2019-08-25 00:00:36 +00:00
# Malware analysis on Gorgon APT campaign (23-08-19)
## Table of Contents
* [Malware analysis ](#Malware-analysis )
+ [Initial vector ](#Initial-vector )
+ [First stage ](#First )
+ [Second stage ](#Second )
2019-08-25 16:17:41 +00:00
+ [Loader + Frombook ](#Loader )
2019-08-25 00:00:36 +00:00
+ [Cyber kill chain ](#Cyber-kill-chain )
* [Cyber Threat Intel ](#Cyber-Threat-Intel )
* [IOC ](#IOC )
* [References MITRE ATT&CK Matrix ](#Ref-MITRE-ATTACK )
* [Links ](#Links )
+ [Original Tweet ](#Original-Tweet )
+ [Link Anyrun ](#Links-Anyrun )
+ [Ref previous analysis ](#Documents )
## Malware-analysis <a name="Malware-analysis"></a>
### Initial vector <a name="Initial-vector"></a>
###### Use a document with a macro as initial vector. On the code of the macro, some functions with differents names are used with the same code inside for obfuscate and make more harder the analysis.
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Macro/Samefunctions.PNG "" )
###### Use in more at the function, strReverse for reverse the data. Finally, combine it and execute it with a Shell request.
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Macro/macroCode.png "" )
###### This use mshta command for download and execute the external content. The bitly URL go on the pastebin share and is the first stage.
2019-08-25 14:46:10 +00:00
### First stage <a name="First"></a>
###### The first stage executed on the computer is a js script who use nested unescape (3 times).
2019-08-25 00:00:36 +00:00
2019-08-25 14:46:10 +00:00
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Loader%20stage%201/Unescape1.PNG "" )
###### At the 3th layer, we can see a vb script using some obfuscating methods (StrReverse, splited variables, multiples Wscript objects)
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Loader%20stage%201/Unescape3.PNG "" )
###### Finally, the script kills the word, excel, publisher and powerpoint instances, add a persistence for re-executes this script for reinfecting the computer and create two schedule task for the second stage and close the hidden window. The persistence by Run key can look like useless but it used like an updating vector for change the TTPs or executing a kill switch on the operation.
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Loader%20stage%201/VBcodefinal.PNG "" )
### Second stage <a name="Second"></a>
###### The first pastebin use too a js script with with 3 layers of unescape and the previous obfuscating methods.
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Loader%20stage%202/Unescape3.PNG "" )
2019-08-25 16:17:41 +00:00
###### we can observe two additionnal requested pastebin links, the first use the LoadWithPartialName funcion by Reflection Assembly in NET framework for download and execute raw hex data in memory, in addition, this execute an array of byte of the PE downloaded by a hijack of the calc program. The second pastebin link close the hidden window.
2019-08-25 14:46:10 +00:00
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Loader%20stage%202/VBcodefinal.PNG "" )
2019-08-25 16:17:41 +00:00
### Loader + Frombook <a name="Loader"></a>
#### Loader
###### The loader have one layer of obfuscation in using the getstring method for have the command and the data of the future dll.
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Loader%20subPaste/tab.PNG "" )
###### After this replace the caracters %_ by 0x with the replace function for get a valid array of hex bytes and execute it in memory.
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Loader%20subPaste/layer2tab.PNG "" )
###### The dll is protected with the ConfuserEx (1.0.0.0) protector, we can see the escaped caracters and the reference module.
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Loader%20subPaste/confuserExref.png "" )
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Loader%20subPaste/confStrings.png "" )
2019-08-25 20:42:51 +00:00
###### Once the protection removed, we can see the functions used by the dll.
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Loader%20subPaste/unpack.png "" )
2019-08-25 23:10:49 +00:00
###### The run method get the payload string push by the second PE, decode it and execute it.
2019-08-25 20:42:51 +00:00
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Loader%20subPaste/run.png "" )
2019-08-25 23:10:49 +00:00
#### Frombook
###### We can observe on the structure, the encoding for scale the data and add junk code on the PE for avoid the detection of the AV (here, in the "Currentversion" string.
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Frombook/dec.png "" )
###### This sample is programming in C++ (Frombook is available in many language : VB, C, C++, C#...) and check the PE structure.
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Frombook/CheckPE.png "" )
###### This continue to detect and steal the data from the navigators.
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Frombook/choicenav.png "" )
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Frombook/chrome.png "" )
##### This parsed and steal the passwords.
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Frombook/config.png "" )
##### We can observe the useragent settings who send the data to the C2.
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/Frombook/useragent.png "" )
##### This use a run key as persistence for the frombook module.
##### Some features of Frombook form the cyberbit analysis can be observed in this analysis and the execution on the anyrun sandbox :
* ###### Keystroke logging
* ###### Clipboard monitoring
* ###### HTTP/HTTPS/SPDY/HTTP2 form and network request grabbing
* ###### Browser and email client password grabbing
* ###### Capturing screenshots
* ###### Bot updating
* ###### Downloading and executing files
* ###### Bot removing
* ###### Launching commands via ShellExecute
* ###### Clear browser cookies
* ###### Reboot the system
* ###### Shutdown the system
* ###### Download and unpack ZIP archive
### Cyber kill chain <a name="Cyber-kill-chain"></a>
###### These process graphs represents the cyber kill chain of the initial vector and the Frombook module.
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/cyber.PNG "" )
![alt text ](https://raw.githubusercontent.com/StrangerealIntel/CyberThreatIntel/master/Pakistan/APT/Gorgon/23-08-19/Images/cyberfrom.PNG "" )
### Cyber Threat Intel<a name="Cyber-Threat-Intel"></a>
2019-08-25 00:00:36 +00:00
## References MITRE ATT&CK Matrix <a name="Ref-MITRE-ATTACK"></a>
###### List of all the references with MITRE ATT&CK Matrix
|Enterprise tactics|Technics used|Ref URL|
| :---------------: |:-------------| :------------- |
|||
|||
|||
|||
## Indicators Of Compromise (IOC) <a name="IOC"></a>
###### List of all the Indicators Of Compromise (IOC)
| Indicator | Description|
| ------------- |:-------------|
|||
||IP C2|
|http[:]//|URL request|
||Domain C2|
###### This can be exported as JSON format [Export in JSON]()
## Links <a name="Links"></a>
* Original tweet: https://twitter.com/Rmy_Reserve/status/1164405054746460161 < a name = "Original-Tweet" ></ a >
2019-08-25 23:10:49 +00:00
* Anyrun Link: < a name = "Links-Anyrun" ></ a >
+ [IMG76329797.xls ](https://app.any.run/tasks/3cff3642-1d54-4a66-8f0d-256f0065479b )
+ [inj2.exe ](https://app.any.run/tasks/d7365b93-470c-4e2e-bc6d-5e43c711d72e )
2019-08-25 16:17:41 +00:00
* Docs : < a name = "Documents" ></ a >
2019-08-25 23:10:49 +00:00
+ [Gorgon analysis by Unit42 ](https://unit42.paloaltonetworks.com/unit42-gorgon-group-slithering-nation-state-cybercrime/ )
+ [The Evolution of Aggah: From Roma225 to the RG Campaign ](https://securityaffairs.co/wordpress/89502/malware/evolution-aggah-roma225-campaign.html )
+ [Frombook analysis from cyberbit (June 2019) ](https://www.cyberbit.com/blog/endpoint-security/formbook-research-hints-large-data-theft-attack-brewing/ )