A problem with urllib
Bryan Olson
fakeaddress at nowhere.org
Tue Jul 2 20:57:17 EDT 2002
Aki Niimura wrote:
> I tried the script both from Solaris and from Windows, but I got the
> same result.
Ah, the base64.encodestring() includes a "\n" at the end of the output.
In the version below, I strip it off. I've tested this with the current
firmware version, and the "good" case works, while the "bad" case
triggers the Linksys bug.
--Bryan
import socket
import base64
for demo in ("good", "bad"):
request_line = "GET /Status.htm HTTP/1.0\r\n"
auth_header = ("Authorization: Basic %s\r\n" %
base64.encodestring(":admin").strip())
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("192.168.1.1", 80))
if demo == "good":
s.send(request_line + auth_header + "\r\n")
else:
s.send(request_line)
s.send(auth_header + "\r\n")
s.shutdown(1)
print s.recv(99999)
s.close()
print "\n\n\n\n"
More information about the Python-list
mailing list