👨🏼‍💻개발/Scapy

Scapy - Scapy로 지나가는 패킷 확인하기

Janger 2021. 12. 5. 01:00
728x90
#!/usr/bin/python  
from scapy.all import*  
  
protocols = {1:'ICMP', 6:'TCP', 17:'UDP'}  
  
def showPacket(packet):  
    src_ip = packet[0][1].src  
    dst_ip = packet[0][1].dst  
    proto = packet[0][1].proto  
  
    if proto in protocols:  
        print( "protocol: %s: %s -> %s" %(protocols[proto], src_ip, dst_ip)  )
		
        if proto == 1:  
            print( "TYPE: [%d], CODE[%d]" %(packet[0][2].type, packet[0][2].code)  )
  
def sniffing(filter):  
    sniff(filter = filter, prn = showPacket, count = 0)  
  
if __name__ == '__main__':  
    filter = 'ip'  
    sniffing(filter)

 

출처: 

https://secretpack.tistory.com/112

 

Python - Scapy (메세지 내용 가로채기)

파이썬으로 구현된 Scapy라는 패키지를 이용하면 보다 쉽게 패킷을 스니핑 할 수 있다. [ 설치 ] sudo pip install scapy 혹은 https://github.com/phaethon/scapy [ 스니퍼 구현 ] #!/usr/bin/python  from sca..

secretpack.tistory.com

 

728x90