OverTheWire-Bandit游戏
城南花已开 Lv5

Level 0

第零关的密码是bandit0,获取到第一关的密码是ZjLjTmM6FvvyRnrb2rfNWOZOTa6ip5If

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
 ⚡maple ❯❯ ssh  [email protected] -p 2220
_ _ _ _
| |__ __ _ _ __ __| (_) |_
| '_ \ / _` | '_ \ / _` | | __|
| |_) | (_| | | | | (_| | | |_
|_.__/ \__,_|_| |_|\__,_|_|\__|


This is an OverTheWire game server.
More information on http://www.overthewire.org/wargames

[email protected]'s password:

,----.. ,----, .---.
/ / \ ,/ .`| /. ./|
/ . : ,` .' : .--'. ' ;
. / ;. \ ; ; / /__./ \ : |
. ; / ` ; .'___,/ ,' .--'. ' \' .
; | ; \ ; | | : | /___/ \ | ' '
| : | ; | ' ; |.'; ; ; \ \; :
. | ' ' ' : `----' | | \ ; ` |
' ; \; / | ' : ; . \ .\ ;
\ \ ', / | | ' \ \ ' \ |
; : / ' : | : ' |--"
\ \ .' ; |.' \ \ ;
www. `---` ver '---' he '---" ire.org


Welcome to OverTheWire!

If you find any problems, please report them to the #wargames channel on
discord or IRC.

--[ Playing the games ]--

This machine might hold several wargames.
If you are playing "somegame", then:

* USERNAMES are somegame0, somegame1, ...
* Most LEVELS are stored in /somegame/.
* PASSWORDS for each level are stored in /etc/somegame_pass/.

Write-access to homedirectories is disabled. It is advised to create a
working directory with a hard-to-guess name in /tmp/. You can use the
command "mktemp -d" in order to generate a random and hard to guess
directory in /tmp/. Read-access to both /tmp/ is disabled and to /proc
restricted so that users cannot snoop on eachother. Files and directories
with easily guessable or short names will be periodically deleted! The /tmp
directory is regularly wiped.
Please play nice:

* don't leave orphan processes running
* don't leave exploit-files laying around
* don't annoy other players
* don't post passwords or spoilers
* again, DONT POST SPOILERS!
This includes writeups of your solution on your blog or website!

--[ Tips ]--

This machine has a 64bit processor and many security-features enabled
by default, although ASLR has been switched off. The following
compiler flags might be interesting:

-m32 compile for 32bit
-fno-stack-protector disable ProPolice
-Wl,-z,norelro disable relro

In addition, the execstack tool can be used to flag the stack as
executable on ELF binaries.

Finally, network-access is limited for most levels by a local
firewall.

--[ Tools ]--

For your convenience we have installed a few useful tools which you can find
in the following locations:

* gef (https://github.com/hugsy/gef) in /opt/gef/
* pwndbg (https://github.com/pwndbg/pwndbg) in /opt/pwndbg/
* gdbinit (https://github.com/gdbinit/Gdbinit) in /opt/gdbinit/
* pwntools (https://github.com/Gallopsled/pwntools)
* radare2 (http://www.radare.org/)

--[ More information ]--

For more information regarding individual wargames, visit
http://www.overthewire.org/wargames/

For support, questions or comments, contact us on discord or IRC.

Enjoy your stay!

bandit0@bandit:~$ ls
readme
bandit0@bandit:~$ cat readme
Congratulations on your first steps into the bandit game!!
Please make sure you have read the rules at https://overthewire.org/rules/
If you are following a course, workshop, walkthrough or other educational activity,
please inform the instructor about the rules as well and encourage them to
contribute to the OverTheWire community so we can keep these games free!

The password you are looking for is: ZjLjTmM6FvvyRnrb2rfNWOZOTa6ip5If

Level 1

263JGJPfgU6LtdEvgfWU1XP5yac29mFx,切关卡不能用su也不能内部ssh只能退出重连ssh

所以我利用powershell脚本方便一点连接ssh "[email protected]" -p 2220

直接执行 ⚡maple ❯❯ .\bandit.ps1 关卡数就行了

三种方式任选其一

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 ⚡maple ❯❯ ssh  [email protected] -p 2220
_ _ _ _
| |__ __ _ _ __ __| (_) |_
| '_ \ / _` | '_ \ / _` | | __|
| |_) | (_| | | | | (_| | | |_
|_.__/ \__,_|_| |_|\__,_|_|\__|


This is an OverTheWire game server.
More information on http://www.overthewire.org/wargames

[email protected]'s password:
bandit1@bandit:~$ cat < -
263JGJPfgU6LtdEvgfWU1XP5yac29mFx
bandit1@bandit:~$ cat ./-
263JGJPfgU6LtdEvgfWU1XP5yac29mFx
bandit1@bandit:~$ more -
263JGJPfgU6LtdEvgfWU1XP5yac29mFx
bandit1@bandit:~$ rev -|rev
263JGJPfgU6LtdEvgfWU1XP5yac29mFx

Level 2

MNk8KNH3Usiio41PRUEoDFPqfxLPlSmx,前面实在是比较基础没啥好说的,就是文件名中有空格加个转义即可,你按Tab补全自动会转义的

1
2
3
4
5
6
7
8
9
10
bandit2@bandit:~$ ls -al
total 24
drwxr-xr-x 2 root root 4096 Sep 19 07:08 .
drwxr-xr-x 70 root root 4096 Sep 19 07:09 ..
-rw-r--r-- 1 root root 220 Mar 31 2024 .bash_logout
-rw-r--r-- 1 root root 3771 Mar 31 2024 .bashrc
-rw-r--r-- 1 root root 807 Mar 31 2024 .profile
-rw-r----- 1 bandit3 bandit2 33 Sep 19 07:08 spaces in this filename
bandit2@bandit:~$ cat spaces\ in\ this\ filename
MNk8KNH3Usiio41PRUEoDFPqfxLPlSmx

Level 3

2WmrDFRmJIq3IPxneAaMGhap0pFhF3NJ感觉这些是针对于刚学Linux的小白

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
bandit3@bandit:~$  ls -al
total 24
drwxr-xr-x 3 root root 4096 Sep 19 07:08 .
drwxr-xr-x 70 root root 4096 Sep 19 07:09 ..
-rw-r--r-- 1 root root 220 Mar 31 2024 .bash_logout
-rw-r--r-- 1 root root 3771 Mar 31 2024 .bashrc
drwxr-xr-x 2 root root 4096 Sep 19 07:08 inhere
-rw-r--r-- 1 root root 807 Mar 31 2024 .profile
bandit3@bandit:~$ cd inhere/
bandit3@bandit:~/inhere$ ls -al
total 12
drwxr-xr-x 2 root root 4096 Sep 19 07:08 .
drwxr-xr-x 3 root root 4096 Sep 19 07:08 ..
-rw-r----- 1 bandit4 bandit3 33 Sep 19 07:08 ...Hiding-From-You
bandit3@bandit:~/inhere$ cat ...Hiding-From-You
2WmrDFRmJIq3IPxneAaMGhap0pFhF3NJ

Level 4

4oQYVPkxZOOEOO5pTW81FB8j8lxXGUQw,写个循环读取目录中所有文件

1
2
3
4
5
6
7
8
bandit4@bandit:~/inhere$ for i in *;do cat <$i;done
�p��&�y�,�(jo�.at�:uf�^���@i�R�,�Λ�:Y���?�%�A����B��ͩ�3� �)Ʈ�#Y��-6c��IR-�$����:�����/�
������qGi��,�2�Yb�
dۙ�rOx����h0~ey
��c�~�h�n��G1}���ߓ��ߤ��W>��#lk�d�ܮ��yE��6�0]�\�$�1�%�������o@��b/��4oQYVPkxZOOEOO5pTW81FB8j8lxXGUQw
�nS�
�<��]�
W��e�˥m�����O��D��2g��?�����`>5HYA�u���8�g�`0�$`��

或者

1
2
3
4
5
6
7
8
9
10
11
12
13
bandit4@bandit:~/inhere$ file ./*
./-file00: data
./-file01: data
./-file02: data
./-file03: data
./-file04: data
./-file05: data
./-file06: data
./-file07: ASCII text
./-file08: data
./-file09: data
bandit4@bandit:~/inhere$ cat ./-file07
4oQYVPkxZOOEOO5pTW81FB8j8lxXGUQw

Level 5

HWasnPhtq9AVKe0dmk45nxy20cvUa6EG

原来每一关还有题目提示的image

1
2
3
4
5
bandit5@bandit:~/inhere$ find . -type f -size 1033c -exec file {} \;
./maybehere07/.file2: ASCII text, with very long lines (1000)
bandit5@bandit:~/inhere$ cat ./maybehere07/.file2
HWasnPhtq9AVKe0dmk45nxy20cvUa6EG
......省略

Level 6

The password for the next level is stored somewhere on the server and has all of the following properties:
下一级的密码存储在服务器上的某个位置,并具有以下所有属性:

  • owned by user bandit7 由用户 bandit7 拥有
  • owned by group bandit6 归bandit 6组所有
  • 33 bytes in size 大小为 33 字节

morbNTDkSW6jIlUc0ymOdMaLnOlFVAaj

直接find加参数搜索即可

1
2
3
4
bandit6@bandit:~$ find / -user bandit7 -group bandit6 -size 33c 2>/dev/null
/var/lib/dpkg/info/bandit7.password
bandit6@bandit:~$ cat /var/lib/dpkg/info/bandit7.password
morbNTDkSW6jIlUc0ymOdMaLnOlFVAaj

Level 7

The password for the next level is stored in the file data.txt next to the word millionth
下一级的密码存储在文件data.txtmillionth单词旁边

dfwvzFQi4mU0wfNbFOe9RoWskMLg7eEc

1
2
bandit7@bandit:~$ cat data.txt | grep millionth
millionth dfwvzFQi4mU0wfNbFOe9RoWskMLg7eEc

Level 8

The password for the next level is stored in the file data.txt and is the only line of text that occurs only once
下一级的密码存储在文件data.txt中,并且是唯一只出现一次的文本行

4CKMh1JI91bUIZZPXDqGanal4xvAg0JMsort排序后再用uniq去重即可

1
2
bandit8@bandit:~$ cat data.txt |sort |uniq -u
4CKMh1JI91bUIZZPXDqGanal4xvAg0JM

Level 9

The password for the next level is stored in the file data.txt in one of the few human-readable strings, preceded by several ‘=’ characters.
下一级的密码存储在文件data.txt中,位于少数几个人类可读的字符串之一中,前面有几个“=”字符。

FGUW5ilLVJrxX9kMYMmlN4MgbpfMiqeystring查看加grep筛选

1
2
3
4
5
bandit9@bandit:~$ strings data.txt |grep "=="
}========== the
3JprD========== passwordi
~fDV3========== is
D9========== FGUW5ilLVJrxX9kMYMmlN4MgbpfMiqey

Level 10

The password for the next level is stored in the file data.txt, which contains base64 encoded data
下一级的密码存储在文件data.txt中,其中包含base64编码的数据

dtR173fZKb0RRsDFSGsg2RWnpNVj3qRr,实在是没啥好讲的

1
2
bandit10@bandit:~$ cat data.txt |base64 -d
The password is dtR173fZKb0RRsDFSGsg2RWnpNVj3qRr

Level 11

The password for the next level is stored in the file data.txt, where all lowercase (a-z) and uppercase (A-Z) letters have been rotated by 13 positions
下一级的密码存储在文件data.txt中,其中所有小写 (az) 和大写 (AZ) 字母均已旋转 13 个位置

7x16WNeHIi5YkIhWsfFIqoognUTyj9Q4,很明显的ROT13加密,可以用在线网站但是也可以利用tr替换一下

1
2
bandit11@bandit:~$ cat data.txt |tr "A-Za-z" "N-ZA-Mn-za-m"
The password is 7x16WNeHIi5YkIhWsfFIqoognUTyj9Q4

‘A-Za-z’ 表示所有的英文字母,包括大写和小写

‘N-ZA-Mn-za-m’ 是一个替换字符串,数13位字母可以得到

其中’A-Z’对应替换’N-ZA-M’

‘a-z’对应替换为’n-za-m’

Level 12

The password for the next level is stored in the file data.txt, which is a hexdump of a file that has been repeatedly compressed. For this level it may be useful to create a directory under /tmp in which you can work. Use mkdir with a hard to guess directory name. Or better, use the command “mktemp -d”. Then copy the datafile using cp, and rename it using mv (read the manpages!)
下一级的密码存储在文件data.txt中,该文件是经过反复压缩的文件的十六进制转储。对于此级别,在 /tmp 下创建一个可以在其中工作的目录可能会很有用。使用 mkdir 和难以猜测的目录名。或者更好的是,使用命令“mktemp -d”。然后使用 cp 复制数据文件,并使用 mv 重命名它(阅读手册页!)

FO5dwFsc0cbaIiH0h8J2eUks2vdTDwAn

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
bandit12@bandit:/$ mktemp -d
/tmp/tmp.kMCRHiv7fo
bandit12@bandit:/$ cd /tmp/tmp.kMCRHiv7fo
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ cp ~/data.txt .
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ ls
data.txt
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ cat data.txt
00000000: 1f8b 0808 dfcd eb66 0203 6461 7461 322e .......f..data2.
00000010: 6269 6e00 013e 02c1 fd42 5a68 3931 4159 bin..>...BZh91AY
00000020: 2653 59ca 83b2 c100 0017 7fff dff3 f4a7 &SY.............
00000030: fc9f fefe f2f3 cffe f5ff ffdd bf7e 5bfe .............~[.
00000040: faff dfbe 97aa 6fff f0de edf7 b001 3b56 ......o.......;V
00000050: 0400 0034 d000 0000 0069 a1a1 a000 0343 ...4.....i.....C
00000060: 4686 4341 a680 068d 1a69 a0d0 0068 d1a0 F.CA.....i...h..
00000070: 1906 1193 0433 5193 d4c6 5103 4646 9a34 .....3Q...Q.FF.4
00000080: 0000 d320 0680 0003 264d 0346 8683 d21a ... ....&M.F....
00000090: 0686 8064 3400 0189 a683 4fd5 0190 001e ...d4.....O.....
000000a0: 9034 d188 0343 0e9a 0c40 69a0 0626 4686 .4...C...@i..&F.
000000b0: 8340 0310 d340 3469 a680 6800 0006 8d0d .@[email protected].....
000000c0: 0068 0608 0d1a 64d3 469a 1a68 c9a6 8030 .h....d.F..h...0
000000d0: 9a68 6801 8101 3204 012a ca60 51e8 1cac .hh...2..*.`Q...
000000e0: 532f 0b84 d4d0 5db8 4e88 e127 2921 4c8e S/....].N..')!L.
000000f0: b8e6 084c e5db 0835 ff85 4ffc 115a 0d0c ...L...5..O..Z..
00000100: c33d 6714 0121 5762 5e0c dbf1 aef9 b6a7 .=g..!Wb^.......
00000110: 23a6 1d7b 0e06 4214 01dd d539 af76 f0b4 #..{..B....9.v..
00000120: a22f 744a b61f a393 3c06 4e98 376f dc23 ./tJ....<.N.7o.#
00000130: 45b1 5f23 0d8f 640b 3534 de29 4195 a7c6 E._#..d.54.)A...
00000140: de0c 744f d408 4a51 dad3 e208 189b 0823 ..tO..JQ.......#
00000150: 9fcc 9c81 e58c 9461 9dae ce4a 4284 1706 .......a...JB...
00000160: 61a3 7f7d 1336 8322 cd59 e2b5 9f51 8d99 a..}.6.".Y...Q..
00000170: c300 2a9d dd30 68f4 f9f6 7db6 93ea ed9a ..*..0h...}.....
00000180: dd7c 891a 1221 0926 97ea 6e05 9522 91f1 .|...!.&..n.."..
00000190: 7bd3 0ba4 4719 6f37 0c36 0f61 02ae dea9 {...G.o7.6.a....
000001a0: b52f fc46 9792 3898 b953 36c4 c247 ceb1 ./.F..8..S6..G..
000001b0: 8a53 379f 4831 52a3 41e9 fa26 9d6c 28f4 .S7.H1R.A..&.l(.
000001c0: 24ea e394 651d cb5c a96c d505 d986 da22 $...e..\.l....."
000001d0: 47f4 d58b 589d 567a 920b 858e a95c 63c1 G...X.Vz.....\c.
000001e0: 2509 612c 5364 8e7d 2402 808e 9b60 02b4 %.a,Sd.}$....`..
000001f0: 13c7 be0a 1ae3 1400 4796 4370 efc0 9b43 ........G.Cp...C
00000200: a4cb 882a 4aae 4b81 abf7 1c14 67f7 8a34 ...*J.K.....g..4
00000210: 0867 e5b6 1df6 b0e8 8023 6d1c 416a 28d0 .g.......#m.Aj(.
00000220: c460 1604 bba3 2e52 297d 8788 4e30 e1f9 .`.....R)}..N0..
00000230: 2646 8f5d 3062 2628 c94e 904b 6754 3891 &F.]0b&(.N.KgT8.
00000240: 421f 4a9f 9feb 2ec9 83e2 c20f fc5d c914 B.J..........]..
00000250: e142 432a 0ecb 0459 1b15 923e 0200 00 .BC*...Y...>...
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ xxd -r data.txt data
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ ls
data data.txt
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ file data
data: gzip compressed data, was "data2.bin", last modified: Thu Sep 19 07:08:15 2024, max compression, from Unix, original size modulo 2^32 574

发现是个十六进制转储文件可以利用xxd -r还原为原文件,发现是个gzip压缩包

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ mv data data.gz
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ gzip -d data.gz
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ cat data
BZh91AY&SYʃ�����������������ݿ~[���߾��o������;V4�i���CF�CA���␦i��hѠ�3Q���QFF�4� �&MF���␦��d4���O���4шC�
␦d�F�␦hɦ�0�hh�2*�`Q��S/ @i�&F��@�@4i��h�
���]�N��')!L��L�5��O�Z
�=g!Wb^
�d �����#�{B��9�v�/tJ���<N�7o�#E�_#
54�)A����
tOJQ��#�̜�匔a���JB�a�}6�"�YⵟQ���*��0h���}�����|�␦! &��n�"��{�
�Go7
6a�ީ�/�F��8��S6��Gα�S7�H1R�A��&�l(�$��e�\�l�ن�"G�ՋX�Vz�
���\c�% a,Sd�}$���`�Ǿ
␦�G�Cp���C�ˈ*J�K���g��g����#mAj(��`��.R)}��N0��&F�]0b&(�N�KgT8�BJ���.Ƀ���]��BC*�
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ file data
data: bzip2 compressed data, block size = 900k

解压后发现是个套娃,里面是个bzip压缩包

1
2
3
4
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ mv data 1.bz2
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ bzip2 -d 1.bz2
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ file 1
1: gzip compressed data, was "data4.bin", last modified: Thu Sep 19 07:08:15 2024, max compression, from Unix, original size modulo 2^32 20480

里面又是个gzip文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ mv 1 2.gz
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ gzip -d 2.gz
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ file 2
2: POSIX tar archive (GNU)
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ mv 2 3.tar
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ tar -xvf 3.tar
data5.bin
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ file data5.bin
data5.bin: POSIX tar archive (GNU)
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ mv data5.bin 4.tar
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ tar -xvf 4.tar
data6.bin
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ file data6.bin
data6.bin: bzip2 compressed data, block size = 900k
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ mv data6.bin 5.bz2
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ bzip2 -d 5.bz2
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ file 5
5: POSIX tar archive (GNU)
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ mv 5 5.tar
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ tar -xvf 5.tar
data8.bin
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ file data8.bin
data8.bin: gzip compressed data, was "data9.bin", last modified: Thu Sep 19 07:08:15 2024, max compression, from Unix, original size modulo 2^32 49
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ mv data8.bin 6.gz
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ gzip -d 6.gz
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ file 6
6: ASCII text
bandit12@bandit:/tmp/tmp.kMCRHiv7fo$ cat 6
The password is FO5dwFsc0cbaIiH0h8J2eUks2vdTDwAn

恶心👿,一直套娃其实有脚本就更好了

Level 13

The password for the next level is stored in /etc/bandit_pass/bandit14 and can only be read by user bandit14. For this level, you don’t get the next password, but you get a private SSH key that can be used to log into the next level. Note: localhost is a hostname that refers to the machine you are working on
下一级的密码存储在**/etc/bandit_pass/bandit14 中,并且只能由用户 bandit14 读取。对于此级别,您不会获得下一个密码,但您会获得可用于登录下一个级别的 SSH 私钥。注意:** localhost是指您正在使用的计算机的主机名

MU4VWeTyJk8ROof1qqmcBPaLh7lDCPvS,登入后可得到密码

直接给了私钥,通过私钥连接即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
bandit13@bandit:~$ ls
sshkey.private
bandit13@bandit:~$ cat sshkey.private
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAxkkOE83W2cOT7IWhFc9aPaaQmQDdgzuXCv+ppZHa++buSkN+
gg0tcr7Fw8NLGa5+Uzec2rEg0WmeevB13AIoYp0MZyETq46t+jk9puNwZwIt9XgB
ZufGtZEwWbFWw/vVLNwOXBe4UWStGRWzgPpEeSv5Tb1VjLZIBdGphTIK22Amz6Zb
ThMsiMnyJafEwJ/T8PQO3myS91vUHEuoOMAzoUID4kN0MEZ3+XahyK0HJVq68KsV
ObefXG1vvA3GAJ29kxJaqvRfgYnqZryWN7w3CHjNU4c/2Jkp+n8L0SnxaNA+WYA7
jiPyTF0is8uzMlYQ4l1Lzh/8/MpvhCQF8r22dwIDAQABAoIBAQC6dWBjhyEOzjeA
J3j/RWmap9M5zfJ/wb2bfidNpwbB8rsJ4sZIDZQ7XuIh4LfygoAQSS+bBw3RXvzE
pvJt3SmU8hIDuLsCjL1VnBY5pY7Bju8g8aR/3FyjyNAqx/TLfzlLYfOu7i9Jet67
xAh0tONG/u8FB5I3LAI2Vp6OviwvdWeC4nOxCthldpuPKNLA8rmMMVRTKQ+7T2VS
nXmwYckKUcUgzoVSpiNZaS0zUDypdpy2+tRH3MQa5kqN1YKjvF8RC47woOYCktsD
o3FFpGNFec9Taa3Msy+DfQQhHKZFKIL3bJDONtmrVvtYK40/yeU4aZ/HA2DQzwhe
ol1AfiEhAoGBAOnVjosBkm7sblK+n4IEwPxs8sOmhPnTDUy5WGrpSCrXOmsVIBUf
laL3ZGLx3xCIwtCnEucB9DvN2HZkupc/h6hTKUYLqXuyLD8njTrbRhLgbC9QrKrS
M1F2fSTxVqPtZDlDMwjNR04xHA/fKh8bXXyTMqOHNJTHHNhbh3McdURjAoGBANkU
1hqfnw7+aXncJ9bjysr1ZWbqOE5Nd8AFgfwaKuGTTVX2NsUQnCMWdOp+wFak40JH
PKWkJNdBG+ex0H9JNQsTK3X5PBMAS8AfX0GrKeuwKWA6erytVTqjOfLYcdp5+z9s
8DtVCxDuVsM+i4X8UqIGOlvGbtKEVokHPFXP1q/dAoGAcHg5YX7WEehCgCYTzpO+
xysX8ScM2qS6xuZ3MqUWAxUWkh7NGZvhe0sGy9iOdANzwKw7mUUFViaCMR/t54W1
GC83sOs3D7n5Mj8x3NdO8xFit7dT9a245TvaoYQ7KgmqpSg/ScKCw4c3eiLava+J
3btnJeSIU+8ZXq9XjPRpKwUCgYA7z6LiOQKxNeXH3qHXcnHok855maUj5fJNpPbY
iDkyZ8ySF8GlcFsky8Yw6fWCqfG3zDrohJ5l9JmEsBh7SadkwsZhvecQcS9t4vby
9/8X4jS0P8ibfcKS4nBP+dT81kkkg5Z5MohXBORA7VWx+ACohcDEkprsQ+w32xeD
qT1EvQKBgQDKm8ws2ByvSUVs9GjTilCajFqLJ0eVYzRPaY6f++Gv/UVfAPV4c+S0
kAWpXbv5tbkkzbS0eaLPTKgLzavXtQoTtKwrjpolHKIHUz6Wu+n4abfAIRFubOdN
/+aLoRQ0yBDRbdXMsZN/jvY44eM+xRLdRVyMmdPtP8belRi2E2aEzA==
-----END RSA PRIVATE KEY-----

Level 14

The password for the next level can be retrieved by submitting the password of the current level to port 30000 on localhost.
将当前级别的密码提交到localhost 的 30000 端口即可获取下一级的密码。

8xCjnmgoKbGLhHFAZlGE5Tmu4M2tKJQo,通过nc连上端口即可

1
2
3
4
5
6
7
##先看一下上一题登入14关的密码
bandit14@bandit:~$ cat /etc/bandit_pass/bandit14
MU4VWeTyJk8ROof1qqmcBPaLh7lDCPvS
bandit14@bandit:~$ nc localhost 30000
MU4VWeTyJk8ROof1qqmcBPaLh7lDCPvS
Correct!
8xCjnmgoKbGLhHFAZlGE5Tmu4M2tKJQo

Level 15

The password for the next level can be retrieved by submitting the password of the current level to port 30001 on localhost using SSL/TLS encryption.
可以通过使用 SSL/TLS 加密将当前级别的密码提交到localhost 上的端口 30001来检索下一级的密码。

Helpful note: Getting “DONE”, “RENEGOTIATING” or “KEYUPDATE”? Read the “CONNECTED COMMANDS” section in the manpage.
有用的注释:“完成”、“重新协商”或“密钥更新”?阅读联机帮助页中的“连接命令”部分。

kSkvUpMQ7lBYyCM4GBPvCvT1BfWRy0Dx

题目要求使用SSL连接,那就利用openssl中的s_client客户端来连接30001端口输入当前密码即可

1
2
3
4
5
6
7
8
9
10
bandit16@bandit:~$ openssl s_client -quiet -connect localhost:30001
Can't use SSL_get_servername
depth=0 CN = SnakeOil
verify error:num=18:self-signed certificate
verify return:1
depth=0 CN = SnakeOil
verify return:1
8xCjnmgoKbGLhHFAZlGE5Tmu4M2tKJQo
Correct!
kSkvUpMQ7lBYyCM4GBPvCvT1BfWRy0Dx
  • openssl s_client:这是调用OpenSSL客户端工具的命令。
  • -quiet-q:减少输出信息,使输出更加简洁。
  • -connect:这个参数告诉s_client工具我们想要连接到一个服务器。
  • localhost:30001:这是服务器的地址和端口号。localhost指的是本机地址,30001是服务器监听的端口号。

Level 16

The credentials for the next level can be retrieved by submitting the password of the current level to a port on localhost in the range 31000 to 32000. First find out which of these ports have a server listening on them. Then find out which of those speak SSL/TLS and which don’t. There is only 1 server that will give the next credentials, the others will simply send back to you whatever you send to it.
可以通过将当前级别的密码提交到本地主机上 31000 到 32000 范围内的端口来检索下一个级别的凭据。首先找出服务器正在监听哪些端口。然后找出哪些支持 SSL/TLS,哪些不支持。只有一台服务器会提供下一个凭据,其他服务器只会将您发送给它的任何内容发送回给您。

Helpful note: Getting “DONE”, “RENEGOTIATING” or “KEYUPDATE”? Read the “CONNECTED COMMANDS” section in the manpage.
有用的注释:“完成”、“重新协商”或“密钥更新”?阅读联机帮助页中的“连接命令”部分。

EReVavePLFHtFlFsjn3hyzMlvSuSAcRD

我们先根据:为分隔后打印输出流到grep筛选出31000-32000之间开放的端口

然后依次尝试,第一个31790就出来了,拿到私钥连接即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
bandit16@bandit:~$ ss -lntp |awk -F ':' '{print$2}'|awk '{print $1}'|grep -P "31\d{3}"
31790
31518
31960
31046
31691
bandit16@bandit:~$ openssl s_client -quiet -connect localhost:31790
Can't use SSL_get_servername
depth=0 CN = SnakeOil
verify error:num=18:self-signed certificate
verify return:1
depth=0 CN = SnakeOil
verify return:1
kSkvUpMQ7lBYyCM4GBPvCvT1BfWRy0Dx
Correct!
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAvmOkuifmMg6HL2YPIOjon6iWfbp7c3jx34YkYWqUH57SUdyJ
imZzeyGC0gtZPGujUSxiJSWI/oTqexh+cAMTSMlOJf7+BrJObArnxd9Y7YT2bRPQ
Ja6Lzb558YW3FZl87ORiO+rW4LCDCNd2lUvLE/GL2GWyuKN0K5iCd5TbtJzEkQTu
DSt2mcNn4rhAL+JFr56o4T6z8WWAW18BR6yGrMq7Q/kALHYW3OekePQAzL0VUYbW
JGTi65CxbCnzc/w4+mqQyvmzpWtMAzJTzAzQxNbkR2MBGySxDLrjg0LWN6sK7wNX
x0YVztz/zbIkPjfkU1jHS+9EbVNj+D1XFOJuaQIDAQABAoIBABagpxpM1aoLWfvD
KHcj10nqcoBc4oE11aFYQwik7xfW+24pRNuDE6SFthOar69jp5RlLwD1NhPx3iBl
J9nOM8OJ0VToum43UOS8YxF8WwhXriYGnc1sskbwpXOUDc9uX4+UESzH22P29ovd
d8WErY0gPxun8pbJLmxkAtWNhpMvfe0050vk9TL5wqbu9AlbssgTcCXkMQnPw9nC
YNN6DDP2lbcBrvgT9YCNL6C+ZKufD52yOQ9qOkwFTEQpjtF4uNtJom+asvlpmS8A
vLY9r60wYSvmZhNqBUrj7lyCtXMIu1kkd4w7F77k+DjHoAXyxcUp1DGL51sOmama
+TOWWgECgYEA8JtPxP0GRJ+IQkX262jM3dEIkza8ky5moIwUqYdsx0NxHgRRhORT
8c8hAuRBb2G82so8vUHk/fur85OEfc9TncnCY2crpoqsghifKLxrLgtT+qDpfZnx
SatLdt8GfQ85yA7hnWWJ2MxF3NaeSDm75Lsm+tBbAiyc9P2jGRNtMSkCgYEAypHd
HCctNi/FwjulhttFx/rHYKhLidZDFYeiE/v45bN4yFm8x7R/b0iE7KaszX+Exdvt
SghaTdcG0Knyw1bpJVyusavPzpaJMjdJ6tcFhVAbAjm7enCIvGCSx+X3l5SiWg0A
R57hJglezIiVjv3aGwHwvlZvtszK6zV6oXFAu0ECgYAbjo46T4hyP5tJi93V5HDi
Ttiek7xRVxUl+iU7rWkGAXFpMLFteQEsRr7PJ/lemmEY5eTDAFMLy9FL2m9oQWCg
R8VdwSk8r9FGLS+9aKcV5PI/WEKlwgXinB3OhYimtiG2Cg5JCqIZFHxD6MjEGOiu
L8ktHMPvodBwNsSBULpG0QKBgBAplTfC1HOnWiMGOU3KPwYWt0O6CdTkmJOmL8Ni
blh9elyZ9FsGxsgtRBXRsqXuz7wtsQAgLHxbdLq/ZJQ7YfzOKU4ZxEnabvXnvWkU
YOdjHdSOoKvDQNWu6ucyLRAWFuISeXw9a/9p7ftpxm0TSgyvmfLF2MIAEwyzRqaM
77pBAoGAMmjmIJdjp+Ez8duyn3ieo36yrttF5NSsJLAbxFpdlc1gvtGCWW+9Cq0b
dxviW8+TFVEBl1O4f7HVm6EpTscdDxU+bCXWkfjuRb7Dy9GOtt9JPsX8MBTakzh3
vBgsyi/sN3RqRBcGU40fOoZyfAMT8s1m/uYv52O6IgeuZ/ujbjY=
-----END RSA PRIVATE KEY-----

Level 17

There are 2 files in the homedirectory: passwords.old and passwords.new. The password for the next level is in passwords.new and is the only line that has been changed between passwords.old and passwords.new
主目录中有2个文件: passwords.old和passwords.new 。下一级的密码位于passwords.new中,并且是passwords.old 和password.new之间唯一已更改的行

NOTE: if you have solved this level and see ‘Byebye!’ when trying to log into bandit18, this is related to the next level, bandit19
注意:如果您已解决此级别并看到“再见!”当尝试登录 bandit18 时,这与下一个级别 bandit19 有关

x2gLTTjFwMOhQ8oWNbMN362QKxfRqGlO

利用diff比较即可,下面一行就是更改后的新密码

1
2
3
4
5
6
7
8
9
10
##先看一下上一题登入17关的密码
bandit17@bandit:~$ cat /etc/bandit_pass/bandit17
EReVavePLFHtFlFsjn3hyzMlvSuSAcRD
bandit17@bandit:~$ ls
passwords.new passwords.old
bandit17@bandit:~$ diff passwords.old passwords.new
42c42
< ktfgBvpMzWKR5ENj26IbLGSblgUG9CzB
---
> x2gLTTjFwMOhQ8oWNbMN362QKxfRqGlO

Level 18

The password for the next level is stored in a file readme in the homedirectory. Unfortunately, someone has modified .bashrc to log you out when you log in with SSH.
下一级的密码存储在主目录的自述文件中。不幸的是,有人修改了**.bashrc** ,以便在您使用 SSH 登录时将您注销。

cGWpMaKXVwDUNgPAVJbWYuGHVn9zl3j8

不过当我ssh登入后即可显示Byebye,根据提示看17关的描述

-t分配一个伪终端即可,不然登入会自动执行.bashrc从而断开连接

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
⚡maple ❯❯ ssh  [email protected] -p 2220 -t /bin/sh
_ _ _ _
| |__ __ _ _ __ __| (_) |_
| '_ \ / _` | '_ \ / _` | | __|
| |_) | (_| | | | | (_| | | |_
|_.__/ \__,_|_| |_|\__,_|_|\__|


This is an OverTheWire game server.
More information on http://www.overthewire.org/wargames

[email protected]'s password:
$ ls
readme
$ cat readme
cGWpMaKXVwDUNgPAVJbWYuGHVn9zl3j8

Level 19

To gain access to the next level, you should use the setuid binary in the homedirectory. Execute it without arguments to find out how to use it. The password for this level can be found in the usual place (/etc/bandit_pass), after you have used the setuid binary.
要访问下一个级别,您应该使用主目录中的 setuid 二进制文件。不带参数执行它以了解如何使用它。使用 setuid 二进制文件后,可以在通常的位置 (/etc/bandit_pass) 找到此级别的密码。

0qXahG8ZjOVMN9Ghs7iOWsCfZyXOUbYO

bandit20-do具有SUID权限,直接读取密码即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
bandit19@bandit:~$ ls -al
total 36
drwxr-xr-x 2 root root 4096 Sep 19 07:08 .
drwxr-xr-x 70 root root 4096 Sep 19 07:09 ..
-rwsr-x--- 1 bandit20 bandit19 14880 Sep 19 07:08 bandit20-do
-rw-r--r-- 1 root root 220 Mar 31 2024 .bash_logout
-rw-r--r-- 1 root root 3771 Mar 31 2024 .bashrc
-rw-r--r-- 1 root root 807 Mar 31 2024 .profile
bandit19@bandit:~$ ./bandit20-do
Run a command as another user.
Example: ./bandit20-do id
bandit19@bandit:~$ ./bandit20-do id
uid=11019(bandit19) gid=11019(bandit19) euid=11020(bandit20) groups=11019(bandit19)
bandit19@bandit:~$ ./bandit20-do cat /etc/bandit_pass/bandit20
0qXahG8ZjOVMN9Ghs7iOWsCfZyXOUbYO

当一个普通用户执行一个设置了SUID权限的程序时,该程序会以文件所有者的权限运行,而不是以执行用户的权限运行。这意味着如果一个程序的所有者是root,那么即使普通用户执行该程序,它也会以root的权限运行。

Level 20

There is a setuid binary in the homedirectory that does the following: it makes a connection to localhost on the port you specify as a commandline argument. It then reads a line of text from the connection and compares it to the password in the previous level (bandit20). If the password is correct, it will transmit the password for the next level (bandit21).
主目录中有一个 setuid 二进制文件,它执行以下操作:它在您指定为命令行参数的端口上建立到本地主机的连接。然后,它从连接中读取一行文本,并将其与上一级别 (bandit20) 中的密码进行比较。如果密码正确,则会传送下一级(bandit21)的密码。

NOTE: Try connecting to your own network daemon to see if it works as you think
注意:尝试连接到您自己的网络守护程序,看看它是否按您的想法工作

EeoULMCra2q0dSkYj561DX7s1CpBuOBt

利用nc创建一个新的端口,将echo的数据管道给nc加个&保持在后台运行

1
2
3
4
5
6
7
8
9
bandit20@bandit:~$ echo -n "0qXahG8ZjOVMN9Ghs7iOWsCfZyXOUbYO" |nc -l -p 23333 &
[1] 282778
bandit20@bandit:~$ jobs
[1]+ Running echo -n "0qXahG8ZjOVMN9Ghs7iOWsCfZyXOUbYO" | nc -l -p 23333 &
bandit20@bandit:~$ ./suconnect 23333
Read: 0qXahG8ZjOVMN9Ghs7iOWsCfZyXOUbYO
Password matches, sending next password
EeoULMCra2q0dSkYj561DX7s1CpBuOBt
[1]+ Done echo -n "0qXahG8ZjOVMN9Ghs7iOWsCfZyXOUbYO" | nc -l -p 23333

Level 21

A program is running automatically at regular intervals from cron, the time-based job scheduler. Look in /etc/cron.d/ for the configuration and see what command is being executed.
程序从基于时间的作业调度程序cron定期自动运行。查看**/etc/cron.d/**中的配置并查看正在执行什么命令。

tRae0UfB9v0UzbCdn9cY0gQnds9GF58Q

查看定时脚本,发现会将bandit22的密码写入/tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv文件中,并且权限为644

直接读取即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
bandit21@bandit:~$ cat /etc/cron.d/cronjob_bandit22
@reboot bandit22 /usr/bin/cronjob_bandit22.sh &> /dev/null
* * * * * bandit22 /usr/bin/cronjob_bandit22.sh &> /dev/null
bandit21@bandit:~$ ls -al /usr/bin/cronjob_bandit22.sh
-rwxr-x--- 1 bandit22 bandit21 130 Sep 19 07:08 /usr/bin/cronjob_bandit22.sh
bandit21@bandit:~$ cat /usr/bin/cronjob_bandit22.sh
#!/bin/bash
chmod 644 /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv
cat /etc/bandit_pass/bandit22 > /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv
bandit21@bandit:~$ bash /usr/bin/cronjob_bandit22.sh
chmod: changing permissions of '/tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv': Operation not permitted
/usr/bin/cronjob_bandit22.sh: line 3: /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv: Permission denied
bandit21@bandit:~$ cat /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv
tRae0UfB9v0UzbCdn9cY0gQnds9GF58Q

Level 22

A program is running automatically at regular intervals from cron, the time-based job scheduler. Look in /etc/cron.d/ for the configuration and see what command is being executed.
程序从基于时间的作业调度程序cron定期自动运行。查看**/etc/cron.d/**中的配置并查看正在执行什么命令。

NOTE: This level requires you to create your own first shell-script. This is a very big step and you should be proud of yourself when you beat this level!
注意:此级别要求您创建自己的第一个 shell 脚本。这是非常大的一步,当你通过这个关卡时,你应该为自己感到自豪!

NOTE 2: Keep in mind that your shell script is removed once executed, so you may want to keep a copy around…
注意 2:请记住,您的 shell 脚本一旦执行就会被删除,因此您可能需要保留一份副本……

0Zf11ioIjMVN551jX3CmStKLYqjk54Ga

环境变量劫持即可,将whoami手动改为bandit23

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
bandit22@bandit:~$ cat /etc/cron.d/cronjob_bandit23
@reboot bandit23 /usr/bin/cronjob_bandit23.sh &> /dev/null
* * * * * bandit23 /usr/bin/cronjob_bandit23.sh &> /dev/null
bandit22@bandit:~$ cat /usr/bin/cronjob_bandit23.sh
#!/bin/bash

myname=$(whoami)
mytarget=$(echo I am user $myname | md5sum | cut -d ' ' -f 1)

echo "Copying passwordfile /etc/bandit_pass/$myname to /tmp/$mytarget"

cat /etc/bandit_pass/$myname > /tmp/$mytarget
bandit22@bandit:~$ mktemp -d
/tmp/tmp.QluJTD9nqr
bandit22@bandit:~$ cd /tmp/tmp.QluJTD9nqr
bandit22@bandit:/tmp/tmp.QluJTD9nqr$ echo -n "echo -n 'bandit23'">whoami
bandit22@bandit:/tmp/tmp.QluJTD9nqr$ chmod +x whoami
bandit22@bandit:/tmp/tmp.QluJTD9nqr$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
bandit22@bandit:/tmp/tmp.QluJTD9nqr$ export PATH=/tmp/tmp.QluJTD9nqr:$PATH
bandit22@bandit:/tmp/tmp.QluJTD9nqr$ whoami
bandit23
bandit22@bandit:/tmp/tmp.QluJTD9nqr$ bash /usr/bin/cronjob_bandit23.sh
Copying passwordfile /etc/bandit_pass/bandit23 to /tmp/8ca319486bfbbc3663ea0fbe81326349
/usr/bin/cronjob_bandit23.sh: line 8: /tmp/8ca319486bfbbc3663ea0fbe81326349: Permission denied
bandit22@bandit:/tmp/tmp.QluJTD9nqr$ cat /tmp/8ca319486bfbbc3663ea0fbe81326349
0Zf11ioIjMVN551jX3CmStKLYqjk54Ga

亦或者,用户bandit23会定期执行/usr/bin/cronjob_bandit23.sh脚本,那我们不知道最后写入的文件名,直接按照脚本上的命令改一下不就完了

1
2
3
4
bandit22@bandit:~$ echo I am user bandit23 | md5sum | cut -d ' ' -f 1
8ca319486bfbbc3663ea0fbe81326349
bandit22@bandit:~$ cat /tmp/8ca319486bfbbc3663ea0fbe81326349
0Zf11ioIjMVN551jX3CmStKLYqjk54Ga

Level 23

A program is running automatically at regular intervals from cron, the time-based job scheduler. Look in /etc/cron.d/ for the configuration and see what command is being executed.
程序从基于时间的作业调度程序cron定期自动运行。查看**/etc/cron.d/**中的配置并查看正在执行什么命令。

NOTE: This level requires you to create your own first shell-script. This is a very big step and you should be proud of yourself when you beat this level!
注意:此级别要求您创建自己的第一个 shell 脚本。这是非常大的一步,当你通过这个关卡时,你应该为自己感到自豪!

NOTE 2: Keep in mind that your shell script is removed once executed, so you may want to keep a copy around…
注意 2:请记住,您的 shell 脚本一旦执行就会被删除,因此您可能需要保留一份副本……

gb8KRRCsshuZXI0tUuR6ypOFjiZbf3G8

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
bandit23@bandit:~$ cat /usr/bin/cronjob_bandit24.sh .
#!/bin/bash

myname=$(whoami)

cd /var/spool/$myname/foo
echo "Executing and deleting all scripts in /var/spool/$myname/foo:"
for i in * .*;
do
if [ "$i" != "." -a "$i" != ".." ];
then
echo "Handling $i"
owner="$(stat --format "%U" ./$i)"
if [ "${owner}" = "bandit23" ]; then
timeout -s 9 60 ./$i
fi
rm -f ./$i
fi
done

  1. myname=$(whoami):获取当前用户的用户名,并将其存储在变量myname中。
  2. cd /var/spool/$myname/foo:切换到/var/spool/目录下,该目录包含当前用户名的子目录foo
  3. echo "Executing and deleting all scripts in /var/spool/$myname/foo:":打印一条消息,告知用户脚本将执行并删除/var/spool/$myname/foo目录下的所有脚本。
  4. for i in * .*;:开始一个循环,遍历当前目录下的所有文件和隐藏文件(包括以点开头的文件)。
  5. if [ "$i" != "." -a "$i" != ".." ];:检查当前文件是否不是.(当前目录)和..(上级目录)。
  6. echo "Handling $i":打印正在处理的文件名。
  7. owner="$(stat --format "%U" ./$i)":使用stat命令获取当前文件的所有者,并将其存储在变量owner中。
  8. if [ "${owner}" = "bandit23" ];:检查文件的所有者是否为bandit23
  9. timeout -s 9 60 ./$i:如果文件的所有者是bandit23,则使用timeout命令执行该文件,允许它运行最多60秒,如果脚本运行超过60秒,则会发送信号9(SIGKILL)强制终止它。
  10. fi:结束if语句块。
  11. rm -f ./$i:无论文件是否被执行,都会删除当前文件。
  12. done:结束for循环。

那直接写个脚本让定时任务自动执行就ok了

1
2
3
4
5
6
7
8
9
10
11
12
13
bandit23@bandit:/var/spool/bandit24/foo$ mktemp -d
/tmp/tmp.TycjbImAaV
bandit23@bandit:/var/spool/bandit24/foo$ cd /tmp/tmp.TycjbImAaV
bandit23@bandit:/tmp/tmp.TycjbImAaV$ touch password
bandit23@bandit:/tmp/tmp.TycjbImAaV$ chmod 777 password
bandit23@bandit:/tmp/tmp.TycjbImAaV$ chmod 777 /tmp/tmp.TycjbImAaV
bandit23@bandit:/tmp/tmp.TycjbImAaV$ vim 1.sh
#!/bin/bash
cat /etc/bandit_pass/bandit24 > /tmp/tmp.TycjbImAaV/password
bandit23@bandit:/tmp/tmp.TycjbImAaV$ chmod +x 1.sh
bandit23@bandit:/tmp/tmp.TycjbImAaV$ cp 1.sh /var/spool/bandit24/foo
bandit23@bandit:/tmp/tmp.TycjbImAaV$ cat password
gb8KRRCsshuZXI0tUuR6ypOFjiZbf3G8

Level 24

A daemon is listening on port 30002 and will give you the password for bandit25 if given the password for bandit24 and a secret numeric 4-digit pincode. There is no way to retrieve the pincode except by going through all of the 10000 combinations, called brute-forcing.
守护进程正在侦听端口 30002,并将为您提供密码 bandit25(如果给定 bandit24 的密码和秘密数字 4 位 pincode)。 除非遍历所有 10000 个密码,否则无法检索 pin 码 组合,称为暴力破解。
You do not need to create new connections each time
您不需要每次都创建新连接

iCi86ttT4KSNe1armKiwbQNmB3YJP3q4

写个循环脚本,跑一下就完事了,注意一下bandit24和四位数字之间有空格

1
2
3
4
bandit24@bandit:~$ i=0;while [ $i -le 9999 ];do echo  "gb8KRRCsshuZXI0tUuR6ypOFjiZbf3G8 "$i;i=$((i+1));done|nc localhost 30002
................省略了错误密码
Correct!
The password of user bandit25 is iCi86ttT4KSNe1armKiwbQNmB3YJP3q4

Level 25

Logging in to bandit26 from bandit25 should be fairly easy… The shell for user bandit26 is not /bin/bash, but something else. Find out what it is, how it works and how to break out of it.
从 bandit25 登录 bandit26 应该相当容易……用户 bandit26 的 shell 不是**/bin/bash** ,而是其他东西。了解它是什么、它是如何工作的以及如何摆脱它。

NOTE: if you’re a Windows user and typically use Powershell to ssh into bandit: Powershell is known to cause issues with the intended solution to this level. You should use command prompt instead.
注意:如果您是 Windows 用户并且通常使用 Powershell 来ssh到 bandit:已知 Powershell 会导致此级别的预期解决方案出现问题。您应该使用命令提示符。

s0773xxkk0MXfdqOfPRVr9L3jJBUOgCZ

有个私钥文件尝试直接连接

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
bandit25@bandit:~$ ls
bandit26.sshkey
bandit25@bandit:~$ cat bandit26.sshkey
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEApis2AuoooEqeYWamtwX2k5z9uU1Afl2F8VyXQqbv/LTrIwdW
pTfaeRHXzr0Y0a5Oe3GB/+W2+PReif+bPZlzTY1XFwpk+DiHk1kmL0moEW8HJuT9
/5XbnpjSzn0eEAfFax2OcopjrzVqdBJQerkj0puv3UXY07AskgkyD5XepwGAlJOG
xZsMq1oZqQ0W29aBtfykuGie2bxroRjuAPrYM4o3MMmtlNE5fC4G9Ihq0eq73MDi
1ze6d2jIGce873qxn308BA2qhRPJNEbnPev5gI+5tU+UxebW8KLbk0EhoXB953Ix
3lgOIrT9Y6skRjsMSFmC6WN/O7ovu8QzGqxdywIDAQABAoIBAAaXoETtVT9GtpHW
qLaKHgYtLEO1tOFOhInWyolyZgL4inuRRva3CIvVEWK6TcnDyIlNL4MfcerehwGi
il4fQFvLR7E6UFcopvhJiSJHIcvPQ9FfNFR3dYcNOQ/IFvE73bEqMwSISPwiel6w
e1DjF3C7jHaS1s9PJfWFN982aublL/yLbJP+ou3ifdljS7QzjWZA8NRiMwmBGPIh
Yq8weR3jIVQl3ndEYxO7Cr/wXXebZwlP6CPZb67rBy0jg+366mxQbDZIwZYEaUME
zY5izFclr/kKj4s7NTRkC76Yx+rTNP5+BX+JT+rgz5aoQq8ghMw43NYwxjXym/MX
c8X8g0ECgYEA1crBUAR1gSkM+5mGjjoFLJKrFP+IhUHFh25qGI4Dcxxh1f3M53le
wF1rkp5SJnHRFm9IW3gM1JoF0PQxI5aXHRGHphwPeKnsQ/xQBRWCeYpqTme9amJV
tD3aDHkpIhYxkNxqol5gDCAt6tdFSxqPaNfdfsfaAOXiKGrQESUjIBcCgYEAxvmI
2ROJsBXaiM4Iyg9hUpjZIn8TW2UlH76pojFG6/KBd1NcnW3fu0ZUU790wAu7QbbU
i7pieeqCqSYcZsmkhnOvbdx54A6NNCR2btc+si6pDOe1jdsGdXISDRHFb9QxjZCj
6xzWMNvb5n1yUb9w9nfN1PZzATfUsOV+Fy8CbG0CgYEAifkTLwfhqZyLk2huTSWm
pzB0ltWfDpj22MNqVzR3h3d+sHLeJVjPzIe9396rF8KGdNsWsGlWpnJMZKDjgZsz
JQBmMc6UMYRARVP1dIKANN4eY0FSHfEebHcqXLho0mXOUTXe37DWfZza5V9Oify3
JquBd8uUptW1Ue41H4t/ErsCgYEArc5FYtF1QXIlfcDz3oUGz16itUZpgzlb71nd
1cbTm8EupCwWR5I1j+IEQU+JTUQyI1nwWcnKwZI+5kBbKNJUu/mLsRyY/UXYxEZh
ibrNklm94373kV1US/0DlZUDcQba7jz9Yp/C3dT/RlwoIw5mP3UxQCizFspNKOSe
euPeaxUCgYEAntklXwBbokgdDup/u/3ms5Lb/bm22zDOCg2HrlWQCqKEkWkAO6R5
/Wwyqhp/wTl8VXjxWo+W+DmewGdPHGQQ5fFdqgpuQpGUq24YZS8m66v5ANBwd76t
IZdtF5HXs2S5CADTwniUS5mX1HO9l5gUkk+h0cH5JnPtsMCnAUM+BRY=
-----END RSA PRIVATE KEY-----

发现连接后也会直接退出,我们先回来,看一下26用的什么shell

1
2
3
4
5
6
7
8
9
bandit25@bandit:~$ cat /etc/passwd|grep bandit26
bandit26:x:11026:11026:bandit level 26:/home/bandit26:/usr/bin/showtext
bandit25@bandit:~$ cat /usr/bin/showtext
#!/bin/sh

export TERM=linux

exec more ~/text.txt
exit 0

可以看到使用了more命令读取了用户bandit26家目录下的text.txt文件然后再执行的退出

这里切换到cmd终端再通过ssh连接,不过在此之前需要将终端到很小,这样more显示不下的内容会停住,就有了一个交互模式按v再设置shell为bash,输入:set shell=/bin/bash然后再 :shell

或者之间利用more进行文件读取:e /etc/bandit\_pass/bandit26,即可获得密码

Level 26

Good job getting a shell! Now hurry and grab the password for bandit27!
干得好,得到一个外壳!现在赶快获取 bandit27 的密码吧!

upsNCc7vzaRDx6oZC6GiR6ERwe1MowGB

通过上一题拿到26关的shell后就送分了,有个SUID权限的文件,以bandit27的身份执行命令即可

1
2
3
4
5
6
7
8
9
10
11
12
bandit26@bandit:~$ ls -al
total 44
drwxr-xr-x 3 root root 4096 Sep 19 07:08 .
drwxr-xr-x 70 root root 4096 Sep 19 07:09 ..
-rwsr-x--- 1 bandit27 bandit26 14880 Sep 19 07:08 bandit27-do
-rw-r--r-- 1 root root 220 Mar 31 2024 .bash_logout
-rw-r--r-- 1 root root 3771 Mar 31 2024 .bashrc
-rw-r--r-- 1 root root 807 Mar 31 2024 .profile
drwxr-xr-x 2 root root 4096 Sep 19 07:08 .ssh
-rw-r----- 1 bandit26 bandit26 258 Sep 19 07:08 text.txt
bandit26@bandit:~$ ./bandit27-do cat /etc/bandit_pass/bandit27
upsNCc7vzaRDx6oZC6GiR6ERwe1MowGB

Level 27

There is a git repository at ssh://bandit27-git@localhost/home/bandit27-git/repo via the port 2220. The password for the user bandit27-git is the same as for the user bandit27.
有一个 git 存储库位于 ssh://bandit27-git@localhost/home/bandit27-git/repo 通过端口2220 。用户bandit27-git的密码与用户bandit27的密码相同。

Clone the repository and find the password for the next level.
克隆存储库并找到下一级的密码。

Yz9IpL0sBcCeuG7m9uQFt8ZNpS4HZRcN

1
2
3
4
5
6
7
8
9
10
11
bandit27@bandit:~$ mktemp -d
/tmp/tmp.lwdDNwWWpv
bandit27@bandit:~$ cd /tmp/tmp.lwdDNwWWpv
bandit27@bandit:/tmp/tmp.lwdDNwWWpv$ git clone ssh://bandit27-git@localhost:2220/home/bandit27-git/repo
bandit27@bandit:/tmp/tmp.lwdDNwWWpv$ ls
repo
bandit27@bandit:/tmp/tmp.lwdDNwWWpv$ cd repo/
bandit27@bandit:/tmp/tmp.lwdDNwWWpv/repo$ ls
README
bandit27@bandit:/tmp/tmp.lwdDNwWWpv/repo$ cat README
The password to the next level is: Yz9IpL0sBcCeuG7m9uQFt8ZNpS4HZRcN

Level 28

There is a git repository at ssh://bandit28-git@localhost/home/bandit28-git/repo via the port 2220. The password for the user bandit28-git is the same as for the user bandit28.
有一个 git 存储库位于 ssh://bandit28-git@localhost/home/bandit28-git/repo 通过端口2220 。用户bandit28-git的密码与用户bandit28的密码相同。

Clone the repository and find the password for the next level.
克隆存储库并找到下一级的密码。

4pT1t5DENaYuqnqvadYs1oE4QLCdjmJ7

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
bandit28@bandit:~$ mktemp -d
/tmp/tmp.tqJ1scDFzf
bandit28@bandit:~$ cd /tmp/tmp.tqJ1scDFzf
bandit28@bandit:/tmp/tmp.tqJ1scDFzf$ git clone ssh://bandit28-git@localhost:2220/home/bandit28-git/repo
Cloning into 'repo'...
The authenticity of host '[localhost]:2220 ([127.0.0.1]:2220)' can't be established.
ED25519 key fingerprint is SHA256:C2ihUBV7ihnV1wUXRb4RrEcLfXC5CXlhmAAM/urerLY.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Could not create directory '/home/bandit28/.ssh' (Permission denied).
Failed to add the host to the list of known hosts (/home/bandit28/.ssh/known_hosts).
_ _ _ _
| |__ __ _ _ __ __| (_) |_
| '_ \ / _` | '_ \ / _` | | __|
| |_) | (_| | | | | (_| | | |_
|_.__/ \__,_|_| |_|\__,_|_|\__|


This is an OverTheWire game server.
More information on http://www.overthewire.org/wargames

bandit28-git@localhost's password:
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 9 (delta 2), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (9/9), done.
Resolving deltas: 100% (2/2), done.
bandit28@bandit:/tmp/tmp.tqJ1scDFzf$ ls
repo
bandit28@bandit:/tmp/tmp.tqJ1scDFzf$ cd repo/
bandit28@bandit:/tmp/tmp.tqJ1scDFzf/repo$ ls
README.md
bandit28@bandit:/tmp/tmp.tqJ1scDFzf/repo$ cat README.md
# Bandit Notes
Some notes for level29 of bandit.

## credentials

- username: bandit29
- password: xxxxxxxxxx

git分布式版本控制系统,既然是版本控制那当然可以还原到原先的版本了,先查看log之前的commit

再用reset命令还原到HEAD^上一个版本,具体看下廖雪峰老师的博客很详细

也可以使用show查看当前版本和指定版本的变化区别

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
bandit28@bandit:/tmp/tmp.tqJ1scDFzf/repo$ git log --pretty=oneline
817e303aa6c2b207ea043c7bba1bb7575dc4ea73 (HEAD -> master, origin/master, origin/HEAD) fix info leak
3621de89d8eac9d3b64302bfb2dc67e9a566decd add missing data
0622b73250502618babac3d174724bb303c32182 initial commit of README.md
bandit28@bandit:/tmp/tmp.tqJ1scDFzf/repo$ git reset --hard HEAD^
HEAD is now at 3621de8 add missing data
bandit28@bandit:/tmp/tmp.tqJ1scDFzf/repo$ cat README.md
# Bandit Notes
Some notes for level29 of bandit.

## credentials

- username: bandit29
- password: 4pT1t5DENaYuqnqvadYs1oE4QLCdjmJ7
-------------------------------------------------------------------------------------------
bandit28@bandit:/tmp/tmp.tqJ1scDFzf/repo$ git log --pretty=oneline
3621de89d8eac9d3b64302bfb2dc67e9a566decd (HEAD -> master) add missing data
0622b73250502618babac3d174724bb303c32182 initial commit of README.md
bandit28@bandit:/tmp/tmp.tqJ1scDFzf/repo$ git show 3621de89d8eac9d3b64302bfb2dc67e9a566decd
commit 3621de89d8eac9d3b64302bfb2dc67e9a566decd (HEAD -> master)
Author: Morla Porla <[email protected]>
Date: Thu Sep 19 07:08:39 2024 +0000

add missing data

diff --git a/README.md b/README.md
index 7ba2d2f..d4e3b74 100644
--- a/README.md
+++ b/README.md
@@ -4,5 +4,5 @@ Some notes for level29 of bandit.
## credentials

- username: bandit29
-- password: <TBD>
+- password: 4pT1t5DENaYuqnqvadYs1oE4QLCdjmJ7

版本回退 - Git教程 - 廖雪峰的官方网站

Level 29

There is a git repository at ssh://bandit29-git@localhost/home/bandit29-git/repo via the port 2220. The password for the user bandit29-git is the same as for the user bandit29.
有一个 git 存储库位于 ssh://bandit29-git@localhost/home/bandit29-git/repo 通过端口2220 。用户bandit29-git的密码与用户bandit29的密码相同。

Clone the repository and find the password for the next level.
克隆存储库并找到下一级的密码。

qp30ex3VLz5MDG1n91YowTv4Q8l7CDZL

看了下log发现只是把bandit29改成bandit30而已,密码提示没有在production

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
bandit29@bandit:~$ mktemp -d
/tmp/tmp.FjXziXDmuo
bandit29@bandit:~$ cd /tmp/tmp.FjXziXDmuo
bandit29@bandit:/tmp/tmp.FjXziXDmuo$ git clone ssh://bandit29-git@localhost:2220/home/bandit29-git/repo
bandit29@bandit:/tmp/tmp.FjXziXDmuo$ ls
repo
bandit29@bandit:/tmp/tmp.FjXziXDmuo$ cd repo/
bandit29@bandit:/tmp/tmp.FjXziXDmuo/repo$ ls
README.md
bandit29@bandit:/tmp/tmp.FjXziXDmuo/repo$ cat README.md
# Bandit Notes
Some notes for bandit30 of bandit.

## credentials

- username: bandit30
- password: <no passwords in production!>

那可能创建分支了,branch -a看一下,switch切换到dev分支,就可以看到了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
bandit29@bandit:/tmp/tmp.FjXziXDmuo/repo$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/dev
remotes/origin/master
remotes/origin/sploits-dev
bandit29@bandit:/tmp/tmp.FjXziXDmuo/repo$ git switch dev
branch 'dev' set up to track 'origin/dev'.
Switched to a new branch 'dev'
bandit29@bandit:/tmp/tmp.FjXziXDmuo/repo$ ls
code README.md
bandit29@bandit:/tmp/tmp.FjXziXDmuo/repo$ cat README.md
# Bandit Notes
Some notes for bandit30 of bandit.

## credentials

- username: bandit30
- password: qp30ex3VLz5MDG1n91YowTv4Q8l7CDZL

Level 30

There is a git repository at ssh://bandit30-git@localhost/home/bandit30-git/repo via the port 2220. The password for the user bandit30-git is the same as for the user bandit30.
有一个 git 存储库位于 ssh://bandit30-git@localhost/home/bandit30-git/repo 通过端口2220 。用户bandit30-git的密码与用户bandit30的密码相同。

Clone the repository and find the password for the next level.
克隆存储库并找到下一级的密码。

fb5S2xb7bRyFmAvQYQGEqsbhVyJqhnDy

还哈哈上了🤣

1
2
3
4
5
6
7
8
9
10
11
bandit30@bandit:~$ mktemp -d
/tmp/tmp.aL2NJXFrGx
bandit30@bandit:~$ cd /tmp/tmp.aL2NJXFrGx
bandit30@bandit:/tmp/tmp.aL2NJXFrGx$ git clone ssh://bandit30-git@localhost:2220/home/bandit30-git/repo
bandit30@bandit:/tmp/tmp.aL2NJXFrGx$ ls
repo
bandit30@bandit:/tmp/tmp.aL2NJXFrGx$ cd repo/
bandit30@bandit:/tmp/tmp.aL2NJXFrGx/repo$ ls
README.md
bandit30@bandit:/tmp/tmp.aL2NJXFrGx/repo$ cat README.md
just an epmty file... muahaha

大概率和git其他功能有关,还有个tag没提,尝试下,果然有

1
2
3
4
bandit30@bandit:/tmp/tmp.aL2NJXFrGx/repo$ git tag
secret
bandit30@bandit:/tmp/tmp.aL2NJXFrGx/repo$ git show secret
fb5S2xb7bRyFmAvQYQGEqsbhVyJqhnDy

Level 31

There is a git repository at ssh://bandit31-git@localhost/home/bandit31-git/repo via the port 2220. The password for the user bandit31-git is the same as for the user bandit31.
有一个 git 存储库位于 ssh://bandit31-git@localhost/home/bandit31-git/repo 通过端口2220 。用户bandit31-git的密码与用户bandit31的密码相同。

Clone the repository and find the password for the next level.
克隆存储库并找到下一级的密码。

3O9RfhqyAlVBEZpVb6LYStshZoqoSx5K

那我们就按照任务要求创建key.txt写入内容push到remote

发现提交的时候没有东西被提交,看了下.gitignore发现把txt后缀的文件都忽略了,加个-f强制添加,应该是push之后有个Git Hooks,特定事件发生时运行脚本

此关卡是配置了pre-push钩子,在代码被推送之前执行,至于推不推送就无所谓了,已经拿到我们要的信息了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
bandit31@bandit:~$ mktemp -d
/tmp/tmp.JoBWmokJpp
bandit31@bandit:~$ cd /tmp/tmp.JoBWmokJpp
bandit31@bandit:/tmp/tmp.JoBWmokJpp$ git clone ssh://bandit31-git@localhost:2220/home/bandit31-git/repo
bandit31@bandit:/tmp/tmp.JoBWmokJpp$ cd repo/
bandit31@bandit:/tmp/tmp.JoBWmokJpp/repo$ ls
README.md
bandit31@bandit:/tmp/tmp.JoBWmokJpp/repo$ cat README.md
This time your task is to push a file to the remote repository.
##这次你的任务是将文件推送到远程仓库。
Details:
File name: key.txt
Content: 'May I come in?'
Branch: master
bandit31@bandit:/tmp/tmp.JoBWmokJpp/repo$ echo 'May I come in?'>key.txt
bandit31@bandit:/tmp/tmp.JoBWmokJpp/repo$ cat key.txt
May I come in?
bandit31@bandit:/tmp/tmp.JoBWmokJpp/repo$ git add .
bandit31@bandit:/tmp/tmp.JoBWmokJpp/repo$ git commit -a
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
bandit31@bandit:/tmp/tmp.JoBWmokJpp/repo$ cat .gitignore
*.txt
bandit31@bandit:/tmp/tmp.JoBWmokJpp/repo$ git add -f .
bandit31@bandit:/tmp/tmp.JoBWmokJpp/repo$ git commit -a
Unable to create directory /home/bandit31/.local/share/nano/: No such file or directory
It is required for saving/loading search history or cursor positions.
##这里会打开nano你随便输点描述
[master fb00993] a
1 file changed, 1 insertion(+)
create mode 100644 key.txt
bandit31@bandit:/tmp/tmp.JoBWmokJpp/repo$ git push -u origin master
##push到主分支即可获得密码
The authenticity of host '[localhost]:2220 ([127.0.0.1]:2220)' can't be established.
ED25519 key fingerprint is SHA256:C2ihUBV7ihnV1wUXRb4RrEcLfXC5CXlhmAAM/urerLY.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Could not create directory '/home/bandit31/.ssh' (Permission denied).
Failed to add the host to the list of known hosts (/home/bandit31/.ssh/known_hosts).
_ _ _ _
| |__ __ _ _ __ __| (_) |_
| '_ \ / _` | '_ \ / _` | | __|
| |_) | (_| | | | | (_| | | |_
|_.__/ \__,_|_| |_|\__,_|_|\__|


This is an OverTheWire game server.
More information on http://www.overthewire.org/wargames

bandit31-git@localhost's password:
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 2 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 316 bytes | 316.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: ### Attempting to validate files... ####
remote:
remote: .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
remote:
remote: Well done! Here is the password for the next level:
remote: 3O9RfhqyAlVBEZpVb6LYStshZoqoSx5K
remote:
remote: .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
remote:
To ssh://localhost:2220/home/bandit31-git/repo
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://localhost:2220/home/bandit31-git/repo'

Level 32

After all this git stuff, it’s time for another escape. Good luck!
在经历了所有这些git事情之后,是时候进行另一次逃脱了。祝你好运!

tQdtbs5D5i2vJwkO8mEyYEyTL8izoeJ0

上面好几关都是关于git的现在终于不是了,shell好像只能输入大写,输入$0

当你在正常的shell中输入echo $0会打印出当前的shell,所以直接输入$0,相当于开了个子Shell

而且可以发现uppershell具有SUID权限,当前是以bandi33的身份在运行的Shell

1
2
3
4
5
6
7
8
9
10
11
12
13
14
WELCOME TO THE UPPERCASE SHELL
>> $0
$ ls -al
total 36
drwxr-xr-x 2 root root 4096 Sep 19 07:08 .
drwxr-xr-x 70 root root 4096 Sep 19 07:09 ..
-rw-r--r-- 1 root root 220 Mar 31 2024 .bash_logout
-rw-r--r-- 1 root root 3771 Mar 31 2024 .bashrc
-rw-r--r-- 1 root root 807 Mar 31 2024 .profile
-rwsr-x--- 1 bandit33 bandit32 15136 Sep 19 07:08 uppershell
$ whoami
bandit33
$ cat /etc/bandit\_pass/bandit33
tQdtbs5D5i2vJwkO8mEyYEyTL8izoeJ0

在 Bash shell(sh是Bash的一个变种)中,$0是一个特殊的变量,它代表当前脚本的名称。当你在脚本中使用$0时,它会显示你正在执行的脚本的名称。例如,如果你有一个名为script.sh的脚本,并且你在该脚本中打印$0,那么输出将会是script.sh

如果你在命令行中直接输入$0并按下回车,它通常会显示你当前正在运行的shell的名称,比如bash或者sh。这是因为在没有脚本的情况下,$0代表的是当前shell的名称。

Level 33

At this moment, level 34 does not exist yet.
目前34级还不存在。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
bandit33@bandit:~$ cat README.txt
Congratulations on solving the last level of this game!

At this moment, there are no more levels to play in this game. However, we are constantly working
on new levels and will most likely expand this game with more levels soon.
Keep an eye out for an announcement on our usual communication channels!
In the meantime, you could play some of our other wargames.

If you have an idea for an awesome new level, please let us know!
######
恭喜你完成了这个游戏的最后一关!
目前,这个游戏没有更多的关卡可以玩了。不过,我们正在不断开发新的关卡,并且很可能很快就会为这个游戏增加更多的关卡。
请留意我们通常的沟通渠道上的通知!
在此期间,你可以尝试玩一些我们的其他战争游戏。
如果你有一个很棒的新关卡的想法,请告诉我们!

结束了🥳🥳

由 Hexo 驱动 & 主题 Keep
本站由 提供部署服务
总字数 258.9k