<?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>Tadek's Blog &#187; Hacking</title>
	<atom:link href="http://tadek.pietraszek.org/blog/category/hacking/feed/" rel="self" type="application/rss+xml" />
	<link>http://tadek.pietraszek.org/blog</link>
	<description>Some random notes about computers, security, cool links and others.</description>
	<lastBuildDate>Mon, 02 May 2011 22:32:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Pusterla Elektronik</title>
		<link>http://tadek.pietraszek.org/blog/2006/08/22/pusterla-elektronik/</link>
		<comments>http://tadek.pietraszek.org/blog/2006/08/22/pusterla-elektronik/#comments</comments>
		<pubDate>Tue, 22 Aug 2006 20:39:22 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2006/08/22/pusterla-elektronik/</guid>
		<description><![CDATA[Ever wondered where to get some electronic components in Zurich and was unhappy with what quadruple &#8220;M&#8221; Migros offers in the hobby section? Or looking for a non-typical power supply for your favorite toy that just died? Or need some fancy cables? Or maybe just want to look at cool stuff? I found a really [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wondered where to get some electronic components in Zurich and was unhappy with what quadruple &#8220;M&#8221; Migros offers in the hobby section? Or looking for a non-typical power supply for your favorite toy that just died?  Or need some fancy cables? Or maybe just want to look at cool stuff? <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<p>I found a really nice electronic store in Zurich &#8211; <a href="http://www.pusterla.ch/">Pusterla Elektronik</a> to help you.</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2006/08/22/pusterla-elektronik/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>17 Mistakes Microsoft Made in the Xbox Security System &#8211; Xbox-Linux</title>
		<link>http://tadek.pietraszek.org/blog/2006/06/21/17-mistakes-microsoft-made-in-the-xbox-security-system-xbox-linux/</link>
		<comments>http://tadek.pietraszek.org/blog/2006/06/21/17-mistakes-microsoft-made-in-the-xbox-security-system-xbox-linux/#comments</comments>
		<pubDate>Wed, 21 Jun 2006 21:16:46 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2006/06/21/17-mistakes-microsoft-made-in-the-xbox-security-system-xbox-linux/</guid>
		<description><![CDATA[A cool article on mistakes made in Xbox. Talks a lot about building (in)secure hardware/software systems (may be useful when looking at the TPM stuff).]]></description>
			<content:encoded><![CDATA[<p>A <a href="http://www.xbox-linux.org/wiki/17_Mistakes_Microsoft_Made_in_the_Xbox_Security_System">cool article</a> on mistakes made in Xbox. Talks a lot about building (in)secure hardware/software systems (may be useful when looking at the TPM stuff).</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2006/06/21/17-mistakes-microsoft-made-in-the-xbox-security-system-xbox-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PostgreSQL8.1 &#8220;client encoding mismatch&#8221; with ODBC</title>
		<link>http://tadek.pietraszek.org/blog/2005/12/02/postgresql81-client-encoding-mismatch-with-odbc/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/12/02/postgresql81-client-encoding-mismatch-with-odbc/#comments</comments>
		<pubDate>Fri, 02 Dec 2005 13:09:03 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/?p=218</guid>
		<description><![CDATA[While connecting to PostgreSQL using UnixODBC (from R, but this doesn&#8217;t matter) I got the following error: [unixODBC]client encoding mismatch It seems that there is some problem with PostgreSQL 8.1 and the encoding names: see this post or google. It looks that UTF8 used by default with the new Postgres is not compatible with old [...]]]></description>
			<content:encoded><![CDATA[<p>While connecting to PostgreSQL using UnixODBC (from R, but this doesn&#8217;t matter) I got the following error:</p>

<pre><code>[unixODBC]client encoding mismatch
</code></pre>

<p>It seems that there is some problem with PostgreSQL 8.1 and the encoding names: see <a href="http://archives.postgresql.org/pgsql-odbc/2005-09/msg00161.php">this post</a> or <a href="http://www.google.com/search?q=%22client+encoding+mismatch%22+postgres">google</a>. It looks that UTF8 used by default with the new Postgres is not compatible with old ODBC drivers. I am not sure where the problem really is, but a <em>quick fix</em>  is to change default encoding for the user connecting to the database:</p>

<pre><code>alter user &lt;user&gt; SET client_encoding to LATIN1;
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/12/02/postgresql81-client-encoding-mismatch-with-odbc/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Multiple matches in one line &#8211; perl one-liner</title>
		<link>http://tadek.pietraszek.org/blog/2005/10/14/multiple-matches-in-one-line-perl-one-liner/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/10/14/multiple-matches-in-one-line-perl-one-liner/#comments</comments>
		<pubDate>Fri, 14 Oct 2005 09:40:42 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2005/10/14/multiple-matches-in-one-line-perl-one-liner/</guid>
		<description><![CDATA[(thanks to Diego): perl -ne &#8216;while ((/condition/g)) { print &#8220;something&#8221;; }&#8217;]]></description>
			<content:encoded><![CDATA[<p>(thanks to Diego):
  perl -ne &#8216;while ((/condition/g))  { print &#8220;something&#8221;; }&#8217;</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/10/14/multiple-matches-in-one-line-perl-one-liner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting newlines  DOS  Unix</title>
		<link>http://tadek.pietraszek.org/blog/2005/10/13/converting-newlines-dos-unix/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/10/13/converting-newlines-dos-unix/#comments</comments>
		<pubDate>Thu, 13 Oct 2005 14:09:45 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Progs/Tools/Libs]]></category>
		<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2005/10/13/converting-newlines-dos-unix/</guid>
		<description><![CDATA[Use flip: flip -u &#60;file_name&#62; flip -m &#60;file_name&#62; apt-get install flip]]></description>
			<content:encoded><![CDATA[<p>Use flip:</p>

<p>flip -u &lt;file_name&gt;
flip -m &lt;file_name&gt;</p>

<p>apt-get install flip</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/10/13/converting-newlines-dos-unix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deleting unused config files in Debian</title>
		<link>http://tadek.pietraszek.org/blog/2005/10/13/deleting-unused-config-files-in-debian/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/10/13/deleting-unused-config-files-in-debian/#comments</comments>
		<pubDate>Thu, 13 Oct 2005 14:06:10 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/?p=158</guid>
		<description><![CDATA[Getting a list of unused packages (not the installed ones): dpkg &#8211;list &#124; grep -v -E &#8220;^ii&#8221; Purging packages list: dpkg &#8211;purge packagename So doing all this in one line would be something like: dpkg &#8211;purge dpkg --list &#124; grep -v -E "^ii" &#124; perl -ne '/^rc\s+([^\s]+)/ &#38;&#38; print "$1 ";' Be careful!]]></description>
			<content:encoded><![CDATA[<ul>
<li><p>Getting a list of unused packages (not the installed ones):
dpkg &#8211;list | grep -v -E &#8220;^ii&#8221;</p></li>
<li><p>Purging packages list:
dpkg &#8211;purge packagename</p></li>
</ul>

<p>So doing all this in one line would be something like:
dpkg &#8211;purge <code>dpkg --list | grep -v -E "^ii" | perl -ne '/^rc\s+([^\s]+)/ &amp;&amp; print "$1 ";'</code></p>

<p>Be careful!</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/10/13/deleting-unused-config-files-in-debian/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nessus command line search</title>
		<link>http://tadek.pietraszek.org/blog/2005/10/12/nessus-command-line-search/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/10/12/nessus-command-line-search/#comments</comments>
		<pubDate>Wed, 12 Oct 2005 14:59:14 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2005/10/12/nessus-command-line-search/</guid>
		<description><![CDATA[I&#8217;ve recently tired to do a nessus scan from an X-less gentoo machine. The task is quite simple, but there are a few quirks that are not obvious. The easy part: emerge nessus nessus-mkcert nessus-user-add register at nessus website to get the actiovation code for plugin feeds (FYI: #GPL plugins: 1299, #registered plugins: 9575), so [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently tired to do a nessus scan from an X-less gentoo machine. The task is quite simple, but there are a few quirks that are not obvious.</p>

<p>The easy part:</p>

<ol>
<li>emerge nessus</li>
<li>nessus-mkcert</li>
<li>nessus-user-add</li>
<li>register at nessus website to get the actiovation code for plugin feeds (FYI: #GPL plugins: 1299, #registered plugins: 9575), so unless you register you get a very small subset of (probably outdated)  scanners.</li>
<li>nessus-fetch &#8211;register &lt;activation-code&gt;</li>
<li>nessus-update-plugins (it probably makes sense to add it to cron).</li>
</ol>

<p>Ok, now for scanning the most obvious choice is to run a nessus client with GTK interface. If we don&#8217;t want to do this we can either:</p>

<ul>
<li>run the graphical console remotely</li>
<li>run a command-line interface.</li>
</ul>

<p>The tricky part:
Scanning using command line interface:</p>

<pre><code>nessus -V -q 127.0.0.1 1241 &lt;user&gt; &lt;password&gt; &lt;host file&gt; &lt;output file.nbe&gt;
</code></pre>

<p>It works fine although generates a warning that &#8220;potentially unsafe plugins have been disabled&#8221;. While it makes sense for a big and critical network, you may also want to do the &#8220;unsafe&#8221; scan occasionally. How to enable it?</p>

<p>The first trick, is that nessus creates a &#8220;.nessusrc&#8221; file in your home directory. The first try &#8212; &#8220;safe_checks=no&#8221; &#8211; doesn&#8217;t help.
Second, you figure out that there is also a nessus-wide file /etc/nessus/nessusd.conf&#8221;, which has the same option (overriding the local one) by default set to &#8220;yes&#8221;. Unfortuantely, no warning is generated when this happenes. Unfortunately, this doesn&#8217;t help either <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>

<p>I found the solution analyzing the config file that was created after using nessus with a GUI (with all the plugins enabled). It turns out that such a file the following entry is being added:</p>

<pre><code>begin(PLUGIN_SET)
 14250 = yes
 15094 = yes
 15185 = yes
...
end(PLUGIN_SET)
</code></pre>

<p>So all the plugins are explicitly enabled. Only then AND if both safe_checks in the global and local config files are set to &#8220;no&#8221;, unsafe plugins are executed. Unfortuantely, I don&#8217;t know how to set this option from the command line. Also as the new plugins are being instaled, the list would need to be kept  updated (does nessus client do this?).</p>

<p>Another solution can be using Net::Nessus::ScanLite from CPAN (unfortunately it seems a bit outdated ~Dec 2003). I haven&#8217;t tried it, but it looks ok, and also it supports reading of plugins (so that we can enable/disable some) and also relieves us from parsing the NBE file.
Problem: Net::Nessus::ScanLite uses Net:Nessus::Client, which doesn&#8217;t compile (for a number of reasons) and, moreover,  is not aware that Nessus uses SSL. Surprisingly enough, ScanLite is aware of this and it somehow works around this. How &#8212; I don&#8217;t know.</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/10/12/nessus-command-line-search/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>Simple one-to-many database insertions in PostgreSQL</title>
		<link>http://tadek.pietraszek.org/blog/2005/10/07/simple-one-to-many-database-insertions-in-postgresql/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/10/07/simple-one-to-many-database-insertions-in-postgresql/#comments</comments>
		<pubDate>Fri, 07 Oct 2005 09:42:28 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Hacking]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2005/10/07/simple-one-to-many-database-insertions-in-postgresql/</guid>
		<description><![CDATA[It&#8217;s quite often the case that in a normalized database there is a one-to-many relation that are being populated in a following fashin: loop: - one insert to &#8220;one&#8221; relation - multiple inserts to &#8220;many&#8221; relations. We want to use autoincremented types like SERIAL for IDs linking these two relations and avoid unnecessary queries. create [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s quite often the case that in a normalized database there is a one-to-many relation that are being populated in a following fashin:
loop:
- one insert to &#8220;one&#8221; relation
- multiple inserts to &#8220;many&#8221; relations.</p>

<p>We want to use autoincremented types like SERIAL for IDs linking these two relations and avoid unnecessary queries.</p>

<p>create table one( one_id serial primary_key, something&#8230;.);
create table many(many-id serial primary key, one_id references one(one_id) default currval(&#8216;one_one_id_seq&#8217;),  something&#8230;);</p>

<p>And inserting like these:
insert into one(something)  values (some_values);
insert into many(something) values(some_values1);
insert into many(something) values(some_values2);
&#8230;</p>

<p>If there is no string one-one, many-many pattern, you can still get the last value of the sequence by calling
select currval(&#8216;one_one_id_seq&#8217;);
and stroing it somewhere.</p>

<p>This works well in Postgres, but other databases have similar capabilities. BTW: currval() is stored per session, so there is no threat that the sequences get screwed with concurrent access.</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/10/07/simple-one-to-many-database-insertions-in-postgresql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Easiliy enforcing referential integrity in Postgres</title>
		<link>http://tadek.pietraszek.org/blog/2005/10/06/easiliy-enforcing-referential-integrity-in-postgres/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/10/06/easiliy-enforcing-referential-integrity-in-postgres/#comments</comments>
		<pubDate>Thu, 06 Oct 2005 20:51:48 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Hacking]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2005/10/06/easiliy-enforcing-referential-integrity-in-postgres/</guid>
		<description><![CDATA[Suppose table A has a primary key id of the type SERIAL. This means that Postgres implicity creates a sequence called A_id_seq, which is automatically incremented on insert with no value or DEFAULT value. To enforce referential integrity with B within a session we use it as follows: insert into A (&#60;not A&#62;) values (&#60;values&#62;) [...]]]></description>
			<content:encoded><![CDATA[<p>Suppose table A has a primary key id of the type SERIAL. This means that Postgres implicity creates a sequence called A_id_seq, which is automatically incremented on insert with no value or DEFAULT value.</p>

<p>To enforce referential integrity with B within a session we use it as follows:</p>

<p>insert into A (&lt;not A&gt;)  values (&lt;values&gt;)
insert into B values( CURRVAL(&#8216;A_id_seq&#8217;), &lt;other values;&gt;)</p>

<p>Note that CURRVAL is defined <em>per session</em> so concurrent access is not a problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/10/06/easiliy-enforcing-referential-integrity-in-postgres/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ssh_config file</title>
		<link>http://tadek.pietraszek.org/blog/2005/10/04/ssh_config-file/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/10/04/ssh_config-file/#comments</comments>
		<pubDate>Tue, 04 Oct 2005 08:00:09 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2005/10/04/ssh_config-file/</guid>
		<description><![CDATA[Recently learned about .ssh/config file, in which you can customize parameters used for connecting to different hosts. The complete syntax is described in &#8220;man ssh_config&#8221;, here is just a few highlights: Host &#60;short hostname&#62; Hostname &#60;full hostname&#62; Port port User user LocalForward 54320 localhost:5432 Dynamic Forward 9050]]></description>
			<content:encoded><![CDATA[<p>Recently learned about .ssh/config file, in which you can customize parameters used for connecting to different hosts. The complete syntax is described in &#8220;man ssh_config&#8221;, here is just a few highlights:</p>

<p>Host &lt;short hostname&gt;
Hostname &lt;full hostname&gt;
Port port
User user
LocalForward 54320 localhost:5432
Dynamic Forward 9050</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/10/04/ssh_config-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

