Windows Golang / Base64
Author | Thomas Roccia (fr0gger) |
Platform | Windows |
Language | Golang |
Technique | Base64 |
Description:
This Go program uses the Base64 encoding scheme to encode and decode a string. The program takes a single command line argument, which is the string to be encoded and decoded. The program first uses the base64 package to encode the string using the Standard encoding alphabet. The encoded string is then printed to the screen. The program then decodes the encoded string using the same alphabet, and prints the resulting decoded string to the screen. This example demonstrates how the Base64 encoding scheme can be used to encode and decode binary data in a compact and easily transmitted format. In the context of malware, this technique can be used to conceal payloads or encode network communication in order to avoid detection and analysis.
Code
package main
import (
"encoding/base64"
"fmt"
"os"
)
func main() {
arg1 := os.Args[1]
encoded := base64.StdEncoding.EncodeToString([]byte(arg1))
fmt.Println(encoded)
decoded, err := base64.StdEncoding.DecodeString(encoded)
if err != nil {
panic("error")
}
fmt.Println(string(decoded))
}
Created
September 12, 2020
Last Revised
April 22, 2024