首页 > 其他分享 >hackthebox format medium walkthrough

hackthebox format medium walkthrough

时间:2023-11-28 11:13:20浏览次数:39  
标签:medium http htb nginx microblog redis hackthebox code walkthrough

walkthough 

1.We must browse the website and look up the business point for the webpage.

at this box we can find the code repository.code auditing and discovering the privilege escalated through the Redis Unix sock vulnerability.

2.After privilege escalating,the new username is pro. Through code auditing, we can find the upload directory location and upload vulnerability.we can write a php script file into box and accomplish remote code execution

nmap collecting message

nmap -sT -p- 10.10.11.213 -oN ports

nmap -sT -pxx -sV -A 10.10.11.213 -oN tcpports

nmap -script=vuln -pxx 10.10.11.213 -oN detialed

发现存在microblog.htb:3000 并没有发现自域名,可以进行一个子域名fuzz

ffuf -u http://microblog.htb -H "Host:FUZZ.microblog.htb" -w dictionary

发现存在app和sunny两个子域名

进行网页端的功能发现

At http://microblog.htb:3000 Discover this website power by gitea and also find code repositories that include the microblog framework.

After code auditing we know that two breakthrough points

1.there is exists upload directory ,but only open for pro user -- the next question is how we can be a pro user 

 2.utilizing redis nginx proxy loophole and hit the location in /etc/nginx/sites-enable/default (the following content is in the /etc/nginx/sites-enable/microblog.htb)

At the 97 line,there is a vulnerability between the redis and nginx routes.

loophole instruction (include two loop)

keyword:redis grammar/nginx route/curl/

location / \/static\/(.*)\/(.*) {  #The first /(.*) as $1 parameter second as $2.
    resolver 127.0.0.1;
    proxy_pass http:\/\/$1.microbucket.htb\/$2;
}

for example, if the url is xxx/static/fisrt/second. the website will redirect to http://first.microbucket.htb/second.

the content above is the correct use of nginx routes analysis. but we can insert redis socket link into the $1 to have the nginx initiate two different requests.

Such as we could insert statement unix:/var/run/redis/redis.sock to link the redis server. and nginx will initiate request for http and unix socket.

Broadly speaking,we using this loop to achieve set user pro is ture through redis statement

but still having snare,How do we insert Unix sockets with so many '/' into nginx syntax that only allows two '/' --the solution is urlencode

since the poc is accomplished

curl -X "HSET" http://microblog.htb/static/unix:%2fvar%2frun%2fredis%2fredis.sock:username%20pro%20true%20/uri

and the response is 502; badgateway means success.

keyword:python format() vulnerability.

vulnerablility study url: https://podalirius.net/en/articles/python-format-string-vulnerabilities/

标签:medium,http,htb,nginx,microblog,redis,hackthebox,code,walkthrough
From: https://www.cnblogs.com/lisenMiller/p/17860083.html

相关文章

  • 华为最高学术成果发表 —— 《Nature》正刊发表论文《Accurate medium-range global w
          论文《Accuratemedium-rangeglobalweatherforecastingwith3Dneuralnetworks》的《Nature》地址:https://www.nature.com/articles/s41586-023-06185-3.pdf   论文的代码地址:https://github.com/198808xc/Pangu-Weather   这篇论文可以......
  • Codeforces Round 904 (Div. 2) C. Medium Design(前缀和+差分)
    CodeforcesRound904(Div.2)C.MediumDesign思路:因为出现的线段应该为不相同的线段,所以最小值应该为\(1\)或\(m\)因此我们可以通过差分储存线段范围内的加值,再用前缀和表示这个范围内的最大加值sl为不包含\(1\)的线段的差分,sr为不包含\(m\)的线段差分记录用于差分的......
  • C. Medium Design
    C.MediumDesignThearray$a_1,a_2,\ldots,a_m$isinitiallyfilledwithzeroes.Youaregiven$n$pairwisedistinctsegments$1\lel_i\ler_i\lem$.Youhavetoselectanarbitrarysubsetofthesesegments(inparticular,youmayselectanempt......
  • CF1884C Medium Design
    思路Step1.贪心拿到题后,第一时间想到贪心,如果这个区间加上会使答案变小或不变就不加。但是很显然,这个贪心是错误的。如果答案的最大值在区间B,但是先加了区间A,导致加区间B使答案不变,那么这样就会使答案变劣。所以贪心是错误的。Step2.枚举接着,想到了可以枚举最小值,如......
  • DVWA CSRF medium
    一、DVWACSRFmedium代码分析if(stripos($_SERVER['HTTP_REFERER'],$_SERVER['SERVER_NAME'])!==false){...}medium添加了对httpreferer头的判断,但只是简单的判断。只要httpreferer头里包服务器域名就可以了。二、实现步骤1、把DVWA部署在127.0.0......
  • hackthebox agile medium
    信息收集portscanningsudonmap--sT--min-rate10000-p-10.10.11.203-oAnmap/agilesudonmap-sT-sC-sV-pxx10.10.11.203-oAnmap/detialbannertellsusit'sanubuntuserverwealsoaddthatdomainto/etc/hostsfile->10.10.11.203superp......
  • hackthebox streamIO
    信息收集端口扫描nmap-sT--min-rate10000-p-10.129.64.95-oAnmap/ports由于端口比较多所以需要对端口进行详细服务的扫描字符操作grepnamp/ports|awk-F'/''{print$1}'|paste-sd','获得nmap需要的端口数据当端口比较多的时候可以将该段数据echo到某个......
  • HackTheBox系列之Unicode
    本次推荐的模拟环境如下:https://www.hackthebox.com/ 本次环境主要涉及Nginx目录遍历、JKU伪造、JWT令牌伪造、命令注入、SUDO提权,目标拿下flag。                     扫描客服微信 获取完整PDF ......
  • 31. 下一个排列 (Medium)
    问题描述31.下一个排列(Medium)整数数组的一个排列就是将其所有成员以序列或线性顺序排列。例如,arr=[1,2,3],以下这些都可以视作arr的排列:[1,2,3]、[1,3,2]、[3,1,2]、[2,3,1]。整数数组的下一个排列是指其整数的下一个字典序更大的排列。更正式地,如果数......
  • 918. Maximum Sum Circular Subarray (Medium)
    Description918.MaximumSumCircularSubarray(Medium)Givenacircularintegerarraynumsoflengthn,returnthemaximumpossiblesumofanon-emptysubarrayofnums.Acirculararraymeanstheendofthearrayconnectstothebeginningofthearray.F......