Skip to content

Commit fb5a840

Browse files
authored
Release v1.2.2
2 parents 94d4840 + d10b235 commit fb5a840

27 files changed

+1266
-199
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
myph
1313
myph-out/
1414

15+
scripts/hash_function
16+
scripts/hash
17+
1518
# Test binary, built with `go test -c`
1619
*.test
1720

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -------------------
33

44
APP_NAME = myph
5-
APP_VERSION = 1.2.0
5+
APP_VERSION = 1.2.2
66
GIT_REVISION = `git rev-parse HEAD`
77
DOCKER_IMAGE_TAG ?= $(APP_VERSION)
88
DOCKER_LOCAL_IMAGE = $(APP_NAME):$(DOCKER_IMAGE_TAG)

NOTES.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#############################
2+
######### RESOURCES #########
3+
#############################
4+
5+
- https://media.defcon.org/DEF%20CON%2029/DEF%20CON%2029%20workshops/DEF%20CON%2029%20Workshop%20Ben%20Kurtz%20Writing%20Golang%20Malwar.pdf
6+
7+
- https://evasions.checkpoint.com
8+

README.md

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ make # you can also use `make help` to check recipes
2828
go build -o myph .
2929
```
3030

31-
> You can also grab the latest release from [here](https://github.com/CMEPW/myph/releases/)
31+
> You can also grab the latest release from [here](https://github.com/mato7sh/myph/releases/)
3232
33-
Finally, you can install from the [golang package repository](https://pkg.go.dev/github.com/CMEPW/myph) like so:
33+
Finally, you can install from the [golang package repository](https://pkg.go.dev/github.com/mato7sh/myph) like so:
3434
```bash
3535
# /!\ lowercase is important /!\
3636
go install github.com/cmepw/myph@latest
@@ -39,50 +39,25 @@ go install github.com/cmepw/myph@latest
3939
### Usage
4040

4141
```
42-
43-
... -==[ M Y P H ]==-
44-
;::::;
45-
;::::; :; In loving memory of
46-
;:::::' :; Wassyl Iaroslavovytch Slipak
47-
;:::::; ;.
48-
,:::::' ; OOO (1974 - 2016)
49-
::::::; ; OOOOO
50-
;:::::; ; OOOOOOOO
51-
,;::::::; ;' / OOOOOOO
52-
;::::::::: . ,,,;. / / DOOOOOO
53-
.';:::::::::::::::::;, / / DOOOO
54-
,::::::;::::::;;;;::::;, / / DOOO AV / EDR evasion framework
55-
; :::::: '::::::;;;::::: ,#/ / DOOO to pop shells and
56-
: ::::::: ;::::::;;::: ;::# / DOOO make the blue team cry
57-
:: ::::::: ;:::::::: ;::::# / DOO
58-
: ::::::: ;:::::: ;::::::#/ DOO
59-
::: ::::::: ;; ;:::::::::## OO written with <3 by djnn
60-
:::: ::::::: ;::::::::;:::# OO ------
61-
::::: ::::::::::::;' :;::# O https://djnn.sh
62-
::::: ::::::::; / / :#
63-
:::::: :::::; / / #
64-
65-
Usage:
66-
myph [flags]
67-
myph [command]
68-
6942
Available Commands:
7043
completion Generate the autocompletion script for the specified shell
7144
help Help about any command
7245
spoof spoof PE metadata using versioninfo
7346
7447
Flags:
75-
-b, --builtype string define the output type (allowed: exe, dll) (default "exe")
76-
-e, --encryption encKind encryption method. (allowed: AES, chacha20, XOR, blowfish) (default AES)
77-
-h, --help help for myph
78-
-k, --key string encryption key, auto-generated if empty. (if used by --encryption)
79-
-f, --out string output name (default "payload.exe")
80-
-z, --persistence string name of the binary being placed in '%APPDATA%' and in 'SOFTWARE\Microsoft\Windows\CurrentVersion\Run' reg key (default: "")
81-
-p, --process string target process to inject shellcode to (default "cmd.exe")
82-
-s, --shellcode string shellcode path (default "msf.raw")
83-
--sleep-time uint sleep time in seconds before executing loader (default: 0)
84-
-t, --technique string shellcode-loading technique (allowed: CRT, CRTx, CreateFiber, ProcessHollowing, CreateThread, EnumCalendarInfoA, Syscall, Etwp) (default "CRT")
85-
-v, --version version for myph
48+
--api-hashing-type string Hashing algorithm used for API hashing (default "DJB2")
49+
-d, --debug builds binary with debug symbols
50+
-e, --encryption encKind encryption method. (allowed: AES, chacha20, XOR, blowfish) (default AES)
51+
-h, --help help for myph
52+
-k, --key string encryption key, auto-generated if empty. (if used by --encryption)
53+
-f, --out string output name (default "payload.exe")
54+
-z, --persistence string name of the binary being placed in '%APPDATA%' and in 'SOFTWARE\Microsoft\Windows\CurrentVersion\Run' reg key (default: "")
55+
-p, --process string target process to inject shellcode to (default "cmd.exe")
56+
-s, --shellcode string shellcode path (default "msf.raw")
57+
--sleep-time uint sleep time in seconds before executing loader (default: 0)
58+
-t, --technique string shellcode-loading technique (allowed: CRT, CRTx, CreateFiber, ProcessHollowing, CreateThread, NtCreateThreadEx, Syscall, SyscallTest, Etwp) (default "CRT")
59+
--use-api-hashing Use API Hashing
60+
-v, --version version for myph
8661
```
8762

