Toll fraud: SipPhreak

2011-07-01

Alexis Dorais-Joncas

ESET, Canada
Editor: Helen Martin

Abstract

PHP/SipPhreak.A acts like an ancient SMTP open relay scanner, but with a twist: it targets open or vulnerable SIP devices instead of mail servers. Alexis Dorais-Joncas gives a detailed analysis of this threat - which is probably the initial step in a broader toll fraud scheme.


While performing a routine check on one of our honeypots, a new, particularly large program file caught our attention: a 17MB PE (Portable Executable) file.

After analysis, we identified the file as being the complete distribution of PHP 5.3.5 for Windows bundled with a malicious PHP script. ESET detects this threat as PHP/SipPhreak.A.

The script acts like an ancient SMTP open relay scanner, but with a twist: it targets open or vulnerable SIP devices instead of mail servers. (Wikipedia defines the Session Initiation Protocol (SIP) as ‘an IETF-defined signalling protocol, widely used for controlling multimedia communication sessions such as voice and video calls over Internet Protocol.’)

This paper gives an overview of the malware’s infection vector and its installation procedure, followed by an analysis of the malicious script itself. Finally, an overview of the malware’s activity during the observation period will be presented.

Infection vector and installation

The SipPhreak installer was collected from a machine infected with Win32/Peerfrag. We were able to determine that it was dropped by a secondary infection of the Win32/Restamdos trojan. Figure 1 shows the infection path.

SipPhreak infection source.

Figure 1. SipPhreak infection source.

It is interesting to note that the Restamdos and SipPhreak command and control servers (C&C) and the SipPhreak installer location are all hosted on the same IP address located in Moldavia.

Source of the SipPhreak infection.

Figure 2. Source of the SipPhreak infection.

The SipPhreak installer is a self-extracting archive (SFX). These files are compressed archives that extract their content when executed. They are commonly used as legitimate software installers.

In the case of SipPhreak, the archive contains the entire original distribution of PHP 5.3.5 for Windows and two additional files: an unused batch file (start.bat) and the malicious PHP script (bc.php). The archive content is shown in Figure 3.

Content of SipPhreak’s self-extracting archive.

Figure 3. Content of SipPhreak’s self-extracting archive.

Interestingly, the author did not seem to care very much about the size of his malware. Several unused libraries, PHP modules and even documentation text files were left in the archive, contributing to its large size.

When executed, the SipPhreak SFX silently extracts its content to C:\windows\bc2. Once the extraction is complete, a pre-configured post-extraction command launches the malicious PHP script. Figure 4 shows the command used to start bc.php.

Auto-starting the PHP script after extraction.

Figure 4. Auto-starting the PHP script after extraction.

Analysis of the malicious PHP file

Unsurprisingly, the code inside bc.php is obfuscated. All variables and function names are one letter long, and no new lines or indentations are present. A quick look at Figure 5 should be enough to convince you that the only thing you can expect from trying to understand this code (as-is) is a headache.

Obfuscated PHP code.

Figure 5. Obfuscated PHP code.

The first step towards getting a readable script was to use some sort of PHP formatter tool. We used a free online tool called PHP Formatter, which successfully added the missing indentation and new lines. But even when formatted correctly, the code was not exactly clear. We had to read through it and follow the control flow, changing the variable and function names to meaningful ones and adding comments along the way. We ended up with fully documented PHP source code (see Figure 6) and were finally able to discover all the malware functionalities.

Cleaned up source code.

Figure 6. Cleaned up source code.

The most interesting part of the code is the main loop, where the script waits for commands from the C&C. Figure 7 describes the five different commands available.

SipPhreak commands.

Figure 7. SipPhreak commands.

We can see that the malware is quite powerful: the ‘!’ and ‘~’ commands literally provide a backdoor functionality. However, during our observation period neither of these commands were used. The command most commonly observed was the ‘R’ command, used to perform a SIP scan on a range of IP addresses. The variety of parameters available for this command makes it quite flexible.

An example of a typical ‘R’ command sent by the C&C is shown below:

R 60 44207066xxxx 00,011 55 0 0 asterisk

An explanation of each parameter used is given in Figure 8.

‘R’ command syntax.

Figure 8. ‘R’ command syntax.

Figure 9 shows the scan algorithm. In essence, every target IP is sent one INVITE per country code/phone number combination.

Scan algorithm.

Figure 9. Scan algorithm.

Looking at the clean version of the PHP script also allowed us to analyse the quality of the source code. We would say that it is above average quality for malware code, with clearly separated functions, decent error handling and no debugging leftovers.

However, despite well-conceived source code, the script’s execution is not as stealthy as one would expect. The SIP scans are not throttled, meaning that the script can easily saturate the system resources by issuing hundreds of SIP requests every minute.

Malicious activity

Once initialized, the malware first contacts its C&C to receive orders. With the exception of a few ‘$’ commands to customize the OPTIONS payload, all the commands received during our observation period were ‘R’ commands, issued to scan one or more IP address ranges (see Figure 7 for a description). Over time, the command was issued with quite a wide variety of country codes and phone numbers.

Country codes sent by the C&C.

Figure 10. Country codes sent by the C&C.

Phone numbers sent by the C&C.

Figure 11. Phone numbers sent by the C&C.

Researching these phone numbers yielded very few hits on Google. One of the few numbers we found was in a recent forum post by an unhappy PennyTel user who reported that his account had been compromised. At first he saw incoming probing with the phone number 44207347xxxx, followed by real communications established with various countries:

Last week, I had my account hacked. The attack started with some calls to UK number 44207347xxxx. A simple search on Google shows this number is associated with probing of asterisk type of VoIP systems. After the probing, some real calls were made to destinations such as El Salvador, Ghana, Haiti and Nepal.’ [1]

During the observation period we saw the C&C trying to scan approximately 4,000,000 IP addresses, with very few duplicates. As shown in Figure 12, the vast majority of these IP addresses were located in Germany.

Proportion of IPs scanned, by country.

Figure 12. Proportion of IPs scanned, by country.

During our investigation we intercepted traffic from infected hosts to the C&C server. Along with the IP, the specific SIP response code and the device’s User Agent string are reported. Figure 13 shows that one specific type of device, AVMFritz, was clearly prevalent.

Proportion of valid devices, by UserAgent string.

Figure 13. Proportion of valid devices, by UserAgent string.

Conclusion

It is likely that this malware operation is the initial step in a broader toll fraud scheme. The idea is to find poorly configured SIP gateways that allow an attacker to connect to their SIP sites and then translate the calls to the PSTN network. The attacker can then initiate costly overseas calls or even call his own premium numbers (collecting the money directly), all at the expense of the device owner. The Australian Honeynet Project has published interesting studies in this area at HTCC2010 [3] and the Honeynet Workshop 2011 [4].

VoIP toll fraud is likely to become more popular as businesses continue to convert their telephone infrastructure to VoIP solutions. Way too often, we see news reports of incidents that cost small and medium businesses enormous amounts of money after switching to Internet telephony.

The hackers target any kind of organization, from a small charity in Flintshire in the UK that was hit for a few thousand pounds [5], to the Canadian law firm Martin & Hillyer, which received a $207,000 bill from Bell Canada for long-distance calls to Sierra Leone that its staff had never made [6].

In addition to toll fraud, organizations are also vulnerable to a range of targeted threats including industrial espionage, intellectual property theft and eavesdropping – all of which can result in far greater damage than toll fraud. Unsecured VoIP infrastructures can allow an attacker to gain full access to phone conversations, voicemails and more. Imagine the consequences if the attacker was your closest competitor.

It is imperative that businesses and individuals properly secure their VoIP infrastructures. If they do not have the expertise to do so internally, they should hire an external firm so as to avoid becoming another victim.

twitter.png
fb.png
linkedin.png
hackernews.png
reddit.png

 

Latest articles:

Nexus Android banking botnet – compromising C&C panels and dissecting mobile AppInjects

Aditya Sood & Rohit Bansal provide details of a security vulnerability in the Nexus Android botnet C&C panel that was exploited to compromise the C&C panel in order to gather threat intelligence, and present a model of mobile AppInjects.

Cryptojacking on the fly: TeamTNT using NVIDIA drivers to mine cryptocurrency

TeamTNT is known for attacking insecure and vulnerable Kubernetes deployments in order to infiltrate organizations’ dedicated environments and transform them into attack launchpads. In this article Aditya Sood presents a new module introduced by…

Collector-stealer: a Russian origin credential and information extractor

Collector-stealer, a piece of malware of Russian origin, is heavily used on the Internet to exfiltrate sensitive data from end-user systems and store it in its C&C panels. In this article, researchers Aditya K Sood and Rohit Chaturvedi present a 360…

Fighting Fire with Fire

In 1989, Joe Wells encountered his first virus: Jerusalem. He disassembled the virus, and from that moment onward, was intrigued by the properties of these small pieces of self-replicating code. Joe Wells was an expert on computer viruses, was partly…

Run your malicious VBA macros anywhere!

Kurt Natvig wanted to understand whether it’s possible to recompile VBA macros to another language, which could then easily be ‘run’ on any gateway, thus revealing a sample’s true nature in a safe manner. In this article he explains how he recompiled…


Bulletin Archive

We have placed cookies on your device in order to improve the functionality of this site, as outlined in our cookies policy. However, you may delete and block all cookies from this site and your use of the site will be unaffected. By continuing to browse this site, you are agreeing to Virus Bulletin's use of data as outlined in our privacy policy.