Creating a BITM Framework with NoVNC and Chrome DevTools Protocol
Creating a BITM Framework using NoVNC and Chrome DevTools Protocol to bypass MFA controls.
Preliminary
Phishing against organisations has been an increasingly difficult objective, especially when you are on a limited timeframe. More often than not, as time has progressed, red teams are continuously finding themselves having to resort to assumed breach scenarios where they are supplied VDI or laptop access to continue.
Browser in the Middle has been around for quite a few years now. First introduced by mrd0x, he demonstrated the ability to bypass controls such as MFA by using TigerVNC, with the ultimate goal to extract cookies or tokens to replay. Further research and tool development has been done off the back of this. I'll link a few blog posts below for those interested:
- https://mrd0x.com/bypass-2fa-using-novnc/
- https://fhlipzero.io/blogs/6_noVNC/noVNC.html
- https://cloud.google.com/blog/topics/threat-intelligence/session-stealing-browser-in-the-middle
- https://docs.specterops.io/cuddlephish-docs/overview
NoVNC
Both mrd0x, fhlipzero, and fkaiser have detailed the infrastructure and general implementation required for this technique, which I largely copied. I used the ubuntu-vnc-xfce-firefox-g3 docker container made by accetto which fhlipzero also used.
There are numerous changes which needed to be made. Fhlipzero details some of these in his blog, but I made two larger changes ontop of this:
- Replaced Firefox with Chrome for Chrome DevTool Protocol (CDP) support
- Replaced XFCE with OpenBox for a lighter desktop environment.
Unfortunately there were a few downsides to this. OpenBox has some rendering issues I haven't solved yet, and the docker image increased quite a bit in size (going from 987MB to 3G.
After some time debugging, I settled with the following command to display the login page:
env DISPLAY=:1 google-chrome --no-sandbox --disable-dev-shm-usage --remote-debugging-address=127.0.0.1 --remote-debugging-port=9222 --remote-allow-origins=* --disable-dev-shm-usage --user-data-dir=/tmp/chrome --kiosk https://login.microsoftonline.com &
This enables remote debugging for CDP, kiosk mode to provide that browser tab look and prevent (some) potential breakouts, and other leftover debug commands I needed to provide to prevent crashes.
Chrome DevTools Protocol
CDP is already used for malicious purposes, most commonly to extract cookies once you have already achieved access to a laptop or server. Branching it out into the BITM technique also isn't new, with fkaiser's cuddlephish already using it to extract session cookies instead of relying on firefox profiles. It's a very powerful technique, and not only limited to just sessions.
This example is aimed at Microsoft 365, which is a common gateway due to the incredible value the graphAPI and other microsoft endpoints can provide. Given that our main objective is obtaining session tokens for this service, we first need to understand which tokens are valuable.
Thankfully, Microsoft and it's tendency for great documentation saves the day. They specify ESTSAUTH and ESTSAUTHPERSISTENT containing user session information for SSO. From this, we can use the Session.getCookies command for CDP to extract all cookies, and create regex to only show these interesting results.
Once the cookies are obtained, it's an easy method of simply replaying them in another browser to (hopefully) retrieve the session. We can go one step further with CDP though. It also allows for the passive listening of all network communication going in and out of the chrome session via the Network.requestWillBeSent command, which allows us to sniff POST requests until the primary login request is sent. Once it is, we can extract both the loginfmt and passwd POST variables, which contain the email and password for the user.
A few LLM prompts later for a suitable python script which does the desired, and I proceed to login via the noVNC browser page. Enter my entra details, verify MFA and... get the following results:
[POST] {'loginfmt': 'username@usertenant.onmicrosoft.com', 'passwd': 'thisisafakepassword'}
[COOKIE] {'name': 'ESTSAUTHPERSISTENT', 'value': '1.AUE'}
Pretty cool results! It was also surpringly easy to setup this base docker image, only taking a day or two of effort. Providing dedicated apache/nginx proxying and all that jazz would most likely be the bulk of effort, especially if there was to be a dedicated management interface to control and collate all this information.