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?

PicoCTF 2024 Writeup : General Skills

Posted at

最初に

PicoCTF 2024のGeneral Skillsをやっていきます!!

Writeup

全部で10問ですね

image.png

Binary Search

1から1000の範囲が最初に与えられるので、そのちょうど真ん中の500をまずは入力します。
そこで、ランダムに選ばれたtargetが500よりも大きいのか小さいのかが分かります。

実際にやってみた際は、ちいさかったので、範囲が1から500にになるので、次はその範囲のちょうど真ん中の250を入れる。。。というのを正解がでるまで続けます。

以下はやってみた時の出力です。ちょうど10回で答えがでました

Welcome to the Binary Search Game!
I'm thinking of a number between 1 and 1000.
Enter your guess: 500
Lower! Try again.
Enter your guess: 250
Lower! Try again.
Enter your guess: 125
Higher! Try again.
Enter your guess: 187
Higher! Try again.
Enter your guess: 219
Higher! Try again.
Enter your guess: 235
Higher! Try again.
Enter your guess: 242
Lower! Try again.
Enter your guess: 238
Lower! Try again.
Enter your guess: 236
Higher! Try again.
Enter your guess: 237
Congratulations! You guessed the correct number: 237
Here's your flag: picoCTF{g00d_gu355_de9570b0}
Connection to atlas.picoctf.net closed.

Time Machine

message.txtには以下の内容が記載されています

This is what I was working on, but I'd need to look at my commit history to know why...

日本語訳

これは僕が取り組んでいたことなんだけど、その理由はコミット履歴を見ないとわからないんだ......。

.gitフォルダを適当に探っていたら、フラグがありました

Super SSH

与えられた条件でSSH接続したら、フラグが手に入る問題です!

Welcome ctf-player, here's your flag: picoCTF{s3cur3_c0nn3ct10n_8969f7d3}
Connection to titan.picoctf.net closed.

endianness

エンディアンを変換する問題なのですが、与えられたC言語のファイルにリトルエンディアンとビッグエンディアンの変換方法が記載されているので、少しソースコードを変更して、リトルエンディアンとビッグエンディアンを出力するようにすれば、正解できます

ちなみに、今回のように変換プログラムが与えられていない場合は、CyberChefのSwap Endiannessが使えます!

Commitment Issues

いろいろ探してみましたが、Gitを普段使わないこともあり、手がかりがなくなったので、以下のWriteupをみました

なるほど、.gitがあれば、gitコマンドを使うことができるのか!

まずはlogの確認。

┌──(kali㉿kali)-[~/…/GeneralSkill/CommitmentIssues/drop-in/.git]
└─$ git log             
commit e1237df82d2e69f62dd53279abc1c8aeb66f6d64 (HEAD -> master)
Author: picoCTF <ops@picoctf.com>
Date:   Sat Mar 9 21:10:14 2024 +0000

    remove sensitive info

commit 3d5ec8a26ee7b092a1760fea18f384c35e435139
Author: picoCTF <ops@picoctf.com>
Date:   Sat Mar 9 21:10:14 2024 +0000

    create flag

create flagとあるcommitにcheckoutで移動します

┌──(kali㉿kali)-[~/…/picoCTF_2024/GeneralSkill/CommitmentIssues/drop-in]
└─$ git checkout  3d5ec8
Note: switching to '3d5ec8'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 3d5ec8a create flag

ここで、唯一あるテキストファイルを見てみるとフラグがありました!

┌──(kali㉿kali)-[~/…/picoCTF_2024/GeneralSkill/CommitmentIssues/drop-in]
└─$ ls    
message.txt
                                                                                                    
┌──(kali㉿kali)-[~/…/picoCTF_2024/GeneralSkill/CommitmentIssues/drop-in]
└─$ cat message.txt 
picoCTF{s@n1t1z3_30e86d36}

Collaborative Development

問題文は以下

My team has been working very hard on new features for our flag printing program! I wonder how they'll work together?

.git/logs/HEADの中身は以下。
ブランチを3つ作っていますね。。。

