forked from crucible-security/crucible
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_gemini_crescendo.py
More file actions
87 lines (71 loc) · 2.43 KB
/
Copy pathrun_gemini_crescendo.py
File metadata and controls
87 lines (71 loc) · 2.43 KB
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
import os
import subprocess
import sys
import json
def get_api_key(key_name):
# Try API_KEY_HERE.txt specifically for Gemini
try:
simple_file = os.path.join(os.path.dirname(__file__), "API_KEY_HERE.txt")
if os.path.exists(simple_file):
with open(simple_file, "r") as f:
key = f.read().strip()
if key and "PASTE_YOUR" not in key:
return key
except Exception:
pass
# Try environment variable
key = os.getenv(key_name)
if key:
return key
# Try crucible_keys.json
try:
keys_file = os.path.join(os.path.dirname(__file__), "crucible_keys.json")
if os.path.exists(keys_file):
with open(keys_file, "r") as f:
keys = json.load(f)
key = keys.get(key_name)
if key and "PASTE_YOUR" not in key:
return key
except Exception:
pass
return None
def main():
try:
# Google Gemini AI Studio endpoint
model = os.getenv("GEMINI_MODEL", "gemini-flash-latest")
key = get_api_key("GEMINI_API_KEY")
if not key:
print("Error: GEMINI_API_KEY not found.")
sys.exit(1)
target_url = f"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={key}"
print("\n" + "=" * 60)
print(f" STARTING ADVANCED GEMINI CRESCENDO AUDIT ({model})")
print("=" * 60 + "\n")
# We don't need a body-file for multi-turn as the engine handles it
# but the CLI might require something to start.
# Actually, the MultiTurnEngine ignores the body template if it's Gemini.
cmd = [
sys.executable,
"-m",
"crucible.cli",
"scan",
"--target",
target_url,
"--name",
f"Gemini-Crescendo-Audit",
"--strategy",
"multi-turn",
"--delay",
"3000", # Higher delay for multi-turn stability
"--generate-report",
"--verbose", # Multi-turn is more interesting to see live
]
try:
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
print(f"Error during Gemini Crescendo scan: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
sys.exit(1)
if __name__ == "__main__":
main()