Skip to content

Instantly share code, notes, and snippets.

@netspooky
Last active February 27, 2022 00:54
Show Gist options
  • Save netspooky/ef9de02485cb3cc136314d01cd504c2e to your computer and use it in GitHub Desktop.
Save netspooky/ef9de02485cb3cc136314d01cd504c2e to your computer and use it in GitHub Desktop.
Quickly create permutations of fragmented base64
import sys, base64, hexdump, textwrap
from itertools import permutations
# pip3 install textwrap hexdump
# Create file full of base64 fragments, each one on a new line
# Usage:
# python3 debaser.py <file>
def getLines():
with open(sys.argv[1],"r") as f:
pieces = []
lines = f.readlines()
for line in lines:
#print(line.strip("\n"))
pieces.append(line.strip("\n"))
return pieces
linez = getLines()
print("Finding Permutations in {}".format(sys.argv[1]))
print("\033[0;33;40m"+"-"*80+"\033[0m")
perm = permutations(linez, len(linez))
for i in list(perm):
try:
ii = ''.join(list(i))
data = base64.b64decode(ii)
print("\033[0;32;40m")
print(" \033[0m\n\033[0;32;40m".join(textwrap.wrap(ii,80)))
print("\033[0m")
hexdump.hexdump(data)
print("\n\033[0;33;40m"+"-"*80+"\033[0m")
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment