CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/encoders/x86/xor_dynamic.rb
Views: 11779
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Encoder::XorDynamic
7
8
def initialize
9
super(
10
'Name' => 'Dynamic key XOR Encoder',
11
'Description' => 'An x86 XOR encoder with dynamic key size',
12
'Author' => [ 'lupman', 'phra' ],
13
'Arch' => ARCH_X86,
14
'License' => MSF_LICENSE
15
)
16
end
17
18
# Indicate that this module can preserve some registers
19
# ...which is currently not true. This is a temp fix
20
# until the full preserve_registers functionality is
21
# implemented.
22
def can_preserve_registers?
23
true
24
end
25
26
def stub
27
"\xeb\x23" + # jmp _call
28
"\x5b" + # _ret: pop ebx
29
"\x89\xdf" + # mov edi, ebx
30
"\xb0\x41" + # mov al, 'A'
31
"\xfc" + # cld
32
"\xae" + # _lp1: scas al, BYTE PTR es:[edi]
33
"\x75\xfd" + # jne _lp1
34
"\x89\xf9" + # mov ecx, edi
35
"\x89\xde" + # _lp2: mov esi, ebx
36
"\x8a\x06" + # _lp3: mov al, BYTE PTR [esi]
37
"\x30\x07" + # xor BYTE PTR [edi], al
38
"\x47" + # inc edi
39
"\x66\x81\x3f\x42\x42" + # cmp WORD PTR [edi], 'BB'
40
"\x74\x08" + # je _jmp
41
"\x46" + # inc esi
42
"\x80\x3e\x41" + # cmp BYTE PTR [esi], 'A'
43
"\x75\xee" + # jne _lp3
44
"\xeb\xea" + # jmp _lp2
45
"\xff\xe1" + # _jmp: jmp ecx
46
"\xe8\xd8\xff\xff\xff" # _call: call _ret
47
end
48
49
def stub_key_term
50
/A/
51
end
52
53
def stub_payload_term
54
/BB/
55
end
56
end
57
58