Skip to content

Commit

Permalink
more ui fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jayjb committed Feb 22, 2017
1 parent 7468108 commit 8a5216e
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 49 deletions.
12 changes: 11 additions & 1 deletion channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import datetime

import simplejson

import settings
from exception import DuplicateChannel
from twisted.python import log
Expand Down Expand Up @@ -50,12 +52,15 @@ def format_webhook_canaryalert(self,canarydrop=None,
payload['additional_data'] = kwargs
return payload

def format_canaryalert(self, canarydrop=None, protocol="http",
def format_canaryalert(self, canarydrop=None, protocol="HTTP",
host=settings.PUBLIC_DOMAIN, params=None, **kwargs):
msg = {}
if not host or host == '':
host=settings.PUBLIC_IP

if 'useragent' in kwargs:
msg['useragent'] = kwargs['useragent']

if 'src_ip' in kwargs:
msg['src_ip'] = kwargs['src_ip']

Expand Down Expand Up @@ -93,6 +98,11 @@ def format_canaryalert(self, canarydrop=None, protocol="http",
""".format(host=host,
token=canarydrop['canarytoken'],
auth=canarydrop['auth'])
msg['history'] = """
http://{host}/history?token={token}&auth={auth}
""".format(host=host,
token=canarydrop['canarytoken'],
auth=canarydrop['auth'])

if params.get('subject_required', False):
msg['subject'] = settings.ALERT_EMAIL_SUBJECT
Expand Down
7 changes: 5 additions & 2 deletions channel_output_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def format_report_html(self,):
Title=self.DESCRIPTION,
Intro=self.format_report_intro(),
BasicDetails=self.get_basic_details(),
AdditionalDetails=self.data['manage']
ManageLink=self.data['manage'],
HistoryLink=self.data['history']
)
return minify(rendered_html)

Expand All @@ -52,6 +53,9 @@ def get_basic_details(self,):
'SourceIP' : self.data['src_ip']
}

if 'useragent' in self.data:
vars['User-Agent'] = self.data['useragent']

return vars

def do_send_alert(self, input_channel=None, canarydrop=None, **kwargs):
Expand All @@ -61,7 +65,6 @@ def do_send_alert(self, input_channel=None, canarydrop=None, **kwargs):
'from_address_required':True},
canarydrop=canarydrop,
**kwargs)
print msg
self.data = msg
self.data['canarytoken'] = canarydrop['canarytoken']
self.data['description'] = canarydrop['memo']
Expand Down
6 changes: 4 additions & 2 deletions queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@ def add_canarydrop_hit(canarytoken,input_channel,hit_time=None,**kwargs):
db.hset(KEY_CANARYDROP+canarytoken.value(), 'triggered_list',simplejson.dumps(triggered_list))
return triggered_key

def add_additional_info_to_hit(canarytoken,hit_time,additional_info):
def add_additional_info_to_hit(canarytoken,hit_time,additional_info=None):
try:
if not additional_info:
return

triggered_list = get_canarydrop_triggered_list(canarytoken)

if 'additional_info' not in triggered_list[hit_time]:
Expand All @@ -139,7 +142,6 @@ def add_additional_info_to_hit(canarytoken,hit_time,additional_info):
triggered_list[hit_time]['additional_info'][k] = v
db.hset(KEY_CANARYDROP+canarytoken.value(), 'triggered_list',simplejson.dumps(triggered_list))
except Exception as e:
import pdb; pdb.set_trace()
log.err('Failed adding additional info: {err}'.format(err=e))

def get_geoinfo(ip):
Expand Down
16 changes: 13 additions & 3 deletions templates/emails/notification.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
height: 50px;
}
}

</style>
</head>

Expand Down Expand Up @@ -88,6 +89,13 @@ <h2 style="font-size: 18px;">Basic Details:</h2></td>
<td style="border: 1px solid #cccccc; padding: 5px;"><code>{{ BasicDetails['SourceIP'] }}</code></td>
</tr>
{% endif %}
{% if BasicDetails['User-Agent'] %}
<tr>
<td class="label" style="background: #eeeeee; font-weight: bold; _border: none; width: 180px; border: 1px solid #cccccc; padding: 5px;">User Agent</td>
<td style="border: 1px solid #cccccc; padding: 5px;"><code>{{ BasicDetails['User-Agent'] }}</code></td>
</td>
</tr>
{% endif %}
{% if BasicDetails['CanaryIP'] or BasicDetails['CanaryName'] %}
<tr>
<td class="label" style="background: #eeeeee; font-weight: bold; _border: none; width: 180px; border: 1px solid #cccccc; padding: 5px;">Canary</td>
Expand Down Expand Up @@ -124,7 +132,7 @@ <h2 style="font-size: 18px;">Basic Details:</h2></td>
</table>
</td>
</tr>
{% if AdditionalDetails %}
{% if ManageLink or HistoryLink %}
<tr>
<td>
<h2 style="font-size: 18px;">Canary Token Management Details:</h2></td>
Expand All @@ -133,8 +141,10 @@ <h2 style="font-size: 18px;">Canary Token Management Details:</h2></td>
<td>
<table class="data" style="border: 1px solid #cccccc; font-size: 14px; border-collapse: collapse;" width="100%">
<tr>
<td class="label" style="background: #eeeeee; font-weight: bold; _border: none; width: 180px; border: 1px solid #cccccc; padding: 5px;">Manage your settings and browse more information regarding this Canarydrop over <a href="{{ AdditionalDetails }}">here</a></td>

<td class="label" style="background: #eeeeee; font-weight: bold; _border: none; width: 120px; border: 1px solid #cccccc; padding: 5px;text-align: center;">Manage this CanaryToken at <a href="{{ ManageLink }}">here</a></td>
</tr>
<tr>
<td class="label" style="background: #eeeeee; font-weight: bold; _border: none; width: 120px; border: 1px solid #cccccc; padding: 5px;text-align: center;">Check out this CanaryToken's Incident List over <a href="{{ HistoryLink }}">here</a></td>
</tr>
</table>
</td>
Expand Down
11 changes: 9 additions & 2 deletions templates/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ <h3 class="text-muted">Canarytokens by Thinkst</h3>
<div class="history-header">
<h3>History for Canary Token : {{canarydrop['canarytoken']}}</h3>
</div>
<div class="alert alert-info alert-dismissible" role="alert" style="text-align: center;">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Heads Up!</strong> Click the incident items for more info.
</div>
<div class="row content">
<div class="col-sm-6 incident-size">
<h4 style="text-align: center;">Incident Map</h4>
Expand All @@ -55,14 +59,16 @@ <h4 style="text-align: center;">Incident Map</h4>
<div class="col-sm-6 incident-size">
{% if (canarydrop['triggered_list']|length) > 0 %}
<h4 style="text-align: center;">Incident List</h4>
<h6 class="text-info" style="text-align: center;">Click to expand Incidents</h6>
{% else %}
<h4 style="text-align: center;">Incident List is Currently Empty</h4>
{% endif %}
<div class="row incident-list">
<div class="col-md-12" id="incidents">
{% for item in canarydrop['triggered_list']|sort(reverse=True) %}
<div class="incident-item expand">
<p class="details-header"><b>Date:</b> {{ item|e }}
<p class="details-header">
<b>Date:</b> {{ item|e }}
<b>IP:</b> {{ canarydrop['triggered_list'][item]['src_ip'] }}
<b>Channel:</b> {{ canarydrop['triggered_list'][item]['input_channel'] }}
</p>
Expand Down Expand Up @@ -234,6 +240,7 @@ <h4 style="text-align: center;">Incident List is Currently Empty</h4>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.6.0/clipboard.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.tooltipster/4.1.8/js/tooltipster.bundle.min.js" integrity="sha256-q732ZLDh1y9/RwzPjKt/GODE3lqj+078N0wwMDYQiPg=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script>
// $(window).on('load', calcSizes());
// $(window).on('resize', calcSizes());
Expand All @@ -255,7 +262,7 @@ <h4 style="text-align: center;">Incident List is Currently Empty</h4>
// calcSizes();
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 0, lng: 0},
zoom: 2,
zoom: 5,
mapTypeId: 'hybrid',
mapTypeControl: false,
streetViewControl: false
Expand Down
94 changes: 55 additions & 39 deletions templates/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
color: darkslategrey;
border-radius: .3rem;
margin-bottom: 0.5rem;
cursor: pointer;
}

.incident-item-details{
Expand All @@ -84,7 +85,6 @@
outline: none;
border-color: #1ecaed;
box-shadow: 0 0 10px green;

}

.header_row{
Expand Down Expand Up @@ -453,68 +453,84 @@
margin-right: 10px;
margin-left: 10px;
content: "";
height: 57px;
width: 57px;
height: 40px;
width: 40px;
background-size: contain;
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
-webkit-transform: translate3d(0, 0, 0);
}

@media (max-width: 768px) {
a.icon:before {
width: 20px;
height: 20px;
}
}
a.icon-web:before {
background: url("https://cdn2.iconfinder.com/data/icons/browsers/Netscape.png");
background-size: 40px 40px;
background-repeat: no-repeat;
background-image: url("/resources/web.png");
}
a.icon-dns:before {
background: url("/resources/dns.png");
background-size: 40px 40px;
background-repeat: no-repeat;
background-image: url("/resources/dns.png");
}
a.icon-web-image:before {
background: url("/resources/web_image.png");
background-size: 40px 40px;
background-repeat: no-repeat;
background-image: url("/resources/web_image.png");
}
a.icon-email:before {
/*Email by Lorena Salagre from the Noun Project*/
background: url("/resources/email.png");
background-size: 40px 40px;
background-repeat: no-repeat;
background-image: url("/resources/email.png");
}
a.icon-word:before {
background: url("/resources/word.png");
background-size: 40px 40px;
background-repeat: no-repeat;
background-image: url("/resources/word.png");
}
a.icon-pdf:before {
background: url("/resources/pdf.png");
background-size: 40px 40px;
background-repeat: no-repeat;
background-image: url("/resources/pdf.png");
}
a.icon-folder:before {
background: url("/resources/folder.png");
background-size: 40px 40px;
background-repeat: no-repeat;
background-image: url("/resources/folder.png");
}
a.icon-exe:before {
background: url("/resources/exe.png");
background-size: 40px 40px;
background-repeat: no-repeat;
background-image: url("/resources/exe.png");
}
a.icon-clonedsite:before {
background: url("/resources/clonedsite.png");
background-size: 40px 40px;
background-repeat: no-repeat;
background-image: url("/resources/clonedsite.png");
}
a.icon-sqlserver:before {
background: url("/resources/sqlserver.png");
background-size: 40px 40px;
background-repeat: no-repeat;
background-image: url("/resources/sqlserver.png");
}
a.icon-qrcode:before {
background: url("/resources/qrcode.png");
background-size: 40px 40px;
background-repeat: no-repeat;
background-image: url("/resources/qrcode.png");
}
a.icon-svn:before {
background: url("/resources/svn.png");
background-size: 40px 40px;
background-repeat: no-repeat;
background-image: url("/resources/svn.png");
}

@media (max-width: 768px) {
input.form-control:-moz-placeholder {
font-size: .8rem;
}
input.form-control::-moz-placeholder {
font-size: .8rem;
}
input.form-control:placeholder {
font-size: .8rem;
}
input.form-control::-webkit-input-placeholder {
font-size: .8rem;
}
}
@media (max-width: 500px) {
input.form-control:-moz-placeholder {
font-size: .7rem;
}
input.form-control::-moz-placeholder {
font-size: .7rem;
}
input.form-control:placeholder {
font-size: .7rem;
}
input.form-control::-webkit-input-placeholder {
font-size: .7rem;
}
}

0 comments on commit 8a5216e

Please sign in to comment.