Skip to content

Commit

Permalink
Merge pull request #285 from ninoseki/feature/urlhaus-analyzer
Browse files Browse the repository at this point in the history
Feature/urlhaus analyzer
  • Loading branch information
3c7 authored Jul 2, 2018
2 parents cc8acc0 + 10d130a commit ba2a8fe
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 9 deletions.
2 changes: 1 addition & 1 deletion analyzers/URLhaus/URLhaus.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"type": "number",
"multi": false,
"required": true,
"defaultValue": 3600
"defaultValue": 300
},
{
"name": "cache.root",
Expand Down
14 changes: 7 additions & 7 deletions analyzers/URLhaus/URLhaus.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from bs4 import BeautifulSoup
from diskcache import Cache
from requests_html import HTML
import requests


Expand All @@ -16,7 +16,7 @@ class URLhaus:

def __init__(self,
query,
cache_duration=3600,
cache_duration=300,
cache_root="/tmp/cortex/URLhaus"):
self.URL = "https://urlhaus.abuse.ch/browse.php"
self.query = query
Expand Down Expand Up @@ -47,15 +47,15 @@ def fetch(self):

def parse(self, doc):
results = []
html = HTML(html=doc)
table = html.find("table.table", first=True)
rows = table.find("tr")[1:]
soup = BeautifulSoup(doc, "html.parser")
table = soup.find("table", class_="table")
rows = table.find_all("tr")[1:]
for row in rows:
cols = row.find("td")
cols = row.find_all("td")
results.append({
"dateadded": cols[0].text,
"malware_url": cols[1].text,
"link": cols[1].find("a", first=True).attrs.get("href"),
"link": cols[1].find("a").attrs.get("href"),
"status": cols[2].text,
"tags": cols[3].text.split(),
"gsb": cols[4].text,
Expand Down
2 changes: 1 addition & 1 deletion analyzers/URLhaus/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
beautifulsoup4
cortexutils
diskcache
requests
requests-html
51 changes: 51 additions & 0 deletions thehive-templates/URLhaus_0_1_0/long.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<div class="panel panel-info" ng-if="success">
<div class="panel-heading">
URLhaus search resutls for
<strong>{{artifact.data}}</strong>
</div>
<div class="panel-body">
<p ng-if="content.results.length == 0">
No result found.
</p>
<table class="table" ng-if="content.results">
<thead>
<th>Dateadded (UTC)</th>
<th>Malware URL</th>
<th>Status</th>
<th>Tags</th>
<th>GSB</th>
<th>Reporter</th>
</thead>
<tbody ng-repeat="r in content.results">
<tr>
<td>{{r.dateadded}}</td>
<td>
<a href="https://urlhaus.abuse.ch{{r.link}}" target=”_blank”>
{{r.malware_url}}
</a>
</td>
<td>{{r.status}}</td>
<td>
<span ng-repeat="tag in r.tags"> {{tag}} </span>
</td>
<td>{{r.gsb}}</td>
<td>{{r.reporter}}</td>
</tr>
</tbody>
</table>
</div>
</div>

<!-- General error -->
<div class="panel panel-danger" ng-if="!success">
<div class="panel-heading">
<strong>{{artifact.data | fang}}</strong>
</div>
<div class="panel-body">
<dl class="dl-horizontal" ng-if="content.errorMessage">
<dt>
<i class="fa fa-warning"></i> urlscan.io: </dt>
<dd class="wrap">{{content.errorMessage}}</dd>
</dl>
</div>
</div>
3 changes: 3 additions & 0 deletions thehive-templates/URLhaus_0_1_0/short.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<span class="label" ng-repeat="t in content.taxonomies" ng-class="{'info': 'label-info', 'safe': 'label-success', 'suspicious': 'label-warning', 'malicious':'label-danger'}[t.level]">
{{t.namespace}}:{{t.predicate}}={{t.value}}
</span>

0 comments on commit ba2a8fe

Please sign in to comment.