bin letztens auf nen kleinen python websniffer gestoßen den ich selber bissl erweitern will.
hier mal schnell der code:
Code: Alles auswählen
#!/usr/bin/python
"""WEBSNIFFER"""
import httplib
import string
import os
opera = { "User-Agent":"Opera/9.20 (Windows NT 6.0; U; en)",
"Accept-Charset":"ISO-8859-1, UTF-8; q=0.7, *; q=0.7",
"Cache-Control":"no",
"Accept-Language":"de, en; q=0.7, en-us; q=0.3",
"Referer":"http://www.google.de" }
domain = 'www.harlekin-bowling.de'
path = '/'
method = 'GET'
params = None
profile = opera
conn = httplib.HTTPConnection (domain)
conn.request (method, path, params, profile)
stat = conn.getresponse()
headers = stat.getheaders()
version = stat.version
status = stat.status
reason = stat.reason
data = stat.read()
conn.close()
file_name = domain.replace (".", "-")
file_object = open (file_name, "w")
file_object.write (data)
file_object.close()
print "\n"
print "WEBSNIFFER 0.1"
print 20 * "-"
print "\n"
print "Header (Client)"
print 20 * "-"
for key, value in profile.iteritems():
print "%s \t %s" % (key, value)
print 20 * "-"
print "\n"
print "Header (Server)"
print 20 * "-"
print "HTTP \t %s" % (version)
print "Status \t %s (%s)" % (status, reason)
for key, value in headers:
print "%s \t %s" % (key, value)
print 20 * "-"
print "\n"
print "Quelltext - geschrieben in file:"
print file_name
print 20 * "-"
print "\n"
: No such file or directory1: #!/usr/bin/python
: command not foundy: line 2:
: command not foundy: line 3: programmbeschreibung
: command not foundy: line 4:
./websnifferStart.py: line 5: import: command not found
./websnifferStart.py: line 6: import: command not found
./websnifferStart.py: line 7: import: command not found
: command not foundy: line 8:
denke daran kann man deutlich sehen dass das prog nicht interpretiert wird durch den python interpreter. rufe ich das skript mit "python websniffer.py" auf funktioniert es wunderbar! auch jemand anders hat das bei sich getestet u es hat wunderbar geklappt.
/usr/bin/python zeigt bei mir auf /usr/bin/python2.5.
könnt ihr mir bitte helfen? warum funktioniert der shebang nicht?
ach ja...bei:
Code: Alles auswählen
#!/usr/bin/python
print "Hello World!"