Skip to content

Commit 414f461

Browse files
author
biggiesmallsAG
committed
preparation for new build
1 parent f08afd5 commit 414f461

File tree

4 files changed

+72
-79
lines changed

4 files changed

+72
-79
lines changed

nighthawk_utils/reindex.py

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,27 @@
11
#!/usr/bin/env python
22
## ElasticSearch Reindexer by Daniel Eden
3-
## 28/07/2016 Update
3+
## 29/08/2016 Update
44
## - Fixed SSL based communications
55
## daniel.eden@gmail.com
66

77
import requests
88
from requests import ConnectionError
9+
from requests.packages.urllib3.exceptions import InsecureRequestWarning
10+
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
911
import json
1012
import re
1113
import sys
12-
13-
class CommonAttributes():
14-
def __init__(self):
15-
with open('/opt/nighthawk/etc/nighthawk.json', 'r') as config:
16-
self.conf_data = json.load(config)
17-
18-
with open('/opt/nighthawk/lib/elastic/ElasticMapping.json', 'r') as mapping:
19-
self.mapping_file = json.load(mapping)
20-
21-
if self.conf_data['elastic']['elastic_ssl']:
22-
self.es_host = "https://{0}".format(self.conf_data['elastic']['elastic_server'])
23-
self.es_port = str(self.conf_data['elastic']['elastic_port'])
24-
else:
25-
self.es_host = "http://{0}".format(self.conf_data['elastic']['elastic_server'])
26-
self.es_port = str(self.conf_data['elastic']['elastic_port'])
27-
28-
self.elastic_user = self.conf_data['elastic']['elastic_user']
29-
self.elastic_pass = self.conf_data['elastic']['elastic_pass']
30-
self.index = '/investigations'
14+
sys.path.append('/opt/nighthawk/web')
15+
from nighthawk.triageapi.dataendpoint.common import CommonAttributes
3116

3217
class SearchQuery(CommonAttributes):
3318
def __init__(self):
3419
CommonAttributes.__init__(self)
3520

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

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

6448
try:
6549
print '[-] Sending mapping to new index'
66-
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)
50+
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)
6751
try:
6852
if r.json()['acknowledged']:
6953
print '[+] Returned successfully, index created.'
@@ -90,7 +74,7 @@ def RemoveOldAlias(self, op_code, index_num):
9074
]
9175
}
9276

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

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

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

121+
def Version(self):
122+
print "-- Reindexing automation by Daniel Eden (nightHawk Response team)."
123+
print "-- Version 1.0.3. 29/08/2016\n"
124+
137125
def main():
138126

139127
s = SearchQuery()
128+
s.Version()
140129
index = s.CheckAliases()
141130
op_code, index_num = s.GetMappingAndCreateIndex(index)
142131
op_code = s.RemoveOldAlias(op_code, index_num)

nighthawk_web/nighthawk/triageapi/dataendpoint/common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ def __init__(self):
55
with open('/opt/nighthawk/etc/nighthawk.json', 'r') as config:
66
self.conf_data = json.load(config)
77

8+
with open('/opt/nighthawk/lib/elastic/ElasticMapping.json', 'r') as mapping:
9+
self.mapping_file = json.load(mapping)
10+
811
self.name = 'nightHawk'
912
self.nighthawk_version = 'v1.0.3'
1013
self.nighthawk_stack = 'Stack'

nighthawk_web/static/core/brsapp.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ table.stats td, th {
108108
padding: 0;
109109
padding-top: 2px !important;
110110
padding-bottom: 2px !important;
111-
padding-right: 30px !important;
111+
padding-right: 15px !important;
112112
}
113113

114114
table.task_table td.tasklist, th.tasks {
115115
padding-left: 5px !important;
116116
padding-top: 5px !important;
117117
padding-bottom: 5px !important;
118-
padding-right: 30px !important;
118+
padding-right: 15px !important;
119119
font-size: 10pt;
120120
}
121121

nighthawk_web/templates/platform_stats.html

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,83 @@
11
<body>
22
<div class="platform_stats">
33
<div class="row">
4-
<div class="col-md-6">
5-
<div class="upload_stats" style="height:300px;overflow-y:scroll">
4+
<div class="col-md-3">
5+
<div class="cpu_stats">
66
<div style="color: #F7973D">
7-
<b>Upload Logs</b>
7+
<b>CPU(s)</b>
88
</div>
99
<table class="stats table-striped">
1010
<thead>
1111
<tr>
12-
<th>Time:</th>
13-
<th>Level:</th>
14-
<th>Message:</th>
12+
<th>CPU:</th>
13+
<th>User:</th>
14+
<th>Sys:</th>
15+
<th>Idle:</th>
1516
</tr>
1617
</thead>
1718
<tbody>
1819
</tbody>
1920
</table>
20-
</div>
21+
</div>
2122
</div>
22-
<div class="col-md-6">
23-
<div class="processes" style="height:300px;overflow-y:scroll">
23+
<div class="col-md-3">
24+
<div class="memstats_stats">
2425
<div style="color: #F7973D">
25-
<b>Services</b>
26+
<b>Memory</b>
2627
</div>
2728
<table class="stats table-striped">
2829
<thead>
2930
<tr>
30-
<th>Name:</th>
31-
<th>Cmd:</th>
32-
<th>Status:</th>
31+
<th>Available:</th>
32+
<th>Total:</th>
33+
<th>Used:</th>
34+
<th>Free:</th>
3335
</tr>
3436
</thead>
3537
<tbody>
3638
</tbody>
3739
</table>
38-
</div>
39-
</div>
40-
</div>
41-
<div class="row">
42-
<div class="col-md-3">
43-
<div class="cpu_stats">
40+
</div>
41+
<br>
42+
<div class="disk_stats">
4443
<div style="color: #F7973D">
45-
<b>CPU(s)</b>
44+
<b>Disk</b>
4645
</div>
4746
<table class="stats table-striped">
4847
<thead>
4948
<tr>
50-
<th>CPU:</th>
51-
<th>User:</th>
52-
<th>Sys:</th>
53-
<th>Idle:</th>
49+
<th>Device:</th>
50+
<th>Mnt:</th>
51+
<th>Total:</th>
52+
<th>Free:</th>
53+
</tr>
54+
</thead>
55+
<tbody>
56+
</tbody>
57+
</table>
58+
</div>
59+
</div>
60+
<div class="col-md-6">
61+
<div class="processes" style="height:300px;overflow-y:scroll">
62+
<div style="color: #F7973D">
63+
<b>Services</b>
64+
</div>
65+
<table class="stats table-striped">
66+
<thead>
67+
<tr>
68+
<th>Name:</th>
69+
<th>Cmd:</th>
70+
<th>Status:</th>
5471
</tr>
5572
</thead>
5673
<tbody>
5774
</tbody>
5875
</table>
5976
</div>
6077
</div>
61-
<div class="col-md-7">
78+
</div>
79+
<div class="row">
80+
<div class="col-md-12">
6281
<div class="es_stats">
6382
<div style="color: #F7973D">
6483
<b>Elastic Stats</b>
@@ -80,42 +99,24 @@
8099
</table>
81100
</div>
82101
<br>
83-
<div class="memstats_stats">
84-
<div style="color: #F7973D">
85-
<b>Memory</b>
86-
</div>
87-
<table class="stats table-striped">
88-
<thead>
89-
<tr>
90-
<th>Available:</th>
91-
<th>Total:</th>
92-
<th>Used:</th>
93-
<th>Free:</th>
94-
</tr>
95-
</thead>
96-
<tbody>
97-
</tbody>
98-
</table>
99-
</div>
100-
<br>
101-
<div class="disk_stats">
102+
103+
<div class="upload_stats" style="height:300px;overflow-y:scroll">
102104
<div style="color: #F7973D">
103-
<b>Disk</b>
105+
<b>Upload Logs</b>
104106
</div>
105107
<table class="stats table-striped">
106108
<thead>
107109
<tr>
108-
<th>Device:</th>
109-
<th>Mnt:</th>
110-
<th>Total:</th>
111-
<th>Free:</th>
110+
<th>Time:</th>
111+
<th>Level:</th>
112+
<th>Message:</th>
112113
</tr>
113114
</thead>
114115
<tbody>
115116
</tbody>
116117
</table>
117-
</div>
118-
</div>
118+
</div>
119+
</div>
119120
</div>
120121
</div>
121122
</body>

0 commit comments

Comments
 (0)