Skip to content

Commit

Permalink
preparation for new build
Browse files Browse the repository at this point in the history
  • Loading branch information
biggiesmallsAG committed Aug 29, 2016
1 parent f08afd5 commit 414f461
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 79 deletions.
41 changes: 15 additions & 26 deletions nighthawk_utils/reindex.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,27 @@
#!/usr/bin/env python
## ElasticSearch Reindexer by Daniel Eden
## 28/07/2016 Update
## 29/08/2016 Update
## - Fixed SSL based communications
## daniel.eden@gmail.com

import requests
from requests import ConnectionError
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
import json
import re
import sys

class CommonAttributes():
def __init__(self):
with open('/opt/nighthawk/etc/nighthawk.json', 'r') as config:
self.conf_data = json.load(config)

with open('/opt/nighthawk/lib/elastic/ElasticMapping.json', 'r') as mapping:
self.mapping_file = json.load(mapping)

if self.conf_data['elastic']['elastic_ssl']:
self.es_host = "https://{0}".format(self.conf_data['elastic']['elastic_server'])
self.es_port = str(self.conf_data['elastic']['elastic_port'])
else:
self.es_host = "http://{0}".format(self.conf_data['elastic']['elastic_server'])
self.es_port = str(self.conf_data['elastic']['elastic_port'])

self.elastic_user = self.conf_data['elastic']['elastic_user']
self.elastic_pass = self.conf_data['elastic']['elastic_pass']
self.index = '/investigations'
sys.path.append('/opt/nighthawk/web')
from nighthawk.triageapi.dataendpoint.common import CommonAttributes

class SearchQuery(CommonAttributes):
def __init__(self):
CommonAttributes.__init__(self)


def CheckAliases(self):
print "\n[+] Obtaining latest index alias to determine index number"
print "[+] Obtaining latest index alias to determine index number"
try:
r = requests.get(self.es_host + self.es_port + '/_aliases', auth=(self.elastic_user, self.elastic_pass), verify=False)
r = requests.get(self.es_host + ":" + self.es_port + '/_aliases', auth=(self.elastic_user, self.elastic_pass), verify=False)
except ConnectionError as e:
print '[!] Error connecting to {0}{1}'.format(self.es_host, self.es_port)

Expand All @@ -63,7 +47,7 @@ def GetMappingAndCreateIndex(self, current_index):

try:
print '[-] Sending mapping to new index'
r = requests.put("{0}{1}{2}{3}".format(self.es_host, self.es_port, self.index, index_num), data=json.dumps(self.mapping_file), auth=(self.elastic_user, self.elastic_pass), verify=False)
r = requests.put("{0}:{1}{2}{3}".format(self.es_host, self.es_port, self.index, index_num), data=json.dumps(self.mapping_file), auth=(self.elastic_user, self.elastic_pass), verify=False)
try:
if r.json()['acknowledged']:
print '[+] Returned successfully, index created.'
Expand All @@ -90,7 +74,7 @@ def RemoveOldAlias(self, op_code, index_num):
]
}

r = requests.post(self.es_host + self.es_port + '/_aliases', data=json.dumps(remove_alias), auth=(self.elastic_user, self.elastic_pass), verify=False)
r = requests.post(self.es_host + ":" + self.es_port + '/_aliases', data=json.dumps(remove_alias), auth=(self.elastic_user, self.elastic_pass), verify=False)
try:
if r.json()['acknowledged']:
print '[+] Returned successfully, alias removed.'
Expand Down Expand Up @@ -119,7 +103,7 @@ def ReindexData(self, op_code, index, index_num):
}

print '[-] Large datasets will take a while, sit back and grab a coke....'
r = requests.post(self.es_host + self.es_port + '/_reindex', data=json.dumps(reindex), auth=(self.elastic_user, self.elastic_pass), verify=False)
r = requests.post(self.es_host + ":" + self.es_port + '/_reindex', data=json.dumps(reindex), auth=(self.elastic_user, self.elastic_pass), verify=False)

try:
if r.json()['created']:
Expand All @@ -134,9 +118,14 @@ def ReindexData(self, op_code, index, index_num):
print '[!] Returned op_code 1, error in index creation and mapping. Exiting now'
sys.exit(1)

def Version(self):
print "-- Reindexing automation by Daniel Eden (nightHawk Response team)."
print "-- Version 1.0.3. 29/08/2016\n"

def main():

s = SearchQuery()
s.Version()
index = s.CheckAliases()
op_code, index_num = s.GetMappingAndCreateIndex(index)
op_code = s.RemoveOldAlias(op_code, index_num)
Expand Down
3 changes: 3 additions & 0 deletions nighthawk_web/nighthawk/triageapi/dataendpoint/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ def __init__(self):
with open('/opt/nighthawk/etc/nighthawk.json', 'r') as config:
self.conf_data = json.load(config)

with open('/opt/nighthawk/lib/elastic/ElasticMapping.json', 'r') as mapping:
self.mapping_file = json.load(mapping)

self.name = 'nightHawk'
self.nighthawk_version = 'v1.0.3'
self.nighthawk_stack = 'Stack'
Expand Down
4 changes: 2 additions & 2 deletions nighthawk_web/static/core/brsapp.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ table.stats td, th {
padding: 0;
padding-top: 2px !important;
padding-bottom: 2px !important;
padding-right: 30px !important;
padding-right: 15px !important;
}

table.task_table td.tasklist, th.tasks {
padding-left: 5px !important;
padding-top: 5px !important;
padding-bottom: 5px !important;
padding-right: 30px !important;
padding-right: 15px !important;
font-size: 10pt;
}

Expand Down
103 changes: 52 additions & 51 deletions nighthawk_web/templates/platform_stats.html
Original file line number Diff line number Diff line change
@@ -1,64 +1,83 @@
<body>
<div class="platform_stats">
<div class="row">
<div class="col-md-6">
<div class="upload_stats" style="height:300px;overflow-y:scroll">
<div class="col-md-3">
<div class="cpu_stats">
<div style="color: #F7973D">
<b>Upload Logs</b>
<b>CPU(s)</b>
</div>
<table class="stats table-striped">
<thead>
<tr>
<th>Time:</th>
<th>Level:</th>
<th>Message:</th>
<th>CPU:</th>
<th>User:</th>
<th>Sys:</th>
<th>Idle:</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-md-6">
<div class="processes" style="height:300px;overflow-y:scroll">
<div class="col-md-3">
<div class="memstats_stats">
<div style="color: #F7973D">
<b>Services</b>
<b>Memory</b>
</div>
<table class="stats table-striped">
<thead>
<tr>
<th>Name:</th>
<th>Cmd:</th>
<th>Status:</th>
<th>Available:</th>
<th>Total:</th>
<th>Used:</th>
<th>Free:</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="cpu_stats">
</div>
<br>
<div class="disk_stats">
<div style="color: #F7973D">
<b>CPU(s)</b>
<b>Disk</b>
</div>
<table class="stats table-striped">
<thead>
<tr>
<th>CPU:</th>
<th>User:</th>
<th>Sys:</th>
<th>Idle:</th>
<th>Device:</th>
<th>Mnt:</th>
<th>Total:</th>
<th>Free:</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<div class="col-md-6">
<div class="processes" style="height:300px;overflow-y:scroll">
<div style="color: #F7973D">
<b>Services</b>
</div>
<table class="stats table-striped">
<thead>
<tr>
<th>Name:</th>
<th>Cmd:</th>
<th>Status:</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<div class="col-md-7">
</div>
<div class="row">
<div class="col-md-12">
<div class="es_stats">
<div style="color: #F7973D">
<b>Elastic Stats</b>
Expand All @@ -80,42 +99,24 @@
</table>
</div>
<br>
<div class="memstats_stats">
<div style="color: #F7973D">
<b>Memory</b>
</div>
<table class="stats table-striped">
<thead>
<tr>
<th>Available:</th>
<th>Total:</th>
<th>Used:</th>
<th>Free:</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<br>
<div class="disk_stats">

<div class="upload_stats" style="height:300px;overflow-y:scroll">
<div style="color: #F7973D">
<b>Disk</b>
<b>Upload Logs</b>
</div>
<table class="stats table-striped">
<thead>
<tr>
<th>Device:</th>
<th>Mnt:</th>
<th>Total:</th>
<th>Free:</th>
<th>Time:</th>
<th>Level:</th>
<th>Message:</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
Expand Down

0 comments on commit 414f461

Please sign in to comment.