<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>idlethreat &#187; Code</title>
	<atom:link href="http://idlethreat.com/site/index.php/archives/category/code/feed" rel="self" type="application/rss+xml" />
	<link>http://idlethreat.com/site</link>
	<description>stupid is durable</description>
	<lastBuildDate>Fri, 03 Sep 2010 11:33:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>How to Use the Command Line to Test Cipher Strength</title>
		<link>http://idlethreat.com/site/index.php/archives/181</link>
		<comments>http://idlethreat.com/site/index.php/archives/181#comments</comments>
		<pubDate>Thu, 28 Jan 2010 17:06:44 +0000</pubDate>
		<dc:creator>crickel</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://idlethreat.com/site/?p=181</guid>
		<description><![CDATA[Using curl and s_client to test SSL cipher strength on website is darn handy, but there are a few roadbumps to be aware of in the process.]]></description>
			<content:encoded><![CDATA[<p>Hi everyone! A friend of mine convinced me that I should be putting technical items up on a blog. So without further ado:</p>
<p>Everyone knows that transmitting private data using https is far more secure than using http. But how secure is it, really? There are many different encryption methods that https has available to it, especially in a default configuration. Sometimes, however, you may not have the configuration available to check. And even if you have access, even when you&#8217;ve modified your default configuration to be secure, rogue included configuration files may change the ciphers settings on a site-per-site basis. The best way to be sure that your website is configured to use strong ciphers is to test it.</p>
<p>There are many fine tools out there that already fill this need. Some of them, such as Foundstone&#8217;s SSLDigger, can even generate and save attractive reports to hand to the administrators. (Red ink is optional.) The fastest way to test your cipher strength, though, is right within your reach at the command line.</p>
<p>There are two applications I&#8217;m going to cover here, curl and openssl.</p>
<h2>openssl</h2>
<p>openssl has many useful commands when it comes to using ciphers. Right now, I&#8217;m only going over the two we&#8217;re concerned with. The first, of course, is the &#8216;openssl ciphers&#8217; command, which can fetch you a list of ciphers available on the server. If the cipher isn&#8217;t in this list, you can&#8217;t even configure your system to use it, so doublecheck what LOW, MEDIUM, and HIGH ciphers you have available first!</p>
<pre style="padding-left: 30px;">openssl cipers -v 'HIGH'</pre>
<p>The second command is the openssl s_client. It has a couple quirks. Here&#8217;s an example:</p>
<pre style="padding-left: 30px;">echo 'GET HTTP/1.0' | openssl s_client -connect gmail.com:443</pre>
<p>Notice that the line starts with an &#8216;echo&#8217;. When s_client connects to a host, it then waits for user input for what it sends to the remote host. It needs to send an appropriate &#8216;GET&#8217; string in order to fetch data. So we feed that input to it in a pipe, it&#8217;s happy, the remote server&#8217;s happy, and everybody gets what they&#8217;re looking for.</p>
<p>This little command is quite versitile and robust. For instance, you can fetch a remote certificate and check the dates on it like this:</p>
<pre style="padding-left: 30px;">echo 'GET HTTP/1.0' | openssl s_client -connect www.google.com:443 2&gt;/dev/null |\
sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' |\
openssl x509 -noout -subject -dates</pre>
<p>What we&#8217;re interested in, though, is testing out ciphers.</p>
<pre style="padding-left: 30px;">echo 'GET HTTP/1.0' | openssl s_client -cipher HIGH -connect gmail.com:443</pre>
<p>The -cipher option takes a cipherlist and uses only those ciphers. For the the nitty gritty details about what constitutes a cipher list, check &#8216;man ciphers&#8217; &#8211; but you should already have a good idea on this. Remember to make sure and use &#8216;openssl ciphers&#8217; to check your server specifically if you&#8217;re having problems!</p>
<h2>curl</h2>
<p>One thing that&#8217;s important to note is that we&#8217;ve found through testing on multiple servers that the curl command does not always use the ciphers given in the arguments. Sometimes it fails and simply continues on with the strongest ciphers available instead. That said, if it DOES use the proper ciper (and you can tell if it does in the verbose output!) it&#8217;s more convenient since you don&#8217;t have to pipe things at it.</p>
<pre style="padding-left: 30px;">curl --ciphers HIGH -v https://www.google.com</pre>
<p>Note that if you&#8217;re trying to pipe output to a file, more or less, curl uses STDERR for all its verbose output, and STDOUT for all the. You&#8217;ll need to redirect both of them in order to get the whole story.</p>
<pre style="padding-left: 30px;">curl --ciphers HIGH -v https://www.google.com &amp;&gt; test.txt</pre>
<p>Using the pipe is even more fun. This redirects STDERR to STDOUT and then lobs them both through the pipe:</p>
<pre style="padding-left: 30px;">curl --ciphers HIGH -v https://www.google.com 2&gt;&amp;1 | less</pre>
<p>There are many more options available to curl that can be found in the manual, including authenticating with usernames and passwords, POST variables, change the user agent and even limit the speed to simulate real user scenarios.</p>
<p>Using these commands, you can quickly and easily test your webpage performance under realistic scenarios and record results from ciphers on the command line directly, without having to break out your GUI and get your hands dirty.</p>
]]></content:encoded>
			<wfw:commentRss>http://idlethreat.com/site/index.php/archives/181/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visualizing network connections using GraphViz and Afterglow</title>
		<link>http://idlethreat.com/site/index.php/archives/5</link>
		<comments>http://idlethreat.com/site/index.php/archives/5#comments</comments>
		<pubDate>Sun, 15 Mar 2009 16:53:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[GraphViz]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[After recovering from a particularly nasty crash and migrating my sites and data over to a new server, I became curious at the number of networking connections that it received, and what was going where. Sure, there&#8217;s a lot of tools out there to give me that sort of information, but sometimes you would really [...]]]></description>
			<content:encoded><![CDATA[<p>After recovering from a particularly nasty crash and migrating my sites and data over to a new server, I became curious at the number of networking connections that it received, and what was going where. Sure, there&#8217;s a lot of tools out there to give me that sort of information, but sometimes you would really just like a pretty (if informative) picture of information instead of dry old text scrolling across the screen.<br />
<span id="more-5"></span><br />
In this document I&#8217;ll assume the following:</p>
<p>You have access to a Linux / Unix server system and have administrative capabilities on it.</p>
<h2>tools I used</h2>
<p>Graphviz is an open source graph visualization software. It takes standard textual input and can automatically generate graphs depending on the input itself. It has its own graphing language, which is used to create all of this information for you.</p>
<p>Afterglow is a collection of scripts which assist in converting csv and other table data into information which can be pushed off to Graphviz to generate graphs with.</p>
<p>I also ended up with a &#8216;glue&#8217; shell script or two which assisted in gathering the information and pushing it off to Afterglow for processing.</p>
<h2>How To</h2>
<p>Download and install <a href="http://www.graphviz.org/">GraphViz</a> using your favorite package management system. Next, download and un-archive the <a href="http://afterglow.sourceforge.net/">Afterglow</a> package on the system. For myself, I placed all the Afterglow packages from afterglow/src/perl directory to a new /opt/afterglow directory.</p>
<p>After that has been set up, it&#8217;s time to get a tcpdump of your current connections. We&#8217;ll grab the first 10,000 packets and put it in the /opt/afterglow directory.</p>
<p><code class="prettyprint">tcpdump -vttttnneli eth0 -c10000 &gt; /opt/afterglow/eth0.dump</</code></p>
<p>Next, we'll parse it through Afterglow and let it do its magic. In this instance, we'll be looking at the source IP, destination IP, and finally the destination port. There's quite a number of possible fields to go by. Check out the source code from tcpdump2csv.pl for a full treatment of what is available.</p>
<p><code class="prettyprint">cat /opt/afterglow/eth0.dump | /opt/afterglow/parsers/tcpdump2csv.pl "sip dip dport" | /opt/afterglow/graph/afterglow.pl -c /opt/afterglow/parsers/color.properties -e 2 | neato -Tgif -o /opt/afterglow/eth0.gif</code>></p>
<p><img src="http://idlethreat.com/files/networking/fig1.gif" alt="" width="500" /></p>
<p>The initial run is interesting, but pretty cluttered. Looks more like a geek version of a fertilized-egg-and-sperm picture.</p>
<p>Since we're using three arguments (sip dip dport) as arguments, let's change the mode from the default (zero) up to three and then re-run the results.</p>
<p><code class="prettyprint">cat /opt/afterglow/eth0.dump | /opt/afterglow/parsers/tcpdump2csv.pl "sip dip dport" | /opt/afterglow/graph/afterglow.pl -p3 -c /opt/afterglow/parsers/color.properties -e 2 | neato -Tgif -o /opt/afterglow/eth0.gif</code></p>
<p><img src="http://idlethreat.com/files/networking/fig2.gif" alt="" width="500" /></p>
<p>This one is much more revealing and easy to read. You will notice by now that:</p>
<ul>
<li>Arrows show the direction of traffic</li>
<li>Red ovals will be an IP address which <strong>initiates</strong> a connection. A lot of the time this will be your own system. Other times it will be an external system sending in a request.</li>
<li>Red blocks will be an IP address which is <strong>processing</strong> a request. Again, your system will show up either as a processor of requests, or sending something out.</li>
<li>Light Blue Ovals will show which port this traffic is traveling across</li>
<li>Dark Blue Ovals will show up whenever communication is going across a 'named' port (below 1024). This is normally like port 80, 443, or 53 (DNS).</li>
</ul>
<p>Changing colors to fit your needs are relatively easy as well. I like a nice bright green to distinguish my system against all the other connections out there. To color your own "home" system as green, edit the /opt/afterglow/parsers/color.properties. At the top of the regex list, add in a line something like:</p>
<p><code class="prettyprint">color.source="green" if ($fields[0]=~/^your.ip.address.here/);</code></p>
<p>Save your changes and re-run the script to get an output where your IP address has a dinstinct color to it.</p>
<p><img src="files/networking/fig3.gif" alt="" width="500" /></p>
<p>Finally, if you would like to have a constantly refreshing view of your server traffic, then something like this should work out well for you:</p>
<p><code class="prettyprint"><br />
while true; do<br />
tcpdump -vttttnneli eth0 -c 2000 &gt; /opt/afterglow/current.dump<br />
cat current.dump |/opt/afterglow/parsers/tcpdump2csv.pl "sip dip dport" | /opt/afterglow/graph/afterglow.pl -p3 -c /opt/afterglow/parsers/color.properties -e 2 | neato -Tgif -o /var/www/yourwebsite.com/traffic.gif<br />
sleep 60<br />
done<br />
</code></p>
<p>Kick off the script, let it run once, and then hit <a title="http://yourwebsite.com/traffic.gif" href="http://yourwebsite.com/traffic.gif">http://yourwebsite.com/traffic.gif</a> for the story. It will refresh every 60 seconds.</p>
<h2>Summary</h2>
<p>Using Graphviz and Afterglow will give you a unique overview of your incoming and outgoing traffic and a much broader overview of what is coming in and out of your immediate network. This is a wonderful tool and one that deserves to be in every server geek's arsenal.</p>
<p>Enjoy!</p>
<p>tom</p>
]]></content:encoded>
			<wfw:commentRss>http://idlethreat.com/site/index.php/archives/5/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spotlight Image Gallery</title>
		<link>http://idlethreat.com/site/index.php/archives/16</link>
		<comments>http://idlethreat.com/site/index.php/archives/16#comments</comments>
		<pubDate>Tue, 30 Sep 2008 23:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[On the heels of my previous app which used Apple&#039;s Spotlight searching capabilities to create your own personal search engine, I have written a new application to create your own web photo gallery from a Spotlight search. All of the code is based off of the previous application, so there&#039;s no shockers to getting it [...]]]></description>
			<content:encoded><![CDATA[<p>On the heels of my <a href="http://idlethreat.com/drupal/?q=node/51">previous app</a> which used Apple&#039;s Spotlight searching capabilities to create your own personal search engine, I have written a new application to create your own web photo gallery from a Spotlight search.</p>
<p><span id="more-16"></span></p>
<p>All of the code is based off of the previous application, so there&#039;s no shockers to getting it setup on your own mac- just change the name in your head from &#039;search&#039; to &#039;image&#039; and you should be just fine.</p>
<p>The one thing that <b>has</b> changed is the search string being used. While the search engine was only searching for the contents of all files, we are search all files for a particular <i>type</i>. </p>
<p>In Mac OS X 10.5, groups of file types are placed into groups. As it happens, the  _kMDItemGroupId of &#8220;all images&#8221; happens to be 13. So, in the search, we&#039;re just running something like:</p>
<p><tt>mdfind _kMDItemGroupId = 13</tt></p>
<p>from the command line and parsing the results which come back from the search.</p>
<p>Unfortunately, I have no clue what the GroupId is in 10.4, so this script will probably only work reliably in 10.5. Besides, don&#039;t you think it&#039;s time to upgrade?</p>
<p>Anyway, download is located <a href="http://idlethreat.com/drupal/files/spotlight.image.gallery.zip">over here</a>. To use, check out the documents on the <a href="http://idlethreat.com/drupal/?q=node/51">search app</a>. They&#039;re very close together when it comes to code reuse.</p>
<p>Also, forgive me for calling it an &#039;image gallery&#039;. It just pretty much outputs images and that&#039;s it. However, there&#039;s a lot of code out there that can show you how to turn an array of images into an actual gallery, so I didn&#039;t include all those bits in there. That, is an exercise left up to the Dear Reader to perform.</p>
<p>Enjoy!</p>
<p>tom</p>
]]></content:encoded>
			<wfw:commentRss>http://idlethreat.com/site/index.php/archives/16/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turning Your Mac Into a Search Engine</title>
		<link>http://idlethreat.com/site/index.php/archives/17</link>
		<comments>http://idlethreat.com/site/index.php/archives/17#comments</comments>
		<pubDate>Sun, 21 Sep 2008 07:52:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Spotlight is one of the more interesting, and (for me), useful features of Apple&#039;s Mac OSX. While it&#039;s superb with locating documents, programs, and the like, it really shines when it comes to the number if built-in and freely available plugins for use. So, basically, you have an inbuilt system on Mac OS X which [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Spotlight_(software)">Spotlight</a> is one of the more interesting, and (for me), useful features of Apple&#039;s Mac OSX. While it&#039;s superb with locating documents, programs, and the like, it really shines when it comes to the number if built-in and <a href="http://www.apple.com/downloads/macosx/spotlight/">freely available</a> plugins for use.</p>
<p>So, basically, you have an inbuilt system on Mac OS X which will allow you to search text files, html files, images, Word documents, PDF&#039;s, the list goes on and on. The really interesting bit (to me, at least) is that there&#039;s nothing to configure or tweak. If you are running a Mac, then everything copied over to the file system is automatically indexed, and made quickly available for searching- even from a web browser.</p>
<p><span id="more-17"></span></p>
<h2>Setup</h2>
<p>All that I am using here is Apache, PHP 5.2, and the command line Spotlight search application &#8220;mdfind&#8221;. All of these technologies are already built into OSX 10.5 and ready for use. All I ended up doing was creating a web interface to them.</p>
<p>Since Spotlight has its own database (sqlite), there is no need to anyfor any database connection. Also, since all of the importing is handled in the background, there&#039;s nothing to write or tweak. It just works. However, if you are wanting a little more control on how Spotlight searches your data, I&#039;d recommend checking out the relevant Apple documentation or <a href="http://www.macworld.com/article/45793/2005/07/augustgeekfactor.html">this helpful page</a> with more information on Spotlight from the command line.</p>
<h2>Web-ifying Search</h2>
<p>Well, enough of the gushing about the searching capabilities, how can we turn this puppy into a document search repository?</p>
<p>basically, the PHP script will run a command line query and then output the results back to the screen. The configuration file (conf.php) will let you set the relevant paths so that all the correct links go to the right places.</p>
<p>The only caveat is that if you search for something silly (like the word &#8220;the&#8221; as the only search term), the script will take a <b>long time</b> for it to return any relevant results back to you. There should be a way to tie in an array of <a href="http://www.google.com/search?q=stop+words">&#8220;stop words&#8221;</a> to reject those searches, but adding that functionality in is left up to the discretion of the reader.</p>
<h2>Install</h2>
<p>Anyway, download a copy of it over <a href="http://idlethreat.com/drupal/files/search.zip">over here</a> and extract it.</p>
<p>Copy the search/ directory to the default web directory on the mac (normally, its /Library/WebServer/Documents/) so that the full path looks like:</p>
<p>/Library/WebServer/Documents/search</p>
<p>Drop some documents into the /Library/WebServer/Documents/search/documents/ directory. These can be .PDF files, Word documents, etc. Whatever you want to peek at.</p>
<p>Open your web browser and browse to <a href="http://localhost/search/index.php" title="http://localhost/search/index.php">http://localhost/search/index.php</a> and make a search.</p>
<p>That really should be it. If you run into any issues, let me know.</p>
<h2>Caveats</h2>
<p>I seem to remember a while back having issues with search to function correctly under 10.4. This ended up being permissions issues in the httpd.conf file. 10.4&#039;s Apache run as the &#039;nobody&#039; user. Switching to the &#039;www&#039; user fixed the issue. If that does not do it for you, try running Apache as a standard user and see if you run into any issues with it.</p>
<p>Enjoy!</p>
<p>tom</p>
]]></content:encoded>
			<wfw:commentRss>http://idlethreat.com/site/index.php/archives/17/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weather Script</title>
		<link>http://idlethreat.com/site/index.php/archives/18</link>
		<comments>http://idlethreat.com/site/index.php/archives/18#comments</comments>
		<pubDate>Sat, 20 Sep 2008 03:32:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Well, it looks like it&#039;s been a while since I updated the site with any new content. A lot of that has to do with work, and things on the weekends crowding all the wonderful time that I used to have dedicated to screwing around on the computer. Nevertheless, here&#039;s a bit of an app [...]]]></description>
			<content:encoded><![CDATA[<p>Well, it looks like it&#039;s been a while since I updated the site with any new content. A lot of that has to do with work, and things on the weekends crowding all the wonderful time that I used to have dedicated to screwing around on the computer.</p>
<p>Nevertheless, here&#039;s a bit of an app that I managed to stop messing with and actually prep for release.</p>
<p>Late summer / early fall always gets me interested in the weather a lot more than other times of the year. I poke around at <a href="http://noaa.gov">noaa.gov</a> for weather reports, temperatures, humidity, and all that crap. This year I looked into just pulling the raw information down from noaa, parsing it how I like it, and then working on my local copy of the data.</p>
<p><span id="more-18"></span></p>
<p><a href="http://idlethreat.com/drupal/files/weather_script.zip">Weather Script</a> is the results of my curiosity into creating weather charts for my own use (You can see some example charts over at <a href="http://idlethreat.com/weather">http://idlethreat.com/weather</a>, if you&#039;re curious about what it looks like).</p>
<p>Currently, I capture all the big stuff (temp, humidity, wind, etc.) from noaa&#039;s .xml feed on an hourly basis. That is fed into a MySQL database and can be queried from there to create a wide range of really nice charts and the like using libchart- which is included in the package.</p>
<p>So, if you happen to have a unix box with PHP and wanted to mess around with weather for a bit, this is probably the place for you.</p>
<p>It&#039;s all licensed under a liberal license, so feel free to hack on it and make it yours.</p>
<p>Enjoy.</p>
<p>tom</p>
]]></content:encoded>
			<wfw:commentRss>http://idlethreat.com/site/index.php/archives/18/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Encrypted Browsing Using Squid and OpenVPN</title>
		<link>http://idlethreat.com/site/index.php/archives/19</link>
		<comments>http://idlethreat.com/site/index.php/archives/19#comments</comments>
		<pubDate>Mon, 25 Aug 2008 02:50:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Here&#039;s a rather old-ish document that I published on Google Docs a while back. Now looking back on it, it probably needs a revamp. and filling out of the particular bits. There&#039;s still a deep need to finish up the bottom bit and make it more presentable. This evening I spent quite a bit of [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#039;s a <a href="http://docs.google.com/Doc?id=arhn9hb6htg_8dm53n4">rather old-ish</a> document that I published on <a href="http://docs.google.com">Google Docs</a> a while back.</p>
<p>Now looking back on it, it probably needs a revamp. and filling out of the particular bits. There&#039;s still a deep need to finish up the bottom bit and make it more presentable.</p>
<p>This evening I spent quite a bit of time coming up with a web-based OpenVPN certificate generator. while successful in writing up an application to do the job, there&#039;s still quite a number of dependencies that I need to flesh out and document before I can put everything together and present it.</p>
<p>In any case. Enjoy the other stuff. more later as it comes in.</p>
<p>tom</p>
]]></content:encoded>
			<wfw:commentRss>http://idlethreat.com/site/index.php/archives/19/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UDP Syslog Beacon</title>
		<link>http://idlethreat.com/site/index.php/archives/55</link>
		<comments>http://idlethreat.com/site/index.php/archives/55#comments</comments>
		<pubDate>Thu, 14 Aug 2008 03:43:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Yet another one-trick-pony bit of software. This application will send a &#8220;beacon&#8221; message every two seconds from one server to another via UDP syslog. To make it go, you will need to run it with an argument- the argument is the IP address you wish to send message to. Click read more for examples! &#8220;python [...]]]></description>
			<content:encoded><![CDATA[<p>Yet another one-trick-pony bit of software.</p>
<p>This application will send a &#8220;beacon&#8221; message every two seconds from one server to another via UDP syslog. To make it go, you will need to run it with an argument- the argument is the IP address you wish to send message to. </p>
<p>Click read more for examples!<br />
<span id="more-55"></span><br />
&#8220;python bacon.py 111.111.111.111&#8243; will being sending messages off to IP 111.111.111.111.</p>
<p>You can adjust the port it sends messages to, just check the &#8220;port&#8221; variable and change as needed.</p>
<p>You can download the script <a href="http://idlethreat.com/drupal/files/bacon.zip">here</a>.</p>
<p>Enjoy!</p>
<p>tom</p>
]]></content:encoded>
			<wfw:commentRss>http://idlethreat.com/site/index.php/archives/55/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending Your Clipboard Across The Internet</title>
		<link>http://idlethreat.com/site/index.php/archives/56</link>
		<comments>http://idlethreat.com/site/index.php/archives/56#comments</comments>
		<pubDate>Sun, 27 Jul 2008 14:40:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I&#039;ve been working on some components of Utopiaprojekt this morning and run across the idea of sending the contents of the clipboard across the internet. So, after tooling around for a few minutes, I wrote up a working example using Python on OS X. So, click on Read More for more information on how I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#039;ve been working on some components of <a href="http://utopiaprojekt.com/">Utopiaprojekt</a> this morning and run across the idea of sending the contents of the clipboard across the internet. So, after tooling around for a few minutes, I wrote up a working example using Python on OS X.</p>
