7 | Site:
8 | Twitter:
9 | Location:
10 |
11 | /* THANKS */
12 | Daniel Kehoe (@rails_apps) for the RailsApps project
13 |
14 | /* SITE */
15 | Standards: HTML5, CSS3
16 | Components: jQuery
17 | Software: Ruby on Rails
18 |
19 | /* GENERATED BY */
20 | RailsApps application template: http://railsapps.github.io/
21 |
--------------------------------------------------------------------------------
/test/fixtures/users.yml:
--------------------------------------------------------------------------------
1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2 |
3 | # This model initially had no columns defined. If you add columns to the
4 | # model remove the '{}' from the fixture names and add the columns immediately
5 | # below each fixture, per the syntax in the comments below
6 | #
7 | one:
8 | id: 1
9 | name: test1
10 | email: test1@test.com
11 | two:
12 | id: 2
13 | name: test2
14 | email: test2@test.com
15 |
--------------------------------------------------------------------------------
/app/views/layouts/_navigation_links2.html.erb:
--------------------------------------------------------------------------------
1 | <% if user_signed_in? %>
2 |
5 | <%= link_to '', edit_user_registration_path, :class => 'navbar-brand glyphicon glyphicon-cog', :data => {:toggle=>"tooltip"}, :title => "Edit Account" %>
6 | Logged in as: <%= current_user.name %>
7 | <%= button_to 'Logout', destroy_user_session_path, :method=>'delete', :class => 'btn btn-default navbar-btn' %>
8 | <% else %>
9 | <% end %>
--------------------------------------------------------------------------------
/app/views/admin/users/show.html.erb:
--------------------------------------------------------------------------------
1 | <%= t("activerecord.attributes.user.email", :default => t("activerecord.labels.email", :default => "Email")) %>:
2 | <%= @user.email %>
3 |
4 |
5 | <%= link_to "Back", admin_users_path, :class => 'btn' %>
6 | <%= link_to "Edit", edit_admin_user_path(@user), :class => 'btn' %>
7 | <%= link_to "Delete", admin_user_path(@user), :method => "delete", :confirm => "#{t("web-app-theme.confirm", :default => "Are you sure?")}", :class => 'btn' %>
8 |
--------------------------------------------------------------------------------
/app/views/samples/new_yara.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
Compose Yara Signature
3 | <%= form_tag("addrule", method: "post") do %>
4 | <%= label_tag(:q, '') %>
5 |
6 |
Rule Name: <%= text_field_tag(:rule_name, '') %>.yar
7 |
8 |
Rule Content
9 |
10 | <%= text_area_tag(:rule_body, '', size: "100x15") %>
11 |
12 |
13 | <%= submit_tag("Save", class: "btn btn-primary") %>
14 |
15 | <% end %>
16 |
17 |
--------------------------------------------------------------------------------
/app/toolbox/retrieve.rb:
--------------------------------------------------------------------------------
1 | require 'open-uri'
2 | require 'find_artifacts'
3 |
4 | class Updater
5 | $discover = FindArtifacts.new
6 |
7 | def retrieval(url, tags)
8 | open(url) {|f|
9 | f.each_line {|line|
10 | str = line.to_str
11 | if str.start_with?("#")
12 | else
13 | $discover.domain(str, tags)
14 | $discover.ipv4(str, tags)
15 | end}
16 | }
17 | end
18 |
19 | def dedupe(artifact)
20 | # Checks database to see if value already exists
21 |
22 | end
23 |
24 | def extract
25 |
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/app/views/devise/passwords/new.html.erb:
--------------------------------------------------------------------------------
1 |
13 |
--------------------------------------------------------------------------------
/bin/spring:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # This file loads spring without using Bundler, in order to be fast
4 | # It gets overwritten when you run the `spring binstub` command
5 |
6 | unless defined?(Spring)
7 | require "rubygems"
8 | require "bundler"
9 |
10 | if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m)
11 | ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
12 | ENV["GEM_HOME"] = ""
13 | Gem.paths = ENV
14 |
15 | gem "spring", match[1]
16 | require "spring/binstub"
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/db/migrate/20150124050227_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb:
--------------------------------------------------------------------------------
1 | # This migration comes from acts_as_taggable_on_engine (originally 3)
2 | class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[4.2]
3 | def self.up
4 | add_column :tags, :taggings_count, :integer, default: 0
5 |
6 | ActsAsTaggableOn::Tag.reset_column_information
7 | ActsAsTaggableOn::Tag.find_each do |tag|
8 | ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings)
9 | end
10 | end
11 |
12 | def self.down
13 | remove_column :tags, :taggings_count
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/app/views/kaminari/_paginator.html.erb:
--------------------------------------------------------------------------------
1 | <%= paginator.render do -%>
2 |
15 | <% end -%>
16 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # SQLite version 3.x
2 | # gem install sqlite3
3 | #
4 | # Ensure the SQLite 3 gem is defined in your Gemfile
5 | # gem 'sqlite3'
6 |
7 | development:
8 | adapter: postgresql
9 | database: db
10 | pool: 5
11 | timeout: 5000
12 |
13 | # Warning: The database defined as "test" will be erased and
14 | # re-generated from your development database when you run "rake".
15 | # Do not set this db to the same as development or production.
16 | test:
17 | adapter: postgresql
18 | database: db
19 | pool: 5
20 | timeout: 5000
21 |
22 | production:
23 | adapter: postgresql
24 | database: db
25 | pool: 5
26 | timeout: 5000
27 |
--------------------------------------------------------------------------------
/app/controllers/threats_controller.rb:
--------------------------------------------------------------------------------
1 | class ThreatsController < ApplicationController
2 |
3 | def tags
4 | end
5 |
6 | def analysis
7 | @profile = params[:profile]
8 | end
9 |
10 | def ioc_list
11 | @ioc_matches = []
12 | @mal_matches = []
13 | @tag_name = params[:tag]
14 |
15 | # Query IOCs table
16 | Element.tagged_with(@tag_name).find_each do |item|
17 | @ioc_matches.push(item.value)
18 | end
19 |
20 | # Query Samples table
21 | Sample.tagged_with(@tag_name).find_each do |item|
22 | @mal_matches.push(item.md5sum)
23 | end
24 |
25 | @tagged = @ioc_matches.length + @mal_matches.length
26 | end
27 | end
--------------------------------------------------------------------------------
/config/unicorn.rb:
--------------------------------------------------------------------------------
1 | # Set the working application directory
2 | # working_directory "/path/to/your/app"
3 | working_directory "/home/malstrom"
4 |
5 | # Unicorn PID file location
6 | # pid "/path/to/pids/unicorn.pid"
7 | pid "/home/malstrom/pids/unicorn.pid"
8 |
9 | # Path to logs
10 | # stderr_path "/path/to/log/unicorn.log"
11 | # stdout_path "/path/to/log/unicorn.log"
12 | stderr_path "/home/malstrom/log/unicorn.log"
13 | stdout_path "/home/malstrom/log/unicorn.log"
14 |
15 | # Unicorn socket
16 | listen "/tmp/unicorn.malstrom.sock"
17 | listen "/tmp/unicorn.myapp.sock"
18 |
19 | # Number of processes
20 | worker_processes 4
21 | #worker_processes 2
22 |
23 | # Time-out
24 | timeout 75
25 |
--------------------------------------------------------------------------------
/app/views/search/index.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 | <%= paginate @results %>
4 |
5 |
6 |
7 | Value
8 | Type
9 | Tags
10 | Created
11 |
12 |
13 |
14 |
15 | <%- @results.all.each do |i| %>
16 |
17 | <%= i.value %>
18 | <%= i.kind %>
19 | <%= i.tag_list %>
20 | <%= i.created_at %>
21 | <%= link_to '', search_delete_iocs_path(:ioc => i.id), :class => 'btn btn-danger glyphicon glyphicon-remove'%>
22 |
23 | <% end %>
24 |
25 |
26 |
--------------------------------------------------------------------------------
/config/sqlite_database.yml:
--------------------------------------------------------------------------------
1 | # SQLite version 3.x
2 | # gem install sqlite3
3 | #
4 | # Ensure the SQLite 3 gem is defined in your Gemfile
5 | # gem 'sqlite3'
6 |
7 | development:
8 | adapter: sqlite3
9 | database: db/development.sqlite3
10 | pool: 5
11 | timeout: 5000
12 |
13 | # Warning: The database defined as "test" will be erased and
14 | # re-generated from your development database when you run "rake".
15 | # Do not set this db to the same as development or production.
16 | test:
17 | adapter: sqlite3
18 | database: db/test.sqlite3
19 | pool: 5
20 | timeout: 5000
21 |
22 | production:
23 | adapter: sqlite3
24 | database: db/development.sqlite3
25 | pool: 5
26 | timeout: 5000
27 |
--------------------------------------------------------------------------------
/db/migrate/20171018201141_change_collation_for_tag_names.acts_as_taggable_on_engine.rb:
--------------------------------------------------------------------------------
1 | # This migration comes from acts_as_taggable_on_engine (originally 5)
2 | # This migration is added to circumvent issue #623 and have special characters
3 | # work properly
4 | if ActiveRecord.gem_version >= Gem::Version.new('5.0')
5 | class ChangeCollationForTagNames < ActiveRecord::Migration[4.2]; end
6 | else
7 | class ChangeCollationForTagNames < ActiveRecord::Migration[4.2]; end
8 | end
9 | ChangeCollationForTagNames.class_eval do
10 | def up
11 | if ActsAsTaggableOn::Utils.using_mysql?
12 | execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;")
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/app/models/sample.rb:
--------------------------------------------------------------------------------
1 | class Sample < ActiveRecord::Base
2 | include ActionView::Helpers::TextHelper
3 |
4 | has_attached_file :malz,
5 | :url => "/assets/malware/:basename.:extension",
6 | :path => ":rails_root/app/assets/malware/:basename.:extension"
7 |
8 | validates_attachment :malz,
9 | :content_type => { :content_type => /^.*/ }
10 | validates_attachment_size :malz, :less_than => 10.megabytes
11 | # Allow tagging
12 | acts_as_taggable
13 |
14 | def samples
15 | render partial 'samples'
16 | end
17 |
18 | def signatures
19 | render partial 'signatures'
20 | end
21 |
22 | def upload
23 | render partial 'upload'
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym 'RESTful'
16 | # end
17 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # To learn more, please read the Rails Internationalization guide
20 | # available at http://guides.rubyonrails.org/i18n.html.
21 |
22 | en:
23 | hello: "Hello world"
24 |
--------------------------------------------------------------------------------
/app/toolbox/virustotal.rb:
--------------------------------------------------------------------------------
1 | # VirusTotal module
2 |
3 | require 'json'
4 | require 'rest-client'
5 |
6 | class VirusTotal
7 | def vtquery(hash)
8 | apikey = File.open('app/assets/api.key', 'rb').read
9 |
10 | begin
11 | vtrequest = RestClient.post "https://www.virustotal.com/vtapi/v2/file/report", :resource => "#{hash}", :apikey => "#{apikey}"
12 | end
13 |
14 | results = JSON.parse(vtrequest.body)
15 | vt_link = results["permalink"]
16 |
17 | if vt_link.nil?
18 | vt_status = "N/A"
19 | else
20 | total = results["total"]
21 | detected = results["positives"]
22 | detect_ratio = "#{detected}/#{total}"
23 | vt_status = detect_ratio
24 | end
25 |
26 | return vt_status
27 | end
28 | end
--------------------------------------------------------------------------------
/app/controllers/registrations_controller.rb:
--------------------------------------------------------------------------------
1 | class RegistrationsController < Devise::RegistrationsController
2 |
3 | def new
4 | flash[:info] = 'Registrations are not open yet, but please check back soon'
5 | redirect_to root_path
6 | end
7 |
8 | def create
9 | flash[:info] = 'Registrations are not open yet, but please check back soon'
10 | redirect_to root_path
11 | end
12 |
13 | before_action :update_sanitized_params, if: :devise_controller?
14 |
15 | def update_sanitized_params
16 | devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:name, :email, :password, :password_confirmation)}
17 | devise_parameter_sanitizer.for(:account_update) {|u| u.permit(:name, :email, :password, :password_confirmation, :current_password)}
18 | end
19 |
20 | end
21 |
--------------------------------------------------------------------------------
/app/assets/javascripts/tree.js:
--------------------------------------------------------------------------------
1 | $(function () {
2 | $('.tree li:has(ul)').addClass('parent_li').find(' > span').attr('title', 'Collapse this branch');
3 | $('.tree li.parent_li > span').on('click', function (e) {
4 | var children = $(this).parent('li.parent_li').find(' > ul > li');
5 | if (children.is(":visible")) {
6 | children.hide('fast');
7 | $(this).attr('title', 'Expand this branch').find(' > i').addClass('icon-plus-sign').removeClass('glyphicon glyphicon-minus-sign');
8 | } else {
9 | children.show('fast');
10 | $(this).attr('title', 'Collapse this branch').find(' > i').addClass('glyphicon glyphicon-minus-sign').removeClass('icon-plus-sign');
11 | }
12 | e.stopPropagation();
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/db/migrate/20150124050226_add_missing_unique_indices.acts_as_taggable_on_engine.rb:
--------------------------------------------------------------------------------
1 | # This migration comes from acts_as_taggable_on_engine (originally 2)
2 | class AddMissingUniqueIndices < ActiveRecord::Migration[4.2]
3 | def self.up
4 | add_index :tags, :name, unique: true
5 |
6 | remove_index :taggings, :tag_id
7 | remove_index :taggings, [:taggable_id, :taggable_type, :context]
8 | add_index :taggings,
9 | [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
10 | unique: true, name: 'taggings_idx'
11 | end
12 |
13 | def self.down
14 | remove_index :tags, :name
15 |
16 | remove_index :taggings, name: 'taggings_idx'
17 | add_index :taggings, :tag_id
18 | add_index :taggings, [:taggable_id, :taggable_type, :context]
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/config/locales/simple_form.en.yml:
--------------------------------------------------------------------------------
1 | en:
2 | simple_form:
3 | "yes": 'Yes'
4 | "no": 'No'
5 | required:
6 | text: 'required'
7 | mark: '*'
8 | # You can uncomment the line below if you need to overwrite the whole required html.
9 | # When using html, text and mark won't be used.
10 | # html: '* '
11 | error_notification:
12 | default_message: "Please review the problems below:"
13 | # Labels and hints examples
14 | # labels:
15 | # defaults:
16 | # password: 'Password'
17 | # user:
18 | # new:
19 | # email: 'E-mail to sign in.'
20 | # edit:
21 | # email: 'E-mail.'
22 | # hints:
23 | # defaults:
24 | # username: 'User name to sign in.'
25 | # password: 'No special characters, please.'
26 |
27 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/application.css.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 | * compiled file so the styles you add here take precedence over styles defined in any styles
10 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11 | * file per style scope.
12 | *
13 | *= require_tree .
14 | *= require_self
15 | *= require jquery-ui/core
16 | *= require jquery-ui/theme
17 | *= require dataTables/src/demo_table_jui
18 | */
19 |
--------------------------------------------------------------------------------
/app/assets/javascripts/application.js:
--------------------------------------------------------------------------------
1 | // This is a manifest file that'll be compiled into application.js, which will include all the files
2 | // listed below.
3 | //
4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 | // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6 | //
7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 | // compiled file.
9 | //
10 | // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11 | // about supported directives.
12 | //
13 | //= require jquery
14 | //= require jquery_ujs
15 | //= require dataTables/jquery.dataTables
16 | //= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
17 | //= require tree.js
18 | //= require tagCanvas.js
19 | //= require turbolinks
20 | //= require bootstrap
21 | //= require_tree .
22 |
--------------------------------------------------------------------------------
/app/views/devise/registrations/new.html.erb:
--------------------------------------------------------------------------------
1 |
24 |
--------------------------------------------------------------------------------
/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | <%= content_for?(:title) ? yield(:title) : "Malstrom" %>
6 | <%= favicon_link_tag 'favicon.ico' %>
7 | ">
8 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
9 | <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
10 | <%= csrf_meta_tags %>
11 |
12 |
13 |
14 | <%= render 'layouts/navigation' %>
15 |
16 |
17 | <%= render 'layouts/messages' %>
18 | <%= yield %>
19 | <% flash.each do |name, msg| %>
20 | <%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
21 | <% end %>
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/controllers/search_controller.rb:
--------------------------------------------------------------------------------
1 | class SearchController < ApplicationController
2 | before_action :authenticate_user!
3 |
4 | def indicators
5 | end
6 |
7 | def index
8 | # IOC search page handler
9 | if params[:search][0].to_s.length < 1
10 | redirect_to search_indicators_path
11 | else
12 | query = params[:search][0]
13 | @result = search(query)
14 | end
15 | end
16 |
17 | def search(search)
18 | # search function
19 | @results = Element.where("value like ?", "%#{search}%").page params[:page]
20 | if @results.blank?
21 | redirect_to search_indicators_path, :alert => "No results"
22 | end
23 | end
24 |
25 | def delete_iocs
26 | # function to remove IOCs from the db
27 | data = params[:ioc]
28 | ioc = Element.find_by(:id => data)
29 | begin
30 | ioc.destroy
31 | rescue
32 | redirect_to :back, :alert => "Error: IOC was not deleted!"
33 | end
34 | redirect_to :back, :notice => "IOC successfully deleted!"
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/app/views/admin/users/index.html.erb:
--------------------------------------------------------------------------------
1 | Users
2 |
3 |
4 |
5 | ID
6 |
7 | <%= t("activerecord.attributes.user.email", :default => t("activerecord.labels.email", :default => "Email")) %>
8 |
9 | Created at
10 | Actions
11 |
12 |
13 |
14 | <% @users.each do |user| -%>
15 |
16 | <%= user.id %>
17 | <%= link_to user.email, admin_user_path(user) %>
18 |
19 | <%= user.created_at %>
20 |
21 | <%= link_to "Show", admin_user_path(user) %>
22 | <%= link_to "Edit", edit_admin_user_path(user) %>
23 | <%= link_to "Destroy", admin_user_path(user), :method => :delete, :confirm => "#{t("web-app-theme.confirm", :default => "Are you sure?")}" %>
24 |
25 |
26 | <% end -%>
27 |
28 |
29 |
30 | <%= link_to "New", new_admin_user_path, :class => 'btn btn-primary' %>
--------------------------------------------------------------------------------
/app/views/feeds/new_feed.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Add Feed
6 |
7 | Feed Builder
8 |
9 |
10 |
11 |
12 |
29 |
30 |
--------------------------------------------------------------------------------
/db/migrate/20150124050225_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb:
--------------------------------------------------------------------------------
1 | # This migration comes from acts_as_taggable_on_engine (originally 1)
2 | class ActsAsTaggableOnMigration < ActiveRecord::Migration[4.2]
3 | def self.up
4 | create_table :tags do |t|
5 | t.string :name
6 | end
7 |
8 | create_table :taggings do |t|
9 | t.references :tag
10 |
11 | # You should make sure that the column created is
12 | # long enough to store the required class names.
13 | t.references :taggable, polymorphic: true
14 | t.references :tagger, polymorphic: true
15 |
16 | # Limit is created to prevent MySQL error on index
17 | # length for MyISAM table type: http://bit.ly/vgW2Ql
18 | t.string :context, limit: 128
19 |
20 | t.datetime :created_at
21 | end
22 |
23 | add_index :taggings, :tag_id
24 | add_index :taggings, [:taggable_id, :taggable_type, :context]
25 | end
26 |
27 | def self.down
28 | drop_table :taggings
29 | drop_table :tags
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 | ruby '2.4.2'
3 |
4 | gem 'rails'
5 | gem 'rake'
6 | gem 'pg'
7 | #gem 'sqlite3'
8 | gem 'delayed_job_active_record'
9 | gem 'sass-rails'
10 | gem 'rails_12factor'
11 | gem 'uglifier'
12 | gem 'coffee-rails'
13 | gem 'jquery-rails'
14 | gem 'turbolinks'
15 | gem 'jbuilder', '~> 2.0'
16 | gem 'sdoc', '~> 0.4.0', group: :doc
17 | gem 'spring', group: :development
18 | gem 'bootstrap-sass'
19 | gem 'twitter-bootstrap-rails'
20 | gem 'devise'
21 | gem 'simple_form'
22 | gem 'paperclip', github: 'thoughtbot/paperclip'
23 | gem 'archive-zip'
24 | gem 'hex_string'
25 | gem 'metasm'
26 | gem 'digest'
27 | gem 'exifr'
28 | gem 'json'
29 | gem 'rest-client'
30 | gem 'pedump'
31 | gem 'acts-as-taggable-on'
32 | gem 'kaminari'
33 | gem 'docsplit'
34 |
35 |
36 | #assets
37 | gem 'jquery-ui-rails'
38 | gem 'jquery-datatables-rails', '~> 3.1.1'
39 |
40 | group :development do
41 | gem 'better_errors'
42 | gem 'binding_of_caller', :platforms=>[:mri_19, :mri_20, :mri_21, :rbx]
43 | gem 'rails_layout'
44 | end
45 |
--------------------------------------------------------------------------------
/app/views/layouts/admin.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | <%= content_for?(:title) ? yield(:title) : "Mssd" %>
6 | ">
7 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
8 | <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
9 | <%= csrf_meta_tags %>
10 |
11 |
12 |
13 | <%= render 'layouts/navigation' %>
14 |
15 |
16 | <%= render 'layouts/messages' %>
17 | <%= yield %>
18 | <% flash.each do |name, msg| %>
19 | <%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
20 | <% end %>
21 |
22 | <% if user_signed_in? %>
23 | <% #link_to "My Profile", user_root_path%>
24 | <%= link_to('Logout', destroy_user_session_path, :method=>'delete') %>
25 | <%end%>
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/views/feeds/import.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Import IOC set:
4 | <%= form_tag @extract, html: {action: :upload_ioc}, multipart: true do %>
5 | <%= file_field_tag 'ioc_set' %>
6 |
7 |
Supported File Formats: TXT, CSV, XML, and PDF
8 |
9 |
Tags
10 |
11 |
12 |
13 | <%= text_field(:tag_list, :upload_ioc, :class => "form-control", :placeholder => "Putter Panda, APT, from report") %>
14 |
15 | <%= submit_tag("Import", class: "btn btn-primary")%>
16 |
17 |
18 |
19 |
20 | <% end %>
21 |
22 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../boot', __FILE__)
2 |
3 | require 'rails/all'
4 |
5 | # Require the gems listed in Gemfile, including any gems
6 | # you've limited to :test, :development, or :production.
7 | Bundler.require(*Rails.groups)
8 |
9 | module Malstrom
10 | class Application < Rails::Application
11 | # Settings in config/environments/* take precedence over those specified here.
12 | # Application configuration should go into files in config/initializers
13 | # -- all .rb files in that directory are automatically loaded.
14 |
15 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
16 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
17 | # config.time_zone = 'Central Time (US & Canada)'
18 |
19 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
21 | # config.i18n.default_locale = :de
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/app/views/threats/tags.html.erb:
--------------------------------------------------------------------------------
1 | Threat Tags
2 |
3 |
14 |
15 |
16 |
17 |
18 |
19 | <% tag_cloud( Element.tag_counts_on(:tags), %w(css1 css2 css3 css4)) do |tag, css_class| %>
20 | <%= link_to tag, threats_ioc_list_path(:tag => tag), :class => css_class %>
21 | <% end %>
22 |
23 | <% tag_cloud( Sample.tag_counts_on(:tags), %w(css1 css2 css3 css4)) do |tag, css_class| %>
24 | <%= link_to tag, threats_ioc_list_path(:tag => tag), :class => css_class %>
25 | <% end %>
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Bobby Argenbright
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 all
13 | 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 THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/app/views/devise/sessions/new.html.erb:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/db/migrate/20171018201142_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb:
--------------------------------------------------------------------------------
1 | # This migration comes from acts_as_taggable_on_engine (originally 6)
2 | if ActiveRecord.gem_version >= Gem::Version.new('5.0')
3 | class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end
4 | else
5 | class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end
6 | end
7 | AddMissingIndexesOnTaggings.class_eval do
8 | def change
9 | add_index :taggings, :tag_id unless index_exists? :taggings, :tag_id
10 | add_index :taggings, :taggable_id unless index_exists? :taggings, :taggable_id
11 | add_index :taggings, :taggable_type unless index_exists? :taggings, :taggable_type
12 | add_index :taggings, :tagger_id unless index_exists? :taggings, :tagger_id
13 | add_index :taggings, :context unless index_exists? :taggings, :context
14 |
15 | unless index_exists? :taggings, [:tagger_id, :tagger_type]
16 | add_index :taggings, [:tagger_id, :tagger_type]
17 | end
18 |
19 | unless index_exists? :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
20 | add_index :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/app/views/admin/users/_form.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <%= f.label :email, t("activerecord.attributes.user.email", :default => "Email"), :class => 'control-label' %>
3 |
4 | <%= f.text_field :email, :class => 'text_field' %>
5 |
6 |
7 |
8 |
9 | <%= f.label :password, t("activerecord.attributes.user.password", :default => "password"), :class => 'control-label' %>
10 |
11 | <%= f.password_field :password, :class => 'password_field' %>
12 |
13 |
14 |
15 | <%= f.label :Password, t("activerecord.attributes.user.password_confirmation", :default => "password_confirmation"), :class => 'control-label' %>
16 |
17 | <%= f.password_field :password_confirmation, :class => 'password_field' %>
18 |
19 |
20 |
21 | <% for role in Role.find(:all) %>
22 |
23 | <%= f.label role.name , :class => 'control-label' %>
24 |
25 | <%= check_box_tag "user[role_ids][]", role.id, @user.roles.include?(role) %>
26 |
27 |
28 | <% end %>
29 |
30 |
31 |
32 | Save or
33 | <%= link_to "Cancel", admin_users_path %>
34 |
--------------------------------------------------------------------------------
/app/views/threats/ioc_list.html.erb:
--------------------------------------------------------------------------------
1 |
4 |
5 |
Found <%= @tagged %>
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
Malware
16 |
17 |
18 |
19 | MD5
20 |
21 |
22 |
23 | <% @mal_matches.each do |item| %>
24 |
25 | <%= item %>
26 |
27 | <% end %>
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
IOC
38 |
39 |
40 |
41 | Indicator
42 |
43 |
44 |
45 | <% @ioc_matches.each do |item| %>
46 |
47 | <%= item %>
48 |
49 | <% end %>
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/db/migrate/20150201011228_create_delayed_jobs.rb:
--------------------------------------------------------------------------------
1 | class CreateDelayedJobs < ActiveRecord::Migration[4.2]
2 | def self.up
3 | create_table :delayed_jobs, force: true do |table|
4 | table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
5 | table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually.
6 | table.text :handler, null: false # YAML-encoded string of the object that will do work
7 | table.text :last_error # reason for last failure (See Note below)
8 | table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
9 | table.datetime :locked_at # Set when a client is working on this object
10 | table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
11 | table.string :locked_by # Who is working on this object (if locked)
12 | table.string :queue # The name of the queue this job is in
13 | table.timestamps null: true
14 | end
15 |
16 | add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority"
17 | end
18 |
19 | def self.down
20 | drop_table :delayed_jobs
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | Cyber Intelligence Management Platform
4 | ---------
5 | []()
6 | [](https://travis-ci.org/opensourcesec/malstrom)
7 | [](https://heroku.com/deploy)
8 |
9 | Malstrom aims to be a repository for threat tracking and forensic artifacts, but also stores YARA rules and notes for investigation
10 |
11 | ### Dashboard
12 | 
13 |
14 | ### Malware Samples
15 | 
16 |
17 | ### Malware File Details
18 | 
19 |
20 | ### Threat Tag Cloud
21 | 
22 |
23 | ### IOC Extraction and Storage
24 | 
25 |
26 | ### YARA Rule Storage
27 | 
28 |
29 | Installation
30 | ---------
31 | * Clone repository
32 | * Edit app/assets/vt.key and input your VirusTotal API key as the only line in the file
33 | * cd into project directory and run 'bundle install'
34 | * setup the database.yml config file for your chosen DB
35 | * Type 'rake db:migrate' to run database migrations
36 | * Run
37 | `RAILS_ENV=production bundle exec rake assets:precompile` to precompile assets
38 | * Finally, run the server with the command 'rails server -e production'
39 |
--------------------------------------------------------------------------------
/app/views/layouts/_navigation_links.html.erb:
--------------------------------------------------------------------------------
1 | <%# add navigation links to this file %>
2 | <% if user_signed_in? %>
3 | <%= link_to 'Samples', samples_list_path, :id => "#samplelist", :class => "Samples" %>
4 |
5 |
6 | IOC
7 |
12 |
13 |
14 | Tools
15 |
21 |
22 | <% else %>
23 | <%= button_to 'Login', new_user_session_path %>
24 | <% end %>
25 |
26 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/tree.css.scss:
--------------------------------------------------------------------------------
1 | .tree {
2 | min-height:20px;
3 | padding:19px;
4 | margin-bottom:20px;
5 | background-color:#fbfbfb;
6 | border:1px solid #999;
7 | -webkit-border-radius:4px;
8 | -moz-border-radius:4px;
9 | border-radius:4px;
10 | -webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05);
11 | -moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05);
12 | box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05)
13 | }
14 | .tree li {
15 | list-style-type:none;
16 | margin:0;
17 | padding:10px 5px 0 5px;
18 | position:relative
19 | }
20 | .tree li::before, .tree li::after {
21 | content:'';
22 | left:-20px;
23 | position:absolute;
24 | right:auto
25 | }
26 | .tree li::before {
27 | border-left:1px solid #999;
28 | bottom:50px;
29 | height:100%;
30 | top:0;
31 | width:1px
32 | }
33 | .tree li::after {
34 | border-top:1px solid #999;
35 | height:20px;
36 | top:25px;
37 | width:25px
38 | }
39 | .tree li span {
40 | -moz-border-radius:5px;
41 | -webkit-border-radius:5px;
42 | border:1px solid #999;
43 | border-radius:5px;
44 | display:inline-block;
45 | padding:3px 8px;
46 | text-decoration:none
47 | }
48 | .tree li.parent_li>span {
49 | cursor:pointer
50 | }
51 | .tree>ul>li::before, .tree>ul>li::after {
52 | border:0
53 | }
54 | .tree li:last-child::before {
55 | height:30px
56 | }
57 | .tree li.parent_li>span:hover, .tree li.parent_li>span:hover+ul li span {
58 | background:#eee;
59 | border:1px solid #94a0b4;
60 | color:#000
61 | }
--------------------------------------------------------------------------------
/app/views/search/indicators.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Feeds
6 |
7 |
8 | Indicators
9 |
10 |
11 |
12 |
36 |
37 |
--------------------------------------------------------------------------------
/db/migrate/20140411031549_devise_create_users.rb:
--------------------------------------------------------------------------------
1 | class DeviseCreateUsers < ActiveRecord::Migration[4.2]
2 | def change
3 | create_table(:users) do |t|
4 | ## Database authenticatable
5 | t.string :email, null: false, default: ""
6 | t.string :encrypted_password, null: false, default: ""
7 |
8 | ## Recoverable
9 | t.string :reset_password_token
10 | t.datetime :reset_password_sent_at
11 |
12 | ## Rememberable
13 | t.datetime :remember_created_at
14 |
15 | ## Trackable
16 | t.integer :sign_in_count, default: 0, null: false
17 | t.datetime :current_sign_in_at
18 | t.datetime :last_sign_in_at
19 | t.string :current_sign_in_ip
20 | t.string :last_sign_in_ip
21 |
22 | ## Confirmable
23 | # t.string :confirmation_token
24 | # t.datetime :confirmed_at
25 | # t.datetime :confirmation_sent_at
26 | # t.string :unconfirmed_email # Only if using reconfirmable
27 |
28 | ## Lockable
29 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
30 | # t.string :unlock_token # Only if unlock strategy is :email or :both
31 | # t.datetime :locked_at
32 |
33 |
34 | t.timestamps
35 | end
36 |
37 | add_index :users, :email, unique: true
38 | add_index :users, :reset_password_token, unique: true
39 | # add_index :users, :confirmation_token, unique: true
40 | # add_index :users, :unlock_token, unique: true
41 | end
42 | end
43 |
--------------------------------------------------------------------------------
/app/toolbox/find_artifacts.rb:
--------------------------------------------------------------------------------
1 | class FindArtifacts
2 | def ipv4(line, tags)
3 | patt = '((?:(?:[12]\d?\d?|[1-9]\d|[1-9])\.){3}(?:[12]\d?\d?|[\d+]{1,2}))'
4 | matches = line.scan(/#{patt}/)
5 | matches.each do |match|
6 | match = match[0]
7 | if match == nil
8 | elsif Element.exists?(:value => match)
9 | else
10 | match = match.downcase
11 | @ip = Element.create do |i|
12 | i.value = match
13 | i.kind = 'IP'
14 | i.tag_list = tags
15 | end
16 | end
17 | end
18 | end
19 |
20 | def domain(line, tags)
21 | patt = '([a-z0-9]+(?:[\-|\.][a-z0-9]+)*(?:\[\.\]|\.)(?:com|net|ru|org|de|uk|jp|br|pl|info|fr|it|cn|in|su|pw|biz|co|eu|nl))'
22 | matches = line.scan(/#{patt}/)
23 | matches.each do |match|
24 | match = match[0]
25 | if match == nil
26 | elsif Element.exists?(:value => match)
27 | else
28 | match = match.downcase
29 | @domain = Element.create do |i|
30 | i.value = match
31 | i.kind = 'Domain'
32 | i.tag_list = tags
33 | end
34 | end
35 | end
36 | end
37 |
38 | def md5(line, tags)
39 | patt = "([A-Fa-f0-9]{32})"
40 | matches = line.scan(/#{patt}/)
41 | matches.each do |match|
42 | match = match[0]
43 | if match == nil
44 | elsif Element.exists?(:value => match)
45 | else
46 | match = match.downcase
47 | @domain = Element.create do |i|
48 | i.value = match
49 | i.kind = 'MD5'
50 | i.tag_list = tags
51 | end
52 | end
53 | end
54 | end
55 | end
--------------------------------------------------------------------------------
/app/views/samples/upload.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Upload new samples:
7 |
8 | <%= form_tag @sample, html: {action: :upload_malz}, multipart: true do %>
9 | <%= file_field_tag 'malz' %>
10 |
Compressed?
11 |
12 |
13 |
14 |
15 | <%= check_box_tag(:box) %>
16 | <%= label_tag(:box, "Unzip") %>
17 |
18 | <%= text_field(:passwd, :box, :class => "form-control", :placeholder => "password (if encrypted)") %>
19 |
20 |
21 |
22 |
Tags
23 |
24 |
25 |
26 | <%= text_field(:tag_list, :malz, :class => "form-control", :placeholder => "Max++, Rootkit, APT") %>
27 |
28 | <%= submit_tag("Upload", class: "btn btn-primary")%>
29 |
30 |
31 |
32 |
33 | <% end %>
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/public/500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | We're sorry, but something went wrong (500)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
We're sorry, but something went wrong.
62 |
63 |
If you are the application owner check the logs for more information.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/app/views/layouts/_navigation.html.erb:
--------------------------------------------------------------------------------
1 | <%# navigation styled for Bootstrap 3.0 %>
2 |
3 |
4 |
13 |
14 | <% if user_signed_in? %>
15 |
16 | <%= render 'layouts/navigation_links' %>
17 |
18 |
19 | <%= render 'layouts/navigation_links2' %>
20 |
21 |
22 | <% else %>
23 |
32 | <% end %>
33 |
34 |
35 |
36 |
37 |
42 |
43 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Do not eager load code on boot. This avoids loading your whole application
11 | # just for the purpose of running a single test. If you are using a tool that
12 | # preloads Rails for running tests, you may have to set it to true.
13 | config.eager_load = false
14 |
15 | # Configure static asset server for tests with Cache-Control for performance.
16 | config.serve_static_assets = true
17 | config.static_cache_control = 'public, max-age=3600'
18 |
19 | # Show full error reports and disable caching.
20 | config.consider_all_requests_local = true
21 | config.action_controller.perform_caching = false
22 |
23 | # Raise exceptions instead of rendering exception templates.
24 | config.action_dispatch.show_exceptions = false
25 |
26 | # Disable request forgery protection in test environment.
27 | config.action_controller.allow_forgery_protection = false
28 |
29 | # Tell Action Mailer not to deliver emails to the real world.
30 | # The :test delivery method accumulates sent emails in the
31 | # ActionMailer::Base.deliveries array.
32 | config.action_mailer.delivery_method = :test
33 |
34 | # Print deprecation notices to the stderr.
35 | config.active_support.deprecation = :stderr
36 |
37 | # Raises error for missing translations
38 | # config.action_view.raise_on_missing_translations = true
39 | end
40 |
--------------------------------------------------------------------------------
/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The change you wanted was rejected (422)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The change you wanted was rejected.
62 |
Maybe you tried to change something you didn't have access to.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/app/views/devise/registrations/edit.html.erb:
--------------------------------------------------------------------------------
1 |
37 |
38 |
Delete Account
39 | <%= button_to "Delete", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete, :class => 'btn btn-danger' %>
40 |
41 |
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/app/views/feeds/list.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Feeds
6 |
7 | <%= image_tag("rss_cube.png", :size => "65x35", :style => "float :left",:crop => :fill) %>
8 | Add Threat Feed <%= link_to '', feeds_new_feed_path, class: 'glyphicon glyphicon-plus btn btn-success' %>
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | Name
18 | URL
19 | Run Now
20 |
21 | Remove
22 | Tags
23 |
24 |
25 |
26 | <% @feeds.each do |feed| %>
27 |
28 | <%= feed.name %>
29 | <%= feed.url %>
30 | <%= link_to '', feeds_run_feed_path(:url => feed.url, :name => feed.name, :tags => feed.tag_list), class: 'glyphicon glyphicon-retweet btn btn-primary' %>
31 |
39 | <%= link_to '', feeds_delete_feed_path(:name => feed.name), class: 'glyphicon glyphicon-trash btn btn-danger' %>
40 | <% feed.tag_list.each do |tag| %>
41 | <%= link_to tag, threats_ioc_list_path(:tag => tag), :class => 'label label-large label-info' %>
42 | <% end %>
43 |
44 | <% end %>
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the web server when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Do not eager load code on boot.
10 | config.eager_load = false
11 |
12 | # Show full error reports and disable caching.
13 | config.consider_all_requests_local = true
14 | config.action_controller.perform_caching = false
15 |
16 | # Don't care if the mailer can't send.
17 | config.action_mailer.raise_delivery_errors = false
18 |
19 | # Print deprecation notices to the Rails logger.
20 | config.active_support.deprecation = :log
21 |
22 | # Raise an error on page load if there are pending migrations.
23 | config.active_record.migration_error = :page_load
24 |
25 | # Debug mode disables concatenation and preprocessing of assets.
26 | # This option may cause significant delays in view rendering with a large
27 | # number of complex assets.
28 | config.assets.debug = true # ActionMailer Config
29 | config.action_mailer.default_url_options = { :host => 'localhost:3000' }
30 | config.action_mailer.delivery_method = :smtp
31 | config.action_mailer.raise_delivery_errors = true
32 | # Send email in development mode?
33 | config.action_mailer.perform_deliveries = true
34 |
35 |
36 | # Adds additional error checking when serving assets at runtime.
37 | # Checks for improperly declared sprockets dependencies.
38 | # Raises helpful error messages.
39 | config.assets.raise_runtime_errors = true
40 |
41 | # Raises error for missing translations
42 | # config.action_view.raise_on_missing_translations = true
43 | end
44 |
--------------------------------------------------------------------------------
/config/initializers/simple_form_bootstrap.rb:
--------------------------------------------------------------------------------
1 | # Use this setup block to configure all options available in SimpleForm.
2 | SimpleForm.setup do |config|
3 | config.wrappers :bootstrap, tag: 'div', class: 'control-group', error_class: 'error' do |b|
4 | b.use :html5
5 | b.use :placeholder
6 | b.use :label
7 | b.wrapper tag: 'div', class: 'controls' do |ba|
8 | ba.use :input
9 | ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
10 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
11 | end
12 | end
13 |
14 | config.wrappers :prepend, tag: 'div', class: "control-group", error_class: 'error' do |b|
15 | b.use :html5
16 | b.use :placeholder
17 | b.use :label
18 | b.wrapper tag: 'div', class: 'controls' do |input|
19 | input.wrapper tag: 'div', class: 'input-prepend' do |prepend|
20 | prepend.use :input
21 | end
22 | input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
23 | input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
24 | end
25 | end
26 |
27 | config.wrappers :append, tag: 'div', class: "control-group", error_class: 'error' do |b|
28 | b.use :html5
29 | b.use :placeholder
30 | b.use :label
31 | b.wrapper tag: 'div', class: 'controls' do |input|
32 | input.wrapper tag: 'div', class: 'input-append' do |append|
33 | append.use :input
34 | end
35 | input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
36 | input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
37 | end
38 | end
39 |
40 | # Wrappers for forms and inputs using the Twitter Bootstrap toolkit.
41 | # Check the Bootstrap docs (http://twitter.github.com/bootstrap)
42 | # to learn about the different styles for forms and inputs,
43 | # buttons and other elements.
44 | config.default_wrapper = :bootstrap
45 | end
46 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #----------------------------------------------------------------------------
2 | # Ignore these files when commiting to a git repository.
3 | #
4 | # See http://help.github.com/ignore-files/ for more about ignoring files.
5 | #
6 | # The original version of this file is found here:
7 | # https://github.com/RailsApps/rails-composer/blob/master/files/gitignore.txt
8 | #
9 | # Corrections? Improvements? Create a GitHub issue:
10 | # http://github.com/RailsApps/rails-composer/issues
11 | #----------------------------------------------------------------------------
12 |
13 | # bundler state
14 | /.bundle
15 | /vendor/bundle/
16 | /vendor/ruby/
17 |
18 | # minimal Rails specific artifacts
19 | db/*.sqlite3
20 | /db/*.sqlite3-journal
21 | /log/*
22 | /tmp/*
23 |
24 | # various artifacts
25 | **.war
26 | *.rbc
27 | *.sassc
28 | .rspec
29 | .redcar/
30 | .sass-cache
31 | /config/config.yml
32 | /coverage.data
33 | /coverage/
34 | /db/*.javadb/
35 | /db/*.sqlite3
36 | /doc/api/
37 | /doc/app/
38 | /doc/features.html
39 | /doc/specs.html
40 | /public/cache
41 | /public/stylesheets/compiled
42 | /public/system/*
43 | /spec/tmp/*
44 | /cache
45 | /capybara*
46 | /capybara-*.html
47 | /gems
48 | /specifications
49 | rerun.txt
50 | pickle-email-*.html
51 | .zeus.sock
52 |
53 | # If you find yourself ignoring temporary files generated by your text editor
54 | # or operating system, you probably want to add a global ignore instead:
55 | # git config --global core.excludesfile ~/.gitignore_global
56 | #
57 | # Here are some files you may want to ignore globally:
58 |
59 | # scm revert files
60 | **.orig
61 |
62 | # Mac finder artifacts
63 | .DS_Store
64 |
65 | # Netbeans project directory
66 | /nbproject/
67 |
68 | # RubyMine project files
69 | .idea
70 |
71 | # Textmate project files
72 | /*.tmproj
73 |
74 | # vim artifacts
75 | **.swp
76 |
77 | # Environment files that may contain sensitive data
78 | .env
79 | .powenv
80 |
--------------------------------------------------------------------------------
/app/views/samples/analysis.html.erb:
--------------------------------------------------------------------------------
1 | File: <%= @sample.malz_file_name %>
2 |
3 |
4 |
5 |
6 |
Details
7 |
8 |
9 | Type: <%= @type %>
10 | Size: <%= @sample.malz_file_size %>
11 | MD5: <%= @sample.md5sum %>
12 | SHA1: <%= @sample.sha1sum %>
13 | SHA256: <%= @sample.sha256 %>
14 |
15 |
16 |
17 |
18 |
Analysis
19 |
20 |
21 |
22 | <%= @sample.deepdive %>
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | Virustotal Detection: <%= link_to @sample.detection, "http://virustotal.com/en/file/#{@sample.sha256}/analysis", :target => "_blank", :class => "label label-danger" %>
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
Notes
42 |
43 |
44 | <%= form_tag("add_note", method: "post") do %>
45 | <%= label_tag(:add_note, '') %>
46 |
47 | <%= text_area_tag(:note_content, "#{@sample.notes}", size: "52x15") %>
48 | <%= hidden_field_tag(:sample_id, @sample.id) %>
49 |
50 |
51 | <%= submit_tag("Save", class: "btn btn-primary") %>
52 |
53 | <% end %>
54 |
55 |
56 |
--------------------------------------------------------------------------------
/app/toolbox/pe.rb:
--------------------------------------------------------------------------------
1 | ### PEdump Module
2 |
3 | require 'pedump'
4 | require 'json/add/struct'
5 |
6 | def pedumper(fi)
7 | fi = File.open(fi)
8 | pe = PEdump.new
9 |
10 | ### Get Compiler
11 | begin
12 | data = pe.packer(fi)
13 | packban = <<-packban
14 | +-------------------+
15 | | Packer/Compiler |
16 | +-------------------+
17 | packban
18 | packer = "#{data[0]['packer']['name']} "
19 | rescue
20 | packer = "Error. Could not get compiler/packer information. "
21 | end
22 |
23 | ### Parse Sections ###
24 | begin
25 | data = pe.sections(fi)
26 | sect = data.to_json
27 | sections = JSON.parse(sect, :create_additions => true)
28 | secban = <<-secban
29 |
30 | +----------+
31 | | Sections |
32 | +----------+
33 | secban
34 | section_headers = "NAME SIZE RVA "
35 | section_data = ''
36 | count = 0
37 | while count < sections.length
38 | par = sections[count]
39 | section_data += "#{par['Name']} #{par['SizeOfRawData']} #{par['VirtualAddress']} "
40 | count += 1
41 | end
42 | rescue
43 | section_data = "Error. Could not parse the sections "
44 | end
45 |
46 | begin
47 | data = pe.resources(fi)
48 | sect = data.to_json
49 | resources = JSON.parse(sect, :create_additions => true)
50 | resban = <<-resban
51 |
52 | +-----------+
53 | | Resources |
54 | +-----------+
55 | resban
56 | resource_headers = "OFFSET CP LANG SIZE TYPE NAME "
57 | resource_data = ''
58 | count = 0
59 | while count < resources.length
60 | par = resources[count]
61 | resource_data += "#{par['file_offset']} #{par['cp']} #{par['lang']} #{par['size']} #{par['type']} #{par['name']} "
62 | count += 1
63 | end
64 | rescue
65 | resource_data = "Error. Could not parse the resources "
66 | end
67 |
68 | data = "#{packban} #{packer} #{secban} #{section_headers} #{section_data} #{resban} #{resource_headers} #{resource_data}"
69 | return data
70 | end
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/app/toolbox/analyzer.rb:
--------------------------------------------------------------------------------
1 | require 'hex_string'
2 | require 'digest'
3 | require 'exifr'
4 | require 'metasm'
5 | require 'pe'
6 | require_relative 'virustotal'
7 |
8 | class Analysis
9 |
10 | ######################### Hashing Module ########################
11 |
12 | def hashes(sample, file)
13 | sha256hash = Digest::SHA256.file(sample).hexdigest
14 | sha1hash = Digest::SHA1.file(sample).hexdigest
15 | md5hash = Digest::MD5.file(sample).hexdigest
16 | samp = Sample.find_by_malz_file_name(file)
17 | samp.sha256 = sha256hash
18 | samp.sha1sum = sha1hash
19 | samp.md5sum = md5hash
20 |
21 | vt = VirusTotal.new
22 | detect = vt.vtquery(sha256hash)
23 | samp.detection = detect
24 |
25 | samp.save
26 |
27 | end
28 |
29 |
30 | ######################### PE Module ########################
31 |
32 |
33 | def scan_pe(sample)
34 | ## Analyzes PE Files
35 |
36 | ## Set Image File Header values ##
37 | #win32 = "014c"
38 | #itanium64 = "0200"
39 | #winamd64 = "8664"
40 |
41 | data = pedumper(sample)
42 |
43 | return data
44 | end
45 |
46 | ######################### PDF Module ########################
47 |
48 |
49 | def scan_pdf(sample)
50 | ## Analyzes PDF Files
51 | end
52 |
53 | ######################### JPG Module ########################
54 |
55 |
56 | def scan_jpg(sample)
57 | ## Analyzes JPG files
58 | #img = EXIFR::JPEG.new
59 | #meta = img.inspect
60 | #puts meta
61 | end
62 |
63 | ######################### ELF Module ########################
64 |
65 |
66 | def scan_elf(sample)
67 | ## Provide hashes
68 | elf = Metasm::ELF.decode_file(sample)
69 | ## Output strings to file
70 | strings(sample)
71 | end
72 |
73 |
74 | ######################### Script Module ########################
75 |
76 |
77 | def scan_script(file)
78 | ## Analyzes Script files
79 |
80 | sample = File.open(file, 'r')
81 | contents = sample.readlines.first.chomp
82 | end
83 |
84 |
85 | ######################### Strings Module ########################
86 |
87 |
88 | def strings(sample)
89 | ## Writes file strings to a text file
90 |
91 | strings = `strings #{sample}`
92 |
93 | end
94 | end
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Malstrom::Application.routes.draw do
2 |
3 | get 'samples/list'
4 |
5 | get 'threats/tags'
6 |
7 | get 'threats/ioc_list'
8 |
9 | get 'threats/profiles'
10 |
11 | get 'threats/analysis'
12 |
13 | get 'feeds/ioc'
14 |
15 | get 'feeds/import'
16 |
17 | post 'feeds/import' => "feeds#extract"
18 | resources :extract, :controller => "feeds"
19 |
20 | get 'feeds/list'
21 |
22 | get 'feeds/new_feed'
23 |
24 | post 'feeds/add_feed' => "feeds#create"
25 | resources :add_feed, :controller => "feeds"
26 |
27 | get 'feeds/run_feed' => "feeds#run_feed"
28 | resources :run_feed, :controller => "feeds"
29 |
30 | get 'feeds/delete_feed' => "feeds#delete_feed"
31 | resources :delete_feed, :controller => "feeds"
32 |
33 | get 'search/delete_iocs' => "search#delete_iocs"
34 |
35 | get 'search/indicators'
36 |
37 | get 'search/index'
38 |
39 | post 'search/index'
40 |
41 | post 'search/indicators' => "search#index"
42 |
43 | get "samples/list/yara" => 'samples#yara', :as => :samples_yara
44 | resources :yara, :controller => "samples"
45 |
46 | get "samples/download_malz", :to => "samples#download_malz"
47 |
48 | get "samples/list/upload" => 'samples#upload', :as => :samples_upload
49 | resources :upload, :controller => "samples"
50 |
51 | post "samples/list" => "samples#upload_malz"
52 |
53 | get 'samples/delete_sample' => "samples#delete_malz"
54 | resources :delete_malz, :controller => "samples"
55 |
56 | get "samples/analysis" => "samples#analysis"
57 |
58 | post "samples/add_note" => "samples#add_note"
59 |
60 | get "samples/remove_rule" => "samples#remove_rule"
61 |
62 | get "samples/new_yara" => "samples#new_yara"
63 |
64 | post "samples/save_sig" => "samples#process_sig"
65 |
66 | post "samples/addrule" => "samples#add_rule"
67 |
68 | #if Rails.env.production?
69 | #devise_for :users, :controllers => { :registrations => "registrations" }
70 | #else
71 | devise_for :users, :path_names => {:sign_in => "login", :sign_out => "logout"}, :path => "d"
72 | resources :users
73 | #end
74 |
75 | root :to => "home#index"
76 | namespace :admin do
77 | get '/' => 'users#index'
78 | resources :users
79 | end
80 | end
81 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/framework_and_overrides.css.scss:
--------------------------------------------------------------------------------
1 | // Temporary workaround for Rails 4.1.2 pending releaase of bootstrap-sass 3.1.2
2 | //= depend_on_asset "bootstrap/glyphicons-halflings-regular.eot"
3 | //= depend_on_asset "bootstrap/glyphicons-halflings-regular.svg"
4 | //= depend_on_asset "bootstrap/glyphicons-halflings-regular.ttf"
5 | //= depend_on_asset "bootstrap/glyphicons-halflings-regular.woff"
6 |
7 | // import the CSS framework
8 | @import "bootstrap";
9 |
10 | // make all images responsive by default
11 | img {
12 | @extend .img-responsive;
13 | margin: 0 auto;
14 | }
15 | // override for the 'Home' navigation link
16 | .navbar-brand {
17 | font-size: inherit;
18 | }
19 |
20 | // THESE ARE EXAMPLES YOU CAN MODIFY
21 | // create your own classes
22 | // to make views framework-neutral
23 | .column {
24 | @extend .col-md-6;
25 | @extend .text-center;
26 | }
27 | .form {
28 | @extend .col-md-6;
29 | }
30 | .form-centered {
31 | @extend .col-md-6;
32 | @extend .text-center;
33 | }
34 | .submit {
35 | @extend .btn;
36 | @extend .btn-primary;
37 | @extend .btn-lg;
38 | }
39 | // apply styles to HTML elements
40 | // to make views framework-neutral
41 | main {
42 | @extend .container;
43 | background-color: #eee;
44 | padding-bottom: 50px;
45 | width: 100%;
46 | margin-top: 51px; // accommodate the navbar
47 | }
48 | section {
49 | @extend .row;
50 | margin-top: 20px;
51 | }
52 |
53 | // Styles for Devise views
54 | // using Bootstrap
55 | // generated by the rails_layout gem
56 | .authform {
57 | padding-top: 30px;
58 | max-width: 320px;
59 | margin: 0 auto;
60 | }
61 | .authform form {
62 | @extend .well;
63 | @extend .well-lg;
64 | padding-bottom: 40px;
65 | }
66 | .authform .right {
67 | float: right !important;
68 | }
69 | .authform .button {
70 | @extend .btn;
71 | @extend .btn-primary;
72 | }
73 | .authform fieldset {
74 | @extend .well;
75 | }
76 | #error_explanation {
77 | @extend .alert;
78 | @extend .alert-danger;
79 | }
80 | #error_explanation h2 {
81 | font-size: 16px;
82 | }
83 | .button-xs {
84 | @extend .btn;
85 | @extend .btn-primary;
86 | @extend .btn-xs;
87 | }
88 |
89 | .css1 { font-size: 1.0em; }
90 | .css2 { font-size: 1.2em; }
91 | .css3 { font-size: 1.4em; }
92 | .css4 { font-size: 1.6em; }
93 |
--------------------------------------------------------------------------------
/app/views/home/index.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | <% if user_signed_in? %>
7 |
8 |
9 |
10 |
11 |
Malware
12 |
13 |
14 |
Samples
15 |
16 |
<%= Sample.count(:all)%>
17 |
18 |
19 |
20 |
21 |
Yara Signatures
22 |
23 | <% @files = Dir['app/assets/yara/*.yar']%>
24 |
<%= @files.length %>
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
Intelligence
35 |
36 |
37 |
Feeds
38 |
39 |
<%= Feeds.count(:all)%>
40 |
41 |
42 |
43 |
44 |
Indicators
45 |
46 |
<%= Element.count(:all)%>
47 |
48 |
49 |
50 |
51 |
52 |
53 | <% else %>
54 |
55 |
56 |
57 |
58 | <%= link_to "Login", new_user_session_path, :class => "btn btn-primary" %>
59 |
60 | <%= link_to "Register", new_user_registration_path, :class => "btn btn-primary" %>
61 |
62 |
63 |
64 |
65 | <% end %>
66 |
67 |
--------------------------------------------------------------------------------
/app/controllers/admin/users_controller.rb:
--------------------------------------------------------------------------------
1 | class Admin::UsersController < Admin::AdminController
2 | #load_and_authorize_resource
3 | # GET /users
4 | # GET /users.json
5 | def index
6 | @users = User.all
7 |
8 | respond_to do |format|
9 | format.html # index.html.erb
10 | format.json { render :json => @users }
11 | end
12 | end
13 |
14 | # GET /users/1
15 | # GET /users/1.json
16 | def show
17 | @user = User.find(params[:id])
18 |
19 | respond_to do |format|
20 | format.html # show.html.erb
21 | format.json { render :json => @user }
22 | end
23 | end
24 |
25 | # GET /users/new
26 | # GET /users/new.json
27 | def new
28 | @user = User.new
29 | respond_to do |format|
30 | format.html # new.html.erb
31 | format.json { render :json => @user }
32 | end
33 | end
34 |
35 | # GET /users/1/edit
36 | def edit
37 | @user = User.find(params[:id])
38 | end
39 |
40 | # POST /users
41 | # POST /users.json
42 | def create
43 | @user.attributes = params[:user]
44 | @user.role_ids = params[:user][:role_ids] if params[:user]
45 | @user = User.new(params[:user])
46 | respond_to do |format|
47 | if @user.save
48 | flash[:notice] = flash[:notice].to_a.concat @user.errors.full_messages
49 | format.html { redirect_to admin_users_path, :notice => 'User was successfully created.' }
50 | format.json { render :json => @user, :status => :created, :location => @user }
51 | else
52 | flash[:notice] = flash[:notice].to_a.concat @user.errors.full_messages
53 | format.html { render :action => "new"}
54 | format.json { render :json => @user.errors, :status => :unprocessable_entity }
55 | end
56 | end
57 | end
58 |
59 | # PUT /users/1
60 | # PUT /users/1.json
61 | def update
62 | @user = User.find(params[:id])
63 | if params[:user][:password].blank?
64 | params[:user].delete(:password)
65 | params[:user].delete(:password_confirmation)
66 | end
67 |
68 | respond_to do |format|
69 | if @user.update_attributes(params[:user])
70 | format.html { redirect_to admin_users_path, :notice => 'User was successfully updated.' }
71 | format.json { head :ok }
72 | else
73 | format.html { render :action => "edit" }
74 | format.json { render :json => @user.errors, :status => :unprocessable_entity }
75 | end
76 | end
77 | end
78 |
79 | # DELETE /users/1
80 | # DELETE /users/1.json
81 | def destroy
82 | @user = User.find(params[:id])
83 | @user.destroy
84 |
85 | respond_to do |format|
86 | format.html { redirect_to admin_users_url }
87 | format.json { head :ok }
88 | end
89 | end
90 | end
--------------------------------------------------------------------------------
/app/controllers/feeds_controller.rb:
--------------------------------------------------------------------------------
1 | require 'find_artifacts'
2 | require 'docsplit'
3 |
4 | class FeedsController < ApplicationController
5 | before_action :authenticate_user!
6 |
7 | def list
8 | # Local var for Feed listing
9 | @feeds = Feeds.all
10 | end
11 |
12 | def feed_params
13 | params.require(:feeds).permit(:name, :url, :tag_list)
14 | end
15 |
16 | def new_feed
17 | @add_feed = Feeds.new
18 | end
19 |
20 | def create
21 | @add_feed = Feeds.new(feed_params)
22 | if @add_feed.save
23 | redirect_to :feeds_list, :notice => "Feed has been saved successfully!"
24 | else
25 | flash.now[:alert] = "Error: Feed can not be saved"
26 | render :feeds_new_feed_path
27 | end
28 | end
29 |
30 | def run_feed
31 | update = Updater.new
32 | # New job for feed update
33 | Thread.new { update.retrieval(params[:url], params[:tags]) }
34 | # Redirect upon job initiation
35 | if update
36 | redirect_to :feeds_list, :notice => "Feed update initiated!"
37 | else
38 | flash.now[:alert] = "Error: Cannot run feed at this time"
39 | render :feeds_list_path
40 | end
41 | end
42 | helper_method :update_feed
43 |
44 | def delete_feed
45 | @feedname = Feeds.find_by_name(params[:name]).delete
46 | if @feedname
47 | redirect_to :feeds_list, :notice => "Feed deleted successfully!"
48 | else
49 | flash.now[:alert] = "Error: Cannot delete feed at this time"
50 | render :feeds_list_path
51 | end
52 | end
53 | helper_method :delete_feed
54 |
55 | def scheduler
56 | # function to keep track of feed scheduling
57 | end
58 |
59 | def extract
60 | # function to import indicators of compromise
61 | extractor = FindArtifacts.new
62 | file_name = params[:ioc_set].original_filename
63 | file_data = params[:ioc_set].tempfile.open.read
64 | tmp_path = "tmp/docsplit/#{file_name}"
65 | tags = params[:tag_list][:upload_ioc]
66 |
67 | # Save uploaded IOC report
68 | File.open(tmp_path, 'wb') { |file| file.write("#{file_data}") }
69 | # Extract text
70 | Docsplit.extract_text(tmp_path, :ocr => false, :output => 'tmp/docsplit')
71 |
72 | # Open TXT file
73 | base_name = file_name.split('.')[0]
74 | data_path = "tmp/docsplit/#{base_name}"
75 | data = File.open("#{data_path}.txt", 'rb').read
76 |
77 | # New jobs for IOC import
78 | Thread.new { extractor.ipv4(data, tags) }
79 | Thread.new { extractor.domain(data, tags) }
80 | Thread.new { extractor.md5(data, tags) }
81 |
82 | if data
83 | #File.delete(tmp_path)
84 | #File.delete(file_name)
85 | redirect_to :feeds_import, :notice => "IOC's are being processed!"
86 | else
87 | flash.now[:alert] = "Error: IOC file could not be processed"
88 | redirect_to :feeds_import
89 | end
90 | end
91 | end
92 |
--------------------------------------------------------------------------------
/app/views/samples/yara.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | <%= image_tag("yara_old-logo.png", :size => "120x150", :style => "float :left",:crop => :fill) %>
5 |
6 |
Add new yara signature <%= link_to '', samples_new_yara_path, :class => 'glyphicon glyphicon-plus btn btn-success' %>
7 |
8 | <% @rules = Dir["app/assets/yara/*.yar"] %>
9 |
10 |
11 |
12 |
Rule Sets
13 |
14 |
15 |
16 | Name
17 | Remove
18 |
19 |
20 |
21 | <% sig_id = 0 %>
22 | <% @rules.each do |x| %>
23 | <% sig_id += 1 %>
24 |
25 | <%= File.basename(x) %>
26 |
27 |
28 |
29 |
30 |
34 |
35 |
40 |
41 |
44 |
45 |
46 |
47 | <%= link_to '', samples_remove_rule_path(:rule_name => File.basename(x)), :class => "btn btn-danger glyphicon glyphicon-trash" %>
48 |
49 | <% end %>
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/app/views/threats/profiles.html.erb:
--------------------------------------------------------------------------------
1 | Threat Profiles
2 |
3 |
4 | <% profiles = Dir["app/views/threats/profile_archive/_*"] %>
5 |
6 |
7 |
8 |
9 | <% count = 1 %>
10 | <% profiles.each do |item| %>
11 | <% item_name = File.basename(item, '.html.erb') %>
12 | <% profile = item_name[1..-1] %>
13 | <%= link_to "#{count}. #{profile}", threats_analysis_path(:profile => profile), :class => 'list-group-item' %>
14 | <% count += count %>
15 | <% end %>
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
29 |
30 | <%= form_tag @new_profile, html: {action: :new_profile}, multipart: true do %>
31 |
36 |
Profile Details
37 |
46 |
47 | Modus Operandi <%= text_field(:passwd, :box, :class => "form-control", :placeholder => "Nation-state actor") %>
48 |
49 |
50 | Tactics & Techniques <%= text_field(:passwd, :box, :class => "form-control", :placeholder => "Spearphishing, Custom Exploits") %>
51 |
52 |
Tags
53 |
54 |
55 |
56 | <%= text_field(:tag_list, :new_profile, :class => "form-control", :placeholder => "APT1, Espionage") %>
57 |
58 | <%# submit_tag("Create", :class => "btn btn-success")%>
59 |
60 |
61 |
62 |
63 | <% end %>
64 |
65 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/app/views/threats/profile_templates/default_template.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Threat Actor
5 |
6 |
7 | Modus Operandi (MO)
8 |
13 |
14 |
15 | Tactics, Techniques & Procedures (TTP)
16 |
17 |
18 | Methods
19 |
24 |
25 |
26 |
27 |
28 | Indicators of Attack & Compromise (IOAC)
29 |
30 |
31 | MD5 Hashes
32 |
33 |
34 | <%= link_to ' ef64872d986a0a5051bfe3b682f14640', samples_list_path(:md5sum => 'ef64872d986a0a5051bfe3b682f14640'), :class => "btn btn-sm" %> – This actor utilizes home-grown malware
35 |
36 |
37 |
38 |
39 | IPv4 C2 Addresses
40 |
45 |
46 |
47 | DNS Compromised Sites
48 |
53 |
54 |
55 | C2 DNS Names
56 |
57 |
58 | <%= link_to ' c2.urpwned.com', feeds_ioc_path(:ioc => 'c2.urpwned.com'), :class => "btn btn-sm" %> – Primary C2 server
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # Code is not reloaded between requests.
5 | config.cache_classes = true
6 |
7 | # Eager load code on boot. This eager loads most of Rails and
8 | # your application in memory, allowing both threaded web servers
9 | # and those relying on copy on write to perform better.
10 | # Rake tasks automatically ignore this option for performance.
11 | config.eager_load = true
12 |
13 | # Full error reports are disabled and caching is turned on.
14 | config.consider_all_requests_local = false
15 | config.action_controller.perform_caching = true
16 |
17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application
18 | # Add `rack-cache` to your Gemfile before enabling this.
19 | # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20 | # config.action_dispatch.rack_cache = true
21 |
22 | # Disable Rails's static asset server (Apache or nginx will already do this).
23 | config.serve_static_assets = false
24 |
25 | # Compress JavaScripts and CSS.
26 | config.assets.js_compressor = :uglifier
27 | # config.assets.css_compressor = :sass
28 |
29 | # Do not fallback to assets pipeline if a precompiled asset is missed.
30 | config.assets.compile = false
31 |
32 | # Generate digests for assets URLs.
33 | config.assets.digest = true
34 |
35 | # Version of your assets, change this if you want to expire all your assets.
36 | config.assets.version = '1.0'
37 |
38 | # Specifies the header that your server uses for sending files.
39 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
40 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
41 |
42 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43 | # config.force_ssl = true
44 |
45 | # Set to :debug to see everything in the log.
46 | config.log_level = :info
47 |
48 | # Prepend all log lines with the following tags.
49 | # config.log_tags = [ :subdomain, :uuid ]
50 |
51 | # Use a different logger for distributed setups.
52 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
53 |
54 | # Use a different cache store in production.
55 | # config.cache_store = :mem_cache_store
56 |
57 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
58 | # config.action_controller.asset_host = "http://assets.example.com"
59 |
60 | # Precompile additional assets.
61 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
62 | # config.assets.precompile += %w( indicators.js )
63 |
64 | # Ignore bad email addresses and do not raise email delivery errors.
65 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
66 | # config.action_mailer.raise_delivery_errors = false
67 |
68 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
69 | # the I18n.default_locale when a translation cannot be found).
70 | config.i18n.fallbacks = true
71 |
72 | # Send deprecation notices to registered listeners.
73 | config.active_support.deprecation = :notify # ActionMailer Config
74 | config.action_mailer.default_url_options = { :host => 'example.com' }
75 | config.action_mailer.delivery_method = :smtp
76 | config.action_mailer.perform_deliveries = true
77 | config.action_mailer.raise_delivery_errors = false
78 |
79 |
80 | # Disable automatic flushing of the log to improve performance.
81 | # config.autoflush_log = false
82 |
83 | # Use default logging formatter so that PID and timestamp are not suppressed.
84 | config.log_formatter = ::Logger::Formatter.new
85 |
86 | # Do not dump schema after migrations.
87 | config.active_record.dump_schema_after_migration = false
88 | end
89 |
--------------------------------------------------------------------------------
/app/views/samples/list.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | <%= image_tag("biohazard-orb.png", :size => "100x60", :style => "float :left",:crop => :fill) %>
5 | Malware Samples
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | DL
16 | MD5
17 | MIME
18 | Detected
19 | Remove
20 | Tags
21 |
22 |
23 |
24 |
25 | <% @all_malz.each do |mal| %>
26 | <%= link_to '', samples_download_malz_path(:sample => mal.malz_file_name), :class => 'glyphicon glyphicon-download-alt btn btn-primary' %>
27 | <%= link_to mal.md5sum, samples_analysis_path(:md5sum => mal.md5sum) %>
28 | <%= mal.malz_content_type %>
29 | <% if mal.detection == 'N/A' %>
30 | <%= mal.detection %>
31 | <% else %>
32 | <%= link_to mal.detection, "http://virustotal.com/en/file/#{mal.sha256}/analysis", :target => "_blank" %>
33 | <% end %>
34 | <%= link_to '', samples_delete_sample_path(:sample_id => mal.id), class: 'glyphicon glyphicon-trash btn btn-danger' %>
35 | <% mal.tag_list.each do |tag| %>
36 | <%= link_to tag, threats_ioc_list_path(:tag => tag), :class => 'label label-large label-info' %>
37 | <% end %>
38 |
39 |
40 | <% end %>
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
54 |
55 |
56 | <%= form_tag @sample, html: {action: :upload_malz}, multipart: true do %>
57 | <%= file_field_tag 'malz' %>
58 |
69 |
70 |
Tags
71 |
72 |
73 |
74 | <%= text_field(:tag_list, :malz, :class => "form-control", :placeholder => "Max++, Rootkit, APT") %>
75 |
76 | <%= submit_tag("Upload", :class => "btn btn-primary")%>
77 |
78 |
79 |
80 |
81 | <% end %>
82 |
83 |
84 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/config/locales/devise.en.yml:
--------------------------------------------------------------------------------
1 | # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2 |
3 | en:
4 | devise:
5 | confirmations:
6 | confirmed: "Your account was successfully confirmed."
7 | send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
8 | send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."
9 | failure:
10 | already_authenticated: "You are already signed in."
11 | inactive: "Your account is not activated yet."
12 | invalid: "Invalid email or password."
13 | locked: "Your account is locked."
14 | last_attempt: "You have one more attempt before your account will be locked."
15 | not_found_in_database: "Invalid email or password."
16 | timeout: "Your session expired. Please sign in again to continue."
17 | unauthenticated: "You need to sign in or sign up before continuing."
18 | unconfirmed: "You have to confirm your account before continuing."
19 | mailer:
20 | confirmation_instructions:
21 | subject: "Confirmation instructions"
22 | reset_password_instructions:
23 | subject: "Reset password instructions"
24 | unlock_instructions:
25 | subject: "Unlock Instructions"
26 | omniauth_callbacks:
27 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
28 | success: "Successfully authenticated from %{kind} account."
29 | passwords:
30 | no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
31 | send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
32 | send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
33 | updated: "Your password was changed successfully. You are now signed in."
34 | updated_not_active: "Your password was changed successfully."
35 | registrations:
36 | destroyed: "Bye! Your account was successfully cancelled. We hope to see you again soon."
37 | signed_up: "Welcome! You have signed up successfully."
38 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
39 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
40 | signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account."
41 | update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
42 | updated: "You updated your account successfully."
43 | sessions:
44 | signed_in: "Signed in successfully."
45 | signed_out: "Signed out successfully."
46 | unlocks:
47 | send_instructions: "You will receive an email with instructions about how to unlock your account in a few minutes."
48 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."
49 | unlocked: "Your account has been unlocked successfully. Please sign in to continue."
50 | errors:
51 | messages:
52 | already_confirmed: "was already confirmed, please try signing in"
53 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
54 | expired: "has expired, please request a new one"
55 | not_found: "not found"
56 | not_locked: "was not locked"
57 | not_saved:
58 | one: "1 error prohibited this %{resource} from being saved:"
59 | other: "%{count} errors prohibited this %{resource} from being saved:"
60 |
--------------------------------------------------------------------------------
/app/views/threats/profile_archive/_test.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Threat Actor
5 |
6 |
7 | Modus Operandi (MO)
8 |
13 |
14 |
15 | Tactics, Techniques & Procedures (TTP)
16 |
17 |
18 | Methods
19 |
24 |
25 |
26 |
27 |
28 | Indicators of Attack & Compromise (IOAC)
29 |
30 |
31 | MD5 Hashes
32 |
33 |
34 | <%= link_to ' ef64872d986a0a5051bfe3b682f14640', samples_list_path(:md5sum => 'ef64872d986a0a5051bfe3b682f14640'), :class => "btn btn-sm" %> – This actor utilizes home-grown malware
35 |
36 |
37 |
38 |
39 | IPv4 C2 Addresses
40 |
45 |
46 |
47 | DNS Compromised Sites
48 |
53 |
54 |
55 | C2 DNS Names
56 |
57 |
58 | <%= link_to ' c2.urpwned.com', feeds_ioc_path(:ioc => 'c2.urpwned.com'), :class => "btn btn-sm" %> – Primary C2 server
59 |
60 |
61 | <%= link_to ' alt-c2.urpwned.com', feeds_ioc_path(:ioc => 'alt-c2.urpwned.com'), :class => "btn btn-sm" %> – Alternate C2 server
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # This file is auto-generated from the current state of the database. Instead
2 | # of editing this file, please use the migrations feature of Active Record to
3 | # incrementally modify your database, and then regenerate this schema definition.
4 | #
5 | # Note that this schema.rb definition is the authoritative source for your
6 | # database schema. If you need to create the application database on another
7 | # system, you should be using db:schema:load, not running all the migrations
8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 | # you'll amass, the slower it'll run and the greater likelihood for issues).
10 | #
11 | # It's strongly recommended that you check this file into your version control system.
12 |
13 | ActiveRecord::Schema.define(version: 20171018201142) do
14 |
15 | # These are extensions that must be enabled in order to support this database
16 | enable_extension "plpgsql"
17 |
18 | create_table "delayed_jobs", force: :cascade do |t|
19 | t.integer "priority", default: 0, null: false
20 | t.integer "attempts", default: 0, null: false
21 | t.text "handler", null: false
22 | t.text "last_error"
23 | t.datetime "run_at"
24 | t.datetime "locked_at"
25 | t.datetime "failed_at"
26 | t.string "locked_by"
27 | t.string "queue"
28 | t.datetime "created_at"
29 | t.datetime "updated_at"
30 | t.index ["priority", "run_at"], name: "delayed_jobs_priority"
31 | end
32 |
33 | create_table "elements", force: :cascade do |t|
34 | t.string "value"
35 | t.datetime "created_at"
36 | t.datetime "updated_at"
37 | t.string "source"
38 | t.string "kind"
39 | end
40 |
41 | create_table "feeds", force: :cascade do |t|
42 | t.string "name"
43 | t.text "last_updated"
44 | t.text "next_run"
45 | t.datetime "created_at"
46 | t.datetime "updated_at"
47 | t.text "url"
48 | end
49 |
50 | create_table "feeds_tags", id: false, force: :cascade do |t|
51 | t.integer "feed_id", null: false
52 | t.integer "tag_id", null: false
53 | t.index ["feed_id", "tag_id"], name: "index_feeds_tags_on_feed_id_and_tag_id"
54 | t.index ["tag_id", "feed_id"], name: "index_feeds_tags_on_tag_id_and_feed_id"
55 | end
56 |
57 | create_table "samples", force: :cascade do |t|
58 | t.string "filename"
59 | t.string "sha256"
60 | t.string "sha1sum"
61 | t.string "md5sum"
62 | t.datetime "created_at"
63 | t.datetime "updated_at"
64 | t.string "malz_file_name"
65 | t.string "malz_content_type"
66 | t.integer "malz_file_size"
67 | t.datetime "malz_updated_at"
68 | t.text "detection"
69 | t.text "deepdive"
70 | t.text "notes"
71 | end
72 |
73 | create_table "taggings", force: :cascade do |t|
74 | t.integer "tag_id"
75 | t.integer "taggable_id"
76 | t.string "taggable_type"
77 | t.integer "tagger_id"
78 | t.string "tagger_type"
79 | t.string "context", limit: 128
80 | t.datetime "created_at"
81 | t.index ["context"], name: "index_taggings_on_context"
82 | t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true
83 | t.index ["tag_id"], name: "index_taggings_on_tag_id"
84 | t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context"
85 | t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy"
86 | t.index ["taggable_id"], name: "index_taggings_on_taggable_id"
87 | t.index ["taggable_type"], name: "index_taggings_on_taggable_type"
88 | t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type"
89 | t.index ["tagger_id"], name: "index_taggings_on_tagger_id"
90 | end
91 |
92 | create_table "tags", force: :cascade do |t|
93 | t.string "name"
94 | t.integer "taggings_count", default: 0
95 | t.index ["name"], name: "index_tags_on_name", unique: true
96 | end
97 |
98 | create_table "users", force: :cascade do |t|
99 | t.string "email", default: "", null: false
100 | t.string "encrypted_password", default: "", null: false
101 | t.string "reset_password_token"
102 | t.datetime "reset_password_sent_at"
103 | t.datetime "remember_created_at"
104 | t.integer "sign_in_count", default: 0, null: false
105 | t.datetime "current_sign_in_at"
106 | t.datetime "last_sign_in_at"
107 | t.string "current_sign_in_ip"
108 | t.string "last_sign_in_ip"
109 | t.datetime "created_at"
110 | t.datetime "updated_at"
111 | t.string "name"
112 | t.index ["email"], name: "index_users_on_email", unique: true
113 | t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
114 | end
115 |
116 | create_table "whois", force: :cascade do |t|
117 | t.string "country"
118 | t.string "state"
119 | t.string "asn"
120 | t.text "registrant"
121 | t.datetime "created_at"
122 | t.datetime "updated_at"
123 | end
124 |
125 | end
126 |
--------------------------------------------------------------------------------
/app/controllers/samples_controller.rb:
--------------------------------------------------------------------------------
1 | require 'digest'
2 | require 'analyzer'
3 | require 'hex_string'
4 | require 'archive/zip'
5 | require 'archive/zip/codec/traditional_encryption'
6 |
7 | class SamplesController < ApplicationController
8 | before_action :authenticate_user!
9 |
10 | def list
11 | @all_malz = Sample.all
12 | end
13 |
14 | # malware downloads
15 | def download_malz
16 | file_name = params[:sample]
17 | base_name = File.basename(file_name, '.*')
18 |
19 | Archive::Zip.archive("tmp/#{base_name}.zip", # destination ZIP file
20 | "app/assets/malware/#{file_name}", # source file to add to ZIP
21 | #:encryption_codec => Archive::Zip::Codec::TraditionalEncryption, # encryption codec
22 | :password => 'infected') # ZIP password
23 |
24 | send_file "tmp/#{base_name}.zip", :type => 'application/octet-stream'
25 |
26 | end
27 |
28 | # malware upload function
29 | def upload_malz
30 | @sample = Sample.new( params[:sample] )
31 | @sample.malz = params[:malz]
32 | @sample.tag_list = params[:tag_list][:malz]
33 | if @sample.save
34 | if params[:box]
35 | if params[:passwd]
36 | unzipper(params[:sample], @sample.malz.path, params[:passwd][:box], params[:tag_list][:malz])
37 | @sample.malz.destroy
38 | @sample.delete
39 | else
40 | pass=''
41 | unzipper(params[:sample], @sample.malz.path, pass, params[:tag_list][:malz])
42 | @sample.malz.destroy
43 | @sample.delete
44 | end
45 | redirect_to samples_list_path, :notice => "Archive was extracted successfully!"
46 | return
47 | end
48 | redirect_to samples_list_path, :notice => "Sample was uploaded successfully!"
49 | end
50 | analyze = Analysis.new
51 | Thread.new { analyze.hashes(@sample.malz.path, @sample.malz_file_name) }
52 | end
53 |
54 | def unzipper(formdata, sample, zip_pass, tags)
55 | if zip_pass.length > 0
56 | if Archive::Zip.extract(sample, 'app/assets/malware', :password => zip_pass) do |zipfile|
57 | zipfile.each do |data|
58 | new_sample = Sample.create(formdata)
59 | new_sample.malz = File.open(data, 'rb')
60 | new_sample.tag_list = tags
61 | analyze = Analysis.new
62 | Thread.new { analyze.hashes(new_sample.malz.path, new_sample.malz_file_name) }
63 | end
64 | end
65 | end
66 | else
67 | if Archive::Zip.extract(sample) do |zipfile|
68 | zipfile.each do |data|
69 | new_sample = Sample.create(formdata)
70 | new_sample.malz = File.open(data, 'rb')
71 | new_sample.tag_list = tags
72 | analyze = Analysis.new
73 | Thread.new { analyze.hashes(new_sample.malz.path, new_sample.malz_file_name) }
74 | end
75 | end
76 | end
77 | end
78 | end
79 |
80 | # sample analysis function
81 | def analysis
82 | @sample = Sample.find_by_md5sum(params[:md5sum])
83 | contents = File.open(@sample.malz.path, 'rb')
84 | content = contents.read
85 | hex = content.to_hex_string
86 | magic = hex[0,5]
87 | scan = Analysis.new
88 |
89 | if magic == "4d 5a"
90 | @type = "PE"
91 | scan_results = scan.scan_pe(contents).html_safe
92 | @sample.deepdive = scan_results
93 | elsif magic == "ff d8"
94 | @type = "JPG"
95 | @page = scan.scan_jpg(content)
96 | elsif magic == "7f 45"
97 | @type = "ELF"
98 | @page = scan.scan_elf(content)
99 | elsif magic == "25 50"
100 | @type = "PDF"
101 | @page = "default"
102 | else
103 | @type = `file #{@sample.malz.path} | cut -d ':' -f 2`
104 | @page = "default"
105 | end
106 | end
107 |
108 |
109 | # parameterss for sample uploads
110 | def sample_params
111 | params.require(:sample).permit(:filename, :malz, :hash, :tags_list)
112 | end
113 |
114 | # malware removal function
115 | def delete_malz
116 | samps = Sample.find_by_id(params[:sample_id])
117 | samps.malz.destroy
118 | samps.delete
119 | redirect_to samples_list_path, :notice => "Sample deleted successfully!"
120 | end
121 |
122 | # add notes
123 | def add_note
124 | sample = Sample.find_by_id(params[:sample_id])
125 | note_contents = params[:note_content]
126 | sample.notes = note_contents
127 | if sample.save
128 | redirect_to samples_analysis_path(:md5sum => sample.md5sum), :notice => "Notes have been updated successfully!"
129 | else
130 | redirect_to samples_list_path, :alert => "Error: Could not save notes"
131 | end
132 | end
133 |
134 | # parameterss for notes
135 | def add_note_params
136 | params.require(:note_content, :sample_id)
137 | end
138 |
139 | # add yara signatures
140 | def add_rule
141 | new_rule_content = params[:rule_body]
142 | patt = 'rule.*\{'
143 | syntax_check = /#{patt}/.match(new_rule_content)
144 | if syntax_check.nil?
145 | redirect_to samples_list_path, :alert => "Syntax - 'rule {' not found!"
146 | return
147 | end
148 | rule_name = params[:rule_name]
149 | new_rule_path = "app/assets/yara/#{rule_name}.yar"
150 | begin
151 | File.write(new_rule_path, new_rule_content)
152 | redirect_to samples_yara_path, :notice => "Signature has been uploaded successfully!"
153 | rescue
154 | redirect_to samples_yara_path, :alert => "Error: Could not create rule"
155 | end
156 | end
157 |
158 | # delete yara rule
159 | def remove_rule
160 | # delete rule here function here
161 | rule_name = params[:rule_name]
162 | rule_path = "app/assets/yara/#{rule_name}"
163 | begin
164 | File.delete(rule_path)
165 | redirect_to samples_yara_path, :notice => "Signature has been deleted successfully!"
166 | rescue
167 | redirect_to samples_yara_path, :alert => "Could not delete rule"
168 | end
169 | end
170 | end
171 |
--------------------------------------------------------------------------------
/config/initializers/simple_form.rb:
--------------------------------------------------------------------------------
1 | # Use this setup block to configure all options available in SimpleForm.
2 | SimpleForm.setup do |config|
3 | # Wrappers are used by the form builder to generate a
4 | # complete input. You can remove any component from the
5 | # wrapper, change the order or even add your own to the
6 | # stack. The options given below are used to wrap the
7 | # whole input.
8 | config.wrappers :default, class: :input,
9 | hint_class: :field_with_hint, error_class: :field_with_errors do |b|
10 | ## Extensions enabled by default
11 | # Any of these extensions can be disabled for a
12 | # given input by passing: `f.input EXTENSION_NAME => false`.
13 | # You can make any of these extensions optional by
14 | # renaming `b.use` to `b.optional`.
15 |
16 | # Determines whether to use HTML5 (:email, :url, ...)
17 | # and required attributes
18 | b.use :html5
19 |
20 | # Calculates placeholders automatically from I18n
21 | # You can also pass a string as f.input placeholder: "Placeholder"
22 | b.use :placeholder
23 |
24 | ## Optional extensions
25 | # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
26 | # to the input. If so, they will retrieve the values from the model
27 | # if any exists. If you want to enable the lookup for any of those
28 | # extensions by default, you can change `b.optional` to `b.use`.
29 |
30 | # Calculates maxlength from length validations for string inputs
31 | b.optional :maxlength
32 |
33 | # Calculates pattern from format validations for string inputs
34 | b.optional :pattern
35 |
36 | # Calculates min and max from length validations for numeric inputs
37 | b.optional :min_max
38 |
39 | # Calculates readonly automatically from readonly attributes
40 | b.optional :readonly
41 |
42 | ## Inputs
43 | b.use :label_input
44 | b.use :hint, wrap_with: { tag: :span, class: :hint }
45 | b.use :error, wrap_with: { tag: :span, class: :error }
46 | end
47 |
48 | # The default wrapper to be used by the FormBuilder.
49 | config.default_wrapper = :default
50 |
51 | # Define the way to render check boxes / radio buttons with labels.
52 | # Defaults to :nested for bootstrap config.
53 | # inline: input + label
54 | # nested: label > input
55 | config.boolean_style = :nested
56 |
57 | # Default class for buttons
58 | config.button_class = 'btn'
59 |
60 | # Method used to tidy up errors. Specify any Rails Array method.
61 | # :first lists the first message for each field.
62 | # Use :to_sentence to list all errors for each field.
63 | # config.error_method = :first
64 |
65 | # Default tag used for error notification helper.
66 | config.error_notification_tag = :div
67 |
68 | # CSS class to add for error notification helper.
69 | config.error_notification_class = 'alert alert-error'
70 |
71 | # ID to add for error notification helper.
72 | # config.error_notification_id = nil
73 |
74 | # Series of attempts to detect a default label method for collection.
75 | # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
76 |
77 | # Series of attempts to detect a default value method for collection.
78 | # config.collection_value_methods = [ :id, :to_s ]
79 |
80 | # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
81 | # config.collection_wrapper_tag = nil
82 |
83 | # You can define the class to use on all collection wrappers. Defaulting to none.
84 | # config.collection_wrapper_class = nil
85 |
86 | # You can wrap each item in a collection of radio/check boxes with a tag,
87 | # defaulting to :span. Please note that when using :boolean_style = :nested,
88 | # SimpleForm will force this option to be a label.
89 | # config.item_wrapper_tag = :span
90 |
91 | # You can define a class to use in all item wrappers. Defaulting to none.
92 | # config.item_wrapper_class = nil
93 |
94 | # How the label text should be generated altogether with the required text.
95 | # config.label_text = lambda { |label, required| "#{required} #{label}" }
96 |
97 | # You can define the class to use on all labels. Default is nil.
98 | config.label_class = 'control-label'
99 |
100 | # You can define the class to use on all forms. Default is simple_form.
101 | # config.form_class = :simple_form
102 |
103 | # You can define which elements should obtain additional classes
104 | # config.generate_additional_classes_for = [:wrapper, :label, :input]
105 |
106 | # Whether attributes are required by default (or not). Default is true.
107 | # config.required_by_default = true
108 |
109 | # Tell browsers whether to use the native HTML5 validations (novalidate form option).
110 | # These validations are enabled in SimpleForm's internal config but disabled by default
111 | # in this configuration, which is recommended due to some quirks from different browsers.
112 | # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
113 | # change this configuration to true.
114 | config.browser_validations = false
115 |
116 | # Collection of methods to detect if a file type was given.
117 | # config.file_methods = [ :mounted_as, :file?, :public_filename ]
118 |
119 | # Custom mappings for input types. This should be a hash containing a regexp
120 | # to match as key, and the input type that will be used when the field name
121 | # matches the regexp as value.
122 | # config.input_mappings = { /count/ => :integer }
123 |
124 | # Custom wrappers for input types. This should be a hash containing an input
125 | # type as key and the wrapper that will be used for all inputs with specified type.
126 | # config.wrapper_mappings = { string: :prepend }
127 |
128 | # Default priority for time_zone inputs.
129 | # config.time_zone_priority = nil
130 |
131 | # Default priority for country inputs.
132 | # config.country_priority = nil
133 |
134 | # When false, do not use translations for labels.
135 | # config.translate_labels = true
136 |
137 | # Automatically discover new inputs in Rails' autoload path.
138 | # config.inputs_discovery = true
139 |
140 | # Cache SimpleForm inputs discovery
141 | # config.cache_discovery = !Rails.env.development?
142 |
143 | # Default class for inputs
144 | # config.input_class = nil
145 | end
146 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GIT
2 | remote: git://github.com/thoughtbot/paperclip.git
3 | revision: 9b4805354864bc729e1a79a67a795e79dc7f42ae
4 | specs:
5 | paperclip (5.1.0)
6 | activemodel (>= 4.2.0)
7 | activesupport (>= 4.2.0)
8 | cocaine (~> 0.5.5)
9 | mime-types
10 | mimemagic (~> 0.3.0)
11 |
12 | GEM
13 | remote: https://rubygems.org/
14 | specs:
15 | actioncable (5.1.4)
16 | actionpack (= 5.1.4)
17 | nio4r (~> 2.0)
18 | websocket-driver (~> 0.6.1)
19 | actionmailer (5.1.4)
20 | actionpack (= 5.1.4)
21 | actionview (= 5.1.4)
22 | activejob (= 5.1.4)
23 | mail (~> 2.5, >= 2.5.4)
24 | rails-dom-testing (~> 2.0)
25 | actionpack (5.1.4)
26 | actionview (= 5.1.4)
27 | activesupport (= 5.1.4)
28 | rack (~> 2.0)
29 | rack-test (>= 0.6.3)
30 | rails-dom-testing (~> 2.0)
31 | rails-html-sanitizer (~> 1.0, >= 1.0.2)
32 | actionview (5.1.4)
33 | activesupport (= 5.1.4)
34 | builder (~> 3.1)
35 | erubi (~> 1.4)
36 | rails-dom-testing (~> 2.0)
37 | rails-html-sanitizer (~> 1.0, >= 1.0.3)
38 | activejob (5.1.4)
39 | activesupport (= 5.1.4)
40 | globalid (>= 0.3.6)
41 | activemodel (5.1.4)
42 | activesupport (= 5.1.4)
43 | activerecord (5.1.4)
44 | activemodel (= 5.1.4)
45 | activesupport (= 5.1.4)
46 | arel (~> 8.0)
47 | activesupport (5.1.4)
48 | concurrent-ruby (~> 1.0, >= 1.0.2)
49 | i18n (~> 0.7)
50 | minitest (~> 5.1)
51 | tzinfo (~> 1.1)
52 | acts-as-taggable-on (5.0.0)
53 | activerecord (>= 4.2.8)
54 | archive-zip (0.10.0)
55 | io-like (~> 0.3.0)
56 | arel (8.0.0)
57 | autoprefixer-rails (7.1.5)
58 | execjs
59 | awesome_print (1.8.0)
60 | bcrypt (3.1.11)
61 | better_errors (2.4.0)
62 | coderay (>= 1.0.0)
63 | erubi (>= 1.0.0)
64 | rack (>= 0.9.0)
65 | binding_of_caller (0.7.2)
66 | debug_inspector (>= 0.0.1)
67 | bootstrap-sass (3.3.7)
68 | autoprefixer-rails (>= 5.2.1)
69 | sass (>= 3.3.4)
70 | builder (3.2.3)
71 | climate_control (0.2.0)
72 | cocaine (0.5.8)
73 | climate_control (>= 0.0.3, < 1.0)
74 | coderay (1.1.2)
75 | coffee-rails (4.2.2)
76 | coffee-script (>= 2.2.0)
77 | railties (>= 4.0.0)
78 | coffee-script (2.4.1)
79 | coffee-script-source
80 | execjs
81 | coffee-script-source (1.12.2)
82 | commonjs (0.2.7)
83 | concurrent-ruby (1.0.5)
84 | crass (1.0.2)
85 | debug_inspector (0.0.3)
86 | delayed_job (4.1.3)
87 | activesupport (>= 3.0, < 5.2)
88 | delayed_job_active_record (4.1.2)
89 | activerecord (>= 3.0, < 5.2)
90 | delayed_job (>= 3.0, < 5)
91 | devise (4.3.0)
92 | bcrypt (~> 3.0)
93 | orm_adapter (~> 0.1)
94 | railties (>= 4.1.0, < 5.2)
95 | responders
96 | warden (~> 1.2.3)
97 | digest (0.0.1)
98 | docsplit (0.7.6)
99 | domain_name (0.5.20170404)
100 | unf (>= 0.0.5, < 1.0.0)
101 | erubi (1.7.0)
102 | execjs (2.7.0)
103 | exifr (1.3.2)
104 | ffi (1.9.18)
105 | globalid (0.4.0)
106 | activesupport (>= 4.2.0)
107 | hex_string (1.0.1)
108 | http-cookie (1.0.3)
109 | domain_name (~> 0.5)
110 | i18n (0.9.0)
111 | concurrent-ruby (~> 1.0)
112 | io-like (0.3.0)
113 | iostruct (0.0.4)
114 | jbuilder (2.7.0)
115 | activesupport (>= 4.2.0)
116 | multi_json (>= 1.2)
117 | jquery-datatables-rails (3.1.1)
118 | actionpack (>= 3.1)
119 | jquery-rails
120 | railties (>= 3.1)
121 | sass-rails
122 | jquery-rails (4.3.1)
123 | rails-dom-testing (>= 1, < 3)
124 | railties (>= 4.2.0)
125 | thor (>= 0.14, < 2.0)
126 | jquery-ui-rails (6.0.1)
127 | railties (>= 3.2.16)
128 | json (1.8.6)
129 | kaminari (1.1.0)
130 | activesupport (>= 4.1.0)
131 | kaminari-actionview (= 1.1.0)
132 | kaminari-activerecord (= 1.1.0)
133 | kaminari-core (= 1.1.0)
134 | kaminari-actionview (1.1.0)
135 | actionview
136 | kaminari-core (= 1.1.0)
137 | kaminari-activerecord (1.1.0)
138 | activerecord
139 | kaminari-core (= 1.1.0)
140 | kaminari-core (1.1.0)
141 | less (2.6.0)
142 | commonjs (~> 0.2.7)
143 | less-rails (2.8.0)
144 | actionpack (>= 4.0)
145 | less (~> 2.6.0)
146 | sprockets (> 2, < 4)
147 | tilt
148 | loofah (2.1.1)
149 | crass (~> 1.0.2)
150 | nokogiri (>= 1.5.9)
151 | mail (2.6.6)
152 | mime-types (>= 1.16, < 4)
153 | metasm (1.0.3)
154 | method_source (0.9.0)
155 | mime-types (3.1)
156 | mime-types-data (~> 3.2015)
157 | mime-types-data (3.2016.0521)
158 | mimemagic (0.3.2)
159 | mini_portile2 (2.3.0)
160 | minitest (5.10.3)
161 | multi_json (1.12.2)
162 | multipart-post (2.0.0)
163 | netrc (0.11.0)
164 | nio4r (2.1.0)
165 | nokogiri (1.8.1)
166 | mini_portile2 (~> 2.3.0)
167 | orm_adapter (0.5.0)
168 | pedump (0.5.2)
169 | awesome_print
170 | iostruct (>= 0.0.4)
171 | multipart-post (~> 2.0.0)
172 | progressbar
173 | zhexdump (>= 0.0.2)
174 | pg (0.21.0)
175 | progressbar (1.9.0)
176 | rack (2.0.3)
177 | rack-test (0.7.0)
178 | rack (>= 1.0, < 3)
179 | rails (5.1.4)
180 | actioncable (= 5.1.4)
181 | actionmailer (= 5.1.4)
182 | actionpack (= 5.1.4)
183 | actionview (= 5.1.4)
184 | activejob (= 5.1.4)
185 | activemodel (= 5.1.4)
186 | activerecord (= 5.1.4)
187 | activesupport (= 5.1.4)
188 | bundler (>= 1.3.0)
189 | railties (= 5.1.4)
190 | sprockets-rails (>= 2.0.0)
191 | rails-dom-testing (2.0.3)
192 | activesupport (>= 4.2.0)
193 | nokogiri (>= 1.6)
194 | rails-html-sanitizer (1.0.3)
195 | loofah (~> 2.0)
196 | rails_12factor (0.0.3)
197 | rails_serve_static_assets
198 | rails_stdout_logging
199 | rails_layout (1.0.41)
200 | rails_serve_static_assets (0.0.5)
201 | rails_stdout_logging (0.0.5)
202 | railties (5.1.4)
203 | actionpack (= 5.1.4)
204 | activesupport (= 5.1.4)
205 | method_source
206 | rake (>= 0.8.7)
207 | thor (>= 0.18.1, < 2.0)
208 | rake (12.1.0)
209 | rb-fsevent (0.10.2)
210 | rb-inotify (0.9.10)
211 | ffi (>= 0.5.0, < 2)
212 | rdoc (4.3.0)
213 | responders (2.4.0)
214 | actionpack (>= 4.2.0, < 5.3)
215 | railties (>= 4.2.0, < 5.3)
216 | rest-client (2.0.2)
217 | http-cookie (>= 1.0.2, < 2.0)
218 | mime-types (>= 1.16, < 4.0)
219 | netrc (~> 0.8)
220 | sass (3.5.2)
221 | sass-listen (~> 4.0.0)
222 | sass-listen (4.0.0)
223 | rb-fsevent (~> 0.9, >= 0.9.4)
224 | rb-inotify (~> 0.9, >= 0.9.7)
225 | sass-rails (5.0.6)
226 | railties (>= 4.0.0, < 6)
227 | sass (~> 3.1)
228 | sprockets (>= 2.8, < 4.0)
229 | sprockets-rails (>= 2.0, < 4.0)
230 | tilt (>= 1.1, < 3)
231 | sdoc (0.4.2)
232 | json (~> 1.7, >= 1.7.7)
233 | rdoc (~> 4.0)
234 | simple_form (3.5.0)
235 | actionpack (> 4, < 5.2)
236 | activemodel (> 4, < 5.2)
237 | spring (2.0.2)
238 | activesupport (>= 4.2)
239 | sprockets (3.7.1)
240 | concurrent-ruby (~> 1.0)
241 | rack (> 1, < 3)
242 | sprockets-rails (3.2.1)
243 | actionpack (>= 4.0)
244 | activesupport (>= 4.0)
245 | sprockets (>= 3.0.0)
246 | thor (0.20.0)
247 | thread_safe (0.3.6)
248 | tilt (2.0.8)
249 | turbolinks (5.0.1)
250 | turbolinks-source (~> 5)
251 | turbolinks-source (5.0.3)
252 | twitter-bootstrap-rails (4.0.0)
253 | actionpack (~> 5.0, >= 5.0.1)
254 | execjs (~> 2.7)
255 | less-rails (~> 2.8, >= 2.8.0)
256 | railties (~> 5.0, >= 5.0.1)
257 | tzinfo (1.2.3)
258 | thread_safe (~> 0.1)
259 | uglifier (3.2.0)
260 | execjs (>= 0.3.0, < 3)
261 | unf (0.1.4)
262 | unf_ext
263 | unf_ext (0.0.7.4)
264 | warden (1.2.7)
265 | rack (>= 1.0)
266 | websocket-driver (0.6.5)
267 | websocket-extensions (>= 0.1.0)
268 | websocket-extensions (0.1.2)
269 | zhexdump (0.0.2)
270 |
271 | PLATFORMS
272 | ruby
273 |
274 | DEPENDENCIES
275 | acts-as-taggable-on
276 | archive-zip
277 | better_errors
278 | binding_of_caller
279 | bootstrap-sass
280 | coffee-rails
281 | delayed_job_active_record
282 | devise
283 | digest
284 | docsplit
285 | exifr
286 | hex_string
287 | jbuilder (~> 2.0)
288 | jquery-datatables-rails (~> 3.1.1)
289 | jquery-rails
290 | jquery-ui-rails
291 | json
292 | kaminari
293 | metasm
294 | paperclip!
295 | pedump
296 | pg
297 | rails
298 | rails_12factor
299 | rails_layout
300 | rake
301 | rest-client
302 | sass-rails
303 | sdoc (~> 0.4.0)
304 | simple_form
305 | spring
306 | turbolinks
307 | twitter-bootstrap-rails
308 | uglifier
309 |
310 | RUBY VERSION
311 | ruby 2.4.2p198
312 |
313 | BUNDLED WITH
314 | 1.15.4
315 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/toggle-switch.css.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * CSS TOGGLE SWITCHES
3 | * Unlicense
4 | *
5 | * Ionuț Colceriu - ghinda.net
6 | * https://github.com/ghinda/css-toggle-switch
7 | *
8 | */
9 | /* Supported values are px, rem-calc, em-calc */
10 | /* Functions */
11 | /* Toggle Switches */
12 | /* Shared */
13 | /* Checkbox
14 | */
15 | /* Radio Switch
16 | */
17 | /* Hide by default
18 | */
19 | .switch-toggle a, .switch-light span span {
20 | display: none; }
21 |
22 | /* We can't test for a specific feature,
23 | * so we only target browsers with support for media queries.
24 | */
25 | @media only screen {
26 | /* Checkbox switch
27 | */
28 | .switch-light {
29 | display: block;
30 | min-height: 1.875em;
31 | /* Outline the toggles when the inputs are focused
32 | */
33 | position: relative;
34 | overflow: visible;
35 | padding: 0;
36 | margin-left: 6.25em;
37 | /* Position the label over all the elements, except the slide-button ()
38 | * Clicking anywhere on the label will change the switch-state
39 | */
40 | /* Don't hide the input from screen-readers and keyboard access
41 | */ }
42 | .switch-light * {
43 | -webkit-box-sizing: border-box;
44 | -moz-box-sizing: border-box;
45 | box-sizing: border-box; }
46 | .switch-light a {
47 | display: block;
48 | -webkit-transition: all 0.2s ease-out;
49 | -moz-transition: all 0.2s ease-out;
50 | transition: all 0.2s ease-out; }
51 | .switch-light label, .switch-light > span {
52 | line-height: 1.875em;
53 | vertical-align: middle; }
54 | .switch-light input:focus ~ a, .switch-light input:focus + label {
55 | outline: 1px dotted #888; }
56 | .switch-light label {
57 | position: relative;
58 | z-index: 3;
59 | display: block;
60 | width: 100%; }
61 | .switch-light input {
62 | position: absolute;
63 | opacity: 0;
64 | z-index: 5; }
65 | .switch-light input:checked ~ a {
66 | right: 0%; }
67 | .switch-light > span {
68 | position: absolute;
69 | left: -6.25em;
70 | width: 100%;
71 | margin: 0;
72 | padding-right: 6.25em;
73 | text-align: left; }
74 | .switch-light > span span {
75 | position: absolute;
76 | top: 0;
77 | left: 0;
78 | z-index: 5;
79 | display: block;
80 | width: 50%;
81 | margin-left: 6.25em;
82 | text-align: center; }
83 | .switch-light > span span:last-child {
84 | left: 50%; }
85 | .switch-light a {
86 | position: absolute;
87 | right: 50%;
88 | top: 0;
89 | z-index: 4;
90 | display: block;
91 | width: 50%;
92 | height: 100%;
93 | padding: 0; }
94 |
95 | /* Radio switch
96 | */
97 | .switch-toggle {
98 | display: block;
99 | min-height: 1.875em;
100 | /* Outline the toggles when the inputs are focused
101 | */
102 | position: relative;
103 | display: table;
104 | table-layout: fixed;
105 | /* For callout panels in foundation
106 | */
107 | padding: 0 !important;
108 | /* Generate styles for the multiple states */ }
109 | .switch-toggle * {
110 | -webkit-box-sizing: border-box;
111 | -moz-box-sizing: border-box;
112 | box-sizing: border-box; }
113 | .switch-toggle a {
114 | display: block;
115 | -webkit-transition: all 0.2s ease-out;
116 | -moz-transition: all 0.2s ease-out;
117 | transition: all 0.2s ease-out; }
118 | .switch-toggle label, .switch-toggle > span {
119 | line-height: 1.875em;
120 | vertical-align: middle; }
121 | .switch-toggle input:focus ~ a, .switch-toggle input:focus + label {
122 | outline: 1px dotted #888; }
123 | .switch-toggle * {
124 | font-size: 1em; }
125 | .switch-toggle input {
126 | position: absolute;
127 | opacity: 0; }
128 | .switch-toggle input + label {
129 | position: relative;
130 | z-index: 2;
131 | display: table-cell;
132 | width: 50%;
133 | padding: 0 0.5em;
134 | margin: 0;
135 | text-align: center; }
136 | .switch-toggle a {
137 | position: absolute;
138 | top: 0;
139 | left: 0;
140 | padding: 0;
141 | z-index: 1;
142 | width: 50%;
143 | height: 100%; }
144 | .switch-toggle input:last-of-type:checked ~ a {
145 | left: 50%; }
146 | .switch-toggle.switch-3 label, .switch-toggle.switch-3 a {
147 | width: 33.3333333333%; }
148 | .switch-toggle.switch-3 input:checked:nth-of-type(2) ~ a {
149 | left: 33.3333333333%; }
150 | .switch-toggle.switch-3 input:checked:last-of-type ~ a {
151 | left: 66.6666666667%; }
152 | .switch-toggle.switch-4 label, .switch-toggle.switch-4 a {
153 | width: 25%; }
154 | .switch-toggle.switch-4 input:checked:nth-of-type(2) ~ a {
155 | left: 25%; }
156 | .switch-toggle.switch-4 input:checked:nth-of-type(3) ~ a {
157 | left: 50%; }
158 | .switch-toggle.switch-4 input:checked:last-of-type ~ a {
159 | left: 75%; }
160 | .switch-toggle.switch-5 label, .switch-toggle.switch-5 a {
161 | width: 20%; }
162 | .switch-toggle.switch-5 input:checked:nth-of-type(2) ~ a {
163 | left: 20%; }
164 | .switch-toggle.switch-5 input:checked:nth-of-type(3) ~ a {
165 | left: 40%; }
166 | .switch-toggle.switch-5 input:checked:nth-of-type(4) ~ a {
167 | left: 60%; }
168 | .switch-toggle.switch-5 input:checked:last-of-type ~ a {
169 | left: 80%; }
170 |
171 | /* Standalone Themes */
172 | /* Candy Theme
173 | * Based on the "Sort Switches / Toggles (PSD)" by Ormal Clarck
174 | * http://www.premiumpixels.com/freebies/sort-switches-toggles-psd/
175 | */
176 | .switch-candy {
177 | background-color: #2d3035;
178 | border-radius: 3px;
179 | color: #fff;
180 | font-weight: bold;
181 | text-align: center;
182 | text-shadow: 1px 1px 1px #191b1e;
183 | box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.2); }
184 | .switch-candy label {
185 | color: #fff;
186 | -webkit-transition: color 0.2s ease-out;
187 | -moz-transition: color 0.2s ease-out;
188 | transition: color 0.2s ease-out; }
189 | .switch-candy input:checked + label {
190 | color: #333;
191 | text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); }
192 | .switch-candy a {
193 | border: 1px solid #333;
194 | background-color: #70c66b;
195 | border-radius: 3px;
196 | background-image: -webkit-linear-gradient(top, rgba(255, 255, 255, 0.2), rgba(0, 0, 0, 0));
197 | background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.2), rgba(0, 0, 0, 0));
198 | box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.45); }
199 | .switch-candy > span {
200 | color: #333;
201 | text-shadow: none; }
202 | .switch-candy span {
203 | color: #fff; }
204 | .switch-candy.switch-candy-blue a {
205 | background-color: #38a3d4; }
206 | .switch-candy.switch-candy-yellow a {
207 | background-color: #f5e560; }
208 |
209 | /* Android Theme
210 | */
211 | .switch-android {
212 | background-color: #464747;
213 | border-radius: 1px;
214 | box-shadow: inset rgba(0, 0, 0, 0.1) 0 1px 0;
215 | color: #fff;
216 | /* Selected ON switch-light
217 | */ }
218 | .switch-android label {
219 | color: #fff; }
220 | .switch-android > span span {
221 | opacity: 0;
222 | margin-left: 7.1875em;
223 | -webkit-transition: all 0.1s;
224 | -moz-transition: all 0.1s;
225 | transition: all 0.1s; }
226 | .switch-android > span span:first-of-type {
227 | opacity: 1; }
228 | .switch-android > span span, .switch-android input + label {
229 | font-size: 85%;
230 | line-height: 2.15625em; }
231 | .switch-android a {
232 | background-color: #666;
233 | border-radius: 1px;
234 | box-shadow: inset rgba(255, 255, 255, 0.2) 0 1px 0, inset rgba(0, 0, 0, 0.3) 0 -1px 0; }
235 | .switch-android.switch-light input:checked ~ a {
236 | background-color: #0E88B1; }
237 | .switch-android.switch-light input:checked ~ span span:first-of-type {
238 | opacity: 0; }
239 | .switch-android.switch-light input:checked ~ span span:last-of-type {
240 | opacity: 1; }
241 | .switch-android.switch-toggle, .switch-android > span span {
242 | text-transform: uppercase; }
243 |
244 | /* iOS Theme
245 | */
246 | .switch-ios.switch-light {
247 | color: #868686; }
248 | .switch-ios.switch-light a {
249 | left: 0;
250 | width: 1.875em;
251 | background-color: #fff;
252 | border: 1px solid #d3d3d3;
253 | border-radius: 100%;
254 | -webkit-transition: all 0.3s ease-out;
255 | -moz-transition: all 0.3s ease-out;
256 | transition: all 0.3s ease-out;
257 | box-shadow: inset 0 -3px 3px rgba(0, 0, 0, 0.025), 0 1px 4px rgba(0, 0, 0, 0.15), 0 4px 4px rgba(0, 0, 0, 0.1); }
258 | .switch-ios.switch-light > span span {
259 | width: 100%;
260 | left: 0;
261 | opacity: 0; }
262 | .switch-ios.switch-light > span span:first-of-type {
263 | opacity: 1;
264 | padding-left: 1.875em; }
265 | .switch-ios.switch-light > span span:last-of-type {
266 | padding-right: 1.875em; }
267 | .switch-ios.switch-light > span:before {
268 | content: '';
269 | display: block;
270 | width: 100%;
271 | height: 100%;
272 | position: absolute;
273 | left: 6.25em;
274 | top: 0;
275 | background-color: #fafafa;
276 | border: 1px solid #d3d3d3;
277 | border-radius: 30px;
278 | -webkit-transition: all 0.5s ease-out;
279 | -moz-transition: all 0.5s ease-out;
280 | transition: all 0.5s ease-out;
281 | box-shadow: inset rgba(0, 0, 0, 0.1) 0 1px 0; }
282 | .switch-ios.switch-light input:checked ~ a {
283 | left: 100%;
284 | margin-left: -1.875em; }
285 | .switch-ios.switch-light input:checked ~ span:before {
286 | border-color: #53d76a;
287 | box-shadow: inset 0 0 0 30px #53d76a; }
288 | .switch-ios.switch-light input:checked ~ span span:first-of-type {
289 | opacity: 0; }
290 | .switch-ios.switch-light input:checked ~ span span:last-of-type {
291 | opacity: 1;
292 | color: #fff; }
293 | .switch-ios.switch-toggle {
294 | background-color: #fafafa;
295 | border: 1px solid #d3d3d3;
296 | border-radius: 30px;
297 | box-shadow: inset rgba(0, 0, 0, 0.1) 0 1px 0; }
298 | .switch-ios.switch-toggle a {
299 | background-color: #53d76a;
300 | border-radius: 25px;
301 | -webkit-transition: all 0.3s ease-out;
302 | -moz-transition: all 0.3s ease-out;
303 | transition: all 0.3s ease-out; }
304 | .switch-ios.switch-toggle label {
305 | color: #868686; }
306 | .switch-ios input:checked + label {
307 | color: #3a3a3a; }
308 | }
309 |
310 | /* Bugfix for older Webkit, including mobile Webkit. Adapted from
311 | * http://css-tricks.com/webkit-sibling-bug/
312 | */
313 | @media only screen and (-webkit-max-device-pixel-ratio: 2) and (max-device-width: 80em) {
314 | .switch-light, .switch-toggle {
315 | -webkit-animation: webkitSiblingBugfix infinite 1s; } }
316 |
317 | @-webkit-keyframes webkitSiblingBugfix {
318 | from {
319 | -webkit-transform: translate3d(0, 0, 0); }
320 |
321 | to {
322 | -webkit-transform: translate3d(0, 0, 0); } }
323 |
--------------------------------------------------------------------------------
/config/initializers/devise.rb:
--------------------------------------------------------------------------------
1 | # Use this hook to configure devise mailer, warden hooks and so forth.
2 | # Many of these configuration options can be set straight in your model.
3 | Devise.setup do |config|
4 | # The secret key used by Devise. Devise uses this key to generate
5 | # random tokens. Changing this key will render invalid all existing
6 | # confirmation, reset password and unlock tokens in the database.
7 | config.secret_key = '60d705c6a0611023aaf3e6c6fbef9d289be3ffc805c2177bc26e38b55df1a8d876c2ecac75c4f3794822c4cb6858a848065371d23b931f4f742f0b9fbcebfe5a'
8 |
9 | # ==> Mailer Configuration
10 | # Configure the e-mail address which will be shown in Devise::Mailer,
11 | # note that it will be overwritten if you use your own mailer class
12 | # with default "from" parameter.
13 | config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
14 |
15 | # Configure the class responsible to send e-mails.
16 | # config.mailer = 'Devise::Mailer'
17 |
18 | # ==> ORM configuration
19 | # Load and configure the ORM. Supports :active_record (default) and
20 | # :mongoid (bson_ext recommended) by default. Other ORMs may be
21 | # available as additional gems.
22 | require 'devise/orm/active_record'
23 |
24 | # ==> Configuration for any authentication mechanism
25 | # Configure which keys are used when authenticating a user. The default is
26 | # just :email. You can configure it to use [:username, :subdomain], so for
27 | # authenticating a user, both parameters are required. Remember that those
28 | # parameters are used only when authenticating and not when retrieving from
29 | # session. If you need permissions, you should implement that in a before filter.
30 | # You can also supply a hash where the value is a boolean determining whether
31 | # or not authentication should be aborted when the value is not present.
32 | # config.authentication_keys = [ :email ]
33 |
34 | # Configure parameters from the request object used for authentication. Each entry
35 | # given should be a request method and it will automatically be passed to the
36 | # find_for_authentication method and considered in your model lookup. For instance,
37 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
38 | # The same considerations mentioned for authentication_keys also apply to request_keys.
39 | # config.request_keys = []
40 |
41 | # Configure which authentication keys should be case-insensitive.
42 | # These keys will be downcased upon creating or modifying a user and when used
43 | # to authenticate or find a user. Default is :email.
44 | config.case_insensitive_keys = [ :email ]
45 |
46 | # Configure which authentication keys should have whitespace stripped.
47 | # These keys will have whitespace before and after removed upon creating or
48 | # modifying a user and when used to authenticate or find a user. Default is :email.
49 | config.strip_whitespace_keys = [ :email ]
50 |
51 | # Tell if authentication through request.params is enabled. True by default.
52 | # It can be set to an array that will enable params authentication only for the
53 | # given strategies, for example, `config.params_authenticatable = [:database]` will
54 | # enable it only for database (email + password) authentication.
55 | # config.params_authenticatable = true
56 |
57 | # Tell if authentication through HTTP Auth is enabled. False by default.
58 | # It can be set to an array that will enable http authentication only for the
59 | # given strategies, for example, `config.http_authenticatable = [:database]` will
60 | # enable it only for database authentication. The supported strategies are:
61 | # :database = Support basic authentication with authentication key + password
62 | # config.http_authenticatable = false
63 |
64 | # If http headers should be returned for AJAX requests. True by default.
65 | # config.http_authenticatable_on_xhr = true
66 |
67 | # The realm used in Http Basic Authentication. 'Application' by default.
68 | # config.http_authentication_realm = 'Application'
69 |
70 | # It will change confirmation, password recovery and other workflows
71 | # to behave the same regardless if the e-mail provided was right or wrong.
72 | # Does not affect registerable.
73 | # config.paranoid = true
74 |
75 | # By default Devise will store the user in session. You can skip storage for
76 | # particular strategies by setting this option.
77 | # Notice that if you are skipping storage for all authentication paths, you
78 | # may want to disable generating routes to Devise's sessions controller by
79 | # passing skip: :sessions to `devise_for` in your config/routes.rb
80 | config.skip_session_storage = [:http_auth]
81 |
82 | # By default, Devise cleans up the CSRF token on authentication to
83 | # avoid CSRF token fixation attacks. This means that, when using AJAX
84 | # requests for sign in and sign up, you need to get a new CSRF token
85 | # from the server. You can disable this option at your own risk.
86 | # config.clean_up_csrf_token_on_authentication = true
87 |
88 | # ==> Configuration for :database_authenticatable
89 | # For bcrypt, this is the cost for hashing the password and defaults to 10. If
90 | # using other encryptors, it sets how many times you want the password re-encrypted.
91 | #
92 | # Limiting the stretches to just one in testing will increase the performance of
93 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
94 | # a value less than 10 in other environments. Note that, for bcrypt (the default
95 | # encryptor), the cost increases exponentially with the number of stretches (e.g.
96 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
97 | config.stretches = Rails.env.test? ? 1 : 10
98 |
99 | # Setup a pepper to generate the encrypted password.
100 | # config.pepper = '39efb18fa1b60c04fd9b22aaaf0f756e29f84f55c377d5eb93277e5d8394bdd7d0d37aa3b3df1cb0fdb242ddaa22cb4476e17f3811ec9f8ea369ae6bab1012e9'
101 |
102 | # ==> Configuration for :confirmable
103 | # A period that the user is allowed to access the website even without
104 | # confirming their account. For instance, if set to 2.days, the user will be
105 | # able to access the website for two days without confirming their account,
106 | # access will be blocked just in the third day. Default is 0.days, meaning
107 | # the user cannot access the website without confirming their account.
108 | # config.allow_unconfirmed_access_for = 2.days
109 |
110 | # A period that the user is allowed to confirm their account before their
111 | # token becomes invalid. For example, if set to 3.days, the user can confirm
112 | # their account within 3 days after the mail was sent, but on the fourth day
113 | # their account can't be confirmed with the token any more.
114 | # Default is nil, meaning there is no restriction on how long a user can take
115 | # before confirming their account.
116 | # config.confirm_within = 3.days
117 |
118 | # If true, requires any email changes to be confirmed (exactly the same way as
119 | # initial account confirmation) to be applied. Requires additional unconfirmed_email
120 | # db field (see migrations). Until confirmed, new email is stored in
121 | # unconfirmed_email column, and copied to email column on successful confirmation.
122 | config.reconfirmable = true
123 |
124 | # Defines which key will be used when confirming an account
125 | # config.confirmation_keys = [ :email ]
126 |
127 | # ==> Configuration for :rememberable
128 | # The time the user will be remembered without asking for credentials again.
129 | # config.remember_for = 2.weeks
130 |
131 | # If true, extends the user's remember period when remembered via cookie.
132 | # config.extend_remember_period = false
133 |
134 | # Options to be passed to the created cookie. For instance, you can set
135 | # secure: true in order to force SSL only cookies.
136 | # config.rememberable_options = {}
137 |
138 | # ==> Configuration for :validatable
139 | # Range for password length.
140 | config.password_length = 8..128
141 |
142 | # Email regex used to validate email formats. It simply asserts that
143 | # one (and only one) @ exists in the given string. This is mainly
144 | # to give user feedback and not to assert the e-mail validity.
145 | # config.email_regexp = /\A[^@]+@[^@]+\z/
146 |
147 | # ==> Configuration for :timeoutable
148 | # The time you want to timeout the user session without activity. After this
149 | # time the user will be asked for credentials again. Default is 30 minutes.
150 | # config.timeout_in = 30.minutes
151 |
152 | # If true, expires auth token on session timeout.
153 | # config.expire_auth_token_on_timeout = false
154 |
155 | # ==> Configuration for :lockable
156 | # Defines which strategy will be used to lock an account.
157 | # :failed_attempts = Locks an account after a number of failed attempts to sign in.
158 | # :none = No lock strategy. You should handle locking by yourself.
159 | # config.lock_strategy = :failed_attempts
160 |
161 | # Defines which key will be used when locking and unlocking an account
162 | # config.unlock_keys = [ :email ]
163 |
164 | # Defines which strategy will be used to unlock an account.
165 | # :email = Sends an unlock link to the user email
166 | # :time = Re-enables login after a certain amount of time (see :unlock_in below)
167 | # :both = Enables both strategies
168 | # :none = No unlock strategy. You should handle unlocking by yourself.
169 | # config.unlock_strategy = :both
170 |
171 | # Number of authentication tries before locking an account if lock_strategy
172 | # is failed attempts.
173 | # config.maximum_attempts = 20
174 |
175 | # Time interval to unlock the account if :time is enabled as unlock_strategy.
176 | # config.unlock_in = 1.hour
177 |
178 | # Warn on the last attempt before the account is locked.
179 | # config.last_attempt_warning = false
180 |
181 | # ==> Configuration for :recoverable
182 | #
183 | # Defines which key will be used when recovering the password for an account
184 | # config.reset_password_keys = [ :email ]
185 |
186 | # Time interval you can reset your password with a reset password key.
187 | # Don't put a too small interval or your users won't have the time to
188 | # change their passwords.
189 | config.reset_password_within = 6.hours
190 |
191 | # ==> Configuration for :encryptable
192 | # Allow you to use another encryption algorithm besides bcrypt (default). You can use
193 | # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
194 | # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
195 | # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
196 | # REST_AUTH_SITE_KEY to pepper).
197 | #
198 | # Require the `devise-encryptable` gem when using anything other than bcrypt
199 | # config.encryptor = :sha512
200 |
201 | # ==> Scopes configuration
202 | # Turn scoped views on. Before rendering "sessions/new", it will first check for
203 | # "users/sessions/new". It's turned off by default because it's slower if you
204 | # are using only default views.
205 | # config.scoped_views = false
206 |
207 | # Configure the default scope given to Warden. By default it's the first
208 | # devise role declared in your routes (usually :user).
209 | # config.default_scope = :user
210 |
211 | # Set this configuration to false if you want /users/sign_out to sign out
212 | # only the current scope. By default, Devise signs out all scopes.
213 | # config.sign_out_all_scopes = true
214 |
215 | # ==> Navigation configuration
216 | # Lists the formats that should be treated as navigational. Formats like
217 | # :html, should redirect to the sign in page when the user does not have
218 | # access, but formats like :xml or :json, should return 401.
219 | #
220 | # If you have any extra navigational formats, like :iphone or :mobile, you
221 | # should add them to the navigational formats lists.
222 | #
223 | # The "*/*" below is required to match Internet Explorer requests.
224 | # config.navigational_formats = ['*/*', :html]
225 |
226 | # The default HTTP method used to sign out a resource. Default is :delete.
227 | config.sign_out_via = :delete
228 |
229 | # ==> OmniAuth
230 | # Add a new OmniAuth provider. Check the wiki for more information on setting
231 | # up on your models and hooks.
232 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
233 |
234 | # ==> Warden configuration
235 | # If you want to use other strategies, that are not supported by Devise, or
236 | # change the failure app, you can configure them inside the config.warden block.
237 | #
238 | # config.warden do |manager|
239 | # manager.intercept_401 = false
240 | # manager.default_strategies(scope: :user).unshift :some_external_strategy
241 | # end
242 |
243 | # ==> Mountable engine configurations
244 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine
245 | # is mountable, there are some extra configurations to be taken into account.
246 | # The following options are available, assuming the engine is mounted as:
247 | #
248 | # mount MyEngine, at: '/my_engine'
249 | #
250 | # The router that invoked `devise_for`, in the example above, would be:
251 | # config.router_name = :my_engine
252 | #
253 | # When using omniauth, Devise cannot automatically set Omniauth path,
254 | # so you need to do it manually. For the users scope, it would be:
255 | # config.omniauth_path_prefix = '/my_engine/users/auth'
256 | end
257 |
--------------------------------------------------------------------------------