Exemple #1
0
static void parse(int cfd, client *c)
{
	switch(c->state)
	{
		case CONNECTING:
			login_send_banner(cfd);
			login_ask_username(cfd);
			c->state = USERNAME;
		break;
		case USERNAME:
			handle_username(c);
			login_ask_password(cfd);
			c->state = PASSWORD;
		break;
		case PASSWORD:
			/* TODO: check the username and password */
			login_send_motd(cfd);
			c->state = CONNECTED;
			send_prompt(cfd);
		break;
		case CONNECTED:
			/* TODO: parse the command prompt */
			send_prompt(cfd);
		break;
	}
}
Exemple #2
0
void	command_cd(t_client *client, char cmd[], int size)
{
  char	buff[512];

  if (size <= 1)
  {
    dprintf(client->sockfd, "TEXT:Error: invalide path%s", TCP_SEPARATOR);
    send_prompt(client);
    return ;
  }
  memset(buff, 0, 512);
  strcpy(buff, client->pwd);
  if (chdir(&cmd[1]) == -1)
    dprintf(client->sockfd, "TEXT:Error: %s%s",
        strerror(errno), TCP_SEPARATOR);
  else
  {
    memset(client->pwd, 0, 512);
    getcwd(client->pwd, 512);
    if (strstr(client->pwd, client->srv_pwd) == NULL)
      cd_fail(client, buff);
    else
      dprintf(client->sockfd, "TEXT:%s%s", client->pwd, TCP_SEPARATOR);
  }
  send_prompt(client);
}
Exemple #3
0
void	command_pwd(t_client *client, char cmd[], int size)
{
  (void)cmd;
  (void)size;
  dprintf(client->sockfd, "TEXT:%s%s", client->pwd, TCP_SEPARATOR);
  send_prompt(client);
}
Exemple #4
0
static void main_monitor_status_refresh (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
  const user_options_t       *user_options       = hashcat_ctx->user_options;
  const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;

  if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
  {
    if (user_options->quiet == false)
    {
      //clear_prompt ();

      event_log_info (hashcat_ctx, "");
      event_log_info (hashcat_ctx, "");
    }
  }

  status_display (hashcat_ctx);

  if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
  {
    if (user_options->quiet == false)
    {
      event_log_info (hashcat_ctx, "");

      send_prompt ();
    }
  }
}
Exemple #5
0
static void main_monitor_performance_hint (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
  const user_options_t       *user_options       = hashcat_ctx->user_options;
  const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;

  if (user_options->quiet == true) return;

  if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
  {
    clear_prompt ();
  }

  if (user_options->workload_profile < 3)
  {
    event_log_warning (hashcat_ctx, "Cracking performance lower than expected? Append -w 3 to the commandline!");
    event_log_warning (hashcat_ctx, "");
  }
  else
  {
    event_log_warning (hashcat_ctx, "Cracking performance lower than expected?");
    event_log_warning (hashcat_ctx, "");
    event_log_warning (hashcat_ctx, "* Update your OpenCL runtime / Driver but the right way:");
    event_log_warning (hashcat_ctx, "  https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#i_may_have_the_wrong_driver_installed_what_should_i_do");
    event_log_warning (hashcat_ctx, "");
    event_log_warning (hashcat_ctx, "* Create more work items to make use of your parallelization power:");
    event_log_warning (hashcat_ctx, "  https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed");
    event_log_warning (hashcat_ctx, "");
  }

  if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
  {
    send_prompt ();
  }
}
Exemple #6
0
static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
  outfile_ctx_t         *outfile_ctx        = hashcat_ctx->outfile_ctx;
  status_ctx_t          *status_ctx         = hashcat_ctx->status_ctx;
  user_options_t        *user_options       = hashcat_ctx->user_options;
  user_options_extra_t  *user_options_extra = hashcat_ctx->user_options_extra;

  if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile

  if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
  {
    if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt ();
  }

  fwrite (buf, len,          1, stdout);
  fwrite (EOL, strlen (EOL), 1, stdout);

  if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
  {
    if (status_ctx->devices_status != STATUS_CRACKED)
    {
      if (outfile_ctx->filename == NULL) if (user_options->quiet == false) send_prompt ();
    }
  }
}
Exemple #7
0
void	handle_fileend(t_client *client, char cmd[], int size)
{
  if (client->file_fd <= 2)
  {
    dprintf(client->sockfd,
        "SENDERROR:Error: receiv file end but have no file desc%s",
        TCP_SEPARATOR);
    send_prompt(client);
    return ;
  }
  (void)cmd;
  (void)size;
  close(client->file_fd);
  client->filesize = 0;
  client->received = 0;
  send_prompt(client);
}
Exemple #8
0
void	handle_senderror(t_client *client, char cmd[], int size)
{
  (void)cmd;
  (void)size;
  if (client->file_fd > 2)
    close(client->file_fd);
  client->file_fd = -1;
  memset(client->filename, 0, 512);
  client->send_statut = -1;
  send_prompt(client);
}
Exemple #9
0
static void main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
  const user_options_t *user_options = hashcat_ctx->user_options;

  if (user_options->quiet == true) return;

  clear_prompt ();

  event_log_info (hashcat_ctx, "INFO: approaching final keyspace, workload adjusted");
  event_log_info (hashcat_ctx, "");

  send_prompt ();
}
Exemple #10
0
void	handle_data(t_client *client, char cmd[], int size)
{
  if (client->file_fd == -1)
  {
    dprintf(client->sockfd,
        "SENDERROR:Error: receiv data but have no file desc%s", TCP_SEPARATOR);
    send_prompt(client);
    return ;
  }
  write(client->file_fd, cmd, size);
  client->received += ((double)size / 1024);
  dprintf(client->sockfd, "NEXT%s", TCP_SEPARATOR);
}
Exemple #11
0
void	command_get(t_client *client, char cmd[], int size)
{
  int	fd;

  if (size <= 1)
  {
    dprintf(client->sockfd, "TEXT:Error: invalide filename%s", TCP_SEPARATOR);
    send_prompt(client);
    return ;
  }
  if ((fd = open(&cmd[1], O_RDONLY)) == -1)
  {
    dprintf(client->sockfd, "TEXT:Error: %s%s",
        strerror(errno), TCP_SEPARATOR);
    send_prompt(client);
    return ;
  }
  client->send_statut = 0;
  memset(client->filename, 0, 512);
  strcpy(client->filename, &cmd[1]);
  client->file_fd = fd;
  dprintf(client->sockfd, "FILENAME:%s%s", &cmd[1], TCP_SEPARATOR);
}
Exemple #12
0
void	handle_filename(t_client *client, char cmd[], int size)
{
  int	fd;

  (void)client;
  (void)size;
  if ((fd = open(cmd, O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1)
  {
    dprintf(client->sockfd, "SENDERROR:Error: %s%s",
        strerror(errno), TCP_SEPARATOR);
    send_prompt(client);
    return ;
  }
  printf("New file : %s\n", cmd);
  client->file_fd = fd;
  client->filesize = 0;
  client->received = 0;
  dprintf(client->sockfd, "NEXT%s", TCP_SEPARATOR);
}
Exemple #13
0
static void main_monitor_throttle2 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
  const user_options_t       *user_options       = hashcat_ctx->user_options;
  const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;

  if (user_options->quiet == true) return;

  if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
  {
    clear_prompt ();
  }

  u32 *device_id = (u32 *) buf;

  event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%u, expect performance to drop...", *device_id + 1);

  if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
  {
    send_prompt ();
  }
}
Exemple #14
0
static void main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
  const user_options_t       *user_options       = hashcat_ctx->user_options;
  const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;

  if (user_options->quiet == true) return;

  // Tell the user we're about to start

  if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
  {
    if ((user_options->quiet == false) && (user_options->benchmark == false) && (user_options->speed_only == false))
    {
      event_log_info_nn (hashcat_ctx, "");

      send_prompt ();
    }
  }
  else if (user_options_extra->wordlist_mode == WL_MODE_STDIN)
  {
    event_log_info (hashcat_ctx, "Starting attack in stdin mode...");
    event_log_info (hashcat_ctx, "");
  }
}
Exemple #15
0
static void keypress (hashcat_ctx_t *hashcat_ctx)
{
  status_ctx_t   *status_ctx   = hashcat_ctx->status_ctx;
  user_options_t *user_options = hashcat_ctx->user_options;

  // this is required, because some of the variables down there are not initialized at that point
  while (status_ctx->devices_status == STATUS_INIT) usleep (100000);

  const bool quiet = user_options->quiet;

  tty_break ();

  while (status_ctx->shutdown_outer == false)
  {
    int ch = tty_getchar ();

    if (ch == -1) break;

    if (ch ==  0) continue;

    //https://github.com/hashcat/hashcat/issues/302
    //#if defined (_POSIX)
    //if (ch != '\n')
    //#endif

    hc_thread_mutex_lock (status_ctx->mux_display);

    event_log_info (hashcat_ctx, NULL);

    switch (ch)
    {
      case 's':
      case '\r':
      case '\n':

        event_log_info (hashcat_ctx, NULL);

        status_display (hashcat_ctx);

        event_log_info (hashcat_ctx, NULL);

        if (quiet == false) send_prompt (hashcat_ctx);

        break;

      case 'b':

        event_log_info (hashcat_ctx, NULL);

        bypass (hashcat_ctx);

        event_log_info (hashcat_ctx, "Next dictionary / mask in queue selected. Bypassing current one.");

        event_log_info (hashcat_ctx, NULL);

        if (quiet == false) send_prompt (hashcat_ctx);

        break;

      case 'p':

        if (status_ctx->devices_status != STATUS_PAUSED)
        {
          event_log_info (hashcat_ctx, NULL);

          SuspendThreads (hashcat_ctx);

          if (status_ctx->devices_status == STATUS_PAUSED)
          {
            event_log_info (hashcat_ctx, "Paused");
          }

          event_log_info (hashcat_ctx, NULL);
        }

        if (quiet == false) send_prompt (hashcat_ctx);

        break;

      case 'r':

        if (status_ctx->devices_status == STATUS_PAUSED)
        {
          event_log_info (hashcat_ctx, NULL);

          ResumeThreads (hashcat_ctx);

          if (status_ctx->devices_status != STATUS_PAUSED)
          {
            event_log_info (hashcat_ctx, "Resumed");
          }

          event_log_info (hashcat_ctx, NULL);
        }

        if (quiet == false) send_prompt (hashcat_ctx);

        break;

      case 'c':

        event_log_info (hashcat_ctx, NULL);

        stop_at_checkpoint (hashcat_ctx);

        if (status_ctx->checkpoint_shutdown == true)
        {
          event_log_info (hashcat_ctx, "Checkpoint enabled. Will quit at next restore-point update.");
        }
        else
        {
          event_log_info (hashcat_ctx, "Checkpoint disabled. Restore-point updates will no longer be monitored.");
        }

        event_log_info (hashcat_ctx, NULL);

        if (quiet == false) send_prompt (hashcat_ctx);

        break;

      case 'q':

        event_log_info (hashcat_ctx, NULL);

        myquit (hashcat_ctx);

        break;

      default:

        if (quiet == false) send_prompt (hashcat_ctx);

        break;
    }

    //https://github.com/hashcat/hashcat/issues/302
    //#if defined (_POSIX)
    //if (ch != '\n')
    //#endif

    hc_thread_mutex_unlock (status_ctx->mux_display);
  }

  tty_fix ();
}