mirror of
https://github.com/autistic-symposium/sec-pentesting-toolkit.git
synced 2025-05-05 00:05:07 -04:00
docs: Clean up resources for Hackoctoberfest 2019 (#41)
* Clean up resources for Hackoctoberfest 2019
* 👩🏾🦱 Add cloud hacking readme
This commit is contained in:
parent
746d808fc0
commit
9ed0254149
458 changed files with 9658 additions and 57 deletions
76
Web_Hacking/urllib2/simple_http_requests.py
Normal file
76
Web_Hacking/urllib2/simple_http_requests.py
Normal file
|
@ -0,0 +1,76 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
__author__ = "bt3"
|
||||
|
||||
import urllib2
|
||||
import urllib
|
||||
|
||||
def post_general(url):
|
||||
values = {'name' : 'Dana Scullt',
|
||||
'location' : 'Virginia',
|
||||
'language' : 'Python' }
|
||||
|
||||
data = urllib.urlencode(values)
|
||||
req = urllib2.Request(url, data)
|
||||
response = urllib2.urlopen(req)
|
||||
print response.read()
|
||||
|
||||
|
||||
def get_general(url):
|
||||
msg = urllib2.urlopen(url)
|
||||
print msg.read()
|
||||
|
||||
|
||||
def get_fancy(url):
|
||||
response = urllib2.urlopen(url)
|
||||
print 'RESPONSE:', response
|
||||
print 'URL :', response.geturl()
|
||||
|
||||
headers = response.info()
|
||||
print 'DATE :', headers['date']
|
||||
print 'HEADERS :'
|
||||
print '---------'
|
||||
print headers
|
||||
|
||||
data = response.read()
|
||||
print 'LENGTH :', len(data)
|
||||
print 'DATA :'
|
||||
print '---------'
|
||||
print data
|
||||
|
||||
|
||||
|
||||
def get_user_agent(url):
|
||||
headers = {}
|
||||
headers['User-Agent'] = 'Googlebot'
|
||||
|
||||
request = urllib2.Request(url, headers=headers)
|
||||
request = urllib2.Request('http://www.google.com/')
|
||||
request.add_header('Referer', 'http://www.python.org/')
|
||||
request.add_header('User-agent', 'Mozilla/5.0')
|
||||
response = urllib2.urlopen(request)
|
||||
|
||||
#print response.read()
|
||||
print "The Headers are: ", response.info()
|
||||
print "The Date is: ", response.info()['date']
|
||||
print "The Server is: ", response.info()['server']
|
||||
response.close()
|
||||
|
||||
|
||||
def error(url):
|
||||
request = urllib2.Request('http://aaaaaa.com')
|
||||
try:
|
||||
urllib2.urlopen(request)
|
||||
except urllib2.URLError, e:
|
||||
print e.reason
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
HOST = 'http://www.google.com'
|
||||
|
||||
#get_user_agent(HOST)
|
||||
#get_fancy(HOST)
|
||||
#post_general(HOST)
|
||||
#get_user_agent(HOST)
|
||||
error(HOST)
|
Loading…
Add table
Add a link
Reference in a new issue