onyphe 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +15 -68
- data/lib/onyphe.rb +4 -17
- data/lib/onyphe/api.rb +12 -72
- data/lib/onyphe/client.rb +2 -1
- data/lib/onyphe/clients/alert.rb +3 -3
- data/lib/onyphe/clients/resolver.rb +15 -0
- data/lib/onyphe/clients/search.rb +3 -49
- data/lib/onyphe/clients/simple.rb +67 -0
- data/lib/onyphe/clients/summary.rb +19 -0
- data/lib/onyphe/version.rb +1 -1
- data/onyphe.gemspec +2 -5
- metadata +11 -54
- data/.solargraph.yml +0 -11
- data/exe/onyphe +0 -8
- data/lib/onyphe/cli.rb +0 -89
- data/lib/onyphe/clients/ctl.rb +0 -13
- data/lib/onyphe/clients/datascan.rb +0 -14
- data/lib/onyphe/clients/forward.rb +0 -13
- data/lib/onyphe/clients/geoloc.rb +0 -13
- data/lib/onyphe/clients/inetnum.rb +0 -13
- data/lib/onyphe/clients/ip.rb +0 -13
- data/lib/onyphe/clients/md5.rb +0 -13
- data/lib/onyphe/clients/onionscan.rb +0 -13
- data/lib/onyphe/clients/pastries.rb +0 -13
- data/lib/onyphe/clients/reverse.rb +0 -13
- data/lib/onyphe/clients/sniffer.rb +0 -13
- data/lib/onyphe/clients/synscan.rb +0 -13
- data/lib/onyphe/clients/threatlist.rb +0 -13
- data/lib/onyphe/validator.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fad6434144492c274cbaffb947b51a0e3e4fa1a1fa4bc1faad177a15a01aafff
|
4
|
+
data.tar.gz: a832efbcdab7040004013bbb31e4dddda3c858fd8ad09f8488d6ea3c6dc55d68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f85af0c0040f8eea8f6060e7b42faa233005b07be869427cbc5996a847575cb7e8df9316e3cd2d6fd1a5c3c6c2f505b2dfae058e50162339536d4d5c518449d
|
7
|
+
data.tar.gz: e556b7a8bf25ac787b92bf7b5c91e3bca1e3c68e704b8e77ed1d909b5afe4aad78af7cb5080fe385fbbcc253e0b1943f56cd39e1bb01f0e2a22617c9f4ff236e
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# Onyphe-rb
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/onyphe.svg)](https://badge.fury.io/rb/onyphe)
|
4
|
-
[![Build Status](https://travis-ci.
|
4
|
+
[![Build Status](https://travis-ci.com/ninoseki/onyphe-rb.svg?branch=master)](https://travis-ci.com/ninoseki/onyphe-rb)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/github/ninoseki/onyphe-rb/badge.svg?branch=master)](https://coveralls.io/github/ninoseki/onyphe-rb?branch=master)
|
6
6
|
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c4afca9e0ff94d11a53332c0598b868f)](https://www.codacy.com/app/ninoseki/onyphe-rb)
|
7
7
|
|
8
|
-
[Onyphe](https://www.onyphe.io) API wrapper for Ruby.
|
8
|
+
[Onyphe](https://www.onyphe.io) v2 API wrapper for Ruby.
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
@@ -35,39 +35,14 @@ api = Onyphe::API.new
|
|
35
35
|
# or you can pass your API key as an argument
|
36
36
|
api = Onyphe::API.new(YOUR_API_KEY)
|
37
37
|
|
38
|
-
api.
|
39
|
-
api.
|
40
|
-
api.
|
41
|
-
|
42
|
-
api.
|
43
|
-
api.
|
44
|
-
|
45
|
-
api.
|
46
|
-
api.pastries("1.1.1.1")
|
47
|
-
api.reverse("1.1.1.1")
|
48
|
-
api.sniffer("1.1.1.1")
|
49
|
-
api.synscan("1.1.1.1")
|
50
|
-
api.threatlist("1.1.1.1")
|
51
|
-
|
52
|
-
api.search.datascan(
|
53
|
-
os: "Windows",
|
54
|
-
port: 443,
|
55
|
-
product: "HTTP Server",
|
56
|
-
tls: true
|
57
|
-
)
|
58
|
-
api.search.synscan(
|
59
|
-
country: "FR",
|
60
|
-
port: 23,
|
61
|
-
tag: "mirai"
|
62
|
-
)
|
63
|
-
|
64
|
-
api.search.inetnum(organization: "OVH SAS")
|
65
|
-
api.search.threatlist(country: "RU")
|
66
|
-
api.search.pastries(content: "hacked")
|
67
|
-
api.search.resolver(ip: "124.108.0.0/16")
|
68
|
-
api.search.sniffer(ip: "14.164.0.0/14")
|
69
|
-
api.search.ctl(host: "vpn")
|
70
|
-
api.search.onionscan("app.http.keywords": "dump")
|
38
|
+
api.summary.ip("1.1.1.1")
|
39
|
+
api.summary.domain("example.com")
|
40
|
+
api.summary.hostname("example.com")
|
41
|
+
|
42
|
+
api.simple.geoloc("1.1.1.1")
|
43
|
+
api.simple.ctl("example.com")
|
44
|
+
|
45
|
+
api.search("category:datascan product:Nginx protocol:http os:Windows tls:true")
|
71
46
|
|
72
47
|
api.alert.list
|
73
48
|
api.alert.add(name: "foo", query:"bar", email: "foo@bar.com")
|
@@ -81,43 +56,15 @@ Enumerable style pagination is not supported at the present time.
|
|
81
56
|
You can specify page index by passing `page` argument to the method.
|
82
57
|
|
83
58
|
```rb
|
84
|
-
res = api.
|
85
|
-
page = res.page
|
86
|
-
max_page = res.max_page
|
59
|
+
res = api.simple.threatlist(country: "RU", page: 1)
|
60
|
+
page = res.dig("page")
|
61
|
+
max_page = res.dig("max_page")
|
87
62
|
|
88
|
-
((page + 1)..max_page).each do |
|
89
|
-
res = api.
|
63
|
+
((page + 1)..max_page).each do |index|
|
64
|
+
res = api.simple.threatlist({ country: "RU" }, page = index)
|
90
65
|
end
|
91
66
|
```
|
92
67
|
|
93
|
-
### As a CLI tool
|
94
|
-
|
95
|
-
Note: make sure that your API key is set as an environment variable `ONYPHE_API_KEY` before using the CLI tool.
|
96
|
-
|
97
|
-
```sh
|
98
|
-
$ onyphe
|
99
|
-
Commands:
|
100
|
-
onyphe ctl DOMAIN # It will return information for the given domain name X509 certificate information from CTLs with history of changes
|
101
|
-
onyphe datascan IP/STRING # It will return datascan information for the given IPv{4,6} address or string with history of changes
|
102
|
-
onyphe forward IP # It will return forward DNS lookup information for the given IPv{4,6} address with history of changes
|
103
|
-
onyphe geoloc IP # It will return geolocation information for the given IPv{4,6} address
|
104
|
-
onyphe help [COMMAND] # Describe available commands or one specific command
|
105
|
-
onyphe inetnum IP # It will return inetnum information for the given IPv{4,6} address with history of changes
|
106
|
-
onyphe ip IP # It will return a summary of all information for the given IPv{4,6} address
|
107
|
-
onyphe md5 MD5 # It will return information for the given datamd5 filter from datascan information category with history of changes
|
108
|
-
onyphe onionscan ONION # It will return information for the given onion domain with history of changes
|
109
|
-
onyphe pastries IP # It will return pastries information for the given IPv{4,6} address with history of changes
|
110
|
-
onyphe reverse IP # It will return reverse DNS lookup information for the given IPv{4,6} address with history of changes
|
111
|
-
onyphe sniffer IP # It will return information for the given IP address with history of changes
|
112
|
-
onyphe synscan IP # It will return synscan information for the given IPv{4,6} address with history of changes.
|
113
|
-
onyphe threattlist IP # It will return threatlist information for the given IPv{4,6} address with history of change
|
114
|
-
```
|
115
|
-
|
116
|
-
```sh
|
117
|
-
$ onyphe geoloc 1.1.1.1
|
118
|
-
{"count":1,"error":0,"myip":"x.x.x.x","results":[{"@category":"geoloc","@timestamp":"2018-11-18T00:15:50.000Z","@type":"doc","asn":"AS13335","city":"","country":"AU","ip":"1.1.1.1","ipv6":"false","latitude":"-33.4940","location":"-33.4940,143.2104","longitude":"143.2104","organization":"Cloudflare, Inc.","subnet":"1.1.1.0/24"}],"status":"ok","took":"0.000","total":1}
|
119
|
-
```
|
120
|
-
|
121
68
|
## Contributing
|
122
69
|
|
123
70
|
Bug reports and pull requests are welcome on GitHub at https://github.com/nioseki/onyphe.
|
data/lib/onyphe.rb
CHANGED
@@ -2,26 +2,13 @@
|
|
2
2
|
|
3
3
|
require "onyphe/api"
|
4
4
|
|
5
|
-
require "onyphe/validator"
|
6
|
-
|
7
5
|
require "onyphe/client"
|
6
|
+
|
8
7
|
require "onyphe/clients/alert"
|
9
|
-
require "onyphe/clients/
|
10
|
-
require "onyphe/clients/datascan"
|
11
|
-
require "onyphe/clients/forward"
|
12
|
-
require "onyphe/clients/geoloc"
|
13
|
-
require "onyphe/clients/inetnum"
|
14
|
-
require "onyphe/clients/ip"
|
15
|
-
require "onyphe/clients/md5"
|
16
|
-
require "onyphe/clients/onionscan"
|
17
|
-
require "onyphe/clients/pastries"
|
18
|
-
require "onyphe/clients/reverse"
|
19
|
-
require "onyphe/clients/sniffer"
|
20
|
-
require "onyphe/clients/synscan"
|
21
|
-
require "onyphe/clients/threatlist"
|
8
|
+
require "onyphe/clients/resolver"
|
22
9
|
require "onyphe/clients/search"
|
23
|
-
|
24
|
-
require "onyphe/
|
10
|
+
require "onyphe/clients/simple"
|
11
|
+
require "onyphe/clients/summary"
|
25
12
|
|
26
13
|
require "onyphe/version"
|
27
14
|
|
data/lib/onyphe/api.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "forwardable"
|
4
|
-
|
5
3
|
module Onyphe
|
6
4
|
class API
|
7
|
-
extend Forwardable
|
8
|
-
|
9
|
-
attr_reader :api_key
|
10
|
-
|
11
5
|
#
|
12
6
|
# API client initialization
|
13
7
|
#
|
@@ -15,83 +9,29 @@ module Onyphe
|
|
15
9
|
#
|
16
10
|
def initialize(api_key = ENV["ONYPHE_API_KEY"])
|
17
11
|
@api_key = api_key
|
18
|
-
raise ArgumentError, "'api_key' argument is required" unless api_key
|
19
|
-
end
|
20
|
-
|
21
|
-
def search
|
22
|
-
@search ||= Clients::Search.new(api_key)
|
23
|
-
end
|
24
|
-
|
25
|
-
def alert
|
26
|
-
@alert ||= Clients::Alert.new(api_key)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def _ctl
|
32
|
-
@_ctl ||= Clients::Ctl.new(api_key)
|
33
|
-
end
|
34
|
-
|
35
|
-
def _datascan
|
36
|
-
@_datascan ||= Clients::Datascan.new(api_key)
|
12
|
+
raise ArgumentError, "'api_key' argument is required" unless @api_key
|
37
13
|
end
|
38
14
|
|
39
|
-
def
|
40
|
-
@
|
15
|
+
def summary
|
16
|
+
@summary ||= Clients::Summary.new(@api_key)
|
41
17
|
end
|
42
18
|
|
43
|
-
def
|
44
|
-
@
|
19
|
+
def simple
|
20
|
+
@simple ||= Clients::Simple.new(@api_key)
|
45
21
|
end
|
46
22
|
|
47
|
-
def
|
48
|
-
@
|
49
|
-
end
|
50
|
-
|
51
|
-
def _ip
|
52
|
-
@_ip ||= Clients::IP.new(api_key)
|
53
|
-
end
|
54
|
-
|
55
|
-
def _md5
|
56
|
-
@_md5 ||= Clients::MD5.new(api_key)
|
57
|
-
end
|
58
|
-
|
59
|
-
def _onionscan
|
60
|
-
@_onionscan ||= Clients::Onionscan.new(api_key)
|
61
|
-
end
|
62
|
-
|
63
|
-
def _pastries
|
64
|
-
@_pastries ||= Clients::Pastries.new(api_key)
|
65
|
-
end
|
66
|
-
|
67
|
-
def _reverse
|
68
|
-
@_reverse ||= Clients::Reverse.new(api_key)
|
23
|
+
def alert
|
24
|
+
@alert ||= Clients::Alert.new(@api_key)
|
69
25
|
end
|
70
26
|
|
71
|
-
def
|
72
|
-
|
27
|
+
def search(oql)
|
28
|
+
_search.search(oql)
|
73
29
|
end
|
74
30
|
|
75
|
-
|
76
|
-
@_synscan ||= Clients::Synscan.new(api_key)
|
77
|
-
end
|
31
|
+
private
|
78
32
|
|
79
|
-
def
|
80
|
-
@
|
33
|
+
def _search
|
34
|
+
@_search ||= Clients::Search.new(@api_key)
|
81
35
|
end
|
82
|
-
|
83
|
-
def_delegator :_ctl, :get_by_domain, :ctl
|
84
|
-
def_delegator :_datascan, :get_by_query, :datascan
|
85
|
-
def_delegator :_forward, :get_by_ip, :forward
|
86
|
-
def_delegator :_geoloc, :get_by_ip, :geoloc
|
87
|
-
def_delegator :_inetnum, :get_by_ip, :inetnum
|
88
|
-
def_delegator :_ip, :get_by_ip, :ip
|
89
|
-
def_delegator :_md5, :get_by_md5, :md5
|
90
|
-
def_delegator :_onionscan, :get_by_onion, :onionscan
|
91
|
-
def_delegator :_pastries, :get_by_ip, :pastries
|
92
|
-
def_delegator :_reverse, :get_by_ip, :reverse
|
93
|
-
def_delegator :_sniffer, :get_by_ip, :sniffer
|
94
|
-
def_delegator :_synscan, :get_by_ip, :synscan
|
95
|
-
def_delegator :_threatlist, :get_by_ip, :threatlist
|
96
36
|
end
|
97
37
|
end
|
data/lib/onyphe/client.rb
CHANGED
data/lib/onyphe/clients/alert.rb
CHANGED
@@ -4,7 +4,7 @@ module Onyphe
|
|
4
4
|
module Clients
|
5
5
|
class Alert < Client
|
6
6
|
def list
|
7
|
-
get("/
|
7
|
+
get("/alert/list") { |json| json }
|
8
8
|
end
|
9
9
|
|
10
10
|
def add(name:, query:, email:)
|
@@ -13,11 +13,11 @@ module Onyphe
|
|
13
13
|
query: query,
|
14
14
|
email: email
|
15
15
|
}
|
16
|
-
post("/
|
16
|
+
post("/alert/add", params) { |json| json }
|
17
17
|
end
|
18
18
|
|
19
19
|
def delete(id)
|
20
|
-
post("/
|
20
|
+
post("/alert/del/#{id}") { |json| json }
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Onyphe
|
4
|
+
module Clients
|
5
|
+
class Resolver < Client
|
6
|
+
def forward(ip, page: 1)
|
7
|
+
get("/simple/resolver/forward/#{ip}", page: page) { |json| json }
|
8
|
+
end
|
9
|
+
|
10
|
+
def reverse(ip, page: 1)
|
11
|
+
get("/simple/resolver/reverse/#{ip}", page: page) { |json| json }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -5,55 +5,9 @@ require "addressable/uri"
|
|
5
5
|
module Onyphe
|
6
6
|
module Clients
|
7
7
|
class Search < Client
|
8
|
-
def
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def synscan(params, page: 1)
|
13
|
-
search("synscan", params, page)
|
14
|
-
end
|
15
|
-
|
16
|
-
def inetnum(params, page: 1)
|
17
|
-
search("inetnum", params, page)
|
18
|
-
end
|
19
|
-
|
20
|
-
def threatlist(params, page: 1)
|
21
|
-
search("threatlist", params, page)
|
22
|
-
end
|
23
|
-
|
24
|
-
def pastries(params, page: 1)
|
25
|
-
search("pastries", params, page)
|
26
|
-
end
|
27
|
-
|
28
|
-
def resolver(params, page: 1)
|
29
|
-
search("resolver", params, page)
|
30
|
-
end
|
31
|
-
|
32
|
-
def sniffer(params, page: 1)
|
33
|
-
search("sniffer", params, page)
|
34
|
-
end
|
35
|
-
|
36
|
-
def ctl(params, page: 1)
|
37
|
-
search("ctl", params, page)
|
38
|
-
end
|
39
|
-
|
40
|
-
def onionscan(params, page: 1)
|
41
|
-
search("onionscan", params, page)
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def search(type, params, page)
|
47
|
-
get("/search/#{type}/#{params_to_uri_string(params)}", page: page) { |json| json }
|
48
|
-
end
|
49
|
-
|
50
|
-
def params_to_uri_string(params)
|
51
|
-
s = params.map do |k, v|
|
52
|
-
v = "\"#{v}\"" if v.to_s.include? " "
|
53
|
-
[k, v].join(":")
|
54
|
-
end.join(" ")
|
55
|
-
|
56
|
-
Addressable::URI.encode s
|
8
|
+
def search(oql, page: 1)
|
9
|
+
path = Addressable::URI.encode(oql)
|
10
|
+
get("/search/#{path}", page: page) { |json| json }
|
57
11
|
end
|
58
12
|
end
|
59
13
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Onyphe
|
4
|
+
module Clients
|
5
|
+
class Simple < Client
|
6
|
+
def geoloc(ip, page: 1)
|
7
|
+
get("/simple/geoloc/#{ip}", page: page) { |json| json }
|
8
|
+
end
|
9
|
+
|
10
|
+
def inetnum(ip, page: 1)
|
11
|
+
get("/simple/inetnum/#{ip}", page: page) { |json| json }
|
12
|
+
end
|
13
|
+
|
14
|
+
def pastries(ip, page: 1)
|
15
|
+
get("/simple/pastries/#{ip}", page: page) { |json| json }
|
16
|
+
end
|
17
|
+
|
18
|
+
def resolver(ip, page: 1)
|
19
|
+
get("/simple/resolver/#{ip}", page: page) { |json| json }
|
20
|
+
end
|
21
|
+
|
22
|
+
def sniffer(ip, page: 1)
|
23
|
+
get("/simple/sniffer/#{ip}", page: page) { |json| json }
|
24
|
+
end
|
25
|
+
|
26
|
+
def synscan(ip, page: 1)
|
27
|
+
get("/simple/synscan/#{ip}", page: page) { |json| json }
|
28
|
+
end
|
29
|
+
|
30
|
+
def threatlist(ip, page: 1)
|
31
|
+
get("/simple/threatlist/#{ip}", page: page) { |json| json }
|
32
|
+
end
|
33
|
+
|
34
|
+
def topsite(ip, page: 1)
|
35
|
+
get("/simple/topsite/#{ip}", page: page) { |json| json }
|
36
|
+
end
|
37
|
+
|
38
|
+
def vulnscan(ip, page: 1)
|
39
|
+
get("/simple/vulnscan/#{ip}", page: page) { |json| json }
|
40
|
+
end
|
41
|
+
|
42
|
+
def onionshot(ip, page: 1)
|
43
|
+
get("/simple/onionshot/#{ip}", page: page) { |json| json }
|
44
|
+
end
|
45
|
+
|
46
|
+
def datashot(ip, page: 1)
|
47
|
+
get("/simple/datasnot/#{ip}", page: page) { |json| json }
|
48
|
+
end
|
49
|
+
|
50
|
+
def ctl(hostname, page: 1)
|
51
|
+
get("/simple/ctl/#{hostname}", page: page) { |json| json }
|
52
|
+
end
|
53
|
+
|
54
|
+
def onionscan(hostname, page: 1)
|
55
|
+
get("/simple/onionscan/#{hostname}", page: page) { |json| json }
|
56
|
+
end
|
57
|
+
|
58
|
+
def datascan(hostname, page: 1)
|
59
|
+
get("/simple/datascan/#{hostname}", page: page) { |json| json }
|
60
|
+
end
|
61
|
+
|
62
|
+
def datamd5(md5, page: 1)
|
63
|
+
get("/simple/datascan/datamd5/#{md5}", page: page) { |json| json }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Onyphe
|
4
|
+
module Clients
|
5
|
+
class Summary < Client
|
6
|
+
def ip(ip)
|
7
|
+
get("/summary/ip/#{ip}") { |json| json }
|
8
|
+
end
|
9
|
+
|
10
|
+
def domain(domain)
|
11
|
+
get("/summary/domain/#{domain}") { |json| json }
|
12
|
+
end
|
13
|
+
|
14
|
+
def hostname(hostname)
|
15
|
+
get("/summary/hostname/#{hostname}") { |json| json }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/onyphe/version.rb
CHANGED
data/onyphe.gemspec
CHANGED
@@ -24,13 +24,10 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
25
|
spec.require_paths = ["lib"]
|
26
26
|
|
27
|
-
spec.add_dependency "addressable", "~> 2.7"
|
28
|
-
spec.add_dependency "thor", "~> 1.0"
|
29
|
-
|
30
27
|
spec.add_development_dependency "bundler", "~> 2.1"
|
31
28
|
spec.add_development_dependency "coveralls", "~> 0.8"
|
32
29
|
spec.add_development_dependency "rake", "~> 13.0"
|
33
30
|
spec.add_development_dependency "rspec", "~> 3.9"
|
34
|
-
spec.add_development_dependency "vcr", "~> 5.
|
35
|
-
spec.add_development_dependency "webmock", "~> 3.
|
31
|
+
spec.add_development_dependency "vcr", "~> 5.1"
|
32
|
+
spec.add_development_dependency "webmock", "~> 3.8"
|
36
33
|
end
|
metadata
CHANGED
@@ -1,43 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onyphe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manabu Niseki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: addressable
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.7'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.7'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: thor
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.0'
|
41
13
|
- !ruby/object:Gem::Dependency
|
42
14
|
name: bundler
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,39 +72,37 @@ dependencies:
|
|
100
72
|
requirements:
|
101
73
|
- - "~>"
|
102
74
|
- !ruby/object:Gem::Version
|
103
|
-
version: '5.
|
75
|
+
version: '5.1'
|
104
76
|
type: :development
|
105
77
|
prerelease: false
|
106
78
|
version_requirements: !ruby/object:Gem::Requirement
|
107
79
|
requirements:
|
108
80
|
- - "~>"
|
109
81
|
- !ruby/object:Gem::Version
|
110
|
-
version: '5.
|
82
|
+
version: '5.1'
|
111
83
|
- !ruby/object:Gem::Dependency
|
112
84
|
name: webmock
|
113
85
|
requirement: !ruby/object:Gem::Requirement
|
114
86
|
requirements:
|
115
87
|
- - "~>"
|
116
88
|
- !ruby/object:Gem::Version
|
117
|
-
version: '3.
|
89
|
+
version: '3.8'
|
118
90
|
type: :development
|
119
91
|
prerelease: false
|
120
92
|
version_requirements: !ruby/object:Gem::Requirement
|
121
93
|
requirements:
|
122
94
|
- - "~>"
|
123
95
|
- !ruby/object:Gem::Version
|
124
|
-
version: '3.
|
96
|
+
version: '3.8'
|
125
97
|
description: ONYPHE API wrapper for Ruby
|
126
98
|
email:
|
127
99
|
- manabu.niseki@gmail.com
|
128
|
-
executables:
|
129
|
-
- onyphe
|
100
|
+
executables: []
|
130
101
|
extensions: []
|
131
102
|
extra_rdoc_files: []
|
132
103
|
files:
|
133
104
|
- ".gitignore"
|
134
105
|
- ".rspec"
|
135
|
-
- ".solargraph.yml"
|
136
106
|
- ".travis.yml"
|
137
107
|
- Gemfile
|
138
108
|
- LICENSE
|
@@ -140,27 +110,14 @@ files:
|
|
140
110
|
- Rakefile
|
141
111
|
- bin/console
|
142
112
|
- bin/setup
|
143
|
-
- exe/onyphe
|
144
113
|
- lib/onyphe.rb
|
145
114
|
- lib/onyphe/api.rb
|
146
|
-
- lib/onyphe/cli.rb
|
147
115
|
- lib/onyphe/client.rb
|
148
116
|
- lib/onyphe/clients/alert.rb
|
149
|
-
- lib/onyphe/clients/
|
150
|
-
- lib/onyphe/clients/datascan.rb
|
151
|
-
- lib/onyphe/clients/forward.rb
|
152
|
-
- lib/onyphe/clients/geoloc.rb
|
153
|
-
- lib/onyphe/clients/inetnum.rb
|
154
|
-
- lib/onyphe/clients/ip.rb
|
155
|
-
- lib/onyphe/clients/md5.rb
|
156
|
-
- lib/onyphe/clients/onionscan.rb
|
157
|
-
- lib/onyphe/clients/pastries.rb
|
158
|
-
- lib/onyphe/clients/reverse.rb
|
117
|
+
- lib/onyphe/clients/resolver.rb
|
159
118
|
- lib/onyphe/clients/search.rb
|
160
|
-
- lib/onyphe/clients/
|
161
|
-
- lib/onyphe/clients/
|
162
|
-
- lib/onyphe/clients/threatlist.rb
|
163
|
-
- lib/onyphe/validator.rb
|
119
|
+
- lib/onyphe/clients/simple.rb
|
120
|
+
- lib/onyphe/clients/summary.rb
|
164
121
|
- lib/onyphe/version.rb
|
165
122
|
- onyphe.gemspec
|
166
123
|
homepage: https://github.com/ninoseki/onyphe-rb
|
@@ -182,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
139
|
- !ruby/object:Gem::Version
|
183
140
|
version: '0'
|
184
141
|
requirements: []
|
185
|
-
rubygems_version: 3.
|
142
|
+
rubygems_version: 3.1.2
|
186
143
|
signing_key:
|
187
144
|
specification_version: 4
|
188
145
|
summary: ONYPHE API wrapper for Ruby
|
data/.solargraph.yml
DELETED
data/exe/onyphe
DELETED
data/lib/onyphe/cli.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "json"
|
4
|
-
require "thor"
|
5
|
-
|
6
|
-
module Onyphe
|
7
|
-
class CLI < Thor
|
8
|
-
desc "ctl DOMAIN", "It will return information for the given domain name X509 certificate information from CTLs with history of changes"
|
9
|
-
def ctl(domain)
|
10
|
-
with_error_handling { puts api.ctl(domain).to_json }
|
11
|
-
end
|
12
|
-
|
13
|
-
desc "datascan IP/STRING", "It will return datascan information for the given IPv{4,6} address or string with history of changes"
|
14
|
-
def datascan(query)
|
15
|
-
with_error_handling { puts api.datascan(query).to_json }
|
16
|
-
end
|
17
|
-
|
18
|
-
desc "forward IP", "It will return forward DNS lookup information for the given IPv{4,6} address with history of changes"
|
19
|
-
def forward(ip)
|
20
|
-
with_error_handling { puts api.forward(ip).to_json }
|
21
|
-
end
|
22
|
-
|
23
|
-
desc "geoloc IP", "It will return geolocation information for the given IPv{4,6} address"
|
24
|
-
def geoloc(ip)
|
25
|
-
with_error_handling { puts api.geoloc(ip).to_json }
|
26
|
-
end
|
27
|
-
|
28
|
-
desc "inetnum IP", "It will return inetnum information for the given IPv{4,6} address with history of changes"
|
29
|
-
def inetnum(ip)
|
30
|
-
with_error_handling { puts api.inetnum(ip).to_json }
|
31
|
-
end
|
32
|
-
|
33
|
-
desc "ip IP", "It will return a summary of all information for the given IPv{4,6} address"
|
34
|
-
def ip(ip)
|
35
|
-
with_error_handling { puts api.ip(ip).to_json }
|
36
|
-
end
|
37
|
-
|
38
|
-
desc "md5 MD5", "It will return information for the given datamd5 filter from datascan information category with history of changes"
|
39
|
-
def md5(md5)
|
40
|
-
with_error_handling { puts api.md5(md5).to_json }
|
41
|
-
end
|
42
|
-
|
43
|
-
desc "onionscan ONION", "It will return information for the given onion domain with history of changes"
|
44
|
-
def onionscan(onion)
|
45
|
-
with_error_handling { puts api.onionscan(onion).to_json }
|
46
|
-
end
|
47
|
-
|
48
|
-
desc "pastries IP", "It will return pastries information for the given IPv{4,6} address with history of changes"
|
49
|
-
def pastries(ip)
|
50
|
-
with_error_handling { puts api.pastries(ip).to_json }
|
51
|
-
end
|
52
|
-
|
53
|
-
desc "reverse IP", "It will return reverse DNS lookup information for the given IPv{4,6} address with history of changes"
|
54
|
-
def reverse(ip)
|
55
|
-
with_error_handling { puts api.reverse(ip).to_json }
|
56
|
-
end
|
57
|
-
|
58
|
-
desc "sniffer IP", "It will return information for the given IP address with history of changes"
|
59
|
-
def sniffer(ip)
|
60
|
-
with_error_handling { puts api.sniffer(ip).to_json }
|
61
|
-
end
|
62
|
-
|
63
|
-
desc "synscan IP", "It will return synscan information for the given IPv{4,6} address with history of changes."
|
64
|
-
def synscan(ip)
|
65
|
-
with_error_handling { puts api.synscan(ip).to_json }
|
66
|
-
end
|
67
|
-
|
68
|
-
desc "threattlist IP", "It will return threatlist information for the given IPv{4,6} address with history of change"
|
69
|
-
def threatlist(ip)
|
70
|
-
with_error_handling { puts api.threatlist(ip).to_json }
|
71
|
-
end
|
72
|
-
|
73
|
-
no_commands do
|
74
|
-
def with_error_handling
|
75
|
-
yield
|
76
|
-
rescue StandardError => e
|
77
|
-
if e.to_s == "'api_key' argument is required"
|
78
|
-
puts "Please set your API key as an environment variable `ONYPHE_API_KEY`"
|
79
|
-
else
|
80
|
-
puts "Warning: #{e}"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def api
|
85
|
-
@api ||= API.new
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
data/lib/onyphe/clients/ctl.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Onyphe
|
4
|
-
module Clients
|
5
|
-
class Ctl < Client
|
6
|
-
def get_by_domain(domain, page: 1)
|
7
|
-
raise ArgumentError, "Invalid domain: #{domain}" unless Validator.valid_domain?(domain)
|
8
|
-
|
9
|
-
get("/ctl/#{domain}", page: page) { |json| json }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "addressable/uri"
|
4
|
-
|
5
|
-
module Onyphe
|
6
|
-
module Clients
|
7
|
-
class Datascan < Client
|
8
|
-
def get_by_query(query, page: 1)
|
9
|
-
query = Addressable::URI.encode(query)
|
10
|
-
get("/datascan/#{query}", page: page) { |json| json }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Onyphe
|
4
|
-
module Clients
|
5
|
-
class Forward < Client
|
6
|
-
def get_by_ip(ip, page: 1)
|
7
|
-
raise ArgumentError, "Invalid IP address: #{ip}" unless Validator.valid_ip?(ip)
|
8
|
-
|
9
|
-
get("/forward/#{ip}", page: page) { |json| json }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Onyphe
|
4
|
-
module Clients
|
5
|
-
class Geoloc < Client
|
6
|
-
def get_by_ip(ip, page: 1)
|
7
|
-
raise ArgumentError, "Invalid IP address: #{ip}" unless Validator.valid_ip?(ip)
|
8
|
-
|
9
|
-
get("/geoloc/#{ip}", page: page) { |json| json }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Onyphe
|
4
|
-
module Clients
|
5
|
-
class Inetnum < Client
|
6
|
-
def get_by_ip(ip, page: 1)
|
7
|
-
raise ArgumentError, "Invalid IP address: #{ip}" unless Validator.valid_ip?(ip)
|
8
|
-
|
9
|
-
get("/inetnum/#{ip}", page: page) { |json| json }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/lib/onyphe/clients/ip.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Onyphe
|
4
|
-
module Clients
|
5
|
-
class IP < Client
|
6
|
-
def get_by_ip(ip, page: 1)
|
7
|
-
raise ArgumentError, "Invalid IP address: #{ip}" unless Validator.valid_ip?(ip)
|
8
|
-
|
9
|
-
get("/ip/#{ip}", page: page) { |json| json }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/lib/onyphe/clients/md5.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Onyphe
|
4
|
-
module Clients
|
5
|
-
class MD5 < Client
|
6
|
-
def get_by_md5(md5, page: 1)
|
7
|
-
raise ArgumentError, "Invalid md5: #{md5}" unless Validator.valid_md5?(md5)
|
8
|
-
|
9
|
-
get("/md5/#{md5}", page: page) { |json| json }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Onyphe
|
4
|
-
module Clients
|
5
|
-
class Onionscan < Client
|
6
|
-
def get_by_onion(onion, page: 1)
|
7
|
-
raise ArgumentError, "Invalid oninon domain: #{onion}" unless Validator.valid_onion_domain?(onion)
|
8
|
-
|
9
|
-
get("/onionscan/#{onion}", page: page) { |json| json }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Onyphe
|
4
|
-
module Clients
|
5
|
-
class Pastries < Client
|
6
|
-
def get_by_ip(ip, page: 1)
|
7
|
-
raise ArgumentError, "Invalid IP address: #{ip}" unless Validator.valid_ip?(ip)
|
8
|
-
|
9
|
-
get("/pastries/#{ip}", page: page) { |json| json }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Onyphe
|
4
|
-
module Clients
|
5
|
-
class Reverse < Client
|
6
|
-
def get_by_ip(ip, page: 1)
|
7
|
-
raise ArgumentError, "Invalid IP address: #{ip}" unless Validator.valid_ip?(ip)
|
8
|
-
|
9
|
-
get("/reverse/#{ip}", page: page) { |json| json }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Onyphe
|
4
|
-
module Clients
|
5
|
-
class Sniffer < Client
|
6
|
-
def get_by_ip(ip, page: 1)
|
7
|
-
raise ArgumentError, "Invalid IP address: #{ip}" unless Validator.valid_ip?(ip)
|
8
|
-
|
9
|
-
get("/sniffer/#{ip}", page: page) { |json| json }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Onyphe
|
4
|
-
module Clients
|
5
|
-
class Synscan < Client
|
6
|
-
def get_by_ip(ip, page: 1)
|
7
|
-
raise ArgumentError, "Invalid IP address: #{ip}" unless Validator.valid_ip?(ip)
|
8
|
-
|
9
|
-
get("/synscan/#{ip}", page: page) { |json| json }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Onyphe
|
4
|
-
module Clients
|
5
|
-
class Threatlist < Client
|
6
|
-
def get_by_ip(ip, page: 1)
|
7
|
-
raise ArgumentError, "Invalid IP address: #{ip}" unless Validator.valid_ip?(ip)
|
8
|
-
|
9
|
-
get("/threatlist/#{ip}", page: page) { |json| json }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/lib/onyphe/validator.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "ipaddr"
|
4
|
-
require "uri"
|
5
|
-
|
6
|
-
module Onyphe
|
7
|
-
class Validator
|
8
|
-
def self.valid_ip?(ip)
|
9
|
-
IPAddr.new ip
|
10
|
-
true
|
11
|
-
rescue IPAddr::InvalidAddressError => _e
|
12
|
-
false
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.valid_domain?(domain)
|
16
|
-
uri = URI("https://#{domain}")
|
17
|
-
uri.hostname == domain && domain.include?(".") && !valid_ip?(domain)
|
18
|
-
rescue ArgumentError => _e
|
19
|
-
false
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.valid_onion_domain?(domain)
|
23
|
-
uri = URI("https://#{domain}")
|
24
|
-
uri.hostname == domain && domain.end_with?(".onion")
|
25
|
-
rescue ArgumentError => _e
|
26
|
-
false
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.valid_md5?(md5)
|
30
|
-
md5.to_s.match?(/^[a-f0-9]{32}$/)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|