Merhabalar bugün geçmiş forumları incelerken pek çok hazır kaynak kod üretici İngilizce deyimi ile source generator gördüm. Bunlardan bazıları @'AnKeBuT adlı üyeye ait. Visual Basic 6 dilinde kodlanmış ve FUD oranı ele alınmış zaten bu tür uygulamalarda önemli olan bu orandır. Bu oran ise kullanmış olduğunuz algoritma ile alakalıdır. Ben de daha önce sanal ortamda araştırma yaparken Bawaneh adlı bir kullanıcının kodlamış olduğu RunPE oluşturucuya biraz modifikasyon ekledim. Ortaya çıkan sonucu sizinle paylaşmak istedim...
Konuya başlamadan önce üretim için bir adet modül ekleyelim projemize. İçerisine aşağıda vereceğim kodları yerleştirelim.
Modulümüzün başına en başına ekleyelim;
Modül Kodlarımız;
RC4 İçin;
1 Adet TrackBar ekleyelim. Bu bize üretilen değişkenlerin uzunluğunu verecek.
21 adet Textbox ekledim bunlardan 19 tanesini arka planda gizledim. Üretilen değişkenlere bir nesneye bağlayınca aynı sonucu veriyor farklı sonuç vermesi için böyle bir şey yaptım. Siz Resource yani Kaynaklar sekmesinden değişken kullanarak benim yaptığım gibi uzun yoldan gitmezsiniz zaten alt bölmelerde Bawaneh adlı kullanıcı böyle yapmış. Bu arada Textbox'lara isim verdim. Bunlardan sadece 2 ve 3 numaraları Textbox'lar işlem yapacak Textbox2 RC4'ün nasıl kullanıldığı hakkında bilgi verecek Textbox3 şifrelenmiş RC4 sonucunu ortaya çıkartacak.
2 adet Buton ekleyelim bunlardan birisi RC4 üretmek için diğeri üretilen RC4'ü kopyalamak için.
RC4 Üret Kodum;
Kopyala Kodum;
Konuya başlamadan önce üretim için bir adet modül ekleyelim projemize. İçerisine aşağıda vereceğim kodları yerleştirelim.
Modulümüzün başına en başına ekleyelim;
Imports System.Security.Cryptography
Modül Kodlarımız;
C#:
Public Class RandomPassword
' Define default min and max password lengths.
Private Shared DEFAULT_MIN_PASSWORD_LENGTH As Integer = 8
Private Shared DEFAULT_MAX_PASSWORD_LENGTH As Integer = 10
' Define supported password characters divided into groups.
' You can add (or remove) characters to (from) these groups.
Private Shared PASSWORD_CHARS_LCASE As String = "abcdefgijkmnopqrstwxyz"
Private Shared PASSWORD_CHARS_UCASE As String = "ABCDEFGHJKLMNPQRSTWXYZ"
Private Shared PASSWORD_CHARS_NUMERIC As String = "1234567890"
Private Shared PASSWORD_CHARS_SPECIAL As String = "öşçğıü"
Public Shared Function Generate() As String
Generate = Generate(DEFAULT_MIN_PASSWORD_LENGTH, _
DEFAULT_MAX_PASSWORD_LENGTH)
End Function
Public Shared Function Generate(ByVal length As Integer) As String
Generate = Generate(length, length)
End Function
Public Shared Function Generate(ByVal minLength As Integer, _
ByVal maxLength As Integer) _
As String
If (minLength <= 0 Or maxLength <= 0 Or minLength > maxLength) Then
Generate = Nothing
End If
Dim charGroups As Char()() = New Char()() _
{ _
PASSWORD_CHARS_LCASE.ToCharArray(), _
PASSWORD_CHARS_UCASE.ToCharArray(), _
PASSWORD_CHARS_NUMERIC.ToCharArray(), _
PASSWORD_CHARS_SPECIAL.ToCharArray() _
}
Dim charsLeftInGroup As Integer() = New Integer(charGroups.Length - 1) {}
Dim I As Integer
For I = 0 To charsLeftInGroup.Length - 1
charsLeftInGroup(I) = charGroups(I).Length
Next
' Use this array to track (iterate through) unused character groups.
Dim leftGroupsOrder As Integer() = New Integer(charGroups.Length - 1) {}
' Initially, all character groups are not used.
For I = 0 To leftGroupsOrder.Length - 1
leftGroupsOrder(I) = I
Next
' Because we cannot use the default randomizer, which is based on the
' current time (it will produce the same "random" number within a
' second), we will use a random number generator to seed the
' randomizer.
' Use a 4-byte array to fill it with random bytes and convert it then
' to an integer value.
Dim randomBytes As Byte() = New Byte(3) {}
' Generate 4 random bytes.
Dim rng As RNGCryptoServiceProvider = New RNGCryptoServiceProvider()
rng.GetBytes(randomBytes)
' Convert 4 bytes into a 32-bit integer value.
Dim seed As Integer = ((randomBytes(0) And &H7F) << 24 Or _
randomBytes(1) << 16 Or _
randomBytes(2) << 8 Or _
randomBytes(3))
' Now, this is real randomization.
Dim random As Random = New Random(seed)
' This array will hold password characters.
Dim password As Char() = Nothing
' Allocate appropriate memory for the password.
If (minLength < maxLength) Then
password = New Char(random.Next(minLength - 1, maxLength)) {}
Else
password = New Char(minLength - 1) {}
End If
' Index of the next character to be added to password.
Dim nextCharIdx As Integer
' Index of the next character group to be processed.
Dim nextGroupIdx As Integer
' Index which will be used to track not processed character groups.
Dim nextLeftGroupsOrderIdx As Integer
' Index of the last non-processed character in a group.
Dim lastCharIdx As Integer
' Index of the last non-processed group.
Dim lastLeftGroupsOrderIdx As Integer = leftGroupsOrder.Length - 1
' Generate password characters one at a time.
For I = 0 To password.Length - 1
' If only one character group remained unprocessed, process it;
' otherwise, pick a random character group from the unprocessed
' group list. To allow a special character to appear in the
' first position, increment the second parameter of the Next
' function call by one, i.e. lastLeftGroupsOrderIdx + 1.
If (lastLeftGroupsOrderIdx = 0) Then
nextLeftGroupsOrderIdx = 0
Else
nextLeftGroupsOrderIdx = random.Next(0, lastLeftGroupsOrderIdx)
End If
' Get the actual index of the character group, from which we will
' pick the next character.
nextGroupIdx = leftGroupsOrder(nextLeftGroupsOrderIdx)
' Get the index of the last unprocessed characters in this group.
lastCharIdx = charsLeftInGroup(nextGroupIdx) - 1
' If only one unprocessed character is left, pick it; otherwise,
' get a random character from the unused character list.
If (lastCharIdx = 0) Then
nextCharIdx = 0
Else
nextCharIdx = random.Next(0, lastCharIdx + 1)
End If
' Add this character to the password.
password(I) = charGroups(nextGroupIdx)(nextCharIdx)
' If we processed the last character in this group, start over.
If (lastCharIdx = 0) Then
charsLeftInGroup(nextGroupIdx) = _
charGroups(nextGroupIdx).Length
' There are more unprocessed characters left.
Else
' Swap processed character with the last unprocessed character
' so that we don't pick it until we process all characters in
' this group.
If (lastCharIdx <> nextCharIdx) Then
Dim temp As Char = charGroups(nextGroupIdx)(lastCharIdx)
charGroups(nextGroupIdx)(lastCharIdx) = _
charGroups(nextGroupIdx)(nextCharIdx)
charGroups(nextGroupIdx)(nextCharIdx) = temp
End If
' Decrement the number of unprocessed characters in
' this group.
charsLeftInGroup(nextGroupIdx) = _
charsLeftInGroup(nextGroupIdx) - 1
End If
' If we processed the last group, start all over.
If (lastLeftGroupsOrderIdx = 0) Then
lastLeftGroupsOrderIdx = leftGroupsOrder.Length - 1
' There are more unprocessed groups left.
Else
' Swap processed group with the last unprocessed group
' so that we don't pick it until we process all groups.
If (lastLeftGroupsOrderIdx <> nextLeftGroupsOrderIdx) Then
Dim temp As Integer = _
leftGroupsOrder(lastLeftGroupsOrderIdx)
leftGroupsOrder(lastLeftGroupsOrderIdx) = _
leftGroupsOrder(nextLeftGroupsOrderIdx)
leftGroupsOrder(nextLeftGroupsOrderIdx) = temp
End If
' Decrement the number of unprocessed groups.
lastLeftGroupsOrderIdx = lastLeftGroupsOrderIdx - 1
End If
Next
' Convert password characters into a string and return the result.
Generate = New String(password)
End Function
End Class
RC4 İçin;
1 Adet TrackBar ekleyelim. Bu bize üretilen değişkenlerin uzunluğunu verecek.
21 adet Textbox ekledim bunlardan 19 tanesini arka planda gizledim. Üretilen değişkenlere bir nesneye bağlayınca aynı sonucu veriyor farklı sonuç vermesi için böyle bir şey yaptım. Siz Resource yani Kaynaklar sekmesinden değişken kullanarak benim yaptığım gibi uzun yoldan gitmezsiniz zaten alt bölmelerde Bawaneh adlı kullanıcı böyle yapmış. Bu arada Textbox'lara isim verdim. Bunlardan sadece 2 ve 3 numaraları Textbox'lar işlem yapacak Textbox2 RC4'ün nasıl kullanıldığı hakkında bilgi verecek Textbox3 şifrelenmiş RC4 sonucunu ortaya çıkartacak.
2 adet Buton ekleyelim bunlardan birisi RC4 üretmek için diğeri üretilen RC4'ü kopyalamak için.
RC4 Üret Kodum;
C#:
TextBox1.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
yusuf.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
hasan.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
rahmi.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
kadir.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
ahmet.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
faruk.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
bilal.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
cem.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
soner.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
adnan.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
kenan.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
volkan.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
taner.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
şaban.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
ferhat.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
burak.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
necati.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
timur.Text = RandomPassword.Generate(TrackBar1.Value, TrackBar1.Value)
TextBox2.Text = TextBox1.Text + "(" + yusuf.Text + "," + " " + hasan.Text + ")"
TextBox3.Text = "Public Shared Function " + TextBox1.Text + "(" + "Byval " + yusuf.Text + " As String" + ", " + "Byval " + hasan.Text + " As String" + ")" + "As String" + vbCrLf & "Dim " + rahmi.Text + " As Integer = 0" + vbCrLf + "Dim " + kadir.Text + " As Integer = 0" + vbCrLf + "Dim " + ahmet.Text + " As New StringBuilder" + vbCrLf + "Dim " + faruk.Text + " As String = String.Empty" + vbCrLf + "Dim " + bilal.Text + " As Integer() = New Integer(256) {}" + vbCrLf + "Dim " + cem.Text + " As Integer() = New Integer(256) {}" + vbCrLf + "Dim " + soner.Text + " As Integer = " + hasan.Text + "." + "Length" + vbCrLf + "Dim " + adnan.Text + " As Integer = 0" + vbCrLf + "While " + adnan.Text + " <= 255" + vbCrLf + "Dim " + kenan.Text + " As Char = (" + hasan.Text + ".Substring((" + adnan.Text + " " + "Mod" + " " + soner.Text + "), 1).ToCharArray()(0))" + vbCrLf + cem.Text + "(" + adnan.Text + ") " + "= Microsoft.VisualBasic.Strings.Asc(" + kenan.Text + ")" + vbCrLf + bilal.Text + "(" + adnan.Text + ") " + "= " + adnan.Text + vbCrLf + "System.Math.Max(System.Threading.Interlocked.Increment(" + adnan.Text + ")" + ", " + adnan.Text + " - 1)" + vbCrLf + "End While" + vbCrLf + "Dim " + volkan.Text + " As Integer = 0" + vbCrLf + "Dim " + taner.Text + " As Integer = 0" + vbCrLf + "While " + taner.Text + " <= 255" + vbCrLf + volkan.Text + " =" + " (" + volkan.Text + " +" + " " + bilal.Text + "(" + taner.Text + ") " + "+ " + cem.Text + "(" + taner.Text + ")" + ")" + " Mod 256" + vbCrLf + "Dim " + şaban.Text + " As Integer = " + bilal.Text + "(" + taner.Text + ")" + vbCrLf + bilal.Text + "(" + taner.Text + ") " + "= " + bilal.Text + "(" + volkan.Text + ")" + vbCrLf + bilal.Text + "(" + volkan.Text + ") " + "= " + şaban.Text + vbCrLf + "System.Math.Max(System.Threading.Interlocked.Increment(" + taner.Text + "), " + taner.Text + " -1)" + vbCrLf + "End While" + vbCrLf + adnan.Text + " = 1" + vbCrLf + "While " + adnan.Text + " <=" + " " + yusuf.Text + ".Length" + vbCrLf + "Dim " + ferhat.Text + " As Integer = 0" + vbCrLf + rahmi.Text + " =" + " (" + rahmi.Text + " +" + " 1" + ")" + " Mod 256" + vbCrLf + kadir.Text + " =" + " (" + kadir.Text + " +" + " " + bilal.Text + "(" + rahmi.Text + ")" + ")" + " Mod 256" + vbCrLf + ferhat.Text + " =" + " " + bilal.Text + "(" + rahmi.Text + ")" + vbCrLf + bilal.Text + "(" + rahmi.Text + ")" + " =" + " " + bilal.Text + "(" + kadir.Text + ")" + vbCrLf + bilal.Text + "(" + rahmi.Text + ")" + " =" + " " + ferhat.Text + vbCrLf + "Dim " + burak.Text + " As Integer = " + bilal.Text + "(" + "(" + bilal.Text + "(" + rahmi.Text + ")" + " +" + " " + bilal.Text + "(" + kadir.Text + ")" + ")" + " Mod 256)" + vbCrLf + "Dim " + necati.Text + " As Char = " + yusuf.Text + ".Substring(" + adnan.Text + " - 1, 1).ToCharArray()(0)" + vbCrLf + ferhat.Text + " =" + " Asc(" + necati.Text + ")" + vbCrLf + "Dim " + timur.Text + " As Integer = " + ferhat.Text + " " + "Xor " + burak.Text + vbCrLf + ahmet.Text + ".Append(Chr(" + timur.Text + ")" + ")" + vbCrLf + "System.Math.Max(System.Threading.Interlocked.Increment(" + adnan.Text + "), " + adnan.Text + " - 1)" + vbCrLf + "End While" + vbCrLf + faruk.Text + " =" + " " + ahmet.Text + ".ToString" + vbCrLf + ahmet.Text + ".Length = 0" + vbCrLf + "Return " + faruk.Text + vbCrLf + "End Function"
Kopyala Kodum;
C#:
Clipboard.Clear()
Clipboard.SetText(TextBox1.Text)
MsgBox("Başarı İle Kopyalandı.", MsgBoxStyle.Information, "Sistem")
Demo Form Tasarım Örneği;
Konu Devam Ediyor...
Konu Devam Ediyor...