Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/nops/mipsbe/better.rb
Views: 11780
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45###6#7# MixedNop8# ----------9#10# This class implements a mixed NOP generator for MIPS (big endian)11#12###13class MetasploitModule < Msf::Nop1415def initialize16super(17'Name' => 'Better',18'Alias' => 'mipsbe_better',19'Description' => 'Better NOP generator',20'Author' => 'jm',21'License' => MSF_LICENSE,22'Arch' => ARCH_MIPSBE)2324register_advanced_options(25[26OptBool.new('RandomNops', [ false, "Generate a random NOP sled", true ])27])28end2930def get_register()31return rand(27) + 132end3334def make_bne(reg)35op = 0x140000003637reg = get_register()38offset = rand(65536)3940op = op | ( reg << 21 ) | ( reg << 16 ) | offset41return op42end4344def make_or(reg)45op = 0x000000254647op = op | ( reg << 21 ) | ( reg << 11 )48return op49end5051def make_sll(reg)52op = 0x000000005354op = op | ( reg << 16 ) | ( reg << 11 )55return op56end5758def make_sra(reg)59op = 0x000000036061op = op | ( reg << 16 ) | ( reg << 11 )62return op63end6465def make_srl(reg)66op = 0x000000026768op = op | ( reg << 16 ) | ( reg << 11 )69return op70end7172def make_xori(reg)73op = 0x380000007475op = op | ( reg << 21 ) | ( reg << 16 )76return op77end7879def make_ori(reg)80op = 0x340000008182op = op | ( reg << 21 ) | ( reg << 16 )83return op84end8586def generate_sled(length, opts)8788badchars = opts['BadChars'] || ''89random = opts['Random'] || datastore['RandomNops']90nop_fn = [ :make_bne, :make_or, :make_sll, :make_sra, :make_srl, :make_xori, :make_ori ]91sled = ''9293for i in 1..length/4 do94n = nop_fn.sample95sled << [send(n, get_register())].pack("N*")96end9798return sled99end100end101102103104