[MENU] | |||||||||
[THOUGHTS] | [TECH RESOURCES] | [TRASH TALK] | |||||||
[DANK MEMES] | [FEATURED ARTISTS] | [W] |
Here is a ruby snippet to get a shell through WinRM service with usage of known credentials.
- #!/usr/bin/env ruby
-
- require 'winrm'
-
- # Author: Alamot
-
- conn = WinRM::Connection.new(
- endpoint: 'http:/<REPLACE_ME>:5985/wsman',
- transport: :ssl,
- user: 'Administrator',
- password: '<REPLACEME>',
- :no_ssl_peer_verification => true
- )
-
- command=""
-
- conn.shell(:powershell) do |shell|
- until command == "exit\n" do
- output = shell.run("-join($id,'PS ',$(whoami),'@',$env:computername,' ',$((gi $pwd).Name),'> ')")
- print(output.output.chomp)
- command = gets
- output = shell.run(command) do |stdout, stderr|
- STDOUT.print stdout
- STDERR.print stderr
- end
- end
- puts "Exiting with code #{output.exitcode}"
- end