h4cker/python_ruby_and_bash/http_sniffer.py

25 lines
485 B
Python
Raw Normal View History

2019-03-31 04:17:37 +00:00
#!/usr/bin/python
from __future__ import print_function
2019-03-31 04:17:37 +00:00
import socket
s=socket.socket(socket.PF_PACKET, socket.SOCK_RAW, socket.ntohs(0x0800))
while True:
data=s.recvfrom(65535)
2019-03-31 04:17:37 +00:00
try:
if "HTTP" in data[0][54:]:
print("[","="*30,']')
2019-03-31 04:17:37 +00:00
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'):])
2019-03-31 04:17:37 +00:00
else:
print(raw)
2019-03-31 04:17:37 +00:00
else:
#print '[{}]'.format(data)
pass
except:
pass