linux - Python Import issues: AttributeError: 'NoneType' object has no attribute 'fields' -
i'm trying write little python script on linux embedded scapy lib. on osx or linux box don't have problem this:
from scapy.all import ip, sniff scapy.layers import http import urllib, re def process_tcp_packet(packet): http_layer = packet.getlayer(http.httprequest) ip_layer = packet.getlayer(ip) url = str('{1[path]}'.format(ip_layer.fields, http_layer.fields)) if url: url = urllib.unquote(url).decode('utf8') print re.findall(r'(https?://\s+lh1)', url) sniff(filter="tcp , host hostexample.com", prn=process_tcp_packet)
the scapy folder looks this:
enter code here /scapy __init__.py all.py ... /layers __init__.py http.py dhcp.py ...
when start script, seems modules imported line:
url = str('{1[path]}'.format(ip_layer.fields, http_layer.fields))
return error:
attributeerror: 'nonetype' object has no attribute 'fields' -->end of python script error report<--
any appreciated! thanks!
"print http_layer" on osx-box:
get path: someurl.... http-version: http/1.1 host: hostexample.com user-agent: mozilla/5.0 (macintosh; intel mac os x 10.10; rv:37.0) gecko/20100101 firefox/37.0 accept: image/png,image/*;q=0.8,*/*;q=0.5 accept-language: de,en-us;q=0.7,en;q=0.3 accept-encoding: gzip, deflate referer: http://hostexample/someurl connection: keep-alive
on embedded: "none"
Comments
Post a Comment