PyHacker實(shí)現(xiàn)網(wǎng)站后臺(tái)掃描器編寫指南
包括如何處理假的200頁(yè)面/404智能判斷等
喜歡用Python寫腳本的小伙伴可以跟著一起寫一寫呀。
編寫環(huán)境:Python2.x
00x1:模塊
需要用到的模塊如下:
import request
00x2:請(qǐng)求基本代碼
先將請(qǐng)求的基本代碼寫出來(lái):
import requests
def dir(url):
headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3314.0 Safari/537.36 SE 2.X MetaSr 1.0'}
req = requests.get(url=url,headers=headers)
print req.status_code
dir('http://www.hackxc.cc')
00x3:設(shè)置
設(shè)置超時(shí)時(shí)間,以及忽略不信任證書
import urllib3 urllib3.disable_warnings() req = requests.get(url=url,headers=headers,timeout=3,verify=False)
再加個(gè)異常處理

調(diào)試一下

再進(jìn)行改進(jìn),如果為200則輸出
if req.status_code==200:
print "[*]",req.url00x4:200頁(yè)面處理
難免會(huì)碰到假的200頁(yè)面,我們?cè)偬幚硪幌?/p>
處理思路:
首先訪問hackxchackxchackxc.php和xxxxxxxxxx記錄下返回的頁(yè)面的內(nèi)容長(zhǎng)度,然后在后來(lái)的掃描中,返回長(zhǎng)度等于這個(gè)長(zhǎng)度的判定為404
def dirsearch(u,dir):
try:
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3314.0 Safari/537.36 SE 2.X MetaSr 1.0'}
#假的200頁(yè)面進(jìn)行處理
hackxchackxchackxc = '/hackxchackxchackxc.php'
hackxchackxchackxc_404 =requests.get(url=u+hackxchackxchackxc,headers=headers)
# print len(hackxchackxchackxc_404.content)
xxxxxxxxxxxx = '/xxxxxxxxxxxx'
xxxxxxxxxxxx_404 = requests.get(url=u + xxxxxxxxxxxx, headers=headers)
# print len(xxxxxxxxxxxx_404.content)
#正常掃描
req = requests.get(url=u+dir,headers=headers,timeout=3,verify=False)
# print len(req.content)
if req.status_code==200:
if len(req.content)!=len(hackxchackxchackxc_404.content)and len(req.content)!= len(xxxxxxxxxxxx_404.content):
print "[+]",req.url
else:
print u+dir,404
except:
pass很nice

00x5:保存結(jié)果
再讓結(jié)果自動(dòng)保存

0x06:完整代碼
#!/usr/bin/python
#-*- coding:utf-8 -*-
import requests
import urllib3
urllib3.disable_warnings()
urls = []
def dirsearch(u,dir):
try:
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3314.0 Safari/537.36 SE 2.X MetaSr 1.0'}
#假的200頁(yè)面進(jìn)行處理
hackxchackxchackxc = '/hackxchackxchackxc.php'
hackxchackxchackxc_404 =requests.get(url=u+hackxchackxchackxc,headers=headers)
# print len(hackxchackxchackxc_404.content)
xxxxxxxxxxxx = '/xxxxxxxxxxxx'
xxxxxxxxxxxx_404 = requests.get(url=u + xxxxxxxxxxxx, headers=headers)
# print len(xxxxxxxxxxxx_404.content)
#正常掃描
req = requests.get(url=u+dir,headers=headers,timeout=3,verify=False)
# print len(req.content)
if req.status_code==200:
if len(req.content)!=len(hackxchackxchackxc_404.content)and len(req.content)!= len(xxxxxxxxxxxx_404.content):
print "[+]",req.url
with open('success_dir.txt','a+')as f:
f.write(req.url+"\n")
else:
print u+dir,404
else:
print u + dir, 404
except:
pass
if __name__ == '__main__':
url = raw_input('\nurl:')
print ""
if 'http' not in url:
url = 'http://'+url
dirpath = open('rar.txt','r')
for dir in dirpath.readlines():
dir = dir.strip()
dirsearch(url,dir)以上就是PyHacker實(shí)現(xiàn)網(wǎng)站后臺(tái)掃描器編寫指南的詳細(xì)內(nèi)容,更多關(guān)于PyHacker網(wǎng)站后臺(tái)掃描器的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Python操作Redis之設(shè)置key的過(guò)期時(shí)間實(shí)例代碼
這篇文章主要介紹了Python操作Redis之設(shè)置key的過(guò)期時(shí)間實(shí)例代碼,小編覺得還是挺不錯(cuò)的,具有一定借鑒價(jià)值,需要的朋友可以參考下2018-01-01
安裝pycurl報(bào)錯(cuò)Could not run curl-config: &ap
這篇文章主要為大家介紹了安裝pycurl報(bào)錯(cuò)Could not run curl-config: 'curl-config'解決方法,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-12-12
Python反爬機(jī)制-驗(yàn)證碼功能的具體實(shí)現(xiàn)過(guò)程
Tesseract-OCR是一個(gè)免費(fèi)、開源的OCR引擎,通過(guò)該引擎可以識(shí)別圖片中的驗(yàn)證碼,這篇文章主要介紹了Python反爬機(jī)制-驗(yàn)證碼的示例代碼,需要的朋友可以參考下2022-02-02
Pygame游戲開發(fā)之太空射擊實(shí)戰(zhàn)圖像精靈下篇
相信大多數(shù)8090后都玩過(guò)太空射擊游戲,在過(guò)去游戲不多的年代太空射擊自然屬于經(jīng)典好玩的一款了,今天我們來(lái)自己動(dòng)手實(shí)現(xiàn)它,在編寫學(xué)習(xí)中回顧過(guò)往展望未來(lái),下面開始入門篇2022-08-08
解決python 出現(xiàn)unknown encoding: idna 的問題
這篇文章主要介紹了解決python出現(xiàn) unknown encoding: idna 的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2021-03-03
python射線法判斷檢測(cè)點(diǎn)是否位于區(qū)域外接矩形內(nèi)
這篇文章主要為大家詳細(xì)介紹了python射線法判斷檢測(cè)點(diǎn)是否位于區(qū)域外接矩形內(nèi),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-06-06
pandas去重復(fù)行并分類匯總的實(shí)現(xiàn)方法
這篇文章主要介紹了pandas去重復(fù)行并分類匯總的實(shí)現(xiàn)方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-01-01
用Python實(shí)現(xiàn)局域網(wǎng)控制電腦
大家好,本篇文章主要講的是用Python實(shí)現(xiàn)局域網(wǎng)控制電腦,感興趣的同學(xué)趕快來(lái)看一看吧,對(duì)你有幫助的話記得收藏一下2022-01-01
python實(shí)現(xiàn)定時(shí)壓縮指定文件夾發(fā)送郵件
這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)定時(shí)壓縮指定文件夾發(fā)送郵件,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-04-04

