<?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>Saiweb &#187; python</title>
	<atom:link href="http://www.saiweb.co.uk/category/python/feed" rel="self" type="application/rss+xml" />
	<link>http://www.saiweb.co.uk</link>
	<description>Ramblings of a Sys admin</description>
	<lastBuildDate>Mon, 06 Feb 2012 14:57:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>easy_install for python 3</title>
		<link>http://www.saiweb.co.uk/python/easy_install-for-python-3</link>
		<comments>http://www.saiweb.co.uk/python/easy_install-for-python-3#comments</comments>
		<pubDate>Mon, 19 Sep 2011 20:47:05 +0000</pubDate>
		<dc:creator>Buzz</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[easy_install]]></category>
		<category><![CDATA[python3]]></category>

		<guid isPermaLink="false">http://www.saiweb.co.uk/?p=1120</guid>
		<description><![CDATA[easy_install for python3 simple 12curl -O http://python-distribute.org/distribute_setup.py python3 distribute_setup.py Enjoy!Tweet]]></description>
			<content:encoded><![CDATA[<p>easy_install for python3 simple</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">curl -O http://python-distribute.org/distribute_setup.py<br />
python3 distribute_setup.py</div></td></tr></tbody></table></div>
<p>Enjoy!<span style="float: left;" ><a class="twitter-share-button"  data-via="Saiweb" data-count="horizontal" data-related="Saiweb:David Busby" data-lang="en" data-url="http://www.saiweb.co.uk/python/easy_install-for-python-3" data-text="easy_install for python 3" href="http://twitter.com/share?via=Saiweb&#038;count=horizontal&#038;related=Saiweb%3ADavid%20Busby&#038;lang=en&#038;url=http%3A%2F%2Fwww.saiweb.co.uk%2Fpython%2Feasy_install-for-python-3&#038;text=easy_install%20for%20python%203" >Tweet</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saiweb.co.uk/python/easy_install-for-python-3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>matplotlib ImportError: No module named ma</title>
		<link>http://www.saiweb.co.uk/mac/matplotlib-importerror-no-module-named-ma</link>
		<comments>http://www.saiweb.co.uk/mac/matplotlib-importerror-no-module-named-ma#comments</comments>
		<pubDate>Fri, 15 Oct 2010 15:07:12 +0000</pubDate>
		<dc:creator>Buzz</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ma]]></category>
		<category><![CDATA[matplotlib]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[named]]></category>
		<category><![CDATA[no]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://www.saiweb.co.uk/?p=968</guid>
		<description><![CDATA[ImportError: No module named ma Fix is to edit the following files: 12sudo vi /Library/Python/2.6/site-packages/matplotlib-0.91.1-py2.6-macosx-10.6-universal.egg/matplotlib/numerix/ma/__init__.py sudo vi /Library/Python/2.6/site-packages/matplotlib-0.91.1-py2.6-macosx-10.6-universal.egg/matplotlib/numerix/npyma/__init__.py On my installed on lines 16 and 7 respectively replace 1from numpy.core.ma import * with 1from numpy.ma import * and done.Tweet]]></description>
			<content:encoded><![CDATA[<p>ImportError: No module named ma</p>
<p>Fix is to edit the following files:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Python<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2.6</span><span style="color: #000000; font-weight: bold;">/</span>site-packages<span style="color: #000000; font-weight: bold;">/</span>matplotlib-0.91.1-py2.6-macosx-<span style="color: #000000;">10.6</span>-universal.egg<span style="color: #000000; font-weight: bold;">/</span>matplotlib<span style="color: #000000; font-weight: bold;">/</span>numerix<span style="color: #000000; font-weight: bold;">/</span>ma<span style="color: #000000; font-weight: bold;">/</span>__init__.py<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Python<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2.6</span><span style="color: #000000; font-weight: bold;">/</span>site-packages<span style="color: #000000; font-weight: bold;">/</span>matplotlib-0.91.1-py2.6-macosx-<span style="color: #000000;">10.6</span>-universal.egg<span style="color: #000000; font-weight: bold;">/</span>matplotlib<span style="color: #000000; font-weight: bold;">/</span>numerix<span style="color: #000000; font-weight: bold;">/</span>npyma<span style="color: #000000; font-weight: bold;">/</span>__init__.py</div></td></tr></tbody></table></div>
<p>On my installed on lines 16 and 7 respectively replace</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">from</span> numpy.<span style="color: black;">core</span>.<span style="color: black;">ma</span> <span style="color: #ff7700;font-weight:bold;">import</span> *</div></td></tr></tbody></table></div>
<p>with</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">from</span> numpy.<span style="color: black;">ma</span> <span style="color: #ff7700;font-weight:bold;">import</span> *</div></td></tr></tbody></table></div>
<p>and done.<span style="float: left;" ><a class="twitter-share-button"  data-via="Saiweb" data-count="horizontal" data-related="Saiweb:David Busby" data-lang="en" data-url="http://www.saiweb.co.uk/mac/matplotlib-importerror-no-module-named-ma" data-text="matplotlib ImportError: No module named ma" href="http://twitter.com/share?via=Saiweb&#038;count=horizontal&#038;related=Saiweb%3ADavid%20Busby&#038;lang=en&#038;url=http%3A%2F%2Fwww.saiweb.co.uk%2Fmac%2Fmatplotlib-importerror-no-module-named-ma&#038;text=matplotlib%20ImportError%3A%20No%20module%20named%20ma" >Tweet</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saiweb.co.uk/mac/matplotlib-importerror-no-module-named-ma/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Dissecting the hack &#8211; packed r57shell</title>
		<link>http://www.saiweb.co.uk/hacking/dissecting-the-hack-r57shell</link>
		<comments>http://www.saiweb.co.uk/hacking/dissecting-the-hack-r57shell#comments</comments>
		<pubDate>Wed, 26 May 2010 12:00:46 +0000</pubDate>
		<dc:creator>Buzz</dc:creator>
				<category><![CDATA[hacking]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[dissecting]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[r57]]></category>
		<category><![CDATA[r57shell]]></category>

		<guid isPermaLink="false">http://www.saiweb.co.uk/?p=869</guid>
		<description><![CDATA[Before you read any further note, I will not be including the original hack file, simply due to peoples stupidity in putting this on a production environment to play with, if you use the code you do so at your own risk, and by reading this blog entry / using the code provided you agree [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff0000;"><strong>Before you read any further note, I will not be including the original hack file, simply due to peoples stupidity in putting this on a production environment to play with, if you use the code you do so at your own risk, and by reading this blog entry / using the code provided you agree to accept all liability upon yourself for your own actions. Don&#8217;t be an idiot.</strong></span></p>
<p>Around 10 days ago I came across this seemingly innocuous little file.</p>
<p>What I am going to cover in this entry is dissecting the &#8216;payload&#8217; and not so much the web app in question or methods used to compromise it,</p>
<p>Whereas I will not at this time provide the original file, I will provide you with the md5 and sha1 hashes of the file so you can check it&#8217;s not lurking on your systems:</p>
<p>md5: 9ee3e6523d154114460d320477a8665a<br />
sha1: 9c64fecea5620d70a716bbd74f6e89612a4a79c7</p>
<p>The bit we are interested in is the last line of the file:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/eval"><span style="color: #990000;">eval</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/gzinflate"><span style="color: #990000;">gzinflate</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/base64_decode"><span style="color: #990000;">base64_decode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DATA'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Were you to run this line you would get</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/eval"><span style="color: #990000;">eval</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/gzinflate"><span style="color: #990000;">gzinflate</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/base64_decode"><span style="color: #990000;">base64_decode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DATA2'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p><a href="http://cdn.saiweb.co.uk/wp-content/uploads/2010/05/sense-this-picture-makes-none.jpg"><img src="http://cdn.saiweb.co.uk/wp-content/uploads/2010/05/sense-this-picture-makes-none-240x300.jpg" alt="" title="sense-this-picture-makes-none" width="240" height="300" class="aligncenter size-medium wp-image-870" /></a></p>
<p>Confused yet? now I can appreciate the thinking behind packing a payload to avoid detection, but in this case the payload is packed 12 times, and no before you ask I did not manually run each returned statement to find this out. </p>
<p>Enter Python-Fu:</p>
<p><a href="http://cdn.saiweb.co.uk/wp-content/uploads/2010/05/getbritf.jpg"><img src="http://cdn.saiweb.co.uk/wp-content/uploads/2010/05/getbritf-236x300.jpg" alt="" title="getbritf" width="236" height="300" class="aligncenter size-medium wp-image-871" /></a></p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span><br />
<span style="color: #808080; font-style: italic;"># saiweb.co.uk payload unpack script 26/05/2010</span><br />
<span style="color: #808080; font-style: italic;"># copy the eval(gzinflate()) line to payload.raw, place in same directory as this file.</span><br />
<br />
<span style="color: #483d8b;">&quot;&quot;&quot;<br />
Copyright (C) 2010 Buzz saiweb.co.uk.co.uk<br />
<br />
&nbsp; &nbsp; This program is free software: you can redistribute it and/or modify<br />
&nbsp; &nbsp; it under the terms of the GNU General Public License as published by<br />
&nbsp; &nbsp; the Free Software Foundation, either version 3 of the License, or<br />
&nbsp; &nbsp; (at your option) any later version.<br />
<br />
&nbsp; &nbsp; This program is distributed in the hope that it will be useful,<br />
&nbsp; &nbsp; but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
&nbsp; &nbsp; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. &nbsp;See the<br />
&nbsp; &nbsp; GNU General Public License for more details.<br />
<br />
&nbsp; &nbsp; You should have received a copy of the GNU General Public License<br />
&nbsp; &nbsp; along with this program. &nbsp;If not, see &lt;http://www.gnu.org/licenses/&gt;.<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Additional Terms as Per section 7<br />
<br />
&nbsp; &nbsp; Attribution:<br />
<br />
&nbsp; &nbsp; Redistribution/Reuse of this code is permitted under the GNU v3 license, as an additional term ALL code must carry the original Author(s) credit in comment form.<br />
&quot;&quot;&quot;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">base64</span><span style="color: #66cc66;">,</span> <span style="color: #dc143c;">zlib</span><span style="color: #66cc66;">,</span> <span style="color: #dc143c;">re</span><span style="color: #66cc66;">,</span> <span style="color: #dc143c;">sys</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Running ...'</span><br />
&nbsp; &nbsp; f <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'payload.raw'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; php <span style="color: #66cc66;">=</span> f.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; f.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; iteration <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'eval<span style="color: #000099; font-weight: bold;">\(</span>gzinflate<span style="color: #000099; font-weight: bold;">\(</span>base64_decode<span style="color: #000099; font-weight: bold;">\(</span><span style="color: #000099; font-weight: bold;">\'</span>'</span><span style="color: #66cc66;">,</span>php<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; iteration +<span style="color: #66cc66;">=</span> <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Iteration: %d'</span> % iteration<br />
&nbsp; &nbsp; &nbsp; &nbsp; raw <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'eval<span style="color: #000099; font-weight: bold;">\(</span>gzinflate<span style="color: #000099; font-weight: bold;">\(</span>base64_decode<span style="color: #000099; font-weight: bold;">\(</span><span style="color: #000099; font-weight: bold;">\'</span>'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">''</span><span style="color: #66cc66;">,</span>php<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; raw <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\'</span><span style="color: #000099; font-weight: bold;">\)</span><span style="color: #000099; font-weight: bold;">\)</span><span style="color: #000099; font-weight: bold;">\)</span>;'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">''</span><span style="color: #66cc66;">,</span>raw<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; gstring <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">base64</span>.<span style="color: black;">b64decode</span><span style="color: black;">&#40;</span>raw.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; php <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">zlib</span>.<span style="color: black;">decompressobj</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">decompress</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'x<span style="color: #000099; font-weight: bold;">\x</span>9c'</span> + gstring<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">#print payload</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">#sys.exit()</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> php<br />
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'__main__'</span>:<br />
&nbsp; &nbsp; main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>Copy the first payload lines into a file named payload.raw, take the above code and copy it into a file named dissect.py.</p>
<p>When dissect.py is run you will get the following output:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">python .<span style="color: #000000; font-weight: bold;">/</span>dissect.py<br />
Running ...<br />
Iteration: <span style="color: #000000;">1</span><br />
Iteration: <span style="color: #000000;">2</span><br />
Iteration: <span style="color: #000000;">3</span><br />
Iteration: <span style="color: #000000;">4</span><br />
Iteration: <span style="color: #000000;">5</span><br />
Iteration: <span style="color: #000000;">6</span><br />
Iteration: <span style="color: #000000;">7</span><br />
Iteration: <span style="color: #000000;">8</span><br />
Iteration: <span style="color: #000000;">9</span><br />
Iteration: <span style="color: #000000;">10</span><br />
Iteration: <span style="color: #000000;">11</span><br />
Iteration: <span style="color: #000000;">12</span><br />
<span style="color: #000000; font-weight: bold;">&lt;</span>?php<br />
...</div></td></tr></tbody></table></div>
<p>As such you may want to run it using the following command:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">python .<span style="color: #000000; font-weight: bold;">/</span>dissect.py <span style="color: #000000; font-weight: bold;">&gt;</span> r57.php</div></td></tr></tbody></table></div>
<p><a href="http://cdn.saiweb.co.uk/wp-content/uploads/2010/05/ggwit.jpg"><img src="http://cdn.saiweb.co.uk/wp-content/uploads/2010/05/ggwit-257x300.jpg" alt="" title="ggwit" width="257" height="300" class="aligncenter size-medium wp-image-872" /></a></p>
<p>And what you will find after unpacking 12 times in total, the &#8220;payload&#8221; is the r57shell, this script is an information gathering tool and pseudo shell, meaning it will run any command on the host server that php can, providing in most cases ssh esq access to the exploited host, allowing you to do pretty much anything you wanted at this point, some of the features also include /etc/passwd /etc/shadow dumping, aswell as searching for a tirade of common file *.sql* admin* etc, it&#8217;s a one stop script for information gathering on a LAMP/WAMP based host.</p>
<p><strong><br />
Defense: modify php.ini to disable eval(), exec, shell_exec and all none essential functions.<br />
</strong></p>
<p>And of course, ensure your web apps are patched and up to date as well as the host they are running on. </p>
<p><span style="float: left;" ><a class="twitter-share-button"  data-via="Saiweb" data-count="horizontal" data-related="Saiweb:David Busby" data-lang="en" data-url="http://www.saiweb.co.uk/hacking/dissecting-the-hack-r57shell" data-text="Dissecting the hack &#8211; packed r57shell" href="http://twitter.com/share?via=Saiweb&#038;count=horizontal&#038;related=Saiweb%3ADavid%20Busby&#038;lang=en&#038;url=http%3A%2F%2Fwww.saiweb.co.uk%2Fhacking%2Fdissecting-the-hack-r57shell&#038;text=Dissecting%20the%20hack%20%26%238211%3B%20packed%20r57shell" >Tweet</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saiweb.co.uk/hacking/dissecting-the-hack-r57shell/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>net-snmp python bindings</title>
		<link>http://www.saiweb.co.uk/python/net-snmp-python-bindings</link>
		<comments>http://www.saiweb.co.uk/python/net-snmp-python-bindings#comments</comments>
		<pubDate>Wed, 03 Mar 2010 14:26:09 +0000</pubDate>
		<dc:creator>Buzz</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[bindings]]></category>
		<category><![CDATA[net-snmp]]></category>
		<category><![CDATA[snmp]]></category>

		<guid isPermaLink="false">http://www.saiweb.co.uk/?p=833</guid>
		<description><![CDATA[UPDATE 28/06/10: added &#8211;libdir=/usr/lib64 &#8211;enable-shared otherwise shared libs are not built at all! Having spent a few hours trying to get this working on CentOS 5.4 x64 I am posting this blog entry for others to reference: Download and complie net-snmp >= 5.4.2.1 http://net-snmp.sourceforge.net/ 12345./configure --with-python-modules --libdir=/usr/lib64 --enable-shared make &#38;&#38; make install cd /path/to/net-snmp-src/python/ python [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE 28/06/10:</strong> added &#8211;libdir=/usr/lib64 &#8211;enable-shared otherwise shared libs are not built at all!</p>
<p>Having spent a few hours trying to get this working on CentOS 5.4 x64 I am posting this blog entry for others to reference:</p>
<p>Download and complie net-snmp >= 5.4.2.1 <a href="http://net-snmp.sourceforge.net/">http://net-snmp.sourceforge.net/</a></p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-python-modules</span> <span style="color: #660033;">--libdir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib64 <span style="color: #660033;">--enable-shared</span><br />
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span><br />
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>net-snmp-src<span style="color: #000000; font-weight: bold;">/</span>python<span style="color: #000000; font-weight: bold;">/</span><br />
python .<span style="color: #000000; font-weight: bold;">/</span>setup.py build<br />
python .<span style="color: #000000; font-weight: bold;">/</span>setup.py <span style="color: #7a0874; font-weight: bold;">test</span></div></td></tr></tbody></table></div>
<p>You may get ImportError: libnetsnmp.so.20, this is due to x64 build creating as /usr/lib64/libnetsnmp.so.10</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib64<span style="color: #000000; font-weight: bold;">/</span>libnetsnmp.so.10.0.3 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib64<span style="color: #000000; font-weight: bold;">/</span>libnetsnmp.so.20<br />
python .<span style="color: #000000; font-weight: bold;">/</span>setup.py <span style="color: #c20cb9; font-weight: bold;">install</span></div></td></tr></tbody></table></div>
<p>And you are done, you can now use the netsnmp python bindings, I&#8217;d recomend seeing the examples here: <a href="http://www.ibm.com/developerworks/aix/library/au-netsnmpnipython/">http://www.ibm.com/developerworks/aix/library/au-netsnmpnipython/</a><span style="float: left;" ><a class="twitter-share-button"  data-via="Saiweb" data-count="horizontal" data-related="Saiweb:David Busby" data-lang="en" data-url="http://www.saiweb.co.uk/python/net-snmp-python-bindings" data-text="net-snmp python bindings" href="http://twitter.com/share?via=Saiweb&#038;count=horizontal&#038;related=Saiweb%3ADavid%20Busby&#038;lang=en&#038;url=http%3A%2F%2Fwww.saiweb.co.uk%2Fpython%2Fnet-snmp-python-bindings&#038;text=net-snmp%20python%20bindings" >Tweet</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saiweb.co.uk/python/net-snmp-python-bindings/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux – Generating file manifests and then checking them &#8211; Improved</title>
		<link>http://www.saiweb.co.uk/linux/linux-%e2%80%93-generating-file-manifests-and-then-checking-them-improved</link>
		<comments>http://www.saiweb.co.uk/linux/linux-%e2%80%93-generating-file-manifests-and-then-checking-them-improved#comments</comments>
		<pubDate>Tue, 29 Sep 2009 14:14:06 +0000</pubDate>
		<dc:creator>Buzz</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[indication]]></category>
		<category><![CDATA[indicator]]></category>
		<category><![CDATA[manifest]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[progress]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.saiweb.co.uk/?p=788</guid>
		<description><![CDATA[Following on from Linux – Generating file manifests and then checking them I was always getting the same questions &#8230; How long left on the manifest Buzz ? How long left on the verification Buzz ? And I HATE having to turn around an say &#8230; I don&#8217;t know &#8230; The problem with the usual [...]]]></description>
			<content:encoded><![CDATA[<p>Following on from <a href="http://www.saiweb.co.uk/linux/linux-generating-file-manifests-and-then-checking-them">Linux – Generating file manifests and then checking them</a> I was always getting the same questions &#8230;</p>
<p>How long left on the manifest Buzz ?<br />
How long left on the verification Buzz ?</p>
<p>And I <strong>HATE</strong> having to turn around an say &#8230; I don&#8217;t know &#8230;</p>
<p>The problem with the usual command line method is that it give no indication of progress, and by extension no indication that it was infact running and not &#8216;hung&#8217; &#8230;</p>
<p>As such I have now added the &#8216;manifest&#8217; command set to the <a href="http://www.saiweb.co.uk/sysadmin">Sysadmin toolset</a></p>
<p>The manifest command take two data types, the first is a folder path from which to build the file manifest from, the manifest itself is also compatible with the &#8220;md5sum &#8211;check&#8221; function.</p>
<p><div id="saiweb_b5927dbcf8c758857dc8f6f2e43a7239" style="width:900px; height:300px;"></div><script language="Javascript" type="text/javascript">
	WPFP(document).ready(function() {
		//load player
		$f("saiweb_b5927dbcf8c758857dc8f6f2e43a7239", "/wp-content/plugins/wordpress-flowplayer/flowplayer/gpl/flowplayer-3.1.5.swf", {
				plugins: {
  					 controls: {    					
      					
      					
      					
      					sliderGradient: 'none',
      					progressGradient: 'medium',
      					
      					
      					backgroundColor: '#141648',
      					
      					
      					backgroundGradient: 'none',
      					bufferGradient: 'none',
   						opacity:1.0
   						}
				},
			clip: {
					url:'http://content.screencast.com/users/D.Busby/folders/Jing/media/dd41bc92-17d3-4c34-8d46-80188f13aff2/00000337.mp4',
					autoPlay: false,
       				autoBuffering: false
				},
				canvas: {
					backgroundColor:''
				}})
			});</script>
				</p>
<p>The second is the path to the manifest itself, in this case the manifest command will verify each file against it&#8217;s entry in the manifest:</p>
<p><div id="saiweb_ec2e0938086858a97cfd2ef4de12913d" style="width:900px; height:300px;"></div><script language="Javascript" type="text/javascript">
	WPFP(document).ready(function() {
		//load player
		$f("saiweb_ec2e0938086858a97cfd2ef4de12913d", "/wp-content/plugins/wordpress-flowplayer/flowplayer/gpl/flowplayer-3.1.5.swf", {
				plugins: {
  					 controls: {    					
      					
      					
      					
      					sliderGradient: 'none',
      					progressGradient: 'medium',
      					
      					
      					backgroundColor: '#141648',
      					
      					
      					backgroundGradient: 'none',
      					bufferGradient: 'none',
   						opacity:1.0
   						}
				},
			clip: {
					url:'http://content.screencast.com/users/D.Busby/folders/Jing/media/2d3eb196-87ef-4464-982b-5b9481c000fe/00000338.mp4',
					autoPlay: false,
       				autoBuffering: false
				},
				canvas: {
					backgroundColor:''
				}})
			});</script>
				</p>
<p>At each point the command give you an indication of it&#8217;s current status, however this does come at a small cost, the script has no concept of the size of you console and as such will always render out the same number of character meaning if you console is not wide enough it will not render correctly, in the videos I have the console on a high resolution monitor as can be seen each video itself is 900 pixels wide.</p>
<p>This process is CPU intensive (20-45% on one core of a intel core2duo 2.8GHZ) and uses around 140KB of memory.<span style="float: left;" ><a class="twitter-share-button"  data-via="Saiweb" data-count="horizontal" data-related="Saiweb:David Busby" data-lang="en" data-url="http://www.saiweb.co.uk/linux/linux-%e2%80%93-generating-file-manifests-and-then-checking-them-improved" data-text="Linux – Generating file manifests and then checking them &#8211; Improved" href="http://twitter.com/share?via=Saiweb&#038;count=horizontal&#038;related=Saiweb%3ADavid%20Busby&#038;lang=en&#038;url=http%3A%2F%2Fwww.saiweb.co.uk%2Flinux%2Flinux-%25e2%2580%2593-generating-file-manifests-and-then-checking-them-improved&#038;text=Linux%20%E2%80%93%20Generating%20file%20manifests%20and%20then%20checking%20them%20%26%238211%3B%20Improved" >Tweet</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saiweb.co.uk/linux/linux-%e2%80%93-generating-file-manifests-and-then-checking-them-improved/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://content.screencast.com/users/D.Busby/folders/Jing/media/dd41bc92-17d3-4c34-8d46-80188f13aff2/00000337.mp4" length="6951906" type="video/mp4" />
<enclosure url="http://content.screencast.com/users/D.Busby/folders/Jing/media/2d3eb196-87ef-4464-982b-5b9481c000fe/00000338.mp4" length="7847114" type="video/mp4" />
		</item>
		<item>
		<title>Subversion &#8211; Force commit message</title>
		<link>http://www.saiweb.co.uk/python/subversion-force-commit-message</link>
		<comments>http://www.saiweb.co.uk/python/subversion-force-commit-message#comments</comments>
		<pubDate>Mon, 24 Aug 2009 14:21:35 +0000</pubDate>
		<dc:creator>Buzz</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[commit]]></category>
		<category><![CDATA[force]]></category>
		<category><![CDATA[Subversion]]></category>

		<guid isPermaLink="false">http://www.saiweb.co.uk/?p=743</guid>
		<description><![CDATA[Again this is a late blog post about some code committed several months ago, in this case the code was committed 09/06/2009 It is a very short python script to force a subversion commit message to be greater than 10 characters in length Installation: svn export http://svn.saiweb.co.uk/branches/python/svn_force_message.py /path/to/your/svn/hooks/pre-commit chmod +x /path/to/your/svn/hooks/pre-commit Note installation this way [...]]]></description>
			<content:encoded><![CDATA[<p>Again this is a late blog post about some code committed several months ago, in this case the code was committed 09/06/2009 </p>
<p>It is a very short python script to force a subversion commit message to be greater than 10 characters in length</p>
<p><strong>Installation:</strong></p>
<p>svn export <a href="http://svn.saiweb.co.uk/branches/python/svn_force_message.py">http://svn.saiweb.co.uk/branches/python/svn_force_message.py</a> /path/to/your/svn/hooks/pre-commit<br />
chmod +x /path/to/your/svn/hooks/pre-commit</p>
<p>Note installation this way will replace your current pre-commit hooks file.</p>
<p><span style="float: left;" ><a class="twitter-share-button"  data-via="Saiweb" data-count="horizontal" data-related="Saiweb:David Busby" data-lang="en" data-url="http://www.saiweb.co.uk/python/subversion-force-commit-message" data-text="Subversion &#8211; Force commit message" href="http://twitter.com/share?via=Saiweb&#038;count=horizontal&#038;related=Saiweb%3ADavid%20Busby&#038;lang=en&#038;url=http%3A%2F%2Fwww.saiweb.co.uk%2Fpython%2Fsubversion-force-commit-message&#038;text=Subversion%20%26%238211%3B%20Force%20commit%20message" >Tweet</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saiweb.co.uk/python/subversion-force-commit-message/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subversion and twitter &#8211; Keep your followers up to date with your code commits</title>
		<link>http://www.saiweb.co.uk/twitter/subversion-and-twitter-keep-your-followers-up-to-date-with-your-code-commits</link>
		<comments>http://www.saiweb.co.uk/twitter/subversion-and-twitter-keep-your-followers-up-to-date-with-your-code-commits#comments</comments>
		<pubDate>Mon, 24 Aug 2009 12:23:46 +0000</pubDate>
		<dc:creator>Buzz</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[hooks]]></category>
		<category><![CDATA[post-commit]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.saiweb.co.uk/?p=738</guid>
		<description><![CDATA[Some two months after the fact, I thought it may well be time to post a blog on this little code snippet. As some of you have noticed every commit message to my subversion repository is infact updating my twitter. This code was uploaded to subversion on 10/06/2009, so sorry for the late write up! [...]]]></description>
			<content:encoded><![CDATA[<p>Some two months after the fact, I thought it may well be time to post a blog on this little code snippet.</p>
<p>As some of you have noticed every commit message to my subversion repository is infact updating my twitter.</p>
<p>This code was uploaded to subversion on 10/06/2009, so sorry for the late write up!<br />
<strong><br />
Requirements</strong></p>
<p>Python 2.5 or higher<br />
Subversion server</p>
<p><strong>Installation</strong></p>
<ul>
<li>svn co http://svn.saiweb.co.uk/branches/python/svn_tweeter.py /usr/bin/svn_tweeter</li>
<li>chmod +x /usr/bin/svn_tweeter</li>
<li>cd /path/to/svn/hooks</li>
<li>Edit post-commit with your favorite text editor</li>
</ul>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">REPOS</span>=<span style="color: #ff0000;">&quot;$1&quot;</span><br />
<span style="color: #007800;">REV</span>=<span style="color: #ff0000;">&quot;$2&quot;</span></div></td></tr></tbody></table></div>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;</div></td></tr></tbody></table></div>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>python <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>svn_tweeter <span style="color: #660033;">-u</span> twitterusername <span style="color: #660033;">-p</span> twitterpassword <span style="color: #660033;">-r</span> <span style="color: #007800;">$REV</span> <span style="color: #660033;">-s</span> <span style="color: #007800;">$REPOS</span></div></td></tr></tbody></table></div>
<p>Now try a commit, and check your syslog for entries from the script.</p>
<p>Aug 24 11:36:26 132 python: SVN_TWEETER: http://twitter.com/statuses/update.json query complete</p>
<p><strong>UPDATE 24/03/2011</strong> Twitter has removed basic authentication, you must use oauth (admittedly it has been like this for a fair while now) use this <a href="https://github.com/Oneiroi/nagios_addons/blob/master/twitter/nagios_bot.py">nagios_bot</a> instead<span style="float: left;" ><a class="twitter-share-button"  data-via="Saiweb" data-count="horizontal" data-related="Saiweb:David Busby" data-lang="en" data-url="http://www.saiweb.co.uk/twitter/subversion-and-twitter-keep-your-followers-up-to-date-with-your-code-commits" data-text="Subversion and twitter &#8211; Keep your followers up to date with your code commits" href="http://twitter.com/share?via=Saiweb&#038;count=horizontal&#038;related=Saiweb%3ADavid%20Busby&#038;lang=en&#038;url=http%3A%2F%2Fwww.saiweb.co.uk%2Ftwitter%2Fsubversion-and-twitter-keep-your-followers-up-to-date-with-your-code-commits&#038;text=Subversion%20and%20twitter%20%26%238211%3B%20Keep%20your%20followers%20up%20to%20date%20with%20your%20code%20commits" >Tweet</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saiweb.co.uk/twitter/subversion-and-twitter-keep-your-followers-up-to-date-with-your-code-commits/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding pyinotify to CentOS 5 x64</title>
		<link>http://www.saiweb.co.uk/python/adding-pyinotify-to-centos-5-x64</link>
		<comments>http://www.saiweb.co.uk/python/adding-pyinotify-to-centos-5-x64#comments</comments>
		<pubDate>Tue, 16 Jun 2009 15:45:44 +0000</pubDate>
		<dc:creator>Buzz</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[pyinotify]]></category>

		<guid isPermaLink="false">http://www.saiweb.co.uk/?p=671</guid>
		<description><![CDATA[In order to get pyinotify working on CentOS 5 x64 a few workarounds need to take place. (Thanks to Matthew Ife at ukFast for help with this) First off you are going to need the python-ctypes RPM, available from DAG here: python-ctypes-1.0.0-2.el5.rf.x86_64.rpm Once installed you are going to need the Fedora 8 python-inotify SOURCE rpm [...]]]></description>
			<content:encoded><![CDATA[<p>In order to get pyinotify working on CentOS 5 x64 a few workarounds need to take place.</p>
<p>(Thanks to Matthew Ife at ukFast for help with this)</p>
<p>First off you are going to need the python-ctypes RPM, available from DAG here: <a href="http://dag.wieers.com/rpm/packages/python-ctypes/python-ctypes-1.0.0-2.el5.rf.x86_64.rpm">python-ctypes-1.0.0-2.el5.rf.x86_64.rpm</a></p>
<p>Once installed you are going to need the Fedora 8 python-inotify SOURCE rpm available from here: <a href="ftp://ftp.pbone.net/mirror/archive.fedoraproject.org/fedora/linux/updates/8/SRPMS.newkey/python-inotify-0.8.0-3.r.fc8.src.rpm">python-inotify-0.8.0-3.r.fc8.src.rpm</a></p>
<p>The easiest way I found to extract the required packages was using the following:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> .<span style="color: #000000; font-weight: bold;">/</span>python-inotify<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> .<span style="color: #000000; font-weight: bold;">/</span>python-inotify<br />
<span style="color: #c20cb9; font-weight: bold;">wget</span> ftp:<span style="color: #000000; font-weight: bold;">//</span>ftp.pbone.net<span style="color: #000000; font-weight: bold;">/</span>mirror<span style="color: #000000; font-weight: bold;">/</span>archive.fedoraproject.org<span style="color: #000000; font-weight: bold;">/</span>fedora<span style="color: #000000; font-weight: bold;">/</span>linux<span style="color: #000000; font-weight: bold;">/</span>updates<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span><span style="color: #000000; font-weight: bold;">/</span>SRPMS.newkey<span style="color: #000000; font-weight: bold;">/</span>python-inotify-0.8.0-<span style="color: #000000;">3</span>.r.fc8.src.rpm<br />
rpm2cpio .<span style="color: #000000; font-weight: bold;">/</span>python-inotify-0.8.0-<span style="color: #000000;">3</span>.r.fc8.src.rpm <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cpio</span> <span style="color: #660033;">-idv</span><br />
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-zxvf</span> .<span style="color: #000000; font-weight: bold;">/</span>pyinotify-0.8.0r.tar.gz<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> .<span style="color: #000000; font-weight: bold;">/</span>pyinotify<br />
.<span style="color: #000000; font-weight: bold;">/</span>setup.py <span style="color: #c20cb9; font-weight: bold;">install</span></div></td></tr></tbody></table></div>
<p><span style="float: left;" ><a class="twitter-share-button"  data-via="Saiweb" data-count="horizontal" data-related="Saiweb:David Busby" data-lang="en" data-url="http://www.saiweb.co.uk/python/adding-pyinotify-to-centos-5-x64" data-text="Adding pyinotify to CentOS 5 x64" href="http://twitter.com/share?via=Saiweb&#038;count=horizontal&#038;related=Saiweb%3ADavid%20Busby&#038;lang=en&#038;url=http%3A%2F%2Fwww.saiweb.co.uk%2Fpython%2Fadding-pyinotify-to-centos-5-x64&#038;text=Adding%20pyinotify%20to%20CentOS%205%20x64" >Tweet</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saiweb.co.uk/python/adding-pyinotify-to-centos-5-x64/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python urllib2, basic http authentication</title>
		<link>http://www.saiweb.co.uk/python/python-urllib2-basic-http-authentication</link>
		<comments>http://www.saiweb.co.uk/python/python-urllib2-basic-http-authentication#comments</comments>
		<pubDate>Wed, 03 Jun 2009 11:43:27 +0000</pubDate>
		<dc:creator>Buzz</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[auth]]></category>
		<category><![CDATA[basic]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[urllib2]]></category>

		<guid isPermaLink="false">http://www.saiweb.co.uk/?p=660</guid>
		<description><![CDATA[I meant to write this up over a week ago now, basically the need arose for one of my Python scripts to use HTTP Basic authentication when grabbing the output from a URL. An example script can be seen below: Quick description, the script will attempt to connect to a URL and read the data [...]]]></description>
			<content:encoded><![CDATA[<p>I meant to write this up over a week ago now, basically the need arose for one of my Python scripts to use HTTP Basic authentication when grabbing the output from a URL.</p>
<p>An example script can be seen below:</p>
<p>Quick description, the script will attempt to connect to a URL and read the data supplied by the webserver, if a HTTP 401 error is returned (Authentication required) the script will then go on to attempt to authenticate using the credentials supplied.</p>
<p>Printing out to the console at each point.</p>
<p>Subversion:<a href="http://svn.saiweb.co.uk/branches/python/urllib2_httpbasic_auth.py"> http://svn.saiweb.co.uk/branches/python/urllib2_httpbasic_auth.py</a></p>
<p>Highlighted source (at the time of writing)</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span><br />
<span style="color: #483d8b;">&quot;&quot;&quot;<br />
&nbsp; &nbsp; Author: David Busby (http://saiweb.co.uk)<br />
&nbsp; &nbsp; Program: Python HTTP Basic Auth Exa<br />
&nbsp; &nbsp; Copyright: David Busby 2009. All rights reserved.<br />
&nbsp; &nbsp; License: http://creativecommons.org/licenses/by-sa/2.0/uk/<br />
&quot;&quot;&quot;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib2</span><span style="color: #66cc66;">,</span> <span style="color: #dc143c;">base64</span><br />
<br />
<span style="color: #483d8b;">&quot;&quot;&quot; URL List &quot;&quot;&quot;</span><br />
urls <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff4500;">0</span>:<span style="color: black;">&#123;</span><span style="color: #483d8b;">&quot;url&quot;</span>:<span style="color: #483d8b;">&quot;www.saiweb.co.uk/some/fictional/auth/area&quot;</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">&quot;user&quot;</span>:<span style="color: #483d8b;">&quot;someuser&quot;</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">&quot;pass&quot;</span>:<span style="color: #483d8b;">&quot;somepass&quot;</span><span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp;ulen <span style="color: #66cc66;">=</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>urls<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: #66cc66;">,</span>ulen<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp;url <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;http://%s&quot;</span> % <span style="color: black;">&#40;</span>urls<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;url&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;req <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">Request</span><span style="color: black;">&#40;</span>url<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff7700;font-weight:bold;">try</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;res <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span>req<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;headers <span style="color: #66cc66;">=</span> res.<span style="color: black;">info</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">headers</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;data <span style="color: #66cc66;">=</span> res.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">IOError</span><span style="color: #66cc66;">,</span> e:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">hasattr</span><span style="color: black;">&#40;</span>e<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'reason'</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; err <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;%s ERROR(%s)&quot;</span> % <span style="color: black;">&#40;</span>urls<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;url&quot;</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span>e.<span style="color: black;">reason</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> err<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #008000;">hasattr</span><span style="color: black;">&#40;</span>e<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'code'</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> e.<span style="color: #dc143c;">code</span> <span style="color: #66cc66;">!=</span> <span style="color: #ff4500;">401</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; err <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;%s ERROR(%s)&quot;</span> % <span style="color: black;">&#40;</span>urls<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;url&quot;</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span>e.<span style="color: #dc143c;">code</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> err<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">#401 = auth required error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> e.<span style="color: #dc143c;">code</span> <span style="color: #66cc66;">==</span> <span style="color: #ff4500;">401</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; base64string <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">base64</span>.<span style="color: black;">encodestring</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'%s:%s'</span> % <span style="color: black;">&#40;</span>urls<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;user&quot;</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> urls<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;pass&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span>:-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; authheader <span style="color: #66cc66;">=</span> &nbsp;<span style="color: #483d8b;">&quot;Basic %s&quot;</span> % base64string<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; req.<span style="color: black;">add_header</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Authorization&quot;</span><span style="color: #66cc66;">,</span> authheader<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">try</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span>req<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; headers <span style="color: #66cc66;">=</span> res.<span style="color: black;">info</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">headers</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data <span style="color: #66cc66;">=</span> res.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">IOError</span><span style="color: #66cc66;">,</span> e:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">hasattr</span><span style="color: black;">&#40;</span>e<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'reason'</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; err <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;%s:%s@%s ERROR(%s)&quot;</span> % <span style="color: black;">&#40;</span>urls<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;user&quot;</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span>urls<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;pass&quot;</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span>urls<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;url&quot;</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span>e.<span style="color: black;">reason</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> err<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #008000;">hasattr</span><span style="color: black;">&#40;</span>e<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'code'</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; err <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;%s:%s@%s ERROR(%s)&quot;</span> % <span style="color: black;">&#40;</span>urls<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;user&quot;</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span>urls<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;pass&quot;</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span>urls<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;url&quot;</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span>e.<span style="color: #dc143c;">code</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> err<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; err <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;%s query complete&quot;</span> % <span style="color: black;">&#40;</span>urls<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;url&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> err<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; err <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;%s query complete&quot;</span> % <span style="color: black;">&#40;</span>urls<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;url&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> err<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">&quot;__main__&quot;</span>:<br />
&nbsp; &nbsp; main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p><strong>NOTES:</strong> This script does not check the authentication type, it always assumes it is HTTP BASIC, HTTP DIGEST for example is not compatible with this script, though there is no reason why you can not get the Auth type form the headers returned by the server and write in a Digest auth method.<span style="float: left;" ><a class="twitter-share-button"  data-via="Saiweb" data-count="horizontal" data-related="Saiweb:David Busby" data-lang="en" data-url="http://www.saiweb.co.uk/python/python-urllib2-basic-http-authentication" data-text="Python urllib2, basic http authentication" href="http://twitter.com/share?via=Saiweb&#038;count=horizontal&#038;related=Saiweb%3ADavid%20Busby&#038;lang=en&#038;url=http%3A%2F%2Fwww.saiweb.co.uk%2Fpython%2Fpython-urllib2-basic-http-authentication&#038;text=Python%20urllib2%2C%20basic%20http%20authentication" >Tweet</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saiweb.co.uk/python/python-urllib2-basic-http-authentication/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making the bird tweet using python</title>
		<link>http://www.saiweb.co.uk/python/making-the-bird-tweet-using-python</link>
		<comments>http://www.saiweb.co.uk/python/making-the-bird-tweet-using-python#comments</comments>
		<pubDate>Thu, 02 Apr 2009 16:56:35 +0000</pubDate>
		<dc:creator>Buzz</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.saiweb.co.uk/?p=630</guid>
		<description><![CDATA[After taking another look at Python I am quickly coming to love it, as an &#8220;exercise&#8221; in re-learning python I decided to write a very simple command line &#8220;tweeter&#8221; this uses the Twitter API to update your twitter status, extending from the &#8220;update twitter in a single line&#8221; You can grab a copy of the [...]]]></description>
			<content:encoded><![CDATA[<p>After taking another look at Python I am quickly coming to love it, as an &#8220;exercise&#8221; in re-learning python I decided to write a very simple command line &#8220;tweeter&#8221; this uses the Twitter API to update your twitter status, extending from the &#8220;<a href="http://www.saiweb.co.uk/linux/update-twitter-in-a-single-line">update twitter in a single line</a>&#8221;</p>
<p>You can grab a copy of the script from here: <a href="http://svn.saiweb.co.uk/branches/python/tweet.py">http://svn.saiweb.co.uk/branches/python/tweet.py</a></p>
<p><strong>UPDATE 24/03/2011:</strong>Oauth version <a href="https://github.com/Oneiroi/nagios_addons/blob/master/twitter/nagios_bot.py">here</a></p>
<p>Example usage:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">.<span style="color: #000000; font-weight: bold;">/</span>tweet.py <span style="color: #660033;">-u</span> username <span style="color: #660033;">-p</span> password <span style="color: #660033;">-t</span> your tweet goes here</div></td></tr></tbody></table></div>
<p>If you want to parse the JSON data normally returned after submitting a new tweet simply add the -j flag.</p>
<p>If you are prompted for a username and password when running this script the username and password supplied using the -u and -p flags was incorrect.</p>
<p><span style="float: left;" ><a class="twitter-share-button"  data-via="Saiweb" data-count="horizontal" data-related="Saiweb:David Busby" data-lang="en" data-url="http://www.saiweb.co.uk/python/making-the-bird-tweet-using-python" data-text="Making the bird tweet using python" href="http://twitter.com/share?via=Saiweb&#038;count=horizontal&#038;related=Saiweb%3ADavid%20Busby&#038;lang=en&#038;url=http%3A%2F%2Fwww.saiweb.co.uk%2Fpython%2Fmaking-the-bird-tweet-using-python&#038;text=Making%20the%20bird%20tweet%20using%20python" >Tweet</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saiweb.co.uk/python/making-the-bird-tweet-using-python/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using apc
Database Caching 22/67 queries in 0.250 seconds using apc
Object Caching 2012/2143 objects using apc
Content Delivery Network via Rackspace Cloud Files: cdn.saiweb.co.uk

Served from: www.saiweb.co.uk @ 2012-02-08 16:06:24 -->
