Clearing Varnish Cache without Restart
Posted on Monday, November 4, 2013, 06:01 PM
| nessy
There has been a number of times when I’ve needed to clear the Varnish caching server’s cache, but had no clue how to do this. This resulted in me restarting Varnish, which really wasn’t needed.
The easiest way to clear the Varnish cache (without restarting) is by using the varnishadm command line tool:
varnishadm -T 127.0.0.1:6082 url.purge . The man page for varnishd shows a number of command which can be used with varnishadm , but the one we need is url.
Python Running System Command
Posted on Monday, November 4, 2013, 06:01 PM
| nessy
So there are a few ways to run system command using python, but I tend to find the below approach the easiest to use and has error handling.
First off I would create a function rather than running the commands over and over:
import subprocess def run(command): '''takes a string command and hands back a subprocess object''' process = subprocess.Popen(command.split(), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) process.wait() return process The function itself is pretty small and makes use of the subprocess library .
Creating QR Code with Google
Posted on Monday, November 4, 2013, 05:58 PM
| nessy
So today I thought I would be neat to show how to quickly create QR codes using Google’s Chart Tools .
Google gives us a extremely easy way to create QR code by sending GET data request via URL: https://chart.googleapis.com/chart?cht=qr&chs=300x300&chl=nessy That is nice and easy, but I figured I would wrap this up in a small Python script just because:
#!/usr/bin/env python from urllib2 import quote, urlopen, Request from poster.encode import multipart_encode from poster.
Brute Forcing Salted Password
Posted on Monday, November 4, 2013, 05:56 PM
| nessy
Since my last post showed how to check a salted password, I figured this time we can look over some example code for brute forcing a salted password. Of course this is just proof of concept and should not be used on any password you do not have access to.
The code I tossed together is using a bit of some examples I found online, and is no where near optimized for speed, but as I will show it will work.
UNIX SHA-512 Passwords & Python
Posted on Monday, November 4, 2013, 05:56 PM
| nessy
Well today I spent a bit of time looking up how /etc/shadow created their shadow passwords.
I found a good source for the method at http://www.akkadia.org/drepper/SHA-crypt.txt , and if you take some time to review it you will notice the steps are a bit involved
Lucky for us Python has a Crypt module that works nicely.
First off I started by creating a dummy user with the password of test on one of my Linux computers: