From b3ee8ce11975db1b5e159405116901103a638401 Mon Sep 17 00:00:00 2001 From: young thug Date: Fri, 12 Feb 2021 20:49:04 -0500 Subject: [PATCH] Initial --- README.md | 28 ++++++++++++++++++++++++++++ b64mute.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 README.md create mode 100644 b64mute.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..911aec4 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +# b64mute - Base64 Mutator + +This program applies simple mutations to base64 encoded strings for obfuscation purposes. It applies an uneven chunk approach to concatenate arbitrary chunks with padding. + +For more info read [this writeup](https://n0.lol/encmute/)! + +[Duck Duck Go](https://duckduckgo.com) +## Usage ## + +Generate a mutation from a string + + $ python3 b64mute.py -d "netspooky" + bmU=dHNwb28=a3k= + +Generate a mutation on a file: + + $ python3 b64mute.py -f test.txt + aA==dHQ=cHM6Ly90d2k=dHRlcg==Lg==Y28=bS8=bg==ZQ==dA==c3Bvb2t5 + +Save the output to a file: + + $ python3 b64mute.py -d "admin:hunter2" -o out.txt + +Test your string: + + $ base64 -d <<< "bmU=dHNwb28=a3k=" + netspooky + diff --git a/b64mute.py b/b64mute.py new file mode 100644 index 0000000..1780998 --- /dev/null +++ b/b64mute.py @@ -0,0 +1,47 @@ +import base64 +import argparse +from random import randrange + +parser = argparse.ArgumentParser(description='Base64 Mutator') +parser.add_argument('-d', dest='indata', help='Input data (string)') +parser.add_argument('-f', dest='infile', help='Input file') +parser.add_argument('-o', dest='outfile', help='Output file') + +def doEncode(mBytes): + b64Bytes = base64.b64encode(mBytes) + return b64Bytes + +def openFile(filename): + with open(filename, "rb") as f: + fileobj = f.read() + return fileobj + +if __name__ == '__main__': + args = parser.parse_args() + indata = args.indata + infile = args.infile + outfile = args.outfile + + outmsg = b'' # This will hold the base64 object + + if indata: + data2enc = indata + data2enc_bytes = data2enc.encode('utf-8') # Convert to bytes object + elif infile: + data2enc = openFile(infile) + data2enc_bytes = data2enc # It's already a bytes object here + + msgLen = len(data2enc_bytes) + x = 0 + while x < msgLen: + chunkSize = randrange(1,4) + outmsg += doEncode(data2enc_bytes[x:x+chunkSize]) + x = x + chunkSize + if outfile: # We write to file + f = open(outfile, 'wb') + f.write(outmsg) + f.close() + else: # Otherwise write to stdout + b64Enc = outmsg.decode('utf-8') + print("{}".format(b64Enc)) +