Today, many companies, especially large companies, use both online and offline sandbox solutions. We can say that sandbox technology is the backbone of a cyber defense center. Because malicious files are constantly coming to your company! It’s hard to find more than one “really” trained malware analyst, and even if you find the right people to do the job, they have to do it over and over again. Long story short, you need a sandbox solution and if you are already using sandbox technology, you are doing well.
In the current situation of sandbox technology, sandboxes that can analyze at the hypervisor level stand out. Such sandboxes are considered to be relatively difficult to bypass. These types of sandboxes can understand the standard anti-sanbox techniques and can take counter action. If you are using a sandbox technology and this sandbox technology can analyze at the hypervisor level, you are doing the good things in right way.
The way you prefer to bypass sanboxes that can perform advanced analysis and detections, such as sandboxes that analyze at the hypervisor level, is to develop malicious software that requires user interaction. For example, you can integrate the Pickl3 project into your malware. When you complete the integration, Pickl3 will wait for the target user to enter the correct Windows account information. If the target user enters the correct account information, you will run your malware and “KA-BOOM!” You will probably bypass the sandbox. However, in this article, I will share a technique that I have applied and succeeded in many operations before. This technique has always reminded me of Odysseus and the Trojan Horse.
Mistakes Made and Their Results
Even though the sandbox technology is advanced, companies do not tighten the operating system in the sandbox. Those who perform Red Team Operations or attackers primarily target end users. Now, let’s talk about what we can do with the system features of an average company’s end user. Below I talked about some mistakes and what we can do.
Mistake-1: Almost every sandbox runs the malware on Administrator rights while analyzing. You can develop your malware to run according to the answer to the following question; Do you have administrator rights?
If it does not have Administrator rights, you can make it run and bypass the sandbox. For this,
AllocateAndInitializeSid APIs will give us the necessary information. I have given the sample C ++ code below.
If you want to take the above code further, you can also check the Integrity Level of your malicious process. ;)
Mistake-2: Many companies do not install Active Directory for Sandbox’s analysis environment. Every average company has a domain and end users are included in that domain. In other words, the malware you develop will run on a system with domain integration. You can develop your malware to run according to the answer to the following question; Is the environment in which you work integrated into the domain? If the system is integrated into the domain, you can make it work and bypass the sandbox. The
DsRoleGetPrimaryDomainInformation API can use for this . This API returns information about the domain that has been integrated. I have given the sample C ++ code below.
Mistake-3: We can take the technique I explained in the previous step to higher level. In the previous step, we made a query about the target system’s domain (Active Directroy) integration. We can also check for integration directly for a specific domain. For example, our target company is DZ Corp Inc. and they use a domain named dzcorp.local on their internal network. In the previous step, we ensured that our malware works on a system that belongs to the domain, now we will enable it to work only in the domain with the name dzcorp.local. For this, we need to find the DNS name for the target system’s domain. There are two traceable steps for this.
- Finding disclosed SSL certificates
- Finding a directory that is accessible from the Internet and allows NTLM Autentication
- Finding the Skype for Business (formerly Microsoft Lync or Microsoft Office Communicator) server
Disclosed SSL Certificates
There are many systems on the internet that scan and record certificates. Companies can sometimes use their internal network certificates in their internet-enabled systems. The domain name of the certificate created for use in the internal network can usually be the DNS name of the internal domain. In such cases, you can find the DNS name of the domain used inside.
Directories That Allow NTLM Authentication
Companies use a variety of technologies and some of them feature NTLM Authentication. Some of these are given below.
- OWA Servers
- Skype for Business (formerly Microsoft Lync or Microsoft Office Communicator)
- Autodiscover Servers (autodiscover.domain.com and lyncdiscover.domain.com)
- ADFS Servers
For example, if the target company is using Skype for Business and this server is open to the Internet, you can find it with Subdomain Bruteforce. For example, once we find Subdomain for Skype for Business, we need to find a directory with NTLM Authentication by requesting one of the directories below. I have given the following possible directories.
After finding a directory that requires NTLM Authentication, all that remains is to find the DNS name of the domain used in the internal network. When you make a request to one of the directories I gave above for Skype for Business, if NTLM Authentication is active, monitor its traffic using an HTTP (S) proxy. Try to login with any account information. The server will respond with an HTTP 401 (Unauthorized) status code and a value starting with
WWW-Authenticate header information
TlRMTVNTUAACAAAA.... Here, in this
WWW-Authenticate header information, the domain DNS name used by the target company is mentioned. By reading this binary data, you will get a value as follows.
You now have information about the target company’s domain DNS name. You can develop your malware to work according to the answers to the following questions; Is the system you are running integrated into a domain? If so, is this domain named “dzcorp.local”?
To do this, you can compare the values of
dsRoleInfo->DomainNameDns in the code below with the domain DNS name of the target company.