@@ -77,11 +77,36 @@ def ai_suggest_next_steps(report, scan_history=None, extracted_data=None):
7777 if any (opt .startswith ('--data=' ) for opt in options ) and "json" in ' ' .join (options ).lower () and not any (opt == '--json' for opt in options ):
7878 options .append ("--json" )
7979
80- # Filter out options that might cause issues
80+ # Filter out options that might cause issues and optimize for timeout prevention
8181 valid_options = []
82+ has_timeout_risk = False
83+
8284 for opt in options :
83- if not opt .startswith ('-d ' ) and not opt == '-d' and not opt == '--dump-all' :
84- valid_options .append (opt )
85+ # Skip potentially problematic options
86+ if opt .startswith ('-d ' ) or opt == '-d' or opt == '--dump-all' :
87+ continue
88+
89+ # Check for high-complexity options that might cause timeouts
90+ if any (high_risk in opt for high_risk in ['--level=4' , '--level=5' , '--risk=4' , '--risk=5' , '--dump-all' ]):
91+ has_timeout_risk = True
92+
93+ valid_options .append (opt )
94+
95+ # If we have timeout risk, suggest a more conservative approach
96+ if has_timeout_risk :
97+ print_warning ("High-complexity options detected. Consider using more conservative settings to avoid timeouts." )
98+ # Replace high-risk options with safer alternatives
99+ safer_options = []
100+ for opt in valid_options :
101+ if opt == '--level=4' or opt == '--level=5' :
102+ safer_options .append ('--level=3' )
103+ elif opt == '--risk=4' or opt == '--risk=5' :
104+ safer_options .append ('--risk=2' )
105+ elif opt == '--dump-all' :
106+ safer_options .append ('--tables' ) # Start with table enumeration instead
107+ else :
108+ safer_options .append (opt )
109+ valid_options = safer_options
85110
86111 if not valid_options and structured_info .get ("dbms" , "" ).lower () == "sqlite" :
87112 print_info ("Using SQLite-specific options as fallback" )
@@ -109,6 +134,13 @@ def create_advanced_prompt(report, structured_info, scan_history=None, extracted
109134 Look at the scan report, previous steps, and any data extracted to decide the most effective next steps.
110135 Analyze what has been discovered so far and what remains to be explored.
111136
137+ # IMPORTANT: TIMEOUT CONSIDERATIONS
138+ - Avoid suggesting overly aggressive options that might cause timeouts
139+ - Prefer incremental approaches over comprehensive scans
140+ - Start with lower levels (1-2) and risks (1-2) before escalating
141+ - Use specific techniques rather than broad enumeration when possible
142+ - Consider the target's response time and stability
143+
112144 # SCAN REPORT SUMMARY:
113145 DBMS: {dbms}
114146 Vulnerable Parameters: {vulnerable_params}
@@ -132,6 +164,14 @@ def create_advanced_prompt(report, structured_info, scan_history=None, extracted
132164 3. Dumping interesting tables when appropriate
133165 4. Using techniques that haven't been tried yet
134166 5. Avoiding techniques that have failed
167+ 6. Using conservative settings to prevent timeouts
168+
169+ # OPTIMIZATION GUIDELINES:
170+ - Start with level 1-2 and risk 1-2 for initial scans
171+ - Use specific techniques (B, E, U, S, T) rather than all at once
172+ - Prefer targeted enumeration over broad scanning
173+ - Use --tables before --dump to avoid excessive data extraction
174+ - Consider using --threads=3-5 for better performance
135175
136176 # DBMS-SPECIFIC GUIDELINES:
137177 - For SQLite databases: Use '--tables' instead of '--dbs' as SQLite doesn't support database enumeration.
@@ -142,7 +182,7 @@ def create_advanced_prompt(report, structured_info, scan_history=None, extracted
142182 # SQL INJECTION SCENARIOS:
143183 - Classic GET Parameter: For URLs like 'http://target.com/page.php?id=1', use basic options like '--dbs'
144184 - URL Path Parameter: For URLs like 'http://target.com/page/1/', use asterisk as injection marker (e.g., 'page/1*') and '--dbs'
145- - Multiple Parameters: For URLs with multiple parameters, specify which to test with '-p' or use '--level=3 ' to test all
185+ - Multiple Parameters: For URLs with multiple parameters, specify which to test with '-p' or use '--level=2 ' to test all
146186 - POST Parameter: Use '--data' or '--forms' to test POST parameters
147187 - Cookie-Based: Use '--cookie' to specify cookie values to test
148188 - Header-Based: Use '--headers' to test HTTP headers for injection
@@ -155,8 +195,9 @@ def create_advanced_prompt(report, structured_info, scan_history=None, extracted
155195 }}
156196 ```
157197
158- Each option should be a separate string in the array (e.g., "--level=3 ", "--risk=2 ").
198+ Each option should be a separate string in the array (e.g., "--level=2 ", "--risk=1 ").
159199 Be specific and concise. Don't include basic options like -u (URL) as these will be added automatically.
200+ Prefer conservative settings to avoid timeouts.
160201 """
161202 report_lines = report .split ('\n ' )
162203 report_excerpt = '\n ' .join (report_lines [- 30 :]) if len (report_lines ) > 30 else report
0 commit comments