This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Networking Utilities

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

Network utilities are tools used to manage, monitor, and troubleshoot network connections and performance. They provide information about network status, diagnose connectivity issues, and test network speed and reliability. Network utilities are essential for maintaining a healthy and efficient network. They also assist in network configuration and optimization.

1 - 🖥️airport

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the airport command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#   █████╗ ██╗██████╗ ██████╗  ██████╗ ██████╗ ████████╗
#  ██╔══██╗██║██╔══██╗██╔══██╗██╔═══██╗██╔══██╗╚══██╔══╝
#  ███████║██║██████╔╝██████╔╝██║   ██║██████╔╝   ██║   
#  ██╔══██║██║██╔══██╗██╔═══╝ ██║   ██║██╔══██╗   ██║   
#  ██║  ██║██║██║  ██║██║     ╚██████╔╝██║  ██║   ██║   
#  ╚═╝  ╚═╝╚═╝╚═╝  ╚═╝╚═╝      ╚═════╝ ╚═╝  ╚═╝   ╚═╝   
#

# airport
#
# Wireless network configuration utility.

# Show current wireless status information:
airport -I

# Sniff wireless traffic on channel 1:
airport sniff 1

# Scan for available wireless networks:
airport -s

# Disassociate from current airport network:
sudo airport -z
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

2 - 🖥️arp

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the arp command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#    █████╗ ██████╗ ██████╗ 
#   ██╔══██╗██╔══██╗██╔══██╗
#   ███████║██████╔╝██████╔╝
#   ██╔══██║██╔══██╗██╔═══╝ 
#   ██║  ██║██║  ██║██║     
#   ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝     
                                        
                                        
arp -an
# Adress resolution Protocol -a =Tabelle -n =Nummerisch

Jeder Netzwerkcontroller hat eine einmalige unverwechselbare und nicht veränderbare Mac-Adresse (Media Access Control), die für die Adressierung der Datenpakete im Internet unverzichtbar ist – die Mac-Adresse ist somit die physische Adresse Ihrer Netzwerkkarte, die sich in der Regel in einem festen EEPROM-Speicher auf der Netzwerkkarte beziehungsweise beim Onboard-LAN-Adapter im Bios-Chip befindet. Die Mac-Adressen werden zentral verwaltet, jede Adresse besteht aus zwölf hexadezimalen Ziffern.

Die hinlänglich bekannten IP-Adressen, die zunächst einmal für die Adressierung der Datenpakete verantwortlich sind, werden auf die Mac-Adressen abgebildet. Bei jeder Internetkommunikation muss also die zu einer IP-Adresse gehörige Mac-Adresse gesucht werden. Dafür ist das Adress Resolution Procotol ARP zuständig.

Im so genannten ARP-Cache (Adress Resolution Protocol) werden IP-Adressen gespeichert, die bereits in Mac-Adressen aufgelöst wurden. Wird ARP hier nicht fündig, wird eine Rundsendung (Broadcast) an alle im Netzwerk erreichbaren Rechner verschickt, um die Mac-Adresse zur angefragten IP-Adresse zu ermitteln. Das Gerät, zu dem die gesuchte IP-Adresse gehört, antwortet und schickt seine Mac-Adresse. Darauf trägt ARP im anfragenden Rechner die IP-Adresse in den ARP-Cache ein, alle Anfragen an diesen Rechner werden nun direkt zugestellt. Nach einem Neustart werden alle ARP-Einträge gelöscht

Mit der Eingabe von ARP ermitteln Sie die Mac-Adresse Ihrer Ethernet- und WLAN-Netzwerkschnittstelle. Außerdem sehen Sie, welche (veränderbare) IP-Adresse der (unveränderbaren) Mac-Adresse zugeordnet ist. Mit arp –a lassen Sie sich die gesamte Adress-Tabelle anzeigen.

ARP lässt sich auch mit diversen Optionen verwenden. Damit können Sie dann die automatisiert erstellten Einträge der Adressumwandlungstabelle manuell verändern.

#==============================##==============================#
# CMD arp						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

3 - 🖥️arp-scan

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the arp-scan command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#   █████╗ ██████╗ ██████╗       ███████╗ ██████╗ █████╗ ███╗   ██╗
#  ██╔══██╗██╔══██╗██╔══██╗      ██╔════╝██╔════╝██╔══██╗████╗  ██║
#  ███████║██████╔╝██████╔╝█████╗███████╗██║     ███████║██╔██╗ ██║
#  ██╔══██║██╔══██╗██╔═══╝ ╚════╝╚════██║██║     ██╔══██║██║╚██╗██║
#  ██║  ██║██║  ██║██║           ███████║╚██████╗██║  ██║██║ ╚████║
#  ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝           ╚══════╝ ╚═════╝╚═╝  ╚═╝╚═╝  ╚═══╝

arp-scan -h

# Syntax
Usage: arp-scan [options] [hosts...]

# Scan Local Network
# Most basic usage of arp-scan is scanning local network with a single options named --localnet or-l . This will scan whole local network with arp packets. While using arp-scan we need root privileges.
arp-scan  --localnet

# Specify Network Interface
# Enterprise environments requires more than one network interface for backup, load balancing etc. In this situations we need to specify network interface. We will use -i option. In the example we will use network interface named ens3 .
arp-scan --interface=ens3 --localnet

# Set Source Mac Address
# During the scan process our exisiting mac address will be used. This may create some clue about the scan. We can change the source mac address during scan. This will make all sent packets have different mac address than our hardware mac address. We will use --destaddr or -T option.
arp-scan -T aa:bb:cc:dd:ee:ff

# Set Destination Mac Address
# Another useful option is setting destination mac address with --srcaddr or -S option.
arp-scan -S aa:bb:cc:dd:ee:ff

# Specify Vlan
# In real world networks single interface can host multiple networks. This is generally done using some multiplexing protocol named Virtual Local Area Network or simply VLAN. If the interface is trunk which means interface hosts multiple VLANS we may need to specify VLAN id. We will use --vlan or -Q option to specify VLAN id. In the example we will only scan VLAN 10 .
arp-scan -i ens3 -Q 10

# Write Received Packets To Pcap
# If the responses return by the scanned hosts are important for us we can save them in pcap format. Pcap format is supported by tools like tcpdump, wireshark etc. We will us -pcapsavefile or -W options to specify pcap file.
arp-scan  --localnet -W scan.pcap

# We can read pcap file with tcpdump like below.
tcpdump -r scan.pcap

# arp-scan
arp-scan 10.194.120.0:255.255.252.0
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

4 - 🖥️bind

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the bind command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ██████╗ ██╗███╗   ██╗██████╗ 
#  ██╔══██╗██║████╗  ██║██╔══██╗
#  ██████╔╝██║██╔██╗ ██║██║  ██║
#  ██╔══██╗██║██║╚██╗██║██║  ██║
#  ██████╔╝██║██║ ╚████║██████╔╝
#  ╚═════╝ ╚═╝╚═╝  ╚═══╝╚═════╝ 

bind -x '"\er":READLINE_LINE=$(eval "$READLINE_LINE");READLINE_POINT=${#READLINE_LINE}'
# Make M-r run the contents of the Readline line buffer and replace it with the result in Bash bind -x was added in Bash 4.0 so this does not work with Bash 3.2 which comes with macOS.

bind '"\er":menu-complete-backward';bind '"\es":menu-complete'
# Add keybindings for cycling through completions (or for inserting the last or first completion) in Bash menu-complete-backward was added in Bash 4.1. This makes for example M-s insert the path of the first file in the current directory after a space when the word to be completed is empty.

bind '"\ej": "!#:$\e^"'
# Make M-j insert (duplicate) the last word of the Readline line buffer in Bash !# is the current line, :$ is the last word, and \e^ is history-expand-line .
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

5 - 🖥️curl

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the curl command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                 ██████╗██╗   ██╗██████╗ ██╗     
#                ██╔════╝██║   ██║██╔══██╗██║     
#                ██║     ██║   ██║██████╔╝██║     
#                ██║     ██║   ██║██╔══██╗██║     
#                ╚██████╗╚██████╔╝██║  ██║███████╗
#                 ╚═════╝ ╚═════╝ ╚═╝  ╚═╝╚══════╝
                                                 
                                                
# Download a single file
curl http://path.to.the/file

# Download a file and specify a new filename
curl http://example.com/file.zip -o new_file.zip

# Download multiple files
curl -O URLOfFirstFile -O URLOfSecondFile

# Download all sequentially numbered files (1-24)
curl http://example.com/pic[1-24].jpg

# Download a file and pass HTTP Authentication
curl -u username:password URL 

# Download a file with a Proxy
curl -x proxysever.server.com:PORT http://addressiwantto.access

# Download a file from FTP
curl -u username:password -O ftp://example.com/pub/file.zip

# Get an FTP directory listing
curl ftp://username:[email protected]

# Resume a previously failed download
curl -C - -o partial_file.zip http://example.com/file.zip

# Fetch only the HTTP headers from a response
curl -I http://example.com

# Fetch your external IP and network info as JSON
curl http://ifconfig.me/all/json

# Limit the rate of a download
curl --limit-rate 1000B -O http://path.to.the/file

# POST to a form
curl -F "name=user" -F "password=test" http://example.com

# POST JSON Data
curl -H "Content-Type: application/json" -X POST -d '{"user":"bob","pass":"123"}' http://example.com

# POST data from the standard in / share data on sprunge.us
curl -F 'sprunge=<-' sprunge.us

#==============================#
# CMD CURL
#==============================##==============================#

10 Example of curl command in Linux
# Here are some of the useful examples of curl command in Linux. You can use this command to test your REST API from the Linux command line. You can also check if your web application is up and down by using curl command in a script and then running it from crontab or a scheduling application like Autosys.

1) How to send HTTP request from UNIX
You can use curl or wget to send HTTP request from UNIX, as shown below:

curl http://google.com

# By default, curl uses GET method to send HTTP request. You can also use query parameters while connecting to web services using HTTP as shown below:
curl http://api.openweathermap.org/data/2.5/weather?id=2172797

# Do not forget to include URL inside single quotes if you include more than one query parameters. Why? because multiple query parameters are separated using & which has special meaning in the shell, to run the command in the background, by including it inside single quotes we use it literally, as shown below:
curl 'http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139'

2) How to provide timeout for HTTP request in UNIX
# Another interesting example of curl command is by using -m option. You can use curl -m option to provide a timeout for HTTP request. If server will not return any response within specified time period then curl will exit, as shown below
curl -m 3 'http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139'

# will wait for 3 seconds before timing out. BTW, -m is used for a couple of things in curl e.g. for the maximum number of redirects and maximum file size to download.

# Alternatively, you can use more verbose --max-time, --max-redirs and --max-filesize options. Worth noting is maximum time allowed for transfer is in seconds, which means -m 5 means 5 seconds. You can use this option to check whether your website or web service is responsive or not.

curl http://api.openweathermap.org/data/2.5/weather?id=2172797
# By default, curl uses GET method to send HTTP request. You can also use query parameters while connecting to web services using HTTP

curl 'http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139'
# Don't forget to include URL inside single quotes if you include more than one query parameters. Why? because multiple query parameters are separated using & which has special meaning in the shell, to run the command in the background, by including it inside single quotes we use it literally

curl -m 3 'http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139'
# How to provide timeout for HTTP request in UNIX
# Another interesting example of curl command is by using -m option. You can use curl -m option to provide a timeout for HTTP request. If server will not return any response within specified time period then curl will exit, as shown below will wait for 3 seconds before timing out. BTW, -m is used for a couple of things in curl e.g. for the maximum number of redirects and maximum file size to download.

3) How to send HTTP POST request from Linux
# You can send any type of HTTP request by using curl -X command in Linux. It allows you to specify HTTP methods other than GET, for example, following command will send HTTP POST request from linux command line:

curl -X POST http://api.openweathermap.org

# Since GET is the default method, you don't need to specify it but if you want to send other HTTP methods e.g. PUT or POST, you can use this option. Btw, what is the use of POST request without sending any data? Let's see our next example, which allows you to send data to the server using curl command.

4) How to send data using HTTP POST in UNIX
# You can also send POST request using curl -d option. -d is nothing but for data, which is sent as POST body. The data is expected to be URL-encoded.

curl -d 'lat=35&lon=139' http://api.openweathermap.org/data/2.5/weather

# This will send query parameters as a POST request. You can also use -d option multiple times to specify different data pieces e.g.

curl -d lat=35 -d lon=139 http://api.openweathermap.org/data/2.5/weather

# This will eventually be combined as -d 'lat=35&lon=139'. The -d option can also be used to submit HTML form data to the server. You can see The Linux command line:  A complete Introduction for more details on sending data using curl command.

# How to send HTTP post request from Linux using curl
#=====================================================#

5) How to send a file via HTTP POST in Linux
# If your data is large, you can keep them inside a file and tell curl the file name. It will transfer all that data using HTTP post request to the server, here is an example of sending a file using curl:

curl -d @requestData.txt http://api.openweathermap.org/data/2.5/weather

# The @ sign tells curl that whatever follows is a file name. BTW, the content of file must be URL encoded. You can also use --data instead of -d if you prefer the most verbose option.

6) How to send username password for authentication using curl
# You can use curl -u option to pass username and password for authentication. The -u option is a shortcut of --user option which specifies username and password for server authentication. If you using twitter, here is how you can update your status using curl command right from UNIX:

curl -u username:password -d status='curl is great' http://twitter.com/statuses/update.xml

# If you don't wish your password to be saved in the shell history, you can omit password part and curl will prompt for password when it tries to authenticate on the server. As I told earlier, -d instructs curl to use HTTP POST method to send a request and "status=.." will be sent as part of the request body. You can further read Practical guide to Linux command and shell editors to learn more about it.

The curl Command example in UNIX and Linux
===========================================

7) How to specify HTTP header using curl command in Linux
# You can specify HTTP header by using curl -H option. Since with web service you often deal with either JSON or XML rather than HTML, it makes sense to specify content-type as either "application/json" or "application/xml". You can do this using curl as shown in the following example:

curl -H "Accept: application/json" 'http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139'

# You can also use headers while sending data to server using HTTP post e.g.

curl -X PUT \
    -H 'Content-Type: application/json' \
    -d '{"id":"101", "description":"baby soap"}'
    http://localhost:8080/item/add

# One side tip, you can split your UNIX command into multiple lines by using \ (backslash). It makes your command more readable, especially if it's getting long.

8) How to view HTTP response header in Linux
# You can use the curl -i command to view response header in UNIX. Since API and WebService provider is increasingly using HTTP header to provide information about caching, content-type, authorization etc, it's very useful to see HTTP header using curl as shown below:

curl -i http://api.openweathermap.org/data/2.5/weather?zip=94040,us

# This will return all response headers from HTTP response as shown below:

10 Examples of curl Command in UNIX and Linux
===============================================

# That is all about how to use curl command to send HTTP request and receive a response. We have seen several examples of curl command ranging from sending simple HTTP request to timeout, with query parameters and different types of HTTP request e.g. POST, PUT, and DELETE.

# It is actually a must know tool if you are working with REST web services which return JSON or XML output. You can test your web services right from UNIX box, can build scripts to test and monitor them as well. As a Java developer, I use curl a lot when I work with web services based application.

# UNIX command to send HTTP GET request
#-------------------------------------#
# Here is one example of calling web service from Linux shell by sending HTTP GET request using cURL command:

