Othmane Moutaouakkil
LinkedInGitHub
  • Introduction
  • OSCP Journey
    • HTB
      • HTB Linux Boxes
      • HTB Windows Boxes
  • Write-Ups
    • TCM Security
      • Practical Ethical Hacking
        • Networking Refresher
        • The Ethical Hacker Methodology
        • Information Gathering (Reconnaissance)
        • Scanning & Enumeration
        • Vulnerability Scanning with Nessus
        • Exploitation Basics
        • New Capstone
        • Active Directory (AD)
          • AD Overview
          • AD Lab Build
          • Attacking AD: Initial Attack Vectors
          • Attacking AD: Post-Compromise Enumeration
          • Attacking AD: Post-Compromise Attacks
          • We've Compromised the Domain - Now What?
          • Additional AD Attacks
          • AD Case Studies
        • Post Exploitation
        • Web Application Enumeration, Revisited
        • Find & Exploit Common Web Vulnerabilities
        • Wireless Penetration Testing
        • Legal Documents and Report Writing
      • Open-Source Intelligence (OSINT)
    • Hacking Challenges
      • OTW
        • Bandit
          • Level 0
          • Level 0 → 1
          • Level 1 → 2
          • Level 2 → 3
          • Level 3 → 4
          • Level 4 → 5
          • Level 5 → 6
          • Level 6 → 7
          • Level 7 → 8
          • Level 8 → 9
          • Level 9 → 10
          • Level 10 → 11
          • Level 11 → 12
          • Level 12 → 13
          • Level 13 → 14
          • Level 14 → 15
          • Level 15 → 16
          • Level 16 → 17
          • Level 17 → 18
          • Level 18 → 19
        • Natas
        • Leviathan
        • Krypton
        • Narnia
        • Behemoth
        • Utumno
        • Maze
        • Vortex
        • Manpage
        • Drifter
        • FormulaOne
      • THM
  • Research
  • Resume
Powered by GitBook
On this page
  • Level Goal
  • Write-Up
  • Lessons Learned

Was this helpful?

  1. Write-Ups
  2. Hacking Challenges
  3. OTW
  4. Bandit

Level 16 → 17

PreviousLevel 15 → 16NextLevel 17 → 18

Last updated 7 months ago

Was this helpful?

Level Goal

The credentials for the next level can be retrieved by submitting the password of the current level to a port on localhost in the range 31000 to 32000. First find out which of these ports have a server listening on them. Then find out which of those speak SSL/TLS 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.

Helpful note: Getting “DONE”, “RENEGOTIATING” or “KEYUPDATE”? Read the “CONNECTED COMMANDS” section in the manpage.

Write-Up

  1. Use nmap to scan for open ports and services:

nmap -sV localhost -p 31000-32000
  • nmap: Network exploration tool and security scanner

  • -sV: Probe open ports to determine service/version info

  • localhost: The target (the working machine)

  • -p 31000-32000: Specifies the port range to scan

The SSL/TLS port 31790 was identified from the nmap results.

  1. Connect to the SSL port and submit the bandit15 password:

echo "kSkvUpMQ7lBYyCM4GBPvCvT1BfWRy0Dx" | openssl s_client -connect localhost:31790 -ign_eof
  • echo "...": Outputs the RSA Private Key

  • |: Pipes the output to the next command

  • openssl s_client: OpenSSL command for testing SSL/TLS connections

  • -connect localhost:31790: Specifies the host and port to connect to

  • -ign_eof: Ignores EOF (end-of-file), keeping the connection open

This outputs the RSA Private Key.

  1. Save the RSA Private Key to a file:

echo "-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAvmOkuifmMg6HL2YPIOjon6iWfbp7c3jx34YkYWqUH57SUdyJ
imZzeyGC0gtZPGujUSxiJSWI/oTqexh+cAMTSMlOJf7+BrJObArnxd9Y7YT2bRPQ
Ja6Lzb558YW3FZl87ORiO+rW4LCDCNd2lUvLE/GL2GWyuKN0K5iCd5TbtJzEkQTu
DSt2mcNn4rhAL+JFr56o4T6z8WWAW18BR6yGrMq7Q/kALHYW3OekePQAzL0VUYbW
JGTi65CxbCnzc/w4+mqQyvmzpWtMAzJTzAzQxNbkR2MBGySxDLrjg0LWN6sK7wNX
x0YVztz/zbIkPjfkU1jHS+9EbVNj+D1XFOJuaQIDAQABAoIBABagpxpM1aoLWfvD
KHcj10nqcoBc4oE11aFYQwik7xfW+24pRNuDE6SFthOar69jp5RlLwD1NhPx3iBl
J9nOM8OJ0VToum43UOS8YxF8WwhXriYGnc1sskbwpXOUDc9uX4+UESzH22P29ovd
d8WErY0gPxun8pbJLmxkAtWNhpMvfe0050vk9TL5wqbu9AlbssgTcCXkMQnPw9nC
YNN6DDP2lbc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Private Key

  • >: Redirects the output to a file

  • ~/Desktop/sshkey_private_b17: The file path and name to save the key

  1. Change the permissions of the key file for security:

chmod 600 ~/Desktop/sshkey_private_b17
  • chmod: Changes the permissions of the file

  • 600: Sets read and write permissions for the owner only

  1. Use the private key to access the next level:

ssh bandit17@bandit.labs.overthewire.org -p 2220 -i ~/Desktop/sshkey_private_b17

Lessons Learned

  • Port scanning tools like nmap are essential for identifying open ports and services

  • Not all open ports use the same protocol; distinguishing between SSL and non-SSL services is important

  • Private keys can be transmitted as text and need to be properly saved and secured

-- Othmane

nmap -sV localhost -p 31000-32000
echo "kSkvUpMQ7lBYyCM4GBPvCvT1BfWRy0Dx" | openssl s_client -connect localhost:31790 -ign_eof
Save the RSA Private Key to a file