Browse Source

Update, added some ATT&CK stuff for linux/osx

pull/8/head
root 5 years ago
parent
commit
9b51e1c68b
50 changed files with 4735 additions and 699 deletions
  1. +104
    -0
      Draft/ATT&CK-Stuff/Linux/Linux Collection.md
  2. +253
    -0
      Draft/ATT&CK-Stuff/Linux/Linux Command and Control.md
  3. +220
    -0
      Draft/ATT&CK-Stuff/Linux/Linux Credential Access.md
  4. +387
    -0
      Draft/ATT&CK-Stuff/Linux/Linux Defense Evasion.md
  5. +0
    -0
      Draft/ATT&CK-Stuff/Linux/Linux Discovery.md
  6. +153
    -0
      Draft/ATT&CK-Stuff/Linux/Linux Execution.md
  7. +91
    -0
      Draft/ATT&CK-Stuff/Linux/Linux Exfiltration.md
  8. +100
    -0
      Draft/ATT&CK-Stuff/Linux/Linux Lateral Movement.md
  9. +199
    -0
      Draft/ATT&CK-Stuff/Linux/Linux Persistence.md
  10. +130
    -0
      Draft/ATT&CK-Stuff/Linux/Linux Privilege Escalation.md
  11. +92
    -0
      Draft/ATT&CK-Stuff/OS X/Mac Collection.md
  12. +247
    -0
      Draft/ATT&CK-Stuff/OS X/Mac Command and Control.md
  13. +275
    -0
      Draft/ATT&CK-Stuff/OS X/Mac Credential Access.md
  14. +414
    -0
      Draft/ATT&CK-Stuff/OS X/Mac Defense Evasion.md
  15. +214
    -0
      Draft/ATT&CK-Stuff/OS X/Mac Discovery.md
  16. +155
    -0
      Draft/ATT&CK-Stuff/OS X/Mac Execution.md
  17. +131
    -0
      Draft/ATT&CK-Stuff/OS X/Mac Exfiltration.md
  18. +138
    -0
      Draft/ATT&CK-Stuff/OS X/Mac Lateral Movement.md
  19. +358
    -0
      Draft/ATT&CK-Stuff/OS X/Mac Persistence.md
  20. +137
    -0
      Draft/ATT&CK-Stuff/OS X/Mac Privilege Escalation.md
  21. +19
    -0
      Draft/ATT&CK-Stuff/Windows/Windows_Collection.md
  22. +5
    -3
      Draft/ATT&CK-Stuff/Windows/Windows_Credential_Access.md
  23. +0
    -11
      Draft/ATT&CK-Stuff/Windows/Windows_Defense_Evasion.md
  24. +63
    -1
      Draft/AnonOpsecPrivacy.md
  25. +5
    -8
      Draft/Building A Pentest Lab.md
  26. +27
    -11
      Draft/CTFs_Wargames.md
  27. +5
    -1
      Draft/Conferences.md
  28. +15
    -1
      Draft/Cryptography & Encryption.md
  29. +28
    -2
      Draft/Defense.md
  30. +11
    -0
      Draft/Exfiltration.md
  31. +51
    -26
      Draft/Exploit Development.md
  32. +10
    -2
      Draft/Forensics Incident Response.md
  33. +26
    -7
      Draft/Game Hacking.md
  34. +8
    -0
      Draft/Interesting Things Useful stuff.md
  35. +2
    -1
      Draft/Malware.md
  36. +21
    -15
      Draft/Network Attacks & Defenses.md
  37. +3
    -1
      Draft/Open Source Intelligence.md
  38. +45
    -8
      Draft/Phishing.md
  39. +2
    -0
      Draft/Policy-Compliance.md
  40. +26
    -17
      Draft/Port_List.md
  41. +113
    -59
      Draft/Privilege Escalation & Post-Exploitation.md
  42. +26
    -4
      Draft/Programming - Languages Libs Courses References.md
  43. +6
    -0
      Draft/Red-Teaming.md
  44. +29
    -0
      Draft/Reverse Engineering.md
  45. +9
    -0
      Draft/Rootkits.md
  46. +5
    -0
      Draft/System Internals Windows and Linux Internals Reference.md
  47. +108
    -34
      Draft/Web & Browsers.md
  48. +21
    -1
      Draft/Wireless Networks & RF.md
  49. +232
    -483
      Draft/things-added.md
  50. +16
    -3
      README.md

+ 104
- 0
Draft/ATT&CK-Stuff/Linux/Linux Collection.md View File

