>> 欢迎您, 傲气雄鹰: 重登陆 | 退出 | 注册 | 资料 | 设置 | 排行 | 新贴 | 精华 | 管理 | 帮助 首页

  小榕软件实验室
  刀光雪影
  C++实现CGI漏洞扫描
发表文章 发表涂鸦
  回复数:6  点击数:100 将此页发给您的朋友        
作者 主题: C++实现CGI漏洞扫描 回复 | 收藏 | 打印 | 篇末
MIXTER帅哥哦
级别:长 老 级
威望:0
经验:0
货币:2007
体力:78.6
来源:61.147.229.*
总发帖数:529
注册日期:2001-08-12
查看 邮件 主页 QQ 消息 引用 复制 下载 

暴简单的一个程序
我做了一下分析
如下
#include <stdio.h>


#include <winsock2.h>


#include <time.h>





#define iPort 80//目标Web Server端口


#define szSign "500 13\r\nServer: Microsoft-IIS/5.0"//根据此标志来检查目标是否有漏洞





#pragma comment(lib,"ws2_32.lib")


///////////////////////////////////////////////////////////////////////////


//


//定义&初始化全局变量


//


char *SendBuff="GET /NULL.printer\n",//发送的请求buff


    CurrentTarget[52]={0},//存放最后一个线程将扫描的目标


    turn[4][2]={"-","\\","|","/"};//显示进度时的字符


int SendBuffLen=strlen(SendBuff),//发送的buff长度


    iConnTimeout,//TCP Connect TimeOut


    ii=0,//扫描进度


    iTotal;//服务器总数


HANDLE hSemaphore=NULL,//信标内核对象句柄,用来控制线程数量


       hStdout;//console标准输出句柄,做进度显示的时候用的


struct timeval timeout;//连接、发送和接收的超时值


DWORD SleepTime;//每个一个线程后等待的时间


    /*


    SleepTime值根据用户输入的线程数量[ThreadNum]和TCP ConnectTimeOut[CONNTIMEO]来计算。确保在CONNTIMEO时间左右开    ThreadNum个线程。这样在CONNTIMEO时间后,所开的线程开始陆续超时退出,可以继续稳定的开线程,可以有效的保证同时有    ThreadNum个线程在运行。


    */


///////////////////////////////////////////////////////////////////////////


void ShowError(char *);//显示出错信息函数,可以写完善一些,偶偷懒了:)


BOOL ResetCursor(void);//重置光标位置,线程输出的时候调用的


DWORD WINAPI ShowProInfo(LPVOID);//显示进度信息


DWORD WINAPI scan(LPVOID);//扫描函数


void usage(char *);//帮助函数


///////////////////////////////////////////////////////////////////////////


int main(int argc,char **argv)


