Anh Nguyen
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # task02 ## Hoàn thành 34 level overthewire: https://overthewire.org/wargames/bandit/ ### level 0: ![image](https://hackmd.io/_uploads/BJzxWmT10.png) tại level 0 này đề yêu cầu sử dụng ssh kết nối vào bandit.labs.overthewire.org. => tìm hiểu ssh: - SSH: là giao thức đăng nhập server từ xa cho phép ng dùng kiểm soát và chỉnh sửa cũng như quản lí dữ liệu của server thông qua nền tảng Internet - có 3 kỹ thuật mã hóa SSH: - SSH Symmetrical Encryption: sd secret key ở cả 2 chiều mã hóa và giải mã tin nhắn bởi cả host và client - SSH Asymmetrical Encryption: ss 2 khóa khác nhau để mã hóa vag giả mã(public key và private key)=> hình thành nên cặp khóa public-private key pair - SSH hashing: ko đc sinh ra để giải mã mà nó đc tạo ra một giá trị duy nhất với độ dài nhất định cho mỗi lần nhập liệu mà ko có hướng nào khác để khai thác(xác thực tn)=> đảm bảo ko bị giả mạo bởi bất kỳ phương thức nào - SSH Command ls Liệt kê danh sách file và thư mục cd Đổi thư mục mkdir Tạo thư mục mới touch Tạo file mới rm Xóa file cat Xem nội dung của file pwd Xem đường dẫn chi tiết thư mục hiện hành cp Sao chép file/folder mv Di chuyển file/folder grep Tìm một cụm từ trong files/dòng find Tìm files và thư mục vi/nano Biên tập file (text editor) history Hiển thị 50 lệnh thường dùng nhất clear Xóa màn hình terminal (cho gọn) * tổng hợp lệnh: https://kdata.vn/tin-tuc/tong-hop-cac-lenh-ssh-command-co-ban-ma-ban-can-biet sử dụng lệnh -p (ở đây là port 2220) ![image](https://hackmd.io/_uploads/H1h0iQpyR.png) - nhập pass ![image](https://hackmd.io/_uploads/B1eZ3Qpy0.png) ### level 0-1: ![image](https://hackmd.io/_uploads/r1bu67ay0.png) - theo yêu cầu thì có pass đăng nhặp bandit1 trong file readme - sd lệnh ```ls``` để xem các file - sd lệnh ```cat``` để đọc nd ![image](https://hackmd.io/_uploads/S1S8RmTk0.png) => pass : ```NH2SXQwcBdpmTEzi3bvBHMM9H66vVXjL``` sử dụng pass khai thác đc để thực hiện login bandit1: ![image](https://hackmd.io/_uploads/H1B1gNaJ0.png) ### level 1-2: ![image](https://hackmd.io/_uploads/BJUmeV61A.png) - sd ls để xem danh sách file![image](https://hackmd.io/_uploads/rkEQz4py0.png) ở đây ko hiện tên file vì vậy dùng lệnh find để tìm kiếm ![image](https://hackmd.io/_uploads/rJamVN6JC.png) ở đây ko thể dùng lệnh cat liền để đọc nd file vì nếu sd ```cat -``` thì tại - nó sẽ hiểu là option chứ ko phải tên file. hoặc dùng ```cat < -``` => vậy pass: rRGizSaX8Mk1RTb1CNQoXTcYZWU6lgzi ![image](https://hackmd.io/_uploads/B1idSETJ0.png) đăng nhập thành công. ### level 2-3: ![image](https://hackmd.io/_uploads/BJG6INpkR.png) - tại level này sẽ gặp lỗi nếu vẫn đọc file theo lệnh thường ![image](https://hackmd.io/_uploads/BkOgwVay0.png) - search xem hướng dẫn [" spaces in this filename"](https://linuxhandbook.com/filename-spaces-linux/) **note: tên file chưa cách có thể dùng "" hoặc '' cho tên file hoặc dùng\ thay cho space** ![image](https://hackmd.io/_uploads/H1FNu4TJR.png) => pass: aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG ![image](https://hackmd.io/_uploads/HJj9OVp1C.png) ### level 3-4: ![image](https://hackmd.io/_uploads/SyFMtEpyA.png) - xem các file tồn tại (gồm cả file ẩn) dùng ls -a ![image](https://hackmd.io/_uploads/SJLqlBayC.png) - khi đọc ns cảu inhere thì nhận đc inhere là 1 thư mục - do đó cần truy cập vào thư mục inhere dùng lệnh cd - dùng ls -a để xem file ẩn trong thư mục inhere ![image](https://hackmd.io/_uploads/BJVg-rpJA.png) => pass: 2EW7BBsr6aMMoJ2HjW067dm8EgX26xNe ![image](https://hackmd.io/_uploads/SkSO-S6JR.png) ### level 4-5: ![Ảnh chụp màn hình 2024-04-05 161650](https://hackmd.io/_uploads/S1iNHHpJR.png) mở từng file bị báo lỗi định dạng do đó có thể dùng lệnh file./* để xem tất cả định dạng của file - chỉ có -file07 là định dạng txt nên ta sẽ mở file này ![image](https://hackmd.io/_uploads/SJ7QSH6JC.png) => pass: lrIWWI6bB37kxfiCQZqUdOIYfr6eEeqR ![image](https://hackmd.io/_uploads/SkWruBTJA.png) ### level 5-6: ![image](https://hackmd.io/_uploads/r1yoOS6y0.png) ![image](https://hackmd.io/_uploads/BJ6RwtpJR.png) có rất nhiều thư mục con nên là sẽ sử dụng lệnh find để tìm kiếm dựa trên kích thước size ![image](https://hackmd.io/_uploads/BkQiMhTyA.png) sử dụng lệnh find theo cấu trúc này để tìm kiếm: ```find inhere -type f -size 1033c``` trong đó ```-type f```: chỉ quan tâm tới file ko quan tâm thư mục ![image](https://hackmd.io/_uploads/ryltQ3T10.png) xuất hiện file thỏa yêu cầu về kích thước size ![image](https://hackmd.io/_uploads/HkSpQ2pJ0.png) => pass:P4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU ![image](https://hackmd.io/_uploads/Hyv-N36k0.png) ### level 6-7: ![image](https://hackmd.io/_uploads/rkLuVh6kA.png) ![Ảnh chụp màn hình 2024-04-06 004622](https://hackmd.io/_uploads/Bkr2KnT1R.png) có file chứa password vào xem ![image](https://hackmd.io/_uploads/HyjCthpJR.png) => pass: z7WtoNQU2XfjmMtWA8u5rN4vzqu4v99S ### level 7-8: ![image](https://hackmd.io/_uploads/rkFmtUGeC.png) - sử dụng ls -a để xem tất cả các file - sử dụng ```grep``` để tìm "millonth" trong các file ![image](https://hackmd.io/_uploads/rJm7h8Ml0.png) có thể pass là: TESKZC0XvTetK0S9xNwm25STk5iWrBvP ![image](https://hackmd.io/_uploads/BkGh3IfgC.png) thành công ### level 8-9: ![image](https://hackmd.io/_uploads/BkeA2LGeA.png) - dùng lệnh ls để hiện file - dùng cat để đọc nội dung trong file (thấy xuất hiện rất nhiều dòng) - dùng lệnh sort để sắp xếp nội dung file theo trình tự - dựa vào gợi ý từ đề bài là xuất hiện 1 lần và các lệnh đc gợi ý thì dùng lệnh ```uniq -u ``` để xóa tất cả các dòng xuất hiện giống nhau, hoặc ```uniq -c``` để hiển thị số lần dòng xuất hiện ![image](https://hackmd.io/_uploads/HyzwW-meR.png) ![image](https://hackmd.io/_uploads/rJq-gbml0.png) => pass: EN632PlfYiZbn3PhVK3XOGSlNInNE00t ![image](https://hackmd.io/_uploads/ryknZbXlA.png) ### level 9-10: ![image](https://hackmd.io/_uploads/H15pbZQxA.png) - sử dụng ls để liệt kê file - dùng sort để xếp lại nội dung file - vì kiểu nhị phân nên dùng ```strings data.txt | grep '='``` để tìm kiếm đoạn chứ '=' - ![image](https://hackmd.io/_uploads/S1gew-mlR.png) => pass: G7w8LIi6J3kTb8A7j9LgrywtEUlyyp6s ![image](https://hackmd.io/_uploads/BJIxj3Ix0.png) ### level 10-11: ![image](https://hackmd.io/_uploads/HyIMs3LeR.png) - dùng lệnh ls xem danh sách các file - đoc thử nội dung file data.txt - daujw vào gợi ý đề, thử giải mã bằng base64 ![image](https://hackmd.io/_uploads/ByTB16Lg0.png) => pass: 6zPeziLdR2RKNdNYFNb6nVCKzphlXHBM ![image](https://hackmd.io/_uploads/HJxWJaUgR.png) ### level 11-12: ![image](https://hackmd.io/_uploads/r15XkpLgR.png) - lệnh ls xem file - cat file - dùng echo cho đoạn mã hóa ![image](https://hackmd.io/_uploads/Hy4BOT8xR.png) => pass: JVNBBFSmZwKKOP0XbFXOoW8chDz5yVRv ![image](https://hackmd.io/_uploads/HJnSyyDeA.png) ### level 12-13: ![image](https://hackmd.io/_uploads/BybMR08eA.png) - dùng lệnh ls coi file - ``cat data.txt`` để xem file - thấy chứa dump hex -> dùng ```xxd -r data.txt``` để chuyển dump hex sang nhị phân - vẫn chưa có kết quả nên là sẽ cho nó vào 1 file flg ![image](https://hackmd.io/_uploads/BkaMmL9eA.png) -> lỗi ko thể tạo directory ở đây chỉ có thể xem hoặc chỉnh sữa - dùng mktemp -d tạo dicrectory - lệnh cd để đến thư mục vừa tạo ![image](https://hackmd.io/_uploads/ByLGH85x0.png) ![image](https://hackmd.io/_uploads/ryHbcO5gA.png) ![image](https://hackmd.io/_uploads/Hklm5_9gC.png) ![image](https://hackmd.io/_uploads/rJn4qd5xC.png) => pass: wbWdlBxEir4CaE8LaPhauuOo6pwRmrDw ![image](https://hackmd.io/_uploads/SyHq5uqlR.png) ### level 13-14: ![image](https://hackmd.io/_uploads/H1bX4n9l0.png) -dùng lệnh ls xem file -dùng lệnh cat để đọc nọi dung file ![image](https://hackmd.io/_uploads/SJI-zvag0.png) -sử dụng ssh để connect với bandit14 nhưng không được ![image](https://hackmd.io/_uploads/BJrNadagA.png) để sử dụng ssh để connect với user localhost ![image](https://hackmd.io/_uploads/S1iwTupgA.png) -sau đó ta sẽ truy cập với usr bandit14 -để xem đucợ pass của bandit14 t sử dụng lệnh cat theo đường dẫn đề gợi ý: ![image](https://hackmd.io/_uploads/SkB41_vb0.png) =>pass: fGrHPx402xGC7U7rXKDaxiWFTOiF0ENq ### level 14-15: -![image](https://hackmd.io/_uploads/rynJ5DsgR.png) -sử dụng lệnh ls xem các file nhưng ko có file nào -dựa vào dự kiện đề cho là gửi mật khẩu đến 1 cổng mở 30000 -sử dụng netcat/ nc đọc nội dung file ![image](https://hackmd.io/_uploads/H1BQgTvWC.png) ->pass: jN2kgmIXJ6fShzhT2avhotn4Zcka6tnt ### level 15-16: ![image](https://hackmd.io/_uploads/r1rHzd6lC.png) -đề yêu cầu nộp mật khẩu vào port 30001, có user là localhost và sử dụng SSL để kết nối ```openssl s_client -connect localhost:30001``` -openssl: công cụ cho phép thực hiện thao tác liên quan đến SSL/TLS và mã hóa -s_client: là 1 chế độ của openssl dùng để kết nối đến máy chủ và hiện thị thông tin cuat ssl/tls của máy chỉ đó ![image](https://hackmd.io/_uploads/B199BpD-R.png) ![image](https://hackmd.io/_uploads/BJZFrpPbC.png) -> ta nhập pass level 15 và ta sẽ có được pass của level 16 -> pass: JQttfApK4SeyHwDlI9SXGR50qclOAil1 ### level 16-17: ![image](https://hackmd.io/_uploads/HJEQMOpxA.png) - đề cho ta biết cần phải nộp mật khẩu vào port có range từ 31000 - 32000 nên ta sẽ phải sử dụng nmap để xem port nào mở, sử dụng dịch vụ gì ![image](https://hackmd.io/_uploads/ByaaLVuZR.png) -sử dụng openssl để xem port nào hỗ trợ ssl: ![image](https://hackmd.io/_uploads/B12bw4dWR.png) ![image](https://hackmd.io/_uploads/rksUPNuZA.png) ![image](https://hackmd.io/_uploads/Bky_DE_bR.png) -thử vào có vẻ tại port 31790 là port cần tìm: ![image](https://hackmd.io/_uploads/HkohDVubC.png) -và nhận được 1 đoạn RSA: ![image](https://hackmd.io/_uploads/SJAAvEdbA.png) ![image](https://hackmd.io/_uploads/BJtfsBOZC.png) ở đây báo lỗi do chauw cấp quyền -> cần cấp quyền -sử dụng ```chmod 700``` để cấp quyền đọc cho máy chủ ![image](https://hackmd.io/_uploads/HJXvjBOZA.png) ![image](https://hackmd.io/_uploads/H1gKjHdW0.png) ta thấy rằng nó không trả cho ta kết quả của level 17 nên ta phải cat /etc/banditpass/bandit17 (sẽ được vì ta đang có quyền truy cập khi đang ở bandit17) ![image](https://hackmd.io/_uploads/H1vWnH_b0.png) -> pass: VwOSWtCA7lRKkTfbr2IDh6awj9RNZM5e ### level 17-18: ![image](https://hackmd.io/_uploads/Bk9gMd6xR.png) -sử dụng ls để xem file và cat xem file -đề yêu cầu tìm sự khác biệt giữa 2 file này ![image](https://hackmd.io/_uploads/BJ9-AS_b0.png) -dựa vào gợi ý đề cho thì ta dùng diff để xem sự khác nhau giữa 2 tệp ![image](https://hackmd.io/_uploads/S1JI0BubR.png) -sử dụng thêm grep để xem kết quả ![image](https://hackmd.io/_uploads/BkAICrdWA.png) => pass: hga5tuuCLF6fFzUpnagiMN8ssu9LFrdg ### level 18-19 ![image](https://hackmd.io/_uploads/rkdJMOTeC.png) -ta thấy file .bashrc đã được chỉnh sửa là khi ta đăng nhập vào sẽ log out ta ra ![image](https://hackmd.io/_uploads/ryVx8UubC.png) -in và out liên tục vậy nên cần đọc trực tiếp ![image](https://hackmd.io/_uploads/B1J6HI_W0.png) nên ta chỉ cần cat nó ra là oki => pass: awhqfNnAbc1naukrpqDYcF95h7HoMTrC ### level 19 - 20 ![image](https://hackmd.io/_uploads/rkxKb_6gC.png) -thấy bandit20-do có quyền đọc bandit19 và bandit20 ![image](https://hackmd.io/_uploads/HJN_S4FZR.png) -thử đọc file bandit20- do ![image](https://hackmd.io/_uploads/SyqaPVYZR.png) -sau khi cat bandit20-do và dựa theo gợi ý đề cho thì ta thử thực thi đường dẫn /etc/bandit_pass trên bandit20-do -ở đây em sử dụng ./ để trực tiếp thực thi trên bandit20-do mà ko cần qua đường dẫn ![image](https://hackmd.io/_uploads/Hk6tOVK-A.png) -nhận đc flag => pass: VxCazJaVykI6W36BkBU0mJTCM8rR95XT ### level 20 - 21 ![image](https://hackmd.io/_uploads/B1X4YynbR.png) ![image](https://hackmd.io/_uploads/r1B5ZycWR.png) -tại suconnect có bandit20 và bandit21 có thể đọc -thử đọc file suconnect xem có gì ![image](https://hackmd.io/_uploads/S1FRbJqWR.png) -trong level này cần sử dụng 2 terminal. trong đó 1 teminal sẽ khởi chạy network daemon để lắng nghe kết nối trên một cổng; terminal 2, sẽ kết nối đến localhostbằng setuid binary ![image](https://hackmd.io/_uploads/SJKTyl9WR.png) => pass: NvEJF7oVjkddltPSrdKEFOllh9V1IBcq ### level 21-22: - ![image](https://hackmd.io/_uploads/rykSZ_pl0.png) ![image](https://hackmd.io/_uploads/BJMxUl9WA.png) -ko có được gì -theo đề cho giờ thử truy cập vào /etc/cron.d/ ![image](https://hackmd.io/_uploads/SJ0QUe5-R.png) -ở đây có cronjob_bandit22 có thể là file cần tìm -thử dùng cat đọc nội dung file thông qua đường dẫn đề gợi ý ![image](https://hackmd.io/_uploads/HJqF8g9WC.png) -ở đây có thể thấy tệp lệnh /usr/bin/cronjob_bandit22.sh và chuyển sang /dev/null(mọi đầu ra của lệnh sẽ được loại bỏ và không được ghi lại) -tiếp tục thử đọc tệp lệnh ```/usr/bin/cronjob_bandit22.sh``` này xem ![image](https://hackmd.io/_uploads/H1yUDe9bA.png) -chuyển hướng sang tệp lệnh khác -tiếp tục thử đọc tệp lệnh ![image](https://hackmd.io/_uploads/SyTOweq-A.png) -ở đây có hiện 1 pass có thể là pass cần tìm => pass: WdDozAdTM2z9DiFEQ2mGlwngMfj4EZff ### level 22-23: ![image](https://hackmd.io/_uploads/BJFMnDpxC.png) - mở thư mục /etc/cron.d ![image](https://hackmd.io/_uploads/rkWBhP6lA.png) - Mở file cronjob_bandit23 ![image](https://hackmd.io/_uploads/HkB8nP6x0.png) ![image](https://hackmd.io/_uploads/BkhUnwagA.png) Và script này sẽ sử dụng tên user + hàm md5sum + cut sẽ ra 1 [chuỗi kí tự mã hóa(1)] và sau đó lưu password vào thư mục /tmp/[chuỗi kí tự mã hóa(1)] ![image](https://hackmd.io/_uploads/SJmKnP6l0.png) ![image](https://hackmd.io/_uploads/rkOYnvaxA.png) => pass: QYw0Y2aiA672PsMmh9puTQuhoz8SyR2G ### level 23-24: ![image](https://hackmd.io/_uploads/rkM_BwplR.png) -vào thư mục /etc/cron.d ![image](https://hackmd.io/_uploads/r165HD6gA.png) -Mở bandit24 nó sẽ hiện ra 1 đường dẫn như level trướ ![image](https://hackmd.io/_uploads/rJiArv6x0.png) -Mở file shell lên ta được: ![image](https://hackmd.io/_uploads/B1klIvpeR.png) -Dựa vào file shell bên trên ta có thể thấy rằng có thể tạo 1 file shell script riêng bên ngoài và để câu lệnh đó thực hiện việc tìm password ![image](https://hackmd.io/_uploads/B1dQUDagC.png) -tự tạo script riêng dựa trên level trước và kết quả là ta có file như thế này: ![image](https://hackmd.io/_uploads/BktE8PplR.png) ![image](https://hackmd.io/_uploads/S1gBLvplC.png) -đưa file ta vừa tạo vào thư mục thực thi /var/spool/$myname/foo và ![image](https://hackmd.io/_uploads/ByNILPaxR.png) => pass: VAfGXJ1PBSsPSnvsjI8p759leLZ9GGar ### level 24-25: ![image](https://hackmd.io/_uploads/BJnu8PpgR.png) -Theo như đề bài thì ta có thể lấy được pass khi vào port 30002 và nhập mật khẩu của level 24 và thêm mã pin từ 0000 đến 9999 Ta sẽ sử dụng lệnh netcat để connect với port 30002 ![image](https://hackmd.io/_uploads/SyR28vplR.png) -dùng shell để tạo code lưu data vào 1 file testcase -tạo 1 thư mục để lưu code và thực thi file sử dụng lệnh mkdir ![image](https://hackmd.io/_uploads/S1H1DDae0.png) ![image](https://hackmd.io/_uploads/r1R1vDTl0.png) ![image](https://hackmd.io/_uploads/SJ_lPD6lA.png) -sử dụng cat và netcat để lấy pass ![image](https://hackmd.io/_uploads/Bk2WwDaxC.png) => pass: p7TaowMYrmu23Ol8hiZh9UvD0O9hpx8d ### level 25-26: ![image](https://hackmd.io/_uploads/rJhEDPplC.png) -ta cần xem shell mà bandit26 đang sử dụng ![image](https://hackmd.io/_uploads/BJVDwPal0.png) -(*/etc/passwd thường là chứa username, password, UID,GIP, User ID info, home directory và shell của các user) -Ta thấy shell của usr bandit26 đang ở thư mục /usr/bin/showtext: ![image](https://hackmd.io/_uploads/S1xFDvTeR.png) ![image](https://hackmd.io/_uploads/Sk0Yvv6l0.png) ![image](https://hackmd.io/_uploads/SkuqDv6e0.png) ![image](https://hackmd.io/_uploads/H1-iwPpxC.png) Khi cố gắng đăng nhập với user bandit26 thì thấy connection closed do lệnh more ~/text.txt đã được thực thi -có thể thu nhỏ terminal đến mức file txt không thể show hết ra được. Đến đây ta sẽ dùng V để vào vim. *vim là 1 text editor và ta có thể sử dụng vim để thực thi shell script trên đó ![image](https://hackmd.io/_uploads/Sy9CvPTlC.png) -sử dụng lệnh set shell = /bin/bash để đổi shell hiện tại của user bandit26 sang /bin/bash ![image](https://hackmd.io/_uploads/rkT1OPTlC.png) ![image](https://hackmd.io/_uploads/BkNguPaxC.png) ![image](https://hackmd.io/_uploads/r19x_D6eA.png) => pass: c7GvcKlw9mC7aUQaPx7nwFstuAIBw1o1 ### level 26-27: ![image](https://hackmd.io/_uploads/SyyE_D6gR.png) -sử dụng ls để list ra các file -![image](https://hackmd.io/_uploads/S1Gr_P6gC.png) -chạy thử file bandit27-do ![image](https://hackmd.io/_uploads/rk4LuvpeR.png) -thấy được là file ./bandit27-do sẽ chạy lệnh dưới quyền 1 user khác và trong trường hợp này là user bandit27-> Do đó chỉ cần dùng file này để cat ra password là xong: ![image](https://hackmd.io/_uploads/HJAPuwpxA.png) => pass: YnQpBuifNMas1hcUFk70ZmqkhUU2EuaS ### level 27-28: ![image](https://hackmd.io/_uploads/ryKqdPTeA.png) -ta chỉ cần clone thư mục đó về máy ![image](https://hackmd.io/_uploads/BJKiODpxC.png) ![image](https://hackmd.io/_uploads/ryI2Ov6lC.png) ![image](https://hackmd.io/_uploads/BkRnOPae0.png) -Đến đây ta sẽ clone: ![image](https://hackmd.io/_uploads/rJ1ROvpgC.png) -Sau khi clone thì thư mục repo sẽ được tải về trên máy và từ đó cứ mở file rồi lấy ![image](https://hackmd.io/_uploads/r1TCdwTlR.png) => pass: AVanL161y9rsbcJIsFHuw35rjaOM19nR ### level 28- 29: ![image](https://hackmd.io/_uploads/ryBbYDTx0.png) -ta sẽ cần clone thư mục repo: ![image](https://hackmd.io/_uploads/B17QYwaeA.png) -mật khẩu không được show ra. ![image](https://hackmd.io/_uploads/H1r4YDTlR.png) -có thể sử dụng git log để check: ![image](https://hackmd.io/_uploads/HJ8rFDagA.png) -kiểm tra từng log sử dụng git show ![image](https://hackmd.io/_uploads/ByDIFv6xA.png) => pass: tQKvmcwNYcFS6vmPHIUSI3ShmsrQZK8S ### level 29-30: ![image](https://hackmd.io/_uploads/HJ_9Fw6lA.png) -clone repo về máy ![image](https://hackmd.io/_uploads/Sk3hYPplR.png) -thử check git log và cat file md ![image](https://hackmd.io/_uploads/Bk9TKwaeC.png) ![image](https://hackmd.io/_uploads/r1JCYPTxA.png) có thể còn có những branch khác, ta có thể sử dụng flag -a để show các git branch: ![image](https://hackmd.io/_uploads/HJ-eqPTgR.png) ![image](https://hackmd.io/_uploads/Hktx5vplC.png) ![image](https://hackmd.io/_uploads/rJpe9PTxC.png) -Sau khi Switch sang branch dev thì ta sẽ có thể thấy 1 thư mục code và 1 file markdown ![image](https://hackmd.io/_uploads/SyYf5Dpg0.png) => pass: xbhV3HpNGlTIdnjUrdAlPzc2L6y9EOnS ### level 30-31: -![image](https://hackmd.io/_uploads/BJCKqPpgC.png) -trước thì chúng ta sẽ clone, cat, check log và branch: ![image](https://hackmd.io/_uploads/S1V29Pax0.png) ![image](https://hackmd.io/_uploads/r19n9PTe0.png) => pass: OoffzGDlzhAlerFJ2cAiz1D41JW1Mhmt ### level 31-32 ![image](https://hackmd.io/_uploads/SJzWsvTlC.png) -tạo thư mục để lưu repos ![image](https://hackmd.io/_uploads/B14MiPaxR.png) ![image](https://hackmd.io/_uploads/SyDzswagA.png) ![image](https://hackmd.io/_uploads/rkx-msPpeA.png) -ta chỉ cần push 1 file key.txt với nội dung ‘May I come in’ lên git ![image](https://hackmd.io/_uploads/BJBEow6gC.png) ![image](https://hackmd.io/_uploads/HyoSiw6eR.png) -Sau khi dùng git commit thì git sẽ hiện lên bảng bên dưới để chúng ta add message vào commit. Chúng ta cần phải thêm message riêng sau đó Ctrl + X để đóng và lưu lại -![image](https://hackmd.io/_uploads/ByePiDaeA.png) ![image](https://hackmd.io/_uploads/HkrPoDTxR.png) -Sau khi commit thành công thì push -![image](https://hackmd.io/_uploads/SkWtsDTgA.png) ![image](https://hackmd.io/_uploads/SyLYjP6gA.png) => pass: rmCBvG56y58BXzv98yZGdO7ATVL5dW8y ### level 32-33: ![image](https://hackmd.io/_uploads/SJV3sD6eC.png) Sau khi ssh đến bài này thì chúng ta sẽ được chuyển đến UPPER CASE SHELL thay vì /bin/bash như thường lệ: ![image](https://hackmd.io/_uploads/Hki2aw6xR.png) ![image](https://hackmd.io/_uploads/r1WTTvpeA.png) -sử dụng 1 số command để nhập nhưng đều bị chặn quyền => https://www.ibm.com/docs/en/aix/7.2?topic=shell-positional-parameters-in-bourne nhập $0 thì nó sẽ không bị uppercase trong trường hợp này khi nhập $0 thì shell sẽ thực hiện lấy tham số hiện tại lệnh sh $0 tương đương sh ./tên_script_hiện_tại.sh và ta sẽ được dùng shell ![image](https://hackmd.io/_uploads/By_7APax0.png) dùng được shell và chỉ cần cat ra password ![image](https://hackmd.io/_uploads/r1ZrRPTgR.png) => pass: odHo63fHiFqcWWJG9rLiLDtPm45KzUKy ### level 33-34: ![image](https://hackmd.io/_uploads/BJZqRDpx0.png) # PicoCTF: ## Get aHEAD ![image](https://hackmd.io/_uploads/ryMRmicZR.png) Đọc sơ qua hint của thử thách, em thấy họ gợi ý sử dụng Burpsuite để kiểm tra **request** như thế nào, thêm vào đó thử thách là **get aHead** nên em nghĩ nó liên quan đến **header** được trả về. Để thuận tiện hơn thì ta kiểm tra **request head** bằng thư viện ```requests``` trong ```python``` và kết quả: ![getAhead](https://hackmd.io/_uploads/BJfCERjZ0.png) ``` import requests url = 'http://mercury.picoctf.net:53554/' res = requests.head(url) print(res.headers["flag"]) ``` -pass: picoCTF{r3j3ct_th3_du4l1ty_6ef27873} ## COOKIE: -Trang web gửi một form tìm kiếm đơn giản, thử nhập kí tự tùy ý như ```picoCTF``` nào vào ô tìm kiếm, kết quả trả về: ![cookies1](https://hackmd.io/_uploads/B1x8r0oZA.png) -Vậy thử ```snickerdoodle```? ![cookies2](https://hackmd.io/_uploads/SkuBUAi-A.png) -có vẻ như ta đã đúng cookie và url được chuyển sang *http://mercury.picoctf.net:17781/check*, tuy nhiên vẫn chưa thấy flag. -Vì thử thách liên quan đến cookie, cho nên ta cứ kiểm tra cookie thử: ![cookies3](https://hackmd.io/_uploads/SyULIRj-A.png) -Thử thay đổi giá trị của cookie và tải lại trang: ![cookies4](https://hackmd.io/_uploads/S1UDLCoZ0.png) ![cookies5](https://hackmd.io/_uploads/ryZOLRs-R.png) -có được **chocolate**, vậy ta cứ thử in hết cookies thì sẽ như thế nào? ``` import requests url = "http://mercury.picoctf.net:17781" for i in range(0, 20): text = str(i) cookies = { 'name': text } r = requests.get(url, cookies=cookies) result = r.text.split( "<p style=\"text-align:center; font-size:30px;\"><b>")[1].split("</b>")[0] print("[+] Testing Cookie:{} | Result: {}".format(i, result)) if 'I love' not in result: print(r.text.split("<code>")[1].split("</code>")[0]) break ``` -Vậy là tới cookies thứ 19 ta có được flag. ![cookies6](https://hackmd.io/_uploads/BkBKLAibR.png) pass: picoCTF{3v3ry1_l0v3s_c00k135_bb3b3535} # Root me ## IP restriction bypass -Trong thử thách, em thấy địa chỉ IP máy không thuộc vào mạng LAN. -Em nghĩ cần đưa địa chỉ IP đi qua nhiều lớp hơn, cụ thể cần một dải IP thuộc mạng LAN này, để làm được điều đó trường ```X-Forwarded-For``` ở **header**: ``` import requests url = 'http://challenge01.root-me.org/web-serveur/ch68/' HEADERS = { 'X-Forwarded-For': '172.16.0.1', } res = requests.get(url, headers=HEADERS) # print(res.request.headers) print(res.text) ``` ![ip](https://hackmd.io/_uploads/r1IcURsWR.png) Pass: Ip_$po0Fing ## 4. User-Agent -Bắt đầu thử thách em đã có câu: ``` Wrong user-agent: you are not the "admin" browser! ``` -Vậy thì em nghĩ chỉ cần thêm ```User-agent: admin``` vào header là được: ``` import requests url = 'http://challenge01.root-me.org/web-serveur/ch2/' HEADERS = { 'User-agent': 'admin' } res = requests.get(url, headers=HEADERS) print(res.text) ``` ![userAgent](https://hackmd.io/_uploads/BJ6jUCo-A.png) pass: rr$Li9%L34qd1AAe27 ## 5.HTTP - Header -Thử thách liên quan đến header nên em nghĩ cần kiểm tra các thông tin trên Header (dùng ```curl``` cho nhanh): ![header](https://hackmd.io/_uploads/Hy-JPRiZ0.png) -nhưng ```Header-RootMe-Admin: none``` nên em đã thử làm giá trị này khác ```none```: ``` import requests url = 'http://challenge01.root-me.org/web-serveur/ch5/' HEADERS = { 'Header-RootMe-Admin': "not none" } res = requests.get(url, headers=HEADERS) print(res.text) ``` ![header1](https://hackmd.io/_uploads/Bkgogw0iZR.png) pass: HeadersMayBeUseful ## 6. HTTP - Post -ở đây em thử kiểm tra data dược post lên khi ta nhấn nút ```Give a try!``` ![post](https://hackmd.io/_uploads/r1GpIRo-C.png) -thấy dữ liệu được trả về gồm có 2 thành phần là ```score``` và ```generate``, vậy sao ta không thử post data với ```score``` cao hơn: ``` import requests url = 'http://challenge01.root-me.org/web-serveur/ch56/' data = { 'score': "99999999", 'generate': "Give a try!" } res = requests.post(url, headers=HEADERS, data=data) print(res.text) ``` ![post1](https://hackmd.io/_uploads/BJJAUCjbC.png) pass: H7tp_h4s_N0_s3Cr37S_F0r_y0U

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully