Module 5: Windows Client-Side Attacks
Attacking Microsoft Office
Social Engineering and Spearphishing
Social Engineering is where an attacker tricks a user into disclosing secrets or engaging in risky technical actions via deception.
Spearphishing is a form of phishing in which an email is customized to the target, increasing likelihood of the victim succumbing to the attack.
Typically the attack comes in three forms:
User solicitation
Malicious attachment
Malicious link
Installing Microsoft Office
This is specific to the OffSec labs.
Navigate to C:\tools\windows_client_side_attacks\ and double click the Office2019.img file to mount it. Run the installer Setup64.exe located in the Office directory on this new mount. Close the pop-up to begin a 7-day trial.
Using Macros
Macros are a series of command and instructions grouped together to accomplish a task programmatically.

Setting up a listener for our infected attachment reverse shell to connect to
Protected View followed by Compatibility Mode both stop the macro from executing. In our scenario, we'll select Enable Editing followed by Enable Content so the macro executes.
Table of all SysmonEvents within the minute of downloading and running Meterpreter
Limiting the Sysmon events to ProcessCreate
Querying the FileCreate events
Querying the following events
Querying the DNSEvent created by the malicious attachment
When encountering network indicators of suspicious activity, it is worthwhile to check other resources in your environment such as firewalls and proxies. Reviewing these resources may mean the difference between a successful infection or a potential incident that was stopped with automated mechanisms.
Searching for NetworkConnect events with the identified IPv4 address
Monitoring Windows PowerShell
Introduction to PowerShell Logging
PowerShell logging can be enabled via group policy. The settings for PowerShell logging are located in Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell.

PowerShell Module Logging
Module logging records all pipeline execution events in PowerShell, showing the order and details of the executing activity.


Runnin Get-WMIObject to generate events
The event ID for module logging events is 4103.
Pipeline Execution events with Module Logging
Expanding an entry to view the content
Context entry of Get-WMIObect, Format-Table event
The Command Name is the cmdlet that initiated the pipeline execution. If it was a script, it would be shown beside Script Name. The Sequence Number tracks the order for PowerShell event execution while Pipeline ID is the unique ID for a given pipeline.
PowerShell Script Block Logging
Script block logging captures the contents of code contained within script blocks, including some deobfuscated commands.

Generating an event
The event ID for Script Block events is 4104.
Script Block event
Encoding a Get-Hotfix PowerShell cmdlet
Executing the encoded PowerShell command
Script block event for the encoded command
PowerShell Transcription
Transcription generates full records of a PowerShell session, with all input and output stored in a text file.
Information saved in a transcript is in cleartext, ensure these files are secured properly.

Generating an event
Transcription file header information
Transcription logging input command and output
Case Study: PowerShell Logging for Phishing Attacks
Custom Function Get-PSLogEvent for PowerShell logs
Extra Mile
In regards to the Extra_Mile.msg:
Identify the .exe that runs the malicious .hta file with Sysmon.
Identify the PowerShell script block and module log events generated by the malicious attachment.
Find the malicious attachment activity in a PowerShell transcription log.
Obfuscating/Deobfuscating Commands
Obfuscation is not the same as encoding. Encoding is a translation that is meant to be converted and restored using the same encoding scheme. Obfuscation is the deliberate act of makin something harder to understand for evasive purposes.
Invoke-Obfuscation Menu
Setting Script Block command for Invoke-Obfuscation
Invoke-Obfuscation: Obfuscating command tokens menu
Invoke-Obfuscation: Obfuscated Cmdlets
Moving back to the Token submenu
Invoke-Obfuscation: Obfuscating argument tokens menu
Invoke-Obfuscation: Obfuscated Arguments
Showing optiosn in Invoke-Obfuscation
Obfuscated command generating expected results
Script Block Log event for obfuscated command
Module Log event for obfuscated command
Importing Revoke-Obfuscation module
Obfuscated PowerShell script
Exporting PowerShell log events using wevtutil
Deobfuscated PowerShell script from Event Logs
Last updated