Phishing 101 with Modlishka

Very recently I got a chance to get my hands dirty on Modlishka, thanks to some awesome people at my workplace 🀘

For those who aren’t aware Modlishka is a powerful and flexible HTTP reverse proxy that has a universal 2FA β€œbypass” support.

It allows to transparently proxy multi-domain destination traffic, both TLS & non-TLS, over a single domain, without a requirement of installing any additional certificate on the client. Enough of technical jargons …

Requirements

β€” β€” β€” β€” β€” β€” β€” β€”

I needed to setup a fake Outlook Web App login page…

With time I realized that the Modlishka default templates are little bit outdated and it took me some time and effort to get it up & working again so I decided to blog about it :)

Setup

β€” β€” β€” β€”

  1. We will create a new Digital Ocean droplet.

2. After we ssh in, we will install certbot and download the Modlishka standalone binary as well as the default config file

Generating wild-card SSL certificates

β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€”

Suppose that we own the domain redacted.com and we wish generate a wild card SSL certificate that allow us to secure multiple sub domain names (hosts) pertaining to the same base domain. For that we will use https://letsencrypt.org/

This will generate a challenge code as shown below:

Adding DNS records

β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€”

In total we need to create three DNS records:

  • A record for the root host @ that will point to the droplet IP
  • CNAME record for any subdomain * pointing to @
  • TXT record for redacted.com according to the challenge code shown above

Fixing certificate formats

β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€”

Once the TXT record is set and verified, the certificate and the private key will be generated. However Modlishka wants them in a different format so let’s convert it accordingly:

Open office365.json and copy the result of the awk’d command from fullchain.pem into cert parameter and privkey.pem into certKey parameter.

Fixing the configuration

β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€” β€”

The Modlishka Office365 template in Github doesn’t parse the username and password by itself and needs some tweaking πŸ€”

We see that owa based authentication does a POST request at the owa/auth.owa endpoint.

In order to grab the credentials so we need to adjust Modlishka’s credParams configuration using regex that can be verified from https://regex101.com/

Now we will add these base64 encoded values inside credParams separated by a comma.

Full configuration without the certificate and key:

Pwnage

β€” β€” β€” β€” β€”

Let’s get the modlishka up and running…

Finally after the victim has logged in using our Modlishka proxy page we can find the stolen credentials not only via logs but also via the /SayHello2Modlishka endpoint.

Now we can use their credentials directly to log into our target domain or use their cookies and feed them to a cookie editor and refresh the page to get logged in automatically.

Disclaimer

β€” β€” β€” β€” β€” β€” β€”

This demo is only for demonstration and education purposes. Do not use these instructions to anything illegal.

--

--

CTF 🚩 ● Hack the Box ● CyberSec Enthusiast ● Snooker Addict

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Soumyadeep Basu

CTF 🚩 ● Hack the Box ● CyberSec Enthusiast ● Snooker Addict