Objective:
Today, my master called me to write a python version of the sword. And I wrote it before.
But not very well, this time there are new ideas.
Ideas:
Imperial Sword: Read all the paths in the sword configuration file, plus the URL that the user wants to scan. For batch detection, the path is present if the status code is 200 and no Error.ini error exists. Report existence Save.txt (detailed code)
Path:
Imperial Sword Code:
Import requestsimport randomimport osfile=[]url=[]error=[]bc=[]ip=[]headers={}user=input (' Import TXT: ') banner= ' _ ___ _ | _ \ ___ ___| |_ _ __ ___ _ _ ___ _ __ | | | |/ _ \/ __| __| ' __/_ \| | | |/_ \ ' __| | |_| | __/\__ \ |_| | | (_) | |_| | __/ | |____/ \___|| ___/\__|_| \___/ \__, |\___|_| |___/producer:nine World "Useragent=[]twoo=[]print (banner) def urls (): Dk=open (' {} '. Format (user), ' R ') for K In Dk.readlines (): qcs= "". Join (K.split (' \ n ')) Url.append (QCS) print (' [+]url.txt Load completion ') PRI NT (") print (") URLs () def judge (): Pd=os.listdir (' Imperial Sword Config file ') for name in Pd:file.append (name) for F in file: Print (' [+]existence {} '. Format (f)) print (') print (') ' Dk=open (' user-agent.txt ', ' R ') for D in Dk.readlines (): Qc= "". Join (D.split (' \ n ')) Useragent.append (QC) print (' [+]user-agent Load completion ') print (') print (") Judge ( ) def errors(): Lv=open (' Error/error.txt ', ' R ') for E in Lv.readlines (): qcsw= "". Join (E.split (' \ n ')) Error.append (q CSW) print (' [+]the filter file is loaded ') print (') print (') errors () def Forge (): sj=[] Dkw=open (' Ip.txt ', ' r ') for I in Dkw.readlines (): k= "". Join (I.split (' \ n ')) Ip.append (k) for G in range (0,len (useragent) ): u= ' user-agent= ' x= ' x-forwarded-for= ' c= ' client-ip= ' Sj.append (u+useragent[g]+ ' & ' +x+ip[g ]+ ' & ' +c+ip[g]) kc=list (set (SJ)) Su=random.choice (KC) qc=str (SU) for V in Qc.split (' & '): Key,val Ue=v.split (' = ', 1) headers[key]=valueforge () def exploit (): Wi=os.listdir (' Imperial Sword Config file ') for W in Wi:dp=open (' {} '). Format (' Royal Sword Profile/' +w '), ' R ', encoding= ' GBK ') for S in Dp.readlines (): we= "". Join (S.split (' \ n ')) for u in url:up= ' {} '. Format (u). Rstrip ('/') +we Try:requet=requests.get (url=up,headers=he Aders,timeout=3,allow_reDirects=false) for E in Error:if requet.status_code==200 and not E in Requet.text: Ok= ' [+]code:{} url:{} '. Format (requet.status_code,requet.url) if OK in Twoo:conti Nue Twoo.append (OK) print (OK) Else: no= ' [x]not URL: {} '. Format (Requet.url) if no in Bc:continue bc.append (NO) Print (no) except Exception as U:print (' [-]error {} '. Format (u)) if L En (Twoo) >0:od=open (' Save.txt ', ' W ') Od.close () xr=open (' Save.txt ', ' R ') for C in Twoo:prin T (C,file=open (' save.txt ', ' a ')) exploit ()
Test results:
github:https://github.com/422926799/python/tree/master/%e5%be%a1%e5%89%91
Python writes a sword.