Skip to content

Instantly share code, notes, and snippets.

@atmb4u
Created November 25, 2011 03:03
Show Gist options
  • Save atmb4u/1392738 to your computer and use it in GitHub Desktop.
Save atmb4u/1392738 to your computer and use it in GitHub Desktop.
Basic self modifying code - puts the md5 of parent and last modified time. More info @ http://en.wikipedia.org/wiki/Self-modifying_code
import md5
f = open("newmd5.py","r+")
b = md5.md5(f.read())
# MD5 of the parent: 54062bcee8cdff7b3c3124421f5c5018 Last Modified:2011-11-21 23:28:46.974856
f.seek(60)
import datetime
digest = b.hexdigest()
f.writelines("# MD5 of the parent: "+digest+" Last Modified:"+str(datetime.datetime.now()))
print digest
f.close()
@atmb4u
Copy link
Author

atmb4u commented Nov 25, 2011

Basic self modifying code written in Python. Save the file with name newmd5.py and run it. Each time, it will self modify the code and get the latest md5 digest, with time
Just a simple idea to start with serious self modifying code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment