How Jeroen Zomer sees IT

Unstash in Python

February 20th, 2013 Posted in security, technology, work

I once wrote a Java version of the infamous unstash script, written in Perl.

As I am picking up Python (so refreshing, so little clutter) I thought it would be nice as a little practice to rewrite it in Python as well. And it is really compact.


This is what I came up with:

#!/usr/bin/python
# (c) 2013 Jeroen Zomer   http://strelitzia.net
import sys
def parseStash():
    if len(sys.argv) < 2:
        print "please add the stashfile as argument"
        return
    print "extracting password from: " + sys.argv[1]
    for b in open(sys.argv[1]).read():
        if ord(b) == 0xf5 :
            return 
        sys.stdout.write( chr(ord(b) ^ 0xf5) )
parseStash()

or if we would take the absolute bare minimum, it gets really impressive how powerful and compact python can be:

import sys

def parseStash():
    for b in open(sys.argv[1]).read():
        if ord(b) == 0xf5 :
            return
        sys.stdout.write( chr(ord(b) ^ 0xf5) )

parseStash()

This reminds me of the famous oneliners we used to have in Basic or the JavaScript 1k competitions

  1. 2 Responses to “Unstash in Python”

  2. By Dexter on Nov 13, 2015

    Each and every bride wants to locate a costume type that improves her search for her wedding
    reception. This amazing Russian bear not only does
    these unbelievable things, but he seems to be enjoying himself, too.
    For this reason, it is important for any would be learner to humble themselves and start
    off with this simple trumpet, and then later on advance to the higher order trumpets as seen fit by their instructors.

  3. By We send a transaction from our company. Next > https://out.carrotquest.io/r?hash=YXBwPTYyNTczJmNvbnZlcnNhdGlvbj0xNzI3NDA0NjkyMzAxOTQwMzY3JmFjdGlvbj1jbGlja2VkJnVybD1odHRwcyUzQSUyRiUyRnRlbGVncmEucGglMkZHby10by15b3VyLXBlcnNvbmFsLWNhYmluZXQtMDUtMTAmcm on Aug 1, 2024

    vffptk

Post a Comment


Warning: Undefined variable $user_ID in /var/www/vhosts/strelitzia.net/httpdocs/wp/wp-content/themes/strelitzia/comments.php on line 117