Sha256: 993180699f80dd59e39fcb4e511067b45e6d9ce4e3d9eb555690c0d3402b5231

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

# encoding: US-ASCII

require 'spec_helper'
require 'ronin/code/asm/shellcode'

describe Ronin::Code::ASM::Shellcode do
  describe "#assemble", integration: true do
    subject do
      described_class.new do
        xor   eax,  eax
        push  eax
        push  0x68732f2f
        push  0x6e69622f
        mov   ebx, esp
        push  eax
        push  ebx
        mov   ecx,  esp
        xor   edx,  edx
        mov   al,   0xb
        int   0x80
      end
    end

    let(:shellcode) { "1\xC0Ph//shh/bin\x89\xE3PS\x89\xE11\xD2\xB0\v\xCD\x80" }

    it "must assemble down to raw machine code" do
      expect(subject.assemble).to eq(shellcode)
    end

    it "must return an ASCII-8bit encoded String" do
      expect(subject.assemble.encoding).to eq(Encoding::ASCII_8BIT)
    end

    context "with :output" do
      let(:output) do
        Tempfile.new(['ronin-shellcode-custom-path', '.bin']).path
      end

      it "must write to the custom path" do
        expect(subject.assemble(output: output)).to eq(shellcode)

        File.binread(output)
      end
    end

    context "with :syntax is :intel" do
      it "assemble down to raw machine code" do
        expect(subject.assemble(syntax: :intel)).to eq(shellcode)
      end
    end

    context "with :syntax is :att" do
      it "assemble down to raw machine code" do
        expect(subject.assemble(syntax: :att)).to eq(shellcode)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-code-asm-1.0.0.beta1 spec/shellcode_spec.rb