一个辅助AWVS C段扫描的小php脚本

小菜写的小脚本,大牛轻拍砖~~~~~~

 

 

 

  渗透前信息收集时喜欢用椰树来获取旁站及二级域名,然后根据二级、三级域名地址扩展C段,扩大扫描业务边界。例如

以联想为例

 

但,各个旁站对应IP可能不同,或有CDN代理混淆真实IP。正常情况下我会用命令ping 以及nslookup来确定。例如:

 

 

nslookup与ping回显不同,且nslookup有多个Addresses一般认为有CDN。不适合扫描C段。

 

接下来这段比较合适测试,例如:

 

获得真实ip后,我喜欢用awvs来扫描其C段,从而扩大业务范围。例如用上述ip:

 

 

业务范围就打了,随便打开一个,发现个后台。

 

那么多Ip,难道我要一个一个ping 和nslookup来确定有没有CDN,而且椰树默认提供的是二级、三级域名,肿么办,只能自己写个脚本。

 

 

代码如下:

 1 <?php
 2 /*
 3       ◢████████████◣        
 4    ██████████████        
 5    ██   ◥██◤   ██        
 6  ◢███    ◥◤    ██◣       
 7  ▊▎██◣        ◢█▊▊       
 8  ▊▎██◤  ●  ●  ◥█▊▊      
 9  ▊ ██          █▊▊       
10  ◥▇██ ▊      ▊ █▇◤       
11    ██ ◥▆▄▄▄▄▆◤ █▊   ◢▇▇◣ 
12 ◢██◥◥▆▅▄▂▂▂▂▄▅▆███◣ ▊◢ █ 
13 █╳               ╳█ ◥◤◢◤ 
14 ◥█◣   ˙     ˙   ◢█◤  ◢◤  
15   ▊             ▊    █   
16   ▊             ▊   ◢◤   
17   ▊      ⊕      █▇▇▇◤   
18  ◢█▇▆▆▆▅▅▅▅▆▆▆▇█◣       
19  ▊ ▂ ▊      ▊ ▂ 
20 
21 
22 code by elliott
23 qq 1352133162
24 
25 
26 function:
27     获得目标大致真实ip,自动去除cdn代理的结果。方便C段扫描。
28 
29 
30 
31 usage:
32     将御剑扫到的二级或三级域名导出至本脚本同目录,文件名默认为zhuanhuan.txt
33     开扫,默认结果输出为同目录  result.txt
34 
35 
36 
37 
38 
39 variables:
40     $result1
41     $result2
42     $matches1
43     $matches2
44     $sucess
45     $url_array
46     $url_nums
47     $filecontent
48 */
49     error_reporting ( E_ERROR  |  E_WARNING  |  E_PARSE );
50     set_time_limit(200);    //脚本执行时间默认为2分钟,若要完整结果请设置为0,等待时间较长。
51 
52     $result1 = '';
53     $result2 = '';
54     $matches1 = '';
55     $matches2 = '';
56     $url_array = '';
57     $url_nums = '';
58     $filecontent = '';
59     $success = '';
60 
61 
62     $filecontent = file_get_contents('./zhuanhuan.txt');    //获取御剑得到的结果文本
63 
64     $url_array = explode("\n",$filecontent); 
65     $url_nums = count($url_array);
66 
67 
68     for($i=0; $i<$url_nums;$i++){
69             $result1=shell_exec('ping  '.$url_array[$i]);
70             preg_match_all("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $result1,$matches1);
71                 $result2 = shell_exec('nslookup  '.$url_array[$i]);
72                 preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $result2,$matches2);    //去除cdn结果
73                 if(count($matches2[0]) >= 2){
74                     continue;
75                 }else{        
76                     if(!$matches1[0][1]){
77                     continue;
78                     }
79                     @$success = "find url:".$url_array[$i].'-------'.$matches1[0][1]."\r\n";
80                     if(!$fp1=fopen('result.txt','a+')){
81                             echo "file write error";
82                     }
83 
84                     if(fwrite($fp1,$success."\n\r")){
85                         echo 'write success!output to result.txt!';
86                     }
87 
88                     fclose($fp1);
89             
90                 }    
91     
92 }
93 
94 
95 ?>


下载地址:

http://pan.baidu.com/s/1hqpQJQW

 

用法:

1.用椰树右键导出目标的二级、三级域名。保存文件名为 zhuanhuan.txt

 

 

2.将zhuanhuan.txt与findtarget.php放置同一个PHP可执行目录。我放置默认xampp目录。然后执行findtarget.php脚本。我默认脚本执行时间为2分钟,可能执行结果不完全。根据需求你可以将第50行set_time_limit()改为你想要的执行时间。

 

3.结果保存在同目录的result.txt文本中。该程序功能是批量ping 及  nslookup,自动排除cdn结果。省一些体力。来看看结果

 

 

 

 

 

^^ over

 

posted @ 2015-08-22 16:14  elliottc  阅读(1125)  评论(0编辑  收藏  举报