Skip to content

Commit

Permalink
adds the new method to the manual client (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cictrone authored Jan 23, 2024
1 parent 75fd936 commit df4283f
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions implants/lib/c2/src/c2_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod c2_manual_client {

static CLAIM_TASKS_PATH: &str = "/c2.C2/ClaimTasks";
static REPORT_TASK_OUTPUT_PATH: &str = "/c2.C2/ReportTaskOutput";
static REPORT_PROCESS_LIST_PATH: &str = "/c2.C2/ReportProcessList";
static DOWNLOAD_FILE_PATH: &str = "/c2.C2/DownloadFile";

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -62,6 +63,40 @@ pub mod c2_manual_client {
self.grpc.unary(req, path, codec).await
}

///
/// Report the active list of running processes. This list will replace any previously reported
/// lists for the same host.
pub async fn report_process_list(
&mut self,
request: impl tonic::IntoRequest<super::ReportProcessListRequest>,
) -> std::result::Result<tonic::Response<super::ReportProcessListResponse>, tonic::Status>
{
self.grpc.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e),
)
})?;
let codec: ProstCodec<
super::ReportProcessListRequest,
super::ReportProcessListResponse,
> = tonic::codec::ProstCodec::default();
let path =
tonic::codegen::http::uri::PathAndQuery::from_static(REPORT_PROCESS_LIST_PATH);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("c2.C2", "ReportProcessList"));
self.grpc.unary(req, path, codec).await
}

///
/// Download a file from the server, returning one or more chunks of data.
/// The maximum size of these chunks is determined by the server.
/// The server should reply with two headers:
/// - "sha3-256-checksum": A SHA3-256 digest of the entire file contents.
/// - "file-size": The number of bytes contained by the file.
///
/// If no associated file can be found, a NotFound status error is returned.
pub async fn download_file(
&mut self,
request: impl tonic::IntoRequest<super::DownloadFileRequest>,
Expand Down

0 comments on commit df4283f

Please sign in to comment.