Visual Basic.NET - Buscar Contraseña de Conexion a DB

 
Vista:
sin imagen de perfil

Buscar Contraseña de Conexion a DB

Publicado por Nelson LC (5 intervenciones) el 22/08/2015 06:47:41
Hola a todos!
Espero pueda ayudarme realmente ya no se que hacer ya e intentado lo poco que se. El caso es que tengo un programa en VB .net con una conexion a una base de datos Access, pero esta conexion esta hecho por un modulo el cual crea un archivo Config.ini el cual encripta la contraseña de la base de datos.
Lo que yo necesito es ver la contraseña de la base de datos ya que no la tengo y pues la conexion no la hice yo quisiera me pudieran ayudar para saber la contraseña o saber donde se aloja dicha contraseña a continuacion les paso el codigo del modulo:

Donde aparece subryado deberia de estar la contraseña y en su lugar esta la llamada al modulo hecho antes y este modulo lo que contiene es la declaracion de variables y la Public MASCARA


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Friend Module ModInicio
		Public MascaraDefault As String = "yopiensoentituvivesenmimentesolafijasintreguaatodahora"
 
		Public strDNS As String
 
		Public strusr As String
 
		Public strpwd As String
 
		Public strconn As String
 
		Public m_mascara As String
 
		Public Usuario As String
 
		Public Rol As Integer
 
		Public DescRol As String
 
		Public FechaFin As String
 
		Private Function fAsignaMascara() As String
			Dim result As String
			If Strings.Len(ModInicio.m_mascara) <= 0 Then
				result = ModInicio.MascaraDefault
			Else
				result = ModInicio.m_mascara
			End If
			Return result
		End Function
 
		Public Function Encriptar(valor As String) As String
			Dim result As String
			Try
				Dim str As String = ModInicio.fAsignaMascara()
				Dim text As String = Conversions.ToString(Conversion.Int(9F * VBMath.Rnd() + 1F))
				Dim arg_2C_0 As Integer = 1
				Dim num As Integer = Strings.Len(valor)
				' The following expression was wrapped in a checked-statement
				For i As Integer = arg_2C_0 To num
					Dim text2 As String = Conversion.Hex(Strings.Asc(Strings.Mid(valor, i, 1)) + Strings.Asc(Strings.Mid(str, i, 1)))
					Select Case Strings.Len(text2)
						Case 1
							text = text + "00" + text2
						Case 2
							text = text + "0" + text2
						Case 3
							text += text2
					End Select
				Next
				result = text
			Catch expr_A1 As System.Exception
				ProjectData.SetProjectError(expr_A1)
				Dim ex As System.Exception = expr_A1
				Interaction.MsgBox("Error en funcion Encriptar " & vbCrLf + ex.Message, MsgBoxStyle.OkOnly, Nothing)
				result = Nothing
				ProjectData.ClearProjectError()
			End Try
			Return result
		End Function
 
		Public Function DesEncriptar(valor As String) As String
			' The following expression was wrapped in a checked-statement
			Dim result As String
			Try
				Dim str As String = ModInicio.fAsignaMascara()
				Dim text As String = ""
				Dim str2 As String = Strings.Mid(valor, 2, Strings.Len(Strings.Trim(valor)))
				Dim arg_2B_0 As Integer = 1
				Dim num As Integer = Strings.Len(valor) - 1
				For i As Integer = arg_2B_0 To num Step 3
					text += Conversions.ToString(Strings.Chr(System.Convert.ToInt32(Decimal.Subtract(Conversions.ToDecimal("&H" + Strings.Mid(str2, i, 3)), New Decimal(Strings.Asc(Strings.Mid(str, Strings.Len(text) + 1, 1)))))))
				Next
				result = text
			Catch expr_89 As System.Exception
				ProjectData.SetProjectError(expr_89)
				Dim ex As System.Exception = expr_89
				Interaction.MsgBox("Error en funcion Desencriptar " & vbCrLf + ex.Message, MsgBoxStyle.OkOnly, Nothing)
				result = Nothing
				ProjectData.ClearProjectError()
			End Try
			Return result
		End Function
 
		Public Function App_Path() As String
			Return System.Environment.CurrentDirectory
		End Function
 
		Public Sub Conexion()
			Try
				Dim classEncriptar As ClassEncriptar = New ClassEncriptar()
				AddressOf classEncriptar.Archivo = ModInicio.App_Path() + "\config.ini"
				ModInicio.strDNS = classEncriptar.LeeIni("DBMS", "DSN")
				ModInicio.strusr = ModInicio.DesEncriptar(classEncriptar.LeeIni("DBMS", "USER"))
ModInicio.strpwd = ModInicio.DesEncriptar(classEncriptar.LeeIni("DBMS", "PASS"))
				ModInicio.strconn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\DBDondeVotas2015.accdb;Persist Security Info=False;Jet OLEDB:Database Password=" + ModInicio.strpwd + ";"
			Catch expr_7F As System.Exception
				ProjectData.SetProjectError(expr_7F)
				Dim ex As System.Exception = expr_7F
				Interaction.MsgBox("Error en funcion Conexion - Modulo Inicio " & vbCrLf + ex.Message, MsgBoxStyle.OkOnly, Nothing)
				ProjectData.ClearProjectError()
			End Try
		End Sub
	End Module
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de giancarlo
Val: 377
Bronce
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Buscar Contraseña de Conexion a DB

Publicado por giancarlo (488 intervenciones) el 22/08/2015 17:09:08
Tienes el codigo fuente del proyecto? o es que lo descompilaste con algun programa para eso? porque si lo tienes, solo bastaria con ejecutarlo paso a paso o pones un punto de interrupcion debajo de la linea ModInicio.strpwd = ModInicio.DesEncriptar(classEncriptar.LeeIni("DBMS", "PASS")), al señalar te deberia sair la contraseña.

si no lo tienes puedes crear un proyecto y ejecutarlo, pero temo que te faltaría la clase ClassEncriptar() que no aparece en el codigo que muestras
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Buscar Contraseña de Conexion a DB

Publicado por Nelson (5 intervenciones) el 23/08/2015 06:28:32
Que tal giancarlo gracias por responder, pues si el codigo solo lo descompile con otro programa y la clase que tu dices si aparece, solo que no se como agregarla al nuevo proyecto ya que anteriormente ya habia intentado hacerlo como me dices solo que unicamente agrege el modulo donde esta esta conexion.

Te agradeceria me pudieras ayudar la verdad que si lo necesito , ya que recien me inicio en VB. porfa te paso el codigo de la clase
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Public Class ClassEncriptar
		Private m_Ini As String
 
		Public Property Archivo() As String
			Get
				Return Me.m_Ini
			End Get
			Set(value As String)
				Me.m_Ini = value
			End Set
		End Property
 
		Private Shared Declare Ansi Function GetPrivateProfileStringKey Lib "kernel32" Alias "GetPrivateProfileStringA" (<System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpApplicationName As String, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpKeyName As String, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpDefault As String, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpReturnedString As String, nSize As Integer, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpFileName As String) As Integer
 
		Private Shared Declare Ansi Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (<System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpApplicationName As String, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpKeyName As String, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpString As String, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpFileName As String) As Integer
 
		Public Function LeeIni(Seccion As String, Llave As String) As String
			Dim text As String = New String(vbNullChar, 255)
			Dim text2 As String = ""
			Dim privateProfileStringKey As Integer = ClassEncriptar.GetPrivateProfileStringKey(Seccion, Llave, text2, text, Strings.Len(text), Me.m_Ini)
			Dim result As String
			If privateProfileStringKey = 0 Then
				result = ""
			Else
				result = Strings.Left(text, privateProfileStringKey)
			End If
			Return result
		End Function
 
		Public Sub GrabaIni(Seccion As String, Llave As String, Valor As String)
			Dim num As Long = CLng(ClassEncriptar.WritePrivateProfileString(Seccion, Llave, Valor, Me.m_Ini))
		End Sub
	End Class
End Namespace
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de giancarlo
Val: 377
Bronce
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Buscar Contraseña de Conexion a DB

Publicado por giancarlo (488 intervenciones) el 23/08/2015 06:59:15
En tu proyecto agregas una clase, clic derecho, agregar, clase( te saldrá igual coko cuando agregas un nuevo formulario) seleccionas class o clase, pones el mismo nombre del que aparece lo que desconpilaste y copias/pegas el código que extrajiste. Ejecutas paso a paso
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Buscar Contraseña de Conexion a DB

