pid-dump
Real Time Response - Dump memory for a running process
This sample leverages CrowdStrike's Hosts and Real Time Response APIs to dump the memory for a process running in memory.
This example requires FalconPy v0.6.0+
Procedure
The AID for the provided hostname is retrieved.
If not found, the routine will stop at this point.
A Real Time Response session is initialized between your host and the target host.
If a session cannot be instantiated, the routine will stop processing.
The requested command is analyzed:
Command of "ps"
The list of running processes is requested.
The resulting output is displayed to the screen.
Procedure terminates
Command of "dump"
Process ID is confirmed to be provided by the end user.
If process ID has not been provided, the routine terminates with an error.
The
dump-pid-memory.shutility script is uploaded to CrowdStrike cloud.Script contents
#!/bin/bash grep rw-p /proc/$1/maps \ | sed -n 's/^\([0-9a-f]*\)-\([0-9a-f]*\) .*$/\1 \2/p' \ | while read start stop; do \ gdb --batch --pid $1 -ex \ "dump memory $1-$start-$stop.dump 0x$start 0x$stop"; \ doneA put command is issued, requesting the
dump-pid-memory.shutility be dropped on the target machine.Two helper scripts are uploaded to CrowdStrike cloud.
pid-memdump- Installs gdb, calls thememdumputility to perform the memory dump of the specified PID and then zips up the generated dump files.pid-memdump-cleanup- Removes the dump archive, dump files, and all remaining artifacts on the target machine.
The
dump-pid-memory.shutility script is executed on the target machine.The routine waits for this execution to complete.
The archive containing the generated dump files is retrieved using a get command. This file is uploaded to CrowdStrike cloud.
The routine waits for this upload to complete.
The routine then requests a list of all available files for the current RTR session. This will contain only the one file that was just requested with get.
The file is retrieved and downloaded to your local machine.
On download error, the routine will display the detail that it has and then stop processing.
The downloaded file is a 7-zip archive containing our regular archive of dump files. This archive is extracted into a temporary folder. Since this file was downloaded from the target system with get, we use the password of "infected" to open the archive.
The regular archive is then extracted to the current directory.
All temporary download files and folders are removed from your local system.
The
pip-memdump-cleanupcommand is executed, removing all artifacts from the target system.The helper scripts
pid-memdumpandpid-memdump-cleanupare removed from CrowdStrike cloud.The
dump-pid-memory.shutility script is removed from CrowdStrike cloud.The Real Time Response session is closed and deleted.
All remaining local temporary files are removed.
Running the program
In order to run this demonstration, you will need a partial hostname for the target system and access to CrowdStrike API keys with the following scopes:
Hosts
READ
Real Time Response
READ, WRITE
Real Time Response Admin
READ, WRITE
Execution syntax
The following command will request a process list for the target system.
Once you have determined the Process ID you wish to dump, you can do so with the following command.
Command-line help is available using the -h flag.
Example source code
The source code for this example is available here
Last updated
Was this helpful?

