Jump to content
Tuts 4 You
Sign in to follow this  
mrtifa13

[Help VB.NET] value does not fall within the expected range

Recommended Posts

mrtifa13

Hello eveyone , i was coding an obfuscator , everything is working good , but when i start to deobfuscate , it says value does not fall within the expected range , can someone help me please , here is the code 

  Private Sub DesignButton8_Click(sender As Object, e As EventArgs) Handles DesignButton8.Click
        Try
            Dim S As New SaveFileDialog
            S.Filter = "|*.exe"
            If S.ShowDialog = vbOK Then
                If Protectpart2() = True Then
                    ASM.Write(S.FileName)
                        MsgBox("Sucessfully Obfuscated at: " & vbCrLf & S.FileName, MsgBoxStyle.Information)
                    Else
                        Exit Sub
 
                    End If
                End If
        Catch ex As Exception
        End Try
    End Sub
 
    Public Function Protectpart2() As Boolean
        Dim FilePath As String = ""
        Try
            ASM = AssemblyDefinition.ReadAssembly(FilePath)
            ASM.MainModule.Attributes = ModuleAttributes.Required32Bit
            Dim definition As TypeDefinition
            For Each definition In ASM.MainModule.Types
                If (definition.Name <> "<Module>") Then
                    Me.RenameTypesMethodsFields(definition, True, True, True)
                    Dim i As Integer
                    For i = 0 To 750 - 1
                        Dim item As New MethodDefinition(Me.SingleCharRename, (MethodAttributes.ReuseSlot Or MethodAttributes.Private), ASM.MainModule.Import(Type.GetType("System.Void")))
                        definition.Methods.Add(item)
                        item.Body.Instructions.Add(Instruction.Create(OpCodes.Br_S, CByte(&H2C)))
                        item.Body.Instructions.Add(Instruction.Create(OpCodes.Nop))
                        List.Items.Add(item)
                    Next i
                End If
            Next
            Dim definition3 As TypeDefinition
            For Each definition3 In ASM.MainModule.Types
                If (definition3.Namespace <> "") Then
                    Dim newValue As String = Me.SingleCharRename
                    Dim resource As Resource
                    For Each resource In ASM.MainModule.Resources
                        resource.Name = resource.Name.Replace(definition3.Namespace, newValue)
                    Next
                    definition3.Namespace = newValue
                End If
            Next
        Catch exception As Exception
            MessageBox.Show(exception.Message)
            Return False
        End Try
        Return True
    End Function
 

Share this post


Link to post
GIV
n0th!ng

check your code more carefully and debug it


here is the problem :



Dim FilePath As String = ""

you've passed an empty path to "ReadAssembly"


Edited by n0th!ng (see edit history)
  • Like 1

Share this post


Link to post
mrtifa13

check your code more carefully and debug it

here is the problem :


Dim FilePath As String = ""

you've passed an empty path to "ReadAssembly"

well , how can i fix it :D , sorry for my lazy brain im just new on vb.net

Share this post


Link to post
GIV

How on earth you code a obfuscator if you don't know basic coding....????


 


Replace:



Dim FilePath As String = ""

With:



Dim result As DialogResult = OpenFileDialog1.ShowDialog()
If result = Windows.Forms.DialogResult.OK Then
Dim FilePath As String = OpenFileDialog1.FileName.ToString
EndIf

This is when you execute trough a button.


 


Inside your bolean function you can:


1. Make fixed file path value:



Dim FilePath As String = "c:\assembly.exe"

or before passing the arguments to function just open the dialog and pass the result to a variable withch is later imported to your boolean variable.



Public Function Protectpart2( byval mypath as string) As Boolean


Dim FilePath As String = mypath

Edited by GIV (see edit history)
  • Like 1

Share this post


Link to post
mrtifa13

 

How on earth you code a obfuscator if you don't know basic coding....????

 

Replace:

Dim FilePath As String = ""

With:

Dim result As DialogResult = OpenFileDialog1.ShowDialog()If result = Windows.Forms.DialogResult.OK ThenDim FilePath As String = OpenFileDialog1.FileName.ToStringEndIf

This is when you execute trough a button.

 

Inside your bolean function you can:

1. Make fixed file path value:

Dim FilePath As String = "c:\assembly.exe"

or before passing the arguments to function just open the dialog and pass the result to a variable withch is later imported to your boolean variable.

Public Function Protectpart2( byval mypath as string) As Boolean
Dim FilePath As String = mypath

like this u mean?

 

  Private Sub DesignButton8_Click(ByVal sender As Object, ByVal e As EventArgs) Handles DesignButton8.Click
        Try
            Dim File1 As New OpenFileDialog
            Dim FilePath As String = File1.FileName.ToString
            Dim result As DialogResult = File1.ShowDialog()
            If result = Windows.Forms.DialogResult.OK Then
                File1.FileName.ToString()
            End If
            Dim S As New SaveFileDialog
            S.Filter = "|*.exe"
            If S.ShowDialog = vbOK Then
                If Protectpart2() = True Then
                    ASM.Write(S.FileName)
                    ASM.Write(SavePath)
                    MsgBox("Sucessfully Obfuscated at: " & vbCrLf & S.FileName, MsgBoxStyle.Information)
                Else
                    Exit Sub
 
                End If
            End If
        Catch ex As Exception
        End Try
    End Sub
 
    Public Function Protectpart2() As Boolean
        Dim FilePath As String = "c:\...\...\desktop\"
        Try
            ASM = AssemblyDefinition.ReadAssembly(FilePath)
            ASM.MainModule.Attributes = ModuleAttributes.Required32Bit
            Dim definition As TypeDefinition
            For Each definition In ASM.MainModule.Types
                If (definition.Name <> "<Module>") Then
                    Me.RenameTypesMethodsFields(definition, True, True, True)
                    Dim i As Integer
                    For i = 0 To 750 - 1
                        Dim item As New MethodDefinition(Me.SingleCharRename, (MethodAttributes.ReuseSlot Or MethodAttributes.Private), ASM.MainModule.Import(Type.GetType("System.Void")))
                        definition.Methods.Add(item)
                        item.Body.Instructions.Add(Instruction.Create(OpCodes.Br_S, CByte(&H2C)))
                        item.Body.Instructions.Add(Instruction.Create(OpCodes.Nop))
                        List.Items.Add(item)
                    Next i
                End If
            Next
            Dim definition3 As TypeDefinition
            For Each definition3 In ASM.MainModule.Types
                If (definition3.Namespace <> "") Then
                    Dim newValue As String = Me.SingleCharRename
                    Dim resource As Resource
                    For Each resource In ASM.MainModule.Resources
                        resource.Name = resource.Name.Replace(definition3.Namespace, newValue)
                    Next
                    definition3.Namespace = newValue
                End If
            Next
        Catch exception As Exception
            MessageBox.Show(exception.Message)
            Return False
        End Try
        Return True
    End Function

Share this post


Link to post
GIV

Define a global variable as:

public FilePath  as string=""

Just before execute your code make a button with the code inside:

 

 

 

Dim result As DialogResult = OpenFileDialog1.ShowDialog()
If result = Windows.Forms.DialogResult.OK Then
Dim FilePath As String = OpenFileDialog1.FileName.ToString
EndIf

Share this post


Link to post
mrtifa13

Define a global variable as:

public FilePath  as string=""

Just before execute your code make a button with the code inside:

do u have skype?

Share this post


Link to post
GIV

Yep.

Share this post


Link to post
mrtifa13

name?


Share this post


Link to post
mrtifa13

add me : forzizo2010_1

Share this post


Link to post
mrtifa13

Yep.

please answer me or add

Share this post


Link to post
GIV

Look at my profile to see my Skype name.


Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×
×
  • Create New...