評測告訴你:那些免費(fèi)代理悄悄做的齷蹉事兒
作者:明明知道
筆者2013年曾發(fā)表過一篇文章《免費(fèi)代理服務(wù)器為何免費(fèi)?》——文中提及代理服務(wù)器之所以免費(fèi),是因?yàn)槠淇梢暂p松浸染用戶的上網(wǎng)行為并收集數(shù)據(jù)。而最新上線的Proxy Checker可以檢測代理服務(wù)器的安全性。
筆者2013年曾發(fā)表過一篇文章《免費(fèi)代理服務(wù)器為何免費(fèi)?》——文中提及代理服務(wù)器之所以免費(fèi),是因?yàn)槠淇梢暂p松浸染用戶的上網(wǎng)行為并收集數(shù)據(jù)。而最新上線的Proxy Checker可以檢測代理服務(wù)器的安全性。
后來,為了找到那些使用了文章中所述的免費(fèi)代理服務(wù)器,我寫了個(gè)極簡單的腳本(實(shí)際就是一個(gè)PHP函數(shù)),從不同的位置請求獲取Javascript文件并檢測可修改的內(nèi)容。
評測方法
如果你并不關(guān)心代碼,請直接跳至檢測結(jié)果。
我說這個(gè)腳本“極簡單”是因?yàn)檫@是個(gè)完整函數(shù):
/**************************************************************************/
/* scanProxy function by Christian Haschek christian@haschek.at */
/* It's intended to be used with php5-cli .. don't put it on a web server */
/* */
/* Requests a specific file ($url) via a proxy ($proxy) */
/* if first parameter is set to false it will retrieve */
/* $url without a proxy. CURL extension for PHP is required. */
/* */
/* @param $proxy (string) is the proxy server used (eg 127.0.0.1:8123) */
/* @param $url (string) is the URL of the requested file or site */
/* @param $socks (bool) true: SOCKS proxy, false: HTTP proxy */
/* @param $timeout (int) timeout for the request in seconds */
/* @return (string) the content of requested url */
/**************************************************************************/
function scanProxy($proxy,$url,$socks=true,$timeout=10)
{
$ch = curl_init($url);
$headers["User-Agent"] = "Proxyscanner/1.0";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0); //we don't need headers in our output
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,$timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //return output as string
$proxytype = ($socks?CURLPROXY_SOCKS5:CURLPROXY_HTTP); //socks or http proxy?
if($proxy)
{
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXYTYPE, $proxytype);
}
$out = curl_exec($ch);
curl_close($ch);
return trim($out);
}
你可以用這個(gè)函數(shù)做各種分析:
/* scanProxy function by Christian Haschek christian@haschek.at */
/* It's intended to be used with php5-cli .. don't put it on a web server */
/* */
/* Requests a specific file ($url) via a proxy ($proxy) */
/* if first parameter is set to false it will retrieve */
/* $url without a proxy. CURL extension for PHP is required. */
/* */
/* @param $proxy (string) is the proxy server used (eg 127.0.0.1:8123) */
/* @param $url (string) is the URL of the requested file or site */
/* @param $socks (bool) true: SOCKS proxy, false: HTTP proxy */
/* @param $timeout (int) timeout for the request in seconds */
/* @return (string) the content of requested url */
/**************************************************************************/
function scanProxy($proxy,$url,$socks=true,$timeout=10)
{
$ch = curl_init($url);
$headers["User-Agent"] = "Proxyscanner/1.0";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0); //we don't need headers in our output
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,$timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //return output as string
$proxytype = ($socks?CURLPROXY_SOCKS5:CURLPROXY_HTTP); //socks or http proxy?
if($proxy)
{
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXYTYPE, $proxytype);
}
$out = curl_exec($ch);
curl_close($ch);
return trim($out);
}
你可以用這個(gè)函數(shù)做各種分析:
·檢查代理是否隱藏了你的IP,通過 http://ip.haschek.at 找到你的IP,然后你可以在參考數(shù)據(jù)中檢查是否有與你的IP相同的;
·檢查代理是否使用的https隧道傳輸(一種安全傳輸協(xié)議),如果不是,那可能是服務(wù)器擁有者想查看明文,然后從中提取數(shù)據(jù);
·檢查代理是否修改了靜態(tài)網(wǎng)頁(例如:添加廣告)。
分析443個(gè)免費(fèi)代理服務(wù)器
我從各種渠道獲得了代理服務(wù)器的信息,但是我發(fā)現(xiàn)Google有通向所有網(wǎng)站的鏈接
我們需要檢測什么
是否使用了HTTPS?
是否修改了JS內(nèi)容?
是否修改了靜態(tài)網(wǎng)頁?
是否隱藏了我的IP?
評測結(jié)果
現(xiàn)在問題來了:75%的代理服務(wù)器是安全的?
僅僅因?yàn)橐粋€(gè)代理服務(wù)器“不積極”地修改你的內(nèi)容,這并不意味著它就是安全的。使用免費(fèi)代理服務(wù)器的的唯一安全的方法就是如果HTTPS可用,你只訪問實(shí)施HTTPS的站點(diǎn)即可。
只有21%代理服務(wù)器使用了HTTPS。
令人震驚的結(jié)果
出乎意料的是,會(huì)有如此多的代理禁止HTTPS流量。代理服務(wù)器這么做可能是因?yàn)樗麄兿胱屇闶褂肏TTP,這樣它就能分析你的流量并竊取你的登錄憑證了。
199個(gè)代理服務(wù)器中只有17個(gè)(8.5%)修改JS,他們中大多出都被注入了客戶廣告。但是其中只有兩個(gè)是錯(cuò)誤信息或者web過濾器警告。
33個(gè)代理服務(wù)器(16.6%)活躍于修改靜態(tài)HTML頁面并且注入廣告。
他們中的大多數(shù)在結(jié)束標(biāo)簽之前加入了下面這段代碼:
<link rel="stylesheet" type="text/css" href="http://ads.adt100.com/css/bottom.css" /><div id="center_xad" class="cwindow_xad"><div class="center_title_xad" id="center_title_xad"><img onclick="closeWindow()" width="39px" id="cwindow_xclose" height="11px" src="http://ads.adt100.com/images/close_btn.gif"></div><div id="center_xad_cnt" class="injection_content"></div></div><div id="right_xad" class="window_xad"><div class="right_title_xad" id="right_title_xad"><img onclick="closeWindow()" id="cwindow_rclose" width="39px" height="11px" src="http://ads.adt100.com/images/close_btn.gif"></div><div id="right_xad_cnt" class="injection_content"></div></div><script src="http://ads.adt100.com/js/bottom.js"></script>
絕對的惡意廣告,及可能存在cookie竊取。然而,筆者并沒有進(jìn)一步進(jìn)行檢測。
另一個(gè)廣告注入代理服務(wù)器更加“精致”。他們頁面的注入腳本如下:
<script type="text/javascript" charset="utf-8" mediaproAccountID="0" mediaproSlotID="0" usermac="" src="/7b26d4601fbe440b35e496a0fcfa15f7/00212600d7e6/w1/i.js" async="async" defer></script><meta charset="utf-8">
有趣的是,他們指向一個(gè)看起來像是本地的JS。當(dāng)瀏覽器通過代理服務(wù)器請求這一文件,代理就會(huì)劫持請求然后回復(fù)一個(gè)受感染的JS。因?yàn)樗土硪粋€(gè)相同,并非一個(gè)跨域JS鏈接。
如果你仍然認(rèn)為自己有必要使用一個(gè)免費(fèi)代理服務(wù)器,嘗試使用一個(gè)HTTPS可用的,并且要訪問安全的站點(diǎn)。
責(zé)任編輯:何妍
來源:
黑客與極客