Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add new feed ip reputation Alienvault * add otx alienvault * change timedelta and try catch logical * change dict * rm otx_alienvault * rm debug strings * rm debug strings and resolve conflict * change except statements * add docstrings
- Loading branch information
Showing
2 changed files
with
62 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import logging | ||
from datetime import timedelta | ||
|
||
from core import Feed | ||
from core.errors import ObservableValidationError | ||
from core.observables import Ip | ||
|
||
|
||
class AlienVaultIPReputation(Feed): | ||
default_values = { | ||
"frequency": | ||
timedelta(hours=4), | ||
"name": | ||
"AlienVaultIPReputation", | ||
"source": | ||
"http://reputation.alienvault.com/reputation.data", | ||
"description": | ||
"Reputation IP generated by Alienvault", | ||
} | ||
|
||
def update(self): | ||
for line in self.update_csv(delimiter='#', quotechar=None): | ||
self.analyze(line) | ||
|
||
def analyze(self, item): | ||
|
||
if not item: | ||
return | ||
try: | ||
context = dict(source=self.name) | ||
|
||
ip_str = item[0] | ||
category = item[3] | ||
country = item[4] | ||
ip = None | ||
try: | ||
ip = Ip.get_or_create(value=ip_str) | ||
except ObservableValidationError as e: | ||
logging.error(e) | ||
return False | ||
|
||
ip.add_source('feed') | ||
|
||
context['country'] = country | ||
context['threat'] = category | ||
|
||
ip.tag(category) | ||
ip.add_context(context) | ||
|
||
except Exception as e: | ||
logging.error('Error to process the item %s %s' % (item, e)) | ||
return False | ||
return True |