本文整理自网络,侵删。
好几年前,飘零金盾的山寨,域名转向还是个高端的东西,那时候梦想能自己实现易语言的HOOK,可是始终没有大佬能公布源码,或者公布的都是C的源码,无非都是调用逆缘的DLL,自己用E加个调用窗体就是所谓的xx专版域名转向,今日想起来这个事,随手做一下吧,等会看一下封包的Send和Recv能不能实现。
引用mq5123的回复:
一般破解来说验证方式都是tcp,http/https post/get 提交InternetOpenA 创建句柄InternetConnectA 建立连接HttpOpenRequestA 创建http请求HttpSendRequestA 发送请求InternetReadFile 读取返回数据InternetCloseHandle 关闭句柄这个也看验证种类了,易游、核盾什么的都可以,不过例如飘零金盾什么的就不行,这种应该没有调用这类api,而是自行构建了send请求,一般这种情况给sendsendtoWSASend下发包断点recvrecvfromWSARecv下收包断点
实现前(访问的是百度):


易语言访问网页的源码:添加一个超文本浏览框,在_启动窗口创建完毕下面写 超文本浏览框1.地址=“www.baidu.com”
以下为Delphi实现HOOK源码:
library Project1; { Important note about DLL memory management: ShareMem must be the first unit in your library's USES clause AND your project's (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results. This applies to all strings passed to and from your DLL--even those that are nested in records and classes. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL. To avoid using BORLNDMM.DLL, pass string information using PChar or ShortString parameters. } uses System.SysUtils, System.Classes, wininet, //加载wininet库,不然无法调用InternetConnectA函数 Winapi.Windows; //加载常用API库 function MyMoveMemo(old: Pointer; New: Pointer; size: Integer): integer; stdcall; external 'kernel32.dll' name 'RtlMoveMemory'; //内存移动复制函数,这里暂时用不到 {$R *.res}var read: array[0..4] of Byte; //保存的API的头部5个字节,方便还原 rd: NativeUInt; //读内存API函数的最后一个参数 apiaddr: Integer; //API首地址 // 参数:权限名称 ,返回: 成功返回TRUEFunction AdjustProcessPrivilege(Token_Name: Pchar): Boolean;var Token: THandle; TokenPri: TOKEN_PRIVILEGES; ProcessDest: int64; PreSta: DWORD;begin Result := False; if OpenProcessToken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES,Token) then begin if LookupPrivilegeValue(nil,Token_Name,ProcessDest) then begin TokenPri.PrivilegeCount := 1; TokenPri.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED; TokenPri.Privileges[0].Luid := ProcessDest; PreSta := 0; if AdjustTokenPrivileges(Token,False,TokenPri,sizeof(TokenPri),nil,PreSta) then begin Result := True; end; end; end;end; function MyInternet(hInet: HINTERNET; lpszServerName: LPSTR;nServerPort: INTERNET_PORT; lpszUsername: LPSTR; lpszPassword: LPSTR;dwService: DWORD; dwFlags: DWORD; dwContext: DWORD_PTR): HINTERNET;stdcall; //我们构造的函数,从API头跳到我们这个函数当中,方便我们做事var I: Integer; //循环次数变量,每次都要写入1个字节,还原API头 reads: byte; //取出我们保存的5个字节,然后循环写入begin for I := 1 to 5 do begin reads := read[I - 1]; //因为数组下标从0开始,I是从1开始,则用I-1 WriteProcessMemory(GetCurrentProcess, Pointer(apiaddr + I - 1), Pointer(@reads), 1, rd); end;Result:=InternetConnectA(hInet,PAnsiChar('www.52pojie.cn'),nServerPort,lpszUsername,lpszPassword,dwService,dwFlags,dwContext); //就是将第二个参数的域名改成自己的,然后转PansiChar类型,就没有了,其他不用管,非常简单end; function lens(x, y: Integer): Integer; //取跳转长度begin Result := x - y - 5;end;procedure MyMian(); //将HOOK操作封装成一个过程,我称为MyMainvar jmps: Integer; lengths: Integer;begin AdjustProcessPrivilege('SeDebugPrivilege'); //提权函数,不用管 ,可以不写,但是如果写入内存失败,就要用提权,我这边测试可以不用提权也能写入 apiaddr := Integer(GetProcAddress(LoadLibrary('wininet.dll'), 'InternetConnectA')); //获取API地址 ReadProcessMemory(GetCurrentProcess, Pointer(apiaddr), Pointer(@read), 5, rd); //读前5个字节 jmps := 233; //这里是jmp的10进制,16进制的E9 lengths := lens(Integer(@MyInternet), apiaddr); //计算长度 WriteProcessMemory(GetCurrentProcess, Pointer(apiaddr), Pointer(@jmps), 1, rd); //开始写入jmp WriteProcessMemory(GetCurrentProcess, Pointer(apiaddr + 1), Pointer(@lengths), 4, rd); //开始写入长度end;begin MyMian() //这里是DLLmain,会首先调用这里,所以我们这里直接将HOOK封装成一个过程,然后直接调用这个过程end.
作者:bester
相关阅读 >>
更多相关阅读请进入《Delphi》频道 >>