核心函式:createtoolhelp32snapshot
createtoolhelp32snapshot函式為指定的程序、
程序使用的堆[heap]、模組[module]、
執行緒[thread])
建立乙個快照[snapshot]。
handle winapi createtoolhelp32snapshot(
dword dwflags, //
用來指定「
快照dword th32processid //
乙個程序id號,用來指定要獲取哪乙個程序的快照,
//當獲取
系統程序
列表或獲取當前程序快照時可以設為0);
dwflags
[輸入]
指定快照中包含的系統內容,這個引數能夠使用下列數值(
常量在快照中包含系統中所有的程序。
th32cs_snapthread - 在快照中包含系統中所有的執行緒。
注意:需要使用processentry32
結構體,以及process32first
和process32next
遍歷。
修改呼叫程序的許可權(xp下為除錯許可權)
核心函式:openprocesstoken,lookupprivilegevalue,adjusttokenprivileges
//開啟程序令牌環
bool openprocesstoken(
__in handle processhandle,//要修改訪問許可權的程序控制代碼
__in dword desiredaccess,//指定你要進行的操作型別
__out phandle tokenhandle//返回的訪問令牌
指標);
//獲得本地程序name所代表的許可權型別的區域性唯一id
bool lookupprivilegevalue(
lpctstr lpsystemname,//表示所要檢視的系統,本地系統直接用null
lpctstr lpname,//
指向乙個以零結尾的字串,指定特權的名稱
pluid lpluid//用來接收所返回的制定特權名稱的資訊
);
//調整程序許可權
bool adjusttokenprivileges(
handletokenhandle, //包含特權的控制代碼
booldisableallprivileges,//
禁用所有許可權標誌
ptoken_privilegesnewstate,//
新特權資訊的指標(結構體)
dwordbufferlength, //緩衝資料大小,以位元組為單位的previousstate的快取區(sizeof)
ptoken_privilegespreviousstate,//
接收被改變特權當前狀態的buffer
pdwordreturnlength
//接收previousstate快取區要求的大小
);
開啟程序
handle openprocess(
dword dwdesiredaccess, //渴望得到的訪問許可權(標誌)
bool binherithandle, // 是否繼承控制代碼
dword dwprocessid// 程序標示符
);向遠端程序空間中寫入dll路徑字串
注意:dll
路徑必須是全路徑
使用函式如下:
virtualallocex和writeprocessmemory
handle winapi createremotethread(
__in handle hprocess,//
執行緒所屬程序的程序控制代碼
__in lpsecurity_attributes lpthreadattributes,//
為null即可
__in size_t dwstacksize,//0,代表預設的棧大小
__in lpthread_start_routine lpstartaddress,//
遠端程序中loadlibrary()的位址
__in lpvoid lpparameter,//
遠端程序中分配記憶體
__in dword dwcreationflags,//
執行緒的建立標誌.0:執行緒建立後立即執行
__out lpdword lpthreadid//指向所建立執行緒的id
);釋放遠端程序中的記憶體以及關閉程序控制代碼
virtualfreeex和closehandle(m_hremoproc)
遠端注入DLL
ool cinject injectdll char m path,dword m id 如果開啟程序成功,則在該程序中開闢記憶體空間 this m baseaddress virtualallocex m handle,null,1024,mem commit,page execute readw...
windows平台實現dll遠端注入的簡單例子
最新看了下關於dll遠端注入的東西,這個技術原來是用來隱藏木馬很好的方式,現在貌似很難通過了,一般的殺軟都能檢測到相關的行為,乙個dll的 隨便加了乙個messagebox函式,僅用來測試注入時候成功的,注入成功會彈出這個對話方塊 include stdafx.h include bool apie...
遠端執行緒DLL注入
在其他程序中,建立乙個新的執行緒來loadlibrarya我們的dll。include include void main 給程序分配記憶體 lpvoid baseaddress char strdllname int len strlen strdllname 1 baseaddress virt...