首页
社区
课程
招聘
[求助]打造自己的WSOCK32.DLL,遇到的疑问
发表于: 2011-2-16 15:07 6937

[求助]打造自己的WSOCK32.DLL,遇到的疑问

2011-2-16 15:07
6937
function accept:integer;stdcall;export;
begin
asm
call x_accept
end;
end;
function bind:integer;stdcall;export;
begin
asm
call x_bind
end;
end;
function closesocket:integer;stdcall;export;
begin
asm
call x_closesocket
end;
end;
function connect:integer;stdcall;export;
begin
asm
call x_connect
end;
end;
function getpeername:integer;stdcall;export;
begin
asm
call x_getpeername
end;
end;
function getsockname:integer;stdcall;export;
begin
asm
call x_getsockname
end;
end;
function getsockopt:integer;stdcall;export;
begin
asm
call x_getsockopt
end;
end;
function htonl:integer;stdcall;export;
begin
asm
call x_htonl
end;
end;
function inet_addr:integer;stdcall;export;
begin
asm
call x_inet_addr
end;
end;
function inet_ntoa:integer;stdcall;export;
begin
asm
call x_inet_ntoa
end;
end;
function ioctlsocket:integer;stdcall;export;
begin
asm
call x_ioctlsocket
end;
end;
function listen:integer;stdcall;export;
begin
asm
call x_listen
end;
end;
function ntohl:integer;stdcall;export;
begin
asm
call x_ntohl
end;
end;
function ntohs:integer;stdcall;export;
begin
asm
call x_ntohs
end;
end;
function recv:integer;stdcall;export;
begin
asm
call x_recv
end;
end;
function recvfrom:integer;stdcall;export;
begin
asm
call x_recvfrom
end;
end;
function select:integer;stdcall;export;
begin
asm
call x_select
end;
end;
function send:integer;stdcall;export;
begin
asm
call x_send
end;
end;
function sendto:integer;stdcall;export;
begin
asm
call x_sendto
end;
end;
function setsockopt:integer;stdcall;export;
begin
asm
call x_setsockopt
end;
end;
function shutdown:integer;stdcall;export;
begin
asm
call x_shutdown
end;
end;
function socket:integer;stdcall;export;
begin
asm
call x_socket
end;
end;
function MigrateWinsockConfiguration:integer;stdcall;export;
begin
asm
call x_MigrateWinsockConfiguration
end;
end;
function gethostbyaddr:integer;stdcall;export;
begin
asm
call x_gethostbyaddr
end;
end;
function gethostbyname:integer;stdcall;export;
begin
asm
call x_gethostbyname
end
end;
function getprotobyname:integer;stdcall;export;
begin
asm
call x_getprotobyname
end;
end;
function getprotobynumber:integer;stdcall;export;
begin
asm
call x_getprotobynumber
end;
end;
function getservbyname:integer;stdcall;export;
begin
asm
call x_getservbyname
end;
end;
function getservbyport:integer;stdcall;export;
begin
asm
call x_getservbyport
end;
end;
function gethostname:integer;stdcall;export;
begin
asm
call x_gethostname
end;
end;
function WSAAsyncSelect:integer;stdcall;export;
begin
asm
call x_WSAAsyncSelect
end;
end;
function WSAAsyncGetHostByAddr:integer;stdcall;export;
begin
asm
call x_WSAAsyncGetHostByAddr
end;
end;
function WSAAsyncGetHostByName:integer;stdcall;export;
begin
asm
call x_WSAAsyncGetHostByName
end;
end;
function WSAAsyncGetProtoByNumber:integer;stdcall;export;
begin
asm
call x_WSAAsyncGetProtoByNumber
end;
end;
function WSAAsyncGetProtoByName:integer;stdcall;export;
begin
asm
call x_WSAAsyncGetProtoByName
end;
end;
function WSAAsyncGetServByPort:integer;stdcall;export;
begin
asm
call x_WSAAsyncGetServByPort
end;
end;
function WSAAsyncGetServByName:integer;stdcall;export;
begin
asm
call x_WSAAsyncGetServByName
end;
end;
function WSACancelAsyncRequest:integer;stdcall;export;
begin
asm
call x_WSACancelAsyncRequest
end;
end;
function WSASetBlockingHook:integer;stdcall;export;
begin
asm
call WSASetBlockingHook
end;
end;
function WSAUnhookBlockingHook:integer;stdcall;export;
begin
asm
call x_WSAUnhookBlockingHook
end;
end;
function WSAGetLastError:integer;stdcall;export;
begin
asm
call x_WSAGetLastError
end;
end;
function WSASetLastError:integer;stdcall;export;
begin
asm
call x_WSASetLastError
end;
end;
function WSACancelBlockingCall:integer;stdcall;export;
begin
asm
call x_WSACancelBlockingCall
end;
end;
function WSAIsBlocking:integer;stdcall;export;
begin
asm
call x_WSAIsBlocking
end;
end;
function WSAStartup:integer;stdcall;export;
begin
asm
call x_WSAStartup
end;
end;
function WSACleanup:integer;stdcall;export;
begin
asm
call x_WSACleanup
end;
end;
function __WSAFDIsSet:integer;stdcall;export;
begin
asm
call x___WSAFDIsSet
end;
end;
function WEP:integer;stdcall;export;
begin
asm
call x_WEP
end;
end;
function WSApSetPostRoutine:integer;stdcall;export;
begin
asm
call x_WSApSetPostRoutine
end;
end;
function inet_network:integer;stdcall;export;
begin
asm
call x_inet_network
end;
end;
function getnetbyname:integer;stdcall;export;
begin
asm
call x_getnetbyname
end;
end;
function rcmd:integer;stdcall;export;
begin
asm
call x_rcmd
end;
end;
function rexec:integer;stdcall;export;
begin
asm
call x_rexec
end;
end;
function rresvport:integer;stdcall;export;
begin
asm
call x_rresvport
end;
end;
function sethostname:integer;stdcall;export;
begin
asm
call x_sethostname
end;
end;
function dn_expand:integer;stdcall;export;
begin
asm
call x_dn_expand
end;
end;
function WSARecvEx:integer;stdcall;export;
begin
asm
call x_WSARecvEx
end;
end;
function s_perror:integer;stdcall;export;
begin
asm
call x_s_perror
end;
end;
function GetAddressByNameA:integer;stdcall;export;
begin
asm
call x_GetAddressByNameA
end;
end;
function GetAddressByNameW:integer;stdcall;export;
begin
asm
call x_GetAddressByNameW
end;
end;
function EnumProtocolsA:integer;stdcall;export;
begin
asm
call x_EnumProtocolsA
end;
end;
function EnumProtocolsW:integer;stdcall;export;
begin
asm
call x_EnumProtocolsW
end;
end;
function GetTypeByNameA:integer;stdcall;export;
begin
asm
call x_GetTypeByNameA
end;
end;
function GetTypeByNameW:integer;stdcall;export;
begin
asm
call x_GetTypeByNameW
end;
end;
function GetNameByTypeA:integer;stdcall;export;
begin
asm
call x_GetNameByTypeA
end;
end;
function GetNameByTypeW:integer;stdcall;export;
begin
asm
call x_GetNameByTypeW
end;
end;
function SetServiceA:integer;stdcall;export;
begin
asm
call x_SetServiceA
end;
end;
function SetServiceW:integer;stdcall;export;
begin
asm
call x_SetServiceW
end;
end;
function GetServiceA:integer;stdcall;export;
begin
asm
call x_GetServiceA
end;
end;
function GetServiceW:integer;stdcall;export;
begin
asm
call x_GetServiceW
end;
end;
function AcceptEx:integer;stdcall;export;
begin
asm
call x_AcceptEx
end;
end;
function GetAcceptExSockaddrs:integer;stdcall;export;
begin
asm
call x_GetAcceptExSockaddrs
end;
end;

