Need Help With Displaying Strings After Wild Card Symbols

    General discussion

  • I have been working on a project. I need to know how to make my program read text information from a text document hash table and be able to only show the text on the end portion. This text document is in the following format:

    MD5 Hash Here:Byte Size Here:Alphanumeric String/Name Here



    I need to have the text on the end to display the word as a Label or in a listbox.

    The ":" is the wildcard symbol I wish to use. I'm not sure how to declare the above format into three separate parts. I have

    looked at some tutorials on strings and concatenation but can't figure this out. Below is the following code:

    Private Sub btnBrowse_Click(sender As Object, e As EventArgs) Handles btnCustomScanFile.Click
            If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                Dim path As String = OpenFileDialog1.FileName
                txtFilePath.Text = path
                Dim sample As String
                sample = md5_hash(path)
                txtMD5Hash.Text = md5_hash(path)
                Using f As System.IO.FileStream = System.IO.File.OpenRead("md5.txt")
                    Using s As System.IO.StreamReader = New System.IO.StreamReader(f)
                        While Not s.EndOfStream
                            Dim line As String = s.ReadLine
                            If (line = sample) Then
                                lblResult.Text = "Infected!"
                                lblResult.ForeColor = Color.Red
                                lblResult.Text = "Clean!"
                                lblResult.ForeColor = Color.Green
                            End If
                        End While
                    End Using
                End Using
            End If
        End Sub
    End Class

    I just want to output/print the ending part "Backdoor.ASP.Ace.a"as a string without the text to the left of it. If anyone can help me it would be greatly appreciated.

    • Edited by Brut3Forc3d Monday, November 21, 2016 12:43 AM
    Monday, November 21, 2016 12:42 AM

All replies

  • Hello Brut3Forc3d,

    Try this:

    Dim line As String = "Software/Microsoft/Windows/Run"
    Dim firstpart As String = line.Substring(0, line.IndexOf("/"))
    Dim lastpart As String = line.Substring(line.LastIndexOf("/") + 1)



    Monday, November 21, 2016 1:11 AM
  • I still can't seem to get it to work. I don't know if i am putting it in the wrong spot.
    Monday, November 21, 2016 1:26 AM
  • You can try to debug it step by step. Just add a breakpoint with F9 and see what's happening...

    Turn this:

    Dim lastpart As String = line.Substring(line.LastIndexOf("/") + 1)

    Into this:

    Dim LineLastPartIndex = line.LastIndexOf("/") + 1
    Dim lastpart As String = line.Substring(LineLastPartIndex)

    And try to step-by-step debug the result.



    Monday, November 21, 2016 1:37 AM
  • Thanks! It worked. Just trying to figure out how to display the middle piece now "byte size". 


    Monday, November 21, 2016 8:47 AM
  • Something like:

    Dim middle As String = line.Substring(line.IndexOf("/")+1, line.LastIndexOf("/") )

    This assumes you have a 3 part string only.


    Monday, November 21, 2016 9:52 AM