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 +4 -4
- data/README.md +2 -1
- data/fushin.gemspec +1 -0
- data/lib/fushin.rb +3 -0
- data/lib/fushin/http/headers.rb +0 -0
- data/lib/fushin/hybrid_analysis.rb +42 -0
- data/lib/fushin/models/attachment.rb +39 -0
- data/lib/fushin/monitor.rb +1 -0
- data/lib/fushin/posts/post.rb +4 -0
- data/lib/fushin/posts/shinobi.rb +9 -0
- data/lib/fushin/version.rb +1 -1
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2886480988a7953bf20c22ffd1ab3590926c5121700b2aaf007bebe3c93438fd
|
4
|
+
data.tar.gz: abbf709568fc79ff6d57aee267d0cf4b3875a783410b2594a40430126c734db1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
- [
|
14
|
+
- [x] Attachment handling
|
15
|
+
- Scan a URL via Hybrid Analysis
|
15
16
|
|
16
17
|
## Supported blog types
|
17
18
|
|
data/fushin.gemspec
CHANGED
@@ -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"
|
data/lib/fushin.rb
CHANGED
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
|
data/lib/fushin/monitor.rb
CHANGED
@@ -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)
|
data/lib/fushin/posts/post.rb
CHANGED
data/lib/fushin/posts/shinobi.rb
CHANGED
@@ -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
|
data/lib/fushin/version.rb
CHANGED
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.
|
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-
|
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
|