Learn Python. Do Pythonic things.

http client using a library

#!/usr/bin/python
# HTTP Client using a library

import urllib2

response = urllib2.urlopen('http://vulnerable/')

print response.read()

#print response.info()

#html = response.read()
response.close() # Best practice to close the file

http client using a socket

#!/usr/bin/python
# HTTP Client using a socket

import socket

# create an INET, STREAMing socket
s= socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# now connect to the Vulnerable web server on port 80 - the normal http port
s.connect(("vulnerable" , 80))

#Send a GET reqest?
s.sendall("GET /\r\n")


print s.recv(4096)
s.close

A different http client that I found online

#!/usr/bin/python
# HTTP Client with Header Info

import httplib

# connect to HTTP server, send GET request, receive response
h = httplib.HTTPConnection('vulnerable')
h.request('GET', '')
r = h.getresponse()

# get and print HTTP header response
rh = r.getheaders()
print 'Header:'
for i in rh:
    print i[0], ':', i[1]
print '\n'

# get and print content of response
rr = r.read()
print 'Content:'
print rr
print '\n'

# close HTTP connection to server
h.close()

results matching ""

    No results matching ""