Python大法之告别脚本小子系列—信息资产收集类脚本编写(下)
作者:阿甫哥哥
原文来自:https://bbs.ichunqiu.com/article-1618-1.html
系列文章专辑:
Python大法之告别脚本小子系列
目录:
0×05 高精度字典生成脚本编写
0×06 Queue模块的讲解
0×07 目录扫描脚本编写
0×08 C段扫描脚本编写
0×05 高精度字典生成脚本编写
思路来自i春秋讲师ADO的课程,传送门:
Python安全工具开发应用 > 高精度字典生成(一)
有人可能会问生成字典有什么卵用??
如果你在爆破中用一个G大小的字典,可能也不会获得到什么信息,但是,如果你通过已知的部分信息生成字典进行爆破,这样你的成功率会大大的提高,本文用到的模块也是exrex,思路也五五开。。。
官方介绍:https://github.com/asciimoo/exrex
安装方法:pip install exrex
建立一个密码字典(无非就是已知的信息)
我只是简单的举了个栗子,也用了一个简单的匹配方式
#-*- coding: UTF-8 -*- import exrex def dic_create(hosts):web_dics = hosts.split('.')for web_dic in web_dics:f_pass = open('pass.txt',"r")for dic_pass in f_pass:dics = list(exrex.generate(web_dic+'[!@#]'+dic_pass))for dic in dics:print dic.strip('\n') if __name__ == '__main__':dic_create('www.ichunqiu.com')
这样就简单的造了一个字典生成器
问题又来了,他把我域名中的http://,www,com都生成了,其实并没有什么卵用。。。所以,就要去掉他
#-*- coding: UTF-8 -*- import exrex def dic_create(hosts):web_dics = hosts.split('.')for web_dic in web_dics:if web_dic not in web_white:f_pass = open('pass.txt',"r")for dic_pass in f_pass:dics = list(exrex.generate(web_dic+'[!@#]'+dic_pass))for dic in dics:print dic.strip('\n') if __name__ == '__main__':web_white = ['com','cn','org','edu','gov','www']host = 'www.ichunqiu.com'if '://' in host:host = host.split('://')[1]if '/' in host:host = host.replace('/','')dic_create(host)
然后就差不多了,顶多加个判断,排除简单的密码组合
#-*- coding: UTF-8 -*- import exrex def dic_create(hosts):web_dics = hosts.split('.')for web_dic in web_dics:if web_dic not in web_white:f_pass = open('pass.txt',"r")for dic_pass in f_pass:dics = list(exrex.generate(web_dic+'[!@#]'+dic_pass))for dic in dics:if len(dic) > 5:print dic.strip('\n') if __name__ == '__main__':web_white = ['com','cn','org','edu','gov','www']host = raw_input('PLEASE INPUT YOUR TARGET:')if '://' in host:host = host.split('://')[1]if '/' in host:host = host.replace('/','')dic_create(host)
0×06 Queue模块的讲解
自带的模块,不用安装,你们可以去看官方文档学习,我也只是简单的说一下
创建一个队列
D:\ichunqiu\items>python Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import Queue >>> queue = Queue.Queue()
将值放入队列中
>>> for i in range(8): ... queue.put(i) ...
返回队列大小
>>> queue.qsize() 8
取出队列中的值
>>> queue.get() 0 >>> queue.get() 1 >>> queue.get() 2
Threading与Queue的结合
#-*- coding: UTF-8 -*- import threading import Queue class DemoRUN(threading.Thread):def __init__(self,queue):threading.Thread.__init__(self)self._queue = queuedef run(self):while not self._queue.empty():key = self._queue.get()print key def main():threads = []threadnum = 20 #线程数queue = Queue.Queue()for i in range(1,9):queue.put(i)for i in xrange(threadnum):threads.append(DemoRUN(queue))for t in threads:t.start()for t in threads:t.join() if __name__ == '__main__':main()
这就是一个大概的模块
0×07 目录扫描脚本编写
目录扫描,顾名思义,就是目录扫描,在信息收集中也算重要的一环了
所以我先简单放出一个单线程版,大概思路就是引入字典,URl+字典内容,访问,状态码是200就保留
#-*- coding: UTF-8 -*- import requests def scan_target_url_exists(target_url):headers={'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36','Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8','Accept-Encoding': 'gzip, deflate','Referer': 'http://www.google.com'}status_codes = [200]all_lines=open(dir_file,'r').readlines()for i in all_lines:url = target_url+'/'+str(i)req=requests.head(url.strip(),timeout=8,headers=headers)if req.status_code in status_codes:print 'CODE:%s,URL:%s'%(str(req.status_code),url.strip('\n').strip('\r'))open('exists_target_url.txt','a').write(url) if __name__ == '__main__':dir_file='demo.txt'target_url='localhost'if target_url.startswith('http://') or target_url.startswith('https://'):passelse:target_url = 'http://' + target_urlscan_target_url_exists(target_url)
没有什么知识点,直接看吧,接下来,是多线程的
用到了queue,优化了一下code
#-*- coding: UTF-8 -*- import requests from threading import Thread, activeCount import Queue queue = Queue.Queue() dir_file='demo.txt' def scan_target_url_exists(target_url):headers={'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36','Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8','Accept-Encoding': 'gzip, deflate','Referer': 'http://www.google.com'}status_codes = [200]try:req=requests.head(target_url.strip(),timeout=8,headers=headers)if req.status_code in status_codes:print 'CODE:%s,URL:%s'%(str(req.status_code),target_url.strip('\n').strip('\r'))open('exists_target_url.txt','a').write(target_url)except:pass def open_pathfile(file):all_lines=open(file,'r').readlines()for line in all_lines:if target_url.endswith('/'):if line.startswith('/'):queue.put(target_url+line[1:])else:queue.put(target_url + line)else:if line.startswith('/'):queue.put(target_url + line)else:queue.put(target_url + '/' + line) if __name__ == '__main__':print '''____ _ ____ | _ \(_)_ __/ ___| ___ __ _ _ __ | | | | | '__\___ \ / __/ _` | '_ \ | |_| | | | ___) | (_| (_| | | | | |____/|_|_| |____/ \___\__,_|_| |_| '''target_url=raw_input('Please input your target:')threadnum = raw_input('Please input your threadnum:')if target_url.startswith('http://') or target_url.startswith('https://'):passelse:target_url = 'http://' + target_urlprint 'The number of threads is %s' % threadnumprint 'Matching.......'open_pathfile(dir_file)while queue.qsize() > 0:if activeCount() <= int(threadnum):Thread(target=scan_target_url_exists,args=(queue.get(),)).start()
当然了,阅读原文查看你们想要的目录扫描的字典>>>>https://bbs.ichunqiu.com/article-1618-1.html
转载于:https://www.cnblogs.com/ichunqiu/p/9322678.html
Python大法之告别脚本小子系列—信息资产收集类脚本编写(下)相关推荐
- Python大法之告别脚本小子系列——信息资产收集类脚本编写附源码
关注头条号,私信回复资料会有意外惊喜呦------最后一张照片有资料呦. 前言 在采集到URL之后,要做的就是对目标进行信息资产收集了,收集的越好,你挖到洞也就越多了............当然这一切 ...
- 魔兽世界python脚本拍卖行_Python大法之告别脚本小子系列—信息资产收集类脚本编写(上)...
0×01 前言 在采集到URL之后,要做的就是对目标进行信息资产收集了,收集的越好,你挖到洞也就越多了----当然这一切的前提,就是要有耐心了!!!由于要写工具较多,SO,我会分两部分写-- 0×02 ...
- 告别脚本小子系列丨JAVA安全(6)——反序列化利用链(上)
0x01 前言 我们通常把反序列化漏洞和反序列化利用链分开来看,有反序列化漏洞不一定有反序列化利用链(经常用shiro反序列化工具的人一定遇到过一种场景就是找到了key,但是找不到gadget,这也就 ...
- 告别脚本小子系列丨JAVA安全(7)——反序列化利用链(中)
0x01 前言 距离上一次更新JAVA安全的系列文章已经过去一段时间了,在上一篇文章中介绍了反序列化利用链基本知识,并阐述了Transform链的基本知识.Transform链并不是一条完整的利用链, ...
- Python大法之告别脚本小子系列—各类URL采集器编写
本文作者:i春秋签约作家--阿甫哥哥 系列文章专辑:https://bbs.ichunqiu.com/forum.php?mod=collection&action=view&ctid ...
- Unity3D脚本中文系列教程(五)
http://dong2008hong.blog.163.com/blog/static/4696882720140302848544/?suggestedreading&wumii Unit ...
- python 写脚本 预约课程_Python盘纪念币系列之三:自动预约脚本编写 03 系列总结...
前一篇遗漏了"预约兑换日期"的自动输入,这篇文章将介绍如何处理.另外,将会对"Python盘纪念币系列"做一个简单的总结. 自动输入预约兑换日期 不像文本输入框 ...
- 初探脚本小子--快速上手自写信息收集脚本
原文地址:初探脚本小子_白帽子技术/思路_i春秋社区-分享你的技术,为安全加点温度. - Powered by Discuz! (ichunqiu.com) 最近在学习写脚本,这里作者分析几个信息收集 ...
- activexobject对象不能创建_脚本语言系列之Python | Python面向对象
Python是做自动化工作首选的一门语言,与更复杂的语言相比,Python 非常便于快速学习.语法很少,具有良好的 可读性,即使测试工程师们没有丰富的编码经验,也能快速学会:Python 的极简风格对 ...
- python 特性和方法同名_脚本语言系列之Python | Python面向对象
Python是做自动化工作首选的一门语言,与更复杂的语言相比,Python 非常便于快速学习.语法很少,具有良好的 可读性,即使测试工程师们没有丰富的编码经验,也能快速学会:Python 的极简风格对 ...
最新文章
- Axure RP使用攻略--入门级(七)之axure元件使用思路的补充
- iis6扩展php_Web服务器IIS6的PHP5.2.5最佳配置方法
- Qt Example各例子演示功能说明
- P1372 又是毕业季I
- ajax js图片上传到php,Ajax上传并预览图片(附代码)
- 苍狼敏捷软件开发团队建设指南-2-团队建设
- (1)电源管理-S3C2440芯片电源管理模块解析
- 快速复制文件地址——无任何安装
- 分享一个07版的office, 有密匙的。
- element el-table 在IE浏览器 表头失效问题
- .Net中Web增加加密狗管理
- 动态规划之求解三角形最小路径问题
- 分享 Python 教学视频,从基础到爬虫、网页、数据分析、机器学习.....
- Alpha测试和Beta测试的区别
- Linux中的TTY是什么意思
- python出现 'ascii' codec can't decode byte 0xXX in position XX: ordinal not in range(128)问题
- 直播平台对企业的作用有哪些
- Chrome插件开发先看这篇:如何实现一键上班赖皮
- CSR8675项目实战:BlueEarphone 左右声道各10个Speaker EQ
- 便携式CD DVD播放机
热门文章
- 更为详细的Txtsetup.sif文件解释
- 【网络安全工程师面试合集】—社会工程学到底是什么?
- Cygwin下安装apt-cyg
- 解决 Windows XP 桌面图标阴影的情况
- 程序集引用里面的“Culture=neutral”是什么意思?
- 今天是个好日子 12月17日
- lowB三人组---冒泡排序原理和实现
- layui设置td宽度_layui静态表格固定td宽度,table固定td宽度
- Caltech-UCSD Birds-200-鸟类数据集
- ssh整合错误 0 nanoseconds spent acquiring 0 JDBC connections;