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/spec/tools/egghunter_spec.rb
Views: 11766
load Metasploit::Framework.root.join('tools/exploit/egghunter.rb').to_path1require 'spec_helper'23RSpec.describe Egghunter do45describe Egghunter::Driver do67subject do8Egghunter::Driver.new9end1011let(:egg) {12'W00T'13}1415describe '#run' do1617let(:default_opts) {18{ :platform => 'windows', :format => 'c', :eggtag => egg, :arch => 'x86' }19}2021before(:example) do22allow(Egghunter::OptsConsole).to receive(:parse).with(any_args).and_return(options)23end2425context 'when the platform is windows' do26let(:options) { default_opts }2728it 'returns a windows egghunter' do29output = get_stdout { subject.run }30expect(output).to include("\\x66\\x81\\xca\\xff")31end32end3334context 'when the platform is linux' do35let(:options) do36{ :platform => 'linux', :format => 'c', :eggtag => egg, :arch => 'x86' }37end3839it 'returns a linux egghunter' do40output = get_stdout { subject.run }41expect(output).to include("\\xfc\\x66\\x81\\xc9\\xff")42end43end4445context 'when the egg is WOOT' do46let(:options) { default_opts }4748it 'includes W00T in the egghunter' do49output = get_stdout { subject.run }50expect(output).to include("\\x57\\x30\\x30\\x54")51end52end53end54end555657describe Egghunter::OptsConsole do58subject do59Egghunter::OptsConsole60end6162context 'when no options are given' do63it 'raises OptionParser::MissingArgument' do64expect{subject.parse([])}.to raise_error(OptionParser::MissingArgument)65end66end6768context 'when no format is specified and --list-formats isn\'t used' do69it 'raises OptionParser::MissingArgument' do70args = '-e AAAA'.split71expect{subject.parse(args)}.to raise_error(OptionParser::MissingArgument)72end73end7475context 'when no egg is specified and --list-formats isn\'t used' do76it 'raises OptionParser::MissingArgument' do77args = '-f python'.split78expect{subject.parse(args)}.to raise_error(OptionParser::MissingArgument)79end80end8182context 'when :depsize is a string' do83it 'raises OptionParser::InvalidOption' do84args = '-e AAAA -f c --depsize STRING'.split85expect{subject.parse(args)}.to raise_error(OptionParser::InvalidOption)86end87end88end8990end919293