BASH Level 5
Table of Contents
Guess the listening port!
Problem
#!/bin/bash
x=$(shuf -i 1024-65500 -n 1)
echo "Guess the listening port"
input=$(nc -lp $x)
echo "That was easy right? :)"
cat flag.txt
Solution
Terminal #1
It just popped out the flag as soon as I tried to connect to the port and break the connection!
level5@74faccee6de9:~$ sudo -u root ./portforce.sh
Guess the listening port
That was easy right? :)
auctf{n3tc@_purt_$can}
Terminal #2
Use to find what ports are listening
- port is in HEX.
level5@74faccee6de9:/proc/5934/net$ cat tcp
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
0: 00000000:2793 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 397645058 1 0000000000000000 100 0 0 10 0
1: 00000000:0016 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 377103420 1 0000000000000000 100 0 0 10 0
2: 00000000:35FB 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 393051118 1 0000000000000000 100 0 0 10 0
Terminal #3
Use to decide which port is mine.
0x2793
equals with 10131
level5@74faccee6de9:/tmp$ nc 127.0.0.1 10131
111111
1
1
1
^C
level5@74faccee6de9:/tmp$