@ -0,0 +1,104 @@
## Linux Collection
-------------------------------
## Automated Collection
[Automated Collection - ATT&CK](https://attack.mitre.org/wiki/Technique/T1119)
* Once established within a system or network, an adversary may use automated techniques for collecting internal data. Methods for performing this technique could include use of Scripting to search for and copy information fitting set criteria such as file type, location, or name at specific time intervals. This functionality could also be built into remote access tools.
[LaZagne](https://github.com/AlessandroZ/LaZagne/blob/master/README.md)
* The LaZagne project is an open source application used to retrieve lots of passwords stored on a local computer. Each software stores its passwords using different techniques (plaintext, APIs, custom algorithms, databases, etc.). This tool has been developed for the purpose of finding these passwords for the most commonly-used software.
-------------------------------
## Clipboard Data
[Clipboard Data - ATT&CK](https://attack.mitre.org/wiki/Technique/T1115)
* Adversaries may collect data stored in the clipboard from users copying information within or between applications.
[Access Unix Clipboard - StackOverflow](https://unix.stackexchange.com/questions/44204/access-unix-clipboard)
* If xclip is available: [Accessing clipboard in Linux terminal](http://www.nurkiewicz.com/2012/09/accessing-clipboard-in-linux-terminal.html)
-------------------------------
## Data Staged
[Data Staged - ATT&CK](https://attack.mitre.org/wiki/Technique/T1074)
* Collected data is staged in a central location or directory prior to Exfiltration. Data may be kept in separate files or combined into one file through techniques such as Data Compressed or Data Encrypted.
-------------------------------
## Data from Local System
[Data from Local System - ATT&CK](https://attack.mitre.org/wiki/Technique/T1005)
* Sensitive data can be collected from local system sources, such as the file system or databases of information residing on the system prior to Exfiltration.
* /etc/passwd : Contains local Linux users.
* /etc/shadow : Contains local account password hashes.
* /etc/group : Contains local account groups.
* /etc/init.d/ : Contains service init script - worth a look to see whats installed.
* /etc/hostname : System hostname.
* /etc/network/interfaces : Network interfaces.
* /etc/resolv.conf : System DNS servers.
* /etc/profile : System environment variables.
* ~/.ssh/ : SSH keys.
* ~/.bash_history : Users bash history log.
* /var/log/ : Linux system log files are typically stored here.
* /var/adm/ : UNIX system log files are typically stored here.
* /var/log/apache2/access.log & /var/log/httpd/access.log : Apache access log file typical path.
* /etc/fstab : File system mounts.
* [From: highoncoffee](https://highon.coffee/blog/linux-commands-cheat-sheet/#linux-interesting-files--dirs)
-------------------------------
## Data from Network Shared Drive
[Data from Network Shared Drive](https://attack.mitre.org/wiki/Technique/T1039)
* ensitive data can be collected from remote systems via shared network drives (host shared directory, network file server, etc.) that are accessible from the current system prior to Exfiltration. Adversaries may search network shares on computers they have compromised to find files of interest. Interactive command shells may be in use, and common functionality within cmd may be used to gather information.
-------------------------------
## Data from Removable Media
[Data from Removable Media - ATT&CK](https://attack.mitre.org/wiki/Technique/T1025)
* Sensitive data can be collected from any removable media (optical disk drive, USB memory, etc.) connected to the compromised system prior to Exfiltration.
-------------------------------
## Input Capture
[Input Capture - ATT&CK](https://attack.mitre.org/wiki/Technique/T1056)
* Adversaries can use methods of capturing user input for obtaining credentials for Valid Accounts and information Collection that include keylogging and user input field interception.
* Keylogging is the most prevalent type of input capture, with many different ways of intercepting keystrokes,1 but other methods exist to target information for specific purposes, such as performing a UAC prompt or wrapping the Windows default credential provider.2
* Keylogging is likely to be used to acquire credentials for new access opportunities when Credential Dumping efforts are not effective, and may require an adversary to remain passive on a system for a period of time before an opportunity arises.
* Adversaries may also install code on externally facing portals, such as a VPN login page, to capture and transmit credentials of users who attempt to log into the service. This variation on input capture may be conducted post-compromise using legitimate administrative access as a backup measure to maintain network access through External Remote Services and Valid Accounts or as part of the initial compromise by exploitation of the externally facing web service.3
-------------------------------
## Screen Capture
[Screen Capture - ATT&CK](https://attack.mitre.org/wiki/Technique/T1113)
* Adversaries may attempt to take screen captures of the desktop to gather information over the course of an operation. Screen capturing functionality may be included as a feature of a remote access tool used in post-compromise operations.
* On Linux, there is the native command xwd.

+ 253
- 0
Draft/ATT&CK-Stuff/Linux/Linux Command and Control.md View File

@ -0,0 +1,253 @@
## Linux Command and Control
-------------------------------
## Commonly Used Port
[Commonly Used Port - ATT&CK](https://attack.mitre.org/wiki/Technique/T1043)
-------------------------------
## Communication Through Removable Media
[Communication Through Removable Media](https://attack.mitre.org/wiki/Technique/T1092)
* Adversaries can perform command and control between compromised hosts on potentially disconnected networks using removable media to transfer commands from system to system. Both systems would need to be compromised, with the likelihood that an Internet-connected system was compromised first and the second through lateral movement by Replication Through Removable Media. Commands and files would be relayed from the disconnected system to the Internet-connected system to which the adversary has direct access.
-------------------------------
## Connection Proxy
[Connection Proxy - ATT&CK](https://attack.mitre.org/wiki/Technique/T1090)
* A connection proxy is used to direct network traffic between systems or act as an intermediary for network communications. Many tools exist that enable traffic redirection through proxies or port redirection, including HTRAN, ZXProxy, and ZXPortMap.
* The definition of a proxy can also be expanded out to encompass trust relationships between networks in peer-to-peer, mesh, or trusted connections between networks consisting of hosts or systems that regularly communicate with each other.
* The network may be within a single organization or across organizations with trust relationships. Adversaries could use these types of relationships to manage command and control communications, to reduce the number of simultaneous outbound network connections, to provide resiliency in the face of connection loss, or to ride over existing trusted communications paths between victims to avoid suspicion.
-------------------------------
## Custom Command and Control Protocol
[Custom Command and Control Protocol - ATT&CK](https://attack.mitre.org/wiki/Technique/T1094)
* Adversaries may communicate using a custom command and control protocol instead of using existing Standard Application Layer Protocol to encapsulate commands. Implementations could mimic well-known protocols.
-------------------------------
## Custom Cryptographic Protocol
[Custom Cryptographic Protocol - ATT&CK](https://attack.mitre.org/wiki/Technique/T1024)
* Adversaries may use a custom cryptographic protocol or algorithm to hide command and control traffic. A simple scheme, such as XOR-ing the plaintext with a fixed key, will produce a very weak ciphertext.
* Custom encryption schemes may vary in sophistication. Analysis and reverse engineering of malware samples may be enough to discover the algorithm and encryption key used.
* Some adversaries may also attempt to implement their own version of a well-known cryptographic algorithm instead of using a known implementation library, which may lead to unintentional errors.
-------------------------------
## Data Encoding
[Data Encoding - ATT&CK](https://attack.mitre.org/wiki/Technique/T1132)
* Command and control (C2) information is encoded using a standard data encoding system. Use of data encoding may be to adhere to existing protocol specifications and includes use of ASCII, Unicode, Base64, MIME, UTF-8, or other binary-to-text and character encoding systems. Some data encoding systems may also result in data compression, such as gzip.
-------------------------------
## Data Obfuscation
[Data Obfuscation - ATT&CK](https://attack.mitre.org/wiki/Technique/T1001)
* Command and control (C2) communications are hidden (but not necessarily encrypted) in an attempt to make the content more difficult to discover or decipher and to make the communication less conspicuous and hide commands from being seen. This encompasses many methods, such as adding junk data to protocol traffic, using steganography, commingling legitimate traffic with C2 communications traffic, or using a non-standard data encoding system, such as a modified Base64 encoding for the message body of an HTTP request.
-------------------------------
## Fallback Channels
[Fallback Channels - ATT&CK](https://attack.mitre.org/wiki/Technique/T1008)
* Adversaries may use fallback or alternate communication channels if the primary channel is compromised or inaccessible in order to maintain reliable command and control and to avoid data transfer thresholds.
-------------------------------
## Multi-Stage Channels
[Multi-Stage Channels - ATT&CK](https://attack.mitre.org/wiki/Technique/T1104)
* Adversaries may create multiple stages for command and control that are employed under different conditions or for certain functions. Use of multiple stages may obfuscate the command and control channel to make detection more difficult.
* Remote access tools will call back to the first-stage command and control server for instructions. The first stage may have automated capabilities to collect basic host information, update tools, and upload additional files. A second remote access tool (RAT) could be uploaded at that point to redirect the host to the second-stage command and control server. The second stage will likely be more fully featured and allow the adversary to interact with the system through a reverse shell and additional RAT features.
* The different stages will likely be hosted separately with no overlapping infrastructure. The loader may also have backup first-stage callbacks or Fallback Channels in case the original first-stage communication path is discovered and blocked.
-------------------------------
## Multiband Communication
[Multiband Communication - ATT&CK](https://attack.mitre.org/wiki/Technique/T1026)
* Some adversaries may split communications between different protocols. There could be one protocol for inbound command and control and another for outbound data, allowing it to bypass certain firewall restrictions. The split could also be random to simply avoid data threshold alerts on any one communication.
-------------------------------
## Multilayer Encryption
[Multilayer Encryption - ATT&CK](https://attack.mitre.org/wiki/Technique/T1079)
* An adversary performs C2 communications using multiple layers of encryption, typically (but not exclusively) tunneling a custom encryption scheme within a protocol encryption scheme such as HTTPS or SMTPS.
-------------------------------
## Remote File Copy
[Remote File Copy - ATT&CK](https://attack.mitre.org/wiki/Technique/T1105)
* Files may be copied from one system to another to stage adversary tools or other files over the course of an operation. Files may be copied from an external adversary-controlled system through the Command and Control channel to bring tools into the victim network or through alternate protocols with another tool such as FTP. Files can also be copied over on Mac and Linux with native tools like scp, rsync, and sftp.
* Adversaries may also copy files laterally between internal victim systems to support Lateral Movement with remote Execution using inherent file sharing protocols such as file sharing over SMB to connected network shares or with authenticated connections with Windows Admin Shares or Remote Desktop Protocol.
-------------------------------
## Standard Application Layer Protocol
[Standard Application Layer Protocol - ATT&CK](https://attack.mitre.org/wiki/Technique/T1071)
* Adversaries may communicate using a common, standardized application layer protocol such as HTTP, HTTPS, SMTP, or DNS to avoid detection by blending in with existing traffic. Commands to the remote system, and often the results of those commands, will be embedded within the protocol traffic between the client and server.
* For connections that occur internally within an enclave (such as those between a proxy or pivot node and other nodes), commonly used protocols are RPC, SSH, or RDP.
-------------------------------
## Standard Cryptographic Protocol
[Standard Cryptographic Protocol - ATT&CK](https://attack.mitre.org/wiki/Technique/T1032)
* Adversaries use command and control over an encrypted channel using a known encryption protocol like HTTPS or SSL/TLS. The use of strong encryption makes it difficult for defenders to detect signatures within adversary command and control traffic.
Some adversaries may use other encryption protocols and algorithms with symmetric keys, such as RC4, that rely on encryption keys encoded into malware configuration files and not public key cryptography. Such keys may be obtained through malware reverse engineering.
-------------------------------
## Standard Non-Application Layer Protocol
[Standard Non-Application Layer Protocol - ATT&CK](https://attack.mitre.org/wiki/Technique/T1095)
* Use of a standard non-application layer protocol for communication between host and C2 server or among infected hosts within a network. The list of possible protocols is extensive. Specific examples include use of network layer protocols, such as the Internet Control Message Protocol (ICMP), and transport layer protocols, such as the User Datagram Protocol (UDP).
* ICMP communication between hosts is one example. Because ICMP is part of the Internet Protocol Suite, it is required to be implemented by all IP-compatible hosts; however, it is not as commonly monitored as other Internet Protocols such as TCP or UDP and may be used by adversaries to hide communications.
-------------------------------
## Uncommonly Used Port
[Uncommonly Used Port - ATT&CK](https://attack.mitre.org/wiki/Technique/T1065)
-------------------------------
## Web Service
[Web Service - ATT&CK](https://attack.mitre.org/wiki/Technique/T1102)
* Adversaries may use an existing, legitimate external Web service as a means for relaying commands to a compromised system.
* Popular websites and social media can act as a mechanism for command and control and give a significant amount of cover due to the likelihood that hosts within a network are already communicating with them prior to a compromise. Using common services, such as those offered by Google or Twitter, makes it easier for adversaries to hide in expected noise. Web service providers commonly use SSL/TLS encryption, giving adversaries an added level of protection.

+ 220
- 0
Draft/ATT&CK-Stuff/Linux/Linux Credential Access.md View File

@ -0,0 +1,220 @@
## Linux Credential Access
-------------------------------
## Bash History
[Bash History - ATT&CK](https://attack.mitre.org/wiki/Technique/T1139)
* Bash keeps track of the commands users type on the command-line with the "history" utility. Once a user logs out, the history is flushed to the user’s .bash_history file. For each user, this file resides at the same location: ~/.bash_history. Typically, this file keeps track of the user’s last 500 commands. Users often type usernames and passwords on the command-line as parameters to programs, which then get saved to this file when they log out. Attackers can abuse this by looking through the file for potential credentials.
[Command history in Zsh - StackOverflow](https://unix.stackexchange.com/questions/111718/command-history-in-zsh)
-------------------------------
## Brute Force
[Brute Force - ATT&CK](https://attack.mitre.org/wiki/Technique/T1110)
* Adversaries may use brute force techniques to attempt access to accounts when passwords are unknown or when password hashes are obtained.
* Credential Dumping to obtain password hashes may only get an adversary so far when Pass the Hash is not an option. Techniques to systematically guess the passwords used to compute hashes are available, or the adversary may use a pre-computed rainbow table. Cracking hashes is usually done on adversary-controlled systems outside of the target network.
* Adversaries may attempt to brute force logins without knowledge of passwords or hashes during an operation either with zero knowledge or by attempting a list of known or possible passwords. This is a riskier option because it could cause numerous authentication failures and account lockouts, depending on the organization's login failure policies.
* A related technique called password spraying uses one password, or a small list of passwords, that matches the complexity policy of the domain and may be a commonly used password. Logins are attempted with that password and many different accounts on a network to avoid account lockouts that would normally occur when brute forcing a single account with many passwords.
-------------------------------
## Create Account
[Create Account - ATT&CK](https://attack.mitre.org/wiki/Technique/T1136)
* Adversaries with a sufficient level of access may create a local system or domain account. Such accounts may be used for persistence that do not require persistent remote access tools to be deployed on the system.
[adduser(8) - Linux man page](https://linux.die.net/man/8/adduser)
[The Complete Guide to “useradd” Command in Linux – 15 Practical Examples](https://www.tecmint.com/add-users-in-linux/)
-------------------------------
## Credentials in Files
[Credentials in Files - ATT&CK](https://attack.mitre.org/wiki/Technique/T1081)
* * Adversaries may search local file systems and remote file shares for files containing passwords. These can be files created by users to store their own credentials, shared credential stores for a group of individuals, configuration files containing passwords for a system or service, or source code/binary files containing embedded passwords.
* It is possible to extract passwords from backups or saved virtual machines through Credential Dumping. Passwords may also be obtained from Group Policy Preferences stored on the Windows Domain Controller.
[How do I find all files containing specific text on Linux? - StackOverflow](https://stackoverflow.com/questions/16956810/how-do-i-find-all-files-containing-specific-text-on-linux)
[Find Files in Linux, Using the Command Line - Linode](https://www.linode.com/docs/tools-reference/tools/find-files-in-linux-using-the-command-line)
-------------------------------
## Exploitation of Vulnerability
[Exploitation of Vulnerability - ATT&CK](https://attack.mitre.org/wiki/Technique/T1068)
* Exploitation of a software vulnerability occurs when an adversary takes advantage of a programming error in a program, service, or within the operating system software or kernel itself to execute adversary-controlled code. Exploiting software vulnerabilities may allow adversaries to run a command or binary on a remote system for lateral movement, escalate a current process to a higher privilege level, or bypass security mechanisms. Exploits may also allow an adversary access to privileged accounts and credentials. One example of this is MS14-068, which can be used to forge Kerberos tickets using domain user permissions.
[Triple-Fetch-Kernel-Creds](https://github.com/coffeebreakerz/Tripple-Fetch-Kernel-Creds)
* Attempt to steal kernelcredentials from launchd + task_t pointer (Based on: CVE-2017-7047)
-------------------------------
## Input Capture
[Input Capture - ATT&CK](https://attack.mitre.org/wiki/Technique/T1056)
* Adversaries can use methods of capturing user input for obtaining credentials for Valid Accounts and information Collection that include keylogging and user input field interception.
* Keylogging is the most prevalent type of input capture, with many different ways of intercepting keystrokes, but other methods exist to target information for specific purposes, such as performing a UAC prompt or wrapping the Windows default credential provider.
* Keylogging is likely to be used to acquire credentials for new access opportunities when Credential Dumping efforts are not effective, and may require an adversary to remain passive on a system for a period of time before an opportunity arises.
* Adversaries may also install code on externally facing portals, such as a VPN login page, to capture and transmit credentials of users who attempt to log into the service. This variation on input capture may be conducted post-compromise using legitimate administrative access as a backup measure to maintain network access through External Remote Services and Valid Accounts or as part of the initial compromise by exploitation of the externally facing web service.
[logkeys - a GNU/Linux keylogger](https://github.com/kernc/logkeys)
* logkeys is a linux keylogger. It is no more advanced than other available linux keyloggers, notably lkl and uberkey, but is a bit newer, more up to date, it doesn't unreliably repeat keys and it shouldn't crash your X. All in all, it just seems to work. It relies on event interface of the Linux input subsystem. Once completely set, it logs all common character and function keys, while also being fully aware of Shift and AltGr key modifiers.
[Using xkeyscan to Parse an X-Based Linux Keylogger](http://porterhau5.com/blog/xkeyscan-parse-linux-keylogger/)
* Leverage native X-based tools for real-time keylogging with xkeyscan, a Python script that translates X keycodes into legible keystrokes.
[keysniffer: trace pressed keys in debugfs](http://tuxdiary.com/2015/10/14/keysniffer/)
[SKeylogger](https://github.com/gsingh93/simple-key-logger)
* SKeylogger is a simple keylogger. I had previously been using a few other open source keyloggers, but they stopped working when I upgraded my operating system. I tried to look through the code of those keyloggers, but it was undocumented, messy, and complex. I decided to make my own highly documented and very simple keylogger.
[The Linux Security Circus: On GUI isolation](https://theinvisiblethings.blogspot.com/2011/04/linux-security-circus-on-gui-isolation.html)
-------------------------------
## Network Sniffing
[Network Sniffing - ATT&CK](https://attack.mitre.org/wiki/Technique/T1040)
* Network sniffing refers to using the network interface on a system to monitor or capture information sent over a wired or wireless connection.
* User credentials may be sent over an insecure, unencrypted protocol that can be captured and obtained through network packet analysis. An adversary may place a network interface into promiscuous mode, using a utility to capture traffic in transit over the network or use span ports to capture a larger amount of data. In addition, Address Resolution Protocol (ARP) and Domain Name Service (DNS) poisoning can be used to capture credentials to websites, proxies, and internal systems by redirecting traffic to an adversary.
[Manpage for TCPDump](http://www.tcpdump.org/tcpdump_man.html)
[A tcpdump Tutorial and Primer with Examples - Daniel Messler](https://danielmiessler.com/study/tcpdump/)
[net-creds](https://github.com/DanMcInerney/net-creds)
* Thoroughly sniff passwords and hashes from an interface or pcap file. Concatenates fragmented packets and does not rely on ports for service identification.
[tcpflow](https://github.com/simsong/tcpflow)
* tcpflow is a program that captures data transmitted as part of TCP connections (flows), and stores the data in a way that is convenient for protocol analysis and debugging. Each TCP flow is stored in its own file. Thus, the typical TCP flow will be stored in two files, one for each direction. tcpflow can also process stored 'tcpdump' packet flows.
-------------------------------
## Private Keys
[Private Keys - ATT&CK](https://attack.mitre.org/wiki/Technique/T1145)
* Private cryptographic keys and certificates are used for authentication, encryption/decryption, and digital signatures.1
* Adversaries may gather private keys from compromised systems for use in authenticating to Remote Services like SSH or for use in decrypting other collected files such as email. Common key and certificate file extensions include: .key, .pgp, .gpg, .ppk., .p12, .pem, pfx, .cer, .p7b, .asc. Adversaries may also look in common key directories, such as ~/.ssh for SSH keys on *nix-based systems or C:\Users\(username)\.ssh\ on Windows.
* Private keys should require a password or passphrase for operation, so an adversary may also use Input Capture for keylogging or attempt to Brute Force the passphrase off-line.
[What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats? - StackOverflow](https://serverfault.com/questions/9708/what-is-a-pem-file-and-how-does-it-differ-from-other-openssl-generated-key-file)
-------------------------------
## Two-Factor Authentication Interception
[Two-Factor Authentication Interception - ATT&CK](https://attack.mitre.org/wiki/Technique/T1111)
* Use of two- or multifactor authentication is recommended and provides a higher level of security than user names and passwords alone, but organizations should be aware of techniques that could be used to intercept and bypass these security mechanisms. Adversaries may target authentication mechanisms, such as smart cards, to gain access to systems, services, and network resources.
* If a smart card is used for two-factor authentication (2FA), then a keylogger will need to be used to obtain the password associated with a smart card during normal use. With both an inserted card and access to the smart card password, an adversary can connect to a network resource using the infected system to proxy the authentication with the inserted hardware token.
* Other methods of 2FA may be intercepted and used by an adversary to authenticate. It is common for one-time codes to be sent via out-of-band communications (email, SMS). If the device and/or service is not secured, then it may be vulnerable to interception. Although primarily focused on by cyber criminals, these authentication mechanisms have been targeted by advanced actors.
* Other hardware tokens, such as RSA SecurID, require the adversary to have access to the physical device or the seed and algorithm in addition to the corresponding credentials.

+ 387
- 0
Draft/ATT&CK-Stuff/Linux/Linux Defense Evasion.md View File

@ -0,0 +1,387 @@
## Linux Defense Evasion
-------------------------------
## Binary Padding
[Binary Padding - ATT&CK](https://attack.mitre.org/wiki/Technique/T1009)
* Some security tools inspect files with static signatures to determine if they are known malicious. Adversaries may add data to files to increase the size beyond what security tools are capable of handling or to change the file hash to avoid hash-based blacklists.
-------------------------------
## Clear Command History
[Clear Command History - ATT&CK](https://attack.mitre.org/wiki/Technique/T1146)
* macOS and Linux both keep track of the commands users type in their terminal so that users can easily remember what they've done. These logs can be accessed in a few different ways. While logged in, this command history is tracked in a file pointed to by the environment variable HISTFILE. When a user logs off a system, this information is flushed to a file in the user's home directory called ~/.bash_history. The benefit of this is that it allows users to go back to commands they've used before in different sessions. Since everything typed on the command-line is saved, passwords passed in on the command line are also saved. Adversaries can abuse this by searching these files for cleartext passwords. Additionally, adversaries can use a variety of methods to prevent their own commands from appear in these logs such as unset HISTFILE, export HISTFILESIZE=0, history -c, rm ~/.bash_history.
* Location of bash history file on linux: ```~/.bash_history```
[How to clear bash history completely? - StackOverflow](https://askubuntu.com/questions/191999/how-to-clear-bash-history-completely)
[How To Delete / Clear Linux Comand Line History With Examples](https://linoxide.com/how-tos/how-to-delete-history-linux/)
-------------------------------
## Disabling Security Tools
[Disabling Security Tools - ATT&CK](https://attack.mitre.org/wiki/Technique/T1089)
* Adversaries may disable security tools to avoid possible detection of their tools and activities. This can take the form of killing security software or event logging processes, deleting Registry keys so that tools do not start at run time, or other methods to interfere with security scanning or event reporting.
-------------------------------
## Exploitation of Vulnerability
[Exploitation of Vulnerability - ATT&CK](https://attack.mitre.org/wiki/Technique/T1068)
* Exploitation of a software vulnerability occurs when an adversary takes advantage of a programming error in a program, service, or within the operating system software or kernel itself to execute adversary-controlled code. Exploiting software vulnerabilities may allow adversaries to run a command or binary on a remote system for lateral movement, escalate a current process to a higher privilege level, or bypass security mechanisms. Exploits may also allow an adversary access to privileged accounts and credentials. One example of this is MS14-068, which can be used to forge Kerberos tickets using domain user permissions.
-------------------------------
## File Deletion
[File Deletion - ATT&CK](https://attack.mitre.org/wiki/Technique/T1107)
* Malware, tools, or other non-native files dropped or created on a system by an adversary may leave traces behind as to what was done within a network and how. Adversaries may remove these files over the course of an intrusion to keep their footprint low or remove them at the end as part of the post-intrusion cleanup process.
* There are tools available from the host operating system to perform cleanup, but adversaries may use other tools as well. Examples include native cmd functions such as DEL, secure deletion tools such as Windows Sysinternals SDelete, or other third-party file deletion tools.
[rm(1) - Linux man page](https://linux.die.net/man/1/rm)
[Linux / UNIX: Delete a file - nixcraft](https://www.google.com/search?q=linux+clear+history&ie=utf-8&oe=utf-8)
-------------------------------
## HISTCONTROL
[HISTCONTROL - ATT&CK](https://attack.mitre.org/wiki/Technique/T1148)
* The HISTCONTROL environment variable keeps track of what should be saved by the history command and eventually into the ~/.bash_history file when a user logs out. This setting can be configured to ignore commands that start with a space by simply setting it to "ignorespace". HISTCONTROL can also be set to ignore duplicate commands by setting it to "ignoredups". In some Linux systems, this is set by default to "ignoreboth" which covers both of the previous examples. This means that “ ls” will not be saved, but “ls” would be saved by history. HISTCONTROL does not exist by default on macOS, but can be set by the user and will be respected. Adversaries can use this to operate without leaving traces by simply prepending a space to all of their terminal commands.
[15 Examples To Master Linux Command Line History](http://www.thegeekstuff.com/2008/08/15-examples-to-master-linux-command-line-history/)
-------------------------------
## Hidden Files and Directories
[Hidden Files and Directories - ATT&CK](https://attack.mitre.org/wiki/Technique/T1158)
* To prevent normal users from accidentally changing special files on a system, most operating systems have the concept of a ‘hidden’ file. These files don’t show up when a user browses the file system with a GUI or when using normal commands on the command line. Users must explicitly ask to show the hidden files either via a series of Graphical User Interface (GUI) prompts or with command line switches (dir /a for Windows and ls –a for Linux and macOS).
-------------------------------
## Indicator Removal from Tools
[Indicator Removal from Tools - ATT&CK](https://attack.mitre.org/wiki/Technique/T1066)
* * If a malicious tool is detected and quarantined or otherwise curtailed, an adversary may be able to determine why the malicious tool was detected (the indicator), modify the tool by removing the indicator, and use the updated version that is no longer detected by the target's defensive systems or subsequent targets that may use similar systems.
* A good example of this is when malware is detected with a file signature and quarantined by anti-virus software. An adversary who can determine that the malware was quarantined because of its file signature may use Software Packing or otherwise modify the file so it has a different signature, and then re-use the malware.
-------------------------------
## Indicator Removal on Host
[Indicator Removal on Host - ATT&CK](https://attack.mitre.org/wiki/Technique/T1070)
* Adversaries may delete or alter generated event files on a host system, including potentially captured files such as quarantined malware. This may compromise the integrity of the security solution, causing events to go unreported, or make forensic analysis and incident response more difficult due to lack of sufficient data to determine what occurred.
-------------------------------
## Install Root Certificate
[Install Root Certificate - ATT&CK](https://attack.mitre.org/wiki/Technique/T1130)
* Root certificates are used in public key cryptography to identify a root certificate authority (CA). When a root certificate is installed, the system or application will trust certificates in the root's chain of trust that have been signed by the root certificate. Certificates are commonly used for establishing secure TLS/SSL communications within a web browser. When a user attempts to browse a website that presents a certificate that is not trusted an error message will be displayed to warn the user of the security risk. Depending on the security settings, the browser may not allow the user to establish a connection to the website.
* Installation of a root certificate on a compromised system would give an adversary a way to degrade the security of that system. Adversaries have used this technique to avoid security warnings prompting users when compromised systems connect over HTTPS to adversary controlled web servers that spoof legitimate websites in order to collect login credentials.
* Atypical root certificates have also been pre-installed on systems by the manufacturer or in the software supply chain and were used in conjunction with malware/adware to provide a man-in-the-middle capability for intercepting information transmitted over secure TLS/SSL communications.
[How do I install a root certificate? - StackOverflow](https://askubuntu.com/questions/73287/how-do-i-install-a-root-certificate)
-------------------------------
## Masquerading
[Masquerading - ATT&CK](https://attack.mitre.org/wiki/Technique/T1036)
* Masquerading occurs when an executable, legitimate or malicious, is placed in a commonly trusted location (such as C:\Windows\System32) or named with a common name (such as "explorer.exe" or "svchost.exe") to bypass tools that trust executables by relying on file name or path. An adversary may even use a renamed copy of a legitimate utility, such as rundll32.exe. Masquerading also may be done to deceive defenders and system administrators into thinking a file is benign by associating the name with something that is thought to be legitimate.
* Think Shell Scripts that call out to services/items; Cron Jobs;
-------------------------------
## Redundant Access
[Redundant Access - ATT&CK](https://attack.mitre.org/wiki/Technique/T1108)
* Adversaries may use more than one remote access tool with varying command and control protocols as a hedge against detection. If one type of tool is detected and blocked or removed as a response but the organization did not gain a full understanding of the adversary's tools and access, then the adversary will be able to retain access to the network. Adversaries may also attempt to gain access to Valid Accounts to use External Remote Services such as external VPNs as a way to maintain access despite interruptions to remote access tools deployed within a target network.
-------------------------------
## Scripting
[Scripting - ATT&CK](https://attack.mitre.org/wiki/Technique/T1064)
* Adversaries may use scripts to aid in operations and perform multiple actions that would otherwise be manual. Scripting is useful for speeding up operational tasks and reducing the time required to gain access to critical resources. Some scripting languages may be used to bypass process monitoring mechanisms by directly interacting with the operating system at an API level instead of calling other programs. Common scripting languages for Windows include VBScript and PowerShell but could also be in the form of command-line batch scripts.
[BASH Programming - Introduction HOW-TO - tldp](http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html)
[Advanced Bash-Scripting Guide - tldp](http://tldp.org/LDP/abs/html/)
[Bash Shell Scripting - Wikibooks](https://en.wikibooks.org/wiki/Bash_Shell_Scripting)
-------------------------------
## Spaces after Filename
[Spaces after Filename - ATT&CK](https://attack.mitre.org/wiki/Technique/T1151)
* Adversaries can hide a program's true filetype by changing the extension of a file. With certain file types (specifically this does not work with .app extensions), appending a space to the end of a filename will change how the file is processed by the operating system. For example, if there is a Mach-O executable file called evil.bin, when it is double clicked by a user, it will launch Terminal.app and execute. If this file is renamed to evil.txt, then when double clicked by a user, it will launch with the default text editing application (not executing the binary). However, if the file is renamed to "evil.txt " (note the space at the end), then when double clicked by a user, the true file type is determined by the OS and handled appropriately and the binary will be executed.
-------------------------------
## Timestomp
[Timestomp - ATT&CK](https://attack.mitre.org/wiki/Technique/T1099)
* Timestomping is a technique that modifies the timestamps of a file (the modify, access, create, and change times), often to mimic files that are in the same folder. This is done, for example, on files that have been modified or created by the adversary so that they do not appear conspicuous to forensic investigators or file analysis tools. Timestomping may be used along with file name Masquerading to hide malware and tools.
[Bash - Timestomping Linux Files](http://64bit.ca/code/bash-timestomping-linux-files/)
[Timestomp - Forensics Wiki](http://www.forensicswiki.org/wiki/Timestomp)
[Linux Timestamps, Oh boy!](https://articles.forensicfocus.com/2015/08/25/linux-timestamps-oh-boy/)
-------------------------------
## Valid Accounts
[Valid Accounts - ATT&CK](https://attack.mitre.org/wiki/Technique/T1078)
* Adversaries may steal the credentials of a specific user or service account using Credential Access techniques. Compromised credentials may be used to bypass access controls placed on various resources on hosts and within the network and may even be used for persistent access to remote systems. Compromised credentials may also grant an adversary increased privilege to specific systems or access to restricted areas of the network. Adversaries may choose not to use malware or tools in conjunction with the legitimate access those credentials provide to make it harder to detect their presence.
* Adversaries may also create accounts, sometimes using pre-defined account names and passwords, as a means for persistence through backup access in case other means are unsuccessful.
* The overlap of credentials and permissions across a network of systems is of concern because the adversary may be able to pivot across accounts and systems to reach a high level of access (i.e., domain or enterprise administrator) to bypass access controls set within the enterprise.
* ```cat /etc/passwd```

+ 0
- 0
Draft/ATT&CK-Stuff/Linux/Linux Discovery.md View File


+ 153
- 0
Draft/ATT&CK-Stuff/Linux/Linux Execution.md View File

@ -0,0 +1,153 @@
## Linux Execution
-------------------------------
## Command-Line Interface
[Command-Line Interace - ATT&CK](https://attack.mitre.org/wiki/Technique/T1059)
* Command-line interfaces provide a way of interacting with computer systems and is a common feature across many types of operating system platforms.1 One example command-line interface on Windows systems is cmd, which can be used to perform a number of tasks including execution of other software. Command-line interfaces can be interacted with locally or remotely via a remote desktop application, reverse shell session, etc. Commands that are executed run with the current permission level of the command-line interface process unless the command includes process invocation that changes permissions context for that execution (e.g. Scheduled Task).
[Linuxcommand.org](http://linuxcommand.org/lc3_learning_the_shell.php)
[Learn the Bash Command Line](https://ryanstutorials.net/linuxtutorial/)
-------------------------------
## Graphical User Interface
[Graphical User Interface - ATT&CK](https://attack.mitre.org/wiki/Technique/T1061)
* Cause a binary or script to execute based on interacting with the file through a graphical user interface (GUI) or in an interactive remote session such as Remote Desktop Protocol.
-------------------------------
## Scripting
[Scripting - ATT&CK](https://attack.mitre.org/wiki/Technique/T1064)
* Adversaries may use scripts to aid in operations and perform multiple actions that would otherwise be manual. Scripting is useful for speeding up operational tasks and reducing the time required to gain access to critical resources. Some scripting languages may be used to bypass process monitoring mechanisms by directly interacting with the operating system at an API level instead of calling other programs. Common scripting languages for Windows include VBScript and PowerShell but could also be in the form of command-line batch scripts.
[BASH Programming - Introduction HOW-TO - tldp](http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html)
[Advanced Bash-Scripting Guide - tldp](http://tldp.org/LDP/abs/html/)
[Bash Shell Scripting - Wikibooks](https://en.wikibooks.org/wiki/Bash_Shell_Scripting)
-------------------------------
## Source
[Source - ATT&CK](https://attack.mitre.org/wiki/Technique/T1153)
* The source command loads functions into the current shell or executes files in the current context. This built-in command can be run in two different ways source /path/to/filename [arguments] or . /path/to/filename [arguments]. Take note of the space after the ".". Without a space, a new shell is created that runs the program instead of running the program within the current context. This is often used to make certain features or functions available to a shell or to update a specific shell's environment.
[Sourcing a File - tldp](http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x237.html)
[Source command - bash.cyberciti](https://bash.cyberciti.biz/guide/Source_command)
-------------------------------
## Space after Filename
[Space after Filename - ATT&CK](https://attack.mitre.org/wiki/Technique/T1151)
* Adversaries can hide a program's true filetype by changing the extension of a file. With certain file types (specifically this does not work with .app extensions), appending a space to the end of a filename will change how the file is processed by the operating system. For example, if there is a Mach-O executable file called evil.bin, when it is double clicked by a user, it will launch Terminal.app and execute. If this file is renamed to evil.txt, then when double clicked by a user, it will launch with the default text editing application (not executing the binary). However, if the file is renamed to "evil.txt " (note the space at the end), then when double clicked by a user, the true file type is determined by the OS and handled appropriately and the binary will be executed.
-------------------------------
## Third-Party Software
[Third-Party Software](https://attack.mitre.org/wiki/Technique/T1072)
* Third-party applications and software deployment systems may be in use in the network environment for administration purposes (e.g., SCCM, VNC, HBSS, Altiris, etc.). If an adversary gains access to these systems, then they may be able to execute code.
* Adversaries may gain access to and use third-party application deployment systems installed within an enterprise network. Access to a network-wide or enterprise-wide software deployment system enables an adversary to have remote code execution on all systems that are connected to such a system. The access may be used to laterally move to systems, gather information, or cause a specific effect, such as wiping the hard drives on all endpoints.
* The permissions required for this action vary by system configuration; local credentials may be sufficient with direct access to the deployment server, or specific domain credentials may be required. However, the system may require an administrative account to log in or to perform software deployment.
[How do I list all installed programs? - StackOverflow](https://unix.stackexchange.com/questions/20979/how-do-i-list-all-installed-programs)
-------------------------------
## Trap
[Trap - ATT&CK](https://attack.mitre.org/wiki/Technique/T1154)
* The trap command allows programs and shells to specify commands that will be executed upon receiving interrupt signals. A common situation is a script allowing for graceful termination and handling of common keyboard interrupts like ctrl+c and ctrl+d. Adversaries can use this to register code to be executed when the shell encounters specific interrupts either to gain execution or as a persistence mechanism. Trap commands are of the following format trap 'command list' signals where "command list" will be executed when "signals" are received.
[Traps - tldp](http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_12_02.html)
[Shell Scripting Tutorial - Trap](https://www.shellscript.sh/trap.html)
[Unix / Linux - Signals and Traps - TutorialsPoint](https://www.tutorialspoint.com/unix/unix-signals-traps.htm)

+ 91
- 0
Draft/ATT&CK-Stuff/Linux/Linux Exfiltration.md View File

@ -0,0 +1,91 @@
## Linux Exfiltration
-------------------------------
## Automated Exfiltration
[Automated Exfiltration - ATT&CK](https://attack.mitre.org/wiki/Technique/T1020)
* Data, such as sensitive documents, may be exfiltrated through the use of automated processing or Scripting after being gathered during Collection.
-------------------------------
## Data Compressed
[Data Compressed - ATT&CK](https://attack.mitre.org/wiki/Technique/T1002)
* An adversary may compress data (e.g., sensitive documents) that is collected prior to exfiltration in order to make it portable and minimize the amount of data sent over the network. The compression is done separately from the exfiltration channel and is performed using a custom program or algorithm, or a more common compression library or utility such as 7zip, RAR, ZIP, or zlib.
-------------------------------
## Data Encrypted
[Data Encrypted - ATT&CK](https://attack.mitre.org/wiki/Technique/T1022)
* Data is encrypted before being exfiltrated in order to hide the information that is being exfiltrated from detection or to make the exfiltration less conspicuous upon inspection by a defender. The encryption is performed by a utility, programming library, or custom algorithm on the data itself and is considered separate from any encryption performed by the command and control or file transfer protocol. Common file archive formats that can encrypt files are RAR and zip.
-------------------------------
## Data Transfer Size Limits
[Data Transfer Size Limits - ATT&CK](https://attack.mitre.org/wiki/Technique/T1030)
* An adversary may exfiltrate data in fixed size chunks instead of whole files or limit packet sizes below certain thresholds. This approach may be used to avoid triggering network data transfer threshold alerts.
-------------------------------
## Exfiltration Over Alternative Protocol
[Exfiltration Over Alternative Protocol - ATT&CK](https://attack.mitre.org/wiki/Technique/T1048)
* Data exfiltration is performed with a different protocol from the main command and control protocol or channel. The data is likely to be sent to an alternate network location from the main command and control server. Alternate protocols include FTP, SMTP, HTTP/S, DNS, or some other network protocol. Different channels could include Internet Web services such as cloud storage.
-------------------------------
## Exfiltration Over Command and Control Channel
[Exfiltration Over Command and Control Channel - ATT&CK](https://attack.mitre.org/wiki/Technique/T1041)
* Data exfiltration is performed over the Command and Control channel. Data is encoded into the normal communications channel using the same protocol as command and control communications.
-------------------------------
## Exfiltration Over Other Network Medium
[Exfiltration Over Other Network Medium - ATT&CK](https://attack.mitre.org/wiki/Technique/T1011)
* Exfiltration could occur over a different network medium than the command and control channel. If the command and control network is a wired Internet connection, the exfiltration may occur, for example, over a WiFi connection, modem, cellular data connection, Bluetooth, or another radio frequency (RF) channel. Adversaries could choose to do this if they have sufficient access or proximity, and the connection might not be secured or defended as well as the primary Internet-connected channel because it is not routed through the same enterprise network.
-------------------------------
## Exfiltration over Physical Medium
[Exfiltration over Physical Medium - ATT&CK](https://attack.mitre.org/wiki/Technique/T1052)
* In certain circumstances, such as an air-gapped network compromise, exfiltration could occur via a physical medium or device introduced by a user. Such media could be an external hard drive, USB drive, cellular phone, MP3 player, or other removable storage and processing device. The physical medium or device could be used as the final exfiltration point or to hop between otherwise disconnected systems.
-------------------------------
## Scheduled Transfer
[Scheduled Transfer - ATT&CK](https://attack.mitre.org/wiki/Technique/T1029)
* Data exfiltration may be performed only at certain times of day or at certain intervals. This could be done to blend traffic patterns with normal activity or availability.

+ 100
- 0
Draft/ATT&CK-Stuff/Linux/Linux Lateral Movement.md View File

@ -0,0 +1,100 @@
## Linux Lateral Movement
-------------------------------
## Application Deployment Software
[Application Deployment Software - ATT&CK](https://attack.mitre.org/wiki/Technique/T1017)
* Adversaries may deploy alicious software to systems within a network using application deployment systems employed by enterprise administrators. The permissions required for this action vary by system configuration; local credentials may be sufficient with direct access to the deployment server, or specific domain credentials may be required. However, the system may require an administrative account to log in or to perform software deployment.
* Access to a network-wide or enterprise-wide software deployment system enables an adversary to have remote code execution on all systems that are connected to such a system. The access may be used to laterally move to systems, gather information, or cause a specific effect, such as wiping the hard drives on all endpoints.
-------------------------------
## Exploitation of Vulnerability
[Exploitation of Vulnerability](https://attack.mitre.org/wiki/Technique/T1068)
* Exploitation of a software vulnerability occurs when an adversary takes advantage of a programming error in a program, service, or within the operating system software or kernel itself to execute adversary-controlled code. Exploiting software vulnerabilities may allow adversaries to run a command or binary on a remote system for lateral movement, escalate a current process to a higher privilege level, or bypass security mechanisms. Exploits may also allow an adversary access to privileged accounts and credentials. One example of this is MS14-068, which can be used to forge Kerberos tickets using domain user permissions.
-------------------------------
## Remote File Copy
[Remote File Copy - ATT&CK](https://attack.mitre.org/wiki/Technique/T1105)
* Files may be copied from one system to another to stage adversary tools or other files over the course of an operation. Files may be copied from an external adversary-controlled system through the Command and Control channel to bring tools into the victim network or through alternate protocols with another tool such as FTP. Files can also be copied over on Mac and Linux with native tools like scp, rsync, and sftp.
-------------------------------
## Remote Services
[Remote Service - ATT&CK](https://attack.mitre.org/wiki/Technique/T1021)
* An adversary may use valid credentials to log into a service specifically designed to accept remote connections, such as telnet, SSH, and VNC. The adversary may then perform actions as the logged-on user.
-------------------------------
## Third-Party Software
[Third-Party Software - ATT&CK](https://attack.mitre.org/wiki/Technique/T1072)
* Third-party applications and software deployment systems may be in use in the network environment for administration purposes (e.g., SCCM, VNC, HBSS, Altiris, etc.). If an adversary gains access to these systems, then they may be able to execute code.
* Adversaries may gain access to and use third-party application deployment systems installed within an enterprise network. Access to a network-wide or enterprise-wide software deployment system enables an adversary to have remote code execution on all systems that are connected to such a system. The access may be used to laterally move to systems, gather information, or cause a specific effect, such as wiping the hard drives on all endpoints.
* The permissions required for this action vary by system configuration; local credentials may be sufficient with direct access to the deployment server, or specific domain credentials may be required. However, the system may require an administrative account to log in or to perform software deployment.

+ 199
- 0
Draft/ATT&CK-Stuff/Linux/Linux Persistence.md View File

@ -0,0 +1,199 @@
## Linux Persistence
-------------------------------
## .bash_profile and .bashrc
[.bash_profile and .bashrc - ATT&CK](https://attack.mitre.org/wiki/Technique/T1156)
* ~/.bash_profile and ~/.bashrc are executed in a user's context when a new shell opens or when a user logs in so that their environment is set correctly. ~/.bash_profile is executed for login shells and ~/.bashrc is executed for interactive non-login shells. This means that when a user logs in (via username and password) to the console (either locally or remotely via something like SSH), ~/.bash_profile is executed before the initial command prompt is returned to the user. After that, every time a new shell is opened, ~/.bashrc is executed. This allows users more fine grained control over when they want certain commands executed.
* Mac's Terminal.app is a little different in that it runs a login shell by default each time a new terminal window is opened, thus calling ~/.bash_profile each time instead of ~/.bashrc.
-------------------------------
## Bootkit
[Bootkit - ATT&CK](https://attack.mitre.org/wiki/Technique/T1067)
* A bootkit is a malware variant that modifies the boot sectors of a hard drive, including the Master Boot Record (MBR) and Volume Boot Record (VBR).1
* Adversaries may use bootkits to persist on systems at a layer below the operating system, which may make it difficult to perform full remediation unless an organization suspects one was used and can act accordingly.
-------------------------------
## Cron Job
[Cron Job - ATT&CK](https://attack.mitre.org/wiki/Technique/T1168)
* System-wide cron jobs are installed by modifying /etc/crontab while per-user cron jobs are installed using crontab with specifically formatted crontab files 1. This works on Mac and Linux systems.
* Both methods allow for commands or scripts to be executed at specific, periodic intervals in the background without user interaction. An adversary may use task scheduling to execute programs at system startup or on a scheduled basis for persistence234, to conduct Execution as part of Lateral Movement, to gain root privileges, or to run a process under the context of a specific account.
[Intro to Cron - unixgeeks](http://www.unixgeeks.org/security/newbie/unix/cron-1.html)
[Scheduling Tasks with Cron Jobs - tutsplus](https://code.tutsplus.com/tutorials/scheduling-tasks-with-cron-jobs--net-8800)
-------------------------------
## Hidden Files and Directories
[Hidden Files and Directories - ATT&CK](https://attack.mitre.org/wiki/Technique/T1158)
* To prevent normal users from accidentally changing special files on a system, most operating systems have the concept of a ‘hidden’ file. These files don’t show up when a user browses the file system with a GUI or when using normal commands on the command line. Users must explicitly ask to show the hidden files either via a series of Graphical User Interface (GUI) prompts or with command line switches (dir /a for Windows and ls –a for Linux and macOS).
[Hidden File Definition - LinuxInfoProject](http://www.linfo.org/hidden_file.html)
-------------------------------
## Rc.common
[Rc.common - ATT&CK](https://attack.mitre.org/wiki/Technique/T1163)
* During the boot process, macOS and Linux both execute source /etc/rc.common, which is a shell script containing various utility functions. This file also defines routines for processing command-line arguments and for gathering system settings, and is thus recommended to include in the start of Startup Item Scripts1. In macOS and OS X, this is now a deprecated technique in favor of launch agents and launch daemons, but is currently still used.
[An introduction to services, runlevels, and rc.d scripts - linux.com](https://www.linux.com/news/introduction-services-runlevels-and-rcd-scripts)
-------------------------------
## Redundant Access
[Redundant Access - ATT&CK](https://attack.mitre.org/wiki/Technique/T1108)
* Adversaries may use more than one remote access tool with varying command and control protocols as a hedge against detection. If one type of tool is detected and blocked or removed as a response but the organization did not gain a full understanding of the adversary's tools and access, then the adversary will be able to retain access to the network. Adversaries may also attempt to gain access to Valid Accounts to use External Remote Services such as external VPNs as a way to maintain access despite interruptions to remote access tools deployed within a target network.
-------------------------------
## Trap
[Trap - ATT&CK](https://attack.mitre.org/wiki/Technique/T1154)
* The trap command allows programs and shells to specify commands that will be executed upon receiving interrupt signals. A common situation is a script allowing for graceful termination and handling of common keyboard interrupts like ctrl+c and ctrl+d. Adversaries can use this to register code to be executed when the shell encounters specific interrupts either to gain execution or as a persistence mechanism. Trap commands are of the following format trap 'command list' signals where "command list" will be executed when "signals" are received.
[Traps - tldp](http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_12_02.html)
[Shell Scripting Tutorial - Trap](https://www.shellscript.sh/trap.html)
[Unix / Linux - Signals and Traps - TutorialsPoint](https://www.tutorialspoint.com/unix/unix-signals-traps.htm)
-------------------------------
## Valid Accounts
[Valid Accounts - ATT&CK](https://attack.mitre.org/wiki/Technique/T1078)
* Adversaries may steal the credentials of a specific user or service account using Credential Access techniques. Compromised credentials may be used to bypass access controls placed on various resources on hosts and within the network and may even be used for persistent access to remote systems. Compromised credentials may also grant an adversary increased privilege to specific systems or access to restricted areas of the network. Adversaries may choose not to use malware or tools in conjunction with the legitimate access those credentials provide to make it harder to detect their presence.
* Adversaries may also create accounts, sometimes using pre-defined account names and passwords, as a means for persistence through backup access in case other means are unsuccessful.
* The overlap of credentials and permissions across a network of systems is of concern because the adversary may be able to pivot across accounts and systems to reach a high level of access (i.e., domain or enterprise administrator) to bypass access controls set within the enterprise
-------------------------------
## Web Shell
[Web Shell - ATT&CK](https://attack.mitre.org/wiki/Technique/T1100)
* A Web shell is a Web script that is placed on an openly accessible Web server to allow an adversary to use the Web server as a gateway into a network. A Web shell may provide a set of functions to execute or a command-line interface on the system that hosts the Web server. In addition to a server-side script, a Web shell may have a client interface program that is used to talk to the Web server (see, for example, China Chopper Web shell client).
[public-shell](https://github.com/BDLeet/public-shell)
* Some Public Shell
[php-webshells](https://github.com/JohnTroony/php-webshells)
* Common php webshells. Do not host the file(s) on your server!
[PHP-Backdoors](https://github.com/bartblaze/PHP-backdoors)
* A collection of PHP backdoors. For educational or testing purposes only.
[Weevely](https://github.com/epinna/weevely3)
* Weevely is a command line web shell dynamically extended over the network at runtime, designed for remote server administration and penetration testing.

+ 130
- 0
Draft/ATT&CK-Stuff/Linux/Linux Privilege Escalation.md View File

@ -0,0 +1,130 @@
## Linux Privilege Escalation
-------------------------------
## Exploitation of Vulnerability
[Exploitation of Vulnerability - ATT&CK](https://attack.mitre.org/wiki/Technique/T1068)
* Exploitation of a software vulnerability occurs when an adversary takes advantage of a programming error in a program, service, or within the operating system software or kernel itself to execute adversary-controlled code. Exploiting software vulnerabilities may allow adversaries to run a command or binary on a remote system for lateral movement, escalate a current process to a higher privilege level, or bypass security mechanisms. Exploits may also allow an adversary access to privileged accounts and credentials. One example of this is MS14-068, which can be used to forge Kerberos tickets using domain user permissions.
[unix-privesc-check](https://github.com/pentestmonkey/unix-privesc-check)
* Shell script to check for simple privilege escalation vectors on Unix systems. Unix-privesc-checker is a script that runs on Unix systems (tested on Solaris 9, HPUX 11, Various Linuxes, FreeBSD 6.2). It tries to find misconfigurations that could allow local unprivileged users to escalate privileges to other users or to access local apps (e.g. databases).
[LinEnum](https://github.com/rebootuser/LinEnum)
* Scripted Local Linux Enumeration & Privilege Escalation Checks
[linux-exploit-suggester.sh](https://github.com/mzet-/linux-exploit-suggester)
* linux-exploit-suggester.sh was inspired by the excellent Linux_Exploit_Suggester script by PenturaLabs. The issue with Pentura's script however is that it isn't up to date anymore (the script was last updated in early 2014) so it lacks some recent Linux kernel exploits. linux-exploit-suggester.sh on the other hand also contains all the latest (as of early 2017) publicly known Linux kernel exploits. It is also capable to identify possible privilege escalation vectors via installed userspace packages and comes with some additional minor features that makes finding right exploit more time efficient.
[cve-check-tool - Intel](https://github.com/clearlinux/cve-check-tool)
* Original Automated CVE Checking Tool
[Linux Kernel Exploitation - xairy github](https://github.com/xairy/linux-kernel-exploitation)
[Vuls: Vulnerability Scanner](https://github.com/future-architect/vuls)
* Vulnerability scanner for Linux/FreeBSD, agentless, written in golang.
[cvechecker](https://github.com/sjvermeu/cvechecker)
* The goal of cvechecker is to report about possible vulnerabilities on your system, by scanning a list of installed software and matching results with the CVE database. This is not a bullet-proof method and you will have many false positives (ie: vulnerability is fixed with a revision-release, but the tool isn't able to detect the revision itself), yet it is still better than nothing, especially if you are running a distribution with little security coverage.
[kernel-exploits - xairy](https://github.com/xairy/kernel-exploits)
* A bunch of proof-of-concept exploits for the Linux kernel
-------------------------------
## Setuid and Setgid
[Setuid and Setgid - ATT&CK](https://attack.mitre.org/wiki/Technique/T1166)
* When the setuid or setgid bits are set on Linux or macOS for an application, this means that the application will run with the privileges of the owning user or group respectively. Normally an application is run in the current user’s context, regardless of which user or group owns the application. There are instances where programs need to be executed in an elevated context to function properly, but the user running them doesn’t need the elevated privileges. Instead of creating an entry in the sudoers file, which must be done by root, any user can specify the setuid or setgid flag to be set for their own applications. These bits are indicated with an "s" instead of an "x" when viewing a file's attributes via ls -l. The chmod program can set these bits with via bitmasking, chmod 4777 [file] or via shorthand naming, chmod u+s [file].
[Setuid - Wikipedia](https://en.wikipedia.org/wiki/Setuid)
[SETGID(2) - man7.org](http://man7.org/linux/man-pages/man2/setgid.2.html)
[Special File Permissions (setuid, setgid and Sticky Bit)](https://docs.oracle.com/cd/E19683-01/806-4078/secfiles-69/index.html)
[Exploiting SUID Executables](https://www.pentestpartners.com/security-blog/exploiting-suid-executables/)
-------------------------------
## Sudo
[Sudo - ATT&CK](https://attack.mitre.org/wiki/Technique/T1169)
* The sudoers file, ****/etc/sudoers****, describes which users can run which commands and from which terminals. This also describes which commands users can run as other users or groups. This provides the idea of least privilege such that users are running in their lowest possible permissions for most of the time and only elevate to other users or permissions as needed, typically by prompting for a password. However, the sudoers file can also specify when to not prompt users for passwords with a line like user1 ALL=(ALL) NOPASSWD: ALL1.
* Adversaries can take advantage of these configurations to execute commands as other users or spawn processes with higher privileges. You must have elevated privileges to edit this file though.
[sudo(8) - Linux man page](https://linux.die.net/man/8/sudo)
[Sudo Main Page](https://www.sudo.ws/)
[sudo - Wikipedia](https://en.wikipedia.org/wiki/Sudo)
-------------------------------
## Valid Accounts
[Valid Accounts - ATT&CK](https://attack.mitre.org/wiki/Technique/T1078)
* Adversaries may steal the credentials of a specific user or service account using Credential Access techniques. Compromised credentials may be used to bypass access controls placed on various resources on hosts and within the network and may even be used for persistent access to remote systems. Compromised credentials may also grant an adversary increased privilege to specific systems or access to restricted areas of the network. Adversaries may choose not to use malware or tools in conjunction with the legitimate access those credentials provide to make it harder to detect their presence.
* Adversaries may also create accounts, sometimes using pre-defined account names and passwords, as a means for persistence through backup access in case other means are unsuccessful.
* The overlap of credentials and permissions across a network of systems is of concern because the adversary may be able to pivot across accounts and systems to reach a high level of access (i.e., domain or enterprise administrator) to bypass access controls set within the enterprise.
-------------------------------
## Web Shell
[Web Shell - ATT&CK](https://attack.mitre.org/wiki/Technique/T1100)
* A Web shell is a Web script that is placed on an openly accessible Web server to allow an adversary to use the Web server as a gateway into a network. A Web shell may provide a set of functions to execute or a command-line interface on the system that hosts the Web server. In addition to a server-side script, a Web shell may have a client interface program that is used to talk to the Web server (see, for example, China Chopper Web shell client).
[public-shell](https://github.com/BDLeet/public-shell)
* Some Public Shell
[php-webshells](https://github.com/JohnTroony/php-webshells)
* Common php webshells. Do not host the file(s) on your server!
[PHP-Backdoors](https://github.com/bartblaze/PHP-backdoors)
* A collection of PHP backdoors. For educational or testing purposes only.
[Weevely](https://github.com/epinna/weevely3)
* Weevely is a command line web shell dynamically extended over the network at runtime, designed for remote server administration and penetration testing.

+ 92
- 0
Draft/ATT&CK-Stuff/OS X/Mac Collection.md View File

@ -0,0 +1,92 @@
## Mac Collection
-------------------------------
## Automated Collection
[Automated Collection - ATT&CK](https://attack.mitre.org/wiki/Technique/T1119)
* Once established within a system or network, an adversary may use automated techniques for collecting internal data. Methods for performing this technique could include use of Scripting to search for and copy information fitting set criteria such as file type, location, or name at specific time intervals. This functionality could also be built into remote access tools.
[Lazagne](https://github.com/AlessandroZ/LaZagne)
* The LaZagne project is an open source application used to retrieve lots of passwords stored on a local computer. Each software stores its passwords using different techniques (plaintext, APIs, custom algorithms, databases, etc.). This tool has been developed for the purpose of finding these passwords for the most commonly-used software.
-------------------------------
## Clipboard Data
[Clipboard Data - ATT&CK](https://attack.mitre.org/wiki/Technique/T1115)
* Adversaries may collect data stored in the Windows clipboard from users copying information within or between applications.
* OSX provides a native command, pbpaste, to grab clipboard contents
[pbcopy & pbpaste: Manipulating the Clipboard from the Command Line](http://osxdaily.com/2007/03/05/manipulating-the-clipboard-from-the-command-line/)
-------------------------------
## Data Staged
[Data Staged - ATT&CK](https://attack.mitre.org/wiki/Technique/T1074)
* Collected data is staged in a central location or directory prior to Exfiltration. Data may be kept in separate files or combined into one file through techniques such as Data Compressed or Data Encrypted.
-------------------------------
## Data from Local System
[Data from Local System - ATT&CK](https://attack.mitre.org/wiki/Technique/T1005)
* Sensitive data can be collected from local system sources, such as the file system or databases of information residing on the system prior to Exfiltration.
-------------------------------
## Data from Network Shared Drive
[Data from Network Shared Drive - ATT&CK](https://attack.mitre.org/wiki/Technique/T1039)
* Sensitive data can be collected from remote systems via shared network drives (host shared directory, network file server, etc.) that are accessible from the current system prior to Exfiltration.
-------------------------------
## Data from Removable Media
[Data from Removable Media - ATT&CK](https://attack.mitre.org/wiki/Technique/T1025)
* Sensitive data can be collected from any removable media (optical disk drive, USB memory, etc.) connected to the compromised system prior to Exfiltration.
http://osxdaily.com/2007/03/05/manipulating-the-clipboard-from-the-command-line/
-------------------------------
## Input Capture
[Input Capture - ATT&CK](https://attack.mitre.org/wiki/Technique/T1056)
* Adversaries can use methods of capturing user input for obtaining credentials for Valid Accounts and information Collection that include keylogging and user input field interception.
* Keylogging is the most prevalent type of input capture, with many different ways of intercepting keystrokes,1 but other methods exist to target information for specific purposes, such as performing a UAC prompt or wrapping the Windows default credential provider.
* Keylogging is likely to be used to acquire credentials for new access opportunities when Credential Dumping efforts are not effective, and may require an adversary to remain passive on a system for a period of time before an opportunity arises.
* Adversaries may also install code on externally facing portals, such as a VPN login page, to capture and transmit credentials of users who attempt to log into the service. This variation on input capture may be conducted post-compromise using legitimate administrative access as a backup measure to maintain network access through External Remote Services and Valid Accounts or as part of the initial compromise by exploitation of the externally facing web service.3
-------------------------------
## Screen Capture
[Screen Capture - ATT&CK](https://attack.mitre.org/wiki/Technique/T1113)
* Adversaries may attempt to take screen captures of the desktop to gather information over the course of an operation. Screen capturing functionality may be included as a feature of a remote access tool used in post-compromise operations.
* On OSX, the native command screencapture is used to capture screenshots.

+ 247
- 0
Draft/ATT&CK-Stuff/OS X/Mac Command and Control.md View File

@ -0,0 +1,247 @@
## Mac Command and Control
-------------------------------
## Commonly Used Port
[Commonly Used Port - ATT&CK](https://attack.mitre.org/wiki/Technique/T1043)
* Adversaries may communicate over a commonly used port to bypass firewalls or network detection systems and to blend with normal network activity to avoid more detailed inspection.
-------------------------------
## Communication Through Removable Media
[Communication Through Removable Media - ATT&CK](https://attack.mitre.org/wiki/Technique/T1092)
* Adversaries can perform command and control between compromised hosts on potentially disconnected networks using removable media to transfer commands from system to system. Both systems would need to be compromised, with the likelihood that an Internet-connected system was compromised first and the second through lateral movement by Replication Through Removable Media. Commands and files would be relayed from the disconnected system to the Internet-connected system to which the adversary has direct access.
-------------------------------
## Connection Proxy
[Connection Proxy - ATT&CK](https://attack.mitre.org/wiki/Technique/T1090)
* A connection proxy is used to direct network traffic between systems or act as an intermediary for network communications. Many tools exist that enable traffic redirection through proxies or port redirection, including HTRAN, ZXProxy, and ZXPortMap.
* The definition of a proxy can also be expanded out to encompass trust relationships between networks in peer-to-peer, mesh, or trusted connections between networks consisting of hosts or systems that regularly communicate with each other.
* The network may be within a single organization or across organizations with trust relationships. Adversaries could use these types of relationships to manage command and control communications, to reduce the number of simultaneous outbound network connections, to provide resiliency in the face of connection loss, or to ride over existing trusted communications paths between victims to avoid suspicion.
-------------------------------
## Custom Command and Control Protocol
[Custom Command and Control Protocol - ATT&CK](https://attack.mitre.org/wiki/Technique/T1094)
* Adversaries may communicate using a custom command and control protocol instead of using existing Standard Application Layer Protocol to encapsulate commands. Implementations could mimic well-known protocols.
-------------------------------
## Custom Cryptographic Protocol
[Custom Cryptographic Protocol - ATT&CK](https://attack.mitre.org/wiki/Technique/T1024)
* Adversaries may use a custom cryptographic protocol or algorithm to hide command and control traffic. A simple scheme, such as XOR-ing the plaintext with a fixed key, will produce a very weak ciphertext.
* Custom encryption schemes may vary in sophistication. Analysis and reverse engineering of malware samples may be enough to discover the algorithm and encryption key used.
* Some adversaries may also attempt to implement their own version of a well-known cryptographic algorithm instead of using a known implementation library, which may lead to unintentional errors.
-------------------------------
## Data Encoding
[Data Encoding - ATT&CK](https://attack.mitre.org/wiki/Technique/T1132)
* Command and control (C2) information is encoded using a standard data encoding system. Use of data encoding may be to adhere to existing protocol specifications and includes use of ASCII, Unicode, Base64, MIME, UTF-8, or other binary-to-text and character encoding systems. Some data encoding systems may also result in data compression, such as gzip.
-------------------------------
## Data Obfuscation
[Data Obfuscation - ATT&CK](https://attack.mitre.org/wiki/Technique/T1001)
* Command and control (C2) communications are hidden (but not necessarily encrypted) in an attempt to make the content more difficult to discover or decipher and to make the communication less conspicuous and hide commands from being seen. This encompasses many methods, such as adding junk data to protocol traffic, using steganography, commingling legitimate traffic with C2 communications traffic, or using a non-standard data encoding system, such as a modified Base64 encoding for the message body of an HTTP request.
-------------------------------
## Fallback Channels
[Fallback Channels - ATT&CK](https://attack.mitre.org/wiki/Technique/T1008)
* Adversaries may use fallback or alternate communication channels if the primary channel is compromised or inaccessible in order to maintain reliable command and control and to avoid data transfer thresholds.
-------------------------------
## Multi-Stage Channels
[Multi-Stage Channels - ATT&CK](https://attack.mitre.org/wiki/Technique/T1104)
* Adversaries may create multiple stages for command and control that are employed under different conditions or for certain functions. Use of multiple stages may obfuscate the command and control channel to make detection more difficult.
* Remote access tools will call back to the first-stage command and control server for instructions. The first stage may have automated capabilities to collect basic host information, update tools, and upload additional files. A second remote access tool (RAT) could be uploaded at that point to redirect the host to the second-stage command and control server. The second stage will likely be more fully featured and allow the adversary to interact with the system through a reverse shell and additional RAT features.
* The different stages will likely be hosted separately with no overlapping infrastructure. The loader may also have backup first-stage callbacks or Fallback Channels in case the original first-stage communication path is discovered and blocked.
-------------------------------
## Multiband Communication
[Multiband Communication - ATT&CK](https://attack.mitre.org/wiki/Technique/T1026)
* Some adversaries may split communications between different protocols. There could be one protocol for inbound command and control and another for outbound data, allowing it to bypass certain firewall restrictions. The split could also be random to simply avoid data threshold alerts on any one communication.
-------------------------------
## Multilayer Encryption
[Multilayer Encryption - ATT&CK](https://attack.mitre.org/wiki/Technique/T1079)
* An adversary performs C2 communications using multiple layers of encryption, typically (but not exclusively) tunneling a custom encryption scheme within a protocol encryption scheme such as HTTPS or SMTPS.
-------------------------------
## Remote File Copy
[Remote File Copy - ATT&CK](https://attack.mitre.org/wiki/Technique/T1105)
* Files may be copied from one system to another to stage adversary tools or other files over the course of an operation. Files may be copied from an external adversary-controlled system through the Command and Control channel to bring tools into the victim network or through alternate protocols with another tool such as FTP. Files can also be copied over on Mac and Linux with native tools like scp, rsync, and sftp.
* Adversaries may also copy files laterally between internal victim systems to support Lateral Movement with remote Execution using inherent file sharing protocols such as file sharing over SMB to connected network shares or with authenticated connections with Windows Admin Shares or Remote Desktop Protocol.
-------------------------------
## Standard Application Layer Protocol
[Standard Application Layer Protocol - ATT&CK](https://attack.mitre.org/wiki/Technique/T1071)
* Adversaries may communicate using a common, standardized application layer protocol such as HTTP, HTTPS, SMTP, or DNS to avoid detection by blending in with existing traffic. Commands to the remote system, and often the results of those commands, will be embedded within the protocol traffic between the client and server.
*For connections that occur internally within an enclave (such as those between a proxy or pivot node and other nodes), commonly used protocols are RPC, SSH, or RDP.
-------------------------------
## Standard Cryptographic Protocol
[Standard Cryptographic Protocol - ATT&CK](https://attack.mitre.org/wiki/Technique/T1032)