nexpose_cyberark 0.0.1-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjU1OTg2OGJiYTQxMzk1ZjIyOTE2ZTZkMWQwMmNkMzkyZThkMzQ5ZA==
5
+ data.tar.gz: !binary |-
6
+ NmY1YTRlYzEwYTgxMmRjNjgxOTZkZTYxYjkxNWEyZjc2MzY0NTgzMA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MGQxMTRkMDI4OGMwN2U2MDVkNGRhZTEwMTljNTU3N2Y4NjYzMTQwNTRiNmUz
10
+ OWE5NjhlMzg1MzJkMTMxMDE3MzFhZjA0ZTE2NzZjNjg5YWJjNGQ5MWFlYjQ3
11
+ MTJiMTRjODRlOTcxN2RlOWFlMTBkZDBjNTI4NmYxMWE0NTEzMjU=
12
+ data.tar.gz: !binary |-
13
+ M2RmNDAwMTk5YWRlYjQwZDY0MGFkNmRmOTQ4NWVmOGMxNzc1MzBiOWJiNzg5
14
+ YjA1YjAzYzIwMDgzNDhlOTE4YTJlNzYwNTJmYmM3YmEzOWFhODhlOGU5Nzg0
15
+ OTFiMjFmMjQ0ZGM4ZWY0ZjYyMTQzMzIxMzA4NmZlZDVjNjM3ZTk=
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nexpose_cyberark.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nexpose_cyberark (0.0.1-java)
5
+ nexpose (>= 0.6.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.2.5)
11
+ librex (0.0.68)
12
+ nexpose (0.7.6)
13
+ librex (~> 0.0, >= 0.0.68)
14
+ rex (~> 1.0, >= 1.0.2)
15
+ rake (10.3.2)
16
+ rex (1.0.2)
17
+ rspec (3.0.0)
18
+ rspec-core (~> 3.0.0)
19
+ rspec-expectations (~> 3.0.0)
20
+ rspec-mocks (~> 3.0.0)
21
+ rspec-core (3.0.2)
22
+ rspec-support (~> 3.0.0)
23
+ rspec-expectations (3.0.2)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.0.0)
26
+ rspec-mocks (3.0.2)
27
+ rspec-support (~> 3.0.0)
28
+ rspec-support (3.0.2)
29
+
30
+ PLATFORMS
31
+ java
32
+
33
+ DEPENDENCIES
34
+ bundler (~> 1.6)
35
+ nexpose_cyberark!
36
+ rake
37
+ rspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Damian Finol
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # NexposeCyberark
2
+
3
+ The nexpose CyberArk integration allows the use of credentials stored in CyberArk Vault to be used in scanning jobs,
4
+ allowing Nexpose to perform authenticated scans, increasing the confidence in fingerprinting and vulnerabilities found.
5
+
6
+ ## Installation
7
+
8
+ This is a JRuby Gem, it uses CyberArk's Java libraries to perform queries on CyberArk's vaults and Ruby libraries to
9
+ communicate with Nexpose. As such, JRuby needs to be installed on the target system.
10
+
11
+ BEFORE INSTALLATION:
12
+ * Install CyberArk's provided Password SDK Client on the system
13
+ * Configure CyberArk vault Objects to match Nexpose scan targets:
14
+ For example if a Nexpose hostname is in the form of 'systemv6.mydomain.com' your Object must be 'systemv6.mydomain.com'
15
+ If the scan target is an IP address, the object name must be the IP address.
16
+ * Make sure the Policy ID of your objects include the description of the OS: 'unix' or 'windows'
17
+
18
+ ## Usage
19
+
20
+ Configure Vault settings:
21
+ o APP ID, Safe, Folder properties from CyberArk. Please refer to CyberArk documentation.
22
+ Configure Nexpose settings:
23
+ o A valid nexpose user, password, ip address and sites to manage.
24
+ o The start scan variable. If set to true, once updated the gem will trigger a scan of the site, wait until it’s finished and deletes the credentials stored. If set to false, it’ll not kick a scan and will run on scheduled.
25
+ Run the script for the first time.
26
+ o The script can be run using the command from the command line:
27
+ jruby nx_cyberark.rb
28
+ o The script will run and perform the queries, if the start scan variable is set to false, the script will exit silently; otherwise the script will output the status of each scan
29
+
30
+
31
+ ## Help
32
+
33
+ * Email us to integrations_support@rapid7.com
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+ # Nexpose Cyberark Integration
3
+ # Please refer to the configuration documentation for instructions on how to run this gem
4
+ # Do NOT run this gem without proper pre-configuration.
5
+ require 'nexpose_cyberark'
6
+
7
+ # ---- CyberArk Configuration ---- #
8
+ # Vault Options
9
+ # App ID
10
+ app_id = 'Rapid7'
11
+ # Safe
12
+ safe = 'Rapid 7 Accounts'
13
+ # Folder
14
+ folder = 'Root'
15
+ # Objects should have the same name as their counterparts in Nexpose
16
+ # IE: 'serverx01.mydomain.com' in both Cyberark and Nexpose.
17
+ # Individual IP's will be queried and should also correspond to Object names.
18
+ # For ranges, this integration will use the first IP as the credential for all the range.
19
+ # Finally, PolicyIDs in Cyberark should have 'unix' or 'windows' as part of their name for proper credential
20
+ # type assignment in Nexpose (ssh / cifs)
21
+ # ---- End CyberArk Configuration ---- #
22
+
23
+ # ---- Nexpose Configuration ---- #
24
+ # Nexpose username
25
+ nxuser = 'nxadmin'
26
+ # Nexpose password
27
+ nxpasswd = 'nxadmin'
28
+ # Nexpose IP Address
29
+ nxip = 'localhost'
30
+ # Sites to process credentials, separated by commas, ie: [3, 4, 6]
31
+ sites = [ 1 ]
32
+ # Start scans?
33
+ # This setting will start scans on those sites, wait for the site to complete and then remove the credentials
34
+ # If you prefer to let the scans run on schedule, set this to false, otherwise set to true.
35
+ start_scans = false
36
+ # ---- End Nexpose Configuration ---- #
37
+
38
+
39
+
40
+ # --- DO NOT EDIT BELOW THIS LINE --- #
41
+
42
+ vault_options = { :app_id => app_id, :safe => safe, :folder => folder }
43
+ nexpose_options = { :nxip => nxip, :nxuser => nxuser, :nxpassword => nxpasswd, :sites => sites }
44
+ NexposeCyberark::Vault.update_credentials(vault_options, nexpose_options)
45
+ NexposeCyberark::Vault.start_scans(nexpose_options) if start_scans
@@ -0,0 +1,48 @@
1
+ require "nexpose_cyberark/version"
2
+ Dir[File.dirname(__FILE__)+'/nexpose_cyberark/lib/java/*.jar'].each { |jar| require jar }
3
+ require "nexpose_cyberark/password_ops"
4
+ require "nexpose_cyberark/nexpose_ops"
5
+ module NexposeCyberark
6
+ module Vault
7
+ def self.update_credentials(vault_options, nexpose_options = nil)
8
+ @nx = Ops::Nexpose.new(nexpose_options[:nxip], nexpose_options[:nxuser], nexpose_options[:nxpassword])
9
+ # Parse sites from config
10
+ nexpose_options[:sites].each do |site_id|
11
+ # Get ips for each site
12
+ site_ips = @nx.get_ips_from_site(site_id)
13
+ site_credentials = []
14
+ # Get password for each IP
15
+ site_ips.each do |asset|
16
+ host = ''
17
+ host = asset.host if asset.is_a?(HostName)
18
+ host = asset.from if asset.is_a?(IPRange)
19
+ range_scenario = false
20
+ if asset.is_a?(IPRange) then range_scenario = true unless asset.from.nil? end
21
+ vault_options[:object] = host
22
+ asset_data = PasswordOps::get_password(vault_options)
23
+ host = nil if range_scenario
24
+ unless asset_data[:password].nil?
25
+ credential_cifs = Credential.for_service(asset_data[:os], 'Administrator', asset_data, nil, host)
26
+ site_credentials.push(credential_cifs)
27
+ end
28
+ end
29
+ # Save site
30
+ @nx.save_site(site_id, site_credentials)
31
+ end
32
+ end
33
+ def self.start_scans(nexpose_options = nil)
34
+ @nx = Ops::Nexpose.new(nexpose_options[:nxip], nexpose_options[:nxuser], nexpose_options[:nxpassword])
35
+ nexpose_options[:sites].each do |site_id|
36
+ puts "Starting scan #{site_id}"
37
+ scan = @nx.start_scan(site_id)
38
+ begin
39
+ sleep(30)
40
+ status = @nx.scan_status(scan.id)
41
+ puts "Waiting for scan #{scan.id} to finish"
42
+ end while status == Scan::Status::RUNNING
43
+ puts "Deleting creds for #{site_id}"
44
+ @nx.delete_site_credentials(site_id)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,37 @@
1
+ require 'nexpose'
2
+ include Nexpose
3
+ module Ops
4
+ class Nexpose
5
+ attr_accessor :nsc
6
+ def initialize(nxip, nxuser, nxpasword)
7
+ @nsc = Connection.new(nxip, nxuser, nxpasword)
8
+ @nsc.login
9
+ end
10
+
11
+ def get_ips_from_site(site_id)
12
+ site = Site.load(@nsc, site_id)
13
+ site.assets
14
+ end
15
+
16
+ def save_site(site_id, credentials)
17
+ site = Site.load(@nsc, site_id)
18
+ site.credentials = credentials
19
+ site.save(@nsc)
20
+ end
21
+
22
+ def delete_site_credentials(site_id)
23
+ site = Site.load(@nsc, site_id)
24
+ site.credentials = []
25
+ site.save(@nsc)
26
+ end
27
+
28
+ def start_scan(site_id)
29
+ site = Site.load(@nsc, site_id)
30
+ site.scan(@nsc)
31
+ end
32
+
33
+ def scan_status(scan_id)
34
+ @nsc.scan_status(scan_id)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,29 @@
1
+ module PasswordOps
2
+
3
+ def self.cyberark
4
+ Java::javapasswordsdk
5
+ end
6
+
7
+ def self.get_password(vault_options = {}, password_req_sdk = nil, password_sdk = nil )
8
+ password_req_sdk = cyberark.PSDKPasswordRequest.new if password_req_sdk.nil?
9
+ asset_data = {}
10
+ begin
11
+ password_req_sdk.set_app_id(vault_options[:app_id])
12
+ password_req_sdk.set_safe(vault_options[:safe])
13
+ password_req_sdk.set_folder(vault_options[:folder])
14
+ password_req_sdk.set_object(vault_options[:object])
15
+ password_sdk = cyberark.PasswordSDK if password_sdk.nil?
16
+ password_result = password_sdk.getPassword(password_req_sdk)
17
+ if password_result.get_policy_id.downcase.include? 'unix'
18
+ #puts password_result.get_policy_id.downcase.include? 'unix'
19
+ asset_data[:os] = 'ssh'
20
+ else
21
+ asset_data[:os] = 'cifs'
22
+ end
23
+ asset_data[:password] = password_result.get_content
24
+ rescue Exception => e
25
+
26
+ end
27
+ asset_data
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module NexposeCyberark
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nexpose_cyberark/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'nexpose_cyberark'
8
+ spec.version = NexposeCyberark::VERSION
9
+ spec.authors = ['Damian Finol']
10
+ spec.email = ['damian_finol@rapid7.com']
11
+ spec.summary = %q{Nexpose Cyberark integration.}
12
+ spec.description = %q{Nexpose Cyberark integration provides credentials for authenticated scans in Nexpose.}
13
+ spec.homepage = 'http://www.rapid7.com/'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = Dir['[A-Z]*'] + Dir['lib/**/*'] + Dir['bin/**']
17
+ spec.files.reject! { |fn| fn.include? "CVS" }
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+ spec.platform = 'java'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.6'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_dependency('nexpose', '>= 0.6.0')
27
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nexpose_cyberark
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: java
6
+ authors:
7
+ - Damian Finol
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nexpose
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.6.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.6.0
69
+ description: Nexpose Cyberark integration provides credentials for authenticated scans
70
+ in Nexpose.
71
+ email:
72
+ - damian_finol@rapid7.com
73
+ executables:
74
+ - nx_cyberark.rb
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/nx_cyberark.rb
84
+ - lib/nexpose_cyberark.rb
85
+ - lib/nexpose_cyberark/lib/java/JavaPasswordSDK.jar
86
+ - lib/nexpose_cyberark/nexpose_ops.rb
87
+ - lib/nexpose_cyberark/password_ops.rb
88
+ - lib/nexpose_cyberark/version.rb
89
+ - nexpose_cyberark.gemspec
90
+ homepage: http://www.rapid7.com/
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.2.2
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Nexpose Cyberark integration.
114
+ test_files: []