-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFunctions.py
97 lines (81 loc) · 2.74 KB
/
Functions.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from BeautifulSoup import BeautifulSoup
from urllib import urlencode
import os
import Queue
__author__ = 'Lambasoft'
__website__ = "www.aymanabiaoun.com"
def cls():
os.system(['clear', 'cls'][os.name == 'nt'])
def ParseFormNameText(text, name, type="input"):
if not text: return False
soup = BeautifulSoup(text)
return soup.find(type, {"name": name})['value']
def ParseFormIdSrc(text, name, type="input"):
if not text: return False
soup = BeautifulSoup(text)
return soup.find(type, {"id": name})['src']
def ParseContent(text, name, type="input" , tag="class"):
if not text: return False
soup = BeautifulSoup(text)
value = soup.find(type, attrs={tag: name})
if str(value) != "None": return value
return False
def ParseAllContent(text, name, type="input" , tag="class"):
if not text: return False
soup = BeautifulSoup(text)
value = soup.findAll(type, attrs={tag:name})
return value
def ParseMD5Content(text , name="text-green"):
if not text: return False
text = ParseContent(text, "results" , "span" , "class")
text = str(text).replace("<br />" , "\r\n")
results = []
for content in str(text).split("\n"):
if " MD5 :" not in content: continue
md5 = content[:content.index(" MD5 :")]
results.append([md5[-32:], ParseContent(content, name, "span", "class").getText()])
return results
def confirm(prompt=None, resp=False):
if prompt is None:
prompt = 'Confirm'
if resp:
prompt = '%s [%s]|%s: ' % (prompt, 'y', 'n')
else:
prompt = '%s [%s]|%s: ' % (prompt, 'n', 'y')
while True:
ans = raw_input(prompt)
if not ans:
return resp
if ans not in ['y', 'Y', 'n', 'N']:
print 'please enter y or n.'
continue
if ans == 'y' or ans == 'Y':
return True
if ans == 'n' or ans == 'N':
return False
def setMD5():
isValid = False
while not isValid:
answer = raw_input("Enter MD5 hash or .txt path: ")
if ".txt" in answer:
if os.path.isfile(answer):
with open(answer, 'r') as f:
results = f.read().splitlines()
return results
isValid = True
else:
print "[!] Please make sure the file exist"
isValid = False
else:
if len(answer) >= 32:
return [answer]
isValid = True
def SortMD5Hashs(hashs, max=60):
results = Queue.Queue()
if len(hashs) < max:
results.put(hashs)
else:
for i in range(0, (len(hashs) / max) + 1):
if hashs[i*max:i*max + max*1]:
results.put(hashs[i*max:i*max + max*1])
return results