<p>So, click on Read More for more information on how I did it.<br />
<span id="more-56"></span><br />
The example will grab whatever text that is in the Pasteboard (analogous to the Clipboard in Windows), transform it to Base64 encoding (which is pretty much the gold standard for encoding text across the internet) and then ship the text off to a server for processing.</p>
<p>Once there, I wrote up a small PHP page which will decode the text, and then write the results to a file on the local server for viewing. Of course, after decoding you can put the text in a database, write it to files, whatever you need it to do. This is just an exercise in getting it from point A to point B without mangling it too bad.</p>
<p>I&#039;ve left a lot of print statements in here and there so you can see the information transform as it occurs. Note that it only works on OS X at the moment.</p>
<p>Enjoy!</p>
<p>tom</p>
<h2>Client Side</h2>
<p><tt><br />
import subprocess, base64, urllib</tt></p>
<p>p = subprocess.Popen(&#8220;pbpaste&#8221;, stdout=subprocess.PIPE)<br />
mytext = p.stdout.read()<br />
encoded = base64.b64encode(mytext)<br />
decoded = base64.b64decode(encoded)</p>
<p>print &#8220;mytext is:&#8221;,mytext , &#8220;n&#8221;<br />
print &#8220;encoded is:&#8221;,encoded , &#8220;n&#8221;<br />
print &#8220;decoded is:&#8221;,decoded , &#8220;n&#8221;</p>
<p>print &#8220;sending the data up to web server n&#8221;</p>
<p>myurl = &#039;http://example.com/test/decode.php?thought=&#039; + encoded</p>
<p>urllib.urlopen(myurl)
</p>
<h2>Server Side</h2>
<p><tt><br />
&lt;?<br />
$thought = $_GET[&#039;thought&#039;];</tt></p>
<p>$stringData = base64_decode($thought);</p>
<p>$myFile = &#8220;testFile.txt&#8221;;<br />
$fh = fopen($myFile, &#039;w&#039;) or die(&#8220;can&#039;t open file&#8221;);<br />
fwrite($fh, $stringData);<br />
fclose($fh);</p>
<p>?></p>
]]></content:encoded>
			<wfw:commentRss>http://idlethreat.com/site/index.php/archives/56/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Echo.py Released!</title>
		<link>http://idlethreat.com/site/index.php/archives/57</link>
		<comments>http://idlethreat.com/site/index.php/archives/57#comments</comments>
		<pubDate>Thu, 24 Jul 2008 12:05:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Introduction This is an old-ish app that I&#039;ve been sitting on over the past few months and thought I should release it before it joins my BPOUS (Big Pile Of Unpublished Stuff) on a random hard drive somewhere. Echo.py is a one trick pony. It tails a (configurable) log file on the system and sends [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>This is an old-ish app that I&#039;ve been sitting on over the past few months and thought I should release it before it joins my BPOUS (Big Pile Of Unpublished Stuff)  on a random hard drive somewhere.</p>
<p>Echo.py is a one trick pony. It tails a (configurable) log file on the system and sends the logs off to a <a href="http://en.wikipedia.org/wiki/Syslog">syslog</a> server for further processing. It&#039;s configurable for either UDP or TCP syslogging and is highly configurable, depending on your environment and needs. It&#039;s been tested on OS X 10.5 and Ubuntu 7.10 with Python 2.5.*</p>
<p>Since this application is written in Python, it can run on Windows, Linux, etc. Pretty much any OS with a Python interpreter can run this script. This script can be compiled as a &#8220;frozen binary&#8221; and run on systems without a Python interpreter installed on it. I will leave that exercise up to you, Dear Reader, on how to accomplish this.</p>
<p>The only real caveat to using the script is that if the application which creates the log file dies and the log is overwritten whenever it comes back up, echo.py will not catch that change and hang up, not sending out logs until it&#039;s restarted. Since the standard UN*X &#039;tail -f&#039; exhibits the same issue, this should be considered normal.</p>
<p>Click Read More for more information.<br />
<span id="more-57"></span></p>
<h2>How To Use</h2>
<p>After downloading and unzipping the archive, run echo.py from the command line without any arguments. It will create a new configuration file (named echo.cfg) in the local directory. Edit the configuration file as you like it and save your changes. Re-run echo.py and it will use the new configuration. The configuration file is well documented and is in a standard .INI format that works well on either UN*X or Windows systems.</p>
<h2>Download</h2>
<p>That should be it. My contact information is in the script itself, let me know if you have any questions or issues with it. Like all the applications and scripts, there&#039;s a license:<br />
<tt><br />
# File Scanner. Copyright (C) 2008 by idlethreat (tgiles at gmail dot com). All rights reserved.<br />
# This program is released under Creative Commons by-nc-sa. <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/" title="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">http://creativecommons.org/licenses/by-nc-sa/3.0/us/</a><br />
# Read the license. Know your rights.<br />
</tt></p>
<p>Enjoy!</p>
<p><a href="http://idlethreat.com/drupal/files/echo.py.zip">echo.py.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://idlethreat.com/site/index.php/archives/57/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac Hotkeys for Windows Users</title>
		<link>http://idlethreat.com/site/index.php/archives/62</link>
		<comments>http://idlethreat.com/site/index.php/archives/62#comments</comments>
		<pubDate>Sun, 22 Jun 2008 21:09:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Muddling About]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[AHK is an excellent scripting program that&#039;s been around for a number of years now. In it, you can create hotkeys and macros for Windows systems to carry out a bewildering array of tasks. I&#039;m a Mac guy who, due to the nature of my work, has to spend a whole lot of time on [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.autohotkey.com/">AHK</a> is an excellent scripting program that&#039;s been around for a number of years now. In it, you can create hotkeys and macros for Windows systems to carry out a bewildering array of tasks.</p>
<p><span id="more-62"></span></p>
<p>I&#039;m a Mac guy who, due to the nature of my work, has to spend a whole lot of time on Windows systems at work. Of all the Mac hotkeys that I miss terribly, <cmd> + W (close window) is probably going to be at the top of my list. So, with a little hacking around last night I&#039;ve successfully crafted up a hotkey (I use <windows key> + W due to its location on the keyboard) which closes the foremost open window.</windows></cmd></p>
<h2>Window Closer</h2>
<p><tt><br />
HotKey, #w, WindowCloser<br />
return</tt></p>
<p>; uncomment below to remove tray icon<br />
; #NoTrayIcon</p>
<p>WindowCloser:<br />
WinGet, active_id, ID, A<br />
WinClose ahk_id %active_id%
</p>
<p>The only real caveat to it is that Windows task management sees open windows as instances of applications. Close a window and you (may) close the application altogether. The Mac sees all open windows as children of the application. Close all the open windows, and the application is still running (and still requires a <cmd> + q to quit it). However, it pretty much works as advertised pretty much everywhere. I will warn you that applications like Firefox will just close altogether when this hotkey is used. So, keep using your <ctrl> + w in Windows to those those tabs individually.</ctrl></cmd></p>
<h2>And Others&#8230;</h2>
<p>While working on that script, I managed to fire off a couple of more scripts that will make things handy for me that I thought I&#039;d share. This one will open up a new Explorer window in whatever folder you wish it to (I defaulted to the C: drive, but that can be changed). This is another Mac hot key that I have always liked. This hotkey is kicked off by using the <win> + n keys.</win></p>
<p><tt><br />
HotKey, #n, NewExplorerWindow<br />
return</tt></p>
<p>; uncomment below to remove tray icon<br />
; #NoTrayIcon</p>
<p>NewExplorerWindow:<br />
Run C:</p>
<p>; This one will open up an explorer window on your personal desktop<br />
;Run C:Documents and Settings%username%Desktop
 </p>
<p>And finally, this one creates a new email whenever you hit the <win> + e keys. I send a whole bunch of emails off every day and know it will be terribly useful here in the very near future.</win></p>
<p><tt><br />
HotKey, #e, EmailMaker<br />
return</tt></p>
<p>; uncomment below to remove tray icon<br />
; #NoTrayIcon</p>
<p>EmailMaker:<br />
Run mailto:
</p>
<h2>How to Implement?</h2>
<p>Grab and install a copy of <a href="http://www.autohotkey.com/">AHK</a> on your windows systems and either copy-paste in my examples that I have above into new .ahk files, or just <a href="http://idlethreat.com/drupal/files/ahk.zip">[Download Here]</a>.</p>
<p>Once you have them on your system and unzipped, edit the files to your liking and run them as is. If you want them to be runnable executables (I.E. .exe files), right-click on them and select &#8220;compile script&#8221; from the list.</p>
<h2></h2>
<p>I just remembered only after writing this was the rather huge project that I once wrote up in AHK at work. This was a few years ago and I was working in the NOC at a web hosting company (that I&#039;m still at, by the way). One issue we alway seemed to run into was running down websites on IIS servers so we could troubleshoot them.</p>
<p>I wrote an AHK script that would pull all the active sites from IIS and copy them over to a Linux server. the Linux box would parse the list (as a .CSV) and inject them into a MySQL database. I wrote a PHP front end to the entire mess and you could perform boolean searches on site names and which server they were parked at.</p>
<p>It was a hackish affair, abd prone to failure, but at the time there was nothing quite like it for a number of years until that functionality was added into our current ERP system. I think I still have the source code for <a href="http://www.badgerbadgerbadger.com/">Badger</a> somewhere around here. </p>
<p>Would be interesting to see those scripts again.</p>
<p>Ok, well, enjoy these for now.</p>
<p>Cheers,</p>
<p>tom</p>
]]></content:encoded>
			<wfw:commentRss>http://idlethreat.com/site/index.php/archives/62/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
