
Given that this is a Fileless attack there is no hash reputation available via third party validation tools. In this case, we have an alert regarding a PowerShell command. First, we take a look at an attack sequence the first place I always look (if the process is there) will be PowerShell: So let’s see how this could help us to understand an actual attack on the network. ::ASCII.GetString(::FromBase64String($coded_string)) | Out-File -Encoding "ASCII" base64_out.txt ::ASCII.GetString(::FromBase64String($coded_string)) $coded_string = "SG9va2VkIG9uIHBob25pY3Mgd29ya2VkIGZvciBtZQo="
#Base64 decode linux code#
> ::UTF8.GetString(::FromBase64String('SG9va2VkIG9uIHBob25pY3Mgd29ya2VkIGZvciBtZQo='))Īs we did with Python above, we can replace the one-liner CLI with a PowerShell script if we wish: # Replace the quoted text with the code you wish to decrypt. We can swap out ASCII for UTF-8 if we prefer: > ::ASCII.GetString(::FromBase64String('SG9va2VkIG9uIHBob25pY3Mgd29ya2VkIGZvciBtZQo='))

# Print the decryption output to the screen. # Replace the quoted text with the code you wish to decrypt.Ĭoded_string = 'SG9va2VkIG9uIHBob25pY3Mgd29ya2VkIGZvciBtZQo='Ĭode_dump = base64.b64decode(coded_string) We can achieve the same thing with a Python script like this: #!/usr/bin/env python $: echo "SG9va2VkIG9uIHBob25pY3Mgd29ya2VkIGZvciBtZQo=" | base64 -decode On macOS/Linux with Bash (CLI) it’s the same process, but this time we specify the -decode option: SG9va2VkIG9uIHBob25pY3Mgd29ya2VkIGZvciBtZQo= Decoding Strings > ::ToBase64String(::UTF8.GetBytes("Hooked on phonics worked for me")) On Windows, we can encode a string with PowerShell (CLI): $: echo "Hooked on phonics worked for me" | base64 On macOS/Linux with Bash (CLI) we can simply echo the target string and pipe it to the base64 utility: Let’s take a look at not only decrypting but also encrypting because, who knows? Maybe one day you will need or want to know both sides of the process.

They are also widely used by malware authors to disguise their attacks and to implement anti-analysis techniques designed to frustrate malware hunters and reverse engineers.

Encoded strings are everywhere and have many legitimate uses across the technology sector.
