Sandbox API Integration Examples

Python3

import sys
import requests
import json
import time
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

HEADERS = {
    "User-Agent": "Mozilla/5.0 SorbSecurity Cloud Sandbox 1.0"
}
HOST = "sandbox.sorbsecurity.com"
APIKEY = "44b7a0f2d0bb66fd0ddcfd47169db0b2"
SUBMIT_URL = "https://%s/apineo/%s/tasks/create/file/" % (HOST, APIKEY)
SAMPLE = sys.argv[1]
try:
    FILES  = {'file': open(SAMPLE, 'rb')}
except Exception as e:
    print(str(e))
    print("Error: Failed to load the sample!")
    exit(1)
   
submit_response = requests.post(SUBMIT_URL, verify=False, headers = HEADERS, files = FILES)
TASKID = json.loads(submit_response.text)["task_ids"][0]
STATUS_URL = "https://%s/apineo/%s/tasks/status/%s/" % (HOST, APIKEY, TASKID)

STATUS = "progress"
while STATUS == "progress":
    status_response = requests.get(STATUS_URL, allow_redirects=True, verify=False, headers = HEADERS)
    if "reported" in str(status_response.text):
        STATUS = "reported"
    time.sleep(10)

REPORT_URL = "https://%s/apineo/%s/tasks/get/simple_report/%s/" % (HOST, APIKEY, TASKID)
report_response = requests.get(REPORT_URL, allow_redirects=True, verify=False, headers = HEADERS)
print(json.loads(report_response.text)["malscore"])