Year of Python (YOP) – Week Fifteen


Hello Readers!

This week I’m taking a trip back to the past a bit (for me anyway).  Originally I was planning on publishing some code that worked with IMAP and webmail accounts, however I ran out of time in getting the code in a working state.  My plan is still to publish it during this Year of Python.  I’m looking for it to do a specific task with the Spam folder, but I don’t want to say much more than that now.

However, if you want to see an excellent write up on using Python and IMAP/email, check out this post from the System Forensics Blog.

Now this particular piece of code this week I used a long time ago for a case I was working on.  At the time I was going through some Apache log files, and I needed to verify two types of log entries.  One was if a hashed password was being included in the URL string, and then the second was to decode some %xx characters in other URL entries (ex %2f).  At the time I was hoping to automate the process a bit better for my workflow, but the reality of time stepped in, so I turned it into a menu that would just prompt me for what I wanted to do.

Which is all in this piece of code:

while quit_prog:
    choice = raw_input("Choose md5 or url (type quit to exit): ")
    if choice.lower() == "md5":
        enter_md5 = raw_input("Enter the text to convert to md5: ")
        print create_md5(enter_md5)
    elif choice.lower() == "url":
        enter_url = raw_input("Enter the url text to convert: ")
        print decode_url(enter_url)
    elif choice.lower() == "quit":
        quit_prog = False

The code is rather simple.  I just set it up to prompt me if I was decoding and MD5, or a URL.  After that I would just copy/paste what I wanted to decode.  At that point the script would just run the corresponding function, and either generate the MD5 hash from the text I put in, or decode the special characters in the URL.

And that’s it!  Again this was one of these programs I designed to satisfy a need at the time, but it worked.  Moving forward I would probably look at just feeding in the Apache logs and then outputting the decoded data.  That will be version 2.0!

Until next time!


No Responses Yet to “Year of Python (YOP) – Week Fifteen”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: