<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6054074612023958651</id><updated>2012-02-15T23:01:44.336-08:00</updated><category term='Subversion'/><category term='hook'/><category term='OpenSuse Linux'/><category term='prey ssh autossh'/><title type='text'>Spoon's Thoughts</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://psychoticspoon.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://psychoticspoon.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Spoon</name><uri>http://www.blogger.com/profile/17191979739240352083</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6054074612023958651.post-1696859343889264287</id><published>2010-11-15T18:37:00.002-08:00</published><updated>2010-11-15T20:42:43.406-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='prey ssh autossh'/><title type='text'>AutoSSH Module for Prey</title><content type='html'>&lt;h3&gt;Prey&lt;/h3&gt;&lt;br /&gt;&lt;a href="http://preyproject.com"&gt;Prey&lt;/a&gt; is software that allows you to track computers and other devices in case they are stolen. After it's installed on a machine, it periodically checks to see if you have reported it as stolen, and if you have, it will contact you with details about the machine's current status. This information includes its IP address, GPS position, a screenshot of the current desktop and a picture (or video) of the perpetrator using the webcam.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;This makes it much easier to recover your property. However, I also wanted to be able to have full control of the machine in order to access my data and to be able to directly monitor the thief. The easiest option is to &lt;tt&gt;ssh&lt;/tt&gt; directly into the machine; however, this is only possible if the router they are connected to doesn't block outside connections. One solution is to set up Prey to open a &lt;a href="http://www.debianadmin.com/howto-use-ssh-local-and-remote-port-forwarding.html"&gt;remote port&lt;/a&gt; on another machine that forwards back to itself; this way, your laptop initiates an outbound connection and evades the block.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Prerequisites&lt;/h3&gt;&lt;br /&gt;To accomplish this, you will need root access on a server that's running OpenSSH so that you can add a user that's only used for Prey. You could conceivably use your own account instead of creating a new one, but if your laptop is stolen, the thief would be given full access to your account. Your laptop also needs to be running Linux (the same procedures should work for other *nix systems, but modifications will have to be made to the directory structure of the download).&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Account preparation&lt;/h3&gt;&lt;br /&gt;To allow Prey to access your server, we will be setting up SSH keys that allow automatic login onto a server. Because of this, it is very important that you create a new user on the server and disable their shell, so that if your laptop is stolen, the thief won't be given access to an account.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;On the server, run the following as root to add a new user:&lt;br /&gt;&lt;tt&gt;&lt;b&gt;root@server:~#&lt;/b&gt; adduser preyuser&lt;/tt&gt;&lt;br /&gt;Set a password and whatever other options it asks for.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;On your laptop, run all of the following commands as root:&lt;br /&gt;&lt;tt&gt;&lt;b&gt;root@laptop:~#&lt;/b&gt; ssh-keygen -t rsa&lt;/tt&gt;&lt;br /&gt;Do not enter a passphrase.&lt;br /&gt;Now use &lt;tt&gt;ssh&lt;/tt&gt; to create a &lt;tt&gt;~/.ssh&lt;/tt&gt; directory by running:&lt;br /&gt;&lt;tt&gt;&lt;b&gt;root@laptop:~#&lt;/b&gt; ssh preyuser@server mkdir -p .ssh&lt;/tt&gt;&lt;br /&gt;Enter the password for the user you just created.&lt;br /&gt;Now append the laptop's public key to the authorized keys on the server:&lt;br /&gt;&lt;tt&gt;&lt;b&gt;root@laptop:~#&lt;/b&gt; cat ~/.ssh/id_rsa.pub | ssh preyuser@server 'cat &gt;&gt; .ssh/authorized_keys'&lt;/tt&gt;&lt;br /&gt;You should now be able to log into the server as &lt;tt&gt;preyuser&lt;/tt&gt; without entering a password.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Finally, back on the server, disable &lt;tt&gt;preyuser&lt;/tt&gt;'s ability to login by disabling their login shell:&lt;br /&gt;&lt;tt&gt;&lt;b&gt;root@server:~#&lt;/b&gt; which nologin&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;b&gt;/usr/sbin/nologin&lt;/b&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;b&gt;root@server:~#&lt;/b&gt; chsh -s /usr/sbin/nologin preyuser&lt;/tt&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Trying to log into the server should now give give you the message that the account is currently not available.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Configuring your laptop&lt;/h3&gt;&lt;br /&gt;The only thing to do now is to configure Prey. Download the &lt;a href="http://www.skari.org/blogger/prey-autossh.tgz"&gt;AutoSSH module&lt;/a&gt; onto your laptop and decompress it:&lt;br /&gt;&lt;tt&gt;&lt;b&gt;root@laptop:~#&lt;/b&gt; wget http://www.skari.org/blogger/prey-autossh.tgz&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;b&gt;root@laptop:~#&lt;/b&gt; tar -xzvf prey-autossh.tgz&lt;/tt&gt;&lt;br /&gt;Edit the &lt;tt&gt;autossh/config&lt;/tt&gt; file and fill in your server, username, and remote port. When you're done, move the folder into the Prey modules directory:&lt;br /&gt;&lt;tt&gt;&lt;b&gt;root@laptop:~#&lt;/b&gt; mv autossh /usr/share/prey/modules/&lt;/tt&gt;&lt;br /&gt;That's it!&lt;br /&gt;&lt;br /&gt;Prey should now open a forwarded tunnel from your server to your laptop when activated. However, if the connection is interrupted, the tunnel will die. You may want to consider installing &lt;a href="http://www.harding.motd.ca/autossh/"&gt;&lt;tt&gt;autossh&lt;/tt&gt;&lt;/a&gt; which will start and actively monitor an SSH connection and restart it as necessary. This module will use &lt;tt&gt;autossh&lt;/tt&gt; if it is available and fall back to plain &lt;tt&gt;ssh&lt;/tt&gt; otherwise.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Logging into your stolen laptop&lt;/h3&gt;&lt;br /&gt;Now, if your laptop is stolen, Prey should activate and send you a report. To access your laptop, login to your server and run:&lt;br /&gt;&lt;tt&gt;&lt;b&gt;user@server:~$&lt;/b&gt; ssh user@localhost -p &lt;i&gt;port&lt;/i&gt;&lt;/tt&gt;&lt;br /&gt;Enter the laptop's &lt;tt&gt;user&lt;/tt&gt;'s password,and you should be in. Now go catch the bastard!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6054074612023958651-1696859343889264287?l=psychoticspoon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psychoticspoon.blogspot.com/feeds/1696859343889264287/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psychoticspoon.blogspot.com/2010/11/autossh-module-for-prey.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/1696859343889264287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/1696859343889264287'/><link rel='alternate' type='text/html' href='http://psychoticspoon.blogspot.com/2010/11/autossh-module-for-prey.html' title='AutoSSH Module for Prey'/><author><name>Spoon</name><uri>http://www.blogger.com/profile/17191979739240352083</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6054074612023958651.post-262886436375037398</id><published>2010-05-28T21:30:00.000-07:00</published><updated>2010-11-15T20:45:47.383-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OpenSuse Linux'/><title type='text'>No sound for Flash in OpenSuse 11.2</title><content type='html'>I installed OpenSuse 11.2 on my laptop and everything was working fine. except I wasn't getting any sound out of Flash (e.g. Youtube). Sound was working fine in other programs, so I knew my sound card was working. The problem was, &lt;tt&gt;alsamixer&lt;/tt&gt; had my &lt;a href="http://en.wikipedia.org/wiki/Pulse-code_modulation"&gt;Pulse Code Modulation&lt;/a&gt; muted. To fix it, just run this in a terminal:&lt;br&gt;&lt;br /&gt;&lt;tt&gt;alsamixer&lt;/tt&gt;&lt;br&gt;&lt;br /&gt;and move over to PCM with the arrows and hold the up arrow until it's maxed out. Hopefully that will fix your problem!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6054074612023958651-262886436375037398?l=psychoticspoon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psychoticspoon.blogspot.com/feeds/262886436375037398/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psychoticspoon.blogspot.com/2010/05/no-sound-for-flash-in-opensuse-112.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/262886436375037398'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/262886436375037398'/><link rel='alternate' type='text/html' href='http://psychoticspoon.blogspot.com/2010/05/no-sound-for-flash-in-opensuse-112.html' title='No sound for Flash in OpenSuse 11.2'/><author><name>Spoon</name><uri>http://www.blogger.com/profile/17191979739240352083</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6054074612023958651.post-5089674084211350269</id><published>2010-05-23T22:37:00.000-07:00</published><updated>2010-05-24T13:33:00.543-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Subversion'/><category scheme='http://www.blogger.com/atom/ns#' term='hook'/><title type='text'>A Subversion Pre-Commit Hook</title><content type='html'>Subversion allows you to run commands, called &lt;a href="http://svnbook.red-bean.com/en/1.5/svn-book.html#svn.reposadmin.create.hooks"&gt;hook scripts&lt;/a&gt;, whenever actions take place in your repository. The most useful of these that I've found is the pre-commit hook, which allows you check a transaction for problems before it is committed.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://wordaligned.org/articles/a-subversion-pre-commit-hook"&gt;Word Aligned&lt;/a&gt; has an excellent introduction on setting up pre-commit hooks and includes a small example. I use a more complex script on my own server, and thought it might be of use to somebody else. It verifies the following:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;The commit message is at least 10 characters long&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The commit message is different from the previous message (handy when hit the up arrow and accidentally try to commit again)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Tabs are used for indentation instead of spaces (sorry, I'm a tabs guy - you can change it if you need to)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;PHP files don't have syntax errors&lt;/li&gt;&lt;br /&gt;&lt;li&gt;C and C++ files don't have any &lt;a href="http://en.wikipedia.org/wiki/Digraphs_and_trigraphs"&gt;digraphs or trigraphs&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div style='color:#000000;background:#ffffff'&gt;&lt;pre&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;#!/usr/bin/python&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#a520f7"&gt;import&lt;/font&gt; sys&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# These should point to the respective commands&lt;/font&gt;&lt;br /&gt;SVNLOOK = '&lt;font color="#ff00ff"&gt;/usr/bin/svnlook&lt;/font&gt;'&lt;br /&gt;PHP = '&lt;font color="#ff00ff"&gt;/usr/bin/php&lt;/font&gt;'&lt;br /&gt;MIN_MESSAGE_LENGTH = 10&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# Gets a command's output&lt;/font&gt;&lt;br /&gt;&lt;font color="#a52829"&gt;&lt;b&gt;def&lt;/b&gt;&lt;/font&gt; &lt;font color="#008a8c"&gt;commandOutput&lt;/font&gt;(command):&lt;br /&gt;  &lt;font color="#a520f7"&gt;import&lt;/font&gt; subprocess&lt;br /&gt;  process = subprocess.Popen(command.split(), stdout = subprocess.PIPE)&lt;br /&gt;  &lt;font color="#a52829"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/font&gt; process.communicate()[0] &lt;font color="#0000ff"&gt;# 0 is stdout&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# Returns an array of the changed files' names&lt;/font&gt;&lt;br /&gt;&lt;font color="#a52829"&gt;&lt;b&gt;def&lt;/b&gt;&lt;/font&gt; &lt;font color="#008a8c"&gt;getChangedFiles&lt;/font&gt;(svnPath, transaction):&lt;br /&gt;  &lt;font color="#0000ff"&gt;# Run svnlook to find the files that were changed&lt;/font&gt;&lt;br /&gt;  output = commandOutput('&lt;font color="#ff00ff"&gt;%s changed %s --transaction %s&lt;/font&gt;' %&lt;font color="#6b59ce"&gt;\&lt;/font&gt;&lt;br /&gt;    (SVNLOOK, svnPath, transaction))&lt;br /&gt;&lt;br /&gt;  &lt;font color="#0000ff"&gt;# The output from svnlook looks like the following:&lt;/font&gt;&lt;br /&gt;  &lt;font color="#0000ff"&gt;# U   folder/file1.cpp&lt;/font&gt;&lt;br /&gt;  &lt;font color="#0000ff"&gt;# A   folder/file2.cpp&lt;/font&gt;&lt;br /&gt;  &lt;font color="#0000ff"&gt;# where U means updated and A means added&lt;/font&gt;&lt;br /&gt;  &lt;font color="#a52829"&gt;&lt;b&gt;def&lt;/b&gt;&lt;/font&gt; &lt;font color="#008a8c"&gt;changed&lt;/font&gt;(fileName):&lt;br /&gt;    &lt;font color="#a52829"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/font&gt; len(line) &amp;gt; 0 &lt;font color="#a52829"&gt;&lt;b&gt;and&lt;/b&gt;&lt;/font&gt; line[0] &lt;font color="#a52829"&gt;&lt;b&gt;in&lt;/b&gt;&lt;/font&gt; ('&lt;font color="#ff00ff"&gt;A&lt;/font&gt;', '&lt;font color="#ff00ff"&gt;U&lt;/font&gt;')&lt;br /&gt;  changedFiles = [line[4:] &lt;font color="#a52829"&gt;&lt;b&gt;for&lt;/b&gt;&lt;/font&gt; line &lt;font color="#a52829"&gt;&lt;b&gt;in&lt;/b&gt;&lt;/font&gt; output.split('&lt;font color="#6b59ce"&gt;\n&lt;/font&gt;') &lt;font color="#a52829"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt; changed(line)]&lt;br /&gt;&lt;br /&gt;  &lt;font color="#0000ff"&gt;# svnlook inserts an empty line, so output.split() will have an extra&lt;/font&gt;&lt;br /&gt;  &lt;font color="#0000ff"&gt;# line with nothing in it - ignore the last lines if they're empty&lt;/font&gt;&lt;br /&gt;  &lt;font color="#a52829"&gt;&lt;b&gt;while&lt;/b&gt;&lt;/font&gt; 0 == len(changedFiles[-1]):&lt;br /&gt;    changedFiles = changedFiles[:-1]&lt;br /&gt;&lt;br /&gt;  &lt;font color="#a52829"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/font&gt; changedFiles&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# Checks that the message is a minimum length&lt;/font&gt;&lt;br /&gt;&lt;font color="#a52829"&gt;&lt;b&gt;def&lt;/b&gt;&lt;/font&gt; &lt;font color="#008a8c"&gt;checkMessageLen&lt;/font&gt;(svnPath, transaction, minLength):&lt;br /&gt;  &lt;font color="#0000ff"&gt;# Run svnlook to get the message log&lt;/font&gt;&lt;br /&gt;  output = commandOutput('&lt;font color="#ff00ff"&gt;%s log %s --transaction %s&lt;/font&gt;' %&lt;font color="#6b59ce"&gt;\&lt;/font&gt;&lt;br /&gt;    (SVNLOOK, svnPath, transaction))&lt;br /&gt;&lt;br /&gt;  &lt;font color="#a52829"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt; len(output) &amp;lt; minLength:&lt;br /&gt;    sys.stderr.write('&lt;font color="#ff00ff"&gt;Message must be at least %d characters&lt;/font&gt;&lt;font color="#6b59ce"&gt;\n&lt;/font&gt;' %&lt;font color="#6b59ce"&gt;\&lt;/font&gt;&lt;br /&gt;      minLength)&lt;br /&gt;    &lt;font color="#a52829"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/font&gt; 1&lt;br /&gt;  &lt;font color="#a52829"&gt;&lt;b&gt;else&lt;/b&gt;&lt;/font&gt;:&lt;br /&gt;    &lt;font color="#a52829"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/font&gt; 0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# Checks that the message is different from the last message&lt;/font&gt;&lt;br /&gt;&lt;font color="#a52829"&gt;&lt;b&gt;def&lt;/b&gt;&lt;/font&gt; &lt;font color="#008a8c"&gt;checkRepeatMessage&lt;/font&gt;(svnPath, transaction):&lt;br /&gt;  &lt;font color="#0000ff"&gt;# Run svnlook to get the message log&lt;/font&gt;&lt;br /&gt;  output = commandOutput('&lt;font color="#ff00ff"&gt;%s log %s --transaction %s&lt;/font&gt;' %&lt;font color="#6b59ce"&gt;\&lt;/font&gt;&lt;br /&gt;    (SVNLOOK, svnPath, transaction))&lt;br /&gt;&lt;br /&gt;  currentMessage = output&lt;br /&gt;&lt;br /&gt;  lastRevision = int(transaction.split('&lt;font color="#ff00ff"&gt;-&lt;/font&gt;')[0]) - 1&lt;br /&gt;&lt;br /&gt;  &lt;font color="#0000ff"&gt;# Empty repositories have no messages&lt;/font&gt;&lt;br /&gt;  &lt;font color="#a52829"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt; lastRevision &amp;lt;= 0:&lt;br /&gt;    &lt;font color="#a52829"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/font&gt; 0&lt;br /&gt;&lt;br /&gt;  &lt;font color="#0000ff"&gt;# Run svnlook to get the message log&lt;/font&gt;&lt;br /&gt;  output = commandOutput('&lt;font color="#ff00ff"&gt;%s log %s --revision %d&lt;/font&gt;' %&lt;font color="#6b59ce"&gt;\&lt;/font&gt;&lt;br /&gt;    (SVNLOOK, svnPath, lastRevision))&lt;br /&gt;&lt;br /&gt;  lastMessage = output&lt;br /&gt;&lt;br /&gt;  &lt;font color="#a52829"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt; currentMessage == lastMessage:&lt;br /&gt;    sys.stderr.write('&lt;font color="#ff00ff"&gt;Message must be different from last message&lt;/font&gt;&lt;font color="#6b59ce"&gt;\n&lt;/font&gt;')&lt;br /&gt;    &lt;font color="#a52829"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/font&gt; 1&lt;br /&gt;  &lt;font color="#a52829"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/font&gt; 0&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# Checks for occurrences of some strings in a file&lt;/font&gt;&lt;br /&gt;&lt;font color="#a52829"&gt;&lt;b&gt;def&lt;/b&gt;&lt;/font&gt; &lt;font color="#008a8c"&gt;stringsInFile&lt;/font&gt;(svnPath, transaction, badStringRegexes, fileName):&lt;br /&gt;  &lt;font color="#a520f7"&gt;import&lt;/font&gt; re&lt;br /&gt;&lt;br /&gt;  &lt;font color="#0000ff"&gt;# Run svnlook to get the file contents&lt;/font&gt;&lt;br /&gt;  output = commandOutput('&lt;font color="#ff00ff"&gt;%s cat %s %s --transaction %s&lt;/font&gt;' %&lt;font color="#6b59ce"&gt;\&lt;/font&gt;&lt;br /&gt;    (SVNLOOK, svnPath, fileName, transaction))&lt;br /&gt;&lt;br /&gt;  lines = output.split('&lt;font color="#6b59ce"&gt;\n&lt;/font&gt;')&lt;br /&gt;&lt;br /&gt;  matches = 0&lt;br /&gt;  &lt;font color="#a52829"&gt;&lt;b&gt;for&lt;/b&gt;&lt;/font&gt; regex &lt;font color="#a52829"&gt;&lt;b&gt;in&lt;/b&gt;&lt;/font&gt; badStringRegexes:&lt;br /&gt;    badLines = ''&lt;br /&gt;    &lt;font color="#a52829"&gt;&lt;b&gt;for&lt;/b&gt;&lt;/font&gt; lineNum &lt;font color="#a52829"&gt;&lt;b&gt;in&lt;/b&gt;&lt;/font&gt; range(len(lines)):&lt;br /&gt;      &lt;font color="#a52829"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt; re.search(regex, lines[lineNum]):&lt;br /&gt;        matches += 1&lt;br /&gt;        badLines += ('&lt;font color="#ff00ff"&gt;%d &lt;/font&gt;' % (lineNum + 1))&lt;br /&gt;    &lt;font color="#a52829"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt; len(badLines) &amp;gt; 0:&lt;br /&gt;      sys.stderr.write('&lt;font color="#ff00ff"&gt;Regex &lt;/font&gt;&lt;font color="#6b59ce"&gt;\'&lt;/font&gt;&lt;font color="#ff00ff"&gt;%s&lt;/font&gt;&lt;font color="#6b59ce"&gt;\'&lt;/font&gt;&lt;font color="#ff00ff"&gt; matched &lt;/font&gt;&lt;font color="#6b59ce"&gt;\'&lt;/font&gt;&lt;font color="#ff00ff"&gt;%s&lt;/font&gt;&lt;font color="#6b59ce"&gt;\'&lt;/font&gt;&lt;font color="#ff00ff"&gt; on line(s): %s&lt;/font&gt;&lt;font color="#6b59ce"&gt;\n&lt;/font&gt;' %&lt;font color="#6b59ce"&gt;\&lt;/font&gt;&lt;br /&gt;        (regex, fileName, badLines))&lt;br /&gt;&lt;br /&gt;  &lt;font color="#a52829"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/font&gt; matches&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# Checks a PHP file for syntax errors&lt;/font&gt;&lt;br /&gt;&lt;font color="#a52829"&gt;&lt;b&gt;def&lt;/b&gt;&lt;/font&gt; &lt;font color="#008a8c"&gt;checkPHPSyntax&lt;/font&gt;(svnPath, transaction, fileName):&lt;br /&gt;  &lt;font color="#0000ff"&gt;# Run svnlook to get the file contents&lt;/font&gt;&lt;br /&gt;  output = commandOutput('&lt;font color="#ff00ff"&gt;%s cat %s %s --transaction %s&lt;/font&gt;' %&lt;font color="#6b59ce"&gt;\&lt;/font&gt;&lt;br /&gt;    (SVNLOOK, svnPath, fileName, transaction))&lt;br /&gt;&lt;br /&gt;  &lt;font color="#0000ff"&gt;# Run PHP syntax checking on the file contents&lt;/font&gt;&lt;br /&gt;  command = (PHP, '&lt;font color="#ff00ff"&gt;-l&lt;/font&gt;')&lt;br /&gt;  process = subprocess.Popen(command, stdin = subprocess.PIPE,&lt;font color="#6b59ce"&gt;\&lt;/font&gt;&lt;br /&gt;    stdout = subprocess.PIPE, stderr = subprocess.PIPE)&lt;br /&gt;  output = process.communicate(fileContents)[0]&lt;br /&gt;  process.wait()&lt;br /&gt;&lt;br /&gt;  &lt;font color="#a52829"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt; 0 != process.returncode:&lt;br /&gt;    sys.stderr.write('&lt;font color="#ff00ff"&gt;Found syntax errors in &lt;/font&gt;&lt;font color="#6b59ce"&gt;\'&lt;/font&gt;&lt;font color="#ff00ff"&gt;%s&lt;/font&gt;&lt;font color="#6b59ce"&gt;\'&lt;/font&gt;&lt;font color="#ff00ff"&gt;:&lt;/font&gt;' %&lt;font color="#6b59ce"&gt;\&lt;/font&gt;&lt;br /&gt;      fileName)&lt;br /&gt;    &lt;font color="#0000ff"&gt;# Print the offending lines that were returned from php -l&lt;/font&gt;&lt;br /&gt;    &lt;font color="#a52829"&gt;&lt;b&gt;for&lt;/b&gt;&lt;/font&gt; line &lt;font color="#a52829"&gt;&lt;b&gt;in&lt;/b&gt;&lt;/font&gt; output:&lt;br /&gt;      sys.stderr.write(line)&lt;br /&gt;    &lt;font color="#a52829"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/font&gt; 1 &lt;font color="#0000ff"&gt;# Error found&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;  &lt;font color="#a52829"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/font&gt; 0 &lt;font color="#0000ff"&gt;# No errors&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;svnPath = sys.argv[1]&lt;br /&gt;transaction = sys.argv[2]&lt;br /&gt;files = getChangedFiles(svnPath, transaction)&lt;br /&gt;&lt;br /&gt;errorCount = checkMessageLen(svnPath, transaction, MIN_MESSAGE_LENGTH)&lt;br /&gt;errorCount += checkRepeatMessage(svnPath, transaction)&lt;br /&gt;&lt;br /&gt;&lt;font color="#a52829"&gt;&lt;b&gt;for&lt;/b&gt;&lt;/font&gt; file &lt;font color="#a52829"&gt;&lt;b&gt;in&lt;/b&gt;&lt;/font&gt; files:&lt;br /&gt;  &lt;font color="#0000ff"&gt;# Prefer tabs for indentation&lt;/font&gt;&lt;br /&gt;  errorCount = errorCount + stringsInFile(svnPath, transaction,&lt;font color="#6b59ce"&gt;\&lt;/font&gt;&lt;br /&gt;    ['&lt;font color="#ff00ff"&gt; {4}&lt;/font&gt;'], file)&lt;br /&gt;&lt;br /&gt;  &lt;font color="#0000ff"&gt;# Check PHP syntax&lt;/font&gt;&lt;br /&gt;  &lt;font color="#a52829"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt; file.endswith('&lt;font color="#ff00ff"&gt;.php&lt;/font&gt;'):&lt;br /&gt;    errorCount += checkPHPSyntax(svnPath, transaction, file)&lt;br /&gt;&lt;br /&gt;  &lt;font color="#0000ff"&gt;# C and C++ files should not use digraphs or trigraphs&lt;/font&gt;&lt;br /&gt;  digraph = '&lt;font color="#ff00ff"&gt;%s|%s|%s|%s|%s&lt;/font&gt;' % ('&lt;font color="#ff00ff"&gt;&amp;lt;:&lt;/font&gt;', '&lt;font color="#ff00ff"&gt;&amp;lt;%&lt;/font&gt;', '&lt;font color="#ff00ff"&gt;%&amp;gt;&lt;/font&gt;', '&lt;font color="#ff00ff"&gt;:&amp;gt;&lt;/font&gt;', '&lt;font color="#ff00ff"&gt;%:&lt;/font&gt;')&lt;br /&gt;  trigraph = '&lt;font color="#ff00ff"&gt;\?\?[=/&lt;/font&gt;&lt;font color="#6b59ce"&gt;\'&lt;/font&gt;&lt;font color="#ff00ff"&gt;()!&amp;lt;&amp;gt;-]&lt;/font&gt;'&lt;br /&gt;  &lt;font color="#a52829"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt; file.endswith(('&lt;font color="#ff00ff"&gt;.c&lt;/font&gt;', '&lt;font color="#ff00ff"&gt;.cpp&lt;/font&gt;', '&lt;font color="#ff00ff"&gt;.cxx&lt;/font&gt;', '&lt;font color="#ff00ff"&gt;.cc&lt;/font&gt;', '&lt;font color="#ff00ff"&gt;.C&lt;/font&gt;', '&lt;font color="#ff00ff"&gt;.h&lt;/font&gt;', '&lt;font color="#ff00ff"&gt;.hpp&lt;/font&gt;')):&lt;br /&gt;    errorCount += stringsInFile(svnPath, transaction,&lt;font color="#6b59ce"&gt;\&lt;/font&gt;&lt;br /&gt;      [digraph, trigraph], file)&lt;br /&gt;&lt;br /&gt;sys.exit(errorCount)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6054074612023958651-5089674084211350269?l=psychoticspoon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psychoticspoon.blogspot.com/feeds/5089674084211350269/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psychoticspoon.blogspot.com/2010/05/subversion-pre-commit-hook.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/5089674084211350269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/5089674084211350269'/><link rel='alternate' type='text/html' href='http://psychoticspoon.blogspot.com/2010/05/subversion-pre-commit-hook.html' title='A Subversion Pre-Commit Hook'/><author><name>Spoon</name><uri>http://www.blogger.com/profile/17191979739240352083</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6054074612023958651.post-1035282564016450020</id><published>2010-03-20T17:08:00.001-07:00</published><updated>2010-03-20T18:00:59.031-07:00</updated><title type='text'>Compression before encryption</title><content type='html'>&lt;p&gt;If you're going to be compressing and encrypting some data, you should do the compression first. Why? There are several reasons:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt; &lt;li&gt;&lt;b&gt;Compressing it last won't reduce the file size much.&lt;/b&gt; Good encryption should make any input data (especially redundant data) appear random. But compression works by removing redundancy, and doesn't work well on random data. You can see a good example of this &lt;a href=http://lists.gnupg.org/pipermail/gnupg-users/2007-June/031382.html&gt;here&lt;/a&gt;, where encrypting a file and then compressing it actually made it larger than the original!&lt;br /&gt; &lt;li&gt;&lt;b&gt;Compressing it should decrease the effectiveness of some attacks.&lt;/b&gt; Compression works by reducing the redundancy in the data. A common cryptanalysis method is &lt;a href=http://en.wikipedia.org/wiki/Frequency_analysis&gt;frequency analysis&lt;/a&gt;, which relies on finding repeated data. Compressing it should reduce its effectiveness!&lt;br /&gt; &lt;li&gt;&lt;b&gt;&lt;a href=http://en.wikipedia.org/wiki/Brute_force_attack&gt;Brute force attacks&lt;/a&gt; will take longer.&lt;/b&gt; Brute force attacks work by trying various keys and decrypting the data and checking if the output data makes any sense. By compressing it first, an attacker must decrypt the data and then decompress it before seeing if the output data makes any sense. This takes much longer, and if an attacker doesn't know you're compressing the data at all, they might never break the encryption.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I wanted to see how effective the third point was, so I wrote a Python script that encrypted a short message and used a brute force attack to break it. Then I repeated the experiment, but compressed it using &lt;a href=http://en.wikipedia.org/wiki/Gzip&gt;gzip&lt;/a&gt; before encrypting it. Here's how long it took on average, in seconds, to guess a single password:&lt;br /&gt;&lt;br /&gt;&lt;table border="1" bordercolor="#000000" style="background-color:#FFFFFF" width="70%" cellpadding="3" cellspacing="1"&gt;&lt;br /&gt; &lt;tr&gt;&lt;br /&gt;  &lt;td&gt;&lt;b&gt;Password length:&lt;/b&gt;&lt;/td&gt;&lt;br /&gt;  &lt;td&gt;&lt;b&gt;Zipped:&lt;/b&gt;&lt;/td&gt;&lt;br /&gt;  &lt;td&gt;&lt;b&gt;Not zipped:&lt;/b&gt;&lt;/td&gt;&lt;br /&gt; &lt;/tr&gt;&lt;br /&gt; &lt;tr&gt;&lt;br /&gt;  &lt;td&gt;2 letters&lt;/td&gt;&lt;br /&gt;  &lt;td&gt;0.021&lt;/td&gt;&lt;br /&gt;  &lt;td&gt;0.002&lt;/td&gt;&lt;br /&gt; &lt;/tr&gt;&lt;br /&gt; &lt;tr&gt;&lt;br /&gt;  &lt;td&gt;3 letters&lt;/td&gt;&lt;br /&gt;  &lt;td&gt;0.546&lt;/td&gt;&lt;br /&gt;  &lt;td&gt;0.061&lt;/td&gt;&lt;br /&gt; &lt;/tr&gt;&lt;br /&gt; &lt;tr&gt;&lt;br /&gt;  &lt;td&gt;4 letters&lt;/td&gt;&lt;br /&gt;  &lt;td&gt;13.612&lt;/td&gt;&lt;br /&gt;  &lt;td&gt;1.551&lt;/td&gt;&lt;br /&gt; &lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;As you can see, compressing it before encrypting it took about 9 times as long to break.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;small&gt;Details: A short message was chosen, specifically, "&lt;tt&gt;a message&lt;/tt&gt;", to encrypt. Because gzip is a block compression algorithm, an attacker only needs to decompress the first bytes rather than the whole file, so I wanted to keep the message short to simulate this. I used 128-bit &lt;a href=http://en.wikipedia.org/wiki/Advanced_Encryption_Standard&gt;AES&lt;/a&gt;, using a password with only lower case letters. In each iteration, a random password was chosen and both the zipped and unzipped versions were tested. The test was run 1000 times for each password length.&lt;/small&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6054074612023958651-1035282564016450020?l=psychoticspoon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psychoticspoon.blogspot.com/feeds/1035282564016450020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psychoticspoon.blogspot.com/2010/03/compression-before-encryption.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/1035282564016450020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/1035282564016450020'/><link rel='alternate' type='text/html' href='http://psychoticspoon.blogspot.com/2010/03/compression-before-encryption.html' title='Compression before encryption'/><author><name>Spoon</name><uri>http://www.blogger.com/profile/17191979739240352083</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6054074612023958651.post-5813360342557399479</id><published>2010-03-04T17:50:00.000-08:00</published><updated>2010-03-12T15:25:41.555-08:00</updated><title type='text'>Test MySQL password strength</title><content type='html'>&lt;p&gt;Newer versions of MySQL stores passwords using a double &lt;a href="http://en.wikipedia.org/wiki/SHA_hash_functions"&gt;SHA-1 hash&lt;/a&gt;. Because of this, administrators can't tell what someone's password is. What if you want to make sure no users are using weak passwords?&lt;br /&gt;&lt;p&gt;This is a simple Python script that will connect to your local MySQL database, pull out the password hashes for all users, and either run a dictionary search or a brute force search on it. Either give it an argument for the dictionary file, or give it a number for the length of passwords you want to test. If you want to use a different character set (e.g. include special characters), change the &lt;tt&gt;characterSet&lt;/tt&gt; variable near the top of the script.&lt;br /&gt;&lt;p&gt;On my system, I was able to test around 50,000 words per second. &lt;b&gt;Note that this cannot be used to recover the root MySQL password&lt;/b&gt;, as it requires the root password to connect to the database in the first place.&lt;br /&gt;&lt;br /&gt;&lt;!-- Generator: GNU source-highlight 2.4&lt;br /&gt;by Lorenzo Bettini&lt;br /&gt;http://www.lorenzobettini.it&lt;br /&gt;http://www.gnu.org/software/src-highlite --&gt;&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;i&gt;&lt;font color="#9A1900"&gt;#!/usr/bin/python&lt;/font&gt;&lt;/i&gt;&lt;br /&gt; &lt;br /&gt;&lt;b&gt;&lt;font color="#000080"&gt;import&lt;/font&gt;&lt;/b&gt; &lt;font color="#009900"&gt;MySQLdb&lt;/font&gt;&lt;br /&gt;&lt;b&gt;&lt;font color="#000080"&gt;import&lt;/font&gt;&lt;/b&gt; &lt;font color="#009900"&gt;sha&lt;/font&gt;&lt;br /&gt;&lt;b&gt;&lt;font color="#000080"&gt;import&lt;/font&gt;&lt;/b&gt; &lt;font color="#009900"&gt;sys&lt;/font&gt;&lt;br /&gt;&lt;b&gt;&lt;font color="#000080"&gt;import&lt;/font&gt;&lt;/b&gt; &lt;font color="#009900"&gt;os&lt;/font&gt;&lt;br /&gt;&lt;b&gt;&lt;font color="#000080"&gt;import&lt;/font&gt;&lt;/b&gt; &lt;font color="#009900"&gt;getpass&lt;/font&gt;&lt;br /&gt; &lt;br /&gt;alpha &lt;font color="#990000"&gt;=&lt;/font&gt; &lt;font color="#FF0000"&gt;"abcdefghijklmnopqrstuvwxyz"&lt;/font&gt;&lt;br /&gt;numbers &lt;font color="#990000"&gt;=&lt;/font&gt; &lt;font color="#FF0000"&gt;"0123456789"&lt;/font&gt;&lt;br /&gt;&lt;i&gt;&lt;font color="#9A1900"&gt;# Set this to a string with the character set you want to check&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color="#9A1900"&gt;# Examples:&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;characterSet &lt;font color="#990000"&gt;=&lt;/font&gt; alpha&lt;br /&gt;&lt;i&gt;&lt;font color="#9A1900"&gt;#characterSet = alpha + alpha.upper()&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color="#9A1900"&gt;#characterSet = numbers&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;font color="#9A1900"&gt;#characterSet = alpha + alpha.upper() + numbers&lt;/font&gt;&lt;/i&gt;&lt;br /&gt; &lt;br /&gt;&lt;b&gt;&lt;font color="#0000FF"&gt;def&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color="#000000"&gt;recurse&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;width&lt;font color="#990000"&gt;,&lt;/font&gt; logins&lt;font color="#990000"&gt;):&lt;/font&gt;&lt;br /&gt;  &lt;b&gt;&lt;font color="#0000FF"&gt;for&lt;/font&gt;&lt;/b&gt; i &lt;b&gt;&lt;font color="#0000FF"&gt;in&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color="#000000"&gt;range&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;&lt;font color="#993399"&gt;0&lt;/font&gt;&lt;font color="#990000"&gt;,&lt;/font&gt; width &lt;font color="#990000"&gt;+&lt;/font&gt; &lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;):&lt;/font&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color="#0000FF"&gt;print&lt;/font&gt;&lt;/b&gt; &lt;font color="#FF0000"&gt;"Checking width %d"&lt;/font&gt; &lt;font color="#990000"&gt;%&lt;/font&gt; i&lt;br /&gt;    &lt;b&gt;&lt;font color="#000000"&gt;recurse2&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;i&lt;font color="#990000"&gt;,&lt;/font&gt; logins&lt;font color="#990000"&gt;,&lt;/font&gt; &lt;font color="#993399"&gt;0&lt;/font&gt;&lt;font color="#990000"&gt;,&lt;/font&gt; &lt;font color="#FF0000"&gt;""&lt;/font&gt;&lt;font color="#990000"&gt;)&lt;/font&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color="#0000FF"&gt;print&lt;/font&gt;&lt;/b&gt; &lt;font color="#FF0000"&gt;""&lt;/font&gt;&lt;br /&gt; &lt;br /&gt;&lt;b&gt;&lt;font color="#0000FF"&gt;def&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color="#000000"&gt;recurse2&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;width&lt;font color="#990000"&gt;,&lt;/font&gt; logins&lt;font color="#990000"&gt;,&lt;/font&gt; position&lt;font color="#990000"&gt;,&lt;/font&gt; string&lt;font color="#990000"&gt;):&lt;/font&gt;&lt;br /&gt;  &lt;b&gt;&lt;font color="#0000FF"&gt;for&lt;/font&gt;&lt;/b&gt; char &lt;b&gt;&lt;font color="#0000FF"&gt;in&lt;/font&gt;&lt;/b&gt; characterSet&lt;font color="#990000"&gt;:&lt;/font&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color="#9A1900"&gt;# Show progress&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color="#0000FF"&gt;if&lt;/font&gt;&lt;/b&gt; position &lt;font color="#990000"&gt;==&lt;/font&gt; &lt;font color="#993399"&gt;0&lt;/font&gt;&lt;font color="#990000"&gt;:&lt;/font&gt;&lt;br /&gt;      &lt;b&gt;&lt;font color="#0000FF"&gt;print&lt;/font&gt;&lt;/b&gt; char&lt;font color="#990000"&gt;,&lt;/font&gt;&lt;br /&gt;      &lt;font color="#009900"&gt;sys&lt;/font&gt;&lt;font color="#990000"&gt;.&lt;/font&gt;stdout&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;flush&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;()&lt;/font&gt;&lt;br /&gt; &lt;br /&gt;    &lt;b&gt;&lt;font color="#0000FF"&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color="#990000"&gt;(&lt;/font&gt;position &lt;font color="#990000"&gt;&amp;lt;&lt;/font&gt; width &lt;font color="#990000"&gt;-&lt;/font&gt; &lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;):&lt;/font&gt;&lt;br /&gt;      &lt;b&gt;&lt;font color="#000000"&gt;recurse2&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;width&lt;font color="#990000"&gt;,&lt;/font&gt; logins&lt;font color="#990000"&gt;,&lt;/font&gt; position &lt;font color="#990000"&gt;+&lt;/font&gt; &lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;,&lt;/font&gt; string &lt;font color="#990000"&gt;+&lt;/font&gt; char&lt;font color="#990000"&gt;)&lt;/font&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color="#0000FF"&gt;else&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;:&lt;/font&gt;&lt;br /&gt;      hash &lt;font color="#990000"&gt;=&lt;/font&gt; &lt;font color="#009900"&gt;sha&lt;/font&gt;&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;new&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;&lt;font color="#009900"&gt;sha&lt;/font&gt;&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;new&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;string &lt;font color="#990000"&gt;+&lt;/font&gt; char&lt;font color="#990000"&gt;).&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;digest&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;())\&lt;/font&gt;&lt;br /&gt;          &lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;hexdigest&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;()&lt;/font&gt;&lt;br /&gt;      &lt;b&gt;&lt;font color="#0000FF"&gt;for&lt;/font&gt;&lt;/b&gt; login &lt;b&gt;&lt;font color="#0000FF"&gt;in&lt;/font&gt;&lt;/b&gt; logins&lt;font color="#990000"&gt;:&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color="#0000FF"&gt;if&lt;/font&gt;&lt;/b&gt; hash &lt;font color="#990000"&gt;==&lt;/font&gt; login&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;2&lt;/font&gt;&lt;font color="#990000"&gt;]:&lt;/font&gt;&lt;br /&gt;          &lt;b&gt;&lt;font color="#0000FF"&gt;print&lt;/font&gt;&lt;/b&gt; &lt;font color="#FF0000"&gt;"\n'%s'@'%s': '%s'\n"&lt;/font&gt; &lt;font color="#990000"&gt;%\&lt;/font&gt;&lt;br /&gt;              &lt;font color="#990000"&gt;(&lt;/font&gt;login&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;0&lt;/font&gt;&lt;font color="#990000"&gt;],&lt;/font&gt; login&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;],&lt;/font&gt; string &lt;font color="#990000"&gt;+&lt;/font&gt; char&lt;font color="#990000"&gt;)&lt;/font&gt;&lt;br /&gt;          logins&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;remove&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;login&lt;font color="#990000"&gt;)&lt;/font&gt;&lt;br /&gt; &lt;br /&gt;&lt;b&gt;&lt;font color="#0000FF"&gt;if&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color="#000000"&gt;len&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;&lt;font color="#009900"&gt;sys&lt;/font&gt;&lt;font color="#990000"&gt;.&lt;/font&gt;argv&lt;font color="#990000"&gt;)&lt;/font&gt; &lt;font color="#990000"&gt;&amp;gt;&lt;/font&gt; &lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;:&lt;/font&gt;&lt;br /&gt;  password &lt;font color="#990000"&gt;=&lt;/font&gt; &lt;font color="#009900"&gt;getpass&lt;/font&gt;&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;getpass&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;&lt;font color="#FF0000"&gt;'Enter the root password: '&lt;/font&gt;&lt;font color="#990000"&gt;)&lt;/font&gt;&lt;br /&gt;  conn &lt;font color="#990000"&gt;=&lt;/font&gt; &lt;font color="#009900"&gt;MySQLdb&lt;/font&gt;&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;connect&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;host &lt;font color="#990000"&gt;=&lt;/font&gt; &lt;font color="#FF0000"&gt;"localhost"&lt;/font&gt;&lt;font color="#990000"&gt;,&lt;/font&gt;&lt;br /&gt;    user &lt;font color="#990000"&gt;=&lt;/font&gt; &lt;font color="#FF0000"&gt;"root"&lt;/font&gt;&lt;font color="#990000"&gt;,&lt;/font&gt;&lt;br /&gt;    passwd &lt;font color="#990000"&gt;=&lt;/font&gt; password&lt;font color="#990000"&gt;,&lt;/font&gt;&lt;br /&gt;    db &lt;font color="#990000"&gt;=&lt;/font&gt; &lt;font color="#FF0000"&gt;"mysql"&lt;/font&gt;&lt;font color="#990000"&gt;)&lt;/font&gt;&lt;br /&gt;  cursor &lt;font color="#990000"&gt;=&lt;/font&gt; conn&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;cursor&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;()&lt;/font&gt;&lt;br /&gt;  cursor&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;execute&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;&lt;font color="#FF0000"&gt;"SELECT User, Host, Password from user;"&lt;/font&gt;&lt;font color="#990000"&gt;)&lt;/font&gt;&lt;br /&gt;  logins &lt;font color="#990000"&gt;=&lt;/font&gt; cursor&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;fetchall&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;()&lt;/font&gt;&lt;br /&gt;  cursor&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;close&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;()&lt;/font&gt;&lt;br /&gt;  conn&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;close&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;()&lt;/font&gt;&lt;br /&gt; &lt;br /&gt;  &lt;i&gt;&lt;font color="#9A1900"&gt;# Preprocess the logins&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;  processed &lt;font color="#990000"&gt;=&lt;/font&gt; &lt;font color="#990000"&gt;[]&lt;/font&gt;&lt;br /&gt;  &lt;b&gt;&lt;font color="#0000FF"&gt;for&lt;/font&gt;&lt;/b&gt; login &lt;b&gt;&lt;font color="#0000FF"&gt;in&lt;/font&gt;&lt;/b&gt; logins&lt;font color="#990000"&gt;:&lt;/font&gt;&lt;br /&gt;    ignore &lt;font color="#990000"&gt;=&lt;/font&gt; &lt;font color="#009900"&gt;False&lt;/font&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color="#9A1900"&gt;# Ignore empty passwords&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color="#0000FF"&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color="#993399"&gt;0&lt;/font&gt; &lt;font color="#990000"&gt;==&lt;/font&gt; &lt;b&gt;&lt;font color="#000000"&gt;len&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;login&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;2&lt;/font&gt;&lt;font color="#990000"&gt;]):&lt;/font&gt;&lt;br /&gt;      &lt;b&gt;&lt;font color="#0000FF"&gt;print&lt;/font&gt;&lt;/b&gt; &lt;font color="#FF0000"&gt;"'%s'@'%s' has empty password, ignoring"&lt;/font&gt; &lt;font color="#990000"&gt;%\&lt;/font&gt;&lt;br /&gt;          &lt;font color="#990000"&gt;(&lt;/font&gt;login&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;0&lt;/font&gt;&lt;font color="#990000"&gt;],&lt;/font&gt; login&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;])&lt;/font&gt;&lt;br /&gt;      ignore &lt;font color="#990000"&gt;=&lt;/font&gt; &lt;font color="#009900"&gt;True&lt;/font&gt;&lt;br /&gt;    &lt;i&gt;&lt;font color="#9A1900"&gt;# Ignore duplicates&lt;/font&gt;&lt;/i&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color="#0000FF"&gt;for&lt;/font&gt;&lt;/b&gt; p &lt;b&gt;&lt;font color="#0000FF"&gt;in&lt;/font&gt;&lt;/b&gt; processed&lt;font color="#990000"&gt;:&lt;/font&gt;&lt;br /&gt;      &lt;b&gt;&lt;font color="#0000FF"&gt;if&lt;/font&gt;&lt;/b&gt; p&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;2&lt;/font&gt;&lt;font color="#990000"&gt;]&lt;/font&gt; &lt;font color="#990000"&gt;==&lt;/font&gt; login&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;2&lt;/font&gt;&lt;font color="#990000"&gt;][&lt;/font&gt;&lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;:].&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;lower&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;():&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color="#0000FF"&gt;print&lt;/font&gt;&lt;/b&gt; &lt;font color="#FF0000"&gt;"'%s'@'%s' has same password as '%s'@'%s', ignoring"&lt;/font&gt; &lt;font color="#990000"&gt;%\&lt;/font&gt;&lt;br /&gt;            &lt;font color="#990000"&gt;(&lt;/font&gt;login&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;0&lt;/font&gt;&lt;font color="#990000"&gt;],&lt;/font&gt; login&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;],&lt;/font&gt; p&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;0&lt;/font&gt;&lt;font color="#990000"&gt;],&lt;/font&gt; p&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;])&lt;/font&gt;&lt;br /&gt;        ignore &lt;font color="#990000"&gt;=&lt;/font&gt; &lt;font color="#009900"&gt;True&lt;/font&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color="#0000FF"&gt;if&lt;/font&gt;&lt;/b&gt; &lt;b&gt;&lt;font color="#0000FF"&gt;not&lt;/font&gt;&lt;/b&gt; ignore&lt;font color="#990000"&gt;:&lt;/font&gt;&lt;br /&gt;      processed&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;append&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;((&lt;/font&gt;login&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;0&lt;/font&gt;&lt;font color="#990000"&gt;],&lt;/font&gt; login&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;],&lt;/font&gt; login&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;2&lt;/font&gt;&lt;font color="#990000"&gt;][&lt;/font&gt;&lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;:].&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;lower&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;()))&lt;/font&gt;&lt;br /&gt; &lt;br /&gt;  &lt;b&gt;&lt;font color="#0000FF"&gt;if&lt;/font&gt;&lt;/b&gt; &lt;font color="#009900"&gt;os&lt;/font&gt;&lt;font color="#990000"&gt;.&lt;/font&gt;path&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;isfile&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;&lt;font color="#009900"&gt;sys&lt;/font&gt;&lt;font color="#990000"&gt;.&lt;/font&gt;argv&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;]):&lt;/font&gt;&lt;br /&gt;    f &lt;font color="#990000"&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color="#000000"&gt;open&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;&lt;font color="#009900"&gt;sys&lt;/font&gt;&lt;font color="#990000"&gt;.&lt;/font&gt;argv&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;])&lt;/font&gt;&lt;br /&gt;    lines &lt;font color="#990000"&gt;=&lt;/font&gt; f&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;readlines&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;()&lt;/font&gt;&lt;br /&gt;    f&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;close&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;()&lt;/font&gt;&lt;br /&gt; &lt;br /&gt;    &lt;b&gt;&lt;font color="#0000FF"&gt;for&lt;/font&gt;&lt;/b&gt; line &lt;b&gt;&lt;font color="#0000FF"&gt;in&lt;/font&gt;&lt;/b&gt; lines&lt;font color="#990000"&gt;:&lt;/font&gt;&lt;br /&gt;      hash &lt;font color="#990000"&gt;=&lt;/font&gt; &lt;font color="#009900"&gt;sha&lt;/font&gt;&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;new&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;&lt;font color="#009900"&gt;sha&lt;/font&gt;&lt;font color="#990000"&gt;.&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;new&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;line&lt;font color="#990000"&gt;[:-&lt;/font&gt;&lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;]).&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;digest&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;()).&lt;/font&gt;&lt;b&gt;&lt;font color="#000000"&gt;hexdigest&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;()&lt;/font&gt;&lt;br /&gt;      &lt;b&gt;&lt;font color="#0000FF"&gt;for&lt;/font&gt;&lt;/b&gt; login &lt;b&gt;&lt;font color="#0000FF"&gt;in&lt;/font&gt;&lt;/b&gt; processed&lt;font color="#990000"&gt;:&lt;/font&gt;&lt;br /&gt;        &lt;b&gt;&lt;font color="#0000FF"&gt;if&lt;/font&gt;&lt;/b&gt; hash &lt;font color="#990000"&gt;==&lt;/font&gt; login&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;2&lt;/font&gt;&lt;font color="#990000"&gt;]:&lt;/font&gt;&lt;br /&gt;          &lt;b&gt;&lt;font color="#0000FF"&gt;print&lt;/font&gt;&lt;/b&gt; &lt;font color="#FF0000"&gt;"'%s'@'%s': '%s'"&lt;/font&gt; &lt;font color="#990000"&gt;%&lt;/font&gt; &lt;font color="#990000"&gt;(&lt;/font&gt;login&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;0&lt;/font&gt;&lt;font color="#990000"&gt;],&lt;/font&gt; login&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;],&lt;/font&gt; line&lt;font color="#990000"&gt;[:-&lt;/font&gt;&lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;])&lt;/font&gt;&lt;br /&gt;          &lt;b&gt;&lt;font color="#0000FF"&gt;break&lt;/font&gt;&lt;/b&gt;&lt;br /&gt;  &lt;b&gt;&lt;font color="#0000FF"&gt;else&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;:&lt;/font&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color="#0000FF"&gt;try&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;:&lt;/font&gt;&lt;br /&gt;      depth &lt;font color="#990000"&gt;=&lt;/font&gt; &lt;b&gt;&lt;font color="#000000"&gt;int&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;&lt;font color="#009900"&gt;sys&lt;/font&gt;&lt;font color="#990000"&gt;.&lt;/font&gt;argv&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;1&lt;/font&gt;&lt;font color="#990000"&gt;])&lt;/font&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color="#0000FF"&gt;except&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;:&lt;/font&gt;&lt;br /&gt;      &lt;b&gt;&lt;font color="#0000FF"&gt;print&lt;/font&gt;&lt;/b&gt; &lt;font color="#FF0000"&gt;"Usage: %s [dictionary file | brute force depth]"&lt;/font&gt; &lt;font color="#990000"&gt;%&lt;/font&gt; &lt;font color="#009900"&gt;sys&lt;/font&gt;&lt;font color="#990000"&gt;.&lt;/font&gt;argv&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;0&lt;/font&gt;&lt;font color="#990000"&gt;]&lt;/font&gt;&lt;br /&gt;    &lt;b&gt;&lt;font color="#000000"&gt;recurse&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;(&lt;/font&gt;depth&lt;font color="#990000"&gt;,&lt;/font&gt; processed&lt;font color="#990000"&gt;)&lt;/font&gt;&lt;br /&gt;&lt;b&gt;&lt;font color="#0000FF"&gt;else&lt;/font&gt;&lt;/b&gt;&lt;font color="#990000"&gt;:&lt;/font&gt;&lt;br /&gt;  &lt;b&gt;&lt;font color="#0000FF"&gt;print&lt;/font&gt;&lt;/b&gt; &lt;font color="#FF0000"&gt;"Usage: %s [dictionary file | brute force depth]"&lt;/font&gt; &lt;font color="#990000"&gt;%&lt;/font&gt; &lt;font color="#009900"&gt;sys&lt;/font&gt;&lt;font color="#990000"&gt;.&lt;/font&gt;argv&lt;font color="#990000"&gt;[&lt;/font&gt;&lt;font color="#993399"&gt;0&lt;/font&gt;&lt;font color="#990000"&gt;]&lt;/font&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6054074612023958651-5813360342557399479?l=psychoticspoon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psychoticspoon.blogspot.com/feeds/5813360342557399479/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psychoticspoon.blogspot.com/2010/03/newer-versions-of-mysql-stores.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/5813360342557399479'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/5813360342557399479'/><link rel='alternate' type='text/html' href='http://psychoticspoon.blogspot.com/2010/03/newer-versions-of-mysql-stores.html' title='Test MySQL password strength'/><author><name>Spoon</name><uri>http://www.blogger.com/profile/17191979739240352083</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6054074612023958651.post-2579957636234061374</id><published>2009-11-14T15:55:00.000-08:00</published><updated>2009-11-14T16:04:45.304-08:00</updated><title type='text'>Convert mkv files to xvid for Xbox 360</title><content type='html'>&lt;a href="http://ushare.geexbox.org/"&gt;Ushare&lt;/a&gt; is an excellent media server that allows you to watch videos, listen to music and view pictures on your Xbox 360 that are stored on another computer. Unfortunately, the Xbox can be somewhat finicky about which formats it supports - and it doesn't support &lt;a href="http://en.wikipedia.org/wiki/Matroska"&gt;mkv&lt;/a&gt; files. To convert it to a file that the Xbox does support, you can use mencoder as follows:&lt;br /&gt;&lt;blockquote&gt;mencoder inputFile.mkv -ffourcc XVID -ovc lavc -lavcopts vcodec=mpeg4:threads=8:vbitrate=1000:cmp=2:subcmp=2:trell=yes:v4mv=yes:mbd=2 -oac lavc -lavcopts acodec=ac3:abitrate=128 -channels 2 -o outputFile.avi&lt;/blockquote&gt;&lt;br /&gt;If the original file is high quality, you'll probably want to increase the vbitrate parameter to prevent the quality from degrading. If you have surround sound, you should set the number of channels to 6 and set the audio bitrate higher (384 is probably a good choice) as well.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6054074612023958651-2579957636234061374?l=psychoticspoon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psychoticspoon.blogspot.com/feeds/2579957636234061374/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psychoticspoon.blogspot.com/2009/11/convert-mkv-files-to-xvid-for-xbox-360.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/2579957636234061374'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/2579957636234061374'/><link rel='alternate' type='text/html' href='http://psychoticspoon.blogspot.com/2009/11/convert-mkv-files-to-xvid-for-xbox-360.html' title='Convert mkv files to xvid for Xbox 360'/><author><name>Spoon</name><uri>http://www.blogger.com/profile/17191979739240352083</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6054074612023958651.post-562423287540586325</id><published>2009-01-10T13:59:00.000-08:00</published><updated>2009-01-10T14:16:50.092-08:00</updated><title type='text'>Using Javadoc with Eclipse in Ubuntu</title><content type='html'>&lt;p&gt;When you're using Eclipse to program in Java and you hover over a keyword (like a function name, a package, or a class), some Javadoc will be displayed, showing what the keyword does and how it is used. The default installation of Eclipse did not include Javadoc, so hovering over keywords only gave me a message that Javadoc wasn't installed. Here's how to get Javadoc installed and working.&lt;br /&gt;&lt;p&gt;First, enter&lt;br /&gt;&lt;tt&gt;sudo apt-get install sun-java6-doc&lt;/tt&gt;&lt;br /&gt;The installer will prompt you to download a zip file containing the documentation from Sun. Bring up Firefox and head to &lt;a href="http://java.sun.com/javase/downloads/"&gt;Sun's website&lt;/a&gt;. Click the Download link next to Java SE 6 Documentation, agree to the terms and click Continue. Click the zip file to download the documentation.&lt;br /&gt;&lt;p&gt;When the download finishes, in another terminal, enter&lt;br /&gt;&lt;tt&gt;sudo mv /path/to/zip/file/documentation.zip /tmp/jdk-6-doc.zip&lt;/tt&gt;&lt;br /&gt;You need to rename the file to &lt;tt&gt;jdk-6-doc.zip&lt;/tt&gt; for the installer to work. Enter&lt;br /&gt;&lt;tt&gt;sudo chown root:root /tmp/jdk-6-doc.zip&lt;/tt&gt;&lt;br /&gt;to change the file permissions.&lt;br /&gt;&lt;p&gt;Back in the first terminal, hit enter, and the installer should continue. When it finishes, in Eclipse, click Window - Preferences - Java - Installed JREs, and click the JRE (mine was called java-sun-1.6.0.07). Click Edit, and use Shift+Click to select all the JRE system libraries. Click Javadoc Location, and enter &lt;tt&gt;file:/usr/lib/jvm/java-6-sun/docs/api/&lt;/tt&gt; in the box. Click Validate to test it (you can open it in your browser to double check), and click OK out of all the dialogs. Javadoc should now be working!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6054074612023958651-562423287540586325?l=psychoticspoon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psychoticspoon.blogspot.com/feeds/562423287540586325/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psychoticspoon.blogspot.com/2009/01/using-javadoc-with-eclipse-in-ubuntu.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/562423287540586325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/562423287540586325'/><link rel='alternate' type='text/html' href='http://psychoticspoon.blogspot.com/2009/01/using-javadoc-with-eclipse-in-ubuntu.html' title='Using Javadoc with Eclipse in Ubuntu'/><author><name>Spoon</name><uri>http://www.blogger.com/profile/17191979739240352083</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6054074612023958651.post-1377968158954965985</id><published>2009-01-07T22:49:00.000-08:00</published><updated>2009-01-08T00:52:27.559-08:00</updated><title type='text'>Booting multiple LiveCD's from a single USB stick</title><content type='html'>&lt;p&gt;I love LiveCD's - they let you try out an operating system or Linux distro without messing with your current installation. Recently, I've become hooked on LiveUSB distro's that allow you to boot off of a USB stick rather than a CD. I tried putting &lt;a href="http://www.remote-exploit.org/backtrack.html"&gt;Backtrack&lt;/a&gt; on a 1 GB stick, and then &lt;a href="http://damnsmalllinux.org/"&gt;DamnSmallLinux&lt;/a&gt; on a 64 MB stick. I started wondering if it would be possible to put several distributions on a larger stick, and then boot from one of your choice. It turns out that it is possible, and here's how.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-weight: bold;"&gt;Things you will need&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;an i386 computer running Linux (other architectures won't work with the bootloader)&lt;/li&gt;&lt;li&gt;ISO images of LiveCDs (or LiveUSBs) you want to run&lt;/li&gt;&lt;li&gt;a large USB stick that can hold all the images&lt;/li&gt;&lt;li&gt;&lt;b&gt;Optional:&lt;/b&gt; QEmu can be installed to test the stick, or boot LiveCD's from within your host OS.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I started off by downloading five ISO images: &lt;a href="http://www.belenix.org/"&gt;Belenix&lt;/a&gt;, &lt;a href="http://www.remote-exploit.org/backtrack.html"&gt;Backtrack&lt;/a&gt;, &lt;a href="http://www.freesbie.org/"&gt;Freesbie&lt;/a&gt;, &lt;a href="http://www.knoppix.net/"&gt;Knoppix&lt;/a&gt;, and &lt;a href="http://www.nimblex.net/"&gt;NimbleX&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Insert your USB stick. In a console, enter&lt;br /&gt;&lt;tt&gt;dmesg | tail&lt;/tt&gt;&lt;br /&gt;You should see something similar to&lt;br /&gt;&lt;tt&gt;sd 9:0:0:0: [sdc] Attached SCSI removable disk&lt;/tt&gt;&lt;br /&gt;My USB stick is therefore attached at &lt;tt&gt;/dev/sdc&lt;/tt&gt;, although yours will probably be different. From here on out, I'll refer to your drive as driveName. To make sure you have the right drive, as root, enter&lt;br /&gt;&lt;tt&gt;fdisk -l /dev/driveName&lt;/tt&gt;&lt;br /&gt;It should report the size of your USB stick.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;We're going to partition the USB stick for use with each LiveCD. &lt;b&gt;This will destroy all data on the stick! Make sure you're using the correct drive from above too, or you might accidentally wipe your hard drive!&lt;/b&gt;&lt;br /&gt;As root, enter&lt;br /&gt;&lt;tt&gt;fdisk /dev/driveName&lt;/tt&gt;&lt;br /&gt;You can enter &lt;tt&gt;p&lt;/tt&gt; to show the current partitions. It should list a number of partitions. Delete each of them by entering &lt;tt&gt;d&lt;/tt&gt; and entering each number.&lt;br /&gt;When you've deleted them all, enter &lt;tt&gt;n&lt;/tt&gt; for a new partition. Choose &lt;tt&gt;p&lt;/tt&gt; for a primary partition, hit enter for the default, and enter &lt;tt&gt;+16M&lt;/tt&gt; to make a 16 MB partition at the beginning of the drive. Enter &lt;tt&gt;a&lt;/tt&gt; to make the partition bootable, and enter &lt;tt&gt;t&lt;/tt&gt; to change the partition type. Enter &lt;tt&gt;6&lt;/tt&gt; for the partition type.&lt;br /&gt;Now you're going to make an extended partition, and logical partitions for each of your ISO images. First, note the size in MB of all of your ISO images. Mine were 696, 784, 672, 697, and 200. You can find these in another terminal by running &lt;tt&gt;ls -lh *.iso&lt;/tt&gt; in the directory containing your ISO images. When you use these numbers, you'll want to add 5 MB to them to make sure they fit in the partition.&lt;br /&gt;In fdisk, enter &lt;tt&gt;n&lt;/tt&gt; for new partition, &lt;tt&gt;e&lt;/tt&gt; for extended, and enter twice to fill the rest of the drive. Enter &lt;tt&gt;n&lt;/tt&gt;, &lt;tt&gt;l&lt;/tt&gt; for logical, enter for the default, and &lt;tt&gt;+sizeM&lt;/tt&gt;, where size is the size of your first ISO image &lt;i&gt;plus 5 MB&lt;/i&gt;. In my case, I ran &lt;tt&gt;+701M&lt;/tt&gt;. Repeat this procedure for the remainder of your ISO files.&lt;br /&gt;When you are done, enter &lt;tt&gt;p&lt;/tt&gt; to make sure everything looks right. Your output should look similar to this:&lt;br /&gt;&lt;pre class="source-code"&gt;&lt;code&gt;&lt;br /&gt;Device Boot      Start         End      Blocks   Id  System&lt;br /&gt;/dev/sdc1   *           1           3       24066    6  FAT16&lt;br /&gt;/dev/sdc2               4         488     3895762+   5  Extended&lt;br /&gt;/dev/sdc5               4          97      717824+  83  Linux&lt;br /&gt;/dev/sdc6              98         203      809984+  83  Linux&lt;br /&gt;/dev/sdc7             204         294      693248   83  Linux&lt;br /&gt;/dev/sdc8             295         388      718848+  83  Linux&lt;br /&gt;/dev/sdc9             389         416      209920+  83  Linux&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;If everything looks good, enter &lt;tt&gt;w&lt;/tt&gt; to write the changes to the USB stick. If you messed up, you can enter &lt;tt&gt;q&lt;/tt&gt; to quit and try again.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now we're going to install the bootloader. Most Linux distributions use GRUB or LILO, which are great, but since we're trying to boot ISO images off of a USB stick, we're going to use something a little different. &lt;a href="http://gujin.sourceforge.net/"&gt;Gujin&lt;/a&gt; is an alternative bootloader that can boot all sorts of things, and will automatically scan your partitions to look for Linux kernels. It's a handy piece of software, and if you find it useful, you should consider &lt;a href="http://sourceforge.net/donate/index.php?group_id=15465"&gt;donating&lt;/a&gt;. &lt;small&gt;(Disclaimer: I don't know the author and make no money off of your donation)&lt;/small&gt;&lt;br /&gt;First, format the first partition on your USB stick by entering&lt;br /&gt;&lt;tt&gt;mkfs.msdos -F 16 /dev/driveName1&lt;/tt&gt;&lt;br /&gt;Then, download the &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=15465&amp;amp;package_id=76732&amp;amp;release_id=574220"&gt;&lt;br /&gt;Gujin installer&lt;/a&gt; and unzip it. Enter the &lt;tt&gt;gujin-install&lt;/tt&gt; directory and run&lt;br /&gt;&lt;tt&gt;./instboot boot.bin /dev/driveName1 --disk=BIOS:0x80 -w&lt;/tt&gt;&lt;br /&gt;This will install the bootloader to the first partition. The -w option prints out useful debugging information.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;At this point, your USB stick should be bootable. You can test it in another terminal by running&lt;br /&gt;&lt;tt&gt;qemu -usb /dev/diskDrive&lt;/tt&gt;&lt;br /&gt;Your output should look similar to this:&lt;br /&gt;&lt;img src="http://www.skari.org/blogger/gujin-start.gif" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now, you're ready to copy the ISO images onto your disk. Enter&lt;br /&gt;&lt;tt&gt;fdisk -l /dev/diskDrive&lt;/tt&gt;&lt;br /&gt;and find the number of the first partition under 'extended' block. For example, mine above was sdc5. This is where the first ISO image will go. Make sure you're using the right ISO image for the partition size, and enter&lt;br /&gt;&lt;tt&gt;cat nameOfImage1.iso &gt; /dev/diskImage5&lt;/tt&gt;&lt;br /&gt;to copy the ISO image to partition 5. When that finishes, similarly copy the other ISO images onto the other partitions.&lt;br /&gt;&lt;tt&gt;cat nameOfImage2.iso &gt; /dev/diskImage6&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;cat nameOfImage3.iso &gt; /dev/diskImage7&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;...&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You can test your USB stick in another terminal again by running&lt;br /&gt;&lt;tt&gt;qemu -usb /dev/diskDrive&lt;/tt&gt;&lt;br /&gt;The full Gujin menu should now be displayed!&lt;br /&gt;&lt;img src="http://www.skari.org/blogger/gujin-installed.gif" /&gt;&lt;br /&gt;At this point, I had to scroll down a page (using Page Down). The options you want are listed with the code 0x80 and the '&lt;a href="http://en.wikipedia.org/wiki/El_Torito_%28CD-ROM_standard%29"&gt;El Torito&lt;/a&gt;' option:&lt;br /&gt;&lt;img src="http://www.skari.org/blogger/gujin-installed2.gif" /&gt;&lt;br /&gt;Press the appropriate key (F1, F2, etc.) to boot and you should see that CD's particular GRUB screen!&lt;br /&gt;&lt;img src="http://www.skari.org/blogger/gujin-nimblex.gif" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If everything works, you should be able to boot any of your LiveCDs from USB.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6054074612023958651-1377968158954965985?l=psychoticspoon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psychoticspoon.blogspot.com/feeds/1377968158954965985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psychoticspoon.blogspot.com/2009/01/booting-multiple-livecds-from-single.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/1377968158954965985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6054074612023958651/posts/default/1377968158954965985'/><link rel='alternate' type='text/html' href='http://psychoticspoon.blogspot.com/2009/01/booting-multiple-livecds-from-single.html' title='Booting multiple LiveCD&apos;s from a single USB stick'/><author><name>Spoon</name><uri>http://www.blogger.com/profile/17191979739240352083</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry></feed>
