ssh bandit16@bandit.labs.overthewire.org -p 2220
bandit password: JQttfApK4SeyHwDlI9SXGR50qclOAil1
Task
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.
Solution
To do this we can run a nmap scan that will look check every port from 31000 to 32000 and check what services is running on that port.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
bandit16@bandit:~$ nmap -v -A -T4 -p 31000-32000 localhost
Starting Nmap 7.80 ( https://nmap.org ) at 2023-08-04 13:45 UTC
NSE: Loaded 151 scripts for scanning.
NSE: Script Pre-scanning.
Initiating NSE at 13:45
Completed NSE at 13:45, 0.00s elapsed
Initiating NSE at 13:45
Completed NSE at 13:45, 0.00s elapsed
Initiating NSE at 13:45
Completed NSE at 13:45, 0.00s elapsed
Initiating Ping Scan at 13:45
Scanning localhost (127.0.0.1) [2 ports]
Completed Ping Scan at 13:45, 0.00s elapsed (1 total hosts)
Initiating Connect Scan at 13:45
Scanning localhost (127.0.0.1) [1001 ports]
Discovered open port 31518/tcp on 127.0.0.1
Discovered open port 31691/tcp on 127.0.0.1
Discovered open port 31960/tcp on 127.0.0.1
Discovered open port 31046/tcp on 127.0.0.1
Discovered open port 31790/tcp on 127.0.0.1
Completed Connect Scan at 13:45, 0.03s elapsed (1001 total ports)
Initiating Service scan at 13:45
Scanning 5 services on localhost (127.0.0.1)
....
31790/tcp open ssl/unknown --> that it
...
The -A option in the command allows us to detect the OS, version detection or if there are any scripts running and -v increases the verbosity
As we can see, there are 5 host online and 3 of them are running the echo service 1 of them is running msdtc and port 31790 is running ssl. After connecting to the 31790 port with “openssl s_client -connect localhost:31790” and entering the password for bandit16 I received a private RSA key.
1
openssl s_client -connect localhost:31790
After type passwd will receive results
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28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bAjm7enCIvGCSx+X3l5SiWg0A
R57hJglezIiVjv3aGwHwvlZvtszK6zV6oXFAu0ECgYAbjo46T4hyP5tJi93V5HDi
Ttiek7xRVxUl+iU7rWkGAXFpMLFteQEsRr7PJ/lemmEY5eTDAFMLy9FL2m9oQWCg
R8VdwSk8r9FGLS+9aKcV5PI/WEKlwgXinB3OhYimtiG2Cg5JCqIZFHxD6MjEGOiu
L8ktHMPvodBwNsSBULpG0QKBgBAplTfC1HOnWiMGOU3KPwYWt0O6CdTkmJOmL8Ni
blh9elyZ9FsGxsgtRBXRsqXuz7wtsQAgLHxbdLq/ZJQ7YfzOKU4ZxEnabvXnvWkU
YOdjHdSOoKvDQNWu6ucyLRAWFuISeXw9a/9p7ftpxm0TSgyvmfLF2MIAEwyzRqaM
77pBAoGAMmjmIJdjp+Ez8duyn3ieo36yrttF5NSsJLAbxFpdlc1gvtGCWW+9Cq0b
dxviW8+TFVEBl1O4f7HVm6EpTscdDxU+bCXWkfjuRb7Dy9GOtt9JPsX8MBTakzh3
vBgsyi/sN3RqRBcGU40fOoZyfAMT8s1m/uYv52O6IgeuZ/ujbjY=
-----END RSA PRIVATE KEY-----
closed
After login to user bandit17 with private key
1
2
3
4
5
6
7
8
9
10
mkdir -p /tmp/bandit17
cd /tmp/bandit17
cat << EOF > bandit17.key
...
key
...
EOF
chmod 600 bandit17.key
Now loggin with private key and show passwd bandit17
1
2
3
ssh -i bandit17.key bandit17@bandit.labs.overthewire.org -p 2220
cat /etc/bandit_pass/bandit17
--> VwOSWtCA7lRKkTfbr2IDh6awj9RNZM5e
==> CTF: { VwOSWtCA7lRKkTfbr2IDh6awj9RNZM5e
}
Comments powered by Disqus.