Skip to content

Commit cf3190f

Browse files
authored
remove nc/powershell examples and replace with send-to in docs/readme (#151)
1 parent 6c2510d commit cf3190f

File tree

3 files changed

+11
-29
lines changed

3 files changed

+11
-29
lines changed

README.md

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -132,37 +132,19 @@ To write events to a file, just redirect your output:
132132
code42 security-data search -b 2020-02-02 > filename.txt
133133
```
134134

135-
To send events to an external server using `netcat` on Linux/Mac:
135+
To send events to an external server, use the `send-to` command, which behaves exactly the same as `search` but sends
136+
results to an external server instead of to stdout:
136137

137-
UDP:
138-
```bash
139-
code42 security-data search -b 10d | nc -u syslog.company.com 514
140-
```
138+
The default port (if none is specified on the address) is the standard syslog port 514, and default protocol is UDP:
141139

142-
TCP:
143140
```bash
144-
code42 security-data search -b 10d | nc server.company.com 8080
141+
code42 security-data send-to 10.10.10.42 -b 1d
145142
```
146143

147-
Using `powershell` on Windows:
144+
Results can also be sent over TCP to any port by using the `-p/--protocol` flag and adding a port to the address argument:
148145

149-
UDP:
150-
```powershell
151-
# set up connection
152-
$Connection = New-Object System.Net.Sockets.UDPClient("syslog.company.com",514)
153-
154-
# pipe code42 output through connection
155-
code42 security-data search -b 10d | foreach {$Message = [Text.Encoding]::UTF8.GetBytes($_); $Connection.Send($Message, $Message.Length)}
156-
```
157-
158-
TCP:
159-
```powershell
160-
# set up connection
161-
$Connection = New-Object System.Net.Sockets.TcpClient("127.0.0.1","65432")
162-
$Writer = New-Object System.IO.StreamWriter($Connection.GetStream())
163-
164-
# pipe code42 output through connection
165-
code42 security-data search -b 10d | foreach { $Writer.WriteLine($_); $Writer.Flush() }
146+
```bash
147+
code42 security-data send-to 10.10.10.42:8080 -p TCP -b 1d
166148
```
167149

168150
Note: For more complex requirements when sending to an external server (SSL, special formatting, etc.), use a dedicated

docs/userguides/siemexample.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ scheduled job or run ad-hoc queries. Learn more about [searching](../commands/se
2020
### Run a query as a scheduled job
2121

2222
Use your favorite scheduling tool, such as cron or Windows Task Scheduler, to run a query on a regular basis. Specify
23-
the profile to use by including `--profile`. An example using `netcat` to forward only the new file event data since the previous request to an external syslog server:
23+
the profile to use by including `--profile`. An example using the `send-to` command to forward only the new file event data since the previous request to an external syslog server:
2424
```bash
25-
code42 security-data search --profile profile1 -c syslog_sender | nc syslog.example.com 514
25+
code42 security-data send-to syslog.example.com:514 -p UDP --profile profile1 -c syslog_sender
2626
```
2727

2828
An example to send to the syslog server only the new alerts that meet the filter criteria since the previous request:
2929
```bash
30-
code42 alerts send-to "https://syslog.example.com:514" -p UDP --profile profile1 --rule-name “Source code exfiltration” --state OPEN -i
30+
code42 alerts send-to syslog.example.com:514 -p UDP --profile profile1 --rule-name “Source code exfiltration” --state OPEN -i
3131
```
3232

3333
As a best practice, use a separate profile when executing a scheduled task. Using separate profiles can help prevent accidental updates to your stored checkpoints, for example, by adding `--use-checkpoint` to adhoc queries.

src/code42cli/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def server_options(f):
163163
"--protocol",
164164
type=click.Choice(ServerProtocol(), case_sensitive=False),
165165
default=ServerProtocol.UDP,
166-
help="Protocol used to send logs to server.",
166+
help="Protocol used to send logs to server. Defaults to UDP",
167167
)
168168
f = hostname_arg(f)
169169
f = protocol_option(f)

0 commit comments

Comments
 (0)