Field Notes: Agent Tesla Open Directory

Posted on 2018-05-22 by Adam Swanda

InQuest discovered an open directory hosting several Agent Tesla payloads, as well as several separate web panels for the administration of different Agent Tesla malware campaigns. We decided this was a good time to have a quick look at this malware family, it's capabilities, and the artifacts found in the open directory.

Agent Tesla is a malware family written in .NET for Microsoft Windows systems and has much in common with spyware in it's capabilities. It has many spyware like capabilities such as stealing credentials, keylogging, collecting screenshots, capturing web camera images, and gathering clipboard data, but it is often seen in more standard malware campaigns and uses common malware techniques for obfuscation, unpacking, and data collection. Recently, Agent Tesla has been distributed in the wild through phishing emails and malicious Word documents containing macros to drop and execute the malware.

While not directly related, Agent Tesla could almost be considered an evolution of the Pony/Fareit malware family in that it is most often used in campaigns by being coupled with another primary malware payload and its main use is for information collection from infected hosts while the primary malware performs it's designated task.

Field Notes

Field Notes is a new blog post series meant to quickly share threat data, Indicators of Compromise, commentary on current events, or other brief types of analysis with the community at a higher level without performing in-depth reverse engineering or deep dives into a given campaign, actor, infrastructure, or otherwise. Many researchers often post short briefs on campaigns or threats as Pastebin posts, GitHub Gist's, or Twitter threads but we feel this blog format is a great medium to get across not only the technical analysis and indicators but also some contextual information on the threat or event of focus. The complete series can be browed by tag:field-notes.

Agent Tesla Execution

Once an Agent Tesla payload gets executed, it creates a second process/payload and ultimately transfers execution to this process in a rather standard way. The second process gets created in a suspended state, and executable code is written to it using the WriteProcessMemory call. Once completed, the ResumeThread function gets called, and the secondary payload runs.

After extracting the unpacked version of the secondary payload, we can analyze the final .NET malware. Using conventional analysis tools for .NET like Reflector and dnSpy reveal mangled function and class names, paths that lead to nowhere, and overall a highly obfuscated application.

During some analysis attempts within my Windows Virtual Machine, Reflector itself would crash when attempting to decompile certain sections of the source code. After moving to other analysis applications, dnSpy and ILSpy, I was able to dig through the code without further issue.
Even though the code is highly obfuscated, manually digging through the code can give you the overall idea of what each function does, and you begin to understand the bigger picture. At this point, I began renaming functions to more suitable names that explained their use, such as "DecryptString" or "SendC2Message".

Below is a screenshot of the function used to decrypt strings throughout the malware. This particular decryption routine is used in almost every function throughout the samples for strings such as Command and Control addresses, HTTP methods, C&C commands, Windows Registry entries, directory names, and more.

String Decryption

Agent Tesla also includes the capability to avoid analysis by sandboxes or within Virtual Machines. For example, the following DLL's and system artifacts can be checked for to determine if the malware is running inside a sandbox or VM, if specific Anti-Virus software is being used, or the system is otherwise being monitored:

avghookx.dll

avghooka.dll

snxhk.dll

dbghelp.dll

api_log.dll

dir_watch.dll

pstorec.dll

vmcheck.dll

wpespy.dll

Sf2.dll

cmdvrt32.dll

SxIn.dll

VirtualBox

vbox

vmware

Many of the DLL's listed come directly from the Al-Khaser application which is meant to test malware analysis environments to ensure the sandbox environment is well disguised from commonly looked for virtualization or analysis tools that legitimate malware often checks for.

Another notable attribute of the analyzed samples was the shared PDB of "C:\Users\Admin\Desktop\IELibrary\IELibrary\obj\Debug\IELibrary.pdb". This PDB was found across all samples, and upon some minor OSINT, it was discovered this same PDB is in many malicious files in the wild that all contact similar Command & Control URLs.

Functionality
Agent Tesla has many malicious features common to most malware, including:

Recording keystrokes

Copying clipboard data

Capture screenshots

Capture Webcam recordings

Steal credentials from browsers and other installed applications

Credential theft occurs against the following applications if installed, and send the resulting data back to the C&C server using one HTTP request per stolen credential set:

Mozilla Firefox

Google Chrome

Internet Explorer

Apple Safari

Opera

Torch Browser

SeaMonkey

UC Browser

ComodoDragon

FileZilla

FTPCommander

WinSCP

SmartFTP

WS_FTP

CoreFTP

Internet Download Manager

JDownloader

Microsoft Outlook

Mozilla Thunderbird

Opera Mail

TheBat!

Fox mail

Eudora

PocoMail

Pidgin

Paltalk

Web Panel & Open Directory

Recent campaigns of Agent Tesla appear to be using the C&C URL of /WebPortal/api.php and this case is no different. In the open directory, we found this same file and several samples discovered in the wild were reporting back to the same URL at their own Command & Control servers.

The analyzed payloads can also communicate with a C&C server over SMTP, instead of HTTP, but this was not used in any of the samples. Remnants of the email messages that would have been crafted can be seen in names such as "set_Subject", "set_Body", and "SmtpClient". Other unused functions include the ability to collect system information such as processor information, total memory, and total free disk space.

The screenshot below shows what the login page of the administration web panel looks like:

Portal Login

Open Directory
Once we discovered the open web directory, we immediately crawled the site to pull down the contents for examination. The screenshot below provides a high-level view of the directory structure and shows the numerous other Web Panels hosted on the same C&C server.

Open Directory Index

By taking a look at the source code of the Web Panel, we can see it is PHP as are most malware web panels and is encoded using the popular IonCube encoding method. While we won't be de-obfuscating this here, even having a quick look at the pages available to the malware administrators is useful to get a glimpse into what they see when controlling infected hosts. Below is the screenshot showing the first level extracted contents of WebPanel.zip and the files within the "pages" directory, which sheds some light on the functionality available to an administrator of this malware.

Directory Structure

From here we can see there is the central panel from which they can capture and view screenshots, web camera video, view victim keystrokes, and view collected passwords.

File Artifacts
The following information details the executable files and zipped web panel found within the open directory we discovered. Each executable is it's own Agent Tesla payload, while WebPanel.zip contains the PHP and HTML that compromises the administrative panel for the malware itself.

These samples have been made available to the public on our GitHub repository malware-samples.

Detections, Mitigations, and Remediations

Agent Tesla may seem like common malware, but with its recent campaigns, it may be a formidable malware family that defenders need to begin to pay attention to more closely.

The likely vectors of infection for this malware include the common vectors such as through phishing email lures, malicious documents, and potentially Exploit Kit delivery.

Indicators of Compromise

C&C Servers

hxxp://78.128.76.165/~t1onishl/kc/WebPanel/api.php

hxxp://78.128.76.165/~t1onishl/nonso/WebPanel/api.php

hxxp://78.128.76.165/~t1onishl/sammy/WebPanel/api.php

hxxp://firstshipone.com/WebPanel/api.php

hxxp://31.220.40.22/~idoyrddf/mavlad/WebPanel/api.php

hxxp://31.220.40.22/~akatisgc/chibu/WebPanel/api.php

hxxp://www.apexlogisticscompany.com/uber/WebPanel/api.php

hxxp://37.72.171.98/WebPanel/api.php

hxxp://varsolar.com/wp-content/upgrade/WebPanel/api.php

The above list is a non-exhaustive list of C&C servers for Agent Tesla, although a useful resource for keeping track of new instances is the CyberCrime-Tracker. That URL provides a search specifically for these types of Command and Control servers, and the website itself is generally highly reliable in its data.

Payload MD5 Hashes

059bb09924b0d8cb7a8cffb72fd0bb03

32b2668174be406d98bde8c055e809d6

732ad6e95c86b3be894fe6ffa27eb683

YARA Signature
InQuest would like to provide the following YARA rule as a detection measure for Agent Tesla. This rule is based on the samples analyzed above and may not be indicative of every variant, but it has been yielding several results during our hunting process. Hopefully, this helps the defenders out there get a step ahead and take action if this YARA signature triggers in their environment.

We recommend deploying this rule in a way that it scans network traffic as well as on disk, that way it may be possible to detect the malware in-transit as opposed to after an asset is already infected. This YARA rule can also be found in our GitHub repository of open sourced rules located at https://github.com/InQuest/yara-rules.