Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - fudmario

#81
Interesante, voy a ver si puedo implementarlo algo similar en You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.
#82
C# - VB.NET / [VB.NET] NativeOsVersion
Enero 12, 2017, 08:00:25 PM
Alternativa a You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login, para aplicaciones que no se han manifestado para Windows 8.1 o Windows 10.
Código: vbnet

    <DllImport("Ntdll.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
    Friend Shared Function RtlGetVersion(<[In], Out> ByVal osversion As RtlOsVersionInfoExW) As Integer
    End Function

    <StructLayout(LayoutKind.Sequential)>
    Public Class RtlOsVersionInfoExW
        Public dwOSVersionInfoSize As UInt32
        Public dwMajorVersion As UInt32
        Public dwMinorVersion As UInt32
        Public dwBuildNumber As UInt32
        Public dwPlataformId As UInt32
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> Public szCSDVersion As String
        Public wServicePackMajor As UInt16
        Public wServicePackMinor As UInt16
        Public wSuiteMask As UInt16
        Public bProductType As Byte
        Public bReserved As Byte
    End Class

    Public Function NativeOsVersion() As Version
        Dim osVersionInfo As New RtlOsVersionInfoExW()
        osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(GetType(RtlOsVersionInfoExW))
        Dim status As Integer = RtlGetVersion(osVersionInfo)
        If status <> 0 Then
            ' Throw New Win32Exception(RtlNtStatusToDosError(status))
            Return Environment.OSVersion.Version
        End If

        Return New Version(osVersionInfo.dwMajorVersion,
                           osVersionInfo.dwMinorVersion,
                           osVersionInfo.dwBuildNumber)
    End Function
#83
Cualquier Antivirus es bueno, siempre y cuando lo manejes de manera adecuada.
Y al momento de elegir que Software de proteccion quisieras utilizar, se deberian considerar diferentes aspectos.


Hay empresas que realizan comparativas entre los diferentes Antivirus, si quieres puedes visitar: You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
#84
Hay muchas herramienta de donde elegir, aquí te dejo algunas:


  • You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
  • You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
  • You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
  • You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
  • You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
#85
C# - VB.NET / Re:[Aporte] Ghost Killer Adf.ly by Flamer
Diciembre 30, 2016, 09:48:46 PM
 
Si bien You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login es flexible en ciertas cosas, no siempre es la mejor y/o la más óptima forma de realizar las cosas, como te dije teniendo a mano tan extensa libreria de clases que ofrece .NetFramework, porqué no aprovecharlas?....

De hecho Utilizando, WebClient.DownloadString tendrias un mejor control de lo que va a pasar en tiempo de ejecución.


Igual que tú, Yo tampoco soy bueno programando solo conozco pocas cosas, pero con el tiempo aprenderás y entenderás por que es mejor hacerlo de una u otra forma(como por ejemplo especificar el tipo de retorno en una función).


Saludos.
#86
C# - VB.NET / Re:[Aporte] Ghost Killer Adf.ly by Flamer
Diciembre 29, 2016, 09:13:20 PM
Hola,...
Sugerencia: Evita usar On Error Resume Next en You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login, siempre es mejor tener un control de errores, puedes optar por un bloque Try/Catch.

En .NET dispones de una amplia Biblioteca de Classes para poder utilizarla, razon por la cual trata de evitar usar:(CreateObject("Microsoft.XmlHttp")).
En You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login puedes usar: You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login

Saludos...
#87
Dudas y pedidos generales / Re:Mouse Clicks Webbrowser
Diciembre 22, 2016, 10:17:22 PM
Hola,.

Para poder Simular los Clicks, puedes usar(Asumiendo que tienes un WebBrowser con el Nombre: WebBrowser1):
Código: vbnet

WebBrowser1.Document.GetElementById("yourID").InvokeMember("click")

O:
Código: vbnet

WebBrowser1.Document.GetElementFromPoint(x, y).InvokeMember("click")


Aqui te dejo Un ejemplo de cómo Iniciar sesión en el foro:

Código: vbnet


' Ir a la dirección para Iniciar Sesión:
     WebBrowser1.Navigate("https://underc0de.org/foro/index.php?action=login")
' Llenando el campo para el Nombre de Usuario:
    WebBrowser1.Document.GetElementById("user").InnerText = "fudmario"
' Llenando el campo para la Contraseña de Usuario:
    WebBrowser1.Document.GetElementById("passwrd").InnerText = "1234567890miPass"
' Para hacer clic en el boton "Ingresar"
    WebBrowser1.Document.GetElementById("frmLogin").InvokeMember("submit")
#88
C# - VB.NET / [VB.NET] WindowsSecurityCenter by fudmario
Diciembre 22, 2016, 02:19:20 PM



Implementacion de Windows Security Center (WSC) en You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login, cualquier error o sugerencia enviarlo por MP o Skype...



Ejemplo de Uso:
Código: vbnet

        Dim avsStatus As WindowsSecurityCenter.WscSecurityProviderHealth = WindowsSecurityCenter.GetStatusOfSecurityProvider(WindowsSecurityCenter.WscSecurityProvider.WscSecurityProviderAntivirus)
        Select Case avsStatus
            Case WindowsSecurityCenter.WscSecurityProviderHealth.WscSecurityProviderHealthGood
                MessageBox.Show("El estado del proveedor de seguridad es bueno y no necesita atención del usuario.")
            Case WindowsSecurityCenter.WscSecurityProviderHealth.WscSecurityProviderHealthPoor
                MessageBox.Show("El estado del proveedor de seguridad es deficiente y el equipo puede estar en riesgo.")
            Case WindowsSecurityCenter.WscSecurityProviderHealth.WscSecurityProviderHealthSnooze
                MessageBox.Show("El proveedor de seguridad está en estado suspendido. Snooze indica que WSC no está protegiendo activamente la computadora.")
        End Select
        Dim uacStatus As WindowsSecurityCenter.WscSecurityProviderHealth = WindowsSecurityCenter.GetStatusOfSecurityProvider(WindowsSecurityCenter.WscSecurityProvider.WscSecurityProviderUserAccountControl)
        If uacStatus = WindowsSecurityCenter.WscSecurityProviderHealth.WscSecurityProviderHealthPoor Then
            MessageBox.Show("El UAC se encuentra desactivado....")
        End If




Código: vbnet

' ***********************************************************************
' Assembly         : WinControl
' Author           : fudmario
' Created          : 12-21-2016
'
' Last Modified By : fudmario
' Last Modified On : 12-21-2016
' ***********************************************************************
' <copyright file="WindowsSecurityCenter.vb" company="DeveloperTeam">
'     Copyright ©  2016
' </copyright>
' <summary></summary>
' ***********************************************************************
Imports System.Runtime.InteropServices
Public NotInheritable Class WindowsSecurityCenter
    <DebuggerNonUserCode>
    Private Sub New()
    End Sub
    ''' <summary>
    ''' Defines all the services that are monitored by Windows Security Center (WSC).
    ''' </summary>
    ''' <remarks>
    ''' <see href="https://msdn.microsoft.com/en-us/library/bb432509(v=vs.85).aspx"/>
    ''' </remarks>
    <Flags>
    Public Enum WscSecurityProvider As Integer
        ''' <summary>
        ''' The aggregation of all firewalls for this computer.
        ''' </summary>
        WscSecurityProviderFirewall = 1
        ''' <summary>
        ''' The automatic update settings for this computer.
        ''' </summary>
        WscSecurityProviderAutoupdateSettings = 2
        ''' <summary>
        ''' The aggregation of all antivirus products for this computer.
        ''' </summary>
        WscSecurityProviderAntivirus = 4
        ''' <summary>
        ''' The aggregation of all anti-spyware products for this computer.
        ''' </summary>
        WscSecurityProviderAntispyware = 8
        ''' <summary>
        ''' The settings that restrict the access of web sites in each of the Internet zones for this computer.
        ''' </summary>
        WscSecurityProviderInternetSettings = 16
        ''' <summary>
        ''' The User Account Control (UAC) settings for this computer.
        ''' </summary>
        WscSecurityProviderUserAccountControl = 32
        ''' <summary>
        ''' The running state of the WSC service on this computer.
        ''' </summary>
        WscSecurityProviderService = 64
        ''' <summary>
        ''' None of the items that WSC monitors.
        ''' </summary>
        WscSecurityProviderNone = 0
        ''' <summary>
        ''' All of the items that the WSC monitors.
        ''' </summary>
        WscSecurityProviderAll =
            WscSecurityProviderFirewall Or WscSecurityProviderAutoupdateSettings Or WscSecurityProviderAntivirus Or
            WscSecurityProviderAntispyware Or WscSecurityProviderInternetSettings Or
            WscSecurityProviderUserAccountControl Or
            WscSecurityProviderService Or WscSecurityProviderNone
    End Enum

    ''' <summary>
    ''' Defines the possible states for any service monitored by Windows Security Center (WSC).
    ''' </summary>
    ''' <remarks>
    ''' <see href="https://msdn.microsoft.com/en-us/library/bb432510(v=vs.85).aspx"/>
    ''' </remarks>
    <Flags>
    Public Enum WscSecurityProviderHealth As Integer
        ''' <summary>
        ''' The status of the security provider category is good and does not need user attention.
        ''' </summary>
        WscSecurityProviderHealthGood
        ''' <summary>
        ''' The status of the security provider category is not monitored by WSC.
        ''' </summary>
        WscSecurityProviderHealthNotmonitored
        ''' <summary>
        ''' The status of the security provider category is poor and the computer may be at risk.
        ''' </summary>
        WscSecurityProviderHealthPoor
        ''' <summary>
        ''' The security provider category is in snooze state. Snooze indicates that WSC is not actively protecting the computer.
        ''' </summary>
        WscSecurityProviderHealthSnooze
        ''' <summary>
        ''' The status of the security provider category is unknown
        ''' </summary>
        WscSecurityProviderHealthUnknown
    End Enum

    ''' <summary>
    ''' Gets the aggregate health state of the security provider categories represented by the specified <see cref="WscSecurityProvider"/> enumeration values.
    ''' </summary>
    ''' <param name="providers ">One or more of the values in the <see cref="WscSecurityProvider"/> enumeration. To specify more than one value, combine the individual values by performing a bitwise OR operation.</param>
    ''' <param name="pHealth ">A pointer to a variable that takes the value of one of the members of the <see cref="WscSecurityProviderHealth"/> enumeration. If more than one provider is specified in the Providers parameter, the value of this parameter is the health of the least healthy of the specified provider categories.</param>
    ''' <returns>Returns S_OK if the function succeeds, otherwise returns an error code. If the WSC service is not running, the return value is always S_FALSE and the pHealth out parameter is always set to WSC_SECURITY_PROVIDER_HEALTH_POOR.</returns>
    ''' <remarks>
    ''' <see href="https://msdn.microsoft.com/en-us/library/bb432506(v=vs.85).aspx"/>
    ''' </remarks>
    <DllImport("wscapi.dll")>
    Private Shared Function WscGetSecurityProviderHealth(<[In]> providers As WscSecurityProvider,
                                                         <Out> ByRef pHealth As WscSecurityProviderHealth) _
        As Integer
    End Function

    ''' <summary>
    ''' Gets the status of security provider.
    ''' </summary>
    ''' <param name="provider">provider.</param>
    ''' <returns>The possible states for service monitored by Windows Security Center (WSC).</returns>
    Public Shared Function GetStatusOfSecurityProvider(provider As WscSecurityProvider) As WscSecurityProviderHealth
        Dim outValue As WscSecurityProviderHealth = WscSecurityProviderHealth.WscSecurityProviderHealthUnknown
        Dim ret As Integer = WscGetSecurityProviderHealth(provider, outValue)
        Return If(ret <> &H0, WscSecurityProviderHealth.WscSecurityProviderHealthUnknown, outValue)
    End Function
End Class

#89
Hola, en todas la funciones retorna en codificado en Base64, prueba de esta forma:


Código: vbnet

    Public Function HashMd5(ByVal str As String) As String
        Dim enc As Encoding = Encoding.UTF8
        Using md5 As New MD5CryptoServiceProvider()
            Dim data As Byte() = enc.GetBytes(str)
            Dim hash As Byte() = md5.ComputeHash(data)
            Dim sb As New StringBuilder(hash.Length*2)
            For Each b As Byte In hash
                sb.Append(b.ToString("x2"))
            Next
            Return sb.ToString()
        End Using
    End Function


De forma generica podrias usar esta función:

Código: vbnet

' parte de la Libreria ElektroKit
     Public Function ComputeHashOfString(Of T As HashAlgorithm)(ByVal str As String,
                                                                              Optional ByVal enc As Encoding = Nothing) As String
            If (enc Is Nothing) Then
                enc = Encoding.Default
            End If
            Using algorithm As HashAlgorithm = DirectCast(Activator.CreateInstance(GetType(T)), HashAlgorithm)
                Dim data As Byte() = enc.GetBytes(str)
                Dim hash As Byte() = algorithm.ComputeHash(data)
                Dim sb As New StringBuilder(capacity:=hash.Length * 2)
                For Each b As Byte In hash
                    sb.Append(b.ToString("X2"))
                Next
                Return sb.ToString.ToLower()
            End Using

        End Function



Ejemplo de Uso:

Código: vbnet


Dim md5 As String = ComputeHashOfString(Of MD5CryptoServiceProvider)("HelThunk")
Dim sha1 As String = ComputeHashOfString(Of SHA1CryptoServiceProvider)("HelThunk")
Dim sha256 As String = ComputeHashOfString(Of SHA256CryptoServiceProvider)("HelThunk")
#90
C# - VB.NET / [VB.NET] Opera Password Viewer
Diciembre 07, 2016, 11:06:08 PM

Opera Test: Versión 41.0.2353.69 (WoW64)



Se necesita de la Clase SqliteHandler, la pueden copiar de You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login


Código: vbnet

Dim loginPath As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Opera Software\Opera Stable\Login Data")
Dim sb As New StringBuilder
Dim sqlDataBase As New SqLiteHandler(loginPath)
      sqlDataBase.ReadTable("logins")
Dim count As Integer = sqlDataBase.GetRowCount()
For i = 0 To count - 1
                Dim mUrl As String = sqlDataBase.GetValue(i, "origin_url")
                Dim mUserName As String = sqlDataBase.GetValue(i, "username_value")
                Dim mPassword As String = Decode(sqlDataBase.GetValue(i, "password_value"))
                sb.AppendLine("User: " & mUserName)
                sb.AppendLine("Url: " & mUrl)
                sb.AppendLine("Password: " & mPassword)
Next i

Messagebox.Show(sb.ToString)


Para decifrar las contraseñas, agregar Referencias a: You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login e Importar: System.Security.Cryptography

Código: vbnet

    Private Function Decode(ByVal data As String) As String
        If String.IsNullOrEmpty(data) Then
            Return String.Empty
        Else
            Dim encryptedData As Byte() = Encoding.Default.GetBytes(data)
            Dim decryptedData As Byte() = ProtectedData.Unprotect(encryptedData, Nothing, DataProtectionScope.CurrentUser)
            Return Encoding.UTF8.GetString(decryptedData)
        End If
    End Function




SQLiteHandler Class:


Código: vbnet


' ***********************************************************************
' Assembly         : SQLiteHandler
' Author           : ??????
' Created          : ??-??-????
'' ***********************************************************************

Imports System.IO
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic.CompilerServices
Public Class SqLiteHandler
    Private db_bytes As Byte()
    Private mEncoding As ULong
    Private field_names As String()
    Private master_table_entries As sqlite_master_entry()
    Private page_size As UShort
    Private SQLDataTypeSize As Byte() = New Byte() {0, 1, 2, 3, 4, 6, 8, 8, 0, 0}
    Private table_entries As table_entry()

    Public Sub New(baseName As String)
        If File.Exists(baseName) Then
            FileSystem.FileOpen(1, baseName, OpenMode.Binary, OpenAccess.Read, OpenShare.[Shared], -1)
            Dim str As String = Strings.Space(CInt(FileSystem.LOF(1)))
            FileSystem.FileGet(1, str, -1L, False)
            FileSystem.FileClose(New Integer() {1})
            Me.db_bytes = System.Text.Encoding.Default.GetBytes(str)
            If String.Compare(System.Text.Encoding.Default.GetString(Me.db_bytes, 0, 15), "SQLite format 3", StringComparison.Ordinal) <> 0 Then
                Throw New Exception("Not a valid SQLite 3 Database File")
            End If
            If Me.db_bytes(&H34) <> 0 Then
                Throw New Exception("Auto-vacuum capable database is not supported")
            End If
            Me.page_size = CUShort(Me.ConvertToInteger(&H10, 2))
            Me.mEncoding = Me.ConvertToInteger(&H38, 4)
            If Decimal.Compare(New Decimal(Me.mEncoding), Decimal.Zero) = 0 Then
                Me.mEncoding = 1L
            End If
            Me.ReadMasterTable(100L)
        End If
    End Sub

    Private Function ConvertToInteger(startIndex As Integer, Size As Integer) As ULong
        If (Size > 8) Or (Size = 0) Then
            Return 0L
        End If
        Dim num2 As ULong = 0L
        Dim num4 As Integer = Size - 1
        For i As Integer = 0 To num4
            num2 = (num2 << 8) Or Me.db_bytes(startIndex + i)
        Next
        Return num2
    End Function

    Private Function CVL(startIndex As Integer, endIndex As Integer) As Long
        endIndex += 1
        Dim buffer As Byte() = New Byte(7) {}
        Dim num4 As Integer = endIndex - startIndex
        Dim flag As Boolean = False
        If (num4 = 0) Or (num4 > 9) Then
            Return 0L
        End If
        If num4 = 1 Then
            buffer(0) = CByte(Me.db_bytes(startIndex) And &H7F)
            Return BitConverter.ToInt64(buffer, 0)
        End If
        If num4 = 9 Then
            flag = True
        End If
        Dim num2 As Integer = 1
        Dim num3 As Integer = 7
        Dim index As Integer = 0
        If flag Then
            buffer(0) = Me.db_bytes(endIndex - 1)
            endIndex -= 1
            index = 1
        End If
        Dim num7 As Integer = startIndex
        Dim i As Integer = endIndex - 1
        While i >= num7
            If (i - 1) >= startIndex Then
                buffer(index) = CByte((CByte(Me.db_bytes(i) >> ((num2 - 1) And 7)) And (CInt(&HFF) >> num2)) Or CByte(Me.db_bytes(i - 1) << (num3 And 7)))
                num2 += 1
                index += 1
                num3 -= 1
            ElseIf Not flag Then
                buffer(index) = CByte(CByte(Me.db_bytes(i) >> ((num2 - 1) And 7)) And (CInt(&HFF) >> num2))
            End If
            i += -1
        End While
        Return BitConverter.ToInt64(buffer, 0)
    End Function

    Public Function GetRowCount() As Integer
        Return Me.table_entries.Length
    End Function

    Public Function GetTableNames() As String()
        Dim strArray2 As String() = Nothing
        Dim index As Integer = 0
        Dim num3 As Integer = Me.master_table_entries.Length - 1
        For i As Integer = 0 To num3
            If Me.master_table_entries(i).item_type = "table" Then
                strArray2 = DirectCast(Utils.CopyArray(DirectCast(strArray2, Array), New String(index) {}), String())
                strArray2(index) = Me.master_table_entries(i).item_name
                index += 1
            End If
        Next
        Return strArray2
    End Function

    Public Function GetValue(row_num As Integer, field As Integer) As String
        If row_num >= Me.table_entries.Length Then
            Return Nothing
        End If
        If field >= Me.table_entries(row_num).content.Length Then
            Return Nothing
        End If
        Return Me.table_entries(row_num).content(field)
    End Function

    Public Function GetValue(row_num As Integer, field As String) As String
        Dim num As Integer = -1
        Dim length As Integer = Me.field_names.Length - 1
        For i As Integer = 0 To length
            If Me.field_names(i).ToLower().CompareTo(field.ToLower()) = 0 Then
                num = i
                Exit For
            End If
        Next
        If num = -1 Then
            Return Nothing
        End If
        Return Me.GetValue(row_num, num)
    End Function

    Private Function GVL(startIndex As Integer) As Integer
        If startIndex > Me.db_bytes.Length Then
            Return 0
        End If
        Dim num3 As Integer = startIndex + 8
        For i As Integer = startIndex To num3
            If i > (Me.db_bytes.Length - 1) Then
                Return 0
            End If
            If (Me.db_bytes(i) And &H80) <> &H80 Then
                Return i
            End If
        Next
        Return (startIndex + 8)
    End Function

    Private Function IsOdd(value As Long) As Boolean
        Return ((value And 1L) = 1L)
    End Function

    Private Sub ReadMasterTable(Offset As ULong)
        If Me.db_bytes(CInt(Offset)) = 13 Then
            Dim num2 As UShort = Convert.ToUInt16(Decimal.Subtract(New Decimal(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(New Decimal(Offset), 3D)), 2)), Decimal.One))
            Dim length As Integer = 0
            If Me.master_table_entries IsNot Nothing Then
                length = Me.master_table_entries.Length
                Me.master_table_entries = DirectCast(Utils.CopyArray(DirectCast(Me.master_table_entries, Array), New sqlite_master_entry((Me.master_table_entries.Length + num2)) {}), sqlite_master_entry())
            Else
                Me.master_table_entries = New sqlite_master_entry(num2) {}
            End If
            Dim num13 As Integer = num2
            For i As Integer = 0 To num13
                Dim num As ULong = Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(Offset), 8D), New Decimal(i * 2))), 2)
                If Decimal.Compare(New Decimal(Offset), 100D) <> 0 Then
                    num += Offset
                End If
                Dim endIndex As Integer = Me.GVL(CInt(num))
                Dim num7 As Long = Me.CVL(CInt(num), endIndex)
                Dim num6 As Integer = Me.GVL(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), Decimal.Subtract(New Decimal(endIndex), New Decimal(num))), Decimal.One)))
                Me.master_table_entries(length + i).row_id = Me.CVL(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), Decimal.Subtract(New Decimal(endIndex), New Decimal(num))), Decimal.One)), num6)
                num = Convert.ToUInt64(Decimal.Add(Decimal.Add(New Decimal(num), Decimal.Subtract(New Decimal(num6), New Decimal(num))), Decimal.One))
                endIndex = Me.GVL(CInt(num))
                num6 = endIndex
                Dim num5 As Long = Me.CVL(CInt(num), endIndex)
                Dim numArray As Long() = New Long(4) {}
                Dim index As Integer = 0
                Do
                    endIndex = num6 + 1
                    num6 = Me.GVL(endIndex)
                    numArray(index) = Me.CVL(endIndex, num6)
                    If numArray(index) > 9L Then
                        If Me.IsOdd(numArray(index)) Then
                            numArray(index) = CLng(Math.Round(CDbl(CDbl(numArray(index) - 13L) / 2.0)))
                        Else
                            numArray(index) = CLng(Math.Round(CDbl(CDbl(numArray(index) - 12L) / 2.0)))
                        End If
                    Else
                        numArray(index) = Me.SQLDataTypeSize(CInt(numArray(index)))
                    End If
                    index += 1
                Loop While index <= 4
                If Decimal.Compare(New Decimal(Me.mEncoding), Decimal.One) = 0 Then
                    Me.master_table_entries(length + i).item_type = System.Text.Encoding.Default.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(New Decimal(num), New Decimal(num5))), CInt(numArray(0)))
                ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 2D) = 0 Then
                    Me.master_table_entries(length + i).item_type = System.Text.Encoding.Unicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(New Decimal(num), New Decimal(num5))), CInt(numArray(0)))
                ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 3D) = 0 Then
                    Me.master_table_entries(length + i).item_type = System.Text.Encoding.BigEndianUnicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(New Decimal(num), New Decimal(num5))), CInt(numArray(0)))
                End If
                If Decimal.Compare(New Decimal(Me.mEncoding), Decimal.One) = 0 Then
                    Me.master_table_entries(length + i).item_name = System.Text.Encoding.Default.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num5)), New Decimal(numArray(0)))), CInt(numArray(1)))
                ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 2D) = 0 Then
                    Me.master_table_entries(length + i).item_name = System.Text.Encoding.Unicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num5)), New Decimal(numArray(0)))), CInt(numArray(1)))
                ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 3D) = 0 Then
                    Me.master_table_entries(length + i).item_name = System.Text.Encoding.BigEndianUnicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num5)), New Decimal(numArray(0)))), CInt(numArray(1)))
                End If
                Me.master_table_entries(length + i).root_num = CLng(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(Decimal.Add(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num5)), New Decimal(numArray(0))), New Decimal(numArray(1))), New Decimal(numArray(2)))), CInt(numArray(3))))
                If Decimal.Compare(New Decimal(Me.mEncoding), Decimal.One) = 0 Then
                    Me.master_table_entries(length + i).sql_statement = System.Text.Encoding.Default.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(Decimal.Add(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num5)), New Decimal(numArray(0))), New Decimal(numArray(1))), New Decimal(numArray(2))), New Decimal(numArray(3)))), CInt(numArray(4)))
                ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 2D) = 0 Then
                    Me.master_table_entries(length + i).sql_statement = System.Text.Encoding.Unicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(Decimal.Add(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num5)), New Decimal(numArray(0))), New Decimal(numArray(1))), New Decimal(numArray(2))), New Decimal(numArray(3)))), CInt(numArray(4)))
                ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 3D) = 0 Then
                    Me.master_table_entries(length + i).sql_statement = System.Text.Encoding.BigEndianUnicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(Decimal.Add(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num5)), New Decimal(numArray(0))), New Decimal(numArray(1))), New Decimal(numArray(2))), New Decimal(numArray(3)))), CInt(numArray(4)))
                End If
            Next
        ElseIf Me.db_bytes(CInt(Offset)) = 5 Then
            Dim num11 As UShort = Convert.ToUInt16(Decimal.Subtract(New Decimal(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(New Decimal(Offset), 3D)), 2)), Decimal.One))
            Dim num14 As Integer = num11
            For j As Integer = 0 To num14
                Dim startIndex As UShort = CUShort(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(Offset), 12D), New Decimal(j * 2))), 2))
                If Decimal.Compare(New Decimal(Offset), 100D) = 0 Then
                    Me.ReadMasterTable(Convert.ToUInt64(Decimal.Multiply(Decimal.Subtract(New Decimal(Me.ConvertToInteger(startIndex, 4)), Decimal.One), New Decimal(Me.page_size))))
                Else
                    Me.ReadMasterTable(Convert.ToUInt64(Decimal.Multiply(Decimal.Subtract(New Decimal(Me.ConvertToInteger(CInt(Offset + startIndex), 4)), Decimal.One), New Decimal(Me.page_size))))
                End If
            Next
            Me.ReadMasterTable(Convert.ToUInt64(Decimal.Multiply(Decimal.Subtract(New Decimal(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(New Decimal(Offset), 8D)), 4)), Decimal.One), New Decimal(Me.page_size))))
        End If
    End Sub

    Public Function ReadTable(TableName As String) As Boolean
        Dim index As Integer = -1
        Dim length As Integer = Me.master_table_entries.Length - 1
        For i As Integer = 0 To length
            If String.Compare(Me.master_table_entries(i).item_name.ToLower(), TableName.ToLower(), StringComparison.Ordinal) = 0 Then
                index = i
                Exit For
            End If
        Next
        If index = -1 Then
            Return False
        End If
        Dim strArray As String() = Me.master_table_entries(index).sql_statement.Substring(Me.master_table_entries(index).sql_statement.IndexOf("(", StringComparison.Ordinal) + 1).Split(New Char() {","c})
        Dim num6 As Integer = strArray.Length - 1
        For j As Integer = 0 To num6
            strArray(j) = (strArray(j)).TrimStart()
            Dim num4 As Integer = strArray(j).IndexOf(" ", StringComparison.Ordinal)
            If num4 > 0 Then
                strArray(j) = strArray(j).Substring(0, num4)
            End If
            If strArray(j).IndexOf("UNIQUE", StringComparison.Ordinal) = 0 Then
                Exit For
            End If
            Me.field_names = DirectCast(Utils.CopyArray(DirectCast(Me.field_names, Array), New String(j) {}), String())
            Me.field_names(j) = strArray(j)
        Next
        Return Me.ReadTableFromOffset(CULng((Me.master_table_entries(index).root_num - 1L) * Me.page_size))
    End Function

    Private Function ReadTableFromOffset(offset As ULong) As Boolean
        If Me.db_bytes(CInt(offset)) = 13 Then
            Dim num2 As Integer = Convert.ToInt32(Decimal.Subtract(New Decimal(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(New Decimal(offset), 3D)), 2)), Decimal.One))
            Dim length As Integer = 0
            If Me.table_entries IsNot Nothing Then
                length = Me.table_entries.Length
                Me.table_entries = DirectCast(Utils.CopyArray(DirectCast(Me.table_entries, Array), New table_entry((Me.table_entries.Length + num2)) {}), table_entry())
            Else
                Me.table_entries = New table_entry(num2) {}
            End If
            Dim num16 As Integer = num2
            For i As Integer = 0 To num16
                Dim _fieldArray As record_header_field() = Nothing
                Dim num As ULong = Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(offset), 8D), New Decimal(i * 2))), 2)
                If Decimal.Compare(New Decimal(offset), 100D) <> 0 Then
                    num += offset
                End If
                Dim endIndex As Integer = Me.GVL(CInt(num))
                Dim num9 As Long = Me.CVL(CInt(num), endIndex)
                Dim num8 As Integer = Me.GVL(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), Decimal.Subtract(New Decimal(endIndex), New Decimal(num))), Decimal.One)))
                Me.table_entries(length + i).row_id = Me.CVL(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), Decimal.Subtract(New Decimal(endIndex), New Decimal(num))), Decimal.One)), num8)
                num = Convert.ToUInt64(Decimal.Add(Decimal.Add(New Decimal(num), Decimal.Subtract(New Decimal(num8), New Decimal(num))), Decimal.One))
                endIndex = Me.GVL(CInt(num))
                num8 = endIndex
                Dim num7 As Long = Me.CVL(CInt(num), endIndex)
                Dim num10 As Long = Convert.ToInt64(Decimal.Add(Decimal.Subtract(New Decimal(num), New Decimal(endIndex)), Decimal.One))
                Dim j As Integer = 0
                While num10 < num7
                    _fieldArray = DirectCast(Utils.CopyArray(DirectCast(_fieldArray, Array), New record_header_field(j) {}), record_header_field())
                    endIndex = num8 + 1
                    num8 = Me.GVL(endIndex)
                    _fieldArray(j).type = Me.CVL(endIndex, num8)
                    If _fieldArray(j).type > 9L Then
                        _fieldArray(j).size = If(Me.IsOdd(_fieldArray(j).type), CLng(Math.Round(CDbl(CDbl(_fieldArray(j).type - 13L) / 2.0))), CLng(Math.Round(CDbl(CDbl(_fieldArray(j).type - 12L) / 2.0))))
                    Else
                        _fieldArray(j).size = Me.SQLDataTypeSize(CInt(_fieldArray(j).type))
                    End If
                    num10 = (num10 + (num8 - endIndex)) + 1L
                    j += 1
                End While
                Me.table_entries(length + i).content = New String((_fieldArray.Length - 1)) {}
                Dim num4 As Integer = 0
                Dim num17 As Integer = _fieldArray.Length - 1
                For k As Integer = 0 To num17
                    If _fieldArray(k).type > 9L Then
                        If Not Me.IsOdd(_fieldArray(k).type) Then
                            If Decimal.Compare(New Decimal(Me.mEncoding), Decimal.One) = 0 Then
                                Me.table_entries(length + i).content(k) = System.Text.Encoding.Default.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num7)), New Decimal(num4))), CInt(_fieldArray(k).size))
                            ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 2D) = 0 Then
                                Me.table_entries(length + i).content(k) = System.Text.Encoding.Unicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num7)), New Decimal(num4))), CInt(_fieldArray(k).size))
                            ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 3D) = 0 Then
                                Me.table_entries(length + i).content(k) = System.Text.Encoding.BigEndianUnicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num7)), New Decimal(num4))), CInt(_fieldArray(k).size))
                            End If
                        Else
                            Me.table_entries(length + i).content(k) = System.Text.Encoding.Default.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num7)), New Decimal(num4))), CInt(_fieldArray(k).size))
                        End If
                    Else
                        Me.table_entries(length + i).content(k) = Conversions.ToString(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num7)), New Decimal(num4))), CInt(_fieldArray(k).size)))
                    End If
                    num4 += CInt(_fieldArray(k).size)
                Next
            Next
        ElseIf Me.db_bytes(CInt(offset)) = 5 Then
            Dim num14 As UShort = Convert.ToUInt16(Decimal.Subtract(New Decimal(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(New Decimal(offset), 3D)), 2)), Decimal.One))
            Dim num18 As Integer = num14
            For m As Integer = 0 To num18
                Dim num13 As UShort = CUShort(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(offset), 12D), New Decimal(m * 2))), 2))
                Me.ReadTableFromOffset(Convert.ToUInt64(Decimal.Multiply(Decimal.Subtract(New Decimal(Me.ConvertToInteger(CInt(offset + num13), 4)), Decimal.One), New Decimal(Me.page_size))))
            Next
            Me.ReadTableFromOffset(Convert.ToUInt64(Decimal.Multiply(Decimal.Subtract(New Decimal(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(New Decimal(offset), 8D)), 4)), Decimal.One), New Decimal(Me.page_size))))
        End If
        Return True
    End Function

    <StructLayout(LayoutKind.Sequential)>
    Private Structure record_header_field
        Public size As Long
        Public type As Long
    End Structure

    <StructLayout(LayoutKind.Sequential)>
    Private Structure sqlite_master_entry
        Public row_id As Long
        Public item_type As String
        Public item_name As String
        Public astable_name As String
        Public root_num As Long
        Public sql_statement As String
    End Structure

    <StructLayout(LayoutKind.Sequential)>
    Private Structure table_entry
        Public row_id As Long
        Public content As String()
    End Structure
End Class





Descarga del Proyecto Ejemplo: You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
#91
C# - VB.NET / [VB.NET] Morse Encode/Decode
Diciembre 04, 2016, 05:33:10 PM


Ejemplo de Uso:

Código: vbnet

Dim textEnc As String = MorseEncDec.Morse(word:="EXAMPLE MORSE ENCODE DECODE FUNCTION",
                                    mode:=Morse.Mode.Encode)

Dim textDec As String = MorseEncDec.Morse(word:=". -..- .- -- .--. .-.. .  -- --- .-. ... .  . -. -.-. --- -.. .  -.. . -.-. --- -.. .  ..-. ..- -. -.-. - .. --- -.",
                                    mode:=Morse.Mode.Decode)


Código: vbnet

Public NotInheritable Class MorseEncDec
    Public Enum Mode As Integer
        [Encode] = 0I
        [Decode] = 1I
    End Enum
    Public Shared Function Morse(ByVal word As String, mode As Mode) As String
        Dim res As String = String.Empty
        Dim dic As Dictionary(Of String, String)
        dic = New Dictionary(Of String, String) From
                    {
                        {"A", ".-"},
                        {"B", "-..."},
                        {"C", "-.-."},
                        {"D", "-.."},
                        {"E", "."},
                        {"F", "..-."},
                        {"G", "--."},
                        {"H", "...."},
                        {"I", ".."},
                        {"J", ".---"},
                        {"K", "-.-"},
                        {"L", ".-.."},
                        {"M", "--"},
                        {"N", "-."},
                        {"Ñ", "--.--"},
                        {"O", "---"},
                        {"P", ".--."},
                        {"Q", "--.-"},
                        {"R", ".-."},
                        {"S", "..."},
                        {"T", "-"},
                        {"U", "..-"},
                        {"V", "...-"},
                        {"W", ".--"},
                        {"X", "-..-"},
                        {"Y", "-.--"},
                        {"Z", "--.."},
                        {"Ä", ".-.-"},
                        {"Ö", "---."},
                        {"Ü", "..--"},
                        {" ", ""},
                        {"0", "-----"},
                        {"1", ".----"},
                        {"2", "..---"},
                        {"3", "...--"},
                        {"4", "....-"},
                        {"5", "....."},
                        {"6", "-...."},
                        {"7", "--..."},
                        {"8", "---.."},
                        {"9", "----."},
                        {".", ".-.-.-"},
                        {",", "--..--"},
                        {"?", "..--.."},
                        {"!", "..--."},
                        {":", "---..."},
                        {"""", ".-..-."},
                        {"'", ".----."},
                        {"-", "-....-"},
                        {"=", "-...-"}
                    }
        Select Case mode
            Case Mode.Encode
                Dim arrWord As IEnumerable(Of Char) = word.ToUpper().ToCharArray()
                Return ((From mStr In arrWord Where dic.ContainsKey(mStr)).Aggregate(res, Function(x, mStr) String.Format("{0} {1}", x, dic.Item(mStr)))).Trim()
            Case Mode.Decode
                Return ((From letter In word.Split(" "c) Select dic.Where(Function(pair) pair.Value = letter).Select(Function(pair) pair.Key).FirstOrDefault()).Aggregate(res, Function(x, key) String.Format("{0}{1}", x, key))).Trim()
        End Select
        Return String.Empty
    End Function

End Class
#92
C# - VB.NET / [VB.NET] GeoIP basado en Maxmind DB Free
Diciembre 04, 2016, 05:26:24 PM
Ejemplo de uso de You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login y su base de datos Disponible de manera Gratuita You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.


Complementos:

  • Las banderas estan disponibles de manera gratuita en: You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
  • You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login, se puede agregar atraves del administrador de Paquetes NuGet.
Código: text
install-package MaxMind.GeoIP2



  • Proyecto Disponible en Github: You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
  • Proyector Completo:  You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
#93
C# - VB.NET / [VB.NET] ZoneIdentifier Wrapper by fudmario
Diciembre 04, 2016, 05:17:08 PM
Una simple implementacion para obtener el ZONE.IDENTIFIER(Windows Zone Identifier File) del archivos.

Ejemplo de Uso:

Código: vbnet

   Using zi As New ZoneIdentifier("D:\Sample.exe")
            If zi.Zone = UrlZone.Internet Then
                zi.Remove
            End If
   End Using



El Proyecto esta disponible para descargar: You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login


Si solo quieren eliminar el ZoneIdentifier, pueden usar la API:

Código: vbnet

<DllImport("kernel32.dll", CharSet:=CharSet.Auto, BestFitMapping:=False, ThrowOnUnmappableChar:=True, SetLastError:=True)>
        Public Shared Function DeleteFile(<MarshalAs(UnmanagedType.LPTStr)> ByVal filepath As String
        ) As <MarshalAs(UnmanagedType.Bool)> Boolean
        End Function


Ejemplo de Uso:

Código: vbnet

<DllImport("kernel32.dll", CharSet:=CharSet.Auto, BestFitMapping:=False, ThrowOnUnmappableChar:=True, SetLastError:=True)>
        Public Shared Function DeleteFile(<MarshalAs(UnmanagedType.LPTStr)> ByVal filepath As String
        ) As <MarshalAs(UnmanagedType.Bool)> Boolean
        End Function
Public Function DeleteZoneIdentifier(ByVal filePath As String) As Boolean
       Return DeleteFile(filePath + ":Zone.Identifier")
End Function
#94
C# - VB.NET / [VB.NET | C#] ProcessCritical
Diciembre 04, 2016, 05:05:15 PM
Un ejemplo sencillo para proteger el proceso y generar el BSOD.



Código: vbnet

        <DllImport("NTdll.dll", EntryPoint:="RtlSetProcessIsCritical", SetLastError:=True)>
        Public Shared Sub SetCurrentProcessIsCritical(
                      <MarshalAs(UnmanagedType.Bool)> ByVal isCritical As Boolean,
                      <MarshalAs(UnmanagedType.Bool)> ByRef refWasCritical As Boolean,
                      <MarshalAs(UnmanagedType.Bool)> ByVal needSystemCriticalBreaks As Boolean)
        End Sub

Private Sub SetProcessCritical()
Dim refWasCritical As Boolean
System.Diagnostics.Process.EnterDebugMode()
SetCurrentProcessIsCritical(True, refWasCritical, False)
End Sub
Private Sub UnSetProcessCritical()
Dim refWasCritical As Boolean
SetCurrentProcessIsCritical(False, refWasCritical, False)
End Sub


Código: csharp

        [DllImport("NTdll.dll", EntryPoint = "RtlSetProcessIsCritical", SetLastError = true)]
        public static extern void SetCurrentProcessIsCritical(
            [MarshalAs(UnmanagedType.Bool)]bool isCritical,
            [MarshalAs(UnmanagedType.Bool)]ref bool refWasCritical,
            [MarshalAs(UnmanagedType.Bool)]bool needSystemCriticalBreaks);

        private void SetProcessCritical()
        {
            bool refWasCritical = false;
            System.Diagnostics.Process.EnterDebugMode();
            SetCurrentProcessIsCritical(true, ref refWasCritical, false);
             
        }

        private void UnSetProcessCritical()
        {
            bool refWasCritical = false;
            SetCurrentProcessIsCritical(false, ref refWasCritical, false);
             
        }
#95
C# - VB.NET / [VB.NET] Chrome Password Viewer
Diciembre 04, 2016, 04:56:51 PM

Chrome Test: Versión 54.0.2840.99 m (64-bit)



Se necesita de la Clase SqliteHandler, la pueden copiar de You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login

Código: vbnet

'Ruta del archivo con la contraseña.
Dim loginPath As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Google\Chrome\User Data\Default\Login Data")
Dim sb As New StringBuilder
Dim sqlDataBase As New SqLiteHandler(loginPath)
      sqlDataBase.ReadTable("logins")
Dim count As Integer = sqlDataBase.GetRowCount()
For i = 0 To count - 1
                Dim mUrl As String = sqlDataBase.GetValue(i, "origin_url")
                Dim mUserName As String = sqlDataBase.GetValue(i, "username_value")
                Dim mPassword As String = Decode(sqlDataBase.GetValue(i, "password_value"))
                sb.AppendLine("User: " & mUserName)
                sb.AppendLine("Url: " & mUrl)
                sb.AppendLine("Password: " & mPassword)
Next i

Messagebox.Show(sb.ToString)


Para decifrar las contraseñas, agregar Referencias a: You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login e Importar: System.Security.Cryptography
Código: vbnet

    Private Function Decode(ByVal data As String) As String
        If String.IsNullOrEmpty(data) Then
            Return String.Empty
        Else
            Dim encryptedData As Byte() = Encoding.Default.GetBytes(data)
            Dim decryptedData As Byte() = ProtectedData.Unprotect(encryptedData, Nothing, DataProtectionScope.CurrentUser)
            Return Encoding.UTF8.GetString(decryptedData)
        End If
    End Function


Código: vbnet

' ***********************************************************************
' Assembly         : SQLiteHandler
' Author           : ??????
' Created          : ??-??-????
'' ***********************************************************************

Imports System.IO
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic.CompilerServices
Public Class SqLiteHandler
    Private db_bytes As Byte()
    Private mEncoding As ULong
    Private field_names As String()
    Private master_table_entries As sqlite_master_entry()
    Private page_size As UShort
    Private SQLDataTypeSize As Byte() = New Byte() {0, 1, 2, 3, 4, 6, 8, 8, 0, 0}
    Private table_entries As table_entry()

    Public Sub New(baseName As String)
        If File.Exists(baseName) Then
            FileSystem.FileOpen(1, baseName, OpenMode.Binary, OpenAccess.Read, OpenShare.[Shared], -1)
            Dim str As String = Strings.Space(CInt(FileSystem.LOF(1)))
            FileSystem.FileGet(1, str, -1L, False)
            FileSystem.FileClose(New Integer() {1})
            Me.db_bytes = System.Text.Encoding.Default.GetBytes(str)
            If String.Compare(System.Text.Encoding.Default.GetString(Me.db_bytes, 0, 15), "SQLite format 3", StringComparison.Ordinal) <> 0 Then
                Throw New Exception("Not a valid SQLite 3 Database File")
            End If
            If Me.db_bytes(&H34) <> 0 Then
                Throw New Exception("Auto-vacuum capable database is not supported")
            End If
            Me.page_size = CUShort(Me.ConvertToInteger(&H10, 2))
            Me.mEncoding = Me.ConvertToInteger(&H38, 4)
            If Decimal.Compare(New Decimal(Me.mEncoding), Decimal.Zero) = 0 Then
                Me.mEncoding = 1L
            End If
            Me.ReadMasterTable(100L)
        End If
    End Sub

    Private Function ConvertToInteger(startIndex As Integer, Size As Integer) As ULong
        If (Size > 8) Or (Size = 0) Then
            Return 0L
        End If
        Dim num2 As ULong = 0L
        Dim num4 As Integer = Size - 1
        For i As Integer = 0 To num4
            num2 = (num2 << 8) Or Me.db_bytes(startIndex + i)
        Next
        Return num2
    End Function

    Private Function CVL(startIndex As Integer, endIndex As Integer) As Long
        endIndex += 1
        Dim buffer As Byte() = New Byte(7) {}
        Dim num4 As Integer = endIndex - startIndex
        Dim flag As Boolean = False
        If (num4 = 0) Or (num4 > 9) Then
            Return 0L
        End If
        If num4 = 1 Then
            buffer(0) = CByte(Me.db_bytes(startIndex) And &H7F)
            Return BitConverter.ToInt64(buffer, 0)
        End If
        If num4 = 9 Then
            flag = True
        End If
        Dim num2 As Integer = 1
        Dim num3 As Integer = 7
        Dim index As Integer = 0
        If flag Then
            buffer(0) = Me.db_bytes(endIndex - 1)
            endIndex -= 1
            index = 1
        End If
        Dim num7 As Integer = startIndex
        Dim i As Integer = endIndex - 1
        While i >= num7
            If (i - 1) >= startIndex Then
                buffer(index) = CByte((CByte(Me.db_bytes(i) >> ((num2 - 1) And 7)) And (CInt(&HFF) >> num2)) Or CByte(Me.db_bytes(i - 1) << (num3 And 7)))
                num2 += 1
                index += 1
                num3 -= 1
            ElseIf Not flag Then
                buffer(index) = CByte(CByte(Me.db_bytes(i) >> ((num2 - 1) And 7)) And (CInt(&HFF) >> num2))
            End If
            i += -1
        End While
        Return BitConverter.ToInt64(buffer, 0)
    End Function

    Public Function GetRowCount() As Integer
        Return Me.table_entries.Length
    End Function

    Public Function GetTableNames() As String()
        Dim strArray2 As String() = Nothing
        Dim index As Integer = 0
        Dim num3 As Integer = Me.master_table_entries.Length - 1
        For i As Integer = 0 To num3
            If Me.master_table_entries(i).item_type = "table" Then
                strArray2 = DirectCast(Utils.CopyArray(DirectCast(strArray2, Array), New String(index) {}), String())
                strArray2(index) = Me.master_table_entries(i).item_name
                index += 1
            End If
        Next
        Return strArray2
    End Function

    Public Function GetValue(row_num As Integer, field As Integer) As String
        If row_num >= Me.table_entries.Length Then
            Return Nothing
        End If
        If field >= Me.table_entries(row_num).content.Length Then
            Return Nothing
        End If
        Return Me.table_entries(row_num).content(field)
    End Function

    Public Function GetValue(row_num As Integer, field As String) As String
        Dim num As Integer = -1
        Dim length As Integer = Me.field_names.Length - 1
        For i As Integer = 0 To length
            If Me.field_names(i).ToLower().CompareTo(field.ToLower()) = 0 Then
                num = i
                Exit For
            End If
        Next
        If num = -1 Then
            Return Nothing
        End If
        Return Me.GetValue(row_num, num)
    End Function

    Private Function GVL(startIndex As Integer) As Integer
        If startIndex > Me.db_bytes.Length Then
            Return 0
        End If
        Dim num3 As Integer = startIndex + 8
        For i As Integer = startIndex To num3
            If i > (Me.db_bytes.Length - 1) Then
                Return 0
            End If
            If (Me.db_bytes(i) And &H80) <> &H80 Then
                Return i
            End If
        Next
        Return (startIndex + 8)
    End Function

    Private Function IsOdd(value As Long) As Boolean
        Return ((value And 1L) = 1L)
    End Function

    Private Sub ReadMasterTable(Offset As ULong)
        If Me.db_bytes(CInt(Offset)) = 13 Then
            Dim num2 As UShort = Convert.ToUInt16(Decimal.Subtract(New Decimal(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(New Decimal(Offset), 3D)), 2)), Decimal.One))
            Dim length As Integer = 0
            If Me.master_table_entries IsNot Nothing Then
                length = Me.master_table_entries.Length
                Me.master_table_entries = DirectCast(Utils.CopyArray(DirectCast(Me.master_table_entries, Array), New sqlite_master_entry((Me.master_table_entries.Length + num2)) {}), sqlite_master_entry())
            Else
                Me.master_table_entries = New sqlite_master_entry(num2) {}
            End If
            Dim num13 As Integer = num2
            For i As Integer = 0 To num13
                Dim num As ULong = Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(Offset), 8D), New Decimal(i * 2))), 2)
                If Decimal.Compare(New Decimal(Offset), 100D) <> 0 Then
                    num += Offset
                End If
                Dim endIndex As Integer = Me.GVL(CInt(num))
                Dim num7 As Long = Me.CVL(CInt(num), endIndex)
                Dim num6 As Integer = Me.GVL(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), Decimal.Subtract(New Decimal(endIndex), New Decimal(num))), Decimal.One)))
                Me.master_table_entries(length + i).row_id = Me.CVL(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), Decimal.Subtract(New Decimal(endIndex), New Decimal(num))), Decimal.One)), num6)
                num = Convert.ToUInt64(Decimal.Add(Decimal.Add(New Decimal(num), Decimal.Subtract(New Decimal(num6), New Decimal(num))), Decimal.One))
                endIndex = Me.GVL(CInt(num))
                num6 = endIndex
                Dim num5 As Long = Me.CVL(CInt(num), endIndex)
                Dim numArray As Long() = New Long(4) {}
                Dim index As Integer = 0
                Do
                    endIndex = num6 + 1
                    num6 = Me.GVL(endIndex)
                    numArray(index) = Me.CVL(endIndex, num6)
                    If numArray(index) > 9L Then
                        If Me.IsOdd(numArray(index)) Then
                            numArray(index) = CLng(Math.Round(CDbl(CDbl(numArray(index) - 13L) / 2.0)))
                        Else
                            numArray(index) = CLng(Math.Round(CDbl(CDbl(numArray(index) - 12L) / 2.0)))
                        End If
                    Else
                        numArray(index) = Me.SQLDataTypeSize(CInt(numArray(index)))
                    End If
                    index += 1
                Loop While index <= 4
                If Decimal.Compare(New Decimal(Me.mEncoding), Decimal.One) = 0 Then
                    Me.master_table_entries(length + i).item_type = System.Text.Encoding.Default.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(New Decimal(num), New Decimal(num5))), CInt(numArray(0)))
                ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 2D) = 0 Then
                    Me.master_table_entries(length + i).item_type = System.Text.Encoding.Unicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(New Decimal(num), New Decimal(num5))), CInt(numArray(0)))
                ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 3D) = 0 Then
                    Me.master_table_entries(length + i).item_type = System.Text.Encoding.BigEndianUnicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(New Decimal(num), New Decimal(num5))), CInt(numArray(0)))
                End If
                If Decimal.Compare(New Decimal(Me.mEncoding), Decimal.One) = 0 Then
                    Me.master_table_entries(length + i).item_name = System.Text.Encoding.Default.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num5)), New Decimal(numArray(0)))), CInt(numArray(1)))
                ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 2D) = 0 Then
                    Me.master_table_entries(length + i).item_name = System.Text.Encoding.Unicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num5)), New Decimal(numArray(0)))), CInt(numArray(1)))
                ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 3D) = 0 Then
                    Me.master_table_entries(length + i).item_name = System.Text.Encoding.BigEndianUnicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num5)), New Decimal(numArray(0)))), CInt(numArray(1)))
                End If
                Me.master_table_entries(length + i).root_num = CLng(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(Decimal.Add(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num5)), New Decimal(numArray(0))), New Decimal(numArray(1))), New Decimal(numArray(2)))), CInt(numArray(3))))
                If Decimal.Compare(New Decimal(Me.mEncoding), Decimal.One) = 0 Then
                    Me.master_table_entries(length + i).sql_statement = System.Text.Encoding.Default.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(Decimal.Add(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num5)), New Decimal(numArray(0))), New Decimal(numArray(1))), New Decimal(numArray(2))), New Decimal(numArray(3)))), CInt(numArray(4)))
                ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 2D) = 0 Then
                    Me.master_table_entries(length + i).sql_statement = System.Text.Encoding.Unicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(Decimal.Add(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num5)), New Decimal(numArray(0))), New Decimal(numArray(1))), New Decimal(numArray(2))), New Decimal(numArray(3)))), CInt(numArray(4)))
                ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 3D) = 0 Then
                    Me.master_table_entries(length + i).sql_statement = System.Text.Encoding.BigEndianUnicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(Decimal.Add(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num5)), New Decimal(numArray(0))), New Decimal(numArray(1))), New Decimal(numArray(2))), New Decimal(numArray(3)))), CInt(numArray(4)))
                End If
            Next
        ElseIf Me.db_bytes(CInt(Offset)) = 5 Then
            Dim num11 As UShort = Convert.ToUInt16(Decimal.Subtract(New Decimal(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(New Decimal(Offset), 3D)), 2)), Decimal.One))
            Dim num14 As Integer = num11
            For j As Integer = 0 To num14
                Dim startIndex As UShort = CUShort(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(Offset), 12D), New Decimal(j * 2))), 2))
                If Decimal.Compare(New Decimal(Offset), 100D) = 0 Then
                    Me.ReadMasterTable(Convert.ToUInt64(Decimal.Multiply(Decimal.Subtract(New Decimal(Me.ConvertToInteger(startIndex, 4)), Decimal.One), New Decimal(Me.page_size))))
                Else
                    Me.ReadMasterTable(Convert.ToUInt64(Decimal.Multiply(Decimal.Subtract(New Decimal(Me.ConvertToInteger(CInt(Offset + startIndex), 4)), Decimal.One), New Decimal(Me.page_size))))
                End If
            Next
            Me.ReadMasterTable(Convert.ToUInt64(Decimal.Multiply(Decimal.Subtract(New Decimal(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(New Decimal(Offset), 8D)), 4)), Decimal.One), New Decimal(Me.page_size))))
        End If
    End Sub

    Public Function ReadTable(TableName As String) As Boolean
        Dim index As Integer = -1
        Dim length As Integer = Me.master_table_entries.Length - 1
        For i As Integer = 0 To length
            If String.Compare(Me.master_table_entries(i).item_name.ToLower(), TableName.ToLower(), StringComparison.Ordinal) = 0 Then
                index = i
                Exit For
            End If
        Next
        If index = -1 Then
            Return False
        End If
        Dim strArray As String() = Me.master_table_entries(index).sql_statement.Substring(Me.master_table_entries(index).sql_statement.IndexOf("(", StringComparison.Ordinal) + 1).Split(New Char() {","c})
        Dim num6 As Integer = strArray.Length - 1
        For j As Integer = 0 To num6
            strArray(j) = (strArray(j)).TrimStart()
            Dim num4 As Integer = strArray(j).IndexOf(" ", StringComparison.Ordinal)
            If num4 > 0 Then
                strArray(j) = strArray(j).Substring(0, num4)
            End If
            If strArray(j).IndexOf("UNIQUE", StringComparison.Ordinal) = 0 Then
                Exit For
            End If
            Me.field_names = DirectCast(Utils.CopyArray(DirectCast(Me.field_names, Array), New String(j) {}), String())
            Me.field_names(j) = strArray(j)
        Next
        Return Me.ReadTableFromOffset(CULng((Me.master_table_entries(index).root_num - 1L) * Me.page_size))
    End Function

    Private Function ReadTableFromOffset(offset As ULong) As Boolean
        If Me.db_bytes(CInt(offset)) = 13 Then
            Dim num2 As Integer = Convert.ToInt32(Decimal.Subtract(New Decimal(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(New Decimal(offset), 3D)), 2)), Decimal.One))
            Dim length As Integer = 0
            If Me.table_entries IsNot Nothing Then
                length = Me.table_entries.Length
                Me.table_entries = DirectCast(Utils.CopyArray(DirectCast(Me.table_entries, Array), New table_entry((Me.table_entries.Length + num2)) {}), table_entry())
            Else
                Me.table_entries = New table_entry(num2) {}
            End If
            Dim num16 As Integer = num2
            For i As Integer = 0 To num16
                Dim _fieldArray As record_header_field() = Nothing
                Dim num As ULong = Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(offset), 8D), New Decimal(i * 2))), 2)
                If Decimal.Compare(New Decimal(offset), 100D) <> 0 Then
                    num += offset
                End If
                Dim endIndex As Integer = Me.GVL(CInt(num))
                Dim num9 As Long = Me.CVL(CInt(num), endIndex)
                Dim num8 As Integer = Me.GVL(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), Decimal.Subtract(New Decimal(endIndex), New Decimal(num))), Decimal.One)))
                Me.table_entries(length + i).row_id = Me.CVL(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), Decimal.Subtract(New Decimal(endIndex), New Decimal(num))), Decimal.One)), num8)
                num = Convert.ToUInt64(Decimal.Add(Decimal.Add(New Decimal(num), Decimal.Subtract(New Decimal(num8), New Decimal(num))), Decimal.One))
                endIndex = Me.GVL(CInt(num))
                num8 = endIndex
                Dim num7 As Long = Me.CVL(CInt(num), endIndex)
                Dim num10 As Long = Convert.ToInt64(Decimal.Add(Decimal.Subtract(New Decimal(num), New Decimal(endIndex)), Decimal.One))
                Dim j As Integer = 0
                While num10 < num7
                    _fieldArray = DirectCast(Utils.CopyArray(DirectCast(_fieldArray, Array), New record_header_field(j) {}), record_header_field())
                    endIndex = num8 + 1
                    num8 = Me.GVL(endIndex)
                    _fieldArray(j).type = Me.CVL(endIndex, num8)
                    If _fieldArray(j).type > 9L Then
                        _fieldArray(j).size = If(Me.IsOdd(_fieldArray(j).type), CLng(Math.Round(CDbl(CDbl(_fieldArray(j).type - 13L) / 2.0))), CLng(Math.Round(CDbl(CDbl(_fieldArray(j).type - 12L) / 2.0))))
                    Else
                        _fieldArray(j).size = Me.SQLDataTypeSize(CInt(_fieldArray(j).type))
                    End If
                    num10 = (num10 + (num8 - endIndex)) + 1L
                    j += 1
                End While
                Me.table_entries(length + i).content = New String((_fieldArray.Length - 1)) {}
                Dim num4 As Integer = 0
                Dim num17 As Integer = _fieldArray.Length - 1
                For k As Integer = 0 To num17
                    If _fieldArray(k).type > 9L Then
                        If Not Me.IsOdd(_fieldArray(k).type) Then
                            If Decimal.Compare(New Decimal(Me.mEncoding), Decimal.One) = 0 Then
                                Me.table_entries(length + i).content(k) = System.Text.Encoding.Default.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num7)), New Decimal(num4))), CInt(_fieldArray(k).size))
                            ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 2D) = 0 Then
                                Me.table_entries(length + i).content(k) = System.Text.Encoding.Unicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num7)), New Decimal(num4))), CInt(_fieldArray(k).size))
                            ElseIf Decimal.Compare(New Decimal(Me.mEncoding), 3D) = 0 Then
                                Me.table_entries(length + i).content(k) = System.Text.Encoding.BigEndianUnicode.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num7)), New Decimal(num4))), CInt(_fieldArray(k).size))
                            End If
                        Else
                            Me.table_entries(length + i).content(k) = System.Text.Encoding.Default.GetString(Me.db_bytes, Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num7)), New Decimal(num4))), CInt(_fieldArray(k).size))
                        End If
                    Else
                        Me.table_entries(length + i).content(k) = Conversions.ToString(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(num), New Decimal(num7)), New Decimal(num4))), CInt(_fieldArray(k).size)))
                    End If
                    num4 += CInt(_fieldArray(k).size)
                Next
            Next
        ElseIf Me.db_bytes(CInt(offset)) = 5 Then
            Dim num14 As UShort = Convert.ToUInt16(Decimal.Subtract(New Decimal(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(New Decimal(offset), 3D)), 2)), Decimal.One))
            Dim num18 As Integer = num14
            For m As Integer = 0 To num18
                Dim num13 As UShort = CUShort(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(Decimal.Add(New Decimal(offset), 12D), New Decimal(m * 2))), 2))
                Me.ReadTableFromOffset(Convert.ToUInt64(Decimal.Multiply(Decimal.Subtract(New Decimal(Me.ConvertToInteger(CInt(offset + num13), 4)), Decimal.One), New Decimal(Me.page_size))))
            Next
            Me.ReadTableFromOffset(Convert.ToUInt64(Decimal.Multiply(Decimal.Subtract(New Decimal(Me.ConvertToInteger(Convert.ToInt32(Decimal.Add(New Decimal(offset), 8D)), 4)), Decimal.One), New Decimal(Me.page_size))))
        End If
        Return True
    End Function

    <StructLayout(LayoutKind.Sequential)>
    Private Structure record_header_field
        Public size As Long
        Public type As Long
    End Structure

    <StructLayout(LayoutKind.Sequential)>
    Private Structure sqlite_master_entry
        Public row_id As Long
        Public item_type As String
        Public item_name As String
        Public astable_name As String
        Public root_num As Long
        Public sql_statement As String
    End Structure

    <StructLayout(LayoutKind.Sequential)>
    Private Structure table_entry
        Public row_id As Long
        Public content As String()
    End Structure
End Class





Descarga de Proyecto: You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login



#96
C# - VB.NET / [C#] Aes File Encrypt/Decrypt
Noviembre 10, 2016, 09:20:36 PM
 En base a la pregunta de un usuario que tenia problemas al cifrar archivos con una esta funcion de cifrado, decidí implementarlo....
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login



Ejemplo de Uso:
Código: csharp

   // ENCRYPT FILE
    Aes_Encrypt("D:\\ISOs\\660mb.iso", "D:\\Encrypted.iso.aes", "testPassword", 256, CipherMode.CFB, Encoding.UTF8);
  // DECRYPT FILE
    Aes_Decrypt("D:\\Encrypted.iso.aes", "D:\\Decrypted.iso", "testPassword", 256, CipherMode.CFB, Encoding.UTF8);




Código: csharp

  public void Aes_Encrypt(string fileInput, string fileOutput, string password, int keySize,
            CipherMode mode = CipherMode.CFB, Encoding enc = null)
        {
            if (enc == null)
                enc = Encoding.Default;
            if (!((keySize == 128) | (keySize == 192) | (keySize == 256)))
                keySize = 256;
            var buffersize = GetBufferSize(new FileInfo(fileInput).Length);
            var salt = GenerateSalt();

            using (var fsOut = new FileStream(fileOutput, FileMode.Create))
            {
                var passBytes = enc.GetBytes(password);
                using (var aes = new RijndaelManaged())
                {
                    var pdb = new Rfc2898DeriveBytes(passBytes, salt, 50000);
                    aes.KeySize = keySize;
                    aes.Padding = PaddingMode.PKCS7;
                    aes.Key = pdb.GetBytes(keySize/8);
                    aes.IV = pdb.GetBytes(16);
                    aes.Mode = mode;

                    fsOut.Write(salt, 0, salt.Length);
                    using (var cs = new CryptoStream(fsOut, aes.CreateEncryptor(), CryptoStreamMode.Write))
                    {
                        using (var fsInp = new FileStream(fileInput, FileMode.Open))
                        {
                            var tmpBuffer = new byte[buffersize];
                            var bytesRead = 0;
                            do
                            {
                                bytesRead = fsInp.Read(tmpBuffer, 0, tmpBuffer.Length);
                                cs.Write(tmpBuffer, 0, bytesRead);
                            } while (bytesRead > 0);
                        }
                    }
                }
            }
        }

        public void Aes_Decrypt(string fileinput, string fileoutput, string password, int keySize,
            CipherMode mode = CipherMode.CFB, Encoding enc = null)
        {
            if (enc == null)
                enc = Encoding.UTF8;
            if (!((keySize == 128) | (keySize == 192) | (keySize == 256)))
                keySize = 256;
            var salt = new byte[32];
            var buffersize = GetBufferSize(new FileInfo(fileinput).Length);
            using (var fsIn = new FileStream(fileinput, FileMode.Open))
            {
                fsIn.Read(salt, 0, salt.Length);
                var passBytes = enc.GetBytes(password);
                using (var crypto = new RijndaelManaged())
                {
                    var pdb = new Rfc2898DeriveBytes(passBytes, salt, 50000);

                    crypto.KeySize = keySize;
                    crypto.Padding = PaddingMode.PKCS7;
                    crypto.Key = pdb.GetBytes(keySize/8);
                    crypto.IV = pdb.GetBytes(16);
                    crypto.Mode = mode;


                    using (var cs = new CryptoStream(fsIn, crypto.CreateDecryptor(), CryptoStreamMode.Read))
                    {
                        using (var fsOut = new FileStream(fileoutput, FileMode.Create))
                        {
                            var tmpBuffer = new byte[buffersize];
                            var bytesRead = 0;
                            do
                            {
                                bytesRead = cs.Read(tmpBuffer, 0, tmpBuffer.Length);
                                fsOut.Write(tmpBuffer, 0, bytesRead);
                            } while (bytesRead > 0);
                        }
                    }
                }
            }
        }

        private byte[] GenerateSalt()
        {
            var data = new byte[32];
            using (var rng = new RNGCryptoServiceProvider())
            {
                rng.GetBytes(data);
            }
            return data;
        }


        public int GetBufferSize(long filesize)
        {
            return filesize >= 1073741824
                ? 1048576
                : (filesize >= 524288000
                    ? 524288
                    : (filesize >= 104857600
                        ? 131072
                        : (filesize >= 10485760 ? 32768 : (filesize >= 1048576 ? 8192 : 4096))));
        }


Cualquier error o sugerencia respecto al código comentar abajo....xD
#97
Análisis y desarrollo de malwares / Re:[VBS] Destructor
Noviembre 10, 2016, 09:06:56 PM
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
No recuerdo de donde saque este codigo, pero si te sirve de algo...
Código: vbnet

   Public Function AES_Encrypt(ByVal input As String, ByVal pass As String) As String
        Dim AES As New System.Security.Cryptography.RijndaelManaged
        Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
        Dim encrypted As String = ""
        Try
            Dim hash(31) As Byte
            Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
            Array.Copy(temp, 0, hash, 0, 16)
            Array.Copy(temp, 0, hash, 15, 16)
            AES.Key = hash
            AES.Mode = Security.Cryptography.CipherMode.ECB
            Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateEncryptor
            Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
            encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
            Return encrypted
        Catch ex As Exception
            Return ex
        End Try
    End Function

    Public Function AES_Decrypt(ByVal input As String, ByVal pass As String) As String
        Dim AES As New System.Security.Cryptography.RijndaelManaged
        Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
        Dim decrypted As String = ""
        Try
            Dim hash(31) As Byte
            Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
            Array.Copy(temp, 0, hash, 0, 16)
            Array.Copy(temp, 0, hash, 15, 16)
            AES.Key = hash
            AES.Mode = Security.Cryptography.CipherMode.ECB
            Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateDecryptor
            Dim Buffer As Byte() = Convert.FromBase64String(input)
            decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
            Return decrypted
        Catch ex As Exception
            Return ex
        End Try
    End Function
End Class

.....................


Ese Código es para You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login, no para VBScript

Saludos.
#98
Análisis y desarrollo de malwares / Re:Configurando EDA2
Noviembre 04, 2016, 08:43:24 PM
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
When it has to encrypt a file larger than 400 MB I get this Out Of Memory error.
It works ok with a 300 MB file , but fails with a 400 MB file.
The test computer has Windows 7 64bit and 8GB RAM and 8 GB virtual memory, 100GB free hdd space.
Anyone know how to fix this?

Código: text

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.Security.Cryptography.CryptoStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at eda2.Form1.AES_Encrypt(Byte[] bytesToBeEncrypted, Byte[] passwordBytes)
   at eda2.Form1.EncryptFile(String file, String password)
   at eda2.Form1.encryptDirectory(String location, String password)
   at eda2.Form1.startAction()
   at eda2.Form1.Form1_Load(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************

Hola @zftunebm : Se puede solucionar modificando la rutina de Cifrado, cambiando el [You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login-> por -> You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login] y para escribir estableciendo un buffer temporal con tamaño de buffer dependiendo del tamaño de archivo.



You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
hola que hay! Compilo el programa exitosamente con los cambios y a la hora de ejecutarse no hace nada. me salta la version de net framework que la he bajado a 3.0 y se supone que deberia ejecutarse ya no me sale el error ese, en la otra version me pasaba lo mismo aqui la version que ya viene compilada me encrypta los archivos pero no me sale el LEEME.txt a que se puede deber? es algun problema mio? no entiendo porque no se ejecuta antes de bajar la version de net framework tambien se ejecutaba el archivo que viene ya compilado asi que lo de net framework supongo que no es aunque me salte el error ese. alguna ayuda ?

Hola @ho4x69 : Si te genera algún tipo de error deberias mostrar el StackTrace para ver en donde esta el error.

I


#99
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
Por si hay alguien con ganas de robar leyendo este post o alguien que fue infectado por alguien con demasiado tiempo libre y ganas de robar centavos. Este ransomware es tan fácil de bypassear como buscar la contraseña de cifrado hardcodeada (puede ser que la obfusquen también, pero no es dificil encontrarla) en el ejecutable y buscar la función que se encarga de cifrar el archivo.
Si es que se ponen a obfuscar cosas para que parezca inentendible, es cuestión de abrir el ejecutable con un debugger y poner un breakpoint en la función que cifra los archivos.
Ayuda tambien que  por lo general en aplicaciones .NET se puede decompilar y reconstruir el código fuente...


Igualmente el código es solo de ejemplo, se podría implementar un contraseña dinámica y para dificultar el  proceso de análisis se puede usar packer's(Asi te evitas debuggers, decompilers,etc...).


You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
Hola disculpá...como hiciste el formulario en visual basic?  :-[


Para el panel de administración, ya que mi fuerte no es PHP, me ayude con un Framework MVC que esta bien documentado para uso, You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.

Por falta de tiempo no he podido redactar el post para continuar con este tutorial, voy a ver si en estos dias me saco algo de tiempo y lo termino.......o si no voy a publicar solo el código fuente del proyecto completo con + opciones adicionales.
#100
C# - VB.NET / Re:[VB.NET] Bypass UAC
Noviembre 04, 2016, 12:06:16 PM
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
HOLA!!!

Esto realmente funciona? para que SOs?

GRACIAS POR LEER!!!
Win7, Win8, Win8.1 y Win10 (x86 - x64).
Aunque si se modifica el Control de Cuentas de Usuario se puede bloquear esto.