【OverTheWire-bandit0-17通关笔记 上篇】

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


前言

OverTheWire是一个提供网络安全游戏的平台,其中Bandit是最受欢迎的系列之一。Bandit主要关注Linux系统基础知识,通过一系列逐步递进的任务,引导用户学习基本的命令行操作、文件管理、权限控制、脚本编写等技能
。这个游戏是针对初学者设计的,目的是帮助用户掌握基本的命令行操作和网络安全技能。
题目网址:https://overthewire.org/wargames/bandit/

一、靶场信息SSH information

host(主机):bandit.labs.overthewire.org
port(端口号):2220
用xshell可以连接但容易遇到小问题,建议直接使用kali linux进行闯关。
初始账号:bandit0
初始密码:bandit0(其余账号密码为32位字符串)

二、解题步骤及知识点

0.level0

goal(目标):The goal of this level is for you to log into the game using SSH. The host to which you need to connect is bandit.labs.overthewire.org, on port 2220. The username is bandit0 and the password is bandit0. Once logged in, go to the Level 1 page to find out how to beat Level 1.

  • 解题思路:使用ssh连接靶机(bandit.labs.overthewire.org)
ssh -p 2220 bandit0@bandit.labs.overthewire.org #密码bandit0 登录bandit0

1.level0-leve1

  • 解题思路:bandit0 登录后,ls发现存在readme文本,cat ./readme发现下一级密码
  • 截图如下:
bandit0@bandit:~$ ls
readme
bandit0@bandit:~$ cat 
.bash_logout  .bashrc       .profile      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

band1的密码为:ZjLjTmM6FvvyRnrb2rfNWOZOTa6ip5If【密码每个人的都不一样,系统会定期更新】

ssh -p2220 bandit1@bandit.labs.overthewire.org  # 输入密码,登录bandit1

1.level1-level2

Goal:The password for the next level is stored in a file called - located in the home directory
下一级的密码存储在一个名为"-"的文件中,该文件位于主目录。

Tips: ls 发现存在文件名为"-"的文件,在Linux系统中,文件名"-"(连字符)可能会导致一些混淆,因为它在命令行中通常被用作命令选项的前缀,因此无法通过cat - 直接查看。

  • 解题思路1:cat ./-
cat ./-
  • 解题思路2:cat < “-”
cat < "-"

截图如下:

bandit1@bandit:~$ ls
-
bandit1@bandit:~$ cat ./-
263JGJPfgU6LtdEvgfWU1XP5yac29mFx
bandit1@bandit:~$ cat < "-"
263JGJPfgU6LtdEvgfWU1XP5yac29mFx

获得下一级账号bandit2的密码为:263JGJPfgU6LtdEvgfWU1XP5yac29mFx

ssh -p2220 bandit3@bandit.labs.overthewire.org  #登录bandit3

3.level2-level3

Goal:The password for the next level is stored in a file called spaces in this filename located in the home directory
下一级的密码存储在一个名为"spaces in this filename"的文件中,该文件位于主目录。

Tips: 文件名存在空格,试试用引号括起来。

  • 解题思路:cat ./“spaces in this filename”
cat ./"spaces in this filename"

截图如下:

bandit2@bandit:~$ ls
spaces in this filename
bandit2@bandit:~$ cat ./"spaces in this filename"
MNk8KNH3Usiio41PRUEoDFPqfxLPlSmx
bandit2@bandit:~$ 

获得下一级账号bandit3的密码为:MNk8KNH3Usiio41PRUEoDFPqfxLPlSmx

ssh -p2220 bandit3@bandit.labs.overthewire.org #登录bandit3

4.level3-level4

Goal:The password for the next level is stored in a hidden file in the inhere directory.
下一级的密码存储在一个隐藏文件中,该文件位于"inhere"目录下。

Tips: 隐藏文件以.开头。

  • 解题思路:上一题的方法可以查看;cat ./“隐藏文件”
cat ./"...Hiding-From-You"

截图如下:

bandit3@bandit:~$ ls
inhere
bandit3@bandit:~$ cd inhere/
bandit3@bandit:~/inhere$ ll
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

获得下一级账号bandit4的密码为:2WmrDFRmJIq3IPxneAaMGhap0pFhF3NJ

ssh -p2220 bandit4@bandit.labs.overthewire.org #登录bandit4

5.level4-level5

Goal:The password for the next level is stored in the only human-readable file in the inhere directory. Tip: if your terminal is messed up, try the “reset” command.
下一级的密码存储在"inhere"目录中唯一的可读文件里。提示:如果你的终端出现问题,尝试使用“reset”命令。

Tips:file $file查看文件类型,grep -q "text"找出文本类型文件。

  • 解题思路:ls 发现inhere文件夹,cd进入inhere ;ls -al,可以一个一个打开,也可以用脚本循环查看文件类型。
for file in ./-file*; do
    if file "$file" | grep -q "text"; then
        echo "$file"
    fi
done

截图如下:

bandit4@bandit:~/inhere$ ls -al
total 48
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 bandit5 bandit4   33 Sep 19 07:08 -file00
-rw-r----- 1 bandit5 bandit4   33 Sep 19 07:08 -file01
-rw-r----- 1 bandit5 bandit4   33 Sep 19 07:08 -file02
-rw-r----- 1 bandit5 bandit4   33 Sep 19 07:08 -file03
-rw-r----- 1 bandit5 bandit4   33 Sep 19 07:08 -file04
-rw-r----- 1 bandit5 bandit4   33 Sep 19 07:08 -file05
-rw-r----- 1 bandit5 bandit4   33 Sep 19 07:08 -file06
-rw-r----- 1 bandit5 bandit4   33 Sep 19 07:08 -file07
-rw-r----- 1 bandit5 bandit4   33 Sep 19 07:08 -file08
-rw-r----- 1 bandit5 bandit4   33 Sep 19 07:08 -file09
bandit4@bandit:~/inhere$ for file in ./-file*; do
    if file "$file" | grep -q "text"; then
        echo "$file"
    fi
done
./-file07
bandit4@bandit:~/inhere$ cat ./-file07
4oQYVPkxZOOEOO5pTW81FB8j8lxXGUQw

发现./-file07文件为文本类型,cat ./-file07
获得下一级账号bandit5的密码为:4oQYVPkxZOOEOO5pTW81FB8j8lxXGUQw

ssh -p2220 bandit5@bandit.labs.overthewire.org #登录bandit5

6.level5-level6

Goal:The password for the next level is stored in a file somewhere under the inhere directory and has all of the following properties:

human-readable
1033 bytes in size
not executable。

Tips: text文本文件 1033 bytes大小 不是可执行文件。

  • 解题思路:直接写脚本
for dir in $(find . -maxdepth 1 -type d -name 'maybehere*'); do
    find "$dir" -type f -size 1033c ! -executable -exec sh -c 'file "{}" | grep -qi "text" && echo "{}" && cat "{}"' \;
done

截图如下:

bandit5@bandit:~/inhere$ ls
maybehere00  maybehere04  maybehere08  maybehere12  maybehere16
maybehere01  maybehere05  maybehere09  maybehere13  maybehere17
maybehere02  maybehere06  maybehere10  maybehere14  maybehere18
maybehere03  maybehere07  maybehere11  maybehere15  maybehere19
bandit5@bandit:~/inhere$ for dir in $(find . -maxdepth 1 -type d -name 'maybehere*'); do
    find "$dir" -type f -size 1033c ! -executable -exec sh -c 'file "{}" | grep -qi "text" && echo "{}" && cat "{}"' \;
done
./maybehere07/.file2
HWasnPhtq9AVKe0dmk45nxy20cvUa6EG

这里是命令的逐行解释:

for dir in $(find . -maxdepth 1 -type d -name ‘maybehere*’); do:这是一个 for 循环,它使用 find 命令来查找当前目录下所有以 maybehere 开头的目录。

find “$dir” -type f -size 1033c ! -executable:对于每个找到的目录($dir),内层的 find 命令查找该目录下所有类型为文件(-type f)、大小为 1033 字节(-size 1033c)、且不是可执行文件(! -executable)的文件。

-exec sh -c ‘file “{}” | grep -qi “text” && echo “{}” && cat “{}”’ ;:对于内层 find 命令找到的每个文件,执行 sh -c 并使用 file 命令检查文件类型。如果 file 命令的输出包含文本(“text”),则使用 echo 打印文件名。grep -qi “text” 表示不区分大小写的安静模式搜索。如果文件是文本文件,接着使用 cat “{}” 命令打印文件的内容。

