Squid 代理服务器 编译源码 伪造HTTP_X_FORWARDED_FOR 请求头
實驗目的實現?Squid 代理服務器 編譯源碼 偽造HTTP_X_FORWARDED_FOR ?請求頭 .使其顯示任意IP?
過程如下:?
1.下載對應系統的squid源碼版本Squid源碼連接:http://www.squid-cache.org/Versions/
?本次實驗下載:http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.STABLE21.tar.gz
命令:?wget??http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.STABLE21.tar.gz
2.解壓修改編譯源碼 一次執行如下命令
?yum -y install gcc perl make
tar xzf?squid-2.6.STABLE21.tar.gz
cd?squid-2.6.STABLE21
? ? ? ? ?修改代碼文件?http.c??
??/*?append?X-Forwarded-For?*/
if?(opt_forwarded_for)?{????strFwd?=?httpHeaderGetList(hdr_in,?HDR_X_FORWARDED_FOR);
????strListAdd(&strFwd,"112.121.182.45",?',');
????httpHeaderPutStr(hdr_out,?HDR_X_FORWARDED_FOR,?strBuf(strFwd));
????stringClean(&strFwd);
????} cd?squid-2.6.STABLE21 ./configure --prefix=/usr/local/squid --disable-internal-dns make make install
3.設置配置文件 ?
?/usr/local/squid/etc/squid.conf 如下配置
visible_hostname?nginxs.com http_port?3128icp_port?3130
cache_log?/dev/null
cache_store_log?none
pid_filename?/var/run/squid.pid
maximum_object_size?32768?KB
acl?all?src?0.0.0.0/0.0.0.0
http_access?allow?all
icp_access?allow?all
dns_nameservers?8.8.8.8
header_access?Via?deny?all
?
chmod?-R?777?/usr/local/squid/var
?/usr/local/squid/sbin/squid -z
/usr/local/squid/sbin/squid start
echo "/usr/local/squid/sbin/squid start" >> /etc/rc.local
vi /etc/rc.local
不出意外 現在可以打開IE 掛上代理IP測試了 對于修改之后重新編譯 make?? uninstallmake?? clean 對于啟動出現錯誤?squid: Cannot open HTTP Port 原來是Selinux防火墻阻止了,把SELinux關閉掉之后,便可以正常啟動squid服務了!
vi /etc/selinux/config
改成SELINUX=disabled
?
header_access Via deny all
header_access X-Forwarded-For deny all
header_access Server deny all
header_access X-Cache deny all
header_access X-Cache-Lookup deny all
CentOS6 Shell腳本/bin/bash^M: bad interpreter錯誤解決方法
在windows下保存了一個腳本文件,用ssh上傳到centos,添加權限執行nginx提示沒有那個文件或目錄。
shell腳本放到/etc/init.d/目錄下,再執行/etc/init.d/nginx,提示多了這句/bin/bash^M: bad interpreter。
網上找了資料才知道
如果這個腳本在Windows下編輯過,就有可能被轉換成Windows下的dos文本格式了,這樣的格式每一行的末尾都是以\r\n來標識,它的ASCII碼分別是0x0D,0x0A。如果你將這個腳本文件直接放到Linux上執行就會報/bin/bash^M: bad interpreter錯誤提示。
解決方法很簡單,首先你先要檢查一下看看你的腳本文件是不是這個問題導致的,用vi命令打開要檢查的腳本文件,然后用
:set ff?
命令檢查一下,看看是不是dos字樣,如果是dos格式的,繼續執行
:set ff=unix
然后執行
:qw
保存退出即可。
?
?方法2:修改squid,confi 中visible_hostname?8.8.8.8 這樣不用每次編譯
/* append X-Forwarded-For */
if (opt_forwarded_for) {
strFwd = httpHeaderGetList(hdr_in, HDR_X_FORWARDED_FOR);
strListAdd(&strFwd,Config.visibleHostname, ',');
httpHeaderPutStr(hdr_out, HDR_X_FORWARDED_FOR, strBuf(strFwd));
stringClean(&strFwd);
}
?
?
轉載于:https://www.cnblogs.com/xishi/archive/2012/04/10/ada.html
總結
以上是生活随笔為你收集整理的Squid 代理服务器 编译源码 伪造HTTP_X_FORWARDED_FOR 请求头的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 理解osi参考模型分层
- 下一篇: 永无止境