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

 

 


Tema destacado: Guía rápida para descarga de herramientas gratuitas de seguridad y desinfección


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  StrConv Alternative Function
0 Usuarios y 2 Visitantes están viendo este tema.
Páginas: [1] 2 3 Ir Abajo Respuesta Imprimir
Autor Tema: StrConv Alternative Function  (Leído 10,842 veces)
Swellow

Desconectado Desconectado

Mensajes: 77


Ver Perfil
StrConv Alternative Function
« en: 7 Octubre 2012, 17:03 pm »

Hola amigos!

Does anyone could help me fixing this function? It works but fails with unicode chars.... Here it is:

Código:
Public Function AltStrConv(Temp As Variant, Conversion As VbStrConv) As Variant
Dim i As Long, lLen As Long, bvHack(0) As Byte, lHackDelta As Long
Dim bArr() As Byte, sString As String
 
lHackDelta = VarPtr(bvHack(0))
 
If Conversion = vbFromUnicode Then
    sString = Temp
    lLen = Len(sString)
    ReDim bArr(0 To lLen - 1)
    For i = 0 To lLen - 1
        bvHack(VarPtr(bArr(0)) - lHackDelta + i) = bvHack(StrPtr(sString) - lHackDelta + (i * 2))
    Next i
    AltStrConv = bArr
ElseIf Conversion = vbUnicode Then
    bArr = Temp
    lLen = UBound(Temp) + 1
    sString = Space$(lLen)
    For i = 0 To lLen - 1
        bvHack(StrPtr(sString) - lHackDelta + (i * 2)) = bvHack(VarPtr(bArr(0)) - lHackDelta + i)
    Next i
    AltStrConv = sString
End If
 
End Function

Thanks A lot!


« Última modificación: 7 Octubre 2012, 17:25 pm por Swellow » En línea

Danyfirex


Desconectado Desconectado

Mensajes: 493


My Dear Mizuho


Ver Perfil
Re: StrConv Alternative Function
« Respuesta #1 en: 7 Octubre 2012, 22:09 pm »

aquí te la dejo como se me ocurrió.  ;D

Código
  1. Private Function AltStrConv(Temp As Variant, Conversion As VbStrConv) As Variant
  2. Dim i As Long, lLen As Long
  3. Dim bArr() As Byte, sString As String
  4.  
  5.  
  6.  
  7. If Conversion = vbFromUnicode Then
  8.    sString = Temp
  9.    lLen = Len(sString) - 1
  10.    ReDim bArr(lLen)
  11.    For i = 0 To lLen
  12.       bArr(i) = Asc(Mid(Temp, (i + 1), 1))
  13.       Next i
  14.    AltStrConv = bArr
  15.  
  16. ElseIf Conversion = vbUnicode Then
  17.    bArr = Temp
  18.    lLen = UBound(Temp)
  19.    sString = Space$(lLen + 1)
  20.    For i = 0 To lLen
  21.    sString = sString & Chr(bArr(i))
  22.    Next i
  23.    AltStrConv = sString
  24. End If
  25.  
  26. End Function
  27.  


saludos


En línea

Swellow

Desconectado Desconectado

Mensajes: 77


Ver Perfil
Re: StrConv Alternative Function
« Respuesta #2 en: 7 Octubre 2012, 23:02 pm »

aquí te la dejo como se me ocurrió.  ;D

Código
  1. Private Function AltStrConv(Temp As Variant, Conversion As VbStrConv) As Variant
  2. Dim i As Long, lLen As Long
  3. Dim bArr() As Byte, sString As String
  4.  
  5.  
  6.  
  7. If Conversion = vbFromUnicode Then
  8.    sString = Temp
  9.    lLen = Len(sString) - 1
  10.    ReDim bArr(lLen)
  11.    For i = 0 To lLen
  12.       bArr(i) = Asc(Mid(Temp, (i + 1), 1))
  13.       Next i
  14.    AltStrConv = bArr
  15.  
  16. ElseIf Conversion = vbUnicode Then
  17.    bArr = Temp
  18.    lLen = UBound(Temp)
  19.    sString = Space$(lLen + 1)
  20.    For i = 0 To lLen
  21.    sString = sString & Chr(bArr(i))
  22.    Next i
  23.    AltStrConv = sString
  24. End If
  25.  
  26. End Function
  27.  


saludos


Yeah I know this one but it uses Asc/Mid/Space/Chr and this is not good, if anyone can mod it without using Mid at least. Thanks
En línea

Danyfirex


Desconectado Desconectado

Mensajes: 493


My Dear Mizuho


Ver Perfil
Re: StrConv Alternative Function
« Respuesta #3 en: 8 Octubre 2012, 03:56 am »

maybe using copymemory. Tomorrow I'll try to make something.  :)
En línea

Karcrack


Desconectado Desconectado

Mensajes: 2.416


Se siente observado ¬¬'


Ver Perfil
Re: StrConv Alternative Function
« Respuesta #4 en: 8 Octubre 2012, 13:51 pm »

I made a post in HH time ago where I put all the different methods I found... Ofc HH is down so I can't paste them here... Anyway I throw some ideas: MultiByteToWideChar() and __vbaStrToUnicode()...

@Danyfirex: Working with memory is the same as using the "bvHack()" thingy.
En línea

Swellow

Desconectado Desconectado

Mensajes: 77


Ver Perfil
Re: StrConv Alternative Function
« Respuesta #5 en: 8 Octubre 2012, 15:37 pm »

I made a post in HH time ago where I put all the different methods I found... Ofc HH is down so I can't paste them here... Anyway I throw some ideas: MultiByteToWideChar() and __vbaStrToUnicode()...

@Danyfirex: Working with memory is the same as using the "bvHack()" thingy.

It's no problem if it use memory (bvHack) but do not use APIs..
En línea

Danyfirex


Desconectado Desconectado

Mensajes: 493


My Dear Mizuho


Ver Perfil
Re: StrConv Alternative Function
« Respuesta #6 en: 8 Octubre 2012, 16:42 pm »

I made a post in HH time ago where I put all the different methods I found... Ofc HH is down so I can't paste them here... Anyway I throw some ideas: MultiByteToWideChar() and __vbaStrToUnicode()...



@Danyfirex: Working with memory is the same as using the "bvHack()" thingy.

si ya veo, es que no recordaba ese tema.

voy a mirar con bvHack().
En línea

Danyfirex


Desconectado Desconectado

Mensajes: 493


My Dear Mizuho


Ver Perfil
Re: StrConv Alternative Function
« Respuesta #7 en: 8 Octubre 2012, 17:38 pm »

well before reading about Karcrack says , I notice that is necesary to remove array bounds checks and try out of Visual Basic IDE, it means Compiled, And work Correctly.

try it.



En línea

Swellow

Desconectado Desconectado

Mensajes: 77


Ver Perfil
Re: StrConv Alternative Function
« Respuesta #8 en: 8 Octubre 2012, 17:50 pm »

well before reading about Karcrack says , I notice that is necesary to remove array bounds checks and try out of Visual Basic IDE, it means Compiled, And work Correctly.

try it.





Yes I already checked that but It's not the problem, the function works but fails with unicode chars, try using it on this function and then try encrypting a string you will realize that it does not work...

Código:
Function ROTXDecrypt(ByVal strData As String, ByVal strKey As String)
    On Error Resume Next
    Dim bData() As Byte, bKey() As Byte
    bData = AltStrConv(strData, vbFromUnicode)
    bKey = AltStrConv(strKey, vbFromUnicode)
    For i = 0 To UBound(bData)
        If i <= UBound(bKey) Then
            bData(i) = bData(i) - bKey(i)
        Else
            bData(i) = bData(i) - bKey(i Mod UBound(bKey))
        End If
    Next i
    ROTXDecrypt = AltStrConv(bData, vbUnicode)
End Function

Function ROTXEncrypt(ByVal strData As String, ByVal strKey As String)
    On Error Resume Next
    Dim bData() As Byte
    Dim bKey() As Byte
    bData = StrConv(strData, vbFromUnicode)
    bKey = StrConv(strKey, vbFromUnicode)
    For i = 0 To UBound(bData)
        If i <= UBound(bKey) Then
            bData(i) = bData(i) + bKey(i)
        Else
            bData(i) = bData(i) + bKey(i Mod UBound(bKey))
        End If
    Next i
    ROTXEncrypt = StrConv(bData, vbUnicode)
End Function
En línea

Danyfirex


Desconectado Desconectado

Mensajes: 493


My Dear Mizuho


Ver Perfil
Re: StrConv Alternative Function
« Respuesta #9 en: 8 Octubre 2012, 18:07 pm »

Maybe you're trying before compiling. because If you're running into vb IDE doesn't work. but if you compile work correctly. at least for me work correclty.
En línea

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

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
GetProcAddress alternative function
Programación Visual Basic
cobein 2 3,012 Último mensaje 9 Octubre 2008, 00:24 am
por cobein
StrPtr Alternative
Programación Visual Basic
Swellow 4 2,942 Último mensaje 11 Junio 2012, 14:30 pm
por Swellow
[HELP] Invoke or Alternative to InternetReadFile API
Programación Visual Basic
Swellow 2 1,979 Último mensaje 22 Junio 2012, 04:31 am
por Swellow
Alternative Replace & Right Functions
Programación Visual Basic
Swellow 6 2,723 Último mensaje 9 Noviembre 2012, 20:46 pm
por Swellow
Duda sobre strconv y conversiones byte-caracter
Programación Visual Basic
OfTheVara 2 1,585 Último mensaje 8 Julio 2015, 13:11 pm
por OfTheVara
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines