├── .gitattributes
├── .gitignore
├── README.md
├── Release
├── call_dll.exe
├── output_dll.exe
├── output_dll.iobj
├── output_dll.ipdb
├── output_dll.tlog
│ └── output_dll.lastbuildstate
└── outputdll.res
├── demo.jpg
├── framework.h
├── output_dll.cpp
├── output_dll.h
├── output_dll.sln
├── output_dll.vcxproj
├── output_dll.vcxproj.filters
├── output_dllDlg.cpp
├── output_dllDlg.h
├── outputdll.aps
├── outputdll.rc
├── pch.cpp
├── pch.h
├── res
├── output_dll.ico
├── outputdll.rc2
└── shellcode.dll
├── resource.h
└── targetver.h
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Compiled Object files
5 | *.slo
6 | *.lo
7 | *.o
8 | *.obj
9 |
10 | # Precompiled Headers
11 | *.gch
12 | *.pch
13 |
14 | # Compiled Dynamic libraries
15 | *.so
16 |
17 | # Fortran module files
18 | *.mod
19 | *.smod
20 |
21 | # Compiled Static libraries
22 | *.lai
23 | *.la
24 | *.a
25 | *.lib
26 |
27 | # Executables
28 | *.out
29 | *.app
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # shellcode To DLL
2 | shellcode 异或加密并生成dll
3 |
4 | https://kfi.re/816.html
5 |
6 |
7 | 
8 |
--------------------------------------------------------------------------------
/Release/call_dll.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k-fire/shellcode-to-dll/32208bf068461dc59c1c2df8bdfea14b78472e14/Release/call_dll.exe
--------------------------------------------------------------------------------
/Release/output_dll.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k-fire/shellcode-to-dll/32208bf068461dc59c1c2df8bdfea14b78472e14/Release/output_dll.exe
--------------------------------------------------------------------------------
/Release/output_dll.iobj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k-fire/shellcode-to-dll/32208bf068461dc59c1c2df8bdfea14b78472e14/Release/output_dll.iobj
--------------------------------------------------------------------------------
/Release/output_dll.ipdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k-fire/shellcode-to-dll/32208bf068461dc59c1c2df8bdfea14b78472e14/Release/output_dll.ipdb
--------------------------------------------------------------------------------
/Release/output_dll.tlog/output_dll.lastbuildstate:
--------------------------------------------------------------------------------
1 | #TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0
2 | Release|Win32|D:\桌面\code\c++\shellcode to dll\|
3 |
--------------------------------------------------------------------------------
/Release/outputdll.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k-fire/shellcode-to-dll/32208bf068461dc59c1c2df8bdfea14b78472e14/Release/outputdll.res
--------------------------------------------------------------------------------
/demo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k-fire/shellcode-to-dll/32208bf068461dc59c1c2df8bdfea14b78472e14/demo.jpg
--------------------------------------------------------------------------------
/framework.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef VC_EXTRALEAN
4 | #define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料
5 | #endif
6 |
7 | #include "targetver.h"
8 |
9 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
10 |
11 | // 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息
12 | #define _AFX_ALL_WARNINGS
13 |
14 | #include // MFC 核心组件和标准组件
15 | #include // MFC 扩展
16 |
17 |
18 | #include // MFC 自动化类
19 |
20 |
21 |
22 | #ifndef _AFX_NO_OLE_SUPPORT
23 | #include // MFC 对 Internet Explorer 4 公共控件的支持
24 | #endif
25 | #ifndef _AFX_NO_AFXCMN_SUPPORT
26 | #include // MFC 对 Windows 公共控件的支持
27 | #endif // _AFX_NO_AFXCMN_SUPPORT
28 |
29 | #include // MFC 支持功能区和控制条
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | //#ifdef _UNICODE
40 | #if defined _M_IX86
41 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
42 | #elif defined _M_X64
43 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
44 | #else
45 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
46 | #endif
47 | //#endif
48 |
49 |
50 |
--------------------------------------------------------------------------------
/output_dll.cpp:
--------------------------------------------------------------------------------
1 |
2 | // output_dll.cpp: 定义应用程序的类行为。
3 | //
4 |
5 | #include "pch.h"
6 | #include "framework.h"
7 | #include "output_dll.h"
8 | #include "output_dllDlg.h"
9 |
10 | #ifdef _DEBUG
11 | #define new DEBUG_NEW
12 | #endif
13 |
14 |
15 | // CoutputdllApp
16 |
17 | BEGIN_MESSAGE_MAP(CoutputdllApp, CWinApp)
18 | ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
19 | END_MESSAGE_MAP()
20 |
21 |
22 | // CoutputdllApp 构造
23 |
24 | CoutputdllApp::CoutputdllApp()
25 | {
26 | // 支持重新启动管理器
27 | m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
28 |
29 | // TODO: 在此处添加构造代码,
30 | // 将所有重要的初始化放置在 InitInstance 中
31 | }
32 |
33 |
34 | // 唯一的 CoutputdllApp 对象
35 |
36 | CoutputdllApp theApp;
37 |
38 |
39 | // CoutputdllApp 初始化
40 |
41 | BOOL CoutputdllApp::InitInstance()
42 | {
43 | // 如果一个运行在 Windows XP 上的应用程序清单指定要
44 | // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
45 | //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。
46 | INITCOMMONCONTROLSEX InitCtrls;
47 | InitCtrls.dwSize = sizeof(InitCtrls);
48 | // 将它设置为包括所有要在应用程序中使用的
49 | // 公共控件类。
50 | InitCtrls.dwICC = ICC_WIN95_CLASSES;
51 | InitCommonControlsEx(&InitCtrls);
52 |
53 | CWinApp::InitInstance();
54 |
55 |
56 | AfxEnableControlContainer();
57 |
58 | // 创建 shell 管理器,以防对话框包含
59 | // 任何 shell 树视图控件或 shell 列表视图控件。
60 | CShellManager *pShellManager = new CShellManager;
61 |
62 | // 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题
63 | CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
64 |
65 | // 标准初始化
66 | // 如果未使用这些功能并希望减小
67 | // 最终可执行文件的大小,则应移除下列
68 | // 不需要的特定初始化例程
69 | // 更改用于存储设置的注册表项
70 | // TODO: 应适当修改该字符串,
71 | // 例如修改为公司或组织名
72 | SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
73 |
74 | CoutputdllDlg dlg;
75 | m_pMainWnd = &dlg;
76 | INT_PTR nResponse = dlg.DoModal();
77 | if (nResponse == IDOK)
78 | {
79 | // TODO: 在此放置处理何时用
80 | // “确定”来关闭对话框的代码
81 | }
82 | else if (nResponse == IDCANCEL)
83 | {
84 | // TODO: 在此放置处理何时用
85 | // “取消”来关闭对话框的代码
86 | }
87 | else if (nResponse == -1)
88 | {
89 | TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n");
90 | TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n");
91 | }
92 |
93 | // 删除上面创建的 shell 管理器。
94 | if (pShellManager != nullptr)
95 | {
96 | delete pShellManager;
97 | }
98 |
99 | #if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS)
100 | ControlBarCleanUp();
101 | #endif
102 |
103 | // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
104 | // 而不是启动应用程序的消息泵。
105 | return FALSE;
106 | }
107 |
108 |
--------------------------------------------------------------------------------
/output_dll.h:
--------------------------------------------------------------------------------
1 |
2 | // output_dll.h: PROJECT_NAME 应用程序的主头文件
3 | //
4 |
5 | #pragma once
6 |
7 | #ifndef __AFXWIN_H__
8 | #error "在包含此文件之前包含 'pch.h' 以生成 PCH"
9 | #endif
10 |
11 | #include "resource.h" // 主符号
12 |
13 |
14 | // CoutputdllApp:
15 | // 有关此类的实现,请参阅 output_dll.cpp
16 | //
17 |
18 | class CoutputdllApp : public CWinApp
19 | {
20 | public:
21 | CoutputdllApp();
22 |
23 | // 重写
24 | public:
25 | virtual BOOL InitInstance();
26 |
27 | // 实现
28 |
29 | DECLARE_MESSAGE_MAP()
30 | };
31 |
32 | extern CoutputdllApp theApp;
33 |
--------------------------------------------------------------------------------
/output_dll.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29728.190
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "output_dll", "output_dll.vcxproj", "{9D36ED30-0FC3-4427-A71B-272A7656C8FE}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {9D36ED30-0FC3-4427-A71B-272A7656C8FE}.Debug|x64.ActiveCfg = Debug|x64
17 | {9D36ED30-0FC3-4427-A71B-272A7656C8FE}.Debug|x64.Build.0 = Debug|x64
18 | {9D36ED30-0FC3-4427-A71B-272A7656C8FE}.Debug|x86.ActiveCfg = Debug|Win32
19 | {9D36ED30-0FC3-4427-A71B-272A7656C8FE}.Debug|x86.Build.0 = Debug|Win32
20 | {9D36ED30-0FC3-4427-A71B-272A7656C8FE}.Release|x64.ActiveCfg = Release|x64
21 | {9D36ED30-0FC3-4427-A71B-272A7656C8FE}.Release|x64.Build.0 = Release|x64
22 | {9D36ED30-0FC3-4427-A71B-272A7656C8FE}.Release|x86.ActiveCfg = Release|Win32
23 | {9D36ED30-0FC3-4427-A71B-272A7656C8FE}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {ABDA7BF7-1F0C-4C5D-AE04-28E014F7224C}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/output_dll.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | {9D36ED30-0FC3-4427-A71B-272A7656C8FE}
24 | MFCProj
25 | outputdll
26 | 10.0
27 |
28 |
29 |
30 | Application
31 | true
32 | v142
33 | MultiByte
34 | Dynamic
35 | false
36 |
37 |
38 | Application
39 | false
40 | v142
41 | true
42 | MultiByte
43 | Dynamic
44 |
45 |
46 | Application
47 | true
48 | v142
49 | Unicode
50 | Dynamic
51 |
52 |
53 | Application
54 | false
55 | v142
56 | true
57 | Unicode
58 | Dynamic
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | true
80 |
81 |
82 | true
83 |
84 |
85 | false
86 |
87 |
88 | false
89 |
90 |
91 |
92 | Use
93 | Level3
94 | false
95 | WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)
96 | pch.h
97 | false
98 | false
99 | true
100 |
101 |
102 | Windows
103 |
104 |
105 | false
106 | true
107 | _DEBUG;%(PreprocessorDefinitions)
108 |
109 |
110 | 0x0804
111 | _DEBUG;%(PreprocessorDefinitions)
112 | $(IntDir);%(AdditionalIncludeDirectories)
113 |
114 |
115 |
116 |
117 | Use
118 | Level3
119 | true
120 | _WINDOWS;_DEBUG;%(PreprocessorDefinitions)
121 | pch.h
122 |
123 |
124 | Windows
125 |
126 |
127 | false
128 | true
129 | _DEBUG;%(PreprocessorDefinitions)
130 |
131 |
132 | 0x0804
133 | _DEBUG;%(PreprocessorDefinitions)
134 | $(IntDir);%(AdditionalIncludeDirectories)
135 |
136 |
137 |
138 |
139 | Use
140 | Level3
141 | true
142 | false
143 | false
144 | WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)
145 | pch.h
146 | Disabled
147 | false
148 |
149 |
150 | Windows
151 | true
152 | true
153 |
154 |
155 | false
156 | true
157 | NDEBUG;%(PreprocessorDefinitions)
158 |
159 |
160 | 0x0804
161 | NDEBUG;%(PreprocessorDefinitions)
162 | $(IntDir);%(AdditionalIncludeDirectories)
163 |
164 |
165 |
166 |
167 | Use
168 | Level3
169 | true
170 | true
171 | true
172 | _WINDOWS;NDEBUG;%(PreprocessorDefinitions)
173 | pch.h
174 |
175 |
176 | Windows
177 | true
178 | true
179 |
180 |
181 | false
182 | true
183 | NDEBUG;%(PreprocessorDefinitions)
184 |
185 |
186 | 0x0804
187 | NDEBUG;%(PreprocessorDefinitions)
188 | $(IntDir);%(AdditionalIncludeDirectories)
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 | Create
204 | Create
205 | Create
206 | Create
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
--------------------------------------------------------------------------------
/output_dll.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 头文件
20 |
21 |
22 | 头文件
23 |
24 |
25 | 头文件
26 |
27 |
28 | 头文件
29 |
30 |
31 | 头文件
32 |
33 |
34 | 头文件
35 |
36 |
37 |
38 |
39 | 源文件
40 |
41 |
42 | 源文件
43 |
44 |
45 | 源文件
46 |
47 |
48 |
49 |
50 | 资源文件
51 |
52 |
53 |
54 |
55 | 资源文件
56 |
57 |
58 |
59 |
60 |
61 | 资源文件
62 |
63 |
64 | 资源文件
65 |
66 |
67 | 资源文件
68 |
69 |
70 |
--------------------------------------------------------------------------------
/output_dllDlg.cpp:
--------------------------------------------------------------------------------
1 |
2 | // output_dllDlg.cpp: 实现文件
3 | //
4 |
5 | #include "pch.h"
6 | #include "framework.h"
7 | #include "output_dll.h"
8 | #include "output_dllDlg.h"
9 | #include "afxdialogex.h"
10 |
11 | #ifdef _DEBUG
12 | #define new DEBUG_NEW
13 | #endif
14 | #include
15 |
16 |
17 | // CoutputdllDlg 对话框
18 |
19 |
20 |
21 | CoutputdllDlg::CoutputdllDlg(CWnd* pParent /*=nullptr*/)
22 | : CDialogEx(IDD_OUTPUT_DLL_DIALOG, pParent)
23 | , init_text1(_T(""))
24 | , init_text2(_T(""))
25 | {
26 | init_text1 = "格式说明:\r\n输入HEX数组 fc e8 89 00 00 00 60 \r\n方法:原始 \\xfc\\xe8\\x89\\x00\\x00\\x00\\x60 \r\n :操作 \\x替换为空格\r\n :结果 fc e8 89 00 00 00 60";
27 | init_text2 = "建议16~255";
28 | m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
29 | }
30 |
31 | void CoutputdllDlg::DoDataExchange(CDataExchange* pDX)
32 | {
33 | CDialogEx::DoDataExchange(pDX);
34 | // DDX_Control(pDX, IDC_EDIT1, m_edit1);
35 | // DDX_Control(pDX, IDC_EDIT2, m_edit2);
36 | // DDX_Text(pDX, IDC_EDIT1, m_edit1);
37 | // DDX_Text(pDX, IDC_EDIT1, m_edit1);
38 | DDX_Control(pDX, IDC_EDIT1, m_edit1);
39 | DDX_Control(pDX, IDC_EDIT2, m_edit2);
40 | DDX_Text(pDX, IDC_EDIT1, init_text1);
41 | DDX_Text(pDX, IDC_EDIT2, init_text2);
42 | }
43 |
44 | BEGIN_MESSAGE_MAP(CoutputdllDlg, CDialogEx)
45 | ON_WM_PAINT()
46 | ON_WM_QUERYDRAGICON()
47 | ON_BN_CLICKED(IDOK, &CoutputdllDlg::OnBnClickedOk)
48 | END_MESSAGE_MAP()
49 |
50 |
51 | // CoutputdllDlg 消息处理程序
52 |
53 | BOOL CoutputdllDlg::OnInitDialog()
54 | {
55 | CDialogEx::OnInitDialog();
56 |
57 | // 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动
58 | // 执行此操作
59 | SetIcon(m_hIcon, TRUE); // 设置大图标
60 | SetIcon(m_hIcon, FALSE); // 设置小图标
61 |
62 | // TODO: 在此添加额外的初始化代码
63 |
64 | return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
65 | }
66 |
67 | // 如果向对话框添加最小化按钮,则需要下面的代码
68 | // 来绘制该图标。 对于使用文档/视图模型的 MFC 应用程序,
69 | // 这将由框架自动完成。
70 |
71 | void CoutputdllDlg::OnPaint()
72 | {
73 | if (IsIconic())
74 | {
75 | CPaintDC dc(this); // 用于绘制的设备上下文
76 |
77 | SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0);
78 |
79 | // 使图标在工作区矩形中居中
80 | int cxIcon = GetSystemMetrics(SM_CXICON);
81 | int cyIcon = GetSystemMetrics(SM_CYICON);
82 | CRect rect;
83 | GetClientRect(&rect);
84 | int x = (rect.Width() - cxIcon + 1) / 2;
85 | int y = (rect.Height() - cyIcon + 1) / 2;
86 |
87 | // 绘制图标
88 | dc.DrawIcon(x, y, m_hIcon);
89 | }
90 | else
91 | {
92 | CDialogEx::OnPaint();
93 | }
94 | }
95 |
96 | //当用户拖动最小化窗口时系统调用此函数取得光标
97 | //显示。
98 | HCURSOR CoutputdllDlg::OnQueryDragIcon()
99 | {
100 | return static_cast(m_hIcon);
101 | }
102 |
103 | BOOL CoutputdllDlg::ReleaseRes(CString strFileName, WORD wResID, CString strFileType)
104 | {
105 | DWORD dwWrite = 0;
106 | HANDLE hFile = CreateFile(strFileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
107 | CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
108 | if (hFile == INVALID_HANDLE_VALUE)
109 | {
110 | return FALSE;
111 | }
112 |
113 | // 查找资源文件中、加载资源到内存、得到资源大小
114 | HRSRC hrsc = FindResource(NULL, MAKEINTRESOURCE(wResID), strFileType);
115 | HGLOBAL hG = LoadResource(NULL, hrsc);
116 | DWORD dwSize = SizeofResource(NULL, hrsc);
117 |
118 | // 写入文件
119 | WriteFile(hFile, hG, dwSize, &dwWrite, NULL);
120 | CloseHandle(hFile);
121 | return TRUE;
122 | }
123 |
124 | unsigned int strlen(const char* str)
125 | {
126 | const char* cp = str;
127 | while (*cp++);
128 | return (cp - str - 1);
129 | }
130 | //十六进制转字符
131 | int hex2char(uint8_t c)
132 | {
133 | return ((c >= '0') && (c <= '9')) ? int(c - '0') :
134 | ((c >= 'A') && (c <= 'F')) ? int(c - 'A' + 10) :
135 | ((c >= 'a') && (c <= 'f')) ? int(c - 'a' + 10) :
136 | -1;
137 | }
138 | //十六进制转字符串
139 | int Hex2Ascii(char* hex, char* ascii)
140 | {
141 | int hexLen = strlen(hex);
142 | int asciiLen = 0;
143 |
144 | for (int i = 0, cnt = 0; i < hexLen; i++)
145 | {
146 | char c = hex2char(hex[i]);
147 |
148 | if (-1 == c)
149 | continue;
150 | if (cnt) {
151 | cnt = 0;
152 | ascii[asciiLen++] += c;
153 | }
154 | else {
155 | cnt = 1;
156 | ascii[asciiLen] = c << 4;
157 | }
158 | }
159 | ascii[asciiLen++] = 0;
160 | return asciiLen;
161 | }
162 |
163 |
164 | void CoutputdllDlg::OnBnClickedOk()
165 | {
166 | //获取shellcode
167 | CString m_SRC;///-///源字符串
168 | m_edit1.GetWindowText(m_SRC);
169 | char buf[1500];
170 | char* p = (LPSTR)(LPCTSTR)m_SRC;
171 | Hex2Ascii(p, buf);
172 |
173 | //获取key
174 | CString m_key;///-///源字符串
175 | int num;
176 | m_edit2.GetWindowText(m_key);
177 | num = atoi(m_key);
178 | if (num > 15 && num < 256)
179 | {
180 | //异或
181 | for (int c = 0; c < sizeof(buf); c++)
182 | {
183 | buf[c] = buf[c] ^ num;
184 | }
185 |
186 | if (ReleaseRes("shellcode.dll", IDR_DLL1, "DLL"))
187 | {
188 | HMODULE hCurrentModule = GetModuleHandle(NULL);
189 | HRSRC hRes = FindResource(hCurrentModule, MAKEINTRESOURCE(IDR_DLL1), "DLL");
190 | HGLOBAL hGlobal = LoadResource(hCurrentModule, hRes);
191 | DWORD nLen = SizeofResource(hCurrentModule, hRes);
192 | LPBYTE p = (LPBYTE)LockResource(hGlobal);
193 |
194 | CFile f;
195 | f.Open("shellcode.dll", CFile::modeCreate | CFile::modeWrite);
196 | f.Write(p, nLen);
197 | f.Seek(0x001E18, CFile::begin);
198 | f.Write(buf, sizeof(buf) + 1);
199 | f.Seek(0x001500, CFile::begin);
200 | char key[2];
201 | char key_hex[2];
202 | sprintf(key_hex, "%x", num);
203 | char* b = (LPSTR)(LPCTSTR)key_hex;
204 | Hex2Ascii(b, key);
205 | for (int i = 0; i < 16; i++)
206 | {
207 | f.Write(key, sizeof(key) - 1);
208 | }
209 | f.Close();
210 | UnlockResource(hGlobal);
211 | MessageBox("生成成功", "提示", MB_OK);
212 | }
213 | else
214 | {
215 | MessageBox("发生错误", "提示", MB_OK);
216 | }
217 | }
218 | else
219 | {
220 | MessageBox("KEY需要在16~255", "提示", MB_OK);
221 | }
222 |
223 |
224 | }
225 |
226 |
227 |
--------------------------------------------------------------------------------
/output_dllDlg.h:
--------------------------------------------------------------------------------
1 |
2 | // output_dllDlg.h: 头文件
3 | //
4 |
5 | #pragma once
6 |
7 |
8 | // CoutputdllDlg 对话框
9 | class CoutputdllDlg : public CDialogEx
10 | {
11 | // 构造
12 | public:
13 | CoutputdllDlg(CWnd* pParent = nullptr); // 标准构造函数
14 |
15 | // 对话框数据
16 | #ifdef AFX_DESIGN_TIME
17 | enum { IDD = IDD_OUTPUT_DLL_DIALOG };
18 | #endif
19 |
20 | protected:
21 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
22 |
23 |
24 | // 实现
25 | protected:
26 | HICON m_hIcon;
27 |
28 | // 生成的消息映射函数
29 | virtual BOOL OnInitDialog();
30 | afx_msg void OnPaint();
31 | afx_msg HCURSOR OnQueryDragIcon();
32 | DECLARE_MESSAGE_MAP()
33 | public:
34 | afx_msg void OnBnClickedOk();
35 | BOOL ReleaseRes(CString strFileName, WORD wResID, CString strFileType);
36 | // CEdit m_edit1;
37 | // CEdit m_edit2;
38 | // char *m_edit1;
39 | // unsigned char m_edit1;
40 | // CString m_edit1;
41 | CEdit m_edit1;
42 | CEdit m_edit2;
43 | CString init_text1;
44 | CString init_text2;
45 | afx_msg void OnEnChangeEdit1();
46 | afx_msg void OnEnSetfocusEdit1();
47 | };
48 |
--------------------------------------------------------------------------------
/outputdll.aps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k-fire/shellcode-to-dll/32208bf068461dc59c1c2df8bdfea14b78472e14/outputdll.aps
--------------------------------------------------------------------------------
/outputdll.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k-fire/shellcode-to-dll/32208bf068461dc59c1c2df8bdfea14b78472e14/outputdll.rc
--------------------------------------------------------------------------------
/pch.cpp:
--------------------------------------------------------------------------------
1 | // pch.cpp: 与预编译标头对应的源文件
2 |
3 | #include "pch.h"
4 |
5 | // 当使用预编译的头时,需要使用此源文件,编译才能成功。
6 |
--------------------------------------------------------------------------------
/pch.h:
--------------------------------------------------------------------------------
1 | // pch.h: 这是预编译标头文件。
2 | // 下方列出的文件仅编译一次,提高了将来生成的生成性能。
3 | // 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
4 | // 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
5 | // 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
6 |
7 | #ifndef PCH_H
8 | #define PCH_H
9 |
10 | // 添加要在此处预编译的标头
11 | #include "framework.h"
12 |
13 | #endif //PCH_H
14 |
--------------------------------------------------------------------------------
/res/output_dll.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k-fire/shellcode-to-dll/32208bf068461dc59c1c2df8bdfea14b78472e14/res/output_dll.ico
--------------------------------------------------------------------------------
/res/outputdll.rc2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k-fire/shellcode-to-dll/32208bf068461dc59c1c2df8bdfea14b78472e14/res/outputdll.rc2
--------------------------------------------------------------------------------
/res/shellcode.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k-fire/shellcode-to-dll/32208bf068461dc59c1c2df8bdfea14b78472e14/res/shellcode.dll
--------------------------------------------------------------------------------
/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ 生成的包含文件。
3 | // 供 outputdll.rc 使用
4 | //
5 | #define IDD_OUTPUT_DLL_DIALOG 102
6 | #define IDR_MAINFRAME 128
7 | #define IDR_DLL1 133
8 | #define IDB_BITMAP1 139
9 | #define IDC_EDIT1 1000
10 | #define IDC_MFCEDITBROWSE1 1001
11 | #define IDC_EDIT2 1002
12 |
13 | // Next default values for new objects
14 | //
15 | #ifdef APSTUDIO_INVOKED
16 | #ifndef APSTUDIO_READONLY_SYMBOLS
17 | #define _APS_NEXT_RESOURCE_VALUE 140
18 | #define _APS_NEXT_COMMAND_VALUE 32771
19 | #define _APS_NEXT_CONTROL_VALUE 1003
20 | #define _APS_NEXT_SYMED_VALUE 101
21 | #endif
22 | #endif
23 |
--------------------------------------------------------------------------------
/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
4 |
5 | // 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将
6 | // 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
7 |
8 | #include
9 |
--------------------------------------------------------------------------------