soleranetworks 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.md +99 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/bin/solera_get +107 -0
- data/lib/soleranetworks.rb +140 -0
- data/soleranetworks.gemspec +55 -0
- data/test/helper.rb +10 -0
- data/test/test_soleranetworks.rb +7 -0
- metadata +74 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 fracBlend
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# soleranetworks
|
2
|
+
|
3
|
+
Solera Networks API Gem
|
4
|
+
|
5
|
+
## Description
|
6
|
+
|
7
|
+
Handy little library and binary to automate building Solera Networks REST API calls
|
8
|
+
|
9
|
+
### lib/soleranetworks.rb
|
10
|
+
|
11
|
+
Library for use in your own ruby scripts to build API Call URIs
|
12
|
+
|
13
|
+
### solera_get
|
14
|
+
|
15
|
+
Command line tool that automatically builds an API Call and grabs the resulting PCAP.
|
16
|
+
|
17
|
+
## Where to get a Demo VM Appliance
|
18
|
+
|
19
|
+
Don't have a Solera DS Network Forensics Appliance?
|
20
|
+
|
21
|
+
Download a [VMWare Based Demo Appliance](http://www.soleranetworks.com/products/network-forensics-appliances/virtual-appliance)
|
22
|
+
|
23
|
+
## Install
|
24
|
+
$ sudo gem install soleranetworks
|
25
|
+
## Usage (solera_get)
|
26
|
+
### Command Line Options
|
27
|
+
$ solera_get -h
|
28
|
+
Usage: solera_get [options] host ...
|
29
|
+
-v, --verbose Output more information
|
30
|
+
-u, --username USERNAME API Username
|
31
|
+
-p, --password PASSWORD API Password
|
32
|
+
-o, --output_filename FILENAME Filename for Returned PCAP
|
33
|
+
-b, --build_uri Build and Dump the URI ONLY
|
34
|
+
--host HOSTNAME Hostname or IP of Solera Appliance
|
35
|
+
--ethernet_address MAC_ADDR ethernet_address
|
36
|
+
--ethernet_source MAC_ADDR ethernet_source
|
37
|
+
--ethernet_destination MAC_ADDR
|
38
|
+
ethernet_destination
|
39
|
+
--ethernet_protocol PROTOCOL ethernet_protocol
|
40
|
+
--interface INTERFACE interface
|
41
|
+
--ip_protocol IP_PROTOCOL ip_protocol
|
42
|
+
--ipv4_address IPv4_ADDRESS ipv4_address
|
43
|
+
--ipv4_source IPv4_ADDRESS ipv4_source
|
44
|
+
--ipv4_destination IPv4_ADDRESS
|
45
|
+
ipv4_destination
|
46
|
+
--ipv6_address IPv6_ADDRESS ipv6_address
|
47
|
+
--ipv6_source IPv6_ADDRESS ipv6_source
|
48
|
+
--ipv6_destination IPv6_ADDRESS
|
49
|
+
ipv6_destination
|
50
|
+
--packet_length PACKET_LENGTH
|
51
|
+
packet_length
|
52
|
+
--tcp_port TCP_PORT tcp_port
|
53
|
+
--tcp_source_port TCP_PORT tcp_source_port
|
54
|
+
--tcp_destination_port TCP_PORT
|
55
|
+
tcp_destination_port
|
56
|
+
--udp_port UDP_PORT udp_port
|
57
|
+
--udp_source_port UDP_PORT udp_source_port
|
58
|
+
--udp_destination_port UDP_PORT
|
59
|
+
udp_destination_port
|
60
|
+
--timespan TIMESPAN timespan
|
61
|
+
--vlan_id VLAN_ID vlan_id
|
62
|
+
-h, --help Display this screen
|
63
|
+
|
64
|
+
### Pull all traffic from 1.2.3.4
|
65
|
+
$ solera_get -u username -p password --ipv4_address 1.2.3.4
|
66
|
+
### Pull all traffic from 1.2.3.4 occurring on 03/02/2010
|
67
|
+
$ solera_get -u username -p password --ipv4_address 1.2.3.4 --timespan 03.02.2010.00.00.00.03.03.2010.00.00.00
|
68
|
+
### Pull all DNS traffic larger than 52 bytes
|
69
|
+
$ solera_get -u username -p password --udp_port 53 --packet_length 53_to_1549
|
70
|
+
## Usage lib/soleranetworks.rb
|
71
|
+
require 'rubygems'
|
72
|
+
require 'soleranetworks'
|
73
|
+
|
74
|
+
options = {
|
75
|
+
:host => '192.168.20.20',
|
76
|
+
:user => 'admin',
|
77
|
+
:pass => 'somePassword',
|
78
|
+
:ipv4_address => '1.2.3.4',
|
79
|
+
:timespan => (Time.now.getlocal-(60*5)).strftime('%m.%d.%Y.%H.%M.%S')+"."+Time.now.getlocal.strftime('%m.%d.%Y.%H.%M.%S')
|
80
|
+
}
|
81
|
+
request = SoleraNetworks.new(options)
|
82
|
+
|
83
|
+
# Generate API Call URI
|
84
|
+
puts request.uri
|
85
|
+
# https://192.168.20.20/ws/pcap?method=deepsee&user=admin&password=somePassword&path=%2Ftimespan%2F03.25.2010.14.14.37.03.25.2010.14.19.37%2Fipv4_address%2F1.2.3.4%2Fdata.pcap
|
86
|
+
|
87
|
+
## Note on Patches/Pull Requests
|
88
|
+
|
89
|
+
* Fork the project.
|
90
|
+
* Make your feature addition or bug fix.
|
91
|
+
* Add tests for it. This is important so I don't break it in a
|
92
|
+
future version unintentionally.
|
93
|
+
* Commit, do not mess with rakefile, version, or history.
|
94
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
95
|
+
* Send me a pull request. Bonus points for topic branches.
|
96
|
+
|
97
|
+
## Copyright
|
98
|
+
|
99
|
+
Copyright (c) 2010 fracBlend. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "soleranetworks"
|
8
|
+
gem.executables = "solera_get"
|
9
|
+
gem.summary = %Q{Solera Networks API gem}
|
10
|
+
gem.description = %Q{Solera Neworks API gem}
|
11
|
+
gem.email = "gbelknap@soleranetworks.com"
|
12
|
+
gem.homepage = "http://github.com/fracBlend/soleranetworks"
|
13
|
+
gem.authors = ["fracBlend"]
|
14
|
+
gem.requirements << "Solera Networks DS (Appliance or VM), SoleraOS v4.x or greater"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
26
|
+
test.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
task :rcov do
|
38
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
task :test => :check_dependencies
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "soleranetworks #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.4
|
data/bin/solera_get
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
|
3
|
+
## Solera Networks API Example Script
|
4
|
+
## gbelknap@soleranetworks.com
|
5
|
+
|
6
|
+
# Copyright (c) 2010 Solera Networks, Inc
|
7
|
+
|
8
|
+
# This program is free software; you can redistribute it and/or
|
9
|
+
# modify it under the terms of the GNU General Public License
|
10
|
+
# as published by the Free Software Foundation; either version 2
|
11
|
+
# of the License, or (at your option) any later version.
|
12
|
+
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
|
18
|
+
require 'open-uri'
|
19
|
+
require 'openssl'
|
20
|
+
require 'optparse'
|
21
|
+
require 'rubygems'
|
22
|
+
require 'soleranetworks'
|
23
|
+
|
24
|
+
# Ignore self-signed SSL Certificates
|
25
|
+
module OpenSSL
|
26
|
+
module SSL
|
27
|
+
remove_const :VERIFY_PEER
|
28
|
+
end
|
29
|
+
end
|
30
|
+
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
31
|
+
|
32
|
+
# Default Options
|
33
|
+
options = {
|
34
|
+
:verbose => false,
|
35
|
+
:host => "192.168.20.20",
|
36
|
+
:user => "changeme",
|
37
|
+
:pass => "changeme",
|
38
|
+
:output_filename => "data.pcap",
|
39
|
+
:ipv4_address => "127.0.0.1",
|
40
|
+
:timespan => (Time.now.getlocal-(60*5)).strftime('%m.%d.%Y.%H.%M.%S')+"."+Time.now.getlocal.strftime('%m.%d.%Y.%H.%M.%S'),
|
41
|
+
}
|
42
|
+
|
43
|
+
optparse = OptionParser.new do|opts|
|
44
|
+
opts.banner = "Usage: #{File.basename($0)} [options] host ..."
|
45
|
+
# Basic Params
|
46
|
+
opts.on( '-v', '--verbose', 'Output more information' ) {|options[:verbose]|}
|
47
|
+
opts.on( '-u', '--username USERNAME', String, 'API Username' ) {|options[:user]|}
|
48
|
+
opts.on( '-p', '--password PASSWORD', String, 'API Password' ) {|options[:pass]|}
|
49
|
+
opts.on( '-o', '--output_filename FILENAME', String, 'Filename for Returned PCAP' ) {|options[:output_filename]|}
|
50
|
+
opts.on( '-b', '--build_uri', 'Build and Dump the URI ONLY' ) {|options[:nop]|}
|
51
|
+
opts.on( '--host HOSTNAME', String, 'Hostname or IP of Solera Appliance' ) {|options[:host]|}
|
52
|
+
# Ethetnet Params
|
53
|
+
opts.on( '--ethernet_address MAC_ADDR', String, 'ethernet_address' ) {|options[:ethernet_address]|}
|
54
|
+
opts.on( '--ethernet_source MAC_ADDR', String, 'ethernet_source' ) {|options[:ethernet_source]|}
|
55
|
+
opts.on( '--ethernet_destination MAC_ADDR', String, 'ethernet_destination' ) {|options[:ethernet_destination]|}
|
56
|
+
opts.on( '--ethernet_protocol PROTOCOL', String, 'ethernet_protocol' ) {|options[:ethernet_protocol]|}
|
57
|
+
# Interface Params
|
58
|
+
opts.on( '--interface INTERFACE', String, 'interface' ) {|options[:interface]|}
|
59
|
+
# IP Params
|
60
|
+
opts.on( '--ip_protocol IP_PROTOCOL', String, 'ip_protocol' ) {|options[:ip_protocol]|}
|
61
|
+
# IPv4 Params
|
62
|
+
opts.on( '--ipv4_address IPv4_ADDRESS', String, 'ipv4_address' ) {|options[:ipv4_address]|}
|
63
|
+
opts.on( '--ipv4_source IPv4_ADDRESS', String, 'ipv4_source' ) {|options[:ipv4_source]|}
|
64
|
+
opts.on( '--ipv4_destination IPv4_ADDRESS', String, 'ipv4_destination' ) {|options[:ipv4_destination]|}
|
65
|
+
# IPv6 Params
|
66
|
+
opts.on( '--ipv6_address IPv6_ADDRESS', String, 'ipv6_address' ) {|options[:ipv6_address]|}
|
67
|
+
opts.on( '--ipv6_source IPv6_ADDRESS', String, 'ipv6_source' ) {|options[:ipv6_source]|}
|
68
|
+
opts.on( '--ipv6_destination IPv6_ADDRESS', String, 'ipv6_destination' ) {|options[:ipv6_destination]|}
|
69
|
+
# Packet Params
|
70
|
+
opts.on( '--packet_length PACKET_LENGTH', String, 'packet_length' ) {|options[:packet_length]|}
|
71
|
+
# TCP Params
|
72
|
+
opts.on( '--tcp_port TCP_PORT', String, 'tcp_port' ) {|options[:tcp_port]|}
|
73
|
+
opts.on( '--tcp_source_port TCP_PORT', String, 'tcp_source_port' ) {|options[:tcp_source_port]|}
|
74
|
+
opts.on( '--tcp_destination_port TCP_PORT', String, 'tcp_destination_port' ) {|options[:tcp_destination_port]|}
|
75
|
+
# UDP Params
|
76
|
+
opts.on( '--udp_port UDP_PORT', String, 'udp_port' ) {|options[:udp_port]|}
|
77
|
+
opts.on( '--udp_source_port UDP_PORT', String, 'udp_source_port' ) {|options[:udp_source_port]|}
|
78
|
+
opts.on( '--udp_destination_port UDP_PORT', String, 'udp_destination_port' ) {|options[:udp_destination_port]|}
|
79
|
+
# Time Params
|
80
|
+
opts.on( '--timespan TIMESPAN', String, 'timespan' ) {|options[:timespan]|}
|
81
|
+
# VLAN Params
|
82
|
+
opts.on( '--vlan_id VLAN_ID', String, 'vlan_id' ) {|options[:vlan_id]|}
|
83
|
+
# Help Param
|
84
|
+
opts.on( '-h', '--help', 'Display this screen' ) do
|
85
|
+
puts opts
|
86
|
+
exit
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
optparse.parse!
|
91
|
+
|
92
|
+
ARGV[0] ? options[:host] = ARGV[0] : options[:host]
|
93
|
+
# ARGV[0].nil? ? options[:host] = ARGV[0]
|
94
|
+
|
95
|
+
puts "Being Verbose" if options[:verbose]
|
96
|
+
puts "Username : #{options[:user]}" if options[:user] && options[:verbose]
|
97
|
+
puts "Password : #{options[:pass]}" if options[:pass] && options[:verbose]
|
98
|
+
puts "DS Appliance : #{options[:host]}" if options[:host] && options[:verbose]
|
99
|
+
puts "Output Filename : #{options[:output_filename]}" if options[:output_filename] && options[:verbose]
|
100
|
+
|
101
|
+
begin
|
102
|
+
s = SoleraNetworks.new(options)
|
103
|
+
puts "API CALL URI : " + s.uri if options[:verbose] || options[:nop]
|
104
|
+
s.get_pcap(s.uri) if !options[:nop]
|
105
|
+
rescue => error
|
106
|
+
puts "Awww SNAP! : #{error}"
|
107
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
## Solera Networks API Gem
|
2
|
+
## gbelknap@soleranetworks.com
|
3
|
+
|
4
|
+
# Copyright (c) 2010 Solera Networks, Inc
|
5
|
+
|
6
|
+
# This program is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation; either version 2
|
9
|
+
# of the License, or (at your option) any later version.
|
10
|
+
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
|
16
|
+
class SoleraNetworks
|
17
|
+
attr_accessor :options
|
18
|
+
|
19
|
+
# Constants for Humanizing File Sizes
|
20
|
+
IS_AWESOME = 1
|
21
|
+
GIGA_SIZE = 1073741824.0
|
22
|
+
MEGA_SIZE = 1048576.0
|
23
|
+
KILO_SIZE = 1024.0
|
24
|
+
|
25
|
+
def initialize(options={})
|
26
|
+
@options = {
|
27
|
+
#
|
28
|
+
# GEM Specific Method Paramaters
|
29
|
+
#
|
30
|
+
# DS Appliance Hostname / IP
|
31
|
+
:host => '', # ie: 192.168.20.20
|
32
|
+
# Username for Accessing API
|
33
|
+
:user => '',
|
34
|
+
# Password
|
35
|
+
:pass => '',
|
36
|
+
# Filename for returned PCAP
|
37
|
+
:output_filename => "data.pcap",
|
38
|
+
# Type of Request URI ['pcap', 'sonar', 'applications', 'conversations', 'packetsizes', 'ipdiscovery', 'bandwidth']
|
39
|
+
:type => 'pcap',
|
40
|
+
#
|
41
|
+
# DeepSee API Method Parameters
|
42
|
+
#
|
43
|
+
:ethernet_address => '', # ff:ff:ff:ff:ff:ff
|
44
|
+
:ethernet_source => '', # ff:ff:ff:ff:ff:ff
|
45
|
+
:ethernet_destination => '', # ff:ff:ff:ff:ff:ff
|
46
|
+
:ethernet_protocol => '', # ipv4
|
47
|
+
:interface => '', # eth2
|
48
|
+
:ip_protocol => '', # tcp
|
49
|
+
:ipv4_address => '', # 127.0.0.1
|
50
|
+
:ipv4_destination => '', # 127.0.0.1
|
51
|
+
:ipv4_source => '', # 127.0.0.1
|
52
|
+
:ipv6_address => '', # ::ffff:127.0.0.1
|
53
|
+
:ipv6_destination => '', # ::ffff:127.0.0.1
|
54
|
+
:ipv6_source => '', # ::ffff:127.0.0.1
|
55
|
+
:packet_length => '', # 0_to_1549
|
56
|
+
:tcp_destination_port => '', # 80
|
57
|
+
:tcp_port => '', # 80
|
58
|
+
:tcp_source_port => '', # 80
|
59
|
+
# A Timespan is specified as start_time.end_time in the format of strftime('%m.%d.%Y.%I.%M.%S')
|
60
|
+
# Default here is last 5 mins
|
61
|
+
:timespan => (Time.now.getlocal-(60*5)).strftime('%m.%d.%Y.%H.%M.%S')+"."+Time.now.getlocal.strftime('%m.%d.%Y.%H.%M.%S'),
|
62
|
+
# :start_time => (Time.now.getlocal-(60*5)).strftime('%m.%d.%Y.%H.%M.%S'),
|
63
|
+
# :end_time => Time.now.getlocal.strftime('%m.%d.%Y.%H.%M.%S'),
|
64
|
+
:udp_destination_port => '', # 53
|
65
|
+
:udp_port => '', # 53
|
66
|
+
:udp_source_port => '', # 53
|
67
|
+
:vlan_id => '', # 1
|
68
|
+
}.merge(options)
|
69
|
+
end
|
70
|
+
|
71
|
+
def uri()
|
72
|
+
# Build Call : Long and Drawn out for ease of reading/editing
|
73
|
+
api_call = "https://#{@options[:host]}/ws/pcap?method=deepsee&"
|
74
|
+
api_call += "user=#{@options[:user]}&"
|
75
|
+
api_call += "password=#{@options[:pass]}&"
|
76
|
+
api_call += "path=%2F"
|
77
|
+
# Time Params
|
78
|
+
api_call += "timespan%2F#{@options[:timespan]}%2F" unless @options[:timespan].empty?
|
79
|
+
# Ethetnet Params
|
80
|
+
api_call += "ethernet_address%2F#{@options[:ethernet_address]}%2F" unless @options[:ethernet_address].empty?
|
81
|
+
api_call += "ethernet_source%2F#{@options[:ethernet_source]}%2F" unless @options[:ethernet_source].empty?
|
82
|
+
api_call += "ethernet_destination%2F#{@options[:ethernet_destination]}%2F" unless @options[:ethernet_destination].empty?
|
83
|
+
api_call += "ethernet_protocol%2F#{@options[:ethernet_protocol]}%2F" unless @options[:ethernet_protocol].empty?
|
84
|
+
# Interface Params
|
85
|
+
api_call += "interface%2F#{@options[:interface]}%2F" unless @options[:interface].empty?
|
86
|
+
# IP Params
|
87
|
+
api_call += "ip_protocol%2F#{@options[:ip_protocol]}%2F" unless @options[:ip_protocol].empty?
|
88
|
+
# IPv4 Params
|
89
|
+
api_call += "ipv4_address%2F#{@options[:ipv4_address]}%2F" unless @options[:ipv4_address].empty?
|
90
|
+
api_call += "ipv4_source%2F#{@options[:ipv4_source]}%2F" unless @options[:ipv4_source].empty?
|
91
|
+
api_call += "ipv4_destination%2F#{@options[:ipv4_destination]}%2F" unless @options[:ipv4_destination].empty?
|
92
|
+
# IPv6 Params
|
93
|
+
api_call += "ipv6_address%2F#{@options[:ipv6_address]}%2F" unless @options[:ipv6_address].empty?
|
94
|
+
api_call += "ipv6_source%2F#{@options[:ipv6_source]}%2F" unless @options[:ipv6_source].empty?
|
95
|
+
api_call += "ipv6_destination%2F#{@options[:ipv6_destination]}%2F" unless @options[:ipv6_destination].empty?
|
96
|
+
# Packet Params
|
97
|
+
api_call += "packet_length%2F#{@options[:packet_length]}%2F" unless @options[:packet_length].empty?
|
98
|
+
# TCP Params
|
99
|
+
api_call += "tcp_port%2F#{@options[:tcp_port]}%2F" unless @options[:tcp_port].empty?
|
100
|
+
api_call += "tcp_source_port%2F#{@options[:tcp_source_port]}%2F" unless @options[:tcp_source_port].empty?
|
101
|
+
api_call += "tcp_destination_port%2F#{@options[:tcp_destination_port]}%2F" unless @options[:tcp_destination_port].empty?
|
102
|
+
# UDP Params
|
103
|
+
api_call += "udp_port%2F#{@options[:udp_port]}%2F" unless @options[:udp_port].empty?
|
104
|
+
api_call += "udp_source_port%2F#{@options[:udp_source_port]}%2F" unless @options[:udp_source_port].empty?
|
105
|
+
api_call += "udp_destination_port%2F#{@options[:udp_destination_port]}%2F" unless @options[:udp_destination_port].empty?
|
106
|
+
# VLAN Params
|
107
|
+
api_call += "vlan_id%2F#{@options[:vlan_id]}%2F" unless @options[:vlan_id].empty?
|
108
|
+
# Type of URI [pcap, sonar, applications, conversations, packetsizes, ipdiscovery, bandwidth]
|
109
|
+
api_call += case @options[:type]
|
110
|
+
when "pcap" then "data.pcap"
|
111
|
+
when "sonar" then ";reportIndex=0"
|
112
|
+
when "applications" then ";reportIndex=1"
|
113
|
+
when "conversations" then ";reportIndex=2"
|
114
|
+
when "packetsizes" then ";reportIndex=3"
|
115
|
+
when "ipdiscovery"then ";reportIndex=4"
|
116
|
+
when "bandwidth" then ";reportIndex=5"
|
117
|
+
else "data.pcap"
|
118
|
+
end
|
119
|
+
|
120
|
+
return api_call
|
121
|
+
end
|
122
|
+
|
123
|
+
def make_readable(size, precision)
|
124
|
+
case
|
125
|
+
when size == 1 : "1 Byte"
|
126
|
+
when size < KILO_SIZE : "%d Bytes" % size
|
127
|
+
when size < MEGA_SIZE : "%.#{precision}f KB" % (size / KILO_SIZE)
|
128
|
+
when size < GIGA_SIZE : "%.#{precision}f MB" % (size / MEGA_SIZE)
|
129
|
+
else "%.#{precision}f GB" % (size / GIGA_SIZE)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def get_pcap(call)
|
134
|
+
open(call, 'User-Agent' => 'Wget') {|call| @pcap = call.read}
|
135
|
+
File.open(@options[:output_filename], 'w') {|file|
|
136
|
+
file.write(@pcap)
|
137
|
+
puts "#{@options[:output_filename]} : " + make_readable(file.stat.size, 2)
|
138
|
+
}
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{soleranetworks}
|
8
|
+
s.version = "0.1.4"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["fracBlend"]
|
12
|
+
s.date = %q{2010-03-25}
|
13
|
+
s.default_executable = %q{solera_get}
|
14
|
+
s.description = %q{Solera Neworks API gem}
|
15
|
+
s.email = %q{gbelknap@soleranetworks.com}
|
16
|
+
s.executables = ["solera_get"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README.md",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/solera_get",
|
29
|
+
"lib/soleranetworks.rb",
|
30
|
+
"soleranetworks.gemspec",
|
31
|
+
"test/helper.rb",
|
32
|
+
"test/test_soleranetworks.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/fracBlend/soleranetworks}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.requirements = ["Solera Networks DS (Appliance or VM), SoleraOS v4.x or greater"]
|
38
|
+
s.rubygems_version = %q{1.3.6}
|
39
|
+
s.summary = %q{Solera Networks API gem}
|
40
|
+
s.test_files = [
|
41
|
+
"test/helper.rb",
|
42
|
+
"test/test_soleranetworks.rb"
|
43
|
+
]
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
50
|
+
else
|
51
|
+
end
|
52
|
+
else
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: soleranetworks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 4
|
9
|
+
version: 0.1.4
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- fracBlend
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-03-25 00:00:00 -06:00
|
18
|
+
default_executable: solera_get
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Solera Neworks API gem
|
22
|
+
email: gbelknap@soleranetworks.com
|
23
|
+
executables:
|
24
|
+
- solera_get
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- LICENSE
|
29
|
+
- README.md
|
30
|
+
files:
|
31
|
+
- .document
|
32
|
+
- .gitignore
|
33
|
+
- LICENSE
|
34
|
+
- README.md
|
35
|
+
- Rakefile
|
36
|
+
- VERSION
|
37
|
+
- bin/solera_get
|
38
|
+
- lib/soleranetworks.rb
|
39
|
+
- soleranetworks.gemspec
|
40
|
+
- test/helper.rb
|
41
|
+
- test/test_soleranetworks.rb
|
42
|
+
has_rdoc: true
|
43
|
+
homepage: http://github.com/fracBlend/soleranetworks
|
44
|
+
licenses: []
|
45
|
+
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options:
|
48
|
+
- --charset=UTF-8
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
version: "0"
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
requirements:
|
66
|
+
- Solera Networks DS (Appliance or VM), SoleraOS v4.x or greater
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.3.6
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Solera Networks API gem
|
72
|
+
test_files:
|
73
|
+
- test/helper.rb
|
74
|
+
- test/test_soleranetworks.rb
|