0000000000000000000000000000000000000000 5e4b2dae1868abb644627483c78a683286dfe67c picoCTF <ops@picoctf.com> 1710202077 +0000	commit (initial): init flag printer
5e4b2dae1868abb644627483c78a683286dfe67c 5e4b2dae1868abb644627483c78a683286dfe67c picoCTF <ops@picoctf.com> 1710202077 +0000	checkout: moving from main to feature/part-1
5e4b2dae1868abb644627483c78a683286dfe67c 300cff1bf1f64637dd9ff603d90176e8e8bdeb01 picoCTF <ops@picoctf.com> 1710202077 +0000	commit: add part 1
300cff1bf1f64637dd9ff603d90176e8e8bdeb01 5e4b2dae1868abb644627483c78a683286dfe67c picoCTF <ops@picoctf.com> 1710202077 +0000	checkout: moving from feature/part-1 to main
5e4b2dae1868abb644627483c78a683286dfe67c 5e4b2dae1868abb644627483c78a683286dfe67c picoCTF <ops@picoctf.com> 1710202077 +0000	checkout: moving from main to feature/part-2
5e4b2dae1868abb644627483c78a683286dfe67c 74989a4f650d024929388b6788d2b4c214a07e49 picoCTF <ops@picoctf.com> 1710202077 +0000	commit: add part 2
74989a4f650d024929388b6788d2b4c214a07e49 5e4b2dae1868abb644627483c78a683286dfe67c picoCTF <ops@picoctf.com> 1710202077 +0000	checkout: moving from feature/part-2 to main
5e4b2dae1868abb644627483c78a683286dfe67c 5e4b2dae1868abb644627483c78a683286dfe67c picoCTF <ops@picoctf.com> 1710202077 +0000	checkout: moving from main to feature/part-3
5e4b2dae1868abb644627483c78a683286dfe67c 12c2ae89d8035b7a5aa7cd169dc9e93cc68201be picoCTF <ops@picoctf.com> 1710202077 +0000	commit: add part 3
12c2ae89d8035b7a5aa7cd169dc9e93cc68201be 5e4b2dae1868abb644627483c78a683286dfe67c picoCTF <ops@picoctf.com> 1710202077 +0000	checkout: moving from feature/part-3 to main

3つのブランチに移ってflag.pyの中身をみていきます

まず1つ目。

┌──(kali㉿kali)-[~/…/picoCTF_2024/GeneralSkill/CollaborativeDevelopment/drop-in]
└─$ git checkout 300cff1bf1f64637dd9ff603d90176e8e8bdeb01
Note: switching to '300cff1bf1f64637dd9ff603d90176e8e8bdeb01'.

┌──(kali㉿kali)-[~/…/picoCTF_2024/GeneralSkill/CollaborativeDevelopment/drop-in]
└─$ cat flag.py    
print("Printing the flag...")
print("picoCTF{t3@mw0rk_", end='')                                                             

次に2つ目。

┌──(kali㉿kali)-[~/…/picoCTF_2024/GeneralSkill/CollaborativeDevelopment/drop-in]
└─$ git checkout 74989a4f650d024929388b6788d2b4c214a07e49

Previous HEAD position was 300cff1 add part 1
HEAD is now at 74989a4 add part 2
                                                                                                    
┌──(kali㉿kali)-[~/…/picoCTF_2024/GeneralSkill/CollaborativeDevelopment/drop-in]
└─$ ls
flag.py
                                                                                                    
┌──(kali㉿kali)-[~/…/picoCTF_2024/GeneralSkill/CollaborativeDevelopment/drop-in]
└─$ cat flag.py 
print("Printing the flag...")

print("m@k3s_th3_dr3@m_", end='')                                                                   

最後に3つ目。

                                 
┌──(kali㉿kali)-[~/…/picoCTF_2024/GeneralSkill/CollaborativeDevelopment/drop-in]
└─$ git checkout 12c2ae89d8035b7a5aa7cd169dc9e93cc68201be

Previous HEAD position was 74989a4 add part 2
HEAD is now at 12c2ae8 add part 3
                                                                                                    
┌──(kali㉿kali)-[~/…/picoCTF_2024/GeneralSkill/CollaborativeDevelopment/drop-in]
└─$ cat flag.py 
print("Printing the flag...")

print("w0rk_798f9981}")

全部をつなげたらフラグになります!

Blame Game

message.pyは以下だが、カッコが無い、、、、