8863
#### Loader Methods
@@ -91,13 +66,14 @@ This tool supports few methods for now, but aims to add more as time goes on:
9166
- Syscall
9267
- CreateFiber
9368
- CreateThread
69+
- NtCreateThreadEx
9470
- Process hollowing
9571
- EnumCalendarInfoA
9672
- CreateRemoteThread
9773
- EtwpCreateEtwThread
9874
- CreateRemoteThreadEx
9975

100-
If you don't know what that is about, go check out [this repository](https://github.com/CMEPW/BypassAV) :)~
76+
If you don't know what that is about, go check out [this repository](https://github.com/matro7sh/BypassAV) :)~
10177

10278

10379
#### Example run

TODO.txt

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
#############################
2-
####### ROADMAP 1.2.0 #######
2+
####### ROADMAP 1.2.3 #######
33
#############################
44

55
Misc:
66
- support for loading API calls from PEB
7-
- Refactoring CLI options to interfaces
87
- Decrypt shellcode at the last possible time & split templates into trigger & prepare-payload functions
98

109

11-
Encoders:
12-
- add support for SGN
13-
14-
1510
#############################
1611
####### ROADMAP 1.3.0 #######
1712
#############################
@@ -22,12 +17,30 @@ Commands:
2217
Sleep / jitter:
2318
- Ekko
2419

20+
Encoders:
21+
- add support for SGN
2522

26-
dll:
23+
24+
Dll:
2725
- hijacking techniques (teams/onedrive)
2826

2927
Misc:
3028
- indirect syscalls
3129
- support for dameonizing ?
3230
- introduce ppid spoofing ?
3331
- add support for passing arguments to payload from command-line
32+
33+
34+
#############################
35+
####### ROADMAP 1.4.0 #######
36+
#############################
37+
38+
39+
Misc:
40+
- add support for attaching to new processes
41+
- add support for multiple hashing algorithms for retrieving API calls through PEB
42+
- add support for variable assignment randomization
43+
-> should assign variables differently (as random as possible) in order to
44+
have different signatures each time
45+
- optionally implement sandbox checks
46+

cli/defaults.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ func GetDefaultCLIOptions() Options {
1818
SleepTime: 0,
1919
PEFilePath: "payload.exe",
2020
VersionFilePath: "goversion.json",
21+
WithDebug: false,
2122
BuildType: "exe",
2223
Persistence: "",
24+
UseAPIHashing: false,
25+
APIHashingType: "DJB2",
2326
}
2427

2528
return opts

cli/parser.go

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,25 @@ const ASCII_ART = `
4343
`
4444

