Sans Automating RMF Steps Using Lightweight Scripts and Tools
Sans Automating RMF Steps Using Lightweight Scripts and Tools
gh
Automating RMF Steps Using Lightweight Scripts
Ri
and Tools
ll
Fu
ns
Author: Brett Fry, [email protected]
Advisor: Jonathan Risto
ai
et
rR
Accepted: September 19, 2022
ho
Abstract
ut
,A
Many Risk Management Framework (RMF) steps and sub-tasks can be accomplished
te
using small, lightweight tools and scripting. Only specific administrative tasks can be
itu
constraint results in many government organizations using different tools, creating their
In
own standards, and often buying costly tools to capture all the information needed. This
NS
research will explore the many tools and techniques that can be leveraged to accomplish
these steps and tasks using a set of scripts that focuses on efficiency and repeatability.
SA
Since RMF is not strictly a framework the United States government uses, this research
e
will benefit the community by providing tools and techniques to generate specific
Th
information required for implementing the RMF process or data collection activities.
22
20
©
gh
Ri
1. Introduction
ll
Fu
Automating many RMF steps, the primary Risk Management Framework for the
United States federal government, can be accomplished faster and more efficiently
ns
through scripting or using lightweight open-source tools than bulkier tools. Moreover,
ai
scripting can be used to baseline a system or network more efficiently and with more
et
specific results than bulkier tools that are usually cost-prohibitive or resource hogs.
rR
Using lightweight tools and scripts, an organization can automate many essential
ho
tasks in the Prepare step, which eMASS cannot. It can assist in assessing the
ut
effectiveness of the tools or security measures implemented in the Assess step and
,A
accomplish many of the tasks in the Monitor step.
te
itu
These scripts and techniques will assist the cybersecurity community by proving
st
process that integrates information security and risk management activities into the
20
gh
Ri
1.2. The problems with RMF and eMASS
ll
The RMF process can often be daunting and complicated. The federal government
Fu
does not use a single automated solution or product to collect information or complete
ns
required tasks that must be input into eMASS. All information and artifacts must be
ai
uploaded into eMASS to gain authorization for use.
et
eMASS, despite the current built-in automation, is often burdensome since no
rR
single script or solution can generate the requested information in the desired format.
ho
Using third-party products or applications that require installation or allocation of
ut
resources will often require a lengthy review process. Due to these constraints, built-in
,A
tools are the perfect solution to this problem. However, the staff tasked with assessing
te
and authorizing the systems or networks often have little experience with programming
itu
or scripting. Therefore, they will look to pre-built solutions, even if it generates more
st
information than required. Organizations often have to invest significant money and
In
resources in license fees for software that provides significantly more information than is
NS
needed and can greatly impact the application, system, or network performance. Since
SA
many applications are highly restricted, it usually requires detailed planning and a
stringent approval process to obtain authorization to install or run an application against
e
Th
collect the specific information required to implement RMF. A homegrown solution can
leverage the built-in tools available in eMASS to fully or partially automate the
©
authorization process without buying new tools, paying license fees, or training
personnel. This research targets particular areas that the current processes do not
automate. Moreover, eMASS and RMF leverage the National Institute of Standards and
Technology (NIST) Cybersecurity Frame to assist in validating and measuring aspects.
gh
Ri
2. Research Method
ll
Fu
2.1. Lab Components and Functionality
The testing environment uses a combination of operating systems due to the
ns
nature of many businesses. The US Government, specifically the Department of Defense
ai
(DoD), relies heavily on Unix and Linux operating systems for backend, penetration
et
rR
testing, and tactical systems. Except for NASA, which uses Linux as its primary OS,
most US Government workstations are Windows (Gunter, 2013). The test network shown
ho
in Figure 1 is a flat network intended to simulate part of a production network in a small
ut
office/home office environment.
Figure 1 ,A
te
Network Diagram
itu
st
In
NS
SA
e
Th
22
Since the focus is on RMF and automating the steps and tasks listed above, the
20
network will simulate various operating systems. However, it can also be tailored or
©
expanded to other networks. Each system on the network has a fresh install and has not
been hardened in advance to demonstrate the effectiveness in automating various aspects.
Moreover, anti-virus has been disabled or modified to allow malware to infect each
system.
2.2. Tools
Each tool was carefully chosen based on the following criteria:
gh
Ri
3. Ease of Use
ll
4. Ability to automate
Fu
Additionally, the ability to run without elevated privileges was preferred but not a
ns
sole determining factor. By using the resources on the system, an organization can reduce
ai
training requirements and the overall cost of additional tools, which often require
et
additional training. Additionally, implementing a solution like this will typically require
rR
someone skilled in programming or an entire development team. It is important to note
ho
that the scripts can collect most of the required information, so administrator privileges
ut
were unnecessary for many tasks and information collection requirements. However,
,A
running the scripts as a privileged user or service is possible and can produce more
detailed results and information.
te
itu
scripts. Furthermore, the organization can modify the scripts if additional requirements
In
arise to collect the additional required information. The scripts use multiple methods to
NS
demonstrate the effectiveness of the tools commonly available to most users. Appendix A
SA
Many of the scripts developed can function on larger, more segmented networks
e
Th
that will allow for pivoting if desired. These are scalable for use in a domain
environment, but the use cases will focus on a flat network given the size and mixed
22
environment.
20
gh
Ri
Lastly, the NIST Cybersecurity and Privacy Frameworks will be used to do a
ll
crosswalk with RMF to determine the percentage of each step that the scripts completed.
Fu
2.3.2. Experiments and Testing
ns
Through rigorous and careful testing in a lab environment, this research
ai
demonstrated that using lightweight and tailored tools, an organization could accomplish
et
many RMF steps and tasks through automation. Additionally, these processes
rR
simultaneously address the various aspects of the Cybersecurity Framework
ho
Requirements.
ut
After establishing the baseline, a series of tests took place to assess the
,A
effectiveness of the scripts. These tests included generating malicious traffic and
te
installing malware on the VMs and IoT devices. After running the tests, the baseline was
itu
compared to the current state to determine the percentage of anomalies detected. This
st
enabled the assessment of the implemented controls and remediation action using the
In
assess scripts. Lastly, the systems and network were then periodically scanned to detect
NS
changes in the baseline for anomalous behavior which might indicate malicious activity.
SA
various forms of malware using scripts. Coinminers and Trojan Horses were used based
Th
on industry findings that they are the most common types of malware in the wild (Center
22
for Internet Security, 2022; Cybersecurity and Infrastructure Security Agency &
20
Australian Cyber Security Centre, 2022; SonicWall Inc., 2022). However, the scripts also
identified Command and Control (C2) communications.
©
gh
Ri
3.1. Automation of RMF Steps and Tasks
ll
Since the RMF process is vast, this research will strictly focus on the steps and
Fu
tasks that are often manually completed or require significant information filtering if
ns
gathered by commercial tools. These tasks can be partially or fully automated using built-
ai
in applications or free and open-source software. Since RMF is not specifically for the
et
US Federal Government and is a decent framework for information systems and security,
rR
this process can significantly assist those wishing to transition to this Risk Management
ho
Framework.
ut
The three steps of the RMF Process that could greatly benefit from automation or
,A
partial automation are Prepare, Assess, and Monitor.
te
eMASS is currently unable to automate these steps or tasks. Therefore, an
itu
organization can automate information collection for the Prepare step through lightweight
st
tools and scripts. The tools and scripts can also assess the effectiveness of the security
In
measures implemented in the Assess step and accomplish many of the tasks in the
NS
Monitor step.
SA
The purpose of the Prepare step is to carry out essential activities at all levels of
Th
the organization to help prepare the organization to manage its security and privacy risks
22
This step is often one of the most protracted because all other efforts that follow
©
use the information collected in this step. To accurately perform this step, the network's
boundary must be defined, assets identified, and system stakeholders identified. Scanning
the network to identify all systems residing within the network boundary can accomplish
these tasks. All data generated from this step must be captured and documented.
The main tasks that can be automated are Baselining, Common Control
Identification, System Stakeholders, Asset Identification, and Authorization Boundary.
gh
Ri
scripting, baseline information can be collected for the enclave and later compared to the
ll
current configuration. This information can assist in detecting anomalies or changes in
Fu
the network or systems. Since baseline information is essential in the future, it is crucial
ns
to determine what information is collected. More importantly, to speed detection, it is
ai
imperative to determine the best method of parsing the information and comparing it to a
et
future state.
rR
Baselining can be accomplished by collecting the system and network information
ho
or statistics and then storing the information in a format that can later be easily parsed or
ut
filtered to detect differences or deviations. This process cannot always be fully
,A
automated, but it can assist in detecting changes that require further review.
te
The prepare04 scripts collect all information and output it in the raw format first.
itu
Next, the scripts normalize the data and output the information to a comma-separated-
st
value (CSV) or text format using utf8 encoding. This technique enables retention of the
In
original file, faster change detection, and standardizes the format so that it can be read
NS
and parsed by all operating systems. The prepare04 scripts accomplished these tasks
SA
using various tools. While the raw output might look slightly different, the essential
elements and parsed output are the same. Moreover, the prepare04 scripts include
e
Th
information. Hashing is a mechanism used to assist in ensuring integrity. The tools used
for collecting and hashing the information will vary depending on the operating system,
but the process is nearly identical. It is essential to use a robust hashing tool to ensure
there are no possibilities of collisions.
gh
Ri
Linux distributions come with numerous tools for hashing. Two command-line
ll
tools, shasum and sha256sum, were used to generate hashes and verify that the hashing
Fu
information output was correct. As with their Windows counterparts, these programs
ns
were integrated into the scripts to hash files or folders.
ai
Cross-platform tools, md5deep and hashdeep, are very robust. These programs
et
are often the tool of choice for the public sector in the United States. Moreover, these
rR
tools served as a mechanism to validate that the file hashing output was accurate.
ho
As demonstrated in Figure A1, the baseline_hash scripts gathered the required
ut
system file information and hashed it, accomplishing the sub-task of creating a baseline
,A
of the file system and folders. While this sub-task is not measurable per se, any person
te
could test and validate the script's accuracy by running it against a folder or folders and
itu
then comparing them. Additionally, the baseline_hash scripts use SHA256 hashing,
st
considered a very robust hashing algorithm and common throughout the industry
In
(Schatten, 2021).
NS
Next, ports, processes, services, and protocol information are collected and
SA
Figure 2
Th
Prepare04_netstat.bat Output
22
20
©
Note. On both Windows and Linux systems, the prepare04_netstat scripts identified all
open or running ports on a system and output them to an easy-to-read file.
Since eMASS only requires the port and protocol information for the entire
enclave a separate file in the prepare04 scripts parses the information and outputs only
the information required. A tool exclusive to Linux, ss, was also capable of providing the
exact information required for eMASS.
gh
Ri
The specific tools in Windows and Linux environments vary slightly for
ll
collecting process information. This sub-task quickly identifies malicious applications by
Fu
narrowing down changes in the system state.
ns
Collecting processes in a Windows environment was accomplished using tasklist,
ai
wmic, and the PowerShell cmdlets Get-Process and Get-WmiObject. Microsoft has
et
released a few robust programs as part of the Sysinternals Suite that can be run over the
rR
network or can locally investigate processes. Pslist is one of the tools integrated into the
ho
Windows scripts and used to identify detailed information about running processes. For
ut
Linux systems, ps is the best tool for the job. The ps tool is much more robust than
,A
tasklist, and it is comparable to wmic, PowerShell, and Sysinternals Pslist.
te
Figure 3
itu
Prepare04_processes.sh Output
st
In
NS
Note. The prepare04_processes.sh uses ps and other built-in Linux tools to format the
SA
output. The prepare04_processes scripts collect user, process, parent process, and
e
than on a Linux one. For the Windows systems, the scripts used the PowerShell Get-
©
Service cmdlet and command-line tools sc query and sc queryex to acquire the service
information. However, in a Linux environment, the method for identifying and collecting
service information varies depending on the distribution or system setup. One of Linux's
most common methods of obtaining service information is the service –status -all
command. On machines running systemd using the systemctl list-unit-files –type
service –all command works best. Therefore, the scripts written for Linux-based systems
enable users to select the method used to collect the information required.
In Windows and Linux environments, nmap, nc, and netstat can be used to
identify ports, protocols, and services running. After identifying and uploading the
gh
Ri
information, anything outside these processes, ports, protocols, or services captured will
ll
be deemed abnormal in the future.
Fu
Next, eMASS requires that network statistics, system states, and firewall rules are
ns
identified and documented during this step. Both Windows and Linux have a built-in
ai
solution for identifying firewall rules. In a Windows environment, the Netsh advfirewall
et
firewall show rule name =all command will output the current firewall rules. The
rR
iptables -l command can identify current configurations in a Linux environment. The
ho
prepare04_firewall scripts output the current information as a text file enabling the
ut
upload of the information.
,A
Since many organizations have Python installed on their systems, a cross-platform
te
solution to collect all the above information is using Python. This method is valuable
itu
since a single program collected and formatted all the information above using the os,
st
hashlib, csv, numpy, and psutil libraries. There is no need to go into detail since
In
specifics are within the Python scripts themselves and collecting most of the information
NS
Figure 4
e
Note. This code snippet demonstrates the logic used for the detection of the operating
system using the platform class of the sys library in Python.
Lastly, while only used for validation and collection of pcaps and statistics during
this research, more robust tools like Wireshark, pktmon, and tcpdump can monitor and
detect the ports and protocols running on a given system or network. Using these network
monitoring tools to capture information over a specific period can significantly assist in
identifying the requirements for network statistics.
gh
Ri
Most importantly, using the tools above and the prepare4 scripts collected and
ll
formatted all the required information for eMASS.
Fu
3.2.2. Prepare Task 5 – Identify Common Controls to Implement
ns
The task aims to identify, document, and publish organization-wide standard
ai
controls available for inheritance by organizational systems. An essential element to note
et
is that eMASS can automatically select controls for a system based on the inputs from the
rR
hardware and software asset inventory. Since RMF is not strictly limited to use by the US
ho
Government and eMASS is not accessible to private entities, a handful of common
ut
controls have been identified, and scripts have been used to validate them.
,A
The example controls come from the Center for Internet Security (CIS)
te
Benchmarks for a specific operating system. The scripts apply three common system
itu
hardening standards based on the operating system. The prepare5 scripts identified and
st
applied all configuration changes designed to harden the system. However, Lynis, as
In
shown in Figure A2, which is standard on many Linux systems, was used to identify any
NS
The scripts designed for Windows systems extensively used reg query to locate
e
the information and reg add to make modifications. However, the PowerShell scripts
Th
used the Get-Item, New-Item, and Remove-Item cmdlets to query, modify, and delete
22
registry values. The scripts designed for Linux extensively used the cat, grep, and find
20
tools. The output of these tools was then used to determine values and, if not hardened, to
make the required changes.
©
gh
Ri
For Windows systems, the PowerShell cmdlets Get-LocalUser and Get-
ll
LocalGroup were two effective methods of collecting user and group information used
Fu
in the prepare09 scripts. Other methods used for the Windows environment are net user
ns
and net localgroup. Since the lab environment does not contain an Active Directory
ai
setup, this research will not go in-depth about the tools available for this type of
et
environment. Moreover, using the scripts enabled the correlation of users to groups.
rR
For Linux systems, identifying users on the systems was accomplished using a
ho
similar process and filtering out any built-in accounts. Moreover, many Linux systems
ut
can identify users by searching the /home folder. Since automation is the key, the
,A
following commands were useful: cat /etc/passwd, cat /etc/group, getent passwd, and
te
getent group. Other commands used were compgen –u or compgen –g. However, since
itu
these commands are not always on every Linux distribution, using the /etc/passwd and
st
/etc/group files is the preferred method if running against multiple systems with different
In
Linux distributions.
NS
Overall, the prepare09 scripts quickly identified 100% of users and group
SA
accounts on each system. It is important to note that this task can only be partially
automated; it still requires direct interaction and validation by a human. However, it is
e
Th
easy to determine who logged in to a system or who last logged into it through scripting.
Moreover, it can determine what should be on the system. One approach is that an
22
organization can filter out the built-in account. Then using personnel data coupled with
20
login information, an organization can detect any irregularities such as stale or rogue
©
accounts.
gh
Ri
During the Prepare step, eMASS requires each system's asset information:
ll
Hostname, IP Address, Virtual Asset, Manufacturer, Model, Serial Number, Operating
Fu
System, and Memory Size. Next, eMASS requires inputting the following software
ns
information for Windows: Software Vendor, Software Name, and Software Version. For
ai
Linux systems, eMASS requires only the Software Name and Software Version.
et
The Windows system scripts used the PowerShell cmdlets Get-NetIPAddress,
rR
Get-NetConnectionProfile, Get-ComputerInfo, and Get-WmiObject. In the
ho
PowerShell scripts, two functions demonstrate how to accomplish the same task
ut
differently. Additionally, the batch scripts used the command line wmic tools to
,A
accomplish these tasks. In Linux, this is not a straightforward process.
First, many methods exist for identifying the hardware information on a Linux
te
itu
tree/model versus /sys/devices/virtual/dmi/id/. Using the same logic as with the Python
NS
scripts, an IF ELSE statement was used to detect if a file existed and if it did not, then it
parsed the information from the /proc/device-tree/model file. Next, identifying software
SA
will vary depending on the software installation method or Linux distribution. The two
e
methods to locate the information needed were dpkg -l and apt list.
Th
The prepare10 scripts quickly accomplished all requirements of this task. The
22
only portion not automated by these tasks are the software type and software license
20
information. This additional information can easily be input manually via eMASS. These
scripts are designed for individual hosts but can be modified to run against multiple
©
systems. As shown in Figure A3 and Figure A4, these scripts collected 100% of the
hardware and software information requirements by eMASS. Even better, the scripts
could format the output to match the required inputs by eMASS. Compared to the
Cybersecurity Framework, all scripts identified 100% of the requirements to complete
this step.
gh
Ri
relation to others. While the scripts written for this research will incorporate the ability to
ll
navigate the network and collect information, the research network is flat and, therefore,
Fu
will not go in-depth on this functionality.
ns
Both Windows and Linux environments use many of the same tools to accomplish
ai
this task. However, in a Windows environment, the netcat portable executable was used
et
instead of nc. Moreover, since Windows has limited packet capture abilities, Wireshark
rR
portable app was used to assist in the baseline of the network portion,
ho
In a Windows environment, command-line tools, the netsh interface ipv4 show
ut
neighbors, ipconfig, route, arp -a, and ping were very useful in collecting this
,A
information. PowerShell Test-Connection or Get-NetNeighbor cmdlets were used to
accomplish the bulk of the primary network discovery. Tools like netcat or nmap were
te
itu
information gathering were conducted using ping, ifconfig, ip route, ip addr, ip neigh,
NS
and arp -a. Since nc is already standard on many Linux systems, this tool is very
efficient at providing detailed information on ports. Since nmap is often pre-installed on
SA
many Linux distributions and is easily scriptable, this research included it in the tests.
e
By leveraging the tools above, the prepare11 scripts rapidly identified all systems within
Th
compromise. The Assess step aims to determine if the controls selected are implemented
correctly, operating as intended, and producing the desired outcome to meet the security
and privacy requirements for the system and the organization.
During the Assess step, information collected during the Prepare step and
baselining process can assist in identifying any deficiencies in running configurations or
implementing a standardized hardening script to improve the system's overall security.
gh
Ri
During this step and the following step, the vulnerabilities and detection methods
ll
will vary depending on the specific operating system.
Fu
3.3.1. Assess Task 3 – Control Assessments
ns
The automation of this task requires using available benchmarks or secure
ai
baseline information. CIS Benchmarks are an excellent place to obtain information on a
et
particular system or application and will provide an overview of hardening standards and
rR
risks to systems. Tools such as Microsoft Baseline Security Analyzer and Lynis for
ho
Linux can also detect any known issues that might need to be addressed.
ut
The first thing to reference when assessing controls is any documentation
,A
regarding secure configurations of the specific application or system. Next, determine the
te
implementation status of these configurations; if these configurations are not applied, run
itu
scripts to apply them and address the vulnerability. The information required to complete
st
this task is collected in the Prepare step. However, if it is not collected, this would be the
In
time to collect the information or run a script to identify any vulnerabilities and mitigate
NS
them. Using Boolean expressions and built-in tools in both Windows and Linux operating
SA
systems, a security professional can create a tool to identify if control is implemented and
also run a test against it.
e
Th
Lastly, assessing the control requires testing it to ensure it behaves correctly. The
assess3 scripts were able to address all the use cases done in this research. Later in this
22
paper, this topic will be covered more in-depth, but it is essential to point out that these
20
gh
Ri
developed to accomplish the same task. While Lynis is a near-perfect solution for
ll
identification it does not have the ability to automate correction of the issues identified.
Fu
Figure 5
ns
Lynis Output
ai
et
rR
ho
ut
,A
te
itu
st
In this task, any configuration errors that might still exist after tasks 3 and 4 can
NS
again be programmatically addressed. These actions might entail data collection or the
SA
removal of malicious software. After remediation, Assess tasks 3 and 4 must be rerun to
ensure that remediation has been successful.
e
Th
3.3.4. Persistence
22
malicious actors can enable persistence on a system. While the implementation and
mechanisms for persistence vary by the operating system, finding and identifying them is
©
gh
Ri
finding persistence are running a script to check for any cron jobs using crontab -l or cat
ll
/etc/crontab file. Often malware will attempt to maintain persistence in Linux using this
Fu
method. However, if file or folder permissions are not properly set, an attacker can hide
ns
in numerous locations or maintain persistence using startup scripts. Some common
ai
locations for these scripts are: /etc/inittab, /etc/init.d, /etc/rc.d, /etc/init.conf, /etc/init,
et
/etc/rc, /sbin/rc, and /sbin/init.d.
rR
Organizations can determine if remediation is required by running the
ho
assess03_04 script to query current configurations and automated tasks. The services that
ut
need to be disabled will vary from organization to organization, and the scripts are
,A
designed to demonstrate one method of assessing controls.
One of the limitations of the assess03_to_05 scripts for Linux was that it searches
te
itu
for only common startup locations. Due to the nature of Linux, a service can be run from
any location. However, cron jobs can be viewed using the crontab-l or cat /etc/crontab.
st
In
However, as shown in Figures A5, A6, and A7, tasks 3, 4 and 5 can be
NS
accomplished using the assess03_to_05 scripts to determine if the actions are detected or
not. Suppose the changes are not functioning as planned. In that case, the assess03_to_05
SA
scripts will run to remove or disable any unneeded tasks or services and validate that the
e
controls are implemented and functional. The scripts identified the state of the control. If
Th
a concern was identified, the scripts prompted the user to take remediation action. If
22
gh
Ri
system and environmental changes were detected. On a Windows system, comparing two
ll
files using the PowerShell Compare-Object cmdlet was the best solution. However,
Fu
Windows systems do not possess a very robust tool for comparing files outside of
ns
PowerShell. Rudimentary tools, fc.exe and comp.exe, can be used but often generate
ai
more information than is practical or desired.
et
Linux distributions ship with many robust tools for comparing files or hashes.
rR
Since the number of applications commonly found on Linux is so vast, the research
ho
focused on the most common and those that can rapidly detect changes with ease. The
ut
diff, colordiff, cmp, sdiff, emacs, and vimdiff detected changes rapidly in Linux.
,A
Another standard is Meld; while this is a GUI-based tool, it is very robust and capable of
te
detecting changes. Moreover, Python’s filecmp module can quickly detect differences in
itu
text-based documents.
st
Hash and change detection conducted in the Monitor step is crucial to finding
NS
issues with processes, services, files, folders, and system changes in general. Often
SA
during baselining in the Prepare step and using it in the Assess and Monitor steps.
22
Figure 6
20
Monitor01_process.ps1 Output
©
Note. This output is not abnormal. If an executable path or name changed, that would be
a concern, but new or missing processes are not necessarily indicators of compromise.
New processes should be examined but could be a standard deviation from the baseline.
gh
Ri
baseline information and monitor01 scripts detected all the changes in minutes.
ll
While changes are not always specific indicators of malicious action, these scripts
Fu
were able to detect changes in critical files, processes, and services. This detection
ns
method is handy in detecting malware. Most importantly, it can detect actual
ai
indicators of compromise and known malicious hashes. Identifying malicious hashes
et
can be done by feeding the hashes of the files collected to a service like VirusTotal.
rR
3.4.3. Evasion Detection
ho
It is crucial to monitor all environments for signs of detection evasion. Often the
ut
most common method of hiding information is changing attributes to hidden.
,A
Additionally, Alternate Data Streams (ADS) can be used on the Windows system to hide
te
information from view. Since there are legitimate uses for Alternate Data Streams, the
itu
scripts only identify the Zone.Identifiers and not $DATA files. On the Windows systems,
st
command-line tools dir /r and streams -s to identify all Alternate Data Streams shown in
NS
Figure A8. The scripts used Powershell cmdlet, Get-ChildItem -Force, and the
SA
command-line tool dir /a:h /s to locate all hidden files and folders.
The monitor01_evasion_detection for Linux used the find, ls -a, and dir -a tools to
e
Th
locate all hidden files and folders. It is important to note that Alternate Data Streams in
Linux are just regular files and, therefore, not hidden from view. However, in both
22
file and folders searched for on each system as demonstrated by Figure A9 and Figure
©
A10. While hidden files or folders are not always indicative of compromise, ensuring
they are identified can be used to detect deviations from the baseline. If an unexpected or
unexplainable file is detected, as shown in Figure 7, it should be investigated.
Figure 7
Compare-HiddenFilesList.ps1 Output
Note. This output is not abnormal. This only indicates that a new hidden file was located.
gh
Ri
3.5. Remote Admin Tools
ll
3.5.1. PSEXEC.EXE
Fu
PsExec is a lightweight tool that allows executing processes on other systems,
ns
complete with full interactivity for console applications, without needing to install client
ai
software manually.
et
Using the psexec scripts, it can be determined if remote administrative tools were
rR
used on or against a Windows system. The scripts query the status of registry keys and
ho
system logs to detect the use of PSEXEC.
ut
If nothing is detected, the psexec scripts were able to remediate this and enable
,A
command-line auditing. The scripts detected each instance the registry was modified,
te
resulting in a 100% detection rate. This script was successful because PSEXEC requires
itu
acceptance of the EULA before use. Moreover, this action creates a registry artifact on
st
the system. As shown in Figure A11, this task can be assessed by running PSEXEC on
In
the system. If the script above identifies the use of PSEXEC, it is successful. If the
NS
The psexec scripts can be used to harden the system by enabling auditing of
e
processes and the command-line. It can also block PSEXEC outright if it is not a standard
Th
tool used in that organization. The monitoring task was addressed using a scheduled task
22
to periodically run the psexec_query scripts on Windows and alert anyone that logs in if
20
the use of PSEXEC is detected. Since PSEXEC can be a legitimate administrative tool,
administrators should review alerts and correlate the time with a specific action.
©
3.5.2. SSH
While SSH is a typical remote administration tool, monitoring is still essential.
The network_forensic scripts look for information inside log files to accomplish this
task. Moreover, the service status can be checked and disabled by the ssh scripts. Tools
like fail2ban can detect and respond to multiple bad authentication attempts without
locking the account and instead leverage iptables to restrict the offending network or ip
address.
gh
Ri
It is best practice to disable unneeded or unused services. If ssh is not required, it
ll
can and should be turned off. Using the ssh scripts can identify if the service is running.
Fu
The ssh scripts can stop, disable, and create a cron job to periodically query the log files
ns
for specific terms and send an alert if something is detected. Using the information in
ai
Assess task 3, users can check the status of the service. If running, it can be stopped, or a
et
task can be created to query the ssh logs. If the service is needed and running, it can be
rR
tested by logging in multiple times using incorrect information. If fail2ban is configured,
ho
it should block after three tries, and the log queries should create some entries for each
ut
failed attempt. If not successful, it can be remediated by rerunning the ssh scripts and
,A
manually checking the status using the services or systemctl commands.
te
The ssh_monitor script checks if ssh is enabled. If it is, it will then check if
itu
fail2ban is installed; if not, it will install it. Next, it will create an iptables rule and a
st
Tools like mimkatz can dump credentials on a system with relative ease.
e
Guard is not enabled, it will be selected as a control for this task. The credentialGuard
20
scripts can verify the registry values and determine if Credential Guard is enabled. If
©
Credential Guard is not enabled, the credentialGuard scripts will enable it. Furthermore,
the scripts will prompt the user if they would like to harden other password protection
mechanisms available in Windows.
gh
Ri
applied to system files, it can allow access to /etc/passwd and /etc/shadow files, thus
ll
enabling attackers to dump the credentials and later crack them. The assess04 scripts
Fu
which will in turn verify that the appropriate files and folders are hardened to prevent
ns
access or copying. Next, Lynis will be run to verify a secure configuration. If a secure
ai
configuration is not in place, the assess05 scripts can automate all the required changes.
et
3.6.4. Linux - Monitor Task 1
rR
Using tripwire or AIDE to monitor files and folders can alert and log any changes
ho
or attempts at unauthorized access.
ut
,A
3.7. Anomalous Network Behavior and C2 Channels
te
3.7.1. Host-Based Detection
itu
system. In a Linux environment, scanning /proc/ and using lsof are terrific methods of
In
finding hidden processes and activities. However, in a Windows environment, netsh and
NS
pktmon can be used to detect malicious traffic. On most Linux systems, iptables can
also be used to detect and log unusual traffic. These command-line tools often go
SA
overlooked since GUI tools provide simple filtering of the activity or network-based
e
firewalls or tools for filtering with little training. However, these tools can enable a user
Th
While the use of netsh, iptables, pktmon, netstat, or ss are all beneficial and
capable tools, there are times when tools designed to scan the network or capture traffic
are required. Tools like nmap, pf0, tshark, and tcpdump are all capable of performing
these tasks and can be automated. Moreover, while slightly outside the scope, a portable
executable of Wireshark can be used for graphically viewing and filtering pcaps
captured. It can also be used to collect the network information and then use the tools
above to filter out the relevant information.
The network_forensics scripts developed could detect anomalous behavior,
specifically the functions that focus on system detection. Since typically, tcpdump,
gh
Ri
tshark, pf0, and pktmon tools often require human interaction to look for specific
ll
anomalous activity, the functions in the script focused on this task require user input.
Fu
Therefore, results will vary based on the skill or experience of the user. However, using
ns
pcaps with specific known anomalous activity, the script could identify User-Agent
ai
strings, known malicious IP addresses, scanning, and packetcrafting.
et
3.7.3. Intrusion Detection
rR
Using honeyports, netsh, and iptables, all traffic directed at these systems was
ho
detected. While not always the case, honeyports can be used to identify malicious
ut
activity and block it quickly. Since it is a cross-platform solution, it can be used to
,A
automate the detection of scans and leverage netsh or iptables to alert and block
te
anomalous activity. These tools, therefore, can serve to automate the monitoring tasks.
itu
Using many of the tools outlined earlier in the research, users can combine them to
NS
The scripts used were explicitly created to detect specific pieces of malware and the
changes made in the environment. However, it is essential to note that the Compare
e
scripts and the information collected in the baseline process also detected the file
Th
changes.
22
20
3.8.1. Cryptominer
According to researchers at Trend Micro, one of the most common virus types
©
targeting users are crypto miners (Oliveira & Fiser, 2020). While these might appear
harmless, they can consume resources, reduce performance, and open additional
backdoors that malicious actors can leverage. For this reason, they must be detected
early. The task of locating active crypto miner viruses for Linux was near impossible. Of
the fifteen attempts, none were functional. The issue seems to be that domain registrars
and ISPs block nearly all C2 communication or shut down the C2 sites. However, the
executable worked on Windows, but only on the 64-bit OS. This virus behaved very
strangely. It appeared to make a massive number of requests which did not require a
script to identify because it was that obvious. Next, the malicious network traffic was so
gh
Ri
obvious using netstat that it enabled the quick identification of the malicious processes.
ll
Some running processes were hidden, which is another red flag, but these processes can
Fu
be identified. Multiple registry changes were made, and a handful of files changed,
ns
missing, or created in the filesystem. Most were stored within User\<Username>\App
ai
folders. The virus appeared to have issues connecting to some of its IP addresses, but it
et
seems to connect to many at once. Moreover, using the network_forensic scripts, User-
rR
Agent scripts and known malicious IP addresses were detected.
ho
3.8.2. Windows – Assess Tasks
ut
On a Windows system the control identified was DisableRunOnce and user access
,A
to the registry. Using this information, the coinminer script can validate run once, and
te
user access to the registry is disabled. Next, the coinminer script can make the
itu
appropriate changes to the registry, specifically the DisableRunOnce key and user
st
registry access.
In
NS
using the basic scripts based on changes in the environment. The coinminer scripts were
e
created to periodically query the registry, scheduled tasks, processes, services, known file
Th
locations, and outbound network connections for the IOCs and generate an alert. These
22
scripts worked but were unnecessary since the virus was obvious and CPU usage was
20
near 100%.
©
Given that this virus is a Trojan horse, the best prevention method is training
users and administrators to continually validate the checksum of any software they wish
to install and ensure it is from a known or trustworthy source.
gh
Ri
However, while prevention is ideal, detection is a must. Therefore, using a
ll
combination of the tools created to detect persistence, hashing, and beaconing, the
Fu
malware could be detected and removed.
ns
The scripts could detect the filesystem changes, persistence mechanism, and
ai
newly created processes by comparing the baseline to the current running configuration.
et
Using the hashes enabled it to alert on a possible known virus. The netstat portion of the
rR
script also identified the C2 channel being used to connect to the internet.
ho
While the commands used were not detected, this was an expected result of the
ut
setup and not a flaw in the script. This result should trigger a review of the controls and
,A
monitoring steps in a real-world environment. Implementing some basic command line
te
auditing could have been identified using a log query for the specific commands.
itu
st
DisableLocalMachineRunOnce
e
Th
Using this information, the sysjoker scripts will verify that it is not in use and then
generate a status report. Next, the sysjoker scripts will DisableRunOnce and re-validate
22
With this specific virus, many indicators of compromise were rapidly detected
using the basic scripts based on changes in the environment. The sysjoker scripts were
created to periodically query the registry, scheduled tasks, processes, services, known file
locations, and outbound network connections for the IOCs and generate alerts.
gh
Ri
files and then report them. Using this information, the sysjoker scripts make the file
ll
permissions more restrictive based on any vulnerabilities identified.
Fu
3.8.8. Linux - Monitor Task
ns
As with the Windows monitoring steps the sysjoker scripts were created to check
ai
the system for changes periodically. Additionally, it checks the setuid bit to determine if
et
it is set.
rR
ho
4. Recommendations and Implications
ut
Organizations often do not take the proper time to research solutions that can
,A
reduce costs and collect the specific information required to meet their business needs. In
te
today’s fast-paced technology industry, the focus is often on the latest and greatest gadget
itu
or commercial solution, which is often not in line with business objectives. Most
st
commercial solutions are one-size-fits-all, but often this leads to excessive amounts of
In
data collection, baselining, assessing, and monitoring with reliable and repeatable
methods. Most importantly, by developing the tools in-house, an organization can tailor
22
Using the RMF, an organization can address many risks using automated
©
processes. The step most often overlooked is the Prepare step. Vast resources and energy
must be allocated to collecting and parsing data for later comparison. Collecting and
documenting detailed baseline and system information can often rapidly detect even the
slightest deviations later. Moreover, ensuring a secure baseline configuration makes
completing the Assess and Monitor steps easier. In a production environment, scripts can
periodically collect a new system state and compare it to the baseline or a future state.
The more information is collected and updated, the more effectively it will identify
changes.
gh
Ri
One method of implementation would be creating a script each time the system
ll
boots and then comparing it to the previous version. If a change is detected, the system
Fu
should send an alert so that it can be addressed. Direct human interaction or review is a
ns
best practice to validate the findings since not all system changes are malicious.
ai
These techniques can also be used with great success in a larger organization. In a
et
Windows environment, Active Directory tools can usually be automated to gather this
rR
information more efficiently and effectively. AD Tools can quickly identify users of a
ho
system and also identify the location or department of the users if configured correctly.
ut
Through group policies, baselines and configurations can easily be pushed to systems
,A
ensuring they all comply with organizational standards. Lastly, tools like Ansible or
te
Puppet can be leveraged to implement these in larger mixed networks.
itu
Assess, and Monitor Steps of the RMF process for mobile platforms. Another area often
NS
overlooked and not well documented is the many GUI applications native to Windows
SA
and Linux systems that can often be used to implement a more robust solution. Although
e
they are not easily automated, they are still often effective at accomplishing a specific
Th
task.
22
5. Conclusion
20
©
gh
Ri
process. Using hashes and comparing system states is highly effective at detecting
ll
deviations even if they are not known or identified as malicious. Using these tools and
Fu
techniques, administrators can rapidly identify evil in their environment while collecting
ns
the information requirements for RMF and eMASS.
ai
et
rR
ho
ut
,A
te
itu
st
In
NS
SA
e
Th
22
20
©
gh
Ri
References
ll
Fu
Center for Internet Security. (2022, March 15). Blog: Top 10 malware February 2022.
ns
CIS. Retrieved August 14, 2022, from
ai
et
https://www.cisecurity.org/insights/blog/top-10-malware-february-2021
rR
Cybersecurity and Infrastructure Security Agency, & Australian Cyber Security Centre.
ho
(2022, August 4). Alert (AA22-216A) - 2021 Top Malware Strains. CISA.
ut
Retrieved August 19, 2022, from https://www.cisa.gov/uscert/ncas/alerts/aa22-
,A
te
216a
itu
https://www.dcsa.mil/is/emass/
SA
Gunter, J. (2013, May 10). International Space Station to boldly go with linux over
e
https://www.telegraph.co.uk/technology/news/10049444/International-Space-
22
Station-to-boldly-go-with-Linux-over-Windows.html
20
Mechtinger, A., Robinson, R., & Fishbein, N. (2022, January 11). New SysJoker
©
backdoors and targets windows, linux, and macos. Retrieved July 16, 2022, from
https://www.intezer.com/blog/incident-response/new-backdoor-sysjoker/
Mihăilă, P., Bălan, T., Curpen, R., & Sandu, F. (2017). Network automation and
https://doi.org/10.1515/macro-2017-0011
Oliveira, A., & Fiser, D. (2020, September 10). War of linux cryptocurrency miners
a battle for resources. Trend Micro. Retrieved July 17, 2022, from
gh
Ri
https://www.trendmicro.com/en_us/research/20/i/war-of-linux-cryptocurrency-
ll
miners-a-battle-for-resources.html
Fu
Red Canary. (n.d.). Mitre ATT&CK technique T1003: Credential dumping. Red Canary.
ns
ai
Retrieved July 17, 2022, from https://redcanary.com/threat-detection-
et
report/techniques/credential-dumping/
rR
Schatten, J. (2021, March 24). Rehashing Hashing: What is SHA-256? Retrieved August
ho
ut
7, 2022, from https://www.ssltrust.com/blog/what-is-sha-256
,A
Slandau. (2022, June 6). 10 of the most dangerous malware threats in 2022. CyberTalk.
te
Retrieved August 19, 2022, from https://www.cybertalk.org/2022/06/06/10-of-
itu
the-most-dangerous-malware-threats-in-2022/
st
In
SonicWall Inc. (2022). (rep.). Mid-Year Update: 2022 SonicWall Cyber Threat Report.
NS
https://www.sonicwall.com/medialibrary/en/white-paper/mid-year-2022-cyber-
e
Th
threat-report.pdf.
SteelCloud. (2022, May 27). EMASS automation and uniting the missing security
22
20
https://www.steelcloud.com/emass-automation-and-uniting-the-missing-security-
compliance-data/
Tegelaar, K. (2019, October 7). Monitoring with powershell: external port scanning.
https://www.cyberdrain.com/monitoring-with-powershell-external-port-scanning/
gh
Ri
Appendix
ll
Network Layout
Fu
The test environment consists of the following systems and devices: VMWare
ns
Workstation 16, one Netgear GS108E ProSAFE Plus Switch, one GLiNet wireless router,
ai
one 32-bit Windows 10 virtual machine, one 64-bit Windows 10 virtual machine, one
et
Debian 11 virtual machine, one Raspberry Pi 3 running RaspiOS, and two Raspberry Pi 2
rR
running RaspiOS.
ho
Tools and Scripts
ut
,A
These scripts and techniques will assist the cyber security community because
they will serve as a proof of concept in demonstrating the effectiveness of homegrown
te
itu
more resources to implement. These scripts can also be modified to save to a network
NS
Tools
Windows Powershell Linux Python
e
echo Get-WMIObject ss os
Th
gh
Ri
wmic os get caption Get-LocalGroup
wmic csproduct get vendor Get-LocalUser
ll
Fu
wmic service get Get-FileHash
wmic startup Get-WinEvent
ns
wmic memorychip
ai
wmic memphysical
et
wmic product
wmic share
rR
wmic useraccount
ho
ut
Scripts
,A
The scripts used in the research will be available shortly at
te
https://github.com/FryGuy01/ along with more detailed use cases, screenshots,
itu
and software use documentation. The repository is private, please send me a
request via email for access, thanks. I will make a publicly accessible page shortly.
st
In
Prepare Step
SA
Figure A1
Baseline_hash.ps1 Output
e
Th
22
20
Figure A2
©
Lynis Output
Figure A3
Prepare10.bat Hardware Output
gh
Ri
Figure A4
ll
Prepare10.bat Software Output
Fu
ns
ai
et
rR
Assess Step
ho
Figure A5
ut
Assess03_to_05.ps1 Script Output
,A
te
itu
st
Figure A6
In
gh
Ri
Figure A7
ll
Assess03_to_05.ps1 Script Output
Fu
ns
ai
et
Monitor Step
rR
Figure A8
ho
Hidden.ps1 ADS_Scanner Output
ut
,A
te
itu
st
Figure A9
In
Figure A10
Hidden.sh Hidden_Scanner Output
gh
Ri
Multiple Steps
ll
Figure A11
Fu
Assess03_to_05.ps1 Script Output
ns
ai
et
rR
Note. This output is not abnormal. However, to accomplish the assess 3, 4, and 5 tasks
ho
the script prompts the user if they wish to perform testing or remediation action for the
ut
controls.
Malware IOCs
,A
te
SysJoker
itu
st
Windows IOCs
In
Type Name
NS
D8C4E8C28807A11B32E1C21D88096D854E2190C377A0E667548
Hash 7F2A275144EE6
SA
File C:\ProgramData\SystemData\tempo1.txt
File C:\ProgramData\SystemData\tempo2.txt
e
File C:\ProgramData\SystemData\tempo2.txt
Th
File C:\ProgramData\SystemData\tempi2.txt
22
File C:\ProgramData\SystemData\temps1.txt
File C:\ProgramData\SystemData\temps2.txt
20
File C:\ProgramData\SystemData\tempu.txt
©
File C:\ProgramData\SystemData\microsoft_windows.dll
File C:\ProgramData\SystemData
File C:\ProgramData\SystemData\igfxCUIService.exe
1ffd6559d21470c40dcf9236da51e5823d7ad58c93502279871c3fe771
Hash 8c901c
Service/Prog
ram igfxCUIService
HKEY_CURRENT_USER\Software\Microsoft\
Persistence Windows\CurrentVersion\Run igfxCUIService
IP 142.251.36.238
Linux IOCs
File /.Library/
File /.Library/SystemServices/updateSystem
gh
Ri
File /.Library/SystemNetwork
File /.Library/log.txt
ll
Fu
Persistence @reboot (/.Library/SystemServices/updateSystem)
ns
Coinminer
ai
Other than the file hash and a few strange user-agent strings found using the
et
network_forensic scripts there were too many IP addresses and files created and
rR
changed in the system to list here. The text file output from the programs will be located
ho
on GitHub. The raw baseline and post virus run will also be included. There were also
ut
many requests made to known malicious IP addresses.
,AWindows IOCs
te
Type Name
itu
st
Hash 75ac88c8819efbd6bb63137b2d9bee0bbda1e4f9b80c170cb9e97142eebb3694
In
User-
Agent Go HTTP Client
NS
User-
Agent Rocke
SA
e
Th
22
20
©