月度归档:2015年04月

工具:php实现穷举域名功能

1.需求如下:
假设某网站域名为http://www.wangzhan.com,要实现这个功能:
域名第一个字符遍历
http://www.aangzhan.com
……
zangzhan.com
域名第二个字符遍历
http://www.wangzhan.com
……
wzngzhan.com
以此类推到域名最后一个字符遍历
2.实现代码如下:

<?php 
 
$str=$argv[1];
$website_arr=explode(".",$str);
$website_name=$website_arr[1];
$website_length=strlen($website_name);
$key = array(
	array("/j/","l"),
	array("/l/","j"),
	array("/i/","j"),
	array("/j/","i"),
	array("/i/","1"),
	array("/1/","i"),
	array("/j/","1"),
	array("/1/","j"),
	array("/l/","i"),
	array("/i/","l"),
	array("/b/","lo"),
	array("/lo/","b"),
	array("/q/","9"),
	array("/9/","q"),
	array("/u/","v"),
	array("/v/","u"),
	array("/6/","b"),
	array("/b/","6"),
	array("/w/","vv"),
	array("/vv/","w"),
	array("/m/","nn"),
	array("/nn/","m"),
	array("/o/","0"),
	array("/0/","o"),
	array("/m/","n"),
	array("/n/","m"),
	array("/com/","com.cn"),
	array("/com/","cn"),
	array("/com/","net"),
	array("/com/","org"),
	array("/com/","tk"),
	array("/com/","pk"),
	array("/com/","cf"),
	array("/com/","cc"),
	array("/com/","tv"),
	array("/com/","pl"),
	array("/com/","im"),
	array("/cn/","com"),
	array("/cn/","com.cn"),
	array("/cn/","net"),
	array("/cn/","org"),
	array("/cn/","tk"),
	array("/cn/","pk"),
	array("/cn/","cf"),
	array("/cn/","cc"),
	array("/cn/","tv"),
	array("/cn/","pl"),
	array("/cn/","im"),
	array("/cn/","cn.com"),
	array("/cn/","cn.org"),
	array("/cn/","org.cn"),
	array("/cn/","net.cn"),
	array("/cn/","cn.net"),
	array("/www./","www-"),
	array("/www./","www"),
	array("/china/","chnina"),
	array("/abc/","abcd"),
	array("/bank/","bork"),
	array("/bank/","benk"),
	array("/bank/","bonk"),
	array("/bank/","bark"),
	array("/so/","sou"),
	array("/2/","z"),
	array("/z/","2"),
	array("/c/","2"),
	array("/c/","z"),
 
 
 
 
	);
for($j=0;$j<$website_length;$j++){
	if($j==0){
		dealstring('',substr($website_name,$j+1),$website_arr,$key);
	}else if($j==$website_length-1){
		dealstring(substr($website_name,0,$j),'',$website_arr,$key);
	}else{
		dealstring(substr($website_name,0,$j),substr($website_name,$j+1),$website_arr,$key);
	}
}
 
function dealstring($str_zuo,$str_you,$website_arr,$key){
 
//echo 'string:'.$str_zuo.' '.$str_you."\r\n";
 
for($i=97;$i<123;$i++){
 
	echo findHost($website_arr[0].'.'.$str_zuo.chr($i).$str_you.'.'.$website_arr[2],$key);
}
 
}
 
function findHost($host,$key){
	//echo $host."\r\n";
	for($i=0;$i<sizeof($key);$i++){ 		
           $hostChange =preg_replace($key[$i][0],$key[$i][1],$host); 	
           if($hostChange!=$host) 		
              echo $hostChange."\r\n"; 		
        }
} 
?>

下图为运行结果:

接着可以实现访问每个网站检查其是否可以访问,然后监控其内容是否为钓鱼网站。