Sha256: 991b3e015e19ec8583a17d1ac48a09bbfe6bede98a7ca0c5e2b720c85c2aaa68

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'
require 'ronin/exploits/mixins/format_string'

require 'ronin/exploits/exploit'
require 'ronin/exploits/metadata/arch'
require 'ronin/exploits/metadata/os'

describe Ronin::Exploits::Mixins::FormatString do
  module TestFormatString
    class TestExploit < Ronin::Exploits::Exploit
      include Ronin::Exploits::Metadata::Arch
      include Ronin::Exploits::Metadata::OS
      include Ronin::Exploits::Mixins::FormatString

      arch :x86
      os :linux
    end
  end

  let(:exploit_class) { TestFormatString::TestExploit }
  subject { exploit_class.new }

  describe "#build_format_string" do
    let(:pop_length) { 256        }
    let(:overwrite)  { 0xffffaaaa }
    let(:address)    { 0xffffbbbb }
    let(:payload)    { "shellcode here".b }

    it "must create a '%.DDDd%DDD$hn%.DDDd%DDD$hn' format string using the pop_length, overwrite, address, and payload" do
      format_string = subject.build_format_string(
        overwrite:  overwrite,
        pop_length: pop_length,
        address:    address,
        payload:    payload
      )

      expect(format_string).to eq(
        [overwrite, overwrite+2].pack('L<2') +
        "%.16759731d%256$hn%.1056965709d%257$hn" +
        payload
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ronin-exploits-1.0.0.beta2 spec/mixins/format_string_spec.rb
ronin-exploits-1.0.0.beta1 spec/mixins/format_string_spec.rb