示例#1
0
static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, char *buf, u32 index)
{
  FILE *fp = fopen (buf, "rb");

  if (fp == NULL) // feof() in case if file is empty
  {
    const int rc = mp_expand (hashcat_ctx, buf, strlen (buf), mp_sys, mp_usr, index, 1);

    if (rc == -1) return -1;
  }
  else
  {
    char mp_file[1024] = { 0 };

    const size_t nread = fread (mp_file, 1, sizeof (mp_file) - 1, fp);

    if (!feof (fp))
    {
      event_log_error (hashcat_ctx, "%s: Custom charset file is too large", buf);

      fclose (fp);

      return -1;
    }
    else
    {
      fclose (fp);
    }

    if (nread == 0)
    {
      event_log_error (hashcat_ctx, "%s: Custom charset file is empty", buf);

      return -1;
    }

    const size_t len = in_superchop (mp_file);

    if (len == 0)
    {
      event_log_error (hashcat_ctx, "%s: Custom charset file is corrupted", buf);

      return -1;
    }

    const int rc = mp_expand (hashcat_ctx, mp_file, len, mp_sys, mp_usr, index, 0);

    if (rc == -1) return -1;
  }

  return 0;
}
示例#2
0
文件: mpsp.c 项目: ritchietam/hashcat
static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, const char *buf, const u32 userindex)
{
  FILE *fp = fopen (buf, "rb");

  if (fp == NULL) // feof() in case if file is empty
  {
    const int rc = mp_expand (hashcat_ctx, buf, strlen (buf), mp_sys, mp_usr, userindex, 1);

    if (rc == -1) return -1;
  }
  else
  {
    char mp_file[1024];

    const size_t nread = hc_fread (mp_file, 1, sizeof (mp_file) - 1, fp);

    if (!feof (fp))
    {
      event_log_error (hashcat_ctx, "%s: Custom charset file is too large.", buf);

      fclose (fp);

      return -1;
    }

    fclose (fp);

    if (nread == 0)
    {
      event_log_error (hashcat_ctx, "%s: Custom charset file is empty.", buf);

      return -1;
    }

    mp_file[nread] = 0;

    const size_t len = superchop_with_length (mp_file, nread);

    if (len == 0)
    {
      event_log_error (hashcat_ctx, "%s: Custom charset file is corrupted.", buf);

      return -1;
    }

    const int rc = mp_expand (hashcat_ctx, mp_file, len, mp_sys, mp_usr, userindex, 0);

    if (rc == -1) return -1;
  }

  return 0;
}
示例#3
0
文件: mpolarmod.c 项目: aluque/strees
static PyObject *
expand (PyObject *self, PyObject *args)
{
  int maxl, inout;

  PyArrayObject *r, *q, *res;

  if (!PyArg_ParseTuple(args, "iO!O!i", 
			&maxl,
			&PyArray_Type, &r, 
			&PyArray_Type, &q, 
			&inout))
    return NULL;

  if (maxl > MP_MAXL) {
     PyErr_SetString(PyExc_ValueError, 
		     "Not enough memory to compute so many terms.  Change MP_MAXL and recompile");
     return NULL;
  }

  res = mp_expand (maxl, r, q, inout);

  return PyArray_Return (res);
}