zoukankan      html  css  js  c++  java
  • 弱口令扫描.python脚本

    转载自:

    手把手教你打造自己的弱口令扫描工具(系统弱口令篇)

    还可参考:https://blog.csdn.net/weixin_34162629/article/details/89362425

     

    前言

      在渗透测试过程中,弱口令检测是必要的一个环节,选择一个好用的弱口令扫描工具,尤为重要。

      类似的弱口令检测工具如:Hydra、Hscan、X-Scan,很多时候满足不了自己的需求。

      通过Python打造自己的弱口令扫描工具,集成在一起的Python脚本,在实战应用中,更切合实际。

    FTP模块

      FTP一般分为两种情况,匿名访问和弱口令,分别编写:

    复制代码
    复制代码
    import ftplib
    def ftp_anonymous(ip,port):
        try:
            ftp = ftplib.FTP()
            ftp.connect(ip,port,2)
            ftp.login()
            ftp.quit()
            print '[+] FTP login for anonymous'
        except:
            print '[-] checking for FTP anonymous fail'
    def ftp_login(ip,port,user,pwd):
        try:
            ftp = ftplib.FTP()
            ftp.connect(ip,port,2)
            ftp.login(user,pwd)
            ftp.quit()
            print '[+] FTP weak password: '+user,pwd
        except:
            print '[-] checking for '+user,pwd+' fail'
    复制代码
    复制代码

    SSH模块

    复制代码
    复制代码
    import paramiko
    def ssh_login(ip,port,user,pwd):
        try:
            ssh = paramiko.SSHClient()
            ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
            ssh.connect(ip,port,user,pwd,timeout=5)
            print '[+] SSH weak password: '+user,pwd
            ssh.close()
        except:
            print '[-] checking for '+user,pwd+' fail'
    复制代码
    复制代码

    Telnet模块

    复制代码
    复制代码
    import telnetlib
    def telnet(ip,port=23):
      try:
        tn = telnetlib.Telnet(ip,timeout=5)
        tn.set_debuglevel(0)
        tn.read_until("login: ")
        tn.write(user + '
    ')
        tn.read_until("assword: ")
        tn.write(pwd + '
    ')
        result = tn.read_some()
        result = result+tn.read_some()
        if result.find('Login Fail')>0 or result.find('incorrect')>0:
           print "[-] Checking for "+user,pwd+" fail"
        else:
          print "[+] Success login for "+user,pwd
        tn.close()
      except:
        print '[-] Something Error'+username,password+" fail"
    复制代码
    复制代码

    ipc$模块

    复制代码
    复制代码
    from impacket import smb
    def smb_login(ip,port,user,pwd):
        try:
            client = smb.SMB('*SMBSERVER',ip)
            client.login(user,pwd)
            flag ='[+] IPC$ weak password: '+user,pwd
        except:
            print '[-] checking for '+user,pwd+' fail'
    复制代码
    复制代码
  • 相关阅读:
    css 冷知识
    js跨域问题
    检测浏览器是否支持ES6
    新增项目到GIT仓库中
    如何正确设置统计博客园的个人博客访问量(图文详解)
    Node中包的加载机制
    图片路径中含有中文在jsp下不能正常显示的问题
    通过Xshell来访问和连接Linux
    文件下载该注意的问题
    文件上传该注意的问题
  • 原文地址:https://www.cnblogs.com/dazhu-secure/p/14135514.html
Copyright © 2011-2022 走看看