what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

priv8hex.c

priv8hex.c
Posted Jul 26, 2004
Authored by konewka | Site priv8security.com

Simple utility to view hex.

SHA-256 | aac4af0dd11b60dd8e9c9f7d53aac544ce99b0e1fedce792e18d52f71a54f3c7

priv8hex.c

Change Mirror Download
/*
** priv8hex.c by aleksander 'konewka' ambrozkiewicz
**
** Simple hex viewer.
**
** www.priv8security.com
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>

#define RED "\033[01;31m"
#define NORM "\033\[00;00m"

void usage(char *progname);
void dump_hex(FILE *fd);
void clear_buf(char *buf, int size);
void clear_int(int itc[], int size);

void clear_int(int itc[], int size) {
int i;

for (i=0;i<=size;i++)
itc[i] = 0;
}

void clear_buf(char *buf, int size) {
int i;

for (i=0;i<=size;i++)
buf[i] = '\0';
}

void dump_hex(FILE *fd) {
char buf[16];
int c, i, j, hex[15];

clear_buf(buf, 16);
clear_int(hex, 15);
for (i=1,j=0;(c = getc(fd)) != EOF;i++) {
(isprint(c)) ? (buf[j] = c) : (buf[j] = '.');
hex[j++] = c;

if (!(i%16)) {
printf("("RED"0x%02x"NORM") | ", i/16);
for (j=0;j<=15;j++)
printf("%02x ", hex[j]);
printf("| %s\n", buf);
j = 0;
clear_buf(buf, 16);
clear_int(hex, 15);
}
}
if (i%16) {
printf("("RED"0x%02x"NORM") | ", (i+16)/16);
for (j=0;j<=15;j++)
printf("%02x ", hex[j]);
printf("| %s\n", buf);
}
}

void usage(char *progname) {
printf(RED"+"NORM" priv8hex written by konewka (www.priv8security.com)\n");
printf(RED"+"NORM" usage : %s <file>\n", progname);
exit(0);
}

int main(int argc, char *argv[]) {
FILE *fd;

if (argc < 2)
usage(argv[0]);

if (!(fd = fopen(argv[1], "r"))) {
printf(RED"-"NORM" cant open file\n");
return -1;
}

dump_hex(fd);

return 0;
}
Login or Register to add favorites

File Archive:

May 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    44 Files
  • 2
    May 2nd
    5 Files
  • 3
    May 3rd
    11 Files
  • 4
    May 4th
    0 Files
  • 5
    May 5th
    0 Files
  • 6
    May 6th
    28 Files
  • 7
    May 7th
    3 Files
  • 8
    May 8th
    4 Files
  • 9
    May 9th
    54 Files
  • 10
    May 10th
    12 Files
  • 11
    May 11th
    0 Files
  • 12
    May 12th
    0 Files
  • 13
    May 13th
    17 Files
  • 14
    May 14th
    11 Files
  • 15
    May 15th
    17 Files
  • 16
    May 16th
    13 Files
  • 17
    May 17th
    22 Files
  • 18
    May 18th
    0 Files
  • 19
    May 19th
    0 Files
  • 20
    May 20th
    17 Files
  • 21
    May 21st
    18 Files
  • 22
    May 22nd
    7 Files
  • 23
    May 23rd
    111 Files
  • 24
    May 24th
    27 Files
  • 25
    May 25th
    0 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    6 Files
  • 28
    May 28th
    12 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close