<?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> &#187; network security</title>
	<atom:link href="http://travisaltman.com/category/network-security/feed/" rel="self" type="application/rss+xml" />
	<link>http://travisaltman.com</link>
	<description></description>
	<lastBuildDate>Sat, 24 Mar 2012 04:16:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Honeypot / honeyd tutorial part 5, email alerts</title>
		<link>http://travisaltman.com/honeypot-honeyd-tutorial-part-5-email-alerts/</link>
		<comments>http://travisaltman.com/honeypot-honeyd-tutorial-part-5-email-alerts/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 05:17:49 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[honeypot]]></category>
		<category><![CDATA[network security]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=510</guid>
		<description><![CDATA[So this is the final article in this series of honeypots and honeyd and before I wrap it up I&#8217;ve gotta give big shout outs to Neils Provos the creator of honeyd. Neils has done an excellent job with the honeyd program and his book Virtual Honeypots is hands down the best book about honeypots [...]]]></description>
			<content:encoded><![CDATA[<p>So this is the final article in this series of honeypots and honeyd and before I wrap it up I&#8217;ve gotta give big shout outs to <a href="http://www.citi.umich.edu/u/provos/">Neils Provos</a> the creator of honeyd. Neils has done an excellent job with the honeyd program and his book <a href="http://www.amazon.com/Virtual-Honeypots-Tracking-Intrusion-Detection/dp/0321336321" target="_blank">Virtual Honeypots</a> is hands down the best book about honeypots and I highly recommend picking up a copy. While writing some of these tutorials Neils was even kind enough to answer some of my emails.</p>
<p>Up to this point you hopefully have an understanding on how to get honeyd up and running on your preferred hardware while having the ability to run multiple honeypots in either a static or dhcp environment. Now that everything is running smoothly and you&#8217;ve successfully tested all connectivity you&#8217;ll probably want to start getting alerts from some of the honeypots you&#8217;ve setup and deployed. I&#8217;ve written a small python script that accomplishes this for me so hopefully my explanation of the setup will get you receiving email alerts as well.</p>
<p>So out of the box honeyd doesn&#8217;t natively support getting emails sent to you when your device is port scanned. I really wanted this feature but had to figure out the best way of determining when my honeypot was being scanned. Honeyd has the option of creating a log file so my first idea was to parse this file for items of interest. Below is the command I would use to launch honeyd with the logging option.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">honeyd -d -f honeyd.conf -l /tmp/logfile</div></div>
<p>You should see similar output as below after running the above command.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Honeyd V1.5c Copyright (c) 2002-2007 Niels Provos<br />
honeyd[12073]: started with -d -f honeyd.conf -l /tmp/logfile<br />
Warning: Impossible SI range in Class fingerprint &quot;IBM OS/400 V4R2M0&quot;<br />
Warning: Impossible SI range in Class fingerprint &quot;Microsoft Windows NT 4.0 SP3&quot;<br />
honeyd[12073]: listening promiscuously on eth1: (arp or ip proto 47 or (udp and src port 67 and dst port 68) or (ip )) and not ether src 00:0c:29:11:1e:53<br />
honeyd[12073]: [eth1] trying DHCP<br />
honeyd[12073]: Demoting process privileges to uid 65534, gid 65534<br />
honeyd[12073]: [eth1] got DHCP offer: 192.168.134.147<br />
honeyd[12073]: Updating ARP binding: 00:00:24:54:9e:06 -&gt; 192.168.134.147<br />
honeyd[12073]: arp reply 192.168.134.147 is-at 00:00:24:54:9e:06<br />
honeyd[12073]: Sending ICMP Echo Reply: 192.168.134.147 -&gt; 192.168.134.254<br />
honeyd[12073]: arp_send: who-has 192.168.134.254 tell 192.168.134.147<br />
honeyd[12073]: arp_recv_cb: 192.168.134.254 at 00:50:56:e8:c9:74</div></div>
<p>So this just created a honeypot with the IP address of 192.168.134.147. From another machine let&#8217;s port scan our honeypot, to keep the output simple I&#8217;m only going to scan one port.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@tht:~# nmap -p 135 192.168.134.147<br />
<br />
Starting Nmap 5.21 ( http://nmap.org ) at 2012-02-10 19:37 PST<br />
Nmap scan report for 192.168.134.147<br />
Host is up (0.0013s latency).<br />
PORT STATE SERVICE<br />
135/tcp open msrpc<br />
MAC Address: 00:00:24:54:9E:06 (Connect AS)<br />
<br />
Nmap done: 1 IP address (1 host up) scanned in 0.14 seconds</div></div>
<p>So port 135 is open so we know our configuration is working properly. Also honeyd will output information to the terminal letting you know that connections are being made to your honeypot. The information below was appended to the output from when we started honeyd.</p>
<div class="codecolorer-container text blackboard" 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 /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">honeyd[12073]: arp reply 192.168.134.147 is-at 00:00:24:54:9e:06<br />
honeyd[12073]: arp reply 192.168.134.147 is-at 00:00:24:54:9e:06<br />
honeyd[12073]: Connection request: tcp (192.168.134.143:49677 - 192.168.134.147:135)<br />
honeyd[12073]: arp_send: who-has 192.168.134.143 tell 192.168.134.147<br />
honeyd[12073]: arp_recv_cb: 192.168.134.143 at 00:0c:29:e3:2a:39<br />
honeyd[12073]: Connection dropped by reset: tcp (192.168.134.143:49677 - 192.168.134.147:135)<br />
honeyd[12073]: arp_recv_cb: 192.168.134.254 at 00:50:56:e8:c9:74<br />
honeyd[12073]: arp_recv_cb: 192.168.134.254 at 00:50:56:e8:c9:74</div></td></tr></tbody></table></div>
<p>On line three we see a connection request from 192.168.134.143 to our honeypot at 192.168.134.147 and the &#8220;:135&#8243; after the IP address is the destination port so from this output we can verify everything is working and we&#8217;re getting the correct response from our port scan. You also see on line six that the connection from 192.168.134.143 to 192.168.134.147 was dropped. Now let&#8217;s take a look at our log file to see what kind of information about our port scan shows up. We&#8217;ll use the tail command in Linux, by default the tail command only shows the last 10 lines of a file although this can be adjusted.</p>
<div class="codecolorer-container text blackboard" 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 /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@bt:~# tail /tmp/logfile<br />
2012-02-10-22:37:42.9749 udp(17) - 192.168.134.1 61712 224.0.0.252 5355: 60<br />
2012-02-10-22:37:48.0504 udp(17) - 192.168.134.143 44907 192.168.134.2 53: 74<br />
2012-02-10-22:37:48.0751 udp(17) - 192.168.134.2 53 192.168.134.143 44907: 74<br />
2012-02-10-22:37:48.0799 tcp(6) S 192.168.134.143 49677 192.168.134.147 135<br />
2012-02-10-22:37:48.0814 tcp(6) E 192.168.134.143 49677 192.168.134.147 135: 0 0<br />
2012-02-10-22:38:00.0874 udp(17) - 192.168.134.1 57479 224.0.0.252 5355: 55<br />
2012-02-10-22:38:02.9374 udp(17) - 192.168.134.1 64855 224.0.0.252 5355: 55<br />
2012-02-10-22:38:09.9825 udp(17) - 192.168.134.1 57141 224.0.0.252 5355: 57<br />
2012-02-10-22:38:13.2114 udp(17) - 192.168.134.1 60692 224.0.0.252 5355: 56<br />
2012-02-10-22:38:16.0751 udp(17) - 192.168.134.1 57282 224.0.0.252 5355: 56</div></td></tr></tbody></table></div>
<p>In the log file we see very similar information on lines 5 and 6 as we did in the standard output of the terminal. Turns out there&#8217;s a third location of output that we could tap into. All processes in Linux will probably display some kind of information into one of two system log files. Either the /var/log/messages or the /var/log/syslog file. Different <a href="http://distrowatch.com/" target="_blank">distros</a> of Linux will put this information into different locations but for the backtrack distro I know it goes into /var/log/syslog. Let&#8217;s tail this file to see what kind of information it holds.</p>
<div class="codecolorer-container text blackboard" 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 /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Feb 10 22:36:53 bt honeyd[12073]: arp reply 192.168.134.147 is-at 00:00:24:54:9e:06<br />
Feb 10 22:36:53 bt honeyd[12073]: Sending ICMP Echo Reply: 192.168.134.147 -&gt; 192.168.134.254<br />
Feb 10 22:36:53 bt honeyd[12073]: arp_send: who-has 192.168.134.254 tell 192.168.134.147<br />
Feb 10 22:36:53 bt honeyd[12073]: arp_recv_cb: 192.168.134.254 at 00:50:56:e8:c9:74<br />
Feb 10 22:37:48 bt honeyd[12073]: arp reply 192.168.134.147 is-at 00:00:24:54:9e:06<br />
Feb 10 22:37:48 bt honeyd[12073]: arp reply 192.168.134.147 is-at 00:00:24:54:9e:06<br />
Feb 10 22:37:48 bt honeyd[12073]: Connection request: tcp (192.168.134.143:49677 - 192.168.134.147:135)<br />
Feb 10 22:37:48 bt honeyd[12073]: arp_send: who-has 192.168.134.143 tell 192.168.134.147<br />
Feb 10 22:37:48 bt honeyd[12073]: arp_recv_cb: 192.168.134.143 at 00:0c:29:e3:2a:39<br />
Feb 10 22:37:48 bt honeyd[12073]: Connection dropped by reset: tcp (192.168.134.143:49677 - 192.168.134.147:135)</div></td></tr></tbody></table></div>
<p>On lines 7 and 10 we see similar information as we&#8217;ve seen in other areas. So when I decided to build an email alert script I had three sources of information I could pull from. I eventually went with combing through /var/log/syslog but I could have easily went a different route. For me /var/log/syslog seem to have more verbosity and better keywords but then again that&#8217;s just my opinion. My next step was to write a script that would parse /var/log/syslog then generate an email alert when it saw connections to my honeypot. I wrote my script in <a href="http://python.org/" target="_blank">Python</a> because I&#8217;m most familiar with that language and Python comes installed by default on most Linux distributions so whatever distro you decide to run honeyd on it&#8217;s more than likely Python will already be installed on that same operating system.</p>
<p>Before you implement any scripted email solution it&#8217;s a good idea to test email functionality with a small email script just to ensure you can properly communicate and receive email alerts. To do this you&#8217;ll need to know the name (<a href="http://en.wikipedia.org/wiki/Fully_qualified_domain_name" target="_blank">FQDN</a>) of your<a href="http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol" target="_blank"> SMTP </a>email server. You can usually find them in your email client. For Outlook you can go to File &gt; Account Settings &gt; Account Settings &gt; Email tab &gt; click on Change, there you&#8217;ll see the name of your organizations smtp server. Typically it&#8217;ll be something simple, if the email of your organization ends in example.com then your smtp server will likely be smtp.example.com. SMTP servers are usually configured to send emails in one of two ways, authenticated or unauthenticated. We&#8217;ll look at examples for both. The first example below is a python script of sending authentication credentials along with the request, in this particular I&#8217;m sending the alert to my gmail account.</p>
<div class="codecolorer-container python blackboard" 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 />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<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;">import</span> <span style="color: #dc143c;">smtplib</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">time</span><br />
<br />
From <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'someuser@gmail.com'</span><br />
To <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'travisaltman@gmail.com'</span><br />
Date <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">time</span>.<span style="color: black;">ctime</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
Subject <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'test'</span><br />
Text <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'test'</span><br />
<br />
Message <span style="color: #66cc66;">=</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'From: %s<span style="color: #000099; font-weight: bold;">\n</span>To: %s<span style="color: #000099; font-weight: bold;">\n</span>Date: %s<span style="color: #000099; font-weight: bold;">\n</span>Subject: %s<span style="color: #000099; font-weight: bold;">\n</span>%s<span style="color: #000099; font-weight: bold;">\n</span>'</span> % <span style="color: black;">&#40;</span>From<span style="color: #66cc66;">,</span> To<span style="color: #66cc66;">,</span> Date<span style="color: #66cc66;">,</span> Subject<span style="color: #66cc66;">,</span> Text<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
username <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'someuser'</span><br />
password <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'somepassword'</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'Connecting to server'</span><span style="color: black;">&#41;</span><br />
s <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">smtplib</span>.<span style="color: black;">SMTP</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'smtp.gmail.com'</span><span style="color: black;">&#41;</span><br />
s.<span style="color: black;">starttls</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
s.<span style="color: black;">login</span><span style="color: black;">&#40;</span>username<span style="color: #66cc66;">,</span>password<span style="color: black;">&#41;</span><br />
sendMail <span style="color: #66cc66;">=</span> s.<span style="color: black;">sendmail</span><span style="color: black;">&#40;</span>From<span style="color: #66cc66;">,</span> To<span style="color: #66cc66;">,</span> Message<span style="color: black;">&#41;</span><br />
s.<span style="color: black;">quit</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">if</span> sendMail:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'error'</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'great success'</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>Hopefully some of this script is easy to figure out, the main thing you need to be concerned with is lines 11,12, and 15. Lines 11 and 12 hold the username and password you&#8217;ll need to authenticate to your smtp server and line 15 is the name of your smtp server. More than likely your internal smtp server will not require authentication if that&#8217;s the case simply remove lines 11,12,16, and 17 from the script above. If you&#8217;re not sure first send the test email without authentication and if you get the error message &#8220;smtplib.SMTPSenderRefused&#8221; then more than likely you&#8217;ll need to provide credentials. If everything goes smooth running your test email script then you should see the output below, here I&#8217;ve named my script test.py.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@tht:~# python test.py<br />
Connecting to server<br />
great success</div></div>
<p>Next you can implement the full email alerting script. Simply copy and paste the script below into your text editor of choice and name the script, I&#8217;ve named my alert.py.</p>
<div class="codecolorer-container python blackboard" 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 />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 />58<br />59<br />60<br />61<br />62<br />63<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;">import</span> <span style="color: #dc143c;">re</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">time</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">smtplib</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">try</span>:<br />
&nbsp; <span style="color: #dc143c;">os</span>.<span style="color: black;">remove</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/root/outputHoney'</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">except</span>:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">pass</span><br />
<br />
log <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;/var/log/syslog&quot;</span><br />
output <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'outputHoney'</span><br />
<br />
systemTime <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">time</span>.<span style="color: black;">ctime</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
loggedDate <span style="color: #66cc66;">=</span> systemTime<span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span>:<span style="color: #ff4500;">10</span><span style="color: black;">&#93;</span><br />
loggedYear <span style="color: #66cc66;">=</span> systemTime<span style="color: black;">&#91;</span><span style="color: #ff4500;">20</span>:<span style="color: #ff4500;">24</span><span style="color: black;">&#93;</span><br />
hostFile <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'/etc/hostname'</span><br />
readHostFile <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>hostFile<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'rU'</span><span style="color: black;">&#41;</span>.<span style="color: #dc143c;">readline</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span><br />
extractHostName1 <span style="color: #66cc66;">=</span> readHostFile.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'&quot;'</span><span style="color: black;">&#41;</span><br />
hostname <span style="color: #66cc66;">=</span> extractHostName1<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">rstrip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #008000;">file</span> <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>log<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'rU'</span><span style="color: black;">&#41;</span>.<span style="color: black;">readlines</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">file</span>:<br />
<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>loggedDate<span style="color: #66cc66;">,</span> line<span style="color: black;">&#41;</span>:<br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;192.168.1.55&quot;</span><span style="color: #66cc66;">,</span> line<span style="color: black;">&#41;</span>: <span style="color: #808080; font-style: italic;">#This if for any IP(s) you want to exclude</span><br />
&nbsp; &nbsp; ignore <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">''</span><br />
&nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Connection request&quot;</span><span style="color: #66cc66;">,</span> line<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; loggedTime <span style="color: #66cc66;">=</span> line<span style="color: black;">&#91;</span><span style="color: #ff4500;">7</span>:<span style="color: #ff4500;">15</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; timeString <span style="color: #66cc66;">=</span> loggedDate + <span style="color: #483d8b;">' '</span> + loggedYear + <span style="color: #483d8b;">' '</span> + loggedTime<br />
&nbsp; &nbsp; timeTuple <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">time</span>.<span style="color: black;">strptime</span><span style="color: black;">&#40;</span>timeString<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'%b %d %Y %H:%M:%S'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; epochLogTime <span style="color: #66cc66;">=</span> <span style="color: #008000;">int</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">time</span>.<span style="color: black;">mktime</span><span style="color: black;">&#40;</span>timeTuple<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; epochSystemTime <span style="color: #66cc66;">=</span> <span style="color: #008000;">int</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> epochSystemTime <span style="color: #66cc66;">&lt;=</span> epochLogTime+<span style="color: #ff4500;">300</span>:<br />
&nbsp; &nbsp; &nbsp; lineSplit1 <span style="color: #66cc66;">=</span> line.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'('</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; lineSplit2 <span style="color: #66cc66;">=</span> lineSplit1<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; lineSplit3 <span style="color: #66cc66;">=</span> lineSplit2.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">':'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; lineSplit4 <span style="color: #66cc66;">=</span> lineSplit2.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'-'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; lineSplit5 <span style="color: #66cc66;">=</span> lineSplit4<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; lineSplit6 <span style="color: #66cc66;">=</span> lineSplit5.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">':'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; destinationIP <span style="color: #66cc66;">=</span> lineSplit6<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; sourceIP <span style="color: #66cc66;">=</span> lineSplit3<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; srcAndDest <span style="color: #66cc66;">=</span> sourceIP + <span style="color: #483d8b;">' connected to '</span> + destinationIP<br />
&nbsp; &nbsp; &nbsp; <span style="color: #008000;">file</span> <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>output<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'w'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #008000;">file</span>.<span style="color: black;">writelines</span><span style="color: black;">&#40;</span>srcAndDest<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #008000;">file</span>.<span style="color: black;">close</span><br />
<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">exists</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/root/outputHoney'</span><span style="color: black;">&#41;</span>:<br />
&nbsp; From <span style="color: #66cc66;">=</span> hostname+<span style="color: #483d8b;">'@example.xxx'</span><br />
&nbsp; <span style="color: #808080; font-style: italic;"># To = ['user1@example.xxx','user2@example.xxx']</span><br />
&nbsp; To <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'travisaltman@gmail.com'</span><br />
&nbsp; Date <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">time</span>.<span style="color: black;">ctime</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; Subject <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'honeypot alert'</span><br />
&nbsp; username <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'someusername'</span><br />
&nbsp; password <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'somepassword'</span><br />
&nbsp; <span style="color: #808080; font-style: italic;"># IPSconnecting = open(output, 'r').read()</span><br />
&nbsp; Text <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;A device at &quot;</span> + sourceIP + <span style="color: #483d8b;">&quot; is port scanning our honeypot at &quot;</span> \<br />
&nbsp; + destinationIP + <span style="color: #483d8b;">&quot;. This honeypot is being emulated on device &quot;</span> \<br />
&nbsp; + hostname + <span style="color: #483d8b;">&quot;.&quot;</span><br />
&nbsp; Message <span style="color: #66cc66;">=</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'From: %s<span style="color: #000099; font-weight: bold;">\n</span>To: %s<span style="color: #000099; font-weight: bold;">\n</span>Date: %s<span style="color: #000099; font-weight: bold;">\n</span>Subject: %s<span style="color: #000099; font-weight: bold;">\n</span>%s<span style="color: #000099; font-weight: bold;">\n</span>'</span> % <span style="color: black;">&#40;</span>From<span style="color: #66cc66;">,</span> To<span style="color: #66cc66;">,</span> Date<span style="color: #66cc66;">,</span> Subject<span style="color: #66cc66;">,</span> Text<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; s <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">smtplib</span>.<span style="color: black;">SMTP</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'smtp.gmail.com'</span><span style="color: black;">&#41;</span><br />
&nbsp; s.<span style="color: black;">starttls</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; s.<span style="color: black;">login</span><span style="color: black;">&#40;</span>username<span style="color: #66cc66;">,</span>password<span style="color: black;">&#41;</span><br />
&nbsp; sendMail <span style="color: #66cc66;">=</span> s.<span style="color: black;">sendmail</span><span style="color: black;">&#40;</span>From<span style="color: #66cc66;">,</span> To<span style="color: #66cc66;">,</span> Message<span style="color: black;">&#41;</span><br />
&nbsp; s.<span style="color: black;">quit</span></div></td></tr></tbody></table></div>
<p>I&#8217;m not a developer and I always mangle my scripts together so this isn&#8217;t the prettiest code. I&#8217;ll give you a run down of what this script does, if you have any specific questions please feel free to leave a comment I generally respond to comments fairly quickly. Basically the script combs through /var/log/syslog looking for the string &#8220;Connection request&#8221;. I&#8217;ve also confirmed that this script works just as well combing through /var/log/messages, you&#8217;ll have to verify which log your Linux distro is dumping this information. To test the script to make sure it works I would first port scan your honeypot from another device then simply run the python script to see if you get no errors and hopefully you get an email in your inbox, just run the following command after you&#8217;ve port scanned your honeypot.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">python alert.py</div></div>
<p>This command should only run for maybe 10 seconds then return you to the command line. If you get any errors then you&#8217;ll have to trouble shoot the script, contact me if you need help with that. Just to give you an idea of what the email alert would look like I&#8217;ve got a screen shot of an alert I got sent to my gmail address below.</p>
<p><a href="http://travisaltman.com/wp-content/Gmail-honeypotAlert-travisaltman@gmail.png"><img class="aligncenter size-full wp-image-542" title="Gmail-honeypotAlert-travisaltman@gmail" src="http://travisaltman.com/wp-content/Gmail-honeypotAlert-travisaltman@gmail.png" alt="" width="469" height="142" /></a></p>
<p>Currently the script only looks for &#8220;Connection request&#8221; in the last five minutes of log files so you&#8217;ll need to combo that up with running the script every five minutes, this can be done with Linux&#8217;s <a href="http://ss64.com/bash/crontab.html" target="_blank">crontab</a>. <a href="http://en.wikipedia.org/wiki/Cron" target="_blank">Cron</a> can schedule programs to be run at certain frequencies. To set up alert.py to run every five minutes use the crontab command.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">crontab -e</div></div>
<p>This opens up a text file in the terminal where you enter a specific syntax to tell cron which program you want to run and how often. Enter the text below to tell cron to run alert.py every five minutes.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">*/5 * * * * /root/alert.py</div></div>
<p>Then use control+w to save your work and control+x to quit the text editor. So in the alert.py script the every five minutes comes from line 33 where 300 is seconds which equals five minutes so if you wanted to modify the time you could do it on that line. Another line in the script you may want to change is line 25, here you can add any IP&#8217;s that you want to ignore for whatever reason. You&#8217;ll definitely want to change line 55 that has the text of the email you&#8217;ll be receiving and customize that to your hearts content. Don&#8217;t forget to modify smtp server information and also remove or change the authentication piece as needed. Also in the screenshot you&#8217;ll notice that the device is &#8220;bt&#8221; which is short for backtrack. I implemented this feature because you may want to run honeyd on multiple devices throughout your network and you&#8217;ll want to know what device is sending you the email. The name of the device is determined in lines 17-20. You may have to modify that code because not all distros of Linux keep their hostname in that location and you may have to parse the text file that holds that hostname in a different manner. There&#8217;s more information that I could go into about the script but hopefully I&#8217;ve hit the major points if there&#8217;s something I missed or if you have any questions or feedback please leave comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/honeypot-honeyd-tutorial-part-5-email-alerts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Honeypot / honeyd tutorial part 3, static IP&#8217;s</title>
		<link>http://travisaltman.com/honeypot-honeyd-tutorial-part-3-static-ips/</link>
		<comments>http://travisaltman.com/honeypot-honeyd-tutorial-part-3-static-ips/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 20:25:29 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[honeypot]]></category>
		<category><![CDATA[network security]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=386</guid>
		<description><![CDATA[In the past two tutorials I&#8217;ve used DHCP to obtain IP&#8217;s for our honeypots running honeyd. Using dhcp is fine when testing honeyd and getting familiar with how honeyd works but a static IP may be more suitable for your environment. In my case I initially fooled around with honeyd via dhcp but when I [...]]]></description>
			<content:encoded><![CDATA[<p>In the past two tutorials I&#8217;ve used DHCP to obtain IP&#8217;s for our honeypots running honeyd. Using dhcp is fine when testing honeyd and getting familiar with how honeyd works but a static IP may be more suitable for your environment. In my case I initially fooled around with honeyd via dhcp but when I wanted to implement in a more production environment I realized that static IP&#8217;s are more stable and less maintenance. In order to ping our honeypot the router / switch has to know what IP and MAC address our honeypot has so it can update it&#8217;s information, going through dhcp does this automatically. I&#8217;ll touch on how to add the static IP configuration later but first let&#8217;s go over our layout. I&#8217;ll be using the same simple layout as in the first tutorial as seen below.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_171.png"><img class="aligncenter size-full wp-image-358" title="Selection_171" src="http://travisaltman.com/wp-content/Selection_171.png" alt="" width="557" height="431" /></a></p>
<p>There may need to be some clarification in that diagram. Backtrack is what is actually running honeyd, the address of 192.168.99.135 (labeled Honeyd) which is the honeypot honeyd created can be configured to emulate any operating system. Now for the honeyd config file.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">create default<br />
set default default tcp action block<br />
set default default udp action block<br />
set default default icmp action block<br />
<br />
create windows<br />
set windows personality &quot;Microsoft Windows XP Professional SP1&quot;<br />
set windows default tcp action reset<br />
add windows tcp port 135 open<br />
add windows tcp port 139 open<br />
add windows tcp port 445 open<br />
<br />
set windows ethernet &quot;00:00:24:ab:8c:12&quot;<br />
<br />
bind 192.168.99.135 windows</div></div>
<p>So the only real difference between dhcp and a static IP is the last line of the config. If you go back to the first tutorial you&#8217;ll notice the last line is the only difference as well. As a side I&#8217;ve used some configs that do not have the MAC address defined in their config but when I did not include the &#8220;set windows ethernet&#8221; line honeyd would complain and not start. So after you&#8217;ve set your config simply start honeyd.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">honeyd  -d  -f  honeyd.conf</div></div>
<p>After running honeyd you should get similar output to below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Honeyd V1.5c Copyright (c) 2002-2007 Niels Provos<br />
honeyd[27305]: started with -d -f honeyd.conf<br />
Warning: Impossible SI range in Class fingerprint &quot;IBM OS/400 V4R2M0&quot;<br />
Warning: Impossible SI range in Class fingerprint &quot;Microsoft Windows NT 4.0 SP3&quot;<br />
honeyd[27305]: listening promiscuously on eth0: (arp or ip proto 47 or (udp and src port 67 and dst port 68) or (ip )) and not ether src 00:00:24:ca:6b:08<br />
honeyd[27305]: Demoting process privileges to uid 65534, gid 65534</div></div>
<p>The difference in output between static and dynamic is that you&#8217;ll see the IP address your honeypot gets when using DHCP. With static IP configuration you&#8217;re not going to get that in your output because you already know the IP you&#8217;re using. So the output via DHCP will the lines below included.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">honeyd[1870]: [eth0] trying DHCP<br />
honeyd[1870]: Demoting process privileges to uid 65534, gid 65534<br />
honeyd[1870]: [eth0] got DHCP offer: 192.168.99.135</div></div>
<p>So now you&#8217;ve take care of properly setting up honeyd to use a static IP address but now you&#8217;ll have to configure the network to use your static IP. In my enterprise production environment I&#8217;ve configured this via the DHCP server. I went into the DHCP server and made a static reservation. I also had to configure the switch I plugged my computer into and tell what VLAN that port needed to be assigned to. If you&#8217;re trying to get this set up in your work production environment you may have to work with your network team that manages DHCP / DNS / routers &amp; switches. Networks may be managed differently so check with your local team on how you would get a static IP. Now if you&#8217;re doing this on a home network for testing then you probably have a wireless router such as Linksys. Inside all of these home wireless routers you can configure static IP&#8217;s. Each wireless router will have different steps for configuring static IP&#8217;s so refer to your manufacturers documentation on how to do that.</p>
<p>Next in this tutorial is what to run your honeypot / honeyd on? Laptop, desktop, server? These questions will be tackled in future articles.</p>
]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/honeypot-honeyd-tutorial-part-3-static-ips/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Honeypot / honeyd tutorial part 2, multiple honeypots</title>
		<link>http://travisaltman.com/honeypot-honeyd-tutorial-part-2-multiple-honeypots/</link>
		<comments>http://travisaltman.com/honeypot-honeyd-tutorial-part-2-multiple-honeypots/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 17:43:06 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[honeypot]]></category>
		<category><![CDATA[network security]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=371</guid>
		<description><![CDATA[Part one of this series was to mainly get honeyd up and running. Hopefully you also took away from part one that the configuration file, honeyd.conf, is the key to making things work smoothly and properly. Now that you&#8217;ve got honeyd up and running let&#8217;s tweak honeyd.conf so that we have multiple honeypots running on [...]]]></description>
			<content:encoded><![CDATA[<p>Part one of this series was to mainly get honeyd up and running. Hopefully you also took away from part one that the configuration file, honeyd.conf, is the key to making things work smoothly and properly. Now that you&#8217;ve got honeyd up and running let&#8217;s tweak honeyd.conf so that we have multiple honeypots running on one installation of honeyd. One honeypot is great but having three or four is even better. Part two is dedicated to showing you how to properly setup multiple honeypots in honeyd. In part one we only emulated a Windows device via the line below in honeyd.conf</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">set windows personality &quot;Microsoft Windows XP Professional SP1&quot;<br />
set windows default tcp action reset</div></div>
<p>The personality tries to emulate what device you are trying to pretend to be. There are plenty of other personalities we could choose from so when setting up multiple honeypots you may want to emulate other devices besides a standard Windows device. Maybe you&#8217;d like to emulate a Solaris box, PBX system, or if you are going to emulate a Windows device make it real juicy to an attacker by making it a Windows 98 device. You&#8217;ve got plenty of options when choosing a personality for your honeypot. Honeyd takes advantage of nmap and the way it fingerprints devices. The list of personalities is located in the nmap.prints file, you should be able to find this file by using the following command</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">locate nmap.prints</div></div>
<p>You can view this file using less, for me I issued the following command.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">less /usr/share/honeyd/nmap.prints</div></div>
<p>Nmap has a version of this file as well named &#8220;nmap-os-db&#8221;. The nmap.prints and the nmap-os-db may or may not match up depending on your versions of nmap and honeyd. My nmap-os-db is in the following location.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">/usr/share/nmap/nmap-os-db</div></div>
<p>Within nmap.prints anything that follows the word &#8220;Fingerprint&#8221; is available as a personality. As an example below the string &#8220;Avaya G3 PBX version 8.3&#8243; can be used as a personality in honeyd.conf</p>
<p><a href="http://travisaltman.com/wp-content/Selection_187.png"><img class="aligncenter size-full wp-image-372" title="Selection_187" src="http://travisaltman.com/wp-content/Selection_187.png" alt="" width="483" height="163" /></a></p>
<p>In my example I will emulate this Avaya PBX device and I will also emulate a Soalris device. So a diagram of my setup looks like the following.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_189.png"><img class="aligncenter size-full wp-image-380" title="Selection_189" src="http://travisaltman.com/wp-content/Selection_189.png" alt="" width="594" height="392" /></a></p>
<p>So now that I&#8217;ve decided to also emulate a Solaris and Avaya device I&#8217;ll need to add both of these do honeyd.conf. Basically all you&#8217;ll need to do is copy and paste from the Windows device you&#8217;ve already setup in honeyd.conf then make some minor modifications such as the personality. My honeyd.conf for all three of these honeypots is below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">create default<br />
set default default tcp action block<br />
set default default udp action block<br />
set default default icmp action block<br />
<br />
create windows<br />
set windows personality &quot;Microsoft Windows XP Professional SP1&quot;<br />
set windows default tcp action reset<br />
add windows tcp port 135 open<br />
add windows tcp port 139 open<br />
add windows tcp port 445 open<br />
<br />
create avaya<br />
set avaya personality &quot;Avaya G3 PBX version 8.3&quot;<br />
set avaya default tcp action reset<br />
add avaya tcp port 4445 open<br />
add avaya tcp port 5038 open<br />
<br />
create solaris<br />
set solaris personality &quot;Avaya G3 PBX version 8.3&quot;<br />
set solaris default tcp action reset<br />
add solaris tcp port 22 open<br />
add solaris tcp port 2049 open<br />
<br />
set windows ethernet &quot;00:00:24:ab:8c:12&quot;<br />
set avaya ethernet &quot;00:00:24:ab:8c:13&quot;<br />
set solaris ethernet &quot;00:00:24:ab:8c:14&quot;<br />
dhcp windows on eth1<br />
dhcp avaya on eth1<br />
dhcp solaris on eth1</div></div>
<p>After you&#8217;ve added this information to honeyd.conf go ahead and run honeyd with the options discussed in part one, you should see the following.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@bt:~# honeyd -d -f honeyd.conf<br />
Honeyd V1.5c Copyright (c) 2002-2007 Niels Provos<br />
honeyd[2697]: started with -d -f honeyd.conf<br />
Warning: Impossible SI range in Class fingerprint &quot;IBM OS/400 V4R2M0&quot;<br />
Warning: Impossible SI range in Class fingerprint &quot;Microsoft Windows NT 4.0 SP3&quot;<br />
honeyd[2697]: listening promiscuously on eth1: (arp or ip proto 47 or (udp and src port 67 and dst port 68) or (ip )) and not ether src 00:0c:29:88:e6:db<br />
honeyd[2697]: [eth1] trying DHCP<br />
honeyd[2697]: [eth1] trying DHCP<br />
honeyd[2697]: [eth1] trying DHCP<br />
honeyd[2697]: Demoting process privileges to uid 65534, gid 65534<br />
honeyd[2697]: [eth1] got DHCP offer: 192.168.99.159<br />
honeyd[2697]: Updating ARP binding: 00:00:24:c5:59:29 -&amp;gt; 192.168.99.159<br />
honeyd[2697]: [eth1] got DHCP offer: 192.168.99.160<br />
honeyd[2697]: Updating ARP binding: 00:00:24:02:ac:73 -&amp;gt; 192.168.99.160<br />
honeyd[2697]: [eth1] got DHCP offer: 192.168.99.161<br />
honeyd[2697]: Updating ARP binding: 00:00:24:68:0c:45 -&amp;gt; 192.168.99.161<br />
honeyd[2697]: arp reply 192.168.99.159 is-at 00:00:24:c5:59:29<br />
honeyd[2697]: arp reply 192.168.99.160 is-at 00:00:24:02:ac:73<br />
honeyd[2697]: arp reply 192.168.99.161 is-at 00:00:24:68:0c:45<br />
honeyd[2697]: Sending ICMP Echo Reply: 192.168.99.159 -&amp;gt; 192.168.99.254<br />
honeyd[2697]: arp_send: who-has 192.168.99.254 tell 192.168.99.159<br />
honeyd[2697]: Sending ICMP Echo Reply: 192.168.99.160 -&amp;gt; 192.168.99.254<br />
honeyd[2697]: Sending ICMP Echo Reply: 192.168.99.161 -&amp;gt; 192.168.99.254<br />
honeyd[2697]: arp_recv_cb: 192.168.99.254 at 00:50:56:ec:10:84</div></div>
<p>If everything has gone smooth up to this point you&#8217;ve gotten output similar to above. So currently we&#8217;ve got three honeypots running on one installation of honeyd. Now the proof is in the pudding by port scanning these devices and see if the ports are open and what OS nmap claims it to be. DHCP gave our Avaya device an IP address of 192.168.99.160, let&#8217;s port scan for the two open ports and a port we know to be closed and see what results we get.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">travis@tht:~/documents$ nmap -p 4445,5038,5555 192.168.99.160<br />
<br />
Starting Nmap 5.00 ( http://nmap.org ) at 2011-06-15 01:25 EDT<br />
Interesting ports on 192.168.99.160:<br />
PORT     STATE  SERVICE<br />
4445/tcp open   unknown<br />
5038/tcp open   unknown<br />
5555/tcp closed freeciv<br />
<br />
Nmap done: 1 IP address (1 host up) scanned in 1.18 seconds</div></div>
<p>Looks like everything is on the up and up with our Avaya device. Port 5555 is closed because we did not define it in honeyd.conf. I&#8217;ll spare you with the nmap scan of the Solaris device but everything was operating as normal for it as well. So the ports are open but how well is this personality thing working? Nmap can try and determine the OS of a device through a number of TCP exchanges. Honeyd tries to use the nmap fingerprint database to send the appropriate TCP responses to a nmap scan so that the personality you&#8217;ve assigned to your template will respond as it should. This doesn&#8217;t always work properly. New versions of nmap are constantly coming out which means the nmap fingerprint database is changing as well. So nmap may respond properly or it may not, this will just depend on the version of nmap you or an attacker is scanning with. It will also depend on the nmap.prints that honeyd uses as well. You can perform an OS detection in nmap by providing it the -O option, let&#8217;s try scanning our Solaris device and see what it returns.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_188.png"><img class="aligncenter size-full wp-image-376" title="Selection_188" src="http://travisaltman.com/wp-content/Selection_188.png" alt="" width="442" height="307" /></a></p>
<p>Seeing how this might happen you don&#8217;t want to totally rely on the personality in honeyd. The best idea is to open up ports that are common to a particular device. For instance most Linux and Solaris devices have port 22 open while routers and switches will probably have port 161 open (SNMP). The configuration is totally up to you but trying to make your honeypot as sweet as possible is the main goal.</p>
<p>So adding multiple honeypots to your honeyd install is fairly straightforward but there are some things to consider when setting it up. Other topics such as email alerts are coming but for now make sure you can get multiple honeypots running via honyed.</p>
]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/honeypot-honeyd-tutorial-part-2-multiple-honeypots/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Honeypot / honeyd tutorial part 1, getting started</title>
		<link>http://travisaltman.com/honeypot-honeyd-tutorial-part-1-getting-started/</link>
		<comments>http://travisaltman.com/honeypot-honeyd-tutorial-part-1-getting-started/#comments</comments>
		<pubDate>Fri, 06 May 2011 17:27:06 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[honeypot]]></category>
		<category><![CDATA[network security]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=353</guid>
		<description><![CDATA[If you&#8217;ve somehow found my obscure site then you probably already know a little bit about honeypots and their functionality, if not here is a good breakdown. There are many different types of honeypots and these different types are explained very well in the book Virtual Honeypots which I highly recommend you read if you [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve somehow found my obscure site then you probably already know a little bit about honeypots and their functionality, if not <a href="http://www.honeypots.net/">here is a good breakdown</a>. There are many different types of honeypots and these different types are explained very well in the book <a href="http://www.amazon.com/Virtual-Honeypots-Tracking-Intrusion-Detection/dp/0321336321" target="_blank">Virtual Honeypots</a> which I highly recommend you read if you are serious about deploying a honeypot. This series of articles will focus on honeypots using an application called <a href="http://www.honeyd.org/" target="_blank">honeyd</a>. There are a number of honeypot solutions out there but I personally feel like honeyd is a great fit because it can be relatively simple or you can start tweaking it to get a more full featured product. You may think of honeypots as internet facing and it&#8217;s true that they can be configured that way but during this series of tutorials I will only be using honeyd on an internal network. Internet facing honeypots are mainly used to research and find new malware, internal honeypots are mainly used as alerting systems that would alert you when other devices / users are connecting to your honeypots. You can also use honeyd when investigating malware which I&#8217;ll discuss in a later tutorial.</p>
<p>For this tutorial I will be using one Windows machine and one Linux machine, <a href="http://www.backtrack-linux.org/" target="_blank">Backtrack </a>distribution to be exact. Backtrack will be the machine that is running honeyd. Honeyd is available for Windows but I highly recommend that you use honeyd on Linux. If you&#8217;re half way interested in information security then I suggest that you get to know Linux as there are a lot of information security tools such as honeyd that use Linux. Sorry for the Linux rant, below is basic diagram of my setup.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_171.png"><img class="aligncenter size-full wp-image-358" title="Selection_171" src="http://travisaltman.com/wp-content/Selection_171.png" alt="" width="557" height="431" /></a></p>
<p>The idea here is that we&#8217;ll install and configure honeyd on Backtrack then simply test that we have connectivity with our Windows machine. To see if you have honeyd installed on Backtrack (or any Linux system) simply type &#8220;honey + TAB&#8221;, if &#8220;d&#8221; is shown right after honey then you know you have honeyd installed as it is an available command if you don&#8217;t have honeyd installed on Backtrack run the following command</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sudo apt-get install honeyd</div></div>
<p>This will also work for any Debian based Linux system. To install on other distributions such as Gentoo, Fedora, Slackware, etc I would check their documentation on how to install packages. After honeyd is installed the next thing we&#8217;ll need to do is create a configuration file. A honeyd configuration file is the heart of your honeypot. The configuration file tells honeyd what operating system to emulate, what ports to open, what services should be ran, etc. This config file can be tweaked to emulate all sorts setups but for right now let&#8217;s look at a simple setup and get that up and running. Below is my config file.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">create default<br />
set default default tcp action block<br />
set default default udp action block<br />
set default default icmp action block<br />
<br />
create windows<br />
set windows personality &quot;Microsoft Windows XP Professional SP1&quot;<br />
set windows default tcp action reset<br />
add windows tcp port 135 open<br />
add windows tcp port 139 open<br />
add windows tcp port 445 open<br />
<br />
set windows ethernet &quot;00:00:24:ab:8c:12&quot;<br />
dhcp windows on eth0</div></div>
<p>Within Backtrack you can use Kate or nano text editors to create this file. In Backtrack Kate is under the Utilities menu. The &#8220;create default&#8221; section simply tells honeyd to drop traffic unless it is defined later in the configuration file. I find this section is needed when you let your honeypot acquire an IP address via dhcp. Also it&#8217;s probably a good idea to implement this section so that you only answer to network connections that you define later in the config file. Anytime you see &#8220;create&#8221; within the config file you are creating a template for a honeypot, so you can create as many honeypots as you&#8217;d like within the honed.conf config. In the windows template we are defining a number of things. First we are setting the personality, meaning when another device on the network connects to this honeypot it will appear to be a Windows XP Pro SP1 device. This is emulated via network stack fingerprints. In the windows template I&#8217;m also opening up three ports (135, 139, and 445). These are common ports that are open on a windows system. The &#8220;action reset&#8221; statement will drop traffic if it is not aimed at the open ports defined in this config. The &#8220;set windows ethernet&#8221; sets a MAC address for our honeypot.  This will be needed if you run your honeypot via dhcp. You can simply make up any MAC address you&#8217;d like, I usually keep it close to the physical MAC address that I&#8217;m running the honeypot off of. Finally the dhcp statement tells the windows template to acquire an IP address from dhcp. Now that we have our honeyd.conf file properly setup it&#8217;s time to launch honeyd, below is the command I use when initially getting honeyd up and running.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">honeyd  -d  -f  honeyd.conf</div></div>
<p>Here we use the -d so that it doesn&#8217;t run in the background (or doesn&#8217;t run as a daemon in Linux terms). This allow for more verbose output so that we can troubleshoot as needed. Running in this mode will also show the IP that was given to our honeypot via dhcp. Below is the type of output you should see after running the honeyd command.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Honeyd V1.5c Copyright (c) 2002-2007 Niels Provos<br />
honeyd[1870]: started with -d -f honeyd.conf<br />
Warning: Impossible SI range in Class fingerprint &quot;IBM OS/400 V4R2M0&quot;<br />
Warning: Impossible SI range in Class fingerprint &quot;Microsoft Windows NT 4.0 SP3&quot;<br />
honeyd[1870]: listening promiscuously on eth0: (arp or ip proto 47 or (udp and src ...<br />
honeyd[1870]: [eth0] trying DHCP<br />
honeyd[1870]: Demoting process privileges to uid 65534, gid 65534<br />
honeyd[1870]: [eth0] got DHCP offer: 192.168.99.135<br />
honeyd[1870]: Updating ARP binding: 00:00:24:c8:e3:34 -&amp;gt; 192.168.99.135</div></div>
<p>In this verbose output we see that dhcp gave our honeypot the address of 192.168.99.135. From our windows machine let&#8217;s ping that IP address and make sure that we have connectivity. You should see output on the terminal similar to below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">honeyd[1870]: arp reply 192.168.99.135 is-at 00:00:24:c8:e3:34<br />
honeyd[1870]: Sending ICMP Echo Reply: 192.168.99.135 -&amp;gt; 192.168.99.128<br />
honeyd[1870]: arp_send: who-has 192.168.99.128 tell 192.168.99.135<br />
honeyd[1870]: arp_recv_cb: 192.168.99.128 at 00:0c:29:7e:60:d0<br />
honeyd[1870]: Sending ICMP Echo Reply: 192.168.99.135 -&amp;gt; 192.168.99.128<br />
honeyd[1870]: Sending ICMP Echo Reply: 192.168.99.135 -&amp;gt; 192.168.99.128<br />
honeyd[1870]: Sending ICMP Echo Reply: 192.168.99.135 -&amp;gt; 192.168.99.128</div></div>
<p>So congrats you&#8217;ve successfully deployed honeyd. We can now ping our honeypot but we need to make sure the ports we&#8217;ve configured to be open are open. Let&#8217;s us the cadillac of port scanners <a href="http://nmap.org/" target="_blank">nmap</a> to detect open ports on our honeypot. You can scan for all 65,535 ports on our honeypot but to keep the verbose output of honeyd low let&#8217;s just scan for a handful of ports. Below is the nmap command I used.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nmap -p 135,139,445,1337 192.168.99.135</div></div>
<p>The output of this command should look similar to below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Starting Nmap 5.00 ( http://nmap.org ) at 2011-05-06 13:13 EDT<br />
Interesting ports on someone (172.20.73.77):<br />
PORT     STATE  SERVICE<br />
135/tcp  open   msrpc<br />
139/tcp  open   netbios-ssn<br />
445/tcp  open   microsoft-ds<br />
1337/tcp closed waste<br />
MAC Address: 00:00:24:26:C4:ED (Connect AS)<br />
<br />
Nmap done: 1 IP address (1 host up) scanned in 0.37 seconds</div></div>
<p>So honeyd appears to be working correctly. If you&#8217;ve reached this point then you are on your way to doing even more with honeypots and honeyd. The main purpose of this article was to get you up and running. In the next series of articles we&#8217;ll configure more honeypots, set static IP&#8217;s, get alerts on devices port scanning our honeypots, investigate malware, etc. If you have any questions, catch errors, or have any feedback please comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/honeypot-honeyd-tutorial-part-1-getting-started/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>ARP spoofing 101: Trust your LAN?</title>
		<link>http://travisaltman.com/arp-spoofing-101-do-you-trust-your-lan/</link>
		<comments>http://travisaltman.com/arp-spoofing-101-do-you-trust-your-lan/#comments</comments>
		<pubDate>Wed, 18 Jul 2007 14:32:59 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[network security]]></category>
		<category><![CDATA[privacy]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=10</guid>
		<description><![CDATA[At home you&#8217;re fully aware of the hosts/people that are on your network, or at least you should be. Friends and family are usually trustworthy people and you don&#8217;t have to worry about them carrying out malicious activity, but what if you aren&#8217;t sharing the LAN (Local Area Network) with people you can trust? This [...]]]></description>
			<content:encoded><![CDATA[<p>At home you&#8217;re fully aware of the hosts/people that are on your network, or at least you should be. Friends and family are usually trustworthy people and you don&#8217;t have to worry about them carrying out malicious activity, but what if you aren&#8217;t sharing the LAN (Local Area Network) with people you can trust? This article will explain why untrusted LAN&#8217;s can be dangerous and what users/admins can do to protect themselves.</p>
<p><span id="more-10"></span></p>
<p>If a malicious user is on the same network as you there are numerous types of attacks they could carry out to compromise your computer and identity. One common attack they might use is called ARP (Address Resolution Protocol) spoofing. Before we get into the details of ARP spoofing it&#8217;s helpful to understand how this protocol came about.</p>
<p>The early developers of Ethernet or LAN technology designed the system based upon trust, meaning they never thought anyone using this technology would use it in a malicious way. About thirty years ago, the early stages of Ethernet development, it was hard to imagine a large scale LAN. Hardware was very expensive in those days and only large organizations could afford such technology, even then these large organizations only had a small number of computers that could communicate with one another. So it was hard to imagine that they would ever communicate with someone they didn&#8217;t trust. Problem is that Ethernet exists on Layer 2 using a flat addressing scheme (e.g. MAC address). This type of addressing doesn&#8217;t scale well for the internet, which uses a hierarchical addressing scheme (e.g. IP). The solution to this problem was ARP.</p>
<p>ARP is used for mapping IP addresses to MAC addresses. A basic diagram for ARP can be seen in figure 1 below.</p>
<p><a title="ARP protocol diagram" href="http://travisaltman.com/wp-content/arpspofingdiagram.JPG"><img src="http://travisaltman.com/wp-content/arpspofingdiagram.JPG" alt="ARP protocol diagram" /></a></p>
<p>Figure 1: ARP protocol diagram</p>
<p>So A wants to communicate with B:</p>
<ol>
<li>A checks its local ARP table for B&#8217;s info</li>
<li>A doesn&#8217;t have B&#8217;s info so its sends a request</li>
<li>Router closet to B adds A&#8217;s info to ARP table</li>
<li>Router sends B&#8217;s info to A so it can update its ARP table</li>
<li>ARP info updated, A &amp; B can now communicate</li>
</ol>
<p>This ARP thing seems to work out nicely, so what&#8217;s the problem? In an untrusted environment how does A know that B is who he says he is? Turns out that the ARP protocol has a slew of vulnerabilities.</p>
<p>Vulnerabilities of ARP:</p>
<ul>
<li>No authentication! (you cannot be assured who you are talking to)</li>
<li>ARP tables can be manipulated by anyone on the LAN</li>
<li>Allows malicious users to pretend to be someone else (the SPOOF)</li>
<li>Perfect protocol for launching Man in the Middle Attacks (MITM)</li>
</ul>
<p>Once a malicious user is on your LAN they can easily manipulate ARP tables, spoof who you are trying to communicate with, and launch a MITM attack. A MITM attack allows the attacker to sniff all your traffic and pick up sensitive information (e.g. username, passwords). A diagram of a MITM attack can be seen in figure 2.</p>
<p><a title="Man in the middle diagram" href="http://travisaltman.com/wp-content/maninthemiddle.JPG"><img src="http://travisaltman.com/wp-content/maninthemiddle.JPG" alt="Man in the middle diagram" /></a></p>
<p>Figure 2: Man in the middle diagram</p>
<p>Anytime you are on an untrusted LAN (e.g. Hotel, Public WiFi, University, any large organization) there is the possibility that someone could be listening in on your communications via ARP spoofing. There are plenty of tools available that would allow even the most novice attacker to gain your personal information. So if you are going to communicate on an untrusted LAN here are some tips to stay secure.</p>
<ul>
<li>Use encryption (e.g. SSL, SSH, or VPN)</li>
<li>If unencrypted, don&#8217;t communicate private information</li>
<li>Only visit trusted websites (easier said than done)</li>
</ul>
<p>For system administrators there are two countermeasures against ARP spoofing.</p>
<ol>
<li>Static ARP tables (difficult to maintain)</li>
<li>Arpwatch (will notify if someone is ARP spoofing)</li>
</ol>
<p>The point of this article is to educate others about how protocols behind the scenes work and how insecure they can be. If you can&#8217;t trust everyone on your current LAN, then use encryption and stay away from communicating sensitive information. Now you know, and knowing is half the battle.  As always feel free to leave comments if you find any errors within this article.</p>
<p>References:</p>
<p>http://www.grc.com/nat/arp.htm, http://en.wikipedia.org/wiki/ARP_spoofing</p>
]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/arp-spoofing-101-do-you-trust-your-lan/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

