--- title: OverTheWire Bandit Writeup 34 Levels tags: wargame --- ## Level 0 Level 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. ``` Level này ta chỉ cần login được vào ssh server với host là `bandit.labs.overthewire.org` account `bandit0:bandit0` ở port 2220 ![](https://i.imgur.com/aY3k60I.png) Login thành công ![](https://i.imgur.com/Id5oRX1.png) > Pass: `bandit0` --- ## Level 0 → Level 1 Level Goal: ```! The password for the next level is stored in a file called readme located in the home directory. Use this password to log into bandit1 using SSH. Whenever you find a password for a level, use SSH (on port 2220) to log into that level and continue the game. ``` Ta chỉ cần đọc file `readme` ở thư mục home là xong ![](https://i.imgur.com/DXsC3YW.png) > Pass: `NH2SXQwcBdpmTEzi3bvBHMM9H66vVXjL` --- ## Level 1 → Level 2 Level Goal ```! The password for the next level is stored in a file called - located in the home directory ``` Login lại ssh server với user là `bandit1` và password lấy từ level trước, sẽ có một file là `-` ![](https://i.imgur.com/CzfGB9X.png) Vì tên file này khá đặt biệt nên để đọc thì ta sẽ làm như sau ![](https://i.imgur.com/OWQL4QG.png) > Pass: `rRGizSaX8Mk1RTb1CNQoXTcYZWU6lgzi` --- ## Level 2 → Level 3 Level Goal: ```! The password for the next level is stored in a file called spaces in this filename located in the home directory ``` Ssh vào server sẽ thấy môt file có tên là `spaces in this filename` ![](https://i.imgur.com/MpT4adE.png) Để đọc file này có rất nhìu cách, ví dụ: dùng `\` để escape dấu ` ` hoặc có thể dùng wildcard để đọc tất cả file trong thư mục home ... ![](https://i.imgur.com/mTPfIy0.png) > Pass: `aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG` --- ## Level 3 → Level 4 Level Goal ```! The password for the next level is stored in a hidden file in the inhere directory. ``` Có một thư mục tên là `inhere` ở thư mục home ![](https://i.imgur.com/dRqvKY4.png) và nhiệm vụ của ta là đọc được file ẩn trong thư mục này. Để list ra tất cả các file trong thư mục hiện tại sử dụng lệnh `ls -a` ![](https://i.imgur.com/9wMrmFg.png) Và đọc nó thôi ![](https://i.imgur.com/Eu3hWrV.png) > Pass: `2EW7BBsr6aMMoJ2HjW067dm8EgX26xNe` --- ## Level 4 → Level 5 Level 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. ``` List ra các file trong thư mục `inhere` ![](https://i.imgur.com/yZojsJd.png) Dùng command `file` để check thuộc tính của các file ![](https://i.imgur.com/1vDZuQ4.png) Tới đây ta cat file 07 là được password cho level kế tiếp ![](https://i.imgur.com/HhaLz4z.png) > Pass: `lrIWWI6bB37kxfiCQZqUdOIYfr6eEeqR` --- ## Level 5 → Level 6 Level 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 ``` Trong folder `inhere` bao gồm nhiều folder khác ![](https://i.imgur.com/TtVMuLF.png) Dùng command find với các option như sau để thỏa yêu cầu của đề ![](https://i.imgur.com/Pswqd3b.png) Cuối cùng chỉ cần cat file này ra là có password ![](https://i.imgur.com/WnJfJyt.png) > Pass: `P4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU` --- ## Level 6 → Level 7 Level 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 ``` Vẫn tương tự như bài trước, nhưng ở đây dùng 2 option là -user và -group để check ![](https://i.imgur.com/aVlwmND.png) `2>/dev/null` để redirect std error vào `/dev/null` -> tránh print lỗi ra terminal Và lấy password ![](https://i.imgur.com/ukjJf0X.png) > Pass: `z7WtoNQU2XfjmMtWA8u5rN4vzqu4v99S` --- ## Level 7 → Level 8 Level Goal ```! The password for the next level is stored in the file data.txt next to the word millionth ``` Có một file là `data.txt` nằm ở thư mục home, tuy nhiên size khá lớn ![](https://i.imgur.com/ZpteIJx.png) Đề gợi ý pass nằm kế string `millionth` => có thể dùng command grep ![](https://i.imgur.com/3i4jSeH.png) > Pass: `TESKZC0XvTetK0S9xNwm25STk5iWrBvP` --- ## Level 8 → Level 9 Level 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 ``` Trong thư mục home có file `data.txt` như đã mô tả ![](https://i.imgur.com/xFX83cE.png) Dùng sort + uniq -u để tìm dòng xuất hiện 1 lần - password ![](https://i.imgur.com/06HDnUs.png) > Pass: `EN632PlfYiZbn3PhVK3XOGSlNInNE00t` --- ## Level 9 → Level 10 Level 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. ``` Dùng grep với ^= để tìm các dòng bắt đầu với `=` trong file data.txt ![](https://i.imgur.com/4fhFh3b.png) Lỗi bởi vì trong file data.txt được xem là binary file khi pipe trực tiếp qua grep Có thể dùng thêm command `strings` ![](https://i.imgur.com/3Gy9uZo.png) > Pass: `G7w8LIi6J3kTb8A7j9LgrywtEUlyyp6s` --- ## Level 10 → Level 11 Level Goal ```! The password for the next level is stored in the file data.txt, which contains base64 encoded data ``` File data.txt nằm ở thư mục home, thử cat file này ra thì ta thấy nó đã bị base64 encode ![](https://i.imgur.com/yKKFPNm.png) Dùng pipe qua base64 command với option -d để decode, ta được password cho level kế ![](https://i.imgur.com/Cf0nXCl.png) > Pass: `6zPeziLdR2RKNdNYFNb6nVCKzphlXHBM` --- ## Level 11 → Level 12 Level 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 ``` Cat thử file data.txt, dựa theo mô tả của đề thì có vẻ như nó đã bị encrypt với rot13 ![](https://i.imgur.com/6TST7Dz.png) Thử search cách để decrypt rot13 trên linux ta được ![](https://i.imgur.com/FeRXTSf.png) Dùng `tr 'A-Za-z' 'N-ZA-Mn-za-m'` để decrypt ta được password ![](https://i.imgur.com/bIruS9z.png) > Pass: `JVNBBFSmZwKKOP0XbFXOoW8chDz5yVRv` --- ## Level 12 → Level 13 Level 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 using mkdir. For example: mkdir /tmp/myname123. Then copy the datafile using cp, and rename it using mv (read the manpages!) ``` Trước tiên ta sẽ tạo folder `/tmp/to` và copy file data.txt đến folder này theo như mô tả ![](https://i.imgur.com/rYD9bmc.png) Sau đó ta reverse lại file hexdump này với xxd ![](https://i.imgur.com/uRm5jKj.png) Check thuộc tính với command `file` ![](https://i.imgur.com/9w9T91G.png) Đổi tên, thêm extension cho file và gz decompress ![](https://i.imgur.com/W8dSqXe.png) Ta được một file mới là `dump` ![](https://i.imgur.com/QUKIJxt.png) Tiếp tục check thuộc tính của file này ![](https://i.imgur.com/NY4uCQ9.png) Thêm extension cho file và tiếp đục bzip decompress ![](https://i.imgur.com/MMAXYLq.png) Lại được một file gzip compress ![](https://i.imgur.com/gN8rUk9.png) Tiếp tục ![](https://i.imgur.com/B5zKofL.png) ![](https://i.imgur.com/LuVOHZD.png) ![](https://i.imgur.com/THZTmui.png) ![](https://i.imgur.com/chWRGH2.png) ![](https://i.imgur.com/ko3wP00.png) ![](https://i.imgur.com/JrwdrLn.png) ![](https://i.imgur.com/e0qxia0.png) Tới đây ta đã có password ![](https://i.imgur.com/e3qVq2V.png) > Password: `wbWdlBxEir4CaE8LaPhauuOo6pwRmrDw` --- ## Level 13 → Level 14 Level 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 ``` Thử kết nối vào và xem đề cho ta những gì ![](https://i.imgur.com/uN09ANE.png) Thấy rằng máy đang chứa 1 tệp tin sshkey.private, tệp này được dùng để kết nối đến level tiếp theo. Tiến hành đọc doc để xem cách dùng tệp key này với lệnh ssh như nào. ![](https://i.imgur.com/ZiKbuAt.png) Option `-i` cho phép chúng ta dùng tệp key để kết nối. Kết hợp với dữ kiện đề cho là localhost là hostname cần kết nối đến. ![](https://i.imgur.com/JpsnJuP.png) Kết nối thành công ![](https://i.imgur.com/vX5eTaf.png) Tiến hành đọc passwork theo đường dẫn đề yêu cầu ![](https://i.imgur.com/tO09N81.png) > Password: `fGrHPx402xGC7U7rXKDaxiWFTOiF0ENq` ## Level 14 → Level 15 Level Goal ```! The password for the next level can be retrieved by submitting the password of the current level to port 30000 on localhost ``` Tiến hành dùng lệnh `nc` để gửi password đã lấy được ở level trước đến cổng 30000 localhost để lấy password mới ![](https://i.imgur.com/ViWmELR.png) > Password: `jN2kgmIXJ6fShzhT2avhotn4Zcka6tnt` ## Level 15 → Level 16 Level 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 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… ``` Đề bài yêu cầu rằng cần gửi password của level hiện tại được mã hoá SSL qua cổng 30001 của localhost. Xem manual của lệnh `ncat` và search google ta thấy option `--ssl` ![](https://i.imgur.com/kXKMJqU.png) ![](https://i.imgur.com/u4X1m34.png) Tiến hành kết nối đến localhost với mã hoá ssl và gửi password ![](https://i.imgur.com/i8znK55.png) > Password: `JQttfApK4SeyHwDlI9SXGR50qclOAil1` ## Level 16 → Level 17 Level 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 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. ``` Chúng ta cần tìm ra xem cổng nào trong đoạn 31000 đến 32000 sẽ trả về thứ chúng ta cần, là credentials cho level tiếp theo. Search google ta thấy được `Nmap` có chứng năng scan các port ![](https://i.imgur.com/Sdm77KY.png) Tiến hành scan các port đề cho ![](https://i.imgur.com/Cq1OU70.png) Thấy có tổng cộng 5 port đang mở, tiến hành gửi từng port để xem port nào gửi về thứ ta cần ![](https://i.imgur.com/PyerS4t.png) Cổng 31790 trả về thứ cần tìm ## Level 17 → Level 18 Level Goal ```! 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 ``` Đề cho ta 2 tệp và yêu cầu tìm ra dòng khác nhau ở tệp password.new so với tệp password.old Search google thì thấy lệnh `diff` sẽ tìm điểm khác nhau giữa 2 tệp cho ta ![](https://i.imgur.com/OU6bt98.png) Tiến hành tìm kiếm ![](https://i.imgur.com/3z4XeMI.png) > Password: `hga5tuuCLF6fFzUpnagiMN8ssu9LFrdg` ## Level 18 → Level 19 Level Goal ```! 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. ``` Thử kết nối vào thì chúng ta sẽ bị văng ra ![](https://i.imgur.com/G6ezfqM.png) Search google ta thấy được rằng SSH thông thường sử dụng pseudo-terminal. Để không bị văng ra ngay lúc kết nối, thử tìm cách không dùng pseudo-terminal. Search trên trang SSHOpen Linux Manual, ta thấy dùng option -T có thể loại bỏ đc pseudo-terminal ![](https://i.imgur.com/9oQpNOH.png) Áp dụng thử ![](https://i.imgur.com/5rxl9hs.png) > Password: `awhqfNnAbc1naukrpqDYcF95h7HoMTrC` ## Level 19 → Level 20 Level Goal ```! 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. ``` Thử kết nối vào xem đề cho ta cái gì ![](https://i.imgur.com/xv1uhiv.png) Một tệp tin bandit20-do được highlight màu đỏ Cat ra thì thấy đây là tệp binary thực thi 1 cái gì đó ![](https://i.imgur.com/XozZf8S.png) Thực thi thử thì thấy đây là file giúp ta thực thi dưới quyền là user bandit20 ![](https://i.imgur.com/njZ9YhQ.png) Tiến hành lấy password thôi ![](https://i.imgur.com/RwKgpaO.png) > Password: `VxCazJaVykI6W36BkBU0mJTCM8rR95XT` ## Level 20 → Level 21 Level Goal ```! 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 ``` Đọc đề bài ta thấy rằng, tại home sẽ có một tệp setuid binary sẽ kết nối đến cổng mà ta chỉ định tại localhost và sẽ đọc 1 dòng text từ đó và so sánh xem nó có giống với password ở level 20 không, nếu có thì nhả ra password. ![](https://i.imgur.com/E0kdiWi.png) Đầu tiên ta cần tạo 1 listener tại localhost để lắng nghe kết nối đến. Và sẽ gửi password của level 20 cho bất kì kết nối nào kết nối đến nó. Và đưa nó xuống chạy nền. ![](https://i.imgur.com/khL9FUa.png) Kiểm tra xem có tồn tại hay không ![](https://i.imgur.com/IAaMKv6.png) Dùng tệp suconnect được cho để kết nối đến và lấy pass ![](https://i.imgur.com/vNlva9M.png) > Password: `NvEJF7oVjkddltPSrdKEFOllh9V1IBcq` ## Level 21 → Level 22 Level Goal ```! 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ần theo hướng dẫn của đề, ta tìm tồi và tiến vào thư mục `/etc/cron.d/` để xem trong này có cái gì. ![](https://i.imgur.com/VfaaD1C.png) Có các thư mục, mục tiêu của chúng ta là tìm ra password của level 22, `cat cronjob_bandit22` tìm hiểu tệp này mần cái gì ![](https://i.imgur.com/ULec6YT.png) Tệp này sẽ set cho câu lệnh `/usr/bin/cronjob_bandit22.sh` thực thi mỗi lần khởi động và mỗi 1 phút. Có thêm manh mối, vào tệp `cronjob_bandit22.sh` xem nó có cái gì. ![](https://i.imgur.com/EEEn0m9.png) Thấy rằng nó làm 2 việc, set quyền cho tệp `/tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv` và truyền password của bandit22 vào tệp này. Đọc tệp này là ta sẽ có được password cần tìm ![](https://i.imgur.com/evusrEM.png) > Password: `WdDozAdTM2z9DiFEQ2mGlwngMfj4EZff` ## Level 22 → Level 23 Level Goal ```! 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. ``` Đề vẫn yêu cầu ta vào thư mục `etc/cron.d/` để xem có những gì. Vào đấy ta thấy được có vài chương trình đang được set chạy, mục tiêu của ta là level 23, mở xem `cronjob_bandit23` nó như nào ![](https://i.imgur.com/YUJtpIL.png) Nó thực hiện `/usr/bin/cronjob_bandit23.sh` mỗi lần khởi động và mỗi 1 phút. Tiếp tục xem `cronjob_bandit23.sh` thực hiện những gì. ![](https://i.imgur.com/MgoYbH9.png) Xem shell thấy rằng nó sẽ ghi password của bandit23 vào tệp có tên là kết quả của md5sum của "I am user bandit23". Ý tưởng ban đầu là thử thay đổi mytarget để nó về tệp ta muốn nhưng không được. Thử cách khác là tính md5sum của "I am user bandit23" sau đó `cat` nội dung của tệp đấy ra. ![](https://i.imgur.com/Qmrf7ST.png) > Password: `QYw0Y2aiA672PsMmh9puTQuhoz8SyR2G` ## Level 23 → Level 24 Level Goal ```! 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… ``` Tiến vào thư mục `etc/cron.d/` và đọc nội dung thực thi của chương trình ![](https://i.imgur.com/C6FNXvr.png) Phân tích ta thấy rằng đoạn script này sẽ `cd /var/spool/bandit24/foo` và thực thi các tệp có dạng *.* với quyền sở hữu là của bandit23. Ý tưởng khai thác là chúng ta sẽ viết một script để cho bandit24 thực thi và gửi password về cho chúng ta ở thư mục ta chỉ định thuộc /tmp Tạo thư mục sẽ chứa pass24 được gửi về và chứa đoạn script của ta. ![](https://i.imgur.com/M3sS9Vp.png) Viết script khai thác ![](https://i.imgur.com/tpMpXZ2.png) Copy chuyển vào trong `/var/spool/bandit24/foo` để bandit24 thực thi nó ![](https://i.imgur.com/B0dJ51c.png) Đợi 1 lát thì pass24 xuất hiện trong thư mục `/tmp/TO`. `Cat` ra ta được password. ![](https://i.imgur.com/IPCx1Ss.png) > Password: `VAfGXJ1PBSsPSnvsjI8p759leLZ9GGar` ## Level 24 → Level 25 Level Goal ```! 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. ``` Đề bảo ta cần kết nối đến localhost cổng 30002 và gửi password của level 24 cùng với mã pin là 1 dãy 4 số từ 0000-9999 và đề gợi ý rằng chún ta cần brutefore để có thể giải. Ý tưởng đầu tiên là viết loop kết nối đến `nc` mỗi lần tạo ra 1 trường hợp nhưng chạy lâu quá. Thay vào đó sẽ viết script tạo ra 1 tệp chứa hết các trường hợp đặt tên là `input.txt`, truyền tệp nào vào `nc` để chạy lẹ hơn. ![](https://i.imgur.com/wYuxucp.png) Thực thi và kiểm tra. Tệp input gồm các dòng có format là "pass_bandit24 pin" ![](https://i.imgur.com/KqcrNhH.png) `cat` nội dung `input.txt` vào `nc localhost 30002` đưa kết quả vào tệp `output.txt`. ![](https://i.imgur.com/M69B9hP.png) Nội dung của tệp output.txt sẽ lẫn lộn các trường hợp sai và một trường hợp đúng. Khi thử `cat output.txt` trường hợp sai có cú pháp là "Wrong!", tình cờ password nằm ở cuối tệp 😀😀 ![](https://i.imgur.com/lDvHbL0.png) Ta có thể dùng `grep -v "Wrong"` để loại bỏ các trường hợp này, khi đó password sẽ hiện ra ![](https://i.imgur.com/VUCkFuU.png) > Password: `p7TaowMYrmu23Ol8hiZh9UvD0O9hpx8d` ## Level 25 → Level 26 Level Goal ```! 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 vào dùng lệnh `ls` ta thấy được một tệp key, dùng lệnh `ssh -i` để thử kết nối đến bandit26 với tâm trạng ngon ăn trong lòng. Kết quả là vừa kết nối vào đã bị dis ra. ![](https://i.imgur.com/bnqaKd6.png) Hơi mừng hụt nhưng không sao, xem lại đề thấy rằng bandit26 không dùng `/bin/bash`, tiến hành vào kiểm tra thử. Truy cập vào và `cat /etc/passwd` và dùng grep để lọc ra thứ ta cần. ![](https://i.imgur.com/9B3UwVa.png) Thấy rằng bandit26 dùng cái `/usr/bin/showtext`.Vô đó xem thử ![](https://i.imgur.com/oyiU3g8.png) Nó sẽ exit ngay sau khi nó kiểm tra xong và show hết thông tin. Có thể lệnh `more` sẽ có gì đó, đi search google đọc về lệnh này. ![](https://i.imgur.com/MIc5cEg.png) Có thể hiểu là nó sẽ hiển thị tất cả trong 1 lần gọi, nó sẽ hiển thị như cuốn sách,có lật qua các trang sau khi tệp quá dài. Khi nào hiển thị hết thì nó mới kết thúc. Bây giờ ta đã có ý tưởng là làm sao để lệnh `more` không kết thúc ngay khi ta kết nối đến bandit26, kéo cái màng hình nhỏ lại khi đó more sẽ kgonog hiển thị hết và nó sẽ không kết thúc ngay. ![](https://i.imgur.com/5yWXqC9.png) Bây giờ thì tiến hành khai thác thoi. Gọi vim và setup shell để gõ lệnh lấy password từ `/etc/pass_bandit/bandit26` ![](https://i.imgur.com/3dCY3gD.png) > Password: `c7GvcKlw9mC7aUQaPx7nwFstuAIBw1o1` ## Level 26 → Level 27 Level Goal ```! Good job getting a shell! Now hurry and grab the password for bandit27! ``` Cũng cần phải kéo cho cái khung nhỏ lại để không bị dis ra, thử dùng lệnh `ls` xem đề cho ta những gì, thấy một tệp bandit27-do. ![](https://i.imgur.com/aOT1oIF.png) Giống như ở level nào đó ở trước, đây là một tệp binary cho phép ta thực thi câu lệnh dưới quyền bandit27 ![](https://i.imgur.com/ihS0gMd.png) Lấy nó xài gòi `cat` ra cái password của bandit27 thoi nào ![](https://i.imgur.com/E506aUl.png) > Password: `YnQpBuifNMas1hcUFk70ZmqkhUU2EuaS` ## Level 27 → Level 28 Level Goal ```! There is a git repository at ssh://bandit27-git@localhost/home/bandit27-git/repo. 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. ``` Ở level này đều yêu cầu mình `git clone` cái repo từ cái link đề cho về rùi vọc trong đó. thử `git clone` nó về thử ![](https://i.imgur.com/2YNCJDL.png) Kết quả là không được, đọc sơ qua thấy nó bảo mình cố kết nối vào port 22 nên nó không cho, ngẫm lại thì từ đầu tới giờ làm ssh nó chỉ cho xài cổng 2220 thôi. Search google thì thấy có thể `git clone` custom port ![](https://i.imgur.com/3P1qU2g.png) Thử chỉ định cho nó cái cổng 2220, kết quả là clone về thành công. ![](https://i.imgur.com/N9n8Nkh.png) Truy cập vào và cat tệp REAME ra là có được password ![](https://i.imgur.com/ErhXUkX.png) > Password: `AVanL161y9rsbcJIsFHuw35rjaOM19nR` ## Level 28 → Level 29 Level Goal ```! There is a git repository at ssh://bandit28-git@localhost/home/bandit28-git/repo. 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ự ta cũng `git clone` về rùi xem nó có cái gì. Thấy rằng đây là 1 tệp chứa thông tin password đã bị che đi. ![](https://i.imgur.com/lNkPOcy.png) Dùng lệnh `git log -p` để xem lịch sử sửa chữa của tệp này và chỉ ra các khác biệt giữa tệp trước đó so với tệp đã được thao tác lên. Lúc này password hiện ra ![](https://i.imgur.com/B4SkBKA.png) > Password: `tQKvmcwNYcFS6vmPHIUSI3ShmsrQZK8S` ## Level 29 → Level 30 Level Goal ```! There is a git repository at ssh://bandit29-git@localhost/home/bandit29-git/repo. 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. ``` Tiếp tục `git clone` về và xem thử ![](https://i.imgur.com/rXvVLaQ.png) Thử dùng lệnh `git log -p` để xem các điểm khác nhau giữa các lần comit ![](https://i.imgur.com/RRFhoRf.png) Không tìm được gì ở đây cả, nhưng một project có thể có nhiều nhánh, thử liệt kê các nhánh có trong git thử bằng lệnh `git branch -r` ![](https://i.imgur.com/yxCI7xe.png) Có các nhánh khác, thử vào từng nhánh và xem xét. Vào nhánh dev ![](https://i.imgur.com/XgsfVHX.png) Sau đấy tìm thử xem trong đấy có những gì và password hiện ra ![](https://i.imgur.com/43LEf9y.png) > Password: `xbhV3HpNGlTIdnjUrdAlPzc2L6y9EOnS` ## Level 30 → Level 31 Level Goal ```! There is a git repository at ssh://bandit30-git@localhost/home/bandit30-git/repo. 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. ``` Tiến hành clone về và xem nó có gì ![](https://i.imgur.com/gbZFikg.png) Một file rỗng và không có lịch sử chỉnh sửa. Thử xem các branch khác ![](https://i.imgur.com/qNILxcf.png) Không có branch nào khác cả, giờ chỉ còn 2 hướng là xem các tag của git và xem conflict của git. Thử xem git có tag không ![](https://i.imgur.com/g3QeSsE.png) Tồn tại 1 tag, mở ra xem thử thì đây là password ![](https://i.imgur.com/XHnTjLZ.png) > Password: `OoffzGDlzhAlerFJ2cAiz1D41JW1Mhmt` ## Level 31 → Level 32 Level Goal ```! There is a git repository at ssh://bandit31-git@localhost/home/bandit31-git/repo. 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. ``` Vẫn là tiếp tực `git clone` về và xem đề cho ta những gì. `Cat` tệp README.md thấy đề bảo ta tạo một tệp `key.txt` với nội dung là "Can I come in?" và `push` lên ở branch master. ![](https://i.imgur.com/UOYaQrb.png) Tiến hành tạo tệp theo yêu cầu và `push` lên ![](https://i.imgur.com/DwEzM2V.png) Kiểm tra branch và tiến hành `add` với `commit` ![](https://i.imgur.com/Lsqp79y.png) `push` lên và nhận password ![](https://i.imgur.com/yLMkUSk.png) > Password: `rmCBvG56y58BXzv98yZGdO7ATVL5dW8y` ## Level 32 → Level 33 Level Goal ```! After all this git stuff its time for another escape. Good luck! ``` Đọc vào đề bài, thấy nó bảo ta cần thoát ra khỏi cái gì đó. Tiến hành kết nối vào bandit32 và thử xem có g ì thú vị. ![](https://i.imgur.com/jnzOtoC.png) Đây là 1 shell mà nó sẽ viết hoa những gì ta nhập vào trước khi xử lý, vậy là cần thoát ra khỏi shell này. Thử tổ hợp `crt + z` chúng ta thoát ra được và quay về shell ban đầu. ![](https://i.imgur.com/ug0cZmq.png) Bây giờ chỉ việc `cat` cái password ra thôi ![](https://i.imgur.com/kxZFeuf.png) > Password: `odHo63fHiFqcWWJG9rLiLDtPm45KzUKy` ## Level 33 → Level 34 Level Goal ![](https://i.imgur.com/JBEtnDE.png) Doneee. Challenge 34 level bandit complete !!! 🥳🥳