-
Notifications
You must be signed in to change notification settings - Fork 36
Quark types
Adam Mashinchi edited this page Feb 24, 2022
·
3 revisions
A list of available quark types with examples.
- Contents
- chmod, fchmod, fchmodat
- chown, fchown, fchownat, lchown
- connect
- copy
- execve, execveat
- file-append
- file-create
- file-touch
- fork-and-rename
- listen
- remove
- sleep
Change the access permissions of a file.
"chmod" : { "path" : "<file>", "mode" : "<mode>" }-
modemust be a octal-formatted string.
{
"name" : "CHMOD-EXISTING-FILE",
"chmod" : { "path" : "/tmp/cr.path.test", "mode" : "600" },
"fchmod" : { "path" : "/tmp/cr.descriptor.test", "mode" : "060" },
"fchmodat" : { "path" : "/tmp/cr.at.test", "mode" : "606" }
}Change the ownership of a file.
"chown" : { "path" : "<path>", "user" : "<user>", "group" : "<group>" }-
userandgroupare strings and must encode valid names or numbers. - You might need elevated permissions to change file ownership.
{
"name" : "CHOWN-EXISTING-FILE",
"chown" : { "path" : "/tmp/cr.path.test", "user" : "1000", "group" : "nogroup" },
"fchown" : { "path" : "/tmp/cr.descriptor.test", "user" : "1000", "group" : "nogroup" },
"fchownat" : { "path" : "/tmp/cr.at.test", "user" : "1000", "group" : "nogroup" },
"lchown" : { "path" : "/tmp/cr.link.test", "user" : "1000", "group" : "nogroup" }
}Establish a network connection and send 512 random bytes.
"connect" : { "method": "<method>", "protocol": "<protocol>", "address": "<address>", "port": <port> }-
methodmust besocketcallorsyscall.-
socketcalluses thesocketcallABI. -
syscalluses thesocket,connect, andsendsystem calls for TCP connections, and thesocketandsendtosystem calls for UDP connections.
-
-
protocolmust betcp4,tcp6,udp4, orudp6. -
addressmust be a valid DNS, IPV4, or IPV6 address. -
portmust be a valid port number.
{
"name" : "C2-BEACON",
"fork-and-rename" : [ "crontab" ],
"connect" : { "method": "socketcall", "protocol": "tcp4", "address": "google.com", "port": 443 }
}Copy a file.
"copy" : [ "<file>", "<destination>" ]- If
destinationexists, the reaction overwrites it. -
copycan't operate on directories.
{
"name" : "LINUX-SHM-DIR-EXECUTION",
"copy" : [ "/proc/self/exe", "/dev/shm/chain_reactor" ],
"execve" : [ "/dev/shm/chain_reactor", "exit" ],
"remove" : [ "/dev/shm/chain_reactor" ]
}Execute a program with command-line arguments.
"execve" : [ "<program>", "<arg1>", "<arg2>", ..., "<argN>" ]- Chain Reactor includes PATH in its search for
program. - Chain Reactor redirects the standard input, output, and error to
/dev/null. - The reaction pauses until the process created by
execveorexecveatterminates. -
Note:
execveatrequires Linux kernel version 3.19 or higher.
{
"name" : "NIX-WHOIS-TRANSFER",
"execve" : [ "whois", "-h", "redcanary.com", "-p", "443", "iioo" ],
"execveat" : [ "whois", "-h", "redcanary.com", "-p", "443", "iioo" ]
}Append data to an existing file.
"file-append" : { "path" : "<file>", data : "<payload>", backup-and-revert : <boolean> }-
payloadcan be a string or a path to a file.- If
payloadis a string, all escape sequences are converted to binary. - Any files included as part of the payload are read at compilation time and baked into the reaction executable.
- If
- If
backup-and-revertistrue, Chain Reactor creates a backup of the file specified byfile.
{
"name" : "PERSIST_CRONTAB",
"file-append" : { "path" : "/etc/crontab", data : "\n1 * * * * root /var/www/malware-r-us/userkit\n", backup-and-revert : true },
}Create a file with data.
"file-create" : { "path" : "<file>", data : "<payload>", backup-and-revert : <boolean> }-
payloadcan be a string or a path to a file.- If
payloadis a string, all escape sequences are converted to binary. - Any files included as part of the payload are read at compilation time and baked into the reaction executable.
- If
- If
backup-and-revertistrue, Chain Reactor creates a backup of the file specified byfile.
{
"name" : "TOUCH-TMP-TRUNCATE-IF-EXISTS",
"file-create" : { "path" : "/tmp/cr.test", data : "Hello World!\n", backup-and-revert : false },
"file-create" : { "path" : "/etc/passwd", data : "/etc/passwd", backup-and-revert : true }
}Create an empty file.
"file-touch" : { "path" : "<file>" }- If
filealready exists,file-touchdoes nothing.
{
"name" : "TOUCH-TMP-NEW-FILE",
"file-touch" : { "path" : "/tmp/cr.test" }
}Execute Chain Reactor under a different name.
"fork-and-rename" : [ "<name>", "<arg1>", "<arg2>", ..., "<argN>" ]- The reaction creates a new process, copies the Chain Reactor executable to a
temporary directory, and runs the executable as
name. - Subsequent quarks execute in the new process.
- You can use
fork-and-renamerepeatedly to create multiple child processes.
{
"name" : "NIX-WHOIS-TRANSFER-FAKE",
"fork-and-rename" : [ "whois", "-h", "redcanary.com", "-p", "443", "iioo" ],
"connect" : { "method": "socketcall", "protocol": "tcp4", "address": "redcanary.com", "port": 443 }
}Listen for a network connection.
"listen" : { "method": "<method>", "protocol": "<protocol>, "address": "<address>", "port": <port> }- Chain Reactor forks and performs an implicit
connectto simulate a network connection. - You might need elevated permissions to listen for a network connection.
-
methodmust besocketcallorsyscall.-
socketcalluses thesocketcallABI. -
syscalluses thesocket,bind,listen,accept4, andrecvsystem calls for TCP connections, and thesocket,bind, andrecvsystem calls for UDP connections.
-
-
protocolmust betcp4,tcp6,udp4, orudp6. -
addressmust be0.0.0.0,::/0,127.0.0.1, or::1/128. -
portmust be a valid port number.
{
"name" : "C2-BIND",
"fork-and-rename" : [ "crontab" ],
"listen" : { "method": "socketcall", "protocol": "udp4", "address": "0.0.0.0", "port": 443 }
}Delete any number of files or directories.
"remove" : [ "<path1>", "<path2>", ..., "<pathN>" ]-
removedoesn't generate errors. -
Caution: Deletion is permanent. Exercise the same caution with
removeas withrm -rf.
{
"name" : "LINUX-SHM-DIR-EXECUTION",
"copy" : [ "/proc/self/exe", "/dev/shm/chain_reactor" ],
"execve" : [ "/dev/shm/chain_reactor", "exit" ],
"remove" : [ "/dev/shm/chain_reactor" ]
}Sleep for a specified number of seconds.
"sleep" : <integer>{
"name" : "SLEEP-FOR-TEN-SECONDS",
"sleep" : 10
}Questions? Get connected to the community on the Atomic Red Team Slack channel