4545
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)
4848
if opts.BuildType == "dll" {
4949
os.Setenv("CGO_ENABLED", "1")
5050
os.Setenv("CC", "x86_64-w64-mingw32-gcc")
5151
fmt.Println("[*] Compiling payload as dll...")
5252

53+
if opts.WithDebug {
54+
return exec.Command("go", "build", "-buildmode=c-shared", "-o", "payload.dll", ".")
55+
}
56+
5357
return exec.Command("go", "build", "-buildmode=c-shared", "-ldflags", "-s -w -H=windowsgui", "-o", "payload.dll", ".")
5458
} else if opts.BuildType == "exe" {
5559
fmt.Println("[*] Compiling payload as executable...")
5660

61+
if opts.WithDebug {
62+
return exec.Command("go", "build", "-o", "payload.exe", ".")
63+
}
64+
5765
return exec.Command("go", "build", "-ldflags", "-s -w -H=windowsgui", "-o", "payload.exe", ".")
5866
} else {
5967
fmt.Printf("[!] Buildtype format not supported!")
@@ -63,7 +71,7 @@ func BuildLoader(opts *Options) *exec.Cmd {
6371

6472
func GetParser(opts *Options) *cobra.Command {
6573

66-
version := "1.2.0"
74+
version := "1.2.2"
6775
var spoofMetadata = &cobra.Command{
6876
Use: "spoof",
6977
Version: version,
@@ -142,7 +150,7 @@ func GetParser(opts *Options) *cobra.Command {
142150
os.Exit(1)
143151
}
144152

145-
/* i got 99 problems but generating a random key aint one */
153+
/* generating a random key if none are selected */
146154
if opts.Key == "" {
147155
opts.Key = tools.RandomString(32)
148156
}
@@ -190,9 +198,6 @@ func GetParser(opts *Options) *cobra.Command {
190198
panic(err)
191199
}
192200

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-
196201
/* Running `go get "golang.org/x/crypto/chacha20poly1305"` in MYPH_TMP_DIR` */
197202
execCmd := exec.Command("go", "get", "golang.org/x/crypto/chacha20poly1305")
198203
execCmd.Dir = MYPH_TMP_DIR
@@ -207,9 +212,6 @@ func GetParser(opts *Options) *cobra.Command {
207212
panic(err)
208213
}
209214

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-
213215
/* Running `go get golang.org/x/crypto/blowfish in MYPH_TMP_DIR` */
214216
execCmd := exec.Command("go", "get", "golang.org/x/crypto/blowfish")
215217
execCmd.Dir = MYPH_TMP_DIR
@@ -224,6 +226,7 @@ func GetParser(opts *Options) *cobra.Command {
224226
panic(err)
225227
}
226228

229+
/* FIXME(djnn): this should not work like this but instead have a flag and an array of techniques like the rest */
227230
persistData := ""
228231
if opts.Persistence != "" {
229232
persistData = fmt.Sprintf(`persistExecute("%s")`, opts.Persistence)
@@ -258,7 +261,7 @@ func GetParser(opts *Options) *cobra.Command {
258261
panic(err)
259262
}
260263

261-
templateFunc := loaders.SelectTemplate(opts.Technique)
264+
templateFunc := loaders.SelectTemplate(opts.Technique, opts.UseAPIHashing, opts.APIHashingType)
262265
if templateFunc == nil {
263266
fmt.Printf("[!] Could not find a technique for this method: %s\n", opts.Technique)
264267
os.Exit(1)
@@ -270,19 +273,33 @@ func GetParser(opts *Options) *cobra.Command {
270273
}
271274

272275
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+
273283
execCmd := BuildLoader(opts)
274284
execCmd.Dir = MYPH_TMP_DIR
275285

276-
_, stderr := execCmd.Output()
286+
var stderr error
287+
_, stderr = execCmd.Output()
277288

278289
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+
279296
fmt.Printf("[!] error compiling shellcode: %s\n", stderr.Error())
280297
fmt.Printf(
281298
"\nYou may try to run the following command in %s to find out what happend:\n\n GOOS=%s GOARCH=%s %s\n\n",
282299
MYPH_TMP_DIR,
283300
opts.OS,
284301
opts.Arch,
285-
"go build -ldflags \"-s -w -H=windowsgui\" -o payload.exe",
302+
command,
286303
)
287304

288305
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 {
308325
rootCmd.Flags().StringVarP(&opts.OutName, "out", "f", defaults.OutName, "output name")
309326
rootCmd.Flags().StringVarP(&opts.ShellcodePath, "shellcode", "s", defaults.ShellcodePath, "shellcode path")
310327
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)")
313329
rootCmd.Flags().VarP(&opts.Encryption, "encryption", "e", "encryption method. (allowed: AES, chacha20, XOR, blowfish)")
314330
rootCmd.Flags().StringVarP(&opts.Key, "key", "k", "", "encryption key, auto-generated if empty. (if used by --encryption)")
315331
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: \"\")")
317337

318338
spoofMetadata.Flags().StringVarP(&opts.PEFilePath, "pe", "p", defaults.PEFilePath, "PE file to spoof")
319339
spoofMetadata.Flags().StringVarP(&opts.VersionFilePath, "file", "f", defaults.VersionFilePath, "manifest file path (as JSON)")

0 commit comments

Comments
 (0)