-
-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
316 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,42 @@ | ||
# Example file to demonstrate remote python functionality with the LeechAgent. | ||
# | ||
# Example: | ||
# pcileech.exe -device <device> -remote rpc://<spn or insecure>:host agent-execpy -in agent-find-rwx.py | ||
# | ||
# The python script will be executed in a child process to the LeechAgent in | ||
# the user-context of the LeechAgent. If the agent is running as a service this | ||
# is most likely SYSTEM. It's also possible to use this functionality to run | ||
# Python scripts on the remote host without using the memory analysis functionality. | ||
# | ||
# Please check out agent installation instructions at: | ||
# https://github.com/ufrisk/LeechCore/wiki/LeechAgent | ||
# https://github.com/ufrisk/LeechCore/wiki/LeechAgent_Install | ||
# | ||
|
||
|
||
# | ||
# Example to load LeechCore for Python connecting to the memory acqusition device | ||
# specified in the PCILeech -device parameter. Please uncomment to activate. | ||
# Guide at: https://github.com/ufrisk/LeechCore/wiki/LeechCore_API_Python | ||
# | ||
''' | ||
import leechcorepyc | ||
lc = leechcorepyc.LeechCore('existing') | ||
print(lc) | ||
''' | ||
|
||
|
||
# | ||
# Example to load MemProcFS for Python connecting to the memory acqusition device | ||
# specified in the PCILeech -device parameter. | ||
# For information about MemProcFS Python API please check out the wiki for API | ||
# usage examples and a youtube demo. | ||
# https://github.com/ufrisk/MemProcFS/wiki/API_Python | ||
# | ||
# | ||
import memprocfs | ||
vmm = memprocfs.Vmm() | ||
for process in vmm.process_list(): | ||
for entry in process.maps.pte(): | ||
if '-rwx' in entry['flags']: | ||
print(str(process.pid) + ': ' + process.name + ': ' + str(entry)) | ||
print(str(process.pid) + ': ' + process.name + ': ' + str(entry)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
// (c) Ulf Frisk, 2020-2021 | ||
// Author: Ulf Frisk, [email protected] | ||
// | ||
// Header Version: 2.6 | ||
// Header Version: 2.7 | ||
// | ||
|
||
#ifndef __LEECHCORE_H__ | ||
|
@@ -396,7 +396,7 @@ EXPORTED_FUNCTION BOOL LcCommand( | |
#define LC_OPT_FPGA_DELAY_WRITE 0x0300000700000000 // RW - uS | ||
#define LC_OPT_FPGA_DELAY_READ 0x0300000800000000 // RW - uS | ||
#define LC_OPT_FPGA_RETRY_ON_ERROR 0x0300000900000000 // RW | ||
#define LC_OPT_FPGA_DEVICE_ID 0x0300008000000000 // R | ||
#define LC_OPT_FPGA_DEVICE_ID 0x0300008000000000 // RW - bus:dev:fn (ex: 04:00.0 == 0x0400). | ||
#define LC_OPT_FPGA_FPGA_ID 0x0300008100000000 // R | ||
#define LC_OPT_FPGA_VERSION_MAJOR 0x0300008200000000 // R | ||
#define LC_OPT_FPGA_VERSION_MINOR 0x0300008300000000 // R | ||
|
@@ -433,6 +433,14 @@ EXPORTED_FUNCTION BOOL LcCommand( | |
|
||
#define LC_CMD_AGENT_EXEC_PYTHON 0x8000000100000000 // RW - [lo-dword: optional timeout in ms] | ||
#define LC_CMD_AGENT_EXIT_PROCESS 0x8000000200000000 // - [lo-dword: process exit code] | ||
#define LC_CMD_AGENT_VFS_LIST 0x8000000300000000 // RW | ||
#define LC_CMD_AGENT_VFS_READ 0x8000000400000000 // RW | ||
#define LC_CMD_AGENT_VFS_WRITE 0x8000000500000000 // RW | ||
#define LC_CMD_AGENT_VFS_OPT_GET 0x8000000600000000 // RW | ||
#define LC_CMD_AGENT_VFS_OPT_SET 0x8000000700000000 // RW | ||
|
||
#define LC_CMD_AGENT_VFS_REQ_VERSION 0xfeed0001 | ||
#define LC_CMD_AGENT_VFS_RSP_VERSION 0xfeee0001 | ||
|
||
#define LC_STATISTICS_VERSION 0xe1a10002 | ||
#define LC_STATISTICS_ID_OPEN 0x00 | ||
|
@@ -445,6 +453,28 @@ EXPORTED_FUNCTION BOOL LcCommand( | |
#define LC_STATISTICS_ID_COMMAND 0x07 | ||
#define LC_STATISTICS_ID_MAX 0x07 | ||
|
||
typedef struct tdLC_CMD_AGENT_VFS_REQ { | ||
DWORD dwVersion; | ||
DWORD _FutureUse; | ||
CHAR uszPathFile[2*MAX_PATH]; // file path to list/read/write | ||
union { | ||
QWORD qwOffset; // offset to read/write | ||
QWORD fOption; // option to get/set (qword data in *pb) | ||
}; | ||
DWORD dwLength; // length to read | ||
DWORD cb; | ||
BYTE pb[0]; | ||
} LC_CMD_AGENT_VFS_REQ, *PLC_CMD_AGENT_VFS_REQ; | ||
|
||
typedef struct tdLC_CMD_AGENT_VFS_RSP { | ||
DWORD dwVersion; | ||
DWORD dwStatus; // ntstatus of read/write | ||
DWORD cbReadWrite; // number of bytes read/written | ||
DWORD _FutureUse[2]; | ||
DWORD cb; | ||
BYTE pb[0]; | ||
} LC_CMD_AGENT_VFS_RSP, *PLC_CMD_AGENT_VFS_RSP; | ||
|
||
static LPCSTR LC_STATISTICS_NAME[] = { | ||
"LcOpen", | ||
"LcRead", | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
// (c) Ulf Frisk, 2018-2021 | ||
// Author: Ulf Frisk, [email protected] | ||
// | ||
// Header Version: 4.0 | ||
// Header Version: 4.2 | ||
// | ||
|
||
#include "leechcore.h" | ||
|
@@ -306,6 +306,7 @@ typedef struct _SERVICE_STATUS { | |
|
||
#define VMMDLL_VFS_FILELIST_EXINFO_VERSION 1 | ||
#define VMMDLL_VFS_FILELIST_VERSION 2 | ||
#define VMMDLL_VFS_FILELISTBLOB_VERSION 0xf88f0001 | ||
|
||
typedef struct tdVMMDLL_VFS_FILELIST_EXINFO { | ||
DWORD dwVersion; | ||
|
@@ -331,8 +332,24 @@ typedef struct tdVMMDLL_VFS_FILELIST2 { | |
HANDLE h; | ||
} VMMDLL_VFS_FILELIST2, *PVMMDLL_VFS_FILELIST2; | ||
|
||
typedef struct tdVMMDLL_VFS_FILELISTBLOB_ENTRY { | ||
ULONG64 ouszName; // byte offset to string from VMMDLL_VFS_FILELISTBLOB.uszMultiText | ||
ULONG64 cbFileSize; // -1 == directory | ||
VMMDLL_VFS_FILELIST_EXINFO ExInfo; // optional ExInfo | ||
} VMMDLL_VFS_FILELISTBLOB_ENTRY, *PVMMDLL_VFS_FILELISTBLOB_ENTRY; | ||
|
||
typedef struct tdVMMDLL_VFS_FILELISTBLOB { | ||
DWORD dwVersion; // VMMDLL_VFS_FILELISTBLOB_VERSION | ||
DWORD cbStruct; | ||
DWORD cFileEntry; | ||
DWORD cbMultiText; | ||
LPSTR uszMultiText; | ||
DWORD _FutureUse[8]; | ||
VMMDLL_VFS_FILELISTBLOB_ENTRY FileEntry[0]; | ||
} VMMDLL_VFS_FILELISTBLOB, *PVMMDLL_VFS_FILELISTBLOB; | ||
|
||
/* | ||
* Helper functions for callbacks into the VMM_VFS_FILELIST structure. | ||
* Helper functions for callbacks into the VMM_VFS_FILELIST2 structure. | ||
*/ | ||
EXPORTED_FUNCTION | ||
VOID VMMDLL_VfsList_AddFile(_In_ HANDLE pFileList, _In_ LPSTR uszName, _In_ ULONG64 cb, _In_opt_ PVMMDLL_VFS_FILELIST_EXINFO pExInfo); | ||
|
@@ -355,6 +372,15 @@ EXPORTED_FUNCTION | |
_Success_(return) BOOL VMMDLL_VfsListU(_In_ LPSTR uszPath, _Inout_ PVMMDLL_VFS_FILELIST2 pFileList); | ||
_Success_(return) BOOL VMMDLL_VfsListW(_In_ LPWSTR wszPath, _Inout_ PVMMDLL_VFS_FILELIST2 pFileList); | ||
|
||
/* | ||
* List a directory of files in MemProcFS and return a VMMDLL_VFS_FILELISTBLOB. | ||
* CALLER FREE: VMMDLL_MemFree(return) | ||
* -- uszPath | ||
* -- return | ||
*/ | ||
EXPORTED_FUNCTION | ||
_Success_(return != NULL) PVMMDLL_VFS_FILELISTBLOB VMMDLL_VfsListBlobU(_In_ LPSTR uszPath); | ||
|
||
/* | ||
* Read select parts of a file in MemProcFS. | ||
* -- [uw]szFileName | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.