Permalink
Fetching contributors…
Cannot retrieve contributors at this time
2322 lines (2042 sloc) 95.4 KB
<html>
<head>
<title>ThreatConnect Javascript SDK</title>
<!--
<script src="./libs/uuid.js" type="text/javascript"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
-->
<!-- JQuery -->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<!-- Bootstrap Table -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/bootstrap-table.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/bootstrap-table.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/extensions/editable/bootstrap-table-editable.min.js"></script>
<!-- X-Editable -->
<link href="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>
<script src="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
<!-- LeafLet -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-beta.2.rc.2/leaflet.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-beta.2.rc.2/leaflet.js"></script>
<!-- D3 -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.8/d3.min.js"></script>
<!-- C3 -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.js"></script>
<!-- HMAC -->
<script src="./libs/core.js" type="text/javascript"></script>
<script src="./libs/sha256.js" type="text/javascript"></script>
<script src="./libs/hmac.js" type="text/javascript"></script>
<script src="./libs/enc-base64.js" type="text/javascript"></script>
<!-- ThreatConnect -->
<script src="./threatconnect.js" type="text/javascript"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-static-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">TC JavaScript Tester</a>
</div>
<div>
<ul class="nav navbar-nav">
<li class="active">
<a data-toggle="tab" href="#Api-pane">API Request</a>
</li>
<li><a data-toggle="tab" href="#Adversary-pane">
Adversaries <span class="label label-primary label-as-badge"></span>
</a></li>
<li><a data-toggle="tab" href="#Document-pane">
Documents <span class="label label-primary label-as-badge"></span>
</a></li>
<li><a data-toggle="tab" href="#Email-pane">
Emails <span class="label label-primary label-as-badge"></span>
</a></li>
<li><a data-toggle="tab" href="#Group-pane">
Groups <span class="label label-primary label-as-badge"></span>
</a></li>
<li><a data-toggle="tab" href="#Incident-pane">
Incidents <span class="label label-primary label-as-badge"></span>
</a></li>
<li><a data-toggle="tab" href="#Indicator-pane">
Indicators <span class="label label-primary label-as-badge"></span>
</a></li>
<li><a data-toggle="tab" href="#Threat-pane">
Threats <span class="label label-primary label-as-badge"></span>
</a></li>
<li><a data-toggle="tab" href="#Owner-pane">Owners </a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<form class="navbar-form navbar-right navbar-input-group" role="search">
<div class="form-group">
<label for="Owner-select">Owner</label>
<select class="form-control" id="Owner-select">
</select>
</div>
</form>
</li>
</ul>
</div>
</div>
</nav>
<div class="tab-content">
<div class="tab-pane active" id="Api-pane">
<div class="panel panel-default">
<div class="panel-body">
<h3>API URI</h3>
<div class="input-group">
<input type="input" class="form-control" id="api-uri">
<div class="input-group-btn">
<button type="button"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
Action<span class="caret"></span>
</button>
<ul id="api-method" class="dropdown-menu">
<li><a href="#">GET</a></li>
<li><a href="#">POST</a></li>
<li><a href="#">PUT</a></li>
<!--
<li role="separator" class="divider"></li>
-->
<li><a href="#">DELETE</a></li>
</ul>
</div>
</div>
<h3>Post/Put Body</h3>
<div class="form-group">
<textarea class="form-control" rows="5" id="api-body"></textarea>
</div>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-body">
<h3>Results:</h3>
<pre id="api-content"></pre>
</div>
</div>
</div>
<div class="tab-pane" id="Adversary-pane" data="Adversary" data-id="#Adversary-table">
<div class="panel panel-default">
<div class="panel-body">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Adversary-table-tab">Data Table</a></li>
<li><a data-toggle="tab" href="#Adversary-raw">Raw Data</a></li>
</ul>
<div class="tab-content">
<div id="Adversary-table-tab" class="tab-pane fade in active">
<table id="Adversary-table"
data-cache="false"
data-detail-view="true"
data-minimum-count-columns="2"
data-height="543"
data-id-field="id"
data-search="true"
data-striped="true"
data-select-item-name="toolbar1"
data-toggle="table"
data-toolbar="#Adversary-toolbar"
data-pagination="true"
data-show-columns="true"
data-show-export="true"
data-show-refresh="false"
data-show-toggle="true"
data-sort-name="id"
data-sort-order="desc">
<thead>
<tr>
<th data-field="state" data-checkbox="true">Item ID</th>
<th data-field="id" data-align="right" data-sortable="true">ID</th>
<th data-field="name" data-align="center" data-sortable="true" data-editable="true">Name</th>
<th data-field="ownerName" data-align="center">Owner</th>
<th data-field="dateAdded" data-align="center">Date Added</th>
<th data-field="webLink" data-align="center">Web Link</th>
</tr>
</thead>
</table>
</div>
<div id="Adversary-toolbar" class="btn-group pull-right">
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#Adversary-modal">Add</button>
<button type="button" class="btn btn-danger" id="Adversary-delete">Delete</button>
<button type="button" class="btn btn-default" id="Adversary-clear">Clear</button>
<button type="button" class="btn btn-default" id="Adversary-refresh">Refresh</button>
<button type="button" class="btn btn-default" data-id="Adversary" data-toggle="modal" data-target="#Group-Association-modal">Group Associations</button>
<button type="button" class="btn btn-default" data-id="Adversary" data-toggle="modal" data-target="#Group-Association-modal">Indicator Associations</button>
</div>
<div id="Adversary-raw" class="tab-pane fade">
<pre id="Adversary-content"></pre>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="Document-pane" data="Document" data-id="#Document-table">
<div class="panel panel-default">
<div class="panel-body">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Document-table-tab">Data Table</a></li>
<li><a data-toggle="tab" href="#Document-raw">Raw Data</a></li>
</ul>
<div class="tab-content">
<div id="Document-table-tab" class="tab-pane fade in active">
<table id="Document-table"
data-cache="false"
data-height="543"
data-search="true"
data-striped="true"
data-select-item-name="toolbar1"
data-toggle="table"
data-toolbar="#Document-toolbar"
data-pagination="true"
data-show-columns="true"
data-show-refresh="false"
data-show-toggle="true"
data-sort-name="id"
data-sort-order="desc">
<thead>
<tr>
<th data-field="state" data-checkbox="true">Item ID</th>
<th data-field="id" data-align="right" data-sortable="true">ID</th>
<th data-field="name" data-align="center" data-sortable="true" data-editable="true">Name</th>
<th data-field="ownerName" data-align="center">Owner</th>
<th data-field="dateAdded" data-align="center">Date Added</th>
<th data-field="webLink" data-align="center">Web Link</th>
</tr>
</thead>
<input type="file" class="hide" id="Document-file"/>
</table>
</div>
<div id="Document-toolbar" class="btn-group pull-right">
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#Document-modal">Add</button>
<button type="button" class="btn btn-danger" id="Document-delete">Delete</button>
<button type="button" class="btn btn-default" id="Document-clear">Clear</button>
<button type="button" class="btn btn-default" id="Document-refresh">Refresh</button>
<button type="button" class="btn btn-primary" id="Document-upload">Upload</button>
<button type="button" class="btn btn-default" data-id="Document" data-toggle="modal" data-target="#Group-Association-modal">Group Associations</button>
<button type="button" class="btn btn-default" data-id="Document" data-toggle="modal" data-target="#Group-Association-modal">Indicator Associations</button>
</div>
<div id="Document-raw" class="tab-pane fade">
<pre id="Document-content"></pre>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="Email-pane" data="Email" data-id="#Email-table">
<div class="panel panel-default">
<div class="panel-body">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Email-table-tab">Data Table</a></li>
<li><a data-toggle="tab" href="#Email-raw">Raw Data</a></li>
</ul>
<div class="tab-content">
<div id="Email-table-tab" class="tab-pane fade in active">
<table id="Email-table"
data-cache="false"
data-height="543"
data-search="true"
data-striped="true"
data-select-item-name="toolbar1"
data-toggle="table"
data-toolbar="#Email-toolbar"
data-pagination="true"
data-show-columns="true"
data-show-refresh="false"
data-show-toggle="true"
data-sort-name="id"
data-sort-order="desc">
<thead>
<tr>
<th data-field="state" data-checkbox="true">Item ID</th>
<th data-field="id" data-align="right" data-sortable="true">ID</th>
<th data-field="name" data-align="center" data-sortable="true" data-editable="true">Name</th>
<th data-field="ownerName" data-align="center">Owner</th>
<th data-field="dateAdded" data-align="center">Date Added</th>
<th data-field="webLink" data-align="center">Web Link</th>
</tr>
</thead>
<input type="file" class="hide" id="Email-file"/>
</table>
</div>
<div id="Email-toolbar" class="btn-group pull-right">
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#Email-modal">Add</button>
<button type="button" class="btn btn-danger" id="Email-delete">Delete</button>
<button type="button" class="btn btn-default" id="Email-clear">Clear</button>
<button type="button" class="btn btn-default" id="Email-refresh">Refresh</button>
<button type="button" class="btn btn-default" data-id="Email" data-toggle="modal" data-target="#Group-Association-modal">Group Associations</button>
<button type="button" class="btn btn-default" data-id="Email" data-toggle="modal" data-target="#Group-Association-modal">Indicator Associations</button>
<!--
<button type="button" class="btn btn-default">Attributes</button>
<button type="button" class="btn btn-default">Tags</button>
-->
</div>
<div id="Email-raw" class="tab-pane fade">
<pre id="Email-content"></pre>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="Group-pane" data="Group" data-id="#Group-table">
<div class="panel panel-default">
<div class="panel-body">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Group-table-tab">Data Table</a></li>
<li><a data-toggle="tab" href="#Group-raw">Raw Data</a></li>
</ul>
<div class="tab-content">
<div id="Group-table-tab" class="tab-pane fade in active">
<table id="Group-table"
data-cache="false"
data-height="543"
data-search="true"
data-striped="true"
data-select-item-name="toolbar1"
data-toggle="table"
data-toolbar="#Group-toolbar"
data-pagination="true"
data-show-columns="true"
data-show-refresh="false"
data-show-toggle="true"
data-sort-name="id"
data-sort-order="desc">
<thead>
<tr>
<th data-field="state" data-checkbox="true">Item ID</th>
<th data-field="id" data-align="right" data-sortable="true">ID</th>
<th data-field="name" data-align="center" data-sortable="true">Name</th>
<th data-field="type" data-align="center" data-sortable="true">Type</th>
<th data-field="ownerName" data-align="center">Owner</th>
<th data-field="dateAdded" data-align="center">Date Added</th>
<th data-field="webLink" data-align="center">Web Link</th>
</tr>
</thead>
</table>
</div>
<div id="Group-toolbar" class="btn-group pull-right">
<button type="button" class="btn btn-default" id="Group-clear">Clear</button>
<button type="button" class="btn btn-default" id="Group-refresh">Refresh</button>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#Group-map-modal">
Association Map
</button>
<!--
<button type="button" class="btn btn-default">Attributes</button>
<button type="button" class="btn btn-default">Tags</button>
-->
</div>
<div id="Group-raw" class="tab-pane fade">
<pre id="Group-content"></pre>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="Incident-pane" data="Incident" data-id="#Incident-table">
<div class="panel panel-default">
<div class="panel-body">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Incident-table-tab">Data Table</a></li>
<li><a data-toggle="tab" href="#Incident-raw">Raw Data</a></li>
</ul>
<div class="tab-content">
<div id="Incident-table-tab" class="tab-pane fade in active">
<table id="Incident-table"
data-cache="false"
data-height="543"
data-search="true"
data-striped="true"
data-select-item-name="toolbar1"
data-toggle="table"
data-toolbar="#Incident-toolbar"
data-pagination="true"
data-show-columns="true"
data-show-refresh="false"
data-show-toggle="true"
data-sort-name="id"
data-sort-order="desc">
<thead>
<tr>
<th data-field="state" data-checkbox="true">Item ID</th>
<th data-field="id" data-align="right" data-sortable="true">ID</th>
<th data-field="name" data-align="center" data-sortable="true" data-editable="true">Name</th>
<th data-field="ownerName" data-align="center">Owner</th>
<th data-field="dateAdded" data-align="center">Date Added</th>
<th data-field="webLink" data-align="center">Web Link</th>
</tr>
</thead>
</table>
</div>
<div id="Incident-toolbar" class="btn-group pull-right">
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#Incident-modal">Add</button>
<button type="button" class="btn btn-danger" id="Incident-delete">Delete</button>
<button type="button" class="btn btn-default" id="Incident-clear">Clear</button>
<button type="button" class="btn btn-default" id="Incident-refresh">Refresh</button>
<button type="button" class="btn btn-default" data-id="Incident" data-toggle="modal" data-target="#Group-Association-modal">Group Associations</button>
<button type="button" class="btn btn-default" data-id="Incident" data-toggle="modal" data-target="#Group-Association-modal">Indicator Associations</button>
<!--
<button type="button" class="btn btn-default">Attributes</button>
<button type="button" class="btn btn-default">Tags</button>
-->
</div>
<div id="Incident-raw" class="tab-pane fade">
<pre id="Incident-content"></pre>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="Indicator-pane" data="Indicator" data-id="#Indicator-table">
<div class="panel panel-default">
<div class="panel-body">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Indicator-table-tab">Data Table</a></li>
<li><a data-toggle="tab" href="#Indicator-raw">Raw Data</a></li>
<!--
<li><a data-toggle="tab" href="#Indicator-chart">Add/Modified Chart</a></li>
-->
<li><a data-toggle="tab" href="#map-tab">(IP/Host) Map</a></li>
</ul>
<div class="tab-content">
<div id="Indicator-table-tab" class="tab-pane fade in active">
<table id="Indicator-table"
data-cache="false"
data-height="543"
data-search="true"
data-striped="true"
data-select-item-name="toolbar1"
data-toggle="table"
data-toolbar="#Indicator-toolbar"
data-pagination="true"
data-show-columns="true"
data-show-refresh="false"
data-show-toggle="true"
data-sort-name="id"
data-sort-order="desc">
<thead>
<tr>
<th data-field="state" data-checkbox="true">Item ID</th>
<th data-field="id" data-align="right" data-sortable="true">ID</th>
<th data-field="indicators" data-align="center" data-sortable="true">Indicators</th>
<th data-field="rating" data-align="center" data-sortable="true">Rating</th>
<th data-field="confidence" data-align="center" data-sortable="true">Confidence</th>
<th data-field="type" data-align="center" data-sortable="true">Type</th>
<th data-field="ownerName" data-align="center">Owner</th>
<th data-field="dateAdded" data-align="center">Date Added</th>
<th data-field="lastModified" data-align="center">Last Modified</th>
<th data-field="webLink" data-align="center" data-visible="false">Web Link</th>
</tr>
</thead>
</table>
<div id="Indicator-toolbar" class="btn-group pull-right">
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#Indicator-modal">Add</button>
<button type="button" class="btn btn-danger" id="Indicator-delete">Delete</button>
<button type="button" class="btn btn-default" id="Indicator-clear">Clear</button>
<button type="button" class="btn btn-default" id="Indicator-refresh">Refresh</button>
<!--
<button type="button" class="btn btn-default">Attributes</button>
<button type="button" class="btn btn-default">Tags</button>
-->
</div>
</div>
<div id="Indicator-raw" class="tab-pane fade">
<pre id="Indicator-content"></pre>
</div>
<div id="Indicator-chart" class="tab-pane fade">
<div id="indicatorChart"></div>
</div>
<div id="map-tab" class="tab-pane fade">
<div class="container fill">
<div id="map"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="Threat-pane" data="Threat" data-id="#Threat-table">
<div class="panel panel-default">
<div class="panel-body">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Threat-table-tab">Data Table</a></li>
<li><a data-toggle="tab" href="#Threat-raw">Raw Data</a></li>
</ul>
<div class="tab-content">
<div id="Threat-table-tab" class="tab-pane fade in active">
<table id="Threat-table"
data-cache="false"
data-height="543"
data-search="true"
data-striped="true"
data-select-item-name="toolbar1"
data-toggle="table"
data-toolbar="#Threat-toolbar"
data-pagination="true"
data-show-columns="true"
data-show-refresh="false"
data-show-toggle="true"
data-sort-name="id"
data-sort-order="desc">
<thead>
<tr>
<th data-field="state" data-checkbox="true">Item ID</th>
<th data-field="id" data-align="right" data-sortable="true">ID</th>
<th data-field="name" data-align="center" data-sortable="true" data-editable="true">Name</th>
<th data-field="ownerName" data-align="center">Owner</th>
<th data-field="dateAdded" data-align="center">Date Added</th>
<th data-field="webLink" data-align="center">Web Link</th>
</tr>
</thead>
</table>
</div>
<div id="Threat-toolbar" class="btn-group pull-right">
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#Threat-modal">Add</button>
<button type="button" class="btn btn-danger" id="Threat-delete">Delete</button>
<button type="button" class="btn btn-default" id="Threat-clear">Clear</button>
<button type="button" class="btn btn-default" id="Threat-refresh">Refresh</button>
<button type="button" class="btn btn-default" data-id="Threat" data-toggle="modal" data-target="#Group-Association-modal">Group Associations</button>
<button type="button" class="btn btn-default" data-id="Threat" data-toggle="modal" data-target="#Group-Association-modal">Indicator Associations</button>
<!--
<button type="button" class="btn btn-default">Attributes</button>
<button type="button" class="btn btn-default">Tags</button>
-->
</div>
<div id="Threat-raw" class="tab-pane fade">
<pre id="Threat-content"></pre>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="Owner-pane" data="Owner" data-id="#Owner-table">
<div class="panel panel-default">
<div class="panel-body">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Owner-table-tab">Data Table</a></li>
<li><a data-toggle="tab" href="#Owner-raw">Raw Data</a></li>
</ul>
<div class="tab-content">
<div id="Owner-table-tab" class="tab-pane fade in active">
<table id="Owner-table"
data-cache="false"
data-height="543"
data-search="true"
data-striped="true"
data-select-item-name="toolbar1"
data-toggle="table"
data-toolbar="#Owner-toolbar"
data-pagination="true"
data-show-columns="true"
data-show-refresh="false"
data-show-toggle="true"
data-sort-name="id"
data-sort-order="desc">
<thead>
<tr>
<th data-field="state" data-checkbox="true">Item ID</th>
<th data-field="id" data-align="right" data-sortable="true">ID</th>
<th data-field="name" data-align="center" data-sortable="true">Name</th>
<th data-field="type" data-align="center">Type</th>
</tr>
</thead>
</table>
<div id="Owner-toolbar" class="btn-group pull-right">
<button type="button" class="btn btn-default" id="Owner-clear">Clear</button>
<button type="button" class="btn btn-default" id="Owner-refresh">Refresh</button>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#Owner-metric-modal">Metrics</button>
<!--
<button type="button" class="btn btn-default">Attributes</button>
<button type="button" class="btn btn-default">Tags</button>
-->
</div>
</div>
<div id="Owner-raw" class="tab-pane fade">
<pre id="Owner-content"></pre>
</div>
</div>
</div>
</div>
</div>
<div id="alert-status"></div>
</div>
<!-- Modals -->
<div id="Adversary-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Add Adversary</h4>
</div>
<div class="modal-body">
<form role="form">
<div class="form-group">
<label for="Adversary-name">Adversary Name</label>
<input type="input" class="form-control" id="Adversary-name">
</div>
<button id="Adversary-commit" type="submit" class="btn btn-default">Submit</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="Document-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Add Document</h4>
</div>
<div class="modal-body">
<form role="form">
<div class="form-group">
<label for="Document-name">Document Name</label>
<input type="input" class="form-control" id="Document-name">
</div>
<div class="form-group">
<label for="file-name">File Name</label>
<input type="input" class="form-control" id="file-name">
</div>
<div class="form-group">
<label for="file-size">File Size</label>
<input type="input" class="form-control" id="file-size">
</div>
<button id="Document-commit" type="submit" class="btn btn-default">Submit</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="Email-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Add Email</h4>
</div>
<div class="modal-body">
<form role="form">
<div class="form-group">
<label for="Email-name">Email Name</label>
<input type="input" class="form-control" id="Email-name">
</div>
<div class="form-group">
<label for="Email-body">Body</label>
<input type="input" class="form-control" id="Email-body">
</div>
<div class="form-group">
<label for="Email-from">From Address</label>
<input type="input" class="form-control" id="Email-from">
</div>
<div class="form-group">
<label for="Email-header">Header</label>
<input type="input" class="form-control" id="Email-header">
</div>
<div class="form-group">
<label for="Email-score">Score</label>
<input type="input" class="form-control" id="Email-score">
</div>
<div class="form-group">
<label for="Email-subject">Subject</label>
<input type="input" class="form-control" id="Email-subject">
</div>
<div class="form-group">
<label for="Email-to">To</label>
<input type="input" class="form-control" id="Email-to">
</div>
<button id="Email-commit" type="submit" class="btn btn-default">Submit</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="Incident-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Add Incident</h4>
</div>
<div class="modal-body">
<form role="form">
<div class="form-group">
<label for="Incident-name">Incident Name</label>
<input type="input" class="form-control" id="Incident-name">
</div>
<button id="Incident-commit" type="submit" class="btn btn-default">Submit</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="Indicator-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Add Indicator</h4>
</div>
<div class="modal-body">
<form role="form">
<div class="form-group">
<label for="Indicator-value">Indicator</label>
<input type="input" class="form-control" id="Indicator-value">
</div>
<div class="form-group">
<label for="Indicator-type">Indicator Type</label>
<select id="Indicator-type" class="form-control">
<option>ADDRESS</option>
<option>EMAIL_ADDRESS</option>
<option>FILE</option>
<option>HOST</option>
<option>URL</option>
</select>
</div>
<button id="Indicator-commit" type="submit" class="btn btn-default">Submit</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="Indicator-Association-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Indicator Association</h4>
</div>
<div class="modal-body">
<div id="Indicator-Association-content"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="Group-map-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Association Map</h4>
</div>
<div class="modal-body">
<div id="Group-map"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="Group-Association-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Group Association</h4>
</div>
<div class="modal-body">
<div id="Group-Association-content"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="Threat-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Add Threat</h4>
</div>
<div class="modal-body">
<form role="form">
<div class="form-group">
<label for="Threat-name">Threat Name</label>
<input type="input" class="form-control" id="Threat-name">
</div>
<button id="Threat-commit" type="submit" class="btn btn-default">Submit</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="Attribute-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Attribute</h4>
</div>
<div class="modal-body">
<pre id="Attribute-content"></pre>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="Tag-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Tag</h4>
</div>
<div class="modal-body">
<pre id="Tag-content"></pre>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="Owner-metric-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Metrics</h4>
</div>
<div class="modal-body">
<div id="Owner-metric-content"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</body>
<style>
#Group-map
{
width: 100px;
height: 600px;
min-height: 500px;
min-width: 100%;
display: block;
}
.modal-body {
max-height: 600px;
}
#map
{
width: 100px;
height: 80px;
min-height: 80%;
min-width: 100%;
display: block;
}
.label-as-badge {
border-radius: 1em;
}
</style>
<script>
/* global c3, getParameterByName, getParameterFromUri, L, map, RequestObject, ThreatConnect, TYPE */
var apiSettings,
c = console,
groupMap = undefined,
map = undefined,
tcSpaceElementId = getParameterByName('tcSpaceElementId'), // spaces mode if spaceElementId defined
geoIpUrl = 'https://geoip.sumx.us/geoip';
if ( tcSpaceElementId ) {
var server = window.location.protocol + "//" + window.location.host;
c.log('server', server);
apiSettings = {
apiToken: getParameterByName('tcToken'),
apiUrl: getParameterByName('tcApiPath'),
proxyServer: server
};
} else {
apiSettings = {
apiId: '16976120412908824823',
apiSec: 'Jw@aPN9Xn6h3v3Bksn$@%ivhbtjKRFPiok8DR^SAA^^Wyorr6k9oOiV6YlCZXypG',
apiUrl: 'https://ti.sumx.us/api'
};
// apiSettings = {
// apiId: '36096177525557134167',
// apiSec: 'rh!57`d]!X+Hk*P]K#Dm9@LsCz}nSPz&88c(=Rka4Dc*oiqJKh3eTq*%?G]H)JjR',
// apiUrl: 'https://ti.sumx.us/api'
// };
}
var tc = new ThreatConnect(apiSettings);
//turn to inline mode
// $.fn.editable.defaults.mode = 'inline';
$.fn.editable.defaults.mode = 'popup';
// Set select owner options
tc.owners()
.async(false)
.done(function(response) {
var owner,
selected = 'selected';
for (owner in response.data) {
$('#Owner-select')
.append($('<option ' + selected + '></option>')
.attr('value', response.data[owner].name)
.text(response.data[owner].name));
selected = '';
}
// set resource counts
badgeCounts();
})
.error(function(response) {
var message = 'Owner Retrieval failed. (' + response + ').';
statusAlert('danger', message);
})
.retrieve();
// Owner Select
$('#Owner-select').change(function() {
var active_tab = $('.tab-content > .active').not('.fade').attr('data');
c.log('changed', active_tab);
$('#' + active_tab + '-table').bootstrapTable('removeAll');
var retrieveMethod = 'retrieve' + active_tab;
if (window[retrieveMethod]) {
window[retrieveMethod]();
}
// set resource counts
badgeCounts();
});
// Modal Hide
$('.modal').on('hidden.bs.modal', function(){
var modalId = $(this).attr('id');
if (modalId === 'Group-map-modal') {
groupMap.remove();
} else if (modalId === 'Group-Association-modal') {
} else {
$(this).find('form')[0].reset();
}
});
// Modal Show
$('.modal').on('show.bs.modal', function(e, params){
var modalId = $(this).attr('id');
c.log('modalId', modalId);
// var group = $(e.relatedTarget).data('id');
// var groupType = TYPE[group.toUpperCase()];
// var groupTable = $('#' + group + '-table');
// var selections = groupTable.bootstrapTable('getSelections');
// c.log('selections', selections);
if (modalId === 'Group-Association-modal') {
var group = $(e.relatedTarget).data('id');
var groupType = TYPE[group.toUpperCase()];
var groupTable = $('#' + group + '-table');
var selections = groupTable.bootstrapTable('getSelections');
c.log('selections', selections);
retrieveGroupAssociations({
groupType: groupType,
associationType: TYPE.GROUP,
id: selections[0].id
});
} else if (modalId === 'Indicator-Association-modal') {
var group = $(e.relatedTarget).data('id');
var groupType = TYPE[group.toUpperCase()];
var groupTable = $('#' + group + '-table');
var selections = groupTable.bootstrapTable('getSelections');
c.log('selections', selections);
retrieveGroupAssociations({
groupType: TYPE.ADVERSARY,
associationType: TYPE.INDICATOR,
id: selections[0].id
});
// } else if (modalId === 'Attribute-modal') {
// retrieveAttributes({
// groupType: TYPE.ADVERSARY,
// id: selections[0].id
// });
// } else if (modalId === 'Tag-modal') {
// retrieveTags({
// groupType: TYPE.ADVERSARY,
// id: selections[0].id
// });
} else if (modalId === 'Group-map-modal') {
} else if (modalId === 'Owner-metric-modal') {
c.log('opened modal');
retrieveOwnerMetrics();
}
});
$('#Group-map-modal').on('show.bs.modal', function(){
c.log('map modal shown');
var group_table = $('#Group-table'),
selections = group_table.bootstrapTable('getSelections');
groupMap = createMap('Group-map');
if (selections.length == 0) {
c.warn('at least one document must be selected.');
setTimeout(function() {
c.log('close map modal');
$('#Group-map-modal').modal('hide');
}, 200);
return;
} else if (selections.length > 1) {
c.warn('only one group can be selected at a time.');
group_table.bootstrapTable('uncheckAll');
setTimeout(function() {
c.log('close map modal');
$('#Group-map-modal').modal('hide');
}, 200);
return;
}
// get group associations
tc.groups()
.owner($('#Owner-select :selected').text())
.type(TYPE[selections[0].type.toUpperCase()])
.associationType(TYPE.INDICATOR)
.id(selections[0].id)
.resultLimit(500)
.done(function(response) {
c.log('response', response);
var data;
for (data in response.data) {
if (response.data[data].type == 'Address') {
var ip = response.data[data].indicators;
// geoIpUrl = geoIpUrl + '/' + ip + '?callback=?';
// $.getJSON(geoIpUrl, function() {
$.getJSON(geoIpUrl + '/' + ip + '?callback=?', function() {
console.log("success");
})
.always(function(data) {
console.log("complete", data);
if (data.latitude && data.longitude) {
L.marker([data.latitude, data.longitude]).addTo(groupMap)
.bindPopup(data.ip)
.openPopup();
}
});
}
}
})
.error(function(response) {
var message = 'Group Retrieval failed. (' + response + ').';
statusAlert('danger', message);
})
.retrieveAssociations();
setTimeout(function() {
c.log('invalidate size');
groupMap.invalidateSize();
}, 200);
});
// Tab Hide
$('a[data-toggle="tab"]').on('hide.bs.tab', function(e) {
console.log('e', $($(e.target).attr('href')).data('id'));
var prevTab = $(e.target).attr('href'),
prevId = $(prevTab).data('id');
c.log('prevId', prevId);
$(prevId).bootstrapTable('removeAll');
});
// Tab Show
$('a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
c.log('tab', $(this).attr('href'));
// var active_tab = $('#BCS').find('.tab-pane.active');
// var active_tab = $('.tab-content > .tab-pane.active').data('id');
if ($(this).attr('href') === '#Home') {
// do nothing for now
} else if ($(this).attr('href') === '#Adversary-pane') {
retrieveGroup({type: TYPE.ADVERSARY});
} else if ($(this).attr('href') === '#Document-pane') {
retrieveGroup({type: TYPE.DOCUMENT});
} else if ($(this).attr('href') === '#Email-pane') {
retrieveGroup({type: TYPE.EMAIL});
} else if ($(this).attr('href') === '#Group-pane') {
retrieveGroup({type: TYPE.GROUP});
} else if ($(this).attr('href') === '#Incident-pane') {
retrieveGroup({type: TYPE.INCIDENT});
} else if ($(this).attr('href') === '#Indicator-pane') {
retrieveIndicator();
map = createMap('map');
} else if ($(this).attr('href') === '#Threat-pane') {
retrieveGroup({type: TYPE.THREAT});
} else if ($(this).attr('href') === '#map-tab') {
var data;
map.invalidateSize(false);
var indicators = tc.indicators();
indicators.owner($('#Owner-select :selected').text())
.type(TYPE.ADDRESS)
.resultLimit(500)
.done(function(response) {
for (data in response.data) {
var ip = response.data[data].indicators;
var lookupUrl = geoIpUrl + '/' + ip + '?callback=?';
$.getJSON(geoIpUrl + '/' + ip + '?callback=?', function() {
console.log('success', lookupUrl);
})
.always(function(data) {
console.log("complete", data);
if (data.latitude && data.longitude) {
L.marker([data.latitude, data.longitude])
.addTo(map)
.bindPopup(data.ip)
.openPopup();
}
});
}
})
.error(function(response) {
var message = 'Indicator Retrieval failed. (' + response.error + ').';
statusAlert('danger', message);
});
indicators.retrieve(function() {
while(indicators.hasNext()) {
indicators.next();
}
});
// var indicators = tc.indicators();
// indicators.owner($('#Owner-select :selected').text())
// .type(TYPE.HOST)
// .resultLimit(500)
// .done(function(response) {
// for (data in response.data) {
// var host = response.data[data].indicators;
// geoIpUrl = 'https://freegeoip.net/json/' + host + '?callback=';
// $.getJSON(geoIpUrl, function() {
// console.log("success");
// })
// .always(function(data) {
// console.log("complete", data);
// if (data.latitude && data.longitude) {
// L.marker([data.latitude, data.longitude])
// .addTo(map)
// .bindPopup(data.ip)
// .openPopup();
// }
// });
// }
// })
// .error(function(response) {
// var message = 'Indicator Retrieval failed. (' + response.error + ').';
// statusAlert('danger', message);
// });
// indicators.retrieve(function() {
// while(indicators.hasNext()) {
// indicators.next();
// }
// });
} else if ($(this).attr('href') === '#Owner-pane') {
retrieveOwner();
}
return false;
});
// $('#Adversary-table').on('sort.bs.table', function(e) {
// c.log('sorted');
// enableForm();
// });
// adversary
$('#Adversary-clear').click(function() {
c.log('clearing adversary table');
$('#Adversary-table').bootstrapTable('removeAll');
});
$('#Adversary-commit').click(function(e){
c.log('commiting adversary');
commitGroup({type: TYPE.ADVERSARY});
return false;
});
$('#Adversary-delete').click(function(e){
c.log('deleteing adversaries');
deleteGroup({type: TYPE.ADVERSARY});
});
$('#Adversary-refresh').click(function(e){
c.log('refreshing adversaries');
$('#Adversary-table').bootstrapTable('removeAll');
// retrieveAdversary();
retrieveGroup({type: TYPE.ADVERSARY})
});
// document
$('#Document-clear').click(function(){
c.log('clearing document table');
$('#Document-table').bootstrapTable('removeAll');
});
$('#Document-commit').click(function(e){
c.log('commiting Document');
commitGroup({type: TYPE.DOCUMENT});
return false;
});
$('#Document-delete').click(function(e){
c.log('deleteing Documents');
deleteGroup({type: TYPE.DOCUMENT});
});
$('#Document-refresh').click(function(e){
c.log('refreshing Documents');
$('#Document-table').bootstrapTable('removeAll');
// retrieveDocument();
retrieveGroup({type: TYPE.DOCUMENT})
});
// email
$('#Email-clear').click(function(){
c.log('clearing email table');
$('#Email-table').bootstrapTable('removeAll');
});
$('#Email-commit').click(function(e){
c.log('commiting email');
commitGroup({type: TYPE.EMAIL});
return false;
});
$('#Email-delete').click(function(e){
c.log('deleteing emails');
deleteGroup({type: TYPE.EMAIL});
});
$('#Email-refresh').click(function(e){
c.log('refreshing emails');
$('#Email-table').bootstrapTable('removeAll');
// retrieveEmail();
retrieveGroup({type: TYPE.EMAIL});
});
// group
$('#Group-clear').click(function(){
c.log('clearing group table');
$('#Group-table').bootstrapTable('removeAll');
});
$('#Group-refresh').click(function(e){
c.log('refreshing groups');
$('#Group-table').bootstrapTable('removeAll');
retrieveGroup({type: TYPE.GROUP});
});
// incident
$('#Incident-clear').click(function(){
c.log('clearing incident table');
$('#Incident-table').bootstrapTable('removeAll');
});
$('#Incident-commit').click(function(e){
c.log('commiting incidents');
commitGroup({type: TYPE.INCIDENT});
return false;
});
$('#Incident-delete').click(function(e){
c.log('deleteing incidents');
deleteGroup({type: TYPE.INCIDENT});
});
$('#Incident-refresh').click(function(e){
c.log('refreshing incidents');
$('#Incident-table').bootstrapTable('removeAll');
// retrieveIncident();
retrieveGroup({type: TYPE.INCIDENT});
});
// indicator
$('#Indicator-clear').click(function(){
c.log('clearing indicator table');
$('#Indicator-table').bootstrapTable('removeAll');
});
$('#Indicator-commit').click(function(e){
c.log('commiting indicators');
commitIndicator();
return false;
});
$('#Indicator-delete').click(function(e){
c.log('deleteing indicators');
deleteIndicator();
});
$('#Indicator-refresh').click(function(e){
c.log('refreshing indicators');
$('#Indicator-table').bootstrapTable('removeAll');
retrieveIndicator();
});
// owner
$('#Owner-clear').click(function(){
c.log('clearing owner table');
$('#Owner-table').bootstrapTable('removeAll');
});
$('#Owner-refresh').click(function(e){
c.log('refreshing owners');
$('#Owner-table').bootstrapTable('removeAll');
retrieveOwner();
});
// threat
$('#Threat-clear').click(function(){
c.log('clearing incident table');
$('#Threat-table').bootstrapTable('removeAll');
});
$('#Threat-commit').click(function(e){
c.log('commiting incidents');
commitGroup({type: TYPE.THREAT});
return false;
});
$('#Threat-delete').click(function(e){
c.log('deleteing incidents');
deleteGroup({type: TYPE.THREAT});
});
$('#Threat-refresh').click(function(e){
c.log('refreshing incidents');
$('#Threat-table').bootstrapTable('removeAll');
retrieveGroup({type: TYPE.THREAT});
});
/* Commit */
var commitGroup = function(params) {
var groups = tc.groups(),
groupType = params.type,
name = $('#' + groupType.type + '-name').val();
groups.owner($('#Owner-select :selected').text())
.type(params.type)
.name(name)
.done(function(response) {
if (response.status === "Success") {
message = groupType.type + ' ' + name + ' was successfully committed.';
statusAlert('success', message);
increaseCount(groupType.type);
if (response.data.length > 0) {
c.log('done response', response);
$('#' + groupType.type + '-table').bootstrapTable('append', response.data);
}
}
})
.error(function(response) {
var message = groupType.type + ' failed to commit (' + response.error + ').';
statusAlert('danger', message);
});
if (params.id) {
groups.id(paramas.id);
}
// bcs
switch (params.type.type) {
case TYPE.ADVERSARY.type:
break;
case TYPE.DOCUMENT.type:
groups.fileName($('#file-name').val())
.fileSize($('#file-size').val());
break;
case TYPE.EMAIL.type:
groups.emailBody($('#Email-body').val())
.emailFrom($('#Email-from').val())
.emailHeader($('#Email-header').val())
.emailScore($('#Email-score').val())
.emailSubject($('#Email-subject').val())
.emailTo($('#Email-to').val());
break;
case TYPE.INCIDENT.type:
break;
case TYPE.SIGNATURE.type:
break;
case TYPE.THREAT.type:
break;
default:
c.warn('Invalid type provided.', params.type);
}
groups.commit();
$('#' + groupType.type + '-modal').modal('hide');
};
var commitIndicator = function() {
var message,
indicator = $('#Indicator-value').val(),
indicatorType = $('#Indicator-type').val();
tc.indicators()
.owner($('#Owner-select :selected').text())
.action('Create') // Create|Delete
.attributeWriteType('Append') // Append|Replace
.haltOnError(false)
.done(function(response) {
c.log('commit response', response);
if (response.status === "Completed") {
message = 'Indicator ' + indicator + ' was successfully committed.';
statusAlert('success', message);
increaseCount('Indicator');
$('#Indicator-table').bootstrapTable('removeAll');
retrieveIndicator();
}
})
.error(function(response) {
c.log('error');
message = 'Indicator failed to commit. (' + response.error + ').';
statusAlert('danger', message);
})
.indicator(indicator)
.type(TYPE[indicatorType])
.attributes([{type: 'Description', value: 'JS SDK Test'}])
.tags(['JavaScript', 'SDK'])
.add()
// bcs
// .indicator('a.5.8.3')
// .type(TYPE.ADDRESS)
// .attributes([{type: 'Description1', value: 'JS SDK Test'}])
// .add()
// .indicator('a.b.8.3')
// .type(TYPE.ADDRESS)
// .attributes([{type: 'Description1', value: 'JS SDK Test'}])
// .add()
.commit();
$('#Indicator-modal').modal('hide');
};
/* Update */
var updateGroup = function(params) {
var groups = tc.groups(),
groupType = params.type,
name = $('#' + groupType.type + '-name').val();
groups.owner($('#Owner-select :selected').text())
.type(params.type)
.name(params.name)
.id(params.id)
.done(function(response) {
if (response.status === "Success") {
c.log('updated', response);
message = groupType.type + ' ' + params.id + ' was successfully updated.';
statusAlert('success', message);
}
})
.error(function(response) {
var message = groupType.type + ' failed to update (' + response.error + ').';
statusAlert('danger', message);
})
.commit();
};
// var updateAdversary = function(params) {
// var message;
// tc.groups()
// .owner($('#Owner-select :selected').text())
// .type(TYPE.ADVERSARY)
// .id(params.id)
// .name(params.name)
// .done(function(response) {
// if (response.status === "Success") {
// message = 'Adversary ' + params.name + ' was successfully updated.';
// statusAlert('success', message);
// }
// })
// .error(function(response) {
// var message = 'Adversary failed to update. (' + response.error + ').';
// statusAlert('danger', message);
// })
// .commit();
// $('#Adversary-modal').modal('hide');
// };
// var updateDocument = function(params) {
// var message;
// tc.groups()
// .owner($('#Owner-select :selected').text())
// .type(TYPE.DOCUMENT)
// .id(params.id)
// .name(params.name)
// .done(function(response) {
// if (response.status === "Success") {
// message = 'Document ' + params.name + ' was successfully updated.';
// statusAlert('success', message);
// }
// })
// .error(function(response) {
// var message = 'Document Update failed. (' + response + ').';
// if (response.error) {
// message = 'Document Update failed. (' + response.error + ').';
// }
// statusAlert('danger', message);
// })
// .commit();
// };
// var updateIncident = function(params) {
// var message;
// tc.groups()
// .owner($('#Owner-select :selected').text())
// .type(TYPE.INCIDENT)
// .id(params.id)
// .name(params.name)
// .done(function(response) {
// if (response.status === "Success") {
// message = 'Incident ' + params.name + ' was successfully updated.';
// statusAlert('success', message);
// }
// })
// .error(function(response) {
// c.log('error', response);
// var message = 'Incident Update failed. (' + response + ').';
// if (response.error) {
// message = 'Incident Update failed. (' + response.error + ').';
// }
// statusAlert('danger', message);
// })
// .commit();
// };
/* Delete */
var deleteGroup = function(params) {
var groupType = params.type
groupTable = $('#' + groupType.type + '-table'),
selections = groupTable.bootstrapTable('getSelections');
var message;
for (selection in selections) {
selection = selections[selection];
tc.groups()
.owner($('#Owner-select :selected').text())
.type(groupType)
.id(selection.id)
.done(function(response) {
c.log('response', response);
if (response.status === 'Success') {
groupTable.bootstrapTable('remove', {
field: 'id',
values: [response.id]
});
message = groupType.type + ' ' + response.id + ' was successfully deleted.';
statusAlert('success', message);
decreaseCount(groupType.type);
} else {
message = groupType.type + ' ' + response.id + ' failed to deleted.';
statusAlert('danger', message);
}
})
.error(function(response) {
message = groupType.type + ' ID ' + response.id + ' failed to delete. (' + response.error + ').';
statusAlert('danger', message);
})
.delete();
}
};
var deleteIndicator = function() {};
/* Retrieve */
var retrieveGroup = function(params) {
c.log('retrieveGroup');
var groups = tc.groups(),
groupType = params.type;
// clear content from previous load
$('#' + groupType.type + '-content').text('');
groups.owner($('#Owner-select :selected').text())
.type(groupType)
.resultLimit(500)
.done(function(response) {
c.log(groupType.type + ' retrieve done', response);
var d;
// raw data
$('#' + groupType.type + '-content').append(JSON.stringify(response, null, 4));
// data table
if (response.data.length > 0) {
$('#' + groupType.type + '-table').bootstrapTable('append', response.data);
}
detailView();
enableForm({type: groupType});
tableActions({type: groupType});
// setCount('Adversary', response.resultCount);
})
.error(function(response) {
var message = groupType + ' Retrieval failed. (' + response.error + ').';
statusAlert('danger', message);
});
groups.retrieve(function() {
while(groups.hasNext()) {
groups.next();
}
});
};
var retrieveIndicator = function() {
c.log('retrieve indicator');
var indicators = tc.indicators();
// filter = new Filter(FILTER.AND);
// filter.on('summary', FILTER.SW, 'www');
// filter.on('rating', FILTER.GE, '1');
// filter.on('confidence', FILTER.GT, '0');
indicators.owner($('#Owner-select :selected').text())
.resultLimit(100)
// .filter(filter)
.done(function (response) {
console.log('response', response);
if (response.data.length > 0) {
$('#Indicator-table').bootstrapTable('append', response.data);
$('#Indicator-content').append(JSON.stringify(response, null, 4));
}
setCount('Indicator', response.resultCount);
// genChart(response);
})
.error(function (response) {
var message = 'Indicator Retrieval failed. (' + response.error + ').';
statusAlert('danger', message);
});
indicators.retrieve(function () {
while (indicators.hasNext()) {
indicators.next();
}
});
}
var retrieveOwner = function() {
c.log('retrieve owners');
tc.owners()
.done(function(response) {
c.log('owner retrieve done');
$('#Owner-content').text(JSON.stringify(response, null, 4));
$('#Owner-table').bootstrapTable('refreshOptions', {
sortName: 'id',
sortOrder: 'asc',
data: response.data
});
})
.error(function(response) {
var message = 'Owner Retrieval failed. (' + response + ').';
statusAlert('danger', message);
})
.retrieve();
};
var retrieveOwnerMetrics = function() {
c.log('retrieve owner metrics');
tc.owners()
.done(function(response) {
c.log('owner stats retrieve done');
$('#Owner-metric-content').text(JSON.stringify(response, null, 4));
})
.error(function(response) {
var message = 'Owner Retrieval failed. (' + response + ').';
statusAlert('danger', message);
})
.retrieveMetrics();
};
/* Retrieve Associations */
var retrieveGroupAssociations = function(params) {
c.log('retrieve associations');
tc.groups()
.owner($('#Owner-select :selected').text())
.type(params.groupType)
.id(params.id)
.resultLimit(500)
.done(function(response) {
c.log('association retrieve done', response);
$('#Group-Association-content').text(JSON.stringify(response, null, 4));
})
.error(function(response) {
var message = 'Association Retrieval failed. (' + response + ').';
statusAlert('danger', message);
})
.retrieveAssociations({
type: params.associationType
});
};
var retrieveIndicatorAssociations = function(params) {
c.log('retrieve associations');
tc.indicators()
.owner($('#Owner-select :selected').text())
.type(params.indicatorType)
.indicator(params.indicator)
.resultLimit(500)
.done(function(response) {
c.log('association retrieve done', response);
$('#Indicator-Association-content').text(JSON.stringify(response, null, 4));
})
.error(function(response) {
var message = 'Association Retrieval failed. (' + response + ').';
statusAlert('danger', message);
})
.retrieveAssociations({
type: params.associationType
});
};
var retrieveAttributes = function(params) {
c.log('retrieve attributes');
tc.groups()
.owner($('#Owner-select :selected').text())
.type(params.groupType)
.id(params.id)
.resultLimit(500)
.done(function(response) {
var attrib,
panel = $('#attribute-panel-' + params.id);
for (attrib in response.data) {
panel.append('<p></p>')
.text(response.data[attrib].type + ' : ' + response.data[attrib].value);
}
})
.error(function(response) {
var message = 'Attribute Retrieval failed. (' + response + ').';
statusAlert('danger', message);
})
.retrieveAttributes();
};
var retrieveTags = function(params) {
c.log('retrieve tags');
var groups = tc.groups()
.owner($('#Owner-select :selected').text())
.type(params.groupType)
.id(params.id)
.resultLimit(500)
.done(function(response) {
var tag,
panel = $('#tag-panel-' + params.id);
for (tag in response.data) {
panel.append('<h3></h3>')
.append($('<span></span>')
.addClass('label label-default')
.text(response.data[tag].name));
}
})
.error(function(response) {
var message = 'Tag Retrieval failed. (' + response + ').';
statusAlert('danger', message);
})
.retrieveTags();
};
//
// Upload
//
$('#Document-upload').click(function(e) {
c.group('document-upload');
var document_table = $('#Document-table'),
file_input = $('#Document-file'),
selections = document_table.bootstrapTable('getSelections');
c.log('file_input', file_input);
if (selections.length == 0) {
c.warn('at least one document must be selected.');
return;
} else if (selections.length > 1) {
c.warn('only one upload at a time is supported.');
document_table.bootstrapTable('uncheckAll');
return;
}
file_input.click();
file_input.on('change', function(){
var file = file_input[0].files[0],
selection = selections[0],
id = selection.id,
fr = new FileReader();
fr.readAsText(file);
fr.onload = function(data) {
c.log('fr.result', fr.result);
tc.upload()
.owner($('#Owner-select :selected').text())
.body(fr.result)
.id(id)
.done(function(response) {
statusAlert('success', 'Upload successful.');
})
.error(function(response) {
var message = 'Upload failed. (' + response.error + ').';
statusAlert('danger', message);
})
.commit();
};
});
c.groupEnd();
});
$('#api-method a').click( function () {
var apiUri = $('#api-uri').val(),
body = $('#api-body').val(),
method = $(this).text(),
ro = tc.requestObject(),
formActivityLog = getParameterFromUri('createActivityLog', apiUri),
formOwner = getParameterFromUri('owner', apiUri),
formResultLimit = getParameterFromUri('resultLimit', apiUri),
formResultStart = getParameterFromUri('resultStart', apiUri),
formFilters = getParameterFromUri('filters', apiUri),
uri = apiUri.split("?")[0].replace('/', '');
c.log('formFilters', formFilters);
c.log('formOwner', formOwner);
var activityLog = formActivityLog || false,
roOwner = formOwner || $('#Owner-select :selected').text(),
resultLimit = formResultLimit || 500,
resultStart = formResultStart || 0;
c.log('URI', apiUri);
c.log('Method', $(this).text());
c.log('activityLog', activityLog);
c.log('owner', roOwner);
ro.owner(roOwner)
.createActivityLog(activityLog)
.done(function(response) {
c.log('api response', response);
$('#api-content').text(JSON.stringify(response, null, 4));
})
.error(function(response) {
$('#api-content').text(JSON.stringify(response, null, 4));
})
.requestUri(uri)
.requestMethod(method)
.resultLimit(resultLimit)
.resultStart(resultStart);
if (formFilters) {
ro.addPayload('filters', formFilters);
}
if (method === 'POST' || method === 'PUT') {
if (body.length > 0) {
ro.body(JSON.parse(body));
} else {
$('#api-content').text(JSON.stringify({error: 'Body must not be empty.'}, null, 4));
}
}
c.log('ro', ro);
ro.apiRequest(ro);
});
var statusAlert = function(type, message) {
var alertDiv = $('<div></div>')
.addClass('alert alert-' + type)
.attr('data-dismiss', 'alert')
.text(message);
$('#alert-status').append(alertDiv);
};
var createMap = function(mapId) {
c.log('createMap', mapId);
// var map = L.map('map').setView([0, 0], 2);
var map = L.map(mapId).setView([0, 0], 2);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6IjZjNmRjNzk3ZmE2MTcwOTEwMGY0MzU3YjUzOWFmNWZhIn0.Y8bhBaUMqFiPrDRW9hieoQ', {
maxZoom: 18,
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
'Imagery © <a href="http://mapbox.com">Mapbox</a>',
id: 'mapbox.streets'
}).addTo(map);
return map;
};
var badgeCounts = function() {
// Badge Counts (after owner selection)
retrieveGroupCount('Adversary');
retrieveGroupCount('Document');
retrieveGroupCount('Email');
retrieveGroupCount('Group');
retrieveGroupCount('Incident');
retrieveIndicatorCount('Indicator');
retrieveGroupCount('Threat');
};
var increaseCount = function(type) {
var pane = $('.nav.navbar-nav li a[href="#' + type + '-pane"] span'),
count = parseInt(pane.text(), 10) + 1;
pane.text(count);
};
var decreaseCount = function(type) {
var pane = $('.nav.navbar-nav li a[href="#' + type + '-pane"] span'),
count = parseInt(pane.text(), 10) - 1;
pane.text(count);
};
var setCount = function(type, count) {
var pane = $('.nav.navbar-nav li a[href="#' + type + '-pane"] span');
pane.text(count);
};
var tableActions = function(params) {
$('#' + params.type.type + '-table')
.on('sort.bs.table', function (e) {
setTimeout(function() {
enableForm(params);
}, 200);
})
.on('page-change.bs.table', function (e, size, number) {
setTimeout(function() {
enableForm(params);
}, 200);
});
};
var enableForm = function(params) {
var type = params.type;
// bcs - need to remove all other save actions first
$('.editable').on('save', function(data, params) {
var name = params.newValue;
// bcs - cleanup
var id = $($($(this))[0]).data('pk');
// c.log('id deal', $($($(this))[0]) );
// c.log('name', name);
// c.log('id', id);
// c.log('type', type);
updateGroup({
type: type,
name: name,
id: id
});
});
};
// var genEditSpan = function(id, name) {
// var iSpan = $('<span></span>')
// .addClass('editName')
// .attr('id', id)
// .text(name);
// return iSpan[0].outerHTML;
// };
var genChart = function(response) {
// chart
var dateArray = [];
var i;
for (i in response.data) {
var indicator = response.data[i],
dateAdded = indicator.dateAdded.split('T')[0],
lastModified = indicator.lastModified.split('T')[0];
if (dateAdded in dateArray) {
dateArray[dateAdded]['da']++;
} else {
dateArray[dateAdded] = {
da: 0,
lm: 0
};
}
if (lastModified in dateArray) {
dateArray[lastModified].lm++;
} else {
dateArray[lastModified] = {
da: 0,
lm: 0
};
}
}
var d,
x = ['x'],
data1 = ['added'],
data2 = ['modified'];
for (d in dateArray) {
var da = 0,
dm = 0;
x.push(d);
if (dateArray[d].da) {
da = dateArray[d].da;
}
if (dateArray[d].lm) {
dm = dateArray[d].lm;
}
data1.push(da);
data2.push(dm);
}
c.log('x', x);
c.log('data1', data1);
c.log('data2', data2);
indicatorChart([x, data1, data2]);
};
var detailView = function() {
$('a.detail-icon').on('click', function(e) {
// event.preventDefault();
var detail = $(this);
// bcs if this
if ($($(e)[0].toElement).hasClass('icon-minus')) {
var idIndex = $(detail.closest('table')).find('[data-field="id"]').index(),
id = $($(detail.closest('tr')).find('td')[idIndex]).text(),
detailViewTd = detail.closest('tr').next().find('td');
detailViewTd.append(
$('<div></div>')
.append($('<div></div>').addClass('panel panel-primary')
.append($('<div>Attributes</div>').addClass('panel-heading'))
.append($('<div></div>')
.addClass('panel panel-body')
.attr('id', 'attribute-panel-' + id))
.append($('<div>Tags</div>').addClass('panel-heading'))
.append($('<div></div>')
.addClass('panel panel-body')
.attr('id', 'tag-panel-' + id))));
retrieveAttributes({
groupType: TYPE.ADVERSARY,
id: id
});
retrieveTags({
groupType: TYPE.ADVERSARY,
id: id
});
}
});
};
var indicatorChart = function(columns) {
var chart = c3.generate({
bindto: '#indicatorChart',
data: {
x: 'x',
columns: columns
},
subchart: {
show: true
},
axis: {
x: {
type: 'timeseries',
tick: {
format: '%Y-%m-%d'
}
}
}
});
};
function manualRequest(params) {
c.groupCollapsed('manualRequest');
// var ro = new RequestObject();
var ro = tc.requestObject();
ro.owner(params.owner)
.done(params.done)
.error(params.error)
.requestUri(params.uri)
.requestMethod(params.method)
.resultLimit(params.resultLimit);
tc.apiRequest(ro);
c.groupEnd();
}
function resourceCounts(uri, pane) {
c.groupCollapsed('resourceCounts');
manualRequest({
owner: $('#Owner-select :selected').text(),
done: function(response) {
c.log('done', response);
setCount(pane, response.data.resultCount);
},
error: function(response) {
var message = 'Manual Retrieval failed. (' + response + ').';
statusAlert('danger', message);
},
uri: uri,
method: 'GET',
resultLimit: 1
});
c.groupEnd();
}
function retrieveIndicatorCount(pane) {
var indicators = tc.indicators();
indicators.owner($('#Owner-select :selected').text())
.resultLimit(1)
.done(function(response) {
setCount(pane, response.resultCount);
})
.error(function(response) {
var message = 'Indicator Retrieval failed. (' + response.error + ').';
statusAlert('danger', message);
}).retrieve();
}
function retrieveGroupCount(pane) {
var groups = tc.groups();
groups.owner($('#Owner-select :selected').text())
.type(TYPE[pane.toUpperCase()])
.resultLimit(1)
.done(function(response) {
setCount(pane, response.resultCount);
})
.error(function(response) {
var message = 'Group Retrieval failed. (' + response.error + ').';
statusAlert('danger', message);
})
.retrieve();
}
</script>
</body>
</html>
<!--
POST:
/v2/indicators/addresses/192.168.0.1/tags/Tracked
POST:
/v2/groups/adversaries/1/tags/newTag
Splunk App:
Source to Destination Map.
Indicators:
https://localhost:8443/api/v2/indicators?filters=summary=lmco.com
https://localhost:8443/api/v2/indicators?filters=rating%3E3
https://localhost:8443/api/v2/indicators/urls?filters=threatAssessConfidence%3E50
https://localhost:8443/api/v2/indicators/addresses?filters=organization=mosso%20hosting
https://localhost:8443/api/v2/indicators/hosts?filters=whoisActive=true
Groups:
https://localhost:8443/api/v2/groups?filters=name%5ETes
https://localhost:8443/api/v2/groups/documents?filters=fileType=PDF
Tags, SecurityLabels, Victims:
https://localhost:8443/api/v2/securityLabels?filters=name=dictators
https://localhost:8443/api/v2/victims?filters=name%5ETes
https://localhost:8443/api/v2/tags?filters=weight%3E2
Multiple Parameters (with implicit AND):
https://localhost:8443/api/v2/indicators?filters=summary=lmco.com,dateAdded%3C20151015
Multiple Parameters (with parameters OR’ed)
https://localhost:8443/api/v2/indicators?filters=summary=lmco.com,dateAdded%3E20151015&orParams=true
< %3C
> %3E
^ %5E
-->