Skip to content

Commit b068997

Browse files
committed
Fix to_bytes
1 parent ed0720d commit b068997

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

modules/exploits/linux/http/empire_skywalker.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def exploit
270270
# len(bin(self.sharedSecret)) - 2 // 8 + 1, byteorder="big"
271271
# )
272272
# 2(0b) + 1(- 2 // 8 + 1) = 3
273-
_sharedSecret = to_bytes(sharedSecret, sharedSecret.to_s(2).length + 3, byteorder="big")
273+
_sharedSecret = to_bytes(sharedSecret, sharedSecret.to_s(2).length + 3, little_endian=false)
274274
sha = OpenSSL::Digest.new('sha256')
275275
sha.update(_sharedSecret)
276276
session_key = sha.digest
@@ -405,12 +405,9 @@ def build_response_packet(tasking_id, packet_data)
405405
packetType + totalPacket + packetNum + result_id + length + packet_data
406406
end
407407

408-
def to_bytes(n, length=1, byteorder='big', signed=false)
409-
raise ArgumentError, "byteorder must be either 'little' or 'big'" unless ['little', 'big'].include?(byteorder)
410-
411-
order = (byteorder == 'little') ? (0...length) : (0...length).to_a.reverse
412-
413-
bytes_array = order.map { |i| (n >> i*8) & 0xff }
408+
def to_bytes(n, length=1, little_endian=false)
409+
order = little_endian ? (0...length) : (0...length).to_a.reverse
410+
bytes_array = order.map { |i| (n >> i * 8) & 0xff }
414411
bytes_array.pack('C*')
415412
end
416413

0 commit comments

Comments
 (0)