how to get percentage
#1
how to get percentage or calcul position from oclhashcat.restore file
#2
here is the .restore struct

Code:
typedef struct
{
  uint   version_bin;
  char   cwd[256];
  uint   argc;
  char   argv[30][256];
  uint   pw_min;
  uint64 pw_skip;
  pid_t  pid;
  char   unused[228];

} restore_data_t;

all you need is the pw_skip variable (and pw_min if you are not doing -m 1900).

#3
Hi, I folow your advice but to parse the file I have a problem,
how many bytes each field occupies the structure. Since I did this task and the results are as follows
typedef struct
{
uint version_bin; 4 bytes
char cwd[256]; 256 bytes
uint argc; 4 bytes
char argv[30][256]; 7680 bytes
uint pw_min; 4 bytes
uint64 pw_skip; 8 bytes
pid_t pid; 4 bytes (int)
char unused[228]; 228 bytes

} restore_data_t;
If you add up the bytes of each field that results in 8188 bytes, but the file in my oclhashcat-lite v0.06 “oclHashcat-lite.restore” has 8192 bytes, so i have 4 bytes of difference. I can not do anything until we find out why those 4 bytes of difference.
#4
its not really a problem since the pw_skip offset does not change.
#5
but how can i read the file? where I put the bytes in the difference, in the end?
#6
pls atom! i need more details about how to read from .restore file... thanks
#7
do i really explain you how to code?
#8
sir, i send to you my code, tha was made with your instrucction and not work. this is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace OCLFileReader
{
public class OCLRestoreData
{
public uint version_bin;
public byte[] cwd = new byte[256];
public uint argc;
public byte[,] argv = new byte[30, 256];
public uint pw_min;
public ulong pw_skip;
public int pid;

public byte[] unused = new byte[232];

public static OCLRestoreData Deserialize(string fileName)
{
OCLRestoreData rData = new OCLRestoreData();
byte[] bytes = File.ReadAllBytes(fileName);
int cursor = 0;

// Reading version_bin
rData.version_bin = (uint)bytes[cursor++] << 24 | (uint)bytes[cursor++] << 16 | (uint)bytes[cursor++] << 8 | (uint)bytes[cursor++];

// Reading cwd
for (int i = 0; i < 256; i++)
rData.cwd[i] = bytes[cursor++];

// Reading argc
rData.argc = (uint)bytes[cursor++] << 24 | (uint)bytes[cursor++] << 16 | (uint)bytes[cursor++] << 8 | (uint)bytes[cursor++];

// Reading argv
for (int i = 0; i < 30; i++)
for (int j = 0; j < 256; j++)
rData.argv[i, j] = bytes[cursor++];

// Reading pw_min
rData.pw_min = (uint)bytes[cursor++] << 24 | (uint)bytes[cursor++] << 16 | (uint)bytes[cursor++] << 8 | (uint)bytes[cursor++];

// Reading pw_skip
rData.pw_skip = (uint)bytes[cursor++] << 56 | (uint)bytes[cursor++] << 48 | (uint)bytes[cursor++] << 40 | (uint)bytes[cursor++] << 32 |
(uint)bytes[cursor++] << 24 | (uint)bytes[cursor++] << 16 | (uint)bytes[cursor++] << 8 | (uint)bytes[cursor++];

// Reading pw_min
rData.pid = bytes[cursor++] << 24 | bytes[cursor++] << 16 | bytes[cursor++] << 8 | bytes[cursor++];

// Reading unused
for (int i = 0; i < 232; i++)
rData.unused[i] = bytes[cursor++];

return rData;
}
}

class Program
{
static void Main(string[] args)
{
string fileName = @"d:\SL3-xgold\tools\oclHashcat-lite-0.06\oclHashcat-lite.restore";

OCLRestoreData rData = OCLRestoreData.Deserialize(fileName);

Console.WriteLine("version_bin: " + rData.version_bin);
Console.WriteLine("argc: " + rData.argc);
Console.WriteLine("pw_min: " + rData.pw_min);
Console.WriteLine("pw_skip: " + rData.pw_skip);
Console.WriteLine("pid: " + rData.pid);

string r = Console.ReadLine();
}
}
}


the scanned data are not correct
#9
this one should compile cleanly with gcc.

Code:
$ cat print-restore.c
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <sys/stat.h>
#include <time.h>
#include <getopt.h>
#include <unistd.h>

typedef uint32_t uint;
typedef uint64_t uint64;

typedef struct
{
  uint   version_bin;
  char   cwd[256];
  uint   argc;
  char   argv[30][256];
  uint   pw_min;
  uint64 pw_skip;
  char   unused[232];

} restore_data_t;

static void read_restore (const char *eff_restore_file, restore_data_t *rd)
{
  FILE *fp = fopen (eff_restore_file, "rb");

  if (fp == NULL)
  {
    fprintf (stderr, "ERROR: restore file '%s': %s\n", eff_restore_file, strerror (errno));

    exit (-1);
  }

  size_t nread = fread (rd, sizeof (restore_data_t), 1, fp);

  if (nread != 1)
  {
    fprintf (stderr, "ERROR: cannot read %s\n", eff_restore_file);

    exit (-1);
  }

  fclose (fp);

  if (chdir (rd->cwd))
  {
    fprintf (stderr, "ERROR: cannot chdir to %s: %s\n", rd->cwd, strerror (errno));

    exit (-1);
  }
}

int main (int argc, char *argv[])
{
  if (argc != 2)
  {
    fprintf (stderr, "usage: %s restore-file\n", argv[0]);

    return (-1);
  }

  restore_data_t *rd = (restore_data_t *) malloc (sizeof (restore_data_t));

  memset (rd, 0, sizeof (restore_data_t));

  read_restore (argv[1], rd);

  printf ("%llu\n", rd->pw_skip);

  return 0;
}
#10
Sir thank you very much for your cooperation I appreciate it a lot, the code let me know where are the errors in my.
Sir if you would kindly provide me some information about how to ask other status parameters like time running and time left, HW.Monitor, etc, and if there is any way to send pause or resume, that operations are essential for the shell that I building.
Again thanks a lot for your help