Challenge - 5 Problems
Port Scanning Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this simple port scan script?
Consider this bash script that scans ports 80 and 443 on localhost. What output will it produce?
Bash Scripting
for port in 80 443; do timeout 1 bash -c "</dev/tcp/127.0.0.1/$port" && echo "Port $port is open" || echo "Port $port is closed" done
Attempts:
2 left
💡 Hint
Think about which common services usually listen on ports 80 and 443 on localhost.
✗ Incorrect
Ports 80 (HTTP) and 443 (HTTPS) are commonly open on localhost if a web server is running. The script tries to open a TCP connection to each port and prints if it is open or closed.
📝 Syntax
intermediate2:00remaining
Identify the syntax error in this port scanning snippet
Which option contains the correct syntax to scan port 22 on 192.168.1.1 using bash's /dev/tcp?
Bash Scripting
timeout 1 bash -c "</dev/tcp/192.168.1.1/22" && echo "Open" || echo "Closed"
Attempts:
2 left
💡 Hint
Check the correct format for /dev/tcp host and port separation.
✗ Incorrect
The correct syntax for bash's /dev/tcp is /dev/tcp/host/port without any colon or dash. Options A, B, and C use invalid separators or misplaced arguments causing syntax errors.
🔧 Debug
advanced2:00remaining
Why does this port scan script always report ports as closed?
This script tries to scan ports 20 to 22 on 10.0.0.1 but always prints 'Port X is closed'. What is the likely cause?
Bash Scripting
for port in {20..22}; do if timeout 1 bash -c "</dev/tcp/10.0.0.1/$port"; then echo "Port $port is open" else echo "Port $port is closed" fi done
Attempts:
2 left
💡 Hint
Check network connectivity and firewall rules on the target host.
✗ Incorrect
If the target host is unreachable or firewall blocks connections, all attempts fail, so ports appear closed. The other options would cause errors or different failures.
🚀 Application
advanced2:00remaining
How to scan multiple ports efficiently in bash?
You want to scan ports 22, 80, 443, and 8080 on host 192.168.0.10 using bash. Which script snippet scans all ports and prints only open ones?
Attempts:
2 left
💡 Hint
Only print when the connection succeeds, not when it fails.
✗ Incorrect
Option C correctly tests if the connection succeeds and prints 'Port X open'. Option C prints on success but also continues silently on failure. Options C and D invert logic causing wrong output.
🧠 Conceptual
expert2:00remaining
What is a limitation of using bash /dev/tcp for port scanning?
Which of the following is a true limitation when using bash's /dev/tcp feature for port scanning?
Attempts:
2 left
💡 Hint
Think about the protocol support of /dev/tcp.
✗ Incorrect
/dev/tcp in bash supports only TCP connections, so it cannot scan UDP ports. It does not require root privileges, does not scan all ports automatically, and does not provide service banners.