Skip to content

Commit

Permalink
check server response before decode
Browse files Browse the repository at this point in the history
  • Loading branch information
dadokkio authored and jeromeleonard committed Jun 19, 2020
1 parent 0a434a2 commit 9c1fda3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions analyzers/CyberChef/cyberchef.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ def run(self):
data = { "input": observable, "recipe":[{"op":"Regular expression","args":["User defined","([0-9]{2,3}(,\\s|))+",True,True,False,False,False,False,"List matches"]},{"op":"From Charcode","args":["Comma",10]},{"op":"Regular expression","args":["User defined","([0-9]{2,3}(,\\s|))+",True,True,False,False,False,False,"List matches"]},{"op":"From Charcode","args":["Space",10]}]}
headers = { 'Content-Type': 'application/json' }
r = requests.post(url.strip('/') + '/bake', headers=headers, data=json.dumps(data))
output_data = "".join([chr(x) for x in r.json().get('value', [])])
self.report({ 'input_data': observable, 'output_data': output_data })
if r.status_code == 200:
output_data = "".join([chr(x) for x in r.json().get('value', [])])
self.report({ 'input_data': observable, 'output_data': output_data })
else:
self.error('Server responded with %d: %s' % (r.status_code, r.text))
except:
self.error("Could not convert provided data.")

Expand Down

0 comments on commit 9c1fda3

Please sign in to comment.