Python脚本|根据URL生成特定目标网站备份文件猜测字典

Python小白,分享一个网站信息搜集的思路,并用Python写出脚本,仅供参考~

搜集常见的备份文件后缀类型,以及一些固定的文件名,可自由添加修改:

#coding=utf-8

# 根据URL生成特定目标网站备份文件猜测字典

#Test By: AnCoLin|影风

#http://www.storysec.com

suffixList = ['.rar','.zip','.sql','.gz','.tar','.bz2','.tar.gz','.bak','.dat']

keyList=['install','INSTALL','index','INDEX','ezweb','EZWEB','flashfxp','FLASHFXP']

# 请输入目标URL

print "Please input the URL:"
url = raw_input()

if (url[:5] == 'http:'):
    url = url[7:].strip()

if (url[:6] == 'https:'):
    url = url[8:].strip()

numT = url.find('/')

if(numT != -1):
    url = url - url[:numT]

# 根据URL,推测一些针对性的文件名:

num1 = url.find('.')
num2 = url.find('.',num1 + 1)

keyList.append(url[num1 + 1:num2])
keyList.append(url[num1 + 1:num2].upper())

keyList.append(url)  # www.test.com
keyList.append(url.upper())

keyList.append(url.replace('.','_'))  # www_test_com
keyList.append(url.replace('.','_').upper())

keyList.append(url.replace('.',''))  # wwwtestcom
keyList.append(url.replace('.','').upper())

keyList.append(url[num1 + 1:])   # test.com
keyList.append(url[num1 + 1:].upper())   

keyList.append(url[num1 + 1:].replace('.','_'))  # test_com
keyList.append(url[num1 + 1:].replace('.','_').upper())

# 生成字典列表,并写入txt文件:

tempList =[]

for key in keyList:
    for suff in suffixList:
        tempList.append(key + suff)

fobj = open("success.txt",'w')

for each in tempList:
    each ='/' + each
    fobj.write('%s%s' %(each,'\n'))
    fobj.flush()

print 'OK!'

测试如图:

根据darkless师傅的提示,进行了修改。对师傅表示感谢~

改成了python3下运行,功能上暂时没有多想的。。。

#coding=utf-8
# 根据 URL 生成特定目标网站备份文件猜测字典
#Test By: AnCoLin|影风
#http://www.storysec.com
suffixList = ['.rar','.zip','.sql','.gz','.tar','.bz2','.tar.gz','.bak','.dat']
keyList=['install','INSTALL','index','INDEX','ezweb','EZWEB','flashfxp','FLASHFXP']
# 请输入目标 URL
url =input("Please input the URL:")
if (url[:5] == 'http:'):
    url = url[7:].strip()
if (url[:6] == 'https:'):
    url = url[8:].strip()
numT = url.find('/')
if(numT != -1):
    url = url - url[:numT]

# 根据 URL,推测一些针对性的文件名:
num1 = url.find('.')
num2 = url.find('.',num1 + 1)

keyList.append(url[num1 + 1:num2])
keyList.append(url[num1 + 1:num2].upper())
keyList.append(url)  # www.test.com
keyList.append(url.upper())
keyList.append(url.replace('.','_'))  # www_test_com
keyList.append(url.replace('.','_').upper())
keyList.append(url.replace('.',''))  # wwwtestcom
keyList.append(url.replace('.','').upper())
keyList.append(url[num1 + 1:])   # test.com
keyList.append(url[num1 + 1:].upper())   
keyList.append(url[num1 + 1:].replace('.','_'))  # test_com
keyList.append(url[num1 + 1:].replace('.','_').upper())

# 生成字典列表,并写入 txt 文件:
tempList =[]
for key in keyList:
    for suff in suffixList:
        tempList.append(key + suff)
        fileName = url+'.'+'txt'
fobj = open(fileName,'w')

for each in tempList:
    each ='/' + each
    fobj.write('%s%s' %(each,'\n'))
    fobj.flush()

print("OK!")

图片展示:

文章目录

9 条评论

发表评论

*

  • 提点建议:如果按照你的代码文件操作执行 file flush()方法后,最好执行 close()方法 关闭文件 ,养成好习惯!推荐使用with 来操作文件,同时把简单的py2代码转换成py3 可以使用 2to3 库来操作

  • 可以优化下:
    第59行加:fileName = url+’.’+’txt’
    地60行改为:fobj = open(fileName,’w’)
    这样就能生成以输入网站为标题的字典文件了。

    • 想法很nice哦,我编程学的不怎么样,多多交流呀

  • 朋友 我的博客地址更新了 关键词:蜗居 URL地址: https://woj.app 望朋友看到更新一下呦。感谢。 好久没来了,路过踩一脚。