├── .bowerrc ├── .github └── wiki │ ├── inquest_logo.svg │ └── threatkb-db-struct.svg ├── .gitignore ├── .travis.yml ├── Dockerfile ├── Gruntfile.js ├── LICENSE ├── MANIFEST.in ├── README.md ├── app ├── __init__.py ├── celeryapp.py ├── geo_ip_helper.py ├── models │ ├── __init__.py │ ├── access_keys.py │ ├── activity_log.py │ ├── bookmarks.py │ ├── c2dns.py │ ├── c2ip.py │ ├── cfg_category_range_mapping.py │ ├── cfg_settings.py │ ├── cfg_states.py │ ├── comments.py │ ├── errors.py │ ├── files.py │ ├── macros.py │ ├── metadata.py │ ├── releases.py │ ├── scripts.py │ ├── tags.py │ ├── tags_mapping.py │ ├── tasks.py │ ├── users.py │ ├── whitelist.py │ └── yara_rule.py ├── routes │ ├── __init__.py │ ├── access_keys.py │ ├── activity_log.py │ ├── authentication.py │ ├── batch.py │ ├── bookmarks.py │ ├── c2dns.py │ ├── c2ips.py │ ├── cfg_category_range_mapping.py │ ├── cfg_settings.py │ ├── cfg_states.py │ ├── comments.py │ ├── countries.py │ ├── documentation.py │ ├── error_handling.py │ ├── errors.py │ ├── files.py │ ├── import_.py │ ├── index.py │ ├── macros.py │ ├── metadata.py │ ├── releases.py │ ├── scripts.py │ ├── search.py │ ├── tags.py │ ├── tags_mapping.py │ ├── tasks.py │ ├── test_yara_rule.py │ ├── version.py │ ├── whitelist.py │ └── yara_rules.py ├── slack_helper.py ├── static │ ├── components │ │ └── tkb-codemirror │ │ │ ├── index.html │ │ │ └── index.js │ ├── css │ │ ├── app.css │ │ └── codemirror.css │ ├── images │ │ ├── favicon.ico │ │ ├── flags │ │ │ ├── icon-flag-ad.svg │ │ │ ├── icon-flag-ae.svg │ │ │ ├── icon-flag-af.svg │ │ │ ├── icon-flag-ag.svg │ │ │ ├── icon-flag-ai.svg │ │ │ ├── icon-flag-al.svg │ │ │ ├── icon-flag-am.svg │ │ │ ├── icon-flag-ao.svg │ │ │ ├── icon-flag-aq.svg │ │ │ ├── icon-flag-ar.svg │ │ │ ├── icon-flag-as.svg │ │ │ ├── icon-flag-at.svg │ │ │ ├── icon-flag-au.svg │ │ │ ├── icon-flag-aw.svg │ │ │ ├── icon-flag-ax.svg │ │ │ ├── icon-flag-az.svg │ │ │ ├── icon-flag-ba.svg │ │ │ ├── icon-flag-bb.svg │ │ │ ├── icon-flag-bd.svg │ │ │ ├── icon-flag-be.svg │ │ │ ├── icon-flag-bf.svg │ │ │ ├── icon-flag-bg.svg │ │ │ ├── icon-flag-bh.svg │ │ │ ├── icon-flag-bi.svg │ │ │ ├── icon-flag-bj.svg │ │ │ ├── icon-flag-bl.svg │ │ │ ├── icon-flag-bm.svg │ │ │ ├── icon-flag-bn.svg │ │ │ ├── icon-flag-bo.svg │ │ │ ├── icon-flag-bq.svg │ │ │ ├── icon-flag-br.svg │ │ │ ├── icon-flag-bs.svg │ │ │ ├── icon-flag-bt.svg │ │ │ ├── icon-flag-bv.svg │ │ │ ├── icon-flag-bw.svg │ │ │ ├── icon-flag-by.svg │ │ │ ├── icon-flag-bz.svg │ │ │ ├── icon-flag-ca.svg │ │ │ ├── icon-flag-cc.svg │ │ │ ├── icon-flag-cd.svg │ │ │ ├── icon-flag-cf.svg │ │ │ ├── icon-flag-cg.svg │ │ │ ├── icon-flag-ch.svg │ │ │ ├── icon-flag-ci.svg │ │ │ ├── icon-flag-ck.svg │ │ │ ├── icon-flag-cl.svg │ │ │ ├── icon-flag-cm.svg │ │ │ ├── icon-flag-cn.svg │ │ │ ├── icon-flag-co.svg │ │ │ ├── icon-flag-cr.svg │ │ │ ├── icon-flag-cu.svg │ │ │ ├── icon-flag-cv.svg │ │ │ ├── icon-flag-cw.svg │ │ │ ├── icon-flag-cx.svg │ │ │ ├── icon-flag-cy.svg │ │ │ ├── icon-flag-cz.svg │ │ │ ├── icon-flag-de.svg │ │ │ ├── icon-flag-dj.svg │ │ │ ├── icon-flag-dk.svg │ │ │ ├── icon-flag-dm.svg │ │ │ ├── icon-flag-do.svg │ │ │ ├── icon-flag-dz.svg │ │ │ ├── icon-flag-ec.svg │ │ │ ├── icon-flag-ee.svg │ │ │ ├── icon-flag-eg.svg │ │ │ ├── icon-flag-eh.svg │ │ │ ├── icon-flag-er.svg │ │ │ ├── icon-flag-es.svg │ │ │ ├── icon-flag-et.svg │ │ │ ├── icon-flag-eu.svg │ │ │ ├── icon-flag-fi.svg │ │ │ ├── icon-flag-fj.svg │ │ │ ├── icon-flag-fk.svg │ │ │ ├── icon-flag-fm.svg │ │ │ ├── icon-flag-fo.svg │ │ │ ├── icon-flag-fr.svg │ │ │ ├── icon-flag-ga.svg │ │ │ ├── icon-flag-gb.svg │ │ │ ├── icon-flag-gd.svg │ │ │ ├── icon-flag-ge.svg │ │ │ ├── icon-flag-gf.svg │ │ │ ├── icon-flag-gg.svg │ │ │ ├── icon-flag-gh.svg │ │ │ ├── icon-flag-gi.svg │ │ │ ├── icon-flag-gl.svg │ │ │ ├── icon-flag-gm.svg │ │ │ ├── icon-flag-gn.svg │ │ │ ├── icon-flag-gp.svg │ │ │ ├── icon-flag-gq.svg │ │ │ ├── icon-flag-gr.svg │ │ │ ├── icon-flag-gs.svg │ │ │ ├── icon-flag-gt.svg │ │ │ ├── icon-flag-gu.svg │ │ │ ├── icon-flag-gw.svg │ │ │ ├── icon-flag-gy.svg │ │ │ ├── icon-flag-hk.svg │ │ │ ├── icon-flag-hm.svg │ │ │ ├── icon-flag-hn.svg │ │ │ ├── icon-flag-hr.svg │ │ │ ├── icon-flag-ht.svg │ │ │ ├── icon-flag-hu.svg │ │ │ ├── icon-flag-id.svg │ │ │ ├── icon-flag-ie.svg │ │ │ ├── icon-flag-il.svg │ │ │ ├── icon-flag-im.svg │ │ │ ├── icon-flag-in.svg │ │ │ ├── icon-flag-io.svg │ │ │ ├── icon-flag-iq.svg │ │ │ ├── icon-flag-ir.svg │ │ │ ├── icon-flag-is.svg │ │ │ ├── icon-flag-it.svg │ │ │ ├── icon-flag-je.svg │ │ │ ├── icon-flag-jm.svg │ │ │ ├── icon-flag-jo.svg │ │ │ ├── icon-flag-jp.svg │ │ │ ├── icon-flag-ke.svg │ │ │ ├── icon-flag-kg.svg │ │ │ ├── icon-flag-kh.svg │ │ │ ├── icon-flag-ki.svg │ │ │ ├── icon-flag-km.svg │ │ │ ├── icon-flag-kn.svg │ │ │ ├── icon-flag-kp.svg │ │ │ ├── icon-flag-kr.svg │ │ │ ├── icon-flag-kw.svg │ │ │ ├── icon-flag-ky.svg │ │ │ ├── icon-flag-kz.svg │ │ │ ├── icon-flag-la.svg │ │ │ ├── icon-flag-lb.svg │ │ │ ├── icon-flag-lc.svg │ │ │ ├── icon-flag-li.svg │ │ │ ├── icon-flag-lk.svg │ │ │ ├── icon-flag-lr.svg │ │ │ ├── icon-flag-ls.svg │ │ │ ├── icon-flag-lt.svg │ │ │ ├── icon-flag-lu.svg │ │ │ ├── icon-flag-lv.svg │ │ │ ├── icon-flag-ly.svg │ │ │ ├── icon-flag-ma.svg │ │ │ ├── icon-flag-mc.svg │ │ │ ├── icon-flag-md.svg │ │ │ ├── icon-flag-me.svg │ │ │ ├── icon-flag-mf.svg │ │ │ ├── icon-flag-mg.svg │ │ │ ├── icon-flag-mh.svg │ │ │ ├── icon-flag-mk.svg │ │ │ ├── icon-flag-ml.svg │ │ │ ├── icon-flag-mm.svg │ │ │ ├── icon-flag-mn.svg │ │ │ ├── icon-flag-mo.svg │ │ │ ├── icon-flag-mp.svg │ │ │ ├── icon-flag-mq.svg │ │ │ ├── icon-flag-mr.svg │ │ │ ├── icon-flag-ms.svg │ │ │ ├── icon-flag-mt.svg │ │ │ ├── icon-flag-mu.svg │ │ │ ├── icon-flag-mv.svg │ │ │ ├── icon-flag-mw.svg │ │ │ ├── icon-flag-mx.svg │ │ │ ├── icon-flag-my.svg │ │ │ ├── icon-flag-mz.svg │ │ │ ├── icon-flag-na.svg │ │ │ ├── icon-flag-nc.svg │ │ │ ├── icon-flag-ne.svg │ │ │ ├── icon-flag-nf.svg │ │ │ ├── icon-flag-ng.svg │ │ │ ├── icon-flag-ni.svg │ │ │ ├── icon-flag-nl.svg │ │ │ ├── icon-flag-no.svg │ │ │ ├── icon-flag-none.svg │ │ │ ├── icon-flag-np.svg │ │ │ ├── icon-flag-nr.svg │ │ │ ├── icon-flag-nu.svg │ │ │ ├── icon-flag-nz.svg │ │ │ ├── icon-flag-om.svg │ │ │ ├── icon-flag-pa.svg │ │ │ ├── icon-flag-pe.svg │ │ │ ├── icon-flag-pf.svg │ │ │ ├── icon-flag-pg.svg │ │ │ ├── icon-flag-ph.svg │ │ │ ├── icon-flag-pk.svg │ │ │ ├── icon-flag-pl.svg │ │ │ ├── icon-flag-pm.svg │ │ │ ├── icon-flag-pn.svg │ │ │ ├── icon-flag-pr.svg │ │ │ ├── icon-flag-ps.svg │ │ │ ├── icon-flag-pt.svg │ │ │ ├── icon-flag-pw.svg │ │ │ ├── icon-flag-py.svg │ │ │ ├── icon-flag-qa.svg │ │ │ ├── icon-flag-re.svg │ │ │ ├── icon-flag-ro.svg │ │ │ ├── icon-flag-rs.svg │ │ │ ├── icon-flag-ru.svg │ │ │ ├── icon-flag-rw.svg │ │ │ ├── icon-flag-sa.svg │ │ │ ├── icon-flag-sb.svg │ │ │ ├── icon-flag-sc.svg │ │ │ ├── icon-flag-sd.svg │ │ │ ├── icon-flag-se.svg │ │ │ ├── icon-flag-sg.svg │ │ │ ├── icon-flag-sh.svg │ │ │ ├── icon-flag-si.svg │ │ │ ├── icon-flag-sj.svg │ │ │ ├── icon-flag-sk.svg │ │ │ ├── icon-flag-sl.svg │ │ │ ├── icon-flag-sm.svg │ │ │ ├── icon-flag-sn.svg │ │ │ ├── icon-flag-so.svg │ │ │ ├── icon-flag-sr.svg │ │ │ ├── icon-flag-ss.svg │ │ │ ├── icon-flag-st.svg │ │ │ ├── icon-flag-sv.svg │ │ │ ├── icon-flag-sx.svg │ │ │ ├── icon-flag-sy.svg │ │ │ ├── icon-flag-sz.svg │ │ │ ├── icon-flag-tc.svg │ │ │ ├── icon-flag-td.svg │ │ │ ├── icon-flag-tf.svg │ │ │ ├── icon-flag-tg.svg │ │ │ ├── icon-flag-th.svg │ │ │ ├── icon-flag-tj.svg │ │ │ ├── icon-flag-tk.svg │ │ │ ├── icon-flag-tl.svg │ │ │ ├── icon-flag-tm.svg │ │ │ ├── icon-flag-tn.svg │ │ │ ├── icon-flag-to.svg │ │ │ ├── icon-flag-tr.svg │ │ │ ├── icon-flag-tt.svg │ │ │ ├── icon-flag-tv.svg │ │ │ ├── icon-flag-tw.svg │ │ │ ├── icon-flag-tz.svg │ │ │ ├── icon-flag-ua.svg │ │ │ ├── icon-flag-ug.svg │ │ │ ├── icon-flag-um.svg │ │ │ ├── icon-flag-us.svg │ │ │ ├── icon-flag-uy.svg │ │ │ ├── icon-flag-uz.svg │ │ │ ├── icon-flag-va.svg │ │ │ ├── icon-flag-vc.svg │ │ │ ├── icon-flag-ve.svg │ │ │ ├── icon-flag-vg.svg │ │ │ ├── icon-flag-vi.svg │ │ │ ├── icon-flag-vn.svg │ │ │ ├── icon-flag-vu.svg │ │ │ ├── icon-flag-wf.svg │ │ │ ├── icon-flag-ws.svg │ │ │ ├── icon-flag-xk.svg │ │ │ ├── icon-flag-xx.svg │ │ │ ├── icon-flag-ye.svg │ │ │ ├── icon-flag-yt.svg │ │ │ ├── icon-flag-za.svg │ │ │ ├── icon-flag-zm.svg │ │ │ └── icon-flag-zw.svg │ │ └── inquest_logo.svg │ ├── index.html │ ├── js │ │ ├── access_keys │ │ │ ├── access_keys-controller.js │ │ │ └── access_keys-service.js │ │ ├── activity_log │ │ │ ├── activity_log-controller.js │ │ │ └── activity_log-service.js │ │ ├── app.js │ │ ├── authentication │ │ │ ├── authentication-controller.js │ │ │ └── authentication-service.js │ │ ├── bookmarks │ │ │ └── bookmarks-service.js │ │ ├── c2dns │ │ │ ├── c2dns-controller.js │ │ │ └── c2dns-service.js │ │ ├── c2ip │ │ │ ├── c2ip-controller.js │ │ │ └── c2ip-service.js │ │ ├── cfg_category_range_mapping │ │ │ ├── cfg_category_range_mapping-controller.js │ │ │ └── cfg_category_range_mapping-service.js │ │ ├── cfg_settings │ │ │ ├── cfg_settings-controller.js │ │ │ └── cfg_settings-service.js │ │ ├── cfg_states │ │ │ ├── cfg_states-controller.js │ │ │ └── cfg_states-service.js │ │ ├── codemirror │ │ │ ├── codemirror.js │ │ │ ├── searchcursor.js │ │ │ └── yara.js │ │ ├── comments │ │ │ ├── comments-controller.js │ │ │ └── comments-service.js │ │ ├── countries │ │ │ └── countries-service.js │ │ ├── dashboard │ │ │ └── dashboard-controller.js │ │ ├── errors │ │ │ ├── errors-controller.js │ │ │ └── errors-service.js │ │ ├── files │ │ │ ├── files-controller.js │ │ │ └── files-service.js │ │ ├── import │ │ │ ├── import-controller.js │ │ │ └── import-service.js │ │ ├── macros │ │ │ ├── macros-controller.js │ │ │ └── macros-service.js │ │ ├── metadata │ │ │ ├── metadata-controller.js │ │ │ └── metadata-service.js │ │ ├── profile │ │ │ └── profile-controller.js │ │ ├── releases │ │ │ ├── releases-controller.js │ │ │ └── releases-service.js │ │ ├── scripts │ │ │ ├── scripts-controller.js │ │ │ ├── scripts-run-controller.js │ │ │ └── scripts-service.js │ │ ├── tags │ │ │ ├── tags-controller.js │ │ │ └── tags-service.js │ │ ├── tags_mapping │ │ │ ├── tags_mapping-controller.js │ │ │ └── tags_mapping-service.js │ │ ├── tasks │ │ │ ├── tasks-controller.js │ │ │ └── tasks-service.js │ │ ├── tests │ │ │ ├── tests-controller.js │ │ │ └── tests-service.js │ │ ├── users │ │ │ └── users-service.js │ │ ├── version │ │ │ └── version-service.js │ │ ├── whitelist │ │ │ ├── whitelist-controller.js │ │ │ └── whitelist-service.js │ │ └── yara_rule │ │ │ ├── yara_rule-controller.js │ │ │ └── yara_rule-service.js │ └── views │ │ ├── access_keys │ │ └── access_keys.html │ │ ├── activity_log │ │ └── activity_log.html │ │ ├── authentication │ │ └── login.html │ │ ├── c2dns │ │ └── c2dns.html │ │ ├── c2ip │ │ └── c2ips.html │ │ ├── cfg_category_range_mapping │ │ └── cfg_category_range_mapping.html │ │ ├── cfg_reference_text_templates │ │ └── cfg_reference_text_templates.html │ │ ├── cfg_settings │ │ └── cfg_settings.html │ │ ├── cfg_states │ │ └── cfg_states.html │ │ ├── comments │ │ └── comments.html │ │ ├── dashboard │ │ └── dashboard.html │ │ ├── errors │ │ └── errors.html │ │ ├── files │ │ └── files.html │ │ ├── home.html │ │ ├── import │ │ └── import.html │ │ ├── login.html │ │ ├── macros │ │ └── macros.html │ │ ├── metadata │ │ └── metadata.html │ │ ├── profile │ │ └── profile.html │ │ ├── releases │ │ └── releases.html │ │ ├── scripts │ │ ├── scripts.html │ │ └── scripts_run.html │ │ ├── tags │ │ └── tags.html │ │ ├── tasks │ │ └── tasks.html │ │ ├── tests │ │ └── tests.html │ │ ├── users │ │ └── users.html │ │ ├── whitelist │ │ └── whitelist.html │ │ └── yara_rule │ │ └── yara_rules.html ├── test │ └── test_tkb.py └── utilities.py ├── bower.json ├── data ├── GeoLite2-ASN.mmdb └── GeoLite2-City.mmdb ├── docker-compose.yml ├── docker-entrypoint.sh ├── env_template ├── fix_c2ip_locations.py ├── generator.json ├── hash_pass.py ├── install.bat ├── install.sh ├── manage.py ├── merge_signatures.py ├── migrations ├── README ├── alembic.ini ├── env.py ├── script.py.mako └── versions │ ├── 072dd2b2d9a5_config_option_for_non_admin_task_.py │ ├── 0822c8e4629a_get_rid_of_unnecessary_metadata_in_.py │ ├── 0896164f6037_add_sig_dns_ip_tracking_to_releases.py │ ├── 0bd5407cc66d_add_is_release_state_column_to_states.py │ ├── 0df6e90050b5_add_mitre_subtechniques.py │ ├── 0e2074fb38e8_default_tags.py │ ├── 14eb52ff5135_add_metadata_choices.py │ ├── 15b203983adb_add_owner_columns_to_c2dns_c2ip_yara_.py │ ├── 2221286081e8_initial_migration.py │ ├── 2a30c4968d80_.py │ ├── 2f0f6d26a505_add_description_and_references_to_all.py │ ├── 34d5b6b940a7_more_default_settings.py │ ├── 385e63a30f6e_add_first_name_last_name_picture_fields_.py │ ├── 38aa862c0a93_add_active_column_to_tasks_table.py │ ├── 3a2003939cc4_made_current_column_nullable.py │ ├── 3a3368610e08_adding_avg_millis_per_file_column_to_.py │ ├── 3cb9b52b4c5b_adding_is_active_flag_to_users.py │ ├── 3d325922125f_added_sigature_id_column_to_yara_rules.py │ ├── 3d8891a2dde0_default_dashboard_release_count.py │ ├── 43120a4ae154_mitre_attack_data.py │ ├── 44b8cd08fe4a_release_flag_for_categories.py │ ├── 45d18cee3c93_add_default_whitelist_entries.py │ ├── 4af97076d0d0_unique_index_on_tags_and_default_.py │ ├── 4d75b1621822_artifact_static_references_2.py │ ├── 4e7228ea59d1_add_active_to_c2dns_c2ip.py │ ├── 4f5f6f314c20_drop_expiration_type_column.py │ ├── 4fb69d540f6d_make_c2dns_domain_name_and_c2ip_ip_.py │ ├── 5ae0821fdf9e_access_keys_table.py │ ├── 5ccd18d62305_add_metadata_and_metadata_mapping.py │ ├── 619d198ab938_add_is_staging_state_to_cfg_states.py │ ├── 63a47ddd8717_add_yara_testing_history_files_matches.py │ ├── 650b0ad88d25_add_indexes.py │ ├── 658ab905b871_change_release_data_to_blob.py │ ├── 65e3f200abd3_category_prefix_mapping.py │ ├── 665baa4d3f57_geoip_database_config_settings.py │ ├── 681507459b5d_makes_entity_type_and_id_nullable_in_.py │ ├── 695612f2c4ad_add_unique_rulenames_check_config_item.py │ ├── 6f68d5b06411_new_macros_table.py │ ├── 705e48818ad8_add_sha1_sha256_md5_to_files_table.py │ ├── 76ac9b0bf6e7_change_date_modified_date_created.py │ ├── 7c6433145877_update_config.py │ ├── 8083ff92369f_whitelist_table.py │ ├── 808f4e517394_create_start_filter_requests_length.py │ ├── 8090f8b3bbcb_bookmarks_table.py │ ├── 838898d63a85_add_description_to_cfg_settings.py │ ├── 8a40de624788_add_active_flag_to_yara_rule.py │ ├── 8c3bbaef0f9c_activity_log.py │ ├── 8d1a65d94f4b_yara_test_settings.py │ ├── 8d2c133477a2_tasks_model.py │ ├── 922e996462ab_get_rid_of_reference_text.py │ ├── 960676c435b2_adding_revision_column_to_yara_rule_and_.py │ ├── 9aadb08451dc_change_signature_id_to_eventid.py │ ├── 9ada96d00858_adding_description_to_ip_and_dns.py │ ├── 9cc6b6e233e5_add_testing_type_column.py │ ├── a688cf44cd8a_add_release_yara_rule_history.py │ ├── a844d4d82d9d_directory_functionality_in_files.py │ ├── aad1bab92536_add_releases_table.py │ ├── ab418625f369_add_is_retired_state_to_cfg_states.py │ ├── ae93b3e95444_add_errors.py │ ├── af2de80654b6_add_default_compile_yara_rule_on_save_.py │ ├── b155053fbd56_merge_705e48818ad8_and_8090f8b3bbcb.py │ ├── b315f76a9a56_changing_tags_mapping_enums.py │ ├── b52a9e4d9587_enable_whitelist_settings.py │ ├── b5357371ee6d_add_config.py │ ├── b67c53c89680_add_imports_column_to_yara_rules.py │ ├── b8ab35edf211_default_states_and_category.py │ ├── b90dcb36a10a_rename_config.py │ ├── bc0fab3363f7_create_cfg_category_range_mapping_table.py │ ├── bf3d4a7f2f15_scripts_table.py │ ├── c5b6185beb4c_add_required_column_to_metadata_table.py │ ├── c8aec30b37d4_length_change_for_releases_text.py │ ├── cb108888af0b_new_files_table.py │ ├── d59c15bea7a6_changing_registered_on_attributes.py │ ├── d5cfdd54cb1f_new_setting_for_macro_tag_template.py │ ├── d73c420813ea_change_rule_json_to_large_binary.py │ ├── d8a036ecf92d_remove_nullable_and_add_total_files.py │ ├── ead50264bdf4_adding_yara_testing_history_table.py │ ├── ee0d67b4e552_add_export_with_release_column.py │ ├── f9ebccbd6e12_merge_aad1bab92536_and_d59c15bea7a6.py │ ├── faa23ce8d2c5_state_for_yara_rule_revisions.py │ ├── fc0cab9d77dc_fetch_revision_count_limit.py │ ├── fe5820317f46_artifact_static_references.py │ └── ffea56d3fc3f_default_cfg_settings.py ├── package.json ├── requirements.txt ├── run.py ├── run_agent.sh ├── run_web.sh ├── setup.py ├── testing_config.py ├── tests └── test_threatkb.py ├── threatkb_cli.py ├── uwsgi.yaml └── wait-for-it.sh /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "app/static/lib", 3 | "ignoredDependencies": [ 4 | "file-saver.js" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | config.py 2 | parsetab.py 3 | .editorconfig 4 | .jshintrc 5 | flask/ 6 | env/ 7 | .DS_Store 8 | *.db 9 | *.pyc 10 | *.swp 11 | *~ 12 | db_repository 13 | flask 14 | node_modules 15 | .DS_Store 16 | .idea 17 | *.log 18 | *.pyc 19 | *.pydevproject 20 | .metadata 21 | bin/ 22 | tmp/ 23 | include/ 24 | local/ 25 | *.tmp 26 | *.bak 27 | *.swp 28 | *~.nib 29 | local.properties 30 | .settings/ 31 | .loadpath 32 | app/static/lib 33 | .env* 34 | 35 | # Python artifact files 36 | build/ 37 | dist/ 38 | *.egg-info/ 39 | 40 | # Redis local output 41 | dump.rdb 42 | 43 | # Eclipse Core 44 | .project 45 | 46 | # External tool builders 47 | .externalToolBuilders/ 48 | 49 | # Locally stored "Eclipse launch configurations" 50 | *.launch 51 | 52 | # CDT-specific 53 | .cproject 54 | 55 | # JDT-specific (Eclipse Java Development Tools) 56 | .classpath 57 | 58 | # Java annotation processor (APT) 59 | .factorypath 60 | 61 | # PDT-specific 62 | .buildpath 63 | 64 | # sbteclipse plugin 65 | .target 66 | 67 | # TeXlipse plugin 68 | .texlipse 69 | 70 | # STS (Spring Tool Suite) 71 | .springBeans 72 | .vagrant 73 | 74 | version 75 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | services: 3 | - mysql 4 | before_install: 5 | - mysql -e 'CREATE DATABASE threatkb_test;' 6 | python: 7 | - "2.7" 8 | install: 9 | - "pip install nose" 10 | - "pip install -r requirements.txt" 11 | script: 12 | - SQL_PASSWORD= nosetests tests 13 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | # Update OS Packages, Install OS Dependencies (Do this in one line to ensure Update always happens) 4 | RUN apt-get update && \ 5 | DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt-get install -y git libsqlite3-dev python3.8 python3-pip npm libffi-dev libssl-dev mysql-client \ 6 | libmysqlclient-dev python3-dev libpython3-dev git yara apt-transport-https ca-certificates curl \ 7 | software-properties-common libpcre3 libpcre3-dev 8 | 9 | # Setup UWSGI Installation 10 | RUN /usr/sbin/useradd --system --no-log-init --no-create-home --shell /sbin/nologin --home-dir /var/run/uwsgi uwsgi 11 | COPY ./uwsgi.yaml /etc/uwsgi.yaml 12 | 13 | # Install Code Dependencies 14 | WORKDIR /opt/threatkb 15 | COPY package.json .bowerrc bower.json Gruntfile.js requirements.txt ./ 16 | 17 | # Install Python Dependencies 18 | RUN /usr/bin/pip3 install --upgrade pip & /usr/bin/pip3 install virtualenv 19 | RUN /usr/local/bin/virtualenv -p /usr/bin/python3.8 env 20 | RUN env/bin/pip3 install -r requirements.txt 21 | 22 | # Install Node Dependencies 23 | RUN npm install -g bower && bower install --allow-root 24 | 25 | # Add Package Files 26 | COPY . /opt/threatkb 27 | 28 | # Generate Version File 29 | RUN git log -1 --format="%H" > version 30 | RUN git log -1 --format="%cE" >> version 31 | RUN git log -1 --format="%ci" >> version 32 | RUN chmod 744 *.sh 33 | 34 | CMD ["/opt/threatkb/docker-entrypoint.sh"] 35 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include app/static * 2 | include config.py -------------------------------------------------------------------------------- /app/celeryapp.py: -------------------------------------------------------------------------------- 1 | from celery import Celery 2 | 3 | from app import app 4 | from app.models import cfg_settings 5 | 6 | def make_celery(flask_app): 7 | celery_app = Celery(flask_app.import_name, 8 | backend=flask_app.config['BROKER_URL'], 9 | broker=flask_app.config['BROKER_URL']) 10 | celery_app.conf.update(flask_app.config) 11 | # task_base = celery_app.Task 12 | # 13 | # class ContextTask(task_base): 14 | # abstract = True 15 | # 16 | # def __call__(self, *args, **kwargs): 17 | # with flask_app.app_context(): 18 | # return task_base.__call__(self, *args, **kwargs) 19 | # 20 | # celery_app.Task = ContextTask 21 | 22 | return celery_app 23 | 24 | 25 | celery = make_celery(app) 26 | -------------------------------------------------------------------------------- /app/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InQuest/ThreatKB/0aa087a7c25276b18e77115e41c6e580e9579dae/app/models/__init__.py -------------------------------------------------------------------------------- /app/models/access_keys.py: -------------------------------------------------------------------------------- 1 | from app import db 2 | 3 | 4 | class AccessKeys(db.Model): 5 | __tablename__ = "access_keys" 6 | 7 | id = db.Column(db.Integer, primary_key=True, autoincrement=True) 8 | user_id = db.Column(db.Integer, db.ForeignKey('kb_users.id'), nullable=False) 9 | user = db.relationship('KBUser', foreign_keys=user_id, primaryjoin="KBUser.id==AccessKeys.user_id") 10 | token = db.Column(db.String(255), unique=True, nullable=False) 11 | created = db.Column(db.DateTime(timezone=True), default=db.func.current_timestamp()) 12 | deleted = db.Column(db.DateTime(timezone=True), nullable=True) 13 | status = db.Column(db.Enum('active', 'inactive', 'deleted'), default='active') 14 | 15 | def to_dict(self): 16 | return dict( 17 | id=self.id, 18 | user=self.user.to_dict(), 19 | token=self.token, 20 | created=self.created.isoformat(), 21 | deleted=None if not self.deleted else self.deleted.isoformat(), 22 | status=self.status 23 | ) 24 | -------------------------------------------------------------------------------- /app/models/bookmarks.py: -------------------------------------------------------------------------------- 1 | from app import db, ENTITY_MAPPING 2 | 3 | 4 | class Bookmarks(db.Model): 5 | __tablename__ = "bookmarks" 6 | 7 | 8 | id = db.Column(db.Integer, primary_key=True) 9 | entity_type = db.Column(db.Integer(), index=True, nullable=False) 10 | entity_id = db.Column(db.Integer(), index=True, nullable=False) 11 | user_id = db.Column(db.Integer, db.ForeignKey('kb_users.id'), nullable=False) 12 | user = db.relationship('KBUser', foreign_keys=user_id) 13 | 14 | def to_dict(self, artifact_name=None, permalink_prefix=None): 15 | return dict( 16 | artifact_name=artifact_name, 17 | entity_type=list(ENTITY_MAPPING.keys())[list(ENTITY_MAPPING.values()).index(self.entity_type)], 18 | entity_id=self.entity_id, 19 | permalink_prefix=permalink_prefix, 20 | user=self.user.to_dict(), 21 | id=self.id 22 | ) 23 | 24 | def __repr__(self): 25 | return '' % self.id 26 | -------------------------------------------------------------------------------- /app/models/errors.py: -------------------------------------------------------------------------------- 1 | from app import db 2 | 3 | 4 | class Error(db.Model): 5 | id = db.Column(db.Integer, primary_key=True) 6 | date_created = db.Column(db.DateTime(timezone=True), default=db.func.current_timestamp()) 7 | date_modified = db.Column(db.DateTime(timezone=True), default=db.func.current_timestamp(), 8 | onupdate=db.func.current_timestamp()) 9 | stacktrace = db.Column(db.TEXT) 10 | route = db.Column(db.String(1024)) 11 | method = db.Column(db.String(16)) 12 | remote_addr = db.Column(db.String(32)) 13 | args = db.Column(db.TEXT) 14 | 15 | user_id = db.Column(db.Integer, db.ForeignKey('kb_users.id'), nullable=False) 16 | 17 | user = db.relationship('KBUser', foreign_keys=user_id) 18 | 19 | def to_dict(self): 20 | return dict( 21 | date_created=self.date_created.isoformat(), 22 | date_modified=self.date_modified.isoformat(), 23 | stacktrace=self.stacktrace, 24 | id=self.id, 25 | user=self.user.to_dict(), 26 | route=self.route, 27 | method=self.method, 28 | remote_addr=self.remote_addr, 29 | args=self.args 30 | ) 31 | 32 | def __repr__(self): 33 | return '' % (self.id, self.route) 34 | -------------------------------------------------------------------------------- /app/models/tags.py: -------------------------------------------------------------------------------- 1 | from app import db 2 | 3 | 4 | class Tags(db.Model): 5 | __tablename__ = "tags" 6 | 7 | id = db.Column(db.Integer, primary_key = True) 8 | text = db.Column(db.String(256), unique=True) 9 | 10 | def to_dict(self): 11 | return dict( 12 | text = self.text, 13 | id = self.id 14 | ) 15 | 16 | def __repr__(self): 17 | return '' % (self.id) 18 | -------------------------------------------------------------------------------- /app/models/tags_mapping.py: -------------------------------------------------------------------------------- 1 | from app import db 2 | from app.models import tags_mapping 3 | 4 | 5 | class Tags_mapping(db.Model): 6 | __tablename__ = "tags_mapping" 7 | 8 | id = db.Column(db.Integer, primary_key=True) 9 | 10 | source_table = db.Column(db.Enum('c2dns', 'c2ip', 'yara_rules', 'tasks'), index=True) 11 | 12 | source_id = db.Column(db.Integer, index=True) 13 | 14 | tag_id = db.Column(db.Integer, index=True) 15 | 16 | def to_dict(self): 17 | return dict( 18 | source_table = self.source_table, 19 | source_id = self.source_id, 20 | tag_id = self.tag_id, 21 | id = self.id 22 | ) 23 | 24 | @staticmethod 25 | def get_tags_mapping_cache(): 26 | from app.models import tags 27 | r = {} 28 | mapping = tags_mapping.Tags_mapping.query.all() 29 | tags = {tag.id: tag for tag in tags.Tags.query.all()} 30 | for map in mapping: 31 | if not r.get(map.source_table, []): 32 | r[map.source_table] = {} 33 | if not r[map.source_table].get(map.source_id,[]): 34 | r[map.source_table][map.source_id] = [] 35 | if map.tag_id in tags: 36 | r[map.source_table][map.source_id].append(tags[map.tag_id].text) 37 | 38 | return r 39 | 40 | def __repr__(self): 41 | return '' % (self.id) 42 | -------------------------------------------------------------------------------- /app/routes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InQuest/ThreatKB/0aa087a7c25276b18e77115e41c6e580e9579dae/app/routes/__init__.py -------------------------------------------------------------------------------- /app/routes/countries.py: -------------------------------------------------------------------------------- 1 | from flask import json, Response 2 | from app import app, auto 3 | import pycountry 4 | 5 | 6 | @app.route('/ThreatKB/countries', methods=['GET']) 7 | @auto.doc() 8 | def get_all_countries(): 9 | """Return all countries in ThreatKB 10 | Return: list of countries dictionary""" 11 | countries = pycountry.countries 12 | return Response(json.dumps([{ 13 | "countryCode2": country.alpha_2, 14 | "countryCode3": country.alpha_3, 15 | "countryName": str(country.name).strip() 16 | } for country in countries]), mimetype="application/json") 17 | 18 | 19 | def get_country(country): 20 | if country: 21 | if len(country) == 2: 22 | full_country = pycountry.countries.get(alpha_2=country) 23 | elif len(country) == 3: 24 | full_country = pycountry.countries.get(alpha_3=country) 25 | else: 26 | full_country = pycountry.countries.get(name=country) 27 | return {"countryCode2": full_country.alpha_2 if full_country else None, 28 | "countryCode3": full_country.alpha_3 if full_country else None, 29 | "countryName": str(full_country.name).strip() if full_country else None} 30 | else: 31 | return None 32 | -------------------------------------------------------------------------------- /app/routes/documentation.py: -------------------------------------------------------------------------------- 1 | from app import app, auto 2 | 3 | 4 | @app.route('/ThreatKB/documentation', methods=["GET"]) 5 | def documentation(): 6 | """Generate and return API documentation 7 | Return: API documentation HTML string""" 8 | return auto.html(template="autodoc_threatkb.html") 9 | -------------------------------------------------------------------------------- /app/routes/errors.py: -------------------------------------------------------------------------------- 1 | from flask import abort, jsonify, request, send_file, json, Response 2 | from flask_login import login_required, current_user 3 | from app import app, db, admin_only, auto 4 | from app.models import errors 5 | 6 | 7 | @app.route('/ThreatKB/errors', methods=['GET']) 8 | @auto.doc() 9 | @login_required 10 | @admin_only() 11 | def get_all_errors(): 12 | """Return all releases in ThreatKB 13 | Return: list of release dictionaries""" 14 | entities = errors.Error.query.order_by(errors.Error.id.desc()).limit(50).all() 15 | return Response(json.dumps([entity.to_dict() for entity in entities]), mimetype="application/json") 16 | 17 | 18 | @app.route('/ThreatKB/errors/', methods=['GET']) 19 | @auto.doc() 20 | @login_required 21 | @admin_only() 22 | def get_error(error_id): 23 | """Return error associated with error_id 24 | Return: error dictionary""" 25 | entity = errors.Error.query.get(error_id) 26 | 27 | if not entity: 28 | abort(404) 29 | 30 | return Response(json.dumps(entity.to_dict()), mimetype="application/json") 31 | -------------------------------------------------------------------------------- /app/routes/index.py: -------------------------------------------------------------------------------- 1 | from app import app, auto 2 | from flask import send_from_directory 3 | import os 4 | 5 | @app.route('/') 6 | @auto.doc() 7 | def root(): 8 | """Root route 9 | Return: index.html""" 10 | return app.send_static_file('index.html') 11 | 12 | 13 | @app.route('/favicon.ico') 14 | def favicon(): 15 | return send_from_directory(os.path.join(app.root_path, 'static/images'), 16 | 'favicon.ico', mimetype='image/vnd.microsoft.icon') 17 | -------------------------------------------------------------------------------- /app/routes/version.py: -------------------------------------------------------------------------------- 1 | from flask import request, Response, json, abort 2 | from flask_login import login_required 3 | from app import app, db, auto 4 | import json 5 | 6 | 7 | @app.route('/ThreatKB/version', methods=['GET']) 8 | @auto.doc() 9 | def get_version(): 10 | """Returns the version of ThreatKB. 11 | Return: version number""" 12 | try: 13 | version = [v.strip() for v in open("version", "r").readlines()] 14 | return Response( 15 | json.dumps({"version": version[0], "version_email": version[1], "version_date": version[2][:-6]}), 16 | mimetype='application/json') 17 | except: 18 | return Response( 19 | json.dumps({"version": "unavailable", "version_email": "unavailable", "version_date": "unavailable"}), 20 | mimetype='application/json') 21 | -------------------------------------------------------------------------------- /app/slack_helper.py: -------------------------------------------------------------------------------- 1 | import json 2 | import requests 3 | 4 | class SlackHelper(): 5 | 6 | @staticmethod 7 | def send_slack_message(web_hook, user, channel, message): 8 | """Send a slack message 9 | 10 | @param web_hook: slack web hook 11 | @param user: slack user 12 | @param channel: slack channel to post to 13 | @param message: the message to send 14 | @return: True on success, false otherwise 15 | @author: danny 16 | """ 17 | 18 | payload = {"text": message, "username": user, "channel": channel} 19 | 20 | req = requests.post(web_hook, json.dumps(payload), headers={'content-type': 'application/json'}) 21 | return True 22 | -------------------------------------------------------------------------------- /app/static/components/tkb-codemirror/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | Find 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Wrap 15 | 17 | 18 | 19 |
20 | 21 |
24 | -------------------------------------------------------------------------------- /app/static/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InQuest/ThreatKB/0aa087a7c25276b18e77115e41c6e580e9579dae/app/static/images/favicon.ico -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-ae.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-am.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-at.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-aw.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-ax.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-flag-ax 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-bd.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-be.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-bf.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-bg.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-bh.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-bj.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-bl.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | icon-flag-bl 4 | Created with Sketch. 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-bo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-br.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-flag-br 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-bs.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-bv.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-flag-bv 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-bw.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-cd.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-cg.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-ch.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-ci.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-cm.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-co.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-cu.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-cw.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-cz.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-de.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-dj.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-dk.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-ee.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-fi.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-fo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-flag-fo 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-fr.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-ga.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-gf.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-flag-gf 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-gg.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-gl.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-gm.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-gn.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-gr.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-gw.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-gy.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-hu.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-id.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-ie.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-is.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-it.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-jm.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-jo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-jp.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-kn.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-kp.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-kw.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-la.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-lc.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-lt.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-lu.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-lv.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-mc.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-mf.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-flag-mf 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-mg.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-mh.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-ml.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-mq.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-flag-mq 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-mr.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-mu.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-mv.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-ne.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-ng.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-nl.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-no.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-none.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-flag-xx 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-nr.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-pe.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-pk.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-pl.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-pm.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-flag-pm 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-ps.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-flag-ps 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-pw.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-qa.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-re.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-flag-re 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-ro.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-ru.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-sc.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-sd.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-se.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-sj.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-sl.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-sn.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-so.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-sr.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-sy.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-td.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-tg.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-flag-tg 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-th.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-tl.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-to.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-tr.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-tt.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-tz.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-ua.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-vc.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-vn.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-wf.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-ye.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-flag-ye 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-yt.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icon-flag-yt 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/static/images/flags/icon-flag-za.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/static/js/access_keys/access_keys-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('AccessKeys', ['$resource', '$http', function ($resource, $http) { 5 | 6 | var access_keys_resource = $resource('/ThreatKB/access_keys/:id', {}, { 7 | 'query': {method: 'GET', isArray: true}, 8 | 'get': {method: 'GET'}, 9 | 'update': {method: 'PUT'} 10 | }); 11 | 12 | function getActiveInactiveCount() { 13 | return $http.get('/ThreatKB/access_keys/count', {cache: false}) 14 | .then(function (response) { 15 | return response; 16 | }, function (error) { 17 | }); 18 | } 19 | 20 | function get_cli() { 21 | return $http.get('/ThreatKB/access_keys/cli', {cache: false}) 22 | .then(function (response) { 23 | return response; 24 | }, function (error) { 25 | }); 26 | } 27 | 28 | return { 29 | resource: access_keys_resource, 30 | getActiveInactiveCount: getActiveInactiveCount, 31 | get_cli: get_cli 32 | }; 33 | }]); 34 | -------------------------------------------------------------------------------- /app/static/js/activity_log/activity_log-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('ActivityLog', ['$resource', function ($resource) { 5 | return { 6 | resource: $resource('ThreatKB/activity_log/:id', {}, { 7 | 'query': {method: 'GET', isArray: true} 8 | }), 9 | PERMALINK_MAPPING: { 10 | IP: "c2ips", 11 | DNS: "c2dns", 12 | SIGNATURE: "yara_rules", 13 | TASK: "tasks", 14 | RELEASE: "releases" 15 | } 16 | }; 17 | }]); 18 | -------------------------------------------------------------------------------- /app/static/js/cfg_category_range_mapping/cfg_category_range_mapping-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('CfgCategoryRangeMapping', ['$resource', function ($resource) { 5 | return $resource('ThreatKB/cfg_category_range_mapping/:id', {}, { 6 | 'query': {method: 'GET', isArray: true}, 7 | 'get': {method: 'GET'}, 8 | 'update': {method: 'PUT'} 9 | }); 10 | }]); 11 | -------------------------------------------------------------------------------- /app/static/js/cfg_settings/cfg_settings-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('Cfg_settings', ['$resource', function ($resource) { 5 | return $resource('ThreatKB/cfg_settings/:key', {}, { 6 | 'query': {method: 'GET', isArray: true}, 7 | 'get': {method: 'GET'}, 8 | 'update': {method: 'PUT'} 9 | }); 10 | }]); 11 | -------------------------------------------------------------------------------- /app/static/js/cfg_states/cfg_states-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('Cfg_states', ['$resource', function ($resource) { 5 | return $resource('ThreatKB/cfg_states/:id', {}, { 6 | 'query': {method: 'GET', isArray: true}, 7 | 'get': {method: 'GET'}, 8 | 'update': {method: 'PUT'} 9 | }); 10 | }]); 11 | -------------------------------------------------------------------------------- /app/static/js/comments/comments-controller.js: -------------------------------------------------------------------------------- 1 | /** EMPTY FOR NOW **/ 2 | -------------------------------------------------------------------------------- /app/static/js/comments/comments-service.js: -------------------------------------------------------------------------------- 1 | angular.module('ThreatKB') 2 | .factory('Comments', ['$resource', function ($resource) { 3 | return { 4 | resource: $resource('ThreatKB/comments/:id', {}, { 5 | 'query': {method: 'GET', isArray: true}, 6 | 'get': {method: 'GET'}, 7 | 'update': {method: 'PUT'} 8 | }), 9 | ENTITY_MAPPING: {IP: 3, DNS: 2, SIGNATURE: 1, TASK: 4} 10 | }; 11 | }]); 12 | -------------------------------------------------------------------------------- /app/static/js/countries/countries-service.js: -------------------------------------------------------------------------------- 1 | angular.module('ThreatKB') 2 | .factory('Countries', ['$resource', 3 | function ($resource) { 4 | return $resource('/ThreatKB/countries', {}, { 5 | 'query': {method: 'GET', isArray: true} 6 | }); 7 | } 8 | ] 9 | ); 10 | -------------------------------------------------------------------------------- /app/static/js/dashboard/dashboard-controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .controller('DashboardController', ['$scope', '$location', 'resolvedCfgCategoryRangeMapping', 'resolvedReleasesLatest', 'resolvedCfg_states', 'resolvedOwnershipData', 'resolvedBookmarks', 'resolvedVersion', 'Release', 5 | function ($scope, $location, resolvedCfgCategoryRangeMapping, resolvedReleasesLatest, resolvedCfg_states, resolvedOwnershipData, resolvedBookmarks, resolvedVersion, Release) { 6 | $scope.bookmarks = resolvedBookmarks; 7 | $scope.cfg_category_range_mapping = resolvedCfgCategoryRangeMapping; 8 | $scope.cfg_states = resolvedCfg_states; 9 | $scope.ownership_data = resolvedOwnershipData; 10 | $scope.latest_releases = resolvedReleasesLatest; 11 | $scope.version = resolvedVersion; 12 | 13 | $scope.customSearch = function(actual, expected) { 14 | if (expected.length < 3) { 15 | return true; 16 | } else if (typeof actual !== "object") { 17 | return actual.toString().toLowerCase().indexOf(expected.toString().toLowerCase()) !== -1; 18 | } else { 19 | return false; 20 | } 21 | }; 22 | 23 | $scope.getPermalink = function (prefix, id) { 24 | return $location.absUrl() + prefix + "/" + id; 25 | }; 26 | }]); 27 | -------------------------------------------------------------------------------- /app/static/js/errors/errors-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('Errors', ['$resource', function ($resource) { 5 | return $resource('ThreatKB/errors/:id', {}, { 6 | 'query': {method: 'GET', isArray: true}, 7 | 'get': {method: 'GET'}, 8 | 'update': {method: 'PUT'} 9 | }); 10 | }]); 11 | -------------------------------------------------------------------------------- /app/static/js/files/files-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('Files', ['$resource', function ($resource) { 5 | return { 6 | resource: $resource('ThreatKB/files/:id', {}, { 7 | 'query': {method: 'GET', isArray: true}, 8 | 'get': {method: 'GET'}, 9 | 'update': {method: 'PUT'} 10 | }), 11 | ENTITY_MAPPING: {SIGNATURE: 1} 12 | }; 13 | }]); 14 | -------------------------------------------------------------------------------- /app/static/js/macros/macros-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('Macros', ['$resource', '$q', '$http', function ($resource, $q, $http) { 5 | 6 | function activate(tag) { 7 | return $http.put('/ThreatKB/macros/activate/' + tag) 8 | .then(function (success) { 9 | if (success.status === 200) { 10 | return success.data; 11 | } 12 | }, function (error) { 13 | return $q.reject(error.data); 14 | } 15 | ); 16 | } 17 | 18 | return { 19 | resource: $resource('ThreatKB/macros/:tag', {}, { 20 | 'query': {method: 'GET', isArray: true}, 21 | 'get': {method: 'GET'}, 22 | 'update': {method: 'PUT'} 23 | }), 24 | activate: activate 25 | }; 26 | }]); 27 | -------------------------------------------------------------------------------- /app/static/js/metadata/metadata-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('Metadata', ['$resource', function ($resource) { 5 | return $resource('ThreatKB/metadata/:key', {}, { 6 | 'query': {method: 'GET', isArray: true}, 7 | 'get': {method: 'GET'}, 8 | 'update': {method: 'PUT'} 9 | }); 10 | }]); 11 | -------------------------------------------------------------------------------- /app/static/js/scripts/scripts-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('Script', ['$resource', '$http', '$q', function ($resource, $http, $q) { 5 | 6 | function run_script(script_id, arguments_, highlight_lines_matching) { 7 | return $http.post('/ThreatKB/scripts/run/' + script_id, { 8 | highlight_lines_matching: highlight_lines_matching, 9 | arguments: arguments_ 10 | }) 11 | .then(function (success) { 12 | if (success.status === 200 && success.data) { 13 | return success.data; 14 | } else { 15 | //TODO 16 | } 17 | }, function (error) { 18 | return $q.reject(error.data); 19 | } 20 | ); 21 | }; 22 | 23 | return { 24 | resource: $resource('ThreatKB/scripts/:id', {}, { 25 | 'query': {method: 'GET', isArray: true}, 26 | 'get': {method: 'GET'}, 27 | 'update': {method: 'PUT'} 28 | }), run_script: run_script 29 | }; 30 | }]); 31 | -------------------------------------------------------------------------------- /app/static/js/tags/tags-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('Tags', ['$resource', '$q', '$timeout', '$http', function ($resource, $q, $timeout, $http) { 5 | 6 | var tags_resource = $resource('ThreatKB/tags/:id', {}, { 7 | 'query': {method: 'GET', isArray: true}, 8 | 'get': {method: 'GET'}, 9 | 'update': {method: 'PUT'} 10 | }); 11 | 12 | function loadTags(query) { 13 | return $http.get('/ThreatKB/tags', {cache: false}).then(function (response) { 14 | var tags = response.data; 15 | return tags.filter(function (tag) { 16 | return tag.text.toLowerCase().indexOf(query.toLowerCase()) !== -1; 17 | }); 18 | }, function (error) { 19 | return $q.reject(error.data); 20 | }); 21 | } 22 | 23 | return { 24 | resource: tags_resource, 25 | loadTags: loadTags 26 | }; 27 | }]); 28 | -------------------------------------------------------------------------------- /app/static/js/tags_mapping/tags_mapping-controller.js: -------------------------------------------------------------------------------- 1 | // 'use strict'; 2 | // 3 | // angular.module('ThreatKB') 4 | // .controller('Tags_mappingController', ['$scope', 'resolvedTags_mapping', 'Tags_mapping', 5 | // function ($scope, resolvedTags_mapping, Tags_mapping) { 6 | // 7 | // $scope.tags_mapping = resolvedTags_mapping; 8 | // 9 | // $scope.update = function (source, id, tags) { 10 | // console.log("update tags: " + tags); 11 | // // $scope.tags_mapping = Tags_mapping.get({id: id}); 12 | // }; 13 | // 14 | // $scope.delete = function (id) { 15 | // Tags_mapping.delete({id: id}, 16 | // function () { 17 | // $scope.tags_mapping = Tags_mapping.query(); 18 | // }); 19 | // }; 20 | // 21 | // $scope.save = function (id) { 22 | // if (id) { 23 | // Tags_mapping.update({id: id}, $scope.tags_mapping, 24 | // function () { 25 | // $scope.tags_mapping = Tags_mapping.query(); 26 | // // $scope.clear(); 27 | // }); 28 | // } else { 29 | // Tags_mapping.save($scope.tags_mapping, 30 | // function () { 31 | // $scope.tags_mapping = Tags_mapping.query(); 32 | // // $scope.clear(); 33 | // }); 34 | // } 35 | // }; 36 | // }]); 37 | -------------------------------------------------------------------------------- /app/static/js/tags_mapping/tags_mapping-service.js: -------------------------------------------------------------------------------- 1 | // 'use strict'; 2 | // 3 | // angular.module('ThreatKB') 4 | // .factory('Tags_mapping', ['$resource', function ($resource) { 5 | // return $resource('ThreatKB/tags_mapping/:id', {}, { 6 | // 'query': { method: 'GET', isArray: true}, 7 | // 'get': { method: 'GET'}, 8 | // 'update': {method: 'PUT'} 9 | // }); 10 | // }]); 11 | -------------------------------------------------------------------------------- /app/static/js/tasks/tasks-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('Task', ['$resource', '$q', '$http', function ($resource, $q, $http) { 5 | 6 | function updateBatch(batch) { 7 | return $http.put('/ThreatKB/tasks/batch/edit', { 8 | batch: batch 9 | }).then(function (success) { 10 | if (success.status === 200) { 11 | return success.data; 12 | } 13 | }, function (error) { 14 | return $q.reject(error.data); 15 | } 16 | ); 17 | } 18 | 19 | function deleteBatch(batch) { 20 | return $http.put('/ThreatKB/tasks/batch/delete', { 21 | batch: batch 22 | }).then(function (success) { 23 | if (success.status === 200) { 24 | return success.data; 25 | } 26 | }, function (error) { 27 | return $q.reject(error.data); 28 | } 29 | ); 30 | } 31 | 32 | return { 33 | resource: $resource('ThreatKB/tasks/:id', {}, { 34 | 'query': {method: 'GET', isArray: true}, 35 | 'get': {method: 'GET'}, 36 | 'update': {method: 'PUT'} 37 | }), 38 | updateBatch: updateBatch, 39 | deleteBatch: deleteBatch 40 | }; 41 | }]); 42 | -------------------------------------------------------------------------------- /app/static/js/tests/tests-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('Tests', ['$resource', '$q', '$http', function ($resource, $q, $http) { 5 | 6 | return { 7 | resource: $resource('ThreatKB/tests/:id', {}, { 8 | 'query': {method: 'GET', isArray: true}, 9 | 'get': {method: 'GET'}, 10 | 'update': {method: 'PUT'} 11 | }) 12 | }; 13 | }]); 14 | -------------------------------------------------------------------------------- /app/static/js/users/users-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('Users', ['$resource', function ($resource) { 5 | return $resource('/ThreatKB/users/:id', {}, { 6 | 'query': {method: 'GET', isArray: true}, 7 | 'get': {method: 'GET'}, 8 | 'delete': {method: 'DELETE'} 9 | }); 10 | }]); 11 | -------------------------------------------------------------------------------- /app/static/js/version/version-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('Version', ['$resource', '$http', '$q', function ($resource, $http, $q) { 5 | 6 | function get_version() { 7 | return $http.get('/ThreatKB/version', { 8 | cache: false, 9 | }).then(function (response) { 10 | return response.data; 11 | }, function (error) { 12 | return $q.reject(error.data); 13 | }) 14 | } 15 | 16 | return { 17 | get_version: get_version 18 | }; 19 | }]); 20 | -------------------------------------------------------------------------------- /app/static/js/whitelist/whitelist-service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('ThreatKB') 4 | .factory('Whitelist', ['$resource', function ($resource) { 5 | return $resource('ThreatKB/whitelist/:id', {}, { 6 | 'query': {method: 'GET', isArray: true}, 7 | 'get': {method: 'GET'}, 8 | 'update': {method: 'PUT'} 9 | }); 10 | }]); 11 | -------------------------------------------------------------------------------- /app/static/views/activity_log/activity_log.html: -------------------------------------------------------------------------------- 1 | 14 | 15 |
16 |
18 |
19 |
20 | -------------------------------------------------------------------------------- /app/static/views/authentication/login.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InQuest/ThreatKB/0aa087a7c25276b18e77115e41c6e580e9579dae/app/static/views/authentication/login.html -------------------------------------------------------------------------------- /app/static/views/home.html: -------------------------------------------------------------------------------- 1 | 2 |

3 |
Say something cool here....
4 | -------------------------------------------------------------------------------- /app/static/views/login.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 32 |
33 | -------------------------------------------------------------------------------- /app/test/test_tkb.py: -------------------------------------------------------------------------------- 1 | from app import app 2 | 3 | a 4 | -------------------------------------------------------------------------------- /data/GeoLite2-ASN.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InQuest/ThreatKB/0aa087a7c25276b18e77115e41c6e580e9579dae/data/GeoLite2-ASN.mmdb -------------------------------------------------------------------------------- /data/GeoLite2-City.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InQuest/ThreatKB/0aa087a7c25276b18e77115e41c6e580e9579dae/data/GeoLite2-City.mmdb -------------------------------------------------------------------------------- /docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | 5 | env 6 | 7 | cd /opt/threatkb 8 | ./wait-for-it.sh db:3306 -- echo "db is up" 9 | 10 | if [[ ! -z "${RUN_AGENT}" ]]; then 11 | env/bin/celery -A app.celery worker --uid uwsgi --loglevel=info 12 | else 13 | find . -name "*.pyc" -exec rm -f {} \; 14 | env/bin/flask db upgrade 15 | 16 | num_users=`echo "select count(*) from kb_users;" | mysql -u ${SQL_USERNAME} -p"${SQL_PASSWORD}" -h ${SQL_HOST} ${SQL_DATABASE} | sed 's/[^0-9]//g'` 17 | if [ $num_users -lt 1 ]; then 18 | PASSWORD=`env/bin/python3.8 hash_pass.py ${THREATKB_PASS}` 19 | mysql -u ${SQL_USERNAME} -p"${SQL_PASSWORD}" ${SQL_DATABASE} -h ${SQL_HOST} -e "insert into kb_users (email,password,admin,active) values (\"${THREATKB_USER}\", \"${PASSWORD}\", 1, 1);" 20 | fi 21 | #env/bin/python run.py --listen-on ${LISTEN_ON} --listen-port ${LISTEN_PORT} 22 | env/bin/python3.8 run.py --listen-on "${LISTEN_ON:-0.0.0.0}" --listen-port "${LISTEN_PORT:-5000}" 23 | fi 24 | -------------------------------------------------------------------------------- /env_template: -------------------------------------------------------------------------------- 1 | export SQL_PROTOCOL='mysql' 2 | export SQL_HOST='127.0.0.1' 3 | export SQL_PORT='3306' 4 | export SQL_DATABASE='' 5 | export SQL_USERNAME='' 6 | export SQL_PASSWORD='' 7 | -------------------------------------------------------------------------------- /hash_pass.py: -------------------------------------------------------------------------------- 1 | #!flask/bin/python 2 | import sys 3 | from flask_bcrypt import Bcrypt 4 | from flask import Flask 5 | 6 | app = Flask(__name__, static_url_path="") 7 | b = Bcrypt(app) 8 | 9 | print((b.generate_password_hash(sys.argv[1]).decode())) 10 | -------------------------------------------------------------------------------- /install.bat: -------------------------------------------------------------------------------- 1 | python virtualenv.py env 2 | env\Scripts\pip install setuptools --no-use-wheel --upgrade 3 | env\Scripts\pip install flask==0.9 4 | env\Scripts\pip install flask-login 5 | env\Scripts\pip install flask-openid 6 | env\Scripts\pip install sqlalchemy==0.7.9 7 | env\Scripts\pip install flask-sqlalchemy==0.16 8 | env\Scripts\pip install sqlalchemy-migrate==0.7.2 9 | env\Scripts\pip install flask-whooshalchemy==0.54a 10 | env\Scripts\pip install flask-wtf==0.8.4 11 | env\Scripts\pip install pytz==2013b 12 | env\Scripts\pip install flask-babel==0.8 13 | env\Scripts\pip install flup 14 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Bootstrap script to setup environment for ThreatKB 3 | 4 | python3 -m venv env 5 | if [ $? -ne 0 ]; then 6 | echo "error: failed to setup virtual environment!" 7 | exit 1 8 | fi 9 | 10 | env/bin/python3 setup.py sdist 11 | if [ $? -ne 0 ]; then 12 | echo "error: failed to install python3 setup.py sdist" 13 | exit 1 14 | fi 15 | 16 | env/bin/pip3 install -r requirements.txt 17 | if [ $? -ne 0 ]; then 18 | echo "error: failed to install pip3 requirements.txt" 19 | exit 1 20 | fi 21 | 22 | env/bin/python3 manage.py db upgrade 23 | if [ $? -ne 0 ]; then 24 | echo "error: failed to run 'python3 db upgrade'" 25 | exit 1 26 | fi 27 | 28 | bower install 29 | if [ $? -ne 0 ]; then 30 | echo "error: failed to install bower requirements!" 31 | exit 1 32 | fi 33 | 34 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | from flask_script import Manager 2 | from flask_migrate import Migrate, MigrateCommand 3 | 4 | from app import app, db 5 | 6 | app.config.from_object('config') 7 | 8 | migrate = Migrate(app, db) 9 | manager = Manager(app) 10 | 11 | manager.add_command('db', MigrateCommand) 12 | 13 | if __name__ == '__main__': 14 | """ 15 | Below imports needed for migration 16 | Alphabetize them for readability and to ensure all are added. 17 | """ 18 | from app.models import access_keys 19 | from app.models import activity_log 20 | from app.models import bookmarks 21 | from app.models import c2dns 22 | from app.models import c2ip 23 | from app.models import cfg_category_range_mapping 24 | from app.models import cfg_settings 25 | from app.models import cfg_states 26 | from app.models import comments 27 | from app.models import errors 28 | from app.models import files 29 | from app.models import macros 30 | from app.models import metadata 31 | from app.models import releases 32 | from app.models import scripts 33 | from app.models import tags 34 | from app.models import tags_mapping 35 | from app.models import tasks 36 | from app.models import users 37 | from app.models import whitelist 38 | from app.models import yara_rule 39 | 40 | manager.run() 41 | -------------------------------------------------------------------------------- /migrations/alembic.ini: -------------------------------------------------------------------------------- 1 | # A generic, single database configuration. 2 | 3 | [alembic] 4 | # template used to generate migration files 5 | # file_template = %%(rev)s_%%(slug)s 6 | 7 | # set to 'true' to run the environment during 8 | # the 'revision' command, regardless of autogenerate 9 | # revision_environment = false 10 | 11 | 12 | # Logging configuration 13 | [loggers] 14 | keys = root,sqlalchemy,alembic 15 | 16 | [handlers] 17 | keys = console 18 | 19 | [formatters] 20 | keys = generic 21 | 22 | [logger_root] 23 | level = WARN 24 | handlers = console 25 | qualname = 26 | 27 | [logger_sqlalchemy] 28 | level = WARN 29 | handlers = 30 | qualname = sqlalchemy.engine 31 | 32 | [logger_alembic] 33 | level = INFO 34 | handlers = 35 | qualname = alembic 36 | 37 | [handler_console] 38 | class = StreamHandler 39 | args = (sys.stderr,) 40 | level = NOTSET 41 | formatter = generic 42 | 43 | [formatter_generic] 44 | format = %(levelname)-5.5s [%(name)s] %(message)s 45 | datefmt = %H:%M:%S 46 | -------------------------------------------------------------------------------- /migrations/script.py.mako: -------------------------------------------------------------------------------- 1 | """${message} 2 | 3 | Revision ID: ${up_revision} 4 | Revises: ${down_revision | comma,n} 5 | Create Date: ${create_date} 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | ${imports if imports else ""} 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = ${repr(up_revision)} 14 | down_revision = ${repr(down_revision)} 15 | branch_labels = ${repr(branch_labels)} 16 | depends_on = ${repr(depends_on)} 17 | 18 | 19 | def upgrade(): 20 | ${upgrades if upgrades else "pass"} 21 | 22 | 23 | def downgrade(): 24 | ${downgrades if downgrades else "pass"} 25 | -------------------------------------------------------------------------------- /migrations/versions/0896164f6037_add_sig_dns_ip_tracking_to_releases.py: -------------------------------------------------------------------------------- 1 | """Add sig, dns, ip tracking to releases 2 | 3 | Revision ID: 0896164f6037 4 | Revises: 658ab905b871 5 | Create Date: 2018-05-16 11:01:28.681080 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '0896164f6037' 14 | down_revision = '658ab905b871' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.add_column('releases', sa.Column('num_dns', sa.Integer(), nullable=True)) 22 | op.add_column('releases', sa.Column('num_ips', sa.Integer(), nullable=True)) 23 | op.add_column('releases', sa.Column('num_signatures', sa.Integer(), nullable=True)) 24 | # ### end Alembic commands ### 25 | 26 | 27 | def downgrade(): 28 | # ### commands auto generated by Alembic - please adjust! ### 29 | op.drop_column('releases', 'num_signatures') 30 | op.drop_column('releases', 'num_ips') 31 | op.drop_column('releases', 'num_dns') 32 | # ### end Alembic commands ### 33 | -------------------------------------------------------------------------------- /migrations/versions/0bd5407cc66d_add_is_release_state_column_to_states.py: -------------------------------------------------------------------------------- 1 | """Add is_release_state column to states 2 | 3 | Revision ID: 0bd5407cc66d 4 | Revises: 681507459b5d 5 | Create Date: 2017-08-29 11:22:54.441854 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | # revision identifiers, used by Alembic. 12 | revision = '0bd5407cc66d' 13 | down_revision = '681507459b5d' 14 | branch_labels = None 15 | depends_on = None 16 | 17 | 18 | def upgrade(): 19 | pass 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | # op.add_column('cfg_states', sa.Column('is_release_state', sa.Integer(), nullable=True)) 22 | # ### end Alembic commands ### 23 | 24 | 25 | def downgrade(): 26 | pass 27 | # ### commands auto generated by Alembic - please adjust! ### 28 | #op.drop_column('cfg_states', 'is_release_state') 29 | # ### end Alembic commands ### 30 | -------------------------------------------------------------------------------- /migrations/versions/0df6e90050b5_add_mitre_subtechniques.py: -------------------------------------------------------------------------------- 1 | """add mitre subtechniques 2 | 3 | Revision ID: 0df6e90050b5 4 | Revises: 072dd2b2d9a5 5 | Create Date: 2022-05-14 09:57:42.657840 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '0df6e90050b5' 14 | down_revision = '072dd2b2d9a5' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.add_column('yara_rules', sa.Column('_mitre_sub_techniques', sa.String(length=256), nullable=True)) 22 | # ### end Alembic commands ### 23 | 24 | 25 | def downgrade(): 26 | # ### commands auto generated by Alembic - please adjust! ### 27 | op.drop_index(op.f('ix_yara_rules__mitre_sub_techniques'), table_name='yara_rules') 28 | # ### end Alembic commands ### 29 | -------------------------------------------------------------------------------- /migrations/versions/0e2074fb38e8_default_tags.py: -------------------------------------------------------------------------------- 1 | """default tags 2 | 3 | Revision ID: 0e2074fb38e8 4 | Revises: b8ab35edf211 5 | Create Date: 2017-10-30 23:20:11.290244 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from app.models import tags 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '0e2074fb38e8' 14 | down_revision = 'b8ab35edf211' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | op.bulk_insert( 21 | tags.Tags.__table__, [ 22 | {"text": "Suspicous Javascript"}, 23 | {"text": "Malware"} 24 | ] 25 | ) 26 | 27 | 28 | def downgrade(): 29 | op.execute("""DELETE from tags;""") 30 | -------------------------------------------------------------------------------- /migrations/versions/15b203983adb_add_owner_columns_to_c2dns_c2ip_yara_.py: -------------------------------------------------------------------------------- 1 | """Add owner columns to c2dns, c2ip, yara_rules 2 | 3 | Revision ID: 15b203983adb 4 | Revises: f9ebccbd6e12 5 | Create Date: 2017-09-04 11:24:13.773895 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '15b203983adb' 14 | down_revision = 'f9ebccbd6e12' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.add_column('c2dns', sa.Column('owner_user_id', sa.Integer(), nullable=True)) 22 | op.create_foreign_key(None, 'c2dns', 'kb_users', ['owner_user_id'], ['id']) 23 | op.add_column('c2ip', sa.Column('owner_user_id', sa.Integer(), nullable=True)) 24 | op.create_foreign_key(None, 'c2ip', 'kb_users', ['owner_user_id'], ['id']) 25 | op.add_column('yara_rules', sa.Column('owner_user_id', sa.Integer(), nullable=True)) 26 | op.create_foreign_key(None, 'yara_rules', 'kb_users', ['owner_user_id'], ['id']) 27 | # ### end Alembic commands ### 28 | 29 | 30 | def downgrade(): 31 | # ### commands auto generated by Alembic - please adjust! ### 32 | pass 33 | # ### end Alembic commands ### 34 | -------------------------------------------------------------------------------- /migrations/versions/2a30c4968d80_.py: -------------------------------------------------------------------------------- 1 | """Merge revision branches 2 | 3 | Revision ID: 2a30c4968d80 4 | Revises: 3a3368610e08, b90dcb36a10a 5 | Create Date: 2017-08-22 15:29:04.446725 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | # revision identifiers, used by Alembic. 12 | revision = '2a30c4968d80' 13 | down_revision = ('3a3368610e08', 'b90dcb36a10a') 14 | branch_labels = None 15 | depends_on = None 16 | 17 | 18 | def upgrade(): 19 | pass 20 | 21 | 22 | def downgrade(): 23 | pass 24 | -------------------------------------------------------------------------------- /migrations/versions/385e63a30f6e_add_first_name_last_name_picture_fields_.py: -------------------------------------------------------------------------------- 1 | """Add first_name, last_name, picture fields to user 2 | 3 | Revision ID: 385e63a30f6e 4 | Revises: 8083ff92369f 5 | Create Date: 2017-10-08 20:05:51.624731 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | # revision identifiers, used by Alembic. 12 | revision = '385e63a30f6e' 13 | down_revision = '8083ff92369f' 14 | branch_labels = None 15 | depends_on = None 16 | 17 | 18 | def upgrade(): 19 | # ### commands auto generated by Alembic - please adjust! ### 20 | op.add_column('kb_users', sa.Column('first_name', sa.String(length=255), nullable=True)) 21 | op.add_column('kb_users', sa.Column('last_name', sa.String(length=255), nullable=True)) 22 | op.add_column('kb_users', sa.Column('picture', sa.LargeBinary(), nullable=True)) 23 | # ### end Alembic commands ### 24 | 25 | 26 | def downgrade(): 27 | # ### commands auto generated by Alembic - please adjust! ### 28 | op.drop_column('kb_users', 'picture') 29 | op.drop_column('kb_users', 'last_name') 30 | op.drop_column('kb_users', 'first_name') 31 | # ### end Alembic commands ### 32 | -------------------------------------------------------------------------------- /migrations/versions/38aa862c0a93_add_active_column_to_tasks_table.py: -------------------------------------------------------------------------------- 1 | """Add active column to tasks table 2 | 3 | Revision ID: 38aa862c0a93 4 | Revises: 4fb69d540f6d 5 | Create Date: 2017-09-17 10:17:00.857968 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | # revision identifiers, used by Alembic. 12 | revision = '38aa862c0a93' 13 | down_revision = '4fb69d540f6d' 14 | branch_labels = None 15 | depends_on = None 16 | 17 | 18 | def upgrade(): 19 | # ### commands auto generated by Alembic - please adjust! ### 20 | op.add_column('tasks', sa.Column('active', sa.Boolean(), nullable=False)) 21 | # ### end Alembic commands ### 22 | 23 | 24 | def downgrade(): 25 | # ### commands auto generated by Alembic - please adjust! ### 26 | op.drop_column('tasks', 'active') 27 | # ### end Alembic commands ### 28 | -------------------------------------------------------------------------------- /migrations/versions/3a2003939cc4_made_current_column_nullable.py: -------------------------------------------------------------------------------- 1 | """made current column nullable 2 | 3 | Revision ID: 3a2003939cc4 4 | Revises: 3d325922125f 5 | Create Date: 2017-08-13 23:33:28.023907 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '3a2003939cc4' 14 | down_revision = '3d325922125f' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.alter_column('cfg_category_range_mapping', 'current', 22 | existing_type=mysql.INTEGER(display_width=11), 23 | nullable=True) 24 | # ### end Alembic commands ### 25 | 26 | 27 | def downgrade(): 28 | # ### commands auto generated by Alembic - please adjust! ### 29 | op.alter_column('cfg_category_range_mapping', 'current', 30 | existing_type=mysql.INTEGER(display_width=11), 31 | nullable=False) 32 | # ### end Alembic commands ### 33 | -------------------------------------------------------------------------------- /migrations/versions/3a3368610e08_adding_avg_millis_per_file_column_to_.py: -------------------------------------------------------------------------------- 1 | """adding avg_millis_per_file column to testing_history 2 | 3 | Revision ID: 3a3368610e08 4 | Revises: ead50264bdf4 5 | Create Date: 2017-08-20 23:08:26.374145 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '3a3368610e08' 14 | down_revision = 'ead50264bdf4' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.add_column('yara_testing_history', sa.Column('avg_millis_per_file', sa.Float(), nullable=False)) 22 | # ### end Alembic commands ### 23 | 24 | 25 | def downgrade(): 26 | # ### commands auto generated by Alembic - please adjust! ### 27 | op.drop_column('yara_testing_history', 'avg_millis_per_file') 28 | # ### end Alembic commands ### 29 | -------------------------------------------------------------------------------- /migrations/versions/3cb9b52b4c5b_adding_is_active_flag_to_users.py: -------------------------------------------------------------------------------- 1 | """adding is_active flag to users. 2 | 3 | Revision ID: 3cb9b52b4c5b 4 | Revises: 681507459b5d 5 | Create Date: 2017-09-02 12:41:03.142103 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '3cb9b52b4c5b' 14 | down_revision = '681507459b5d' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.add_column('kb_users', sa.Column('active', sa.Boolean(), nullable=False)) 22 | # ### end Alembic commands ### 23 | 24 | 25 | def downgrade(): 26 | # ### commands auto generated by Alembic - please adjust! ### 27 | op.drop_column('kb_users', 'active') 28 | # ### end Alembic commands ### 29 | -------------------------------------------------------------------------------- /migrations/versions/3d325922125f_added_sigature_id_column_to_yara_rules.py: -------------------------------------------------------------------------------- 1 | """added sigature_id column to yara_rules. 2 | 3 | Revision ID: 3d325922125f 4 | Revises: bc0fab3363f7 5 | Create Date: 2017-08-13 22:40:43.392676 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '3d325922125f' 14 | down_revision = '44b8cd08fe4a' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.add_column('yara_rules', sa.Column('signature_id', sa.Integer(), nullable=False)) 22 | op.create_index('ix_yara_rules_category', 'yara_rules', ['category'], unique=False) 23 | op.create_index('ix_yara_rules_signature_id', 'yara_rules', ['signature_id'], unique=False) 24 | # ### end Alembic commands ### 25 | 26 | 27 | def downgrade(): 28 | # ### commands auto generated by Alembic - please adjust! ### 29 | op.drop_index('ix_yara_rules_signature_id', table_name='yara_rules') 30 | op.drop_index('ix_yara_rules_category', table_name='yara_rules') 31 | op.drop_column('yara_rules', 'signature_id') 32 | # ### end Alembic commands ### 33 | -------------------------------------------------------------------------------- /migrations/versions/3d8891a2dde0_default_dashboard_release_count.py: -------------------------------------------------------------------------------- 1 | """Default dashboard release count 2 | 3 | Revision ID: 3d8891a2dde0 4 | Revises: b155053fbd56 5 | Create Date: 2017-12-01 22:05:34.057072 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | import datetime 11 | from app.models import cfg_settings 12 | 13 | # revision identifiers, used by Alembic. 14 | revision = '3d8891a2dde0' 15 | down_revision = 'b155053fbd56' 16 | branch_labels = None 17 | depends_on = None 18 | 19 | 20 | def upgrade(): 21 | date_created = datetime.datetime.now().isoformat() 22 | date_modified = datetime.datetime.now().isoformat() 23 | 24 | op.bulk_insert( 25 | cfg_settings.Cfg_settings.__table__, 26 | [ 27 | {"key": "DASHBOARD_RELEASES_COUNT", "value": '3', "public": True, 28 | "date_created": date_created, 29 | "date_modified": date_modified} 30 | ]) 31 | 32 | 33 | def downgrade(): 34 | keys = ["DASHBOARD_RELEASES_COUNT"] 35 | for key in keys: 36 | op.execute("""DELETE from cfg_settings where `key`='%s';""" % (key)) 37 | -------------------------------------------------------------------------------- /migrations/versions/44b8cd08fe4a_release_flag_for_categories.py: -------------------------------------------------------------------------------- 1 | """Release flag for categories 2 | 3 | Revision ID: 44b8cd08fe4a 4 | Revises: 072dd2b2d9a5 5 | Create Date: 2019-09-25 23:09:01.660399 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '44b8cd08fe4a' 14 | down_revision = 'bc0fab3363f7' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.add_column('cfg_category_range_mapping', sa.Column('include_in_release_notes', sa.Boolean(), nullable=True)) 22 | op.create_index('ix_cfg_category_range_mapping_include_in_release_notes', 'cfg_category_range_mapping', 23 | ['include_in_release_notes'], unique=False) 24 | # ### end Alembic commands ### 25 | 26 | 27 | def downgrade(): 28 | # ### commands auto generated by Alembic - please adjust! ### 29 | op.drop_index('ix_cfg_category_range_mapping_include_in_release_notes', table_name='cfg_category_range_mapping') 30 | op.drop_column('cfg_category_range_mapping', 'include_in_release_notes') 31 | # ### end Alembic commands ### 32 | -------------------------------------------------------------------------------- /migrations/versions/4e7228ea59d1_add_active_to_c2dns_c2ip.py: -------------------------------------------------------------------------------- 1 | """add active to c2dns/c2ip 2 | 3 | Revision ID: 4e7228ea59d1 4 | Revises: fe5820317f46 5 | Create Date: 2019-04-06 12:28:04.881531 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '4e7228ea59d1' 14 | down_revision = 'fe5820317f46' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | op.add_column('c2dns', sa.Column('active', sa.Boolean(), nullable=False)) 21 | op.create_index('ix_c2dns_active', 'c2dns', ['active'], unique=False) 22 | op.execute("""UPDATE c2dns set active=1;""") 23 | op.add_column('c2ip', sa.Column('active', sa.Boolean(), nullable=False)) 24 | op.create_index('ix_c2ip_active', 'c2ip', ['active'], unique=False) 25 | op.execute("""UPDATE c2ip set active=1;""") 26 | op.create_index('ix_yara_rules_active', 'yara_rules', ['active'], unique=False) 27 | 28 | 29 | def downgrade(): 30 | op.drop_index('ix_yara_rules_active', table_name='yara_rules') 31 | op.drop_index('ix_c2ip_active', table_name='c2ip') 32 | op.drop_column('c2ip', 'active') 33 | op.drop_index('ix_c2dns_active', table_name='c2dns') 34 | op.drop_column('c2dns', 'active') 35 | -------------------------------------------------------------------------------- /migrations/versions/4f5f6f314c20_drop_expiration_type_column.py: -------------------------------------------------------------------------------- 1 | """Drop expiration type column 2 | 3 | Revision ID: 4f5f6f314c20 4 | Revises: 4d75b1621822 5 | Create Date: 2019-04-13 16:10:00.991797 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '4f5f6f314c20' 14 | down_revision = '4d75b1621822' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.drop_column('c2dns', 'expiration_type') 22 | op.drop_column('c2ip', 'expiration_type') 23 | # ### end Alembic commands ### 24 | 25 | 26 | def downgrade(): 27 | # ### commands auto generated by Alembic - please adjust! ### 28 | op.add_column('c2ip', sa.Column('expiration_type', mysql.VARCHAR(length=32), nullable=True)) 29 | op.add_column('c2dns', sa.Column('expiration_type', mysql.VARCHAR(length=32), nullable=True)) 30 | # ### end Alembic commands ### 31 | -------------------------------------------------------------------------------- /migrations/versions/5ae0821fdf9e_access_keys_table.py: -------------------------------------------------------------------------------- 1 | """Access Keys table. 2 | 3 | Revision ID: 5ae0821fdf9e 4 | Revises: ffea56d3fc3f 5 | Create Date: 2017-09-17 23:36:53.659099 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '5ae0821fdf9e' 14 | down_revision = 'ffea56d3fc3f' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.create_table('access_keys', 22 | sa.Column('id', sa.Integer(), nullable=False), 23 | sa.Column('user_id', sa.Integer(), nullable=False), 24 | sa.Column('token', sa.String(length=255), nullable=False), 25 | sa.Column('created', sa.DateTime(timezone=True), nullable=True), 26 | sa.Column('deleted', sa.DateTime(timezone=True), nullable=True), 27 | sa.Column('status', sa.Enum('active', 'inactive', 'deleted'), nullable=True), 28 | sa.ForeignKeyConstraint(['user_id'], ['kb_users.id'], ), 29 | sa.PrimaryKeyConstraint('id'), 30 | sa.UniqueConstraint('token') 31 | ) 32 | # ### end Alembic commands ### 33 | 34 | 35 | def downgrade(): 36 | # ### commands auto generated by Alembic - please adjust! ### 37 | op.drop_table('access_keys') 38 | # ### end Alembic commands ### 39 | -------------------------------------------------------------------------------- /migrations/versions/619d198ab938_add_is_staging_state_to_cfg_states.py: -------------------------------------------------------------------------------- 1 | """Add is_draft_state to cfg_states 2 | 3 | Revision ID: 619d198ab938 4 | Revises: ab418625f369 5 | Create Date: 2018-04-17 13:21:54.159492 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '619d198ab938' 14 | down_revision = 'ab418625f369' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | pass 21 | # ### commands auto generated by Alembic - please adjust! ### 22 | # op.add_column('cfg_states', sa.Column('is_staging_state', sa.Integer(), nullable=True)) 23 | # ### end Alembic commands ### 24 | 25 | 26 | def downgrade(): 27 | pass 28 | # ### commands auto generated by Alembic - please adjust! ### 29 | #op.drop_column('cfg_states', 'is_staging_state') 30 | # ### end Alembic commands ### 31 | -------------------------------------------------------------------------------- /migrations/versions/63a47ddd8717_add_yara_testing_history_files_matches.py: -------------------------------------------------------------------------------- 1 | """Add yara_testing_history_files_matches 2 | 3 | Revision ID: 63a47ddd8717 4 | Revises: 9cc6b6e233e5 5 | Create Date: 2019-02-22 17:23:25.597951 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '63a47ddd8717' 14 | down_revision = '9cc6b6e233e5' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | op.create_table('yara_testing_history_files_matches', 21 | sa.Column('id', sa.Integer(), nullable=False), 22 | sa.Column('run_time', sa.Float(), nullable=False), 23 | sa.Column('path', sa.String(length=5000), nullable=False), 24 | sa.Column('stdout', sa.String(length=2000), nullable=True), 25 | sa.Column('stderr', sa.String(length=2000), nullable=True), 26 | sa.Column('command', sa.String(length=2000), nullable=True), 27 | sa.Column('command_match_test_regex', sa.String(length=2000), nullable=True), 28 | sa.Column('history_id', sa.Integer(), nullable=False), 29 | sa.ForeignKeyConstraint(['history_id'], ['yara_testing_history.id'], ), 30 | sa.PrimaryKeyConstraint('id') 31 | ) 32 | 33 | 34 | def downgrade(): 35 | op.drop_table('yara_testing_history_files_matches') 36 | -------------------------------------------------------------------------------- /migrations/versions/650b0ad88d25_add_indexes.py: -------------------------------------------------------------------------------- 1 | """add indexes 2 | 3 | Revision ID: 650b0ad88d25 4 | Revises: d8a036ecf92d 5 | Create Date: 2019-03-27 20:34:41.626587 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '650b0ad88d25' 14 | down_revision = 'd8a036ecf92d' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | pass 21 | 22 | def downgrade(): 23 | pass 24 | -------------------------------------------------------------------------------- /migrations/versions/658ab905b871_change_release_data_to_blob.py: -------------------------------------------------------------------------------- 1 | """change release data to blob 2 | 3 | Revision ID: 658ab905b871 4 | Revises: faa23ce8d2c5 5 | Create Date: 2018-04-29 11:46:41.528373 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '658ab905b871' 14 | down_revision = 'faa23ce8d2c5' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.add_column('releases', sa.Column('_release_data', mysql.LONGBLOB(), nullable=True)) 22 | op.drop_column('releases', 'release_data') 23 | # ### end Alembic commands ### 24 | 25 | 26 | def downgrade(): 27 | # ### commands auto generated by Alembic - please adjust! ### 28 | op.add_column('releases', sa.Column('release_data', mysql.LONGTEXT(), nullable=True)) 29 | op.drop_column('releases', '_release_data') 30 | # ### end Alembic commands ### 31 | -------------------------------------------------------------------------------- /migrations/versions/681507459b5d_makes_entity_type_and_id_nullable_in_.py: -------------------------------------------------------------------------------- 1 | """makes entity type and id nullable in files 2 | 3 | Revision ID: 681507459b5d 4 | Revises: 2a30c4968d80 5 | Create Date: 2017-08-22 23:27:59.458389 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '681507459b5d' 14 | down_revision = '2a30c4968d80' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.alter_column('files', 'entity_id', 22 | existing_type=mysql.INTEGER(display_width=11), 23 | nullable=True) 24 | op.alter_column('files', 'entity_type', 25 | existing_type=mysql.INTEGER(display_width=11), 26 | nullable=True) 27 | # ### end Alembic commands ### 28 | 29 | 30 | def downgrade(): 31 | # ### commands auto generated by Alembic - please adjust! ### 32 | op.alter_column('files', 'entity_type', 33 | existing_type=mysql.INTEGER(display_width=11), 34 | nullable=False) 35 | op.alter_column('files', 'entity_id', 36 | existing_type=mysql.INTEGER(display_width=11), 37 | nullable=False) 38 | # ### end Alembic commands ### 39 | -------------------------------------------------------------------------------- /migrations/versions/695612f2c4ad_add_unique_rulenames_check_config_item.py: -------------------------------------------------------------------------------- 1 | """Add unique rulenames check config item 2 | 3 | Revision ID: 695612f2c4ad 4 | Revises: 8c3bbaef0f9c 5 | Create Date: 2019-01-01 18:29:39.454540 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | import datetime 12 | from app.models.cfg_settings import Cfg_settings 13 | 14 | # revision identifiers, used by Alembic. 15 | revision = '695612f2c4ad' 16 | down_revision = '8c3bbaef0f9c' 17 | branch_labels = None 18 | depends_on = None 19 | 20 | 21 | def upgrade(): 22 | date_created = datetime.datetime.now().isoformat() 23 | date_modified = datetime.datetime.now().isoformat() 24 | 25 | op.bulk_insert( 26 | Cfg_settings.__table__, 27 | [ 28 | {"key": "ENFORCE_UNIQUE_YARA_RULE_NAMES", "value": "0", "public": True, "date_created": date_created, 29 | "date_modified": date_modified, 30 | "description": "If true, don't allow duplicate yara rule names."}, 31 | ] 32 | ) 33 | 34 | 35 | def downgrade(): 36 | keys = ["ENFORCE_UNIQUE_YARA_RULE_NAMES"] 37 | for key in keys: 38 | op.execute("""DELETE from cfg_settings where `key`='%s';""" % (key)) 39 | -------------------------------------------------------------------------------- /migrations/versions/705e48818ad8_add_sha1_sha256_md5_to_files_table.py: -------------------------------------------------------------------------------- 1 | """Add sha1, sha256, md5 to files table 2 | 3 | Revision ID: 705e48818ad8 4 | Revises: 34d5b6b940a7 5 | Create Date: 2017-11-19 18:12:18.378072 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | # revision identifiers, used by Alembic. 12 | revision = '705e48818ad8' 13 | down_revision = '34d5b6b940a7' 14 | branch_labels = None 15 | depends_on = None 16 | 17 | 18 | def upgrade(): 19 | # ### commands auto generated by Alembic - please adjust! ### 20 | op.add_column('files', sa.Column('md5', sa.String(length=32), nullable=True)) 21 | op.add_column('files', sa.Column('sha1', sa.String(length=40), nullable=True)) 22 | op.add_column('files', sa.Column('sha256', sa.String(length=64), nullable=True)) 23 | # ### end Alembic commands ### 24 | 25 | 26 | def downgrade(): 27 | # ### commands auto generated by Alembic - please adjust! ### 28 | op.drop_column('files', 'sha256') 29 | op.drop_column('files', 'sha1') 30 | op.drop_column('files', 'md5') 31 | # ### end Alembic commands ### 32 | -------------------------------------------------------------------------------- /migrations/versions/76ac9b0bf6e7_change_date_modified_date_created.py: -------------------------------------------------------------------------------- 1 | """Change date_modified, date_created 2 | 3 | Revision ID: 76ac9b0bf6e7 4 | Revises: 922e996462ab 5 | Create Date: 2017-10-21 21:53:49.002787 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | # revision identifiers, used by Alembic. 12 | revision = '76ac9b0bf6e7' 13 | down_revision = '922e996462ab' 14 | branch_labels = None 15 | depends_on = None 16 | 17 | 18 | def upgrade(): 19 | # ### commands auto generated by Alembic - please adjust! ### 20 | op.add_column('yara_rules', sa.Column('creation_date', sa.DateTime(timezone=True), nullable=True)) 21 | op.add_column('yara_rules', sa.Column('last_revision_date', sa.DateTime(timezone=True), nullable=True)) 22 | op.drop_column('yara_rules', 'date_created') 23 | op.drop_column('yara_rules', 'date_modified') 24 | # ### end Alembic commands ### 25 | 26 | 27 | def downgrade(): 28 | # ### commands auto generated by Alembic - please adjust! ### 29 | op.add_column('yara_rules', sa.Column('date_modified', sa.DATETIME(), nullable=True)) 30 | op.add_column('yara_rules', sa.Column('date_created', sa.DATETIME(), nullable=True)) 31 | op.drop_column('yara_rules', 'last_revision_date') 32 | op.drop_column('yara_rules', 'creation_date') 33 | # ### end Alembic commands ### 34 | -------------------------------------------------------------------------------- /migrations/versions/7c6433145877_update_config.py: -------------------------------------------------------------------------------- 1 | """Update config 2 | 3 | Revision ID: 7c6433145877 4 | Revises: b5357371ee6d 5 | Create Date: 2017-08-18 12:22:54.682578 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '7c6433145877' 14 | down_revision = 'b5357371ee6d' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.drop_column('config', 'id') 22 | # ### end Alembic commands ### 23 | 24 | 25 | def downgrade(): 26 | # ### commands auto generated by Alembic - please adjust! ### 27 | op.add_column('config', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False)) 28 | # ### end Alembic commands ### 29 | -------------------------------------------------------------------------------- /migrations/versions/808f4e517394_create_start_filter_requests_length.py: -------------------------------------------------------------------------------- 1 | """Create START_FILTER_REQUESTS_LENGTH 2 | 3 | Revision ID: 808f4e517394 4 | Revises: af2de80654b6 5 | Create Date: 2018-11-29 10:58:02.103458 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | from app.models import cfg_settings 12 | import datetime 13 | 14 | # revision identifiers, used by Alembic. 15 | revision = '808f4e517394' 16 | down_revision = 'af2de80654b6' 17 | branch_labels = None 18 | depends_on = None 19 | 20 | 21 | def upgrade(): 22 | # ### commands auto generated by Alembic - please adjust! ### 23 | date_created = datetime.datetime.now().isoformat() 24 | date_modified = datetime.datetime.now().isoformat() 25 | 26 | op.bulk_insert( 27 | cfg_settings.Cfg_settings.__table__, 28 | [ 29 | {"key": "START_FILTER_REQUESTS_LENGTH", "value": "3", "public": True, "date_created": date_created, 30 | "date_modified": date_modified, 31 | "description": "The number characters to wait to start filtering table content"}, 32 | ] 33 | ) 34 | # ### end Alembic commands ### 35 | 36 | 37 | def downgrade(): 38 | # ### commands auto generated by Alembic - please adjust! ### 39 | keys = ["START_FILTER_REQUESTS_LENGTH"] 40 | for key in keys: 41 | op.execute("""DELETE from cfg_settings where `key`='%s';""" % (key)) 42 | # ### end Alembic commands ### 43 | -------------------------------------------------------------------------------- /migrations/versions/8090f8b3bbcb_bookmarks_table.py: -------------------------------------------------------------------------------- 1 | """bookmarks table 2 | 3 | Revision ID: 8090f8b3bbcb 4 | Revises: 665baa4d3f57 5 | Create Date: 2017-11-12 21:50:21.374017 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '8090f8b3bbcb' 14 | down_revision = '665baa4d3f57' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.create_table('bookmarks', 22 | sa.Column('id', sa.Integer(), nullable=False), 23 | sa.Column('entity_type', sa.Integer(), nullable=False), 24 | sa.Column('entity_id', sa.Integer(), nullable=False), 25 | sa.Column('user_id', sa.Integer(), nullable=False), 26 | sa.ForeignKeyConstraint(['user_id'], ['kb_users.id'], ), 27 | sa.PrimaryKeyConstraint('id') 28 | ) 29 | op.create_index('ix_bookmarks_entity_id', 'bookmarks', ['entity_id'], unique=False) 30 | op.create_index('ix_bookmarks_entity_type', 'bookmarks', ['entity_type'], unique=False) 31 | # ### end Alembic commands ### 32 | 33 | 34 | def downgrade(): 35 | # ### commands auto generated by Alembic - please adjust! ### 36 | op.drop_index('ix_bookmarks_entity_type', table_name='bookmarks') 37 | op.drop_index('ix_bookmarks_entity_id', table_name='bookmarks') 38 | op.drop_table('bookmarks') 39 | # ### end Alembic commands ### 40 | -------------------------------------------------------------------------------- /migrations/versions/838898d63a85_add_description_to_cfg_settings.py: -------------------------------------------------------------------------------- 1 | """add description to cfg_settings 2 | 3 | Revision ID: 838898d63a85 4 | Revises: c8aec30b37d4 5 | Create Date: 2018-03-12 22:08:04.998913 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '838898d63a85' 14 | down_revision = 'c8aec30b37d4' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | pass 21 | # ### commands auto generated by Alembic - please adjust! ### 22 | # op.add_column('cfg_settings', sa.Column('description', sa.TEXT, nullable=True)) 23 | # ### end Alembic commands ### 24 | 25 | 26 | def downgrade(): 27 | pass 28 | # ### commands auto generated by Alembic - please adjust! ### 29 | #op.drop_column('cfg_settings', 'description') 30 | # ### end Alembic commands ### 31 | -------------------------------------------------------------------------------- /migrations/versions/8a40de624788_add_active_flag_to_yara_rule.py: -------------------------------------------------------------------------------- 1 | """Add active flag to yara_rule 2 | 3 | Revision ID: 8a40de624788 4 | Revises: 15b203983adb 5 | Create Date: 2017-09-10 12:39:39.512733 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | # revision identifiers, used by Alembic. 12 | revision = '8a40de624788' 13 | down_revision = '15b203983adb' 14 | branch_labels = None 15 | depends_on = None 16 | 17 | 18 | def upgrade(): 19 | # ### commands auto generated by Alembic - please adjust! ### 20 | op.add_column('yara_rules', sa.Column('active', sa.Boolean(), nullable=False)) 21 | # ### end Alembic commands ### 22 | 23 | 24 | def downgrade(): 25 | # ### commands auto generated by Alembic - please adjust! ### 26 | op.drop_column('yara_rules', 'active') 27 | # ### end Alembic commands ### 28 | -------------------------------------------------------------------------------- /migrations/versions/9aadb08451dc_change_signature_id_to_eventid.py: -------------------------------------------------------------------------------- 1 | """Change signature_id to eventid 2 | 3 | Revision ID: 9aadb08451dc 4 | Revises: 5ae0821fdf9e 5 | Create Date: 2017-09-30 17:58:53.394735 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '9aadb08451dc' 14 | down_revision = '5ae0821fdf9e' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.add_column('yara_rules', sa.Column('eventid', sa.Integer(), nullable=False)) 22 | op.create_index('ix_yara_rules_eventid', 'yara_rules', ['eventid'], unique=False) 23 | op.drop_index('ix_yara_rules_signature_id', table_name='yara_rules') 24 | op.drop_column('yara_rules', 'signature_id') 25 | # ### end Alembic commands ### 26 | 27 | 28 | def downgrade(): 29 | # ### commands auto generated by Alembic - please adjust! ### 30 | op.add_column('yara_rules', 31 | sa.Column('signature_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False)) 32 | op.create_index('ix_yara_rules_signature_id', 'yara_rules', ['signature_id'], unique=False) 33 | op.drop_index('ix_yara_rules_eventid', table_name='yara_rules') 34 | op.drop_column('yara_rules', 'eventid') 35 | # ### end Alembic commands ### 36 | -------------------------------------------------------------------------------- /migrations/versions/9ada96d00858_adding_description_to_ip_and_dns.py: -------------------------------------------------------------------------------- 1 | """adding description to ip and dns 2 | 3 | Revision ID: 9ada96d00858 4 | Revises: 0e2074fb38e8 5 | Create Date: 2017-11-02 21:58:04.359548 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '9ada96d00858' 14 | down_revision = '0e2074fb38e8' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.add_column('c2dns', sa.Column('description', sa.String(length=4096), nullable=True)) 22 | op.add_column('c2ip', sa.Column('description', sa.String(length=4096), nullable=True)) 23 | # ### end Alembic commands ### 24 | 25 | 26 | def downgrade(): 27 | # ### commands auto generated by Alembic - please adjust! ### 28 | op.drop_column('c2ip', 'description') 29 | op.drop_column('c2dns', 'description') 30 | # ### end Alembic commands ### 31 | -------------------------------------------------------------------------------- /migrations/versions/9cc6b6e233e5_add_testing_type_column.py: -------------------------------------------------------------------------------- 1 | """Add testing type column 2 | 3 | Revision ID: 9cc6b6e233e5 4 | Revises: 695612f2c4ad 5 | Create Date: 2019-02-21 14:42:46.631917 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = '9cc6b6e233e5' 14 | down_revision = '695612f2c4ad' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | op.add_column('yara_testing_history', sa.Column('test_type', sa.String(32), nullable=False)) 21 | 22 | 23 | def downgrade(): 24 | op.drop_column('yara_testing_history', 'test_type') 25 | -------------------------------------------------------------------------------- /migrations/versions/a844d4d82d9d_directory_functionality_in_files.py: -------------------------------------------------------------------------------- 1 | """directory functionality in files 2 | 3 | Revision ID: a844d4d82d9d 4 | Revises: 4af97076d0d0 5 | Create Date: 2022-05-18 18:11:08.028247 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = 'a844d4d82d9d' 14 | down_revision = '4af97076d0d0' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.add_column('files', sa.Column('parent_sha256', sa.String(length=64), nullable=True)) 22 | op.add_column('files', sa.Column('parent_md5', sa.String(length=32), nullable=True)) 23 | op.add_column('files', sa.Column('parent_sha1', sa.String(length=40), nullable=True)) 24 | op.add_column('files', sa.Column('path', sa.TEXT(), nullable=True)) 25 | # ### end Alembic commands ### 26 | 27 | 28 | def downgrade(): 29 | # ### commands auto generated by Alembic - please adjust! ### 30 | op.drop_column('files', 'path') 31 | op.drop_column('files', 'parent_md5') 32 | op.drop_column('files', 'parent_sha256') 33 | op.drop_column('files', 'parent_sha1') 34 | # ### end Alembic commands ### 35 | -------------------------------------------------------------------------------- /migrations/versions/aad1bab92536_add_releases_table.py: -------------------------------------------------------------------------------- 1 | """Add releases table 2 | 3 | Revision ID: aad1bab92536 4 | Revises: 0bd5407cc66d 5 | Create Date: 2017-08-29 15:20:45.220826 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | from sqlalchemy.dialects.mysql import LONGTEXT 12 | 13 | # revision identifiers, used by Alembic. 14 | revision = 'aad1bab92536' 15 | down_revision = '0bd5407cc66d' 16 | branch_labels = None 17 | depends_on = None 18 | 19 | 20 | def upgrade(): 21 | # ### commands auto generated by Alembic - please adjust! ### 22 | op.create_table('releases', 23 | sa.Column('id', sa.Integer(), nullable=False), 24 | sa.Column('name', sa.String(length=500), nullable=False), 25 | sa.Column('is_test_release', sa.Integer(), nullable=True), 26 | sa.Column('date_created', sa.DateTime(timezone=True), nullable=True), 27 | sa.Column('release_data', LONGTEXT(), nullable=False), 28 | sa.Column('created_user_id', sa.Integer(), nullable=False), 29 | sa.ForeignKeyConstraint(['created_user_id'], ['kb_users.id'], ), 30 | sa.PrimaryKeyConstraint('id') 31 | ) 32 | # ### end Alembic commands ### 33 | 34 | 35 | def downgrade(): 36 | # ### commands auto generated by Alembic - please adjust! ### 37 | op.drop_table('releases') 38 | # ### end Alembic commands ### 39 | -------------------------------------------------------------------------------- /migrations/versions/ab418625f369_add_is_retired_state_to_cfg_states.py: -------------------------------------------------------------------------------- 1 | """Add is_retired_state to cfg_states 2 | 3 | Revision ID: ab418625f369 4 | Revises: 838898d63a85 5 | Create Date: 2018-04-16 23:48:34.539875 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = 'ab418625f369' 14 | down_revision = '838898d63a85' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | pass 21 | # ### commands auto generated by Alembic - please adjust! ### 22 | # op.add_column('cfg_states', sa.Column('is_retired_state', sa.Integer(), nullable=True)) 23 | # ### end Alembic commands ### 24 | 25 | 26 | def downgrade(): 27 | pass 28 | # ### commands auto generated by Alembic - please adjust! ### 29 | #op.drop_column('cfg_states', 'is_retired_state') 30 | # ### end Alembic commands ### 31 | -------------------------------------------------------------------------------- /migrations/versions/af2de80654b6_add_default_compile_yara_rule_on_save_.py: -------------------------------------------------------------------------------- 1 | """Add default COMPILE_YARA_RULE_ON_SAVE setting 2 | 3 | Revision ID: af2de80654b6 4 | Revises: 2f0f6d26a505 5 | Create Date: 2018-11-11 19:26:53.631142 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from app.models import cfg_settings 11 | import datetime 12 | from sqlalchemy.dialects import mysql 13 | 14 | # revision identifiers, used by Alembic. 15 | revision = 'af2de80654b6' 16 | down_revision = '2f0f6d26a505' 17 | branch_labels = None 18 | depends_on = None 19 | 20 | 21 | def upgrade(): 22 | date_created = datetime.datetime.now().isoformat() 23 | date_modified = datetime.datetime.now().isoformat() 24 | 25 | op.bulk_insert( 26 | cfg_settings.Cfg_settings.__table__, 27 | [ 28 | {"key": "COMPILE_YARA_RULE_ON_SAVE", "value": "1", "public": True, "date_created": date_created, 29 | "date_modified": date_modified, 30 | "description": "If true, don't save yara rule changes if they are in the draft or release state unless they compile."}, 31 | ] 32 | ) 33 | 34 | 35 | def downgrade(): 36 | keys = ["COMPILE_YARA_RULE_ON_SAVE"] 37 | for key in keys: 38 | op.execute("""DELETE from cfg_settings where `key`='%s';""" % (key)) 39 | -------------------------------------------------------------------------------- /migrations/versions/b155053fbd56_merge_705e48818ad8_and_8090f8b3bbcb.py: -------------------------------------------------------------------------------- 1 | """merge 705e48818ad8 and 8090f8b3bbcb 2 | 3 | Revision ID: b155053fbd56 4 | Revises: 8090f8b3bbcb, 705e48818ad8 5 | Create Date: 2017-12-01 22:03:13.334684 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | # revision identifiers, used by Alembic. 12 | revision = 'b155053fbd56' 13 | down_revision = ('8090f8b3bbcb', '705e48818ad8') 14 | branch_labels = None 15 | depends_on = None 16 | 17 | 18 | def upgrade(): 19 | pass 20 | 21 | 22 | def downgrade(): 23 | pass 24 | -------------------------------------------------------------------------------- /migrations/versions/b315f76a9a56_changing_tags_mapping_enums.py: -------------------------------------------------------------------------------- 1 | """Changing tags mapping enums. 2 | 3 | Revision ID: b315f76a9a56 4 | Revises: 2221286081e8 5 | Create Date: 2017-08-06 19:42:21.467729 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = 'b315f76a9a56' 14 | down_revision = '2221286081e8' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.alter_column("tags_mapping", "source_table", existing_type=mysql.ENUM('c2dns', 'c2ip', 'yara_rule'), 22 | type_=mysql.ENUM('c2dns', 'c2ip', 'yara_rules')) 23 | # ### end Alembic commands ### 24 | 25 | 26 | def downgrade(): 27 | # ### commands auto generated by Alembic - please adjust! ### 28 | op.alter_column("tags_mapping", "source_table", existing_type=mysql.ENUM('c2dns', 'c2ip', 'yara_rules'), 29 | type_=mysql.ENUM('c2dns', 'c2ip', 'yara_rule')) 30 | # ### end Alembic commands ### 31 | -------------------------------------------------------------------------------- /migrations/versions/b5357371ee6d_add_config.py: -------------------------------------------------------------------------------- 1 | """Add config 2 | 3 | Revision ID: b5357371ee6d 4 | Revises: 2221286081e8 5 | Create Date: 2017-08-18 12:08:01.045976 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = 'b5357371ee6d' 14 | down_revision = '2221286081e8' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.create_table('config', 22 | sa.Column('id', sa.Integer(), nullable=False), 23 | sa.Column('date_created', sa.DateTime(timezone=True), nullable=True), 24 | sa.Column('date_modified', sa.DateTime(timezone=True), nullable=True), 25 | sa.Column('key', sa.String(length=256), nullable=True), 26 | sa.Column('public', sa.Boolean(), nullable=True), 27 | sa.Column('value', sa.String(length=2048), nullable=True), 28 | sa.PrimaryKeyConstraint('id') 29 | ) 30 | op.create_index('ix_config_key', 'config', ['key'], unique=False) 31 | op.create_index('ix_config_public', 'config', ['public'], unique=False) 32 | # ### end Alembic commands ### 33 | 34 | 35 | def downgrade(): 36 | # ### commands auto generated by Alembic - please adjust! ### 37 | # op.drop_index(u'ix_config_public', table_name='config') 38 | # op.drop_index(u'ix_config_key', table_name='config') 39 | op.drop_table('config') 40 | # ### end Alembic commands ### 41 | -------------------------------------------------------------------------------- /migrations/versions/b67c53c89680_add_imports_column_to_yara_rules.py: -------------------------------------------------------------------------------- 1 | """Add imports column to yara rules 2 | 3 | Revision ID: b67c53c89680 4 | Revises: 0896164f6037 5 | Create Date: 2018-05-27 16:33:43.266789 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = 'b67c53c89680' 14 | down_revision = '0896164f6037' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.add_column('yara_rules', sa.Column('imports', sa.String(length=2048), nullable=True)) 22 | # ### end Alembic commands ### 23 | 24 | 25 | def downgrade(): 26 | # ### commands auto generated by Alembic - please adjust! ### 27 | op.drop_column('yara_rules', 'imports') 28 | # ### end Alembic commands ### 29 | -------------------------------------------------------------------------------- /migrations/versions/b8ab35edf211_default_states_and_category.py: -------------------------------------------------------------------------------- 1 | """default states and category 2 | 3 | Revision ID: b8ab35edf211 4 | Revises: 45d18cee3c93 5 | Create Date: 2017-10-30 23:02:06.329870 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | import datetime 11 | from app.models import cfg_category_range_mapping, cfg_states 12 | 13 | # revision identifiers, used by Alembic. 14 | revision = 'b8ab35edf211' 15 | down_revision = '45d18cee3c93' 16 | branch_labels = None 17 | depends_on = None 18 | 19 | 20 | def upgrade(): 21 | date_created = datetime.datetime.now().isoformat() 22 | date_modified = datetime.datetime.now().isoformat() 23 | 24 | op.bulk_insert( 25 | cfg_category_range_mapping.CfgCategoryRangeMapping.__table__, [ 26 | {"category": "Default", "range_min": 1, "range_max": 1000, "current": 0}, 27 | ] 28 | ) 29 | op.bulk_insert( 30 | cfg_states.Cfg_states.__table__, [ 31 | {"state": "Production", "is_release_state": 1} 32 | ] 33 | ) 34 | 35 | 36 | def downgrade(): 37 | op.execute("""DELETE from cfg_category_range_mapping;""") 38 | op.execute("""DELETE from cfg_states;""") 39 | -------------------------------------------------------------------------------- /migrations/versions/c5b6185beb4c_add_required_column_to_metadata_table.py: -------------------------------------------------------------------------------- 1 | """add required column to metadata table 2 | 3 | Revision ID: c5b6185beb4c 4 | Revises: 0822c8e4629a 5 | Create Date: 2017-12-25 19:38:40.830662 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | # revision identifiers, used by Alembic. 12 | revision = 'c5b6185beb4c' 13 | down_revision = '0822c8e4629a' 14 | branch_labels = None 15 | depends_on = None 16 | 17 | 18 | def upgrade(): 19 | # ### commands auto generated by Alembic - please adjust! ### 20 | op.add_column('metadata', sa.Column('required', sa.Integer(), nullable=False)) 21 | # ### end Alembic commands ### 22 | 23 | 24 | def downgrade(): 25 | # ### commands auto generated by Alembic - please adjust! ### 26 | op.drop_column('metadata', 'required') 27 | # ### end Alembic commands ### 28 | -------------------------------------------------------------------------------- /migrations/versions/c8aec30b37d4_length_change_for_releases_text.py: -------------------------------------------------------------------------------- 1 | """Length change for releases text 2 | 3 | Revision ID: c8aec30b37d4 4 | Revises: ee0d67b4e552 5 | Create Date: 2018-02-24 13:01:41.987860 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = 'c8aec30b37d4' 14 | down_revision = 'ee0d67b4e552' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.alter_column('releases', 'release_data', 22 | existing_type=mysql.TEXT(), 23 | type_=sa.Text(length=4294967295), 24 | existing_nullable=False) 25 | # ### end Alembic commands ### 26 | 27 | 28 | def downgrade(): 29 | # ### commands auto generated by Alembic - please adjust! ### 30 | op.alter_column('releases', 'release_data', 31 | existing_type=sa.Text(length=4294967295), 32 | type_=mysql.TEXT(), 33 | existing_nullable=False) 34 | # ### end Alembic commands ### 35 | -------------------------------------------------------------------------------- /migrations/versions/d59c15bea7a6_changing_registered_on_attributes.py: -------------------------------------------------------------------------------- 1 | """changing registered_on attributes. 2 | 3 | Revision ID: d59c15bea7a6 4 | Revises: 3cb9b52b4c5b 5 | Create Date: 2017-09-03 16:52:10.630099 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = 'd59c15bea7a6' 14 | down_revision = '3cb9b52b4c5b' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.alter_column('kb_users', 'registered_on', 22 | existing_type=sa.DATETIME(), 23 | nullable=True, 24 | existing_server_default=sa.text('CURRENT_TIMESTAMP')) 25 | # ### end Alembic commands ### 26 | 27 | 28 | def downgrade(): 29 | # ### commands auto generated by Alembic - please adjust! ### 30 | op.alter_column('kb_users', 'registered_on', 31 | existing_type=sa.DATETIME(), 32 | nullable=False, 33 | existing_server_default=sa.text('CURRENT_TIMESTAMP')) 34 | # ### end Alembic commands ### 35 | -------------------------------------------------------------------------------- /migrations/versions/d73c420813ea_change_rule_json_to_large_binary.py: -------------------------------------------------------------------------------- 1 | """change rule_json to large binary 2 | 3 | Revision ID: d73c420813ea 4 | Revises: ae93b3e95444 5 | Create Date: 2018-10-23 20:31:42.304996 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = 'd73c420813ea' 14 | down_revision = 'ae93b3e95444' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.add_column('yara_rules_history', sa.Column('_rule_json', sa.LargeBinary(), nullable=False)) 22 | op.drop_column('yara_rules_history', 'rule_json') 23 | # ### end Alembic commands ### 24 | 25 | 26 | def downgrade(): 27 | # ### commands auto generated by Alembic - please adjust! ### 28 | op.add_column('yara_rules_history', sa.Column('rule_json', mysql.TEXT(), nullable=False)) 29 | op.drop_column('yara_rules_history', '_rule_json') 30 | # ### end Alembic commands ### 31 | -------------------------------------------------------------------------------- /migrations/versions/ee0d67b4e552_add_export_with_release_column.py: -------------------------------------------------------------------------------- 1 | """Add export with release column 2 | 3 | Revision ID: ee0d67b4e552 4 | Revises: c5b6185beb4c 5 | Create Date: 2018-01-13 11:13:22.722140 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | # revision identifiers, used by Alembic. 12 | revision = 'ee0d67b4e552' 13 | down_revision = 'c5b6185beb4c' 14 | branch_labels = None 15 | depends_on = None 16 | 17 | 18 | def upgrade(): 19 | # ### commands auto generated by Alembic - please adjust! ### 20 | op.add_column('metadata', sa.Column('export_with_release', sa.Integer(), nullable=False)) 21 | # ### end Alembic commands ### 22 | 23 | 24 | def downgrade(): 25 | # ### commands auto generated by Alembic - please adjust! ### 26 | op.drop_column('metadata', 'export_with_release') 27 | # ### end Alembic commands ### 28 | -------------------------------------------------------------------------------- /migrations/versions/f9ebccbd6e12_merge_aad1bab92536_and_d59c15bea7a6.py: -------------------------------------------------------------------------------- 1 | """merge aad1bab92536 and d59c15bea7a6 2 | 3 | Revision ID: f9ebccbd6e12 4 | Revises: aad1bab92536, d59c15bea7a6 5 | Create Date: 2017-09-04 11:22:36.483214 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = 'f9ebccbd6e12' 14 | down_revision = ('aad1bab92536', 'd59c15bea7a6') 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | pass 21 | 22 | 23 | def downgrade(): 24 | pass 25 | -------------------------------------------------------------------------------- /migrations/versions/faa23ce8d2c5_state_for_yara_rule_revisions.py: -------------------------------------------------------------------------------- 1 | """state for yara rule revisions 2 | 3 | Revision ID: faa23ce8d2c5 4 | Revises: 619d198ab938 5 | Create Date: 2018-04-17 14:25:48.906841 6 | 7 | """ 8 | from alembic import op 9 | import sqlalchemy as sa 10 | from sqlalchemy.dialects import mysql 11 | 12 | # revision identifiers, used by Alembic. 13 | revision = 'faa23ce8d2c5' 14 | down_revision = '619d198ab938' 15 | branch_labels = None 16 | depends_on = None 17 | 18 | 19 | def upgrade(): 20 | # ### commands auto generated by Alembic - please adjust! ### 21 | op.add_column('yara_rules_history', sa.Column('state', sa.String(length=32), nullable=True)) 22 | op.create_index('ix_yara_rules_history_state', 'yara_rules_history', ['state'], unique=False) 23 | 24 | # ### end Alembic commands ### 25 | 26 | 27 | def downgrade(): 28 | # ### commands auto generated by Alembic - please adjust! ### 29 | op.drop_index('ix_yara_rules_history_state', table_name='yara_rules_history') 30 | op.drop_column('yara_rules_history', 'state') 31 | # ### end Alembic commands ### 32 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threatkb", 3 | "version": "0.0.0", 4 | "description": "Description for ThreatKB", 5 | "dependencies": { 6 | "npm": "^6.9.0" 7 | }, 8 | "devDependencies": { 9 | "grunt": "~0.4.2", 10 | "grunt-autoprefixer": "~0.4.2", 11 | "grunt-bowercopy": "~0.4.1", 12 | "grunt-bower-install": "~0.7.0", 13 | "grunt-concurrent": "~0.4.2", 14 | "grunt-connect-proxy": "~0.2.0", 15 | "grunt-contrib-clean": "~0.5.0", 16 | "grunt-contrib-concat": "~0.3.0", 17 | "grunt-contrib-connect": "~0.5.0", 18 | "grunt-contrib-copy": "~0.4.1", 19 | "grunt-contrib-cssmin": "~0.7.0", 20 | "grunt-contrib-htmlmin": "~0.1.3", 21 | "grunt-contrib-imagemin": "~0.4.0", 22 | "grunt-contrib-jshint": "~0.7.2", 23 | "grunt-contrib-uglify": "^0.2.7", 24 | "grunt-contrib-watch": "~0.5.3", 25 | "grunt-karma": "~0.6.2", 26 | "grunt-modernizr": "~0.4.1", 27 | "grunt-ngmin": "~0.0.3", 28 | "grunt-rev": "~0.1.0", 29 | "grunt-svgmin": "~0.3.0", 30 | "grunt-sync": "~0.0.5", 31 | "grunt-usemin": "~2.0.2", 32 | "load-grunt-tasks": "~0.2.0", 33 | "time-grunt": "0.2.3", 34 | "karma": "~0.10.8", 35 | "karma-junit-reporter": "~0.1.0", 36 | "karma-jasmine": "~0.1.0", 37 | "karma-ng-scenario": "~0.1.0" 38 | }, 39 | "engines": { 40 | "node": ">=0.8.15" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /run.py: -------------------------------------------------------------------------------- 1 | #from app import app 2 | 3 | import argparse 4 | 5 | parser = argparse.ArgumentParser( 6 | description="ThreatKB is THE knowledge base workflow management tool for Yara rules and C2 artifacts (IP, DNS, SSL Certificates)." 7 | ) 8 | 9 | # Define accepted arguments and metadata. 10 | parser.add_argument('--listen-on', 11 | action='store', 12 | type=str, 13 | default="127.0.0.1", 14 | dest='listen_on', 15 | help='Specify the IP address to listen on.') 16 | parser.add_argument('--listen-port', 17 | action='store', 18 | type=int, 19 | default=5000, 20 | dest='listen_port', 21 | help='Specify the port to listen on.') 22 | 23 | args = parser.parse_args() 24 | #app.run(debug=True) 25 | import app 26 | 27 | app.run(debug=True, host=args.listen_on, port=args.listen_port) 28 | -------------------------------------------------------------------------------- /run_agent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -f .env ]; then 4 | . .env 5 | fi 6 | 7 | env 8 | /bin/bash install.sh 9 | 10 | env/bin/celery -A app.celery worker --loglevel=info 11 | -------------------------------------------------------------------------------- /run_web.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -f .env ]; then 4 | /bin/sh .env 5 | fi 6 | 7 | /bin/sh install.sh 8 | 9 | git log -1 --format="%H" > version 10 | git log -1 --format="%cE" >> version 11 | git log -1 --format="%ci" >> version 12 | 13 | env/bin/uwsgi --yaml /etc/uwsgi.yaml --http "${LISTEN_ON:-0.0.0.0}:${LISTEN_PORT:-5000}" --py-autoreload 1 14 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | from setuptools import setup, find_packages 3 | 4 | requirements = open(os.path.join(os.path.dirname(__file__), "requirements.txt")).read().strip().split('\n') 5 | 6 | setup( 7 | name='threatkb', 8 | version='0.1.1', 9 | description='Knowledge base workflow management for Yara rules and C2 artifacts (IP, DNS, SSL)', 10 | url='https://github.com/InQuest/ThreatKB', 11 | author='Daniel Tijerina, Rohan Kotian, David Cuellar, Ryan Shipp, Pedram Amini', 12 | author_email='ryan.ship@inquest.net, pedram@inquest.net', 13 | classifiers=[ 14 | 'Development Status :: 5 - Production/Stable', 15 | 'Intended Audience :: InfoSec', 16 | 'Licence :: ', 17 | 'Programming Language :: Python :: 2.7', 18 | ], 19 | keywords='infosec yara c2 management', 20 | py_modules=['config'], 21 | packages=find_packages(exclude=['migrations', 'venv', 'contrib', 'docs', 'tests', 'build', 'dist', 'flask']), 22 | license='GPL-2.0', 23 | install_requires=requirements, 24 | extra_require={ 25 | 'dev': [], 26 | 'test': [], 27 | }, 28 | include_package_data=True, 29 | package_data={ 30 | 'statics': ['app/static/*'], 31 | 'config': ['config.py'] 32 | }, 33 | entry_points={ 34 | 'console_scripts': [ 35 | 'hunt = hunting.macro_hunter.cli:main', 36 | 'vti_download = crawl.utils.vt_intelligence_downloader:main', 37 | ], 38 | }, 39 | ) 40 | -------------------------------------------------------------------------------- /testing_config.py: -------------------------------------------------------------------------------- 1 | import os, sys, logging 2 | 3 | from flask import Flask 4 | from flask_bcrypt import Bcrypt 5 | 6 | SQL_PROTOCOL = os.getenv('SQL_PROTOCOL', 'mysql') 7 | SQL_HOST = os.getenv('SQL_HOST', '127.0.0.1') 8 | SQL_PORT = os.getenv('SQL_PORT', '3306') 9 | SQL_DATABASE = os.getenv('SQL_DATABASE', 'threatkb_test') 10 | SQL_USERNAME = os.getenv('SQL_USERNAME', 'root') 11 | SQL_PASSWORD = os.getenv('SQL_PASSWORD', 'yourpassword') 12 | SQLALCHEMY_DATABASE_URI = '{protocol}://{username}:{password}@{hostname}:{port}/{database}?use_unicode=1&charset=utf8'.format( 13 | protocol = SQL_PROTOCOL, 14 | username = SQL_USERNAME, 15 | password = SQL_PASSWORD, 16 | hostname = SQL_HOST, 17 | port = SQL_PORT, 18 | database = SQL_DATABASE 19 | ) 20 | 21 | LOGGING_LEVEL = getattr(logging, os.getenv('LOGGING_LEVEL', 'DEBUG')) 22 | 23 | SQLALCHEMY_TRACK_MODIFICATIONS = False 24 | 25 | # Dummy user for tests. 26 | TEST_USER = 'admin' 27 | TEST_PASSWORD = 'password' 28 | TEST_PASSWORD_HASHED = Bcrypt(Flask(__name__, static_url_path="")).generate_password_hash(TEST_PASSWORD) 29 | 30 | try: 31 | SQLALCHEMY_DATABASE_URI 32 | except: 33 | sys.stderr.write("Did you forget to set SQLALCHEMY_DATABASE_URI? Quitting") 34 | sys.exit(1) 35 | -------------------------------------------------------------------------------- /uwsgi.yaml: -------------------------------------------------------------------------------- 1 | uwsgi: 2 | uid: uwsgi 3 | master: 1 4 | workers: 10 5 | auto-procname: 1 6 | close-on-exec: 1 7 | reaper: 1 8 | max-requests: 1000 9 | module: app 10 | callable: app 11 | virtualenv: /opt/threatkb/env 12 | python-path: /opt/threatkb 13 | ignore-sigpipe: true 14 | ignore-write-errors: true 15 | http-timeout: 600 16 | harakiri: 600 17 | --------------------------------------------------------------------------------