curl http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=bd82977b86bf27fb59a04b61b657fb6f
{"coord":{"lon":-0.13,"lat":51.51},"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"base":"stations","main":{"temp":282,"pressure":1022,"humidity":87,"temp_min":277.15,"temp_max":285.15},"visibility":10000,"wind":{"speed":1.5},"clouds":{"all":90},"dt":1445577409,"sys":{"type":1,"id":5093,"message":0.0201,"country":"GB","sunrise":1445582275,"sunset":1445619056},"id":2643743,"name":"London","cod":200}

# You can also specify timeout using -m option as shown below:
curl -m 2 http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=bd82977b86bf27fb59a04b61b657fb6f

# This request will timeout in 2 seconds if it doesn't receive any response.

# You can also use wget to send HTTP request and download the data. Only difference between curl and wget is that curl will print output in console and wget will store it in the file e.g.

wget http://localhost:8080/index.html

#will download the content of index.html and store into a file with the same name.

#Here is how you can use curl to download wget command in UNIX:
#How to send HTTP request from UNIX? Use CURL command

# UNIX command to send HTTP POST request
#----------------------------------------'
# You can also use curl to send HTTP post request. All you need to do is use the --data option to specify the data you want to POST to web service e.g.
curl --data "param1=value1&param2=value2" http://locahost:8080/weather

# if you want to send a data from file to web service, you can also use the following command:
curl -X POST -d @filename http://locahost:8080/weather

# Similarly, if you want to upload a file you can do so by executing the following command:
curl --form "[email protected]" http://locahost:8080/weather

#######################

#  UNIX command to send HTTP GET request
##########################################
# Here is one example of calling web service from Linux shell by sending HTTP GET request using cURL command:

curl http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=bd82977b86bf27fb59a04b61b657fb6f
{"coord":{"lon":-0.13,"lat":51.51},"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"base":"stations","main":{"temp":282,"pressure":1022,"humidity":87,"temp_min":277.15,"temp_max":285.15},"visibility":10000,"wind":{"speed":1.5},"clouds":{"all":90},"dt":1445577409,"sys":{"type":1,"id":5093,"message":0.0201,"country":"GB","sunrise":1445582275,"sunset":1445619056},"id":2643743,"name":"London","cod":200}

# You can also specify timeout using -m option as shown below - This request will timeout in 2 seconds if it does not receive any response.
curl -m 2 http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=bd82977b86bf27fb59a04b61b657fb6f

# You can also use wget to send HTTP request and download the data. Only difference between curl and wget is that curl will print output in console and wget will store it in the file e.g.

wget http://localhost:8080/index.html
# will download the content of index.html and store into a file with the same name.

# How to send HTTP request from UNIX? Use CURL command
#-------------------------------------------------------

# UNIX command to send HTTP POST request - You can also use curl to send HTTP post request. All you need to do is use the --data option to specify the data you want to POST to web service e.g.
curl --data "param1=value1&param2=value2" http://locahost:8080/weather

# if you want to send a data from file to web service, you can also use the following command:
curl -X POST -d @filename http://locahost:8080/weather

# Similarly, if you want to upload a file you can do so by executing the following command:
curl --form "[email protected]" http://locahost:8080/weather

curl -s http://www.coindesk\.com/price/ |grep bpiUSD |sed 's/<\/\?[^>]\+>//g' |tr -d " \t\r" 
# bitcoin prices in USD. 

curl -I http://langs.eserver\.org/latin-terms.txt | grep Last-Modified
# Check the last modified date of a file on a web server.

curl -sI https://www.nianticlabs\.com/privacy/pokemongo/en/ | head -1
# Show the HTTP response code for a URL. Catch it while you can!

curl wttr\.in/Moon
# See the current phase of the moon in your terminal. New feature of wttr.in

curl -d "" http://YourRokuIP:8060/keypress/Pause
# Press pause on your Roku. [When your kids lose the remote]

curl -sr 0-1024 www.nasa\.gov/images/content/618486main_earth_full.jpg |strings
# View image metadata without downloading whole 16MB image

curl -H "Host: http://www.example.com " http://example.climagic\.org/config.php
# Change the host header to bypass the DNS.

curl -s https://www.drownattack\.com/top-sites |html2text|awk -F\. '/^[0-9]+/{print $NF}' |sort|uniq -c|sort -nr
# Drownattack TLD stats

curl ipinfo.io
# The below command will output the ‘Geographical Location‘ of the IP address, provided.

curl ifconfig.me
# So how do you obtain your External IP address? Using google?. Well the command output your external IP address right into your terminal.

curl -u [email protected] --silent "https://mail.google.com/mail/feed/atom" | perl -ne 'print "\t" if //; print "$2\n" if /<(title|name)>(.*)<\/\1>/;'
# How about checking your unread mail from the command line. This command is very useful for those who work on headless server. Again it asks for password at run time and you need not hard code your password in the above line, which is otherwise a security risk.

curl -Ns http://www.climagic\.org/uxmas/[1-14] 
# curl supports numeric ranges. This is the full 14 days of unix-mas from 2012.

curl -v telnet://blt.evedder\.otv:4240
# Don not have telnet, netcat, etc installed. You can use curl with telnet:// prefix. 

# Yeah, so with their API it would just be 
curl https://api.coindesk.com/v1/bpi/currentprice.json  | jq .bpi.USD.rate

curl -d "" http://YourRokuIP:8060/keypress/InstantReplay
# Do an instant replay on your Roku.

# BTW, if you are only getting HTML back, try curl -4 http://wttr\.in/
finger [email protected]
curl http://wttr\.in/dallas

# Show the HTTP response code for a URL. Catch it while you can!
curl -sI https://www.nianticlabs\.com/privacy/pokemongo/en/ | head -1

curl -I http://langs.eserver\.org/latin-terms.txt | grep Last-Modified
# Check the last modified date of a file on a web server.

curl wttr\.in/Moon
# See the current phase of the moon in your terminal. New feature of wttr.in

curl -d "" http://YourRokuIP:8060/keypress/Pause
# Press pause on your Roku. [When your kids lose the remote]

curl -sr 0-1024 www.nasa\.gov/images/content/618486main_earth_full.jpg |strings
# View image metadata without downloading whole 16MB image

curl -H "Host: http://www.example.com " http://example.climagic\.org/config.php
# Change the host header to bypass the DNS.

curl -F password=@/etc/passwd http://www.mypasswords.com 
# Bad man page examples: For example, to send your password file to the server.... 

curl -s https://www.drownattack\.com/top-sites |html2text|awk -F\. '/^[0-9]+/{print $NF}' |sort|uniq -c|sort -nr
# Drownattack TLD stats

curl -N --limit-rate 16K http://f.climagic\.org/techsup.mp3 | mpg123 -
# Stream mp3 at bitrate speed (128Kbits). WARNING: NSFW "lyrics"

curl 'http://web.host/IMG_0[001-105].jpg …' -o "trip#1.jpg"
# Download images named IMG_0001.jpg through IMG_0105.jpg and save with different name.

# bitcoin prices in USD. 
curl -s http://www.coindesk\.com/price/ |grep bpiUSD |sed 's/<\/\?[^>]\+>//g' |tr -d " \t\r" 

curl -sI http://www.w3\.org/History/1989/proposal.rtf |grep Last-Modified
# See an earlier version date for TBLs WWW proposal. #QuestionAll

curl -Ls http://climagic\.org/uxmas/14

curl -v telnet://blt.evedder\.otv:4240
# Don not have telnet, netcat, etc installed. You can use curl with telnet:// prefix. 

curl -N --limit-rate 16K http://f.climagic\.org/techsup.mp3 | mpg123 -
# Stream mp3 at bitrate speed (128Kbits). WARNING: NSFW "lyrics"

curl -F password=@/etc/passwd http://www.mypasswords.com 
# Bad man page examples: For example, to send your password file to the server.... 

curl -4 http://wttr\.in/
# BTW, if you are only getting HTML back, try 

curl http://wttr\.in/dallas

curl 'http://web.host/IMG_0[001-105].jpg …' -o "trip#1.jpg"
# Download images named IMG_0001.jpg through IMG_0105.jpg and save with different name.

curl -sI http://www.w3\.org/History/1989/proposal.rtf |grep Last-Modified
# See an earlier version date for TBLs WWW proposal. #QuestionAll

# Bonus: Here are some of the commands that I used to create the cheat sheet:
curl 'http://www.gnu.org/software/coreutils/manual/coreutils.html' 2>/dev/null |
    grep 'h3 class' |
    grep 'class="command"' |
    sed 's/.*class="command">//' |
    sed 's|</span></samp>||' |
    sed 's|</h3>||' |
    grep ':' |
    sort

curl http://wttr.in/Berlin?lang=de
# Wetterbericht Berlin

URL="http://www.google.com";curl -L --w "$URL\nDNS %{time_namelookup}s  conn %{time_connect}s  time %{time_total}s\nSpeed %{speed_download}bps Size %{size_download}bytes\n" -o/dev/null -s $URL
# How fast is the connexion to a URL, some stats from curl

curl ifconfig.me
# What is my public IP-address?

curl ipinfo.io
# return external ip

curl -s 'http://checkip.dyndns.org' | sed 's/.*Current IP Address: \([0-9\.]*\).*/\1/g'
# Get your external IP address

curl -X POST -d @filename.txt http://example.com/path/to/resource --header "Content-Type:text/xml"
# How to use curl to send HTTP POST using file - Using curl you can send POST request, putting the content of your request in a separated file. For a RESTful HTTP POST containing XML
#    or for JSON, use this:
curl -X POST -d @filename.txt http://example.com/path/to/resource --header "Content-Type:application/json"
# This will read the contents of the file named filename.txt and send it as the post request.
#    Usage options:
#         -d: <filename> where some contents t o post
#         --header : specify the content type of your request (eg json/xml/text)

curl -v -L -G -d "q=test&sort=0&direction=1" https://www.snip2code.com/Explore/InChannel  
# curl to send a GET HTTP request with query parameters - Try to perform a GET HTTP to snip2code server, to list the public snippets in Channels. URL example to get: https://www.snip2code.com/Explore/InChannel?q=test&sort=0&direction=1
#    Options:
#         -d: list all query parameters
#         -G: perform GET verb

curl -sI http://imgs.xkcd.com/comics/i_know_youre_listening.png … | grep Last-Modified 
# Check the last modified date of a file over HTTP.

o=$(curl -Ls bit\.ly/globe_vt);yes "$o"|perl -ne '$/="\e[H";$\=$/;print "$_";select(undef,undef,undef,1/24);' 
# One world, no pv version.

oneworld=$( curl -Ls http://bit\.ly/globe_vt );while sleep .1;do pv -L4220 -q <<<"$oneworld";done 
# ASCII globe animation

curl http://wttr.in/Prague  
# Check the weather for the next few days in Prague. ;-)

curl -d '' http://roku\.home:8060/keypress/Up 
# Move up in your Roku interface. Great for when you can't find the remote. 

curl <addr1> --resolve <addr2> 
# resolve address 1 to address 2. Useful for testing

# Curl command with examples 
###########################

# Download or visit a single URL -> To download a file using CURL from http or ftp or any other protocol, use the following command
curl http://linuxtechlab.com

# If curl can’t identify the protocol being used, it will switch to http. We can also store the output of the command to a file with ‘-o’ option or can also redirect using ‘>’,
curl http://linuxtechlab.com -o test.html , or,

curl http://linuxtechlab.com > test.html

# Download multiple files -> To download two or more files with curl in a single command, we will use ‘-O’ option. Complete command is,
curl -O http://linuxtechlab.com/test1.tar.gz -O http://linuxtechlab.com/test2.tar.gz

# Using ftp with curl -> To browse a ftp server, use the following command,
curl ftp://test.linuxtechlab.com –user username:password

# To download a file from the ftp server, use the following command,
curl ftp://test.linuxtechlab.com/test.tar.gz –user username:password -o test.tar.gz

# To upload a file to the ftp server using th curl command, use the following,
curl -T test.zip ftp:/test.linuxtechlab.com/test_directory/ –user username:password

# Resume a paused download -> We can also pause and resume a download with curl command. To do this, we will first start the download ,
curl -O http://linuxtechlab.com/test1.tar.gz

# than pause the download using ‘ctrl+C’ & to resume the download, use the following command, here, ‘-C’ option is used to resume the download.
curl -C – -O http://linuxtechlab.com/test1.tar.gz
 

# Sending an email -> Though you might not be using it any time soon, but none the less we can use curl command to send email. Complete command for sending an email is,
curl –url “smtps://smtp.linuxtechlab.com:465” –ssl-reqd –mail-from “[email protected]” –mail-rcpt “[email protected]” –upload-file mailcontent.txt –user “[email protected]:password” –insecure

# Limit download rate -> To limit the rate at which a file is downloaded, in order to avoid network choking or for some other reason, use the curl command with ‘–limit-rate’ option,
curl –limit-rate 200k -O http://linuxtechlab.com/test.tar.gz
 

# Show response headers -> To only see the response header of a URL & not the complete content , we can use option ‘-I’ with curl command, This will only show the headers like http protocol, Cache-contorol headers, content-type etc of the mentioned url.
curl -I http://linuxtechlab.com/

# Using http authentication -> We can also use curl to open a web url that has http authentication enabled with curl using ‘-u ‘ option. Complete command is,
curl -u user:passwd http://linuxtechlab.com

# Using a proxy -> To use a proxy server when visiting an URL or downloading, use ‘-x’ option with curl,
curl -x squid.proxy.com:3128 http://linuxtechlab.com

# Verifying Ssl certificate -> To verify a SSL certificate of an URL, use the following command,
curl –cacert ltchlb.crt https://linuxtechlab.com

# Ignoring SSL certificate -> To ignore the SSL certificate for an URL, we can use ‘-k’ option with curl command,
curl -k https://linuxtechlab.com

# git clone all user repos
curl -s https://api.github.com/users/tuxcanfly/repos | jq -r 'map(select(.fork == false)) | map(.url) | map(sub("https://api.github.com/repos/"; "git clone [email protected]:")) | @sh' | xargs -n1 sh -c]

# If you use Linux, you should totally run 
curl http://parrot.live

# Count the number of 3+ letter TLDs 
curl -s https://data.iana.org/TLD/tlds-alpha-by-domain.txt … | egrep "^[^#]{3,}" | wc -l 

# Country code counts of IEEE OUIs.
curl http://standards-oui.ieee.org/oui.txt  | dos2unix | grep '^\s\+[A-Z][A-Z]$' | sort | uniq -c | sort -n

# One nice feature of curl is that it can do more than just HTTP and FTP. You can use it like a generic TCP client when a better tool like nc isn't available.
curl telnet://host.example.com:1093 

curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | awk -F'"' '/ip_prefix/ {print $4}'
# get all Amazon cloud (amazonws etc) ipv4 subnets

curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | awk -F'"' '/ipv6_prefix/ {print $4}'
# get all Amazon cloud (amazonws etc) ipv6 subnets

curl https://www.domain.com/ | grep -Eo "(http|https)://[a-zA-Z0-9./?=_-]*.*(doc|docx|xls|xlsx|ppt|pptx|pdf)" | sort | uniq > list.txt | wget list.txt
# Get all documents (doc,docx,xls,xlsx,pdf,ppt,pptx,...) linked in a webpage

curl http://www.google.com/azerty  | grep title 
# Google's 404 error page has a "typo" in the title tag, suggesting someone haphazardly typed in the title text. They thought you weren't looking!!1 ;)

# Download all files from a Github gist individually - Downloads each file from a github gist individually. - Requires jq ( https://stedolan.github.io/jq/ ).
curl -sS --remote-name-all $(curl -sS https://api.github.com/gists/997ccc3690ccd3ac5196211aff59d989 | jq -r '.files[].raw_url')

curl --remote-name 'http://www.example\.com/images/IMG_[0001-0176].JPG' 
# Download images in sequence IMG_0001.JPG through IMG_0176.JPG

curl -L https://twitter.com/i/web/status/1141450840013754369 | egrep -o ".{0,500}find with prune.{0,500}" # On the web you can encounter some extremely long lines of HTML code. Using a regex like .{0,500} and grep's -o option can help capture just the context around something you're searching for.

curl -s -L t\.co/YG3gLKwG9G | grep -o -P '(?<=<meta\ \ property="og:description" content="“).*(?=”">)' # GET the tweet, the full tweet and nothing but the tweet.This uses Perl regex lookahead/behind regex black magic.

# Print all git repos from a user - Python is installed on many boxes (in case you could not afford installing jq).
curl -s "https://api.github.com/users/<username>/repos?per_page=1000" | python <(echo "import json,sys;v=json.load(sys.stdin);for i in v:; print(i['git_url']);" | tr ';' '\n')

# Print all git repos from a user - in case you could afford installing jq
curl -s "https://api.github.com/users/<username>/repos?per_page=1000" | jq '.[].git_url'

# Print all git repos from a user
curl -s https://api.github.com/users/<username>/repos?per_page=1000 |grep git_url |awk '{print $2}'| sed 's/"\(.*\)",/\1/'

# Ultra fast public IP address lookup using Cloudflare's 1.1.1.1
curl -fSs https://1.1.1.1/cdn-cgi/trace | awk -F= '/ip/ { print $2 }'

# Get your public IP address using Amazon
curl checkip.amazonaws.com

curl -d '{"username": "Zach", "password": "something"}' -H "Content-Type: application/json" -X POST "localhost/api/login"
	# Similar to what we've done before. This time I get back the following:
		{"success": true, "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImp0aSI6Ijg4NGU1ZDI1LTM5MjMtNGM5OS1hMWE5LTBhYjhiY2I1NGI0NiIsImlhdCI6MTU1ODkwNTM3MSwiZXhwIjoxNTU4OTA4OTcxfQ.-5p5Wjk9k9y9Yf-pY0bnd6tOEAJyRKgb9DDzt4GoYIk"}

# We specify it as the argument of ".token" for jq because that's the name of the property whose value we want. What's the -r flag? It means I want the token given to me raw as text instead of as a string. When I pass/inject the TOKEN in my GET request,
curl -H "Accept: application/json" -H "Authorization: $TOKEN" -X GET "localhost/api/jokes"

#==============================##==============================#
# CMD curl						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

6 - 🖥️dhclient

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the dhclient command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗ ██╗  ██╗ ██████╗██╗     ██╗███████╗███╗   ██╗████████╗
#                ██╔══██╗██║  ██║██╔════╝██║     ██║██╔════╝████╗  ██║╚══██╔══╝
#                ██║  ██║███████║██║     ██║     ██║█████╗  ██╔██╗ ██║   ██║   
#                ██║  ██║██╔══██║██║     ██║     ██║██╔══╝  ██║╚██╗██║   ██║   
#                ██████╔╝██║  ██║╚██████╗███████╗██║███████╗██║ ╚████║   ██║   
#                ╚═════╝ ╚═╝  ╚═╝ ╚═════╝╚══════╝╚═╝╚══════╝╚═╝  ╚═══╝   ╚═╝   
                                                                              
                                                                              
                                                                           
# To release the current IP address:
dhclient -r

# To obtain a new IP address:
dhclient

# Running the above in sequence is a common way of refreshing an IP.

# To obtain a new IP address for a specific interface:
dhclient eth0

#==============================##==============================#
# CMD dhclient						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

7 - 🖥️dhcpd

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the dhcpd command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗ ██╗  ██╗ ██████╗██████╗ ██████╗ 
#                ██╔══██╗██║  ██║██╔════╝██╔══██╗██╔══██╗
#                ██║  ██║███████║██║     ██████╔╝██║  ██║
#                ██║  ██║██╔══██║██║     ██╔═══╝ ██║  ██║
#                ██████╔╝██║  ██║╚██████╗██║     ██████╔╝
#                ╚═════╝ ╚═╝  ╚═╝ ╚═════╝╚═╝     ╚═════╝ 
                                                        
                                                       
# Alle Leases - öfter vorkommende IP's ausgefiltert
grep ^lease /var/lib/dhcp/dhcpd.leases | cut -d ' ' -f 2 | sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n | uniq

# Alle Leases, Einfacher jedoch ohne doppelte IP Ausfilterung 
egrep "^lease" /var/lib/dhcp/db/dhcpd.leases |awk '{ print $2 }'

# Syntaxcheck, dann DHCP Stoppen, alles Leases Nullen, anschließend DHCP neustart und statuscheck (ops läuft)
/etc/init.d/dhcpd check-syntax
systemctl dhcpd stop
:> /var/lib/dhcp/db/dhcpd.lease
systemctl dhcpd start
systemctl dhcpd status

#!/bin/bash
# dhcp_pretty.sh
# Awk script to make the dhcp.leases more readable 
awk ' { out = ""} \
{ $1=="lease"||$1=="client-hostname" ? out=" " $2 : out=out } \
{ $1=="binding"||$1=="hardware" ? out= " " $3: out=out } \
{ $1=="ends"? out=" " $3 " " $4: out=out } \
{ $1=="}"? out="\n": out=out } \
{ printf out," " }' dhcpd.leases \
| grep active \
| sed -e s/'[{};" ]'/\ /g  \
| awk '{ printf "%-15s %-17s %-10s %-5s\n", $1, $5, $2, $3 }'

########################
awk 'BEGIN { RS="}" } { for(i=1;i<=NF;i++) if ($i~"192.168") print $2,$i }' /etc/dhcpd.conf|sed 's/;//g'|sort -n -t. -k4
###############################

#==============================##==============================#
# CMD dhcpd						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

8 - 🖥️dig

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the dig command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗ ██╗ ██████╗ 
#                ██╔══██╗██║██╔════╝ 
#                ██║  ██║██║██║  ███╗
#                ██║  ██║██║██║   ██║
#                ██████╔╝██║╚██████╔╝
#                ╚═════╝ ╚═╝ ╚═════╝ 

#==============================#
# CMD DIG
#==============================##==============================#

dig www.example.com @192.168.1.254
#

dig RandomDomainNameThatDoesNotExistLLC\.com @4.2.2.2
# Sigh.. What is happening to our beloved Internet? (also run 'whois level3\.sucks')

dig +short MX example\.com
# Show the mail servers that mail destined to example.com is going to go. +short for less info than default.

dig +short @resolver1.opendns.com myip.opendns.com
dig +short myip.opendns.com @resolver1.opendns.com
# Get your outgoing IP address

dig +short MX example\.com
# Show the mail servers that mail destined to example.com is going to go. +short for less info than default.

dig -x  IP-Adresse  = hostname.domain
# Reverse Namensauflösung

dig lxu.io AXFR | grep 10.45.8.20
# DNS Vorwärtsauflösung

dig srv041.lxu.io AXFR | grep 10.45.8.20
# DNS Vorwärtsauflösung

dig @8.8.8.8 URL SOA
# Frägt speziell den Google Nameserver ab

dig @8.8.8.8 heise.de MX
# Frägt speziell den Google Nameserver ab

dig @8.8.8.8 heise.de ns
# Frägt speziell den Google Nameserver ab

( seq 1 8 200 ; seq 6 8 200 ) | sort -n | xargs -I{} -n 1 dig +short -x 206.214.251.{}
# Star Wars Episode IV in Reverse DNS.
# Fit that exactly into 140. Yes, that will play Star Wars ASCII Animation with some music in the background. It kinda matches up.

# Get your outgoing IP address - Extract your external IP address using dig
dig +short myip.opendns.com @resolver1.opendns.com
## Explanation: This asks the IP address of myip.opendns.com from the name server resolver1.opendns.com (something you trust), which will return your external IP address. If you do not have dig, you could use these other services instead:
	# curl ipecho.net/plain
	# curl icanhazip.com
	# curl curlmyip.com
	# curl l2.io/ip
	# curl ip.appspot.com
	# curl ifconfig.me/ip
## Limitations: All these methods rely on external services, which might be sometimes temporarily or even permanently down. In that case, find an alternative service.


# 2 commands, 1 grep.
{ dig +short AAAA linux.lxu\.io ; dig +short A linux.lxu\.io; } | grep --color=always 42 

# To run dig (domain information groper)
dig [domain]

# To just get the ip address
dig [domain] +nocomments +noauthority +noadditional +nostats 
    OR
dig [domain] +noall +answer
    OR
dig [domain] +short

# To use a specific query type
dig -t [query type] [domain] [options]
    OR
dig [domain] [query type] [options]

# To view ALL DNS record types use query ANY
dig -t ANY [domain] [options]
    OR
dig [domain] ANY [options]

# To do a DNS reverse look up 
dig -x [ip address] +short

# To use a specific DNS server
dig @[specific DNS] [domain]

# To do a bulk DNS query (where file.txt has all the domains, one to a line)
dig [domain1] [options] [domain2] [options]
    OR
dig -f file.txt [options]

# This command will show the output of MX record:
dig @ns1.myname.com myname.com +short MX

# and this will output A record:
dig @ns1.myname.com myname.com +short A

dig +noall +answer @ns1.myname.com myname.com MX
myname.com.      86400   IN      MX      10 ASPMX2.GOOGLEMAIL.COM.
myname.com.      86400   IN      MX      10 ASPMX3.GOOGLEMAIL.COM.
myname.com.      86400   IN      MX      1 ASPMX.L.GOOGLE.COM.
myname.com.      86400   IN      MX      5 ALT1.ASPMX.L.GOOGLE.COM.
myname.com.      86400   IN      MX      5 ALT2.ASPMX.L.GOOGLE.COM.

# I can almost not imagine this being the actual answer due to the simplicity, but based on what I assume is your answer now, this should do the trick:
dig @ns1.myname.com myname.com +short MX; dig @ns1.myname.com myname.com +short A

# Return a list of all the IPs for a DNS record on one line separated by spaces and make sure to provide a newline at the end so that the prompt is on it's own line.
dig +short http://echo.ntp-fireos.com  | tr '\n' ' ' ; echo 

#==============================##==============================#
# CMD DIG @ lxu.io
#==============================##==============================#

# DEKIM Abfrage - Der DEKIM Key wird an eine Subdomain
dig @8.8.8.8 default._domainkey.lxu.io TXT

#; <<>> DiG 9.10.3-P4-Debian <<>> @8.8.8.8 default._domainkey.lxu.io TXT
#; (1 server found)
#;; global options: +cmd
#;; Got answer:
#;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26556
#;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

#;; OPT PSEUDOSECTION:
#; EDNS: version: 0, flags:; udp: 512
#;; QUESTION SECTION:
#;default._domainkey.lxu.io.	IN	TXT

#;; ANSWER SECTION:
#default._domainkey.lxu.io.	21599 IN TXT	"v=DKIM1; k=rsa; s=email; p=MIGfMA0GCSqGSIb3DQEBAQU4GNADCBiQKBgQClk5nmCP9sLeTlzYrbXHaEftPb31/ZOkP7xaP/UmPC8Lyuc5AL0QmbdokIjoVuVSdIvAiHRDlrSKxDampsB33MdQFKofLJYV2gBpFJ2yNNCBSwMp7hptM+SiOhRrOU8ncTMoZbfksFUQzwUIrLaEYeh6RXJqAd7ejLZ1K1etlQIDAQAB"

#;; Query time: 37 msec
#;; SERVER: 8.8.8.8#53(8.8.8.8)
#;; WHEN: Thu May 23 11:49:08 CEST 2019
#;; MSG SIZE  rcvd: 315


# SPF Eintrag abfragen
dig @8.8.8.8 lxu.io TXT

#; <<>> DiG 9.10.3-P4-Debian <<>> @8.8.8.8 lxu.io TXT
#; (1 server found)
#;; global options: +cmd
#;; Got answer:
#;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30840
#;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

#;; OPT PSEUDOSECTION:
#; EDNS: version: 0, flags:; udp: 512
#;; QUESTION SECTION:
#;lxu.io.			IN	TXT

#;; ANSWER SECTION:
#lxu.io.		1719	IN	TXT	"v=spf1 mx ip4:43.25.150.96/28 ip4:92.86.205.38 ip4:112.19.218.80/28 ip4:44.15.134.160/28 ip4:120.18.235.134 ip4:95.91.11.207 ip4:95.91.11.208 ip4:95.11.1.2 ip4:85.55.220.98 ip4:82.5.142.130 ip4:82.5.142.162 ?all"
#lxu.io.		1719	IN	TXT	"ciscocidomainverification=90f933162873d881b9fc5f7b4da9efa7a494d65acc3ab5b873ba4f6b31ce353"

#;; Query time: 18 msec
#;; SERVER: 8.8.8.8#53(8.8.8.8)
#;; WHEN: Thu May 23 11:50:23 CEST 2019
#;; MSG SIZE  rcvd: 382

# Beides zusammen ergibt einen DMARK Record, der bei uns aus Datenschutzrechtlichen Gründen nicht ist...
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

9 - 🖥️dns

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the dns command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗ ███╗   ██╗███████╗
#                ██╔══██╗████╗  ██║██╔════╝
#                ██║  ██║██╔██╗ ██║███████╗
#                ██║  ██║██║╚██╗██║╚════██║
#                ██████╔╝██║ ╚████║███████║
#                ╚═════╝ ╚═╝  ╚═══╝╚══════╝
                                          

curl -s http://public-dns.info/nameserver/br.csv| cut -d, -f1 | xargs -i timeout 1 ping -c1 -w 1 {} | grep time | sed -u "s/.* from \([^:]*\).*time=\([^ ]*\).*/\2\t\1/g" | sort -n | head -n1
# a function to find the fastest DNS server - http://public-dns.info gives a list of online dns servers. you need to change the country in url (br in this url) with your country code. this command need some time to ping all IP in list

timeDNS() { parallel -j0 --tag dig @{} "$*" ::: 208.67.222.222 208.67.220.220 198.153.192.1 198.153.194.1 156.154.70.1 156.154.71.1 8.8.8.8 8.8.4.4 | grep Query | sort -nk5; }
# a function to find the fastest free DNS server Uses GNU Parallel.

timeDNS () { { for x in "${local_DNS}" "208.67.222.222" "208.67.220.220" "198.153.192.1" "198.153.194.1" "156.154.70.1" "156.154.71.1" "8.8.8.8" "8.8.4.4"; do ({ echo -n "$x "; dig @"$x" "$*"|grep Query ; }|sponge &) done ; } | sort -n -k5 ; }
#  a function to find the fastest free DNS server Evoke from the command like as: timeDNS commandlinefu.com
# This isn't too terribly practical, but it is a good code example of using subshells to run the queries in parallel and the use of an "anonymous function" (a/k/a "inline group") to group i/o.
# I'm assuming you have already defined your local DNS cache as ${local_DNS}, (here, it's 192.168.0.1).
# You do need to install `moreutils` to get `sponge`.
# If you're willing to wait, a slower version w/o sponge, (and w/o sorting), is this:
# DNS () { for x in "192.168.0.1" "208.67.222.222" "208.67.220.220" "198.153.192.1" "198.153.194.1" "156.154.70.1" "156.154.71.1" "8.8.8.8" "8.8.4.4"; do (echo -n "$x "; dig @"$x" "$*"|grep Query) ; done ; }

#==============================##==============================#
# CMD dns						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

10 - 🖥️dnsserver

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the dnsserver command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗ ███╗   ██╗███████╗███████╗███████╗██████╗ ██╗   ██╗███████╗██████╗ 
#                ██╔══██╗████╗  ██║██╔════╝██╔════╝██╔════╝██╔══██╗██║   ██║██╔════╝██╔══██╗
#                ██║  ██║██╔██╗ ██║███████╗███████╗█████╗  ██████╔╝██║   ██║█████╗  ██████╔╝
#                ██║  ██║██║╚██╗██║╚════██║╚════██║██╔══╝  ██╔══██╗╚██╗ ██╔╝██╔══╝  ██╔══██╗
#                ██████╔╝██║ ╚████║███████║███████║███████╗██║  ██║ ╚████╔╝ ███████╗██║  ██║
#                ╚═════╝ ╚═╝  ╚═══╝╚══════╝╚══════╝╚══════╝╚═╝  ╚═╝  ╚═══╝  ╚══════╝╚═╝  ╚═╝
                                                                                           
                                                                                           
                                                                                         

# Free DNS Server
#------------------#

# Cloudflare ipv4 
# - verschlüsselte anfragen per DNS over TLS oder DNS over HTTPS
1.1.1.1
1.0.0.1
            
# Cloudflare ipv6
2606:4700:4700::1111
2606:4700:4700::1001 

# Google
8.8.8.8
8.8.4.4

# Quad9 
9.9.9.9
                                  

#==============================##==============================#
# CMD dnsserver						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

11 - 🖥️elinks

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the elinks command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███████╗██╗     ██╗███╗   ██╗██╗  ██╗███████╗
#                ██╔════╝██║     ██║████╗  ██║██║ ██╔╝██╔════╝
#                █████╗  ██║     ██║██╔██╗ ██║█████╔╝ ███████╗
#                ██╔══╝  ██║     ██║██║╚██╗██║██╔═██╗ ╚════██║
#                ███████╗███████╗██║██║ ╚████║██║  ██╗███████║
#                ╚══════╝╚══════╝╚═╝╚═╝  ╚═══╝╚═╝  ╚═╝╚══════╝
                                                             
                                                            
elinks -dump bit\.ly/qutWZK|tr -d ,|sed -e '/^2014/q'|awk '/^[12]/{p=$6/$2*100; printf "%d %0.4f%%\n",$1,p}'
# % US pop. murdered 1960-2014 

elinks http://maximize-your-cpu-temperature.com/ 
# Use elinks to read articles on websites that like to waste CPU energy and your time.

elinks -dump bit\.ly/qutWZK|tr -d ,|sed -e '/^2015/q'|awk '/^[12]/{p=$6/$2*100; printf "%d %0.4f%%\n",$1,p}' 
# % US pop. murdered 1960-2015

elinks https://en.wikipedia.org/wiki/Right_to_privacy … |sed -n '/Article 12/,+6p' 
# Pipe text from Wikipedia into sed, print regex+6 lines.

# Asked 5 years ago this month.
elinks https://stackoverflow\.com/questions/11828270/how-to-exit-the-vim-editor | grep viewed 

# Get a list of instructors from a webpage.
elinks -dump-width 1000 -dump http://example.com/2017training/  | awk -F: '/Instructor/{print $2}' 

# Solve the basic arithmetic CAPTCHA 
elinks -dump https://www.example.com/contact  | awk -F: '/Math question:/{print $2}' | bc 

elinks http://bit.ly/theydidnotpatch  |sed -e 's/Apache Struts security flaw/the fact that/' |less 
# Fixed headline for a @zackwhittaker article

elinks -no-numbering -dump-width 999 $(date +"http://enwp.org/%B_%d ")|sed '/Births/,/Deaths/!d'|grep \* | egrep -i --color=no "(math|computer|program|engineer|scien|invent)" # Show today's famous #STEM birthdays from the Wikipedia page for today's date. #TwoAteZero

#==============================##==============================#
# CMD elinks						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

12 - 🖥️ethtool

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ethtool command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ███████╗████████╗██╗  ██╗████████╗ ██████╗  ██████╗ ██╗     
#  ██╔════╝╚══██╔══╝██║  ██║╚══██╔══╝██╔═══██╗██╔═══██╗██║     
#  █████╗     ██║   ███████║   ██║   ██║   ██║██║   ██║██║     
#  ██╔══╝     ██║   ██╔══██║   ██║   ██║   ██║██║   ██║██║     
#  ███████╗   ██║   ██║  ██║   ██║   ╚██████╔╝╚██████╔╝███████╗
#  ╚══════╝   ╚═╝   ╚═╝  ╚═╝   ╚═╝    ╚═════╝  ╚═════╝ ╚══════╝

ethtool -p eth0 
# Blink eth0's LED so you can find it in the rat's next of server cables. Ctrl-C to stop. Thanks @brimston3
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

13 - 🖥️finger

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the finger command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ███████╗██╗███╗   ██╗ ██████╗ ███████╗██████╗ 
#  ██╔════╝██║████╗  ██║██╔════╝ ██╔════╝██╔══██╗
#  █████╗  ██║██╔██╗ ██║██║  ███╗█████╗  ██████╔╝
#  ██╔══╝  ██║██║╚██╗██║██║   ██║██╔══╝  ██╔══██╗
#  ██║     ██║██║ ╚████║╚██████╔╝███████╗██║  ██║
#  ╚═╝     ╚═╝╚═╝  ╚═══╝ ╚═════╝ ╚══════╝╚═╝  ╚═╝

# Produces a multi-line format displaying all of the information described for
# the -s option as well as the user's home directory, home phone number, login
# shell, mail status, and the contents of the files “.plan”, “.project”,
# “.pgpkey” and “.forward” from the user's home directory.
finger -s username

# weather report in console (for nuremberg in this case)
finger [email protected]
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

14 - 🖥️ftp

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ftp command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ███████╗████████╗██████╗ 
#  ██╔════╝╚══██╔══╝██╔══██╗
#  █████╗     ██║   ██████╔╝
#  ██╔══╝     ██║   ██╔═══╝ 
#  ██║        ██║   ██║     
#  ╚═╝        ╚═╝   ╚═╝

#ftp client commands
binary - set binary transfer type
cd - change remote working directory
lcd - change local working directory
get - recieve file
mget - get multiple files
passive - enter passive transfer mode
ls - list contents of remote directory

#Traditional ports, though they can be dynmically assigned
Port 21 - control commands
Port 20 - data transfer

#Active mode
Client initiates control session on port 21 and leaves port 20 open for the server to send data, and the server initiates the connection for port 20.
***If client is behind a firewall, or NAT, then the sever might not be able to connect to send data.

#Passive mode
Server gives teh client a port to initiate a connection to for data transfer.
***Most commonly used by browsers, ect.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

15 - 🖥️host

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the host command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██╗  ██╗ ██████╗ ███████╗████████╗
#                ██║  ██║██╔═══██╗██╔════╝╚══██╔══╝
#                ███████║██║   ██║███████╗   ██║   
#                ██╔══██║██║   ██║╚════██║   ██║   
#                ██║  ██║╚██████╔╝███████║   ██║   
#                ╚═╝  ╚═╝ ╚═════╝ ╚══════╝   ╚═╝   
               

                                                  
host -t ns google.com
# To find out the domain name servers use the -t option.

host -t ns google.com
# To find out the domain name servers use the -t option.

host -t cname mail.google.com
# To find out the domain CNAME, run.

host -n -t mx google.com
# To find out the MX records for a domain.

host -t txt google.com
# To find out the TXT records for a domain.

host -C google.com
# Find Domain SOA Record -You can make host attempt to display the SOA records for specified zone, from all the listed authoritative name servers for that zone with the -C flag.

host google.com ns4.google.com
# To query particual domain name server.

host -a google.com
# To make a query of type ANY, use the -a (all) option which is equivalent to setting the -v option.

host -v -t a google.com
# To find out domain TTL information.

host -4 google.com
# OR
host -6 google.com
# Use Either IPv4 or IPv6 - The -4 or -6 option forces host to use only IPv4 or only IPV6 query transport respectively.

host -rR 5 google.com
# Perform Non-Recursive Queries - The -r option performs non-recursive queries, note that setting this option clears the RD (recursion desired), the bit in the query which host makes.

host -R 5 google.com
# Set UDP Retries for a Lookup - By default the number of UDP tries is 1, to change it, use the -R flag.

host -T -W 10 google.com
# Set Query Time Wait for Reply - Using the -W switch, you can instruct host to wait for a reply for the specified time in seconds and if the -w flag is used, it makes host to wait forever for a reply.

host -t txt istheinternetonfire.com | cut -f 2 -d '"' | cowsay -f elephant

#==============================##==============================#
# CMD host						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

16 - 🖥️hostname

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the hostname command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██╗  ██╗ ██████╗ ███████╗████████╗███╗   ██╗ █████╗ ███╗   ███╗███████╗
#                ██║  ██║██╔═══██╗██╔════╝╚══██╔══╝████╗  ██║██╔══██╗████╗ ████║██╔════╝
#                ███████║██║   ██║███████╗   ██║   ██╔██╗ ██║███████║██╔████╔██║█████╗  
#                ██╔══██║██║   ██║╚════██║   ██║   ██║╚██╗██║██╔══██║██║╚██╔╝██║██╔══╝  
#                ██║  ██║╚██████╔╝███████║   ██║   ██║ ╚████║██║  ██║██║ ╚═╝ ██║███████╗
#                ╚═╝  ╚═╝ ╚═════╝ ╚══════╝   ╚═╝   ╚═╝  ╚═══╝╚═╝  ╚═╝╚═╝     ╚═╝╚══════╝
                                                                                       
                                                                                       
                                                                                       
                                                                                       

# The hostname command not only displays the system's host name, but lets them set it as well.

hostname
himanshu-desktop

#==============================##==============================#
# CMD HOSTNAME						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

17 - 🖥️http

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the http command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██╗  ██╗████████╗████████╗██████╗ 
#                ██║  ██║╚══██╔══╝╚══██╔══╝██╔══██╗
#                ███████║   ██║      ██║   ██████╔╝
#                ██╔══██║   ██║      ██║   ██╔═══╝ 
#                ██║  ██║   ██║      ██║   ██║     
#                ╚═╝  ╚═╝   ╚═╝      ╚═╝   ╚═╝     

# HTTP Authentication Types
Digest Authentication (uses htdigest)
-->susceptible to MITM attack!
Integrated Windows Authentication
-->will not function over proxy
Form-Based Authentication
-->not inherently encrypted, often poor implimentation

[------------------------- HTTP Response Codes ---------------------------]
#Informational Response Codes (1xx)
100 - Continue
101 - Switching Protocols
102 - Processing

#Success Response Codes (2xx)
200 - OK				206 - Partial Content
201 - Created				207 - Multi-status
202 - Accepted				208 - Already Reported
203 - Non-authoritative Info		226 - IM Used
204 - No Content			250 - Low Storage Space
205 - Reset Content

#Redirection Response Codes (3xx)
300 - Multiple Choices			304 - Not Modified
301 - Moved Permanently			305 - Use Proxy
302 - Found				307 - Temporary Redirect
303 - See Other				308 - Permanent Redirect

#Client Error Response Codes (4xx)
400 - Multiple Choices			410 - Not Modified
401 - Moved Permanently			411 - Use Proxy
402 - Found				412 - Temporary Redirect
403 - See Other				413 - Permanent Redirect
404 - Multiple Choices			414 - Not Modified
405 - Moved Permanently			415 - Use Proxy
406 - Found				416 - Temporary Redirect
407 - See Other				417 - Permanent Redirect
408 - Found				418 - Temporary Redirect
409 - See Other			

#Server Error Response Codes (5xx)
500 - Internal Server Error		508 - Loop Detected
501 - Not Implemented			509 - Bandwidth Limited
502 - Bad Gateway			510 - Not Extended
503 - Service Unavailable		511 - Network Auth Requried
504 - Gateway Timeout			550 - Permission Denied
505 - HTTP Ver Not Supported		551 - Option Not Supported
506 - Variant Also Negotiates		598 - Nework Read Timeout Error
507 - Insufficient Storage		599 - Network Connect Timeout Error	
                                                  
                                               
# Custom HTTP method HTTP headers and JSON data:
http PUT example.org X-API-Token:123 name=John

# Submitting forms:
http -f POST example.org hello=World

# See the request that is being sent using one of the output options:
http -v example.org

# Use Github API to post a comment on an issue with authentication:
http -a USERNAME POST https://api.github.com/repos/jkbrzt/httpie/issues/83/comments body='HTTPie is awesome!'

# Upload a file using redirected input:
http example.org < file.json

# Download a file and save it via redirected output:
http example.org/file > file

# Download a file wget style:
http --download example.org/file

# Use named sessions_ to make certain aspects or the communication
# persistent between requests to the same host:
# http --session=logged-in -a username:password httpbin.org/get API-Key:123
http --session=logged-in httpbin.org/headers

# Set a custom Host header to work around missing DNS records:
http localhost:8000 Host:example.com

# Simple JSON example:
http PUT example.org name=John email[email protected]

# Non-string fields use the := separator, which allows you to embed raw
# JSON into the resulting object. Text and raw JSON files can also be
# embedded into fields using =@ and :=@:
http PUT api.example.com/person/1 name=John age:=29 married:=false hobbies:='["http", "pies"]' description[email protected] bookmarks:[email protected]

# Send JSON data stored in a file:
http POST api.example.com/person/1 < person.json

# Regular Forms
http --form POST api.example.org/person/1 name='John Smith' email[email protected] cv=@~/Documents/cv.txt

# File Upload Forms
# If one or more file fields is present, the serialization and content
# type is multipart/form-data:
http -f POST example.com/jobs name='John Smith' cv@~/Documents/cv.pdf

# To set custom headers you can use the Header:Value notation:
http example.org  User-Agent:Bacon/1.0  'Cookie:valued-visitor=yes;foo=bar' X-Foo:Bar  Referer:http://httpie.org/

# Basic auth:
http -a username:password example.org

# Digest auth:
http --auth-type=digest -a username:password example.org

# With password prompt:
http -a username example.org

# Authorization information from your ~/.netrc file is honored as well:
cat ~/.netrc
    machine httpbin.org
    login httpie
    # password test
http httpbin.org/basic-auth/httpie/test

# You can specify proxies to be used through the --proxy argument for each
# protocol (which is included in the value in case of redirects across
# protocols):
http --proxy=http:http://10.10.1.10:3128 --proxy=https:https://10.10.1.10:1080 example.org

# With Basic authentication:
http --proxy=http:http://user:[email protected]:3128 example.org

# To skip the HOST'S SSL CERTIFICATE VERIFICATION, you can pass
# --verify=no (default is yes):
http --verify=no https://example.org

# You can also use --verify=<CA_BUNDLE_PATH> to set a CUSTOM CA BUNDLE path:
http --verify=/ssl/custom_ca_bundle https://example.org

# To use a CLIENT SIDE CERTIFICATE for the SSL communication, you can pass
# the path of the cert file with --cert:
http --cert=client.pem https://example.org

# If the PRIVATE KEY is not contained in the cert file you may pass the
# path of the key file with --cert-key:
http --cert=client.crt --cert-key=client.key https://example.org

# You can control what should be printed via several options:
  # --headers, -h   Only the response headers are printed.
  # --body, -b      Only the response body is printed.
  # --verbose, -v   Print the whole HTTP exchange (request and response).
  # --print, -p     Selects parts of the HTTP exchange.
http --verbose PUT httpbin.org/put hello=world

# Print request and response headers:
  # Character   Stands for
  # ----------- -------------------
  # H           Request headers.
  # B           Request body.
  # h           Response headers.
  # b           Response body.
http --print=Hh PUT httpbin.org/put hello=world

# Let's say that there is an API that returns the whole resource when it
# is updated, but you are only interested in the response headers to see
# the status code after an update:
http --headers PATCH example.org/Really-Huge-Resource name='New Name'

# Redirect from a file:
http PUT example.com/person/1 X-API-Token:123 < person.json

# Or the output of another program:
grep '401 Unauthorized' /var/log/httpd/error_log | http POST example.org/intruders

# You can use echo for simple data:
echo '{"name": "John"}' | http PATCH example.com/person/1 X-API-Token:123

# You can even pipe web services together using HTTPie:
http GET https://api.github.com/repos/jkbrzt/httpie | http POST httpbin.org/post

# You can use cat to enter multiline data on the terminal:
cat | http POST example.com
    <paste>
    # ^D
cat | http POST example.com/todos Content-Type:text/plain
    - buy milk
    - call parents
    ^D

# On OS X, you can send the contents of the clipboard with pbpaste:
pbpaste | http PUT example.com

# Passing data through stdin cannot be combined with data fields specified
# on the command line:
echo 'data' | http POST example.org more=data   # This is invalid

# AN ALTERNATIVE TO REDIRECTED stdin is specifying a filename (as
# @/path/to/file) whose content is used as if it came from stdin.

# It has the advantage that THE Content-Type HEADER IS AUTOMATICALLY SET
# to the appropriate value based on the filename extension. For example,
# the following request sends the verbatim contents of that XML file with
# Content-Type: application/xml:
http PUT httpbin.org/put @/data/file.xml

# Download a file:
http example.org/Movie.mov > Movie.mov

# Download an image of Octocat, resize it using ImageMagick, upload it
# elsewhere:
http octodex.github.com/images/original.jpg | convert - -resize 25% -  | http example.org/Octocats

# Force colorizing and formatting, and show both the request and the
# response in less pager:
http --pretty=all --verbose example.org | less -R

# When enabled using the --download, -d flag, response headers are printed
# to the terminal (stderr), and a progress bar is shown while the response
# body is being saved to a file.
http --download https://github.com/jkbrzt/httpie/tarball/master

# You can also redirect the response body to another program while the
# response headers and progress are still shown in the terminal:
http -d https://github.com/jkbrzt/httpie/tarball/master |  tar zxf -

# If --output, -o is specified, you can resume a partial download using
# the --continue, -c option. This only works with servers that support
# Range requests and 206 Partial Content responses. If the server doesn't
# support that, the whole file will simply be downloaded:
http -dco file.zip example.org/file

# Prettified streamed response:
http --stream -f -a YOUR-TWITTER-NAME https://stream.twitter.com/1/statuses/filter.json track='Justin Bieber'

# Send each new tweet (JSON object) mentioning "Apple" to another
# server as soon as it arrives from the Twitter streaming API:
http --stream -f -a YOUR-TWITTER-NAME https://stream.twitter.com/1/statuses/filter.json track=Apple | while read tweet; do echo "$tweet" | http POST example.org/tweets ; done

# Create a new session named user1 for example.org:
http --session=user1 -a user1:password example.org X-Foo:Bar

# Now you can refer to the session by its name, and the previously used
# authorization and HTTP headers will automatically be set:
http --session=user1 example.org

# To create or reuse a different session, simple specify a different name:
http --session=user2 -a user2:password example.org X-Bar:Foo

# Instead of a name, you can also directly specify a path to a session
# file. This allows for sessions to be re-used across multiple hosts:
http --session=/tmp/session.json example.orghttp --session=/tmp/session.json admin.example.orghttp --session=~/.httpie/sessions/another.example.org/test.json example.orghttp --session-read-only=/tmp/session.json example.org

#==============================##==============================#
# CMD HTTP						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

18 - 🖥️ifconfig

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ifconfig command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██╗███████╗ ██████╗ ██████╗ ███╗   ██╗███████╗██╗ ██████╗ 
#                ██║██╔════╝██╔════╝██╔═══██╗████╗  ██║██╔════╝██║██╔════╝ 
#                ██║█████╗  ██║     ██║   ██║██╔██╗ ██║█████╗  ██║██║  ███╗
#                ██║██╔══╝  ██║     ██║   ██║██║╚██╗██║██╔══╝  ██║██║   ██║
#                ██║██║     ╚██████╗╚██████╔╝██║ ╚████║██║     ██║╚██████╔╝
#                ╚═╝╚═╝      ╚═════╝ ╚═════╝ ╚═╝  ╚═══╝╚═╝     ╚═╝ ╚═════╝ 
                

                                                                       
# Display network settings of the first ethernet adapter
ifconfig wlan0

# Display all interfaces, even if down
ifconfig -a

# Take down / up the wireless adapter
ifconfig wlan0 {up|down} 

# Set a static IP and netmask
ifconfig eth0 192.168.1.100 netmask 255.255.255.0

ifconfig $(route -n |awk '/0[.]0[.]0[.]0/{print $NF;exit}') | awk '/inet/{print $2}'
# Get primary IP of the local machine

# You may also need to add a gateway IP
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1

# Get primary IP of the local machine
ifconfig $(route -n |awk '/0[.]0[.]0[.]0/{print $NF;exit}') | awk '/inet/{print $2}'

#==============================##==============================#
# CMD IFCONFIG						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

19 - 🖥️ip

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ip command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██╗██████╗ 
#                ██║██╔══██╗
#                ██║██████╔╝
#                ██║██╔═══╝ 
#                ██║██║     
#                ╚═╝╚═╝     
                          
								  
#==============================#
# CMD IP
#==============================##==============================#
# Display all interfaces with addresses
ip addr

# Take down / up the wireless adapter
ip link set dev wlan0 {up|down}

# Set a static IP and netmask
ip addr add 192.168.1.100/32 dev eth0

# Remove a IP from an interface
ip addr del 192.168.1.100/32 dev eth0

# Remove all IPs from an interface
ip address flush dev eth0

# Display all routes
ip route

# Display all routes for IPv6
ip -6 route

# Add default route via gateway IP
ip route add default via 192.168.1.1

# Add route via interface
ip route add 192.168.0.0/24 dev eth0

# Change your mac address 
ip link set dev eth0 address aa:bb:cc:dd:ee:ff

# View neighbors (using ARP and NDP) 
ip neighbor show
#==============================##==============================#

ip route add $destination via $gateway
#

ip route add default via 192.168.2.1 dev ens33
# route add default gateway

ip a | grep -oP '(?<=inet |addr:)(?:\d+\.){3}\d+'
# grep expression (perl regex) to extract all ip addresses from both ip and ifconfig commands output
# It uses the following GNU grep options: "-o" which shows only the matching part of the line and "-P" which allows the use of Perl regular expressions. 
# Show Sample Output:
ip a | grep -oP '(?<=inet |addr:)(?:\d+\.){3}\d+'
        # # 127.0.0.1
        # # 10.0.2.15
        # # 172.17.0.1
ifconfig  | grep -oP '(?<=inet |addr:)(?:\d+\.){3}\d+'
        # # 96.126.108.191
        # # 192.168.135.145
        # # 127.0.0.1

# Really lazy way to print the first instance of $foo that occurs after $bar
ifconfig | grep ^en1 -A5 | grep inet | head -n 1

# Explanation: This is just for the sake of an example of finding $foo that occurs after $bar. Substitute ifconfig and the arguments of grep appropriately for your use case.
    # In the output of ifconfig there are several lines with inet. We want to get to the first one that comes after a line starting with en1
    # grep ^en1 -A5 will print the line starting with en1 and the next 5 lines that follow it
    # grep inet will print only the lines matching inet
    # head -n 1 will print only the first line

# The value 5 in -A5 is really just a guess that the line we're interested in will be within the next 5 lines, the appropriate number depends on your use case. Kind of a dumb technique, but it's easy to remember.

# How to set the ip address in Solaris 11
ipadm create-addr -T static -a 192.168.1.10/24 eth0/staticaddr
# Explanation: 
    # eth0 is the name of the network interface
    # ipadm show-if shows the list of network interfaces
    # staticaddr is a name you can choose
# More details here: http://docs.oracle.com/cd/E19963-01/html/821-1458/gjwiq.html

#==============================##==============================#
# CMD IP
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

20 - 🖥️iscsi

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the iscsi command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ██╗███████╗ ██████╗███████╗██╗
#  ██║██╔════╝██╔════╝██╔════╝██║
#  ██║███████╗██║     ███████╗██║
#  ██║╚════██║██║     ╚════██║██║
#  ██║███████║╚██████╗███████║██║
#  ╚═╝╚══════╝ ╚═════╝╚══════╝╚═╝

# https://www.thomas-krenn.com/de/wiki/ISCSI_unter_Linux_mounten

# discovery der Targets
iscsiadm -m discovery -t sendtargets -p 192.168.1.7:3260

# prüfen aktiver sessions
iscsiadm --mode session

# Einloggen
iscsiadm -m node -T iqn.2004-04.com.qnap:ts-453a:iscsi.iscsi.0bad8c -p 192.168.1.7:3260 --login
iscsiadm -m node -T iqn.2004-04.com.qnap:ts-453a:iscsi.nas.0bad8c -p 192.168.1.7:3260 --login
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

21 - 🖥️iw

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the iw command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ██╗██╗    ██╗
#  ██║██║    ██║
#  ██║██║ █╗ ██║
#  ██║██║███╗██║
#  ██║╚███╔███╔╝
#  ╚═╝ ╚══╝╚══╝ 

# Print wifi access points sorted by signal 
iw dev IFACE scan | egrep "SSID|signal" | awk -F ":" '{print $2}' | sed 'N;s/\n/:/' | sort
# Explanation: 
    # iw dev IFACE scan get info about scanned APs
    # egrep "SSID|signal" take only name and signal
    # awk -F ":" '{print $2}' cut labels of fields
    # sed 'N;s/\n/:/' join couples to single line
    # sort sort by signal asc
# IFACE - wifi interface (like wlan0)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

22 - 🖥️iwconfig

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the iwconfig command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██╗██╗    ██╗ ██████╗ ██████╗ ███╗   ██╗███████╗██╗ ██████╗ 
#                ██║██║    ██║██╔════╝██╔═══██╗████╗  ██║██╔════╝██║██╔════╝ 
#                ██║██║ █╗ ██║██║     ██║   ██║██╔██╗ ██║█████╗  ██║██║  ███╗
#                ██║██║███╗██║██║     ██║   ██║██║╚██╗██║██╔══╝  ██║██║   ██║
#                ██║╚███╔███╔╝╚██████╗╚██████╔╝██║ ╚████║██║     ██║╚██████╔╝
#                ╚═╝ ╚══╝╚══╝  ╚═════╝ ╚═════╝ ╚═╝  ╚═══╝╚═╝     ╚═╝ ╚═════╝ 
                                                                            
                                                                           
# Display wireless settings of the first wireless adapter
iwconfig wlan0

# Take down / up the wireless adapter
iwconfig wlan0 txpower {on|auto|off}

# Change the mode of the wireless adapter
iwconfig wlan0 mode {managed|ad-hoc|monitor}

#==============================##==============================#
# CMD IWCONFIG						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

23 - 🖥️iwlist

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the iwlist command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ██╗██╗    ██╗██╗     ██╗███████╗████████╗
#  ██║██║    ██║██║     ██║██╔════╝╚══██╔══╝
#  ██║██║ █╗ ██║██║     ██║███████╗   ██║   
#  ██║██║███╗██║██║     ██║╚════██║   ██║   
#  ██║╚███╔███╔╝███████╗██║███████║   ██║   
#  ╚═╝ ╚══╝╚══╝ ╚══════╝╚═╝╚══════╝   ╚═╝   

# This one also brings in 5Ghz channels:
iwlist wlp4s0 scan | grep Channel: | grep -P '\d+' -o | sort -g | uniq -c | awk '{ print $2 " " $1}' | termgraph

# Draw bar chart of channels of Wi-Fi networks around:
iwlist wlp3s0 scan | grep \(Channel | grep -P ' \d+' -o | sort -g | uniq -c | awk '{ print $2 " " $1}' | termgraph
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

24 - 🖥️lynx

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the lynx command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ██╗  ██╗   ██╗███╗   ██╗██╗  ██╗
#  ██║  ╚██╗ ██╔╝████╗  ██║╚██╗██╔╝
#  ██║   ╚████╔╝ ██╔██╗ ██║ ╚███╔╝ 
#  ██║    ╚██╔╝  ██║╚██╗██║ ██╔██╗ 
#  ███████╗██║   ██║ ╚████║██╔╝ ██╗
#  ╚══════╝╚═╝   ╚═╝  ╚═══╝╚═╝  ╚═╝

# Dump $url, do not show links urls
lynx -dump -nolist $url

# Use lynx to run repeating website actions
# For creating your keystroke file, use:
#   lynx -cmd_log yourfile
lynx -accept_all_cookies -cmd_script=/your/keystroke-file

# convert html to text
lynx -force_html -stdin -dump -nolist

# List top 100 djs from https://djmag.com/top100djs
lynx -listonly -nonumbers -dump https://djmag.com/top100djs|sed '1d'|cut -d- -f5,6,7|sed -n '180,$p'|nl --number-format=rn --number-width=3|sed 's/-/ /g'|sed -e 's/.*/\L&/' -e 's/\<./\u&/g'
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

25 - 🖥️mail

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the mail command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███╗   ███╗ █████╗ ██╗██╗     
#                ████╗ ████║██╔══██╗██║██║     
#                ██╔████╔██║███████║██║██║     
#                ██║╚██╔╝██║██╔══██║██║██║     
#                ██║ ╚═╝ ██║██║  ██║██║███████╗
#                ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝╚══════╝
                                              
                                           

#=============#
# CMD MAIL
#==============================##==============================#
echo "hello world" | mail -s "a subject" [email protected]
#

echo "This will go into the body of the mail." | mail -s "Hello world" [email protected]
#

mail -s "Hello world" [email protected] < /home/calvin/application.log
#

top -b -n 1 | mail -s "any subject" [email protected]
#

mail -s "Your Subject" [email protected] < /file/with/mail/content
#(/file/with/mail/content sh		ould be a plaintext file, not a file attachment or an image, etc)

echo "Sending an attachment." | mutt -a file.zip -s "attachment" [email protected]
#

# ENTER then type message body then CTRL+D.
mail -s “Hello world” [email protected]

# Otherwise, 
echo "This will go into the body of the mail." | mail -s "Hello world" [email protected]

# Or parse from file, 
mail -s “Hello world” [email protected] < /tmp/message.log

# Use mutt for attaching file, 
echo “Sending an attachment.” | mutt -a backup.zip -s “attachment” [email protected]

# Datei sich per Email zusenden
cat DATEI | mail -s MAILSUBJEKT [email protected]

wait_for_this.sh; echo "wait_for_this.sh finished running" | mail -s "Job Status Update" [email protected]
# Send an email from the terminal when job finishes

echo "This is the message body" | mutt -a "/path/to/file.to.attach" -s "subject of message" -- [email protected]
gzip -c mysqldbbackup.sql | uuencode mysqldbbackup.sql.gz  | mail -s "MySQL DB" [email protected]

mail -s "Backup" -a mysqldbbackup.sql [email protected] < message.txt
or also:
cat message.txt | mail -s "Backup" -a mysqldbbackup.sql [email protected]

EHLO test.example.com
MAIL FROM:<ABSENDERADRESSE>
RCPT TO:<EMPFÄNGERADRESSE>
DATA
Subject: Testnachricht
(Leerzeile, erneut Enter drücken)
Das ist ein Test.
(Leerzeile, erneut Enter drücken)
.
QUIT

#==============================##==============================#
# CMD MAIL					       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

26 - 🖥️mailq

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the mailq command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███╗   ███╗ █████╗ ██╗██╗      ██████╗ 
#                ████╗ ████║██╔══██╗██║██║     ██╔═══██╗
#                ██╔████╔██║███████║██║██║     ██║   ██║
#                ██║╚██╔╝██║██╔══██║██║██║     ██║▄▄ ██║
#                ██║ ╚═╝ ██║██║  ██║██║███████╗╚██████╔╝
#                ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝╚══════╝ ╚══▀▀═╝ 
                                                       
                

#==============================#
# CMD MAILQ
#==============================##==============================#
lq -AC
# -Ac -Am These options are used by Sendmail for selecting configuration files and are ignored by Exim.#

mailq -Lq
#  -L <tag>  This option is equivalent to setting syslog_processname in the config file and setting log_file_path to syslog.  The  -q option starts one queue runner process. This scans the queue of waiting messages, and runs a delivery process for each one in turn.

mailq | awk '/^[0-9A-F]/{print $1}' | tr -d \* | xargs -n 1 postcat -q > mailq-20160801.txt
# Save your whole postfix queue to a file.'

mailq |grep " Jan 20 " |awk {'print $1'} |xargs -n 1 postsuper -d
# Delete messages from Jan 20th in the postfix queue.

mailq | grep " Dec 16 " | awk {'print $1'} | xargs -n 1 postsuper -d 
# Delete messages from Dec 16th in the postfix queue.

mailq | awk '/^[0-9A-F]+ .+ Dec 11 /{print $1}' | xargs -n 1 postsuper -d 
# Delete messages from Dec 11th in the postfix queue.

#==============================##==============================#
# CMD MAILQ
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

27 - 🖥️mongo

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the mongo command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ███╗   ███╗ ██████╗ ███╗   ██╗ ██████╗  ██████╗ 
#  ████╗ ████║██╔═══██╗████╗  ██║██╔════╝ ██╔═══██╗
#  ██╔████╔██║██║   ██║██╔██╗ ██║██║  ███╗██║   ██║
#  ██║╚██╔╝██║██║   ██║██║╚██╗██║██║   ██║██║   ██║
#  ██║ ╚═╝ ██║╚██████╔╝██║ ╚████║╚██████╔╝╚██████╔╝
#  ╚═╝     ╚═╝ ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝  ╚═════╝ 

# mongo
# MongoDB interactive shell client.

# Connect to local host on default port 27017
mongo

# Connect to remote host on specified port
mongo --host 10.121.65.23 --port 23020

# Connect to a database <host>/<database>
mongo 10.121.65.58/mydb

# Connect to a database on specified host and port
# with this username and password
mongo -u username -p password --port 12345 --host localhost

# Run the shell after executing my-script.js
mongo --shell my-script.js

# Connect to database on specified port and host
# and execute my-script.js after that
mongo localhost:27017/myDatabase my-script.js

# Evaluate a javascript expression on the database:
mongo --eval 'JSON.stringify(db.foo.findOne())' database

# See also:
#   MongoDB cheat sheets at /mongo/
#   list of pages:      /mongo/:list
#   search in pages:    /mongo/~keyword
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

28 - 🖥️mtr

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the mtr command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███╗   ███╗████████╗██████╗ 
#                ████╗ ████║╚══██╔══╝██╔══██╗
#                ██╔████╔██║   ██║   ██████╔╝
#                ██║╚██╔╝██║   ██║   ██╔══██╗
#                ██║ ╚═╝ ██║   ██║   ██║  ██║
#                ╚═╝     ╚═╝   ╚═╝   ╚═╝  ╚═╝
                                           

mtr http://duckduckgo.com  
# Check connectivity/latency to a network host. Kind of a real time ping/traceroute hybrid. Try changing display modes.

#==============================##==============================#
# CMD bash                                                     #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

29 - 🖥️nc

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the nc command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███╗   ██╗ ██████╗
#                ████╗  ██║██╔════╝
#                ██╔██╗ ██║██║     
#                ██║╚██╗██║██║     
#                ██║ ╚████║╚██████╗
#                ╚═╝  ╚═══╝ ╚═════╝
                                  
                                  
                                 
# To open a TCP connection to port 42 of host.example.com, using port 31337 as the source port, with a timeout of 5 seconds:
nc -p 31337 -w 5 host.example.com 42

# To open a UDP connection to port 53 of host.example.com:
nc -u host.example.com 53

# To open a TCP connection to port 42 of host.example.com using 10.1.2.3 as the IP for the local end of the connection:
nc -s 10.1.2.3 host.example.com 42

# To create and listen on a UNIX-domain stream socket:
nc -lU /var/tmp/dsocket

# To connect to port 42 of host.example.com via an HTTP proxy at 10.2.3.4, port 8080. This example could also be used by ssh(1); see the ProxyCommand directive in ssh_config(5) for more information.
nc -x10.2.3.4:8080 -Xconnect host.example.com 42

# The same example again, this time enabling proxy authentication with username "ruser" if the proxy requires it:
nc -x10.2.3.4:8080 -Xconnect -Pruser host.example.com 42

# To choose the source IP for the testing using the -s option
nc -zv -s source_IP target_IP Port

#==============================#
# CMD NC - netcat
#==============================##==============================#
nc -C imap.example.org 143

nc -zv localhost 80
# Check if port 80 is open or not. We can replace ‘80‘ with any other port number to check if it is opened or closed

nc -q1 -lvp 1234 < file.txt
# poor man his file serve. Use nc serverhost 1234 > output.txt to retrieve file from remote host. NAT bugs this.

nc -C localhost 80
    GET / HTTP/1.0
    Host: localhost

nc -C localhost 3128
    GET http://www.example.org/ HTTP/1.0
    Host: www.example.org

nc pop3.example.org 110
    +OK Dovecot ready.
    user $user
    +OK
    pass $pass
    +OK Logged in.
    list
    +OK 1

nc -C smtp 25
    220 smtp ESMTP Postfix (Debian/GNU)
    helo $myhostname
    250 smtp
    mail from: $sender
    250 2.1.0 Ok
    rcpt to: $recipient
    250 2.1.5 Ok
    data
    354 End data with <CR><LF>.<CR><LF>
    Subject: Test

    Nicht mehr als ein Test.
    .
    250 2.0.0 Ok: queued as 82C3D440A5
    quit
    221 2.0.0 Bye

### Portscanning
nc -z -v smtp.example.net 22-25

netcat -l 1234 > file.out
#

netcat host.example.net 1234 < file.in
#

netcat -C mail.example.net 25 <<EOT
HELO host.example.net
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
DATA
Subject: Testmail
Body of email.
.
QUIT
EOT

nc -q1 -lvp 1234 < file.txt 
# poor man's file serve. Use nc serverhost 1234 > output.txt to retrieve file from remote host. NAT bugs this.

#-----------------------------------------#
# Bash/nc: netcat as a simple telnet server
#-------------------------------------------------------------------------------------#

## CLIENT/SERVER MODEL
# It is quite simple to build a very basic client/server model using nc.  On one console, start nc listening on a specific port for a connection.  For example:

nc -l 1234
#  nc is now listening on port 1234 for a connection.  On a second console (or a second machine), connect to the machine and port being listened on:

nc 127.0.0.1 1234
# There should now be a connection between the ports.  Anything typed at the second console will be concatenated to the first, and vice-versa.  After the connection has been set up, nc does not really care which side is being used as a ‘server’ and which side is being used as a ‘client’.  The connection may be terminated using an EOF (‘^D’).

# There is no -c or -e option in this netcat, but you still can execute a command after connection being established by redirecting file descriptors. Be cautious here because opening a port and let anyone connected execute arbitrary command on your site isDANGEROUS. If you really need to do this, here is an example:

## -> On ‘server’ side:
rm -f /tmp/f; mkfifo /tmp/f
cat /tmp/f | /bin/sh -i 2>&1 | nc -l 127.0.0.1 1234 > /tmp/f

## -> On ‘client’ side:
nc host.example.com 1234
$ (shell prompt from host.example.com)

# By doing this, you create a fifo at /tmp/f and make nc listen at port 1234 of address 127.0.0.1 on ‘server’ side, when a ‘client’ establishes a connection successfully to that port, /bin/sh gets executed on ‘server’ side and the shell prompt is given to ‘client’ side.

# When connection is terminated, nc quits as well. Use -k if you want it keep listening, but if the command quits this option won't restart it or keep nc running. Also don't forget to remove the file descriptor once you do not need it anymore:
rm -f /tmp/f
#-------------------------------------------------------------------------------------#

#---------------------------------------#
# Bash/nc: netcat as a simple ftp server
#-------------------------------------------------------------------------------------#

## DATA TRANSFER
# The example in the previous section can be expanded to build a basic data transfer model.  Any information input into one end of the connection will be output to the other end, and input and output can be easily captured in order to emulate file transfer.

# Start by using nc to listen on a specific port, with output captured into a file:
nc -l 1234 > filename.out

# Using a second machine, connect to the listening nc process, feeding it the file which is to be transferred:
nc host.example.com 1234 < filename.in

# After the file has been transferred, the connection will close automatically.
#-------------------------------------------------------------------------------------#

#----------------------------------------#
# Bash/nc: netcat as a simple port scanner
#-------------------------------------------------------------------------------------#

## PORT SCANNING
# It may be useful to know which ports are open and running services on a target machine.  The -z flag can be used to tell nc to report open ports, rather than initiate a connection. Usually it's useful to turn on verbose output to stderr by use this option in conjunction with -v option.

# For example:
nc -zv host.example.com 20-30
           Connection to host.example.com 22 port [tcp/ssh] succeeded!
           Connection to host.example.com 25 port [tcp/smtp] succeeded!
# The port range was specified to limit the search to ports 20 - 30, and is scanned by increasing order.

# You can also specify a list of ports to scan, for example:
nc -zv host.example.com 80 20 22
           nc: connect to host.example.com 80 (tcp) failed: Connection refused
           nc: connect to host.example.com 20 (tcp) failed: Connection refused
           Connection to host.example.com port [tcp/ssh] succeeded!
	   # The ports are scanned by the order you given.

# Alternatively, it might be useful to know which server software is running, and which versions.  This information is often contained within the greeting banners. In order to retrieve these, it is necessary to first make a connection, and then break the connection when the banner has been retrieved. This can be accomplished by specifying a small timeout with the -w flag, or perhaps by issuing a "QUIT" command to the server:
echo "QUIT" | nc host.example.com 20-30
           SSH-1.99-OpenSSH_3.6.1p2
           Protocol mismatch.
220 host.example.com IMS SMTP Receiver Version 0.84 Ready
#-------------------------------------------------------------------------------------#

#--------------------------------------------#
# Bash/nc: netcat as a simple http/smtp client 
#-------------------------------------------------------------------------------------#

## TALKING TO SERVERS
# It is sometimes useful to talk to servers “by hand” rather than through a user interface. It can aid in troubleshooting, when it might be necessary to verify what data a server is sending in response to commands issued by the client. 
# For example, to retrieve the home page of a web site:
printf "GET / HTTP/1.0\r\n\r\n" | nc host.example.com 80

# Note that this also displays the headers sent by the web server. They can be filtered, using a tool such as sed(1), if necessary.

# More complicated examples can be built up when the user knows the format of requests required by the server. 
# As another example, an email may be submitted to an SMTP server using:
nc [-C] localhost 25 << EOF
           HELO host.example.com
           MAIL FROM:<[email protected]>
           RCPT TO:<[email protected]>
           DATA
           Body of email.
           .
           QUIT
           EOF
#-------------------------------------------------------------------------------------#
	   
	   
	   

nc -l 8762 < video.mpg  Client: nc server 8762 | mplayer -cache 1000 -
# Server: Poor man his video streaming service at video bitrate.

nc -zv 192.168.1.15 22
# Using netcat, you can check if a single or multiple or a range of open ports as follows. The command above will help us see if the port 22 is open on the host 192.168.56.10
# In the command above, the flag:
#    -z – sets nc to simply scan for listening daemons, without actually sending any data to them.
#    -v – enables verbose mode.

nc -zv 192.168.56.10 80 22 21
# The next command will check if ports 80, 22 and 21 are open on the remote host 192.168.5.10 (we can use the hostname as well)

nc -zv 192.168.56.10 20-80
# It is also possible to specify a range of ports to be scanned

nc -k -l 4444 
# Starts a WebSocket server and prints all requests to stdout 

nc -u -p 123 myrtle 56789 <<<"turtle" 
# Test a firewall rule on host 'myrtle' that is configured for traffic from udp source port 123.

# Fast portscanner via xargs
xargs -i -P 1200 nc -zvn {} 22 < textfile-with-hosts.txt

# Fast portscanner via Parallel
parallel -j200% -n1 -a textfile-with-hosts.txt nc -vz {} ::: 22

#==============================##==============================#
# CMD NC - netcat
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

30 - 🖥️ncat

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ncat command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███╗   ██╗ ██████╗ █████╗ ████████╗
#                ████╗  ██║██╔════╝██╔══██╗╚══██╔══╝
#                ██╔██╗ ██║██║     ███████║   ██║   
#                ██║╚██╗██║██║     ██╔══██║   ██║   
#                ██║ ╚████║╚██████╗██║  ██║   ██║   
#                ╚═╝  ╚═══╝ ╚═════╝╚═╝  ╚═╝   ╚═╝   
                

                                                 
# Connect mode (ncat is client) | default port is 31337
ncat <host> [<port>]

# Listen mode (ncat is server) | default port is 31337
ncat -l [<host>] [<port>]

# Transfer file (closes after one transfer)
ncat -l [<host>] [<port>] < file

# Transfer file (stays open for multiple transfers)
ncat -l --keep-open [<host>] [<port>] < file

# Receive file
ncat [<host>] [<port>] > file

# Brokering | allows for multiple clients to connect
ncat -l --broker [<host>] [<port>]

# Listen with SSL | many options, use ncat --help for full list
ncat -l --ssl [<host>] [<port>]

# Access control
ncat -l --allow <ip>
ncat -l --deny <ip>

# Proxying
ncat --proxy <proxyhost>[:<proxyport>] --proxy-type {http | socks4} <host>[<port>]

# Chat server | can use brokering for multi-user chat
ncat -l --chat [<host>] [<port>]

#==============================##==============================#
# CMD NCAT						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

31 - 🖥️netstat

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the netstat command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███╗   ██╗███████╗████████╗███████╗████████╗ █████╗ ████████╗
#                ████╗  ██║██╔════╝╚══██╔══╝██╔════╝╚══██╔══╝██╔══██╗╚══██╔══╝
#                ██╔██╗ ██║█████╗     ██║   ███████╗   ██║   ███████║   ██║   
#                ██║╚██╗██║██╔══╝     ██║   ╚════██║   ██║   ██╔══██║   ██║   
#                ██║ ╚████║███████╗   ██║   ███████║   ██║   ██║  ██║   ██║   
#                ╚═╝  ╚═══╝╚══════╝   ╚═╝   ╚══════╝   ╚═╝   ╚═╝  ╚═╝   ╚═╝   
                                                                             
                                                                             
                                                                          
# WARNING ! netstat is deprecated. Look below.

# To view which users/processes are listening to which ports:
sudo netstat -lnptu

# To view routing table (use -n flag to disable DNS lookups):
netstat -r

# Which process is listening to port <port>
netstat -pln | grep <port> | awk '{print $NF}'

Example output: 1507/python

# Fast display of ipv4 tcp listening programs
sudo netstat -vtlnp --listening -4

# WARNING ! netstat is deprecated.
# Replace it by:
ss

# For netstat-r
ip route

# For netstat -i
ip -s link

# For netstat-g
ip maddr

#==============================#
# CMD NETSTAT
#==============================##==============================#
# netstat option clusters that make words: German: -tulpen ; English: -plant ; American: -tupac ; Spanish: -puta ; French: -salope

netstat -rn | sort | less
#

netstat -lepunt
# Show the TCP and UDP ports being listened on and if you are root, also show the process associated, user, etc.

# netstat option clusters that make words: German: -tulpen ; English: -plant ; American: -tupac ; Spanish: -puta ; French: -salope

netstat -b -o 5
#	-b attribute: displays the exec	utable involved in creating each connection or listening port.
# 	-o attribute: displays the owning process id associated with each connection.
# 	   integer:  An integer used to display results multiple times with specified number of seconds between displays. It continues until stopped by command ctrl+c.

netstat -b -o 5>>ausgabe.txt
#

netstat -at
# Listing TCP Ports connections (Transmission Control Protocol) port connections 

netstat -au
# Listing UDP Ports connections (User Datagram Protocol ) port connections 

netstat -l
# Listing all active listening ports connections

netstat -lt
# Listing all active listening TCP ports

netstat -lu
# Listing all active listening UDP ports

netstat -lx
# Listing all active UNIX listening ports

netstat -s
# Displays statistics by protocol. By default, statistics are shown for the TCP, UDP, ICMP, and IP protocols. The -s parameter can be used to specify a set of protocols.

netstat -st
# Showing statistics of only TCP protocol

netstat -su
# Showing Statistics by UDP Protocol

netstat -ac 5 | grep tcp
# Displaying Promiscuous mode with -ac switch, netstat print the selected information or refresh screen every five second. Default screen refresh in every second

netstat -r
# Display Kernel IP routing table with netstat and route command

netstat -i
# Showing network interface packet transactions including both transferring and receiving packets with MTU size.

netstat -ie
# Showing Kernel interface table, similar to ifconfig command.

netstat -g
# Displays multicast group membership information for both IPv4 and IPv6.

netstat -c
# To get netstat information every few second, then use the following command, it will print netstat information continuously, say every few seconds.

netstat -ap | grep http
# Find out how many listening programs running on a port

netstat --statistics --raw
# Displaying RAW Network Statistics

# Netstat with examples
###########################

# Checking all connections -> To list out all the connections on a system, we can use ‘a’ option with netstat command, This will produce all tcp, udp & unix connections from the system.
netstat -a

# Checking all tcp or udp or unix socket connections -> To list only the tcp connections our system, use ‘t’ options with netstat,
netstat -at

# Similarly to list out only the udp connections on our system, we can use ‘u’ option with netstat,
netstat -au

# To only list out Unix socket connections, we can use ‘x’ options,
netstat -ax

 

# List process id/Process Name with -> To get list of all connections along with PID or process name, we can use ‘p’ option & it can be used in combination with any other netstat option,
netstat -ap

 

# List only port number & not the name -> To speed up our output, we can use ‘n’ option as it will perform any reverse lookup & produce output with only numbers. Since no lookup is performed, our output will much faster.
netstat -an

 

# Print only listening ports -> To print only the listening ports , we will use ‘l’ option with netstat. It will not be used with ‘a’ as it prints all ports,
netstat -l

 

# Print network stats -> To print network statistics of each protocol like packet received or transmitted, we can use ‘s’ options with netstat,
netstat -s

 

# Print interfaces stats -> To display only the statistics on network interfaces, use ‘I’ option,
netstat -i

# Display multicast group information -> With option ‘g’ , we can print the multicast group information for IPV4 & IPV6,
netstat -g

 

# Display the network routing information -> To print the network routing information, use ‘r’ option,
netstat -r

 

# Continuous output -> To get continuous output of netstat, use ‘c’ option
netstat -c

 

# Filtering a single port -> To filter a single port connections, we can combine ‘grep’ command with netstat,
netstat -anp | grep 3306

 

# Count number of connections -> To count the number of connections from port, we can further add ‘wc’ command with netstat & grep command, This will print the number of connections for the port mysql port i.e. 3306.
netstat -anp | grep 3306 | wc -l

# Kill all processes that listen to ports begin with 50 (50, 50x, 50xxx,...) -> Run netstat as root (via sudo) to get the ID of the process listening on the desired socket. Use awk to 1) match the entry that is the listening socket, 2) matching the exact port (bounded by leading colon and end of column), 3) remove the trailing slash and process name from the last column, and finally 4) use the system(…) command to call kill to terminate the process. Two direct commands, netstat & awk, and one forked call to kill. This does kill the specific port instead of any port that starts with 50. I consider this to be safer.
netstat -plnt | awk '($4 ~ /:50$/){sub(/\/.*/, "", $7); system("sudo kill " $7)}'

# Kill all processes that listen to ports begin with 50 (50, 50x, 50xxx,...)
netstat -plnt | grep :50 | awk '{print $7}' | awk -F/ '{print $1}' | xargs kill -9

# Verbindungen auf oldproxy überprüfen
netstat -ant 'awk '{print $6} | sort | uniq -c | sort

netstat -lepunt 
# Show the TCP and UDP ports being listened on and if you are root, also show the process associated, user, etc.

# Displays the quantity of connections to port 80 on a per IP basis
clear;while x=0; do clear;date;echo "";echo "  [Count] | [IP ADDR]";echo "-------------------";netstat -np|grep :80|grep -v LISTEN|awk '{print $5}'|cut -d: -f1|uniq -c; sleep 5;done
# Explanation: Uses an infinite loop to display output from netstat, reformatted with grep, awk, and cut piped into uniq to provide the count. Complete with a pretty header. Polls every 5 seconds

# Get mac address from default interface OS X
netstat -rn | awk '/default/ { print $NF }' | head -1 | xargs -I {}  ifconfig {} | awk '/ether/ {print $2}'
# Explanation: netstat -rn -> get routing table awk '/default/ { print $NF }' -> grep the default routes head -1 -> limit to the first result (is also the interface with the highest priority xargs -I {} ifconfig {} -> use the result to get data from ifconfig awk '/ether/ {print $2}' ->grep the mac address.
# Limitations: Tested on OSX.

# Below is an Unix command to list all the IP addresses connected to your server on port 80.
netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head

# Explanation: This command is useful to detect if your server is under attack, and null route those IPs. Read this null route attacker IP story. Source: https://www.mkyong.com/linux/list-all-ip-addresses-connected-to-your-server/ Output:
	# 97 114.198.236.100
	# 56 67.166.157.194
	# 44 170.248.43.76
	# 38 141.0.9.20
	# 37 49.248.0.2
	# 37 153.100.131.12
	# 31 223.62.169.73
	# 30 65.248.100.253
	# 29 203.112.82.128
	# 29 182.19.66.187
# Limitations: I think netstat is not a default package on Debian Stretch. You have to install net-tools: apt-get install net-tools

netstat -tlpn
# Show which programs are listening on TCP ports Alternative: ss -tlpn Show Sample Output:
        # Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
        # tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      14139/nginx -g daem
        # tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      14139/nginx -g daem

# List IP addresses connected to your server on port 80
netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head

# Which processes are listening on a specific port (e.g. port 80)
netstat -nap|grep 80|grep LISTEN

# Which processes are connected on a specific port (e.g. port 443)
netstat -nap|grep 443 |grep ESTABLISHED

#==============================##==============================#
# CMD NETSTAT						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

32 - 🖥️ngrep

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ngrep command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███╗   ██╗ ██████╗ ██████╗ ███████╗██████╗ 
#                ████╗  ██║██╔════╝ ██╔══██╗██╔════╝██╔══██╗
#                ██╔██╗ ██║██║  ███╗██████╔╝█████╗  ██████╔╝
#                ██║╚██╗██║██║   ██║██╔══██╗██╔══╝  ██╔═══╝ 
#                ██║ ╚████║╚██████╔╝██║  ██║███████╗██║     
#                ╚═╝  ╚═══╝ ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═╝     
                                                           
                                                           
                                                          

ngrep -d eth0 -i 'select' port 3306
# Show the query and results of 'select' queries going to your mysql server. Won not work on socket conns

#==============================##==============================#
# CMD NGREP						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

33 - 🖥️nmcli

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the nmcli command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███╗   ██╗███╗   ███╗ ██████╗██╗     ██╗
#                ████╗  ██║████╗ ████║██╔════╝██║     ██║
#                ██╔██╗ ██║██╔████╔██║██║     ██║     ██║
#                ██║╚██╗██║██║╚██╔╝██║██║     ██║     ██║
#                ██║ ╚████║██║ ╚═╝ ██║╚██████╗███████╗██║
#                ╚═╝  ╚═══╝╚═╝     ╚═╝ ╚═════╝╚══════╝╚═╝
                                                        
                                                        
                                                       
# Desc: Command line interface to NetworkManager

# Connect to a wireless access point - Parameters:
# 	<wiface> -- the name of your wireless interface
#	<ssid> -- the SSID of the access point
#	<pass> -- the WiFi password
nmcli d wifi connect <ssid> password <pass> iface <wiface>

# Disconnect from WiFi - Parameters:
#	<wiface> -- the name of your wireless interface
nmcli d wifi disconnect iface <wiface>

# Get WiFi status (enabled / disabled)
nmcli radio wifi

# Enable / Disable WiFi
nmcli radio wifi <on|off>

# Show all available WiFi access points
nmcli dev wifi list

# Refresh the available WiFi connection list
nmcli dev wifi rescan

# Show all available connections
nmcli con

# Show only active connections
nmcli con show --active

# Review the available devices
nmcli dev status

# Add a dynamic ethernet connection - parameters:
#	<name> -- the name of the connection
#	<iface_name> -- the name of the interface
ncmli con add type ethernet con-name <name> ifname <iface_name>

# Bring up the ethernet connection
nmcli con up <name>

################################

# connection profiles. We find them in /etc/sysconfig/network-scripts directory.
# ifcfg-static1  und ifcfg-Myoffice1

# We realize that some properties have different values and some others don’t exist if it isn’t necessary. Let’s have a quick look to most important of them.
#    TYPE, we have ethernet type here. We could have wifi, team, bond and others.
#    DEVICE, the name of the network device which is associated with this profile.
#    BOOTPROTO, if it has value “dhcp” then our connection profile takes dynamic IP from dhcp server, if it has value “none” then it takes no dynamic IP and probably whe assign a static IP.
#    IPADDR, is the static IP we assign to our profile.
#    PREFIX, the subnet mask. A value of 24 means 255.255.255.0. You can understand better the subnet mask if you write down its binary format. For example values of 16, 24, 26 means that the first 16, 24 or 26 bits respectively are 1 and the rest 0, defining exactly what the network address is and what is the range of ip which can be assigned.
#    GATEWAY, the gateway IP.
#    DNS1, DNS2, two dns servers we want to use.
#    ONBOOT, if it has value “yes” it means, that on boot our computer will read this profile and try to assign it to its device.
  
 
nmcli con show -a
# check our connections - equal command: nmcli connection show - nmcli con show - nmcli c s 

ip a
# ip addr off devices

nmcli con add type ethernet con-name dhcp1 ifname eth0
# We can make our first connection profile. The minimum properties we must define are type, ifname and con-name:
#    type – for the type of connection.
#    ifname – for the device name which is assigned our connection.
#    con-name – for the connection name.

    
    
    
nmcli con add type ethernet con-name static2 ifname enp0s3 ip4 192.168.1.50/24 gw4 192.168.1.1
# Let us make a new Ethernet connection profile with name static2, which will be assigned to device enp0s3, with static IP 192.168.1.50, subnet mask 255.255.255.0=24 and gateway 192.168.1.1.

nmcli con mod static2 ipv4.dns "8.8.8.8 8.8.4.4"
# Let us modify the last connection profile and add two dns servers.

nmcli con down static1 ; nmcli con up static2
# Now let us bring up this connection profil

nmcli con mod static2 connection.autoconnect no
# If you do not want your connection profile to autoconnect

nmcli con mod static2 connection.permissions otto
# We let only user otto to use this profile

nmcli con mod static2 connection.permissions user:otto,john
# If you want to give permissions to more than one users, you must type user:user1,user2 without blank space between them

nmcli device wifi list
# Show a prettified list of nearby wireless APs

#==============================##==============================#
# CMD NMCLI						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

34 - 🖥️nping

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the nping command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ███╗   ██╗██████╗ ██╗███╗   ██╗ ██████╗ 
#  ████╗  ██║██╔══██╗██║████╗  ██║██╔════╝ 
#  ██╔██╗ ██║██████╔╝██║██╔██╗ ██║██║  ███╗
#  ██║╚██╗██║██╔═══╝ ██║██║╚██╗██║██║   ██║
#  ██║ ╚████║██║     ██║██║ ╚████║╚██████╔╝
#  ╚═╝  ╚═══╝╚═╝     ╚═╝╚═╝  ╚═══╝ ╚═════╝ 

# To perform a TCP connect() (handshake) with a host
nping --tcp-connect [target host]

# To perform a TCP connect() 
nping --tcp-connect [target host] [target host] [target host] 

# To attempt a TCP handshake on a port range (1-80)
nping --tcp-connect [target host] -p1-80 -c 1

# To send a UDP packet with 50 bytes of random data (to port 53 in this example)
nping --udp [target host] -p 53 --data-length 100

# Send 500 TCP packets at a rate of 50 packets per second
nping --tcp [target host] --rate 50 -c 500

# To send an ARP request to a particular host
ping --arp [target host] 

# To send ARP requests to all hosts in the 192.168.1.0/24 network
nping --arp 192.168.1.0/24 

# To send an ICMP echo request
nping [target host] --icmp --icmp-type echo 

# To send an ICMP echo reply
nping google.com --icmp --icmp-type echo-reply

# To send a packet with a bad checksum from port 1221 to port 80
nping --udp --badsum --source-port 1221 -p 80 [target host]

# To toggle how verbose the output should be, simply append '-v ' followed by an integer between -4 (no output) and 4 (very verbose)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

35 - 🖥️nslookup

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the nslookup command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#      ███╗   ██╗███████╗██╗      ██████╗  ██████╗ ██╗  ██╗██╗   ██╗██████╗ 
#      ████╗  ██║██╔════╝██║     ██╔═══██╗██╔═══██╗██║ ██╔╝██║   ██║██╔══██╗
#      ██╔██╗ ██║███████╗██║     ██║   ██║██║   ██║█████╔╝ ██║   ██║██████╔╝
#      ██║╚██╗██║╚════██║██║     ██║   ██║██║   ██║██╔═██╗ ██║   ██║██╔═══╝ 
#      ██║ ╚████║███████║███████╗╚██████╔╝╚██████╔╝██║  ██╗╚██████╔╝██║     
#      ╚═╝  ╚═══╝╚══════╝╚══════╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝ ╚═════╝ ╚═╝     
                                                                                     
                                                                                 
																											
#==============================#
# CMD NSLOOKUP
#==============================##==============================#
nslookup www.example.com 192.168.1.254

nslookup -q=txt -class=CHAOS version.bind NS.PHX5.NEARLYFREESPEECH.NET
# Check version of DNS Server

busybox nslookup www.example.com 192.168.1.254

nslookup -q=TXT _netblocks.google.com | grep -Po '\b([0-1]?\d{1,2}|2[0-4]\d|25[0-5])(\.([0-1]?\d{1,2}|2[0-4]\d|25[0-5])){3}(/\d{1,2})\b'
# get all Google ipv4 subnets for a iptables firewall for example

nslookup -q=TXT _netblocks.google.com | grep -Eo 'ip4:([0-9\.\/]+)' | cut -d: -f2
# get all Google ipv4 subnets for a iptables firewall for example a bit shorter, parenthesis not needed but added for clarity 

#==============================##==============================#
# CMD NSLOOKUP
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

36 - 🖥️ping

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ping command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗ ██╗███╗   ██╗ ██████╗ 
#                ██╔══██╗██║████╗  ██║██╔════╝ 
#                ██████╔╝██║██╔██╗ ██║██║  ███╗
#                ██╔═══╝ ██║██║╚██╗██║██║   ██║
#                ██║     ██║██║ ╚████║╚██████╔╝
#                ╚═╝     ╚═╝╚═╝  ╚═══╝ ╚═════╝ 

                                              
# ping a host with a total count of 15 packets overall.    
ping -c 15 www.example.com

# ping a host with a total count of 15 packets overall, one every .5 seconds (faster ping). 
ping -c 15 -i .5 www.example.com

# test if a packet size of 1500 bytes is supported (to check the MTU for example)
ping -s 1500 -c 10 -M do www.example.com

#==============================#
# CMD PING 
#==============================##==============================#
ping -n -c1 -Mdo -s 1472 172.17.1.2

ping -i 60 -a www.google.com
# Give an audible sound as soon as the server comes live.

ping -c100 4.2.2.2 | sponge | pee head tail 
# The pee command can run head and tail on same input. sponge waits for all the data first.

# Assuming my network is 10.10.0.0/24, if i run a ping on the broadcast address like
ping -c 5 -b 10.10.0.255 | grep 'bytes from' | awk '{ print $4 }' | sort | uniq

# Also using the "ping the broadcast address" method pointed out by chburd, this pipe should do the trick for you:
ping -c 5 -b 10.11.255.255 | sed -n 's/.* \([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/p' | sort | uniq

# Generating list of IP addresses and ping
for ip in 192.168.1.{1..10}; do ping -c 1 -t 1 $ip > /dev/null && echo "${ip} is up"; done
	oder
for i in {1..254} ;do (ping 192.168.1.$i -c 1 -w 5  >/dev/null && echo "192.168.1.$i" &) ;done

# Ping mit echo
ping -c 1 -t 1 192.168.1.1 && echo "192.168.1.1 is up!"

# oder ping mit exit code der variablen $?
ping -c 1 -t 1 192.168.1.1;
if [ $? -eq 0 ]; then
    echo "192.168.1.1 is up";
else 
    echo "ip is down";
fi

# Hiding ping output
ping -c 1 -t 1 192.168.1.1 > /dev/null && echo "IP is up"
	IP is up

# Add timestamp to the output of ping
ping some_host | while read LINE; do echo $(date): $LINE; done
# Explanation: The while loop reads the output of ping line by line, and echoes it back with $(date) prepended.

mtr google.com
# Most of us are familiar with ping and traceroute. How about combining the functionality of both the command into one with mtr command.

mping(){ ping $@|awk -F[=\ ] '/time=/{t=$(NF-1);f=2000-14*log(t^18);c="play -q -n synth 1 pl "f"&";print $0;system(c)}';}
# mping yahoo\.com or mping any other number of IPs that have various ping times. Try mping 127.0.0.1 vs. mping your gateway IP.

arping 10.0.8.5
# Like ping, but it uses an ARP request to check, which gets around host firewalls blocking ICMP. Only works on same subnet

#==============================##==============================#
# CMD PING 
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

37 - 🖥️ping6

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ping6 command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗ ██╗███╗   ██╗ ██████╗  ██████╗ 
#                ██╔══██╗██║████╗  ██║██╔════╝ ██╔════╝ 
#                ██████╔╝██║██╔██╗ ██║██║  ███╗███████╗ 
#                ██╔═══╝ ██║██║╚██╗██║██║   ██║██╔═══██╗
#                ██║     ██║██║ ╚████║╚██████╔╝╚██████╔╝
#                ╚═╝     ╚═╝╚═╝  ╚═══╝ ╚═════╝  ╚═════╝ 
                

                                                      
# get all ipv6 neighbors via broadcast ping
ping6 -I eth0 ff02::1

#==============================##==============================#
# CMD PING6						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

38 - 🖥️postfix

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the postfix command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗  ██████╗ ███████╗████████╗███████╗██╗██╗  ██╗
#                ██╔══██╗██╔═══██╗██╔════╝╚══██╔══╝██╔════╝██║╚██╗██╔╝
#                ██████╔╝██║   ██║███████╗   ██║   █████╗  ██║ ╚███╔╝ 
#                ██╔═══╝ ██║   ██║╚════██║   ██║   ██╔══╝  ██║ ██╔██╗ 
#                ██║     ╚██████╔╝███████║   ██║   ██║     ██║██╔╝ ██╗
#                ╚═╝      ╚═════╝ ╚══════╝   ╚═╝   ╚═╝     ╚═╝╚═╝  ╚═╝
                                                                     
                                                                    

rspamd Doku nur online -> rspamd.conf

postfix flush
# führt arbeitet die mailq sofort ab 

postmap virtual 
# nimmt die virtual sofort in config auf

/home/sglatt/deploy/settings.map
Uploading Files: 	=	header_checks
DST			=	/etc/postfix
CMD			= 	cd /etc/postfix   
				postfix reload
				exit

# Whitelisting
#--------------#	
-> Auf den BlacklistSeiten kann beantragt werden das die Seite gelöscht wird
-> Wenn False Positiv: score29 -> nicht @xyz.de (Domain bassiert)
-> Wenn include encoded ZIP -> Security -> NoAV

# Blacklisting
#----------------#

Postfix Blacklist:
Spamhouse, Manitu

# Was tun wenn email.... 
#-----------------------#

auf Blackliste:
-> Nach 12h automatisch gelöscht wenn auf Blacklist 
-> Kontrolle auf kloth.net

keine Mails mehr von innerhalb:
mx01 (bestimmte Domains)
sonst LB (mx1 mx2 mx3) => smtpout.lxu.io

# redis-cli  -> rspamd infos
#-------------------#
rspamd muss immer laufen, da sonst kein Virenschutz - kann aber gestopt werden und sollte dann ohne Virenschutz funktionieren

redis-cli	# startet cli
-> info memory	# Memory Infos

#==============================##==============================#
# CMD POSTFIX						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

39 - 🖥️redis

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the redis command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ██████╗ ███████╗██████╗ ██╗███████╗
#  ██╔══██╗██╔════╝██╔══██╗██║██╔════╝
#  ██████╔╝█████╗  ██║  ██║██║███████╗
#  ██╔══██╗██╔══╝  ██║  ██║██║╚════██║
#  ██║  ██║███████╗██████╔╝██║███████║
#  ╚═╝  ╚═╝╚══════╝╚═════╝ ╚═╝╚══════╝

# redis
# Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker

# connect to redis server (port 6397)
nc localhost 6397

# Connect to the local server using redis-cli:
redis-cli

# See also:
#   redis cheat sheets at /redis/
#   list of pages:      /redis/:list
#   search in pages:    /mongo/~keyword
#   redis-cli usage at  /redis-cli
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

40 - 🖥️redis-cli

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the redis-cli command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ██████╗ ███████╗██████╗ ██╗███████╗       ██████╗██╗     ██╗
#  ██╔══██╗██╔════╝██╔══██╗██║██╔════╝      ██╔════╝██║     ██║
#  ██████╔╝█████╗  ██║  ██║██║███████╗█████╗██║     ██║     ██║
#  ██╔══██╗██╔══╝  ██║  ██║██║╚════██║╚════╝██║     ██║     ██║
#  ██║  ██║███████╗██████╔╝██║███████║      ╚██████╗███████╗██║
#  ╚═╝  ╚═╝╚══════╝╚═════╝ ╚═╝╚══════╝       ╚═════╝╚══════╝╚═╝

# redis-cli
# Opens a connection to a Redis server.

# Connect to the local server:
redis-cli

# Connect to a remote server on the default port (6379):
redis-cli -h host

# Connect to a remote server specifying a port number:
redis-cli -h host -p port

# Specify a password:
redis-cli -a password

# Execute Redis command:
redis-cli redis_command

# List Redis keys with prefix "prefix:"
redis-cli KEYS "prefix:*"

# Delete Redis key abc
redis-cli DEL abc
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

41 - 🖥️route

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the route command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗  ██████╗ ██╗   ██╗████████╗███████╗
#                ██╔══██╗██╔═══██╗██║   ██║╚══██╔══╝██╔════╝
#                ██████╔╝██║   ██║██║   ██║   ██║   █████╗  
#                ██╔══██╗██║   ██║██║   ██║   ██║   ██╔══╝  
#                ██║  ██║╚██████╔╝╚██████╔╝   ██║   ███████╗
#                ╚═╝  ╚═╝ ╚═════╝  ╚═════╝    ╚═╝   ╚══════╝
                                                           
                

# To display routing table IP addresses instead of host names:
route -n

# To add a default gateway:
route add default gateway 192.168.0.1

# To add the normal loopback entry, using netmask 255.0.0.0 and associated with the "lo" device (assuming this device was previously set up correctly with ifconfig(8)).
route add -net 127.0.0.0 netmask 255.0.0.0 dev lo

# To add a route to the local network 192.56.76.x via "eth0".  The word "dev" can be omitted here.
route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0

# To delete the current default route, which is labeled "default" or 0.0.0.0 in the destination field of the current routing table.
route del default

# To add a default  route (which will be used if no other route matches).  All packets using this route will be gatewayed through "mango-gw". The device which will actually be used for that route depends on how we can reach "mango-gw" - the static route to "mango-gw" will have to be set up before.
route add default gw mango-gw

# To add the route to the "ipx4" host via the SLIP interface (assuming that "ipx4" is the SLIP host).
route add ipx4 sl0

# To add the net "192.57.66.x" to be gateway through the former route to the SLIP interface.
route add -net 192.57.66.0 netmask 255.255.255.0 gw ipx4

# To install a rejecting route for the private network "10.x.x.x."
route add -net 10.0.0.0 netmask 255.0.0.0 reject

# This is an obscure one documented so people know how to do it. This sets all of the class D (multicast) IP routes to go via "eth0". This is the correct normal configuration line with a multicasting kernel
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0

# route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.254
route add -net $destination gw $gateway

# add route default gateway on shell # route add default gateway
route add default gw 192.168.10.1 
        #//OR// 
ip route add default via 192.168.10.1 dev eth0 
        # //OR// 
ip route add default via 192.168.10.1

#Delete current default gw
route del default gw 192.168.1.1 eth0

#Add default gw
route add default gw 192.168.1.1 eth0
ip route add default via 192.168.1.254
/etc/init.d/networking restart

#==============================##==============================#
# CMD ROUTE						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

42 - 🖥️rsync

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the rsync command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗ ███████╗██╗   ██╗███╗   ██╗ ██████╗
#                ██╔══██╗██╔════╝╚██╗ ██╔╝████╗  ██║██╔════╝
#                ██████╔╝███████╗ ╚████╔╝ ██╔██╗ ██║██║     
#                ██╔══██╗╚════██║  ╚██╔╝  ██║╚██╗██║██║     
#                ██║  ██║███████║   ██║   ██║ ╚████║╚██████╗
#                ╚═╝  ╚═╝╚══════╝   ╚═╝   ╚═╝  ╚═══╝ ╚═════╝
                

                                                           
# To copy files from remote to local, maintaining file properties and sym-links (-a), zipping for faster transfer (-z), verbose (-v).  
rsync -avz host:file1 :file1 /dest/
rsync -avz /source host:/dest

# Copy files using checksum (-c) rather than time to detect if the file has changed. (Useful for validating backups). 
rsync -avc /source/ /dest/

# Copy contents of /src/foo to destination:

# This command will create /dest/foo if it does not already exist
rsync -auv /src/foo /dest

# Explicitly copy /src/foo to /dest/foo
rsync -auv /src/foo/ /dest/foo

#==============================#
# CMD rsync
#==============================##==============================#
rsync --bwlimit=200 src dest 
# Do an rsync and limit the bandwidth used to about 200 KBytes/sec. Useful on shared or slow links.

rsync -aqzH (public mirror that supports rsync).???::CentOS /path/to/locate/mirror 
# Build a private mirror of the public mirror. 

rsync -a -delete empty/ foo/
# Apparently according to testing, this is the fastest way to delete millions of small files. Apparently the fastest way to delete millions of small files. http://bit.ly/1fnUVIl 

# Backup pictures while on travel, but exclude larger RAW images for now.
rsync -zav -e ssh . user@remote:europe-backup/ --exclude='*.CR2' 

# Examples for Rsync
######################## 
# It is secure & faster than scp & can also be used in place of scp command to copy files/directories to remote host. 
# Syntax for using rsync is
rsync options source destination

# Rsync’s main function, on the other hand is basically to synchronize files/directories either on local host or on remote host. Rsync initially copies whole directory & then copies newly added files (differential backup) rather than copying whole directory again.

rsync –azvh /datafile [email protected]:/home/susan
# here, option r is archive mode which allows copying of files recursively along with their file permissions, symbolic links etc,
# Second option r is used to compress file data,
# third option h will provide human readable outputs,
# and option v will provide debugging information which can help in diagnosing a problem related to connection, authentication etc,
# Also, we can mention alocal location like /home/dan in place of [email protected]:/home/susan

# Use rsync instead of cp to get a progress indicator when copying large files
rsync --progress largefile.gz somewhere/else/
# Explanation: Although rsync is famous for synchronizing files across machines, it also works locally on the same machine. And although the cp command does not have progress indicator, which can be annoying when copying large files, but rsync does have it, so there you go.
# Limitations: When copying directories be careful that the meaning of a trailing slash when specifying directories can be slightly different from cp.

rsync -azvh – -progress [email protected]:/home/susan /datafile
# above example will let us synchronize a directory from remote location to local host directory & –progress will show us the progress of file/directory transfer.

rsync –avzhe ssh /datafile [email protected]:/home/susan
# this example will let us use rsync over ssh and option –e here is used to define a protocol , which is this case is ssh.

rsync –avzhe ‘ssh –p 300’ /datafile [email protected]:/home/susan
# here, this example will let us use rsync over ssh with modified port.

rsync -azvh – -progress –include ‘A*’ –exclude ‘*’ [email protected]:/home/susan /datafile
# this will let us copy all files starting with “A” & will exclude all other files.

rsync -av --progress Music user@remote: 
# Don't just sit there wondering about the status of your data transfer, use --progress

rsync -av . "$OLDPWD"/ 
# Copy the new/changed files in the current directory to the directory you were previously in.

# Backup with versioning
& 'C:\cwRsync_5.5.0_x86_Free\bin\rsync.exe' --force --ignore-errors --no-perms --chmod=ugo=rwX --checksum --delete --backup --backup-dir="_EVAC/$(Get-Date -Format "yyyy-MM-dd-HH-mm-ss")" --whole-file -a -v "//MyServer/MyFolder" "/cygdrive/c/Backup"

# Rsync using SSH and outputing results to a text file  --delete will delete copies on remote to match local if deleted on local --stats will output the results -z zip -a archive -A preserve ACL -x don't cross filesystem boundaries -h human readable -e specify the remote shell to use
rsync --delete --stats -zaAxh -e ssh /local_directory/ username@IP_of_remote:/Remote_Directory/ > /Text_file_Directory/backuplog.txt

# rsync should continue even if connection lost - Manage partial uploads using append option.
rsync --archive --recursive --compress --partial --progress --append [email protected]:/backup/somefile.txt.bz2 /home/ubuntu/

# rsync using pem file - Especially useful while syncing to Amazon EC2 instance. avz stands for archive verbose compress
rsync -e 'ssh -i /root/my.pem' -avz /mysql/db/data_summary.* ec2-1-2-4-9.compute-1.amazonaws.com:/mysql/test/

#==============================##==============================#
# CMD RSYNC						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

43 - 🖥️scp

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the scp command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███████╗ ██████╗██████╗ 
#                ██╔════╝██╔════╝██╔══██╗
#                ███████╗██║     ██████╔╝
#                ╚════██║██║     ██╔═══╝ 
#                ███████║╚██████╗██║     
#                ╚══════╝ ╚═════╝╚═╝     
                

# To copy a file from your local machine to a remote server:
scp foo.txt [email protected]:remote/dir

# To copy a file from a remote server to your local machine:
scp [email protected]:remote/dir/foo.txt local/dir

#==============================#
# CMD SCP
#==============================##==============================#
scp -vvv
# Remember, if something isn not working, there is a reason and you can often find that reason using more -v options (or strace)

scp(){ [[ "$@" =~ : ]] && /usr/bin/scp "$@" || echo 'You forgot the colon!'; }
# Wrapper function to catch a common scp mistake.

scp(){ [[ "$@" =~ : ]] && /usr/bin/scp "$@" || echo 'You forgot the colon!'; }
# Wrapper function to catch a common scp mistake.

scp -vvv
# Remember, if something isn not working, there is a reason and you can often find that reason using more -v options (or strace)

scp ./file:with:colons.txt user@otherhost: 
# Filename with colons giving you problems with scp or rsync? Use the ./ path prefix B4 filename.

scp source_file_name username@destination_host:destination_folder
#    The “-p” parameter will help you on this. An estimated time and the connection speed will appear on the screen.
#    You can use “-v” parameter to print debug information into the screen. 
#         It can help you debugging connection, authentication and configuration problems.
#    The “-C” parameter will compress your files on the go

scp -r documents [email protected]:.
# Sometimes we need to copy directory and all files / directories inside it. It will be better if we can do it in 1 command. SCP support that scenario using “-r” parameter. When the copy process is done, at the destination server you will found a directory named “documents” with all it’s files. The folder “documents” is automatically created.

# Examples for scp
######################## 
# scp is based on ssh & is used to transfer file from local host to remote host securely.  
# Syntax for using scp is
scp source_file_name username@destination_host:destination_folder

scp –rpv /datafile [email protected]:/home/susan
# here, option r is used when we are copying a directory with all the files inside it,
# secondly option p will provide an estimate time & connection speed,
# and option v will provide debugging information which can help in diagnosing a problem related to                              connection, authentication etc.

scp –C /datafile [email protected]:/home/susan
# option C here will compress the file on the go & will reproduce the same file when it arrives at the destination. Thus saving time consumed for copying the file.

scp –P 300 /datafile [email protected]:/home/susan
# here option –P is used to define a custom port incase we are not using default ssh port (22).

 
#==============================##==============================#
# CMD SCP
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

44 - 🖥️snmpwalk

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the snmpwalk command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███████╗███╗   ██╗███╗   ███╗██████╗ ██╗    ██╗ █████╗ ██╗     ██╗  ██╗
#                ██╔════╝████╗  ██║████╗ ████║██╔══██╗██║    ██║██╔══██╗██║     ██║ ██╔╝
#                ███████╗██╔██╗ ██║██╔████╔██║██████╔╝██║ █╗ ██║███████║██║     █████╔╝ 
#                ╚════██║██║╚██╗██║██║╚██╔╝██║██╔═══╝ ██║███╗██║██╔══██║██║     ██╔═██╗ 
#                ███████║██║ ╚████║██║ ╚═╝ ██║██║     ╚███╔███╔╝██║  ██║███████╗██║  ██╗
#                ╚══════╝╚═╝  ╚═══╝╚═╝     ╚═╝╚═╝      ╚══╝╚══╝ ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝
                                                                                       
                                                                                       
                                                                                       
# To retrieve all of the variables under system for host zeus
snmpwalk -Os -c public -v 1 zeus system

# To retrieve the scalar values, but omit the sysORTable for host zeus
snmpwalk -Os -c public -v 1 -CE sysORTable zeus system

snmpwalk -h |& grep OID 
# Some commands send their help output to STDERR, Using |& in BASH 4+ sends STDERR to STDIN of next command.

# Abfrage des Switches mit v1
snmpwalk -Os -c COMMUNITYPASS -v 1 10.141.4.7

#==============================##==============================#
# CMD SNMPWALK						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

45 - 🖥️socat

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the socat command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███████╗ ██████╗  ██████╗ █████╗ ████████╗
#                ██╔════╝██╔═══██╗██╔════╝██╔══██╗╚══██╔══╝
#                ███████╗██║   ██║██║     ███████║   ██║   
#                ╚════██║██║   ██║██║     ██╔══██║   ██║   
#                ███████║╚██████╔╝╚██████╗██║  ██║   ██║   
#                ╚══════╝ ╚═════╝  ╚═════╝╚═╝  ╚═╝   ╚═╝   
                                                          
                

socat "UNIX-LISTEN:/tmp/mysqld.temp.sock,reuseaddr,fork" EXEC:"ssh [email protected] socat STDIO UNIX-CONNECT\:/var/run/mysqld/mysqld.sock"
# Linux socket-to-socket tunnel (MySQL example)

socat "UNIX-LISTEN:/tmp/mysqld.temp.sock,reuseaddr,fork" EXEC:"ssh [email protected] -i /home/user/rsa-keys/id_rsa socat STDIO UNIX-CONNECT\:/var/run/mysqld/mysqld.sock"
# Will not work with password login. You must add your RSA key to the server his authorizedkeys file, or change the ssh command adding the -i option for a custom RSA key. /tmp/mysqld.temp.sock will be created locally by socat, don't create it yourself. The folder it lives must be writable. Connect your MySQL client to this socket, with database and username set properly.

socat -d -d TCP-L:22,reuseaddr,fork SYSTEM:"nc \$SOCAT_PEERADDR 22" 
# Confuse people SSHing to your host with a redirect back to theirs.

socat -v UDP-LISTEN:8161,fork TCP:localhost:8161 
# Encapsulate UDP packets in a TCP stream so it can be tunneled through an SSH tunnel, etc

#==============================##==============================#
# CMD SOCAT						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

46 - 🖥️ss

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ss command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███████╗███████╗
#                ██╔════╝██╔════╝
#                ███████╗███████╗
#                ╚════██║╚════██║
#                ███████║███████║
#                ╚══════╝╚══════╝
                                

# The 'ss' stands for socket statistics. The command investigates the socket and shows information similar to netstat command. It can display more TCP and state informations than other tools.
                                
# Utility to investigate sockets

Args
-4/-6 list ipv4/ipv6 sockets
-n numeric addresses instead of hostnames
-l list listing sockets
-u/-t/-x list udp/tcp/unix sockets
-p Show process(es) that using socket

# show all listing tcp sockets including the corresponding process
ss -tlp

# show all sockets connecting to 192.168.2.1 on port 80
ss -t dst 192.168.2.1:80

# show all ssh related connection
ss -t state established '( dport = :ssh or sport = :ssh )'

# Display timer information
ss -tn -o

# Filtering connections by tcp state
ss -t4 state established

#Find all clients connected to HTTP or HTTPS ports
#It finds, specifically, the connections to the HTTP and HTTPS ports as source ports. You can check for destination ports as well. 
ss -o state established '( dport = :http or sport = :https )'
#This is sample output - yours may be different.
$ ss -o state established '( sport = :http or sport = :https )'
        # Recv-Q Send-Q                             Local Address:Port                                                                           Peer Address:Port   
        # 0      0                                  123.123.123.123:https                                                                         31.14.72.45:9776    
        # 0      0                                  123.123.123.123:http                                                                          67.204.23.12:55646   

# Find all clients connected to HTTP or HTTPS ports - It finds, specifically, the connections to the HTTP and HTTPS ports as source ports. You can check for destination ports as well.
ss -o state established '( dport = :http or sport = :https )'
    # Sample output
	    # $ ss -o state established '( sport = :http or sport = :https )'
	     # Recv-Q Send-Q     Local Address:Port               Peer Address:Port   
	     # 0      0          123.123.123.123:https         	  31.14.72.45:9776    
	     # 0      0          123.123.123.123:http             67.204.23.12:55646   

# Show all current listening programs by port and pid with SS instead of netstat
ss -plunt

#==============================##==============================#
# CMD SS
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

47 - 🖥️ssh

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ssh command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███████╗███████╗██╗  ██╗
#                ██╔════╝██╔════╝██║  ██║
#                ███████╗███████╗███████║
#                ╚════██║╚════██║██╔══██║
#                ███████║███████║██║  ██║
#                ╚══════╝╚══════╝╚═╝  ╚═╝

# ssh
# access a remote host via SSH

# explicitly specify a key for connection
# (if you have Too many authentication failures for *username*)
ssh -i some_id_rsa -o IdentitiesOnly=yes them@there:/path/

# switch off pubkey authentication
ssh -o PubkeyAuthentication=no [email protected]

# Get help on SSH escape sequences
# Useful for terminating unresponsive sessions
# The default escape character is ~ (tilde), escapes are only recognized immediately after newline
$ [Enter]~?

                                        
# To ssh via pem file (which normally needs 0600 permissions):
ssh -i /path/to/file.pem [email protected]

# To connect on an non-standard port:
ssh -p 2222 [email protected]

# To connect and forward the authentication agent
ssh -A [email protected]

# To execute a command on a remote server:
ssh -t [email protected] 'the-remote-command'

# To tunnel an x session over SSH:
ssh -X [email protected]

# Redirect traffic with a tunnel between local host (port 8080) and a remote
# host (remote.example.com:5000) through a proxy (personal.server.com):
ssh -f -L 8080:remote.example.com:5000 [email protected] -N

# To launch a specific x application over SSH:
ssh -X -t [email protected] 'chromium-browser'

# To create a SOCKS proxy on localhost and port 9999
ssh -D 9999 [email protected]

# -X use an xsession, -C compress data, "-c blowfish" use the encryption blowfish
ssh [email protected] -C -c blowfish -X

# For more information, see:
# http://unix.stackexchange.com/q/12755/44856

# Copy files and folders through ssh from remote host to pwd with tar.gz compression
# when there is no rsync command available
ssh [email protected] "cd /var/www/Shared/; tar zcf - asset1 asset2" | tar zxf -

# Mount folder/filesystem through SSH
# Install SSHFS from https://github.com/libfuse/sshfs
# Will allow you to mount a folder securely over a network.
sshfs name@server:/path/to/folder /path/to/mount/point

# Emacs can read file through SSH
# Doc: http://www.gnu.org/software/emacs/manual/html_node/emacs/Remote-Files.html
emacs /ssh:name@server:/path/to/file

[RETURN][RETURN]~C 
# Open openssh's client prompt so you can add another tunnel without having to logout. Example: -L 8080:192.168.1.1:80

#==============================#
# CMD SSH
#==============================##==============================#
ssh -D 9999 you@remotehost
# Use -D to create a SOCKS5 tunnel inside your SSH connection. Some programs (like a web browser) can use these.

ssh -L 9909:192.168.1.1:80 home
# Connections to tcp localhost:9909 will be made to 192.168.1.1:80 via SSH tunnel to home. 

ssh laptop eject -t
#

ssh --like -u fb::Bob_Reach http://alicebates.dyndns.com 
# Use Facebook authentication for SSH and auto "Like" the host too. New ssh options.

ssh -t user1@server1 'ssh -t user2@server2 "ssh -t user3@server3"'
# After all the host keys and auth, you'll be on server3.

ssh -N -L2001:localhost:80 somemachine
# start a tunnel from some machines port 80 to your local post 2001 now you can acces the website by going to http://localhost:2001/ s far as i know. i use this to access a customers intraweb application. this way the customer only needs to open up port 22 (ssh) in the firewall for just one ip address of some machine in your local lan (your hub machine). this way you can hop for your laptop to that local machine to the customers machine. as secure as it get its while still being relatively easy to use. no tokenstuff needed (i hate tokens and the 'supposed better' security).
# The params explaination:
#	-f tells ssh to go into the background (daemonize).
#	-N tells ssh that you don''t want to run a remote command. That is, you only want to forward ports.
#	-q tells ssh to be quiet
#	-L specifies the port forwarding

# If you want use one of the reserved ports (i.e., under 1023), you will have to run as root (using sudo). Also if you want to connect to server behind the DMZ, you can use a intermediate. This is useful where your have your local machine outside a firewall; a visible machine on the DMZ; and a third machine invisible to the outside.

ssh -f -N -q -L 80:192.168.1.69:80 [email protected]
#

ssh -D 9000 somemachine
# Sets up local port 9000 as a SOCKS 5 proxy via somemachine

ssh -f -N -L 8025:smtp.comcast.net:25 my_home_machine -L 8110:mail.comcast.net:110 my_home_machine
# a little more details, for example, in the case of an email client on a laptop, pointing to localhost:8025 for SMTP services, and localhost:8110 for POP3 services associated with a Comcast account, w/out traversing ?foreign? networks with clear text credentials, looks like. then, when changing locations:

ssh -f -N -L 0.0.0.0:8080:google.com:80 me@remote
# You can also allow access to the tunnel from incoming connections besides 127.0.0.1 which is the default when not stipulated. This allows on any net interface
    # or
ssh -f -N -L 10.1.1.120:8080:google.com:80 me@remote
# This allows any machine that can access your 10.1.1.120 interface access to the tunnel. This is not considering firewalls.

ssh -t user1@server1 'ssh -t user2@server2 "ssh -t user3@server3"'
# After all the host keys and auth, you'll be on server3.

ssh -D 8989 you@remotehost
# Create a dynamic SOCKS5 proxy on port 8989 using an SSH connection. Some apps can be configured to use this.

ssh -R *:8080:localhost:80 remoteserver
# Make local webserver available via remoteserver:8080. Req. GatewayPorts yes on sshd

ssh -L 9909:192.168.1.1:80 home
# Connections to tcp localhost:9909 will be made to 192.168.1.1:80 via SSH tunnel to home. 

# You've already ssh'd (openssh) somewhere but forgot to specify socks5 proxy. Just hit 
<Enter> then ~C and then -D 8888

ssh -D 9999 you@remotehost
# Use -D to create a SOCKS5 tunnel inside your SSH connection. Some programs (like a web browser) can use these.

# network copy with ssh and tar - You can use ssh in conjunction with tar to pull an entire directory tree from a remote machine into your current directory:
ssh <username@sourcehost> tar cf - -C <sourcedir> . | tar xvf -

# For example, let's say you have a "bsmith" account on a host called "apple". You want to copy those files into your "bobsmith" account on a host called "pear". You'd log into your "bobsmith@pear" account and type the following:
ssh bsmith@apple tar cf - -C /home/bsmith . | tar xvf -
# This technique is useful when you have insufficient disk space on the source machine to make an intermediate tarball.

while :; do ssh [email protected] -L8081:localhost:80 -N -v -g ; sleep 100; done
# nice; this line is also very lazy/handy; default ssh tunnel plus recovers automatically after failure. do not forget the sleep!

sshfs user@remotehost:/remotedir mydir
# sshfs is a nice util that uses FUSE and SSH to mount a remote directory as a local one.

RCMD_CMD_ARGS='-o VerifyHostKeyDNS=yes -o StrictHostKeyChecking=no' dsh -g all -e true
# Import ssh host keys without verification - Automatically import host keys for cluster of machines named 'all' -> Using the 'dsh' command from the clusterit tools - http://sourceforge.net/projects/clusterit

cat ~/.ssh/id_dsa.pub | ssh me@remotebox "cat >> ~/.ssh/authorized_keys"
# Just an example, concatenating your SSH key on another host.

ssh me@remotebox "ps auxf" | cat > ~/ProccessesForRemoteBox
    or
ssh <.ssh/id_rsa.pub user@server "cat >>.ssh/authorized_keys"
# Or maybe you would rather dump all the processes running on another computer into a local file

cat /dev/dsp | ssh me@remotebox "cat > /dev/dsp"
# What about playing local audio... Remotely (So both computers play the same thing)

ssh $WEBSERVER tail -f $LOGFILE | logstalgia
# See http://logstalgia.io/

ssh backup@<host> "sudo mysqldump $MYSQLOPTS | pbzip2 -c" | tee >($SSH_CMD "cat > $RPATH/<filename>-`date +%Y-%m-%d-%H-%M`.bz2") > $LPATH/<filename>-`date +%H-%M-%S`.bz2
# I use it to copy the output of a backup job to both a local host and a remote location by piping tee's output to ssh

bro-cut -Cd ts host host_p unparsed_version <software.log|awk -F\\t '$2=="10.2.3.4" && $3=="22"{if(l!=$4){print;l=$4}}' 
# SSH version change -  bro-cut is part of the Bro NSM package. The command will search the software.log and print when it detects the version of ssh changing.

# Use -D to create a SOCKS5 tunnel inside your SSH connection. Some programs (like a web browser) can use these.
ssh -D 1917 [email protected] 

ssh machine "while read -r; do DISPLAY=:0 xdotool getactivewindow key space; done" 
# Forgot your pres. remote ? use your phone

ssh-keygen -t rsa -b 4096
#

ssh-copy-id -i /root/.ssh/id_rsa [email protected]
#

openssl pkcs8 -topk8 -v2 des3 -in id_rsa.old -out id_rsa
# Private-Key Sicherer & abwärtskompatible machen: Umwandeln in anderes Format (PCKS#8)

ssh-keygen -R User@Host
# Eintrag aus /root/.ssh/known_hosts Datei löschen

ssh -C
# aktiviert Komprimierung bei schlechter internetleitung - erhöht latenz

ssh -p 2222 [email protected]
# Auf Port 2222 verbinden

ssh -D 3128 [email protected]
# Dynamische Port Weiterleitung um z.B. mit FritzBox zu verbinden ohne Remote-Administration freigeschaltet zu haben. Dazu brauchen Sie zu Hause einen Rechner, der per SSH erreichbar ist. Nun starten Sie den Browser auf Ihrem lokalen Rechner. In der Netzwerkkonfiguration tragen Sie als Proxy die Adresse 127.0.0.1 als Port 3128 und als Protokoll SOCKS5 ein. Auch andere Programme können sie so VPN tunneln, indem Sie ihnen diesen Proxy vorgeben, durch den SSH-Tunnel hindurchsurfen. 

# Setup a SOCKS5 proxy on port 8222 over an SSH connection. You can use this with for instance Mozilla Thunderbird to keep your home IP out of email headers. It will look like it came from the remote host you connect to.
ssh -D 8222 [email protected] 

ssh 192.168.2.155 pwd
# Führt pwd aus und meldet sich wieder ab

&& Und Verknüpfung ->  Zweites Kommando wird nur dann ausgeführt wenn erstes erfolgreich

|| Oder Verknüpfung > Zweite Befehl läuft nur dann wenn erster NICHT erfolgreich war

Um auf diese Weise ein Konsolenprogramm zu starten, das interaktiv arbeitet und Tastatureingaben entgegennimmt müssen Sie SSH zusätzlich den Parameter -t mitgeben

ssh -t
ssh -t huhnix.org 'tail -f /var/log/daemon.log'
# Startet Pseudo Terminal und sorgt dafür das sie so lange eingeloggt bleiben bis Programm beendet ist.
# z.b. tail -f oder top in ssh-pipe

ssh -vvv
# Bringt mehr infos

ssh-copy-id --i ~/.ssh/id_rsa.pub [email protected]
# ssh schlüssel kopieren

ssh -t -X rechner2 ssh -t -X rechner3 xterm &
# Von Rechner1 aus über rechner2 mit rechner3 verbinden und das grafikprogramm xterm starten

scp -r ~/Dokumente/ct [email protected]:
# Ganze verzeichnisbäume rekursive kopieren -> kopiert ordner ct und gesamten inhalt

scp -C 
# Komprimierung

scp -P
# scp auf port - achtung anderst als bei ssh mit -p

scp -l
# Bandbreite beschränken

sftp kann cd, ls, get oder put help, quit pwd exit

sftp -r 
sftp -r [email protected]:Dokumente/ct
# ganze Verzeichnisbäume übertragen

sftp -l
# Bandbreite beschränken

ssh -o ControlMaster=yes -o ControlPath=~/.ssh/control-%h_%p_%r huhnix.org
2. ssh-o ControlPath=~/.ssh/control-%h_%p_%r huhnix.org
# ssh Mulitplexing - d.h mehrere ssh sessions über einzige tcp verbindung schicken. der ssh-client nutzt ab der zweiten verbindung dann eine bereits existierede und verzichtet auf handshake. geschwindigkeitsvorteil -o ControlMaster=yes eine Masterverbindung -o ControlPath= definieren sie den Socket. Beim nächsten ssh aufruf zu diesem Rechner ist lediglich die Option -o ControlPath= erforderlich. Geht auch mit scp und sftp und rsync oder git

~/.ssh/config
ssh wertet diese datei aus
Host Name		#Speziell
Host * 			#Global
CheckHostIP No		# Für dynip adressen

remode ssh dd -> run from remote computer

$ dd if=/dev/sda | gzip -1 - | ssh user@local dd of=image.gz
run from local computer

$ ssh user@remote "dd if=/dev/sda | gzip -1 -" | dd of=image.gz

 
ssh -D 8222 [email protected] 
# Setup a SOCKS5 proxy on port 8222 over an SSH connection. You can use this with for instance Mozilla Thunderbird to keep your home IP out of email headers. It will look like it came from the remote host you connect to.

ssh -R *:8080:localhost:80 remoteserver 
# Make local webserver available via remoteserver:8080. Req. GatewayPorts yes on sshd

ssh -g -L 8025:smtp.other\.net:25 [email protected]\.net 
# Setup SMTP tunnel (listening on yourhost:8025) and allow others to use it (-g)

ssh -D 8989 you@remotehost 
# Create a dynamic SOCKS5 proxy on port 8989 using an SSH connection. Some apps can be configured to use this.

# Test your bash skills.
ssh [email protected] -p 2220

# Run remote X11 applications with ssh
ssh -X servername
# Explanation: You could follow this command with any other call to an X app: xeyes &
# Limitations: If ssh forwarding is permitted on the ssh server

# Put an ssh session in the background
~^z
# Explanation: 
    # Normally, ^z (read: ctrl-z) pauses the execution of the current foreground task. That does not work in an ssh session, because it is intercepted by the remote shell. ~^z is a special escape character for this case, to pause the ssh session and drop you back to the local shell.
    # For all escape characters see ~?
    # The ~ escape character must always follow a newline to be interpreted as special.
    # See man ssh for more details, search for ESCAPE CHARACTERS

# Copy a directory with a large number of files to another server -> 
tar cp -C /path/to/dir . | ssh server2 'tar x -C /path/to/target'
# Explanation: With a large number of files, scp or rsync can take very very long. It's much faster to tar up on one side and extract on the other. Without the -f flag tar writes output to standard output and expects input from standard input, so piping to ssh can work this way, without creating any intermediary files.
# You may (or may not) gain an extra speed boost by compression, either with the z flag for tar, or with the -C flag for ssh, or with gzip pipes in the middle, like this:
    # tar cp -C /path/to/dir . | gzip | ssh server2 'gzip -cd | tar x -C /path/to/target'
# Limitations: Depending on your system and version of tar, you may need to hyphenate the flags, for example tar -cp, and tar -x. The -C flag might also not work, but that shouldn't be too difficult to work around.

# Run a local shell script on a remote server without copying it there
ssh user@server bash < /path/to/local/script.sh

# Explanation: Yes this is almost trivial: a simple input redirection, from a local shell script to be executed by bash on the remote server.
# The important point being, if you have a complex and very long chain of commands to run on a remote server, it is better to put the commands in a shell script, break the long one-liner to multiple lines for readability and easier debugging.
# Replace bash accordingly depending on the language of the script, for example for python:
ssh user@server python < /path/to/local/script.py

http://www.youtube.com/watch?v=8QlNUzWB-iI … 
# Then this one time, in the terminal, I stuck an SSH tunnel inside an SSH tunnel inside an SSH tunnel inside an SSH tunnel inside an SSH tunnel inside an SSH tunnel inside an SSH tunnel inside an SSH tunnel inside an SSH tunnel.... I was using SSH on my smart phone once and I looked up for a moment and thought.. TRUCK!!!!!!!

ssh user@host script && ssh user@host script && ssh user@host script && ssh user@host script && ssh user@host script && ssh user@host script && ssh user@host script 

# Remote Linux Desktop via Linux
# Open a remote linux desktop from an linux client
# the easy way for gnome or kde you need the right skript, f.e. startx could work or startkde
ssh -X  user@servername startxfce4

# this is the difficult way:
# create an window which is bound to display :1
Xnest -geometry 1024x768 :1
# Opens an Terminal via SSH tunnel which starts an remote applikation in an lokal display
xterm -display :1 -e ssh -X user@servername startxfce4   

# bash-ssh-tunnelling
# Useful Bash/Linux SSH tunnelling commands
## Start SSH agent
eval "$(ssh-agent -s)"

## Open SSH tunnel on port 3307
ssh -fN -L 3307:127.0.0.1:3306 [email protected]

## Check the tunnel is active
netstat -lnp | grep ssh | grep :3307

## Close the tunnel
ps aux | grep ssh | grep 3307 # get the pid
kill <pid> # kill process

#SSH connection through host in the middle
ssh -J user@reachable_host user@unreacheable_host

# SSH connection through host in the middle
ssh -J user@reachable_host user@unreacheable_host

# 
cat ~/.ssh/id_rsa.pub | ssh <user>@<hostname> 'cat >> .ssh/authorized_keys && echo "Key copied"'

# port forwarding - pem file used by AWS servers for additional security
ssh -L8888:localhost:80 -i nov15a.pem [email protected]

# SFTP upload through HTTPS proxy - Overwrites remote file without asking! Uses HTTPS proxy that supports CONNECT. Actually uses SSH and not SFTP to upload the file.
cat myFile.json | ssh root@remoteSftpServer -o "ProxyCommand=nc.openbsd -X connect -x proxyhost:proxyport %h %p" 'cat > myFile.json'

# Block all brute force attacks in realtime (IPv4/SSH) -> Was to long with a loop, use a while loop for have it running 24/7
inotifywait -r -q --format %w /var/log/auth.log|grep -i "Failed pass"|tail -n 1|grep -oE '\b([0-9]{1,3}\.){3}[0-9]{1,3}';iptables -I INPUT -i eth0 -s "$(cat /var/log/auth.log|grep "authentication failure; l"|awk -Frhost= '{print $2}'|tail -n 1)" -j DROP

# Block all IPv4 addresses that has brute forcing our ssh server -> For ipv6 use: grep -oE "\b([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}\b"
for idiots in "$(cat /var/log/auth.log|grep invalid| grep -oE '\b([0-9]{1,3}\.){3}[0-9]{1,3}\b')"; do iptables -A INPUT -s "$idiots" -j DROP; done

#==============================##==============================#
# CMD SSH
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

48 - 🖥️ssh-add

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ssh-add command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███████╗███████╗██╗  ██╗       █████╗ ██████╗ ██████╗ 
#                ██╔════╝██╔════╝██║  ██║      ██╔══██╗██╔══██╗██╔══██╗
#                ███████╗███████╗███████║█████╗███████║██║  ██║██║  ██║
#                ╚════██║╚════██║██╔══██║╚════╝██╔══██║██║  ██║██║  ██║
#                ███████║███████║██║  ██║      ██║  ██║██████╔╝██████╔╝
#                ╚══════╝╚══════╝╚═╝  ╚═╝      ╚═╝  ╚═╝╚═════╝ ╚═════╝ 
                

                                                                      
ssh-add 
# This will load your key into the ssh-agent session so that you can login to hosts without requiring your passphrase each time.

#==============================##==============================#
# CMD SSH-ADD						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

49 - 🖥️ssh-copy-id

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ssh-copy-id command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#      ███████╗███████╗██╗  ██╗       ██████╗ ██████╗ ██████╗ ██╗   ██╗     ██╗██████╗ 
#      ██╔════╝██╔════╝██║  ██║      ██╔════╝██╔═══██╗██╔══██╗╚██╗ ██╔╝     ██║██╔══██╗
#      ███████╗███████╗███████║█████╗██║     ██║   ██║██████╔╝ ╚████╔╝█████╗██║██║  ██║
#      ╚════██║╚════██║██╔══██║╚════╝██║     ██║   ██║██╔═══╝   ╚██╔╝ ╚════╝██║██║  ██║
#      ███████║███████║██║  ██║      ╚██████╗╚██████╔╝██║        ██║        ██║██████╔╝
#      ╚══════╝╚══════╝╚═╝  ╚═╝       ╚═════╝ ╚═════╝ ╚═╝        ╚═╝        ╚═╝╚═════╝ 
                

                                                                                               
# To copy a key to a remote host:
ssh-copy-id username@host

# To copy a key to a remote host on a non-standard port:
ssh-copy-id username@host -p 2222

# To copy a key to a remote host on a non-standard port with non-standard ssh key:
ssh-copy-id ~/.ssh/otherkey "username@host -p 2222"

#==============================#
# CMD SSH-COPY-ID
#==============================##==============================#
ssh-copy-id 'user@remotehost'
# Automatically installs your public key to the remote host (this is included in the openssh package)

# SSH Copy ed25519 key into your host
ssh-copy-id -i your-ed25519-key user@host

ssh-copy-id '-p 4242 user@remotehost' 
# This will install public key to remote host using ssh on non-standard port 4242.

#==============================##==============================#
# CMD SSH-COPY-ID
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

50 - 🖥️ssh-keygen

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ssh-keygen command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#      ███████╗███████╗██╗  ██╗      ██╗  ██╗███████╗██╗   ██╗ ██████╗ ███████╗███╗   ██╗
#      ██╔════╝██╔════╝██║  ██║      ██║ ██╔╝██╔════╝╚██╗ ██╔╝██╔════╝ ██╔════╝████╗  ██║
#      ███████╗███████╗███████║█████╗█████╔╝ █████╗   ╚████╔╝ ██║  ███╗█████╗  ██╔██╗ ██║
#      ╚════██║╚════██║██╔══██║╚════╝██╔═██╗ ██╔══╝    ╚██╔╝  ██║   ██║██╔══╝  ██║╚██╗██║
#      ███████║███████║██║  ██║      ██║  ██╗███████╗   ██║   ╚██████╔╝███████╗██║ ╚████║
#      ╚══════╝╚══════╝╚═╝  ╚═╝      ╚═╝  ╚═╝╚══════╝   ╚═╝    ╚═════╝ ╚══════╝╚═╝  ╚═══╝
                                                                                                  
                

# To generate an SSH key:
ssh-keygen -t rsa

# To generate a 4096-bit SSH key:
ssh-keygen -t rsa -b 4096

# To update a passphrase on a key
ssh-keygen -p -P old_passphrase -N new_passphrase -f /path/to/keyfile

# To remove a passphrase on a key
ssh-keygen -p -P old_passphrase -N '' -f /path/to/keyfile

# To generate a 4096 bit RSA key with a passphase and comment containing the user and hostname
ssh-keygen -t rsa -b 4096 -C "$USER@$HOSTNAME" -P passphrase

#==============================#
# CMD SSH-KEYGEN
#==============================##==============================#
ssh-keygen -F 10.0.0.23 -l
# List the cached ssh host key fingerprint for 10.0.0.23

ssh-keygen -f ~/.ssh/known_hosts -R 192.168.2.155
# If key have changed, with this command delete the entry

# Remove offending key from known_hosts file with one swift move
ssh-keygen -R <hostname>
# Explanation: The ssh-keygen tool comes with an option for this already, there is no need for esoteric one-liners that are hard to remember. Say you ssh server.example.com and its host key has changed because you just reinstalled it. Run ssh-keygen -R server.example.com then try to connect to the server again, you'll be presented with the option to save the host key just like new.

ssh-keygen -y -f user-key.pem | ssh user@host -i already_on_remote_server_key.pem 'cat >> ~/.ssh/authorized_keys'
# Append a pub key from pem file and save in remote server accessing with another key Useful if you need to add another key and you using pem files (typical in AWS EC2 Instances). If you use it in EC2 instances, remember that password authentication is disabled, so you have to use the first key generated when you generated the instance

        # sort -t@ -k2 emails.txt
        # [email protected]
        # [email protected]
        # [email protected]
        # [email protected]
        # [email protected]
        # [email protected]
        # [email protected]
        # [email protected]
        # [email protected]
        # [email protected]
        # [email protected]

ssh-keygen -y -f privatekey.pem > publickey.pem
# Generate SSH public key from the private key

 
#==============================##==============================#
# CMD SSH-KEYGEN
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

51 - 🖥️sshfs

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the sshfs command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ███████╗███████╗██╗  ██╗███████╗███████╗
#  ██╔════╝██╔════╝██║  ██║██╔════╝██╔════╝
#  ███████╗███████╗███████║█████╗  ███████╗
#  ╚════██║╚════██║██╔══██║██╔══╝  ╚════██║
#  ███████║███████║██║  ██║██║     ███████║
#  ╚══════╝╚══════╝╚═╝  ╚═╝╚═╝     ╚══════╝

sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3,IdentityFile=/home/me/.ssh/id_rsa user@server:/home/user/dir dirshare/ 
# uses SSHFS to mount a remote dir - which should mostly survive breaks in connection. mostly.

sshfs user@remotehost:/remotedir localdir 
# sshfs is a util that uses FUSE and SSH to mount a remote directory as a local one. Saves the hassle of having to login to a remote system or copying files back and forth.

## Create a mount point and mount an FS
# You must create a mount point directory where you will mount your remote file system. For example on /mnt/sshfstest. Of course, use the mount point you want or need. Now, you can mount a remote directory under /etc/sshfstest.
sshfs -o IdentityFile=~/.ssh/id_rsa [email protected]:/remote/directory /mnt/sshfstest

# Linux tip; `sshfs` enables remote file-system mounting, and usually no server side setup, just ssh authorization.
mkdir /media/pi
chown ${USER}:${GROUPS} /media/pi

sshfs raspberrypi:/home/pi /media/pi
ls -ahl /media/pi

fusermount -u /media/pi
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

52 - 🖥️sshpass

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the sshpass command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ███████╗███████╗██╗  ██╗██████╗  █████╗ ███████╗███████╗
#  ██╔════╝██╔════╝██║  ██║██╔══██╗██╔══██╗██╔════╝██╔════╝
#  ███████╗███████╗███████║██████╔╝███████║███████╗███████╗
#  ╚════██║╚════██║██╔══██║██╔═══╝ ██╔══██║╚════██║╚════██║
#  ███████║███████║██║  ██║██║     ██║  ██║███████║███████║
#  ╚══════╝╚══════╝╚═╝  ╚═╝╚═╝     ╚═╝  ╚═╝╚══════╝╚══════╝

# Try to install sshpass and 
sshpass -p $PASSWORD scp $USER@$HOST:$PATH/$FILENAME $DOWNLOAD_PATH
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

53 - 🖥️tcpdump

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the tcpdump command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#    ████████╗ ██████╗██████╗ ██████╗ ██╗   ██╗███╗   ███╗██████╗ 
#    ╚══██╔══╝██╔════╝██╔══██╗██╔══██╗██║   ██║████╗ ████║██╔══██╗
#       ██║   ██║     ██████╔╝██║  ██║██║   ██║██╔████╔██║██████╔╝
#       ██║   ██║     ██╔═══╝ ██║  ██║██║   ██║██║╚██╔╝██║██╔═══╝ 
#       ██║   ╚██████╗██║     ██████╔╝╚██████╔╝██║ ╚═╝ ██║██║     
#       ╚═╝    ╚═════╝╚═╝     ╚═════╝  ╚═════╝ ╚═╝     ╚═╝╚═╝     
                

###############
# Basic Usage #
###############

#Capture packets on a particular interface (eth0)
#Note that tcpdump (without the '-i eth0') is also valid if you are only using one interface
tcpdump -i eth0

#Capture packets with more detailed output
tcpdump -i eth0 -nnvvS

#Display captured packets in both HEX and ASCII format
tcpdump -XX -i eth0

#Write captured packets into a file (can be read by tools such as Wireshark, Snort, etc)
tcpdump -w yourfilename.pcap -i eth0

#Read packets from a saved packet capture file
tcpdump -tttt -r yoursavedfile.pcap

#Display IP addresses instead of hostnames when capturing packets
tcpdump -n -i eth0

#Capture packets from a particular source/destination IP address
tcpdump src 192.168.1.1
tcpdump dst 192.168.1.1

#Capture packets from a particular source/destination port number
tcpdump src port 53
tcpdump dst port 21

#Capture an entire network's traffic using CIDR notation
tcpdump net 192.168.1.0/24

#Capture traffic to or from a port
tcpdump port 3389

#Display captured packets above or below a certain size (in bytes)
tcpdump less 64
tcpdump greater 256

##################
# Advanced Usage #
##################

#More complex statements can be formed with the use of logical operators: and(&&), or(||), not(!)
#Examples:

#Capture all traffic from 192.168.1.10 with destination port 80 (with verbose output)
tcpdump -nnvvS and src 192.168.1.10 and dst port 80

#Capture traffic originating from the 172.16.0.0/16 network with destination network 192.168.1.0/24 or 10.0.0.0/8
tcpdump src net 172.16.0.0/16 and dst net 192.168.1.0/24 or 10.0.0.0/8

#Capture all traffic originating from host H1 that isn't going to port 53
tcpdump src H1 and not dst port 22

#With some complex queries you may have to use single quotes to ignore special characters, namely parentheses 
#Capture traffic from 192.168.1.1 that is destined for ports 80 and 21
tcpdump 'src 192.168.1.1 and (dst port 80 or 21)'

                                                                            
# TCPDump is a packet analyzer. It allows the user to intercept and display TCP/IP
# and other packets being transmitted or received over a network. (cf Wikipedia).
# Note: 173.194.40.120 => google.com

# Intercepts all packets on eth0
tcpdump -i eth0

# Intercepts all packets from/to 173.194.40.120
tcpdump host 173.194.40.120

# Intercepts all packets on all interfaces from / to 173.194.40.120 port 80
# -nn => Disables name resolution for IP addresses and port numbers.
tcpdump -nn -i any host 173.194.40.120 and port 80

# Make a grep on tcpdump (ASCII)
#    -A  => Show only ASCII in packets.
#    -s0 => By default, tcpdump only captures 68 bytes.
tcpdump -i -A any host 173.194.40.120 and port 80 | grep 'User-Agent'

# With ngrep
#    -d eth0   => To force eth0 (else ngrep work on all interfaces)
#    -s0       => force ngrep to look at the entire packet. (Default snaplen: 65536 bytes)
ngrep 'User-Agent' host 173.194.40.120 and port 80

# Intercepts all packets on all interfaces from / to 8.8.8.8 or 173.194.40.127 on port 80
tcpdump 'host ( 8.8.8.8 or 173.194.40.127 ) and port 80' -i any

# Intercepts all packets SYN and FIN of each TCP session.
tcpdump 'tcp[tcpflags] & (tcp-syn|tcp-fin) != 0'

# To display SYN and FIN packets of each TCP session to a host that is not on our network
tcpdump 'tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net local_addr'

# To display all IPv4 HTTP packets that come or arrive on port 80 and that contain only data (no SYN, FIN no, no packet containing an ACK)
tcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'

# Saving captured data
tcpdump -w file.cap

# Reading from capture file
tcpdump -r file.cap

# Show content in hexa
# Change -x to -xx => show extra header (ethernet).
tcpdump -x

# Show content in hexa and ASCII
# Change -X to -XX => show extra header (ethernet).
tcpdump -X

# Note on packet maching:
# Port matching:
# 	- portrange 22-23
# 	- not port 22
# 	- port ssh
# 	- dst port 22
# 	- src port 22
#
# Host matching:
# 	- dst host 8.8.8.8
# 	- not dst host 8.8.8.8
# 	- src net 67.207.148.0 mask 255.255.255.0
# 	- src net 67.207.148.0/24

#==============================##==============================#
# CMD tcpdump traceanon tracediff tracemerge tracereplay       #
#==============================##==============================#

#####################################

# 12 Tcpdump Commands – A Network Sniffer Tool
#===============================================

# In our previous article, we have seen 20 Netstat Commands to monitor or mange Linux network. This is our another ongoing series of packet sniffer tool called tcpdump. Here, we are going to show you how to install tcpdump and then we discuss and cover some useful commands with their practical examples.

# tcpdump is a most powerful and widely used command-line packets sniffer or package analyzer tool which is used to capture or filter TCP/IP packets that received or transferred over a network on a specific interface. It is available under most of the Linux/Unix based operating systems. tcpdump also gives us a option to save captured packets in a file for future analysis. It saves the file in a pcap format, that can be viewed by tcpdump command or a open source GUI based tool called Wireshark (Network Protocol Analyzier) that reads tcpdump pcap format files.

# 1. Capture Packets from Specific Interface
#--------------------------------------------
# The command screen will scroll up until you interrupt and when we execute tcpdump command it will captures from all the interfaces, however with -i switch only capture from desire interface.

tcpdump -i eth0
# tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
    11:33:31.976358 IP 172.16.25.126.ssh > 172.16.25.125.apwi-rxspooler: Flags [P.], seq 3500440357:3500440553, ack 3652628334, win 18760, length 196
    11:33:31.976603 IP 172.16.25.125.apwi-rxspooler > 172.16.25.126.ssh: Flags [.], ack 196, win 64487, length 0
    11:33:31.977243 ARP, Request who-has tecmint.com tell 172.16.25.126, length 28
    11:33:31.977359 ARP, Reply tecmint.com is-at 00:14:5e:67:26:1d (oui Unknown), length 46
    11:33:31.977367 IP 172.16.25.126.54807 > tecmint.com: 4240+ PTR? 125.25.16.172.in-addr.arpa. (44)
    11:33:31.977599 IP tecmint.com > 172.16.25.126.54807: 4240 NXDomain 0/1/0 (121)
    11:33:31.977742 IP 172.16.25.126.44519 > tecmint.com: 40988+ PTR? 126.25.16.172.in-addr.arpa. (44)
    11:33:32.028747 IP 172.16.20.33.netbios-ns > 172.16.31.255.netbios-ns: NBT UDP PACKET(137): QUERY; REQUEST; BROADCAST
    11:33:32.112045 IP 172.16.21.153.netbios-ns > 172.16.31.255.netbios-ns: NBT UDP PACKET(137): QUERY; REQUEST; BROADCAST
    11:33:32.115606 IP 172.16.21.144.netbios-ns > 172.16.31.255.netbios-ns: NBT UDP PACKET(137): QUERY; REQUEST; BROADCAST
    11:33:32.156576 ARP, Request who-has 172.16.16.37 tell old-oraclehp1.midcorp.mid-day.com, length 46
    11:33:32.348738 IP tecmint.com > 172.16.25.126.44519: 40988 NXDomain 0/1/0 (121)

# 2. Capture Only N Number of Packets
#-----------------------------------
# When you run tcpdump command it will capture all the packets for specified interface, until you Hit cancel button. But using -c option, you can capture specified number of packets. The below example will only capture 6 packets.

tcpdump -c 5 -i eth0
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
    11:40:20.281355 IP 172.16.25.126.ssh > 172.16.25.125.apwi-rxspooler: Flags [P.], seq 3500447285:3500447481, ack 3652629474, win 18760, length 196
    11:40:20.281586 IP 172.16.25.125.apwi-rxspooler > 172.16.25.126.ssh: Flags [.], ack 196, win 65235, length 0
    11:40:20.282244 ARP, Request who-has tecmint.com tell 172.16.25.126, length 28
    11:40:20.282360 ARP, Reply tecmint.com is-at 00:14:5e:67:26:1d (oui Unknown), length 46
    11:40:20.282369 IP 172.16.25.126.53216 > tecmint.com.domain: 49504+ PTR? 125.25.16.172.in-addr.arpa. (44)
    11:40:20.332494 IP tecmint.com.netbios-ssn > 172.16.26.17.nimaux: Flags [P.], seq 3058424861:3058424914, ack 693912021, win 64190, length 53 NBT Session Packet: Session Message
    6 packets captured
    23 packets received by filter
    0 packets dropped by kernel

# 3. Print Captured Packets in ASCII
#----------------------------------
# The below tcpdump command with option -A displays the package in ASCII format. It is a character-encoding scheme format.

tcpdump -A -i eth0
# tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
    09:31:31.347508 IP 192.168.0.2.ssh > 192.168.0.1.nokia-ann-ch1: Flags [P.], seq 3329372346:3329372542, ack 4193416789, win 17688, length 196
    M.r0...vUP.E.X.......~.%..>N..oFk.........KQ..)Eq.d.,....r^l......m\.[email protected]_..J....i.*.....2f.mQH...Q.c...6....9.v.gb........;..4.).UiCY]..9..x.)..Z.XF....|..E......M..u.5.......ul
    09:31:31.347760 IP 192.168.0.1.nokia-ann-ch1 > 192.168.0.2.ssh: Flags [.], ack 196, win 64351, length 0
    M....vU.r1~P.._..........
    ^C09:31:31.349560 IP 192.168.0.2.46393 > b.resolvers.Level3.net.domain: 11148+ PTR? 1.0.168.192.in-addr.arpa. (42)
    E..F..@[email protected]+............1.0.168.192.in-addr.arpa.....
    3 packets captured
    11 packets received by filter
    0 packets dropped by kernel

# 4. Display Available Interfaces
#--------------------------------
# To list number of available interfaces on the system, run the following command with -D option.

tcpdump -D
    1.eth0
    2.eth1
    3.usbmon1 (USB bus number 1)
    4.usbmon2 (USB bus number 2)
    5.usbmon3 (USB bus number 3)
    6.usbmon4 (USB bus number 4)
    7.usbmon5 (USB bus number 5)
    8.any (Pseudo-device that captures on all interfaces)
    9.lo

# 5. Display Captured Packets in HEX and ASCII
#-----------------------------------------------
# The following command with option -XX capture the data of each packet, including its link level header in HEX and ASCII format.

tcpdump -XX -i eth0
    11:51:18.974360 IP 172.16.25.126.ssh > 172.16.25.125.apwi-rxspooler: Flags [P.], seq 3509235537:3509235733, ack 3652638190, win 18760, length 196
    0x0000:  b8ac 6f2e 57b3 0001 6c99 1468 0800 4510  ..o.W...l..h..E.
    0x0010:  00ec 8783 4000 4006 275d ac10 197e ac10  ....@.@.]...~..
    0x0020:  197d 0016 1129 d12a af51 d9b6 d5ee 5018  .}...).*.Q....P.
    0x0030:  4948 8bfa 0000 0e12 ea4d 22d1 67c0 f123  IH.......M.g..#
    0x0040:  9013 8f68 aa70 29f3 2efc c512 5660 4fe8  ...h.p).....VO.
    0x0050:  590a d631 f939 dd06 e36a 69ed cac2 95b6  Y..1.9...ji.....
    0x0060:  f8ba b42a 344b 8e56 a5c4 b3a2 ed82 c3a1  ...*4K.V........
    0x0070:  80c8 7980 11ac 9bd7 5b01 18d5 8180 4536  ..y.....[.....E6
    0x0080:  30fd 4f6d 4190 f66f 2e24 e877 ed23 8eb0  0.OmA..o.$.w.#..
    0x0090:  5a1d f3ec 4be4 e0fb 8553 7c85 17d9 866f  Z...K....S|....o
    0x00a0:  c279 0d9c 8f9d 445b 7b01 81eb 1b63 7f12  .y....D[{....c..
    0x00b0:  71b3 1357 52c7 cf00 95c6 c9f6 63b1 ca51  q..WR.......c..Q
    0x00c0:  0ac6 456e 0620 38e6 10cb 6139 fb2a a756  ..En..8...a9.*.V
    0x00d0:  37d6 c5f3 f5f3 d8e8 3316 d14f d7ab fd93  7.......3..O....
    0x00e0:  1137 61c1 6a5c b4d1 ddda 380a f782 d983  .7a.j\....8.....
    0x00f0:  62ff a5a9 bb39 4f80 668a                 b....9O.f.
    11:51:18.974759 IP 172.16.25.126.60952 > mddc-01.midcorp.mid-day.com.domain: 14620+ PTR? 125.25.16.172.in-addr.arpa. (44)
    0x0000:  0014 5e67 261d 0001 6c99 1468 0800 4500  ..^g&...l..h..E.
    0x0010:  0048 5a83 4000 4011 5e25 ac10 197e ac10  .HZ.@.@.^%...~..
    0x0020:  105e ee18 0035 0034 8242 391c 0100 0001  .^...5.4.B9.....
    0x0030:  0000 0000 0000 0331 3235 0232 3502 3136  .......125.25.16
    0x0040:  0331 3732 0769 6e2d 6164 6472 0461 7270  .172.in-addr.arp
    0x0050:  6100 000c 0001                           a.....

# 6. Capture and Save Packets in a File
#----------------------------------------
# As we said, that tcpdump has a feature to capture and save the file in a .pcap format, to do this just execute command with -w option.

# tcpdump -w 0001.pcap -i eth0
    tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
    4 packets captured
    4 packets received by filter
    0 packets dropped by kernel

# 7. Read Captured Packets File
#--------------------------------
# To read and analyze captured packet 0001.pcap file use the command with -r option, as shown below.

tcpdump -r 0001.pcap
    reading from file 0001.pcap, link-type EN10MB (Ethernet)
    09:59:34.839117 IP 192.168.0.2.ssh > 192.168.0.1.nokia-ann-ch1: Flags [P.], seq 3353041614:3353041746, ack 4193563273, win 18760, length 132
    09:59:34.963022 IP 192.168.0.1.nokia-ann-ch1 > 192.168.0.2.ssh: Flags [.], ack 132, win 65351, length 0
    09:59:36.935309 IP 192.168.0.1.netbios-dgm > 192.168.0.255.netbios-dgm: NBT UDP PACKET(138)
    09:59:37.528731 IP 192.168.0.1.nokia-ann-ch1 > 192.168.0.2.ssh: Flags [P.], seq 1:53, ack 132, win 65351, length 5

# 8. Capture IP address Packets
#-------------------------------
# To capture packets for a specific interface, run the following command with option -n.

tcpdump -n -i eth0
# tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
    12:07:03.952358 IP 172.16.25.126.ssh > 172.16.25.125.apwi-rxspooler: Flags [P.], seq 3509512873:3509513069, ack 3652639034, win 18760, length 196
    12:07:03.952602 IP 172.16.25.125.apwi-rxspooler > 172.16.25.126.ssh: Flags [.], ack 196, win 64171, length 0
    12:07:03.953311 IP 172.16.25.126.ssh > 172.16.25.125.apwi-rxspooler: Flags [P.], seq 196:504, ack 1, win 18760, length 308
    12:07:03.954288 IP 172.16.25.126.ssh > 172.16.25.125.apwi-rxspooler: Flags [P.], seq 504:668, ack 1, win 18760, length 164
    12:07:03.954502 IP 172.16.25.125.apwi-rxspooler > 172.16.25.126.ssh: Flags [.], ack 668, win 65535, length 0
    12:07:03.955298 IP 172.16.25.126.ssh > 172.16.25.125.apwi-rxspooler: Flags [P.], seq 668:944, ack 1, win 18760, length 276
    12:07:03.955425 IP 172.16.23.16.netbios-ns > 172.16.31.255.netbios-ns: NBT UDP PACKET(137): REGISTRATION; REQUEST; BROADCAST
    12:07:03.956299 IP 172.16.25.126.ssh > 172.16.25.125.apwi-rxspooler: Flags [P.], seq 944:1236, ack 1, win 18760, length 292
    12:07:03.956535 IP 172.16.25.125.apwi-rxspooler > 172.16.25.126.ssh: Flags [.], ack 1236, win 64967, length 0

# 9. Capture only TCP Packets.
# ------------------------------
# To capture packets based on TCP port, run the following command with option tcp.

tcpdump -i eth0 tcp
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
    12:10:36.216358 IP 172.16.25.126.ssh > 172.16.25.125.apwi-rxspooler: Flags [P.], seq 3509646029:3509646225, ack 3652640142, win 18760, length 196
    12:10:36.216592 IP 172.16.25.125.apwi-rxspooler > 172.16.25.126.ssh: Flags [.], ack 196, win 64687, length 0
    12:10:36.219069 IP 172.16.25.126.ssh > 172.16.25.125.apwi-rxspooler: Flags [P.], seq 196:504, ack 1, win 18760, length 308
    12:10:36.220039 IP 172.16.25.126.ssh > 172.16.25.125.apwi-rxspooler: Flags [P.], seq 504:668, ack 1, win 18760, length 164
    12:10:36.220260 IP 172.16.25.125.apwi-rxspooler > 172.16.25.126.ssh: Flags [.], ack 668, win 64215, length 0
    12:10:36.222045 IP 172.16.25.126.ssh > 172.16.25.125.apwi-rxspooler: Flags [P.], seq 668:944, ack 1, win 18760, length 276
    12:10:36.223036 IP 172.16.25.126.ssh > 172.16.25.125.apwi-rxspooler: Flags [P.], seq 944:1108, ack 1, win 18760, length 164
    12:10:36.223252 IP 172.16.25.125.apwi-rxspooler > 172.16.25.126.ssh: Flags [.], ack 1108, win 65535, length 0
    ^C12:10:36.223461 IP mid-pay.midcorp.mid-day.com.netbios-ssn > 172.16.22.183.recipe: Flags [.], seq 283256512:283256513, ack 550465221, win 65531, length 1[|SMB]

# 10. Capture Packet from Specific Port
#-----------------------------------------
Let’s say you want to capture packets for specific port 22, execute the below command by specifying port number 22 as shown below.

# tcpdump -i eth0 port 22
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
    10:37:49.056927 IP 192.168.0.2.ssh > 192.168.0.1.nokia-ann-ch1: Flags [P.], seq 3364204694:3364204890, ack 4193655445, win 20904, length 196
    10:37:49.196436 IP 192.168.0.2.ssh > 192.168.0.1.nokia-ann-ch1: Flags [P.], seq 4294967244:196, ack 1, win 20904, length 248
    10:37:49.196615 IP 192.168.0.1.nokia-ann-ch1 > 192.168.0.2.ssh: Flags [.], ack 196, win 64491, length 0
    10:37:49.379298 IP 192.168.0.2.ssh > 192.168.0.1.nokia-ann-ch1: Flags [P.], seq 196:616, ack 1, win 20904, length 420
    10:37:49.381080 IP 192.168.0.2.ssh > 192.168.0.1.nokia-ann-ch1: Flags [P.], seq 616:780, ack 1, win 20904, length 164
    10:37:49.381322 IP 192.168.0.1.nokia-ann-ch1 > 192.168.0.2.ssh: Flags [.], ack 780, win 65535, length 0

# 11. Capture Packets from source IP
#-------------------------------------
# To capture packets from source IP, say you want to capture packets for 192.168.0.2, use the command as follows.

tcpdump -i eth0 src 192.168.0.2
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
    10:49:15.746474 IP 192.168.0.2.ssh > 192.168.0.1.nokia-ann-ch1: Flags [P.], seq 3364578842:3364579038, ack 4193668445, win 20904, length 196
    10:49:15.748554 IP 192.168.0.2.56200 > b.resolvers.Level3.net.domain: 11289+ PTR? 1.0.168.192.in-addr.arpa. (42)
    10:49:15.912165 IP 192.168.0.2.56234 > b.resolvers.Level3.net.domain: 53106+ PTR? 2.0.168.192.in-addr.arpa. (42)
    10:49:16.074720 IP 192.168.0.2.33961 > b.resolvers.Level3.net.domain: 38447+ PTR? 2.2.2.4.in-addr.arpa. (38)

# 12. Capture Packets from destination IP
#-------------------------------------------
# To capture packets from destination IP, say you want to capture packets for 50.116.66.139, use the command as follows.

tcpdump -i eth0 dst 50.116.66.139
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
    10:55:01.798591 IP 192.168.0.2.59896 > 50.116.66.139.http: Flags [.], ack 2480401451, win 318, options [nop,nop,TS val 7955710 ecr 804759402], length 0
    10:55:05.527476 IP 192.168.0.2.59894 > 50.116.66.139.http: Flags [F.], seq 2521556029, ack 2164168606, win 245, options [nop,nop,TS val 7959439 ecr 804759284], length 0
    10:55:05.626027 IP 192.168.0.2.59894 > 50.116.66.139.http: Flags [.], ack 2, win 245, options [nop,nop,TS val 7959537 ecr 804759787], length 0
    
    

######################################

##Collect Particular Interface report
# Perhaps the most common usage of the tcpdump common is to listen to network traffic on a network interface. To do this we use the -i option with the tcpdump command followed by the interface name. Type the keyword any then tcpdump will listen network traffic on all interfaces.
tcpdump -i ens33

##Omit name resolution for host-names and port numbers
# The default behavior of tcpdump is to perform name resolution for host-names and port numbers which is evident from the output from our previous example. To save time spent in resolving host-names you could use the -n option with tcpdump to instruct to print strictly numeric output only in the form of IP addresses and port numbers.
tcpdump -n -i ens33

##Capture only X number of packets.
# Tcpdump command continues to capture packets and report them in the output until we cancel it. We can use the -c option with the tcpdump command to limit the number of packets it captures. In the below example we are capturing only five packets on the network interface ens33.
tcpdump -c 5 -i ens33

##List available interfaces
# To list the network interfaces on the system available for use by tcpdump, use the -D option. Notice that USB ports are also included in the output because tcpdump can listen for USB protocol from USB interfaces and other special Kernel devices.
tcpdump -D

##Display captured packets in ASCII
# ASCII is a character encoding format. To display packets captured by tcpdump in ASCII encoding use the -A option with the tcpdump command.
tcpdump -A -c 5 -i ens33

##Captured Packets in HEX and ASCII
# In case you would like to analyze captured packets in HEX and ASCII format, use the -XX option. When this option is set, tcpdump displays data of each packet, including its link level header in HEX and ASCII format.

tcpdump -XX -c 2 -i ens33

##Be more verbose
# To increase the level of verbosity reported in the tcpdump output you can use -vvv option. This will report the TTL, total length and options in an the IP packets.
tcpdump -vvv -c 2 -i ens33

##Traffic on a particular port
# It can use to filter out and capture traffic on a single port by specifying the keyword port along with the port number in the tcpdump command. The below command captures traffic on tcp port 22 only.

tcpdump -c 5 -i ens33 port 22
# tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
		.............
		5 packets captured
		15 packets received by filter
		4 packets dropped by kernel

##Capture packets aimed at a destination address
# Can capture and filter out packets being transmitted to a particular destination address as shown in the below example.

tcpdump dst 192.168.87.144
		19 packets captured
		40 packets received by filter
		15 packets dropped by kernel
# In the above example, captured all traffic that is directed towards IP address 192.168.87.144.

##Packets originating from a source IP address
# Capture and filter out packets originating from a particular destination address as shown in the below example.
tcpdump src 192.168.87.144

##Collect particular hostname dump
# We can use tcpdump command to capture communication with a particular host whether it is the source or destination of the communication. The below example captures all communication related to the hostname google.com
tcpdump host google.com

##Output to a file
# Store the output of tcpdump command to a file and later retrieve it for further analysis. To write captured packet information to a file we use the -w option followed by the file name to which the data is to be written to.
tcpdump -c 5 port 22 -w ssh_traffic.pcap

##Read from a file
# To read the packet capture from a file we use the -r option. In the below example we will read from the file we used earlier to write the packet captured
tcpdump -r ssh_traffic.pcap

##Setting up custom filters
# Use logical and, or and not to create very customized filters while running the tcpdump command. Example run tcpdump command to capture traffic directed at host 192.168.87.144 on port 22 and 80 only
tcpdump dst host 192.168.87.144 and "(dst port 22 or dst port 80)"

tcpdump -i eth0 dst net 127.0.0.0/8
# Its a pretty weird day when you find yourself running a command like this to diagnose a problem.

tcpdump -l icmp[icmptype]=icmp-echo | awk '{if (!arr[$3]){print $3;arr[$3]++}}'
# Show new pingers. -l makes tcpdump linebuffered.

tcpdump -n -i $if

traceanon [options] $sourceuri $desturi

tracediff [ -m $maxdiff ] $firsturi $seconduri

tracemerge [ options ] $outputuri $inputuri ...

tracereplay [ options ] $inputuri $outputuri

tcpdump -c 50 -s 0 -i eth1 -A host 192.168.1.1 and tcp port http
# tcpdump to sniff HTTP traffic from a specific host - Linux command to dump HTTP packet
#    The parameter breakdown:
#	-c 50: Capture 50 packe	ts then exit.
#	-s 0: Print it all payload data, no limit.
#	-i eth1: C		apture packets on interface eth1
#	-A: Print packets in ASCII.
# 	   host 192.168.1.1: Only capture packets coming to or from 192.168.1.1. and tcp port http: Only capture TCP HTTP packets.

tcpdump -nn -v -i eth0 -s 1500 -c 1 'ether[20:2] == 0x2000' 
# Dump information from a CDP frame received on eth0

# Get packets from all interfaces -> To get the network packets from all network interfaces, run the following command,
tcpdump -i any

 

# Get packets from a single interfaces -> To get the network packets from a single interface, use
tcpdump -i eth0

 

# Writing captured packets to file -> To write all the captured packets to a file, use the ‘-w’ option,
tcpdump -i eth1 -w packets_file

 

# Reading an old tcpdump file -> To read an already created, old tcpdump file, use the following command,
tcpdump -r packets_file

 

# Getting more packets information with readable timestamps -> To get more information regarding the packets along with readable timestamp, use
tcpdump -ttttnnvvS

 

# Check packets of whole network -> To get the packets for whole network, execute the following command from terminal
tcpdump net 192.168.1.0/24

 

# Check packets based on IP address -> Get all the packets based on the IP address, whether source or destination or both, using the following command,
tcpdump host 192.168.1.100

# To get packets based on source or destination of an IP address, use
tcpdump src 192.168.1.100
tcpdump dst 192.168.1.100

 

# Check packets for a protocol or port number -> To check all the packets used based on the protocol, run the following command
tcpdump ssh

# To get packets for a single port ot for a range of ports. 
#		->We can also use ‘src’ & ‘dst’ options to get packets for ports based on source & destination. 
#		-> We can also combine two conditions with AND (and , && ), OR ( or. || ) & EXCEPT (not , ! ). This helps when we have analyze network packets based on the some condtions.
tcpdump port 22
tcpdump portrange 22-125

 

# Using AND -> We can use ‘and’ or symbol ‘&&’ to combine two conditions or mote with tcpdump. An example would be,
tcpdump src 192.168.1.100 && port 22 -w ssh_packets

 

# Using OR -> OR will check the command agtcpdump -i eth0 src port not 22ainst one the mentioned conditions in the command, like
tcpdump src 192.168.1.100 or dst 192.168.1.50 && port 22 -w ssh_packets
tcpdump port 443 or 80 -w http_packets

 

# Using EXCEPT -> EXCEPT will be used when we want not fulfill a condition. -> This will monitor all the traffic on eth0 but will not capture port 22.+-
tcpdump -i eth0 src port not 22

# Tcp Dump in NL  100mb große files
tcpdump -i eth0 -w /root/bin/pk_traces -C 100 -K -n

# See entire packet payload using tcpdump.
tcpdump -nnvvXSs 1514 -i <device> <filters>

# Check if loopback network interface is working
tcpdump -i lo -nv ip

tcpdump -nn -l port 25 | grep -i 'MAIL FROM\|RCPT TO'
# Capture SMTP / POP3 Email

tcpdump -s 0 -A -n -l | egrep -i "POST /|pwd=|passwd=|password=|Host:"
# Extract HTTP Passwords in POST Requests

tcpdump -nn -v port ftp or ftp-data
#

tcpdump port http or port ftp or port smtp or port imap or port pop3 or port telnet -l -A | egrep -i -B5 'pass=|pwd=|log=|login=|user=|username=|pw=|passw=|passwd=|password=|pass:|user:|username:|password:|login:|pass |user '
# Capture FTP Credentials and Commands Capture all plaintext passwords

# Dump network traffic with tcpdump to file with time-stamp in its filename
date +"%Y-%m-%d_%H-%M-%Z" | xargs -I {} bash -c "sudo tcpdump -nq -s 0 -i eth0 -w ./dump-{}.pcap"
# Explanation: will dump the traffic into a file with a time-stamp in its name. Example filename:
dump-2013-05-17_15-46-UTC.pcap

# Using tcpdump with port ranges and file count/size
tcpdump -i any -s 0 -n -Z <user_name> -C 500 -W 100 -w /home/<user_name>/$(hostname).pcap -f '(port (# or # or # or # or # or # or ...) or portrange <start>-<end>)' &>/dev/null

    
# Using tcpdump with port ranges and file count/size
sudo /usr/sbin/tcpdump -i any -s 0 -n -Z <user_name> -C 500 -W 100 -w /home/<user_name>/$(hostname).pcap -f '(port (# or # or # or # or # or # or ...) or portrange <start>-<end>)' &>/dev/null

#==============================##==============================#
# CMD tcpdump traceanon tracediff tracemerge tracereplay       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

54 - 🖥️telnet

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the telnet command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ████████╗███████╗██╗     ███╗   ██╗███████╗████████╗
#                ╚══██╔══╝██╔════╝██║     ████╗  ██║██╔════╝╚══██╔══╝
#                   ██║   █████╗  ██║     ██╔██╗ ██║█████╗     ██║   
#                   ██║   ██╔══╝  ██║     ██║╚██╗██║██╔══╝     ██║   
#                   ██║   ███████╗███████╗██║ ╚████║███████╗   ██║   
#                   ╚═╝   ╚══════╝╚══════╝╚═╝  ╚═══╝╚══════╝   ╚═╝   
                

                                                                  
telnet localhost 2601
# telnet host port 

telnet http://telehack.com 
# A public telnet server with many little games and distractions.

HOST=127.0.0.1;for((port=1;port<=65535;++port)); do echo -en "$port ";if echo -en "open $HOST $port\nlogout\quit" | telnet 2>/dev/null | grep 'Connected to' > /dev/null; then echo -en "\n\nport $port/tcp is open\n\n";fi;done | grep open
# scans for open ports using telnet

#-----------------------------------------------[CODE BEGINN ]-------------------------------------------------------------------------#
Using telnet

This may help when testing MTA setup such as Postfix, Sendmail, qmail, etc..

    Note S: stand for System message and C: stand for Client user. It is just for tutorial purpose. Do not need to enter C: in your input.
    Just dot (period character) is meaningful.

[root@hostname]# telnet mail.domain.com 25
    S: Trying 123.45.67.890...
    S: Connected to mail.domain.com.
    S: Escape character is '^]'.
    S: 220 mail.domain.com ESMTP Postfix
    C: ehlo domain.com
    S: 250-mail.domain.com  
    S: 250-PIPELINING 
    S: 250-SIZE 10240000  
    S: 250-VRFY  
    S: 250-ETRN  
    S: 250-STARTTLS  
    S: 250-AUTH LOGIN PLAIN DIGEST-MD5 CRAM-MD5  
    S: 250-AUTH=LOGIN PLAIN DIGEST-MD5 CRAM-MD5  
    S: 250 8BITMIME
    C: mail from:<[email protected]>
    S: 250 Ok
    C: rcpt to:<[email protected]>
    S: 250 ok
    C: data
    S: 354 End data with <CR><LF>.<CR><LF>
    C: Subject: Your subject message
    C: Your messages.
    C: Your messages.
    C: .
    S: 250 Ok: queued as ABC1D1C123
    C: quit
    S: 221 Bye
    S: Connection closed by foreign host.

Using mail program
# mail [email protected]
Subject: Hello
Hi,

Testing. Testing. Take care.

. (Type  DOT (.) followed by ENTER KEY}
Cc: (Press ENTER KEY)

 IMAP
 
telnet localhost 143
1 capability
2 login username@domain password

 POP3

Test Your Pop3 Connection From Telnet
Type: telnet "the name of the pop3 server" 110
Type: user "username"
Type: pass "password"
Type: list
You will then get a list over the mails in your mailbox
Type: retr "mailnumber"
You will then see the mail with the mail number
End the session by typing "Quit"

Other Telnet commands:
stat = Status of you mailbox
dele N = delete mail nummer "N"
#------------------------------------------------[CODE ENDE]------------------------------------------------------------------------#

telnet mapscii\.me 
# World maps from OpenStreetMap right in your terminal w/ mouse support. Arrow keys & a/z to zoom, or mouse. 

telnet towel.blinkenlights\.nl 
# StarWars in ASCII. Also, towel! (Note the IPv4 and IPv6 addresses use of 42 too)

telnet http://nyancat.dakko.us  
# The Nyan Cat (flying rainbow poptart cat) telnet server returns! https://nyancat.dakko.us/ 

#-----------------------------------------------------------------------///

# Download a file from a webserver with telnet
(echo 'GET /'; echo; sleep 1; ) | telnet www.google.com 80
# Explanation: If you are ever in a minimal headless *nix which does not have any command line utilities for downloading files (no curl, wget, lynx) but you have telnet, then this can be a workaround.
# Another option is netcat:
/usr/bin/printf 'GET / \n' | nc www.google.com 80
# Use lynx.
# It is pretty common for most of Unix/Linux.  -dump: dump the first file to stdout and exit
lynx -dump http://www.google.com

##############################################

# Diverse Maildienste auf der Kommandozeile testen
# Vertrauen ist gut, Kontrolle ist besser. Hier folgt eine Sammlung von Kommandozeilentests für diverse Maildienste (smtp, pop, imap...)

# Wir gehen davon aus, dass der Mailserver erfolgreich installiert ist, in diesem Fall sei das Postfix mit Postgrey und Amavis, das Zertifikat wurde erstellt, die erforderlichen Dienste laufen und die gewünschten Ports sind in der Firewall geöffnet. Die Dienste imap, imaps, pop3 und pop3s werden von Dovecot zur Verfügung gestellt.
# Als Beispieldomain verwende ich dein.mailserver.net, als Beispiel-IP 1.2.3.4, der Beispieluser (brauchen wir zum Testen der Dienste mit Login) heißt userlein und er hat das Passwort "geheim". Um es übersichtlicher zu machen, sind die einzugebenden Befehle grün, die Antworten des Servers, auf die es besonders ankommt sind blau. Nun aber zu den Praxisbeipielen:

# 1) Funktioniert der Mailserver überhaupt (Test am Server selbst):
#-----------------------------------------------------------------------///
telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 dein.mailserver.net ESMTP Postfix
quit
221 2.0.0 Bye
Connection closed by foreign host.

Er funktioniert, also lauscht auf Port 25.

# 2) Funktioniert Greylisting (Test von anderswo, eine frische IP, die der Mailserver, genau genommen Postgrey, noch nicht "kennt"):
#-----------------------------------------------------------------------///
telnet dein.mailserver.net 25
Trying 1.2.3.4...
Connected to dein.mailserver.net.
Escape character is '^]'.
220 dein.mailserver.net ESMTP Postfix
helo localhost
250 dein.mailserver.net
MAIL FROM:<[email protected]>
250 2.1.0 Ok
RCPT TO:<[email protected]>
450 4.7.1 <[email protected]>: Recipient address rejected: Greylisted, see http://yadda/yadda/yadda..
quit
221 2.0.0 Bye
Connection closed by foreign host.

Greylisting funktioniert. Nach der in postgrey konfigurierten Zeit (z.B. 5 Min.) darf man natürlich nicht nochmal im Greylisting hängen bleiben.

# 3) Wird relaying fremder Domains verweigert (muss es! Test von irgendwo):
#-----------------------------------------------------------------------///
telnet dein.mailserver.net 25
Trying 1.2.3.4...
Connected to dein.mailserver.net.
Escape character is '^]'.
220 dein.mailserver.net ESMTP Postfix
helo example.com
250 dein.mailserver.net
MAIL FROM:<[email protected]>
250 2.1.0 Ok
RCPT TO:<[email protected]>
554 5.7.1 <[email protected]>: Relay access denied
quit
221 2.0.0 Bye
Connection closed by foreign host.

Brav: "Relay access denied"

# 4) Funktioniert pop3 (vom Mailserver selbst, plaintext):
#-----------------------------------------------------------------------///
telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
USER userlein
+OK
PASS geheim
+OK Logged in.
LIST
+OK 3 messages:
1 4136
2 1705
3 1709
.
QUIT
+OK Logging out.
Connection closed by foreign host.

Verwendete Kommandos: USER, PASS, LIST, QUIT
Derselbe Test kann natürlich auch von remote ausgeführt werden.
Für diesen und die anderen Tests gilt: die Kommandos müssen nicht groß geschrieben werden.

# 5) Funktioniert imap (vom Mailserver selbst, plaintext):
#-----------------------------------------------------------------------///
telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
* OK Dovecot ready.
01 LOGIN userlein geheim
01 OK Logged in.
02 LIST "" *
* LIST (\NoInferiors \UnMarked) "/" "Queue"
* LIST (\NoInferiors \UnMarked) "/" "Sent"
* LIST (\NoInferiors \Marked) "/" "Trash"
* LIST (\NoInferiors \UnMarked) "/" "Drafts"
* LIST (\HasNoChildren \UnMarked) "/" "INBOX"
02 OK List completed.
03 LOGOUT
* BYE Logging out
03 OK Logout completed.
Connection closed by foreign host.

Verwendete Kommandos: LOGIN, LIST "" *, LOGOUT, immer mit Nummer davor. Wir lassen uns einfach unsere Ordner auflisten.

# 6) Funktioniert STARTTLS für smtp (getestet von remote):
#-----------------------------------------------------------------------///
telnet dein.mailserver.net 25
Trying 1.2.3.4...
Connected to dein.mailserver.net.
Escape character is '^]'.
220 dein.mailserver.net ESMTP Postfix
ehlo localhost
250-dein.mailserver.net
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.

Es wird auf alle Fälle vom MTA (Postfix) angeboten.
Die doppelte Angabe von "AUTH" ist übrigens kein Fehler, das gehört so - einmal mit, einmal ohne "=" (für manche Clients).

Funktioniert es aber auch wirklich?

openssl s_client -connect dein.mailserver.net:25 -crlf -starttls smtp

...sehr viel Info über den public key des Servers...
---
SSL handshake has read 1556 bytes and written 369 bytes
---
New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA
Server public key is 1024 bit
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : DHE-RSA-AES256-SHA
    Session-ID: D14E6blablabla
    Session-ID-ctx:
    Master-Key: 654C5blablabla
    Key-Arg   : None
    Start Time: 1262264795
    Timeout   : 300 (sec)
    Verify return code: 18 (self signed certificate)
---
250 DSN
quit
221 2.0.0 Bye
read:errno=0

Aha, es ist ein selbst unterzeichnetes Zertifikat, das auch wirklich funktioniert.

# 7) Funktionieren imaps und pop3s:
#-----------------------------------------------------------------------///

IMAPS wird mit folgendem Befehl getestet:

openssl s_client -connect dein.mailserver.net:993

POP3S mit folgendem:

openssl s_client -connect dein.mailserver.net:995

Im Dialog mit Dovecot (bietet in unserem Beispiel imap(s) und pop3(s)) funktionieren jeweils die selben Befehle wie bei Verbindungen ohne Verschlüsselung (siehe weiter oben).

# 8) Funktioniert der Virenfilter:
#-----------------------------------------------------------------------///
Das testet man am einfachsten mit dem Eicar Testvirus: www.eicar.org/anti_virus_test_file.htm
Einfach an einen lokalen User als Anhang schicken. Es darf nicht durchkommen.

# 9) Funktioniert der Spamfilter:
#-----------------------------------------------------------------------///
Auch das ist einfach: in der Datei /etc/mail/spamassassin/local.cf folgende Zeilen einfügen:

header  LOCAL_DEMO_SUBJECT      Subject =~ /halloweltdasistnurspam/
score   LOCAL_DEMO_SUBJECT      15.0

Amavisd durchladen und dann mit genau dem Betreff "halloweltdasistnurspam" ein Mail am besten von anderswo an einen lokalen User senden. Eventuell noch den Score anpassen.

echo 'ein testmail' | mail -s 'halloweltdasistnurspam' [email protected]

#-----------------------------------------------------------------------///

#==============================##==============================#
# CMD TELNET						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

55 - 🖥️traceroute

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the traceroute command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#    ████████╗██████╗  █████╗  ██████╗███████╗██████╗  ██████╗ ██╗   ██╗████████╗███████╗
#    ╚══██╔══╝██╔══██╗██╔══██╗██╔════╝██╔════╝██╔══██╗██╔═══██╗██║   ██║╚══██╔══╝██╔════╝
#       ██║   ██████╔╝███████║██║     █████╗  ██████╔╝██║   ██║██║   ██║   ██║   █████╗  
#       ██║   ██╔══██╗██╔══██║██║     ██╔══╝  ██╔══██╗██║   ██║██║   ██║   ██║   ██╔══╝  
#       ██║   ██║  ██║██║  ██║╚██████╗███████╗██║  ██║╚██████╔╝╚██████╔╝   ██║   ███████╗
#       ╚═╝   ╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝╚══════╝╚═╝  ╚═╝ ╚═════╝  ╚═════╝    ╚═╝   ╚══════╝
                                                                                                    
                                                                                                    

traceroute -m 255 xmas\.futile.net
# Christmas song lyrics from ICMP. Wait for the tree. 

traceroute linux.fi |awk '($2~/[.]/){"geoiplookup "$2 |getline g;$0=sprintf("%-64s %s", $0, g)}{print}'
# GeoIP traceroute 

#==============================##==============================#
# CMD traceroute
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

56 - 🖥️tshark

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the tshark command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ████████╗███████╗██╗  ██╗ █████╗ ██████╗ ██╗  ██╗
#  ╚══██╔══╝██╔════╝██║  ██║██╔══██╗██╔══██╗██║ ██╔╝
#     ██║   ███████╗███████║███████║██████╔╝█████╔╝ 
#     ██║   ╚════██║██╔══██║██╔══██║██╔══██╗██╔═██╗ 
#     ██║   ███████║██║  ██║██║  ██║██║  ██║██║  ██╗
#     ╚═╝   ╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

screen -d -r 
tshark -i eth0 -b filesize:51200 -w hostname.pcapng host 12.46.124.2 or host 12.41.40.125 or host 12.43.32.2  or host 12.46.104.2
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

57 - 🖥️wget

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the wget command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██╗    ██╗ ██████╗ ███████╗████████╗
#                ██║    ██║██╔════╝ ██╔════╝╚══██╔══╝
#                ██║ █╗ ██║██║  ███╗█████╗     ██║   
#                ██║███╗██║██║   ██║██╔══╝     ██║   
#                ╚███╔███╔╝╚██████╔╝███████╗   ██║   
#                 ╚══╝╚══╝  ╚═════╝ ╚══════╝   ╚═╝   
                

                                                  
# To download a single file
wget http://path.to.the/file

# To download a file and change its name
wget http://path.to.the/file -O newname

# To download a file into a directory
wget -P path/to/directory http://path.to.the/file

# To continue an aborted downloaded
wget -c http://path.to.the/file

# To download multiples files with multiple URLs
wget URL1 URL2

# To parse a file that contains a list of URLs to fetch each one
wget -i url_list.txt

# To mirror a whole page locally
wget -pk http://path.to.the/page.html

# To mirror a whole site locally
wget -mk http://site.tl/

# To download files according to a pattern
wget http://www.myserver.com/files-{1..15}.tar.bz2

# To download all the files in a directory with a specific extension if directory indexing is enabled
wget -r -l1 -A.extension http://myserver.com/directory

# Allows you to download just the headers of responses (-S --spider) and display them on Stdout (-O -).
wget -S --spider -O - http://google.com

# Change the User-Agent to 'User-Agent: toto' -> Useragenten fälschen
wget -U 'toto' http://google.com

#==============================#
# CMD WGET - https://www.gnu.org/software/wget/manual/wget.html
#==============================##==============================#
wget --limit-rate=50k  oder --limit-rate=10m
# Bandbreitenbegrenzung auf 50k oder 10 Mbyte pro Sekunde

wget --dns-servers 8.8.8.8 http://www.gnu.org
# 

wget --spider --fore-html -i bookmarks.html
# Damit testet wget ob die genannten URL's existieren, lädt aber nix herunter --force-html weist wget auf eine Datei in der Links liegen. (Bookmarktest)

wget -c http://example\.com/dvd.iso
# Finish a download started by a previous instance of wget, or  by another program

wget -O- ftp://ftp.funet\.fi/pub/linux/kernel/Historic/linux-0.01.tar.gz|tar ztv|sort -k4 
# Evidence that Linux was released Sept 17th 1991

wget -m http://www.example\.com/
# Quick and easy way to make a mirror of a website. Der Parameter -m erhält FTP-Verzeichnislisten, beherrscht Timestamping und holt rekursiv unbegrenzt tiefe Verzeichnisebenen vom Server. Bei einem 2. Aufruf, werden nur noch die geänderten Dateien neu geholt. 

wget -m http://www.example.com/  
# Quick and easy way to make a mirror of a website.

wget -q -O- -U Mozilla "http://translate.google \.com/translate_tts?q=hello&tl=en"|mpg123 -q -
# Say hello using a nice voice.

wget -c 							
# continue 

wget -b 							
# background

wget -N
# Dieser Parameter sorgt dafür das nur Dateien die noch nicht auf Festplatte liegen heruntergeladen werden

wget -r -l 2 ftp://ftp.hlifax.rwth-aachen.de/ubuntu-releases/
# -r weist wget an rekursiv in die Unterverzeichnisse hinabzusteigen und dort jeweils alle Dateien herunterzuladen
#  Standartmaessig steigt wget dabei 5 Verzeichnistiefen ab. Mit -l inf hebt diese Begrenzung auf

wget -E
# Hängt weget die Endung .html an

wget --no-check-certificate
wget --secure-protocol=TLSv1_2     # SSL bzw. TLS erzwingen   
wget --secure-protocol=PFS         # Perfect Forward Secrecy erzwingen
# laed auch sachen von einem Selbstsignierten Zertifikat runter

wget -p -k https://www.wikipedia.org
# Webseiten mit Umleitungen downloaden - ansonsten noch ein -r

wget -p -r -l 1 -k https://www.gnu.org
# wget holt nicht nur die Startseite sondern alle weiteren Seiten die verlinkt sind. -r -l 1 bewirkt nicht das selbe wie -p. -p sort dafür das alle zum Anzeigen benötigten Dateien geladen werden. -k sort abschließend dafür, dass die Seiten auch offline lesbar sind. Dateien landen in Unterordnern die Namen des Servers tragen. Unterbinden kann man das mit -nH. wget holt dann alles ins aktuelle Verzeichnis.

wget -r -l 1 -A jpg,jpeg,png,gif http://www.gnu.org
# Sämtliche Bilder einer Site downloaden - -A nur dateien mit der Endung

wget -r -A iso ftp://ftp.halifax.rwth-aachen.de/ubuntu-releases/16.10/
# Lädt alle .iso-Dateien herunter. mit -R können Dateien ausgeschlossen werden: -R mp4 umd Videos auszuschliesßen

wget --ftp-user USER --ftp-pass PASS
# mit password

wget http://icanhazip.com -qO-
# Get your outgoing IP address 

wget -qO- icanhazip.com
# Get your external IP address without curl

wget -nc -nH -E -r -k -P /home/you/example.com -np http://example.com/
# BASH -> Linux command prompt / AndrewChamp/Download website (scrapping)

wget http://shells.aachen.ccc.de/~spq/md5.gif ; md5sum md5.gif; echo whoa
# get + check

wget -b -o ausgabe.txt http://releses.ubuntu.com/16.10/ubuntu-16.10-desktop-amd64.iso
# -b schickt programm in Hintergrund. Die Programmausgabe wird mit -o in die Datei ausgaben.txt gelenkt

wget -c http://releses.ubuntu.com/16.10/ubuntu-16.10-desktop-amd64.iso
# wget wird abgebrochen via strg+c -> Download wiederaufnahme  mit diesem Befehl

wget --user=tim --password=123 ftp://ftp.example.com/ubuntu.iso
# wget von ftpserver mit user und password - ps -A zeigt allerdings password dann im klartext

wget --user=tim --ask-password ftp://ftp.example.com/ubuntu.iso
# wget von ftpserver mit user und password - password wird dann beim Aufbau von wget abgefragt

.wgetrc
# user= und passwd=   Diese Datei im homeverzeichnis hinterlegen. Eine Zeile verbose = off entspricht beispielsweise dem Parameter -nv, und wget gibt nur absolut nötige Informationen aus. Jede Einstellung erhält eine eigene Zeile, hinter dem Gleichheitszeichen hinterlegen Sie den gewünschten Wert. Alle mit einem Hash-Zeichen "#"auskommentierten Zeilen ignoriert wget. Die Vorgaben der .wgetrc werden mit Parameter auf Kommandozeile überschrieben. Systemweite gltige Vorgaben für wget sind unter /etc/wgetrc oder /usr/local/etc/wgetrc

wget ftp://ftp.halifax.rwth-aachen.de/ubuntu-releases/16.10/*.iso
# Bei FTP Verbindungen dürfen Sie die bekannten Platzhaltersymbole * und ? verwenden. Damit lassen sich beispielsweise sämtliche Dateien mit der Endung .iso holen.

wget -i urls.txt
# wget holt alle URLs in der Datei urls.txt ab

wget --spider -B https://doc.lagout.org --no-check-certificate --continue --convert-links -r -p -e robots=off -U mozilla "https://doc.lagout.org/"  --restrict-file-names=nocontrol -o URLS.list

wget --spider --no-check-certificate --continue --convert-links -r -p --no-clobber -e robots=off -U mozilla "https://doc.lagout.org/"

wget --no-check-certificate -O config.xml "https://your.ironport.box/login?username=admin&password=your_password&action:Login=Login&referrer=https
%3A%2F%2Fyour.ironport.box%2Fsystem_administration%2Fconfiguration_file?acti
on=Save%26operation=download"

wget --mirror -p --html-extension --convert-links [HOST]
# TIL: wget is an extremely powerful scraper.

# spider
wget --spider --recursive --no-verbose --no-parent -t 3 --output-file=wgetlog.txt http://www.asciiartfarts.com

wget -w1 http://www.example\.com/{00..23}h{00,15,30,45}m.png 
# Download a series of timed images from a site with 1 second delay between.

# Force the preferred language when downloading a web page with wget
wget -–header='Accept-Language: en-us' http://www.timeanddate.com/calendar/index.html?year=2008&country=26 -O calendar.html
# Explanation: 
        # When downloading web pages with wget, some websites try to be smart and detect your preferred language based on geographical location of your IP address. This can be a problem if for example you are in Japan but you want to download a page in English.

# Print a random cat
wget -O - http://placekitten.com/$[500 + RANDOM % 500] | lp
# Explanation: 
        # $RANDOM gives a random number. # http://placekitten.com is your cat place
        # wget -O - sends the output to stdout
        # lp prints
# Limitations: 
        # Tested on OSX

# Getting mp4 links from webpage
while read -r url; do wget $url; done < list_or_urls
grep -o '"http://[^"]"' ./ | grep mp4

# BASH -> Linux command prompt Download website (scrapping)
wget -nc -nH -E -r -k -P /home/you/example.com -np http://example.com/

# Write a bootable Linux .iso file directly to a USB-stick - Writes hybrid ISO directly to USB stick; replace /dev/sdb with USB device in question and the ISO image link with the link of your choice
wget -O /dev/sdb https://cdimage.ubuntu.com/daily-live/current/xen-desktop-amd64.iso

#==============================##==============================#
# CMD WGET 
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

58 - 🖥️whois

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the whois command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██╗    ██╗██╗  ██╗ ██████╗ ██╗███████╗
#                ██║    ██║██║  ██║██╔═══██╗██║██╔════╝
#                ██║ █╗ ██║███████║██║   ██║██║███████╗
#                ██║███╗██║██╔══██║██║   ██║██║╚════██║
#                ╚███╔███╔╝██║  ██║╚██████╔╝██║███████║
#                 ╚══╝╚══╝ ╚═╝  ╚═╝ ╚═════╝ ╚═╝╚══════╝
                                                      
                                                      
whois http://slashdot.org  | awk '/Creation Date/{print $NF}' 
# Get the creation date of a domain. Happy anniversary Slashdot. 

whois $(dig +short towel.blinkenlights\.nl) 
# May not be able to do this much longer. By the way, you can telnet to that hostname too for some ASCII art entertainment.

#==============================##==============================#
# CMD WHOIS						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░