0% found this document useful (0 votes)
16 views7 pages

Day 19 - Introduction To Ethical Hacking

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views7 pages

Day 19 - Introduction To Ethical Hacking

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

copyright©Binayak Prasad Gupta

Demo 1 – Using Netcat as a Web Browser (Connect Mode)

Problem Statement:

Use netcat to scan the target URL and return the respective HTML output in the Kali terminal

Solution:

● Step 1: Run the terminal and enter command as shown in the image

● Use command: “nc -C scanme.nmap.org 80”

● The extra line in the end is to be typed, hence press enter twice.

copyright©Binayak Prasad Gupta


● Netcat manually retrieves a web page of the specified target from the HTTP server

Demo 2 – Using Netcat as a Web Server (Listen Mode)

Problem Statement:

Use netcat to create a web server which serves HTTP requests and responses

Solution:

● Step 1: Open the leafpad and enter the commands as shown below to create an HTTP text
file

● Step 2: Type the below command in the terminal after saving the above HTTP file.

● Use command: “ncat -l localhost 8080 < hello.http”.

● Step 3: Open any browser and browse the localhost URL to visit the webpage being served

copyright©Binayak Prasad Gupta


by netcat.

● Step 4: The netcat server also receives the data as a browser even while serving requests.

Demo 3 – Using Netcat to Generate new SSL Certificates

Problem Statement:

Use netcat to automatically generate new SSL certificates as requested

Solution

● Step 1: Open the terminal and enter the command shown below.

● Use command: “ncat -v --listen --ssl”

● This generates a single time use SSL certificate, and will encrypt all communication on port
31337 using SSL as shown above.

Demo 4 – Using Netcat to log outputs through Standard Output

Problem Statement

Use netcat to log verbose outputs, and log hexadecimal verbose.

copyright©Binayak Prasad Gupta


Solution:

● Step 1: Open the terminal and enter the command shown below.

● Use command: “ncat -C -- hex-dump ssh-hex. log scanme.nmap.org 22”

● Step 2: The log file with the name ‘ssh-hex.log’ is saved to the system, and it will contain
the hexadecimal log values of the interaction.
● Use command: “nano ssh-hex.log” to view the file.

Demo 5 – Access Control Using Netcat

Problem Statement

Netcat can also be configured to select which connections to communicate with and which to be
blocked, much like an access control list. Curate an access list to allow/block connections as per
choice.

Solution
● Step 1: Open the terminal and enter the command shown to allow a specific host and
block all other connections.
● Use command: “ncat -l --allow 10.10. 10. 10”

● Step 2: Open the terminal and enter the command shown to deny a specific host and
allow all other connections
● Use command: “ncat -l --deny 10.10. 10. 8”

● Step 3: Open the terminal and enter the command shown to allow/block a specific file

copyright©Binayak Prasad Gupta


● Use command 1: “ncat -l --allowfile trusted_hosts.txt”

● Use command 2: “ncat -l --denyfile trusted_hosts.txt”

● Since the said files are not present on the connection, the above message is shown.

● Step 4: Open the terminal and enter the command shown to limit the maximum number
of connections
● Use command: “ncat -l --max-conns 10”

Demo 6 – Proxying Using Netcat


Problem Statement
Use Netcat to make sure all HTTP requests and responses are routed through a netcat proxy
Solution

● Step 1: Open the terminal and enter the commands shown below to create a named pipe.

● Use command: “mkfifo backpipe”

● Now use command: “nc -I -p 12345 0<backpipe | nc www.google.com 80 1>backpipe”

● Step 2: Open another terminal and display the contents of the pipe

● Use command: “cat backpipe”

Demo 7 – Netcat Port Scanning


Problem Statement:
Use Netcat to connect with the various ports and display their information
Solution

copyright©Binayak Prasad Gupta


● Step 1: Open the terminal in Kali linux and type the following command shown in the
image
● Use command: “nc -v -w2 -z 10.10.10.10 1-300”

● This command will scan all open ports in the range 1-300 of the Windows instance.

Demo 8 – File Transfer Using Netcat


Problem Statement
Use Netcat to transfer files from client to remote host and vice versa
Solution
● Step 1: Open the terminal and enter the commands shown below to transfer the
‘demo.txt’ file over port 8080
● Use command: “nc -lvp 8080 > /root/Desktop/demo.txt”

● Step 2: Type the following command on the attack machine to retrieve the file

● Use command: “nc 10.10.10.12 8080 > /root/Desktop/demo.txt”

● Step 3: Now display the contents of the file on both the terminals

● The file is duplicated as shown in the picture below

copyright©Binayak Prasad Gupta

You might also like