mirror of
https://github.com/autistic-symposium/web3-starter-py.git
synced 2025-05-17 14:10:21 -04:00
💾
This commit is contained in:
parent
7cb7a479f6
commit
69bb4175f1
124 changed files with 20 additions and 15 deletions
33
boilerplates/security/python_sniff_scanner/sniff_example.py
Normal file
33
boilerplates/security/python_sniff_scanner/sniff_example.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
import os
|
||||
import socket
|
||||
|
||||
|
||||
# host to listen
|
||||
HOST = '192.168.1.114'
|
||||
|
||||
|
||||
def sniffing(host, win, socket_prot):
|
||||
|
||||
while True:
|
||||
sniffer = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket_prot)
|
||||
sniffer.bind((host, 0))
|
||||
|
||||
# include the IP headers in the captured packets
|
||||
sniffer.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
|
||||
|
||||
if win == 1:
|
||||
sniffer.ioctl(socket.SIO_RCVALL, socket_RCVALL_ON)
|
||||
|
||||
# read in a single packet
|
||||
print(sniffer.recvfrom(65565))
|
||||
|
||||
|
||||
def main(host):
|
||||
if os.name == 'nt':
|
||||
sniffing(host, 1, socket.IPPROTO_IP)
|
||||
else:
|
||||
sniffing(host, 0, socket.IPPROTO_ICMP)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(HOST)
|
Loading…
Add table
Add a link
Reference in a new issue