Archive

Posts Tagged ‘hacking’

Mr. Robot

December 1, 2015 Leave a comment

I started to watch the TV show Mr. Robot. It’s a very cool techno thriller that displays hacking scenes quite realistically.

But what does it have to do with this blog? Well, in episode “eps1.3_da3m0ns.mp4” I saw the following image:

mr_robot

Check out the source code on the left side :)

Links

Update (20151202):

I found another Python script in the show (in episode 5):

mr_robot_2

Advertisements
Categories: python Tags: , ,

Python keylogger

August 2, 2013 2 comments

See PyKeylogger. Could be useful one day :)

Here is a simple Windows solution too.

Found here.

Categories: python Tags: ,

Hacking with Python

April 5, 2013 Leave a comment
Categories: python Tags:

md5 hash of a text / file + crack an md5 hash

November 17, 2011 Leave a comment

Update (20140406)
The implementation of the function file_to_md5() was replaced. It still produces the same output.

(1) text / file => md5 (encode)
You have a text or a file and you want to generate its md5 hash.

#!/usr/bin/env python

import hashlib

def string_to_md5(content):
    """Calculate the md5 hash of a string.

    This 'string' can be the binary content of a file too."""
    md5 = hashlib.md5()
    md5.update(content)
    return md5.hexdigest()

def file_to_md5(filename, block_size=8192):
    """Calculate the md5 hash of a file. Memory-friendly solution,
    it reads the file piece by piece.

    https://stackoverflow.com/questions/1131220/get-md5-hash-of-big-files-in-python"""
    md5 = hashlib.md5()
    with open(filename, 'rb') as f:
        while True:
            data = f.read(block_size)
            if not data:
                break
            md5.update(data)
    return md5.hexdigest()

#############################################################################

if __name__ == "__main__":
    text = 'uncrackable12'  # :)
    print string_to_md5(text)
    #
    filename = '/usr/bin/bash'
    print file_to_md5(filename)

The md5.hexdigest() returns a string of hex characters that is always 32 characters long. Thus, if you want to store it in a database, you can use the type CHAR(32).

(2) md5 => string (decode)
An md5 hash cannot be decoded, it’s a one-way process. However, you can try to find the md5 hash in a database that contains “string : md5” pairs. One such online database is available at http://www.md5decrypter.co.uk/ for instance. See also dictionary attack.

Categories: python Tags: , , ,