{


    HANDLE hThread=NULL;//线程句柄


    DWORD dwThreadID;//线程ID


    struct sockaddr_in sa;


    int i,


       MaxThread;//最大线程数量


    WSADATA    wsd;


    long PreviousCount;


    clock_t start,end;//程序运行的起始和结束时间


    double duration;





    //检查用户输入参数


    if(argc!=5)


    {


       usage(argv[0]);


       return 1;


    }


    //get target range


    int StartNet=inet_addr(argv[1]);


    int StopNet=inet_addr(argv[2]);


    int StartHost=ntohl(StartNet);


    int StopHost=ntohl(StopNet);


    //取得线程数量


    MaxThread=atoi(argv[3]);


    //取得conn超时时间


    iConnTimeout=atoi(argv[4]);


    //检查参数合法性


    if((iConnTimeout>6) || (iConnTimeout<2) || (MaxThread<1) || (MaxThread>500) || (StopHost<StartHost))


    {


       usage(argv[0]);


       return 1;


    }


    //计算时间


    SleepTime=1000*iConnTimeout/MaxThread;


    //设置连接超时值


    timeout.tv_sec = iConnTimeout;


    timeout.tv_usec =0;


    __try


    {


       //开始计时


       start=clock();


       //加载winsock库


       if (WSAStartup(MAKEWORD(1,1), &wsd) != 0)


       {


           ShowError("WSAStartup");


           __leave;


       }


       //创建信标内核对象句柄


       hSemaphore=CreateSemaphore(NULL,MaxThread,MaxThread,NULL);


       if(hSemaphore==NULL)


       {


           ShowError("CreateSemaphore");


           __leave;


       }


       //取得console标准输出句柄


       hStdout=GetStdHandle(STD_OUTPUT_HANDLE);


       if(hStdout==INVALID_HANDLE_VALUE)


       {


           ShowError("GetStdHandle");


           __leave;


       }


       //设置目标总数


       iTotal=StopHost-StartHost;


       //创建进度显示线程


       hThread=CreateThread(NULL,0,ShowProInfo,NULL,0,&dwThreadID);


       if(hThread==NULL)


       {


           ShowError("1 CreateThread");


           __leave;


       }


//关闭句柄


       CloseHandle(hThread);


       //循环创建扫描线程


       for(i=StartHost;i<=StopHost;i++)


       {


           //等待信标内核对象通知


           WaitForSingleObject(hSemaphore,INFINITE);


           //create thread to scan


           hThread=CreateThread(NULL,0,scan,(LPVOID)i,0,&dwThreadID);


           if(hThread==NULL)


           {


              ShowError("2 CreateThread");


              break;


           }


           //进度自加1


           ii++;


           //重设最后一个线程扫描的目标


           sa.sin_addr.s_addr=htonl(i);


           strncpy(CurrentTarget,inet_ntoa(sa.sin_addr),sizeof(CurrentTarget));


           //休息一会儿)


           Sleep(SleepTime);


           //关闭线程句柄


           CloseHandle(hThread);


       }


       //等待所有线程结束


       while(1)


       {


           WaitForSingleObject(hSemaphore,INFINITE);


           if(!ReleaseSemaphore(hSemaphore,1,&PreviousCount))


           {


              ShowError("main() ReleaseSemaphore");


              Sleep(5000);


              break;


           }


           if(PreviousCount==(MaxThread-1))


           {


              printf("\nAll done.");


              break;


           }


           Sleep(500);


       }


    }//end of try


    //搞定,清场,收工


    __finally


    {


       //计时结束


       end=clock();


       //转换时间格式


       duration = (double)(end - start) / CLOCKS_PER_SEC;


       //显示所用时间


       printf("\n\nComplete.Scan %d targets use %2.1f seconds.Speed %0.3g/s\n",iTotal,duration,iTotal/duration);


       //关闭句柄


       CloseHandle(hStdout);


       CloseHandle(hSemaphore);


       WSACleanup();


    }


    return 0;


}


///////////////////////////////////////////////////////////////////////////


//


//回显错误信息函数


//


void ShowError(char *msg)


{


    MessageBox(NULL,msg,"ERROR",0);


    //printf("\n%s failed:%d",GetLastError());


}


//////////////////////////////////////////////////////////////////////////


//


//重置光标位置函数,以便扫描线程输出结果


//


BOOL ResetCursor()


{


    CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo;


    //取得当前光标位置


    if(!GetConsoleScreenBufferInfo(hStdout,&ConsoleScreenBufferInfo))


    {


       ShowError("GetConsoleScreenBufferInfo");


       return FALSE;


    }


    //设置光标X坐标为0


    ConsoleScreenBufferInfo.dwCursorPosition.X=0;


    //设置当前光标位置


    SetConsoleCursorPosition(hStdout,ConsoleScreenBufferInfo.dwCursorPosition);


    return TRUE;


}


///////////////////////////////////////////////////////////////////////////


//


//显示进度信息函数


//


DWORD WINAPI ShowProInfo(LPVOID lp)


{  


    int j,k;


    CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo;


    float m;


    for(j=0;ii<iTotal;j++)


    {


       //休息一会儿))


       Sleep(SleepTime);


       //取得当前光标位置


       if(!GetConsoleScreenBufferInfo(hStdout,&ConsoleScreenBufferInfo))


       {


           ShowError("GetConsoleScreenBufferInfo");


           return 1;


       }


       //设置百分比进度显示的X坐标


       ConsoleScreenBufferInfo.dwCursorPosition.X=0;


       //设置当前光标位置


       SetConsoleCursorPosition(hStdout,ConsoleScreenBufferInfo.dwCursorPosition);


       //已经完成的百分比


       m=(ii+1)*100.00/iTotal;


       //显示进度


       if(ii==iTotal)


       {


           printf("******** 100%% Wait %d seconds to exit ********       \n",iConnTimeout);


           break;


       }


       else


       {


           k=j%4;


           printf("%-15s %s [%d/%d] %s %%%0.3g",CurrentTarget,turn[k],ii,iTotal,turn[k],m);


       }


    }//end of for


    return 0;


}


///////////////////////////////////////////////////////////////////////////


//


//扫描函数


//


DWORD WINAPI scan(LPVOID lp)


{


    int i=(int)lp,iErr;


    struct sockaddr_in server;


    SOCKET s=INVALID_SOCKET;


    char RecvBuff[1024]={0},*ptr;


    int RecvBuffLen=sizeof(RecvBuff);


    u_long ul=1;//初始化为为非0值


  fd_set r,w;





    //create socket


    s=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);


    if(s==INVALID_SOCKET)


    {


       printf("\nCreate socket failed:%d",GetLastError());


       ExitProcess(1);


    }


    //fill the addr struct


    server.sin_family=AF_INET;


    server.sin_port=htons(iPort);


    server.sin_addr.S_un.S_addr=htonl(i);


    __try


    {


       //设置socket为非锁定模式,ul为0值的话,那么soocket将被设置为锁定模式


       iErr=ioctlsocket(s,FIONBIO,(unsigned long*)&ul);


       if(iErr==SOCKET_ERROR )


       {


           ResetCursor();


           ShowError("ioctlsocket");


           ExitProcess(1);


       }


       //printf("\n%X ioctl ok.strat conn",i);


       //connect to target


       connect(s,(struct sockaddr *)&server,sizeof(server));


       //printf("\n%X conn return,start select w",i);


       //设置select参数


       FD_ZERO(&w);


       FD_SET(s, &w);


       //等待connect成功&socket可写


       iErr=select(0, 0, &w, 0, &timeout);


       //printf("\n%X select w return %d",i,iErr);


       //等待返回后,socket仍不可写则退出


       if((iErr==SOCKET_ERROR) || (iErr==0))


       {


           //printf("\n%X select return w err,exit",i);


           __leave;


       }


       //socket可写则继续


       else


       {


           //send buff to target


           //printf("\n%X send",i);


           iErr=send(s,SendBuff,SendBuffLen,0);


           //printf("\n%X send return",i);


           if(iErr==SOCKET_ERROR)


              __leave;


       }


       //等待socket可读


       FD_ZERO(&r);


       FD_SET(s, &r);


       //printf("\n%X start select r",i);


       iErr=select(0, &r, 0, 0, &timeout);


       //printf("\n%X select r return %d",i,iErr);


       if((iErr==SOCKET_ERROR) || (iErr==0))


       {


           //printf("\n%X select r err,exit",i);


           __leave;


       }


       else


       {


           //recv buff from target


           //printf("\n%X start recv",i);


           iErr=recv(s,RecvBuff,RecvBuffLen,0);


           //printf("\n%X recv ret",i);


           if(iErr==SOCKET_ERROR)


              __leave;


       }


       //verify buff


       ptr=strstr(RecvBuff,szSign);


       if(ptr!=NULL)


       {


           //线程输出前要先调用ResetCursor函数


           ResetCursor();


           //输出信息后务必加一个以上换行符号,输出前请别加换行符号,以免显示混乱


           printf("[%-15s] has .printer mapped.        \n",inet_ntoa(server.sin_addr));


       }


    }


    __finally


    {


       if(!ReleaseSemaphore(hSemaphore,1,NULL))


           ShowError("thread ReleaseSemaphore failed");


       closesocket(s);


    }


    return 0;


}


///////////////////////////////////////////////////////////////////////////


void usage(char *proname)


{


    printf("\n%s v0.1 only can find IIS5 .Printer mapped"


       "\nPower by ey4s<ey4s@21cn.com> 2001.5.20"


       "\nhttp://www.patching.net"


       "\n\nUsage:%s <StartIP> <EndIP> <ThreadNum> <CONNTIMEO>"


       "\n\nNotice"


       "\n    StartIP StopIP ==>Don't forgot StopIP must large than StartIP "


       "\n    ThreadNum ==>Thread number,please input between 1-500"


       "\n    CONNTIMEO ==>TCP connect timeout,please input between 2-6"


       "\n\nExample"


       "\n    %s 192.168.0.0 192.168.255.255 200 2",proname,proname,proname);


}


   程序在VC++6.0上编译通过,在windows2000上运行良好

虽然这个程序总体上功能不算强大
但大体上看出了CGI漏洞扫描的原理
我想榕G的那个流光也差不多吧
但是后来有朋友告诉我如果用PERL实现这些东西
代码行会很少很少

编辑 删除 发表时间发表于 2002-08-31.13:39:46   MSIE 5.0 Windows 98IP: 已记录
痞菜帅哥哦
级别:管理员
威望:9
经验:18
货币:99999
体力:100
来源:不知道
总发帖数:2602
注册日期:2001-04-13
查看 邮件 主页 QQ 消息 引用 复制 下载 

不错 不错 线程在弄好点嘿嘿 也是不错的哦 谢谢 精
----------------------------------------------------------

哈哈

编辑 删除 发表时间发表于 2002-08-31.13:43:19   MSIE 5.01 Windows 2000IP: 已记录
MIXTER帅哥哦
级别:长 老 级
威望:0
经验:0
货币:2007
体力:78.6
来源:61.147.229.*
总发帖数:529
注册日期:2001-08-12
查看 邮件 主页 QQ 消息 引用 复制 下载 

代码不是我写的啊

编辑 删除 发表时间发表于 2002-08-31.13:44:48   MSIE 5.0 Windows 98IP: 已记录
痞菜帅哥哦
级别:管理员
威望:9
经验:18
货币:99999
体力:100
来源:不知道
总发帖数:2602
注册日期:2001-04-13
查看 邮件 主页 QQ 消息 引用 复制 下载 

是的 用 perl 很少的就是要在linux下用 嘿嘿 一会给你找个简单的
----------------------------------------------------------

哈哈

编辑 删除 发表时间发表于 2002-08-31.13:44:59   MSIE 5.01 Windows 2000IP: 已记录
痞菜帅哥哦
级别:管理员
威望:9
经验:18
货币:99999
体力:100
来源:不知道
总发帖数:2602
注册日期:2001-04-13
查看 邮件 主页 QQ 消息 引用 复制 下载 

# TSScgi.sh
# usage : sh TSScgi.sh localhost 80
#
# Dedicated to my dog (Pleun) who doesn't feel well these
# days.... love you.
# -------------------------------------------------------
# Use at own risk!! You will not remain anonymous!!!!
#
# requires NetCat!!! (available at http://www.team-tss.org)
# -------------------------------------------------------
# Written by : GrAzEr1 of Team-TSS : GrAzEr1@team-tss.org
# -------------------------------------------------------

#!/bin/sh

logfile="log.txt"


cgi1=" /cgi-bin/phf"
cgi2=" /index.html"
cgi3=" /cgi-bin/test-cgi"
cgi4="/cgi-bin/nph-test-cgi"
cgi5=" /cgi-bin/finger"
cgi6=" /cgi-bin/campas"
cgi7="/_vti_pvt/service.pwd"
cgi8=" /cgi-bin/htmlscript"

# update vuln cgi's yourself

function check {
if grep 404 $logfile > /dev/null; then # only checks for 404, so found
echo " not found " # found warning may be wrong.
else echo " found!!"
fi
rm $logfile
}
echo "-[GrAzEr1 ::: Team - TSS CGI Scanner]-"
echo "-[ http://www.team-tss.org ]-"
echo "-[ #TSS IRCnet ]- "

sleep 3

echo
echo -n " Checking for: $cgi2 : "
(echo GET $cgi2) | nc $1 $2 > $logfile
check

echo -n " Checking for: $cgi3 : "
(echo GET $cgi3) | ((telnet $1 $2 > $logfile) > /dev/null)
check


echo -n " checking for: $cgi4 : "
(echo GET $cgi4) | nc $1 $2 > $logfile
check

echo -n " Checking for: $cgi5 : "
(echo GET $cgi5) | nc $1 $2 > $logfile
check