done:结束 for 循环。

这个命令会遍历当前目录下所有名为 maybehere* 的目录,然后在每个目录中查找满足条件的文件,并打印出这些文件的名称和内容。请注意,file 命令用于检查文件是否为文本类型,这通常是通过检查 file 命令输出中是否包含如 “ASCII text”、“UTF-8 Unicode text” 等字符串来确定的。
获得下一级账号bandit6的密码为:HWasnPhtq9AVKe0dmk45nxy20cvUa6EG

ssh -p2220 bandit6@bandit.labs.overthewire.org #登录bandit6

7.level6-level7

Goal:The password for the next level is stored somewhere on the server and has all of the following properties:

owned by user bandit7
owned by group bandit6
33 bytes in size.

Tips: 查找所属用户bandit7,所属组bandit6,文件大小33字节 。

  • 解题思路:find查找 -user -group -size
    33c c代表字节 ; 2>/dev/null:将标准错误(stderr)重定向到 /dev/null,这意味着任何错误信息都会被忽略。【/dev/null 是一个特殊的文件,被称为位桶(bit bucket)或黑洞设备。在 Unix 和类 Unix 操作系统中,它被用作数据的“垃圾箱”。】
find / -user bandit7 -group bandit6 -size 33c  2>/dev/null

截图如下:

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

获得下一级账号bandit7的密码为:morbNTDkSW6jIlUc0ymOdMaLnOlFVAaj

ssh -p2220 bandit7@bandit.labs.overthewire.org #登录bandit7

8.level7-level8

Goal:The password for the next level is stored in the file data.txt next to the word millionth:

下一级的密码存储在文件 data.txt 中, “millionth” 这个词下一个字符串.

Tips: grep -oE 。

  • 解题思路:
grep 'millionth' data.txt | grep -oE '[a-zA-Z0-9]+'

截图如下:

bandit7@bandit:~$ ls
data.txt
bandit7@bandit:~$ grep 'millionth' data.txt | grep -oE '[a-zA-Z0-9]+'
millionth
dfwvzFQi4mU0wfNbFOe9RoWskMLg7eEc

获得下一级账号bandit8的密码为:dfwvzFQi4mU0wfNbFOe9RoWskMLg7eEc

ssh -p2220 bandit8@bandit.labs.overthewire.org #登录bandit8

9.level8-level9

Goal: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文件内 唯一出现一次的一行文本.

Tips: sort,uniq 。

  • 解题思路:
sort data.txt | uniq -u

截图如下:

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

获得下一级账号bandit9的密码为:4CKMh1JI91bUIZZPXDqGanal4xvAg0JM

ssh -p2220 bandit9@bandit.labs.overthewire.org #登录bandit9

10.level9-level10

Goal: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中,在一些可读的字符串中,前面有若干个‘=’字符。

Tips:strings。

  • 解题思路:
strings data.txt | grep '=*' | grep -oE '[a-zA-Z0-9]{32}'

截图如下:

bandit9@bandit:~$ ls
data.txt
bandit9@bandit:~$ strings data.txt | grep '=*' | grep -oE '[a-zA-Z0-9]{32}'
FGUW5ilLVJrxX9kMYMmlN4MgbpfMiqey

strings data.txt:这个命令用于从data.txt文件中提取所有可打印的字符串。

grep ‘=*’:这个命令用于过滤出包含一个或多个等号(=)的字符串。

grep -oE ‘[a-zA-Z0-9]{32}’:这个命令用于进一步过滤出长度为32个字符的字符串,这些字符可以是大写字母、小写字母或数字。
获得下一级账号bandit9的密码为:FGUW5ilLVJrxX9kMYMmlN4MgbpfMiqey

ssh -p2220 bandit10@bandit.labs.overthewire.org #登录bandit10

11.level10-level11

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

Tips:base64 --decode。

  • 解题思路:
 cat data.txt  | base64 --decode

截图如下:

bandit10@bandit:~$ ls
data.txt
bandit10@bandit:~$ cat data.txt 
VGhlIHBhc3N3b3JkIGlzIGR0UjE3M2ZaS2IwUlJzREZTR3NnMlJXbnBOVmozcVJyCg==
bandit10@bandit:~$ cat data.txt  | base64 --decode
The password is dtR173fZKb0RRsDFSGsg2RWnpNVj3qRr
bandit10@bandit:~$ cat data.txt  | base64 --decode
The password is dtR173fZKb0RRsDFSGsg2RWnpNVj3qRr

获得下一级账号bandit11的密码为:dtR173fZKb0RRsDFSGsg2RWnpNVj3qRr

ssh -p2220 bandit11@bandit.labs.overthewire.org #登录bandit11

12.level11-level12

Goal: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中,其中所有的小写字母(a-z)和大写字母(A-Z)都被轮询了13个位置。

Tips:tr ROT13。

  • 解题思路:
cat data.txt | tr 'A-Za-z' 'N-ZA-Mn-za-m'

截图如下:

bandit11@bandit:~$ ls
data.txt
bandit11@bandit:~$ cat data.txt 
Gur cnffjbeq vf 7k16JArUVv5LxVuJfsSVdbbtaHGlw9D4
bandit11@bandit:~$ cat data.txt | tr 'A-Za-z' 'N-ZA-Mn-za-m'
The password is 7x16WNeHIi5YkIhWsfFIqoognUTyj9Q4

获得下一级账号bandit12的密码为:7x16WNeHIi5YkIhWsfFIqoognUTyj9Q4

ssh -p2220 bandit12@bandit.labs.overthewire.org #登录bandit12

13.level12-level13

Goal: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 命令重命名它(阅读 man 页面!)。

Tips:file xxd gzip gunzip bzip2。

  • 解题思路:
通过file查看文件类型,反复解压
xxd -r data.txt > bandit   使用 xxd -r data.txt 命令可以将这个十六进制转储还原为原始的二进制文件。
gunzip 解压gz包
bzip2 -d 解压bz2包
tar -xvf 解压tar包

截图如下:

bandit12@bandit:~$ ls
data.txt
bandit12@bandit:~$ mkdir /tmp/secret
bandit12@bandit:~$ cp data.txt /tmp/secret
bandit12@bandit:~$ cd /tmp/secret
bandit12@bandit:/tmp/secret$ ll
total 184
drwxrwxr-x    2 bandit12 bandit12   4096 Sep 27 01:54 ./
drwxrwx-wt 4290 root     root     176128 Sep 27 01:54 ../
-rw-r-----    1 bandit12 bandit12   2583 Sep 27 01:54 data.txt
bandit12@bandit:/tmp/secret$ file data.txt 
data.txt: ASCII text
bandit12@bandit:/tmp/secret$ 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
bandit12@bandit:/tmp/secret$ xxd -r data.txt > bandit
bandit12@bandit:/tmp/secret$ ls
bandit  data.txt
bandit12@bandit:/tmp/secret$ file bandit 
bandit: 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
bandit12@bandit:/tmp/secret$ mv bandit bandit.gz
bandit12@bandit:/tmp/secret$ ls
bandit.gz  data.txt
bandit12@bandit:/tmp/secret$ gunzip bandit.gz 
bandit12@bandit:/tmp/secret$ ls
bandit  data.txt
bandit12@bandit:/tmp/secret$ file bandit 
bandit: bzip2 compressed data, block size = 900k
bandit12@bandit:/tmp/secret$ mv bandit bandit.bz2
bandit12@bandit:/tmp/secret$ ls
bandit.bz2  data.txt
bandit12@bandit:/tmp/secret$ bzip2 -d bandit.bz2 
bandit12@bandit:/tmp/secret$ ls
bandit  data.txt
bandit12@bandit:/tmp/secret$ file bandit 
bandit: 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
bandit12@bandit:/tmp/secret$ mv bandit bandit.gz
bandit12@bandit:/tmp/secret$ ls
bandit.gz  data.txt
bandit12@bandit:/tmp/secret$ gunzip bandit.gz 
bandit12@bandit:/tmp/secret$ ls
bandit  data.txt
bandit12@bandit:/tmp/secret$ file bandit 
bandit: POSIX tar archive (GNU)
bandit12@bandit:/tmp/secret$ mv bandit bandit.tar
bandit12@bandit:/tmp/secret$ ls
bandit.tar  data.txt
bandit12@bandit:/tmp/secret$ tar -xvf bandit.tar 
data5.bin
bandit12@bandit:/tmp/secret$ file data5.bin 
data5.bin: POSIX tar archive (GNU)
bandit12@bandit:/tmp/secret$ mv data5.bin data5.tar
bandit12@bandit:/tmp/secret$ ls
bandit.tar  data5.tar  data.txt
bandit12@bandit:/tmp/secret$ tar -xvf data5.tar 
data6.bin
bandit12@bandit:/tmp/secret$ file data6.bin
data6.bin: bzip2 compressed data, block size = 900k
bandit12@bandit:/tmp/secret$ mv data6.bin data6.bz2
bandit12@bandit:/tmp/secret$ ls
bandit.tar  data5.tar  data6.bz2  data.txt
bandit12@bandit:/tmp/secret$ bzip2 -d data6.bz2 
bandit12@bandit:/tmp/secret$ ls
bandit.tar  data5.tar  data6  data.txt
bandit12@bandit:/tmp/secret$ file data6
data6: POSIX tar archive (GNU)
bandit12@bandit:/tmp/secret$ mv data6 data6.tar
bandit12@bandit:/tmp/secret$ ls
bandit.tar  data5.tar  data6.tar  data.txt
bandit12@bandit:/tmp/secret$ tar -xvf data6.tar 
data8.bin
bandit12@bandit:/tmp/secret$ 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/secret$ mv data8.bin data8.gz
bandit12@bandit:/tmp/secret$ ls
bandit.tar  data5.tar  data6.tar  data8.gz  data.txt
bandit12@bandit:/tmp/secret$ gunzip data8.gz 
bandit12@bandit:/tmp/secret$ ls
bandit.tar  data5.tar  data6.tar  data8  data.txt
bandit12@bandit:/tmp/secret$ file data8
data8: ASCII text
bandit12@bandit:/tmp/secret$ cat data8
The password is FO5dwFsc0cbaIiH0h8J2eUks2vdTDwAn

获得下一级账号bandit13的密码为:FO5dwFsc0cbaIiH0h8J2eUks2vdTDwAn

ssh -p2220 bandit13@bandit.labs.overthewire.org #登录bandit13

14.level13-level14

Goal: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 是指你正在工作的机器的主机名。

Tips:sshkey.private。

  • 解题思路:
ssh -i ./sshkey.private -p 2220 bandit14@bandit.labs.overthewire.org

截图如下:

bandit13@bandit:~$ ls
sshkey.private
bandit13@bandit:~$ ssh -i ./sshkey.private -p 2220 bandit14@bandit.labs.overthewire.org
The authenticity of host '[bandit.labs.overthewire.org]: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
bandit14@bandit:~$ 

cat /etc/bandit_pass/bandit14
获得下一级账号bandit14的密码为:MU4VWeTyJk8ROof1qqmcBPaLh7lDCPvS

15.level14-level15

Goal:he password for the next level can be retrieved by submitting the password of the current level to port 30000 on localhost.
下一级的密码可以通过将当前级别的密码提交到 localhost 的 30000 端口来检索。

Tips:nc /etc/bandit_pass/bandit14。

  • 解题思路:
cat /etc/bandit_pass/bandit14 #获取本级密码
nc localhost 30000   #监听本机30000端口,提交密码

截图如下:

bandit14@bandit:~$ cat /etc/bandit_pass/bandit14
MU4VWeTyJk8ROof1qqmcBPaLh7lDCPvS
bandit14@bandit:~$ nc localhost 30000
MU4VWeTyJk8ROof1qqmcBPaLh7lDCPvS
Correct!
8xCjnmgoKbGLhHFAZlGE5Tmu4M2tKJQo

获得下一级账号bandit15的密码为:8xCjnmgoKbGLhHFAZlGE5Tmu4M2tKJQo

ssh -p2220 bandit15@bandit.labs.overthewire.org #登录bandit15

16.level15-level16

Goal: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 端口来检索。

Tips:openssl。

  • 解题思路:
openssl s_client -quiet -connect bandit.labs.overthewire.org:30001

截图如下:

bandit15@bandit:~$ openssl s_client -quiet -connect bandit.labs.overthewire.org:30001
depth=0 CN = SnakeOil
verify error:num=18:self-signed certificate
verify return:1
depth=0 CN = SnakeOil
verify return:1
8xCjnmgoKbGLhHFAZlGE5Tmu4M2tKJQo
Correct!
kSkvUpMQ7lBYyCM4GBPvCvT1BfWRy0Dx

获得下一级账号bandit16的密码为:kSkvUpMQ7lBYyCM4GBPvCvT1BfWRy0Dx

ssh -p2220 bandit16@bandit.labs.overthewire.org #登录bandit16

17.level16-level17

Goal: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.
下一级的凭证可以通过将当前级别的密码提交到 localhost 上 31000 到 32000 范围内的某个端口来检索。首先找出这些端口中哪些有服务器在监听。然后确定这些服务器中哪些使用了 SSL/TLS 加密,哪些没有。只有一个服务器会提供下一个凭证,其他的会简单地将你发送给它的内容回传给你。

Tips:openssl nmap。

  • 解题思路:
nmap -sT -sV -p 31000-32000
openssl s_client -quiet -connect bandit.labs.overthewire.org:30001

截图如下:

bandit16@bandit:~$ nmap -sT -sV -p31000-32000
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-09-27 03:42 UTC
WARNING: No targets were specified, so 0 hosts scanned.
Nmap done: 0 IP addresses (0 hosts up) scanned in 0.27 seconds
bandit16@bandit:~$ nmap -sT -sV -p31000-32000 localhost
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-09-27 03:42 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00025s latency).
Not shown: 996 closed tcp ports (conn-refused)
PORT      STATE SERVICE     VERSION
31046/tcp open  echo
31518/tcp open  ssl/echo
31691/tcp open  echo
31790/tcp open  ssl/unknown
31960/tcp open  echo

bandit16@bandit:~$ openssl s_client -quiet -connect 127.0.0.1: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-----
bandit16@bandit:~$ mkdir /tmp/pass
bandit16@bandit:~$ cd /tmp/pass
bandit16@bandit:/tmp/pass$ touch ./id_rsa
bandit16@bandit:/tmp/pass$ vim ./id_rsa #将密钥复制进该文件
bandit16@bandit:/tmp/pass$ ssh -i ./id_rsa -p2220 bandit17@127.0.0.1
The authenticity of host '[127.0.0.1]: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
bandit17@bandit:~$

总结

  • 知识点1:
    find命令用来在指定目录下查找文件。任何位于参数之前的字符串都将被视为欲查找的目录名。如果使用该命令时,不设置任何参数,则find命令将在当前目录下查找子目录与文件。并且将查找到的子目录和文件全部进行显示。
    常用参数:
    -size n : 文件大小 是 n 单位,b 代表 512 位元组的区块,c 表示字元数,k 表示 kilo bytes,w 是二个位元组。
    -type c : 文件类型是 c 的文件。
    -name 文件名;
    -group 文件所属组;
    -perm权限(like 770);

  • 知识点2:
    Linux系统预留可三个文件描述符:0、1和2,他们的意义如下所示:
    0——标准输入(stdin)
    1——标准输出(stdout)
    2——标准错误(stderr)
    重定向的符号有两个:>或>>,两者的区别是:前者会先清空文件,然后再写入内容,后者会将重定向的内容追加到现有文件的尾部。
    /dev/null是一个特殊的设备文件,这个文件接收到任何数据都会被丢弃。因此,null这个设备通常也被称为位桶(bit bucket)或黑洞。
    2>/dev/null的意思就是将标准错误stderr删掉。

  • 知识点3:
    grep 命令在 Linux 和 Unix 系统中用于搜索文件中匹配特定模式的行。-o 和 -E 是 grep 命令的两个选项,它们的作用如下:
    -o (–only-matching):这个选项告诉 grep 只输出匹配正则表达式部分的文本,而不是整行。这对于提取行中特定模式的字符串非常有用。
    -E (–extended-regexp):这个选项允许使用扩展的正则表达式。扩展的正则表达式比基本的正则表达式提供了更多的功能和灵活性,例如使用花括号 {} 来指定数量,或者使用 | 来表示逻辑“或”。
    结合起来使用 -oE 选项时,grep 会搜索文件,查找所有匹配扩展正则表达式的部分,并只输出这些匹配的部分,而不是整行文本。

  • 知识点4:
    ROT13 是一种简单的字母替换密码,它属于凯撒密码的一种特殊形式。由于 ROT13 是自反的,即对同一个字符串进行两次 ROT13 操作会还原原始字符串,所以加密和解密过程是相同的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值