<?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>[blog.rayfoo] &#187; scripts</title>
	<atom:link href="http://blog.rayfoo.info/tag/scripts/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.rayfoo.info</link>
	<description>Infosec, DFIR, tech geekery, thoughts and whatnot</description>
	<lastBuildDate>Wed, 25 Jan 2012 00:36:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>DNS tracking with Python</title>
		<link>http://blog.rayfoo.info/2010/08/dns-tracking-with-python</link>
		<comments>http://blog.rayfoo.info/2010/08/dns-tracking-with-python#comments</comments>
		<pubDate>Sun, 01 Aug 2010 18:14:30 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[CC]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[DNS tracking]]></category>
		<category><![CDATA[GPL]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=690</guid>
		<description><![CDATA[For those who have need to keep track of changes (IP address changes and "status") of a list of DNS hosts/addresses, I wrote a Python script to help with this task. Please help by providing comments/ideas for improvement/thanks/death-threats in the comments section below.  Ok, maybe not the death-threats. Download and License The current version of [...]]]></description>
			<content:encoded><![CDATA[<p>For those who have need to keep track of changes (IP address changes and "status") of a  list of DNS hosts/addresses, I wrote a Python script to help with this task.</p>
<p>Please help by <a href="#respond">providing comments</a>/ideas for improvement/thanks/death-threats in the <a href="#respond">comments section</a> below.  Ok, maybe not the death-threats. <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h2>Download and License</h2>
<p>The current version of this script is <strong>v1.03</strong>, released under the GPL license.  <a href="http://blog.rayfoo.info/wp-content/uploads/2010/08/dns_tracker-v1.03.zip">Click here to download it</a>.<br />
<!-- Creative Commons License --><br />
<a href="http://creativecommons.org/licenses/GPL/2.0/"><img src="http://creativecommons.org/images/public/cc-GPL-a.png" border="0" alt="CC-GNU GPL" /></a><br />
This software is licensed under the <a href="http://creativecommons.org/licenses/GPL/2.0/">CC-GNU GPL</a> version 2.0 or later.<br />
<!-- /Creative Commons License --></p>
<h2>What it can do/Features:</h2>
<ul>
<li>Keep track of changes (IP addresses, status: existent/gone) to a list of specified domains</li>
<li>Resolve many many many domains into a greppable format for you!</li>
<li>Multithreaded in Python</li>
<li>Does logging to a logfile, and to console at the same time</li>
<li>Configurable to a certain extent</li>
</ul>
<h2>How to get and use:</h2>
<ul>
<li>Install the PyDNS library found in the <a href="http://pypi.python.org/pypi/pydns/">Python Package Index</a>, hosted at <a href="http://pydns.sourceforge.net/">SourceForge</a></li>
<li>Grab a copy from the download section above and extract the script out</li>
<li>Configure the script if you need to (see below)</li>
<li>Create a text file named <em>dns-list.txt</em> in the same folder as the <em>dns_tracker.py</em> script, list the DNS hosts that you want to track in the dns-list.txt file, one host per line</li>
<li>Run the script from command line: <span style="color: #339966;">python dns_tracker.py</span>.  The log file written to would be called <em>dns-track.log</em></li>
<li>Profit!</li>
<li>You can stop the script by pressing Ctrl-C in the console ONCE.  It will attempt to kill off the waiting threads and exit gracefully.</li>
</ul>
<h2>What you can configure:</h2>
<ul>
<li>All the editable options are in the section marked <span style="color: #00ccff;">##Editable options</span>.  Some of the options are...</li>
<li>Use system configured resolvers: set<span style="color: #00ff00;"> 'use_server': False,</span></li>
<li>Use a DNS resolver of your choice: set <span style="color: #00ff00;">'use_server': True,</span> and also <span style="color: #00ff00;">'server': '&lt;your resolver&gt;',</span></li>
<li>The logfile name can be changed too <span style="color: #00ff00;"> 'logfile': 'dns-track.log',</span></li>
</ul>
<h2>Changelog:</h2>
<ul>
<li>v1.03 (15 Aug 2010)</li>
<blockquote>
<li>fixed logging hierarchy!  now we can control console and file log levels!</li>
</blockquote>
<li>v1.02 (10 Aug 2010)</li>
<blockquote>
<li>added SERVFAIL to recognise as possible status</li>
<li>changed DNS resolving fail behaviour: retry 1min later</li>
<li> changed monitoring start behaviour (faster by using threads)</li>
<li>orphaned threads will also stop themselves if the main thread's killed</li>
</blockquote>
<li>v1.01 (3 Aug 2010)</li>
<blockquote>
<li>demarcated editable options section ("##Editable options")</li>
<li>changed logging to append instead of overwriting existing log</li>
<li>remember that CNAMEs are also extracted for comparison of changes</li>
<li>added in minimum delay checks to account for CNAMEs' TTL being 0</li>
<li>adjusted logging levels for logfile, console still outputs everything</li>
</blockquote>
<li>v1.00 (2 Aug 2010)</li>
<blockquote>
<li>initial release!</li>
</blockquote>
</ul>
<h2>TODO:</h2>
<ul>
<li>Perhaps migrating configurable options out to command line parameters<br />
or a separate config file?</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2010/08/dns-tracking-with-python/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Verifying rkhunter file warnings</title>
		<link>http://blog.rayfoo.info/2009/10/verifying-rkhunter-file-warnings</link>
		<comments>http://blog.rayfoo.info/2009/10/verifying-rkhunter-file-warnings#comments</comments>
		<pubDate>Mon, 12 Oct 2009 06:46:26 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[detection]]></category>
		<category><![CDATA[Finnix]]></category>
		<category><![CDATA[hardening]]></category>
		<category><![CDATA[rkhunter]]></category>
		<category><![CDATA[rootkit]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[server administration]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=250</guid>
		<description><![CDATA[I got this problem as my rkhunter installation detected changed files (due to updates), so I encountered this solution by steve as I was searching for a solution. Of course, as there could be a root kit/trojan/malicious stuff running in your system as rkhunter's meant to detect, you should NOT fully trust anything running from [...]]]></description>
			<content:encoded><![CDATA[<p>I got this problem as my <a href="http://www.rootkit.nl/projects/rootkit_hunter.html">rkhunter</a> installation detected changed files (due to updates), so I encountered this <a href="http://www.shuningbian.net/2009/06/dealing-with-rkhunter-warnings.php">solution</a> by <a href="http://www.shuningbian.net/">steve</a> as I was searching for a solution.</p>
<p>Of course, as there could be a root kit/trojan/malicious stuff running in your system as rkhunter's meant to detect, you should NOT fully trust anything running from the machine.  But I had to rely on this solution temporarily until I can get it (rebooted and) checked out proper using a tool like <a href="http://www.finnix.org/">Finnix</a>.<br />
Am reposting the script here for reference, but you can get the most recent copy of the script <a href="http://git.pictorii.com/?p=scripts.git;a=blob_plain;f=verify.sh;hb=rei">here</a> .<br />
<span id="more-250"></span></p>
<p>
<pre style="color:green">#!/bin/bash
desc="
This script will verify whether files for which rkhunter has logged a
warning for is still valid. It does this by finding which debian package
it came out of, and downloads them, unpacks them, then checks
the checksums.

Run it by supplying a rkhunter log file as first argument
"

HASHER="sha256sum"

IFS="
"
function find_suspect_files
{
	echo "parsing $1 for suspect files" 1>&#038;2
	grep -1 Warning "$1"| grep File | sed 's|.*File: ||'
}

function find_packages
{
	echo "finding packages" 1>&#038;2
	for suspect_file in $1
	do
		package=$(dpkg -S $suspect_file|awk '{print $1}'|sed 's/.$//')
		echo "suspect file $suspect_file found in $package" 1>&#038;2
		echo $package
	done

}

function make_aptitude_args
{
	echo "generating aptitude arguments" 1>&#038;2
	for package in $1
	do
		version=$(dpkg -p $package | grep Version | awk '{print $2}')
		echo $package=$version
	done
}

function cleanup
{
	echo "cleaning up"
	popd
	rm -rf tmp
	exit $1
}

function setup
{
	echo "setting up"
	rm -rf tmp
	mkdir tmp
	pushd tmp
}

if [ $# -ne 1 ];
then
	echo "$desc"
	exit 1
fi

suspect_files=$(find_suspect_files "$1")

packages=$(find_packages "$suspect_files" | sort | uniq)

if [ -z "$packages" ];
then
	echo "***WARNING****"
	echo "No packages contain any of the suspect files!"
	cleanup 1
fi

aptitude_args=$(make_aptitude_args "$packages")

setup

echo "downloading packages"
aptitude download $aptitude_args 1>/dev/null
if [ $? -ne 0 ];
then
	echo "aptitude download failed!"
	echo "args=$aptitude_args"
	cleanup 1
fi

echo "unpacking"
for deb_file in *.deb
do
	ar -x $deb_file
	tar zxf data.tar.gz
	rm -rf data.tar.gz control.tar.gz
done

for suspect_file in $suspect_files
do
	if [ ! -f ".$suspect_file" ]
	then
		echo "***WARNING****"
		echo "For some reason .$suspect_file does not exis!"
		continue
	fi
	echo -n "verifying $suspect_file... "
	suspect_sum=$($HASHER $suspect_file | awk '{print $1}')
	clean_sum=$($HASHER ".$suspect_file" | awk '{print $1}')
	if [ $suspect_sum == $clean_sum ];
	then
		echo "OK"
	else
		echo
		echo "***WARNING****"
		echo "Checksum mistmatch for $suspect_file!!!"
		echo "Should be: $clean_sum"
		echo "Is: $suspect_sum"
	fi
done
cleanup</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2009/10/verifying-rkhunter-file-warnings/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

