Appendices Chapter 5

Untitled

Appendix E: Quick Reference Cards

Port Numbers Reference

Well-Known Ports (0-1023)

PortProtocolService
20TCPFTP Data
21TCPFTP Control
22TCPSSH
23TCPTelnet
25TCPSMTP
53TCP/UDPDNS
67UDPDHCP Server
68UDPDHCP Client
69UDPTFTP
80TCPHTTP
110TCPPOP3
119TCPNNTP
123UDPNTP
143TCPIMAP
161UDPSNMP
162UDPSNMP Trap
389TCPLDAP
443TCPHTTPS
445TCPSMB
465TCPSMTPS
514UDPSyslog
587TCPSMTP Submission
636TCPLDAPS
993TCPIMAPS
995TCPPOP3S

Common High Ports

PortProtocolService
1433TCPMS SQL
1521TCPOracle
3306TCPMySQL
3389TCPRDP
5432TCPPostgreSQL
5900TCPVNC
6379TCPRedis
8080TCPHTTP Proxy
8443TCPHTTPS Alt
9200TCPElasticsearch
27017TCPMongoDB

Nmap Cheat Sheet

Basic Scans

# Host discovery
nmap -sn 192.168.1.0/24

# TCP SYN scan (default)
nmap -sS 192.168.1.100

# TCP connect scan
nmap -sT 192.168.1.100

# UDP scan
nmap -sU 192.168.1.100

# Version detection
nmap -sV 192.168.1.100

# OS detection
nmap -O 192.168.1.100

# Aggressive scan
nmap -A 192.168.1.100

Port Selection

# Specific ports
nmap -p 22,80,443 target

# Port range
nmap -p 1-1000 target

# All ports
nmap -p- target

# Top ports
nmap --top-ports 100 target

Output

# Normal output
nmap -oN output.txt target

# XML output
nmap -oX output.xml target

# All formats
nmap -oA output target

Wireshark Filters

Display Filters

# IP address
ip.addr == 192.168.1.100
ip.src == 192.168.1.100
ip.dst == 192.168.1.100

# Protocol
tcp
udp
icmp
dns
http
tls

# Port
tcp.port == 80
tcp.dstport == 443
udp.port == 53

# TCP Flags
tcp.flags.syn == 1
tcp.flags.ack == 1
tcp.flags.fin == 1
tcp.flags.rst == 1

# Combinations
ip.addr == 192.168.1.100 and tcp.port == 80
http or dns
tcp.flags.syn == 1 and tcp.flags.ack == 0

Capture Filters (BPF)

# Host
host 192.168.1.100

# Network
net 192.168.1.0/24

# Port
port 80
tcp port 443

# Protocol
icmp
tcp
udp

Linux Network Commands

Interface Configuration

# Show interfaces
ip addr
ifconfig -a

# Show routes
ip route
route -n

# Show ARP
ip neigh
arp -a

# Enable interface
ip link set eth0 up

# Set IP address
ip addr add 192.168.1.100/24 dev eth0

Traffic Analysis

# Capture packets
tcpdump -i eth0 -w capture.pcap

# Read capture
tcpdump -r capture.pcap

# Show connections
netstat -ant
ss -ant

# Monitor bandwidth
iftop -i eth0

Firewall (iptables)

# List rules
iptables -L -v -n

# Allow incoming SSH
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# Block IP
iptables -A INPUT -s 10.10.10.10 -j DROP

# Allow established
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Save rules
iptables-save > /etc/iptables.rules

Protocol Headers

IPv4 Header

0 1 2 3

0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version|  IHL  |Type of Service|          Total Length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Identification        |Flags|     Fragment Offset     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Time to Live |    Protocol   |         Header Checksum       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Source Address                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Destination Address                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

TCP Header

0 1 2 3

0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Source Port          |       Destination Port        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Sequence Number                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Acknowledgment Number                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Data |       |C|E|U|A|P|R|S|F|                               |
| Offset|  Res  |W|C|R|C|S|S|Y|I|            Window             |
|       |       |R|E|G|K|H|T|N|N|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Checksum            |         Urgent Pointer        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Attack Quick Reference

Layer 2

AttackToolDefense
ARP Spoofarpspoof, bettercapDAI
MAC FloodmacofPort Security
VLAN HopyersiniaDisable DTP

Layer 3

AttackToolDefense
IP Spoofscapy, hping3uRPF, BCP38
ICMP Floodhping3Rate limiting

Layer 4

AttackToolDefense
SYN Floodhping3SYN cookies
Port ScannmapIDS, firewall

Layer 7

AttackToolDefense
DNS PoisonscapyDNSSEC
HTTP FloodslowlorisWAF, rate limit

MITRE ATT&CK Quick Reference

Network Techniques

IDTechniqueDescription
T1046Network Service DiscoveryPort scanning
T1040Network SniffingPacket capture
T1557Adversary-in-the-MiddleMITM attacks
T1498Network DoSDDoS attacks
T1071Application Layer ProtocolC2 over HTTP/DNS
T1572Protocol TunnelingDNS/ICMP tunneling