../

OverTheWire - Bandit: Level 17 to Level 18


Now, knowing how to connect to SSL ports as well as non-SSL ports the next level includes some network reconnaissance.

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.

To get a clue which of these ports has SSL and hopefully which is the one we are searching for we use nmap in a first step.

1$ nmap -A -p 31000-32000 localhost
2Starting Nmap 7.80 ( https://nmap.org ) at 2023-10-29 17:20 UTC
3Nmap scan report for localhost (127.0.0.1)
4Host is up (0.00012s latency).
5Not shown: 996 closed ports
6PORT STATE SERVICE VERSION
731046/tcp open echo
831518/tcp open ssl/echo
9| ssl-cert: Subject: commonName=localhost
10| Subject Alternative Name: DNS:localhost
11| Not valid before: 2023-10-28T09:38:22
12|_Not valid after: 2023-10-28T09:39:22
1331691/tcp open echo
1431790/tcp open ssl/unknown
15| fingerprint-strings:
16| FourOhFourRequest, GenericLines, GetRequest, HTTPOptions, Help, Kerberos, LDAPSearchReq, LPDString, RTSPRequest, SIPOptions, SSLSessionReq, TLSSessionReq, TerminalServerCookie:
17|_ Wrong! Please enter the correct current password
18| ssl-cert: Subject: commonName=localhost
19| Subject Alternative Name: DNS:localhost
20| Not valid before: 2023-10-28T09:38:22
21|_Not valid after: 2023-10-28T09:39:22
2231960/tcp open echo
231 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
24SF-Port31790-TCP:V=7.80%T=SSL%I=7%D=10/29%Time=653E9478%P=x86_64-pc-linux-
25SF:gnu%r(GenericLines,31,"Wrong!\x20Please\x20enter\x20the\x20correct\x20c
26SF:urrent\x20password\n")%r(GetRequest,31,"Wrong!\x20Please\x20enter\x20th
27SF:e\x20correct\x20current\x20password\n")%r(HTTPOptions,31,"Wrong!\x20Ple
28SF:ase\x20enter\x20the\x20correct\x20current\x20password\n")%r(RTSPRequest
29SF:,31,"Wrong!\x20Please\x20enter\x20the\x20correct\x20current\x20password
30SF:\n")%r(Help,31,"Wrong!\x20Please\x20enter\x20the\x20correct\x20current\
31SF:x20password\n")%r(SSLSessionReq,31,"Wrong!\x20Please\x20enter\x20the\x2
32SF:0correct\x20current\x20password\n")%r(TerminalServerCookie,31,"Wrong!\x
33SF:20Please\x20enter\x20the\x20correct\x20current\x20password\n")%r(TLSSes
34SF:sionReq,31,"Wrong!\x20Please\x20enter\x20the\x20correct\x20current\x20p
35SF:assword\n")%r(Kerberos,31,"Wrong!\x20Please\x20enter\x20the\x20correct\
36SF:x20current\x20password\n")%r(FourOhFourRequest,31,"Wrong!\x20Please\x20
37SF:enter\x20the\x20correct\x20current\x20password\n")%r(LPDString,31,"Wron
38SF:g!\x20Please\x20enter\x20the\x20correct\x20current\x20password\n")%r(LD
39SF:APSearchReq,31,"Wrong!\x20Please\x20enter\x20the\x20correct\x20current\
40SF:x20password\n")%r(SIPOptions,31,"Wrong!\x20Please\x20enter\x20the\x20co
41SF:rrect\x20current\x20password\n");
42
43Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
44Nmap done: 1 IP address (1 host up) scanned in 98.99 seconds

This worked pretty well and we also know now which port is asking for our password. The application behind port 31790 sent “Wrong! Please enter the correct current password”. The other ports are simple echo-servers.

Again we use the openssl s_client tool to connect and send our password.

1$ openssl s_client -crlf -connect localhost:31790 -noservername
2<SSL connection output>
3$ JQttfApK4SeyHwDlI9SXGR50qclOAil1
4Correct!
5-----BEGIN RSA PRIVATE KEY-----
6MIIEogIBAAKCAQEAvmOkuifmMg6HL2YPIOjon6iWfbp7c3jx34YkYWqUH57SUdyJ
7imZzeyGC0gtZPGujUSxiJSWI/oTqexh+cAMTSMlOJf7+BrJObArnxd9Y7YT2bRPQ
8Ja6Lzb558YW3FZl87ORiO+rW4LCDCNd2lUvLE/GL2GWyuKN0K5iCd5TbtJzEkQTu
9DSt2mcNn4rhAL+JFr56o4T6z8WWAW18BR6yGrMq7Q/kALHYW3OekeP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uz7wtsQAgLHxbdLq/ZJQ7YfzOKU4ZxEnabvXnvWkU
27YOdjHdSOoKvDQNWu6ucyLRAWFuISeXw9a/9p7ftpxm0TSgyvmfLF2MIAEwyzRqaM
2877pBAoGAMmjmIJdjp+Ez8duyn3ieo36yrttF5NSsJLAbxFpdlc1gvtGCWW+9Cq0b
29dxviW8+TFVEBl1O4f7HVm6EpTscdDxU+bCXWkfjuRb7Dy9GOtt9JPsX8MBTakzh3
30vBgsyi/sN3RqRBcGU40fOoZyfAMT8s1m/uYv52O6IgeuZ/ujbjY=
31-----END RSA PRIVATE KEY-----

This time we got a RSA private key instead of a password. This key can probably be used as private SSH key for Level 17 -> Level 18.

Kategorien: #/writeups/; #/overthewire/

Tags: #/security/; #/hacking/; #/bash/; #/linux/; #/ctf/