|
| 1 | +# c42seceventcli - AED |
| 2 | + |
| 3 | +The c42seceventcli AED module contains a CLI tool for extracting AED events as well as an optional state manager |
| 4 | +for recording timestamps. The state manager records timestamps so that on future runs, |
| 5 | +you only extract events you did not previously extract. |
| 6 | + |
| 7 | +## Requirements |
| 8 | + |
| 9 | +- Python 2.7.x or 3.5.0+ |
| 10 | +- Code42 Server 6.8.x+ |
| 11 | + |
| 12 | +## Installation |
| 13 | +Until we are able to put `py42` and `c42secevents` on PyPI, you will need to first install them manually. |
| 14 | + |
| 15 | +`py42` is available for download [here](https://confluence.corp.code42.com/pages/viewpage.action?pageId=61767969#py42%E2%80%93Code42PythonSDK-Downloads). |
| 16 | +For py42 installation instructions, see its [README](https://stash.corp.code42.com/projects/SH/repos/lib_c42_python_sdk/browse/README.md). |
| 17 | + |
| 18 | +`c42secevents` is available [here](https://confluence.corp.code42.com/display/LS/Security+Event+Extractor+-+Python). |
| 19 | +For `c42secevents` installation instructions, see its [README](https://stash.corp.code42.com/projects/INT/repos/security-event-extractor/browse/README.md). |
| 20 | + |
| 21 | +Once you've done that, install `c42seceventcli` using: |
| 22 | + |
| 23 | +```bash |
| 24 | +$ python setup.py install |
| 25 | +``` |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +A simple usage requires you to pass in your Code42 authority URL and username as arguments: |
| 30 | + |
| 31 | +```bash |
| 32 | +c42aed -s https://example.authority.com -u security.admin@example.com |
| 33 | +``` |
| 34 | + |
| 35 | +Another option is to put your Code42 authority URL and username (and other arguments) in a config file. |
| 36 | +Use `default.config.cfg` as an example to make your own config file; it has all the supported arguments. |
| 37 | +The arguments in `default.config.cfg` mirror the CLI arguments. |
| 38 | + |
| 39 | +```buildoutcfg |
| 40 | +[Code42] |
| 41 | +c42_authority_url=https://example.authority.com |
| 42 | +c42_username=user@code42.com |
| 43 | +``` |
| 44 | + |
| 45 | +Then, run the script as follows: |
| 46 | + |
| 47 | +```bash |
| 48 | +c42aed -c path/to/config |
| 49 | +``` |
| 50 | + |
| 51 | +To use the state management service, simply provide the `-r` to the command line. |
| 52 | +`-r` is particularly useful if you wish to run this script on a recurring job: |
| 53 | + |
| 54 | +```bash |
| 55 | +c42aed -s https://example.authority.com -u security.admin@example.com -r |
| 56 | +``` |
| 57 | + |
| 58 | +If you are using a config file with `-c`, set `record_cursor` to True: |
| 59 | + |
| 60 | +```buildoutcfg |
| 61 | +[Code42] |
| 62 | +c42_authority_url=https://example.authority.com |
| 63 | +c42_username=user@code42.com |
| 64 | +record_cursor=True |
| 65 | +``` |
| 66 | +By excluding `-r`, future runs will not know about previous events you got, and |
| 67 | +you will get all the events in the given time range (or default time range of 60 days back). |
| 68 | + |
| 69 | +To clear the cursor: |
| 70 | + |
| 71 | +```bash |
| 72 | +c42aed -s https://example.authority.com -u security.admin@example.com -r --clear-cursor |
| 73 | +``` |
| 74 | +There are two possible output formats. |
| 75 | + |
| 76 | +* CEF |
| 77 | +* JSON |
| 78 | + |
| 79 | +JSON is the default. To use CEF, use `-o CEF`: |
| 80 | + |
| 81 | +```bash |
| 82 | +c42aed -s https://example.authority.com -u security.admin@example.com -o CEF |
| 83 | +``` |
| 84 | + |
| 85 | +Or if you are using a config file with `-c`: |
| 86 | + |
| 87 | +```buildoutcfg |
| 88 | +[Code42] |
| 89 | +c42_authority_url=https://example.authority.com |
| 90 | +c42_username=user@code42.com |
| 91 | +output_format=CEF |
| 92 | +``` |
| 93 | + |
| 94 | +There are three possible destination types to use: |
| 95 | + |
| 96 | +* stdout |
| 97 | +* file - writing to a file |
| 98 | +* server - transmitting to a server, such as syslog |
| 99 | + |
| 100 | +The program defaults to `stdout`. To use a file, use `--dest-type` and `--dest` this way: |
| 101 | + |
| 102 | +```bash |
| 103 | +c42aed -s https://example.authority.com -u security.admin@example.com --dest-type file --dest name-of-file.txt |
| 104 | +``` |
| 105 | + |
| 106 | +To use a server destination (like syslog): |
| 107 | + |
| 108 | +```bash |
| 109 | +c42aed -s https://example.authority.com -u security.admin@example.com --dest-type server --dest https://syslog.example.com |
| 110 | +``` |
| 111 | + |
| 112 | +Both `destination_type` and `destination` are possible fields in the config file as well. |
| 113 | + |
| 114 | +You can also use CLI arguments with config file arguments, but the program will favor the CLI arguments. |
| 115 | + |
| 116 | +If this is your first time running, you will be prompted for your Code42 password. |
| 117 | + |
| 118 | +If you get a keychain error when running this script, you may have to add a code signature: |
| 119 | + |
| 120 | +```bash |
| 121 | +codesign -f -s - $(which python) |
| 122 | +``` |
| 123 | + |
| 124 | +All errors are sent to an error log file named `c42seceventcli_aed_errors.log` |
| 125 | +located in your user directory under `.c42seceventcli/log`. |
| 126 | + |
| 127 | +Full usage: |
| 128 | + |
| 129 | +``` |
| 130 | +usage: c42aed [-h] [--clear-cursor] [--reset-password] [-c CONFIG_FILE] |
| 131 | + [-s C42_AUTHORITY_URL] [-u C42_USERNAME] [-b BEGIN_DATE] [-i] |
| 132 | + [-o {CEF,JSON}] |
| 133 | + [-t [{SharedViaLink,SharedToDomain,ApplicationRead,CloudStorage,RemovableMedia,IsPublic} [{SharedViaLink,SharedToDomain,ApplicationRead,CloudStorage,RemovableMedia,IsPublic} ...]]] |
| 134 | + [-d--debug] [--dest-type {stdout,file,server}] |
| 135 | + [--dest DESTINATION] [--dest-port DESTINATION_PORT] |
| 136 | + [--dest-protocol {TCP,UDP}] [-e END_DATE | -r] |
| 137 | +
|
| 138 | +optional arguments: |
| 139 | + -h, --help show this help message and exit |
| 140 | + --clear-cursor Resets the stored cursor. |
| 141 | + --reset-password Clears stored password and prompts user for password. |
| 142 | + -c CONFIG_FILE, --config-file CONFIG_FILE |
| 143 | + The path to the config file to use for the rest of the |
| 144 | + arguments. |
| 145 | + -s C42_AUTHORITY_URL, --server C42_AUTHORITY_URL |
| 146 | + The full scheme, url and port of the Code42 server. |
| 147 | + -u C42_USERNAME, --username C42_USERNAME |
| 148 | + The username of the Code42 API user. |
| 149 | + -b BEGIN_DATE, --begin BEGIN_DATE |
| 150 | + The beginning of the date range in which to look for |
| 151 | + events, in YYYY-MM-DD UTC format OR a number (number |
| 152 | + of minutes ago). |
| 153 | + -i, --ignore-ssl-errors |
| 154 | + Do not validate the SSL certificates of Code42 |
| 155 | + servers. |
| 156 | + -o {CEF,JSON}, --output-format {CEF,JSON} |
| 157 | + The format used for outputting events. |
| 158 | + -t [{SharedViaLink,SharedToDomain,ApplicationRead,CloudStorage,RemovableMedia,IsPublic} [{SharedViaLink,SharedToDomain,ApplicationRead,CloudStorage,RemovableMedia,IsPublic} ...]], --types [{SharedViaLink,SharedToDomain,ApplicationRead,CloudStorage,RemovableMedia,IsPublic} [{SharedViaLink,SharedToDomain,ApplicationRead,CloudStorage,RemovableMedia,IsPublic} ...]] |
| 159 | + To limit extracted events to those with given exposure |
| 160 | + types. |
| 161 | + -d--debug Turn on debug logging. |
| 162 | + --dest-type {stdout,file,server} |
| 163 | + The type of destination to send output to. |
| 164 | + --dest DESTINATION Either a name of a local file or syslog host address. |
| 165 | + Ignored if destination type is 'stdout'. |
| 166 | + --dest-port DESTINATION_PORT |
| 167 | + Port used when sending logs to server. Ignored if |
| 168 | + destination type is not 'server'. |
| 169 | + --dest-protocol {TCP,UDP} |
| 170 | + Protocol used to send logs to server. Ignored if |
| 171 | + destination type is not 'server'. |
| 172 | + -e END_DATE, --end END_DATE |
| 173 | + The end of the date range in which to look for events, |
| 174 | + in YYYY-MM-DD UTC format OR a number (number of |
| 175 | + minutes ago). |
| 176 | + -r, --record-cursor Only get events that were not previously retrieved. |
| 177 | +``` |
| 178 | + |
| 179 | +# Known Issues |
| 180 | + |
| 181 | +Only the first 10,000 of each set of events containing the exact same insertion timestamp is reported. |
0 commit comments