Beispiel #1
0
def obfuscate_light(marshalled, layer):
    # crypt step
    crypted = layer.a(marshalled)

    hexed = to_hex(crypted)

    # template injection step
    template = open("template_light.py", "r").read()
    template = template.replace("__PAYLOAD_PLACEHOLDER__", hexed)
    template = template.replace("__DECRYPT_PLACEHOLDER__", layer.DECRYPT)

    template_compiled = compile(minify(template), "", "exec")

    # marshall step
    return marshal.dumps(template_compiled)
def obfuscate_light(marshalled, layer):
    # crypt step
    crypted = layer.a(marshalled)

    hexed = to_hex(crypted)

    # template injection step
    template = open("template_light.py", "r").read()
    template = template.replace("__PAYLOAD_PLACEHOLDER__", hexed)
    template = template.replace("__DECRYPT_PLACEHOLDER__", layer.DECRYPT)

    template_compiled = compile(minify(template), "", "exec")

    # marshall step
    return marshal.dumps(template_compiled)
Beispiel #3
0
def convert(filename):
    "Convert a Python script into C code."

    with open(filename) as file:
        code = minify(file.read())

    lines = [
        '.pushsection \\".debug_gdb_scripts\\", \\"MS\\",@progbits,1\\n\\',
        '.byte 4\\n\\', '.ascii \\"gdb.inlined-script\\\\n\\"\\n\\'
    ]

    for line in code.split("\n"):
        line = line.replace('"', '\\\\\\"')
        lines.append('.ascii \\"%s\\\\n\\"\\n\\' % line)

    lines += ['.byte 0\\n\\', '.popsection\\n\\']

    return 'asm("\\\n%s\n");' % "\n".join(lines)
def obfuscate(marshalled, layer=no_op_layer):
    # compress step
    compressed = compress(marshalled, 9)

    # crypt step
    crypted = layer.a(compressed)

    # hex step
    hexed = to_hex(crypted)

    # template injection step
    template = open("template.py", "r").read()
    template = template.replace("__PAYLOAD_PLACEHOLDER__", hexed)
    template = template.replace("__DECRYPT_PLACEHOLDER__", layer.DECRYPT)

    # template compile step
    if layer == bf_layer:  # minify fails on this heavily obfuscated py :(
        template_compiled = compile(template, "", "exec")
    else:
        template_compiled = compile(minify(template), "", "exec")

    # marshall step
    return marshal.dumps(template_compiled)
Beispiel #5
0
def obfuscate(marshalled, layer=no_op_layer):
    # compress step
    compressed = compress(marshalled, 9)

    # crypt step
    crypted = layer.a(compressed)

    # hex step
    hexed = to_hex(crypted)

    # template injection step
    template = open("template.py", "r").read()
    template = template.replace("__PAYLOAD_PLACEHOLDER__", hexed)
    template = template.replace("__DECRYPT_PLACEHOLDER__", layer.DECRYPT)

    # template compile step
    if layer == bf_layer:  # minify fails on this heavily obfuscated py :(
        template_compiled = compile(template, "", "exec")
    else:
        template_compiled = compile(minify(template), "", "exec")

    # marshall step
    return marshal.dumps(template_compiled)
builder = builder.replace("__PAYLOAD_PY__", to_hex(payload_f.read()))
payload_f.close()

byteplay_f = open("byteplay.py", "r")
builder = builder.replace("__BYTEPLAY_PY__", to_hex(byteplay_f.read()))
byteplay_f.close()

template_f = open("template_light.py", "r")
builder = builder.replace("__TEMPLATE_PY__", to_hex(template_f.read()))
template_f.close()

xor_layer_f = open("xor_light_layer.py", "r")
builder = builder.replace("__XOR_LAYER_PY__", to_hex(xor_layer_f.read()))
xor_layer_f.close()

payload = marshal.dumps(compile(minify(builder), "", "exec"))

print "Ajout des BF layers"
for i in range(1):
    payload = obfuscate(payload, bf_layer)

print "Ajout des invAll layers"
for i in range(3):
    payload = obfuscate(payload, invAll_layer)

print "Ajout des XOR layers"
for i in range(5):
    payload = obfuscate(payload, xor_layer)

print "Ajout des inv2 layers"
for i in range(5):
Beispiel #7
0
with open(output, 'w') as file:
    file.write(home_html)

for post in POSTS:
    post_metadata = POSTS[post].metadata

    post_data = {
        'content': POSTS[post],
        'title': post_metadata['title'],
        'date': post_metadata['date']
    }

    post_html = post_template.render(post=post_data)
    post_file_path = 'output/posts/{slug}.html'.format(
        slug=post_metadata['slug'])

    os.makedirs(os.path.dirname(post_file_path), exist_ok=True)
    with open(post_file_path, 'w') as file:
        file.write(post_html)

minify('scss/style.css', 'output/css/style.min.css')
minify('scss/newsite.css', 'output/css/newsite.min.css')

newsite_template = env.get_template('newsite.html')

newsite_html = newsite_template.render()
newsite_file_path = "output/newsite.html"

os.makedirs(os.path.dirname(newsite_file_path), exist_ok=True)
with open(newsite_file_path, 'w') as file:
    file.write(newsite_html)
Beispiel #8
0
def strip_whitespace(text):
    return text \
        .replace(" ", "") \
        .replace("\t", "") \
        .replace("\n", "") \
        .replace("\r", "") \
        .replace("\f", "") \
        .replace("\v", "")

if len(sys.argv) > 1:
    filenames = sys.argv[1:]
else:
    print("usage: %s <file>" % sys.argv[0])
    sys.exit(1)

for filename in filenames:
    text = open(filename,errors='surrogateescape').read()
    extension = filename.split(".")[-1]
    if extension in ("cs", "java", "jshell", "groovy", "rs"):
        text = text.strip()
        text2 = strip_whitespace(text)
        mindesc = "%6d characters (minified)" % len(minify.minify(text))
    elif extension in ("py", ):
        text2 = text
        mindesc = "%6d chars (raw text)" % len(text)
    else:
        text2 = text
        mindesc = "%6d bytes (binary)" % len(text)
    print("%-15s: %6d total, %6d whitespace, %6d non-whitespace: %s" % (filename, len(text), len(text)-len(text2), len(text2), mindesc))
Beispiel #9
0
builder = builder.replace("__PAYLOAD_PY__", to_hex(payload_f.read()))
payload_f.close()

byteplay_f = open("byteplay.py", "r")
builder = builder.replace("__BYTEPLAY_PY__", to_hex(byteplay_f.read()))
byteplay_f.close()

template_f = open("template_light.py", "r")
builder = builder.replace("__TEMPLATE_PY__", to_hex(template_f.read()))
template_f.close()

xor_layer_f = open("xor_light_layer.py", "r")
builder = builder.replace("__XOR_LAYER_PY__", to_hex(xor_layer_f.read()))
xor_layer_f.close()

payload = marshal.dumps(compile(minify(builder), "", "exec"))

print "Ajout des BF layers"
for i in range(1):
    payload = obfuscate(payload, bf_layer)

print "Ajout des invAll layers"
for i in range(3):
    payload = obfuscate(payload, invAll_layer)

print "Ajout des XOR layers"
for i in range(5):
    payload = obfuscate(payload, xor_layer)

print "Ajout des inv2 layers"
for i in range(5):