利用python實(shí)現(xiàn)對(duì)web服務(wù)器的目錄探測(cè)的方法
一、python
Python是一種解釋型、面向?qū)ο蟆?dòng)態(tài)數(shù)據(jù)類(lèi)型的高級(jí)程序設(shè)計(jì)語(yǔ)言。
python 是一門(mén)簡(jiǎn)單易學(xué)的語(yǔ)言,并且功能強(qiáng)大也很靈活,在滲透測(cè)試中的應(yīng)用廣泛,讓我們一起打造屬于自己的滲透測(cè)試工具
二、web服務(wù)器的目錄探測(cè)腳本打造
1、在滲透時(shí)如果能發(fā)現(xiàn)web服務(wù)器中的webshell,滲透是不是就可以變的簡(jiǎn)單一點(diǎn)尼
通常情況下御劍深受大家的喜愛(ài),但是今天在測(cè)試的時(shí)候webshell不知道為什么御劍掃描不到
仔細(xì)查看是webshell有防爬功能,是檢測(cè)User-Agent頭,如果沒(méi)有就回返回一個(gè)自己定義的404頁(yè)面
1、先來(lái)看看工具效果
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 庫(kù)對(duì)web目標(biāo)服務(wù)器進(jìn)行目錄探測(cè)
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 庫(kù)對(duì)探測(cè)進(jìn)行線程的設(shè)置
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 庫(kù)進(jìn)行對(duì)自己的工具進(jìn)行封裝
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")
總結(jié)
各位大哥有意見(jiàn)或者建議盡管提,文章哪里不對(duì)的話會(huì)改的,小弟定會(huì)虛心學(xué)習(xí)最后附上全部源碼供大佬指教
#!/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()
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Python Web服務(wù)器Tornado使用小結(jié)
- Python 搭建Web站點(diǎn)之Web服務(wù)器與Web框架
- Python基于twisted實(shí)現(xiàn)簡(jiǎn)單的web服務(wù)器
- Python實(shí)現(xiàn)的檢測(cè)web服務(wù)器健康狀況的小程序
- Python實(shí)現(xiàn)簡(jiǎn)易版的Web服務(wù)器(推薦)
- Python編程實(shí)現(xiàn)的簡(jiǎn)單Web服務(wù)器示例
- Python命令啟動(dòng)Web服務(wù)器實(shí)例詳解
- Python 搭建Web站點(diǎn)之Web服務(wù)器網(wǎng)關(guān)接口
- python探索之BaseHTTPServer-實(shí)現(xiàn)Web服務(wù)器介紹
- python批量同步web服務(wù)器代碼核心程序
- python快速建立超簡(jiǎn)單的web服務(wù)器的實(shí)現(xiàn)方法
- Python Web程序搭建簡(jiǎn)單的Web服務(wù)器
- python實(shí)現(xiàn)靜態(tài)web服務(wù)器
相關(guān)文章
Python類(lèi)的定義繼承調(diào)用比較方法技巧
這篇文章主要介紹了Python類(lèi)的定義繼承調(diào)用比較方法技巧,文章首先通過(guò)類(lèi)的約束展開(kāi)詳情圍繞主題介紹相關(guān)內(nèi)容,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-06-06python實(shí)現(xiàn)高斯(Gauss)迭代法的例子
今天小編就為大家分享一篇python實(shí)現(xiàn)高斯(Gauss)迭代法的例子,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-11-11對(duì)python中矩陣相加函數(shù)sum()的使用詳解
今天小編就為大家分享一篇對(duì)python中矩陣相加函數(shù)sum()的使用詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-01-01解決安裝torch后,torch.cuda.is_available()結(jié)果為false的問(wèn)題
這篇文章主要介紹了解決安裝torch后,torch.cuda.is_available()結(jié)果為false的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-12-12利用python/R語(yǔ)言繪制圣誕樹(shù)實(shí)例代碼
圣誕節(jié)快到了,分別用R和Python繪制了圣誕樹(shù)祝你們圣誕節(jié)快樂(lè),所以下面這篇文章主要給大家介紹了關(guān)于如何利用python/R繪制圣誕樹(shù)的相關(guān)資料,需要的朋友可以參考下2021-12-12python統(tǒng)計(jì)多維數(shù)組的行數(shù)和列數(shù)實(shí)例
今天小編就為大家分享一篇python統(tǒng)計(jì)多維數(shù)組的行數(shù)和列數(shù)實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-06-06Python正則表達(dá)式函數(shù)match()和search()使用全面指南
在Python中,正則表達(dá)式是強(qiáng)大的工具,能夠用于文本匹配、搜索和替換,re模塊提供了許多函數(shù)來(lái)處理正則表達(dá)式,其中match()和search()是兩個(gè)常用的函數(shù),本文將深入探討這兩個(gè)函數(shù)的用法、區(qū)別和示例,幫助你更好地理解它們的功能2024-01-01python實(shí)現(xiàn)學(xué)生管理系統(tǒng)源碼
這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)學(xué)生管理系統(tǒng)源碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-04-04