Advertisement
maat7043

Compare.VB

Apr 25th, 2014
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 31.39 KB | None | 0 0
  1. Imports System
  2. Imports System.IO
  3. Imports System.Threading
  4. Imports System.Threading.Tasks
  5. Imports System.Security.Cryptography
  6. Imports System.Text.RegularExpressions
  7.  
  8. Public Class Compare
  9.     ' Initialize Variables
  10.     Dim Folder As String = Application.StartupPath & "/RABCDasm"
  11.     Dim Compare As String = Application.StartupPath & "/Compare"
  12.  
  13.     Dim OldFiles As String()
  14.     Dim NewFiles As String()
  15.  
  16.     Dim swfok As Boolean = False
  17.     ' Client 1 Selection
  18.     Private Sub Client1(sender As System.Object, e As System.EventArgs) Handles Button2.Click
  19.         Dim fd As OpenFileDialog = New OpenFileDialog()
  20.         Dim strFileName As String
  21.         fd.Title = "Open File Dialog"
  22.         fd.InitialDirectory = Application.StartupPath & "/Clients"
  23.         fd.Filter = "Shockwave Flash Objects (*.swf)|*.*"
  24.         fd.FilterIndex = 2
  25.         fd.RestoreDirectory = True
  26.  
  27.         If fd.ShowDialog() = DialogResult.OK Then
  28.             strFileName = fd.FileName
  29.             If InStr(strFileName, ".swf") <> 0 Then
  30.                 TextBox2.Text = strFileName
  31.                 swfok = True
  32.             Else
  33.                 MessageBox.Show("You have to pick a .swf silly...")
  34.             End If
  35.         End If
  36.     End Sub
  37.     'Client 2 Selector
  38.     Private Sub Client2(sender As System.Object, e As System.EventArgs) Handles Button3.Click
  39.         Dim fd As OpenFileDialog = New OpenFileDialog()
  40.         Dim strFileName As String
  41.         fd.Title = "Open File Dialog"
  42.         fd.InitialDirectory = Application.StartupPath & "/Clients"
  43.         fd.Filter = "Shockwave Flash Objects (*.swf)|*.*"
  44.         fd.FilterIndex = 2
  45.         fd.RestoreDirectory = True
  46.  
  47.         If fd.ShowDialog() = DialogResult.OK Then
  48.             strFileName = fd.FileName
  49.             If InStr(strFileName, ".swf") <> 0 Then
  50.                 TextBox1.Text = strFileName
  51.                 swfok = True
  52.             Else
  53.                 MessageBox.Show("You have to pick a .swf silly...")
  54.             End If
  55.         End If
  56.     End Sub
  57.     ' Decompile Client
  58.     Private Sub Decompile()
  59.         Dim FILE_NAME As String = Folder & "\decompile.bat"
  60.         Dim aryText(4) As String
  61.         aryText(0) = "cd " & Folder
  62.         aryText(1) = "swfdecompress client.swf"
  63.         aryText(2) = "abcexport client.swf"
  64.         aryText(3) = "rabcdasm client-1.abc"
  65.         Create_Batch(aryText, FILE_NAME)
  66.     End Sub
  67.     ' Recompile SWF
  68.     Private Sub Recompile()
  69.         Dim FILE_NAME As String = Folder & "\recompile.bat"
  70.         Dim aryText(3) As String
  71.         aryText(0) = "cd " & Folder
  72.         aryText(1) = "rabcasm client-1\client-1.main.asasm"
  73.         aryText(2) = "abcreplace client.swf 1 client-1\client-1.main.abc"
  74.         Create_Batch(aryText, FILE_NAME)
  75.     End Sub
  76.     ' Create And Run Batch Files
  77.     Public Sub Create_Batch(aryText() As String, FileName As String)
  78.         Dim objWriter As New System.IO.StreamWriter(FileName, False)
  79.         For i = 0 To aryText.Length - 1
  80.             objWriter.WriteLine(aryText(i))
  81.         Next
  82.         objWriter.Close()
  83.  
  84.         Dim Process As New Process
  85.         Dim ps As New ProcessStartInfo(FileName)
  86.         ps.RedirectStandardError = True
  87.         ps.RedirectStandardOutput = True
  88.         ps.CreateNoWindow = False
  89.         ps.WindowStyle = ProcessWindowStyle.Hidden
  90.         ps.UseShellExecute = False
  91.         Process.StartInfo = ps
  92.         Process.Start()
  93.         Process.WaitForExit()
  94.     End Sub
  95.     ' Remove Junk Code
  96.     Private Sub Deobf(Path As String)
  97.         ' Copy over RABCDasm and the swf
  98.         My.Computer.FileSystem.CopyFile(Path, Folder & "\client.swf", True)
  99.  
  100.         ' Decompile the swf
  101.         Decompile()
  102.  
  103.         ' Create an Array containing all of the files in the */client-1 directory
  104.         Dim Classes As String() = Directory.GetFiles(Folder, "*.class.asasm", SearchOption.AllDirectories)
  105.  
  106.         ' Loop Through Every Single file from top to bottom
  107.         Parallel.For(0, Classes.Length, Sub(i)
  108.                                             ' Create a Streamreader to read through each file
  109.  
  110.                                             '' Create Dummy file to be filed, copied in, and deleted
  111.                                             Dim NewFile As String = Folder & "/Temp" & i & ".class.asasm"
  112.                                             '' Path to current file in loop
  113.                                             Dim MyFile As String = Classes(i)
  114.  
  115.                                             '' Loop Variables
  116.                                             Dim CurrentLine As String = ""
  117.                                             Dim LinetoWrite As String = ""
  118.                                             Dim Count As Integer = 0
  119.  
  120.                                             '' Deobf Logic Variables
  121.                                             Dim BoolArray(2) As String
  122.                                             Dim LocalArray(2) As String
  123.                                             Dim InCodeBlock As Boolean = False
  124.                                             Dim TwoSetLocals As Integer = 0
  125.                                             Dim HitaLocal As Boolean = False
  126.                                             Dim LocalHit As Integer = 0
  127.                                             Dim JumpLine As String = "EMPTY"
  128.  
  129.                                             Dim RndFile As String = Folder & "/RndFile" & i & ".class.asasm"
  130.                                             Dim RndWriter As StreamWriter
  131.                                             Dim RndJump As Boolean = False
  132.                                             Dim RndLine As String = "EMPTY"
  133.  
  134.                                             '' Readerwriter Combo to read and write lines as it goes
  135.  
  136.                                             '' Loop 1: Check for Random Jumps
  137.                                             Using sr As StreamReader = New StreamReader(MyFile)
  138.                                                 Using sw As StreamWriter = New StreamWriter(NewFile, False)
  139.                                                     CurrentLine = sr.ReadLine
  140.                                                     Do While (Not CurrentLine Is Nothing)
  141.                                                         LinetoWrite = CurrentLine
  142.  
  143.                                                         If CurrentLine.Contains(" code") Then
  144.                                                             ' Begining of Code Body
  145.                                                             If CurrentLine.Contains("tracking") Then
  146.                                                                 sw.WriteLine(LinetoWrite)
  147.  
  148.                                                             ElseIf Not CurrentLine.Contains("end") Then
  149.                                                                 sw.WriteLine(LinetoWrite)
  150.                                                                 InCodeBlock = True
  151.                                                                 Count = 0
  152.  
  153.                                                                 ' End of Code Block
  154.                                                             Else
  155.                                                                 InCodeBlock = False
  156.                                                                 If RndJump = True Then
  157.                                                                     RndWriter.Close()
  158.                                                                     sw.WriteLine(File.ReadAllText(RndFile))
  159.                                                                     RndLine = "EMPTY"
  160.                                                                     RndJump = False
  161.                                                                 End If
  162.                                                                 sw.WriteLine(LinetoWrite)
  163.                                                             End If
  164.  
  165.                                                             ' Check to See if you are in a code block
  166.                                                         ElseIf InCodeBlock = True Then
  167.                                                             ' Check to see if you are in a jump segment
  168.                                                             If RndJump = True Then
  169.                                                                 ' Check to see if your jumpline is hit
  170.                                                                 '' Check first to see if you made it all the way to the jump without hitting another LXX:
  171.                                                                 If CurrentLine.Contains(RndLine) Then
  172.                                                                     RndJump = False
  173.                                                                     RndLine = "EMPTY"
  174.                                                                     RndWriter.Close()
  175.                                                                     sw.WriteLine(LinetoWrite)
  176.  
  177.                                                                     '' Check to see if the jump is not junk
  178.                                                                 ElseIf CurrentLine.Contains(":") Then
  179.                                                                     RndWriter.WriteLine(CurrentLine)
  180.                                                                     RndWriter.Close()
  181.                                                                     sw.WriteLine(File.ReadAllText(RndFile))
  182.                                                                     RndLine = "EMPTY"
  183.                                                                     RndJump = False
  184.  
  185.                                                                     '' Check for sequential real/fake jumps
  186.                                                                 ElseIf CurrentLine.Contains("jump") Then
  187.                                                                     RndWriter.Close()
  188.                                                                     sw.WriteLine(File.ReadAllText(RndFile))
  189.                                                                     RndLine = "L" & CurrentLine.Split("L")(1) & ":"
  190.                                                                     RndWriter = New StreamWriter(RndFile, False)
  191.                                                                     RndWriter.WriteLine(CurrentLine)
  192.                                                                 Else
  193.                                                                     '' If neither continue to fill your streamwriter just in case
  194.                                                                     RndWriter.WriteLine(CurrentLine)
  195.                                                                 End If
  196.  
  197.  
  198.                                                                 ' Check to see if a new jump segment is initiated  
  199.                                                             ElseIf CurrentLine.Contains("jump") Then
  200.                                                                 RndJump = True
  201.                                                                 RndLine = "L" & CurrentLine.Split("L")(1) & ":"
  202.                                                                 RndWriter = New StreamWriter(RndFile, False)
  203.                                                                 RndWriter.WriteLine(CurrentLine)
  204.  
  205.                                                                 ' Not in a jump Segment or starting a new one
  206.                                                             Else
  207.                                                                 sw.WriteLine(LinetoWrite)
  208.                                                             End If
  209.  
  210.                                                         Else
  211.                                                             ' Write Currentline back if you are not in a code block
  212.                                                             sw.WriteLine(LinetoWrite)
  213.                                                         End If
  214.  
  215.                                                         Count = Count + 1
  216.                                                         CurrentLine = sr.ReadLine
  217.                                                     Loop
  218.                                                 End Using
  219.                                             End Using
  220.  
  221.                                             ' Copy File Back into client-1 Directory
  222.                                             My.Computer.FileSystem.CopyFile(NewFile, MyFile, True)
  223.  
  224.                                             Count = 0
  225.  
  226.                                             '' Loop 2: all other deobfuscation
  227.                                             Using sr As StreamReader = New StreamReader(MyFile)
  228.                                                 Using sw As StreamWriter = New StreamWriter(NewFile, False)
  229.                                                     CurrentLine = sr.ReadLine
  230.                                                     Do While (Not CurrentLine Is Nothing)
  231.                                                         LinetoWrite = CurrentLine
  232.  
  233.                                                         If CurrentLine.Contains(" code") Then
  234.                                                             ' Begining of Code Body
  235.                                                             If CurrentLine.Contains("tracking") Then
  236.                                                                 sw.WriteLine(LinetoWrite)
  237.                                                             ElseIf Not CurrentLine.Contains("end") Then
  238.                                                                 sw.WriteLine(LinetoWrite)
  239.                                                                 InCodeBlock = True
  240.                                                                 ' Reset Count
  241.                                                                 Count = 0
  242.                                                                 TwoSetLocals = 0
  243.  
  244.                                                                 ' End of Code Block
  245.                                                             Else
  246.                                                                 InCodeBlock = False
  247.                                                             End If
  248.                                                         End If
  249.  
  250.                                                         ' Check to See if you are in a code block
  251.                                                         If InCodeBlock = True Then
  252.                                                             ' Write first two line of each code block to the Boolean Array
  253.                                                             If Count = 1 Then
  254.                                                                 If Not CurrentLine.Contains("push") Then
  255.                                                                     InCodeBlock = False
  256.                                                                     sw.WriteLine(LinetoWrite)
  257.                                                                 Else
  258.                                                                     BoolArray(0) = CurrentLine
  259.                                                                 End If
  260.  
  261.                                                             ElseIf Count = 2 Then
  262.                                                                 BoolArray(1) = CurrentLine
  263.  
  264.                                                             ElseIf Not TwoSetLocals = 2 Then
  265.                                                                 ' Check for a swap
  266.                                                                 If CurrentLine.Contains("swap") Then
  267.                                                                     Dim Temp As String = BoolArray(0)
  268.                                                                     BoolArray(0) = BoolArray(1)
  269.                                                                     BoolArray(1) = Temp
  270.                                                                 End If
  271.                                                                 ' Write first two set locals to an array
  272.                                                                 If CurrentLine.Contains("set") Then
  273.                                                                     TwoSetLocals = TwoSetLocals + 1
  274.                                                                     LocalArray(TwoSetLocals - 1) = CurrentLine.Replace("set", "get")
  275.                                                                 End If
  276.  
  277.                                                             ElseIf HitaLocal = True Then
  278.                                                                 ' Check to see if its an iffalse jump
  279.                                                                 If CurrentLine.Contains("iffalse") Then
  280.                                                                     ' Check for a match
  281.                                                                     If BoolArray(LocalHit).Contains("false") Then
  282.                                                                         CurrentLine.Replace("false", "")
  283.                                                                         JumpLine = "L" & CurrentLine.Split("L")(1) & ":"
  284.                                                                     Else
  285.                                                                         JumpLine = "L" & CurrentLine.Split("L")(1) & ":"
  286.                                                                         HitaLocal = False
  287.                                                                     End If
  288.                                                                 End If
  289.                                                                 ' Check to see if its an iffalse jump
  290.                                                                 If CurrentLine.Contains("iftrue") Then
  291.                                                                     ' Check for a match
  292.                                                                     If BoolArray(LocalHit).Contains("true") Then
  293.                                                                         JumpLine = "L" & CurrentLine.Split("L")(1) & ":"
  294.                                                                     Else
  295.                                                                         JumpLine = "L" & CurrentLine.Split("L")(1) & ":"
  296.                                                                         HitaLocal = False
  297.                                                                     End If
  298.                                                                 End If
  299.  
  300.                                                                 'Check to see if first register is checked against
  301.                                                             ElseIf CurrentLine.Contains(LocalArray(0)) Then
  302.                                                                 HitaLocal = True
  303.                                                                 LocalHit = 1
  304.  
  305.                                                                 ' Check to see if Second Register is checked against
  306.                                                             ElseIf CurrentLine.Contains(LocalArray(1)) Then
  307.                                                                 HitaLocal = True
  308.                                                                 LocalHit = 0
  309.  
  310.                                                                 ' Check for label from past if*** check
  311.                                                             ElseIf CurrentLine.Contains(JumpLine) Then
  312.                                                                 HitaLocal = False
  313.                                                                 sw.WriteLine(LinetoWrite)
  314.  
  315.                                                                 ' Write Good Code
  316.                                                             Else
  317.                                                                 sw.WriteLine(LinetoWrite)
  318.                                                             End If
  319.  
  320.                                                         Else
  321.                                                             ' Write Currentline back if you are not in a code block
  322.                                                             sw.WriteLine(LinetoWrite)
  323.                                                         End If
  324.  
  325.                                                         Count = Count + 1
  326.                                                         CurrentLine = sr.ReadLine
  327.                                                     Loop
  328.                                                 End Using
  329.                                             End Using
  330.                                             ' Copy File Back into client-1 Directory
  331.                                             My.Computer.FileSystem.CopyFile(NewFile, MyFile, True)
  332.                                         End Sub)
  333.  
  334.         ' Recompile
  335.         Recompile()
  336.  
  337.         ' Remove old client-1
  338.         My.Computer.FileSystem.DeleteDirectory(Folder & "/client-1", FileIO.DeleteDirectoryOption.DeleteAllContents)
  339.         My.Computer.FileSystem.DeleteFile(Folder & "/client-1.abc")
  340.  
  341.         ' Decompile Again
  342.         Decompile()
  343.     End Sub
  344.     ' Compare Clients
  345.     Private Sub CompareClients(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  346.         If TextBox1.Text = "" Then
  347.             MessageBox.Show("You have to pick a .swf...")
  348.         ElseIf TextBox2.Text = "" Then
  349.             MessageBox.Show("You have to pick a .swf...")
  350.         ElseIf swfok = False Then
  351.             MessageBox.Show("You have to pick a .swf...")
  352.         Else
  353.             ' Change Cursor
  354.             Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
  355.             Try
  356.                 ' Create Directory for Process
  357.                 If My.Computer.FileSystem.DirectoryExists(Compare) Then
  358.                     My.Computer.FileSystem.DeleteDirectory(Compare, FileIO.DeleteDirectoryOption.DeleteAllContents)
  359.                 End If
  360.             Catch
  361.                 MessageBox.Show("You Need to Close File Explorer")
  362.                 Me.Cursor = System.Windows.Forms.Cursors.Default
  363.                 Exit Sub
  364.             End Try
  365.  
  366.             ' Deobfuscate Old Client
  367.             Deobf(TextBox1.Text)
  368.  
  369.             ' Move and Clean
  370.             My.Computer.FileSystem.CopyDirectory(Folder & "/client-1", Compare & "/Old")
  371.             My.Computer.FileSystem.DeleteDirectory(Folder, FileIO.DeleteDirectoryOption.DeleteAllContents)
  372.  
  373.             ' Deobfuscate New Client
  374.             Deobf(TextBox2.Text)
  375.  
  376.             ' Move and Clean
  377.             My.Computer.FileSystem.CopyDirectory(Folder & "/client-1", Compare & "/New")
  378.             My.Computer.FileSystem.DeleteDirectory(Folder, FileIO.DeleteDirectoryOption.DeleteAllContents)
  379.  
  380.  
  381.             ' Create an Array containing all of the files in the */client-1 directory
  382.             Dim Classes As String() = Directory.GetFiles(Folder & "/client1-1", "*.class.asasm", SearchOption.AllDirectories)
  383.             Dim BoolArray(Classes.Length) As Boolean
  384.             ' Loop Through Every Single file from top to bottom
  385.             For i = 0 To Classes.Length - 1
  386.                 BoolArray(i) = CompareFiles(Classes(i), Classes(i).Replace("client1", "client2"))
  387.                 If BoolArray(i) = False Then
  388.                     Dim CurrentLine As String = ""
  389.                     Using sr As StreamReader = New StreamReader(Classes(i))
  390.                         Using sw As StreamWriter = New StreamWriter(Folder & "/Temp.txt")
  391.                             CurrentLine = sr.ReadLine
  392.                             Do While (Not CurrentLine Is Nothing)
  393.                                 Dim LinetoWrite = CurrentLine
  394.  
  395.                                 sw.WriteLine(LinetoWrite.Replace("#1", "#0").Replace("#2", "0"))
  396.                                 CurrentLine = sr.ReadLine
  397.                             Loop
  398.                         End Using
  399.                     End Using
  400.  
  401.                     My.Computer.FileSystem.CopyFile(Folder & "/Temp.txt", Classes(i), True)
  402.                     My.Computer.FileSystem.DeleteFile(Folder & "/Temp.txt")
  403.  
  404.                     Using sr As StreamReader = New StreamReader(Classes(i).Replace("client1", "client2"))
  405.                         Using sw As StreamWriter = New StreamWriter(Folder & "/Temp.txt")
  406.                             CurrentLine = sr.ReadLine
  407.                             Do While (Not CurrentLine Is Nothing)
  408.                                 Dim LinetoWrite = CurrentLine
  409.  
  410.                                 sw.WriteLine(LinetoWrite.Replace("#1", "#0").Replace("#2", "0"))
  411.                                 CurrentLine = sr.ReadLine
  412.                             Loop
  413.                         End Using
  414.                     End Using
  415.  
  416.                     My.Computer.FileSystem.CopyFile(Folder & "/Temp.txt", Classes(i).Replace("client1", "client2"), True)
  417.                     My.Computer.FileSystem.DeleteFile(Folder & "/Temp.txt")
  418.                 End If
  419.                 BoolArray(i) = CompareFiles(Classes(i), Classes(i).Replace("client1", "client2"))
  420.             Next
  421.  
  422.  
  423.             ' Write Files that do not match to a .txt file
  424.             Dim MyFile As String = Application.StartupPath & "/DifferentClasses.txt"
  425.  
  426.             If My.Computer.FileSystem.FileExists(MyFile) Then
  427.                 My.Computer.FileSystem.DeleteFile(MyFile)
  428.             End If
  429.  
  430.             Dim Info As StreamWriter
  431.             Info = File.AppendText(MyFile)
  432.             Info.WriteLine("Classes that are not the same:")
  433.             Info.WriteLine("")
  434.             Dim Count = 0
  435.             For i = 0 To Classes.Length - 1
  436.                 If BoolArray(i) = False Then
  437.                     Info.WriteLine(Classes(i))
  438.                 End If
  439.             Next
  440.             Info.Flush()
  441.             Info.Close()
  442.  
  443.             My.Computer.FileSystem.DeleteDirectory(Folder, FileIO.DeleteDirectoryOption.DeleteAllContents)
  444.             Me.Cursor = System.Windows.Forms.Cursors.Default
  445.             MessageBox.Show("Comparison Complete!", "Finished", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  446.             Me.Activate()
  447.             Process.Start(MyFile)
  448.         End If
  449.     End Sub
  450.     ' Check Hashes
  451.     Public Function CompareFiles(ByVal FileFullPath1 As String, _
  452.     ByVal FileFullPath2 As String) As Boolean
  453.  
  454.         'returns true if two files passed to is are identical, false
  455.         'otherwise
  456.  
  457.         'does byte comparison; works for both text and binary files
  458.  
  459.         'Throws exception on errors; you can change to just return
  460.         'false if you prefer
  461.  
  462.  
  463.         Dim objMD5 As New MD5CryptoServiceProvider()
  464.         Dim objEncoding As New System.Text.ASCIIEncoding()
  465.  
  466.         Dim aFile1() As Byte, aFile2() As Byte
  467.         Dim strContents1, strContents2 As String
  468.         Dim objReader As StreamReader
  469.         Dim objFS As FileStream
  470.         Dim bAns As Boolean
  471.         If Not File.Exists(FileFullPath1) Then _
  472.             Throw New Exception(FileFullPath1 & " doesn't exist")
  473.         If Not File.Exists(FileFullPath2) Then _
  474.          Throw New Exception(FileFullPath2 & " doesn't exist")
  475.  
  476.         Try
  477.  
  478.             objFS = New FileStream(FileFullPath1, FileMode.Open)
  479.             objReader = New StreamReader(objFS)
  480.             aFile1 = objEncoding.GetBytes(objReader.ReadToEnd)
  481.             strContents1 = _
  482.               objEncoding.GetString(objMD5.ComputeHash(aFile1))
  483.             objReader.Close()
  484.             objFS.Close()
  485.  
  486.  
  487.             objFS = New FileStream(FileFullPath2, FileMode.Open)
  488.             objReader = New StreamReader(objFS)
  489.             aFile2 = objEncoding.GetBytes(objReader.ReadToEnd)
  490.             strContents2 = _
  491.              objEncoding.GetString(objMD5.ComputeHash(aFile2))
  492.  
  493.             bAns = strContents1 = strContents2
  494.             objReader.Close()
  495.             objFS.Close()
  496.             aFile1 = Nothing
  497.             aFile2 = Nothing
  498.  
  499.         Catch ex As Exception
  500.             Throw ex
  501.  
  502.         End Try
  503.  
  504.         Return bAns
  505.     End Function
  506.  
  507.     Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
  508.         ' Create a pair of filename arrays
  509.         OldFiles = Directory.GetFiles(Compare & "/Old", "*.class.asasm", SearchOption.AllDirectories)
  510.         NewFiles = Directory.GetFiles(Compare & "/New", "*.class.asasm", SearchOption.AllDirectories)
  511.  
  512.         Parallel.For(0, NewFiles.Length, Sub(i)
  513.                                              ' Create a Streamreader to read through each file
  514.  
  515.                                              '' Create Dummy file to be filed, copied in, and deleted
  516.                                              Dim NewFile As String = Compare & "/Temp" & i & ".class.asasm"
  517.                                              '' Path to current file in loop
  518.                                              Dim MyFile As String = NewFiles(i)
  519.  
  520.                                              '' Loop Variables
  521.                                              Dim CurrentLine As String = ""
  522.                                              Dim LinetoWrite As String = ""
  523.  
  524.                                              Using sr As StreamReader = New StreamReader(NewFiles(i))
  525.                                                  Using sw As StreamWriter = New StreamWriter(NewFile)
  526.                                                      CurrentLine = sr.ReadLine
  527.                                                      Do While (Not CurrentLine Is Nothing)
  528.                                                          ' Make Macros all the same
  529.                                                          CurrentLine = CurrentLine.Replace("#1", "#0").Replace("#2", "#0")
  530.  
  531.                                                          'Define Regex Cases
  532.                                                          Dim name_ As Regex = New Regex("[-!$%^&*()+|~=`{}\[\]:"""";'<>?,.\/]_-([a-z][A-Z][0-9][-][\s])+[-!$%^&*()+|~=`{}\[\]:"""";'<>?,.\/]")
  533.                                                          Dim RegCheck As Boolean = False
  534.                                                          Dim Match As Match
  535.  
  536.                                                          ' Change names_
  537.                                                          Do While RegCheck = False
  538.                                                              Match = name_.Match(CurrentLine)
  539.                                                              If Match.Success = True Then
  540.                                                                  CurrentLine = CurrentLine.Replace(Match.Value, Match.Value.Chars(0) & "$$$" & Match.Value.Chars(Match.Value.Length - 1))
  541.                                                                  MessageBox.Show(CurrentLine)
  542.                                                              Else
  543.                                                                  RegCheck = True
  544.                                                              End If
  545.                                                          Loop
  546.  
  547.                                                          LinetoWrite = CurrentLine
  548.                                                          sw.WriteLine(LinetoWrite)
  549.                                                          CurrentLine = sr.ReadLine
  550.                                                      Loop
  551.                                                  End Using
  552.                                              End Using
  553.  
  554.                                          End Sub)
  555.     End Sub
  556. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement