Can anyone explain me the example of an exploit in Python’s pickle module? -


i want understand the example of exploit in python pickle module? got code github show exploit in pickle module, still not able understand it. please guide me.

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) 

when unpickle object, __reduce__ method called. first argument __reduce__ callable, is, function. next argument tuple of arguments __reduce__. in case, when exploit unpickled, os.system called, , given 'cat /etc/passwd' argument.

os.system allows make system calls according host operating system. in case, it's linux.

cat prints file's contents standard out, , /etc/passwd information on system's users stored. more malicious code might try , send information on internet, or might try , mess file system, etc.

basically, unpickling object don't know about, you're vulnerable whatever __reduce__ method does.

https://docs.python.org/2/library/pickle.html

http://man7.org/linux/man-pages/man1/cat.1.html


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -