mirror of https://github.com/netspooky/b64mute.git
Initial
This commit is contained in:
parent
11f4531e80
commit
b3ee8ce119
|
@ -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
|
||||||
|
|
|
@ -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))
|
||||||
|
|
Loading…
Reference in New Issue