Unzip password protected archive

1. Create a file on CLI

touch hide.txt

2. Now zip it with a password using

zip -e cool.zip hide.txt

3. Let’s create the python decrypting script…

import time
import zipfile
import itertools

start_time = time.time()

zFile = zipfile.ZipFile("cool.zip")

chrs = 'abcdefghijklmnopqrstuvwxyz'
s = ''

for x in range(3, 5):
	for xs in itertools.product(chrs, repeat=x):
		word = s.join(xs)

		try:
			zFile.extractall(pwd=word)			

		except Exception, e:
			#print e
			break

		else:
			print word
			break

print("--- %s seconds ---" % (time.time() - start_time))

In the code above I assume the password contains 3 to 5 lowercase letters, so this can be extended.
Also, I’d like to see elapsed time.

4. Oh, and you should execute it like

python wow.py

… assuming you saved it as ‘wow.py’

How to uninstall and remove Apache2 on Ubuntu

The first step is to stop any running instance of Apache2, because Apache2 will not be properly removed while it is running.

sudo service apache2 stop

Then uninstall Apache2 and its dependent packages. Use purge option instead of remove with apt-get command. The former option will try to remove dependent packages, as well as any configuration files created by them. In addition, use autoremove option as well, to remove any other dependencies that were installed with Apache2, but are no longer used by any other package.

sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common
sudo apt-get autoremove

Finally, check if there is any configuration files or manual pages belonging to Apache2, which are still not removed.

whereis apache2

apache2: /etc/apache2
In this example, /etc/apache2 directory still exists. Since this directory (as well as any configuration files in it) is no longer necessary, go ahead and remove it manually.

sudo rm -rf /etc/apache2

And that’s it!