05.文件包含绕过
本文最后更新于521 天前,其中的信息可能已经过时,如有错误请发送邮件到big_fw@foxmail.com

一、有限制的本地文件包含漏洞绕过:

漏洞代码:

<?php
file=_GET[‘file’];
include($file.".html");
?>
  该代码会默认给文件加一个.html后缀
  导致无法找到该文件
Pasted image 20241116101646.png

绕过方式:
上传html文件
Pasted image 20241116100906.png

Pasted image 20241116101517.png

不能上传html文件时其他绕过方法

第一种方式 %00截断

条件:magic_quotes_gpc=off   PHP版本<5.3.4

第二种路径长度截断

条件:windows ,点号需要长度256;linux 长度需要4096.

Windows下目录最大长度为256字节,超出的部分会被==丢弃==;

Linux下目录最大长度为4096字节,超出的部分会被==丢弃==。

成功截断
/././././././././.(后面省略许多/.)

Pasted image 20241116104652.png

或者…………………………….
Pasted image 20241116104856.png

二、有限制的远程文件包含漏洞:

测试代码也是一样的。

<?php
  $file = GET[file];include(file.".html");
  ?>

Pasted image 20241116110031.png

Pasted image 20241116110447.png

Pasted image 20241116110350.png

1.第一种问号绕过

问号后面的值会当成参数
yuancheng.txt–>yuancheng.txt.html
Pasted image 20241116110900.png

2.第二种井号绕过

号(%23)不是注释

Pasted image 20241116111134.png

3.当allow_url_include和allow_url_fopen设置为off时绕过

在PHP配置文件中,“allow_url_include”wrapper默认设置为“Off”,指示PHP不加载远程HTTP或FTP URL,从而防止远程文件包含攻击。但是,即使“allow_url_include”和“allow_url_fopen”都设置为“Off”,PHP也不会阻止加载SMB URL。而这就极有可能被滥用来从SMB共享加载远程托管的PHP Web shell。

SMB(Server Messages Block,信息服务块)是一种在局域网上共享文件和打印机的一种通信协议,它为局域网内的不同计算机之间提供文件及打印机等资源的共享服务。

smb.conf配置文件:

[global]
workgroup = WORKGROUP     
server string = Samba Server %v
netbios name = indishell-lab
security = user
map to guest = bad user
name resolve order = bcast host
dns proxy = no
bind interfaces only = yes
[ica]
path = /var/www/html/pub
writable = no
guest ok = yes
guest only = yes
read only = yes
directory mode = 0555

kali搭建SMB

1.启动samba

Pasted image 20241116193040.png

2.
Pasted image 20241116193147.png

3.创建pub共享文件夹
Pasted image 20241116193311.png

4.设置权限
Pasted image 20241116193345.png

5.
Pasted image 20241116194923.png

6.修改配置文件
Pasted image 20241116210315.png

Pasted image 20241116210827.png

7.重启smaba
Pasted image 20241116210514.png

8.在共享文件里编写木马
Pasted image 20241116210610.png

Pasted image 20241116210729.png

9.打开运行框
Pasted image 20241116115113.png

10.访问共享文件夹
Pasted image 20241116213623.png

11.进行文件包含
成功绕过
Pasted image 20241116213252.png

文末附加内容
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