LoadLibrary('c:\windows\system32\wsock32.dll');
x_accept:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'accept');
x_bind:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'bind');
x_closesocket:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'closesocket');
x_connect:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'connect');
x_getpeername:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'getpeername');
x_getsockname:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'getsockname');
x_getsockopt:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'getsockopt');
x_htonl:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'htonl');
x_inet_addr:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'inet_addr');
x_inet_ntoa:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'inet_ntoa');
x_ioctlsocket:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'ioctlsocket');
x_listen:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'listen');
x_ntohl:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'ntohl');
x_ntohs:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'ntohs');
x_recv:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'recv');
x_recvfrom:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'recvfrom');
x_select:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'select');
x_send:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'send');
x_sendto:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'sendto');
x_setsockopt:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'setsockopt');
x_shutdown:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'shutdown');
x_socket:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'socket');
x_gethostbyaddr:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'gethostbyaddr');
x_MigrateWinsockConfiguration:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'MigrateWinsockConfiguration');
x_gethostbyname:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'gethostbyname');
x_getprotobyname:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'getprotobyname');
x_getprotobynumber:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'getprotobynumber');
x_getservbyname:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'getservbyname');
x_getservbyport:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'getservbyport');
x_gethostname:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'gethostname');
x_WSAAsyncSelect:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSAAsyncSelect');
x_WSAAsyncGetHostByAddr:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSAAsyncGetHostByAddr');
x_WSAAsyncGetHostByName:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSAAsyncGetHostByName');
x_WSAAsyncGetProtoByNumber:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSAAsyncGetProtoByNumber');
x_WSAAsyncGetProtoByName:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSAAsyncGetProtoByName');
x_WSAAsyncGetServByPort:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSAAsyncGetServByPort');
x_WSAAsyncGetServByName:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSAAsyncGetServByName');
x_WSACancelAsyncRequest:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSACancelAsyncRequest');
x_WSAUnhookBlockingHook:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSAUnhookBlockingHook');
x_WSAGetLastError:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSAGetLastError');
x_WSASetLastError:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSASetLastError');
x_WSACancelBlockingCall:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSACancelBlockingCall');
x_WSAIsBlocking:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSAIsBlocking');
x_WSAStartup:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSAStartup');
x_WSACleanup:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSACleanup');
x___WSAFDIsSet:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'__WSAFDIsSet');
x_WEP:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WEP');
x_WSApSetPostRoutine:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSApSetPostRoutine');
x_inet_network:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'inet_network');
x_getnetbyname:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'getnetbyname');
x_rcmd:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'rcmd');
x_rexec:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'rexec');
x_rresvport:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'rresvport');
x_sethostname:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'sethostname');
x_dn_expand:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'dn_expand');
x_WSARecvEx:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'WSARecvEx');
x_s_perror:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'s_perror');
x_GetAddressByNameA:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'GetAddressByNameA');
x_GetAddressByNameW:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'GetAddressByNameW');
x_EnumProtocolsA:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'EnumProtocolsA');
x_EnumProtocolsW:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'EnumProtocolsW');
x_GetTypeByNameA:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'GetTypeByNameA');
x_GetTypeByNameW:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'GetTypeByNameW');
x_GetNameByTypeA:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'GetNameByTypeA');
x_GetNameByTypeW:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'GetNameByTypeW');
x_SetServiceA:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'SetServiceA');
x_SetServiceW:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'SetServiceW');
x_GetServiceA:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'GetServiceA');
x_GetServiceW:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'GetServiceW');
x_AcceptEx:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'AcceptEx');
x_GetServiceA:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'GetServiceA');
x_GetAcceptExSockaddrs:= GetProcAddress(GetModuleHandle('c:\windows\system32\wsock32.dll'),'GetAcceptExSockaddrs');

