前言:

根据天文地理与风水学,我掐指一算的看到了一篇不错的文章,文章里面写到整理exploit

我顿时心理想写一个exploit采集器,那么说时迟那时快。就开始写了

代码:

思路:http://expku.com,观察URL的变化

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()

效果:

爬下来的exploit保存:

用于搜索:

Github下载地址:https://github.com/422926799/python/blob/master/exploitsearch.py

python写exploit采集器的更多相关文章

  1. python写zip破解器

    浏览桌面依然平静,!!!!等等..怎么有个压缩包 打开一看!!!156.txt???waht the fuck? 卧槽还有密码!!!!!! 但是我不知道╮(╯▽╰)╭该怎么办呢! 很简单,python ...

  2. 自己写的一个简单PHP采集器

    自己写的一个简单PHP采集器 <?php //**************************************************************** $url = &q ...

  3. 写python中的装饰器

    python中的装饰器主要用于在已有函数实现功能前附加需要输出的信息,下面将用实例展示我如何写装饰器. 首先分别尝试写装饰器装饰一个无参函数和一个有参函数(被装饰函数仅输出,无返回值情况下) def ...

  4. 面向切面编程AOP——加锁、cache、logging、trace、同步等这些较通用的操作,如果都写一个类,则每个用到这些功能的类使用多继承非常难看,AOP就是解决这个问题的,python AOP就是装饰器

    面向切面编程(AOP)是一种编程思想,与OOP并不矛盾,只是它们的关注点相同.面向对象的目的在于抽象和管理,而面向切面的目的在于解耦和复用. 举两个大家都接触过的AOP的例子: 1)java中myba ...

  5. WEB页面采集器编写经验之一:静态页面采集器

    严格意义来说,采集器和爬虫不是一回事:采集器是对特定结构的数据来源进行解析.结构化,将所需的数据从中提取出来:而爬虫的主要目标更多的是页面里的链接和页面的TITLE. 采集器也写过不少了,随便写一点经 ...

  6. python写的一个集合

    起因:原本打算用python写一个抢火车票的脚本.在那 期间遇见各种浏览器驱动失败的节奏....打算先缓一下 然后就去写集合了. 0x01 源码: # -*- coding:'utf-8' -*- # ...

  7. prometheus学习系列十一: Prometheus 采集器的编写

    在前面的文章已经写了官方的几个exporter的使用了. 在实际使用环境中,我们可能需要收集一些自定义的数据, 这个时候我们一般是需要自己编写采集器的. 快速入门编写一个入门的demo 编写代码 fr ...

  8. 【PyHacker编写指南】打造URL批量采集器

    这节课是巡安似海PyHacker编写指南的<打造URL批量采集器> 喜欢用Python写脚本的小伙伴可以跟着一起写一写呀. 编写环境:Python2.x 00x1: 需要用到的模块如下: ...

  9. python高级之装饰器

    python高级之装饰器 本节内容 高阶函数 嵌套函数及闭包 装饰器 装饰器带参数 装饰器的嵌套 functools.wraps模块 递归函数被装饰 1.高阶函数 高阶函数的定义: 满足下面两个条件之 ...

随机推荐

  1. Proxy(代理)

    意图: 为其他对象提供一种代理以控制对这个对象的访问. 适用性: 在需要用比较通用和复杂的对象指针代替简单的指针的时候,使用Proxy模式.下面是一 些可以使用Proxy 模式常见情况: 1) 远程代 ...

  2. Java回顾之网络通信

    在这篇文章里,我们主要讨论如何使用Java实现网络通信,包括TCP通信.UDP通信.多播以及NIO. TCP连接 TCP的基础是Socket,在TCP连接中,我们会使用ServerSocket和Soc ...

  3. Vue 组件设计

    Vue 组件设计 Vue 作为 MVVM 框架一员,不管是写业务还是基础服务,都少不了书写组件.本文总结一下书写业务组件的一些心得. 为什么要写组件? 我们知道,只要是组件,就需要在引用的时候与 vi ...

  4. 雷林鹏分享:Ruby CGI Sessions

    Ruby CGI Sessions CGI::Session 可以为用户和CGI环境保存持久的会话状态,会话使用后需要关闭,这样可以保证数据写入到存储当中,当会话完成后,你需要删除该数据. #!/us ...

  5. Rails 5 Test Prescriptions 第4章 什么制造了伟大的测试

    伴随着程序成长,测试变长,复杂性增加,如何更高效的写测试,对以后开发不会造成麻烦. 测试本身没发被测试,所以一定要清楚,可控.不要加循环,不要过于复杂的自动编程. Cost and Value 成本和 ...

  6. hdu1847sg函数

    刚开始因为没注意到f是从0开始的导致wa了几次,f遍历的时候从0到f[j]<=i 这个题只有一个子情况,求出sg值直接判断就好了 #include<map> #include< ...

  7. ubuntu下修改matlab R2016b的快捷键为windows下相同

    选为: windows默认类.

  8. Leetcode 34

    //二分查找后,向两边扩展,二分错了两次,现在是对的.//还有就是vector可以用{}直接赋值很棒 class Solution { public: vector<int> search ...

  9. JAVA中的>>和>>>号以及<<号的作用

    public static void main(String[] args) { //右移2位,输出结果为2.二进制1000右移2位变为0010 System.out.println(8>> ...

  10. Docker ENTRYPOINT

    entrypoint: 在启动镜像的时候会执行这个命令下的脚本,在docker run 和docker start情况下都会触发. 好比这个脚本是对某一个文件追加数据,每次start的时候都会追加,文 ...