Comments (5)
-u
from wxhelper.
-u
我粘贴错了我用的也是-u
.\ConsoleInject.exe -u WeChat.exe -d wxhelper.dll
是这个不生效的。
from wxhelper.
`
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "pch.h"
#include <tlhelp32.h>
DWORD GetPIDForProcess(wchar_t* process)
{
HANDLE hSnapshot;
DWORD targetPid = 0;
PROCESSENTRY32W pe32;
int working;
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (!hSnapshot) {
return 0;
}
pe32.dwSize = sizeof(PROCESSENTRY32);
for (working = Process32FirstW(hSnapshot, &pe32); working; working = Process32NextW(hSnapshot, &pe32))
{
if (!wcscmp(pe32.szExeFile, process))
{
targetPid = pe32.th32ProcessID;
break;
}
}
CloseHandle(hSnapshot);
return targetPid;
}
HINSTANCE__* cdecl GetDLLHandle(wchar_t* wDllName, DWORD dPid)
{
HINSTANCE* result;
tagMODULEENTRY32W me32;
void* snapMod;
if (!dPid) {
return 0;
}
snapMod = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dPid);
me32.dwSize = sizeof(tagMODULEENTRY32W);
if (Module32FirstW(snapMod, &me32))
{
while (wcscmp(wDllName, me32.szModule))
{
if (!Module32NextW(snapMod, &me32))
goto error;
}
CloseHandle(snapMod);
result = me32.hModule;
}
else
{
error:
CloseHandle(snapMod);
result = 0;
}
return result;
}
int cdecl InjectDll(wchar_t* szPName, wchar_t* szDllPath)
{
int result;
HANDLE hRemoteThread;
LPTHREAD_START_ROUTINE lpSysLibAddr;
HINSTANCE* hKernelModule;
LPVOID lpRemoteDllBase;
HANDLE hProcess;
unsigned int dwPid;
size_t ulDllLength;
dwPid = GetPIDForProcess(szPName);
ulDllLength = wcslen(szDllPath) + 1;
hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, dwPid);
if (!hProcess) {
return 0;
}
lpRemoteDllBase = VirtualAllocEx(hProcess, NULL, ulDllLength, MEM_COMMIT, PAGE_READWRITE);
if (lpRemoteDllBase)
{
if (WriteProcessMemory(hProcess, lpRemoteDllBase, szDllPath, ulDllLength, NULL)
&& (hKernelModule = GetModuleHandleW(L"kernel32.dll")) != 0
&& (lpSysLibAddr = (LPTHREAD_START_ROUTINE)GetProcAddress(hKernelModule, "LoadLibraryW")) != 0
&& (hRemoteThread = CreateRemoteThread(hProcess, NULL, 0, lpSysLibAddr, lpRemoteDllBase, 0, NULL)) != 0)
{
WaitForSingleObject(hRemoteThread, INFINITE);
VirtualFreeEx(hProcess, lpRemoteDllBase, ulDllLength, MEM_DECOMMIT | MEM_RELEASE);
CloseHandle(hRemoteThread);
CloseHandle(hProcess);
OutputDebugStringA("[DBG] dll inject success");
result = 1;
}
else
{
VirtualFreeEx(hProcess, lpRemoteDllBase, ulDllLength, MEM_DECOMMIT | MEM_RELEASE);
CloseHandle(hProcess);
result = 0;
}
}
else
{
CloseHandle(hProcess);
result = 0;
}
return result;
}
int cdecl UnInjectDll(wchar_t* szPName, wchar_t* szDName)
{
HINSTANCE* hDll;
LPTHREAD_START_ROUTINE lpFreeLibAddr;
HINSTANCE__* hK32;
HANDLE hProcess;
unsigned int dwPID;
dwPID = GetPIDForProcess(szPName);
hProcess = OpenProcess(0x1FFFFFu, 0, dwPID);
if (!hProcess) {
return 0;
}
hK32 = GetModuleHandleW(L"Kernel32.dll");
if (!hK32) {
return 0;
}
lpFreeLibAddr = (LPTHREAD_START_ROUTINE)GetProcAddress(hK32, "FreeLibraryAndExitThread");
hDll = GetDLLHandle(szDName, dwPID);
if (hDll && CreateRemoteThread(hProcess, 0, 0, lpFreeLibAddr, hDll, 0, 0)) {
return 1;
}
CloseHandle(hProcess);
return 0;
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
`
ida逆向出的来的,卸载函数你可以替换成常规卸载函数。
from wxhelper.
是用这个FreeLibrary 和 FreeLibraryAndExitThread 都是卸载不掉,会在WaitForSingleObject(hThread, INFINITE) 这一步卡着。我自己写了一个dll 弹出窗口的,使用FreeLibrary 可以卸载掉
from wxhelper.
已经修复
from wxhelper.
Related Issues (20)
- 3.9.5.81注入报 应用程序无法启动 0xc000007b HOT 5
- 3.9.2.23 显示注入成功,端口已打开,访问所有接口 404 错误 HOT 3
- 微信外挂老是自动退出是怎么回事 HOT 1
- 【Bug】根据微信号或手机号查找,如果找不到就会让dll挂掉。v5可以返回空,v8v9会出bug。
- 能在getContactList里获得用户性别,备注,描述,标签之类的吗 HOT 2
- 3.9.2.23最新的v9,接收消息延迟很大
- 3.9.2.23-v9推送一段时间的消息后停止推送了 HOT 2
- 3.9.5.81转发功能异常,无法将小程序转发到群里 HOT 1
- 移除群成员接口无效
- 请问hook消息不能收到自己发送的消息?
- 能搞一个详细一点的编译文档吗 HOT 22
- 【求助】3.9.5.81-v10版本下载附件失败 HOT 4
- 能否增加“识别图中二维码”功能?
- 引用消息定位 HOT 4
- 有懂逆向汇编的老哥吗 HOT 6
- 获取登录二维码以及界面【进入微信】的hook点 HOT 7
- 今天突然很多功能不报错不能使用了,数据库查询任何表都是返回空 HOT 3
- 有没有大佬能分享下好友列表应该怎么分类啊
- 注入dll后微信直接闪退
- v2版没有同意好友申请api
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wxhelper.