falconz 1.0.0
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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +39 -0
- data/LICENSE.txt +21 -0
- data/README.md +64 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/examples/debug.rb +8 -0
- data/falcon.jpg +0 -0
- data/falconz.gemspec +29 -0
- data/lib/falconz/apis/apis.rb +27 -0
- data/lib/falconz/apis/feed.rb +10 -0
- data/lib/falconz/apis/key.rb +10 -0
- data/lib/falconz/apis/report.rb +31 -0
- data/lib/falconz/apis/search.rb +27 -0
- data/lib/falconz/apis/submission.rb +36 -0
- data/lib/falconz/apis/system.rb +92 -0
- data/lib/falconz/client.rb +62 -0
- data/lib/falconz/rest/get.rb +16 -0
- data/lib/falconz/rest/post.rb +18 -0
- data/lib/falconz/version.rb +3 -0
- data/lib/falconz.rb +14 -0
- metadata +126 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 7a44850612a4491a8bc2ccb46218be8f36f80510
|
|
4
|
+
data.tar.gz: 2b8f3f8708774e65bd77169bdcbd7652786d0a99
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7bc77c69372fdfae991f229a5e26b7e54c8f7e221764b9d2320f164491e824a3c9538ac4ad59d4a2281afc1b7235a9eaa6d4aedbf9849f51b7fe637d9eaed8d1
|
|
7
|
+
data.tar.gz: e6dd9024bedfc6496a166ca35bcd7f2569da29be41b407e9b1cb029b023a0d5ed330dcffda9364afdbc4811c7bb9fd390d5c5003c59aedf86b9d3dc3fd81f9a2
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at kgruber1@emich.edu. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
falconz (1.0.0)
|
|
5
|
+
httparty (~> 0.16.2)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
diff-lcs (1.3)
|
|
11
|
+
httparty (0.16.2)
|
|
12
|
+
multi_xml (>= 0.5.2)
|
|
13
|
+
multi_xml (0.6.0)
|
|
14
|
+
rake (10.5.0)
|
|
15
|
+
rspec (3.7.0)
|
|
16
|
+
rspec-core (~> 3.7.0)
|
|
17
|
+
rspec-expectations (~> 3.7.0)
|
|
18
|
+
rspec-mocks (~> 3.7.0)
|
|
19
|
+
rspec-core (3.7.1)
|
|
20
|
+
rspec-support (~> 3.7.0)
|
|
21
|
+
rspec-expectations (3.7.0)
|
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
23
|
+
rspec-support (~> 3.7.0)
|
|
24
|
+
rspec-mocks (3.7.0)
|
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
26
|
+
rspec-support (~> 3.7.0)
|
|
27
|
+
rspec-support (3.7.1)
|
|
28
|
+
|
|
29
|
+
PLATFORMS
|
|
30
|
+
ruby
|
|
31
|
+
|
|
32
|
+
DEPENDENCIES
|
|
33
|
+
bundler (~> 1.16)
|
|
34
|
+
falconz!
|
|
35
|
+
rake (~> 10.0)
|
|
36
|
+
rspec (~> 3.0)
|
|
37
|
+
|
|
38
|
+
BUNDLED WITH
|
|
39
|
+
1.16.0
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Kent Gruber
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Falconz
|
|
2
|
+
> Falcon Malware Sandbox APIv2 Connector
|
|
3
|
+
|
|
4
|
+
<p align="center">
|
|
5
|
+
<img alt="i like birds" src="falcon.jpg"/>
|
|
6
|
+
<p>
|
|
7
|
+
|
|
8
|
+
Falcon Sandbox has a powerful and simple API that can be used to submit files/URLs for analysis, pull report data, but also perform advanced search queries. The API is open and free to the entire IT-security community.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
$ gem install falconz
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
Currently requires the `HYBRID_ANALYSIS_API_KEY` enviroment variable set to communicate with the API.
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
require "falconz"
|
|
20
|
+
|
|
21
|
+
client = Falconz.client.new
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Upload a local file to the sandbox.
|
|
25
|
+
```ruby
|
|
26
|
+
client.submit_file(file: "malware.exe", environment_id: 100)
|
|
27
|
+
# => {"job_id"=>"5acc00b27ca3e138c14ab0e4",
|
|
28
|
+
# "environment_id"=>"100",
|
|
29
|
+
# "sha256"=>"015e5c626b993855fa88ce4c9758bc780fac3774c3d8bfcfae62833affc31e00"}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Search for results related to a given hash (MD5/SHA1/SHA256).
|
|
33
|
+
```ruby
|
|
34
|
+
# md5
|
|
35
|
+
client.search_hash("4d86e66537ac0130cce541890e1d9c4b")
|
|
36
|
+
|
|
37
|
+
# sha1
|
|
38
|
+
client.search_hash("62f585da3fea334b83cb8b4cee9b605d901c825c")
|
|
39
|
+
|
|
40
|
+
# sha256
|
|
41
|
+
client.search_hash("82d14e45e6a0586e66f359c6854bd90b6180b92d66d3db03e5e85234edfdcc04")
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Check the number of environments available to use.
|
|
45
|
+
```ruby
|
|
46
|
+
client.number_of_environments
|
|
47
|
+
# => 5
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Get information about current API key being used.
|
|
51
|
+
```ruby
|
|
52
|
+
client.current_key
|
|
53
|
+
# => {"api_key"=>"130cce541890e1d9c4b34b83cb8b4cee9854bd90b6180b9",
|
|
54
|
+
# "auth_level"=>100,
|
|
55
|
+
# "auth_level_name"=>"default",
|
|
56
|
+
# "user"=>
|
|
57
|
+
# {"id"=>"4cee9b605d901c825c",
|
|
58
|
+
# "email"=>"kgruber1@emich.edu",
|
|
59
|
+
# "name"=>"picat"}}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "falconz"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/examples/debug.rb
ADDED
data/falcon.jpg
ADDED
|
Binary file
|
data/falconz.gemspec
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "falconz/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "falconz"
|
|
8
|
+
spec.version = Falconz::VERSION
|
|
9
|
+
spec.authors = ["Kent 'picat' Gruber"]
|
|
10
|
+
spec.email = ["kgruber1@emich.edu"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Falcon Malware Sandbox APIv2 Connector}
|
|
13
|
+
#spec.description = %q{TODO: Write a longer description or delete this line.}
|
|
14
|
+
spec.homepage = "https://github.com/picatz/falconz"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
|
19
|
+
end
|
|
20
|
+
spec.bindir = "exe"
|
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
22
|
+
spec.require_paths = ["lib"]
|
|
23
|
+
|
|
24
|
+
spec.add_dependency "httparty", "~> 0.16.2"
|
|
25
|
+
|
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
29
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Falconz
|
|
2
|
+
module APIs
|
|
3
|
+
module Search
|
|
4
|
+
# summary for given hash
|
|
5
|
+
# https://www.hybrid-analysis.com/docs/api/v2#/Search/post_search_hash
|
|
6
|
+
def hash(string, **options)
|
|
7
|
+
options[:hash] = string unless string.nil?
|
|
8
|
+
raise "Requires a MD5, SHA1 or SHA256 hash" if options[:hash].nil?
|
|
9
|
+
get_request("/key/current", options)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# summary for given hashes
|
|
13
|
+
# https://www.hybrid-analysis.com/docs/api/v2#/Search/post_search_hashes
|
|
14
|
+
def hashes(*strings, **options)
|
|
15
|
+
options[:hashes] = strings unless strings.nil? or strings.empty?
|
|
16
|
+
raise "Requires MD5, SHA1 or SHA256 hashes" if options[:hashes].nil?
|
|
17
|
+
get_request("/search/hashes", options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# search the database using search terms
|
|
21
|
+
# https://www.hybrid-analysis.com/docs/api/v2#/Search/post_search_terms
|
|
22
|
+
def terms(**options)
|
|
23
|
+
get_request("/search/terms", options)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Falconz
|
|
2
|
+
module APIs
|
|
3
|
+
module Report
|
|
4
|
+
def report_state(id, **options)
|
|
5
|
+
raise "ID in one of format: ‘jobId’ or ‘sha256:environmentId’" if id.nil?
|
|
6
|
+
get_request("/report/#{id}/hash", options)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def report_summary(id, **options)
|
|
10
|
+
raise "ID in one of format: ‘jobId’ or ‘sha256:environmentId’" if id.nil?
|
|
11
|
+
get_request("/report/#{id}/hash", options)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def report_file(id, type, **options)
|
|
15
|
+
raise "ID in one of format: ‘jobId’ or ‘sha256:environmentId’" if id.nil?
|
|
16
|
+
raise "Type requirest https://www.reverse.it/docs/api/v2#/Report/get_report__id__file__type_" if type.nil?
|
|
17
|
+
get_request("/report/#{id}/file/#{type}", options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def report_sreenshots(id, **options)
|
|
21
|
+
raise "ID in one of format: ‘jobId’ or ‘sha256:environmentId’" if id.nil?
|
|
22
|
+
get_request("/report/#{id}/screenshots", options)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def report_droppedfiles(id, **options)
|
|
26
|
+
raise "ID in one of format: ‘jobId’ or ‘sha256:environmentId’" if id.nil?
|
|
27
|
+
get_request("/report/#{id}/dropped-files", options)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Falconz
|
|
2
|
+
module APIs
|
|
3
|
+
module Search
|
|
4
|
+
# summary for given hash
|
|
5
|
+
# https://www.hybrid-analysis.com/docs/api/v2#/Search/post_search_hash
|
|
6
|
+
def search_hash(string, **options)
|
|
7
|
+
raise "Requires a MD5, SHA1 or SHA256 hash" if string.nil?
|
|
8
|
+
options[:hash] = string
|
|
9
|
+
post_request("/search/hash", options)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# summary for given hashes
|
|
13
|
+
# https://www.hybrid-analysis.com/docs/api/v2#/Search/post_search_hashes
|
|
14
|
+
def search_hashes(*strings, **options)
|
|
15
|
+
raise "Requires at least one MD5, SHA1 or SHA256 hash" if strings.nil? or strings.empty?
|
|
16
|
+
options[:hashes] = strings
|
|
17
|
+
post_request("/search/hashes", options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# search the database using search terms
|
|
21
|
+
# https://www.hybrid-analysis.com/docs/api/v2#/Search/post_search_terms
|
|
22
|
+
def search_terms(**options)
|
|
23
|
+
post_request("/search/terms", options)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Falconz
|
|
2
|
+
module APIs
|
|
3
|
+
module Submission
|
|
4
|
+
# submit a local file for analysis
|
|
5
|
+
def submit_file(**options)
|
|
6
|
+
options[:file] = File.open(options[:file], "r")
|
|
7
|
+
response = post_request("/submit/file", options)
|
|
8
|
+
options[:file].close
|
|
9
|
+
return response
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# submit a file by url for analysis
|
|
13
|
+
def submit_file_by_url(**options)
|
|
14
|
+
post_request("/submit/url-to-file", options)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# submit a url for analysis
|
|
18
|
+
def submit_url(**options)
|
|
19
|
+
post_request("/submit/url-for-analysis", options)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# submit dropped file for analysis
|
|
23
|
+
def submit_dropped_file(**options)
|
|
24
|
+
post_request("/submit/dropped-file", options)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# determine a SHA256 that an online file or URL
|
|
28
|
+
# submission will have when being processed by
|
|
29
|
+
# the system. Note: this is useful when looking
|
|
30
|
+
# up URL analysis
|
|
31
|
+
def hash_from_url(**options)
|
|
32
|
+
post_request("/submit/hash-for-url", options)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
module Falconz
|
|
2
|
+
module APIs
|
|
3
|
+
module System
|
|
4
|
+
def system_heartbeat(wait = 15, **options)
|
|
5
|
+
return get_request("/system/heartbeat", options) unless block_given?
|
|
6
|
+
while true
|
|
7
|
+
yield get_request("/system/heartbeat", options)
|
|
8
|
+
sleep wait
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def number_of_seconds_since_last_update
|
|
13
|
+
system_heartbeat["number_of_seconds_since_last_update"]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def total_submissions_in_system(**options)
|
|
17
|
+
get_request("/system/total-submissions", options)["value"]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def in_progress(**options)
|
|
21
|
+
return get_request("/system/in-progress", options)["values"] unless block_given?
|
|
22
|
+
get_request("/system/in-progress", options)["values"].each do |value|
|
|
23
|
+
hash, env = value.split(":")
|
|
24
|
+
yield hash, env
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def backend(**options)
|
|
29
|
+
get_request("/system/backend", options)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def environments(**options)
|
|
33
|
+
return get_request("/system/environments", options) unless block_given?
|
|
34
|
+
get_request("/system/environments", options).each do |enviroment|
|
|
35
|
+
yield enviroment
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def number_of_environments
|
|
40
|
+
environments.count
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def find_environment_by_id(id)
|
|
44
|
+
id = id.to_i
|
|
45
|
+
environments do |env|
|
|
46
|
+
return env if env["id"] == id
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def enviroments_busy_percentages
|
|
51
|
+
envs = {}
|
|
52
|
+
environments do |env|
|
|
53
|
+
if env["busy_virtual_machines"] == 0 || env["total_virtual_machines"] == 0
|
|
54
|
+
envs[env["id"]] = 0
|
|
55
|
+
else
|
|
56
|
+
envs[env["id"]] = env["busy_virtual_machines"].to_f / env["total_virtual_machines"]
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
return envs unless block_given?
|
|
60
|
+
envs.each do |k, v|
|
|
61
|
+
yield v k
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def environment_windows?(id)
|
|
66
|
+
env = find_environment_by_id(id)
|
|
67
|
+
return nil if env.nil?
|
|
68
|
+
return true if env["architecture"] == "WINDOWS"
|
|
69
|
+
false
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def environment_linux?(id)
|
|
73
|
+
env = find_environment_by_id(id)
|
|
74
|
+
return nil if env.nil?
|
|
75
|
+
return true if env["architecture"] == "LINUX"
|
|
76
|
+
false
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def system_state(**options)
|
|
80
|
+
get_request("/system/state", options)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def system_version(**options)
|
|
84
|
+
get_request("/system/version", options)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def queue_size(**options)
|
|
88
|
+
get_request("/system/queue-size", options)["value"]
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require_relative "rest/get.rb"
|
|
2
|
+
require_relative "rest/post.rb"
|
|
3
|
+
require_relative "apis/search.rb"
|
|
4
|
+
require_relative "apis/key.rb"
|
|
5
|
+
require_relative "apis/system.rb"
|
|
6
|
+
require_relative "apis/submission.rb"
|
|
7
|
+
require_relative "apis/feed.rb"
|
|
8
|
+
|
|
9
|
+
module Falconz
|
|
10
|
+
class Client
|
|
11
|
+
include REST::GET
|
|
12
|
+
include REST::POST
|
|
13
|
+
include APIs::Key
|
|
14
|
+
include APIs::Search
|
|
15
|
+
include APIs::System
|
|
16
|
+
include APIs::Submission
|
|
17
|
+
include APIs::Feed
|
|
18
|
+
|
|
19
|
+
def initialize
|
|
20
|
+
@url = "https://www.hybrid-analysis.com/api/v2"
|
|
21
|
+
|
|
22
|
+
@header = {
|
|
23
|
+
"User-Agent" => "Falcon Sandbox",
|
|
24
|
+
"api-key" => ENV["HYBRID_ANALYSIS_API_KEY"]
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def valid_user_agent?
|
|
29
|
+
return true if @header["api-key"] && @header["User-Agent"] == "Falcon Sandbox"
|
|
30
|
+
false
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def api_key?
|
|
34
|
+
return true if @header["api-key"]
|
|
35
|
+
false
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def api_key
|
|
39
|
+
@header["api-key"]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def api_key=(k)
|
|
43
|
+
@header["api-key"] = k
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def url
|
|
47
|
+
@url
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def url=(u)
|
|
51
|
+
@url = u
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def header
|
|
55
|
+
@header
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def header=(h)
|
|
59
|
+
@header
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Falconz
|
|
2
|
+
module REST
|
|
3
|
+
module GET
|
|
4
|
+
def get_request(path, json: false, **options)
|
|
5
|
+
response = HTTParty.get(url + path, headers: header)
|
|
6
|
+
if response.success?
|
|
7
|
+
return response.body if json
|
|
8
|
+
return response
|
|
9
|
+
else
|
|
10
|
+
binding.pry
|
|
11
|
+
raise response.to_h
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Falconz
|
|
2
|
+
module REST
|
|
3
|
+
module POST
|
|
4
|
+
def post_request(path, json: false, **options)
|
|
5
|
+
response = HTTParty.post(url + path,
|
|
6
|
+
headers: header,
|
|
7
|
+
body: options)
|
|
8
|
+
if response.success?
|
|
9
|
+
return response.body if json
|
|
10
|
+
return response
|
|
11
|
+
else
|
|
12
|
+
binding.pry
|
|
13
|
+
raise response.to_h
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
data/lib/falconz.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require "httparty"
|
|
2
|
+
require "falconz/client"
|
|
3
|
+
require "falconz/version"
|
|
4
|
+
|
|
5
|
+
# Falcon Sandbox has a powerful and simple API
|
|
6
|
+
# that can be used to submit files/URLs for analysis,
|
|
7
|
+
# pull report data, but also perform advanced search
|
|
8
|
+
# queries. The API is open and free to the entire
|
|
9
|
+
# IT-security community.
|
|
10
|
+
module Falconz
|
|
11
|
+
def self.client
|
|
12
|
+
Client
|
|
13
|
+
end
|
|
14
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: falconz
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Kent 'picat' Gruber
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-04-10 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: httparty
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 0.16.2
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.16.2
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.16'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.16'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '10.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '10.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.0'
|
|
69
|
+
description:
|
|
70
|
+
email:
|
|
71
|
+
- kgruber1@emich.edu
|
|
72
|
+
executables: []
|
|
73
|
+
extensions: []
|
|
74
|
+
extra_rdoc_files: []
|
|
75
|
+
files:
|
|
76
|
+
- ".gitignore"
|
|
77
|
+
- ".rspec"
|
|
78
|
+
- ".travis.yml"
|
|
79
|
+
- CODE_OF_CONDUCT.md
|
|
80
|
+
- Gemfile
|
|
81
|
+
- Gemfile.lock
|
|
82
|
+
- LICENSE.txt
|
|
83
|
+
- README.md
|
|
84
|
+
- Rakefile
|
|
85
|
+
- bin/console
|
|
86
|
+
- bin/setup
|
|
87
|
+
- examples/debug.rb
|
|
88
|
+
- falcon.jpg
|
|
89
|
+
- falconz.gemspec
|
|
90
|
+
- lib/falconz.rb
|
|
91
|
+
- lib/falconz/apis/apis.rb
|
|
92
|
+
- lib/falconz/apis/feed.rb
|
|
93
|
+
- lib/falconz/apis/key.rb
|
|
94
|
+
- lib/falconz/apis/report.rb
|
|
95
|
+
- lib/falconz/apis/search.rb
|
|
96
|
+
- lib/falconz/apis/submission.rb
|
|
97
|
+
- lib/falconz/apis/system.rb
|
|
98
|
+
- lib/falconz/client.rb
|
|
99
|
+
- lib/falconz/rest/get.rb
|
|
100
|
+
- lib/falconz/rest/post.rb
|
|
101
|
+
- lib/falconz/version.rb
|
|
102
|
+
homepage: https://github.com/picatz/falconz
|
|
103
|
+
licenses:
|
|
104
|
+
- MIT
|
|
105
|
+
metadata: {}
|
|
106
|
+
post_install_message:
|
|
107
|
+
rdoc_options: []
|
|
108
|
+
require_paths:
|
|
109
|
+
- lib
|
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
|
+
requirements:
|
|
112
|
+
- - ">="
|
|
113
|
+
- !ruby/object:Gem::Version
|
|
114
|
+
version: '0'
|
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
|
+
requirements:
|
|
117
|
+
- - ">="
|
|
118
|
+
- !ruby/object:Gem::Version
|
|
119
|
+
version: '0'
|
|
120
|
+
requirements: []
|
|
121
|
+
rubyforge_project:
|
|
122
|
+
rubygems_version: 2.6.12
|
|
123
|
+
signing_key:
|
|
124
|
+
specification_version: 4
|
|
125
|
+
summary: Falcon Malware Sandbox APIv2 Connector
|
|
126
|
+
test_files: []
|