mihari 5.7.0 → 5.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/lib/mihari/actor.rb +10 -4
  4. data/lib/mihari/commands/alert.rb +6 -4
  5. data/lib/mihari/commands/search.rb +10 -29
  6. data/lib/mihari/enrichers/ipinfo.rb +1 -1
  7. data/lib/mihari/entities/tag.rb +1 -0
  8. data/lib/mihari/rule.rb +14 -0
  9. data/lib/mihari/service.rb +12 -2
  10. data/lib/mihari/services/alert_builder.rb +81 -8
  11. data/lib/mihari/services/alert_runner.rb +3 -10
  12. data/lib/mihari/services/rule_builder.rb +8 -10
  13. data/lib/mihari/services/rule_runner.rb +2 -25
  14. data/lib/mihari/structs/binaryedge.rb +9 -0
  15. data/lib/mihari/structs/censys.rb +0 -14
  16. data/lib/mihari/structs/fofa.rb +3 -0
  17. data/lib/mihari/structs/google_public_dns.rb +0 -4
  18. data/lib/mihari/structs/greynoise.rb +0 -6
  19. data/lib/mihari/structs/hunterhow.rb +0 -6
  20. data/lib/mihari/structs/ipinfo.rb +0 -2
  21. data/lib/mihari/structs/onyphe.rb +0 -4
  22. data/lib/mihari/structs/shodan.rb +0 -2
  23. data/lib/mihari/structs/urlscan.rb +0 -6
  24. data/lib/mihari/structs/virustotal_intelligence.rb +0 -8
  25. data/lib/mihari/version.rb +1 -1
  26. data/lib/mihari/web/app.rb +20 -17
  27. data/lib/mihari/web/endpoints/alerts.rb +75 -38
  28. data/lib/mihari/web/endpoints/artifacts.rb +60 -53
  29. data/lib/mihari/web/endpoints/ip_addresses.rb +19 -4
  30. data/lib/mihari/web/endpoints/rules.rb +132 -88
  31. data/lib/mihari/web/endpoints/tags.rb +15 -13
  32. data/lib/mihari/web/public/assets/{index-821134e2.js → index-07fafab5.js} +4 -3
  33. data/lib/mihari/web/public/index.html +1 -1
  34. data/lib/mihari.rb +0 -1
  35. data/mihari.gemspec +1 -1
  36. data/mkdocs.yml +1 -0
  37. metadata +3 -130
  38. data/docs/alternatives.md +0 -5
  39. data/docs/analyzers/binaryedge.md +0 -26
  40. data/docs/analyzers/censys.md +0 -31
  41. data/docs/analyzers/circl.md +0 -37
  42. data/docs/analyzers/crtsh.md +0 -26
  43. data/docs/analyzers/dnstwister.md +0 -25
  44. data/docs/analyzers/feed.md +0 -73
  45. data/docs/analyzers/fofa.md +0 -31
  46. data/docs/analyzers/greynoise.md +0 -26
  47. data/docs/analyzers/hunterhow.md +0 -33
  48. data/docs/analyzers/index.md +0 -104
  49. data/docs/analyzers/onyphe.md +0 -26
  50. data/docs/analyzers/otx.md +0 -28
  51. data/docs/analyzers/passivetotal.md +0 -52
  52. data/docs/analyzers/pulsedive.md +0 -28
  53. data/docs/analyzers/securitytrails.md +0 -41
  54. data/docs/analyzers/shodan.md +0 -26
  55. data/docs/analyzers/urlscan.md +0 -28
  56. data/docs/analyzers/virustotal.md +0 -43
  57. data/docs/analyzers/virustotal_intelligence.md +0 -33
  58. data/docs/analyzers/zoomeye.md +0 -38
  59. data/docs/configuration.md +0 -35
  60. data/docs/emitters/database.md +0 -22
  61. data/docs/emitters/hive.md +0 -26
  62. data/docs/emitters/index.md +0 -36
  63. data/docs/emitters/misp.md +0 -21
  64. data/docs/emitters/slack.md +0 -21
  65. data/docs/emitters/webhook.md +0 -63
  66. data/docs/enrichers/google_public_dns.md +0 -19
  67. data/docs/enrichers/index.md +0 -35
  68. data/docs/enrichers/ipinfo.md +0 -26
  69. data/docs/enrichers/shodan.md +0 -22
  70. data/docs/enrichers/whois.md +0 -17
  71. data/docs/github_actions.md +0 -43
  72. data/docs/index.md +0 -11
  73. data/docs/installation.md +0 -31
  74. data/docs/requirements.md +0 -13
  75. data/docs/rule.md +0 -168
  76. data/docs/tags.md +0 -3
  77. data/docs/usage.md +0 -103
  78. data/frontend/.eslintrc.cjs +0 -22
  79. data/frontend/.gitignore +0 -31
  80. data/frontend/.prettierrc.json +0 -8
  81. data/frontend/README.md +0 -3
  82. data/frontend/env.d.ts +0 -5
  83. data/frontend/index.html +0 -21
  84. data/frontend/package-lock.json +0 -7219
  85. data/frontend/package.json +0 -67
  86. data/frontend/public/favicon.ico +0 -0
  87. data/frontend/scripts/swagger_doc_to_yaml.rb +0 -23
  88. data/frontend/src/App.vue +0 -27
  89. data/frontend/src/ace-config.ts +0 -6
  90. data/frontend/src/api-helper.ts +0 -111
  91. data/frontend/src/api.ts +0 -105
  92. data/frontend/src/components/ErrorMessage.vue +0 -31
  93. data/frontend/src/components/Loading.vue +0 -15
  94. data/frontend/src/components/Navbar.vue +0 -42
  95. data/frontend/src/components/Pagination.vue +0 -119
  96. data/frontend/src/components/alert/Alert.vue +0 -87
  97. data/frontend/src/components/alert/Alerts.vue +0 -63
  98. data/frontend/src/components/alert/AlertsWithPagination.vue +0 -90
  99. data/frontend/src/components/alert/AlertsWrapper.vue +0 -128
  100. data/frontend/src/components/alert/Form.vue +0 -169
  101. data/frontend/src/components/artifact/AS.vue +0 -23
  102. data/frontend/src/components/artifact/Artifact.vue +0 -287
  103. data/frontend/src/components/artifact/ArtifactTag.vue +0 -64
  104. data/frontend/src/components/artifact/ArtifactTags.vue +0 -29
  105. data/frontend/src/components/artifact/ArtifactWrapper.vue +0 -57
  106. data/frontend/src/components/artifact/CPEs.vue +0 -23
  107. data/frontend/src/components/artifact/DnsRecords.vue +0 -32
  108. data/frontend/src/components/artifact/Ports.vue +0 -23
  109. data/frontend/src/components/artifact/ReverseDnsNames.vue +0 -23
  110. data/frontend/src/components/artifact/Tags.vue +0 -29
  111. data/frontend/src/components/artifact/WhoisRecord.vue +0 -44
  112. data/frontend/src/components/config/Configs.vue +0 -65
  113. data/frontend/src/components/config/ConfigsWrapper.vue +0 -32
  114. data/frontend/src/components/link/Link.vue +0 -32
  115. data/frontend/src/components/link/Links.vue +0 -42
  116. data/frontend/src/components/rule/EditRule.vue +0 -72
  117. data/frontend/src/components/rule/EditRuleWrapper.vue +0 -48
  118. data/frontend/src/components/rule/Form.vue +0 -158
  119. data/frontend/src/components/rule/InputForm.vue +0 -45
  120. data/frontend/src/components/rule/NewRule.vue +0 -57
  121. data/frontend/src/components/rule/Rule.vue +0 -100
  122. data/frontend/src/components/rule/RuleWrapper.vue +0 -53
  123. data/frontend/src/components/rule/Rules.vue +0 -84
  124. data/frontend/src/components/rule/RulesWrapper.vue +0 -121
  125. data/frontend/src/components/rule/YAML.vue +0 -37
  126. data/frontend/src/components/tag/Tag.vue +0 -65
  127. data/frontend/src/components/tag/Tags.vue +0 -37
  128. data/frontend/src/countries.ts +0 -350
  129. data/frontend/src/index.ts +0 -20
  130. data/frontend/src/links/anyrun.ts +0 -19
  131. data/frontend/src/links/base.ts +0 -14
  132. data/frontend/src/links/censys.ts +0 -20
  133. data/frontend/src/links/crtsh.ts +0 -20
  134. data/frontend/src/links/dnslytics.ts +0 -38
  135. data/frontend/src/links/greynoise.ts +0 -20
  136. data/frontend/src/links/index.ts +0 -40
  137. data/frontend/src/links/intezer.ts +0 -20
  138. data/frontend/src/links/otx.ts +0 -33
  139. data/frontend/src/links/securitytrails.ts +0 -38
  140. data/frontend/src/links/shodan.ts +0 -20
  141. data/frontend/src/links/urlscan.ts +0 -50
  142. data/frontend/src/links/virustotal.ts +0 -72
  143. data/frontend/src/main.ts +0 -41
  144. data/frontend/src/router/index.ts +0 -57
  145. data/frontend/src/rule.ts +0 -14
  146. data/frontend/src/shims-vue.d.ts +0 -6
  147. data/frontend/src/swagger.yaml +0 -771
  148. data/frontend/src/types.ts +0 -188
  149. data/frontend/src/utils.ts +0 -54
  150. data/frontend/src/views/Alerts.vue +0 -20
  151. data/frontend/src/views/Artifact.vue +0 -39
  152. data/frontend/src/views/Configs.vue +0 -20
  153. data/frontend/src/views/EditRule.vue +0 -39
  154. data/frontend/src/views/NewRule.vue +0 -26
  155. data/frontend/src/views/Rule.vue +0 -39
  156. data/frontend/src/views/Rules.vue +0 -20
  157. data/frontend/tests/utils.spec.ts +0 -9
  158. data/frontend/tsconfig.app.json +0 -21
  159. data/frontend/tsconfig.json +0 -14
  160. data/frontend/tsconfig.node.json +0 -13
  161. data/frontend/tsconfig.vitest.json +0 -12
  162. data/frontend/vite.config.ts +0 -24
  163. data/frontend/vitest.config.ts +0 -21
  164. data/lib/mihari/services/alert_proxy.rb +0 -97
data/docs/index.md DELETED
@@ -1,11 +0,0 @@
1
- # Mihari
2
-
3
- A query aggregator for OSINT based threat hunting.
4
-
5
- Mihari can aggregate multiple searches across multiple services in a single rule & persist findings in a database.
6
-
7
- - [Requirements](./requirements.md)
8
- - [Installation](./installation.md)
9
- - [How to Write a Rule](./rule.md)
10
- - [Usage](./usage.md)
11
- - [Configuration](./configuration.md)
data/docs/installation.md DELETED
@@ -1,31 +0,0 @@
1
- # Installation
2
-
3
- ## Ruby Gem
4
-
5
- Mihari is packaged as a Ruby Gem. Thus you can install it via `gem` command.
6
-
7
- ```bash
8
- gem install mihari
9
- ```
10
-
11
- Mihari uses SQLite3 as a primary database by default. Thus a gem for SQLite (`sqlite3`) is installed by default.
12
-
13
- If you want to use MySQL or PostgreSQL instead of SQLite3, please install a gem for that by yourself.
14
-
15
- **MySQL**
16
-
17
- ```bash
18
- gem install mysql2
19
- ```
20
-
21
- **PostgreSQL**
22
-
23
- ```bash
24
- gem install pg
25
- ```
26
-
27
- # Docker
28
-
29
- You can built the Docker image by yourself.
30
-
31
- `Dockerfile` is available at [https://github.com/ninoseki/mihari/tree/master/docker](https://github.com/ninoseki/mihari/tree/master/docker).
data/docs/requirements.md DELETED
@@ -1,13 +0,0 @@
1
- # Requirements
2
-
3
- ## Runtime
4
-
5
- Ruby 2.7+ / 3.0+ (tested with 2.7, 3.0, 3.1 and 3.2)
6
-
7
- ## Database
8
-
9
- - SQLite3
10
- - PostgreSQL
11
- - MySQL
12
-
13
- You need to have a database to persistent the data. See [Database](./emitters/database.md) for details.
data/docs/rule.md DELETED
@@ -1,168 +0,0 @@
1
- # How to Write a Rule
2
-
3
- Mihari has [Sigma](https://github.com/SigmaHQ/sigma) like format to describe a set of search queries to express a rule.
4
-
5
- Mihari has three main components to compose a rule.
6
-
7
- ![](https://imgur.com/BBT99BG.png)
8
-
9
- - Analyzers/Queries: a list of queries (analyzers) that builds a list of artifacts
10
- - Enrichers: a list of enrichers that enriches a list of artifacts
11
- - Emitters: a list of emitters that emits a list of artifacts as an alert
12
-
13
- An artifact has five types:
14
-
15
- - IP address (`ip`)
16
- - Domain (`domain`)
17
- - URL (`url`)
18
- - Mail (`mail`)
19
- - Hash (`hash`)
20
-
21
- An alert can have multiple artifacts bundled by a rule.
22
-
23
- !!! note
24
-
25
- A rule is assumed to be executed multiple times continuously. An alert generated by a rule will only have new findings at that time.
26
-
27
- Let's break down the following example:
28
-
29
- ```yaml
30
- id: c7f6968e-dbe1-4612-b0bb-8407a4fe05df
31
- title: Example
32
- description: Mihari rule example
33
- created_on: "2023-01-01"
34
- updated_on: "2023-01-02"
35
- author: ninoseki
36
- references:
37
- - https://github.com/ninoseki/mihari
38
- related:
39
- - 6254bb74-5e5d-42ad-bc1e-231da0293b0f
40
- tags:
41
- - foo
42
- - bar
43
- queries:
44
- - analyzer: shodan
45
- query: ip:1.1.1.1
46
- - analyzer: censys
47
- query: ip:8.8.8.8
48
- enrichers:
49
- - enricher: whois
50
- - enricher: ipinfo
51
- - enricher: shodan
52
- - enricher: google_public_dns
53
- emitters:
54
- - emitter: database
55
- - emitter: misp
56
- - emitter: slack
57
- - emitter: thehive
58
- data_types:
59
- - hash
60
- - ip
61
- - domain
62
- - url
63
- - mail
64
- falsepositives: []
65
- ```
66
-
67
- ## Components
68
-
69
- ### ID
70
-
71
- `id` (`string`) is an unique ID of a rule. UUID v4 is recommended.
72
-
73
- ### Title
74
-
75
- `title` (`string`) is a title of a rule.
76
-
77
- ### Description
78
-
79
- `description` (`string`) is a short description of a rule.
80
-
81
- ### Created/Updated On
82
-
83
- `created_on` (`date`) is a date of a rule creation. Optional.
84
- Also a rule can have `updated_on` that is a date of a rule modification. Optional.
85
-
86
- ### Tags
87
-
88
- `tags` (`array[:string]`) is a list of tags of a rule.
89
-
90
- ### Author
91
-
92
- `author` (`string`) is an author of a rule. Optional.
93
-
94
- ### References
95
-
96
- `references` (`array[:string]`) is a list of a references of a rule. Optional.
97
-
98
- ### Related
99
-
100
- `related` (`array[:string]`) is a list of related rule IDs. Optional.
101
-
102
- ### Queries
103
-
104
- `queries` is a list of queries/analyzers.
105
- See [Analyzers](./analyzers/index.md) to know details of each analyzer.
106
-
107
- ### Enrichers
108
-
109
- `enrichers` is a list of enrichers.
110
- See [Enrichers](./enrichers/index.md) to know details of each enricher.
111
-
112
- Defaults to:
113
-
114
- - `google_public_dns`
115
- - `ipinfo`
116
- - `shodan`
117
- - `whois`
118
-
119
- ### Emitters
120
-
121
- `emitters` is a list of emitters.
122
- See [Emitters](./emitters/index.md) to know details of each emitter.
123
-
124
- Defaults to:
125
-
126
- - `database`
127
-
128
- ### Data Types
129
-
130
- `data_types` (`array[:string]`) is a list of data (artifact) types to allow by a rule. Types not defined in here will be automatically rejected.
131
-
132
- Defaults to:
133
-
134
- - `ip`
135
- - `domain`
136
- - `url`
137
- - `mail`
138
- - `hash`
139
-
140
- ### False positives
141
-
142
- `falsepositives` (`array[:string]`) is a list of false positive values. A string or regexp can be used in here.
143
-
144
- ### Artifact TTL
145
-
146
- `artifact_ttl` (`integer` / alias: `artifact_lifetime`) is an integer value of artifact TTL (Time-To-Live) in seconds.
147
-
148
- Mihari rejects a same artifact in a same rule in general.
149
-
150
- But you may want to get a same artifact after a certain period of time. `artifact_ttl` is for that. If a rule finds a same artifact after `artifact_ttl` seconds have been passed, that artifact will be included in an alert.
151
-
152
- ## How to Run a Rule
153
-
154
- Once you finish writing a rule, you can run the rule by `mihari` CLI.
155
-
156
- !!! note
157
-
158
- You have to initialize the database by `mihari db migrate` if you haven't already done.
159
-
160
- ```bash
161
- mihari search /path/to/rule.yml
162
- ```
163
-
164
- The command outputs an alert to the standard output. Also you can confirm it with a built-in web app.
165
-
166
- ```bash
167
- mihari web
168
- ```
data/docs/tags.md DELETED
@@ -1,3 +0,0 @@
1
- # Tags
2
-
3
- [TAGS]
data/docs/usage.md DELETED
@@ -1,103 +0,0 @@
1
- # Usage
2
-
3
- ```bash
4
- $ mihari
5
- Commands:
6
- mihari --version, -v # Print the version
7
- mihari alert # Sub commands for alert
8
- mihari db # Sub commands for DB
9
- mihari help [COMMAND] # Describe available commands or one specific command
10
- mihari rule # Sub commands for rule
11
- mihari search [PATH_OR_ID] # Search by a rule (Outputs null if there is no new finding)
12
- mihari web # Launch the web app
13
-
14
- Options:
15
- -d, [--debug], [--no-debug] # Sets up debug mode
16
- ```
17
-
18
- ## `mihari db`
19
-
20
- This sub command is for initializing/migrating database.
21
-
22
- ```bash
23
- mihari db migrate
24
- ```
25
-
26
- See [Database](./emitters/database.md) for detailed database configuration.
27
-
28
- ## `mihari rule`
29
-
30
- This sub command is for validating/initializing a rule.
31
-
32
- ```bash
33
- mihari rule init /path/to/rule.yml
34
- mihari rule validate /path/to/rule.yml
35
- ```
36
-
37
- ## `mihari search`
38
-
39
- This is a command for running a rule.
40
-
41
- ```bash
42
- mihari search /path/to/rule.yml
43
- ```
44
-
45
- Mihari asks whether really you want to update a rule if there is a diff by default.
46
-
47
- ```bash
48
- $ mihari search /path/to/rule.yml
49
- There is a diff in the rule. Are you sure you want to overwrite the rule? (y/n)
50
- ```
51
-
52
- It can be suppressed by providing `-f`.
53
-
54
- ```bash
55
- mihari search -f /path/to/rule.yml
56
- ```
57
-
58
- ## `mihari add`
59
-
60
- You may want to add an alert manually. You can do that by this command.
61
-
62
- ```bash
63
- mihari alert /path/to/alert.yml
64
- ```
65
-
66
- ## `mihari web`
67
-
68
- This command is for launching the built-in web app.
69
-
70
- ```bash
71
- mihari web
72
- ```
73
-
74
- It stars the app with `localhost:9292`. You can configure it by providing options.
75
-
76
- ```bash
77
- $ mihari help web
78
- Usage:
79
- mihari web
80
-
81
- Options:
82
- [--port=N] # Hostname to listen on
83
- # Default: 9292
84
- [--host=HOST] # Port to listen on
85
- # Default: localhost
86
- [--threads=THREADS] # min:max threads to use
87
- # Default: 0:5
88
- [--verbose], [--no-verbose] # Report each request
89
- # Default: true
90
- [--worker-timeout=N] # Worker timeout value (in seconds)
91
- # Default: 60
92
- [--hide-config-values], [--no-hide-config-values] # Whether to hide config values or not
93
- # Default: true
94
- [--open], [--no-open] # Whether to open the app in browser or not
95
- # Default: true
96
- [--rack-env=RACK_ENV] # Rack environment
97
- # Default: production
98
- ```
99
-
100
- !!! tip
101
-
102
- The built-in web app offers API to interact with Mihari.
103
- The API docs are available on `/redoc-static.html`
@@ -1,22 +0,0 @@
1
- /* eslint-env node */
2
- require('@rushstack/eslint-patch/modern-module-resolution')
3
-
4
- module.exports = {
5
- root: true,
6
- extends: [
7
- 'plugin:vue/vue3-essential',
8
- 'eslint:recommended',
9
- '@vue/eslint-config-typescript',
10
- '@vue/eslint-config-prettier/skip-formatting'
11
- ],
12
- plugins: ['simple-import-sort'],
13
- rules: {
14
- 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
15
- 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
16
- 'simple-import-sort/imports': 'error',
17
- 'simple-import-sort/exports': 'error'
18
- },
19
- parserOptions: {
20
- ecmaVersion: 'latest'
21
- }
22
- }
data/frontend/.gitignore DELETED
@@ -1,31 +0,0 @@
1
- # Logs
2
- logs
3
- *.log
4
- npm-debug.log*
5
- yarn-debug.log*
6
- yarn-error.log*
7
- pnpm-debug.log*
8
- lerna-debug.log*
9
-
10
- node_modules
11
- .DS_Store
12
- dist
13
- dist-ssr
14
- coverage
15
- *.local
16
-
17
- /cypress/videos/
18
- /cypress/screenshots/
19
-
20
- # Editor directories and files
21
- .vscode/*
22
- !.vscode/extensions.json
23
- .idea
24
- *.suo
25
- *.ntvs*
26
- *.njsproj
27
- *.sln
28
- *.sw?
29
-
30
- # redoc
31
- public/redoc-static.html
@@ -1,8 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/prettierrc",
3
- "semi": false,
4
- "tabWidth": 2,
5
- "singleQuote": false,
6
- "printWidth": 100,
7
- "trailingComma": "none"
8
- }
data/frontend/README.md DELETED
@@ -1,3 +0,0 @@
1
- # mihari-frontend
2
-
3
- A frontend app for [Mihari](https://github.com/ninoseki/mihari).
data/frontend/env.d.ts DELETED
@@ -1,5 +0,0 @@
1
- /// <reference types="vite/client" />
2
-
3
- interface ImportMeta {
4
- readonly env: ImportMetaEnv
5
- }
data/frontend/index.html DELETED
@@ -1,21 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
- <meta name="viewport" content="width=device-width,initial-scale=1.0" />
7
- <link rel="icon" href="/favicon.ico" />
8
- <title>Mihari</title>
9
- </head>
10
- <body>
11
- <noscript>
12
- <strong
13
- >We're sorry but Mihari doesn't work properly without JavaScript
14
- enabled. Please enable it to continue.</strong
15
- >
16
- </noscript>
17
- <div id="app"></div>
18
- <script type="module" src="/src/main.ts"></script>
19
- <!-- built files will be auto injected -->
20
- </body>
21
- </html>