echo -n " Checking for: $cgi6 : "
(echo GET $cgi6) | nc $1 $2 > $logfile
check

echo -n " Checking for: $cgi7 : "
(echo GET $cgi7) | nc $1 $2 > $logfile
check

echo -n " Checking for: $cgi8 : "
(echo GET $cgi8) | nc $1 $2 > $logfile
check

echo ""
echo "-[ -- Scan Complete -- ]-"
echo ""


一个简单的shell 脚本 需要nc的配合 不错的
----------------------------------------------------------

哈哈

编辑 删除 发表时间发表于 2002-08-31.13:52:19   MSIE 5.01 Windows 2000IP: 已记录
痞菜帅哥哦
级别:管理员
威望:9
经验:18
货币:99999
体力:100
来源:不知道
总发帖数:2602
注册日期:2001-04-13
查看 邮件 主页 QQ 消息 引用 复制 下载 

#!/usr/bin/perl
# UNIX SCRIPTS ###################################################
@scripts_u = ("GET /cgi-bin/rwwwshell.pl HTTP/1.0\n\n","GET /cgi-bin/phf HTTP/1.0\n\n",
"GET /cgi-bin/Count.cgi HTTP/1.0\n\n","GET /cgi-bin/test-cgi HTTP/1.0\n\n",
"GET /cgi-bin/nph-test-cgi HTTP/1.0\n\n","GET /cgi-bin/nph-publish HTTP/1.0\n\n",
"GET /cgi-bin/php.cgi HTTP/1.0\n\n","GET /cgi-bin/handler HTTP/1.0\n\n",
"GET /cgi-bin/webgais HTTP/1.0\n\n","GET /cgi-bin/websendmail HTTP/1.0\n\n",
"GET /cgi-bin/webdist.cgi HTTP/1.0\n\n","GET /cgi-bin/faxsurvey HTTP/1.0\n\n",
"GET /cgi-bin/htmlscript HTTP/1.0\n\n","GET /cgi-bin/pfdispaly.cgi HTTP/1.0\n\n",
"GET /cgi-bin/perl.exe HTTP/1.0\n\n","GET /cgi-bin/wwwboard.pl HTTP/1.0\n\n",
"GET /cgi-bin/www-sql HTTP/1.0\n\n","GET /cgi-bin/view-source HTTP/1.0\n\n",
"GET /cgi-bin/campas HTTP/1.0\n\n","GET /cgi-bin/aglimpse HTTP/1.0\n\n",
"GET /cgi-bin/glimpse HTTP/1.0\n\n","GET /cgi-bin/man.sh HTTP/1.0\n\n",
"GET /cgi-bin/AT-admin.cgi HTTP/1.0\n\n","GET /cgi-bin/filemail.pl HTTP/1.0\n\n",
"GET /cgi-bin/maillist.pl HTTP/1.0\n\n","GET /cgi-bin/jj HTTP/1.0\n\n",
"GET /cgi-bin/info2www HTTP/1.0\n\n","GET /cgi-bin/files.pl HTTP/1.0\n\n",
"GET /cgi-bin/finger HTTP/1.0\n\n","GET /cgi-bin/bnbform.cgi HTTP/1.0\n\n",
"GET /cgi-bin/survey.cgi HTTP/1.0\n\n","GET /cgi-bin/AnyForm2 HTTP/1.0\n\n",
"GET /cgi-bin/textcounter.pl HTTP/1.0\n\n","GET /cgi-bin/classifieds.cgi HTTP/1.0\n\n",
"GET /cgi-bin/environ.cgi HTTP/1.0\n\n","GET /cgi-bin/wrap HTTP/1.0\n\n",
"GET /cgi-bin/cgiwrap HTTP/1.0\n\n","GET /cgi-bin/guestbook.cgi HTTP/1.0\n\n",
"GET /cgi-bin/edit.pl HTTP/1.0\n\n","GET /cgi-bin/perlshop.cgi HTTP/1.0\n\n");

@names_u = ("THC - backdoor ","phf ","Count.cgi ","test-cgi ","nph-test-cgi ",
"nph-publish ","php.cgi ","handler ","webgais ","websendmail ",
"webdist.cgi ","faxsurvey ","htmlscript ","pfdisplay ","perl.exe ",
"wwwboard.pl ","www-sql ","view-source ","campas ","aglimpse ",
"glimpse ","man.sh ","AT-admin.cgi ","filemail.pl ","maillist.pl ",
"jj ","info2www ","files.pl ","finger ","bnbform.cgi ",
"survey.cgi ","AnyForm2 ","textcounter.pl ","classifields.cgi","environ.cgi ",
"wrap ","cgiwrap ","guestbook.cgi ","edit.pl ","perlshop.cgi ");
# Windows SCRIPTS ###################################################
@scripts_w = ("GET /_vti_inf.html HTTP/1.0\n\n","GET /_vti_pvt/service.pwd HTTP/1.0\n\n",
"GET /_vti_pvt/users.pwd HTTP/1.0\n\n","GET /_vti_pvt/authors.pwd HTTP/1.0\n\n",
"GET /_vti_pvt/administrators.pwd HTTP/1.0\n\n","GET /_vti_bin/shtml.dll HTTP/1.0\n\n",
"GET /_vti_bin/shtml.exe HTTP/1.0\n\n","GET /cgi-dos/args.bat HTTP/1.0\n\n",
"GET /cgi-win/uploader.exe HTTP/1.0\n\n","GET /cgi-bin/rguest.exe HTTP/1.0\n\n",
"GET /cgi-bin/wguest.exe HTTP/1.0\n\n","GET /scripts/issadmin/bdir.htr HTTP/1.0\n\n",
"GET /scripts/CGImail.exe HTTP/1.0\n\n","GET /scripts/tools/newdsn.exe HTTP/1.0\n\n",
"GET /scripts/fpcount.exe HTTP/1.0\n\n","GET /cfdocs/expelval/openfile.cfm HTTP/1.0\n\n",
"GET /cfdocs/expelval/exprcalc.cfm HTTP/1.0\n\n","GET /cfdocs/expelval/displayopenedfile.cfm HTTP/1.0\n\n",
"GET /cfdocs/expelval/sendmail.cfm HTTP/1.0\n\n","GET /iissamples/exair/howitworks/codebrws.asp HTTP/1.0\n\n",
"GET /iissamples/sdk/asp/docs/codebrws.asp HTTP/1.0\n\n","GET /msads/Samples/SELECTOR/showcode.asp HTTP/1.0\n\n",
"GET /search97.vts HTTP/1.0\n\n","GET /carbo.dll HTTP/1.0\n\n");
@names_w = (
"_vti_inf.html ","service.pwd ","users.pwd ","authors.pwd ","administrators ",
"shtml.dll ","shtml.exe ","args.bat ","uploader.exe ","rguest.exe ",
"wguest.exe ","bdir - samples ","CGImail.exe ","newdsn.exe ","fpcount.exe ",
"openfile.cfm ","exprcalc.cfm ","dispopenedfile ","sendmail.cfm ","codebrws.asp ",
"codebrws.asp 2 ","showcode.asp ","search97.vts ","carbo.dll ");
$insecure = 0;
system "clear";
use IO::Socket;
my ($port, $sock,$server);
$size=0;
################################ SCAN ##########################
if(! $ARGV[0])
{
&usage;
exit;
}

$server = $ARGV[0];
($s,$e) = split(/-/,$server);
($ia,$ib,$id,$ix) = split(/\./,$s);
print "[Scaning from $s to $ia.$ib.$id.$e]\n";
$port = $ARGV[1];
if(! $ARGV[1]) { $port = 80; }
for($i=$ix;$i<=$e;$i++)
{
$server = "$ia.$ib.$id.$i";
&connect;
}

print "[CGI Scanner by RapMaster2000]\n";


