Notification texts go here Contact Us Buy Now!

[Writeup] Bước vào thế giới CTF - Khởi đầu Bandit - OverTheWire

https://overthewire.org/wargames/bandit/

GIỚI THIỆU

CTF (Capture the Flag) - Cướp cờ xuất phát là một trò chơi thực tế  và thường xuất hiện trong các hoạt động tập thể với số lượng người nhất định chia làm hai đội.
Trong phạm vị của an ninh mạng thì CTF là trò chơi (hoặc cuộc thi) chuyên sâu dành cho tất cả những người tham gia từ chuyên đến không chuyên hoặc có đam mê với an ninh mạng muốn thử sức. Trong CTF người chơi sẽ phải vượt qua những thử thách bằng việc vận dụng những kiến thức hiểu biết và gợi ý để tìm ra lời giải.

Giới thiệu đôi chút vậy thôi, đi vào chủ đề chính của loạt bài viết này là 'Bước vào thế giới CTF - Khởi đầu Bandit - OverTheWire' thì đây sẽ là một series writeup của mình để 'đánh dấu' những kiến thức mà mình tự học được song song với loạt bài Writeup Practical Malware Analysis.

Đây là bài CTF-Writeup đầu tiên và mình chọn OverTheWire vì nó rất căn bản với người mới như mình.

Go ahead !

Vạn sự khởi đầu nan
万     事     开     头     难 
Wàn  shì  kāi   tóu   nán

NỘI DUNG

OverTheWire games sẽ có rất nhiều cấp độ giúp người chơi làm quen với thế giới dòng lệnh Linux từ căn bản đến nâng cao. Ở mỗi level đều sẽ có những gợi ý giúp người chơi thực hiện tìm ra lời giải và điều này rất phù hợp với những người mới.

Địa chỉ chính thức: https://overthewire.org/wargames/

overthewire.org

THỰC HÀNH

Khởi đầu là Bandit wargame có tất cả 34 levels với cấp độ khó tăng dần từ Level 0 → Level 34.
Bandit

The Bandit wargame is aimed at absolute beginners. It will teach the basics needed to be able to play other wargames. If you notice something essential is missing or have ideas for new levels, please let us know!

Level 0

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 Answer

Theo hướng dẫn thì cần phải sử dụng lênh SSH (Secure Shell) để kết nối, mình sử dụng Kali Linux làm môi trường client kết nôi đến Server Bandit.


Trong Kali Linux mở Terminal (phím tắt Ctrl+Alt+T): thực hiện kết nối tới server Bandit trên cổng 2220 với password là bandit0.
ssh bandit0@bandit.labs.overthewire.org -p 2220

Lưu ý password khi gõ sẽ không hiện ra.

Khi kết nối đến server của Bandit thành công thì dấu nhắc lệnh sẽ chuyển sang như thế này bandit0@bandit:~$.

Level 0 Level 1

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.

Level Answer

Như gợi ý của level, ta sử dụng hai lênh lscat để tìm password.
ls [tùy chọn]... [tệp]...
Lệnh ls dùng để liệt kê nội dung thư mục (tham khảo chi tiết về lệnh này bằng câu lệnh man ls).


Lệnh cat (viết tắt của “concatenate”) cho phép người dùng tạo một hoặc nhiều file, xem nội dung file, nối file và chuyển hướng đầu ra trong terminal hoặc file (tham khảo chi tiết về lệnh này bằng câu lệnh man cat).
cat [tùy chọn]... [tệp]...

Thực hiện như sau:

1. Liệt kê tất thư mục gốc ~ls -al

2. Hiển thị nội dung của tệp: cat readme


Level PasswordNH2SXQwcBdpmTEzi3bvBHMM9H66vVXjL

Dùng $ exit để logout SSH.

Level 1  Level 2

The password for the next level is stored in a file called - located in the home directory

Level Answer

1.  Login
SSH: ssh bandit1@bandit.labs.overthewire.org -p 2220
Password: NH2SXQwcBdpmTEzi3bvBHMM9H66vVXjL

2.  Liệt kê thư mục gốc ~ls -al

3.  Đọc nội dung trong tệp -cat ./-


Level Password: rRGizSaX8Mk1RTb1CNQoXTcYZWU6lgzi

Level 2  Level 3

The password for the next level is stored in a file called spaces in this filename located in the home directory

Level Answer

1.  Login
SSH: ssh bandit2@bandit.labs.overthewire.org -p 2220
Password: rRGizSaX8Mk1RTb1CNQoXTcYZWU6lgzi

2.  Liệt kê thư mục gốc ~ls -al

3.  Hiển thị nội dung của tệp: cat spaces in this filename

 
Quan sát ở hình trên nếu sử dụng lệnh cat spaces in this filename sẽ báo lỗi No such file or directory.
Sử dụng hai cách sau  (4) hoặc (5) để đọc nội dung mà tên tệp có khoảng trắng:
bandit2@bandit:~$ cat "spaces in this filename"
bandit2@bandit:~$ cat spaces\ in\ this\ filename
Level Password
aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG

Level 3  Level 4

The password for the next level is stored in a hidden file in the inhere directory.

Level Answer

1.  Login
SSH: ssh bandit3@bandit.labs.overthewire.org -p 2220
Password: aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG

2.  Liệt kê thư mục gốc ~ls -al

3.  Di chuyển con trỏ vào thư mục inhere: cd inhere/

4.  Liệt kê thư mục inhere: ls -al

5.  Hiển thị nội dung tệp .hidden: cat .hidden


Level Password: 2EW7BBsr6aMMoJ2HjW067dm8EgX26xNe

Level 4  Level 5

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.

Level Answer

1.  Login
SSH: ssh bandit4@bandit.labs.overthewire.org -p 2220
Password: 2EW7BBsr6aMMoJ2HjW067dm8EgX26xNe

2. Liệt kê thư mục gốc ~ls -al

3. Di chuyển vào thư mục inhere với cd inhere/

4. Liệt kê các tệp trong thư mục inhere: ls -al


