From d3df9374af830a29cb8ac2c69364739196fed0f2 Mon Sep 17 00:00:00 2001
From: hyb <kk_huangyangbo@163.com>
Date: Mon, 03 Nov 2025 03:04:13 +0000
Subject: [PATCH] 1.更新上传SQL注入安全报告模版 2.更新上传SQL注入安全风险报告 3.更新和补充sqlmap的命令详解和使用
---
测试组/脚本/Change_password/异步批量修改数据库的哈希密码和原始密码V2.0.py | 92 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 92 insertions(+), 0 deletions(-)
diff --git "a/\346\265\213\350\257\225\347\273\204/\350\204\232\346\234\254/Change_password/\345\274\202\346\255\245\346\211\271\351\207\217\344\277\256\346\224\271\346\225\260\346\215\256\345\272\223\347\232\204\345\223\210\345\270\214\345\257\206\347\240\201\345\222\214\345\216\237\345\247\213\345\257\206\347\240\201V2.0.py" "b/\346\265\213\350\257\225\347\273\204/\350\204\232\346\234\254/Change_password/\345\274\202\346\255\245\346\211\271\351\207\217\344\277\256\346\224\271\346\225\260\346\215\256\345\272\223\347\232\204\345\223\210\345\270\214\345\257\206\347\240\201\345\222\214\345\216\237\345\247\213\345\257\206\347\240\201V2.0.py"
index ba139ee..bcb737a 100644
--- "a/\346\265\213\350\257\225\347\273\204/\350\204\232\346\234\254/Change_password/\345\274\202\346\255\245\346\211\271\351\207\217\344\277\256\346\224\271\346\225\260\346\215\256\345\272\223\347\232\204\345\223\210\345\270\214\345\257\206\347\240\201\345\222\214\345\216\237\345\247\213\345\257\206\347\240\201V2.0.py"
+++ "b/\346\265\213\350\257\225\347\273\204/\350\204\232\346\234\254/Change_password/\345\274\202\346\255\245\346\211\271\351\207\217\344\277\256\346\224\271\346\225\260\346\215\256\345\272\223\347\232\204\345\223\210\345\270\214\345\257\206\347\240\201\345\222\214\345\216\237\345\247\213\345\257\206\347\240\201V2.0.py"
@@ -16,9 +16,92 @@
USER_COUNT = -1 # 每库更新前 N 个用户,-1 表示全部
PROTECTED_USER_ID = 1 # 需要排除的用户ID
+# Redis配置
+REDIS_HOST = '192.168.6.168'
+REDIS_PORT = 6002
+REDIS_PASSWORD = None
+
# === 日志列表与锁 ===
log_records = []
log_lock = asyncio.Lock()
+
+
+class RedisRefresher:
+ """Redis缓存刷新器"""
+
+ def __init__(self):
+ self.redis_client = None
+
+ async def connect_redis(self):
+ """连接Redis服务器"""
+ try:
+ # 尝试导入redis库
+ import redis
+ self.redis_client = redis.Redis(
+ host=REDIS_HOST,
+ port=REDIS_PORT,
+ password=REDIS_PASSWORD,
+ decode_responses=True
+ )
+ # 测试连接
+ await asyncio.to_thread(self.redis_client.ping)
+ return True
+ except ImportError:
+ print("错误: 未安装redis库,请使用 'pip install redis' 安装")
+ return False
+ except Exception as e:
+ print(f"连接Redis失败: {str(e)}")
+ return False
+
+ async def refresh_all_redis(self):
+ """刷新所有Redis数据库"""
+ try:
+ if not self.redis_client:
+ if not await self.connect_redis():
+ return False, "无法连接Redis服务器"
+
+ # 获取所有数据库数量
+ try:
+ # 尝试获取配置信息
+ config = await asyncio.to_thread(self.redis_client.config_get, 'databases')
+ db_count = int(config.get('databases', 16))
+ except:
+ # 如果无法获取配置,默认使用16个数据库
+ db_count = 16
+
+ refreshed_dbs = 0
+ total_keys = 0
+
+ # 遍历所有数据库并刷新
+ for db_index in range(db_count):
+ try:
+ # 切换到指定数据库
+ temp_client = self.redis_client.connection_pool.get_connection('ping')
+ await asyncio.to_thread(temp_client.send_command, 'SELECT', db_index)
+ await asyncio.to_thread(temp_client.read_response)
+
+ # 获取当前数据库的key数量
+ await asyncio.to_thread(temp_client.send_command, 'DBSIZE')
+ key_count = await asyncio.to_thread(temp_client.read_response)
+
+ if key_count > 0:
+ # 清空当前数据库
+ await asyncio.to_thread(temp_client.send_command, 'FLUSHDB')
+ await asyncio.to_thread(temp_client.read_response)
+ refreshed_dbs += 1
+ total_keys += key_count
+ print(f"已刷新数据库 {db_index}: 清除了 {key_count} 个键")
+
+ await asyncio.to_thread(self.redis_client.connection_pool.release, temp_client)
+
+ except Exception as e:
+ print(f"刷新数据库 {db_index} 时出错: {str(e)}")
+ continue
+
+ return True, f"成功刷新 {refreshed_dbs} 个Redis数据库,共清除 {total_keys} 个键"
+
+ except Exception as e:
+ return False, f"刷新Redis缓存时发生错误: {str(e)}"
def sanitize_filename(name: str) -> str:
@@ -377,6 +460,15 @@
else:
print("⚠️ 无任何更新记录生成")
+ # 数据库更新完成后,自动刷新Redis缓存
+ print("\n开始刷新Redis缓存...")
+ redis_refresher = RedisRefresher()
+ success, message = await redis_refresher.refresh_all_redis()
+ if success:
+ print(f"✅ {message}")
+ else:
+ print(f"❌ {message}")
+
# === 启动入口 ===
if __name__ == '__main__':
--
Gitblit v1.9.1