Download a File from Element Details Screen

Sometimes, in the course of your analysis or hunting, you find a file that you would like to investigate or run in a sandbox environment to see what the file does. In this case, Cybereason allows you to safely download the file using the API and use it in your own environment as needed.

This task takes multiple requests to perform the actual download of the file.

Step 1: Find the GUID for the file to download

Each file is uniquely identified by the Cybereason platform using a GUID. To download these files, you will need to tell the Cybereason platform the GUIDs for the file.

You can find these GUIDs in a number of places:

  • When you select a file from the list of results in the Investigation screen, the URL bar of your browser window shows the GUID:

    The GUID for a results in the Investigation screen.

  • Results obtained from the API also contain a separate object organized by the GUID assigned to the file:

    The GUID for a results in the Investigation screen.

Note this GUID number to use in the request to start the download.

Step 2: Build the request to start the download

The first step to download the file is to build a request to start the download process. As part of this request, you must specify the GUIDs of the items to download.

Create the relevant cURL command, REST API client request body example, or Python script. In this example, we are using a stand-in address for a Cybereason server (myserver.com). If you use this request, replace this address with your actual server address.

All Python examples are formatted for Python version 3.0 and higher, up to the latest Python version. If you are using versions of Python earlier than 3.0, ensure you manually remove parentheses for the print statements in this sample. For example, the print (response.content) statement updates to print response.content.

curl --request POST \
  --url https://myserver.com/rest/fetchfile/start \
  --header 'Content-Type: application/json' \
  --data '{
                    "elementGuids":["<element GUID>"],
            "initiatorUserName":"<user name>"
          }'

Step 3: Run the first request and evaluate the response

In the command line, REST API client, or IDE, run the command or script containing the request. The response returns details on the success of the request:

{
  "data":true,
  "status":"SUCCESS",
  "message":""
}

Ensure the status field returns SUCCESS. If it does not, you should investigate what is happening on your server to see why the file will not download.

Step 4: Build the request to get the download batch number

After you have started the download operation, run another request to get the batch number for the download operation. You will run a third request using this batch number to actually download the file.

Create the relevant cURL command, REST API client request body example, or Python script. In this example, we are using a stand-in address for a Cybereason server (myserver.com). If you use this request, replace this address with your actual server address.

All Python examples are formatted for Python version 3.0 and higher, up to the latest Python version. If you are using versions of Python earlier than 3.0, ensure you manually remove parentheses for the print statements in this sample. For example, the print (response.content) statement updates to print response.content.

curl --request GET \
  --url https://myserver.com/rest/fetchfile/downloads/progress \
  --header 'Content-Type: application/json' \

Step 5: Run the second request and evaluate the response

In the command line, REST API client, or IDE, run the command or script containing the request.

The response contains a large amount of data. However, the key field in the response is the batchId field. You need this number to actually download the file.

  {
              "data":[
                      {
                        "@class":"com.cybereason.commads.FetchFileActionProgress",
                        "batchId":675769080,
                        "actionType":"FetchFile",
                        "initiatorUserName":"[email protected]",
                        "sizeInBytes":477696,
                        "fileName":"powershell.exe",
                        "machineName":"desktop-vpg2hip",
                        "hash":"1d7634765bcf3050d6272cba514bdb1495bad329",
                        "startTime":1576697965843,
                        "actionStatus":"NONE",
                        "timeout":false,
                        "pending":false,
                        "inProgress":false,
                        "failed":true,
                        "succeeded":false
                      }
                     ]
}

Step 6: Build the request to download the file

With the batch ID number, you can now download the file to your machine. Create the relevant cURL command, REST API client request body example, or Python script. In this example, we are using a stand-in address for a Cybereason server (myserver.com). If you use this request, replace this address with your actual server address.

All Python examples are formatted for Python version 3.0 and higher, up to the latest Python version. If you are using versions of Python earlier than 3.0, ensure you manually remove parentheses for the print statements in this sample. For example, the print (response.content) statement updates to print response.content.

curl --request GET \
  --url https://myserver.com/rest/fetchfile/getfiles/:batchId \
  --header 'Content-Type: application/json' \

Step 7: Run the final request and evaluate the response

Similiar to the request to start the download operation, you will receive a status message in the response.

{
  "data":true,
  "status":"SUCCESS",
  "message":""
}

Ensure that the status field reports SUCCESS. In addition, the file will download to your default downloads folder in a .zip file. Inside the zip file are instructions on how to open the downloaded file.