mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-21 14:50:49 +00:00
Add randomart print mode (pk/pK commands and rahash2 -k)
Random code cleanup Remove borders in webui/two
This commit is contained in:
parent
a436b496ad
commit
84270da643
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2012 pancake<nopcode.org> */
|
||||
/* radare - LGPL - Copyright 2009-2013 - pancake */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -14,28 +14,36 @@ static ut64 to = 0LL;
|
||||
static int incremental = 1;
|
||||
|
||||
static void do_hash_print(RHash *ctx, int hash, int dlen, int rad) {
|
||||
char *o;
|
||||
const ut8 *c = ctx->digest;
|
||||
const char *hname = r_hash_name (hash);
|
||||
ut32 *n = c;
|
||||
int i;
|
||||
if (rad) {
|
||||
printf ("e file.%s=", hname);
|
||||
for (i=0; i<dlen; i++)
|
||||
printf ("%02x", c[i]);
|
||||
printf ("\n");
|
||||
} else {
|
||||
switch (rad) {
|
||||
case 0:
|
||||
printf ("0x%08"PFMT64x"-0x%08"PFMT64x" %s: ", from, to, hname);
|
||||
for (i=0; i<dlen; i++)
|
||||
printf ("%02x", c[i]);
|
||||
printf ("\n");
|
||||
break;
|
||||
case 1:
|
||||
printf ("e file.%s=", hname);
|
||||
for (i=0; i<dlen; i++)
|
||||
printf ("%02x", c[i]);
|
||||
printf ("\n");
|
||||
break;
|
||||
default:
|
||||
o = r_print_randomart (c, dlen, *n);
|
||||
printf ("%s\n", o);
|
||||
free (o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int do_hash_internal(RHash *ctx, int hash, const ut8 *buf, int len, int rad, int print) {
|
||||
int dlen = r_hash_calculate (ctx, hash, buf, len);
|
||||
if (!dlen || rad == 2)
|
||||
return 0;
|
||||
if (!print)
|
||||
return 1;
|
||||
if (!dlen) return 0;
|
||||
if (!print) return 1;
|
||||
if (hash == R_HASH_ENTROPY) {
|
||||
double e = r_hash_entropy (buf, len);
|
||||
if (rad) {
|
||||
@ -47,7 +55,6 @@ static int do_hash_internal(RHash *ctx, int hash, const ut8 *buf, int len, int r
|
||||
printf ("\n");
|
||||
}
|
||||
} else do_hash_print (ctx, hash, dlen, rad);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -121,7 +128,7 @@ static int do_hash(const char *algo, RIO *io, int bsize, int rad) {
|
||||
}
|
||||
|
||||
static int do_help(int line) {
|
||||
printf ("Usage: rahash2 [-rBv] [-b bsize] [-a algo] [-s str] [-f from] [-t to] [file] ...\n");
|
||||
printf ("Usage: rahash2 [-rBkv] [-b bsize] [-a algo] [-s str] [-f from] [-t to] [file] ...\n");
|
||||
if (line) return 0;
|
||||
printf (
|
||||
" -a algo comma separated list of algorithms (default is 'sha1')\n"
|
||||
@ -130,6 +137,7 @@ static int do_help(int line) {
|
||||
" -s string hash this string instead of files\n"
|
||||
" -f from start hashing at given address\n"
|
||||
" -t to stop hashing at given address\n"
|
||||
" -k show hash using the openssh's randomkey algorithm\n"
|
||||
" -r output radare commands\n"
|
||||
" -v show version information\n"
|
||||
"Supported algorithms: md4, md5, sha1, sha256, sha384, sha512, crc16,\n"
|
||||
@ -142,17 +150,12 @@ int main(int argc, char **argv) {
|
||||
int c, rad = 0, quit = 0, bsize = 0;
|
||||
RIO *io;
|
||||
|
||||
while ((c = getopt (argc, argv, "rva:s:b:Bhf:t:")) != -1) {
|
||||
while ((c = getopt (argc, argv, "rva:s:b:Bhf:t:k")) != -1) {
|
||||
switch (c) {
|
||||
case 'r':
|
||||
rad = 1;
|
||||
break;
|
||||
case 'a':
|
||||
algo = optarg;
|
||||
break;
|
||||
case 'B':
|
||||
incremental = 0;
|
||||
break;
|
||||
case 'r': rad = 1; break;
|
||||
case 'k': rad = 2; break;
|
||||
case 'a': algo = optarg; break;
|
||||
case 'B': incremental = 0; break;
|
||||
case 'b':
|
||||
bsize = (int)r_num_math (NULL, optarg);
|
||||
break;
|
||||
@ -164,7 +167,7 @@ int main(int argc, char **argv) {
|
||||
to = strlen (optarg);
|
||||
do_hash_internal (ctx, //0, strlen (optarg),
|
||||
algobit, (const ut8*) optarg,
|
||||
strlen (optarg), 0, 1);
|
||||
strlen (optarg), rad, 1);
|
||||
r_hash_free (ctx);
|
||||
quit = R_TRUE;
|
||||
}
|
||||
|
@ -25,8 +25,7 @@ R_API RAnal *r_anal_new() {
|
||||
int i;
|
||||
RAnalPlugin *static_plugin;
|
||||
RAnal *anal = R_NEW (RAnal);
|
||||
if (!anal)
|
||||
return NULL;
|
||||
if (!anal) return NULL;
|
||||
memset (anal, 0, sizeof (RAnal));
|
||||
anal->diff_ops = 0;
|
||||
anal->diff_thbb = R_ANAL_THRESHOLDBB;
|
||||
@ -39,7 +38,9 @@ R_API RAnal *r_anal_new() {
|
||||
anal->reg = r_reg_new ();
|
||||
anal->lineswidth = 0;
|
||||
anal->fcns = r_anal_fcn_list_new ();
|
||||
#if USE_NEW_FCN_STORE
|
||||
anal->fcnstore = r_listrange_new ();
|
||||
#endif
|
||||
anal->hints = r_list_new ();
|
||||
anal->refs = r_anal_ref_list_new ();
|
||||
anal->types = r_anal_type_list_new ();
|
||||
|
@ -4,14 +4,12 @@
|
||||
#include <r_util.h>
|
||||
#include <r_list.h>
|
||||
|
||||
/* work in progress */
|
||||
#define USE_NEW_FCN_STORE 0
|
||||
/* faster retrival, slower storage */
|
||||
// TODO: use slist ?
|
||||
|
||||
R_API RAnalFunction *r_anal_fcn_new() {
|
||||
RAnalFunction *fcn = R_NEW (RAnalFunction);
|
||||
RAnalFunction *fcn = R_NEW0 (RAnalFunction);
|
||||
if (!fcn) return NULL;
|
||||
memset (fcn, 0, sizeof (RAnalFunction));
|
||||
fcn->name = NULL;
|
||||
fcn->dsc = NULL;
|
||||
/* Function return type */
|
||||
@ -73,7 +71,7 @@ R_API int r_anal_fcn_xref_add (RAnal *anal, RAnalFunction *fcn, ut64 at, ut64 ad
|
||||
R_API int r_anal_fcn_xref_del (RAnal *anal, RAnalFunction *fcn, ut64 at, ut64 addr, int type) {
|
||||
RAnalRef *ref;
|
||||
RListIter *iter;
|
||||
/* No _safe loop necessary because we return immediately after the delete. */
|
||||
/* No need for _safe loop coz we return immediately after the delete. */
|
||||
r_list_foreach (fcn->xrefs, iter, ref) {
|
||||
if ((type != -1 || type == ref->type) &&
|
||||
(at == 0LL || at == ref->at) &&
|
||||
@ -254,7 +252,7 @@ R_API int r_anal_fcn_del(RAnal *anal, ut64 addr) {
|
||||
R_API RAnalFunction *r_anal_fcn_find(RAnal *anal, ut64 addr, int type) {
|
||||
#if USE_NEW_FCN_STORE
|
||||
// TODO: type is ignored here? wtf.. we need more work on fcnstore
|
||||
if (root) return r_listrange_find_root (anal->fcnstore, addr);
|
||||
//if (root) return r_listrange_find_root (anal->fcnstore, addr);
|
||||
return r_listrange_find_in_range (anal->fcnstore, addr);
|
||||
#else
|
||||
RAnalFunction *fcn, *ret = NULL;
|
||||
|
@ -11,6 +11,7 @@
|
||||
// 1024
|
||||
#define RANGE (1<<RANGEBITS)
|
||||
#include <r_anal.h>
|
||||
#if USE_NEW_FCN_STORE
|
||||
|
||||
static int cmpfun(void *a, void *b) {
|
||||
RAnalFunction *fa = (RAnalFunction*)a;
|
||||
@ -113,9 +114,4 @@ R_API RAnalFunction *r_listrange_find_root(RListRange* s, ut64 addr) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
main() {
|
||||
RHashTable64 *h = r_listrange_new();
|
||||
r_listrange_add (h, f1);
|
||||
}
|
||||
#endif
|
||||
|
@ -91,47 +91,3 @@ R_API RAnalHint *r_anal_hint_get(RAnal *anal, ut64 addr) {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#if 0
|
||||
ahl 33 0x80340
|
||||
ahb 16 0x8048 10
|
||||
aha ppc $$ 128
|
||||
ah- $$
|
||||
// hints
|
||||
- instruction length
|
||||
- instruction text
|
||||
- bits
|
||||
- arch
|
||||
- analysis string (not yet)
|
||||
#endif
|
||||
|
||||
R_API RAnalHint *r_anal_init (RAnal* anal) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
R_API RAnalHint *r_anal_fini (RAnal* anal) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
R_API RAnalHint *r_anal_hint_cmd (RAnal* anal, const char *cmd) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
R_API int r_anal_hint_unset (RAnal* anal, ut64 addr) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
R_API RAnalHint *r_anal_hint_set_bits(RAnal* anal, ut64 addr, int bits, int len) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
R_API RAnalHint *r_anal_hint_get (RAnal* anal, ut64 addr) {
|
||||
RAnalHint *rah = NULL;
|
||||
//r_list_foreach (anal->hints, iter, h) { }
|
||||
// bits
|
||||
// if (h->arch) hint->arch = h->arch;
|
||||
// if (h->bits) hint->bits = h->bits;
|
||||
return rah;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* radare - LGPL - Copyright 2008-2012 - nibble, pancake */
|
||||
/* radare - LGPL - Copyright 2008-2013 - nibble, pancake */
|
||||
|
||||
#include <r_anal.h>
|
||||
#include <r_print.h>
|
||||
|
||||
R_API RMeta *r_meta_new() {
|
||||
RMeta *m = R_NEW (RMeta);
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2010-2011 */
|
||||
/* nibble<.ds@gmail.com> + pancake<nopcode.org> */
|
||||
/* radare - LGPL - Copyright 2010-2013 - pancake, nibble */
|
||||
|
||||
#include <r_anal.h>
|
||||
#include <r_util.h>
|
||||
@ -10,6 +9,7 @@ R_API RAnalOp *r_anal_op_new() {
|
||||
if (op) {
|
||||
memset (op, 0, sizeof (RAnalOp));
|
||||
op->mnemonic = NULL;
|
||||
op->evalstr = NULL;
|
||||
op->addr = -1;
|
||||
op->jump = -1;
|
||||
op->fail = -1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2010-2012 - nibble, pancake */
|
||||
/* radare - LGPL - Copyright 2010-2013 - nibble, pancake */
|
||||
|
||||
#include <r_anal.h>
|
||||
#include <r_util.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2012 - pancake, nibble */
|
||||
/* radare - LGPL - Copyright 2009-2013 - pancake, nibble */
|
||||
|
||||
#include <r_anal.h>
|
||||
#include <r_util.h>
|
||||
@ -68,36 +68,31 @@ R_API struct r_anal_refline_t *r_anal_reflines_get(struct r_anal_t *anal,
|
||||
// TODO: this is TOO SLOW. do not iterate over all reflines or gtfo
|
||||
/* umf..this should probably be outside this file */
|
||||
R_API char* r_anal_reflines_str(RAnal *anal, RAnalRefline *list, ut64 addr, int opts) {
|
||||
int linestyle = opts & R_ANAL_REFLINE_TYPE_STYLE;
|
||||
int wide = opts & R_ANAL_REFLINE_TYPE_WIDE;
|
||||
int l, linestyle = opts & R_ANAL_REFLINE_TYPE_STYLE;
|
||||
int dir = 0, wide = opts & R_ANAL_REFLINE_TYPE_WIDE;
|
||||
char ch = ' ', *str = NULL;
|
||||
struct list_head *pos;
|
||||
RAnalRefline *ref;
|
||||
int dir = 0;
|
||||
|
||||
if (!list)
|
||||
return NULL;
|
||||
if (!list) return NULL;
|
||||
str = r_str_concat (str, " ");
|
||||
for (pos = linestyle?(&(list->list))->next:(&(list->list))->prev;
|
||||
pos != (&(list->list)); pos = linestyle?pos->next:pos->prev) {
|
||||
ref = list_entry (pos, RAnalRefline, list);
|
||||
|
||||
if (addr == ref->to) dir = 1;
|
||||
else if (addr == ref->from) dir = 2;
|
||||
// TODO: if dir==1
|
||||
dir = (addr == ref->to)? 1: (addr == ref->from)? 2: dir;
|
||||
if (addr == ref->to) {
|
||||
str = r_str_concat (str, (ref->from>ref->to)?".":"`");
|
||||
ch = '-';
|
||||
} else if (addr == ref->from) {
|
||||
str = r_str_concat (str, (ref->from>ref->to)?"`":",");
|
||||
ch = '=';
|
||||
} else if (ref->from < ref->to) { /* down */
|
||||
} else if (ref->from < ref->to) {
|
||||
if (addr > ref->from && addr < ref->to) {
|
||||
if (ch=='-'||ch=='=')
|
||||
str = r_str_concatch (str, ch);
|
||||
else str = r_str_concatch (str, '|');
|
||||
} else str = r_str_concatch (str, ch);
|
||||
} else { /* up */
|
||||
} else {
|
||||
if (addr < ref->from && addr > ref->to) {
|
||||
if (ch=='-'||ch=='=')
|
||||
str = r_str_concatch (str, ch);
|
||||
@ -109,20 +104,16 @@ R_API char* r_anal_reflines_str(RAnal *anal, RAnalRefline *list, ut64 addr, int
|
||||
}
|
||||
str = r_str_concat (str, (dir==1)?"-> ":(dir==2)?"=< ":" ");
|
||||
if (anal->lineswidth>0) {
|
||||
int len = strlen (str);
|
||||
if (len>anal->lineswidth)
|
||||
r_str_cpy (str, str+len-anal->lineswidth);
|
||||
l = strlen (str);
|
||||
if (l>anal->lineswidth)
|
||||
r_str_cpy (str, str+l-anal->lineswidth);
|
||||
}
|
||||
{
|
||||
int l = anal->lineswidth-strlen (str);
|
||||
while (l-->0) {
|
||||
for (l = anal->lineswidth-strlen (str);l-->0;)
|
||||
str = r_str_prefix (str, " ");
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
R_API int r_anal_reflines_middle(RAnal *anal, RAnalRefline *list, ut64 addr, int len) {
|
||||
R_API int r_anal_reflines_middle(RAnal *a, RAnalRefline *list, ut64 addr, int len) {
|
||||
struct list_head *pos;
|
||||
for (pos = (&(list->list))->next; pos != (&(list->list)); pos = pos->next) {
|
||||
RAnalRefline *ref = list_entry (pos, RAnalRefline, list);
|
||||
|
@ -732,6 +732,39 @@ static int cmd_print(void *data, const char *input) {
|
||||
} else r_print_format (core->print, core->offset,
|
||||
core->block, len, input+1, -1, NULL);
|
||||
break;
|
||||
case 'k':
|
||||
{
|
||||
char *s = r_print_randomart (core->block, core->blocksize, core->offset);
|
||||
r_cons_printf ("%s\n", s);
|
||||
free (s);
|
||||
}
|
||||
break;
|
||||
case 'K':
|
||||
{
|
||||
ut64 offset0 = core->offset;
|
||||
r_cons_clear ();
|
||||
for (i=0; i< 4; i++) {
|
||||
char *s = r_print_randomart (core->block, core->blocksize, core->offset);
|
||||
r_cons_gotoxy (0, 0);
|
||||
r_cons_printf ("\n%s\n", s);
|
||||
free (s);
|
||||
core->offset += core->blocksize;
|
||||
r_core_read_at (core, core->offset, core->block, core->blocksize);
|
||||
s = r_print_randomart (core->block, core->blocksize, core->offset);
|
||||
r_cons_printf ("%s\n", s);
|
||||
core->offset += core->blocksize;
|
||||
r_core_read_at (core, core->offset, core->block, core->blocksize);
|
||||
s = r_print_randomart (core->block, core->blocksize, core->offset);
|
||||
r_cons_printf ("%s\n", s);
|
||||
r_cons_column (i!=3?20:0);
|
||||
free (s);
|
||||
core->offset += core->blocksize;
|
||||
r_core_read_at (core, core->offset, core->block, core->blocksize);
|
||||
}
|
||||
r_core_read_at (core, offset0, core->block, core->blocksize);
|
||||
core->offset = offset0;
|
||||
}
|
||||
break;
|
||||
case 'n': // easter penis
|
||||
for (l=0; l<10; l++) {
|
||||
printf ("\r8");
|
||||
@ -836,6 +869,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
" p[iI][f] [len] print N instructions/bytes (f=func) (see pdi)\n"
|
||||
" pm [magic] print libmagic data (pm? for more information)\n"
|
||||
" pr [len] print N raw bytes\n"
|
||||
" p[kK] [len] print key in randomart (K is for mosaic)\n"
|
||||
" ps[pwz] [len] print pascal/wide/zero-terminated strings\n"
|
||||
" pt[dn?] [len] print different timestamps\n"
|
||||
" pu[w] [len] print N url encoded bytes (w=wide)\n"
|
||||
|
@ -20,6 +20,9 @@
|
||||
*/
|
||||
#define R_ANAL_BB_HAS_OPS 0
|
||||
|
||||
/* TODO: work in progress */
|
||||
#define USE_NEW_FCN_STORE 0
|
||||
|
||||
// TODO: Remove this define? /cc @nibble_ds
|
||||
#define VERBOSE_ANAL if(0)
|
||||
|
||||
@ -539,6 +542,7 @@ typedef struct r_anal_op_t {
|
||||
RAnalValue *src[3];
|
||||
RAnalValue *dst;
|
||||
int refptr;
|
||||
char *evalstr; /* evaluation string . the new anal */
|
||||
struct r_anal_op_t *next;
|
||||
} RAnalOp;
|
||||
|
||||
|
@ -78,7 +78,7 @@ R_API int r_print_date_w32(RPrint *p, const ut8 *buf, int len);
|
||||
R_API int r_print_date_unix(RPrint *p, const ut8 *buf, int len);
|
||||
R_API void r_print_zoom(RPrint *p, void *user, RPrintZoomCallback cb, ut64 from, ut64 to, int len, int maxlen);
|
||||
R_API void r_print_progressbar(RPrint *pr, int pc, int _cols);
|
||||
|
||||
R_API char * r_print_randomart(const ut8 *dgst_raw, ut32 dgst_raw_len, ut64 addr);
|
||||
// WIP
|
||||
R_API int r_print_unpack7bit(const char *src, char *dest);
|
||||
R_API int r_print_pack7bit(const char *src, char *dest);
|
||||
|
@ -8,7 +8,7 @@ OBJS+=prof.o cache.o sys.o buf.o w32-sys.o base64.o base85.o name.o
|
||||
OBJS+=list.o flist.o ht.o ht64.o mixed.o btree.o chmod.o graph.o
|
||||
OBJS+=regex/regcomp.o regex/regerror.o regex/regexec.o uleb128.o
|
||||
OBJS+=sandbox.o calc.o thread.o lock.o strpool.o bitmap.o strht.o
|
||||
OBJS+=p_date.o p_format.o print.o p_seven.o slist.o
|
||||
OBJS+=p_date.o p_format.o print.o p_seven.o slist.o randomart.o
|
||||
|
||||
# DO NOT BUILD r_big api (not yet used and its buggy)
|
||||
ifeq (1,0)
|
||||
|
116
libr/util/randomart.c
Normal file
116
libr/util/randomart.c
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Draw an ASCII-Art representing the fingerprint so human brain can
|
||||
* profit from its built-in pattern recognition ability.
|
||||
* This technique is called "random art" and can be found in some
|
||||
* scientific publications like this original paper:
|
||||
*
|
||||
* "Hash Visualization: a New Technique to improve Real-World Security",
|
||||
* Perrig A. and Song D., 1999, International Workshop on Cryptographic
|
||||
* Techniques and E-Commerce (CrypTEC '99)
|
||||
* sparrow.ece.cmu.edu/~adrian/projects/validation/validation.pdf
|
||||
*
|
||||
* The subject came up in a talk by Dan Kaminsky, too.
|
||||
*
|
||||
* If you see the picture is different, the key is different.
|
||||
* If the picture looks the same, you still know nothing.
|
||||
*
|
||||
* The algorithm used here is a worm crawling over a discrete plane,
|
||||
* leaving a trace (augmenting the field) everywhere it goes.
|
||||
* Movement is taken from dgst_raw 2bit-wise. Bumping into walls
|
||||
* makes the respective movement vector be ignored for this turn.
|
||||
* Graphs are not unambiguous, because circles in graphs can be
|
||||
* walked in either direction.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Field sizes for the random art. Have to be odd, so the starting point
|
||||
* can be in the exact middle of the picture, and FLDBASE should be >=8 .
|
||||
* Else pictures would be too dense, and drawing the frame would
|
||||
* fail, too, because the key type would not fit in anymore.
|
||||
*/
|
||||
#include <r_util.h>
|
||||
|
||||
#define FLDBASE 8
|
||||
#define FLDSIZE_Y (FLDBASE + 1)
|
||||
#define FLDSIZE_X (FLDBASE * 2 + 1)
|
||||
|
||||
//static char * key_fingerprint_randomart(ut8 *dgst_raw, ut32 dgst_raw_len) {
|
||||
R_API char * r_print_randomart(const ut8 *dgst_raw, ut32 dgst_raw_len, ut64 addr) {
|
||||
/*
|
||||
* Chars to be used after each other every time the worm
|
||||
* intersects with itself. Matter of taste.
|
||||
*/
|
||||
char *augmentation_string = " .o+=*BOX@%&#/^SE";
|
||||
char *retval, *p;
|
||||
ut8 field[FLDSIZE_X][FLDSIZE_Y];
|
||||
ut32 i, b;
|
||||
int x, y;
|
||||
size_t len = strlen(augmentation_string) - 1;
|
||||
|
||||
retval = malloc((FLDSIZE_X + 3) * (FLDSIZE_Y + 2));
|
||||
|
||||
/* initialize field */
|
||||
memset(field, 0, FLDSIZE_X * FLDSIZE_Y * sizeof(char));
|
||||
x = FLDSIZE_X / 2;
|
||||
y = FLDSIZE_Y / 2;
|
||||
|
||||
/* process raw key */
|
||||
for (i = 0; i < dgst_raw_len; i++) {
|
||||
int input;
|
||||
/* each byte conveys four 2-bit move commands */
|
||||
input = dgst_raw[i];
|
||||
for (b = 0; b < 4; b++) {
|
||||
/* evaluate 2 bit, rest is shifted later */
|
||||
x += (input & 0x1) ? 1 : -1;
|
||||
y += (input & 0x2) ? 1 : -1;
|
||||
|
||||
/* assure we are still in bounds */
|
||||
x = R_MAX(x, 0);
|
||||
y = R_MAX(y, 0);
|
||||
x = R_MIN(x, FLDSIZE_X - 1);
|
||||
y = R_MIN(y, FLDSIZE_Y - 1);
|
||||
|
||||
/* augment the field */
|
||||
if (field[x][y] < len - 2)
|
||||
field[x][y]++;
|
||||
input = input >> 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* mark starting point and end point*/
|
||||
field[FLDSIZE_X / 2][FLDSIZE_Y / 2] = len - 1;
|
||||
field[x][y] = len;
|
||||
|
||||
/* fill in retval */
|
||||
#if 0
|
||||
snprintf(retval, FLDSIZE_X, "+--[%4s %4u]", key_type(k), key_size(k));
|
||||
#else
|
||||
//strcpy (retval, "+-------------");
|
||||
sprintf (retval, "+--[0x%08"PFMT64x"]-", addr);
|
||||
#endif
|
||||
p = strchr(retval, '\0');
|
||||
|
||||
/* output upper border */
|
||||
for (i = p - retval - 1; i < FLDSIZE_X; i++)
|
||||
*p++ = '-';
|
||||
*p++ = '+';
|
||||
*p++ = '\n';
|
||||
|
||||
/* output content */
|
||||
for (y = 0; y < FLDSIZE_Y; y++) {
|
||||
*p++ = '|';
|
||||
for (x = 0; x < FLDSIZE_X; x++)
|
||||
*p++ = augmentation_string[R_MIN(field[x][y], len)];
|
||||
*p++ = '|';
|
||||
*p++ = '\n';
|
||||
}
|
||||
|
||||
/* output lower border */
|
||||
*p++ = '+';
|
||||
for (i = 0; i < FLDSIZE_X; i++)
|
||||
*p++ = '-';
|
||||
*p++ = '+';
|
||||
*p++ = 0;
|
||||
|
||||
return retval;
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
.Nd block based hashing utility
|
||||
.Sh SYNOPSIS
|
||||
.Nm hasher2
|
||||
.Op Fl hBrv
|
||||
.Op Fl hBrkv
|
||||
.Op Fl a Ar algorithm
|
||||
.Op Fl b Ar size
|
||||
.Op Fl s Ar string
|
||||
@ -30,6 +30,8 @@ Select an algorithm for the hashing. Valid values are md5, crc32 and sha1
|
||||
Define the block size
|
||||
.It Fl B
|
||||
Show per-block hash
|
||||
.It Fl k
|
||||
Show result using OpenSSH's VisualHostKey randomart algorithm
|
||||
.It Fl s Ar string
|
||||
Hash this string instead of using the 'source' and 'hash-file' arguments.
|
||||
.It Fl f Ar from
|
||||
|
@ -1,11 +1,11 @@
|
||||
<html>
|
||||
<body style="border:0;margin:0;background-color:#303030">
|
||||
<table style="spacing:0;spacing:0px;border:0px;padding:0px;width:100%;height:100%">
|
||||
<body style="border:0px;margin:0px;background-color:#303030">
|
||||
<table style="spacing:0px;border:0px;padding:0px;width:100%;height:100%">
|
||||
<tr height="100%">
|
||||
<td>
|
||||
<iframe style="width:100%;height:100%;scroll:overflow" src="/enyo/"></iframe>
|
||||
<iframe style="border:0px;width:100%;height:100%;scroll:overflow" src="/enyo/"></iframe>
|
||||
</td><td style="margin:0px;border:0">
|
||||
<iframe style="width:100%;height:100%;scroll:overflow" src="/enyo/#hex"></iframe>
|
||||
<iframe style="border:0px;width:100%;height:100%;scroll:overflow" src="/enyo/#hex"></iframe>
|
||||
<td>
|
||||
<tr>
|
||||
<table>
|
||||
|
Loading…
x
Reference in New Issue
Block a user