Skip to content

Commit

Permalink
Allow the output path to be overriden.
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Mar 24, 2015
1 parent 491ab9f commit 5cb79f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/ronin/asm/shellcode.rb
Expand Up @@ -52,13 +52,19 @@ class Shellcode < Program
# @param [Hash] options
# Additional options.
#
# @option options [String] :output
# The optional output to write the shellcode to. If no `:output` is
# given a tempfile will be used.
#
# @return [String]
# The raw object-code of the Shellcode.
#
# @see Program#assemble
#
def assemble(options={})
output = Tempfile.new(['ronin-shellcode', '.bin']).path
output = options.fetch(:output) do
Tempfile.new(['ronin-shellcode', '.bin']).path
end

super(output,options.merge(format: :bin))

Expand Down
12 changes: 12 additions & 0 deletions spec/asm/shellcode_spec.rb
Expand Up @@ -27,6 +27,18 @@
subject.assemble.should == shellcode
end

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

it "should write to the custom path" do
subject.assemble(output: output).should == shellcode

File.binread(output)
end
end

context "with :syntax is :intel" do
it "assemble down to raw machine code" do
subject.assemble(syntax: :intel).should == shellcode
Expand Down

0 comments on commit 5cb79f3

Please sign in to comment.