Skip to content

Commit 84469e2

Browse files
authored
Merge pull request #6563 from kingthorin/sqli-hyper-split
ascanrules: SQLi Hypersonic rename scan rule (all time based)
2 parents 105b9ad + ba75bf8 commit 84469e2

File tree

5 files changed

+14
-32
lines changed

5 files changed

+14
-32
lines changed

addOns/ascanrules/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
77
### Changed
88
- Maintenance changes.
99
- Depends on an updated version of the Common Library add-on.
10-
- The SQL Injection - MsSQL scan rule and alerts have been renamed to clarify that they're time based (Issue 7341).
10+
- The following scan rules and their alerts have been renamed to clarify that they're time based (Issue 7341).
11+
- SQL Injection - MsSQL
12+
- SQL Injection - Hypersonic
1113

1214
### Added
1315
- Rules (as applicable) have been tagged in relation to HIPAA and PCI DSS.
Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.Collections;
2525
import java.util.HashMap;
2626
import java.util.Iterator;
27-
import java.util.LinkedHashMap;
2827
import java.util.List;
2928
import java.util.Map;
3029
import java.util.concurrent.atomic.AtomicReference;
@@ -46,7 +45,7 @@
4645
/**
4746
* TODO: maybe implement a more specific UNION based check for Hypersonic (with table names)
4847
*
49-
* <p>The SqlInjectionHypersonicScanRule identifies Hypersonic specific SQL Injection
48+
* <p>The SqlInjectionHypersonicTimingScanRule identifies Hypersonic specific SQL Injection
5049
* vulnerabilities using Hypersonic specific syntax. If it doesn't use Hypersonic specific syntax,
5150
* it belongs in the generic SQLInjection class! Note the ordering of checks, for efficiency is : 1)
5251
* Error based (N/A) 2) Boolean Based (N/A - uses standard syntax) 3) UNION based (TODO) 4) Stacked
@@ -68,7 +67,7 @@
6867
*
6968
* @author 70pointer
7069
*/
71-
public class SqlInjectionHypersonicScanRule extends AbstractAppParamPlugin
70+
public class SqlInjectionHypersonicTimingScanRule extends AbstractAppParamPlugin
7271
implements CommonActiveScanRuleInfo {
7372

7473
/** Hypersonic one-line comment */
@@ -77,26 +76,6 @@ public class SqlInjectionHypersonicScanRule extends AbstractAppParamPlugin
7776
private static final String ORIG_VALUE_TOKEN = "<<<<ORIGINALVALUE>>>>";
7877
private static final String SLEEP_TOKEN = "<<<<SLEEP>>>>";
7978

80-
/**
81-
* create a map of SQL related error message fragments, and map them back to the RDBMS that they
82-
* are associated with keep the ordering the same as the order in which the values are inserted,
83-
* to allow the more (subjectively judged) common cases to be tested first Note: these should
84-
* represent actual (driver level) error messages for things like syntax error, otherwise we are
85-
* simply guessing that the string should/might occur.
86-
*/
87-
private static final Map<String, String> SQL_ERROR_TO_DBMS = new LinkedHashMap<>();
88-
89-
static {
90-
SQL_ERROR_TO_DBMS.put("org.hsql", "Hypersonic SQL");
91-
SQL_ERROR_TO_DBMS.put("hSql.", "Hypersonic SQL");
92-
SQL_ERROR_TO_DBMS.put("Unexpected token , requires FROM in statement", "Hypersonic SQL");
93-
SQL_ERROR_TO_DBMS.put("Unexpected end of command in statement", "Hypersonic SQL");
94-
SQL_ERROR_TO_DBMS.put("Column count does not match in statement", "Hypersonic SQL");
95-
SQL_ERROR_TO_DBMS.put("Table not found in statement", "Hypersonic SQL");
96-
SQL_ERROR_TO_DBMS.put("Unexpected token:", "Hypersonic SQL");
97-
// Note: only Hypersonic mappings here.
98-
}
99-
10079
/** the sleep function in Hypersonic SQL */
10180
private static final String SQL_HYPERSONIC_TIME_FUNCTION =
10281
"\"java.lang.Thread.sleep\"(" + SLEEP_TOKEN + ")";
@@ -212,7 +191,8 @@ public class SqlInjectionHypersonicScanRule extends AbstractAppParamPlugin
212191
}
213192

