Harman5007

sniffing

Jun 18th, 2020
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. import socket
  2. import os
  3.  
  4. # host to listen on
  5. host = "192.168.43.162"
  6.  
  7. # create a raw socket and bind it to the public interface
  8.  
  9. socket_protocol = socket.IPPROTO_ICMP
  10. sniffer = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket_protocol)
  11. sniffer.bind((host, 0))
  12.  
  13. # we want the IP headers included in the capture
  14. sniffer.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
  15.  
  16. # read in a single packet
  17. print(sniffer.recvfrom(65565))
Add Comment
Please, Sign In to add comment