测试 SQL 注入/删除表不起作用

Rla*_*law 1 mysql sql sql-injection

我试图通过删除表(用户)来测试针对我的网站的 SQL 注入,但它不起作用。

我的sql字符串语法:

String sql = "select * from users where username='" + username + "' and password='" + password + "';";
Run Code Online (Sandbox Code Playgroud)

我输入jack用户名字段和 test'; DROP TABLE users; --密码字段并得到以下 sql 字符串:

select * from users where username='jack' and password='test'; DROP TABLE users; --'; 然后我执行它:

Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(sql);
Run Code Online (Sandbox Code Playgroud)

但它不起作用,知道为什么吗?

Jua*_*eza 6

密码应该是:

' OR 1=1; DROP TABLE users; -- 
Run Code Online (Sandbox Code Playgroud)
  1. '关闭密码字符串
  2. 1=1将确保您找到结果。
  3. 将注释掉之前密码的 --最后一个'

编辑:

我犯了一个错误。正在考虑一个不同的黑客。这1=1是为了绕过密码检查并通过登录屏幕。

您只需关闭密码字符串

'; DROP TABLE users; -- 
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述