国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

php curl 偽造IP來源程序?qū)崿F(xiàn)代碼

2024-05-04 21:47:29
字體:
供稿:網(wǎng)友

今天沒事做自己寫了一個php curl 偽造IP來源程序?qū)嵗绦?這里可以偽造IP來源,偽造域名,偽造用戶信息.

定義偽造用戶瀏覽器信息HTTP_USER_AGENT,代碼如下:

  1. $binfo =array('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; InfoPath.2; AskTbPTV/5.17.0.25589; Alexa Toolbar)','Mozilla/5.0 (Windows NT 5.1; rv:22.0) Gecko/20100101 Firefox/22.0','Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET4.0C; Alexa Toolbar)','Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1; SV1)',$_SERVER['HTTP_USER_AGENT']); 
  2. //123.125.68.* 
  3. //125.90.88.* 

定義偽造IP來源段,這里我找的是百度的IP地址,代碼如下:

  1. $cip = '123.125.68.'.mt_rand(0,254); 
  2. $xip = '125.90.88.'.mt_rand(0,254); 
  3. $header = array(  
  4. 'CLIENT-IP:'.$cip,  
  5. 'X-FORWARDED-FOR:'.$xip,  
  6. ); 

利用curl開始向服務(wù)器發(fā)送偽造信息,代碼如下:

  1. function getimgs( $url,$userinfo,$header
  2.  $ch = curl_init(); 
  3.  $timeout = 5; 
  4.  curl_setopt ($ch, CURLOPT_URL, "$url"); 
  5.  curl_setopt ($ch, CURLOPT_HTTPHEADER, $header); 
  6.  curl_setopt ($ch, CURLOPT_REFERER, "http://www.baidu.com/");  
  7.  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
  8.  curl_setopt ($ch, CURLOPT_USERAGENT, "$userinfo"); 
  9.  curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);   
  10.  $contents = curl_exec($ch); 
  11.  curl_close($ch); 
  12.  return $contents

獲取到數(shù)據(jù)我們再保存,代碼如下:

  1. function saveimgs( $handle ) 
  2.  $fp = fopen('a.jpg',"w"); 
  3.  fwrite($fp,$handle); 
  4.  unset($fp); 
  5.  unset($handle); 

測試偽造IP實(shí)例,代碼如下:

  1. $url ='http://www.survivalescaperooms.com/img/logo.jpg'
  2. $u = $binfo[mt_rand(0,3)]; 
  3. saveimgs(getimgs($url,$u,$header)); 

這樣就在你當(dāng)前目錄保存成功了一個文件a.jpg文件,我現(xiàn)可以查看服務(wù)器日志是不是我們自定的用戶信息呢?

192.168.1.108 - - [22/Jul/2013:10:29:37 +0800] "GET /test.php HTTP/1.1" 200 1244 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; InfoPath.2; AskTbPTV/5.17.0.25589; Alexa Toolbar)"

192.168.1.108 - - [22/Jul/2013:10:29:37 +0800] "GET / HTTP/1.1" 200 40538 "http://www.baidu.com/" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET4.0C; Alexa Toolbar)"

192.168.1.108 - - [22/Jul/2013:10:29:37 +0800] "GET /test.php HTTP/1.1" 200 1244 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; InfoPath.2; AskTbPTV/5.17.0.25589; Alexa Toolbar)"

192.168.1.108 - - [22/Jul/2013:10:29:37 +0800] "GET / HTTP/1.1" 200 40538 "http://www.baidu.com/" "Mozilla/5.0 (Windows NT 5.1; rv:22.0) Gecko/20100101 Firefox/22.0"

看出來了吧,完全正確啊,只是IP地址我怎么沒測試出來,這個使用php獲取ip地址時會是顯示我偽造IP地址了.

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 和林格尔县| 镇宁| 理塘县| 九寨沟县| 内黄县| 南木林县| 永新县| 全南县| 镇远县| 开鲁县| 汤原县| 贺州市| 个旧市| 东莞市| 祁阳县| 留坝县| 台山市| 休宁县| 深州市| 临高县| 新源县| 武安市| 义马市| 綦江县| 台南市| 晋江市| 建始县| 石嘴山市| 大同市| 阜平县| 沙雅县| 南江县| 大渡口区| 万盛区| 洮南市| 惠水县| 镇原县| 安国市| 黄浦区| 阜宁县| 阳泉市|