利用 python 实现对web服务器的目录探测
一、python
Python是一种解释型、面向对象、动态数据类型的高级程序设计语言。
python 是一门简单易学的语言,并且功能强大也很灵活,在渗透测试中的应用广泛,让我们一起打造属于自己的渗透测试工具
二、web服务器的目录探测脚本打造
1、在渗透时如果能发现web服务器中的webshell,渗透是不是就可以变的简单一点尼
通常情况下御剑深受大家的喜爱,但是今天在测试的时候webshell不知道为什么御剑扫描不到
仔细查看是webshell有防爬功能,是检测User-Agent头,如果没有就回返回一个自己定义的404页面 ![]()
1、先来看看工具效果![]()
2、利用python读取扫描的目录字典
def get_url(path): with open(path, "r", encoding='ISO-8859-1') as f: for url in f.readlines(): url_list.append(url.strip()) return url_list
3、利用 python 的 requests 库对web目标服务器进行目录探测
- def Go_scan(url):
- while not queue.empty():
- url_path = queue.get(timeout=1)
- new_url = url + url_path
- res = requests.get(new_url, headers=headers, timeout=5)
- #print(res.status_code)
- status_code = "[" + str(res.status_code) + "]"
- if str(res.status_code) != "404":
- print(get_time(), status_code, new_url)
4、利用 python 的 threading 库对探测进行线程的设置
- def thread(Number,url):
- threadlist = []
- for pwd in url_list:
- queue.put(pwd)
- for x in range(Number):
- t = threading.Thread(target=Go_scan, args=(url,))
- threadlist.append(t)
- for t in threadlist:
- t.start()
5、利用 python 的 argparse 库进行对自己的工具进行封装
- def main():
- if len(sys.argv) == 1:
- print_banner()
- exit(1)
- parser = argparse.ArgumentParser(
- formatter_class=argparse.RawTextHelpFormatter,
- epilog='''\
- use examples:
- python dir_scan.py -u [url]http://www.test.com[/url] -d /root/dir.txt
- python dir_scan.py -u [url]http://www.test.com[/url] -t 30 -d /root/dir.txt
- ''')
- parser.add_argument("-u","--url", help="scan target address", dest='url')
- parser.add_argument("-t","--thread", help="Number of threads", default="20", type=int, dest='thread')
- parser.add_argument("-d","--Dictionaries", help="Dictionary of Blasting Loading",
- dest="Dictionaries")
总结
各位大哥有意见或者建议尽管提,文章哪里不对的话会改的,小弟定会虚心学习最后附上全部源码供大佬指教
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import requests
- import threading
- import argparse,sys
- import time,os
- from queue import Queue
- url_list = []
- queue = Queue()
- headers = {
- 'Connection':'keep-alive',
- 'Accept':'*/*',
- 'Accept-Language': 'zh-CN',
- 'User-Agent':'Mozilla/5.0 (Windows NT 6.2; rv:16.0) Gecko/20100101 Firefox/16.0'
- }
- def print_banner():
- banner = r"""
- .___.__ __________________ _____ _______
- __| _/|__|_______ / _____/\_ ___ \ / _ \ \ \
- / __ | | |\_ __ \ \_____ \ / \ \/ / /_\ \ / | \
- / /_/ | | | | | \/ / \\ \____/ | \/ | \
- \____ | |__| |__| /_______ / \______ /\____|__ /\____|__ /
- \/ \/ \/ \/ \/
- [*] Very fast directory scanning tool.
- [*] try to use -h or --help show help message
- """
- print(banner)
- def get_time():
- return '[' + time.strftime("%H:%M:%S", time.localtime()) + '] '
- def get_url(path):
- with open(path, "r", encoding='ISO-8859-1') as f:
- for url in f.readlines():
- url_list.append(url.strip())
- return url_list
- def Go_scan(url):
- while not queue.empty():
- url_path = queue.get(timeout=1)
- new_url = url + url_path
- res = requests.get(new_url, headers=headers, timeout=5)
- #print(res.status_code)
- status_code = "[" + str(res.status_code) + "]"
- if str(res.status_code) != "404":
- print(get_time(), status_code, new_url)
- def thread(Number,url):
- threadlist = []
- for pwd in url_list:
- queue.put(pwd)
- for x in range(Number):
- t = threading.Thread(target=Go_scan, args=(url,))
- threadlist.append(t)
- for t in threadlist:
- t.start()
- def main():
- if len(sys.argv) == 1:
- print_banner()
- exit(1)
- parser = argparse.ArgumentParser(
- formatter_class=argparse.RawTextHelpFormatter,
- epilog='''\
- use examples:
- python dir_scan.py -u [url]http://www.test.com[/url] -d /root/dir.txt
- python dir_scan.py -u [url]http://www.test.com[/url] -t 30 -d /root/dir.txt
- ''')
- parser.add_argument("-u","--url", help="scan target address", dest='url')
- parser.add_argument("-t","--thread", help="Number of threads", default="20", type=int, dest='thread')
- parser.add_argument("-d","--Dictionaries", help="Dictionary of Blasting Loading",
- dest="Dictionaries")
- args = parser.parse_args()
- Number =args.thread
- url = args.url
- url_path = args.Dictionaries
- print_banner()
- get_url(url_path)
- print(get_time(), "[INFO] Start scanning----\n")
- time.sleep(2)
- thread(Number,url)
- if __name__ == '__main__':
- main()
利用 python 实现对web服务器的目录探测的更多相关文章
- 利用Python实现对Web服务器的目录探测
今天是一篇提升技能的干货分享,操作性较强,适用于中级水平的小伙伴,文章阅读用时约3分钟. PART 1/Python Python是一种解释型.面向对象.动态数据类型的高级程序设计语言. Python ...
- python 启动简单web服务器
有时我们在开发web静态页面时,需要一个web服务器来测试. 这时可以利用python提供的web服务器来实现. 1.在命令行下进入某个目录 2.在该目录下运行命令: python -m Simple ...
- 用 Python 脚本实现对 Linux 服务器的监控
目前 Linux 下有一些使用 Python 语言编写的 Linux 系统监控工具 比如 inotify-sync(文件系统安全监控软件).glances(资源监控工具)在实际工作中,Linux 系统 ...
- 用 Python 脚本实现对 Linux 服务器的网卡流量监控
*这篇文章网上已经有相关代码,为了加深印象,我做了相关批注,希望对朋友们有帮助 工作原理:基于/proc文件系统 Linux 系统为管理员提供了非常好的方法,使其可以在系统运行时更改内核,而不需要重新 ...
- 利用过滤器Filter和特性Attribute实现对Web API返回结果的封装和统一异常处理
在我们开发Web API应用的时候,我们可以借鉴ABP框架的过滤器Filter和特性Attribute的应用,实现对Web API返回结果的封装和统一异常处理,本篇随笔介绍利用AuthorizeAtt ...
- c#调用js,以及js调用C#里的函数, c#自己生成js代码,实现对web的控制
using mshtml;using System;using System.Collections.Generic;using System.Linq;using System.Security.P ...
- 通过脚本实现对web的健康检查
前面的文章中(https://www.cnblogs.com/zyxnhr/p/10707932.html),通过nginx的第三方模块实现对web端的一个监控,现在通过一个脚本实现对第三方的监控 脚 ...
- 利用iptables防火墙保护web服务器
实例:利用iptables防火墙保护web服务器 防火墙--->路由器-->交换机-->pc机 配置之前,清空下已有的规则,放在规则冲突不生效 工作中,先放行端口写完规则,再DROP ...
- Python 脚本实现对 Linux 服务器的监控
本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn 摘要: 原文地址 由于原文来自微信公众号,并且脚本都是图片,所以这里 ...
随机推荐
- xpath定位动态iframe
使用xpath定位 driver.switch_to.frame(driver.find_element_by_xpath("//iframe[starts-with(@id, 'x-URS ...
- oracle 启动三步骤
oracle 启动三步骤 oracle启动会经过三个过程,分别是nomount.mount.open 一.nomount 阶段 nomount 阶段,可以看到实例已经启动.oracle进程会根据参数文 ...
- [原创]Zynq SDIO WIFI SotfAP调试
编译好kernel和driver 加载firmware后,运行下述命令. mkdir /var/run/ mkdir /var/run/hostapd ifconfig -a ...
- 1到n的最小步数
1到n的最小步数 Time Limit: 1 Sec Memory Limit: 128 MB 给你一个数n,让你求从1到n的最小步数是多少. 对于当前的数x有三种操作: 1: x+1 2: x ...
- C# Common Log function
public int Log(string info) { info = "-----------------------------" + DateTime.Now.ToStri ...
- Web程序-----批量生成二维码并形成一张图片
需求场景:客户根据前台界面列表所选择的数据,根据需要的信息批量生成二维码并形成一张图片,并且每张图片显示的二维码数量是固定的,需要分页(即总共生成的二维码图片超出每页显示的需另起一页生成),并下载到客 ...
- 课堂小记---JavaScript(2)
本阶段难点疑点梳理 1.关于switch中default的使用: default同case功能一样,区别在于并不匹配任何信息,只有当case中无任何匹配的时候才会执行default.需要注意的是,这是 ...
- 输入a,b,求a^b的所有因子之和
题目 poj的1845 分解a的质因数a=p1^t1*p2^t1........ 每个质因数对sum的贡献: 当除去质因数p1时的因数和为sum,当计入p1时,因子和变成sum*p1^0+sum*p1 ...
- docker-compose.yml 配置文件详解及项目发布
摘自:https://blog.csdn.net/qq_36148847/article/details/79427878 docker部署tomcat项目 1.上传war包2.制作镜像 Docker ...
- VMware workstation pro 15 安装Ubuntu(图文教程)
今天分享一下虚拟机安装Ubuntu的过程,在开始安装之前,需要下载VMware workstation pro和Ubuntu镜像,两者我都用的最新版,由于VMware workstation pro ...