Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes status_code 503 error caused by Cloudflare #861

Merged
merged 3 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions analyzers/TalosReputation/TalosReputation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python3
# encoding: utf-8

import requests
import cloudscraper
from cortexutils.analyzer import Analyzer
import json


class TalosReputation(Analyzer):

Expand All @@ -12,7 +12,7 @@ def __init__(self):

def summary(self, raw):
taxonomies = []
level = 'info' #If there's a change of naming, will be presented as info
level = 'info' # If there's a change of naming, will be presented as info
namespace = 'Talos'
predicate = 'Reputation'
value = raw.get('email_score_name')
Expand All @@ -31,29 +31,28 @@ def run(self):
try:
data = self.get_data()

s = requests.Session()
s.get('https://talosintelligence.com/reputation_center/lookup?search={}'.format(data))
scraper = cloudscraper.CloudScraper()

headers={
'Host':'talosintelligence.com',
'Referer':'https://talosintelligence.com/reputation_center/lookup?search={}'.format(data),
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36',
'Accept':'application/json'
headers = {
'Host': 'talosintelligence.com',
'Referer': 'https://talosintelligence.com/reputation_center/lookup?search={}'.format(data),
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36',
'Accept': 'application/json'
}

response_details = s.get('https://talosintelligence.com/sb_api/query_lookup',
response_details = scraper.get('https://talosintelligence.com/sb_api/query_lookup',
headers = headers,
params = {
'query':'/api/v2/details/ip/',
'query_entry':data
'query': '/api/v2/details/ip/',
'query_entry': data
}
)

response_location = s.get('https://talosintelligence.com/sb_api/query_lookup',
response_location = scraper.get('https://talosintelligence.com/sb_api/query_lookup',
headers = headers,
params = {
'query':'/api/v2/location/ip/',
'query_entry':data
'query': '/api/v2/location/ip/',
'query_entry': data
}
)

Expand All @@ -69,7 +68,8 @@ def run(self):
except Exception as e:
self.unexpectedError(e)
else:
self.notSupported()
self.notSupported()


if __name__ == '__main__':
TalosReputation().run()
2 changes: 1 addition & 1 deletion analyzers/TalosReputation/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cortexutils
requests
cloudscraper