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/nops/ppc/simple.rb
Views: 11778
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
###
7
#
8
# SingleByte
9
# ----------
10
#
11
# This class implements simple NOP generator for PowerPC
12
#
13
###
14
class MetasploitModule < Msf::Nop
15
16
17
def initialize
18
super(
19
'Name' => 'Simple',
20
'Alias' => 'ppc_simple',
21
'Description' => 'Simple NOP generator',
22
'Author' => 'hdm',
23
'License' => MSF_LICENSE,
24
'Arch' => ARCH_PPC)
25
26
register_advanced_options(
27
[
28
OptBool.new('RandomNops', [ false, "Generate a random NOP sled", true ])
29
])
30
end
31
32
33
def generate_sled(length, opts)
34
35
badchars = opts['BadChars'] || ''
36
random = opts['Random'] || datastore['RandomNops']
37
38
if random
39
1.upto(1024) do |i|
40
regs_d = (rand(0x8000 - 0x0800) + 0x0800).to_i
41
regs_b = [regs_d].pack('n').unpack('B*')[0][1, 15]
42
flag_o = rand(2).to_i
43
flag_r = rand(2).to_i
44
45
pcword = ["011111#{regs_b}#{flag_o}100001010#{flag_r}"].pack("B*")
46
failed = false
47
48
pcword.each_byte do |c|
49
failed = true if badchars.include?(c.chr)
50
end
51
52
next if failed
53
54
return (pcword * (length / 4))[0, length]
55
end
56
end
57
58
return ("\x60" * length)[0, length]
59
end
60
end
61
62