# Overthewire ## Bandit0 - ssh bandit0@bandit.labs.overthewire.org -p 2220 - password: bandit0 ## Bandit0-1 - Sau khi dùng lệnh ls ta nhìn thấy file readme. - Dùng lệnh cat readme ta được mật khẩu. ```python bandit0@bandit:~$ ls readme bandit0@bandit:~$ cat readme NH2SXQwcBdpmTEzi3bvBHMM9H66vVXjL bandit0@bandit:~$ ``` ## Bandit1-2 - ssh bandit1@bandit.labs.overthewire.org -p 2220 - password: NH2SXQwcBdpmTEzi3bvBHMM9H66vVXjL - Sau khi dùng lệnh ls, ta sẽ thấy file có tên "-" trong danh sách. Bởi vì tên file có kí tự đặc biệt nên ta phải dùng ./ trước tên file để có thể đọc file => lệnh là cat ./-. ```python! bandit1@bandit:~$ ls - bandit1@bandit:~$ cat ./- rRGizSaX8Mk1RTb1CNQoXTcYZWU6lgzi ``` ## Bandit2-3 - ssh bandit2@bandit.labs.overthewire.org -p 2220 - password: rRGizSaX8Mk1RTb1CNQoXTcYZWU6lgzi - Dùng lệnh ls ta thấy file "spaces in this filename". - Để đọc file có khoảng cách cần dấu ngoặc kép bọc tên file lại => cat "spaces in this filename". ```python! bandit2@bandit:~$ ls spaces in this filename bandit2@bandit:~$ cat "spaces in this filename" aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG ``` ## Bandit3-4 - ssh bandit3@bandit.labs.overthewire.org -p 2220 - password: aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG - Dùng lệnh ls ta thấy folder inhere. - Dự kiện của đề : The password for the next level is stored in a hidden file in the inhere directory. - Nên ta sẽ cd inhere. Sau đó dùng ls -la để tìm file ẩn. ```python! bandit3@bandit:~$ ls inhere bandit3@bandit:~$ cd inhere bandit3@bandit:~/inhere$ ls bandit3@bandit:~/inhere$ ls -la total 12 drwxr-xr-x 2 root root 4096 Apr 23 18:04 . drwxr-xr-x 3 root root 4096 Apr 23 18:04 .. -rw-r----- 1 bandit4 bandit3 33 Apr 23 18:04 .hidden bandit3@bandit:~/inhere$ cat .hidden 2EW7BBsr6aMMoJ2HjW067dm8EgX26xNe ``` ## Bandit4-5 - ssh bandit4@bandit.labs.overthewire.org -p 2220 - password: 2EW7BBsr6aMMoJ2HjW067dm8EgX26xNe - Dùng lệnh ls ta thấy folder inhere. - Dự kiện của đề : 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. - Nên ta sẽ cd inhere. Sau đó dùng ls để kiểm tra thì thấy các file có kí tự đặc biệt nên ta sẽ dùng lệnh file ./* để xem file nào chứ nội dung là ASCII rồi cat nội dung file đó. ```python! bandit4@bandit:~$ ls inhere bandit4@bandit:~$ cd inhere bandit4@bandit:~/inhere$ ls -file00 -file02 -file04 -file06 -file08 -file01 -file03 -file05 -file07 -file09 bandit4@bandit:~/inhere$ file ./* ./-file00: data ./-file01: data ./-file02: data ./-file03: data ./-file04: data ./-file05: data ./-file06: data ./-file07: ASCII text ./-file08: data ./-file09: Non-ISO extended-ASCII text, with no line terminators bandit4@bandit:~/inhere$ cat ./-file07 lrIWWI6bB37kxfiCQZqUdOIYfr6eEeqR ``` ## Bandit5-6 - ssh bandit5@bandit.labs.overthewire.org -p 2220 - password: lrIWWI6bB37kxfiCQZqUdOIYfr6eEeqR - Dùng lệnh ls ta thấy folder inhere. - Dự kiện của đề : 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 - Nên ta sẽ cd inhere. Sau đó dùng ls để kiểm tra thì thấy rất nhiều file maybehere00 đến maybehere19. Sau đó dùng dự kiện 1033 bytes để dùng lệnh find * -size 1033c ta chỉ còn file maybehere07/.file2. Dùng cat để đọc nội dung file ```python! bandit5@bandit:~$ ls inhere bandit5@bandit:~$ cd inhere andit5@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$ find * -size 1033c maybehere07/.file2 bandit5@bandit:~/inhere$ cat maybehere07/.file2 P4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU ``` ## Bandit6-7 - ssh bandit6@bandit.labs.overthewire.org -p 2220 - password: P4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU - Dùng lệnh ls ta thấy folder inhere. - Dự kiện của đề : 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 - Dùng cd .. 2 lần để chuyển qua ngoài cùng của server sau đó dùng lệnh find -user bandit7 -group bandit6 - size 33c và tìm file nào không bị permission denied : ./var/lib/dpkg/info/bandit7.password sau đó cat file này ta được password ```python! bandit6@bandit:/$ find -user bandit7 -group bandit6 -size 33c bandit6@bandit:/$ cat ./var/lib/dpkg/info/bandit7.password z7WtoNQU2XfjmMtWA8u5rN4vzqu4v99S ``` ## Bandit7-8 - ssh bandit7@bandit.labs.overthewire.org -p 2220 - password: z7WtoNQU2XfjmMtWA8u5rN4vzqu4v99S - Đề: The password for the next level is stored in the file data.txt next to the word millionth - dùng cat và grep ```python! bandit7@bandit:~$ cat data.txt | grep millionth millionth TESKZC0XvTetK0S9xNwm25STk5iWrBvP ``` ## Bandit8-9 - ssh bandit8@bandit.labs.overthewire.org -p 2220 - password: TESKZC0XvTetK0S9xNwm25STk5iWrBvP - Đề: The password for the next level is stored in the file data.txt and is the only line of text that occurs only once - dùng sort và uniq ```python! bandit8@bandit:~$ cat data.txt | sort | uniq -u EN632PlfYiZbn3PhVK3XOGSlNInNE00t ``` ## Bandit9-10 - ssh bandit9@bandit.labs.overthewire.org -p 2220 - password: EN632PlfYiZbn3PhVK3XOGSlNInNE00t - Đề: 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. - Dùng strings và grep do trong data.txt có dữ liệu nhị phân mà grep không đọc được nên dùng cat không được còn strings chuyển dữ liệu nhị phân về dạng chuỗi cho grep có thể đọc được ```python! bandit9@bandit:~$ strings data.txt | grep = 4========== the# 5P=GnFE ========== password 'DN9=5 ========== is $Z=_ =TU% =^,T,? W=y q=W X=K, ========== G7w8LIi6J3kTb8A7j9LgrywtEUlyyp6s &S=( nd?= ``` ## Bandit10-11 - ssh bandit10@bandit.labs.overthewire.org -p 2220 - password: G7w8LIi6J3kTb8A7j9LgrywtEUlyyp6s - Đề: The password for the next level is stored in the file data.txt, which contains base64 encoded data - Decode bằng lệnh base64 -d ```python! bandit10@bandit:~$ base64 -d data.txt The password is 6zPeziLdR2RKNdNYFNb6nVCKzphlXHBM ``` ## Bandit11-12 - ssh bandit11@bandit.labs.overthewire.org -p 2220 - password: 6zPeziLdR2RKNdNYFNb6nVCKzphlXHBM - Đề: 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 - Dùng lệnh cat và tr ```python! bandit11@bandit:~$ cat data.txt | tr A-Za-z N-ZA-Mn-za-m The password is JVNBBFSmZwKKOP0XbFXOoW8chDz5yVRv ``` ## Bandit12-13 - ssh bandit12@bandit.labs.overthewire.org -p 2220 - password: JVNBBFSmZwKKOP0XbFXOoW8chDz5yVRv - Đề: 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 using mkdir. For example: mkdir /tmp/myname123. Then copy the datafile using cp, and rename it using mv (read the manpages!) - Dùng lệnh file để xem dạng nén của tệp sau đó giải nén lặp lại nhiều lần - Các lệnh xxd -r,gzip -d,bzip2 -d,tar -xvf ```python! bandit12@bandit:/tmp/khang2204$ cat data9 The password is wbWdlBxEir4CaE8LaPhauuOo6pwRmrDw ``` ## Bandit13-14 - ssh bandit13@bandit.labs.overthewire.org -p 2220 - password: wbWdlBxEir4CaE8LaPhauuOo6pwRmrDw - Đề: 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 - Dùng ssh -i và cat nội dung trong đường dẫn cho sẵn /etc/bandit_pass/bandit14 ```python! ssh bandit14@bandit.labs.overthewire.org -p 2220 -i sshkey.private bandit14@bandit:~$ cat /etc/bandit_pass/bandit14 fGrHPx402xGC7U7rXKDaxiWFTOiF0ENq ``` ## Bandit14-15 - ssh bandit14@bandit.labs.overthewire.org -p 2220 - password: fGrHPx402xGC7U7rXKDaxiWFTOiF0ENq - Đề: The password for the next level can be retrieved by submitting the password of the current level to port 30000 on localhost. - Dùng lệnh nc sau đó nhập password level hiện tại vào. ```python! bandit14@bandit:~$ nc localhost 30000 fGrHPx402xGC7U7rXKDaxiWFTOiF0ENq Correct! jN2kgmIXJ6fShzhT2avhotn4Zcka6tnt ``` ## Bandit15-16 - ssh bandit15@bandit.labs.overthewire.org -p 2220 - password: jN2kgmIXJ6fShzhT2avhotn4Zcka6tnt - Đề: The password for the next level can be retrieved by submitting the password of the current level to port 30001 on localhost using SSL encryption. - Helpful note: Getting “HEARTBEATING” and “Read R BLOCK”? Use -ign_eof and read the “CONNECTED COMMANDS” section in the manpage. Next to ‘R’ and ‘Q’, the ‘B’ command also works in this version of that command… - openssl kết hợp s_client và -ign_eof ```python! openssl s_client -connect localhost:30001 jN2kgmIXJ6fShzhT2avhotn4Zcka6tnt # nhập password lv hiện tại Correct! JQttfApK4SeyHwDlI9SXGR50qclOAil1 # password được nhận được ``` ## Bandit16-17 - ssh bandit16@bandit.labs.overthewire.org -p 2220 - password: JQttfApK4SeyHwDlI9SXGR50qclOAil1 - Đề: 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 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. - Dùng nmap để xác định port cần kết nối và dùng openssl để kết nối sau đó nhập mật khẩu level hiện tại và lấy mật khẩu sshkey sau đó tạo file sshkey và kết nối tới level tiếp theo ```python! nmap -A localhost -p 31000-32000 #kết quả là máy chủ ở port 31790 dùng ssl và đã trả lời Wrong! please enter the correct current password nên máy chủ cần tìm là nó 31790/tcp open ssl/unknown fingerprint-strings: | FourOhFourRequest, GenericLines, GetRequest, HTTPOptions, Help, Kerberos, LDAPSearchReq, LPDString, RTSPRequest, SIPOptions, SSLSessionReq, TLSSessionReq, TerminalServerCookie: |_ Wrong! Please enter the correct current password openssl s_client -connect localhost:31790 # sau đó nhập password level hiện tại ta được một đoạn mã sshkey nên ta cần tạo file key.private sau đó dùng chmod 600 rồi kết nối tới level tiếp theo sau đó cat nơi chứa mật khẩu để lấy mật khẩu bandit16@bandit:/tmp/sshkeylv16-17$ chmod 600 key.private bandit16@bandit:/tmp/sshkeylv16-17$ ssh bandit17@bandit.labs.overthewire.org -p 2220 -i key.private cat /etc/bandit_pass/bandit17 VwOSWtCA7lRKkTfbr2IDh6awj9RNZM5e ``` ## Bandit17-18 - ssh bandit17@bandit.labs.overthewire.org -p 2220 - password: VwOSWtCA7lRKkTfbr2IDh6awj9RNZM5e - Đề: 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 - NOTE: if you have solved this level and see ‘Byebye!’ when trying to log into bandit18, this is related to the next level, bandit19 - Dùng lệnh diff . ```python! bandit17@bandit:~$ diff passwords.new passwords.old 42c42 < hga5tuuCLF6fFzUpnagiMN8ssu9LFrdg # file new --- > glZreTEH1V3cGKL6g4conYqZqaEj0mte # file old ``` ## Bandit18-19 - ssh bandit18@bandit.labs.overthewire.org -p 2220 - password: hga5tuuCLF6fFzUpnagiMN8ssu9LFrdg - Đề: 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. - Dùng lệnh ssh để truy cập vào bandit18 nhưng khi vừa vào ta đã bị ngắt kết nối. Vậy hãy thử lệnh cat ngay sau lệnh ssh để có thể lấy được password ngay sau khi kết nối vào trước khi ngắt kết nối. ```python! khang2204@khang2204:~$ ssh bandit18@bandit.labs.overthewire.org -p 2220 cat readme _ _ _ _ | |__ __ _ _ __ __| (_) |_ | '_ \ / _` | '_ \ / _` | | __| | |_) | (_| | | | | (_| | | |_ |_.__/ \__,_|_| |_|\__,_|_|\__| This is an OverTheWire game server. More information on http://www.overthewire.org/wargames bandit18@bandit.labs.overthewire.org's password: awhqfNnAbc1naukrpqDYcF95h7HoMTrC ``` ## Bandit19-20 - ssh bandit19@bandit.labs.overthewire.org -p 2220 - password: awhqfNnAbc1naukrpqDYcF95h7HoMTrC - Đề: 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. - Dùng ls có file bandit20-do. Để chạy file setuid thì gọi ./bandit20-do trong khi chạy file ta sẽ được truy cập vào /etc/bandit_pass/bandit20 ```python! bandit19@bandit:~$ ./bandit20-do cat /etc/bandit_pass/bandit20 VxCazJaVykI6W36BkBU0mJTCM8rR95XT ``` ## Bandit20-21 - ssh bandit20@bandit.labs.overthewire.org -p 2220 - password: VxCazJaVykI6W36BkBU0mJTCM8rR95XT - Đề: 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). - NOTE: Try connecting to your own network daemon to see if it works as you think - Hình ảnh thao tác ở trong link sau: [Bandit20-21](https://drive.google.com/file/d/1FqZn-jb3NkM2JDaR5-MqzinJ0bzONTyx/view?usp=drive_link) ## Bandit21-22 - ssh bandit21@bandit.labs.overthewire.org -p 2220 - password: NvEJF7oVjkddltPSrdKEFOllh9V1IBcq - Đề: 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. - Làm theo dữ kiện đề tới /etc/cron.d đọc thông tin file bandit22. Sau đó file đó cho đường dẫn rồi đi tới file đường dẫn ... 1 lúc sau sẽ có đáp án. ```python! bandit21@bandit:/etc/cron.d$ ls cronjob_bandit15_root cronjob_bandit23 e2scrub_all cronjob_bandit17_root cronjob_bandit24 otw-tmp-dir cronjob_bandit22 cronjob_bandit25_root sysstat bandit21@bandit:/etc/cron.d$ cat cronjob_bandit22 @reboot bandit22 /usr/bin/cronjob_bandit22.sh &> /dev/null * * * * * bandit22 /usr/bin/cronjob_bandit22.sh &> /dev/null bandit21@bandit:/etc/cron.d$ cat /usr/bin/cronjob_bandit22.sh #!/bin/bash chmod 644 /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv cat /etc/bandit_pass/bandit22 > /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv bandit21@bandit:/etc/cron.d$ cat /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv WdDozAdTM2z9DiFEQ2mGlwngMfj4EZff ``` ## Bandit22-23 - ssh bandit22@bandit.labs.overthewire.org -p 2220 - password: WdDozAdTM2z9DiFEQ2mGlwngMfj4EZff - Đề: 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. - NOTE: Looking at shell scripts written by other people is a very useful skill. The script for this level is intentionally made easy to read. If you are having problems understanding what it does, try executing it to see the debug information it prints. - Sau khi làm như bài trên thì ta được 1 đoạn shell scripts. Sau khi đọc ta có thể thấy là bandit23 sẽ thay thế cho whoami vậy sau khi thay thế vào mytarget ta có thể tìm được thư mục chứ mật khẩu. ```python! bandit22@bandit:~$ ls bandit22@bandit:~$ cd /etc/cron.d/ bandit22@bandit:/etc/cron.d$ ls cronjob_bandit15_root cronjob_bandit23 e2scrub_all cronjob_bandit17_root cronjob_bandit24 otw-tmp-dir cronjob_bandit22 cronjob_bandit25_root sysstat bandit22@bandit:/etc/cron.d$ cat cronjob_bandit23 @reboot bandit23 /usr/bin/cronjob_bandit23.sh &> /dev/null * * * * * bandit23 /usr/bin/cronjob_bandit23.sh &> /dev/null bandit22@bandit:/etc/cron.d$ 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:/etc/cron.d$ echo I am user bandit23 | md5sum | cut -d ' ' -f 1 8ca319486bfbbc3663ea0fbe81326349 bandit22@bandit:/etc/cron.d$ cat /tmp/^C bandit22@bandit:/etc/cron.d$ cat /tmp/8ca319486bfbbc3663ea0fbe81326349 QYw0Y2aiA672PsMmh9puTQuhoz8SyR2G ``` ## Bandit23-24 - ssh bandit23@bandit.labs.overthewire.org -p 2220 - password: QYw0Y2aiA672PsMmh9puTQuhoz8SyR2G - Đề: 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. - 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! - NOTE 2: Keep in mind that your shell script is removed once executed, so you may want to keep a copy around… - Sau khi làm như bài trên thì ta được 1 đoạn shell scripts. Từ bài trước ta thấy để có mật khẩu thì cần có file script shell có lệnh cat /etc/bandit_pass/$myname > /tmp/$mytarget. Bởi vì lệnh này sẽ cho phép lấy mật khẩu trong nơi lưu trữ bandit24(nơi mà chỉ có người dùng bandit24 đọc được) và chép pass này ra /tmp/target(nơi bất kì ai chỉ cần có tên file target là đọc được). Và file shell scripts của đề chỉ đang tìm 1 file trong đường dẫn /var/spool/$myname/foo và có tên khác 2 file ẩn là . và .. để chạy sau đó xóa mọi file ở đó nhiệm vụ của chúng ta là cần code 1 file script shell có nhiệm vụ lấy mật khẩu như ở trên đã nói sau đó chmod để thay đổi quyền truy cập cho phép file shell script của chúng ta được đọc ghi và thực thi (=> chmod 777) và đưa vào đường dẫn mà file scripts shell của đề đọc để chạy và lấy mật khẩu. Lưu ý phải đợi 1 lúc để file pass.txt được gửi về. ```python! bandit23@bandit:/tmp/ac24$ chmod 777 key.sh bandit23@bandit:/tmp/ac24$ cp key.sh /var/spool/bandit24/foo bandit23@bandit:/tmp/ac24$ ls key.sh bandit23@bandit:/tmp/ac24$ nano key.sh Unable to create directory /home/bandit23/.local/share/nano/: No such file or directory It is required for saving/loading search history or cursor positions. bandit23@bandit:/tmp/ac24$ ls key.sh pass.txt bandit23@bandit:/tmp/ac24$ cat pass.txt VAfGXJ1PBSsPSnvsjI8p759leLZ9GGar ``` ## Bandit24-25 - ssh bandit24@bandit.labs.overthewire.org -p 2220 - password: VAfGXJ1PBSsPSnvsjI8p759leLZ9GGar - Đề: 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. - You do not need to create new connections each time - Mỗi lần kết nối tới cổng 30002 rồi nhập pass pin bằng tay quá lâu nên ta viết file cpp để vét hết các trường hợp mã pin và xuất vào file txt bằng lệnh: g++ c.cpp -o c và ./c > text.txt. Sau đó cat text.txt| nc localhost 30002 để nhập vào tất cả trường hợp 1 lần rồi tìm trường hợp đúng bằng lệnh grep ```C++ #include<bits/stdc++.h> using namespace std; int main() { for(int i=8000; i<=9999; i++) { string s=""; int x=i; for(int j=1; j<=4; j++) { s+=('0'+(char)(x%10)); x/=10; } reverse(s.begin(),s.end()); cout<<"VAfGXJ1PBSsPSnvsjI8p759leLZ9GGar"<<" "<<s<<"\n"; } } ``` ![](https://hackmd.io/_uploads/S1f_QqtAn.png) ## Bandit25-27 - ssh bandit25@bandit.labs.overthewire.org -p 2220 - password: p7TaowMYrmu23Ol8hiZh9UvD0O9hpx8d - Đề: 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. - Kết nối bằng file sshkey sắp vào được thì bị văng ra. - ![](https://hackmd.io/_uploads/Hy2p29KAh.png) - ![](https://hackmd.io/_uploads/BJJT6qtC2.png) - ![](https://hackmd.io/_uploads/r1LJ05YCh.png) - Vấn đề ở việc lệnh more kết thúc khi kết nối nên để kết nối ta phải để lệnh more không kết thúc khi kết nối mà khi hiển thị hết thì lệnh more mới kết thúc ta sẽ thu nhỏ màn hình lại để lệnh more không bị kết thúc. - ![](https://hackmd.io/_uploads/S1a8CqFC2.png) - Nhấn v để gọi vim Chỉnh shell về bin/bash bằng lệnh :set shell=/bin/bash , :sh. Để lấy password level 26 thì cat /etc/bandit_pass/bandit26 - ![](https://hackmd.io/_uploads/H1u_XjYAn.png) **password26 : c7GvcKlw9mC7aUQaPx7nwFstuAIBw1o1** - Sau đó dùng ls được file bandit27-do nên chạy file lấy luôn password bandit27 - ![](https://hackmd.io/_uploads/BJ9qVoFC2.png) **password27 : YnQpBuifNMas1hcUFk70ZmqkhUU2EuaS** ## Bandit27-28 - ssh bandit27@bandit.labs.overthewire.org -p 2220 - password: YnQpBuifNMas1hcUFk70ZmqkhUU2EuaS - Đề: 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. - Clone the repository and find the password for the next level. - Tạo thư mục mới dùng git clone - ![](https://hackmd.io/_uploads/HkU6IstCn.png) - ![](https://hackmd.io/_uploads/B1JkPjF0n.png) ## Bandit28-29 - ssh bandit28@bandit.labs.overthewire.org -p 2220 - password: AVanL161y9rsbcJIsFHuw35rjaOM19nR - Đề: 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. - Clone the repository and find the password for the next level. - Tương tự như trên nhưng bài này không tìm thấy password bằng cách đó - ![](https://hackmd.io/_uploads/B1s2vsK03.png) - Dùng git log để xem lại lịch sử - ![](https://hackmd.io/_uploads/HyxXOit02.png) - Dùng git show để check cái đầu tiên nhưng vẫn không thấy gì - ![](https://hackmd.io/_uploads/BkZBdiKAn.png) - Đến cái thứ 2 thì xuất hiện password. - ![](https://hackmd.io/_uploads/rJUwusYC3.png) **password tQKvmcwNYcFS6vmPHIUSI3ShmsrQZK8S** ## Bandit29-30 - ssh bandit29@bandit.labs.overthewire.org -p 2220 - password: tQKvmcwNYcFS6vmPHIUSI3ShmsrQZK8S - Đề: 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. - Clone the repository and find the password for the next level. - Làm tương tự các bài trên và vẫn không tìm đường password - ![](https://hackmd.io/_uploads/HkmYFsYC2.png) - Có thể có nhiều nhánh nên dùng git branch -r để liệt kê. - ![](https://hackmd.io/_uploads/B1y45sK0h.png) - Sau đó qua nhánh dev xem nội dung thì may mắn đã thấy được password - ![](https://hackmd.io/_uploads/BJR59ot0n.png) **password:xbhV3HpNGlTIdnjUrdAlPzc2L6y9EOnS** ## Bandit30-31 - ssh bandit30@bandit.labs.overthewire.org -p 2220 - password: xbhV3HpNGlTIdnjUrdAlPzc2L6y9EOnS - Đề: 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. - Clone the repository and find the password for the next level. - Làm giống các bài trên. Nhưng lần này trong file README.md không có gì cả. - ![](https://hackmd.io/_uploads/H15jjiYR2.png) - Tiến hành xem tag - ![](https://hackmd.io/_uploads/Sycq2iKCn.png) **password:OoffzGDlzhAlerFJ2cAiz1D41JW1Mhmt** ## Bandit31-32 - ssh bandit31@bandit.labs.overthewire.org -p 2220 - password: OoffzGDlzhAlerFJ2cAiz1D41JW1Mhmt - 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. - Clone the repository and find the password for the next level. - Làm như trên vào đọc file README.md - ![](https://hackmd.io/_uploads/Sy8RRoY02.png) - Nó yêu cầu chúng ta tạo file key.txt có nội dung May I come in rồi bỏ ở nhánh master. - Dùng lệnh git add để đưa các thay đổi từ thư mục làm việc vào trạng thái chờ để chuẩn bị cho một commit tuy nhiên có vấn đề sau: - ![](https://hackmd.io/_uploads/SyscJ2K02.png) - Do trong file .gitignore có .txt nên ta phải dùng lệnh git add -f key.txt để bỏ qua tệp hoặc thư mục đã bị xác định trong tệp .gitignore(tệp .txt) và bắt buộc Git để theo dõi tệp key.txt. - Sau đó git commit -m "Add key" - ![](https://hackmd.io/_uploads/r1SMb2FR3.png) - Rồi push lên để lấy password - ![](https://hackmd.io/_uploads/rJGqWnt03.png) - ![](https://hackmd.io/_uploads/BkOjbntA3.png) **password:rmCBvG56y58BXzv98yZGdO7ATVL5dW8y** ## Bandit32-33 - ssh bandit32@bandit.labs.overthewire.org -p 2220 - password: rmCBvG56y58BXzv98yZGdO7ATVL5dW8y - Đề: After all this git stuff its time for another escape. Good luck! - ![](https://hackmd.io/_uploads/Hk33fhtRn.png) - Có cái UPPERCASE SHELL để thoát khỏi nó thì ta dùng lệnh $0 sau đó vô lấy password thôi - ![](https://hackmd.io/_uploads/Hkkfm2KCh.png) **password: odHo63fHiFqcWWJG9rLiLDtPm45KzUKy** ## Bandit33-34 - ssh bandit33@bandit.labs.overthewire.org -p 2220 - password: odHo63fHiFqcWWJG9rLiLDtPm45KzUKy - Đề: At this moment, level 34 does not exist yet. - ![](https://hackmd.io/_uploads/SJ1CX2KC3.png) - Xong rồi !!!