sub connect {
#print "[Trying $server]\n";
    $sock = IO::Socket::INET->new(PeerAddr => $server,
                    PeerPort => $port,
                    Proto => 'tcp');
    if ($sock)    {
        print "[Connected to $server on $port]\n";
$n=0;
&version;
    close(sock);
    $size++;
} else {
   
    }
}
################################ VERSION ##########################
sub version {
$ver = "HEAD / HTTP/1.0\n\n";
my($iaddr,$paddr,$proto);
$iaddr = inet_aton($server) || die "Error: $!";
$paddr = sockaddr_in($port, $iaddr) || die "Error: $!";
$proto = getprotobyname('tcp') || die "Error: $!";
socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "Error: $!";
connect(SOCK, $paddr) || die "Error: $!";
send(SOCK, $ver, 0) || die "Can't to send packet: $!";
print "[Server version is]:\n[##############################]\n";
while(<SOCK>)
{
print;
}
print "[##############################]\n";
print "[It is Windows or UNIX?]\n[Windows-1,Unix-2,Quit-3]:";

$n=0;
chomp($type=<STDIN>);
if($type eq 3)
{ print "Scan aborted!\n"; exit; }
if($type eq 1)
{
foreach $scripts_w(@scripts_w)
{
    print "Searching for @names_w[$n] : ";
    $scw=$scripts_w;
$name = @names_w[$n];
    &win_scan;
    $n++;
}   
}
else {


foreach $scripts_u(@scripts_u)
{
    print "Searching for [@names_u[$n]] : ";
    $sc=$scripts_u;
$name = @names_u[$n];
    &unix_scan;
    $n++;
}
}
close(SOCK);
}
sub win_scan {
my($iaddr,$paddr,$proto);
$iaddr = inet_aton($server) || die "Error: $!";
$paddr = sockaddr_in($port, $iaddr) || die "Error: $!";
$proto = getprotobyname('tcp') || die "Error: $!";
socket(SOCK, PF_INET, SOCK_STREAM, $proto) || &error("Failed to open socket: $!");
connect(SOCK, $paddr) || &error("Unable to connect: $!");
send(SOCK,$scw,0);

    $check=<SOCK>;
    ($http,$code,$blah) = split(/ /,$check);
    if($code == 200)
    {
        print "[Found!]\n";
        $insecure++;
    }
    else
    {
        print "[Not Found]\n";

    }
    close(SOCK);
}


sub unix_scan {

my($iaddr,$paddr,$proto);
$iaddr = inet_aton($server) || die "Error: $!";
$paddr = sockaddr_in($port, $iaddr) || die "Error: $!";
$proto = getprotobyname('tcp') || die "Error: $!";
socket(SOCK, PF_INET, SOCK_STREAM, $proto) || &error("Failed to open socket: $!");
connect(SOCK, $paddr) || &error("Unable to connect: $!");
send(SOCK,$sc,0);

    $check=<SOCK>;
    ($http,$code,$blah) = split(/ /,$check);
    if($code == 200)
    {
        print "[Found!]\n";
        $insecure++;
    }
    else
    {
        print "[Not Found]\n";

    }
    close(SOCK);
}
################################ USAGE ##########################
sub usage {
system "clear";
    print "[Usage: ./port IP-END PORT ]\n[Example: ./port 195.34.0.1-255 23]\n[Put first agument -s for single host scan]\n";
    exit(0); }
################################ END ##########################
print "[Totaly found $size hosts with open $port port and $insecure buggy scripts]\n";


[ 此消息由 痞菜 在 2002-08-31.14:12:32 编辑过 ]
----------------------------------------------------------

哈哈

编辑 删除 发表时间发表于 2002-08-31.14:01:56   MSIE 5.01 Windows 2000IP: 已记录
kof2000帅哥哦
级别:光明使者
威望:0
经验:4
货币:5223
体力:98
来源:VisualStudio
总发帖数:2018
注册日期:2002-03-06
查看 邮件 主页 QQ 消息 引用 复制 下载 

这个代码我见过,编译后运行不错,好象有个WARNING..

----------------------------------------------------------
VB/C/C++,网络安全技术...

编辑 删除 发表时间发表于 2002-08-31.14:05:38   MSIE 5.0 Windows 98IP: 已记录
选择回复        
 快速回复主题: >>>高级模式
  用户名: 没有注册? 密码: 忘记密码?
记住密码
HTML语法
禁止IDB代码
禁止表情字符

[按 Ctrl+Enter 快捷键可直接提交帖子]
 投票评分: 共 0 票  
所有时间均为: 北京时间 ↑TOP 
关闭主题 拉前主题 移动主题 主题置顶 取消置顶 总固顶主题 取消总固顶 加入精华 移出精华 删除主题