214193
/** for logging. */
215-
private static final Logger LOGGER = LogManager.getLogger(SqlInjectionHypersonicScanRule.class);
194+
private static final Logger LOGGER =
195+
LogManager.getLogger(SqlInjectionHypersonicTimingScanRule.class);
216196

217197
/** The number of seconds used in time-based attacks (i.e. sleep commands). */
218198
private int timeSleepSeconds = DEFAULT_SLEEP_TIME;

addOns/ascanrules/src/main/javahelp/org/zaproxy/zap/extension/ascanrules/resources/help/contents/ascanrules.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ <H2 id="id-40020">SQL Injection - Hypersonic (Time Based)</H2>
361361
<br>
362362
Post 2.5.0 you can change the length of time used for the attack by changing the <code>rules.common.sleep</code> parameter via the Options 'Rule configuration' panel.
363363
<p>
364-
Latest code: <a href="https://github.com/zaproxy/zap-extensions/blob/main/addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/SqlInjectionHypersonicScanRule.java">SqlInjectionHypersonicScanRule.java</a>
364+
Latest code: <a href="https://github.com/zaproxy/zap-extensions/blob/main/addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/SqlInjectionHypersonicTimingScanRule.java">SqlInjectionHypersonicTimingScanRule.java</a>
365365
<br>
366366
Alert ID: <a href="https://www.zaproxy.org/docs/alerts/40020/">40020</a>.
367367

addOns/ascanrules/src/main/resources/org/zaproxy/zap/extension/ascanrules/resources/Messages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ ascanrules.sqlinjection.alert.unionbased.extrainfo = RDBMS [{0}] likely, given U
180180
ascanrules.sqlinjection.authbypass.desc = SQL injection may be possible on a login page, potentially allowing the application's authentication mechanism to be bypassed
181181
ascanrules.sqlinjection.authbypass.name = SQL Injection - Authentication Bypass
182182
ascanrules.sqlinjection.desc = SQL injection may be possible.
183-
ascanrules.sqlinjection.hypersonic.name = SQL Injection - Hypersonic SQL
183+
ascanrules.sqlinjection.hypersonic.name = SQL Injection - Hypersonic SQL (Time Based)
184184
ascanrules.sqlinjection.mssql.alert.timebased.extrainfo = The query time is controllable using parameter value [{0}], which caused the request to take [{1}] milliseconds, when the original unmodified query with value [{2}] took [{3}] milliseconds.
185185
ascanrules.sqlinjection.mssql.name = SQL Injection - MsSQL (Time Based)
186186
ascanrules.sqlinjection.mysql.name = SQL Injection - MySQL
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838
import org.zaproxy.zap.model.TechSet;
3939
import org.zaproxy.zap.testutils.NanoServerHandler;
4040

41-
/** Unit test for {@link SqlInjectionHypersonicScanRule}. */
42-
class SqlInjectionHypersonicScanRuleUnitTest
43-
extends ActiveScannerTest<SqlInjectionHypersonicScanRule> {
41+
/** Unit test for {@link SqlInjectionHypersonicTimingScanRule}. */
42+
class SqlInjectionHypersonicTimingScanRuleUnitTest
43+
extends ActiveScannerTest<SqlInjectionHypersonicTimingScanRule> {
4444

4545
@Override
46-
protected SqlInjectionHypersonicScanRule createScanner() {
47-
return new SqlInjectionHypersonicScanRule();
46+
protected SqlInjectionHypersonicTimingScanRule createScanner() {
47+
return new SqlInjectionHypersonicTimingScanRule();
4848
}
4949

5050
@Test

0 commit comments

Comments
 (0)