Files
Desiree Beck c3033e4061 Staging (#162)
* update staging (#158)

* update format/wording

* Capa 7.1 rule updates (#156)

* Update self-deletion.md

Added CAPA rule "self delete using alternate data streams" (https://github.com/mandiant/capa-rules/blob/v7.1.0/anti-analysis/anti-forensic/self-deletion/self-delete-using-alternate-data-streams.yml)

* Update obfuscated-files-or-information.md

added new CAPA rule "encrypt data using RC4 via SystemFunction033" https://github.com/mandiant/capa-rules/blob/v7.1.0/data-manipulation/encryption/rc4/encrypt-data-using-rc4-via-systemfunction033.yml

* Update disk-wipe.md

Added capa rule "https://github.com/mandiant/capa-rules/blob/v7.1.0/impact/wipe-disk/delete-drive-layout-via-ioctl.yml" https://github.com/mandiant/capa-rules/blob/v7.1.0/impact/wipe-disk/delete-drive-layout-via-ioctl.yml

* Update system-information-discovery.md

Added new CAPA rule "get disk information via IOCTL" https://github.com/mandiant/capa-rules/blob/v7.1.0/nursery/get-disk-information-via-ioctl.yml

* Update system-information-discovery.md

Added new CAPA rule "get volume information via IOCTL" https://github.com/mandiant/capa-rules/blob/v7.1.0/nursery/get-volume-information-via-ioctl.yml

* Update dns-communication.md

Removed duplication in APIs in "Resolve DNS" CAPA rule

* Update socket-communication.md

Updated APIs for "create raw socket" CAPA rule

* Update socket-communication.md

Updated APIs on CAPA rule "get socket status"

* Update socket-communication.md

Updated CAPA rule "initialize Winsock library"

* Update socket-communication.md

Updated API listing on CAPA rule "receive data on socket"

* Update socket-communication.md

Updated API listing for "send data on socket" CAPA rule

* Update socket-communication.md

Update APIs for CAPA rule "set socket configuration"

* Update socket-communication.md

Updated CAPA rule "connect tcp socket" to add APIs

* Update socket-communication.md

Added APIs to CAPA rule "create tcp socket"

* Update socket-communication.md

Added APIs to "create UDP socket" CAPA rule

* Update encrypt-data.md

Added new APIs to "encrypt data using DPAPI" CAPA rule

* Update install-driver.md

Added APIs to CAPA rule "install driver"

* Update set-file-attributes.md

Added APIs to CAPA rule "change file permissions on Linux"

* Update writes-file.md

Updated APIs for CAPA rule "write file on linux"

* Update system-information-discovery.md

Removed API from CAPA rule "get disk size" to align with published CAPA rule in v. 7.1

* Update create-process.md

Added API to "create process on linux" CAPA rule

* Update hijack-execution-flow.md

Added API calls to CAPA rule "execute shellcode via Windows callback function"

* Update self-deletion.md

Changed link to master

* Update obfuscated-files-or-information.md

Changed rule link to release to point to master

* Update system-information-discovery.md

Removed nursery rules

* Update disk-wipe.md

Updated link to master branch

* Update socket-communication.md

Checked for correct socket listings under the APIs

---------

Co-authored-by: brightmt <50853930+brightmt@users.noreply.github.com>

* New method (#159)

* update format/wording

* Update disassembler-evasion.md

* Update disassembler-evasion.md

* Corpus fix (#160)

* update format/wording

* fix tables

* Edits

---------

Co-authored-by: ryan <ryanxu@wustl.edu>

* New method (#161)

* update format/wording

* Update disassembler-evasion.md

* Update disassembler-evasion.md

---------

Co-authored-by: brightmt <50853930+brightmt@users.noreply.github.com>
Co-authored-by: ryan <ryanxu@wustl.edu>
2024-08-25 10:09:33 -04:00

4.8 KiB

ID C0021
Objective(s) Cryptography
Related ATT&CK Techniques None
Version 2.1
Created 14 August 2020
Last Modified 30 April 2024

Generate Pseudo-random Sequence

The Generate Pseudo-random Sequence micro-behavior can be used for a number of purposes. The methods below include specific functions, as well as pseudo-random number generators (PRNG).

Methods

Name ID Description
GetTickCount C0021.001 Malware generates a pseudo-random sequence using GetTickCount.
Use API C0021.003 Malware generates a pseudo-random sequence using a Windows API.
rand C0021.002 Malware generates a pseudo-random sequence using rand.
RC4 PRGA C0021.004 Malware generates a pseudo-random sequence using the RC4 Pseudo Random (Byte) Generation Algorithm (PRGA).

Use in Malware

Name Date Method Description
BlackEnergy 2007 C0021.003 BlackEnergy generates random numbers via WinAPI. [1]
Locky Bart 2017 C0021.003 Generate random numbers via WinAPI [1]

Detection

Tool: capa Mapping APIs
encrypt data using RC4 PRGA Generate Pseudo-random Sequence::RC4 PRGA (C0021.004) --
generate random numbers via WinAPI Generate Pseudo-random Sequence::Use API (C0021.003) BCryptGenRandom, CryptGenRandom, BCryptOpenAlgorithmProvider, BCryptCloseAlgorithmProvider, CryptAquireContext
generate random numbers via RtlGenRandom Generate Pseudo-random Sequence::Use API (C0021.003) SystemFunction036
generate random numbers using a Mersenne Twister Generate Pseudo-random Sequence (C0021) --

C0021 Snippet

Cryptography::Generate Pseudo-random Sequence SHA256: 192cdcbdec8bdebb7cae89037d6004b4aff2b8264c35a3875fa2d6db104437ca Location: 0x40B120
mov     eax, [DAT_00423174]     ; set up the array of values used for the twister
mov     ecx, dword ptr [eax*0x4 + DAT_004227b0]
mov     dword ptr [EBP + local_8], ecx
mov     edx, dword ptr [DAT_00423174]
add     edx, 0x1
mov     dword ptr [DAT_OO423174], edx
mov     eax, dword ptr [ebp + local_8]  ; set up by taking x (value in series to start the transform, stored at the memory address [ebp + local_8] in this case
shr     eax, 0xb        ; shift x right by 11
xor     eax, dword ptr [ebp + local_8]  ; xor the result of the previous operation with the old value of x.  The eax register now contains intermediate value y
mov     dword ptr [ebp + local_8], eax  ; store the value of y
mov     ecx, dword ptr [ebp + local_8]  ; ecx now contains y
shl     ecx, 0x7        ; shift y left by 7
and     ecx, 0x9d2c5680 ; perform a bitwise and against a known constant bitmask (this value is specified in the transform equation)
xor     ecx, dword ptr [ebp + local_8]  ; xor the output of the previous two instructions with the old value of y to produce y1 (still an intermediate value)
mov     dword ptr [ebp + local_8], ecx  ; store y1
mov     edx, dword ptr [ebp + local_8]  ; load  y1 into edx to start the third part of the transform
shl     edx, 0xf        ; shift y1 left by 15
and     edx, 0xefc60000 ; take y1 and perform a bitwise and operation with another constant
xor     edx, dword ptr [ebp + local_8]  ; xor the output from the previous two instructions with the value of y1 stored earlier
mov     dword ptr [ebp + local_8], edx  ; save this new intermediate y-value (y2)
mov     eax, dword ptr [ebp + local_8]  ; load y2 into eax to start the final portion of the transform and produce the output
shr     eax, 0x12       ; shift y2 right by 18
xor     eax, dword ptr [ebp + local_8]  ; xor the output from the previous instruction with the value of y2 stored earlier
mov     dword ptr [ebp + local_8], eax  ; store the z-value (final output)
mov     eax, dword ptr [ebp + local_8]  ; load the z-value into eax to return it
mov     esp, ebp        ; move the stack pointer to the frame pointer
pop     ebp     ; pop the current frame off the stack
ret     ; return from the function

References

[1] capa v4.0, analyzed at MITRE on 10/12/2022