-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from knightsc/tasks/modularize-sandbox-support
Modularize sandbox support
- Loading branch information
Showing
9 changed files
with
123 additions
and
79 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
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,25 @@ | ||
Sandboxes | ||
========= | ||
|
||
There are a few sandboxes that can be configured and used in various post process steps. | ||
|
||
There are a few generic options for each input. | ||
|
||
- **enabled**: This turns the sandbox on and off. | ||
- **module**: This is used internally by pastehunter. | ||
|
||
Cuckoo | ||
------ | ||
|
||
If the samples match a binary file format you can optionaly send the file for analysis by a Cuckoo Sandbox. | ||
|
||
- **api_host**: IP or hostname for a Cuckoo API endpoint. | ||
- **api_port**: Port number for a Cuckoo API endpoint. | ||
|
||
Viper | ||
----- | ||
|
||
If the samples match a binary file format you can optionaly send the file to a Viper instance for further analysis. | ||
|
||
- **api_host**: IP or hostname for a Viper API endpoint. | ||
- **api_port**: Port number for a Viper API endpoint. |
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
Empty file.
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,36 @@ | ||
import io | ||
import logging | ||
import requests | ||
from common import parse_config | ||
conf = parse_config() | ||
|
||
logger = logging.getLogger('pastehunter') | ||
|
||
def upload_file(raw_file, paste_object): | ||
try: | ||
task_id = send_to_cuckoo(raw_file, paste_object["pasteid"]) | ||
paste_object["Cuckoo Task ID"] = task_id | ||
logger.info("exe submitted to Cuckoo with task id {0}".format(task_id)) | ||
except Exception as e: | ||
logger.error("Unabled to submit sample to cuckoo") | ||
|
||
# Send any updated json back | ||
return paste_object | ||
|
||
def send_to_cuckoo(raw_exe, pasteid): | ||
cuckoo_ip = conf["sandboxes"]["cuckoo"]["api_host"] | ||
cuckoo_port = conf["sandboxes"]["cuckoo"]["api_port"] | ||
cuckoo_host = 'http://{0}:{1}'.format(cuckoo_ip, cuckoo_port) | ||
submit_file_url = '{0}/tasks/create/file'.format(cuckoo_host) | ||
files = {'file': ('{0}.exe'.format(pasteid), io.BytesIO(raw_exe))} | ||
submit_file = requests.post(submit_file_url, files=files).json() | ||
task_id = None | ||
try: | ||
task_id = submit_file['task_id'] | ||
except KeyError: | ||
try: | ||
task_id = submit_file['task_ids'][0] | ||
except KeyError: | ||
logger.error(submit_file) | ||
|
||
return task_id |
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,19 @@ | ||
import io | ||
import logging | ||
import requests | ||
from common import parse_config | ||
conf = parse_config() | ||
|
||
logger = logging.getLogger('pastehunter') | ||
|
||
def upload_file(raw_file, paste_object): | ||
viper_ip = conf["sandboxes"]["viper"]["api_host"] | ||
viper_port = conf["sandboxes"]["viper"]["api_port"] | ||
viper_host = 'http://{0}:{1}'.format(viper_ip, viper_port) | ||
|
||
submit_file_url = '{0}/tasks/create/file'.format(viper_host) | ||
files = {'file': ('{0}.exe'.format(paste_object["pasteid"]), io.BytesIO(raw_file))} | ||
submit_file = requests.post(submit_file_url, files=files).json() | ||
|
||
# Send any updated json back | ||
return paste_object |
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