print("Hello, World!"

/drop-in/.git/logs/HEADの中身をみて、大量のコミットがあって、これ全部見るの無理やな、、、と思っていたら、最初の方にフラグがあった。。。

2dd46769e2d65656bb14aed0ff5d3237daaa7d9d fadeca9476b6713ec8cdda633aca9e9aebffc698 picoCTF{@sk_th3_1nt3rn_e9957ce1} <ops@picoctf.com> 1710018551 +0000	commit: optimize file size of prod code

試しに、親コミットハッシュとコミットハッシュにcheckoutしてみると、確かにこの前後でカッコがなくなっている。。。

┌──(kali㉿kali)-[~/…/picoCTF_2024/GeneralSkill/BlameGame/drop-in]
└─$ git checkout 2dd46769e2d65656bb14aed0ff5d3237daaa7d9d
Note: switching to '2dd46769e2d65656bb14aed0ff5d3237daaa7d9d'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 2dd4676 create top secret project
                                                                                                    
┌──(kali㉿kali)-[~/…/picoCTF_2024/GeneralSkill/BlameGame/drop-in]
└─$ ls
message.py
                                                                                                    
┌──(kali㉿kali)-[~/…/picoCTF_2024/GeneralSkill/BlameGame/drop-in]
└─$ cat message.py 
print("Hello, World!")
                                                                                                    
┌──(kali㉿kali)-[~/…/picoCTF_2024/GeneralSkill/BlameGame/drop-in]
└─$ git checkout fadeca9476b6713ec8cdda633aca9e9aebffc698
Previous HEAD position was 2dd4676 create top secret project
HEAD is now at fadeca9 optimize file size of prod code
                                                                                                    
┌──(kali㉿kali)-[~/…/picoCTF_2024/GeneralSkill/BlameGame/drop-in]
└─$ cat message.py 
print("Hello, World!"

binhexa

2進数とバイナリの演算子がランダムに6つ与えられるので、それを計算していく問題です。

@webshell:~$ nc titan.picoctf.net 57048

Welcome to the Binary Challenge!"
Your task is to perform the unique operations in the given order and find the final result in hexadecimal that yields the flag.

Binary Number 1: 10100001
Binary Number 2: 01100010


Question 1/6:
Operation 1: '>>'
Perform a right shift of Binary Number 2 by 1 bits .
Enter the binary result: 

>>, <<の1ビットシフトはそれぞれ、右と左に数字を一つずらして、ずらした方向と逆側に一つ0を追加します。

*は2進数を一度10進数に直してから、その2つを乗算して、再度2進数にもどせば正解になります!

dont-you-love-banners

Can you abuse the banner?
The server has been leaking some crucial information on tethys.picoctf.net 56268. Use the leaked information to get to the server.
To connect to the running application use nc tethys.picoctf.net 53413. From the above information abuse the machine and find the flag in the /root directory.

問題文に指示のあるようにncをしてみると、パスワードが求められる

┌──(kali㉿kali)-[~/Documents/PicoCTF/picoCTF_2024/GeneralSkill]
└─$ nc tethys.picoctf.net 61217
*************************************
**************WELCOME****************
*************************************

what is the password? 
a
Lol, good try, try again and good luck

今はパスワードがわからないので、nampしてみる

                                                                                                  
┌──(kali㉿kali)-[~/Documents/PicoCTF/picoCTF_2024/GeneralSkill]
└─$ nmap tethys.picoctf.net      
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-07 21:57 JST
Nmap scan report for tethys.picoctf.net (3.140.72.182)
Host is up (0.16s latency).
rDNS record for 3.140.72.182: ec2-3-140-72-182.us-east-2.compute.amazonaws.com
Not shown: 997 closed tcp ports (conn-refused)
PORT     STATE    SERVICE
22/tcp   open     ssh
25/tcp   filtered smtp
1723/tcp filtered pptp

Nmap done: 1 IP address (1 host up) scanned in 13.37 seconds

ポート22が開いていたので、試しにSSHしてみるが、公開鍵での認証が必要そう

                                                                                               
┌──(kali㉿kali)-[~/Documents/PicoCTF/picoCTF_2024/GeneralSkill]
└─$ ssh tethys.picoctf.net 
The authenticity of host 'tethys.picoctf.net (3.140.72.182)' can't be established.
ED25519 key fingerprint is SHA256:rA4y6Yvrkx4AAp1M3VXtP0oR5mKHps8qNYWe9e6Ku2o.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'tethys.picoctf.net' (ED25519) to the list of known hosts.
kali@tethys.picoctf.net: Permission denied (publickey).

先ほどのnmapでは、ncした時に使ったポート番号が出てきていなかったので、再度全ポートをスキャンしてみると、2376ポートでDockerが動いてるみたい

                                                                                             
┌──(kali㉿kali)-[~/Documents/PicoCTF/picoCTF_2024/GeneralSkill]
└─$ nmap tethys.picoctf.net -p 1-65535 -T4
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-07 22:00 JST
Nmap scan report for tethys.picoctf.net (3.140.72.182)
Host is up (0.17s latency).
rDNS record for 3.140.72.182: ec2-3-140-72-182.us-east-2.compute.amazonaws.com
Not shown: 65529 closed tcp ports (conn-refused)
PORT      STATE    SERVICE
22/tcp    open     ssh
25/tcp    filtered smtp
1723/tcp  filtered pptp
2376/tcp  open     docker
61217/tcp open     unknown
64891/tcp open     unknown

念のため、2376番で脆弱性スキャンもしてみたが、脆弱性はなさそう

                                                                                                    
┌──(kali㉿kali)-[~/Documents/PicoCTF/picoCTF_2024/GeneralSkill]
└─$ nmap --script vuln  tethys.picoctf.net -p 2376                
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-07 22:22 JST
Nmap scan report for tethys.picoctf.net (3.140.72.182)
Host is up (0.17s latency).
rDNS record for 3.140.72.182: ec2-3-140-72-182.us-east-2.compute.amazonaws.com

PORT     STATE SERVICE
2376/tcp open  docker

Nmap done: 1 IP address (1 host up) scanned in 16.16 seconds

問題文では、1つ目で別のポートも指示されているので、そちらでアクセスしてみると、パスワードらしき文字列が!

┌──(kali㉿kali)-[~/Documents/PicoCTF/picoCTF_2024/GeneralSkill]
└─$  nc tethys.picoctf.net 56268
SSH-2.0-OpenSSH_7.6p1 My_Passw@rd_@1234

2つ目で指示されているポートでncでアクセスして、上記のパスワードを入れると、いくつかクイズが出されますが、Webで調べたら簡単に出てきます

そして、playerアカウントで入れました!

player@challenge:~$ pwd
pwd
/home/player
player@challenge:~$ ls -la
ls -la
total 20
drwxr-xr-x 1 player player   20 Mar  9  2024 .
drwxr-xr-x 1 root   root     20 Mar  9  2024 ..
-rw-r--r-- 1 player player  220 Apr  4  2018 .bash_logout
-rw-r--r-- 1 player player 3771 Apr  4  2018 .bashrc
-rw-r--r-- 1 player player  807 Apr  4  2018 .profile
-rw-r--r-- 1 player player  114 Feb  7  2024 banner
-rw-r--r-- 1 root   root     13 Feb  7  2024 text

2つファイルがあるので、中身を見ておきます。
textの中身は、、、まあ深い意味はなさそうです。。

player@challenge:~$ cat banner
cat banner
*************************************
**************WELCOME****************
*************************************
player@challenge:~$ cat text
cat text
keep digging

念のため、SUIDビットがたっているファイルを探しておきます

player@challenge:~$ find / -perm -u=s -type f 2>/dev/null
find / -perm -u=s -type f 2>/dev/null
/bin/mount
/bin/su
/bin/umount
/usr/bin/chfn
/usr/bin/chsh
/usr/bin/gpasswd
/usr/bin/newgrp
/usr/bin/passwd
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/lib/openssh/ssh-keysign

/usr/lib/dbus-1.0/dbus-daemon-launch-helperという見かけないものがあったので見てみると、実行ファイルみたい

player@challenge:/usr/lib/dbus-1.0$ file dbus-daemon-launch-helper
file dbus-daemon-launch-helper
dbus-daemon-launch-helper: setuid 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]=fc1f39bcd43f3b8c3d4d4f3cac99b25848bfc412, stripped

ただ、実行してみても権限がなくて使えないですね。。。。

player@challenge:/usr/lib/dbus-1.0$ ./dbus-daemon-launch-helper
./dbus-daemon-launch-helper
-su: ./dbus-daemon-launch-helper: Permission denied

少し、フォルダーの階層を上がっていくと/rootに入れることに気が付きました。。。。

player@challenge:/$ ls -la
ls -la
total 4
drwxr-xr-x   1 root   root      29 Jan  8 11:15 .
drwxr-xr-x   1 root   root      29 Jan  8 11:15 ..
-rwxr-xr-x   1 root   root       0 Jan  8 11:15 .dockerenv
drwxr-xr-x   1 root   root    4096 Mar  9  2024 bin
drwxr-xr-x   2 root   root       6 Apr 24  2018 boot
d---------   1 root   root      42 Mar 12  2024 challenge
drwxr-xr-x   5 root   root     340 Jan  8 11:15 dev
drwxr-xr-x   1 root   root      66 Jan  8 11:15 etc
drwxr-xr-x   1 root   root      20 Mar  9  2024 home
drwxr-xr-x   1 root   root      86 Mar  9  2024 lib
drwxr-xr-x   2 root   root      34 May 30  2023 lib64
drwxr-xr-x   2 root   root       6 May 30  2023 media
drwxr-xr-x   2 root   root       6 May 30  2023 mnt
drwxr-xr-x   2 root   root       6 May 30  2023 opt
dr-xr-xr-x 230 nobody nogroup    0 Jan  8 11:15 proc
drwxr-xr-x   1 root   root       6 Mar 12  2024 root
drwxr-xr-x   1 root   root      22 Jan  8 11:15 run
drwxr-xr-x   1 root   root      25 Jan  8 11:15 sbin
drwxr-xr-x   2 root   root       6 May 30  2023 srv
dr-xr-xr-x  13 nobody nogroup    0 Jan  8 11:15 sys
drwxrwxrwt   1 root   root       6 Mar  9  2024 tmp
drwxr-xr-x   1 root   root      18 May 30  2023 usr
drwxr-xr-x   1 root   root      17 May 30  2023 var

今のユーザーでは確認のできないflag.txtと、最初のログイン制御をしていると思われるscript.pyがあります

player@challenge:/$ cd root
cd root
player@challenge:/root$ ls -la
ls -la
total 16
drwxr-xr-x 1 root root    6 Mar 12  2024 .
drwxr-xr-x 1 root root   29 Jan  8 11:15 ..
-rw-r--r-- 1 root root 3106 Apr  9  2018 .bashrc
-rw-r--r-- 1 root root  148 Aug 17  2015 .profile
-rwx------ 1 root root   46 Mar 12  2024 flag.txt
-rw-r--r-- 1 root root 1317 Feb  7  2024 script.py
player@challenge:/root$ cat flag.txt
cat flag.txt
cat: flag.txt: Permission denied
player@challenge:/root$ cat script.py
cat script.py

import os
import pty

incorrect_ans_reply = "Lol, good try, try again and good luck\n"

if __name__ == "__main__":
    try:
      with open("/home/player/banner", "r") as f:
        print(f.read())
    except:
      print("*********************************************")
      print("***************DEFAULT BANNER****************")
      print("*Please supply banner in /home/player/banner*")
      print("*********************************************")

try:
    request = input("what is the password? \n").upper()
    while request:
        if request == 'MY_PASSW@RD_@1234':
            text = input("What is the top cyber security conference in the world?\n").upper()
            if text == 'DEFCON' or text == 'DEF CON':
                output = input(
                    "the first hacker ever was known for phreaking(making free phone calls), who was it?\n").upper()
                if output == 'JOHN DRAPER' or output == 'JOHN THOMAS DRAPER' or output == 'JOHN' or output== 'DRAPER':
                    scmd = 'su - player'
                    pty.spawn(scmd.split(' '))

                else:
                    print(incorrect_ans_reply)
            else:
                print(incorrect_ans_reply)
        else:
            print(incorrect_ans_reply)
            break

except:
    KeyboardInterrupt

このscript.pyをroot権限で書き換えるのか?と思って、SUIDビットの立っているファイルを探したりしていたが、うまくいかず、、、、

以下のWriteupを見てみると、シンボリックリンクを作成するとのこと、、

既存の/home/player/bannerを削除して、/root/flag.txtを指す/home/player/bannerのシンボリックリンクを作成するのか。。。

player@challenge:/root$ ln -s /root/flag.txt /home/player/banner

/home/playerls- laをしてみるとシンボリックが作成できている。

player@challenge:~$ ls -la 
ls -la
total 16
drwxr-xr-x 1 player player   20 Jan  8 12:10 .
drwxr-xr-x 1 root   root     20 Mar  9  2024 ..
-rw-r--r-- 1 player player  220 Apr  4  2018 .bash_logout
-rw-r--r-- 1 player player 3771 Apr  4  2018 .bashrc
-rw-r--r-- 1 player player  807 Apr  4  2018 .profile
lrwxrwxrwx 1 player player   14 Jan  8 12:10 banner -> /root/flag.txt
-rw-r--r-- 1 root   root     13 Feb  7  2024 text

この状態で再度、問題文にあるncの
コマンドでアクセスすると、フラグが表示されます!

SansAlpha


This system has been minimized by removing packages and content that are
not required on a system that users do not log into.

To restore this content, you can run the 'unminimize' command.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

このシステムは、ユーザがログインしないシステムで不要なパッケージやコンテン ツを削除することで最小化されている。
このコンテンツを復元するには、「unminimize」コマンドを実行します。
Ubuntuシステムに含まれるプログラムはフリーソフトウェアです。各プログラムの正確な配布条件は、/usr/share/doc//copyrightにある個々のファイルに記載されています。
各プログラムの正確な配布条件は、/usr/share/doc/
/copyright内の各ファイルに記載されています。Ubuntuには、適用される法律で許可される限りにおいて、一切の保証がありません。

適当にコマンドを入れても、SansAlpha: Unknown character detectedしか出力がないが、Ctrl+Cを押すと、Pythonの実行エラーが。。。


SansAlpha$ pwd
SansAlpha: Unknown character detected
SansAlpha$ ls
SansAlpha: Unknown character detected
SansAlpha$ unminimize
SansAlpha: Unknown character detected
SansAlpha$ cd
SansAlpha: Unknown character detected
SansAlpha$ cd /usr/share/doc
SansAlpha: Unknown character detected
SansAlpha$ quit
SansAlpha: Unknown character detected
SansAlpha$ 
Traceback (most recent call last):
 File "/usr/local/lib/python3.8/dist-packages/pwnlib/term/readline.py", line 397, in readline
   keymap.handle_input()
 File "/usr/local/lib/python3.8/dist-packages/pwnlib/term/keymap.py", line 24, in handle_input
   self.send(key.get())
 File "/usr/local/lib/python3.8/dist-packages/pwnlib/term/key.py", line 175, in get
   _read(timeout)
 File "/usr/local/lib/python3.8/dist-packages/pwnlib/term/key.py", line 163, in _read
   _cbuf.extend(getraw(timeout))
 File "/usr/local/lib/python3.8/dist-packages/pwnlib/term/key.py", line 40, in getraw
   c = getch(timeout)
 File "/usr/local/lib/python3.8/dist-packages/pwnlib/term/key.py", line 26, in getch
   rfds, _wfds, _xfds = select.select([_fd], [], [], timeout)
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "/usr/local/sansalpha.py", line 11, in <module>
   user_in = input("SansAlpha$ ")
 File "/usr/local/lib/python3.8/dist-packages/pwnlib/term/readline.py", line 448, in str_input
   return readline(-1, prompt, float).decode()
 File "/usr/local/lib/python3.8/dist-packages/pwnlib/term/readline.py", line 409, in readline
   control_c()
 File "/usr/local/lib/python3.8/dist-packages/pwnlib/term/readline.py", line 261, in control_c
   raise KeyboardInterrupt
KeyboardInterrupt
Connection to mimas.picoctf.net closed.

$をいれたら、Bashが動いた!

SansAlpha$ $
bash: $: command not found
                                                                                                    
┌──(kali㉿kali)-[~/Documents/PicoCTF/picoCTF_2024/GeneralSkill]
└─$ nmap mimas.picoctf.net -p- -T4
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-08 21:40 JST
Nmap scan report for mimas.picoctf.net (52.15.88.75)
Host is up (0.16s latency).
rDNS record for 52.15.88.75: ec2-52-15-88-75.us-east-2.compute.amazonaws.com
Not shown: 65527 closed tcp ports (conn-refused)
PORT      STATE    SERVICE
22/tcp    open     ssh
25/tcp    filtered smtp
1723/tcp  filtered pptp
2376/tcp  open     docker
49775/tcp open     unknown
52048/tcp open     unknown
62159/tcp open     unknown
63612/tcp open     unknown

Nmap done: 1 IP address (1 host up) scanned in 770.21 seconds

開いているポートすべてにアクセスしてみたが、手ごたえ無。。。

                                                                                           
┌──(kali㉿kali)-[~/Documents/PicoCTF/picoCTF_2024/GeneralSkill]
└─$ nc mimas.picoctf.net -p 49775 
no port[s] to connect to
                                                                                                    
┌──(kali㉿kali)-[~/Documents/PicoCTF/picoCTF_2024/GeneralSkill]
└─$ nc mimas.picoctf.net 49775   
^C
                                                                                                    
┌──(kali㉿kali)-[~/Documents/PicoCTF/picoCTF_2024/GeneralSkill]
└─$ nc mimas.picoctf.net 52048
mimas.picoctf.net [52.15.88.75] 52048 (?) : Connection refused
                                                                                                    
┌──(kali㉿kali)-[~/Documents/PicoCTF/picoCTF_2024/GeneralSkill]
└─$ nc mimas.picoctf.net 62159
mimas.picoctf.net [52.15.88.75] 62159 (?) : Connection refused
                                                                                                    
┌──(kali㉿kali)-[~/Documents/PicoCTF/picoCTF_2024/GeneralSkill]
└─$ nc mimas.picoctf.net 63612
SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.11

Invalid SSH identification string.
                                                                                                    
┌──(kali㉿kali)-[~/Documents/PicoCTF/picoCTF_2024/GeneralSkill]
└─$ ssh -p 22 mimas.picoctf.net             
The authenticity of host 'mimas.picoctf.net (52.15.88.75)' can't be established.
ED25519 key fingerprint is SHA256:B51OwUMjcDpHlE9Z+YELZKVw/y1e32B9ddTjcvWkKpg.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'mimas.picoctf.net' (ED25519) to the list of known hosts.
kali@mimas.picoctf.net: Permission denied (publickey).

わからなくなったので、Writeupを見てみると、記号だけでShellは操作できるんですね、、、

うーん、これだけではよくわからない

別のWriteupで以下を見てみた

/???とすれば、3文字のディレクトリを一つ選んで出力するのか。。。

SansAlpha$ /???
bash: /bin: Is a directory

SansAlpha$ /????
bash: /boot: Is a directory

SansAlpha$ /???
bash: /bin: Is a directory

ちなみにKali Linux のコンソールでも試してみたけど同じ感じでした!

┌──(kali㉿kali)-[~]
└─$ /???                             
zsh: permission denied: /bin

Writeupの内容を参考にlsを作っていく
まずはl(これのlはなぜか上手くいかないんですが、、、)

SansAlpha$ /?????/
bash: /lib32/: Is a directory

SansAlpha$ _1=/?????/

続いて、s


SansAlpha$ /???/???/
bash: /dev/pts/: Is a directory

SansAlpha$ _2=/???/???/

_1_2から、それぞれlsを抜き出したが、なぜかlだけ抜き出せず、、、、

SansAlpha$ ${_1:1:1}${_2:7:1}
bash: ?s: command not found

原因不明なので、Writeupのものをもってきました。。。

SansAlpha$ ____=(/???/?????/???)

SansAlpha$ ${____:6:1}${_2:7:1}
blargh    on-calastran.txt

lsが実行できたので、次はcatでファイルの中身をみていきます

SansAlpha$ ${____:5:1}${____:7:1}${_2:6:1} *
cat: blargh: Is a directory
The Calastran multiverse is a(以下略。。。)

blarghはディレクトリのようなので、lsをし直します

SansAlpha$ ${____:6:1}${_2:7:1} *
on-calastran.txt

blargh:
flag.txt  on-alpha-9.txt

flag.txtがあった!!

一つ下の階層をcatすると、中身が見れました!

SansAlpha$ ${____:5:1}${____:7:1}${_2:6:1} */*
return 0 picoCTF{7h15_mu171v3r53_15_m4dn355_4945630a}Alpha-9, a distinctive layer within the Calastran multiverse, stands as a
sanctuary realm offering individuals a rare opportunity for rebirth and
introspection. Positioned as a serene refuge bet

最後に

今回学んだことは以下です!

  • .gitフォルダーがあれば、gitコマンドが使える
  • ファイルパスを指定している場合、シンボリックリンクを作成することで、ほかのファイルを指定させることができる
  • 普段使っているTerminalも自分の知らない使い方がある
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?