psexec 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/psexec +78 -0
  3. metadata +61 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 248bef4500b7a09d25e664c9ceb425be53ba4a10
4
+ data.tar.gz: 21e25f75d5f967c725bd3d9541e7cceab8ead7b1
5
+ SHA512:
6
+ metadata.gz: 26a78d64581dfd8af028f405d6776ef95a217e39c2652b221950aed137cd169aca53a2175c6dcc9a2ffea686f841cba9fd3691d8efba71d22871b46e056cbcf1
7
+ data.tar.gz: 1026a98d337e74b3fccd6506b23a41b23d111948285375a0d7e3b9c9960c093585914b0c7bbc8befe909b03fb7c440ae4581463b1887b7f1815e8318da5a382e
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+ require 'winrm'
4
+
5
+ Options = Struct.new(:name)
6
+
7
+ class Parser
8
+ def self.parse(options)
9
+ args = {}
10
+ opt_parser = OptionParser.new do |opts|
11
+ opts.banner = "Usage: encrypt.rb [options]"
12
+
13
+ opts.on("-s", "--server=NAME", "server name or ipaddress etc") do |j|
14
+ args[:hostname] = j
15
+ end
16
+
17
+ opts.on("-c", "--cmd=NAME", "command line to execute") do |i|
18
+ args[:cmd] = i
19
+ end
20
+
21
+ opts.on("-u", "--username=NAME", "username to execute command") do |p|
22
+ args[:username] = p
23
+ end
24
+
25
+ opts.on("-p", "--password=NAME", "password to execute command") do |r|
26
+ args[:password] = r
27
+ end
28
+
29
+ opts.on("-h", "--help", "Prints this help") do
30
+ puts("example: psexec -h 10.20.30.40 -c 'dir c:\\' -u admin -p pass123")
31
+ puts opts
32
+ exit
33
+ end
34
+ end
35
+
36
+ opt_parser.parse!(options)
37
+ return args
38
+ end
39
+ end
40
+
41
+ options = Parser.parse(ARGV)
42
+
43
+ if (options[:hostname].nil?)
44
+ puts "You must specify a hostname use -h for help"
45
+ exit 1
46
+ end
47
+
48
+ if (options[:cmd].nil?)
49
+ puts "You must specify a command line use -h for help"
50
+ exit 1
51
+ end
52
+
53
+ if (options[:username].nil?)
54
+ puts "You must specify a username use -h for help"
55
+ exit 1
56
+ end
57
+
58
+ if (options[:password].nil?)
59
+ puts "You must specify a password use -h for help"
60
+ exit 1
61
+ end
62
+
63
+ opts = {
64
+ endpoint: "https://#{options[:hostname]}:5986/wsman",
65
+ user: options[:username],
66
+ password: options[:password],
67
+ transport: :ssl,
68
+ no_ssl_peer_verification: true
69
+ }
70
+ conn = WinRM::Connection.new(opts)
71
+ conn.shell(:powershell) do |shell|
72
+ output = shell.run(options[:cmd]) do |stdout, stderr|
73
+ STDOUT.print stdout
74
+ STDERR.print stderr
75
+ end
76
+ puts "The script exited with exit code #{output.exitcode}"
77
+ exit output.exitcode
78
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: psexec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Owain Perry
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: wimrm
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.0
27
+ description: simple windows psexec style script to execute commands on windows hosts
28
+ over https
29
+ email: owain.perry@justgiving.com
30
+ executables:
31
+ - psexec
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - bin/psexec
36
+ homepage: http://rubygems.org/gems/psexec
37
+ licenses:
38
+ - MIT
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 2.6.6
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: simple windows psexec style script to execute commands on windows hosts over
60
+ https
61
+ test_files: []