|
| 1 | +Uploading Files |
| 2 | +=============== |
| 3 | +To upload files for analysis, you need only upload them to the BinaryAlert S3 bucket. The S3 bucket name is of the form |
| 4 | + |
| 5 | +.. code-block:: none |
| 6 | +
|
| 7 | + YOUR.NAME.PREFIX.binaryalert-binaries.REGION |
| 8 | +
|
| 9 | +When uploading to S3, any object metadata you set will be included in all match alerts. In addition, if there is a ``filepath`` metadata key, BinaryAlert will make the filepath :ref:`external-variables` available to the YARA rules. |
| 10 | + |
| 11 | +Uploaded files are persisted indefinitely so that BinaryAlert can retroactively analyze all files with every rule update. The S3 bucket has both `access logging <http://docs.aws.amazon.com/AmazonS3/latest/dev/ServerLogs.html>`_ and `object versioning <http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectVersioning.html>`_ enabled. |
| 12 | + |
| 13 | + |
| 14 | +CarbonBlack Downloader |
| 15 | +---------------------- |
| 16 | +If you use CarbonBlack Enterprise Response, you can enable BinaryAlert's optional downloader Lambda function. The downloader copies files from CarbonBlack into BinaryAlert's S3 bucket (including the appropriate metadata). To enable it: |
| 17 | + |
| 18 | +.. code-block:: none |
| 19 | +
|
| 20 | + $ ./manage.py configure |
| 21 | + AWS Region (us-east-1): |
| 22 | + Unique name prefix, e.g. "company_team": your_unique_prefix |
| 23 | + Enable the CarbonBlack downloader? (no): yes |
| 24 | + CarbonBlack URL: https://your.carbonblack.url |
| 25 | + CarbonBlack API token (only needs binary read access): |
| 26 | +
|
| 27 | +.. warning:: The API token only needs access to read binaries; do not use a token with admin privileges, do not allow other users to share the same token, and be sure to regularly rotate the token. |
| 28 | + |
| 29 | +.. note:: The API token will not be shown on screen and BinaryAlert will create a new KMS key to encrypt the credentials before saving them to the ``terraform.tfvars`` configuration file. The downloader (and no other component) is authorized to decrypt the credentials with the generated key. |
| 30 | + |
| 31 | +Binaries downloaded from CarbonBlack are saved to the BinaryAlert S3 bucket with the key ``carbonblack/MD5`` and with the following metadata: |
| 32 | + |
| 33 | +.. code-block:: python |
| 34 | +
|
| 35 | + [ |
| 36 | + 'carbon_black_group', |
| 37 | + 'carbon_black_host_count', |
| 38 | + 'carbon_black_last_seen', |
| 39 | + 'carbon_black_md5', |
| 40 | + 'carbon_black_os_type', |
| 41 | + 'carbon_black_virustotal_score', |
| 42 | + 'carbon_black_webui_link', |
| 43 | + 'filepath' # from the "observed_filenames" CarbonBlack metadata |
| 44 | + ] |
| 45 | +
|
| 46 | +Once the downloader is enabled, you can either copy everything from CarbonBlack in one go, or you can `deploy <deploying.rst>`_ the downloader components and setup real-time invocations for every new binary. |
| 47 | + |
| 48 | + |
| 49 | +Copy All Files |
| 50 | +.............. |
| 51 | +If you want to run a one-time job to copy every file from CarbonBlack into BinaryAlert: |
| 52 | + |
| 53 | +.. code-block:: bash |
| 54 | +
|
| 55 | + $ ./manage.py cb_copy_all |
| 56 | +
|
| 57 | +This runs *locally*, using multiple threads to enumerate the files in CarbonBlack and copy them over to BinaryAlert. The downloader *code* is used, but there are no Lambda invocations. This means you can copy all of the files from CarbonBlack without actually deploying the downloader components. |
| 58 | + |
| 59 | + |
| 60 | +Real-Time Invocations |
| 61 | +..................... |
| 62 | +To ensure real-time file analysis, we recommend invoking the downloader every time CarbonBlack logs a ``binarystore.file.added`` event. If you use `StreamAlert <https://streamalert.io/>`_ to process CarbonBlack logs, the following `rule <https://streamalert.io/rules.html>`_ will invoke the BinaryAlert downloader for every new binary (assuming BinaryAlert is a properly configured Lambda `output <https://streamalert.io/outputs.html>`_): |
| 63 | + |
| 64 | +.. code-block:: python |
| 65 | +
|
| 66 | + @rule(logs=['carbonblack:binarystore.file.added'], |
| 67 | + matchers=[], |
| 68 | + outputs=['aws-lambda:binaryalert']) |
| 69 | + def cb_binarystore_file_added(rec): |
| 70 | + """ |
| 71 | + description: CarbonBlack found a new binary: forward to BinaryAlert for YARA analysis. |
| 72 | + """ |
| 73 | + return True |
| 74 | +
|
| 75 | +If you don't use StreamAlert, you can invoke the downloader yourself: |
| 76 | + |
| 77 | +.. code-block:: python |
| 78 | +
|
| 79 | + import boto3, json |
| 80 | + boto3.client('lambda').invoke( |
| 81 | + FunctionName='your_prefix_binaryalert_downloader', |
| 82 | + InvocationType='Event', # Asynchronous invocation |
| 83 | + Qualifier='Production', # Invoke production alias |
| 84 | + Payload=json.dumps({'md5': 'FILE_MD5'}).encode('utf-8') |
| 85 | + ) |
0 commit comments