fushin 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45e5e429220ee4897053cd2cf732ccf3423b0d5aab53423f8aec57549a0a240e
4
- data.tar.gz: 072a988d06cca8c2f211767a1ea4dda589282ea630cabc3b6e41afde3dfe2097
3
+ metadata.gz: 2886480988a7953bf20c22ffd1ab3590926c5121700b2aaf007bebe3c93438fd
4
+ data.tar.gz: abbf709568fc79ff6d57aee267d0cf4b3875a783410b2594a40430126c734db1
5
5
  SHA512:
6
- metadata.gz: 51c711d46af5097f286d9a218a54dffa60ed378e19f5ec4fdf6570994499c760ed48e273672e6ded1eaa9c3740f91f3c927d634b306964ede4788e1cebf2d119
7
- data.tar.gz: 6beb9229082f2233c50cc62c23098a5d20fee1b2bca5d04725f397412861e05cae273d2932cbffd8a1eb040053d282b66e69a122015232af8edfb58006ed11d3
6
+ metadata.gz: '098de7ee37619d0403ed2f94bebad99e740bbbeb358fd364247a3f9990cebab816d16974188f70d35500d4c0d09ab1b128b492278c162a5306c030e5c6d4840e'
7
+ data.tar.gz: 9bb31068ef6d71371ae3fb6507f18fc8f49bb4de02c4703f8691e60fdbdcc412d9f3d8fa1b33ea6b22b4e71cb0a3e7e6ef2294f7dd15feed457634fdfd13588f
data/README.md CHANGED
@@ -11,7 +11,8 @@ A malicious blog posts monitoring tool.
11
11
  - [x] Subscribe [a malicious blog posts feed](https://www.inoreader.com/stream/user/1006141524/tag/%E4%B8%8D%E5%AF%A9%E3%83%A1%E3%83%BC%E3%83%AB) (by [@catnap707](https://twitter.com/catnap707))
12
12
  - [x] Extract IoCs(BTC, URL) from a blog post
13
13
  - [x] Post extracted IoCs to Slack (or STDOUT) with enrichment
14
- - [ ] Attachment handling
14
+ - [x] Attachment handling
15
+ - Scan a URL via Hybrid Analysis
15
16
 
16
17
  ## Supported blog types
17
18
 
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 2.0"
28
28
  spec.add_development_dependency "coveralls", "~> 0.8"
29
+ spec.add_development_dependency "dotenv", "~> 2.6"
29
30
  spec.add_development_dependency "rake", "~> 12.3"
30
31
  spec.add_development_dependency "rspec", "~> 3.8"
31
32
  spec.add_development_dependency "vcr", "~> 4.0"
@@ -4,7 +4,10 @@ require "fushin/version"
4
4
 
5
5
  require "fushin/erros"
6
6
 
7
+ require "fushin/hybrid_analysis"
8
+
7
9
  require "fushin/models/model"
10
+ require "fushin/models/attachment"
8
11
  require "fushin/models/btc"
9
12
  require "fushin/models/website"
10
13
 
File without changes
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "http"
5
+
6
+ module Fushin
7
+ class HybridAnalysis
8
+ BASE_URL = "https://www.hybrid-analysis.com"
9
+ VERSION = "v2"
10
+
11
+ def quick_url_scan(url)
12
+ payload = {
13
+ scan_type: "all",
14
+ url: url
15
+ }
16
+ res = HTTP.headers(default_headers).post(url_for("/quick-scan/url-to-file"), form: payload)
17
+ res.code == 200 ? JSON.parse(res.body.to_s) : nil
18
+ end
19
+
20
+ def self.quick_url_scan(url)
21
+ new.quick_url_scan(url)
22
+ end
23
+
24
+ private
25
+
26
+ def api_key
27
+ @api_key ||= ENV.fetch("HA_API_KEY")
28
+ end
29
+
30
+ def default_headers
31
+ {
32
+ "accept" => "application/json",
33
+ "api-key" => api_key,
34
+ "user-agent" => "Falcon Sandbox",
35
+ }
36
+ end
37
+
38
+ def url_for(path)
39
+ "#{BASE_URL}/api/#{VERSION}#{path}"
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fushin
4
+ module Models
5
+ class Attachment < Model
6
+ attr_reader :url
7
+ def initialize(url)
8
+ @url = url
9
+ end
10
+
11
+ def sha256
12
+ @sha256 ||= [].tap do |out|
13
+ res = HybridAnalysis.quick_url_scan(url)
14
+ out << res.dig("sha256")
15
+ end.first
16
+ end
17
+
18
+ def title
19
+ "HA: #{sha256}"
20
+ end
21
+
22
+ def ha_link
23
+ "https://www.hybrid-analysis.com/sample/#{sha256}/"
24
+ end
25
+
26
+ def to_attachements
27
+ [
28
+ {
29
+ fallback: "HA link",
30
+ title: title,
31
+ title_link: ha_link,
32
+ footer: "hybrid-analysis.com",
33
+ footer_icon: "http://www.google.com/s2/favicons?domain=hybrid-analysis.com"
34
+ }
35
+ ]
36
+ end
37
+ end
38
+ end
39
+ end
@@ -15,6 +15,7 @@ module Fushin
15
15
  out << item.post.btcs.map(&:to_attachements)
16
16
  out << item.post.urls.map(&:to_attachements)
17
17
  out << item.post.links.map(&:to_attachements)
18
+ out << item.post.attachements.map(&:to_attachements)
18
19
  end.flatten
19
20
  attachements << { text: "IoC is not found." } if attachements.empty?
20
21
  Notifier.notify("#{item.title} (#{item.link})", attachements)
@@ -57,6 +57,10 @@ module Fushin
57
57
  end.compact
58
58
  end
59
59
 
60
+ def attachements
61
+ []
62
+ end
63
+
60
64
  private
61
65
 
62
66
  def main_selector
@@ -10,6 +10,15 @@ module Fushin
10
10
  def main_cleanup_selectors
11
11
  %w(script)
12
12
  end
13
+
14
+ def attachements
15
+ @attachements ||= doc.css("#primary > div.inner > div > div:nth-child(3) > a").map do |a|
16
+ url = a.get("href")
17
+ next unless url
18
+
19
+ Models::Attachment.new url
20
+ end.compact
21
+ end
13
22
  end
14
23
  end
15
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fushin
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fushin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.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: 2019-01-31 00:00:00.000000000 Z
11
+ date: 2019-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: dotenv
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.6'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -215,7 +229,10 @@ files:
215
229
  - lib/fushin/cache.rb
216
230
  - lib/fushin/config/whitelisted_domains.yml
217
231
  - lib/fushin/erros.rb
232
+ - lib/fushin/http/headers.rb
233
+ - lib/fushin/hybrid_analysis.rb
218
234
  - lib/fushin/item.rb
235
+ - lib/fushin/models/attachment.rb
219
236
  - lib/fushin/models/btc.rb
220
237
  - lib/fushin/models/model.rb
221
238
  - lib/fushin/models/website.rb