Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

How they extracted and analysed the Control Flow graph in runtime (detailed steps) ? why it's useful ?

In the C-FLAT prototype, they extract and analyze the control flow graph (CFG) during
runtime by using a combination of program analysis, instrumentation, and runtime
operation. Here are the detailed steps:

1. Instrumentation Phase: The program binary is analyzed and instrumented using their
tool. The tool collects information about direct branches and loops from the binary. This
data is stored in the branch table and loop table data structures which are part of the
Runtime Tracer in the software image loaded onto the Raspberry Pi 2 device.
2. The program is then instrumented so that each control-flow instruction in the target
program passes control to Trampolines that belong to the Runtime Tracer. These
Trampolines intercept all control-flow instructions.
3. Runtime Operation: During the execution of the program, the C-FLAT Library serves as
a mediator between the attested program and the Measurement Engine. The cfa_init
function initializes a new control-flow trace for attestation, and cfa_quote generates the
attestation response from the initialized trace.
4. When the target program is executed, all control-flow instructions are intercepted by
the Runtime Tracer Trampolines. The Runtime Tracer identifies the source and
destination address of the observed branch and the type of control-flow instruction that
caused it.
5. The Measurement Engine is then triggered by the Runtime Tracer. The Measurement
Engine performs the incremental measurement of the runtime control-flow path. It
computes the cumulative Auth using the BLAKE2 hash function.
6. Control is transferred back to the Runtime Tracer, which resumes execution of the target
program at the destination address of the observed branch.

This approach is useful for multiple reasons:

 It provides a method for real-time tracking and attestation of control-flow, enabling the
detection of unexpected behavior or tampering during runtime.
 The extraction and analysis of CFG at runtime offers a way to enforce the control-flow
integrity, making the system more secure.
 The ability to perform these measurements in an isolated, secure environment
(TrustZone) means that even if the main operating system or application is
compromised, the integrity of the control-flow attestation process is maintained.
 This approach could potentially be used to detect both software and hardware-level
attacks that aim to manipulate the control-flow of a program.
 The use of unique node IDs for CFG nodes allows for precise tracking of control flow,
making it easier to identify specific points of deviation or tampering.
Can we use Control Flow graph to analyse Fileless malware ?
Yes, analyzing the Control Flow Graph (CFG) can be a helpful approach in the detection
and analysis of fileless malware.

Fileless malware refers to malicious software that operates directly in memory instead of
writing files to the hard drive, making it harder to detect using traditional, file-based
antivirus solutions. The malware typically leverages legitimate system tools or runs
scripts directly in memory to avoid detection.

Analyzing the CFG can provide insights into the behavior of a process in memory, which
is particularly useful when dealing with fileless malware. The CFG is a representation of
all paths that might be traversed by a program during its execution. This can be used to
understand the possible execution paths of a fileless malware and how it interacts with
system processes.

By comparing the observed CFG of a process with an expected or benign CFG, we can
potentially detect anomalies that suggest the presence of fileless malware. For instance,
unusual control flow patterns or unexpected calls to system libraries might indicate
malicious activity.

That said, the effectiveness of this approach depends on the complexity of the malware
and the analyst's understanding of the expected behavior of the system and
applications. Moreover, advanced fileless malware might employ various evasion
techniques, such as API function hooking or process hollowing, which can make the
detection and analysis more challenging. Nevertheless, CFG analysis remains a valuable
tool in a comprehensive malware detection and analysis strategy.

What malware features we can find in assembly and CFG ?


Analyzing a malware's assembly and Control Flow Graph (CFG) can provide critical
insights into its operation and features. Here are some malware features that can be
detected:

1. Function Calls and System API usage: Malware often utilizes specific system or library
calls for malicious activities. For instance, certain API functions may be used to
manipulate files (like WriteFile, DeleteFile in Windows), create network connections (like
socket, connect), or to manipulate processes (like CreateProcess, OpenProcess). In the
assembly code, these function calls can be identified and analyzed.
2. Obfuscation Techniques: Malware often uses obfuscation to hinder analysis and evade
detection. This may include techniques like packing, encryption, or the use of
polymorphic or metamorphic code. In the CFG, this might result in unusual or complex
control structures.
3. Control Flow Anomalies: Malware may use unconventional control flow techniques to
confuse static analysis tools. These could include indirect jumps or calls, or executing
code in a non-sequential manner. These anomalies can be identified in the CFG.
4. Loops and Repetitive Actions: Frequent or repetitive actions can indicate a malware's
behavior like scanning for files, spamming a network, etc. These can be identified in the
assembly code as loops, and visually in the CFG as cyclic paths.
5. Unusual Branch Conditions: Conditional branches based on unexpected or hidden
parameters could indicate an attempt to hide malicious behavior or to activate under
specific conditions.
6. Dead Code and Redundancies: Dead code (code that is never executed) or redundant
operations might be inserted to confuse analysts or to inflate the apparent complexity
of the malware. These can also be identified via CFG analysis.
7. Interrupts and Exception Handling: In the assembly code, interrupts or exception
handling routines can be identified. Malware might use these to manipulate its
execution flow or to recover from potential errors.
8. Inline Assembly and Self-modifying Code: The presence of inline assembly or self-
modifying code is often an indicator of malicious intent, as these techniques can be
used to complicate analysis or to hide malicious behavior.

did you answered all the questions from the given content only?
ChatGPT
Yes, all the answers provided are based on the provided content and my training data up until
September 2021. However, in your latest question about malware features that can be found in
assembly and CFG, while the provided content discussed various aspects of ARM binaries, control
flow graphs, and their manipulation, it did not directly address malware analysis. As such, the
response about malware features is based on general principles of malware analysis and my training
data, rather than the specific text you provided. I attempted to relate these general principles back to
the techniques discussed in the provided content where possible.

You might also like