Monday, March 20, 2017

Cyber Security Analyst (Part 3 of 3)

Writing Snort Signatures

This series will cover analyzing the common data types found in cyber security incidents; Netflow,  Domain(s) & IP address(es), PCAP. The format of the posts will be as follows Background information, Concepts & Techniques, Tools, and Recommended reading and/or videos.


Background
Intrusion Detection Systems (IDS) perform network packet inspection for predefined criteria. Its capabilities are to alert and/or collect Packet Capture (PCAP) data related to the predefined criteria.

Overview
For the purpose of this blog we are going to be reviewing the Snort IDS. The information in this blog is design to help people create Snort signatures.

 When creating snort rules remember that you might not have complete inbound/outbound traffic sensor coverage of your network. The longer the duration of PCAP collection the larger the file.  Include documentation on why you are collecting/alerting on the information provided in your signature. Have a set review period for when you will re-evaluate the effectiveness of the signature based on the data collected and its false positive to true positive ratio.

Operators[1]
  • \ - used to indicate the end of a line.
  • Negation "!" - tells Snort to match any IP address except the one indicated by the listed IP address.
  • [] - are used in the "Rules Action" section to define a set.
  • () - the contents inside the parenthesis are the "Rule Options" section.
  • Range ":" - used to define a range of numbers for the rule to take action on. The start of the range goes on the left of the : The end on the right side.
  • Directional "->" - indicates the orientation or direction of the traffic that the rule applies to.
  • BiDirectional "<>" - tells Snort to consider the address/port pairs in either the source or destination orientation.

Basics
  • Most rules are single line.
  • To do multiple line rules use the backslash \ to end the line.
  • Rule are divided into two logical section, "Rule header" and "Rule Options".
  • Rule Header: contains the rule's action, protocol, source and destination IP addresses and netmask, and the source and destination ports information. The text up to the first parenthesis is the rule header.
  • Rule Option: contains alert messages and information on which parts of the packet should be inspected to determine if the rule actions should be taken. The contents enclosed in the parenthesis contains the rule options.
  • (Best Practices) Separate the "Rule header" and "Rule options" onto separate lines making it easier to view both sections.


Rule Components

Rule Header = (Action + Protocol + SourceIP + Source Port) Directional or BiDirectional notation (destIP + destport)

Rule Options = Message + Flow + Reference + Classtype + sid/rev

Snort  Rule equation = Rule Header + Rule Options



Rule Creation Steps

1. Rule action
  • Rule action(s) take effect on one of the supported protocols the user can specify.

  • There are 5 default "Rule Actions" available to in Snort:
  • Alert - generate an alert using the selected alert method, and then log the packet.
  • Log - log the packet.
  • Pass - ignore the packet.
  • Activate-alert and then turn on another dynamic rule.
  • Dynamic - remain idle until activated by an activate rule, then act as a log rule.

2. Protocols
  • After the "Rule Action" is chosen the next field in the rule is the "Protocol"
  • Snort analyzes the following protocols TCP, UDP, ICMP, and IP.

3. IP Address

  • The keyword "any" may be used to define any address.
  • Write IP addresses in numeric four octate format and include a CIDR block. 
  • (i.e. xxx.xxx.xxx.xxx/24)
  • CIDR block indicates the netmask (range of IP addresses) that should be applied to the rule's address and any incoming packets that are tested against the rule.

4. Port Numbers
  • After the "Protocol" is chosen the next field in the rule is the "Port Number".
  • The keyword "any" may be used to define any port number.

5. The Direction Operator
  • Directional -> - indicates the orientation or direction of the traffic that the rule applies to.
  • BiDirectional <> - tells Snort to consider the address/port pairs in either the source or destination orientation.


Detection Options[1]
Content
Allows the user to set rules that search for specific content in the packet payload and trigger response based on that data. Whenever a content option pattern match is performed, the Boyer-Moore pattern match function is called and the (rather computationally expensive) test is performed against the packet contents. If data exactly matching the argument data string is contained anywhere within the packets payload, the test is successful and the remainder of the rule option tests are performed.
Be aware that this test is case sensitive.
Options:
  • nocase
    • Used to specify that the Snort should look for the specific pattern, ignoring case.
  • rawbytes
    • Used to look at the raw packet data, ignoring any decoding that was done by pre-processors.
  • depth
    • Used to specify how far into a packet Snort should search for the specified pattern based on a chosen byte value.
    • only values greater than or equal to the pattern length can be searched. The minimum byte value is 1 and the maximum byte value is 65535.
    • Syntax:
      • depth: [<number>|<var_name>]
  • offset
    • Used to specify where to start searching for a pattern within a packet based on a chosen byte value.
    • The byte ranges from -65535 to 65535.
    • Syntax:
      • offset:[<number>|<var_name>]
  • distance
    • Used to specify how far into a packet Snort should ignore before starting to search for the specified pattern relative to the end of the previous pattern match.
    • syntax:
    • distance:[<byte_count>|<var_name>]
  • within
    • Used to make sure that at most N bytes are between pattern matches using the content keyword.
    • Syntax:
      • within:[<byte_count>|<var_name>]
  • http_client_body
    • Used to restrict the search to the body of an HTTP client request.
    • Syntax:
      • http_client_body


References
1. Snort


Social Media
Facebook:
https://www.facebook.com/BDavisCS/

Twitter:
@BDavis_CyberSec


Friday, March 10, 2017

Social Engineering Toolkit: Credential Harvesting


Overview
The Social Engineering Toolkit (SET) is specifically designed to perform advanced attacks against the human element.[1]


Requirements
For this blog post I used the Kali Linux operating system which comes with SET pre-installed.



Instructions
Launch SET
  • Applications > Exploitation Tools > Social Engineering ToolKit
A. Loading Credential Harvesting
  1. Select: "1) Social-Engineering Attacks" by typing the number 1
  2. Select: "2) Website Attack Vectors" by typing the number 2
  3. Select: "3) Credential Harvester Attack Method" by typing the number 3
  4. Select: "3) Custom Import"  by typing the number 3


 B. Cloning A Website
  1. Open a browser (Any browser will work)
  2. Navigate to the Website Login page you wish to clone. 
  3. Navigate to the File option in your browser.
  4. Change the Name field to index.html (the name is case sensitive)
  5. Change the Save Location to /var/www/html
  6. Change Type to Web Page, Complete
  7. Save
C. Arming the Website
  1. Open a Terminal and type ifconfig
  2. Copy the inet addr: xxx.xxx.xxx.xxx
  3. Paste the inet addr into the terminal running SET
    • set: webattack > IP address for the POST back in Harvester/Tabnabbing: xxx.xxx.xxx.xxx
  4. Type the following file path:
    • /var/www/html
  5. Type the URL of the website you clone.
  6. Type "y" for yes you want to start Apache server. 
D. Testing the Website
If everything was done correctly you'll see an exact clone of the website you cloned. 
  1. Open a browser (on the same machine you used SET on)
  2. Type in your inet addr: xxx.xxx.xxx.xxx into the URL bar.
  3. Hit Enter key

Reference
1. Social Engineering Toolkit

Social Media
Facebook:
https://www.facebook.com/BDavisCS/

Twitter:
@BDavis_CyberSec

OSINT Tool: Recon-ng


How to Use Open Source Intelligence Tool RECON-NG

Overview
"Recon-ng is a full-featured Web Reconnaissance framework written in Python. Complete with independent modules, database interaction, built in convenience functions, interactive help, and command completion, Recon-ng provides a powerful environment in which open source web-based reconnaissance can be conducted quickly and thoroughly." [1]

Recon-ng is a tool used to perform open source intelligence on Domains and IP addresses. It allows you to find sub domains, their relative IP addresses, and perform geographical tagging, etc.


Download
Recon-ng


Syntax
[recon-ng][default] command



Help
To access the help menu type the following command:

  • help
  • example: 
    • [recon-ng][default] help 

Database
Everything this script does is to populate a database which the user creates. This script's database query, creation, and deletion syntax is similar to MySQL.

1. Creating a Database
  • To create a database type the following command:
    • workspaces add
    • example: workspaces add TableName
  • Once you create your table you'll see the following prompt:
    • [recon-ng][TableName]
    • This means your table is ready for use with any of the modules.
2.  Defining Domains
  • After you create a table you have to define a domain for all of the modules to take action on.
  • To add a domain type the following:
    • add domain 
    • [recon-ng][TableName] add domain DomainName
3. Deleting a Table
  • To delete a database type the following command:
    • workspaces delete
    • example: [recon-ng][default] workspaces delete TableName
Modules
To search for Modules follow these steps:
1. Select your table
  • [recon-ng][default] workspaces select TableName
2. Search for Modules
  • Search Syntax:
    • [recon-ng][TableName] load SearchTerm
      • Key search terms: domain, location, reports
3.  Loading a Modular
  • From the list of option you are presented with copy & paste the whole line which contains the FilePath and the ModularName.
    • example: [recon-ng][TableName] load Path&ModularName

Recommended Videos

Reference(s)
1. Tools Kali

Social Media
Facebook:
https://www.facebook.com/BDavisCS/

Twitter:
@BDavis_CyberSec

Wednesday, March 1, 2017

Cyber Security Analyst (Part 2 of 3)

PCAP Data Analysis

This series will cover analyzing the common data types found in cyber security incidents; Netflow,  Domain(s) & IP address(es), PCAP. The format of the posts will be as follows Background information, Concepts & Techniques, Tools, and Recommended reading and/or videos.



The information in this blog is design to help people analyzing PCAP data. There are many programs which can automate the manipulation and organization of PCAP data for the end user. I believe it is always a good idea to know how to perform these task manually because every environment will be different. For the purpose of this blog post we'll be covering the use of open source PCAP analysis tool Wireshark.


Tools
The list tool is a free open source tool for Linux and Windows:



Background
Having a working understanding of the PCAP filters are essential to being able to read PCAP data.

A. Wireshark  Filters [1]
1. HTTP header information
  • Description: used to analyze the packet HTTP header information
  • Syntax:
    • http."option"
    • Commonly used "option(s)"
      • http.user_agent
      • http.response
      • http.connection
  2. TCP session information
  • Description: used to analyze the packet TCP session information
  • Syntax:
    • tcp."option(s)"
    • Commonly used "option(s)"
      • tcp.analysis.flags
      • tcp.flags
      • tcp.srcport
3. SSL connection
  • Description: used to determine if an SSL connection was established.
  • Syntax
    •  
    • Commonly used "option(s)"
      • ssl.handshake
4.  System communications
  • Description: used to determine who the system is trying to communicate with and how often.
  • Syntax:
    • dns."option(s)"."option(s)"
    • Commonly used "option(s)"
      • dns.qry.name
      • dns.resp.addr
      • dns.resp.name
5. Text search
  • Description: used to search for specific text inside of a packet.
  • Syntax:
    • frame contains "text"
    • Common text to search for
      • "Dos"
      • ".exe"



Concepts & Techniques
Two things to look for in PCAP when looking for signs of potential malicious activity are magic numbers and Base64.

A. Magic Numbers [2]
Common in programs across many operating systems. Magic numbers implement strongly typed data and are a form of in-band signaling to the controlling program that reads the data type(s) at program run-times. Detecting such constraints in files is a simple and effective way of distinguishing between many file formats and can yield further run-time information.
  • GIF image file:
    • ASCII cod 
      • "GIF89a" (47 49 46 38 39 61) 
      • "GIF87a" (47 49 46 38 37 61)
  • JPEG image file:
    • Begins with "FF D8" and ends with "FF D9"
  • Postscript file:
    • start with "%!" (25 21)
  • MS-DOS exe file:
    • start with 
      • "MZ" (4D 5A)
      • "ZM" (5A 4D) - is NOT as common
B. Base64 [3]
A group of similar encoding schemes that represent binary data in an ASCII string format by translating it into a Radix-64 representation. Base64 encoding schemes are commonly used when there is a need to encode binary that needs to be stored and transferred over media that are designed to deal with textual data. This is done to ensure that the data remains intact without modification during transport.
  • Characters [A-Z], [a-z],[0-9],[+],[/]
  • Padding: 
    • "==" indicates last group contained only 1 bytes. 
    • "=" indicates that it contained 2 bytes.




References 
  1. Wireshark Filters
  2. Magic Numbers
  3. Base64




Recommended Reading and/or Videos
  • Real Digital Forensics: Computer Security and Incident Response by Keith J. Jones, Richard Bejtlich, and Curtis W. Rose.
  • Extrusion Detection: Security Monitoring for Internal Intrusions by Richard Bejtlich, foreword by Marcus Ranum.
 
Social Media
Facebook:
https://www.facebook.com/BDavisCS/

Twitter:
@BDavis_CyberSec