├── LICENSE ├── README.md └── b64mute.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 【☆ ゆう ☆ 】 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # b64mute - Base64 Mutator 2 | 3 | This program applies simple mutations to base64 encoded strings for obfuscation purposes. It applies an uneven chunk approach to concatenate arbitrary chunks with padding. 4 | 5 | For more info read [this writeup](https://n0.lol/encmute/)! 6 | 7 | ## Usage ## 8 | 9 | Generate a mutation from a string 10 | 11 | $ python3 b64mute.py -d "netspooky" 12 | bmU=dHNwb28=a3k= 13 | 14 | Generate a mutation on a file: 15 | 16 | $ python3 b64mute.py -f test.txt 17 | aA==dHQ=cHM6Ly90d2k=dHRlcg==Lg==Y28=bS8=bg==ZQ==dA==c3Bvb2t5 18 | 19 | Save the output to a file: 20 | 21 | $ python3 b64mute.py -d "admin:hunter2" -o out.txt 22 | 23 | Test your string: 24 | 25 | $ base64 -d <<< "bmU=dHNwb28=a3k=" 26 | netspooky 27 | 28 | -------------------------------------------------------------------------------- /b64mute.py: -------------------------------------------------------------------------------- 1 | import base64 2 | import argparse 3 | from random import randrange 4 | 5 | parser = argparse.ArgumentParser(description='Base64 Mutator') 6 | parser.add_argument('-d', dest='indata', help='Input data (string)') 7 | parser.add_argument('-f', dest='infile', help='Input file') 8 | parser.add_argument('-o', dest='outfile', help='Output file') 9 | 10 | def doEncode(mBytes): 11 | b64Bytes = base64.b64encode(mBytes) 12 | return b64Bytes 13 | 14 | def openFile(filename): 15 | with open(filename, "rb") as f: 16 | fileobj = f.read() 17 | return fileobj 18 | 19 | if __name__ == '__main__': 20 | args = parser.parse_args() 21 | indata = args.indata 22 | infile = args.infile 23 | outfile = args.outfile 24 | 25 | outmsg = b'' # This will hold the base64 object 26 | 27 | if indata: 28 | data2enc = indata 29 | data2enc_bytes = data2enc.encode('utf-8') # Convert to bytes object 30 | elif infile: 31 | data2enc = openFile(infile) 32 | data2enc_bytes = data2enc # It's already a bytes object here 33 | 34 | msgLen = len(data2enc_bytes) 35 | x = 0 36 | while x < msgLen: 37 | chunkSize = randrange(1,4) 38 | outmsg += doEncode(data2enc_bytes[x:x+chunkSize]) 39 | x = x + chunkSize 40 | if outfile: # We write to file 41 | f = open(outfile, 'wb') 42 | f.write(outmsg) 43 | f.close() 44 | else: # Otherwise write to stdout 45 | b64Enc = outmsg.decode('utf-8') 46 | print("{}".format(b64Enc)) 47 | 48 | --------------------------------------------------------------------------------