{黑掉这个盒子} \\ FluxCapacitor Write-Up

源标题:{Hack the Box} \ FluxCapacitor Write-Up

标签(空格分隔): CTF


  好孩子们。今天我们将学习耐心和情绪管理的优点。并且也许有一些关于绕过WEB应用防火墙的东西。

  老实说,这是一个令人愤怒的好盒子。我学习了一个主题的分支但我并没有真的深入研究。
  不管怎样,我们继续吧。
此处输入图片的描述
初始枚举
  开始运行Nmap开始扫描FluxCapacitor。让我们看看我们获得了什么。

root@kali:~# nmap -sC -sV -o        nmap.log 10.10.10.69
Starting Nmap 7.60 ( https://nmap.org ) at 2018-04-13 13:31 EDT
Nmap scan report for 10.10.10.69
Host is up (0.14s latency).
PORT   STATE SERVICE VERSION
80/tcp open  http    SuperWAF
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 34.32 seconds

此处输入图片的描述
  非常棒。只有一个web服务。选择一个浏览器继续浏览。(注意在“版本”之下,它说是superWAF。我们稍后会谈到这一点)。
此处输入图片的描述
  节点1似乎已经经历了一些糟糕的事情。
  除了一个神秘的状态消息之外,这里似乎没有什么进展。我们来看看源代码吧。
此处输入图片的描述
  你的使命:不惜一切代价保护节点1
  看那边的评论。太奇怪了。让我们到这个URL去看看吧。
此处输入图片的描述
  优秀。这是一个死胡同。可能除了在底部的那条线。我们获得了一个web server的名称和版本。这是联系谷歌搜索技巧的好时机(或者必应,我不确定)。搜索OpenResty站点,查看Github页面,浏览文档,并搜索该版本的任何有趣漏洞。这是一项非常值得学习的有价值技巧。虽然我替你节省一两个小时。但请继续练习这个技巧。

回到枚举

root@kali:~# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u 10.10.10.69 -x php,html -t 100 -s 200,204,301,302,307,403
Gobuster v1.2                OJ Reeves (@TheColonial)
[+] Mode         : dir
[+] Url/Domain   : http://10.10.10.69/
[+] Threads      : 100
[+] Wordlist     : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Status codes : 200,204,301,302,307,403
[+] Extensions   : .php,.html
/index.html (Status: 200)
/sync (Status: 200)
/sync.php (Status: 200)
/sync.html (Status: 200)
/synctoy (Status: 200)
/synctoy.php (Status: 200)
/synctoy.html (Status: 200)
/synching (Status: 200)
/synching.php (Status: 200)
/synching.html (Status: 200)
/sync_scan (Status: 200)
/sync_scan.php (Status: 200)
/sync_scan.html (Status: 200)
/syncbackse (Status: 200)
/syncbackse.php (Status: 200)
/syncbackse.html (Status: 200)
/synch (Status: 200)
/synch.php (Status: 200)
/synch.html (Status: 200)

  只是一个预感,但我认为服务器不希望我们知道文件扩展名/sync是什么。
它不会截断过去同步的任何内容。我们可以确认通过在/sync前面增加一串随机字符串。我们仍将获取一个403。但是如果我们移除掉“sync”部分,或者在它之前增加字符。我们获得一个404 not found。非常棒。
此处输入图片的描述
  现在扼杀你的嫉妒,弄清楚为什么服务器不喜欢我们。
  让我们打开Wireshark并比较两个来源的HTTP请求,看看我们哪里出错了。再次运行Gobuster并在tun0上运行Wireshark,这是HtB VPN的接口
此处输入图片的描述
  现在右键单击转到10.10.10.69的任何TCP数据包,然后单击Follow-> TCP Stream。这将为您提供格式良好的HTTP请求,因此您无需学习读取十六进制编码。

GET /43 HTTP/1.1
Host: 10.10.10.69
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
HTTP/1.1 404 Not Found
Date: Sun, 13 May 2018 18:36:33 GMT
Content-Type: text/html
Content-Length: 175
Connection: keep-alive
<html>
<head><title>404 Not Found</title></head> <body bgcolor="white"> <center><h1>404 Not Found</h1></center> <hr><center>openresty/1.13.6.1</center> </body> </html>

  对浏览器执行相同操作。运行wireshark(将界面更改为'any',因为浏览器HTTP请求采用不同的方式),转到Firefox中的/ sync并让我们看看我们得到了什么数据包。
此处输入图片的描述
跟随TCP/HTTP流。

GET /sync HTTP/1.1
Host: 10.10.10.69
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Pragma: no-cache
Cache-Control: no-cache
HTTP/1.1 403 Forbidden
Date: Sun, 13 May 2018 18:45:39 GMT
Content-Type: text/html
Content-Length: 175
Connection: keep-alive
<html>
<head><title>403 Forbidden</title></head> <body bgcolor="white"> <center><h1>403 Forbidden</h1></center> <hr><center>openresty/1.13.6.1</center> </body> </html>

  html内容本身并不重要,因为它总是可以变化的。同样处理GET请求内容。仔细查看两个请求中的HTTP头并进行比较。

Gobuster:

GET /43 HTTP/1.1
Host: 10.10.10.69
User-Agent: Go-http-client/1.1 Accept-Encoding: gzip

Browser (Firefox):

GET /sync HTTP/1.1
Host: 10.10.10.69
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate DNT: 1 Connection: keep-alive Upgrade-Insecure-Requests: 1 Pragma: no-cache Cache-Control: no-cache

  这是用户代理。一直都知道他身上有什么东西。我们的浏览器因任何原因被列入黑名单。你可以在这里玩一下。它似乎只是在User-Agent中寻找“Mozilla”这个词,并禁止来自它的所有流量。也许它也会将其他浏览器列入黑名单。谁知道呢。但如果您尝试wget或curl来获取网页,它会让您访问通过。
  但这并不是十分完美,所以我们将使用Burpsuite代理拦截我们的浏览器请求,修改它,并发送它。
  打开BurpSuite。免费版拥有我们需要的一切。
  转到顶部的Proxy ->Intercept选项卡,确保已启用拦截。
此处输入图片的描述
  要让我们的Firefox请求通过Burp,请转到Firefox - >首选项 - >高级 - >网络 - >连接 - >设置。将代理更改为127.0.0.1:8080。这将确保我们发送的任何浏览器请求都通过Burp代理路由,我们可以在将其发送到预定目的地之前查看和修改HTTP请求。
  请考虑下载FoxyProxy以自动为您执行此操作。这样可以节省10秒钟。然后,如果你每天增加10秒的空闲时间,你可以花他们梦想你的生活会是什么样子。真的很棒。
此处输入图片的描述
  浏览到/sync。您的浏览器将挂起。没关系。不要惊慌。转到Burp,你会(希望)看到原始的HTTP请求。

GET /sync HTTP/1.1
Host: 10.10.10.69
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate DNT: 1 Connection: close Upgrade-Insecure-Requests: 1

  删除当前的用户代理并将其替换为......我猜测的任何东西。只要它的名字中没有Mozilla,你就是上帝。

GET /sync HTTP/1.1
Host: 10.10.10.69
User-Agent: 007 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate DNT: 1 Connection: close Upgrade-Insecure-Requests: 1

  现在forward转发请求,转到您的浏览器。
此处输入图片的描述
  哇。我们得到了时间戳。nice,它让我们过去了,现在怎么办呢?

Waffening
作者:M. Night Shyamalan
  由于/sync似乎是唯一的其他页面,我们在这试图找出到底怎么回事。让我们回到SuperWaf。表明这个网站上是有一些web应用防火墙的。Google搜索SuperWAF并没有发现任何东西,所以我们会进行黑盒测试。
首先,WAF是反向代理。它充当服务器和客户端之间的中介,试图保护Web服务器免受针对错误配置和安全漏洞的攻击。它试图过滤掉常见的攻击尝试,如跨站点脚本(XSS),SQL注入和远程执行代码(RCE)。
  跨站点脚本在这里不会对我们有任何帮助,因为它需要其他用户。SQL注入似乎是一个很大的禁忌,因为数据似乎没有存储在任何地方。我们似乎只是从脚本中获取输出,告诉我们时间。是什么语言呢?没有线索。通过做一些有根据的猜测,我们可以利用某种RCE。waf在这是有原因的。
  我们现在需要打一个比喻,这就相当于我们的头在砖墙上反复撞,并希望我们能找到一些松散的砖块,并把砖墙整个拆掉。只是我们在走过废墟时跌倒,绊倒在砖碎片,反复拉扯,直到我们的裤子被扯掉。
此处输入图片的描述
  回到Burp,如果你还没有关闭它,请转到代理 - > HTTP历史记录,找到我们发送到/ sync的请求。单击它,然后按ctrl-r将其发送到Repeater。转到Repeater选项卡(仍在Burp中),并确保User-Agent没有Mozilla。
  现在我们可以反复修改和发送HTTP请求。
此处输入图片的描述
  在这一点上,我们可以做出有根据的猜测/ sync可能会有一个参数。让我们测试一下这个假设。
如果它可以采用参数,并且有一个WAF,那么很可能是一种执行代码的方法。同步后尝试一些参数,你会看到你得到相同的时间戳。没有什么变化。
此处输入图片的描述
  这是模糊测试器派上用场的地方。Kali linux已经安装了WFuzz,所以让我们使用它。它的作用是使用字典来强制URL,直到我们看到任何异常。我们没有太多选择可以继续,这是我们唯一的选择。在启动WFuzz之前,请检查一下。SecLists有一堆真正有用的模板用于模糊测试。现在好好的检查清单库并将其保存在好的地方。
  启动WFuzz并列出其选项。

root@kali:~# wfuzz -h
********************************************************
* Wfuzz 2.2.9 - The Web Fuzzer                         *
*                                                      *
* Version up to 1.4c coded by:                         *
* Christian Martorella (cmartorella@edge-security.com) *
* Carlos del ojo (deepbit@gmail.com)                   *
*                                                      *
* Version 1.4d to 2.2.9 coded by:                      * * Xavier Mendez (xmendez@edge-security.com)            * ******************************************************** Usage: wfuzz [options] -z payload,params <url> FUZZ, ..., FUZnZ  wherever you put these keywords wfuzz will replace them with the values of the specified payload. FUZZ{baseline_value} FUZZ will be replaced by baseline_value. It will be the first request performed and could be used as a base for filtering. Options: -h            : This help --help       : Advanced help --version      : Wfuzz version details -e <type>      : List of available encoders/payloads/iterators/printers/scripts -c       : Output with colors -v       : Verbose information. --interact      : (beta) If selected,all key presses are captured. This allows you to interact with the program. -p addr       : Use Proxy in format ip:port:type. Repeat option for using various proxies.       Where type could be SOCKS4,SOCKS5 or HTTP if omitted. -t N       : Specify the number of concurrent connections (10 default) -s N       : Specify time delay between requests (0 default) -R depth      : Recursive path discovery being depth the maximum recursion level. -L, --follow             : Follow HTTP redirections -u url                      : Specify a URL for the request. -z payload      : Specify a payload for each FUZZ keyword used in the form of type,parameters,encoder.       A list of encoders can be used, ie. md5-sha1. Encoders can be chained, ie. md5@sha1.       Encoders category can be used. ie. url                            Use help as a payload to show payload plugin's details (you can filter using --slice) -w wordlist      : Specify a wordlist file (alias for -z file,wordlist). -V alltype      : All parameters bruteforcing (allvars and allpost). No need for FUZZ keyword. -X method      : Specify an HTTP method for the request, ie. HEAD or FUZZ -b cookie      : Specify a cookie for the requests -d postdata       : Use post data (ex: "id=FUZZ&catalogue=1") -H header        : Use header (ex:"Cookie:id=1312321&user=FUZZ") --basic/ntlm/digest auth    : in format "user:pass" or "FUZZ:FUZZ" or "domain\FUZ2Z:FUZZ" --hc/hl/hw/hh N[,N]+     : Hide responses with the specified code/lines/words/chars (Use BBB for taking values from baseline) --sc/sl/sw/sh N[,N]+     : Show responses with the specified code/lines/words/chars (Use BBB for taking values from baseline) --ss/hs regex      : Show/Hide responses with the specified regex within the content

  -u,-w和--hh会在这里派上用场。-u和-w分别用于URL和wordlist。但最后一个是什么呢?查看wfuzz命令,你会看到 --hh用于隐藏具有特定字符数的响应。
  如果你回到Burp并随便访问/sync,你会注意到响应Content-Length在所有有效响应中都保持不变。19个字符。我们可以将此作为常量来帮助识别任何异常。
此处输入图片的描述
  现在让我们wfuzz这个坏男孩吧。

root@kali:~# wfuzz -w /usr/share/wordlists/SecLists/Discovery/Web-Content/burp-parameter-names.txt -u http://10.10.10.69/sync?FUZZ=ls -c --hh 19 | tee fuzz.log
********************************************************
* Wfuzz 2.2.9 - The Web Fuzzer                         *
********************************************************
Target: http://10.10.10.69/sync?FUZZ=ls
Total requests: 2588
==================================================================
ID Response   Lines      Word         Chars          Payload    
==================================================================
000753:  C=403      7 L       10 W     175 Ch   "opt"
Total time: 45.04352
Processed Requests: 2588
Filtered Requests: 2587
Requests/sec.: 57.45553

  当wfuzz遍历我们给它的字典时,URL中的FUZZ被字典中其他单词替换。此外,我们可以做出另一个有根据的猜测,并添加'ls'作为参数值。我们的想法是:我们的目标是某种RCE,因此我们想要触发一个目录列表的成功响应,或者让WAF阻止我们尝试这样做。内容长度小于19个字符的任何响应都会在结果中被过滤掉。
哎呀。我们找到了一个有效的参数名称。如果我们使用Burp添加'opt'参数,我们可以再次看到禁止页面。好极了。
此处输入图片的描述
  现在扯掉你的胡子。我们需要猜测这个RCE向量的限制是什么。首先再次启动wfuzz,看看哪些特殊字符被WAF过滤和阻止。

root@kali:~/Documents/hack_the_box/work_in_progress/fluxcapacitor# wfuzz -w /usr/share/wordlists/SecLists/Fuzzing/special-chars.txt -u http://10.10.10.69/sync?opt=FUZZ -c | tee schar_fuzz.log
Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information. ******************************************************** * Wfuzz 2.2.9 - The Web Fuzzer                         * ******************************************************** Target: http://10.10.10.69/sync?opt=FUZZ Total requests: 32 ================================================================== ID Response   Lines      Word         Chars          Payload    ================================================================== 000029:  C=200      1 L        0 W       1 Ch   "'" 000030:  C=200      2 L        1 W      19 Ch   """ 000031:  C=403      7 L       10 W     175 Ch   "<" 000032:  C=403      7 L       10 W     175 Ch   ">" 000002:  C=200      2 L        1 W      19 Ch   "!" 000003:  C=200      2 L        1 W      19 Ch   "@" 000001:  C=200      2 L        1 W      19 Ch   "~" 000004:  C=200      2 L        1 W      19 Ch   "#" 000005:  C=403      7 L       10 W     175 Ch   "$" 000006:  C=200      2 L        1 W      19 Ch   "%" 000007:  C=200      2 L        1 W      19 Ch   "^" 000008:  C=200      2 L        1 W      19 Ch   "&" 000009:  C=403      7 L       10 W     175 Ch   "*" 000010:  C=403      7 L       10 W     175 Ch   "(" 000011:  C=403      7 L       10 W     175 Ch   ")" 000012:  C=200      2 L        1 W      19 Ch   "_" 000013:  C=200      2 L        1 W      19 Ch   "_" 000014:  C=200      2 L        1 W      19 Ch   "+" 000015:  C=200      2 L        1 W      19 Ch   "=" 000016:  C=200      2 L        1 W      19 Ch   "{" 000017:  C=200      2 L        1 W      19 Ch   "}" 000018:  C=200      2 L        1 W      19 Ch   "]" 000019:  C=200      2 L        1 

转载于:https://www.cnblogs.com/ichunqiu/p/9505971.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值