forked from IVorder/python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexploitsearch.py
203 lines (186 loc) · 6.78 KB
/
exploitsearch.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import requests
from bs4 import *
import threading
import re
import optparse
urlsd=[]
#neirons=[]
def main():
parser=optparse.OptionParser()
parser.add_option('-m',action='store_true',dest='home',help='Save the home directory in the local area')
parser.add_option('-w',action='store_true',dest='web',help='Save all the attack loads of Web')
parser.add_option('-s',dest='search',help='search exploit')
parser.add_option('-y',action='store_true',dest='long',help='Save the Long-range all exploit')
parser.add_option('-b',action='store_true',dest='local',help='Save the local all exploit')
(options,args)=parser.parse_args()
if options.home:
poc()
elif options.web:
web()
elif options.search:
searchs=options.search
searchexploit(searchs)
elif options.long:
logins()
elif options.local:
local()
else:
parser.print_help()
exit()
def poc():
global headers
print('[+]Emptying exploit1.txt')
kw=open('exploitcs1.txt','w')
kw.close()
print('[+]Complete the emptying')
print('[+] Generating a new list of exploit')
url='http://expku.com/'
headers={'user-agetn':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36'}
rest=requests.get(url=url,headers=headers)
qinx=rest.content.decode('gbk')
kop=BeautifulSoup(qinx,'html.parser')
for x in kop.find_all('a'):
a=re.findall('<a href=".*?" target="_blank">.*?</a>',str(x))
neiron="".join(a)
nei=BeautifulSoup(neiron,'html.parser')
uw=nei.find_all('a')
for u in uw:
u1=u.get('href')
urlsd.append('http://expku.com/'.strip()+u1)
urlsd.remove(urlsd[0])
lk=list(set(urlsd))
for m in lk:
rest2=requests.get(url=m,headers=headers)
pl=BeautifulSoup(rest2.content.decode('gbk'),'html.parser')
for l in pl.find_all('h1'):
ks='title:',l.get_text(),'','url:',rest2.url
print(ks)
li='{}'.format(ks)
xr=li.replace('(','').replace(')','').replace(',','').replace("''",'')
pw=open('exploitcs1.txt','a')
pw.write(xr)
pw.write('\n')
pw.close()
def web():
print('[+]empty exploit web.txt')
odw=open('exploitweb.txt','w')
odw.close()
print('[+]empty complete')
print('[+]Start writing to the collected web exploit')
urlsd=[]
headers = {
'user-agetn': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36'}
for h in range(88):
url='http://expku.com/web/list_6_{}.html'.format(h)
reques=requests.get(url=url,headers=headers)
kw=BeautifulSoup(reques.content.decode('gbk'),'html.parser')
vb=kw.find_all('a')
for q in vb:
pq=q.get('href')
urls='http://expku.com'.strip()+pq
kq=re.findall('http://expku.com/web/.*.html',urls)
for k in kq:
urlsd.append(k)
kc=list(set(urlsd))
for b in kc:
tfs=requests.get(url=b,headers=headers)
bds=BeautifulSoup(tfs.content.decode('gbk'),'html.parser')
for t in bds.find_all('h1'):
print(t.get_text(), '', tfs.url)
print(t.get_text(),'',tfs.url,file=open('exploitweb.txt','a'))
def searchexploit(searchs):
print('[+]search give the result as follows:')
jg=[]
rs=[]
urlsh=[]
headers = {'user-agetn': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36'}
urls='http://expku.com/search.php?keyword={}'.format(searchs)
resq=requests.get(url=urls,headers=headers)
weq=BeautifulSoup(resq.content.decode('gbk'),'html.parser')
oeq=weq.find_all('a')
for r in oeq:
ds=r.get('title')
durl=r.get('href')
burw=re.findall('/.*/.*.html',durl)
op="".join(burw)
rs.append(op)
kdw = '{}'.format(ds)
jg.append(kdw.replace('None', ''))
while '' in rs:
rs.remove('')
for g in rs:
uw='http://expku.com'.strip()+g
urlsh.append(uw)
urlsqf='http://expku.com'.strip()+durl
while '' in jg:
jg.remove('')
for g in range(0,len(urlsh)):
print(jg[g],urlsh[g])
def logins():
print('[+]empty exploitlong.txt')
lwe=open('exploitlong.txt','w')
lwe.close()
print('[+]Get all remote exploit')
urls=[]
zj=[]
headers = {
'user-agetn': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36'}
for i in range(75):
url='http://expku.com/remote/list_4_{}.html'.format(i)
regw=requests.get(url=url,headers=headers)
lvq=BeautifulSoup(regw.content.decode('gbk'),'html.parser')
fwq=lvq.find_all('a')
for d in fwq:
eq=d.get('href')
oeq=re.findall('/remote/.*.html',eq)
for b in oeq:
ks='http://expku.com'.strip()+b
urls.append(ks)
qwe=list(set(urls))
for asd in lvq.find_all('a'):
kl=re.findall('<a href=".*" target="_blank">.*</a>',str(asd))
for n in kl:
vk=''.strip()+n
peq=BeautifulSoup(vk,'html.parser')
for t in qwe:
zj.append(peq.get_text()+' '+t)
jb=list(set(zj))
for j in jb:
print(j)
print(j,file=open('exploitlong.txt','a'))
def local():
print('[+]empty exploitlocal.txt')
wd=open('exploitlocal.txt','w')
wd.close()
print('[+]get local exploit')
for j in range(56):
uk=[]
url='http://expku.com/local/list_5_{}.html'.format(j)
headers = {
'user-agetn': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36'}
rwqe=requests.get(url=url,headers=headers)
vdq=BeautifulSoup(rwqe.content.decode('gbk'),'html.parser')
hk=vdq.find_all('a')
for f in hk:
ddo=f.get('href')
kio=re.findall('/local/.*.html',str(ddo))
for g in kio:
url='http://expku.com'.strip()+g
uk.append(url)
yf=list(set(uk))
for c in yf:
rtq=requests.get(url=c,headers=headers)
vdq=BeautifulSoup(rtq.content.decode('gbk'),'html.parser')
for a in vdq.find_all('h1'):
print(a.get_text(),'',rtq.url)
print(a.get_text(), '', rtq.url,file=open('exploitlocal.txt','a'))
#while '' in neirons:
# neirons.remove('')
#while ' ' in neirons:
# neirons.remove(' ')
#urlsd.remove(urlsd[0])
#rd=list(set(urlsd))
#for q in range(0,len(rd)):
# print(neirons[q],rd[q])
if __name__ == '__main__':
main()