Sandboxing with Sysmon

My Sysmon use case was mostly about analyzing malware activity in a sandbox, where in the past, I had to orchestrate few utilities to collect process and network activity logs from various sources. The issue with this approach is that sometimes the focus tends to shift towards organizing collected data more than analyzing it.

In the last update to Sysmon View, I added two more features:

  • Visualization of Process creation hierarchy.
  • Ability to import network packet capture for correlation with the Sysmon Network event

The second feature helps in advancing analysis, for example, looking up packet payload, tracing the entire session conversation or even analyzing non-standard port use (MITRE T1065).

Importing a network capture file

To do this, we need an exported XML Sysmon log (check GitHub on how to import logs to Sysmon View) and a matching (captured within the same time frame) packet trace file (PCAP or PCAPNG file). Once Sysmon logs are imported, you can add/import the network trace file as shown here

1_6_JUN_2019

Tshark is needed for all of this to work, it is used to convert the PCAP/PCAPNG files to JSON for parsing; it is also used to extract (filter) packets later. Tshark is part of Wireshark installation, and its path must be set in Sysmon View preferences as shown here (Wireshark is also needed to view extracted packets)

2_6_JUN_2019

Once packet capture file is imported, Sysmon View will correlate any Sysmon network event with a matching network conversation (packets), the event’s “details” box will display a link to indicate that a matching network capture exist for a specific event

3_6_JUN_2019

Clicking this link will run Wireshark with a temporary generated file (in the form of Capture_Year_Month_Day_Hour_Minute_Second.pcapng) with a Wireshark filter matching network event source, destination (IP and Port) and transport (TCP or UDP)

7_6_JUN_2019

To be able to test this feature, a time-matching logs needs to be generated, to help make this task more productive, I created a small command line utility, “Sysmon Box”…

Sysmon Box

5_6_JUN_2019

While testing Sysmon View I spent a good deal of time and effort trying to generate logs from both, Sysmon and Wireshark, so, to save yours, I created a small command line utility, “Sysmon Box” to help in automating this process, here is a description of what the tool will do when running the following command (Sysmon needs to be readily installed):

SysmonBox -in Wi-Fi
  • Start capturing traffic (using tshark in the background, this is why specifying the capture interface using the -in option is mandatory to be passed to tshark)
  • Generate Sysmon and traffic logs, when done, hit CTRL + C to end the session
  • Sysmon Box will stop traffic capture, dump all captured packets to a file and then export Sysmon events logged between the start and end time of the session using EVT utility
  • Build a Sysmon View database file (backup existing database, if any) with imported data, all you have to do is to run Sysmon View from the same folder or copy the database file (SysmonViewDB) in the same folder as Sysmon View (keep the captured packets files in the same location, they will be referenced by Sysmon View)

With Sysmon Box you have a mini (tiny) box running for analyzing behavior at process and network levels.

Sysmon View Database

If you use Sysmon Box or Sysmon View to import data, you can then skip using Sysmon View GUI and use the database directly for analysis, the database is an SQLite database, you can use any free database client tool to read the data, for example, to list all hashes, you can run the following SQL statement

SELECT * FROM AllHashes

Here is the output

4_6_JUN_2019
Similarly, you can extract other information, such as registry keys, DNS queries or do a full-text search in addition to building more complex queries to identify malware behavior; the data model allows for correlating more data, beyond what Sysmon is logging (e.g. geo-mapping, VirusTotal ratings, network traffic, etc.). Additionally, this database file can be shared (safely) with others as a full “running session.”

Downloads

  • The full data model for Sysmon View database is published on Github
  • All tools are uploaded to Github

Stay safe.

Sysmon View 1.4 released!

HeadImage

My last blog entry was about Sysmon View 1.2, since then, Sysmon View went through many changes and updates, related to bug fixing, enhancements and recently, the addition of the new WMI events.

WMI Events and All Events View

Sysmon View can now import the WMI events (WMIFilter, WMIConsumer, and WMIBinding), however, there is no way to actually view those events in Sysmon View directly, only because the first view was meant to focus on binaries logically grouped using the GUID field, and the second view was a geo-mapping of the IP addresses from Network events. This was an issue for events like WMI and “Driver loaded” events, which lead to creating the third “All Events” view…

SysmonAllEventsView

