|
-
Nov 23rd, 2012, 07:06 PM
#1
Thread Starter
Junior Member
Writing a cypter please help
Well so far, no one has actually provided me with any help so I turned to the vb forums to see if anyone could help out here.
I'm in the process of writing a crypter for personal and learning reasons.
Essentially what it does, is takes the bytes of the .exe files, encrypts them using encryption methods, and then creates a new .exe file and writes all the bytes.
The problem I'm having is once the file is written, the .exe doesn't open. I think this is because all of the bytes aren't being written for some reason, help would be appreciated!
When I open the .exe in notepad++, all the bytes from the first file are NOT in the second file, only some which is why I think it's corrupting. Plus the file size isn't the same.
Here's the basis of what I have
Code:
Public Shared Function forD24(ByVal input As Byte()) As String
Dim out As New System.Text.StringBuilder
' Dim base64data As String = Convert.ToBase64String(input)
Dim base64data As String = input.ToString()
Dim arr As String() = Split0923(base64data, 100)
For i As Integer = 0 To arr.Length - 1
If i = arr.Length - 1 Then
out.Append(Chr(34) & arr(i) & Chr(34))
Else 'I is smaller than arr.Length - 1 (i < arr.Length - 1)
out.Append(Chr(34) & arr(i) & Chr(34) & " & _" & vbNewLine)
End If
Next
Return out.ToString
End Function
Code:
Private Sub dat(ByVal dat As Byte())
Dim bit As [Byte]() = dat
KP.Write(bit, 0, bit.Length) 'Writes file bytes to mem stream (NOT WORKING)
End Sub
Dim q As Byte() = IO.File.ReadAllBytes(showDir.Text) 'File to encrypt
dat(q)
Dim bit(KP.Length) As Byte
Dim data As [Byte]() = bit
data = New [Byte](256) {}
Dim bytes As Int32 = KP.Read(data, 0, data.Length)
Dim responseData As [String] = [String].Empty
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes)
MsgBox("This:" & responseData) 'DOESNT PRINT ANYTHING
' Dim input As Byte() = ECT.RijEC(q) 'Encryption
Dim input As Byte() = q 'Forget encryption for now, I can't even write all the bytes properly...
src = src.Replace("%3%", IK93.forD24(input)) 'Formating the bytes to string
GE.GEN_EX(stub_OUT & "12345", src, ICON_PATH) 'Generates the .exe file
-
Nov 23rd, 2012, 07:29 PM
#2
Re: Writing a cypter please help
Um ... you're not trying to run the encrypted .exe, are you? Cos that would be just silly! Have you tried decrypting to see if what you get back is what you put in? I certainly wouldn't be using .exe files for this in the development stages. Start small and scale up when it's working!
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Nov 23rd, 2012, 07:49 PM
#3
Thread Starter
Junior Member
Re: Writing a cypter please help
It's the whole point of a crypter, it encrypts the bytes, but is still functional. And tbh, encrypting it isn't the problem right now, I can't even get the bytes to write from the original file to the new one... Not all of the bytes are being written and idk why...
-
Nov 24th, 2012, 06:08 AM
#4
Re: Writing a cypter please help
Well if you could explain which encryption you're trying to apply to the file.
As it stands, without knowing Split0923, KP, ECT.RijEC, GE, IK93 etc., it's a little bit hard to even decipher your code.
In truth, a mature man who uses hair-oil, unless medicinally , that man has probably got a quoggy spot in him somewhere. As a general rule, he can't amount to much in his totality. (Melville: Moby Dick)
-
Nov 24th, 2012, 02:08 PM
#5
Thread Starter
Junior Member
Re: Writing a cypter please help
 Originally Posted by ThomasJohnsen
Well if you could explain which encryption you're trying to apply to the file.
As it stands, without knowing Split0923, KP, ECT.RijEC, GE, IK93 etc., it's a little bit hard to even decipher your code.
Encryption isn't really the issue at the moment, I need to be able to write all of the bytes, because it's only writing some.
KP is the MemoryStream where the bytes are written from the file. But they don't seem to be writing in properly idk why.
RijEC is Rijndael encryption
Code:
Shared Function RijEC(ByVal data As Byte()) As Byte()
Using vashist As New System.Security.Cryptography.RijndaelManaged
vashist.IV = New Byte() {9, 8, 7, 6, 5, 4, 3, 2, 1, 5, 6, 7, 8, 9, 6, 5}
vashist.Key = New Byte() {2, 1, 5, 6, 7, 8, 9, 6, 5, 9, 8, 7, 6, 5, 4, 3}
Return vashist.CreateEncryptor.TransformFinalBlock(data, 0, data.Length)
End Using
Class GE is in control of creating the executable .exe file and compiling the code.
IK93.forD24 is formatting the encrypted bytes, or bytes from the file.
Code:
Public Shared Function forD24(ByVal input As Byte()) As String
Dim out As New System.Text.StringBuilder
' Dim base64data As String = Convert.ToBase64String(input)
Dim base64data As String = input.ToString()
Dim arr As String() = Split0923(base64data, 100)
For i As Integer = 0 To arr.Length - 1
If i = arr.Length - 1 Then ' If i equals the highest number
out.Append(Chr(34) & arr(i) & Chr(34))
Else 'I is smaller than arr.Length - 1 (i < arr.Length - 1)
out.Append(Chr(34) & arr(i) & Chr(34) & " & _" & vbNewLine)
End If
Next
Return out.ToString
End Function
Split is splitting the parts
Code:
Private Shared Function Split0923(ByVal input As String, ByVal partsize As Long) As String()
Dim amount As Long = Math.Ceiling(input.Length / partsize)
Dim out(amount - 1) As String
Dim currentpos As Long = 0
For I As Integer = 0 To amount - 1
If I = amount - 1 Then
Dim temp((input.Length - currentpos) - 1) As Char
input.CopyTo(currentpos, temp, 0, (input.Length - currentpos))
out(I) = Convert.ToString(temp)
Else 'I is smaller than amount - 1 (i < amount - 1)
Dim temp(partsize - 1) As Char
input.CopyTo(currentpos, temp, 0, partsize)
out(I) = Convert.ToString(temp)
currentpos += partsize
End If
Next
Return out
End Function
The aim of this is to create a crypter that will allow me to encrypt the bytes, but the file will still be usable, so I don't want to corrupt it.
-
Nov 24th, 2012, 03:58 PM
#6
Re: Writing a cypter please help
 Originally Posted by besteR
The aim of this is to create a crypter that will allow me to encrypt the bytes, but the file will still be usable, so I don't want to corrupt it.
I honestly haven't got a clue about what you're trying to do!
I cannot see why you would want to use memorystreams, base64 encoding, splitting into 100 char chunks that apparently are put in "s. It seems to me that you're making this much more complicated than it has to be. Also if you're expecting to still be able to execute a file after it has been encrypted, I'll have to 2nd dunfiddlin - that simply cannot be done. If you could just explain in words, what you're trying to do, helping you would be much easier - your code simply does not make much sense; at least not to me.
In truth, a mature man who uses hair-oil, unless medicinally , that man has probably got a quoggy spot in him somewhere. As a general rule, he can't amount to much in his totality. (Melville: Moby Dick)
-
Nov 24th, 2012, 04:05 PM
#7
Re: Writing a cypter please help
 Originally Posted by besteR
It's the whole point of a crypter, it encrypts the bytes, but is still functional. And tbh, encrypting it isn't the problem right now, I can't even get the bytes to write from the original file to the new one... Not all of the bytes are being written and idk why...
Er ... no. What you're talking about is obfuscation not encryption. I refer you to this StackOverflow thread for some hints as to the difference (and the pointlessness of both in some situations).
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Nov 24th, 2012, 04:23 PM
#8
Thread Starter
Junior Member
Re: Writing a cypter please help
Oh my mistake then, from what I was told I'd need to encrypt the bytes...
I'll look into obfuscation
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|