Skip to content

Instantly share code, notes, and snippets.

@ProIntegritate
Created November 7, 2021 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ProIntegritate/7b6c7b4fb9a869cbe85c608fb4a6c598 to your computer and use it in GitHub Desktop.
Save ProIntegritate/7b6c7b4fb9a869cbe85c608fb4a6c598 to your computer and use it in GitHub Desktop.
CleanCommand
Public Function CleanCommand(ByVal sString As String) As String
' Cleans up commandline params that try to break up strings to bypass detection with ASCII > 127 and Nop characters like "^"
Dim sByteArray() As Byte = System.Text.Encoding.Default.GetBytes(sString)
Dim sResult As String = ""
For n = 0 To UBound(sByteArray)
If sByteArray(n) <= 127 And sByteArray(n) > 0 Then
sResult = sResult & Chr(sByteArray(n))
End If
Next
sByteArray = Nothing
Return sResult.Replace("^", "")
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment