|
|
@ -25,7 +25,7 @@ import java.util.Scanner; |
|
|
|
* @author GuoXin |
|
|
|
* @author GuoXin |
|
|
|
* @date 2024/1/6 |
|
|
|
* @date 2024/1/6 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Rule(key = "FlagLine1Rule", name = "sql注入", description = "sql注入有一定风险", priority = Priority.INFO, tags = {"28suo"}) |
|
|
|
@Rule(key = "SqlVarNameChecker", name = "sql注入", description = "sql注入有一定风险", priority = Priority.INFO, tags = {"28suo"}) |
|
|
|
@ActivatedByDefault |
|
|
|
@ActivatedByDefault |
|
|
|
@SqaleConstantRemediation("5min") |
|
|
|
@SqaleConstantRemediation("5min") |
|
|
|
public class SqlVarNameChecker implements FlagLineRule { |
|
|
|
public class SqlVarNameChecker implements FlagLineRule { |
|
|
@ -54,25 +54,5 @@ public class SqlVarNameChecker implements FlagLineRule { |
|
|
|
throw new RuntimeException(e); |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
/* |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void visitNode(AstNode node) { |
|
|
|
|
|
|
|
File file = getContext().getFile(); |
|
|
|
|
|
|
|
System.out.println("文件路径: " + file.getAbsolutePath()); |
|
|
|
|
|
|
|
try (BufferedReader reader = new BufferedReader(new FileReader(file))) { |
|
|
|
|
|
|
|
String line; |
|
|
|
|
|
|
|
int lineNumber = 0; |
|
|
|
|
|
|
|
while ((line = reader.readLine()) != null) { |
|
|
|
|
|
|
|
lineNumber++; |
|
|
|
|
|
|
|
if (line.contains("= '") || line.contains("OR 1=1") || line.contains("='") |
|
|
|
|
|
|
|
|| line.contains("DROP TABLE") || line.contains("' OR 'a'='a") || line.contains("'; DROP TABLE users; --") |
|
|
|
|
|
|
|
|| line.contains("'; EXEC xp_cmdshell 'dir'") || line.contains("' OR username LIKE '%") || line.contains("' AND SLEEP(5)") |
|
|
|
|
|
|
|
|| line.contains("= \\'' +") || line.contains("= ?")) { |
|
|
|
|
|
|
|
getContext().createLineViolation(ABCVarNameChecker.this, "sql 注入有一定风险", lineNumber); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|