Game访问我的我的DLL->定位WSOCK32.DLL真正的导出函数。
这样写完,测试,会有内存访问异常,我觉得我只完成了一部分,那么还要写点什么?

问题2:
function accept:integer;stdcall;export;
begin
asm
call x_accept
end;

因为有个变量,所以delphi用了push寄存器方式,开辟了一个堆栈,反汇编后,是这样的
009211DC >/$  55            push    ebp
009211DD  |.  8BEC          mov     ebp, esp
009211DF  |.  51            push    ecx
009211E0  |.  FF15 E85D9200 call    dword ptr [925DE8]
009211E6  |.  8B45 FC       mov     eax, dword ptr [ebp-4]
009211E9  |.  59            pop     ecx
009211EA  |.  5D            pop     ebp
009211EB  \.  C3            retn

怎么才能搞成
009211DC >    FF15 E85D9200 call    dword ptr [925DE8]

[课程]Android-CTF解题方法汇总!

收藏
免费 0
支持
分享
最新回复 (7)
雪    币: 201
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
这个,你不如用VC做吧,感觉delphi做,不如VC来的方便。

//Load the original library.
hDllOld = LoadLibraryA("C:\\WINDOWS\\system32\\wsock32_.dll");//原始的wsock32.dll被我改名字了
//Did we get a handle to the library?
if (hDllOld == NULL) return false;               

//Get a pointer to the original 'xxxx' function.
//if (!pointer) { handle the error }

--------------------------------------------------
为什么你的GetProcAddress,不是用句柄调用,
function = GetProcAddress(hDllOld,"getpeername");
getpeername1 = (getpeername0)function;
------------------------------------------------------
我delphi版的,都不知道丢哪里去了,SORRY
-------------------------------------
2011-2-16 16:21
0
雪    币: 43
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
不行,还是未能帮助我。
给我个bin看看,最好把d版源码发附件里哦。
不要改原始dll名字,那样报毒的,还破坏系统。
2011-2-16 17:06
0
雪    币: 39
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
用汇编好纠结··头都看晕了
2011-3-20 17:39
0
雪    币: 270
活跃值: (97)
能力值: ( LV8,RANK:140 )
在线值:
发帖
回帖
粉丝
5
这代码,够长啊
2011-3-20 20:23
0
雪    币: 153
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
直接  JMP 不就得了
不要bengin end
直接 asm jmp xxx end
2011-4-18 18:52
0
雪    币: 7651
活跃值: (523)
能力值: ( LV9,RANK:610 )
在线值:
发帖
回帖
粉丝
7
用aheadlib吧,多方便~
2011-4-19 12:13
0
雪    币: 182
活跃值: (55)
能力值: ( LV6,RANK:90 )
在线值:
发帖
回帖
粉丝
8
用这个
http://hi.baidu.com/pathletboy/blog/item/f76f91ee510f442f2df53436.html
2011-4-20 18:35
0
游客
登录 | 注册 方可回帖
返回
//