Skip to content

Commit 09dc0e6

Browse files
authored
v1.2.3: minor fixes
2 parents fb5a840 + d37fae2 commit 09dc0e6

File tree

9 files changed

+109
-52
lines changed

9 files changed

+109
-52
lines changed

.goreleaser.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ builds:
2020
- linux
2121
- windows
2222
- darwin
23+
goarch:
24+
- amd64
2325

2426
archives:
2527
- format: tar.gz

Makefile

Lines changed: 5 additions & 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.2
5+
APP_VERSION = 1.2.3
66
GIT_REVISION = `git rev-parse HEAD`
77
DOCKER_IMAGE_TAG ?= $(APP_VERSION)
88
DOCKER_LOCAL_IMAGE = $(APP_NAME):$(DOCKER_IMAGE_TAG)
@@ -56,3 +56,7 @@ clean: ## clean up the project directory
5656
.PHONY: docker
5757
docker: ## build a local docker image
5858
@docker build . -t $(APP_NAME):latest -t $(APP_NAME):$(APP_VERSION)
59+
60+
.PHONY: release-build
61+
release-build: ## makes a release build locally on the current commit
62+
@goreleaser release --skip=publish --snapshot

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ for general information and testing. The tool and this repository are carefully
1212
However, the developers cannot be held liable for for any damage, direct or indirect, of whatever nature as a result of
1313
or related to the access to or use of the software.
1414

15+
> IOCs have voluntarily been added to the project. Don't open any issues regarding detections, it's pointless.
16+
> The goal of this project is to learn & teach. If you want a FUD loader, dont be a baby and make your own.
17+
1518
## How to use the software ?
1619

1720
> Please note this project is under development & subject to changes.