The 3rd view works like a pivot table by grouping related events of the same type, or of the same session (GUID), can sort by event time and have a detailed search through any imported events. Furthermore, expanding events provides access to their ID’s that look like hyperlinks, by clicking an ID number (this is an ID from the database itself, not a Sysmon generated data) you can invoke the detailed view of that event, view related sessions and query virus total for more information (hashes and IP addresses)

Here is the screenshot of an imported Sysmon log from a ransomware running session, with events grouped by type

SysmonAllEventsView2.png

Searching for the “delete” word reveals the use of vssadmin.exe with the same word passed as an argument, from there, I was able to track back to all the events sequence related to that session…

SysmonAllEventsView3

Open Database

Sysmon View generates an SQLite database for all the imported events, this database can be loaded by any instance of Sysmon View (for example, passed from another analyst). The database can be read by any application or script, it contains summaries of hashes, executables, IP addresses, ports, geo mappings, registry entries, which are all logically linked through a binary file name or a session (executable GUID)

SysmonDatabase

In the case Sysmon View UI is not sufficient, another UI can be created using the database, and Sysmon View can be used as an import utility (work on progress to create a command line interface)

Sysmon Shell – Release 1.1

I have just uploaded a new version of Sysmon Shell (v1.1)

SS1

Here is the list of updates:

  • Added new configuration options to include or exclude an entire event log, for example (Surprisingly missing in version 1.0):
    <PipeEvent onmatch=”include”/> or <PipeEvent onmatch=”exclude”/>
  • If you are using Sysmon for malware analysis, you might find the last tap marked “Logs Export” useful, as it allows exporting Sysmon logs to an XML file, for example (the exported XML log files can be loaded into Sysmon View for analysis and visualization) the export feature has 3 options:
    • Export only
    • Export and clear Sysmon event log (to mark new analysis starting point)
    • Export, backup evtx file, and clear the event log

SS3

  • In case you are applying Sysmon configuration using Sysmon Shell and not directly using Sysmon, the hash of Sysmon image being executed will be used to run the configuration command will show in the preview pane

SS2

The new version can be found on my Github

Please contact me to report any bugs or suggestions

Visualizing & Tracking Sysmon events with Sysmon View 1.2

With Sysmon View 1.1, I was able to view Sysmon logs visually. However, this drawn image was somehow incomplete as I was unable to track the entire process hierarchy (maybe because I was busy laying down the foundation). With version 1.2, following a process through its hierarchy is now possible, additionally, when investigating an event, it is easy now to get to (trackback) all other events related (associated) to the same session.

Example: in the following image, let’s track the history of events related to “AcroRd32.exe” process

1

Double-clicking on the “process create” event reveals the details of this event (notice that the “Parent process GUID” is being highlighted as a hyperlink), the “event details” is showing “Explorer.exe” as the parent process…

2

New to Sysmon View 1.2: Before proceeding further, let’s talk about the new events details window. In this window, you can retrieve all event’s data, and query virus total for hash information as shown in the next screenshot (You will have to get an API key to enable virus total queries). In the case of network events, query Virus Total for IP and domains information, including whois data, in addition to “jumping” to the logged registry keys in regedit.

3

Now back to our topic, clicking “Parent process GUID” link will bring up the parent process session (in this example, Explorer.exe) and all events associated with it

4

To go further deeper, repeat the same steps recursively: let’s go to the details of the “process create event” of “Explorer.exe”, which shows the parent process as “userinit.exe”

5

Again… lets get the details of “userinit.exe” parent process though the details of the process create event details…

6

Which reveals “winlogon.exe” as the parent process, lets further dig behind the parent process “winlogon.exe” details…

7

You got the idea…

Now you might be asking what the hyperlink of “Process GUID” does, well, it will re-draw (visualize) the same session under investigation again, so why the duplication? well, its not, this is feature is needed for the “Map view”…

8

When selecting a destination country (Map View will be available if you enabled geo ip setting when importing the XML log data), then all network events related to that “destination” will be listed, now to track back to all events within the context of a running session, click the “Process GUID” field…

9

And from there, it’s easy to track that process hierarchy or any other event associated with it

For any questions or suggestions, please contact me by email.

Updated Sysmon View

