mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-14 02:28:23 +00:00
fix hive connection + submitted dir creation
This commit is contained in:
parent
86c2cfa04b
commit
0ee36e484f
5 changed files with 78 additions and 29 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -17,6 +17,7 @@ BASE64
|
||||||
DATA_ARDB
|
DATA_ARDB
|
||||||
indexdir/
|
indexdir/
|
||||||
logs/
|
logs/
|
||||||
|
old/
|
||||||
|
|
||||||
# Webstuff
|
# Webstuff
|
||||||
var/www/static/
|
var/www/static/
|
||||||
|
@ -26,9 +27,11 @@ var/www/static/
|
||||||
!var/www/static/js/plot-graph.js
|
!var/www/static/js/plot-graph.js
|
||||||
!var/www/static/js/trendingchart.js
|
!var/www/static/js/trendingchart.js
|
||||||
var/www/templates/header.html
|
var/www/templates/header.html
|
||||||
|
var/www/submitted
|
||||||
|
|
||||||
# Local config
|
# Local config
|
||||||
bin/packages/config.cfg
|
bin/packages/config.cfg
|
||||||
|
configs/keys
|
||||||
|
|
||||||
# installed files
|
# installed files
|
||||||
nltk_data/
|
nltk_data/
|
||||||
|
|
|
@ -93,8 +93,8 @@ r_serv_db = redis.StrictRedis(
|
||||||
|
|
||||||
sys.path.append('../../configs/keys')
|
sys.path.append('../../configs/keys')
|
||||||
# MISP #
|
# MISP #
|
||||||
from pymisp import PyMISP
|
|
||||||
try:
|
try:
|
||||||
|
from pymisp import PyMISP
|
||||||
from mispKEYS import misp_url, misp_key, misp_verifycert
|
from mispKEYS import misp_url, misp_key, misp_verifycert
|
||||||
pymisp = PyMISP(misp_url, misp_key, misp_verifycert)
|
pymisp = PyMISP(misp_url, misp_key, misp_verifycert)
|
||||||
misp_event_url = misp_url + '/events/view/'
|
misp_event_url = misp_url + '/events/view/'
|
||||||
|
@ -104,23 +104,30 @@ except:
|
||||||
pymisp = False
|
pymisp = False
|
||||||
misp_event_url = '#'
|
misp_event_url = '#'
|
||||||
# The Hive #
|
# The Hive #
|
||||||
from thehive4py.api import TheHiveApi
|
|
||||||
import thehive4py.exceptions
|
|
||||||
try:
|
try:
|
||||||
from theHiveKEYS import the_hive_url, the_hive_key
|
from thehive4py.api import TheHiveApi
|
||||||
|
import thehive4py.exceptions
|
||||||
|
from theHiveKEYS import the_hive_url, the_hive_key, the_hive_verifycert
|
||||||
if the_hive_url == '':
|
if the_hive_url == '':
|
||||||
HiveApi = False
|
HiveApi = False
|
||||||
hive_case_url = '#'
|
hive_case_url = '#'
|
||||||
print('The HIVE not connected')
|
print('The HIVE not connected')
|
||||||
else:
|
else:
|
||||||
HiveApi = TheHiveApi(the_hive_url, the_hive_key)
|
HiveApi = TheHiveApi(the_hive_url, the_hive_key, cert=the_hive_verifycert)
|
||||||
hive_case_url = the_hive_url+'/index.html#/case/id_here/details'
|
hive_case_url = the_hive_url+'/index.html#/case/id_here/details'
|
||||||
print('The Hive connected')
|
#HiveApi.do_patch(the_hive_url)
|
||||||
except:
|
except:
|
||||||
print('The HIVE not connected')
|
print('The HIVE not connected')
|
||||||
HiveApi = False
|
HiveApi = False
|
||||||
hive_case_url = '#'
|
hive_case_url = '#'
|
||||||
|
|
||||||
|
try:
|
||||||
|
HiveApi.get_alert(0)
|
||||||
|
print('The Hive connected')
|
||||||
|
except thehive4py.exceptions.AlertException:
|
||||||
|
HiveApi = False
|
||||||
|
print('The Hive not connected')
|
||||||
|
|
||||||
# VARIABLES #
|
# VARIABLES #
|
||||||
max_preview_char = int(cfg.get("Flask", "max_preview_char")) # Maximum number of character to display in the tooltip
|
max_preview_char = int(cfg.get("Flask", "max_preview_char")) # Maximum number of character to display in the tooltip
|
||||||
max_preview_modal = int(cfg.get("Flask", "max_preview_modal")) # Maximum number of character to display in the modal
|
max_preview_modal = int(cfg.get("Flask", "max_preview_modal")) # Maximum number of character to display in the modal
|
||||||
|
|
|
@ -23,8 +23,16 @@ import Paste
|
||||||
from pytaxonomies import Taxonomies
|
from pytaxonomies import Taxonomies
|
||||||
from pymispgalaxies import Galaxies, Clusters
|
from pymispgalaxies import Galaxies, Clusters
|
||||||
|
|
||||||
from pymisp.mispevent import MISPObject
|
try:
|
||||||
from thehive4py.models import Case, CaseTask, CustomFieldHelper, CaseObservable
|
from pymisp.mispevent import MISPObject
|
||||||
|
flag_misp = True
|
||||||
|
except:
|
||||||
|
flag_misp = False
|
||||||
|
try:
|
||||||
|
from thehive4py.models import Case, CaseTask, CustomFieldHelper, CaseObservable
|
||||||
|
flag_hive = True
|
||||||
|
except:
|
||||||
|
flag_hive = False
|
||||||
|
|
||||||
# ============ VARIABLES ============
|
# ============ VARIABLES ============
|
||||||
import Flask_config
|
import Flask_config
|
||||||
|
@ -37,8 +45,12 @@ r_serv_db = Flask_config.r_serv_db
|
||||||
r_serv_log_submit = Flask_config.r_serv_log_submit
|
r_serv_log_submit = Flask_config.r_serv_log_submit
|
||||||
|
|
||||||
pymisp = Flask_config.pymisp
|
pymisp = Flask_config.pymisp
|
||||||
|
if pymisp is False:
|
||||||
|
flag_misp = False
|
||||||
|
|
||||||
HiveApi = Flask_config.HiveApi
|
HiveApi = Flask_config.HiveApi
|
||||||
|
if HiveApi is False:
|
||||||
|
flag_hive = False
|
||||||
|
|
||||||
PasteSubmit = Blueprint('PasteSubmit', __name__, template_folder='templates')
|
PasteSubmit = Blueprint('PasteSubmit', __name__, template_folder='templates')
|
||||||
|
|
||||||
|
@ -308,6 +320,10 @@ def submit():
|
||||||
# clean file name
|
# clean file name
|
||||||
UUID = clean_filename(paste_name)'''
|
UUID = clean_filename(paste_name)'''
|
||||||
|
|
||||||
|
# create submitted dir
|
||||||
|
if not os.path.exists(UPLOAD_FOLDER):
|
||||||
|
os.makedirs(UPLOAD_FOLDER)
|
||||||
|
|
||||||
if not '.' in file.filename:
|
if not '.' in file.filename:
|
||||||
full_path = os.path.join(UPLOAD_FOLDER, UUID)
|
full_path = os.path.join(UPLOAD_FOLDER, UUID)
|
||||||
else:
|
else:
|
||||||
|
@ -518,7 +534,9 @@ def edit_tag_export():
|
||||||
status_misp=status_misp,
|
status_misp=status_misp,
|
||||||
status_hive=status_hive,
|
status_hive=status_hive,
|
||||||
nb_tags_whitelist_misp=nb_tags_whitelist_misp,
|
nb_tags_whitelist_misp=nb_tags_whitelist_misp,
|
||||||
nb_tags_whitelist_hive=nb_tags_whitelist_hive)
|
nb_tags_whitelist_hive=nb_tags_whitelist_hive,
|
||||||
|
flag_misp=flag_misp,
|
||||||
|
flag_hive=flag_hive)
|
||||||
|
|
||||||
@PasteSubmit.route("/PasteSubmit/tag_export_edited", methods=['POST'])
|
@PasteSubmit.route("/PasteSubmit/tag_export_edited", methods=['POST'])
|
||||||
def tag_export_edited():
|
def tag_export_edited():
|
||||||
|
|
|
@ -71,16 +71,24 @@
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
{% if misp_active %}
|
{% if flag_misp %}
|
||||||
<a href="{{ url_for('PasteSubmit.disable_misp_auto_event') }}" class="btn btn-danger pull-right">
|
{% if misp_active %}
|
||||||
<i class="fa fa-times fa"></i> Disable Event Creation
|
<a href="{{ url_for('PasteSubmit.disable_misp_auto_event') }}" class="btn btn-danger pull-right">
|
||||||
</a>
|
<i class="fa fa-times fa"></i> Disable Event Creation
|
||||||
{% endif %}
|
</a>
|
||||||
{% if not misp_active %}
|
{% endif %}
|
||||||
<a href="{{ url_for('PasteSubmit.enable_misp_auto_event') }}" class="btn btn-success pull-right">
|
{% if not misp_active %}
|
||||||
<i class="fa fa-check-square-o fa"></i> Enable Event Creation
|
<a href="{{ url_for('PasteSubmit.enable_misp_auto_event') }}" class="btn btn-success pull-right">
|
||||||
</a>
|
<i class="fa fa-check-square-o fa"></i> Enable Event Creation
|
||||||
{% endif %}
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if not flag_misp %}
|
||||||
|
<button class="btn btn-danger pull-right disabled">
|
||||||
|
<i class="fa fa-times fa"></i> MISP is not connected
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -101,16 +109,23 @@
|
||||||
<img id="misp-logo" src="{{url_for('static', filename='image/thehive-logo.png') }}" width="500">
|
<img id="misp-logo" src="{{url_for('static', filename='image/thehive-logo.png') }}" width="500">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if hive_active %}
|
{% if flag_hive %}
|
||||||
<a href="{{ url_for('PasteSubmit.disable_hive_auto_alert') }}" class="btn btn-danger pull-right">
|
{% if hive_active %}
|
||||||
<i class="fa fa-times fa"></i> Disable Alert Creation
|
<a href="{{ url_for('PasteSubmit.disable_hive_auto_alert') }}" class="btn btn-danger pull-right">
|
||||||
</a>
|
<i class="fa fa-times fa"></i> Disable Alert Creation
|
||||||
{% endif %}
|
</a>
|
||||||
{% if not hive_active %}
|
{% endif %}
|
||||||
<a href="{{ url_for('PasteSubmit.enable_hive_auto_alert') }}" class="btn btn-success pull-right">
|
{% if not hive_active %}
|
||||||
<i class="fa fa-check-square-o fa"></i> Enable Alert Creation
|
<a href="{{ url_for('PasteSubmit.enable_hive_auto_alert') }}" class="btn btn-success pull-right">
|
||||||
</a>
|
<i class="fa fa-check-square-o fa"></i> Enable Alert Creation
|
||||||
{% endif %}
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if not flag_hive %}
|
||||||
|
<button class="btn btn-danger pull-right disabled">
|
||||||
|
<i class="fa fa-times fa"></i> The Hive is not connected
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -70,3 +70,9 @@ source ./../../AILENV/bin/activate
|
||||||
#Update MISP Taxonomies and Galaxies
|
#Update MISP Taxonomies and Galaxies
|
||||||
python3 -m pip install git+https://github.com/MISP/PyTaxonomies
|
python3 -m pip install git+https://github.com/MISP/PyTaxonomies
|
||||||
python3 -m pip install git+https://github.com/MISP/PyMISPGalaxies
|
python3 -m pip install git+https://github.com/MISP/PyMISPGalaxies
|
||||||
|
|
||||||
|
#Update PyMISP
|
||||||
|
python3 -m pip install git+https://github.com/MISP/PyMISP
|
||||||
|
|
||||||
|
#Update the Hive
|
||||||
|
python3 -m pip install git+https://github.com/TheHive-Project/TheHive4py
|
||||||
|
|
Loading…
Reference in a new issue