Advertisement
CorrM

Untitled

Nov 3rd, 2017
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.24 KB | None | 0 0
  1. require 'msf/core'
  2.  
  3. class MetasploitModule < Msf::Post
  4.  
  5.   #include Msf::Post::Common
  6.   #include Msf::Post::Android::System
  7.   #include Msf::Session::Provider::SingleCommandShell
  8.  
  9.   def initialize(info={})
  10.     super(update_info(info,
  11.         'Name'          => 'android Manage get_apps',
  12.         'Description'   => %q{
  13.           Get all apps in android device
  14.         },
  15.         'License'       => MSF_LICENSE,
  16.         'Author'        => [ 'CorrM' ],
  17.         'Platform'      => [ 'android' ],
  18.         'SessionTypes'  => [ 'meterpreter', 'shell' ]
  19.     ))
  20.   end
  21.  
  22.   def run
  23.     #print_status(session.core.methods.join(', '))
  24.     #return
  25.  
  26.     # Check Platform
  27.     if !session.platform.eql?("android")
  28.       print_error("This Script for android [ONLY].!!")
  29.       return
  30.     end
  31.  
  32.     # Get Apps
  33.     get_device_apps()
  34.    
  35.     #print_line(session.platform)
  36.  
  37.     print_good("Bye, CorrM.")
  38.   end
  39.  
  40.   def get_device_apps
  41.     print_line(session.shell_command('pm list packages -f'))
  42.   end
  43.  
  44.   def shell_commandx(cmd, ret_read)
  45.     buff = ""
  46.     session.shell_write(cmd + "\n")
  47.  
  48.     if ret_read
  49.       1.times do |i|
  50.         res = session.shell_read(-1, 0.01)
  51.         buff << res if res
  52.       end
  53.     end
  54.    
  55.     buff  
  56.   end
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement