Saturday, November 2, 2013

zipcracker

zipcracker is an application that can find zip-file password using brute force or dictionary attack method.


Source code is available at https://bitbucket.org/mijo_gracanin/zipcracker

Inspiration for doing this app I found in book Violent Python by TJ O'Connor. Example in the book shoved me how easy it is to crack zip-file, using dictionary attack, thanks to zipfile library. Basically, method looks like this:
 from zipfile import ZipFile, zlib  
 z = ZipFile(file)  
 d = open(dictionary)  
 for line in d.readlines():  
   password = line.strip('\n')  
   try:  
     z.extractall(path='', pwd=password)  
     print(password)  
   except zlib.error:  
     pass  

I upgraded the example code from the book with GUI and brute force method. Brute force is easily implemented with itertools library, which contains permutations function. For GUI I used tkinter library, which mostly comes included with Python. I found tkinter good enough for simple applications, but some tasks, like restricting Entry widget to only accepts numbers, can be surprisingly difficult and requires, to quote a poster from StackOverflow, Voodoo code.

Of course Python may not be the best choice for this kind of task, because of speed. TJ O'Connor tried to speed up things a bit by using multithreading, but according to Mark Summerfield's book: Python in Practice, multithreading can even decrease performance because of GIL (Global Interpreter Lock) and he advises writing  code in Cython and using multiprocessing module. It would be interesting to see comparison between this approaches.
Other desirable improvements would be adding support for additional file types like rar and 7z. There is a rarfile library with similar interface like zipfile library available on PyPI, and for 7z there is a pylzma library also on PyPI.

Friday, August 16, 2013

Switch to linux

I haven't forgot my blog, just many things happened in the meantime, like: I bought PS3, started to seriously train climbing, work at workplace intensified, then summer and vacation came, and so on. Many times I tried it before, always finding some obstacle or constraint which made me return back to the dark side, but I always knew that one day we would get along just fine. That day came 4 months ago and since then Windows is only "collecting dust" on one partition of HDD, preserved just in case I must work from home. I've chose Linux Mint 14 Cinnamon for my primary OS and I have to say my laptop responds more agile on my commands and almost all apps I need are working, except Visual Studio of course. As for games, like I said earlier, I have PS3 for them, so it's all cool :)  In four months it froze once, which ain't that bad but not as stable as Windows 7 which never crashed in two years.
In initial post I announced that I'll post an useful wxPython project but I left it on that almost forgotten partition of HDD, half complete, with core functionality, but much work remains for it to look attractive and polished. I'll orient more on Tkinter now since it's better integrated with Python and it's future seems more promising. Soon I'll post Python/Tkinter app for crackin zip and rar files.

Wednesday, February 13, 2013

Hello world!

Interestingly, I get new ideas usually just before the bed time. Like with this one, to finally start the tech blog. I'm not sure is it because that way I can't do much real work or so that I can't sleep because of excitement and brain activity. Anyway, blog is started, showcase apps and code are almost done and I'm ready to fill this place with bits and bytes.

What to expect? First few posts will be about Python projects I'm working on in my free time. Just a few apps made with wxPython, to make some daily tasks easier. And later, we will see.