Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions c2/shell/create-unix-reverse-shell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
rule:
meta:
name: create unix reverse shell
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should document unix vs. linux and the preferred terms to use
I suspect the naming here comes from the ATT&CK name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the name is from ATT&CK. Also this is a higher level rule that depends on a few lower level rules that can be OS dependent.

namespace: c2/shell
author: [email protected]
scope: function
att&ck:
- Execution::Command and Scripting Interpreter::Unix Shell [T1059.004]
mbc:
- Impact::Remote Access::Reverse Shell [B0022.001]
examples:
- 7351f8a40c5450557b24622417fc478d:0x40231E
features:
- or:
- and:
- match: duplicate stdin and stdout
- match: create process
14 changes: 14 additions & 0 deletions c2/shell/execute-shell-command-received-from-socket.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
rule:
meta:
name: execute shell command received from socket
namespace: c2/shell
author: [email protected]
scope: function
att&ck:
- Execution::Command and Scripting Interpreter::Unix Shell [T1059.004]
examples:
- 7351f8a40c5450557b24622417fc478d:0x406549
features:
- and:
- match: receive data on socket
- api: system
16 changes: 16 additions & 0 deletions collection/get-current-user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
rule:
meta:
name: get current user
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows rule for this: get session user name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux doesn't use the term session username. This checks for queries via the effective user id and extracting the user's info from "passwd" or the username of the user that started the process.

namespace: collection
author: [email protected]
scope: function
examples:
- 7351f8a40c5450557b24622417fc478d:0x405438
features:
- or:
- and:
- api: geteuid
- api: getpwuid
- api: getlogin
- api: getlogin_r
- api: cuserid
30 changes: 18 additions & 12 deletions collection/network/get-mac-address.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@ rule:
meta:
name: get MAC address
namespace: collection/network
author: [email protected]
author:
- [email protected]
- [email protected]
scope: function
att&ck:
- Discovery::System Information Discovery [T1082]
examples:
- al-khaser_x64.exe_:0x14001A1BC
features:
- and:
- api: iphlpapi.GetAdaptersInfo
- or:
- offset: 0x194 = IP_ADAPTER_INFO.Address
- offset: 0x195 = IP_ADAPTER_INFO.Address+1
- offset: 0x196 = IP_ADAPTER_INFO.Address+2
- offset: 0x197 = IP_ADAPTER_INFO.Address+3
- offset: 0x198 = IP_ADAPTER_INFO.Address+4
- offset: 0x199 = IP_ADAPTER_INFO.Address+5
- optional:
- string: "%02X-%02X-%02X-%02X-%02X-%02X"
- or:
- and:
- api: iphlpapi.GetAdaptersInfo
- or:
- offset: 0x194 = IP_ADAPTER_INFO.Address
- offset: 0x195 = IP_ADAPTER_INFO.Address+1
- offset: 0x196 = IP_ADAPTER_INFO.Address+2
- offset: 0x197 = IP_ADAPTER_INFO.Address+3
- offset: 0x198 = IP_ADAPTER_INFO.Address+4
- offset: 0x199 = IP_ADAPTER_INFO.Address+5
- optional:
- string: "%02X-%02X-%02X-%02X-%02X-%02X"
- and:
- match: read file
- string: /\/sys\/class\/net\/\S+\/address/
Copy link
Collaborator

@williballenthin williballenthin Aug 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yuck these paths are ugly.

i wonder if substring literals are common enough for us to introduce a new feature/format. perhaps something like:

  • substring: "/etc/passwd"
  • string/substring: "/etc/passwd"
  • string: "/etc/passwd"g

note: this specific path isn't the best example because its actually a regex patter, but you get the idea.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think there's room for improvement here since this comes up a lot and has caused confusion (e.g. #390 (comment)).

I like option 1 then option 2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may look ugly because it needs a wildcard for the name of the network adapter. For example /sys/class/net/lo/address, /sys/class/net/docker0/address.

5 changes: 4 additions & 1 deletion communication/socket/receive/receive-data-on-socket.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ rule:
meta:
name: receive data on socket
namespace: communication/socket/receive
author: [email protected]
author:
- [email protected]
- [email protected]
scope: function
mbc:
- Communication::Socket Communication::Receive Data [C0001.006]
Expand All @@ -17,3 +19,4 @@ rule:
- api: ws2_32.WSARecvEx
- api: ws2_32.WSARecvFrom
- api: ws2_32.WSARecvMsg
- api: recv
5 changes: 4 additions & 1 deletion communication/socket/send/send-data-on-socket.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ rule:
meta:
name: send data on socket
namespace: communication/socket/send
author: [email protected]
author:
- [email protected]
- [email protected]
scope: function
mbc:
- Communication::Socket Communication::Send Data [C0001.007]
Expand All @@ -15,3 +17,4 @@ rule:
- api: ws2_32.WSASend
- api: ws2_32.WSASendMsg
- api: ws2_32.WSASendTo
- api: send
5 changes: 4 additions & 1 deletion communication/socket/tcp/connect-tcp-socket.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ rule:
meta:
name: connect TCP socket
namespace: communication/socket/tcp
author: [email protected]
author:
- [email protected]
- [email protected]
scope: function
mbc:
- Communication::Socket Communication::Connect Socket [C0001.004]
Expand All @@ -12,6 +14,7 @@ rule:
- and:
- match: create TCP socket
- or:
- api: connect
- api: ws2_32.connect
- api: ws2_32.WSAConnect
- api: ConnectEx
Expand Down
5 changes: 4 additions & 1 deletion communication/socket/tcp/create-tcp-socket.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ rule:
meta:
name: create TCP socket
namespace: communication/socket/tcp
author: [email protected]
author:
- [email protected]
- [email protected]
scope: basic block
mbc:
- Communication::Socket Communication::Create TCP Socket [C0001.011]
Expand All @@ -16,3 +18,4 @@ rule:
- or:
- api: ws2_32.socket
- api: ws2_32.WSASocket
- api: socket
5 changes: 4 additions & 1 deletion communication/socket/udp/send/create-udp-socket.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ rule:
meta:
name: create UDP socket
namespace: communication/socket/udp/send
author: [email protected]
author:
- [email protected]
- [email protected]
scope: basic block
mbc:
- Communication::Socket Communication::Create UDP Socket [C0001.010]
Expand All @@ -14,3 +16,4 @@ rule:
- or:
- api: ws2_32.socket
- api: ws2_32.WSASocket
- api: socket
14 changes: 14 additions & 0 deletions host-interaction/file-system/change-file-permission.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
rule:
meta:
name: change file permission
namespace: host-interaction/file-system
author: [email protected]
scope: basic block
examples:
- 7351f8a40c5450557b24622417fc478d:0x407C68
features:
- or:
- api: chown
- api: fchown
- api: lchown
- api: fchownat
20 changes: 19 additions & 1 deletion host-interaction/file-system/read/read-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ rule:
meta:
name: read file
namespace: host-interaction/file-system/read
author: [email protected]
author:
- [email protected]
- [email protected]
scope: function
mbc:
- File System::Read File [C0051]
Expand All @@ -23,3 +25,19 @@ rule:
- api: ZwReadFile
- api: _read
- api: fread
- and:
- optional:
- match: create or open file
- or:
- api: fgetc
- api: fgets
- api: getc
- api: getchar
- api: read
- api: getline
- api: getdelim
- api: fgetwc
- api: getwc
- api: fscanf
- api: vfscanf
- api: fread
55 changes: 36 additions & 19 deletions host-interaction/file-system/write/write-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ rule:
meta:
name: write file
namespace: host-interaction/file-system/write
author: [email protected]
author:
- [email protected]
- [email protected]
scope: function
mbc:
- File System::Writes File [C0052]
Expand All @@ -11,22 +13,37 @@ rule:
# ntdll
- 563653399B82CD443F120ECEFF836EA3678D4CF11D9B351BB737573C2D856299:0x1400025C4
features:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file is getting a bit unruly. the logic tree is so deep that its tricky to interpret as a human.

we should probably split this file into "write file on POSIX" and "write file on Windows".

- and:
- optional:
- or:
- and:
- optional:
- or:
- and:
- number: 0x40000000 = GENERIC_WRITE
- or:
- api: kernel32.CreateFile
- and:
- number: 0x2 = FILE_WRITE_DATA
- or:
- api: NtCreateFile
- api: ZwCreateFile
- or:
- and:
- number: 0x40000000 = GENERIC_WRITE
- or:
- api: kernel32.CreateFile
- and:
- number: 0x2 = FILE_WRITE_DATA
- or:
- api: NtCreateFile
- api: ZwCreateFile
- or:
- api: kernel32.WriteFile
- api: kernel32.WriteFileEx
- api: NtWriteFile
- api: ZwWriteFile
- api: _fwrite
- api: fwrite
- api: kernel32.WriteFile
- api: kernel32.WriteFileEx
- api: NtWriteFile
- api: ZwWriteFile
- api: _fwrite
- api: fwrite
- and:
- optional:
- match: create or open file
- or:
- api: fputc
- api: fputs
- api: putc
- api: write
- api: fputwc
- api: putwc
- api: fputws
- api: write
- api: fwrite
- api: putwchar
17 changes: 13 additions & 4 deletions host-interaction/hardware/cpu/get-cpu-information.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@ rule:
meta:
name: get CPU information
namespace: host-interaction/hardware/cpu
author: [email protected]
author:
- [email protected]
- [email protected]
scope: function
att&ck:
- Discovery::System Information Discovery [T1082]
examples:
- BFB9B5391A13D0AFD787E87AB90F14F5:0x13145B5A
features:
- and:
- match: query or enumerate registry value
- string: /Hardware\\Description\\System\\CentralProcessor/i
- or:
- and:
- match: query or enumerate registry value
- string: /Hardware\\Description\\System\\CentralProcessor/i
- and:
- match: read file
- string: "/proc/cpuinfo"
- and:
- api: system
- string: /\/proc\/cpuinfo/
20 changes: 20 additions & 0 deletions host-interaction/hardware/memory/get-memory-information.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
rule:
meta:
name: get memory information
namespace: host-interaction/hardware/memory
author: [email protected]
scope: function
att&ck:
- Discovery::System Information Discovery [T1082]
examples:
- 7351f8a40c5450557b24622417fc478d:0x405438
features:
- or:
- and:
- match: read file
- string: "/proc/meminfo"
- and:
- api: system
- or:
- string: /\/proc\/meminfo/
- string: /^free/
15 changes: 15 additions & 0 deletions host-interaction/mutex/lock-file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
rule:
meta:
name: lock file
namespace: host-interaction/mutex
author: [email protected]
scope: basic block
mbc:
- Process::Create Mutex [C0042]
examples:
- 7351f8a40c5450557b24622417fc478d:0x40858F
features:
- and:
- api: fcntl
- number: 1 = F_WRLCK
- number: 6 = F_SETLK
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ rule:
meta:
name: get local IPv4 addresses
namespace: host-interaction/network/address
author: [email protected]
author:
- [email protected]
- [email protected]
scope: function
att&ck:
- Discovery::System Network Configuration Discovery [T1016]
Expand All @@ -11,6 +13,7 @@ rule:
- 4C0553285D724DCAF5909924B4E3E90A:0x402010
features:
- or:
- api: getsockname
- and:
- api: GetAdaptersInfo
- offset: 0x1B0 = IP_ADAPTER_INFO.IpAddressList.IpAddress
Expand Down
5 changes: 5 additions & 0 deletions host-interaction/network/dns/resolve/resolve-dns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rule:
author:
- [email protected]
- johnk3r
- [email protected]
scope: function
mbc:
- Communication::DNS Communication::Resolve [C0011.001]
Expand All @@ -20,3 +21,7 @@ rule:
- api: getaddrinfo
- api: GetAddrInfo
- api: GetAddrInfoEx
- api: gethostbyname
- api: getaddrinfo
- api: getnameinfo
- api: gethostent
Loading