lzlzzzzzz

在渗透测试中,我们有时候会碰到拿到后台登录界面,而且没有其他漏洞可以利用,只能暴力破解用户名密码,现在直接使用弱口令的网站较少了,常见的字典一般是无法爆破成功,所以我们要针对网站内容来生成对应字典,进一步提升爆破成功率。

所以我们来写个小脚本来生成对应的字典

import exrex
import sys

web_white = [\'com\',\'cn\',\'gov\',\'www\',\'edu\',\'org\']

def host_para(host):
    if \'://\' in host:
        host = host.split(\'://\')[1].replace(\'/\',\' \')#将无用字符替换成空
    if \'/\' in host:
        host = host.replace(\'/\',\'\')
    return host
def dic_creat(hosts):
    web_dics = hosts.split(\'.\')#将有用的东西去除,例如demo,webdic,放入字典生成的地方,生成字典
    #将核心的生成规则写入配置文件,方便以后使用
    #可以对生成密码进行过滤
    f_rule = open(\'ruler.ini\',\'r\',encoding=\'UTF-8\')
    for i in f_rule:
        if \'#\' in  i[0]:
            rule = i
    f_pass_out = open(\'pass_0.txt\',\'r\')
    f_pass_out.close()
    for web_dic in web_dics:
        if web_dic not in web_white:
            f_pass =open(\'123.txt\',\'r\')#打开密码文件
            for dic_pass in f_pass:
                dics = list(exrex.generate( \'{web_dic}[!@#]{dic_pass}\'.format(web_dic = web_dic,dic_pass = dic_pass)))

                for dic in dics:
                    if len(dic) > 4:
                        f_pass_out =open(\'pass_1.txt\',\'a+\')
                        f_pass_out.write(dic =\'\n\')
                        f_pass_out.close()
                        print (dic)


#dic_creat(host_para(\'demo.123.com\'))
if __name__ ==\'__main__\':
    if len(sys.argv) == 2:
        dic_creat(host_para(sys.argv[1]))
        sys.exit(0)
    else:
        print(\'Usage: %s www.demo.com\'%sys.argv[0])
        sys.exit(-1)

我们主要使用了exrex模块来生成字典,将所有可能都列举到字典中,首先先做一个根据网站域名来生成对应字典,并和常见的弱口令结合来生成对应的字典。

将域名中提取出来的内容进行过滤,将符号等无用的东西去掉,并将核心的生成规则写入配置文件,便于修改,后续再加入扩展功能。

分类:

技术点:

相关文章:

  • 2021-09-19
  • 2021-11-22
  • 2021-09-19
  • 2021-09-19
  • 2021-10-07
  • 2022-01-18
  • 2021-10-02
  • 2021-11-29
猜你喜欢
  • 2021-09-19
  • 2021-08-23
  • 2021-11-11
  • 2021-07-15
  • 2021-11-09
  • 2021-08-21
  • 2022-01-15
相关资源
相似解决方案