Publicado por Nelson (5 intervenciones) el 23/08/2015 07:13:57
que tal gracias por la respuesta acabo de hacer lo me dices y ahora me aparecen los otros errores



Error 1 'Shared' no es válido en una instrucción Declare. ClassEncriptar.vb 13 13
Error 1 'Shared' no es válido en una instrucción Declare. ClassEncriptar.vb 15 13

es en este codigo donde aparece Shared no reconocido

Private Shared Declare Ansi Function GetPrivateProfileStringKey Lib "kernel32" Alias "GetPrivateProfileStringA" (<System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpApplicationName As String, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpKeyName As String, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpDefault As String, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpReturnedString As String, nSize As Integer, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpFileName As String) As Integer

Private Shared Declare Ansi Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (<System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpApplicationName As String, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpKeyName As String, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpString As String, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.VBByRefStr)> ByRef lpFileName As String) As Integer
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Wilfredo Patricio Castillo
Val: 1.239
Bronce
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Buscar Contraseña de Conexion a DB

Publicado por Wilfredo Patricio Castillo (720 intervenciones) el 24/08/2015 07:42:36
Prueba a poner al inicio en la sección de Imports algo así:

Imports System.Runtime.InteropServices
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Buscar Contraseña de Conexion a DB

Publicado por Nelson (5 intervenciones) el 24/08/2015 07:46:49
Hola gracias
eso seria en el archivo original, y en que parte o ventana tendria que ver el resultado
ya que lo hice como tu dices pero no encuentro donde ver la contraseña

saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de giancarlo
Val: 377
Bronce
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Buscar Contraseña de Conexion a DB

Publicado por giancarlo (488 intervenciones) el 24/08/2015 07:51:04
intenta quitando el shared por si no te sale. debes crear un nuevo proyecto copiando el código. para mostrar la contraseña tenias que hacer un punto de interrupcion (esas bolitas roja que te aparece cuando haces clic en el lado izquierdo de un linea), tambien puedes intentar con un messagebox despues de obtener la contraseña

1
2
3
4
5
6
ModInicio.strpwd = ModInicio.DesEncriptar(classEncriptar.LeeIni("DBMS", "PASS"))
				ModInicio.strconn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\DBDondeVotas2015.accdb;Persist Security Info=False;Jet OLEDB:Database Password=" + ModInicio.strpwd + ";"
'deberia decir
ModInicio.strpwd = ModInicio.DesEncriptar(classEncriptar.LeeIni("DBMS", "PASS"))
msgbox(ModInicio.strpwd)
ModInicio.strconn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\DBDondeVotas2015.accdb;Persist Security Info=False;Jet OLEDB:Database Password=" + ModInicio.strpwd + ";"
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Buscar Contraseña de Conexion a DB

Publicado por Nelson (5 intervenciones) el 24/08/2015 08:11:29
hola gracias por la ayuda ya solucione el problema gracias a un codigo que me dio MCKSys Argentina de elhacker.net

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Public Class Form1
 
    Public Function descifrar(valor As String) As String
        Dim result As String
        Try
            Dim str As String = "yopiensoentituvivesenmimentesolafijasintreguaatodahora"
            Dim text As String = ""
            Dim str2 As String = Strings.Mid(valor, 2, Strings.Len(Strings.Trim(valor)))
            Dim arg_2B_0 As Integer = 1
            Dim num As Integer = Strings.Len(valor) - 1
            Dim a As Decimal = 0
            Dim b As Decimal = 0
 
            For i As Integer = arg_2B_0 To num Step 3
                Dim s As String = Strings.Mid(str2, i, 3)
                a = System.Convert.ToInt32(s, 16)
                b = Strings.Asc(Strings.Mid(str, Strings.Len(text) + 1, 1))
                text += System.Convert.ToString(Strings.Chr(System.Convert.ToInt32(Decimal.Subtract(a, b))))
            Next
            result = text
        Catch expr_89 As System.Exception
            Dim ex As System.Exception = expr_89
            Interaction.MsgBox("Error en funcion descifrar " & vbCrLf + ex.Message, MsgBoxStyle.OkOnly, Nothing)
            result = Nothing
        End Try
        Return result
    End Function
 
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Debug.Print(descifrar("70BD09F0BE0AD0980C40A30C30A60920A60990A50AA"))
    End Sub
End Class
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar