|
641
|
Programación / Programación Visual Basic / Re: Como saber si una carpeta esta vacia
|
en: 7 Abril 2009, 21:26 pm
|
Igual como escribirias y leerias cualquier archivo '--------------------------------------------------------------------------------------- ' Procedimiento : ReadFile ' Autor : Karcrack ' Fecha : 07/04/2009 ' Parametro(s) : sPath -> La ruta del fichero ' Return : Devuelve un Byte array con los bytes del fichero '--------------------------------------------------------------------------------------- Private Function ReadFile(ByVal sPath As String) As Byte() Dim bvTmp() As Byte Open sPath For Binary As #1 ReDim bvTmp(0 To LOF(1) - 1) Get #1, , bvTmp Close #1 ReadFile = bvTmp End Function '--------------------------------------------------------------------------------------- ' Procedimiento : SaveFile ' Autor : Karcrack ' Fecha : 07/04/2009 ' Parametro(s) : bvData() -> Array de datos ' sPath -> Ruta de guardado '--------------------------------------------------------------------------------------- Private Sub SaveFile(ByRef bvData() As Byte, ByVal sPath As String) Open sPath For Binary As #1 Put #1, , bvData Close #1 End Sub
y para detectarlos http://foro.elhacker.net/programacion_vb/source_detectar_unidades_extraibles_usb-t214774.0.html;msg1030424
|
|
|
643
|
Programación / Programación Visual Basic / Re: Como saber si una carpeta esta vacia
|
en: 7 Abril 2009, 20:13 pm
|
Podrias ver con FindFirstFile si hay archivos o carpetas en la ruta , dame unos minutos y te hago un source. EDIT: Lo prometido es deuda , la función es 100% funcional , el parametro que hay que pasarle es lla ruta de la carpeta sin \ ni nada adelante por ejemplo para revisar C:\ ponemos C: . Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long Private Type FILETIME dwLowDateTime As Long dwHighDateTime As Long End Type Private Type WIN32_FIND_DATA dwFileAttributes As Long ftCreationTime As FILETIME ftLastAccessTime As FILETIME ftLastWriteTime As FILETIME nFileSizeHigh As Long nFileSizeLow As Long dwReserved0 As Long dwReserved1 As Long cFileName As String * 260 cAlternate As String * 14 End Type Dim Find As WIN32_FIND_DATA Dim HandleBusqueda As Long Public Function CapetaVacia(Ruta As String) As Boolean HandleBusqueda = FindFirstFile(Ruta & "\*", Find) FindNextFile HandleBusqueda, Find If Left(Find.cFileName, 2) = ".." Then FindNextFile HandleBusqueda, Find Else End If If Left(Find.cFileName, 2) = ".." Then CapetaVacia = True Else CapetaVacia = False End If End Function
|
|
|
644
|
Programación / ASM / Re: Pequeño visor PE
|
en: 6 Abril 2009, 23:07 pm
|
Ordenando el codigo de a poco. format pe console include 'win32ax.inc' .data Espacio equ 13,10,0 ;Para pasar a una nueva linea. RutaArchivo rb MAX_PATH ;Variable para guardar la ruta de el archivo PunteroPEheader dd ? ; Puntero de el Pe header Logo db ' ===================================',13,10 ; LOGO PRINCIPAL db ' = PE visor by YST =',13,10 db ' ===================================',13,10,0 LogoGeneral db ' ===================================',13,10 ; LOGO GENERAL db ' = General =',13,10 db ' ===================================',13,10,0 LogoSecciones db ' ===================================',13,10 db ' = Secciones =',13,10 ;LOGO DE INFO DE LAS SECCIONES db ' ===================================',13,10,0 LogoExport db ' ===================================',13,10 db ' = Export data =',13,10 ;LOGO DE INFO DE el Export data db ' ===================================',13,10,0 FHandle dd ? ; MZ de el archivo .code start: invoke system,"color 3" ;Ponemos el color de texto invoke printf,Logo ;Imprimimos el logo invoke printf,Espacio ;Ponemos dos nuevas lineas. invoke printf,Espacio invoke printf,"Inserte la ruta de el archivo a examinar:" ; Preguntamos el archivo invoke printf,Espacio invoke scanf,"%s",RutaArchivo ;Obtenemos la ruta de el archivo invoke LoadLibrary,RutaArchivo ;Cargamos el archivo .if eax = 0 ; Si hay error invoke printf,"Hubo un error al cargar el archivo." ;Mostramos el error . invoke ExitProcess,0 ; Nos salimos. .else ; De lo contrario .if word[eax] = "MZ" ; Si los primeros 2 bytes son igual a MZ mov [FHandle],eax ; Guardamos el MZ en FHandle .else ; De lo contrario invoke printf,"Ingrese un archivo valido." ;Mostramos el error . invoke ExitProcess,0 ; Nos salimos. .endif ; Terminamos los if .endif add eax,dword[eax+03ch] ; Guardamos en eax la direccion de el PE header .if word[eax] = "PE" ; Si los primeros 2 bytes son igual a PE mov [PunteroPEheader],eax ; Guardamos el puntero de el PE header en PunteroPEheader .else ; De lo contrario invoke printf,"No se a detectado PE header." ;Mostramos el error . invoke ExitProcess,0 ; Nos salimos. .endif ; Terminamos los if .endif invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,LogoGeneral ;Imprimimos el logo de la informacion general. invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,Espacio ; Pasamos a la siguiente linea. mov ebx,[FHandle] mov ebx,dword[ebx+03ch] invoke printf,"La posicion de el PE header es : 0x%x" ,ebx ;Mostramos la direccion de el PE header invoke printf,Espacio ; Pasamos a la siguiente linea. add ebx,[FHandle]; Le sumamos a la posicion de el PE header el MZ para pasar a el puntero de el PE header invoke printf,"TimeDateStamp: 0x%x " ,dword[ebx+08h] ; Imprimimo el TimeDateStamp invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,"SizeOfCode: 0x%x " ,dword[ebx+1ch] ; Imprimimo el SizeOfCode invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,"AddressOfEntrPoint: 0x%x " ,dword[ebx+28h] ; Imprimimo el AddressOfEntrPoint invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,"ImageBase: 0x%x " ,dword[ebx+34h] ; Imprimimo el ImageBase invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,"SizeOfImage: 0x%x " ,dword[ebx+50h] ; Imprimimo el SizeOfImage invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,"SizeOfHeaders: 0x%x " ,dword[ebx+54h] ; Imprimimo el SizeOfHeaders invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,"CheckSum: 0x%x " ,dword[ebx+58h] ; Imprimimo el CheckSum invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,"Subsystem: " ;Imprimimos el Subsystem .if dword[ebx+5Ch] = 2h ;SI es GUI invoke printf,"Windows GUI" ; Imprimimos Windows GUI .else ; De lo contrario es CUI (Consola) invoke printf,"Windows CUI" ; Imprimimos Windows CUI .endif ;Terminamos el if invoke printf,Espacio ; Pasamos a la siguiente linea. stdcall EOFExtraDataExtract,[FHandle] invoke printf,"Posicion de el EOF: 0x%x",eax ;Imprimimos la posicion de el EOF invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,LogoSecciones ;Imprimimos el logo de la informacion de las secciones. invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,Espacio ; Pasamos a la siguiente linea. mov esi,[PunteroPEheader] ;Movemos el puntero de el PE Header a esi. movzx ebx,word[esi+06h] ; Guardamos la cantidad de secciones en ebx. invoke printf,"Numero de secciones: %d",ebx ;Imprimimos la cantidad de secciones. invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,Espacio ; Pasamos a la siguiente linea. .bucleImprimeSecciones: ; Bucle que imprime secciones dec ebx ;Les restamos uno a ebx mov eax,28h ;Hacemos que eax sea igual a $28 mul ebx ;Multiplicamos ebx add eax,0xf8 ;Le sumamos $F8 ( $F8 = START OF SECTION TABLE ) add eax,esi ;Le agregamos al resultado de la multiplicacion el puntero de el PE header mov edi,eax ;Guardamos eax en edi invoke printf,"Name: %s",edi ;Imprimimos el nombre de la sección. invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,"virtual address: 0x%x",dword[edi+0ch] ;Imprimimos el virtual address invoke printf,Espacio ; Pasamos a la siguiente linea invoke printf,"VirtualSize: 0x%x",dword[edi+08h] ;Imprimimos el VirtualSize invoke printf,Espacio ; Pasamos a la siguiente linea invoke printf,"SizeOfRawData: 0x%x",dword[edi+10h] ; Imprimimos el SizeOfRawData invoke printf,Espacio ; Pasamos a la siguiente linea invoke printf,"pointerToRawData : 0x%x",dword[edi+14h] ;Imprimimos el pointerToRawData invoke printf,Espacio ; Pasamos a la siguiente linea invoke printf,"Characteristics: 0x%x",dword[edi+24h] ;Imprimimos las Characteristics invoke printf,Espacio ; Pasamos a la siguiente linea invoke printf,Espacio ; Pasamos a la siguiente linea invoke printf,Espacio ; Pasamos a la siguiente linea cmp ebx,0 jne .bucleImprimeSecciones ; Si no se an imprimido todas las secciones saltamos a lña etiqueta .bucleImprimeSecciones . invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,LogoExport ;Imprimimos el logo de la informacion de el export data. invoke printf,Espacio ; Pasamos a la siguiente linea. invoke printf,Espacio ; Pasamos a la siguiente linea. .if dword[esi+078h] = 0 ; Si no hay export data invoke printf,"No se exporta ninguna funcion." invoke printf,Espacio ; Pasamos a la siguiente linea. .else mov ebx,dword[esi+078h] add ebx,[FHandle] invoke printf,"Cantidad de funciones exportadas: %d",dword[ebx+18h] ;Imprimimo la cantidad de funciones exportadas. invoke printf,Espacio ; Pasamos a la siguiente linea. + mov edi,dword[ebx+20h] ;AddressOfNames add edi,[FHandle] mov ebx,dword[ebx+18h] ;Numero de exports invoke printf,"Funciones exportadas: " invoke printf,Espacio .bucleExportData: ;Bucle para imprimir la export data dec ebx mov eax, [edi + ebx * 4] add eax,[FHandle] invoke printf,"-%s",eax invoke printf,Espacio cmp ebx,0 jne .bucleExportData ;Si no se an imprimido todas seguimos .endif invoke system,"pause" invoke ExitProcess,0 proc EOFExtraDataExtract,FHandle ;Funcion para extraer el EOF push esi ebx mov eax,[FHandle] mov esi,dword[eax+03ch] ;Offset to start of PE header add esi,eax movzx ebx, word[esi+06h] ;Number Of Sections dec ebx mov eax,28h mul ebx add esi,0xf8 ;START OF SECTION TABLE add esi,eax mov eax,dword[esi+10h] ;SizeOfRawData add eax,dword[esi+14h] ;pointerToRawData pop ebx esi ret endp .end start section '.reloc' fixups data discardable
|
|
|
645
|
Programación / ASM / Re: Pequeño visor PE
|
en: 6 Abril 2009, 19:56 pm
|
Muy bueno lo que andas haciendo con este asm, sigue así Muchas gracias , en unos minutos pasare el code en limpio.
|
|
|
647
|
Programación / ASM / Re: Pequeño visor PE
|
en: 6 Abril 2009, 18:22 pm
|
Actualizado Ahora estoy haciendo para que ponga las funciones importadas , si alguien tiene alguna idea que se le puede agregar la puede decir.
|
|
|
648
|
Programación / ASM / SRCs de YST.
|
en: 6 Abril 2009, 03:44 am
|
Hola , basado en el visor PE de novirusthanks.org hice un modesto visor PE format pe console Espacio equ 13,10,0 include 'win32ax.inc' .data Logo db '===================================',13,10 db '= Humilde visor PE by YST =',13,10 db '===================================',13,10,0 RutaArch rb MAX_PATH HA dd ? bEscritos dd ? Log dd ? CrearLOG rb 10 .code start: invoke printf,Logo invoke printf,Espacio invoke printf,"Ponga la ruta a escanear: " invoke printf,Espacio invoke scanf,"%s",RutaArch invoke printf,Espacio invoke printf,Espacio invoke LoadLibrary,RutaArch stdcall Visualisar,eax invoke ExitProcess,0 proc Visualisar,FHandle push edi esi ebx .if [FHandle] = NULL jmp .error .endif mov eax,[FHandle] cmp word[eax],"MZ" jne .error mov eax,[FHandle] mov esi,dword[eax+03ch] ;Offset to start of PE header invoke printf,"%s","start of PE header: " invoke printf,"0x%x",esi invoke printf,"%s",Espacio add esi,[FHandle] movzx ebx, word[esi+06h] ;Number Of Sections invoke printf,"%s","TimeDateStamp: " invoke printf,"0x%x",dword[esi+8h] invoke printf,"%s",Espacio invoke printf,"%s","SizeOfCode: " invoke printf,"0x%x",dword[esi+1ch] invoke printf,"%s",Espacio invoke printf,"%s","Address Of Entry Point: " invoke printf,"0x%x",dword[esi+28h] invoke printf,"%s",Espacio invoke printf,"%s","ImageBase: " invoke printf,"0x%x",dword[esi+34h] invoke printf,"%s",Espacio invoke printf,"%s","SizeOfImage: " invoke printf,"0x%x",dword[esi+50h] invoke printf,"%s",Espacio invoke printf,"%s","SizeOfHeaders : " invoke printf,"0x%x",dword[esi+54h] invoke printf,"%s",Espacio invoke printf,"%s","CheckSum : " invoke printf,"0x%x",dword[esi+58h] invoke printf,"%s",Espacio invoke printf,"%s","Subsystem: " .if dword[esi+5Ch] = 2h invoke printf,"%s","Windows GUI" .else invoke printf,"%s","Windows CUI" .endif invoke printf,"%s",Espacio invoke printf,"%s","Posicion de el EOF: " stdcall EOFExtraDataExtract,[FHandle] invoke printf,"0x%x",eax invoke printf,"%s",Espacio invoke printf,"%s",Espacio invoke printf," SECTION'S " invoke printf,"%s",Espacio invoke printf,"%s",Espacio invoke printf,"%s","Numero de secciones: " invoke printf,"0x%x",ebx invoke printf,"%s",Espacio invoke printf,"%s",Espacio .bucle: dec ebx mov eax,28h mul ebx add eax,0xf8 add eax,esi mov edi,eax invoke printf,"Name: " invoke printf,"%s",edi invoke printf,"%s",Espacio invoke printf,"virtual address: " invoke printf,"0x%x",dword[edi+0ch] invoke printf,"%s",Espacio invoke printf,"VirtualSize : " invoke printf,"0x%x",dword[edi+08h] invoke printf,"%s",Espacio invoke printf,"SizeOfRawData: " invoke printf,"0x%x",dword[edi+10h] invoke printf,"%s",Espacio invoke printf,"pointerToRawData : " invoke printf,"0x%x",dword[edi+14h] invoke printf,"%s",Espacio invoke printf,"Characteristics : " invoke printf,"0x%x",dword[edi+24h] invoke printf,"%s",Espacio invoke printf,"%s",Espacio invoke printf,"%s",Espacio cmp ebx,0 jne .bucle mov eax,[FHandle] add eax,dword[eax+3ch] .if dword[eax+78h] = 0 .else invoke printf," EXPORT " invoke printf,"%s",Espacio invoke printf,"%s",Espacio stdcall ListarFunciones,[FHandle] .endif ;ListarImport invoke printf," Import's " invoke printf,Espacio invoke printf,Espacio mov eax,[FHandle] add eax,dword[eax+3ch] .if dword[eax+80h] = 0 invoke printf,"No incluye librerias ( .dll ) ." .else stdcall ListarImport ,[FHandle] .endif pop ebx esi edi ret .error: invoke printf,"Ingrese un archivo valido." pop ebx esi edi ret endp proc EOFExtraDataExtract,FHandle push esi ebx mov eax,[FHandle] mov esi,dword[eax+03ch] ;Offset to start of PE header add esi,eax movzx ebx, word[esi+06h] ;Number Of Sections dec ebx mov eax,28h mul ebx add esi,0xf8 ;START OF SECTION TABLE add esi,eax mov eax,dword[esi+10h] ;SizeOfRawData add eax,dword[esi+14h] ;pointerToRawData pop ebx esi ret endp proc ListarFunciones,LibHandle locals DirPEHeader dd ? PunteroPEHeader dd ? RVAofExportDirectory dd ? NumberOfNames dd ? AddressOfNames dd ? endl push ebx edx edi ecx mov eax,[LibHandle] cmp eax,NULL je .Error push dword[eax + 03Ch] pop [DirPEHeader] push [DirPEHeader] pop [PunteroPEHeader] add [PunteroPEHeader],eax mov ebx,[PunteroPEHeader] cmp word[ebx],"PE" jne .Error push dword[ebx+078h] pop [RVAofExportDirectory] mov ebx, [RVAofExportDirectory] add ebx,eax push dword[ebx+018h] pop [NumberOfNames] mov edx,[NumberOfNames] push dword[ebx+20h] pop [AddressOfNames] mov ebx,[NumberOfNames] invoke printf,"%s" ,"Cantidad de funciones exportadas: " invoke printf,"%d",[NumberOfNames] invoke printf,Espacio invoke printf,Espacio invoke printf,"Funciones exportadas: " invoke printf,Espacio mov edi, [AddressOfNames] add edi,[LibHandle] .bucle: dec ebx mov eax, [edi + ebx * 4] add eax,[LibHandle] invoke printf,"-%s",eax invoke printf,Espacio cmp ebx,0 jne .bucle pop ecx edi edx ebx ret .Error: ret endp proc ListarImport,FHandle push eax ebx edi mov ebx,[FHandle] add ebx,dword[ebx+03ch] mov ebx,dword[ebx+80h] add ebx,[FHandle] xor edi,edi .bucle: mov eax,dword[ebx+0ch] add eax,[FHandle] .if eax = [FHandle] invoke printf,"Cantidad de librerias importadas: %d",edi invoke printf,Espacio ret .else inc edi invoke printf,"%s",eax invoke printf,Espacio .endif add ebx,14h jmp .bucle pop edi ebx eax ret endp .end start
|
|
|
650
|
Programación / ASM / SRCs de YST.
|
en: 6 Abril 2009, 02:46 am
|
Hola , viendo una funcion desarrollada por un user de este foro , decidi hacer la mia propia ya que encontre que esta funcion se podia mejorar bastante , bueno se las dejo , el parametro que hay que pasarle es el "MZ" de el archivo , lo pueden cargar con LoadLibrary si se quiere . proc EOFExtraDataExtract,FHandle push esi ebx mov eax,[FHandle] mov esi,dword[eax+03ch] ;Offset to start of PE header add esi,eax movzx ebx, word[esi+06h] ;Number Of Sections dec ebx mov eax,28h mul ebx add esi,0xf8 ;START OF SECTION TABLE add esi,eax mov eax,dword[esi+10h] ;SizeOfRawData add eax,dword[esi+14h] ;pointerToRawData pop ebx esi ret endp
|
|
|
|
|
|
|