cli/parser.go

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func BuildLoader(opts *Options) *exec.Cmd {
7171

7272
func GetParser(opts *Options) *cobra.Command {
7373

74-
version := "1.2.2"
74+
version := "1.2.3"
7575
var spoofMetadata = &cobra.Command{
7676
Use: "spoof",
7777
Version: version,
@@ -143,6 +143,32 @@ func GetParser(opts *Options) *cobra.Command {
143143
os.Exit(1)
144144
}
145145

146+
if opts.UseAPIHashing {
147+
fmt.Printf("[+] Retrieving dependencies to use API Hashing...\n")
148+
149+
execGoGetCmd := exec.Command("go", "get", "github.com/Binject/debug/pe")
150+
execGoGetCmd.Dir = MYPH_TMP_DIR
151+
_, _ = execGoGetCmd.Output()
152+
153+
if opts.WithDebug {
154+
// if running debug, we want to have the local internals because
155+
// it makes development easier
156+
157+
fmt.Printf("[+] Running \"cp -r ./internals /tmp/myph-out\"\n")
158+
159+
execGoGetCmd = exec.Command("cp", "-r", "./internals", MYPH_TMP_DIR)
160+
execGoGetCmd.Dir = "."
161+
_, _ = execGoGetCmd.Output()
162+
163+
} else {
164+
// this should stay to cmepw addr
165+
execGoGetCmd = exec.Command("go", "get", "github.com/cmepw/myph/internals")
166+
execGoGetCmd.Dir = MYPH_TMP_DIR
167+
_, _ = execGoGetCmd.Output()
168+
}
169+
170+
}
171+
146172
/* reading the shellcode as a series of bytes */
147173
shellcode, err := tools.ReadFile(opts.ShellcodePath)
148174
if err != nil {
@@ -274,12 +300,6 @@ func GetParser(opts *Options) *cobra.Command {
274300

275301
fmt.Printf("\n[+] Template (%s) written to tmp directory. Compiling...\n", opts.Technique)
276302

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-
283303
execCmd := BuildLoader(opts)
284304
execCmd.Dir = MYPH_TMP_DIR
285305

loaders/createThread.go

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,15 @@ import (
3535
}
3636

3737
func (t CreateTTemplate) Const() string {
38-
return fmt.Sprintf(`
38+
if !t.UseApiHashing {
39+
40+
return fmt.Sprintf(`
3941
const (
4042
MEM_COMMIT = 0x1000
4143
MEM_RESERVE = 0x2000
4244
PAGE_EXECUTE_READWRITE = 0x40
4345
)
4446
45-
46-
`)
47-
}
48-
49-
func (t CreateTTemplate) Init() string {
50-
51-
if t.UseApiHashing {
52-
return fmt.Sprintf("\n")
53-
}
54-
55-
return fmt.Sprintf(`
5647
var (
5748
kernel32 = syscall.MustLoadDLL("kernel32.dll")
5849
ntdll = syscall.MustLoadDLL("ntdll.dll")
@@ -63,7 +54,23 @@ var (
6354
6455
RtlCopyMemory = ntdll.MustFindProc("RtlCopyMemory")
6556
)
66-
`)
57+
`)
58+
59+
}
60+
61+
return fmt.Sprintf(`
62+
const (
63+
MEM_COMMIT = 0x1000
64+
MEM_RESERVE = 0x2000
65+
PAGE_EXECUTE_READWRITE = 0x40
66+
)
67+
68+
69+
`)
70+
}
71+
72+
func (t CreateTTemplate) Init() string {
73+
return fmt.Sprintf("\n")
6774
}
6875

6976
func (t CreateTTemplate) Process() string {

loaders/ntCreateThreadEx.go

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import (
2929

3030
return fmt.Sprintf(`
3131
import (
32+
"fmt"
33+
"log"
3234
"syscall"
3335
"unsafe"
3436
)
@@ -38,30 +40,40 @@ import (
3840
func (t NtCreateThreadExTemplate) Const() string {
3941
// same consts with or without API Hashing
4042

41-
return fmt.Sprintf(`
42-
const (
43-
MEM_COMMIT = 0x1000
44-
MEM_RESERVE = 0x2000
45-
PAGE_EXECUTE_READ = 0x20
46-
PAGE_READWRITE = 0x04
47-
)
48-
`)
49-
}
50-
51-
func (t NtCreateThreadExTemplate) Init() string {
52-
5343
if t.UseApiHashing {
54-
return fmt.Sprintf("\n")
44+
return fmt.Sprintf(`
45+
const (
46+
MEM_COMMIT = 0x1000
47+
MEM_RESERVE = 0x2000
48+
PAGE_EXECUTE_READ = 0x20
49+
PAGE_READWRITE = 0x04
50+
)
51+
`)
5552
}
5653

5754
return fmt.Sprintf(`
58-
ntdll := syscall.MustLoadDLL("ntdll.dll")
55+
const (
56+
MEM_COMMIT = 0x1000
57+
MEM_RESERVE = 0x2000
58+
PAGE_EXECUTE_READ = 0x20
59+
PAGE_READWRITE = 0x04
60+
)
61+
62+
var (
5963
60-
NtAllocateVirtualMemory = ntdll.MustFindProd("NtAllocateVirtualMemory")
61-
NtWriteVirtualMemory = ntdll.MustFindProd("NtWriteVirtualMemory")
62-
NtProtectVirtualMemory = ntdll.MustFindProd("NtProtectVirtualMemory")
63-
NtCreateThreadEx = ntdll.MustFindProd("NtCreateThreadEx")
64+
ntdll = syscall.MustLoadDLL("ntdll.dll")
65+
66+
NtAllocateVirtualMemory = ntdll.MustFindProc("NtAllocateVirtualMemory")
67+
NtWriteVirtualMemory = ntdll.MustFindProc("NtWriteVirtualMemory")
68+
NtProtectVirtualMemory = ntdll.MustFindProc("NtProtectVirtualMemory")
69+
NtCreateThreadEx = ntdll.MustFindProc("NtCreateThreadEx")
70+
)
6471
`)
72+
73+
}
74+
75+
func (t NtCreateThreadExTemplate) Init() string {
76+
return fmt.Sprintf("\n")
6577
}
6678

6779
func (t NtCreateThreadExTemplate) Process() string {

loaders/syscall.go

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,43 @@ import (
3636
}
3737

3838
func (t SysTemplate) Const() string {
39-
// same consts with or without API Hashing
4039

41-
return fmt.Sprintf(`
40+
if t.UseApiHashing {
41+
return fmt.Sprintf(`
4242
const (
4343
MEM_COMMIT = 0x1000
4444
MEM_RESERVE = 0x2000
4545
PAGE_EXECUTE_READ = 0x20
4646
PAGE_READWRITE = 0x04
4747
)
4848
`)
49-
}
50-
51-
func (t SysTemplate) Init() string {
5249

53-
if t.UseApiHashing {
54-
return fmt.Sprintf("\n")
5550
}
5651

5752
return fmt.Sprintf(`
58-
kernel32 := syscall.MustLoadDLL("kernel32.dll")
59-
ntdll := syscall.MustLoadDLL("ntdll.dll")
53+
const (
54+
MEM_COMMIT = 0x1000
55+
MEM_RESERVE = 0x2000
56+
PAGE_EXECUTE_READ = 0x20
57+
PAGE_READWRITE = 0x04
58+
)
59+
60+
var (
61+
kernel32 = syscall.MustLoadDLL("kernel32.dll")
62+
ntdll = syscall.MustLoadDLL("ntdll.dll")
63+
64+
VirtualAlloc = kernel32.MustFindProc("VirtualAlloc")
65+
VirtualProtect = kernel32.MustFindProc("VirtualProtect")
66+
RtlCopyMemory = ntdll.MustFindProc("RtlCopyMemory")
67+
)
6068
61-
VirtualAlloc := kernel32.MustFindProc("VirtualAlloc")
62-
VirtualProtect := kernel32.MustFindProc("VirtualProtect")
63-
RtlCopyMemory := ntdll.MustFindProc("RtlCopyMemory")
6469
`)
6570
}
6671

72+
func (t SysTemplate) Init() string {
73+
return fmt.Sprintf("\n")
74+
}
75+
6776
func (t SysTemplate) Process() string {
6877
if t.UseApiHashing {
6978
return fmt.Sprintf(`

loaders/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package loaders
33
func InformExpermimental() {
44
println("[!] The API hashing feature is still in an an experimental stage!!")
55
println("Only a few methods are supported for now:")
6-
println("\t-Syscall\n\t-CreateThread\n\t-tNtCreateThreadEx\n")
6+
println("\t-Syscall\n\t-CreateThread\n\t-NtCreateThreadEx\n")
77
}
88

99
func InformProcessUnused(process string) {

utils/utils

-1.95 MB
Binary file not shown.

0 commit comments

Comments
 (0)