0
0
Bash Scriptingscripting~10 mins

Port scanning basics in Bash Scripting - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to scan port 80 on a target IP using netcat.

Bash Scripting
nc -zv [1] 80
Drag options to blanks, or click blank then click option'
A192.168.1.1
B255.255.255.0
Cgoogle.com
Dlocalhost
Attempts:
3 left
💡 Hint
Common Mistakes
Using a network mask like 255.255.255.0 instead of an IP address.
Using a domain name that might not respond on port 80.
2fill in blank
medium

Complete the code to scan ports 20 to 25 on a target IP using a for loop.

Bash Scripting
for port in [1]; do nc -zv 127.0.0.1 $port; done
Drag options to blanks, or click blank then click option'
A{20..25}
B20-25
C20 21 22 23 24 25
D20,21,22,23,24,25
Attempts:
3 left
💡 Hint
Common Mistakes
Using a dash like '20-25' which is not valid for bash loops.
Using commas which are not recognized as separators in bash loops.
3fill in blank
hard

Fix the error in the code to scan port 443 on a target IP stored in variable $target.

Bash Scripting
nc -zv [1] 443
Drag options to blanks, or click blank then click option'
Atarget
B$target
C${target}
Dtarget$
Attempts:
3 left
💡 Hint
Common Mistakes
Using the variable name without the dollar sign.
Placing the dollar sign after the variable name.
4fill in blank
hard

Fill both blanks to create a loop that scans ports 80 to 82 on IP 10.0.0.1.

Bash Scripting
for port in [1]; do nc -zv [2] $port; done
Drag options to blanks, or click blank then click option'
A{80..82}
B10.0.0.2
C10.0.0.1
D80 81 82
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong IP address.
Using a space-separated list instead of brace expansion for ports.
5fill in blank
hard

Fill all three blanks to create a dictionary-like output of ports and their status using a loop and conditional.

Bash Scripting
for port in [1]; do
  nc -z [2] [3] $port && echo "$port: open" || echo "$port: closed"
done
Drag options to blanks, or click blank then click option'
A{22..24}
B127.0.0.1
C-v
D192.168.0.1
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong IP address.
Omitting the verbose flag which helps see connection status.