Here is the latest list of updates to Sysmon View (v1.1), the tool incorporated much of the feedback received (thank you all), bug fixing and adding new features:

  • Bug fixes related to internal database connectivity errors
  • Bug fixes related to UI not to be reset after resetting data
  • Bug fixes related to the way information about binary images (executables) are collected
  • Sysmon View design is now based on multiple visual modules (currently there are two modules)
  • “Process View” got an additional “filtering” option that will show images (executables) that are being reported with specific selected events types. For example, to view the timeline of a process, but excluding its network and Image loaded events, then a filter can be applied to narrow down the results (as shown in the following screenshot), which in turn, helps narrow down the number of listed binaries to be investigated.

  • Map View: the new view displays network events based on destination country (Geo IP lookup), this will work only if the “geo-location” option was selected during the import process. Selecting any country will display the relevant network events.

For any questions or suggestions, please contact me by email.

Sysmon View

Although the noise generated by Sysmon could be reduced through filters applied in its XML configuration, it is still somehow too much to look at, (I usually tend to log everything when doing reverse engineering).

The main idea behind Sysmon View is to aid in the analysis of Sysmon logs using “visual” reporting modules, which are based on specific (useful) use cases.

The utility is still in its initial stages, I am releasing it with the first reporting module which can:

Step 1 – Filter binary images (executables) according to their file name

Step 2 – Further filter binary image files (selected from step 1) according to their path, which might be helpful in investigating anomalies in images location (Images with the same name running from multiple locations)

Step 3 – Visualize Sysmon events (related to binaries filtered through step 1 and 2), but per image logged session (this is Sysmon process GUID in action)

The utility can then help “visually” line up (sorted by time) the different events associated with a particular session.

To get started, you need to export Sysmon events first to an XML file using WEVTUtil (I could have designed the tool to connect and retrieve-pull the logs from the server directly, but Sysmon View was not designed to be used as live log analysis tool)

WEVTUtil query-events “Microsoft-Windows-Sysmon/Operational” /format:xml /e:sysmonview > eventlog.xml

Once exported, run Sysmon View and import the generated file “eventlog.xml” (or the name you selected). Note that this might take some time, depending on the size of the logged data (this needs to be done once per log file, subsequent runs do not need any imports, and can be reloaded using File -> Load existing data menu option, which will load previously saved data again)

1

Sysmon View will build an internal database that I will discuss its structure in upcoming posts and how to utilize its content (which by the way is an SQLite database file).

2

Once the log file is imported, you can start searching through the collected binary images, which can be easily filtered

3

4

Double-clicking any of the binary images will show the path location(s) reported by Sysmon, which will help in identifying anomalies in path location at this stage as previously outlined

5

Double-clicking an image path entry will cause the tool to collect all sessions (again, this is the process GUID in action) for that image entry that was running from that location

6

Double-clicking any of the sessions entries will generate a tree of events sorted by event’s logged time

7

Double-clicking any event block will reveal more details in a floating window (you will notice some additional entries that do not exist in Sysmon XML schema, as previously mentioned, I will elaborate more on this and the internal database structure in upcoming write-ups)

8

Sysmon View can be downloaded (32 & 64 builds) from Github link @ this link, For any questions or suggestions, please contact me by email.

Sysmon Shell

Sysmon Shell can aid in writing and applying Sysmon XML configurations through a simple GUI interface, it can also be used to learn more about Sysmon configuration options available with each release, instead of digging behind the XML Schema, in a nutshell:

  • Sysmon Shell can load Sysmon XML files configurations: with version 1.0, I am only supporting the latest schema v3.30 for Sysmon v6.01, future updates to Sysmon will be supported. Also, the tool won’t be loading any configuration of Sysmon from the registry.
  • It can export/save the final XML to a file.
  • It can apply the generated XML file by calling Sysmon.exe -c directly (creating a temp XML file in the same folder where Sysmon is installed), for this reason, it will need elevated privileges (the need for this is inherited from Sysmon), the output of applying the configuration will be displayed in the preview pan (Sysmon output)
  • XML Configuration can be previewed before saving in the preview pane
  • The utility contains descriptions for all events types taken from Sysmon Sysinternals home page (https://technet.microsoft.com/en-us/sysinternals/sysmon)

What it won’t do: warn you about Include/Exclude conflicts or attempt to validate the rules itself, however, once the configuration is applied, the preview pane will display the output from Sysmon to show the results (this is the output of Sysmon -c command), from which errors can be identified

Following is a screenshot of Sysmon Shell in action

ScreenCapture

Sysmon Shell can be downloaded from my Github.

Please contact me to report any bugs or suggestions