<?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>RemoteRoot &#187; Honeypot</title>
	<atom:link href="http://www.remoteroot.net/category/honeypot/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.remoteroot.net</link>
	<description>The wired world</description>
	<lastBuildDate>Tue, 29 Jul 2008 14:16:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Testing Nepenthes Works</title>
		<link>http://www.remoteroot.net/2008/07/22/testing-nepenthes-works/</link>
		<comments>http://www.remoteroot.net/2008/07/22/testing-nepenthes-works/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 01:54:23 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Honeypot]]></category>
		<category><![CDATA[Nepenthes]]></category>

		<guid isPermaLink="false">http://www.remoteroot.net/?p=92</guid>
		<description><![CDATA[To check that Nepenthes actually works, and more importantly that any server side applications that rely on it receive data correctly it&#8217;s useful to test whether Nepenthes works.
Firstly enable the following lines in nepenthes.conf

//  "x1.so",                    [...]]]></description>
			<content:encoded><![CDATA[<p>To check that Nepenthes actually works, and more importantly that any server side applications that rely on it receive data correctly it&#8217;s useful to test whether Nepenthes works.</p>
<p>Firstly enable the following lines in <code>nepenthes.conf</code></p>
<blockquote>
<pre>//  "x1.so",                       "x-1.conf",                     "",
//  "x2.so",                       "x-2.conf",                     "",</pre>
</blockquote>
<p>
This enables us to connect to the x-2 example module, that provides a simple shell and the x-3 example module that adds a file-handler that reads data from <code>/dev/urandom</code>.</p>
<p>Start Nepenthes and using netcat connect on the port specified in x-2.conf. This is 10002 by default.</p>
<p>You should have a prompt now:</p>
<blockquote>
<pre>joe@nepenthes ~ $ nc 127.0.0.1 10002
Welcome to dong Shell</pre>
</blockquote>
<p>
Enter <code>download file://127.0.0.1:53421//dev/urandom</code> and hit return.</p>
<p>In the nepenthes log file should see something close to the following:</p>
<blockquote>
<pre>[23072008 01:57:18 crit module] Downloading file from "file://127.0.0.1:53421//dev/urandom"
[23072008 01:57:18 info down mgr] Handler urandom download handler will download file://127.0.0.1:53421//dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 debug info fixme] read 2048 bytes from /dev/urandom
[23072008 01:57:18 info mgr submit] File 4a05e1a3a5658274c04409ea5b1a3227 has type data
[23072008 01:57:27 debug info fixme] File info submitted (4a05e1a3a5658274c04409ea5b1a3227, file://127.0.0.1:53421//dev/urandom)
[23072008 01:57:27 debug info fixme] File upload requested (4a05e1a3a5658274c04409ea5b1a3227, file://127.0.0.1:53421//dev/urandom)
[23072008 01:57:31 debug info fixme] Submitted file 4a05e1a3a5658274c04409ea5b1a3227 to sandbox http://www.norman.com/microsites/nsic/Submit/Special/45773/
[23072008 01:57:31 debug info fixme] Submitted file 4a05e1a3a5658274c04409ea5b1a3227 to sandbox http://luigi.informatik.uni-mannheim.de/submit.php?action=verify</pre>
</blockquote>
<p>
Check your filesystem if using the <code>submit-file</code> module or your logging system!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.remoteroot.net/2008/07/22/testing-nepenthes-works/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nepenthes submit-http server (with file upload!).</title>
		<link>http://www.remoteroot.net/2008/07/21/nepenthes-submit-http-server-with-file-upload/</link>
		<comments>http://www.remoteroot.net/2008/07/21/nepenthes-submit-http-server-with-file-upload/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 23:21:32 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Honeypot]]></category>
		<category><![CDATA[Nepenthes]]></category>

		<guid isPermaLink="false">http://www.remoteroot.net/?p=55</guid>
		<description><![CDATA[Simple server for the submit-http module within Nepenthes. This saves the details of the attack into a MySQL Database and sticks the captured binary into a folder.
The submit-http handler, submits the attack data via an HTTP Post, including: URL, Trigger, MD5, SHA512, FileType, SourceHost, TargetHost, Filename and File.
Save the code below as submit.php and edit [...]]]></description>
			<content:encoded><![CDATA[<p>Simple server for the submit-http module within Nepenthes. This saves the details of the attack into a MySQL Database and sticks the captured binary into a folder.</p>
<p>The submit-http handler, submits the attack data via an HTTP Post, including: URL, Trigger, MD5, SHA512, FileType, SourceHost, TargetHost, Filename and File.</p>
<p>Save the code below as <code>submit.php</code> and edit <code>submit-http.conf</code> to point to it. Make sure you read the issues below!</p>
<blockquote>
<pre>&lt;?php

$user = "";
$passwd = "";
$db = "";
$server = "";

$filepath = "binaries/";

if($_FILES['file']['size'] &gt; 0)
{
	if(!is_uploaded_file($_FILES['file']['tmp_name']))	{
		die("S_ERROR");
	}

	storeFile($_POST['md5']);
	echo "S_FILEOK";
}
else
{
	storeData($_POST,$_SERVER['REMOTE_ADDR']);

	if(fileExists($_POST['md5']))	{
		echo "S_FILEKNOWN";
	}
	else	{
		echo "S_FILEREQUEST";
	}
}

function fileExists($file)	{
	file_exists($filepath . $file);
}

function queryDB($query)	{
	global $user, $passwd, $db, $server;
	$con = mysql_connect($server, $user,$passwd);
	if (!$con)	{
 		die('Could not connect: ' . mysql_error());
	}
	mysql_select_db($db, $con);

	$result = mysql_query($query,$con);	

	if (!$result)	{
  		die('Error: ' . mysql_error());
  	}
	mysql_close($con);

	return $result;
}

function storeData($data, $sensor)	{
	$remotehost = $sensor;

	foreach ($_POST as $key =&gt; $value)
	{
			switch ($key) {

			case 'url':
			$url = $value;
			break;
			case 'trigger':
			$trigger = $value;
			break;
			case 'md5':
			$md5 = $value;
			break;
			case 'sha512':
			$sha512 = $value;
			break;
			case 'filetype':
			$filetype = $value;
			break;
			case 'source_host':
			$sourcehost = $value;
			break;
			case 'target_host':
			$targethost = $value;
			break;
			case 'filename':
			$filename = $value;
			break;
		default:
			break;
			}
	}

	$query = "INSERT INTO submission (`RemoteHost`, `URL`, `Trigger`, `MD5`, `SHA512`, `FileType`, `SourceHost`,
           `TargetHost`, `Filename`, `Submitted`)  VALUES ('$remotehost', '$url', '$trigger', '$md5', '$sha512', '$filetype',
           '$sourcehost', '$targethost', '$filename', NOW())";

	queryDB($query);
}

function storeFile($file)	{
	global $filepath;
	if(!move_uploaded_file($_FILES['file']['tmp_name'], $filepath . $file))	{
		die("S_ERROR");
	}
}

?&gt;</pre>
</blockquote>
<p>You can test it works correctly with a simple HTML file as below. Save the file as <code>submit.html</code>.</p>
<blockquote>
<pre>&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form action="submit.php" method="post" enctype="multipart/form-data"&gt;
  &lt;p&gt;URL
    &lt;input type="text" name="url"&gt;
    &lt;br&gt;
Trigger
&lt;input type="text" name="trigger"&gt;
&lt;br&gt;
MD5
&lt;input type="text" name="md5"&gt;
&lt;br&gt;
SHA512
&lt;input type="text" name="sha512"&gt;
&lt;br&gt;
FileType
&lt;input type="text" name="filetype"&gt;
&lt;br&gt;
SourceHost
&lt;input type="text" name="source_host"&gt;
&lt;br&gt;
TargetHost
&lt;input type="text" name="target_host"&gt;
&lt;br&gt;
Filename
&lt;input type="text" name="filename"&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;label&gt;File
    &lt;input type="file" name="file" id="file"&gt;
    &lt;/label&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;input type="submit" value="Submit"&gt;
    &lt;/p&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
</blockquote>
<p>For an example that simply writes to a file, see the UK Honeynet Project <a title="UK Honeynet Project - Submit HTTP for Nepenthes" href="http://www.ukhoneynet.org/2008/06/03/submit-http-for-nepenthes/" target="_blank">submit-http handler</a>. Credit for the submit-http patch and the idea for this post go to <a href="http://macbeth.digitician.eu/nepenthes/" target="_blank">Niklas Schiffler</a>!</p>
<p>Current issues with this implementation:</p>
<ul>
<li>There is no input checking, it&#8217;s SQL injection madness. Run it behind HTTP-Auth and add your own sanity checking!</li>
<li>It&#8217;s not the best way of coding it!</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.remoteroot.net/2008/07/21/nepenthes-submit-http-server-with-file-upload/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
