import os def run_bash(): res = os.system("ls -la") print(res) if __name__ == '__main__': run_bash() if __name__ == '__main__': import pickle class Vuln(): def __reduce__(self): # return (os.system, ("echo 'I should have been stopped by the hook'",)) return (run_bash, ()) with open("vuln.pkl", "wb") as f: pickle.dump(Vuln(), f)