5. Xem tất cả thư mục/tệp với file ./* (thay vì sử dụng lệnh cat để xem từng tệp ta dùng lệnh file để xem tất cả)


Sau khi chạy lệnh file ta thấy có -file007: ASCII text là có thể đọc được.

6. Đọc file07 với cat -- -file07

Level PasswordlrIWWI6bB37kxfiCQZqUdOIYfr6eEeqR

Level 5  Level 6

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

Level Answer 

Ở level này ta sẽ tiếp xúc với lênh mới find.

Thông tin về lệnh find như sau:
find [path] [option]

1.  Login
SSH: ssh bandit5@bandit.labs.overthewire.org -p 2220
Password: lrIWWI6bB37kxfiCQZqUdOIYfr6eEeqR

2. Liệt kê thư mục gốc với  ls -l 

3. Di chuyển vào thư mục inhere với cd inhere/

4. Liệt kê các tệp trong thư mục inhere với ls -l

5. Sử dụng lệnh find để tìm kiếm, cú pháp lệnh find [path] [option]: Tìm kiếm file trong đường dẫn theo các tùy chọn.

Trong trường hợp này ta sẽ sử dụng lệnh find để tìm tệp có dung lượng 1033 byte:
find . size 1033c
(Dấu . có nghĩa là tìm tất cả)

6. Cuối cùng sử dụng lệnh cat để tìm password.
cat ./maybehere07/.file2

Level Password: P4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU

Level 6  Level 7

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

Ở cấp độ này chúng ta được giới thiêu về quyền của tệp trong Linux, cụ thể là sở quyền sở hữu.

Level Answer

1.  Login
SSH: ssh bandit6@bandit.labs.overthewire.org -p 2220
Password: P4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU

2. Vì tệp somewhere on the server và phải thỏa mãn 3 thuộc tính sau: 
  • owned by user bandit7
  • owned by group bandit6
  • 33 bytes in size
Điều này có nghĩa như sau.

user = = bandit7
group = = bandit6
size = = 33 bytes

Vì vậy sử dụng lệnh find với các đối số như sau:
find / -user bandit7 -group bandit6 -size 33c
Giải thích các đối số:
  • /: Có nghĩa là đường dẫn root của máy.
  • user: Tùy chọn tìm chủ sở hữu của tệp tin.
  • group: Tùy chọn tìm nhóm mà tệp thuộc về.
  • size: Tùy chọn tìm kích thước của tập tin c có nghĩa bytes (tham khảo tại explainshell.com).

Kết quả sau khi thực thi lệnh:

Nội dung:
bandit6@bandit:~$ find / -user bandit7 -group bandit6 -size 33c
find: ‘/etc/ssl/private’: Permission denied
find: ‘/etc/polkit-1/localauthority’: Permission denied
find: ‘/etc/sudoers.d’: Permission denied
find: ‘/etc/multipath’: Permission denied
find: ‘/root’: Permission denied
find: ‘/boot/efi’: Permission denied
find: ‘/var/spool/bandit24’: Permission denied
find: ‘/var/spool/cron/crontabs’: Permission denied
find: ‘/var/spool/rsyslog’: Permission denied
find: ‘/var/lib/ubuntu-advantage/apt-esm/var/lib/apt/lists/partial’: Permission denied
find: ‘/var/lib/snapd/cookie’: Permission denied
find: ‘/var/lib/snapd/void’: Permission denied
find: ‘/var/lib/private’: Permission denied
find: ‘/var/lib/chrony’: Permission denied
find: ‘/var/lib/polkit-1’: Permission denied
find: ‘/var/lib/apt/lists/partial’: Permission denied
find: ‘/var/lib/update-notifier/package-data-downloads/partial’: Permission denied
find: ‘/var/lib/amazon’: Permission denied
/var/lib/dpkg/info/bandit7.password
find: ‘/var/log’: Permission denied
find: ‘/var/cache/private’: Permission denied
find: ‘/var/cache/pollinate’: Permission denied
find: ‘/var/cache/apparmor/30d07b40.0’: Permission denied
find: ‘/var/cache/apparmor/a4dd844e.0’: Permission denied
find: ‘/var/cache/apt/archives/partial’: Permission denied
find: ‘/var/cache/ldconfig’: Permission denied
find: ‘/var/tmp’: Permission denied
find: ‘/var/snap/lxd/common/lxd’: Permission denied
find: ‘/var/crash’: Permission denied
find: ‘/sys/kernel/tracing’: Permission denied
find: ‘/sys/kernel/debug’: Permission denied
find: ‘/sys/fs/pstore’: Permission denied
find: ‘/sys/fs/bpf’: Permission denied
find: ‘/proc/tty/driver’: Permission denied
find: ‘/proc/3141118/task/3141118/fd/6’: No such file or directory
find: ‘/proc/3141118/task/3141118/fdinfo/6’: No such file or directory
find: ‘/proc/3141118/fd/5’: No such file or directory
find: ‘/proc/3141118/fdinfo/5’: No such file or directory
find: ‘/home/bandit31-git’: Permission denied
find: ‘/home/drifter8/chroot’: Permission denied
find: ‘/home/drifter6/data’: Permission denied
find: ‘/home/bandit27-git’: Permission denied
find: ‘/home/bandit5/inhere’: Permission denied
find: ‘/home/bandit30-git’: Permission denied
find: ‘/home/bandit29-git’: Permission denied
find: ‘/home/bandit28-git’: Permission denied
find: ‘/home/ubuntu’: Permission denied
find: ‘/tmp’: Permission denied
find: ‘/dev/mqueue’: Permission denied
find: ‘/dev/shm’: Permission denied
find: ‘/lost+found’: Permission denied
find: ‘/snap’: Permission denied
find: ‘/drifter/drifter14_src/axTLS’: Permission denied
find: ‘/run/chrony’: Permission denied
find: ‘/run/user/11531’: Permission denied
find: ‘/run/user/11031’: Permission denied
find: ‘/run/user/11530’: Permission denied
find: ‘/run/user/11009’: Permission denied
find: ‘/run/user/11011’: Permission denied
find: ‘/run/user/11030’: Permission denied
find: ‘/run/user/11017’: Permission denied
find: ‘/run/user/11007’: Permission denied
find: ‘/run/user/11002’: Permission denied
find: ‘/run/user/11019’: Permission denied
find: ‘/run/user/8002’: Permission denied
find: ‘/run/user/11022’: Permission denied
find: ‘/run/user/11015’: Permission denied
find: ‘/run/user/11003’: Permission denied
find: ‘/run/user/11027’: Permission denied
find: ‘/run/user/11001’: Permission denied
find: ‘/run/user/11021’: Permission denied
find: ‘/run/user/11000’: Permission denied
find: ‘/run/user/11004’: Permission denied
find: ‘/run/user/11006/systemd/inaccessible/dir’: Permission denied
find: ‘/run/user/11025’: Permission denied
find: ‘/run/user/11023’: Permission denied
find: ‘/run/user/11008’: Permission denied
find: ‘/run/user/11016’: Permission denied
find: ‘/run/user/11014’: Permission denied
find: ‘/run/user/11020’: Permission denied
find: ‘/run/user/11024’: Permission denied
find: ‘/run/user/11005’: Permission denied
find: ‘/run/user/11032’: Permission denied
find: ‘/run/user/11013’: Permission denied
find: ‘/run/user/11012’: Permission denied
find: ‘/run/sudo’: Permission denied
find: ‘/run/screen/S-bandit0’: Permission denied
find: ‘/run/screen/S-bandit33’: Permission denied
find: ‘/run/screen/S-bandit14’: Permission denied
find: ‘/run/screen/S-bandit25’: Permission denied
find: ‘/run/screen/S-bandit24’: Permission denied
find: ‘/run/screen/S-bandit21’: Permission denied
find: ‘/run/screen/S-bandit19’: Permission denied
find: ‘/run/screen/S-bandit23’: Permission denied
find: ‘/run/screen/S-bandit20’: Permission denied
find: ‘/run/multipath’: Permission denied
find: ‘/run/cryptsetup’: Permission denied
find: ‘/run/lvm’: Permission denied
find: ‘/run/credentials/systemd-sysusers.service’: Permission denied
find: ‘/run/systemd/propagate’: Permission denied
find: ‘/run/systemd/unit-root’: Permission denied
find: ‘/run/systemd/inaccessible/dir’: Permission denied
find: ‘/run/lock/lvm’: Permission denied
bandit6@bandit:~$

Quan sát kết quả thấy có rất nhiều tệp và hầu hết đều xuất hiện lỗi Permission denied.

Do đó ta cần chuyển hướng (Redirection)  thông báo lỗi này vào 1 vị trí khác là /dev/null ( Mọi thứ ghi vào file này đều sẽ bị xóa, có thể hiểu đây là 1 file đặc biệt ghi tất cả mọi thứ mà ta không muốn lưu)

Kết quả sẽ gọn gàng hơn sau khi thực thi lệnh:
find / -user bandit7 -group bandit6 -size 33c 2>/dev/null
NOTE: Trong Linux có khái niệm mô tả tệp tin là File Descriptor



Redirection là tính năng cho phép chuyển hướng đầu vào/đầu ra (INPUT/OUTPUT) trong hệ điều hành Linux. Redirection cho phép chúng ta thay đổi đầu vào tiêu chuẩn (stdin) và đầu ra tiêu chuẩn (stdout) khi thực hiện một lệnh trên terminal. Theo mặc định, thiết bị đầu vào tiêu chuẩn là bàn phím của bạn và thiết bị đầu ra tiêu chuẩn là màn hình của bạn. Ví dụ như bạn cần lưu lại toàn bộ output hiển thị ra màn hình của câu lệnh nmap ra 1 file thì lúc này tính năng chuyển hướng sẽ giúp bạn.

Mọi chương trình chạy từ dòng lệnh trên Linux đều có ba luồng dữ liệu được kết nối với nó để phục vụ như các kênh giao tiếp với môi trường bên ngoài. Các luồng này được định nghĩa như sau:
  • Standard Input (STDIN) : Định nghĩa dữ liệu được đưa vào chương trình tương ứng 0.
  • Standard Output (STDOUT) : Đầu ra từ chương trình (mặc định là terminal) tương ứng 1.
  • Standard Error (STDERR) : Thông báo lỗi (mặc định là terminal) tướng ứng 2.
Redirection (sử dụng toán tử > và <) kết nối các luồng này giữa các chương trình và tệp.
  • A > B: Gửi kết quả của A đến B (lưu).
  • A >> B: Thêm kết quả của A vào dữ liệu hiện có của B.
  • A < B: Nhập dữ liệu từ B vào A (lệnh).
3. Cuối cùng dùng cat để xem password:
cat /var/lib/dpkg/info/bandit7.password

Level Password
z7WtoNQU2XfjmMtWA8u5rN4vzqu4v99S

Level 7  Level 8

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

Level Answer

1.  Login
SSH: ssh bandit7@bandit.labs.overthewire.org -p 2220
Password: z7WtoNQU2XfjmMtWA8u5rN4vzqu4v99S

2. Sử dụng ls -al để liệt kê

3. Sử dụng hoặc ls -l để đưa ra kết quả dể nhìn hơn

4. Dùng lệnh cat để xem nội dung của tệp data.txt.
bandit7@bandit:~$ cat data.txt | more
gallop  hu3ZhCrGRvfaO5jsY6ttvApzVCA2Hjvs
Aurelia's       ikl4F3cK5m6Cl6HAxva6zUAVJhI2Cvc6
stoicism        JiW9ts44udf20bJHe8H5dS1c99Muwz42
embodies        vWheZcAsQHZNnerI3ViW8wqOKIx0kbgR
Plato   dW2U8E5FfuAvNLdGDupP8GAxr922ZV0x
cultivation     A90E75jvWbEKrijFxM4GxqHEw8c8U2Bf
stable  omR4PHolFwbI0IEJsanveA21yWvFy8a7
bedspread       VlBFxuEDi3phEpljbKbahRJvJxfh3k9M
oppressing      hQTiEm5XF3cUQSEiBjh7sekemLOKBrcJ
darnedest       9O2zdCLKVoW5u34P9T7EKTZXcMRE6xh5
quenching       t5Xkurqb7pOHr6zAqdgQKhz7GuVH0NV4
tumblers        QG2UgYNyImG6ai9Wy3d1WEAtAz0yfFvX
border's        eKrzWR3oQNI2srIovGWPbIEF6yTTyRXq
needle  DszgA8lLo4NDQgMmYulAZdkikEmRsmhm
Diane's ZKQTqay3ffmyPT68YuvciGRiHGH3hoMp
windburns       DzaAGZG7HfjALPJSARJoSG0yIAPpghiU
enlargement     0tQ8QTZjk2qyUUfWDas6EpajrE5H5vmP
porcupines      9l3VGo6ns1Th5SX8fn91EeY3KnesmTpw
Reasoner        iS9aYnUBFeJW88iGDFdN2JMQSxs3dEeJ
debugging       tv0VgQpOyuPNK4l1IK0iH5fw3nOQIif5
vine    xIU9W9Y97CMydAL9W6GrH7SrENHmqOcT
scatters        K7G7YUuumRF1NKWpCbalKRyihZM6Xqzu
squander        pCrZh4TZ2aw1MTwvCqMXZ5KCGba2ZGRt
grad    CptdO0dXyekUf7eSz5r8iMjQeO8SFqtz
trawled tjwMUYQVTohgzoCT5AplxhAvGUz1qQ8P
backyard's      MaGl75kuJ5I5igQcYHsdq0s8plk3lxFj
pyromaniac      mUBX0HWneu3VyZ6JFwSCDlCCoPR5IZlt
Yeats's AR6WQn6NtlpBbCf9REQABSPpCbI9U3YZ
eggheads        LLiUkhTsAD1eq1MqcwQOsZU7jDIL6jNc
alleviate       LSyu95zIJL1cp8Tra0eqDlD3hR38xerr
Casey's bi6amdFL5R9SgsXtuJogwA34wgmFI5lt
inattention     ve4jcKUjx5hxzZKQ87tHu6STbylqtJpF

--More--
Tệp này rất dài...chúng ta cần phải lọc nó với lệnh grep.
grep [tùy chọn] [biểu thức] [tên tệp]
Lệnh grep dùng để tìm kiếm và trích xuất các chuỗi ký tự từ các tập tin (tham khảo chi tiết về lệnh này bằng câu lệnh man grep).

Pipe (sử dụng toán tử | ) được dùng để chuyển lệnh, đầu ra của lệnh này là đầu vào của lệnh kia.
 
pipe A | B - Output (STDOUT) của chương trình A sẽ thành input (STDIN) của chương trình B, kết quả của A không được in ra màn hình mà được chuyển thành input của B.

Ở level này ta có text gợi ý là 'millionth' chính là chuỗi cụ thể trong trường hợp này. 


5. Cuối cùng thực hiện lệnh
bandit7@bandit:~$ cat data.txt | grep 'millionth'

Level Passwordmillionth       TESKZC0XvTetK0S9xNwm25STk5iWrBvP

Level 8  Level 9
The password for the next level is stored in the file data.txt and is the only line of text that occurs only once

Level Answer
1.  Login
SSH: ssh bandit8@bandit.labs.overthewire.org -p 2220
Password: TESKZC0XvTetK0S9xNwm25STk5iWrBvP

2. Sử dụng lệnh cat để xem nội dung tệp data.txt
bandit8@bandit:~$ cat data.txt

Nội dung tệp này rất dài do đó ta sẽ phải sử dụng đến lênh uniq và sort.

3. Sử dụng lệnh uniq kết hợp với lệnh sort.
uniq [tùy chọn]

Dùng để xóa các dòng liên tiếp trùng lặp trong một tệp văn bản. Tuy nhiên uniq yêu cầu các dòng trùng lặp phải liên tiếp, nên chúng ta thường chạy sắp xếp trước.

Tùy chọn -c, --count : Đếm theo số lần xuất hiện.


sort [tùy chọn]
Được sử dụng để sắp xếp các dòng của tệp văn bản theo thứ tự tăng dần hoặc giảm dần, theo một khoá sắp xếp. Khóa sắp xếp mặc định là thứ tự của các ký tự ASCII (theo thứ tự bảng chữ cái).


Thực hiện như sau:
bandit8@bandit:~$ cat data.txt | sort | uniq -c

Kết quả:

Nội dung:
bandit8@bandit:~$ cat data.txt | sort | uniq -c
     10 18DyjwhN856SsMx8bNrFSvr6rJxNQKhE
     10 1iyGemEgn3qUOOFcAJyGPHOiewqZyp1y
     10 2CQ5DQRdtoe9Ft8YpMHqCwQcN1Bk9lCI
     10 365RauAVsFlxktPMpoLtIf1uxijU1TfV
     10 4K2MoVHd1gXfoOdDjvlaRxFNZwmi4A4C
     10 52p0CnGhAvm4m3fPKqz9mTxVDeVYCvnG
     10 5Y76FifuxKStZi4CVovF2uPhgLrZnLzG
     10 7A4l2BI3lPJgNdWAmyXAGlfB8uvCQLX0
     10 8cxarYi5VoKRj3lzo2baLOJaMgUtzoRH
     10 97Qwmy18JE8aGIud1stpTsOrOtUMHeGI
     10 9d8exmGtSsGcU1gz6HmqTfSxmnmI4FBo
     10 A16BW831T94qcsYcGDSkgzYhxnX2xUdK
     10 aAd8RbcAAGVRifo0gE2x1nPIGH2fjgZi
     10 ahwL1iJ5EDLt9wpBjrP2DY8pv6FLdrLy
     10 AiYd84lOOVTA4gqJPX7f6DH8eG3zwq1W
     10 aniL5AEkrKcj4mFR1ujwPZdtF4z1SAin
     10 b0XUx8jfeWYAUGlnOGGAyVRxdNziM4SF
     10 bJDV41So5UyGPR98w9x5pX6nqWsOU2ra
     10 br26ueVSoLeZd8HqErTJpNVCtwFufHGO
     10 BVego1OuHFYy1glUiCH3m5dQxEPV8D6d
     10 bWO8QplAdUvLTPoI07UdQc6zKvON0WS3
     10 cEqNrEqHVIIi9fQKdcvAxaip1brmsSxT
     10 Dml3j9ydZQj13Q6xVRPHVuMhD9pt0NbT
     10 drJxnp5fJxeVRYlCldsIEtrEEwBdyRIL
     10 eJZcdtHKg9jLpvpK9v31Fj1opqlA1A9k
      1 EN632PlfYiZbn3PhVK3XOGSlNInNE00t
     10 eNdwlpf6iBeQ3o11iHefoHd9GYKDTIfQ
     10 euIPhAiMI8n0DxPCbaAhJ9RTBO3fX4UE
     10 EzkkJebPKsBh9ERGT3vffA2NhTMCbFS5
     10 EzyaXOFuwjlARDRsbctadMvVgZA1y1Sj
     10 fGJ2YQ92lVRRgQ9dC0TiLEMacCsw8Lm9
     10 FJS8eDt5xeeyabbeEqyRV9W8uQ62BYnX
     10 FQIgwPiuPKftkFhIy9Nzm94sWdNGTlHd
     10 fuBEcq8TyETrSmuD2yQRmvp42K2jlWdH
     10 fWBv5AzQI14holge9okDaOvrgL7NGNTr
     10 gAAoAApNgD1pS0c9OTGWdsGTIwRDgY0M
     10 gOtGle2Dg1bG8UaS5hN6CjIF14eGM4Qu
     10 GuRn8oi7ecl8kSzTh1GrlHXhcFaNBF7f
     10 H4ZQ34QTyLVVE6Q8nSQVQjtt7gAVztVX
     10 hA2abugfwKD5OEdFW4hSBacALoJiJSKg
     10 HbIahMn0Q6vzNgo1RFXG7GPp8nQ9OO56
     10 HmDZyN0zxPJAkwcaZKhru6S9vFbGuJOg
     10 hWy3uJOV7nE8P26AjcCusGfgHo5ILfM6
     10 i7Ith55pB4DL8SoytpbodUwBodotTGjk
     10 JDr0GA5HspKsYLSpdOBCH6kHT71czynh
     10 jL32h6jpv6GGSCRoDBAyECslrqkJQkm7
     10 Kbv13vGt7e4r4KFPCw688NivbBr5K1hs
     10 kjIuqjobFBhKw9Mmfj2wAnWbXB2VxSfv
     10 kkhCyItNHN3wnTVqmE8C3PcZgbVCWuYt
     10 KkwvIeB3CtYvsxjslESZwkR589n51cEY
     10 KYISscbRkhzx8A10I54jgdbq1sEO98lG
     10 l7nwMDTwlZ2ahsqs9EiiiU1zS9oiuTXK
     10 LR92hMCqRihyASXr5srJ041d0WUVbdee
     10 m1vKmRXwPcZQsvRfjAPA1Oq7haLmy4uu
     10 mrgF9gEkQXZKe9E58QfdKcZtG22tMIly
     10 mTYRseor14aRwbazgTmVVgM4mDOkZJJ4
     10 mvfnErC75MoKu7FCjV75ny7r5v3hPtvN
     10 NCO6mwiQQx2Xct00hxWfynfWyAnFLkgZ
     10 nj1s0u8MNekTeuJ7dLQW31zwtsRdHLQe
     10 NRPT61QwcINsfTDrLO2dpFUhayZehqT0
     10 nyPmwN4SQuTg8M8Cx4anpQQMLvwBsycz
     10 NzjErDvr4xRMBJox5tSJsGuBGF9Ini2S
     10 P8jd7Kr8GXVKTLhe1Y7cVYAARwh4lN4A
     10 piYrfvTU6JmxKJlXgfsGnMBc2expvE8Q
     10 PQ0a8vewEyqcaKm7P21uKO88lpXupIMi
     10 pVukrvfmtzHjUQkr4j8N4ri6lWOMbDYj
     10 pWagnmV56wxV241gY75RPloSDlRTWOA7
     10 q519Xqdlz3wnk3tjmiqzxZRB2rdsYv5o
     10 Q5jKs4g4YYQtlgCfRZ5Joh9jwRAtN4Q0
     10 qcm9OMrZwofpcM8CsuTffc9LKRp50Bwk
     10 qtUQnuIjoLTNwviHPE6yULyPEVUuag5K
     10 Qu5gLayacFzgkk6Qy2aAY9tMvAAMm8vh
     10 Rlaj8VWIHkYsAg42TsFplgAd4ekjgR2X
     10 RyLqqJ3d9ocx0ICbF5x9pMiXPAqXtxoH
     10 s4KiXmQhsCpX4zbIDIeVWKaRJWHwYaHm
     10 swXvCokPAhVazCnl9rPeLXWYHIC5yj8h
     10 t4924Or8OK04Bd6NSXPwlGRaYWcG2pfo
     10 t9IKaY2XcYiDkUXvWE2JOZKIdZvpDXt3
     10 tbwqIearQexlJbmkwluaaa7ZoPXLSuXe
     10 TCXcLHZOAPbd1osXWeuNqltMylxtlUVr
     10 TM3NCu6BEfCirP0jPZxtUm8NX2ypTAF5
     10 TOWEeiT4P5TcGnZ2pyG63NKEvTm0MdPg
     10 tUlwNyLyJjRiFaj4n0oN5cvoUlJKpW8m
     10 TzjPxJ7VQMAEB3R4cvQOOq6jrOKelLQe
     10 uw9mhc4SblNVn8TcIR202ar0ejoUv1bX
     10 vlsSKqk3yVx2PZxIkBuZPR3KKIf8hGi1
     10 Vpj0ntqaDt8nWZL7Hf7QKJX8okOqoI79
     10 vwy1ljezuLueU0DgNTKf4ODgnSKmspJA
     10 WcJIGAlq3VP6b0d7uGzMEjv8awnJst1n
     10 WMgbyqEed5iHRvsI5bVMypuXlQh1dkIJ
     10 x18U8IZqzElHvbzuvBIkLHoX60JnsIH6
     10 X7oolq8RgTxDAJVn6XqHZqQsIXWT5ebi
     10 XRTmJCR9zWNbTt7xZyeqIjH1u1TM1qDx
     10 xtcg9IZotPgfR7qGI8V0jd7L6XErPgih
     10 YIcCD3TC5p6UKk44dVtyHktC7DjFm2jf
     10 YMFh71LtzL97GBBRng0YQUmKm4fsVYDO
     10 yPrvV3lIXlttYCnHE6NILDZWmlMiUIcK
     10 YQEGfxSoUTNa0rT9aDX7SvFM9nlt8h6z
     10 yqKbkKmzg8RV8v3GbtfuMktHvWoVDLo6
     10 zOTIYMCpuvJ0DZGzoEwqIYc19SkIVQdl
     10 zwhYlyTRS3mNMsud9hapW5MDorCIGM0r
bandit8@bandit:~$

Quan sát thấy có 1 chuỗi chỉ bị trùng lặp 1 lần. Sử dụng lệnh sau để trích xuất ra:
bandit8@bandit:~$ cat data.txt | sort | uniq -c | grep "1 "
Chú ý đối số là "1 " không phải là "1"


Level PasswordEN632PlfYiZbn3PhVK3XOGSlNInNE00t

Level 9  Level 10

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.

Level Answer

1.  Login
SSH: ssh bandit9@bandit.labs.overthewire.org -p 2220
Password: EN632PlfYiZbn3PhVK3XOGSlNInNE00t

2. Sử dụng lện cat với grep để xem kết quả có lỗi gì không
bandit9@bandit:~$ cat data.txt | grep "="

Báo lỗi grep: (standard input): binary file matches

Vì đây là tệp nhị phân nên không thể sử dụng lệnh catgrep.

Thử với đối số -a

Nội dung:
bandit9@bandit:~$ cat data.txt | grep -a  "="
~��Mk���Axڋ��k��;�▒Jb��mi���~�]��]㹩�ux��R~&�����4SA&l"����x�   6m�q���bf��s���~n�����n����
                                                                                           ��~��=�|ڱ|J�<��=��u��ڷV���1�`�;�s��g�M-�2k���h�(��1�o�0;T�}��DE*'3�i,���x�ʤ��i▒Sn3�6E�p:���M���O!�d����tW������]��]4&�7�FR^+�6ư�������#
                                                                     d��w�'q�Ԇ
                                                                              ��x�)�,V��*"�3��_�3+2)`��5HF���x[
�▒��=����؇���t6�c���89���⟢V2$�ky�N���   ��ۏ_\��7���q@v���~�▒�%�٣c?G�o��h��xkj
                                                                             u+Z��^gjb��
                                                                                        ���ޑ�NE���u�zVC&�=�pH���O�`��=2""L(�hR"�!�4�D����ڡ�'�%n�z����o��ۼ�w������b��`����Qu:qo�O���ɴ��W�k��
                     h��>3;�02��
"x����$�WI��G���gq��B�ș�q6�p�|r9����K�|��[�l������#0jb�7u��uf`e�Y�▒o�   ?>��?�▒��F��){�x%�1�c3  ��l�XQz�U0��
                                                                                                            ��O-@����E�8�jr��i��$�]�:[������x]T========== theG)"�)<�!G���{��X8�?��5�&���O:�@N��s~�i\6�Xz     ����==��S�igy�����>�m���P�I�ݰ���C+x�[ڋ�e▒22�a�
�|�S;��g�`���y�����v�t����Vt!�ö�▒��!^��z:G����'=�Na>O6�A��Pݰ������)sJ-�[4����E����|����t���R��ݕ�*t� J��v'��j�,�������A��f'�Ee~z�~b�oLq�$��(�en�|����=��_�RQ3����J���$M(J�h����MIh'�%�J��;�h���Z>���"V�@+}��4��-��A�!�▒R_/�ZXq���a�ئ��▒��'�5f6;ph�ƚ3A��8��9!�T��(����!4�#�ӆF����
                                                                                                                  �
                                                                                                                   �Crh�        �ո�E�W�k�E�x�:|����▒�Yu���rlk�V�I�@#�{��]}��CJWǘZ�
                     �tW�@
��wp��I/]0���P�&���2��;Y�M���(X�7�w��r'�,`���R�`���*mFvņ�(D�▒Σ�h\g�
                                                                   !�Z`"掼�����T~C�g����%_��Z&�v`_�O
                                                                                                    rH����w@�-��`�G��'�Q)\ c�<��e�7��,���f��Ae�5�(p!Z4HC��LcI�;z$▒y?���D[L)Y�5/��cs�pR}�`▒ɏEy>��k'Y92V���NyRe�$������?��rv�������3��LJ�▒Vݛ���mP�y�Dm#{��.�hQ�||���6M��▒����j�
                                                                                                               G����C���Ӑ���T�����_��G|����@2%�$���b��q;r[s1w񎀶��.t�:�Z[o<A{���@߅�������I�j�SP�{�Uit��ցGe�!ܠ�l�4��;�zVl��9���▒2����܂���Ɉb_�1
�С'{��/��HK���)uf�IhQ���P"�i��;GG�b��mt1�S▒q4����ۉ��-�^(�׾�j"f<��5SC>u�җ¬��G����E�z�L��Ʈ�v`�޷l�<���G    ���&&�3}pU�1��)���s���wD/��m/iJ@i�v�0\��Pܞ�[Zm���z�d�ӚҜ�b;3g!\[���F�▒��@H�V �T��@dwO�▒�Z�<%  Q�FH�a��@�▒ϜL6�#��%���bO)�=�+������mLF�D�Pb����4���!I'��vP�mi�� �E���Ъ�2��F"cJ�@�����J_���u�e��40Uç��.20�F6 |�v
                                                                                                                                                       r�':���w�@d���������:�����P�b���)��;,��t0.�gX��J_r8M����XG���lC��Q5Y�Ү�\2�1�@��Rv(��D����(x��jD"�����O&�<��<�X1�e��Q׽�V���jm���,�L�-��T1��L���l��&�[��a�ـ�0�g��>�J]M?ʾ#6�1�Ά��&��  ��/���]ύ�P�����F���c����$@�y��1G�l�5��?������I
                                                              V���
                                                                  ▒���aL�P4�K !��|��9�D��,+�K�vz�gk���0�3@�2{��0@
                                                                                                                 `4���o�H'Ce��*����yE�p��6��5���|V7o��_���WG~�z��l�n����g��u��b�}'?�Ơ��Ɵ�I��Ϡ���@9��}�i�-W��q;�'�C&▒Xy\����▒�+�{���_�����    �U5&g���ClѨi0���        ��
bx�q�ծ�c��LK��<!O��o�=C����9۷"j�j ����V����1=O�w����Sn\|�@�C���_�H��, ���2VL����A��9�&=�i��ݔ
                                                                                            �   F��|��
                                                                                                       ���J��5`����.��r�%�%�z�C��GN6�Yǵ��l�lC0��P�+|+�ӝ37���'��2�����~��]џ]�!4����P�*�<a�{�Xh+��1H��Ȍ"��>o�U,9���R�A��6ԓ��E�v�ƾS��[�0Ŋ�#w9����J�.���1�%��t'�{�1;�N▒��
                                                                                                        �[_�▒�0���Q'F���Q#���k��&��Wm��Y!J��-��p▒đ��{�g�2���!z�������6O������▒8�z��},�h�Cy�QU����K�I�}L���8O�|\oYK}�▒��u��t���@phW!�k�o�⒭"�u��d�g��s���I�����g��B��U�f��^�Z�+a,>��M�Ţ�L�lp^�[�<2�l=�h���Į��p�$w���!{�c�@����.uJf?,�
qN
  lIyS��߅�����
              �`v<�12�B����s�T'IM�[����wh�������1)��S�VB�p��dZ�3iŪ.▒��@�es
                                                                          ���9� �1�Ri_��w�i�a�Jꋿ
                                                                                                 (&L��_-`�_����"`�����pY��Ĭ"��/Q�'�������c]�r�2I-Yr�@���˪�RD�w-�S+���驄��-���
                fKV�`�3�▒��pH����Z�e�G0C�5�%���cr�L�2�y����aڲ����ʆwF#ɩ/���A�~�ʯ▒[\3Ӥ���ʾe`��%�72���'d\Wx*�s(��~��Y�p��Y
                                                                                                                       2�Y��j��%��ނ�^T����:�j+!]�P� ��?��ˍ.�7�▒��8��u��/���Vcod)))17��8a�7�e�}���t^�������m+!4�r=����5��0�W|���@Y�M��▒����Z�{�����Ȳ��#1^�r:Wzm�0
                                                                                                   .��T9�j��~�E�L�v�$U_ZCn��uO��e5�j�:*�����O8rP}c�/:���J���Sɂ
 ���l?���? Wv��3X����{�▒$����6���.񖻧2n�@|�Π���~޵���:��hN�GE
                                                          ����� �Y�u����q��I��4��▒�������-��D�K?�
                                                                                                 L�H<4���*ҝ{�U2���\~�7�""�#�\,�nc�D�]Ҟd���Կ�r��\w����9(bE������E��$▒<�{aN��#ȿ����k*��
�{��\nF���<��D� �M�f*I�`��@oݗn�ײ�p�n��Y�����x�n��▒���ۓ�4j\9�n:�J�Va���K��▒+     ����f��Z9�)��Q�Ѻ?��r��.���O[��6�^FS�========== passwordk^�ټ�����1>���jg�▒S�>�����5~�I▒�-�"��G|�����6L�"�� �T�'�����j�T=������2_�q+T6(�p
                                                          '
Po5���(D�&�U�rd��G�|����K�I|��
                              �1���7#���*Ȇ?���q��F�42��Rj�\�i9lM�\������c@���p�n���m=����٫ ��U������Cա�y▒���l�'����F)��[k"�rZЎ���d�-'�o'|��'�&����6񎋊k�fJ
                                                                                                                                                        RLYۯZ:�▒=0��jbi$�W��yB����9��*u��aN�9���Ke�O�
 ���n:Q�8�[�X1mW��S#5▒�_��3�ܓS�HWV���t��"���7�h?�e���bN�$�8s��#��&      ��,����?S��_�K;'�����   ���P�
                                                                                                     ��B·�U��kx��ݝ7�<���)�C��)����İu�YX��^��+h�����ꅾXP��Qs�Z�-���Q$XG��k��
              �(�W�P��H���Q�q �/�����M����NNg������
                                                   !���~0r�ڍu�H��ʪ��՟�٦��{�ۄ����U�!��!���
0o�Ԉ�sf���@S�uf>�F�2�ܟ����V����{s0�Η�t�����
                                           �▒A���       n~�f�%f��aW�4FLW�2�P�▒^��������[���!▒�w�hL�W�▒�v�=�����^��R�|��'��j_�(����Z}�4���3ˆ�~���������
                                                                                                                                                      ��qz�s�
2�W�h*kT▒����5������~q���S��e��nq>�I��3��^X#i��
�!�▒6�-���S({����z8Wp�a ͻ"��N��Y=xW��e5x@V.|�Z��i��`�,8z ▒�����: (��O�g{�u�d�Z�[{���B��-Cg�"^+ak�q�
                                                                                                   �qE�s�t%=q����,�_��9u=����腄��s�A�e�&��<�0lp%h��r▒B��S��0�R,:Ú�k@`����O�rߴ&▒��=j���!D^�t�ܔ{�H#�
�T����T�p#fz:�LJ�r*;�o#�E�hϻ��/]��&x��:!�Oη��[%ug�Z��▒hݹkj��D����▒ZH���Ed����ZE������4K�?�p������z�iw?������J�������^`t d�;T��ڪ`��M�T�/�j�M�Ł��$����O�Ms▒h��������8��========== is�w
.�Ze�x��J���i���_qhlbw���X�yϪ�.�-3������7�T�����
x|g3��~+��g:+���OKjq▒��3Y(ʅ\���n��Q�>��W�Ү��A�m4�6�p�����(��nQ@o��)��m~
:����s��3e�P$.H�m��g���h�I@���çKn:�UE�d���f9+���y�7s0��M�
                                                         ��4=}D3뎩I�lN��f8!1�q�A�C�Rj��
���g�}�����,�y:��i1B��(1���B�L�_�                                                      �[55�"▒���տ�Iyޚ�����o�   �~��w�c��ï�v"1�8�����   �v�n�&ђ�,�93�a
j@f��<�y�Cz!z�EQ�"߀^�t����]����!ʧl3��S����x�&Ʊ��D�k�Y�Z�}�xȖxl�קqu��$�
���.ފ+RP��6U4��n��~;ie���u���E'x{�O�▒�%Yf`�`��y�r?�oȼMݣ�o�I�Ht}9�',�6���]k
                                                                          ��6�Q��P!B�9?��Q� Nѫ,x���S�3��ez���G]��ז��^\��<��.ښu_��
��#�    #�=��M�}b�#�}��0*u����ٶ^�
                                 ���^��.���۔�n*����Gߪ��_��Z��28)HEĜ-x4�▒}B�r�W\�Q^����]�g�'�B
g!!�lw�y[���Ͳ�J���      bp��^X�                                                              "�l�E�T4_+D`���$��:S{��
E��|�|���V)��5ۆ��ݳ������O�?R��;�u�z��У�->>�U����?�A�������l<Z�W��3Zt�eȩ{1\=�I�|�gZ4�=b���@�_M�I��y�u▒^�Y�
                                                                                                         Dӣ
O���sZ���.
          l�
            d�踧����l�
                      ���
�EO�1��                  �94%?A�����K�XB����d���        Vi�R�|��A=��▒0
       ��T:�.��n����!�l=�j��o��`a���� �U2��(��gM�F�b8r��M�9���x�n�����xKݲ=W��);��
                                                                                 �W��a���j��gC��B��\������a��I��=׸:���cH?�������        v���&�`��q.6U��3���a5���7�Z��X�f�'��!<$G/�O��G�[
                           1G����#�-�U,K����Kr�q�A�)Scn`�3/�^{RWQ���I�3��c���σ�����=��lZ���^�d��Q$���W������"��7�Xl�t�ʭC�x��F=�\���4    ��T�Z�|T�x��X�)��hl��[h���$]0�����}���O�O
�~O���*��▒��:�^4��*��Yt�Ka'��hW��*�+,p*�▒��9-N�������ؤ��j��QeN$hL]�����Ʌ�?"���:���9�ȯ߄kx��ff
/�N��(\er9�eLRpm�FC&=z����p]>�?�,��#�5@jj~�<�����]������i�!N�����
��U�ơ�d�ur�6���<�v�=��7��>������(���}�ҡR�R��A�����`��Cs|��1ҕ��fw���i�dLz�d��{S;�c��▒�A�=
��-��▒~#�@4G��JݙW��BaZ[ˬ�▒�)�>����A���nZ8h���)����H
�^n���#IH>a��[�)��8���Fe-�����.��*���O���R�P�����P�Y���^�NZ�O��@��-Vt�����0��(d�_��[Y|��|�#:n-��_�▒�q�&&���F���:ɅP��*X4ӥ���9w������v7�Fu��1���p�������P)��@U�;��l{-B�pxg���< 7�h���R�f��ß�0��xΣ�▒�IN��c�����3���)��w����'���
                                                               �W�|_M�=�ƽ��MT�K�9��|�▒�����▒�J��)��A?�#�����=��S�����D���WO�
                                                                                                                            R�((W,�ñ,)�4��������
TO���_�5B��l*r[�p/�Y��|YNЬL:��Pu�b���{=/�CO
                                                n1��|���
uq'�|Vč�ET�� 
             �j�QYSGd��7�c)�%@���
                                 �����0����O��,�8(!7 ]_؉���LA碪�x�b�[
                                                                     ��d���LZ÷/��:��9WU���k0���,��P�����V��G3#"��Y���v�R������G�.��Q�
                                                                                                                                     ����Ԁ▒R.7��Ŭ▒�StG�;��������sW'�v�A;��8����=Y!m����HC可h=ݰa�e�mA�p3\�8!��^��
                                                   ��
                                                     �i�
�zQ���/e��Ȏ�{B��TIKg
u�KULna��e��J_h���0vy����<(o�Vs*�&@��/��▒����[+��R��e�*E�▒�8�^���A����W�(D��\�-��?�S�߅gn#M
                                                                                          �!;(��?��s
                                                                                                    La���;�4!v;�=���8R�G��{�S����Zxl�\c.Q>K'�f)�uvϛ���-'��  $/2`)=Y��$���V���>w�2���y6 �3!������ہ7$�ȁ�����.����Qn+
T��Q�r�q6�4'+2�>IV������a��'H�O�4�M&�4��R▒v{��▒�gPB��7�
                                                       ��*"$5�4_Q=\�s
                                                                     ��O��j�4<�K�����hYY
                                                                                        Sމ�Z��4��IUȋ�|�W?U�B�r�@x1g�\�������_▒k���U��CM�6�=��   y�w?�~2�z��MO=(�>R����K��:��k�Qe8��a�
                        �*謥��^oF�c�� q���H�1�)+���>P\v�S%�ɻ�۷��餰,|�������bmf3q��Mщ�)w����m�=�=z�g/�U(�M�W����         ��V~c)C�ofȠ����Mg��6RLX2�       ���[<��I���Y�vl���38�=�,b�n~���BI>��
                               ,����=�J�HG~hD�14�l�\�W4nQ��K'Ӥ~▒0_.{x�"�ʚ���Ҝd��m�����)��{7č�«��`/���P�yo��BM��Jgn��2r���▒^ϰ`�7��%�▒�z���lY��S����B��▒�����<��z�ߧ,fQp�?���<��V����<�L�������!]�K6������+R�iݍ<:��-�������`�������H�F�5_8c�=D��ɬ�NC�▒8�3 9���6�A���+��p�▒=�_цS��oo���3#i�PR$�ę���L�o�ߏ������w����o���]�P
9�g��)�3�^,to��5L)�?=|J���0�[� ���� ������������Ő
                                                 ;��<.|p�����%.�>@▒��▒��0��:nM1Y�X�gP��v4{)b�>Փi�d5��ݹ#j�[��LڂLU���d�?�)�Ia�k�
�O���vb37sԸ~�vJc�%N���▒�=�\@073]��6���e�~       �z�S��T�4��.���T�"�&UK�1�-#
#▒�i^���#{��@9+D/'?,��"�"����j�hH`��P1vEGF'9|���P3�6��1['F�����6�Z�U�܌�Ϲ������,D��ƘfBNʁ�����N|K��CLV-���)2�*��L ��G!�SLi�N��"S��2-���X����$�▒�Jݛ�M5����sȫ�Ӝ~D���,��Ts?Ը��ǹ���q���h鞹�6ʃ�?k�ٸ���ʖ�'c��_(1�oo�*��
                                                  �X�*E� ��▒��6g<��A~*�F�*�`Ec�O���5B�Hk�Gos�$�� ���l#D��sȿ�~R���c��x[��iڵfOd'�.'F�N    E�R��n�Y�� J��3?��33��}CF��%��`�kv=����;����������,�R���=���T
                                        ���E܊���q$��|�:���Rd*,
�7+\(�)▒��"��w{�1b�7_�7�q�=�V���3����%ۥ�`!�����5{~i���!�L�]`�]������h&�6��BS�|�▒��PԐK6Ŕu���xy@J���$y▒��e��ݜ�r$��:�gX� ��
                                                                                                                        G��Z%��<�
:��g����yV�M]��Vf����i�L�u#�&ZR�7٬.׳?L6>�D�▒GC�:jЂ��}��=��T�k�@I]j5�}0Ļ�_�zW5E��f3c�ᦩ�a��Ozݏ������:�Dr%[+��*2lk���X�齲g/$�%��g�Z"g��x�
                                                                                                                                      ���#� K�_p����?w�Fu�cp�A�tL[��#��Ƴ���wv..ک!�5��nH�mwQ!2�
�(���k�}�N l�E������*�9�<u2����_0�Y���4�`▒�w�j:6�ek�{OXr���/��?d��mH�m�3�EM`��om�x��۽��>���Ihe�X��N�tz�xb�(X�1��oPZ�ɱ�ݿQ��{▒�%�xV��۵G�{TbJ;=l��J�Q�/��,��??r)SՒ98UU��jߗc-�?4���6�[�$�J��S��ۿv��P��u$��4+�2ʾ�$�oI�[=lI���a6�ȁ
u-)E��f�        �Ƙ�p��~��L�]wPP�J��O1#�{"@Ip�I�2��Di�����T�m�Gf�rSa���w�����l��e����0b��n���%����(��xN�]��
���LN�|�r1�7�6��8������<D�_o��kV�Jx�#���[�����딭��E�����O.x�s�薲�Ҋ����I��t�.�RF�L�V¡G�D�5c
                                                                                          %�0d�������^b�C�EX��I��,S��)o��8/�-��ďRj$�e0G�rx70yJ{��|Ƞ��ÒX 5��a���C�2�����{�5���8+�dm)��Z�R��
                             |�q����E▒�C��[�qX2R^{X�����WH      fU�����B�|��������j��n�c�����`����yq��  ����������E�0�Mhr��Xw��<Ͱ�[     �N�iޑ2KYl��A���)�#pJ_�)�]�PJoZP�EW��-"���D��Yq5� �G^xu�,-ҏ����i�o}2��j��Ֆ�����[:ˇ52��)"t     jh�y��========== G7w8LIi6J3kTb8A7j9LgrywtEUlyyp6s
ǎ��a��;)��=�\��CEznc�a=��2[Q:�7�·▒�4�x����k[z\e+        ԋK�/�+
                                                              VcM�w�l���M�>8=6�+(�gl/�hc�r�h�<�6)�v��Ǵ�;�S��B%h�D W�K��l��Ƽ��Fi��ell���Q9z-▒(/�ȗ���-���5)(�z�mY6�xs�("P��OLh���A�s   d�1��gL�@^%{��+�9����bN�J���2���9�
�Djh�Wǣ�ͻ�/���▒0J|Y]�����sl(�t�^�>�P�����▒�S񡣸tVҦ\D���9Lv��1�6�؞���������L=�$?%96
                                                                                ��M�9��囸F�r���.GD#�+<Es�+�Z�C�{�[
�d��0 �ݪj<���3��5~�M��Lp��u�Eu                                                                                      �׫�%j�4?��
x�pH����+�YґD-���'�z�;$ ��=����^��▒@?x�s�2���SF6����
                                                    B���-��d�t)����U@:fA49f!��83�9�^/�▒C��o�HG�נQ�J^�����?a���d-��:
                                                                                                                   ¥n%▒�V��V    ��&�k�f�NrI�2���Z��P@߃_8�89���i�+x.i�R�Қ��L��U����:k<��<�U�Y�����ENJ�ů�>�����~�ni7B�
�sI                                                    ��D���
��+ji��=r=_%ɴ�fpb��jE��tI��(/��C� _H�6A��Kem��▒P��Ѝm;I��"E��������t��Kl��2�sCD���=Ϩ�솃v�L�����7 ��SF ٽ��I��k6*�����h�FS�{�Q▒�;��H%n���ۀ�2XNcD[��r��c>��[,o"b��Q��QH����i�h�|����Л���^�;���g����lN���T�!�%o��DBtwa���t]{P�Ϣ��"��a9~$w����Ü<��)���>.Tp��@o�L�@w�e
                                                                                                  ���k�,�FG�[C����ld�!�°\��
                                                                                                                           ����-q�}x6~E��MqO����{�0���Ѻ�� ����R�<���q���N��,���

%U
  �R�_O�KݮKC�++�A1����d�=q�u���O(�?6�
                                     ݮS˗^�^t|d������������(�thZ��=uea��ҩ[D�[�/��f�<=�]os▒8�?$f��av1�.2j��zڷ/?���gu��x�&�����    k���aH�$M�kY{?�`g}�\~2▒���P����V?�x�)��v���*�Ҋ7Cmpie�m��
��5tKW��pI���1�3�~�o5��~�U��!���'A��$���"�q�\cR4H��ras�З�Є�k[0����
                                                                  Hs���5�`h��B�����
                                                                                   �▒�lg#����▒��L��r�_
                                                                                                      9'Z�u�
                                                                                                            �]3�����׃_q���O5�'�1�k���H�]Y����ӄ�ե��=f�Qg R�;��d���uu��o�R�g
�V�ʈ��� ���σ%�R�y|      |�Lka�isqH�A�Qe>fC�C��S����T�rX�V^ο�ҽ-�i���'�z}�CҼ%R��H5��▒B��▒�BA�k��~}hO����e��e�Ah����ܡ:F�����S�D�o�ϲY߆R"DC▒����ĺe�M�xRq�@��
                                                                                                                                                        �B|?9h(���s���R��Y�%Ø3�ŀ$��-�рxN��)���g�?�
                                     b�/�И?�q��9�i�K��p��>�^QMG/�\J�&   �a�_m�����RҨX�q��"�zl=4 �K������.e��y���q'��%N���T��,��qFh31���aXbۮ��j�q���o��wFU����F�=�G��)�p���F<�N=�gg0/��j8\�� ���#qF~K��y^��?�HeU�     �6�!��f����&�x<A&���gN�j�|�
                                                                                   ��lHZ��y;u_  nN�+�<t�▒맦�%��-nLo�q�
bandit9@bandit:~$

Với đối số -a của lệnh grep đã xử lý được, nhưng kết quả là các ký tự không đọc được vì vậy ta sẽ sử dụng lệnh string để kiểm tra.

Cú pháp của lệnh strings:
strings -h                                     
Usage: strings [option(s)] [file(s)]
 Display printable strings in [file(s)] (stdin by default)
 The options are:
  -a - --all                Scan the entire file, not just the data section [default]
  -d --data                 Only scan the data sections in the file
  -f --print-file-name      Print the name of the file before each string
  -n <number>               Locate & print any sequence of at least <number>
    --bytes=<number>         displayable characters.  (The default is 4).
  -t --radix={o,d,x}        Print the location of the string in base 8, 10 or 16
  -w --include-all-whitespace Include all whitespace as valid string characters
  -o                        An alias for --radix=o
  -T --target=<BFDNAME>     Specify the binary file format
  -e --encoding={s,S,b,l,B,L} Select character size and endianness:
                            s = 7-bit, S = 8-bit, {b,l} = 16-bit, {B,L} = 32-bit
  --unicode={default|show|invalid|hex|escape|highlight}
  -U {d|s|i|x|e|h}          Specify how to treat UTF-8 encoded unicode characters
  -s --output-separator=<string> String used to separate strings in output.
  @<file>                   Read options from <file>
  -h --help                 Display this information
  -v -V --version           Print the program's version number
strings: supported targets: elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 pei-i386 pe-x86-64 pei-x86-64 elf64-little elf64-big elf32-little elf32-big pe-bigobj-x86-64 pe-i386 pdb srec symbolsrec verilog tekhex binary ihex plugin
Report bugs to <https://sourceware.org/bugzilla/>                                                 
3. Sử dụng lệnh string
bandit9@bandit:~$ strings data.txt | grep "="

Level 10  Level 11

The password for the next level is stored in the file data.txt, which contains base64 encoded data

Level Answer

1.  Login
SSH: ssh bandit10@bandit.labs.overthewire.org -p 2220
Password: G7w8LIi6J3kTb8A7j9LgrywtEUlyyp6s

2. Sử dụng lệnh base64
 
Cú pháp lệnh base64:
base64 --help
Usage: base64 [OPTION]... [FILE]
Base64 encode or decode FILE, or standard input, to standard output.

With no FILE, or when FILE is -, read standard input.

Mandatory arguments to long options are mandatory for short options too.
  -d, --decode          decode data
  -i, --ignore-garbage  when decoding, ignore non-alphabet characters
  -w, --wrap=COLS       wrap encoded lines after COLS character (default 76).
                          Use 0 to disable line wrapping
      --help        display this help and exit
      --version     output version information and exit

The data are encoded as described for the base64 alphabet in RFC 4648.
When decoding, the input may contain newlines in addition to the bytes of
the formal base64 alphabet.  Use --ignore-garbage to attempt to recover
from any other non-alphabet bytes in the encoded stream.

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Full documentation <https://www.gnu.org/software/coreutils/base64>
or available locally via: info '(coreutils) base64 invocation'
bandit10@bandit:~$ base64 --decode data.txt

Level Password6zPeziLdR2RKNdNYFNb6nVCKzphlXHBM

Giới thiệu thêm một cách khác để tìm ra password
  • Đầu tiên sử dụng lệnh cat data.txt để xem nội dung têp data.txt

Đưa mã VGhlIHBhc3N3b3JkIGlzIDZ6UGV6aUxkUjJSS05kTllGTmI2blZDS3pwaGxYSEJNCg== cần decode lên CyberChef để giải mã.
https://gchq.github.io/CyberChef/#recipe=From_Base64('A-Za-z0-9%2B/%3D',true,false)&input=VkdobElIQmhjM04zYjNKa0lHbHpJRFo2VUdWNmFVeGtVakpTUzA1a1RsbEdUbUkyYmxaRFMzcHdhR3hZU0VKTkNnPT0&ieol=CRLF

Level 11 → Level 12

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

Level Answer

1.  Login
SSH: ssh bandit11@bandit.labs.overthewire.org -p 2220
Password: 6zPeziLdR2RKNdNYFNb6nVCKzphlXHBM

2. Dùng lệnh cat để lấy nội dung tệp data.txt
bandit11@bandit:~$ cat data.txt
Gur cnffjbeq vf WIAOOSFzMjXXBC0KoSKBbJ8puQm5lIEi

Bây giờ, chúng ta có thể giải mã này bằng bất kỳ công cụ giải mã nào mà bạn thích. Bản thân mình sử dụng CyberChef làm công cụ chính cho writeup.
https://gchq.github.io/CyberChef/#recipe=ROT13(true,true,false,13)&input=R3VyIGNuZmZqYmVxIHZmIFdJQU9PU0Z6TWpYWEJDMEtvU0tCYko4cHVRbTVsSUVp&ieol=CRLF&oeol=CRLF

Level PasswordJVNBBFSmZwKKOP0XbFXOoW8chDz5yVRv

Tuy nhiên, nếu bạn cho rằng giải quyết vấn đề này bằng lệnh Linux tích hợp sẽ hấp dẫn hơn, thì có một phương pháp bắt chước quá trình giải mã ROT13 bằng lệnh tr :

Cú pháp lệnh tr:
man tr
NAME
       tr - translate or delete characters

SYNOPSIS
       tr [OPTION]... STRING1 [STRING2]

DESCRIPTION
       Translate,  squeeze,  and/or delete characters from standard input, writing to standard output.  STRING1 and STRING2 specify arrays of characters ARRAY1 and ARRAY2 that control
       the action.

       -c, -C, --complement
              use the complement of ARRAY1

       -d, --delete
              delete characters in ARRAY1, do not translate

       -s, --squeeze-repeats
              replace each sequence of a repeated character that is listed in the last specified ARRAY, with a single occurrence of that character

       -t, --truncate-set1
              first truncate ARRAY1 to length of ARRAY2

       --help display this help and exit

       --version
              output version information and exit

...
ROT13 ("rotate by 13 places") là một phương pháp "mã hoá" đơn giản bằng việc thay thế 1 chữ cái bằng chữ cách nó 13 chữ cái trong bảng chữ cái tiếng Anh. Lý do có số 13 là bởi bảng chữ cái tiếng Anh gồm 26 chữ, và nhờ vậy mà để giải mã các ký tự đã bị đảo đi, người ta chỉ cần dịch nó đi tiếp 13 chữ là thu được kết quả ban đầu. 

Hãy chia bảng chữ cái làm đôi và xếp cạnh nhau, ta có:
a  b  c  d  e  f  g  h  i  j  k  l  m
n  o  p  q  r  s  t  u  v  w  x  y  z

ROT13 chỉ việc thay một chữ cái bằng chữ tương ứng ở nửa bên kia (a - n, b - o, ... m - z).
Sử dụng lệnh tr như sau để giải mã ROT13:
bandit11@bandit:~$ cat data.txt | tr "A-Za-z" "N-ZA-Mn-za-m"
The password is JVNBBFSmZwKKOP0XbFXOoW8chDz5yVRv

Level 12 → Level 13

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!)

Level Answer

1.  Login

SSH: ssh bandit12@bandit.labs.overthewire.org -p 2220
Password: JVNBBFSmZwKKOP0XbFXOoW8chDz5yVRv

2. Thực hiện làm theo như đề bài xem kết quả trả về.
bandit12@bandit:~$ mkdir /tmp/mt-tec1
bandit12@bandit:~$ cp data.txt /tmp/mt-tec1
bandit12@bandit:~$ cd /tmp/mt-tec1
bandit12@bandit:/tmp/mt-tec1$ ls -l
total 4
-rw-r----- 1 bandit12 bandit12 2582 Apr 12 04:00 data.txt

Giải thích những câu lệnh trên:

Tập lệnhGiải thích
bandit12@bandit:~$ mkdir /tmp/mt-tec1Tạo một thư mục mới tên tmp và đặt tên tệp mới là mt-tec1
bandit12@bandit:~$ cp data.txt /tmp/mt-tec1Sao chép têp data.txt từ ~ sang /tmp/mt-tec1
bandit12@bandit:~$ cd /tmp/mt-tec1Thay đổi thư mục làm việc thành /tmp/mt-tec1 bằng lệnh cd
bandit12@bandit:/tmp/mt-tec1$ ls -lLiệt kê các tệp và thư mục /tmp/mt-tec1

Giờ hãy xem nội dung tệp data.txt trong thư mục /tmp/mt-tec1
bandit12@bandit:/tmp/mt-tec1$ cat data.txt
00000000: 1f8b 0808 6855 1e65 0203 6461 7461 322e  ....hU.e..data2.
00000010: 6269 6e00 013d 02c2 fd42 5a68 3931 4159  bin..=...BZh91AY
00000020: 2653 5948 1b32 0200 0019 ffff faee cff7  &SYH.2..........
00000030: f6ff e4f7 bfbc ffff bff7 ffb9 39ff 7ffb  ............9...
00000040: bd31 eeff b9fb fbbb b9bf f77f b001 3b2c  .1............;,
00000050: d100 0d03 d200 6868 0d00 0069 a00d 0340  ......hh...i...@
00000060: 1a68 00d0 0d01 a1a0 0001 a680 0003 46d4  .h............F.
00000070: 6434 3234 611a 340d 07a4 c351 068f 5000  d424a.4....Q..P.
00000080: 069a 0680 0000 0006 8006 8da4 681a 6868  ............h.hh
00000090: 0d06 8d00 6834 3400 d07a 9a00 01a0 0341  ....h44..z.....A
000000a0: ea1e a190 da40 3d10 ca68 3468 6800 00c8  .....@=..h4hh...
000000b0: 1a1a 1b50 0683 d434 d069 a0d0 3100 d000  ...P...4.i..1...
000000c0: 001e a680 00d0 1a00 d0d0 6864 d0c4 d0d0  ..........hd....
000000d0: 000c 8641 7440 0108 032e 86b4 4cf0 22bb  ...At@......L.".
000000e0: 6682 2b7e b3e2 e98d aa74 dacc 0284 330d  f.+~.....t....3.
000000f0: bbb2 9494 d332 d933 642a 3538 d27e 09ce  .....2.3d*58.~..
00000100: 53da 185a 505e aada 6c75 59a2 b342 0572  S..ZP^..luY..B.r
00000110: 249a 4600 5021 25b0 1973 c18a 6881 1bef  $.F.P!%..s..h...
00000120: 3f9b 1429 5b1d 3d87 68b5 804f 1d28 42fa  ?..)[.=.h..O.(B.
00000130: 16c2 3241 98fb 8229 e274 5a63 fe92 3aca  ..2A...).tZc..:.
00000140: 70c3 a329 d21f 41e0 5a10 08cb 888f 30df  p..)..A.Z.....0.
00000150: f3da ce85 418b 0379 6a65 cfa2 eeb7 9f01  ....A..yje......
00000160: 782c da0e 288b e0c3 fe13 7af5 45ab 2b22  x,..(.....z.E.+"
00000170: a432 bf2f e32d b9e6 1465 2296 d805 a45e  .2./.-...e"....^
00000180: d1c1 eacb 7483 6aac ca0e cf24 8864 bd40  ....t.j....$.d.@
00000190: 118c 644a 1dc6 a127 375c b7a6 c124 bdae  ..dJ...'7\...$..
000001a0: 6d31 63a0 a223 3ea0 61d4 bdf0 450f 56fb  m1c..#>.a...E.V.
000001b0: a546 8d34 08a2 4f1d 43d3 9063 404d dd43  .F.4..O.C..c@M.C
000001c0: b4f2 e65d bcb7 5932 0f5e 6802 3892 a988  ...]..Y2.^h.8...
000001d0: 443d 8e89 7e09 4fb0 499d ee4e 4470 46c0  D=..~.O.I..NDpF.
000001e0: 2ba6 7c62 234a 7f76 151b aec0 23ee 4a97  +.|b#J.v....#.J.
000001f0: bc64 e34c de8a 5724 a1c3 9b89 cd96 1879  .d.L..W$.......y
00000200: d560 0cbb 5c26 09e4 efaf 5b94 402a 7780  .`..\&....[.@*w.
00000210: 4d87 30ce b8a3 946e 72c1 a643 1db7 a060  M.0....nr..C...`
00000220: 6524 629c 0c7e 8e7b e0f8 820c d5cb 60a0  e$b..~.{......`.
00000230: 003c a584 d4c1 61ef eb02 3f65 3a54 a3a2  .<....a...?e:T..
00000240: a565 c154 34c2 b162 d206 1ff8 bb92 29c2  .e.T4..b......).
00000250: 8482 40d9 9010 b3a9 e478 3d02 0000       ..@......x=...
bandit12@bandit:/tmp/mt-tec1$
Nội dung tệp data.txt với rất nhiều ký tự được mã hóa HEX và ký tự ASCII. Chúng ta sử dụng lệnh xxd để chuyển thành mã nhị phân với đối số -r
xxd không thực sự là một trình soạn thảo hex, nó chỉ hiển thị hex. Tuy nhiên, chúng tôi có thể sử dụng nó để chuyển đổi tệp thành hex, chỉnh sửa chúng bằng trình soạn thảo văn bản yêu thích của chúng tôi, sau đó chuyển đổi tệp trở lại định dạng chính xác.
bandit12@bandit:/tmp/mt-tec1$ xxd -r data.txt > solution
bandit12@bandit:/tmp/mt-tec1$ ls
data.txt  solution
bandit12@bandit:/tmp/mt-tec1$ file solution
solution: gzip compressed data, was "data2.bin", last modified: Thu Oct  5 06:19:20 2023, max compression, from Unix, original size modulo 2^32 573

Giải thích các lệnh trên trong bảng sau:

Tập lệnhGiải thích
bandit12@bandit:/tmp/mt-tec1$ xxd -r data.txt > solutionhexdump ngược và lưu kết quả vào một tệp đặt tên là solution
bandit12@bandit:/tmp/mt-tec1$ ls
data.txt  solution
Liệt kê các tệp hoặc thư mục
bandit12@bandit:/tmp/mt-tec1$ file solution
Xác định loại file (trường hợp này là file solution)

Từ đây trở đi, tiến trình như sau:

    1. Sử dụng lệnh file, xác định định dạng của tệp này.

    2. Sử dụng lệnh mv để thay đổi loại tệp bằng cách đổi tên nó thành phần mở rộng định dạng tệp cụ thể đó.

    3. Sử dụng công cụ thích hợp để giải nén/giải nén các tệp (trong trường hợp này, gzip hoặc gunzip, bzip2tar đóng một vai trò quan trọng).

    4. Lặp lại các bước 1-3 cho đến khi bạn nhận được tệp.

Danh sách các lệnh thực hiện như dưới đây, nó sẽ khá dài. Tuy nhiên, nó tuân theo tiến trình ở trên. Để dễ hiểu hơn thì mình đã thêm "ngắt dòng" sau mỗi thay đổi về loại tệp.
bandit12@bandit:/tmp/mt-tec1$ file solution
solution: gzip compressed data, was "data2.bin", last modified: Thu Oct  5 06:19:20 2023, max compression, from Unix, original size modulo 2^32 573
bandit12@bandit:/tmp/mt-tec1$ mv solution solution.gz
bandit12@bandit:/tmp/mt-tec1$ gunzip solution.gz

bandit12@bandit:/tmp/mt-tec1$ file solution
solution: bzip2 compressed data, block size = 900k
bandit12@bandit:/tmp/mt-tec1$ mv solution solution.bz2
bandit12@bandit:/tmp/mt-tec1$ bzip2 -d solution.bz2

bandit12@bandit:/tmp/mt-tec1$ file solution
solution: gzip compressed data, was "data4.bin", last modified: Thu Oct  5 06:19:20 2023, max compression, from Unix, original size modulo 2^32 20480
bandit12@bandit:/tmp/mt-tec1$ 
bandit12@bandit:/tmp/mt-tec1$ mv solution solution.gz
bandit12@bandit:/tmp/mt-tec1$ gunzip solution.gz

bandit12@bandit:/tmp/mt-tec1$ file solution
solution: POSIX tar archive (GNU)
bandit12@bandit:/tmp/mt-tec1$ mv solution solution.tar
bandit12@bandit:/tmp/mt-tec1$ tar xvf solution.tar data5.bin
data5.bin

bandit12@bandit:/tmp/mt-tec1$ file data5.bin
data5.bin: POSIX tar archive (GNU)
bandit12@bandit:/tmp/mt-tec1$ mv data5.bin data5.tar
bandit12@bandit:/tmp/mt-tec1$ tar xvf data5.tar data6.bin
data6.bin

bandit12@bandit:/tmp/mt-tec1$ file data6.bin
data6.bin: bzip2 compressed data, block size = 900k
bandit12@bandit:/tmp/mt-tec1$ mv data6.bin data6.bz2
bandit12@bandit:/tmp/mt-tec1$ bzip2 -d data6.bz2

bandit12@bandit:/tmp/mt-tec1$ file data6
data6: POSIX tar archive (GNU)
bandit12@bandit:/tmp/mt-tec1$ mv data6 data6.tar
bandit12@bandit:/tmp/mt-tec1$ tar xvf data6.tar data8.bin
data8.bin

bandit12@bandit:/tmp/mt-tec1$ file data8.bin
data8.bin: gzip compressed data, was "data9.bin", last modified: Thu Oct  5 06:19:20 2023, max compression, from Unix, original size modulo 2^32 49
bandit12@bandit:/tmp/mt-tec1$ mv data8.bin data8.gz
bandit12@bandit:/tmp/mt-tec1$ gzip -d data8.gz

bandit12@bandit:/tmp/mt-tec1$ file data8
data8: ASCII text
bandit12@bandit:/tmp/mt-tec1$ cat data8
The password is wbWdlBxEir4CaE8LaPhauuOo6pwRmrDw
Level Password: wbWdlBxEir4CaE8LaPhauuOo6pwRmrDw

Level 13 → Level 14

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

Level Answer

1.  Login

SSH: ssh bandit13@bandit.labs.overthewire.org -p 2220
Password: wbWdlBxEir4CaE8LaPhauuOo6pwRmrDw

2. Liệt kê danh sách thực mục hoặc tệp trong thư mục root.
ls -l

3. Xem thử nội dung của tệp sshkey.private (bước này có thể bỏ qua)

cat sshkey.private

4. Đăng nhập với mật mã khóa công khai.

ssh -i {privatekey_file} {username}@{server} -p {port_no}

Thông tin về lệnh SSH với cú pháp man ssh:

Ở những level trước chúng ta mới chỉ đăng nhập vào SSH bằng mật khẩu. Một giải pháp thay thế cho mật khẩu là sử dụng mật mã khóa công khai (public-key cryptography). Khóa chung được đặt trên những máy sẽ cho phép người dùng sở hữu khóa riêng truy cập (máy chủ từ xa). Giống như mật khẩu, điều quan trọng là chỉ người dùng mới biết/sở hữu khóa riêng.

Như vậy ở level này mục đích là ta sẽ đăng nhập vào server bandit 14 khi ta đang ở server bandit 13 mà không cần password SSH chỉ cần mã khóa công khai.

Như vậy áp dụng lệnh SSH tham số[-i identity_file] ta sẽ đăng nhập vào bandit14 như sau:

ssh -i sshkey.private bandit14@localhost -p 2220

Đến đây là đã đăng nhập thành công vào bandit14, có thể kiểm tra với lệnh:
whoami

5. Sử dụng cat để đọc khóa bí mật cho cấp độ tiếp theo như lời nhắc trong câu hỏi.
cat /etc/bandit_pass/bandit14

Level Password: fGrHPx402xGC7U7rXKDaxiWFTOiF0ENq

Toàn bộ level này thực hiện trên terminal như sau:

Nội dung:
┌┌──(kali㉿kali)-[~]
└─$ whoami
kali
                                                                                  
┌──(kali㉿kali)-[~]
└─$ ssh bandit13@bandit.labs.overthewire.org -p 2220
                         _                     _ _ _   
                        | |__   __ _ _ __   __| (_) |_ 
                        | '_ \ / _` | '_ \ / _` | | __|
                        | |_) | (_| | | | | (_| | | |_ 
                        |_.__/ \__,_|_| |_|\__,_|_|\__|
                                                       

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

bandit13@bandit.labs.overthewire.org'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/
    * peda (https://github.com/longld/peda.git) in /opt/peda/
    * 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!

bandit13@bandit:~$ whoami
bandit13
bandit13@bandit:~$ ls -l
total 4
-rw-r----- 1 bandit14 bandit13 1679 Oct  5  2023 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-----
bandit13@bandit:~$ ssh -i sshkey.private bandit14@localhost -p 2220
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/bandit13/.ssh' (Permission denied).
Failed to add the host to the list of known hosts (/home/bandit13/.ssh/known_hosts).
                         _                     _ _ _   
                        | |__   __ _ _ __   __| (_) |_ 
                        | '_ \ / _` | '_ \ / _` | | __|
                        | |_) | (_| | | | | (_| | | |_ 
                        |_.__/ \__,_|_| |_|\__,_|_|\__|
                                                       

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

!!! You are trying to log into this SSH server with a password on port 2220 from localhost.
!!! Connecting from localhost is blocked to conserve resources.
!!! Please log out and log in again.


      ,----..            ,----,          .---.
     /   /   \         ,/   .`|         /. ./|
    /   .     :      ,`   .'  :     .--'.  ' ;
   .   /   ;.  \   ;    ;     /    /__./ \ : |
  .   ;   /  ` ; .'___,/    ,' .--'.  '   \' .
  ;   |  ; \ ; | |    :     | /___/ \ |    ' '
  |   :  | ; | ' ;    |.';  ; ;   \  \;      :
  .   |  ' ' ' : `----'  |  |  \   ;  `      |
  '   ;  \; /  |     '   :  ;   .   \    .\  ;
   \   \  ',  /      |   |  '    \   \   ' \ |
    ;   :    /       '   :  |     :   '  |--"
     \   \ .'        ;   |.'       \   \ ;
  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/
    * peda (https://github.com/longld/peda.git) in /opt/peda/
    * 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!

bandit14@bandit:~$ whoami
bandit14
bandit14@bandit:~$ cat /etc/bandit_pass/bandit14
fGrHPx402xGC7U7rXKDaxiWFTOiF0ENq
bandit14@bandit:~$

Level 14 → Level 15

The password for the next level can be retrieved by submitting the password of the current level to port 30000 on localhost.

Sau khi đọc yêu cầu của câu hỏi, tôi nghĩ ngay đến việc đăng nhập Telnet hoặc nc. Cái gọi là gửi mật khẩu chính là sao chép khóa bí mật khi đăng nhập qua Telnet.

Level Answer

1.  Login

SSH: ssh bandit14@bandit.labs.overthewire.org -p 2220
Password: fGrHPx402xGC7U7rXKDaxiWFTOiF0ENq

2. Thực hiện kết nối đến cổng 30000 bằng telnet và nhập mã khóa đã tìm được ở level trước.
bandit14@bandit:~$ telnet localhost 30000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
fGrHPx402xGC7U7rXKDaxiWFTOiF0ENq
Correct!
jN2kgmIXJ6fShzhT2avhotn4Zcka6tnt

Connection closed by foreign host.

Cách khác là sử dụng lênh nc:
bandit14@bandit:~$ cat /etc/bandit_pass/bandit14 | nc localhost 30000
Correct!
jN2kgmIXJ6fShzhT2avhotn4Zcka6tnt

Giải thích lệnh trên thì kết quả đầu ra STDOUT của lệnh cat sẽ được chuyển thành STDIN của lệnh netcat. Đối số đầu tiên cho netcat là địa chỉ IP muốn gửi đến (trong trường hợp này là localhost hoặc 127.0.0.1 ) và đối số thứ hai là cổng muốn kết nối (trường hợp này là 30000). Netcat sau đó sẽ gửi mật khẩu đến đúng vị trí.

Level PasswordjN2kgmIXJ6fShzhT2avhotn4Zcka6tnt

Toàn bộ level này thực hiện trên terminal như sau:

Nội dung:
┌──(kali㉿kali)-[~]
└─$ ssh bandit14@bandit.labs.overthewire.org -p 2220
                         _                     _ _ _   
                        | |__   __ _ _ __   __| (_) |_ 
                        | '_ \ / _` | '_ \ / _` | | __|
                        | |_) | (_| | | | | (_| | | |_ 
                        |_.__/ \__,_|_| |_|\__,_|_|\__|
                                                       

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

bandit14@bandit.labs.overthewire.org'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/
    * peda (https://github.com/longld/peda.git) in /opt/peda/
    * 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!

bandit14@bandit:~$ telnet localhost 30000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
fGrHPx402xGC7U7rXKDaxiWFTOiF0ENq
Correct!
jN2kgmIXJ6fShzhT2avhotn4Zcka6tnt

Connection closed by foreign host.
bandit14@bandit:~$ cat /etc/bandit_pass/bandit14 | nc localhost 30000
Correct!
jN2kgmIXJ6fShzhT2avhotn4Zcka6tnt

bandit14@bandit:~$

Level 15 → Level 16

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…

Với level này tôi sẽ sử dụng openssl để tìm password như gợi ý của câu hỏi.

Level Answer

1.  Login

SSH: ssh bandit15@bandit.labs.overthewire.org -p 2220
Password: jN2kgmIXJ6fShzhT2avhotn4Zcka6tnt

2. Sử dụng lệnh openssl

Cú pháp lệnh pensl tham khảo với man openssl

openssl s_client -connect localhost:30001


Level PasswordJQttfApK4SeyHwDlI9SXGR50qclOAil1

Toàn bộ level này thực hiện trên terminal như sau:

Nội dung:
┌──(kali㉿kali)-[~]
└─$ ssh bandit15@bandit.labs.overthewire.org -p 2220
                         _                     _ _ _   
                        | |__   __ _ _ __   __| (_) |_ 
                        | '_ \ / _` | '_ \ / _` | | __|
                        | |_) | (_| | | | | (_| | | |_ 
                        |_.__/ \__,_|_| |_|\__,_|_|\__|
                                                       

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

bandit15@bandit.labs.overthewire.org'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/
    * peda (https://github.com/longld/peda.git) in /opt/peda/
    * 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!

bandit15@bandit:~$ openssl s_client -connect localhost:30001
CONNECTED(00000003)
Can't use SSL_get_servername
depth=0 CN = localhost
verify error:num=18:self-signed certificate
verify return:1
depth=0 CN = localhost
verify error:num=10:certificate has expired
notAfter=Apr 15 16:30:42 2024 GMT
verify return:1
depth=0 CN = localhost
notAfter=Apr 15 16:30:42 2024 GMT
verify return:1
---
Certificate chain
 0 s:CN = localhost
   i:CN = localhost
   a:PKEY: rsaEncryption, 2048 (bit); sigalg: RSA-SHA1
   v:NotBefore: Apr 15 16:29:42 2024 GMT; NotAfter: Apr 15 16:30:42 2024 GMT
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIDCzCCAfOgAwIBAgIEE4vgyjANBgkqhkiG9w0BAQUFADAUMRIwEAYDVQQDDAls
b2NhbGhvc3QwHhcNMjQwNDE1MTYyOTQyWhcNMjQwNDE1MTYzMDQyWjAUMRIwEAYD
VQQDDAlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCQ
2tKWEgOWtcocZzoACzYvlOcQJ7cnhKuPtRbi5XkWAgcfIVERreFcbs5PoS90l0zb
7lKXrpI6v+wvJXwXQYGWeYG2YMxzQPWprvIlE5+gV+woIyjSb+uQiqYTnwxqZd8v
P8AF4f0IVS+xBnGxZpKOYWsc6ZLiJ7g+uOgXMn75j3yprga4WQu4YEQuyTqM6nXi
b5sxs2MaoPT4PVPmTwozgWWCvGvWJiHU9H2VfkhpbgOWEm7Z84xLgFjTlJruszZt
KGs/wH7x5pNno6zfaXH4BmgQFhhRit1Ul3o2i95kw6YGCqQMcNLIM99Js67J4G3d
dvW7IOrzlnuFEe7q8YXjAgMBAAGjZTBjMBQGA1UdEQQNMAuCCWxvY2FsaG9zdDBL
BglghkgBhvhCAQ0EPhY8QXV0b21hdGljYWxseSBnZW5lcmF0ZWQgYnkgTmNhdC4g
U2VlIGh0dHBzOi8vbm1hcC5vcmcvbmNhdC8uMA0GCSqGSIb3DQEBBQUAA4IBAQA2
ju1J79ZnGhyxAO6SI4Rl/VKoSTnxTPc3qmm/UEWtzPJmnJLlsnVIxd9IvGMkp9Gp
9JTeb4jJkqkpms4ph2m64wJGWr/yehQ+wbubzo+a6huAHlhbrl60540TySlBvvvy
dCcmvf7H232MRULmJZu8PzFV1S6djQlvxQy5SMugpQM6A5IJv/+9sW3Upfg1Wohf
KVURwURoBQSnIHelymt2YlF9PkeYmPFvTKX9GoyLYIZOgk7aQ0sOek7HQocVuy5M
3CVYrYRwaxkycyaBwL3qdN/af4GWkiTfcXmci52sgQdBH/ZWCIBRpRc5l2WZHh3q
TuVl/callwJshJSwLIv8
-----END CERTIFICATE-----
subject=CN = localhost
issuer=CN = localhost
---
No client certificate CA names sent
Peer signing digest: SHA256
Peer signature type: RSA-PSS
Server Temp Key: X25519, 253 bits
---
SSL handshake has read 1339 bytes and written 373 bytes
Verification error: certificate has expired
---
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Server public key is 2048 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 10 (certificate has expired)
---
---
Post-Handshake New Session Ticket arrived:
SSL-Session:
    Protocol  : TLSv1.3
    Cipher    : TLS_AES_256_GCM_SHA384
    Session-ID: C2C393D497F4B73D1517A9B05AD49768BC364C38D6C2B3CDAA121006ACEC4AC5
    Session-ID-ctx: 
    Resumption PSK: 1B5811EEA8F0F9CF35CA4A4FB951E18D4C324B35E4FC56FADF852A7FB53ACC34798876BA0A4C770421821FFFC23BE00C
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 7200 (seconds)
    TLS session ticket:
    0000 - ea 43 05 0e 9c ae 8f fd-2b 1a 49 1e cb 3a dd bf   .C......+.I..:..
    0010 - 1d 35 fd 37 ed 06 8c 72-19 ae 5a b6 95 8f 15 43   .5.7...r..Z....C
    0020 - 00 37 62 a2 d8 22 e3 4f-12 49 c3 4b 8f ac fe 93   .7b..".O.I.K....
    0030 - 2f f6 c1 a9 55 62 f9 63-0e ea 0b fa d8 15 ea 25   /...Ub.c.......%
    0040 - 17 a4 d8 9c 9b 83 c7 ac-5c 12 02 7e c9 9b f1 cb   ........\..~....
    0050 - 5b 44 41 20 89 7d 02 3c-80 35 e1 f0 ce ec aa 3f   [DA .}.<.5.....?
    0060 - 50 e8 f8 39 30 c0 35 1f-40 0b 16 80 70 df cd 06   P..90.5.@...p...
    0070 - fe 72 ff 1f df a1 67 f2-bf 02 22 39 aa f3 f3 ed   .r....g..."9....
    0080 - 55 bb b4 91 ed 80 07 63-15 48 aa 5c e6 0b 04 0e   U......c.H.\....
    0090 - 2a 16 72 1a b9 2a ae 13-26 72 e5 ad 30 98 65 39   *.r..*..&r..0.e9
    00a0 - bb c5 e0 3d 64 d6 92 7d-6a 21 97 d1 91 74 52 e8   ...=d..}j!...tR.
    00b0 - 9a c0 88 a7 c3 e5 7c af-ca d3 4e 16 86 fb ff d2   ......|...N.....
    00c0 - 99 57 68 08 e0 e1 58 39-c1 ad 58 36 db 02 89 12   .Wh...X9..X6....

    Start Time: 1713247323
    Timeout   : 7200 (sec)
    Verify return code: 10 (certificate has expired)
    Extended master secret: no
    Max Early Data: 0
---
read R BLOCK
---
Post-Handshake New Session Ticket arrived:
SSL-Session:
    Protocol  : TLSv1.3
    Cipher    : TLS_AES_256_GCM_SHA384
    Session-ID: 50AEE343A277FAA3756EF7B1CB0FCADE00952C7E9B00EE24DB44FE5CC0148124
    Session-ID-ctx: 
    Resumption PSK: A3EBD08EAF03228F821E81E7E366BA0B1FA89C451541253E2BACCD87AFEDB8622C37DA1A28075955A91733DC4E569A13
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 7200 (seconds)
    TLS session ticket:
    0000 - ea 43 05 0e 9c ae 8f fd-2b 1a 49 1e cb 3a dd bf   .C......+.I..:..
    0010 - 74 db 6e 28 29 53 99 c9-55 97 ce bd 87 36 40 cc   t.n()S..U....6@.
    0020 - 37 18 cb ba 3a 09 4f bb-45 c1 04 de 5d 3e ff d0   7...:.O.E...]>..
    0030 - 0f 25 c6 5a a1 b2 08 6b-b3 d7 db 1d 8b 11 6e bc   .%.Z...k......n.
    0040 - 06 f7 d5 ca c9 72 3c 96-bb 03 dc 9d 4c 8c 8e b1   .....r<.....L...
    0050 - 97 6c e5 15 55 64 f8 51-f0 ad da e3 53 a3 14 13   .l..Ud.Q....S...
    0060 - 32 1a 99 a2 62 6e a6 31-94 ef 48 75 37 ab eb 36   2...bn.1..Hu7..6
    0070 - 95 d0 9f e8 17 b2 9d 44-48 3b 96 93 18 09 59 79   .......DH;....Yy
    0080 - 15 24 9a 54 79 e1 87 90-23 7e 3c 02 ae 35 e7 15   .$.Ty...#~<..5..
    0090 - 93 0e 07 f1 db 58 d4 af-04 2d 58 89 fb 94 f4 e7   .....X...-X.....
    00a0 - 7a 39 c2 35 73 ca be 27-f2 9f ba 86 4c 63 5f a2   z9.5s..'....Lc_.
    00b0 - a5 06 6a 49 db a0 f5 f2-bd b8 72 6f e3 b8 4b e4   ..jI......ro..K.
    00c0 - 31 0d ed 28 8e dc 9b 17-5c 62 c0 c7 3c 0d fa 59   1..(....\b..<..Y

    Start Time: 1713247323
    Timeout   : 7200 (sec)
    Verify return code: 10 (certificate has expired)
    Extended master secret: no
    Max Early Data: 0
---
read R BLOCK
jN2kgmIXJ6fShzhT2avhotn4Zcka6tnt
Correct!
JQttfApK4SeyHwDlI9SXGR50qclOAil1

closed
bandit15@bandit:~$

Level 15 → 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 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.

Trong câu hỏi có nhắc đến quét cổng và với gợi ý của câu hỏi cũng đề cập đến công cụ nmap - một cổng cụ quét cổng của máy chủ cục bộ. Vì vậy tôi sử dụng công cu nmap.

Level Answer

1.  Login

SSH: ssh bandit16@bandit.labs.overthewire.org -p 2220
Password: JQttfApK4SeyHwDlI9SXGR50qclOAil1

2. Sử dụng nmap để quét các cổng đang mở.

Câu lệnh nmap như sau:

bandit16@bandit:~$ nmap localhost -p 31000-32000
Starting Nmap 7.80 ( https://nmap.org ) at 2024-04-16 09:45 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00010s latency).
Not shown: 996 closed ports
PORT      STATE SERVICE
31046/tcp open  unknown
31518/tcp open  unknown
31691/tcp open  unknown
31790/tcp open  unknown
31960/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds

Quan sát kết quả trả về có 4 cổng đang mở, để biết cổng nào được cấu hình để chấp nhận kết nối bình thường hay kết nối bị giới hạn kết nối SSL.
bandit16@bandit:~$ echo test | nc -v localhost 31046
Connection to localhost (127.0.0.1) 31046 port [tcp/*] succeeded!
test
^C
bandit16@bandit:~$ echo test | nc -v localhost 31518
Connection to localhost (127.0.0.1) 31518 port [tcp/*] succeeded!
bandit16@bandit:~$ echo test | nc -v localhost 31691
Connection to localhost (127.0.0.1) 31691 port [tcp/*] succeeded!
test
^C
bandit16@bandit:~$ echo test | nc -v localhost 31790
Connection to localhost (127.0.0.1) 31790 port [tcp/*] succeeded!
bandit16@bandit:~$ echo test | nc -v localhost 31960
Connection to localhost (127.0.0.1) 31960 port [tcp/*] succeeded!
test
^C
bandit16@bandit:~$









BÙI

إرسال تعليق

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.