Linux/모의해킹

MAC 주소 변경하기

GGkeeper 2022. 1. 6. 17:21

실습> MAC 주소 변경하기

Gateway의 MAC 주소를 변경해서 외부와 통신이 되는지 테스트한다.
LAN(Local Area Network)에서는 Host 끼리의 통신은 MAC주소로 통신한다.
MAC주소가 다르면 통신이 안된다.

Gateway : 
변경 전 : 192.168.108.2 00:50:56:e2:02:72
변경 후 : 192.168.108.2 aa:bb:cc:dd:ee:ff

1. 외부 통신
외부에 통신이 되는지 확인한다.
Attacker# ping -c 3 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=47.9 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=47.6 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=128 time=46.8 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 46.762/47.402/47.868/0.468 ms

2. ARP 캐쉬 테이블 확인

Gateway 의 MAC 주소를 확인한다.
Attacker# arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.108.1            ether   00:50:56:c0:00:08   C                     eth0
192.168.108.2            ether   00:50:56:e2:02:72   C                     eth0
192.168.108.104          ether   00:0c:29:1c:3a:76   C                     eth0

 

3. 고정 MAC 주소 변경

Gateway 의 MAC 주소를 없는 임의의 MAC 주소로 변경한다.
Attacker# arp -s 192.168.108.2 aa:bb:cc:dd:ee:ff

 

변경된 Gateway 의 MAC 주소를 확인한다.
Attacker# arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.108.1            ether   00:50:56:c0:00:08   C                     eth0
192.168.108.2            ether   aa:bb:cc:dd:ee:ff   CM                    eth0
192.168.108.104          ether   00:0c:29:1c:3a:76   C                     eth0

 

4. 통신 확인
Gateway의 MAC주소가 다르면 통신이 안된다.
외부와 통신이 안되는 2가지 
- Gateway의 IP주소가 OS에서 다르면 외부에 접근할 수 없다.
- Gateway의 IP주소는 맞지만 MAC 주소가 다르면 OS에서 다르면 외부에 접근할 수 없다.
Attacker# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.

 

5. 복구
통신이 안되는 것을 확인했다면 arp -d 를 이용해서 수동으로 설정한 MAC주소를 삭제한다.
Attacker# arp -d 192.168.108.2

외부와 통신이 되는지 확인한다.
Attacker# ping -c 3 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=48.1 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=47.7 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=128 time=47.2 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 47.226/47.672/48.141/0.373 ms