scapy 도구에 대해 설명을 본 도구를 제공하는 홈페이지의 설명을 빌려 하자면,
scapy는 강력한 패킷 조작 도구이다.
수 많은, 다양한 프로토콜들에 대한 패킷 디코드 하거나 조작한다고 한다.
또한, 네트워크 확인, 스캐닝, tracerouting과 같은 일반적 수집 작업도 가능하다.
다양한 정보 수집 기능이 있는 scapy에 대해서 홈페이지를 참고하면 더 자세한 정보를 구할 수 있다.
scapy 홈페이지
Scapy
Packet crafting for Python2 and Python3
scapy.net
scapy도 여느 다른 도구들처럼 파이썬으로 작성되어 있고,
사용 방법도 간단하다.
scapy사용은 그냥 scapy라고 입력하면 된다
그러면 scapy 관련 모듈이 로드되고
먼저, scapy에서 어떤 명령을 실행할 수 있는지 lsc()라고 입력한다
그러면, 아래 표와 같이 다양한 명령어 옵션 설명을 확인 할 수 있다.
IPID_count : Identify IP id values classes in a list of packets arpcachepoison : Poison target's cache with (your MAC,victim's IP) couple arping : Send ARP who-has requests to determine which hosts are up arpleak : Exploit ARP leak flaws, like NetBSD-SA2017-002. bind_layers : Bind 2 layers on some specific fields' values. bridge_and_sniff : Forward traffic between interfaces if1 and if2, sniff and return chexdump : Build a per byte hexadecimal representation computeNIGroupAddr : Compute the NI group Address. Can take a FQDN as input parameter corrupt_bits : corrupt_bytes : defrag : defrag(plist) -> ([not fragmented], [defragmented], defragment : defragment(plist) -> plist defragmented as much as possible dhcp_request : Send a DHCP discover request and return the answer dyndns_add : Send a DNS add message to a nameserver for "name" to have a new "rdata" dyndns_del : Send a DNS delete message to a nameserver for "name" etherleak : Exploit Etherleak flaw explore : Function used to discover the Scapy layers and protocols. fletcher16_checkbytes: Calculates the Fletcher-16 checkbytes returned as 2 byte binary-string. fletcher16_checksum : Calculates Fletcher-16 checksum of the given buffer. fragleak : -- fragleak2 : -- fragment : Fragment a big IP datagram fuzz : getmacbyip : Return MAC address corresponding to a given IP address getmacbyip6 : Returns the MAC address corresponding to an IPv6 address hexdiff : hexdump : Build a tcpdump like hexadecimal view hexedit : Run hexedit on a list of packets, then return the edited packets. hexstr : Build a fancy tcpdump like hex from bytes. import_hexcap : Imports a tcpdump like hexadecimal view is_promisc : Try to guess if target is in Promisc mode. The target is provided by its ip. linehexdump : Build an equivalent view of hexdump() on a single line ls : List available layers, or infos on a given layer class or name. neighsol : Sends and receive an ICMPv6 Neighbor Solicitation message overlap_frag : Build overlapping fragments to bypass NIPS promiscping : Send ARP who-has requests to determine which hosts are in promiscuous mode rdpcap : Read a pcap or pcapng file and return a packet list report_ports : portscan a target and output a LaTeX table restart : Restarts scapy rfc : send : sendp : sendpfast : Send packets at layer 2 using tcpreplay for performance sniff : split_layers : Split 2 layers previously bound. sr : sr1 : sr1flood : Flood and receive packets at layer 3 and return only the first answer srbt : send and receive using a bluetooth socket srbt1 : send and receive 1 packet using a bluetooth socket srflood : Flood and receive packets at layer 3 srloop : srp : srp1 : srp1flood : Flood and receive packets at layer 2 and return only the first answer srpflood : Flood and receive packets at layer 2 srploop : tcpdump : Run tcpdump or tshark on a list of packets. tdecode : traceroute : Instant TCP traceroute traceroute6 : Instant TCP traceroute using IPv6 traceroute_map : Util function to call traceroute on multiple targets, then tshark : Sniff packets and print them calling pkt.summary(). wireshark : wrpcap : Write a list of packets to a pcap file |
위 명령어 중 sniff()는 기본적인 패킷 덤프 명령어이다.
sniff()를 입력하면,
아무 표시 없이 대기 상태처럼 보이는데,
일정 시간 지난 후 Ctrl+C를 눌러서 정지를 시키자
그러면, TCP 패킷 2,892개, UDP 패킷 8개, Other 패킷 8개를 덤프 한 것으로 출력한다.
sniff() 함수 안에 조금 더 옵션을 넣어 줄 수 있는데,
위에 보이는 것 처럼 TCP, UDP, ICMP 등 특정 프로토콜에 대한 옵션을 선택할 수 있고,
count 옵션을 추가하여 덤프할 때 패킷 수를 지정할 수도 있다.
그러면 원하는 패킷 수만 덤프하고 강제 종료가 아닌 자동 종료를 할 수 있게 된다.
특정 IP에 대해서 패킷 수집을 원한다면,
sniff 함수 안에 filter 옵션을 이용하여 IP를 지정하면 된다.
그러면 그림과 같이 해당 IP에 대한 패킷을 수집한다.
수집한 패킷을 볼 수 있어야 한다.
그래서 다시 한 번 패킷을 수집하고 패킷 내용을 보는 방법을 알아본다.
1. sniff()에서 특정 IP에 대한 패킷을 수집한다.
2. 수집한 패킷은 "_" 변수에 저장이 되고, 변수 a라는 것으로 저장을 한다.
3. a.nsummary()를 통해 수집한 패킷이 있는지 확인한다.
4. 수집한 패킷 중 2번째 수집한 패킷 a[1]을 호출한다.
참고로, a[1] 이 2 번째 수집 패킷, a[0]이 첫 번째 수집 패킷
패킷 raw 데이터 값을 확인 할 수 있다.
와이어샤크에서 보여주는 것처럼 패킷을 확인하고 싶다면,
hexdump()를 활용할 수 있다.
scapy의 기능은 상당하여 기본적인 내용만 살핀다.
이 도구에 대한 튜토리얼을 여기서 제공한다.
Welcome to Scapy’s documentation! — Scapy 2.5.0 documentation
© Copyright 2008-2022 Philippe Biondi and the Scapy community. Revision 6d0d2307.
scapy.readthedocs.io
파이썬으로 작성된 강력한 정보수집 도구 scapy였다.
'===취미 세상 : 공부=== > 칼리리눅스' 카테고리의 다른 글
[정보수집] httprint (0) | 2022.11.30 |
---|---|
[정보수집] NMAP (0) | 2022.11.26 |
[정보수집] unicornscan (0) | 2022.11.15 |
[정보수집] netenum (0) | 2022.11.14 |
[정보수집] protos (0) | 2022.11.13 |