Skip to content

Commit

Permalink
ready to test
Browse files Browse the repository at this point in the history
  • Loading branch information
int13h committed Jan 4, 2014
1 parent 4a1106f commit bf6e880
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 114 deletions.
27 changes: 17 additions & 10 deletions .css/charts.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
.axis path,
.axis line {
.slideraxis {
font: 0px sans-serif;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.slideraxis .sliderdomain {
display:none;
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.bar {
fill:#c9c9c9;
}
.x.axis path {
display: none;
.slideraxis .sliderhalo {
fill:none;
stroke:#000;
stroke-width:1px;
}
.chrt_ts {
font-size:11px;
.slider .sliderhandle {
fill: #fff;
stroke: #666;
stroke-width: 1px;
pointer-events: none;
}
2 changes: 1 addition & 1 deletion .css/squert.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ color:#545454;
padding-bottom:10px;
float:left;
}
div.ovbi {
div.ovbi, div.ovsl {
float:right;
font-size:11px;
margin-right:10px;
Expand Down
143 changes: 62 additions & 81 deletions .js/charts.js
Original file line number Diff line number Diff line change
@@ -1,95 +1,76 @@
// Slider for data tables
function mkSlider(callerID,low,high) {

/* Copyright (C) 2013 Paul Halliday <[email protected]> */
return;
var margin = {top: 3, right: 15, bottom: 3, left: 5},
width = 100,
height = 10;

function math(stamp) {
p = stamp.split(":");
c = p[0] * 60 + p[1];
return c;
}

function chartInterval(data) {

ct = data.split(",");

var hours = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
if (high > 1000) high = 1000;

$.each(ct, function(a,b) {
parts = b.split(":");
switch (parts[0]) {
case '00': hours[0] = hours[0] + 1; break;
case '01': hours[1] = hours[1] + 1; break;
case '02': hours[2] = hours[2] + 1; break;
case '03': hours[3] = hours[3] + 1; break;
case '04': hours[4] = hours[4] + 1; break;
case '05': hours[5] = hours[5] + 1; break;
case '06': hours[6] = hours[6] + 1; break;
case '07': hours[7] = hours[7] + 1; break;
case '08': hours[8] = hours[8] + 1; break;
case '09': hours[9] = hours[9] + 1; break;
case '10': hours[10] = hours[10] + 1; break;
case '11': hours[11] = hours[11] + 1; break;
case '12': hours[12] = hours[12] + 1; break;
case '13': hours[13] = hours[13] + 1; break;
case '14': hours[14] = hours[14] + 1; break;
case '15': hours[15] = hours[15] + 1; break;
case '16': hours[16] = hours[16] + 1; break;
case '17': hours[17] = hours[17] + 1; break;
case '18': hours[18] = hours[18] + 1; break;
case '19': hours[19] = hours[19] + 1; break;
case '20': hours[20] = hours[20] + 1; break;
case '21': hours[21] = hours[21] + 1; break;
case '22': hours[22] = hours[22] + 1; break;
case '23': hours[23] = hours[23] + 1; break;
}
});

var margin = {top: 20, right: 20, bottom: 30, left: 40},
width = 960 - margin.left - margin.right,
height = 150 - margin.top - margin.bottom;
var x = d3.scale.linear()
.domain([1, high])
.range([1, width])
.clamp(true);

var formatPercent = d3.format(".0%");
var brush = d3.svg.brush()
.x(x)
.extent([0, 0])
.on("brush", brushed);

var x = d3.scale.ordinal()
.rangeRoundBands([0, width], .1);
d3.select("#" + callerID)
.text("");

var y = d3.scale.linear()
.range([height, 0]);

var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");

var yAxis = d3.svg.axis()
.scale(y)
.orient("left")
.tickFormat(formatPercent);

var svg = d3.select(".chrt_ts").append("svg")
var svg = d3.select("#" + callerID).append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");

svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);

svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Frequency");
.attr("class", "x slideraxis")
.attr("transform", "translate(0," + height / 2 + ")")
.call(d3.svg.axis()
.scale(x)
.orient("bottom")
.tickFormat(function(d) { return d; })
.tickSize(0)
.tickPadding(7))
.select(".domain")
.select(function() { return this.parentNode.appendChild(this.cloneNode(true)); })
.attr("class", "sliderhalo");

var slider = svg.append("g")
.attr("class", "slider")
.call(brush);

slider.selectAll(".extent,.resize")
.remove();

slider.select(".background")
.attr("height", height);

var handle = slider.append("circle")
.attr("class", "sliderhandle")
.attr("transform", "translate(0," + height / 2 + ")")
.attr("r", 5);

// Position the brush at our current selection
slider
.call(brush.event)
.transition()
.duration(0)
.call(brush.extent([low, low]))
.call(brush.event);

function brushed() {
var value = brush.extent()[0];
if (d3.event.sourceEvent) {
value = x.invert(d3.mouse(this)[0]);
brush.extent([value, value]);
}

svg.selectAll(".bar")
.data(hours)
.enter().append("rect")
.attr("class", "bar")
.attr("width", x.rangeBand())
});
handle.attr("cx", x(value));
d3.select("#" + callerID + "_lbl").html(value.toFixed(0));
}
}

41 changes: 27 additions & 14 deletions .js/squert.js
Original file line number Diff line number Diff line change
Expand Up @@ -2885,17 +2885,17 @@ $(document).ready(function(){

// Load summary tab
function loadSummary() {
mkSummary("sig");
mkSummary("srcip");
mkSummary("dstip");
mkSummary("srccc");
mkSummary("dstcc");
var limit = 10;
mkSummary("signature",limit);
mkSummary("srcip",limit);
mkSummary("dstip",limit);
mkSummary("srccc",limit);
mkSummary("dstcc",limit);
}

// Summary tab
function mkSummary(box) {
function mkSummary(box,limit) {
var theWhen = getTimestamp();
var limit = 10;

switch (box) {
case "srcip":
Expand All @@ -2914,7 +2914,7 @@ $(document).ready(function(){
$.get(".inc/callback.php?" + urArgs, function(data){cb15(data,cbArgs)});
});
break;
case "sig":
case "signature":
var qargs = "sig-sig";
var urArgs = "type=15&qargs=" + qargs + "&limit=" + limit + "&ts=" + theWhen;
$(function(){
Expand Down Expand Up @@ -2961,6 +2961,9 @@ $(document).ready(function(){

var eventsum = raw[raw.length - 1].n || 0;
var records = raw[raw.length - 1].r || 0;
if (records == 0) {
row = "<tr><td class=row colspan=6>No result.</td></tr>";
}
for (var i=0; i<raw.length - 1; i++) {
var cnt = raw[i].f1 || "-";
var sigs = raw[i].f2 || "-";
Expand Down Expand Up @@ -2995,9 +2998,9 @@ $(document).ready(function(){
tbl += row;
tbl += "</table>";
if ($("#top" + cbArgs)[0]) $("#top" + cbArgs).remove();
$("#ov_" + cbArgs).after(tbl);
$("#ov_" + cbArgs).prev(".ovbi").html("viewing <b>" + i + " </b>of<b> " + records + " </b>results");

$("#ov_" + cbArgs + "_sl").after(tbl);
$("#ov_" + cbArgs + "_msg").html("viewing <b><span id=ov_" + cbArgs + "_sl_lbl>" + i + "</b> of <b>" + records + " </b>results");
if (records > 1) mkSlider("ov_" + cbArgs + "_sl", i, records);
$("#top" + cbArgs).tablesorter({
cancelSelection:true
});
Expand All @@ -3018,6 +3021,9 @@ $(document).ready(function(){

var eventsum = raw[raw.length - 1].n;
var records = raw[raw.length - 1].r;
if (records == 0) {
row = "<tr><td class=row colspan=5>No result.</td></tr>";
}
for (var i=0; i<raw.length - 1; i++) {
var cnt = raw[i].f1 || "-";
var src = raw[i].f2 || "-";
Expand All @@ -3042,15 +3048,22 @@ $(document).ready(function(){
tbl += row;
tbl += "</table>";
if ($('#topsigs')[0]) $('#topsigs').remove();
$("#ov_signature").after(tbl);
$("#ov_signature").prev(".ovbi").html("viewing <b>" + i + " </b>of<b> " + records + " </b>results");

$("#ov_signature_sl").after(tbl);
$("#ov_signature_msg").html("viewing <b><span id=ov_signature_sl_lbl>" + i + "</span></b> of <b>" + records + " </b>results");
if (records > 1) mkSlider("ov_signature_sl", i, records);
$("#topsigs").tablesorter({
cancelSelection:true
});
}
}

$(".ovsl").mouseup(function() {
var section = $(this).attr('id')
var base = section.split("_")[1];
var limit = Number($("#" + section + "_lbl").text());
if (limit > 0) mkSummary(base, limit);
});


// The End.
});
12 changes: 6 additions & 6 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<script type="text/javascript" src=".js/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src=".js/cal.js"></script>
<script type="text/javascript" src=".js/squert.js"></script>
<!-- script type="text/javascript" src=".js/charts.js"></script -->
<script type="text/javascript" src=".js/charts.js"></script>
<script type="text/javascript" src=".js/jquery-jvectormap-1.2.2.min.js"></script>
<script type="text/javascript" src=".js/jquery-jvectormap-world-mill-en.js"></script>
<script type="text/javascript" src=".js/d3/d3.v3.min.js"></script>
Expand Down Expand Up @@ -158,26 +158,26 @@
<div id=t_inc_content class=content></div>
<div id=t_ovr_content class=content>
<div class=onepane>
<div class=ovbl>Top Signatures</div><div class=ovbi></span></div>
<div class=ovbl>Top Signatures</div><div class=ovbi id=ov_signature_msg></div><div class=ovsl id=ov_signature_sl></div>
<div id=ov_signature></div>
</div>
<div class=twopane>
<div class=leftpane>
<div class=ovbl>Top Source IPs</div><div class=ovbi></div>
<div class=ovbl>Top Source IPs</div><div class=ovbi id=ov_srcip_msg></div><div class=ovsl id=ov_srcip_sl></div>
<div id=ov_srcip></div>
</div>
<div class=rightpane>
<div class=ovbl>Top Destination IPs</div><div class=ovbi></div>
<div class=ovbl>Top Destination IPs</div><div class=ovbi id=ov_dstip_msg></div><div class=ovsl id=ov_dstip_sl></div>
<div id=ov_dstip></div>
</div>
</div>
<div class=twopane>
<div class=leftpane>
<div class=ovbl>Top Source Countries</div><div class=ovbi></div>
<div class=ovbl>Top Source Countries</div><div class=ovbi id=ov_srccc_msg></div><div class=ovsl id=ov_srccc_sl></div>
<div id=ov_srccc></div>
</div>
<div class=rightpane>
<div class=ovbl>Top Destination Countries</div><div class=ovbi></div>
<div class=ovbl>Top Destination Countries</div><div class=ovbi id=ov_dstcc_msg></div><div class=ovsl id=ov_dstcc_sl></div>
<div id=ov_dstcc></div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function cleanUp($string) {
<br><br><br><br><br>
<table class=boxes width=450 align=center cellpadding=1 cellspacing=0>
<tr><td colspan=2 class=header>
SQueRT - Please login to continue</td></tr>
squert - Please login to continue</td></tr>
<tr><td colspan=2 class=boxes>
Username<br>
<input class=in type=text name=username value="<?php echo htmlentities($username);?>" maxlength="32"></td></tr>
Expand All @@ -124,7 +124,7 @@ function cleanUp($string) {
<input id=logmein name=logmein class=rb type=submit name=login value=submit><br><br></td>
<td class=err><?php echo $err;?></td></tr>
</table>
<div class=cp>Version 1.1.6<span>&copy;2013 Paul Halliday</span></div>
<div class=cp>Version 1.1.6<span>&copy;2014 Paul Halliday</span></div>
</form>
<script type="text/javascript">document.credcheck.<?php echo $focus;?>.focus();</script>
</body>
Expand Down

0 comments on commit bf6e880

Please sign in to comment.