mirror of
https://github.com/The-Art-of-Hacking/h4cker.git
synced 2024-12-18 10:56:09 +00:00
creating python sniffers
This commit is contained in:
parent
650ca73d87
commit
90bfcbb327
23
python_ruby_and_bash/http_sniffer.py
Normal file
23
python_ruby_and_bash/http_sniffer.py
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import socket
|
||||
|
||||
s=socket.socket(socket.PF_PACKET, socket.SOCK_RAW, socket.ntohs(0x0800))
|
||||
|
||||
while True:
|
||||
data=s.recvfrom(65565)
|
||||
try:
|
||||
if "HTTP" in data[0][54:]:
|
||||
print "[","="*30,']'
|
||||
raw=data[0][54:]
|
||||
if "\r\n\r\n" in raw:
|
||||
line=raw.split('\r\n\r\n')[0]
|
||||
print "[*] Header Captured "
|
||||
print line[line.find('HTTP'):]
|
||||
else:
|
||||
print raw
|
||||
else:
|
||||
#print '[{}]'.format(data)
|
||||
pass
|
||||
except:
|
||||
pass
|
17
python_ruby_and_bash/python_sniffer.py
Normal file
17
python_ruby_and_bash/python_sniffer.py
Normal file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/python
|
||||
# Author: Omar Santos @santosomar
|
||||
# version 1.0
|
||||
# This is a quick demonstration on how to create a
|
||||
# snifffer (packet capture script) using python.
|
||||
#####################################################################
|
||||
|
||||
import socket
|
||||
|
||||
#create an INET, raw socket
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP)
|
||||
|
||||
# receive a packet
|
||||
while True:
|
||||
|
||||
# print output on terminal
|
||||
print s.recvfrom(65565)
|
Loading…
Reference in New Issue
Block a user