Xray批量化自動掃描


關於Xray高級版破解:

https://www.cnblogs.com/Cl0ud/p/13884206.html

不過好像新版本的Xray修復了破解的BUG,親測Xray1.3.3高級版仍然可以破解

因為Xray沒有批量化的選項,在網上查了一下,fofa2Xray是封裝好了的EXE文件,其他的好像需要配置代理之類的,反正挺麻煩,我只是想從txt里面按行讀取URL進行掃描,所以昨晚上花半個小時自己寫了一個小腳本實現Xray自動化批量掃描。

首先是一個大LOGO

def logo():
    logo='''
 _ __  _ __  _ __         
| '_ \| '_ \| '_ \        
| |_) | |_) | |_) |       
| .__/| .__/| .__/        
| |   | |   | |           
|_|   |_|   |_|           
   __   __                
   \ \ / /                
    \ V / _ __ __ _ _   _ 
    /   \| '__/ _` | | | |
   / /^\ \ | | (_| | |_| |
   \/   \/_|  \__,_|\__, |
                     __/ |
                    |___/ 
                            v1.0
                            author:springbird
    '''
    return logo

將Xray高級版破解之后路徑配置在環境變量里,這樣我們這個代碼就不需要固定位置放置

核心是

def xrayScan(targeturl,outputfilename="test"):
    scanCommand="xray.exe webscan --basic-crawler {} --html-output {}.html".format(targeturl,outputfilename)
    print(scanCommand)
    os.system(scanCommand)
    return

os.system執行命令進行掃描,這樣就實現了單個URL的腳本掃描,接着是讀取TXT實現批量

def pppGet():
    f = open("target.txt")
    lines = f.readlines()
    pattern = re.compile(r'^http://')
    for line in lines:
        try:
            if not pattern.match(line.strip()):
                targeturl="http://"+line.strip()
            else:
                targeturl=line.strip()
            print(targeturl.strip())
            outputfilename=hashlib.md5(targeturl.encode("utf-8"))
            xrayScan(targeturl.strip(), outputfilename.hexdigest())
            # print(type(line))
        except Exception as e:
            print(e)
            pass
    f.close()
    print("Xray Scan End~")
    return

這里的代碼就是從文件里面讀取URL,依次放在Xray里面進行掃描,放置待掃描URL的txt的名字為target.txt

最終完整代碼為:

import os
import hashlib
import re
​
def logo():
    logo='''
 _ __  _ __  _ __         
| '_ \| '_ \| '_ \        
| |_) | |_) | |_) |       
| .__/| .__/| .__/        
| |   | |   | |           
|_|   |_|   |_|           
   __   __                
   \ \ / /                
    \ V / _ __ __ _ _   _ 
    /   \| '__/ _` | | | |
   / /^\ \ | | (_| | |_| |
   \/   \/_|  \__,_|\__, |
                     __/ |
                    |___/ 
                            v1.0
                            author:springbird
    '''
    return logo
​
​
def xrayScan(targeturl,outputfilename="test"):
    scanCommand="xray.exe webscan --basic-crawler {} --html-output {}.html".format(targeturl,outputfilename)
    print(scanCommand)
    os.system(scanCommand)
    return
​
# def test():
#     pattern = re.compile(r'^http://')
#     m = pattern.match('http://www.baidu.com')
#     n = pattern.match('hta')
#     print(m)
#     print(n)
#     return
​
def pppGet():
    f = open("target.txt")
    lines = f.readlines()
    pattern = re.compile(r'^http://')
    for line in lines:
        try:
            if not pattern.match(line.strip()):
                targeturl="http://"+line.strip()
            else:
                targeturl=line.strip()
            print(targeturl.strip())
            outputfilename=hashlib.md5(targeturl.encode("utf-8"))
            xrayScan(targeturl.strip(), outputfilename.hexdigest())
            # print(type(line))
        except Exception as e:
            print(e)
            pass
    f.close()
    print("Xray Scan End~")
    return
​
def main():
    print(logo())
    pppGet()
    return
​
if __name__ == '__main__':
    main()

運行截圖為:

其實這個批量的功能還是挺重要的,或許是Xray開發團隊不想掃描器被濫用的原因才沒有實現該功能,把代碼放在了github上:

https://github.com/Cl0udG0d/pppXray

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM