r/visualbasic • • Feb 21 '20

VB.NET Help DecryptString and write in plaintext to text file

Full disclosure, this is to help with me a coding challenge from HTB that has bugged me for days. Other than a bit of VB 10 years ago I'm a complete newbie.

What do i need to add/edit to the following to get it to decrypt the string and write the result in plaintext to a text file? Grateful for any help.

Public Shared Function DecryptString(pTEzAfYDoz1YzkqhQkH6GQFYKp1XY5hm7bjOP86yYxE=) As String

If String.IsNullOrEmpty(EncryptedString) Then

Return String.Empty

Else

Return Decrypt(EncryptedString, "13st22", "28552299", 2, "364R5DFA5DL6LE28", 256)

End If

End Function

5 Upvotes

1 comment sorted by

5

u/TheFotty Feb 21 '20

Two things I see here are that

  1. Your function declaration is wrong, because your actual function definition looks like it has the actual variable argument in it.

Meaning a normal function might look like

Public Shared Function DecryptString(EncryptedString as String) as String
    'Do Stuff
End Function

and called like

Dim myResult = DecryptString("pTEzAfYDoz1YzkqhQkH6GQFYKp1XY5hm7bjOP86yYxE=")

So you can probably see from what I wrote and what you have how your function is not properly declared. You put the actual value you want to pass into it in the declaration instead of EncryptedString.

The second thing is that you have

Return Decrypt(EncryptedString, "13st22", "28552299", 2, "364R5DFA5DL6LE28", 256)

Which isn't wrong from a syntax standpoint, but it is not defined in the code you posted, so we can't tell what the Decrypt is doing when called.