bandit,主要练习linux命令
Level 0
关卡介绍:
提示:此级别的目标是让您使用 SSH 登录游戏。您需要连接的主机是 bandit.labs.overthewire.org,端口为 2220。用户名是bandit0,密码是bandit0。登录后,转到1 级页面以了解如何击败 1 级。
Level 0 → Level 1
关卡介绍:
提示:下一级别的密码存储在位于主目录中的名为readme的文件 中。使用此密码通过 SSH 登录到 bandit1。每当您找到某个级别的密码时,请使用 SSH(在端口 2220 上)登录该级别并继续游戏。
解决方案:
# 通过ssh连接到bandit0
[c:\~]$ ssh bandit.labs.overthewire.org 2220
#查看当前路径下的文件
bandit0@bandit:~$ ls
readme
#发现一个readme的文件,既然它让看它,那就打开看一看
cat 查看得到第一关密码
bandit0@bandit:~$ cat readme
boJ9jbbUNNfktd78OOpsqOltutMc3MY1
bandit0@bandit:~$
Level 1 → Level 2
关卡介绍:
提示:下一级的密码存储在名为-的文件中, 位于主目录中
解决方案:
#发现一个为-的文件名,使用cat - 是不行的
bandit1@bandit:~$ ls
-
bandit1@bandit:~$ ls -l
total 4
-rw-r----- 1 bandit2 bandit1 33 May 7 2020 -
bandit1@bandit:~$ cat ./-
CV1DtqXWVFXTvM2F0k09SHz0YwRINYA9
bandit1@bandit:~$
Level 2 → Level 3
关卡介绍:
提示:下一级别的密码存储在位于主目录中的此文件名中的一个名为空格的文件中
解决方案:
#详细信息显示当前路径下面的文件,发现一个spaces in this filename 。打开得到下一关密码
bandit2@bandit:~$ ls -l
total 4
-rw-r----- 1 bandit3 bandit2 33 May 7 2020 spaces in this filename
bandit2@bandit:~$ cat ./
.bash_logout .bashrc .profile spaces in this filename
bandit2@bandit:~$ cat ./
.bash_logout .bashrc .profile spaces in this filename
bandit2@bandit:~$ cat ./
.bash_logout .bashrc .profile spaces in this filename
bandit2@bandit:~$ cat ./spaces\ in\ this\ filename
UmHadQclWmgdLOKQ3YNgjWxGoRMb5luK
bandit2@bandit:~$
Level 3 → Level 4
关卡介绍:
提示:下一级别的密码存储在inhere目录中的隐藏文件中 。
解决方案:
#先显示当前路径下的内容,发现有一个文件夹,去到文件夹里。ls -a 查看所有。
bandit3@bandit:~$ ls -l
total 4
drwxr-xr-x 2 root root 4096 May 7 2020 inhere
bandit3@bandit:~$
bandit3@bandit:~$ cd inhere/
bandit3@bandit:~/inhere$ ls
bandit3@bandit:~/inhere$ ls -l
total 0
bandit3@bandit:~/inhere$ ls -a
. .. .hidden
bandit3@bandit:~/inhere$ cat .hidden
pIwrPrtPN36QITSp3EQaw936yaFoFgAB
bandit3@bandit:~/inhere$
Level 4 → Level 5
关卡介绍:
提示:下一级的密码存储在inhere目录中唯一的人类可读文件中。提示:如果您的终端搞砸了,请尝试“重置”命令。
解决方案:
还是去到文件夹里,file命令查看一下文件类型
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
koReBOKuIDDepwhWk7jZC0RTdopnAYKh
bandit4@bandit:~/inhere$
Level 5 → Level 6
关卡介绍:
下一级别的密码存储在inhe目录下某处的文件中,并具有以下所有属性:
人类可读的
1033 字节大小
不可执行
解决方案:
#提示给出是人类可读,大小是1033c,并且不可执行的文件。可以用find加参数来搞定
bandit5@bandit:~$ ls
inhere
bandit5@bandit:~$ cd inhere/
bandit5@bandit:~/inhere$ ls
maybehere00 maybehere02 maybehere04 maybehere06 maybehere08 maybehere10 maybehere12 maybehere14 maybehere16 maybehere18
maybehere01 maybehere03 maybehere05 maybehere07 maybehere09 maybehere11 maybehere13 maybehere15 maybehere17 maybehere19
bandit5@bandit:~/inhere$ find -size 1033c
./maybehere07/.file2
bandit5@bandit:~/inhere$ cat ./maybehere07/.file2
DXjZPULLxYr17uwoI01bNLQbtFemEgo7
bandit5@bandit:~/inhere$
Level 6 → Level 7
关卡介绍:
下一级的密码存储在服务器上的某处,并具有以下所有属性:
归用户bandit7所有
归bandit6组所有
33 字节大小
解决方案:
#开始学坏了,转变套路了哈哈哈。
那我们就搜索整个系统。工作组是bandit6 用户是bandit7 大小是33字节
bandit6@bandit:~$ ls -l
total 0
bandit6@bandit:~$ find / - group bandit6 -user bandit7 -size 33c
find: ‘/root’: Permission denied
find: ‘/home/bandit28-git’: Permission denied
find: ‘/home/bandit30-git’: Permission denied
find: ‘/home/bandit5/inhere’: Permission denied
find: ‘/home/bandit27-git’: Permission denied
find: ‘/home/bandit29-git’: Permission denied
find: ‘/home/bandit31-git’: Permission denied
find: ‘/lost+found’: Permission denied
/etc/bandit_pass/bandit7
find: ‘/etc/ssl/private’: Permission denied
find: ‘/etc/polkit-1/localauthority’: Permission denied
find: ‘/etc/lvm/archive’: Permission denied
find: ‘/etc/lvm/backup’: Permission denied
find: ‘/sys/fs/pstore’: Permission denied
find: ‘/proc/tty/driver’: Permission denied
find: ‘/proc/30037/task/30037/fd/6’: No such file or directory
find: ‘/proc/30037/task/30037/fdinfo/6’: No such file or directory
find: ‘/proc/30037/fd/5’: No such file or directory
find: ‘/proc/30037/fdinfo/5’: No such file or directory
find: ‘/cgroup2/csessions’: Permission denied
find: ‘/boot/lost+found’: Permission denied
find: ‘/tmp’: Permission denied
find: ‘/run/lvm’: Permission denied
find: ‘/run/screen/S-bandit1’: Permission denied
find: ‘/run/screen/S-bandit12’: Permission denied
find: ‘/run/screen/S-bandit11’: Permission denied
find: ‘/run/screen/S-bandit10’: Permission denied
find: ‘/run/screen/S-bandit3’: Permission denied
find: ‘/run/screen/S-bandit29’: Permission denied
find: ‘/run/screen/S-bandit15’: Permission denied
find: ‘/run/screen/S-bandit8’: Permission denied
find: ‘/run/screen/S-bandit13’: Permission denied
find: ‘/run/screen/S-bandit19’: Permission denied
find: ‘/run/screen/S-bandit9’: Permission denied
find: ‘/run/screen/S-bandit27’: Permission denied
find: ‘/run/screen/S-bandit2’: Permission denied
find: ‘/run/screen/S-bandit14’: Permission denied
find: ‘/run/screen/S-bandit16’: Permission denied
find: ‘/run/screen/S-bandit22’: Permission denied
find: ‘/run/screen/S-bandit4’: Permission denied
find: ‘/run/screen/S-bandit31’: Permission denied
find: ‘/run/screen/S-bandit24’: Permission denied
find: ‘/run/screen/S-bandit21’: Permission denied
find: ‘/run/screen/S-bandit25’: Permission denied
find: ‘/run/screen/S-bandit23’: Permission denied
find: ‘/run/screen/S-bandit20’: Permission denied
find: ‘/run/shm’: Permission denied
find: ‘/run/lock/lvm’: Permission denied
find: ‘/var/spool/bandit24’: Permission denied
find: ‘/var/spool/cron/crontabs’: Permission denied
find: ‘/var/spool/rsyslog’: Permission denied
find: ‘/var/tmp’: Permission denied
find: ‘/var/lib/apt/lists/partial’: Permission denied
find: ‘/var/lib/polkit-1’: Permission denied
/var/lib/dpkg/info/bandit7.password
find: ‘/var/log’: Permission denied
find: ‘/var/cache/apt/archives/partial’: Permission denied
find: ‘/var/cache/ldconfig’: Permission denied
find: ‘-’: No such file or directory
find: ‘group’: No such file or directory
find: ‘bandit6’: No such file or directory
bandit6@bandit:~$ cat /var/lib/dpkg/info/bandit7.password
HKBPTKQnIay4Fw76bEy8PVxKEDQRKTzs
bandit6@bandit:~$
Level 7 → Level 8
关卡介绍:
提示:下一级别的密码存储在文件data.txt 旁边的单词Millionth
解决方案:
#根据提示,可以联想到grep,水到渠成
bandit7@bandit:~$ ls
data.txt
bandit7@bandit:~$ vim data.txt
bandit7@bandit:~$
bandit7@bandit:~$ cat data.txt |grep Millionth
bandit7@bandit:~$ cat data.txt |grep millionth
millionth cvX2JJa4CFALtqS87jk27qwqGhBM9plV
bandit7@bandit:~$
Level 8 → Level 9
关卡介绍:
下一级别的密码存储在文件data.txt 中, 并且是仅出现一次的唯一文本行
解决方案:
#根据他的提示来判断,它可能逐渐(吃骨头动物)化
提示也给出了uniq命令,那我们就用它。不同的文本比对,可以用到uniq,而仅出现一次呢,则可以sort先排序再去重
bandit8@bandit:~$ ls
data.txt
bandit8@bandit:~$ sort data.txt | uniq -u
UsvVyFSfZZWbi6wgC7dAFyFuR6jQQUhR
bandit8@bandit:~$
Level 9 → Level 10
关卡介绍:
下一级别的密码存储在文件data.txt 中的少数人类可读字符串之一中,前面是几个“=”字符。
解决方案:
#这关没办法,打开是一堆乱码,去百度得到strings命令,它主要用来提取和显示非文本文件中的文本字符串,
bandit9@bandit:~$ cat data.txt
手动****
bandit9@bandit:~$ cat data.txt |strings| grep ===
========== the*2i"4
========== password
Z)========== is
&========== truKLdjsbJ5g7yyJ2X2R0o3a5HQJFuLk
bandit9@bandit:~$
以上命令均为实验过,如有改进请私信留言