### 简要描述:
一处有点奇葩的文件上传………………
### 详细说明:
关键点:找到路径、绕过某个无聊的if判断。需要管理员权限
### 漏洞证明:
jis/manage/sys/opr_logo.jsp
```
String strLoadPath = request.getSession().getServletContext().getRealPath("/front");
Convert.createDirectory( strLoadPath + "/tmp/" );
CommonUploadFile upload = new CommonUploadFile( strLoadPath +"/tmp", "");
```
路径在front下的tmp文件夹
接着看:
```
if(strFileName.toLowerCase().endsWith("gif")||strFileName.toLowerCase().endsWith("jpg")){
//修改文件名
file = new File( strLoadPath + "/tmp/" + strFileName );
fileNew = new File( strLoadPath + "/logo/t_logo.gif" );
if(fileNew.exists())
fileNew.delete();
file.renameTo( fileNew);
}
```
这段if是我们要绕过的,为什么呢?因为只要是后面3位字符是gif或jpg,他就会将文件重命名!修改为t_logo.gif
如果我们不是这3个字符结尾的话,就不会重命名!也就是说,可以直接上传jsp文件,找到路径就可以了!在tmp文件夹下他不会重命名文件的。感觉很神奇
[<img src="https://images.seebug.org/upload/201402/06115108a71178980af56cdaaf5dd1c7a28601ac.png" alt="image069.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201402/06115108a71178980af56cdaaf5dd1c7a28601ac.png)
直接改包传jsp文件即可:
比如我们上传code.jsp,上传后的路径为jis\front\tmp\code.jsp
[<img src="https://images.seebug.org/upload/201402/061151409e64b5e86d709bf536001f4ff4c17635.png" alt="image070.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201402/061151409e64b5e86d709bf536001f4ff4c17635.png)
暂无评论