Skip to content

Instantly share code, notes, and snippets.

@mikemackintosh
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikemackintosh/8edc444764089391c001 to your computer and use it in GitHub Desktop.
Save mikemackintosh/8edc444764089391c001 to your computer and use it in GitHub Desktop.
Vectra Dashing Widget

Vectra Widget

Vectra continuously listens, thinks and learns. Adapting to the fast-changing malware threat landscape, Vectra instantly detects attacks at every phase as they are happening.

Usage

<li data-row="1" data-col="1" data-sizex="3" data-sizey="2">
  <div data-id="vectraevents" data-view="Alert" data-title="Vectra Events" style="background-color:#96bf48;" data-moreinfo="Events Detected by Vectra" ></div>
  <i class="icon-tasks icon-background"></i>
</li>

Preview

Alert Widget Preview

Dependencies

Gems

gem install vectra

Dashing Wigets

The Vectra Widget requires the Alert widget view type. This can be found here:

https://github.com/mikemackintosh/dashing-widget-alert

The MIT License (MIT)

Copyright (c) 2015 Mike Mackintosh

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

require 'vectra'
def relative_time(start_time)
diff_seconds = Time.now - start_time
case diff_seconds
when 0 .. 59
"#{(diff_seconds).ceil} seconds ago"
when 60 .. (3600-1)
"#{(diff_seconds/60).ceil} minutes ago"
when 3600 .. (3600*24-1)
"#{(diff_seconds/3600).ceil} hours ago"
when (3600*24) .. (3600*24*30)
"#{(diff_seconds/(3600*24)).ceil} days ago"
else
start_time.strftime("%m/%d/%Y")
end
end
@endpoint_url = 'http://vectra_endpoint_url'
@username = "username"
@password = "password"
Vectra.configure do |config|
config.endpoint = @endpoint_url
config.username = @username
config.password = @password
end
blist = Hash.new
all_detections = Vectra::Detections.all
SCHEDULER.every '5m' do
all_detections.last(8).each do |detection|
type = detection["type_vname"]
category = detection["category"]
source = detection["source"]
threat = detection["t_score"]
certainty = detection["c_score"]
date = relative_time(Time.parse(DateTime.parse(detection["last_timestamp"]).to_s))
desc = detection["description"]
message = []
unless detection['detection_detail_set'].empty?
d = Vectra::DetectionDetails.get(detection['detection_detail_set'].last)
message.push("#{d['destination']} has been contacted by this IP #{d['count']} times, which is not normal")
end
unless detection['relayed_comm_set'].empty?
d = Vectra::RelayedComms.get(detection['relayed_comm_set'].last)
message.push("#{d['total_bytes_sent']} bytes were sent to #{d['outbound_ip']}:#{d['outbound_port']} (#{d['outbound_proto']})")
end
unless detection['dns_set'].empty?
d = Vectra::DNS.get(detection['dns_set'].last)
message.push("#{d['dns_ip']} resolved #{d['dns_request']} to #{d['resp']}")
end
unless detection['sqli_set'].empty?
d = Vectra::SQLi.get(detection['sqli_set'].last)
message.push("#{d['destination']} received an SQLInjection-style request of #{d['ngram']}")
end
label = "#{source} was flagged for #{category} #{date}"
value = "#{message.join("\n")}"
blist[source] = { value: value, label: label}
end
send_event('vectraevents', { items: blist.values })
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment