#include<iostream>
#include <stdlib.h>
#include <stdio.h>
#include "winsock2.h"
#include <windows.h>
#include<TlHelp32.h>
#include<vector>
#pragma comment(lib,"ws2_32.lib")//引用库文件
using namespace std;
vector<DWORD> GetPIDByProcessName(LPCTSTR szProcessName)
{
STARTUPINFO st;
PROCESS_INFORMATION pi;
PROCESSENTRY32 ps;
HANDLE hSnapshot;
vector<DWORD> dwPID;
ZeroMemory(&st, sizeof(STARTUPINFO));
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
st.cb = sizeof(STARTUPINFO);
ZeroMemory(&ps, sizeof(PROCESSENTRY32));
ps.dwSize = sizeof(PROCESSENTRY32);
//拍摄进程快照
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
//快照拍摄失败
if (hSnapshot == INVALID_HANDLE_VALUE) return dwPID;
//快照中是否含有进程
if (!Process32First(hSnapshot, &ps)) return dwPID;
do
{
//遍历进程快照,比较进程名称
if (lstrcmpi(ps.szExeFile, szProcessName) == 0)
{
//将自身进程id放到容器中
dwPID.push_back(ps.th32ProcessID);
}
} while (Process32Next(hSnapshot, &ps));
//关闭快照句柄
CloseHandle(hSnapshot);
return dwPID;
}
int dllinject() {
cout << "搜寻目标进程...." << endl;
//目标进程的名称
WCHAR targetName[] = L"csgo.exe";
//获取进程id
vector<DWORD> hProcessId = GetPIDByProcessName(targetName);
if (hProcessId.size() == 0) {
cout << "没有找到目标进程!" << endl;
return 1;
}
cout << "-------------------------------------------------------" << endl;
cout << "编号\t进程对应id(十六进制)\t进程对应id(十进制)" << endl;
for (vector<DWORD>::size_type it = 0; it < hProcessId.size(); it++)
{
cout << it << "\t" << hex << hProcessId[it] << "\t\t\t" << dec << hProcessId[it] << endl;
}
//目标dll的名称
char dllName[] = "QingSense.dll";
//得到 kernel32 的模块句柄,因为 loadlibrary 在该dll中
HMODULE kernel = GetModuleHandleA("kernel32.dll");
//此处应该使用 LoadLibraryA 或 LoadLibraryW,不能直接使用 LoadLibrary 因为LoadLibrary 是一个宏,在代码运行时不能直接使用
FARPROC loadlibrary = GetProcAddress(kernel, "LoadLibraryA");
//打开进程,获得进程句柄
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, NULL, hProcessId[0]);
if (hProcess == NULL) {
cout << "打开目标进程失败!" << endl;
return 1;
}
//在目标进程中分配空间,用于存储要加载的dll的名称
LPVOID lpparameter = VirtualAllocEx(hProcess, NULL, sizeof(dllName), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
//将目标dll的名字写入到目标进程
WriteProcessMemory(hProcess, lpparameter, dllName, sizeof(dllName), NULL);
//创建远程线程
HANDLE hThread = CreateRemoteThread(hProcess, NULL, NULL, (LPTHREAD_START_ROUTINE)loadlibrary, lpparameter, 0, NULL);
//等待远程线程运行结束
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
CloseHandle(hProcess);
cout << "-------------------------------------------------------" << endl;
cout << "成功注入进程:" << hProcessId[0] << endl;
cout << "-------------------------------------------------------" << endl << endl;
system("pause");
return 0;
}
int main() {
cout<< "________ .___ _______ ________ ____________________ _______ ____________________\ "<<endl;
cout << "\\_____ \\ | |\\ \\ / _____/ / _____ / \\_ _____ / \\ \\ / _____ / \\_ _____ / \ "<< endl;
cout << " / / \\ \\| |/ | \\/ \\ ___ \\_____ \\ | __)_ / | \\ \\_____ \\ | __)_ \ "<<endl;
cout << "/ \\_/. \\ / | \\ \\_\\ \\/ \\ | \\/ | \\/ \\ | \\ \ "<<endl;
cout << "\\_____\\ \\_/___\\____|__ /\\______ /_______ //_______ /\\____|__ /_______ //_______ /\ "<<endl;
cout << " \\__> \\/ \\/ \\/ \\/ \\/ \\/ \\/ \ "<<endl;
cout << endl << endl;
char username, password;
//初始化Loader
//下面初始化socket
//加载套接字
WSADATA wsaData;
char buff[1024];
memset(buff, 0, sizeof(buff));
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
{
printf("初始化Winsock失败");
printf("程序3秒后退出");
Sleep(3000);
exit(0);
return 0;
}
SOCKADDR_IN addrSrv;
addrSrv.sin_family = AF_INET;
addrSrv.sin_port = htons(61234);//端口号
addrSrv.sin_addr.S_un.S_addr = inet_addr("154.12.91.247");//IP地址
//创建套接字
SOCKET sockClient = socket(AF_INET, SOCK_STREAM, 0);
if (SOCKET_ERROR == sockClient) {
printf("Socket() error:%d", WSAGetLastError());
return 0;
}
//向服务器发出连接请求
if (connect(sockClient, (struct sockaddr*)&addrSrv, sizeof(addrSrv)) == INVALID_SOCKET) {
printf("连接失败:%d", WSAGetLastError());
cout << endl;
printf("程序3秒后退出");
Sleep(3000);
exit(0);
return 0;
}
else
{
const char buffs[]="connecttoverify:";
send(sockClient, buffs, sizeof(buffs), 0);
recv(sockClient, buff, sizeof(buff), 0);
printf("%s\n", buff);
}
const char buffs[] = "verify:";
send(sockClient, buffs, sizeof(buffs), 0);
recv(sockClient, buff, sizeof(buff), 0);
int sginmode;
cout << "1.Sgin up" << endl << "2.Sgin in" << endl<<"3.Inject[DEBUG]"<<endl;
cin >> sginmode;
if (sginmode = 3)
{
dllinject();
}
cout << "Username:";
cin >> username;
cout << "Password:";
cin >> password;
string temp1;
temp1 = "verify:";
temp1 += username;
temp1 += ":";
temp1 += password;
temp1 += ":";
temp1 += sginmode;
cout << endl<<temp1 << endl;
//verify:username:password:sginmode
//buffs =temp1;
//send(sockClient,buffs, sizeof(buffs), 0); // 发送验证信息
recv(sockClient, buff, sizeof(buff), 0);//接收返回消息
printf("%s\n", buff);
if (buff == "Successful verification") {
//dllinject(csgo.exe,QingSense.dll)
//dll注入模块还没搞()
//这里没做云注入,搞得本地注入
}
else if (buff == "Incorrect password") {
cout << endl;
printf("程序3秒后退出");
Sleep(3000);
exit(0);
return 0;
}
//buffs[] = "connecttoverif";
//send(sockClient, buffs, sizeof(buffs), 0);
//关闭套接字
closesocket(sockClient);
WSACleanup();//释放初始化Ws2_32.dll所分配的资源。
return 0;
}
vs2022,我撤回了几下就这样了
你检查一下编码呢? 总感觉是中文编码 utf-8没有 BOM的问题
然后把错误那里 生成+intellisense 改成 仅生成