exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

cdump.c

cdump.c
Posted Jul 17, 2002
Authored by netric, PoWeR PoRK | Site netric.org

Simple pipe driven utility for creating c-style char decs from binary input. Can be of use for embedding shellcode etc in c sourcefiles.

tags | shellcode
systems | unix
SHA-256 | 4a6f029c31af9c526bea153a129ac74524a75df0ffb07a45e880902c7f0e3df0

cdump.c

Change Mirror Download
/*
* [cdump 0.1 by PoWeR_PoRK of netric (http://www.netric.org)]
*
* Simple pipe driven utility for creating c-style char decs from binary
* input. Can be of use for embedding shellcode etc in c sourcefiles.
* Do "./shdump -h" for a usage overview.
*/

#include <stdio.h>

char usage[] =
"Usage: ./cdump [-h][-n <var name>][-u][-s <linesize>][-c [-cu]]\n"
"Pipe driven utility for coverting binary data to c char declaration.\n"
"Example: cat binfile | ./shdump -u -s 20 >> bin.c\n"
"This adds the contents of binfile to bin.c in char declaration format\n\n"

"-h <var name> See this usage overview\n"
"-n Name of the char identifier (maxsize=30, default=foobar)\n"
"-u Set this to uppercase the hex output\n"
"-s <linesize> Set the maximum line size per byte input (default=10)\n"
"-c Comment the byte offsets into the output\n"
"-cu Set this to uppercase hex chars in byte offset comment\n";

int main(int argc, char **argv[])
{
int i = -2,oldi, lsize = 10, ucase = 0, npar = 1, cc = 1, cmt = 0, cucase = 0;
unsigned long place = 0;
char c, vname[31];
vname[30] = 0;
strncpy(&vname, "foobar", 30);

if(argc > 1){
if(!strncmp(argv[1], "-h", 2)){
printf("%s", &usage);
exit(0);
}

while(npar <= 5 && npar <= (argc - 1)){
if(!strncmp(argv[npar], "-n", 2)){
strncpy(&vname, argv[npar+1], 30);
npar+=2;
}else if(!strncmp(argv[npar], "-u", 2)){
ucase = 1;
npar++;
}else if(!strncmp(argv[npar], "-s", 2)){
lsize = atoi(argv[npar+1]);
npar+=2;
}else if(!strncmp(argv[npar], "-c", 2)){
cmt = 1;
npar++;
if(npar <= (argc - 1)){
if(!strncmp(argv[npar], "-cu", 3)){
cucase = 1;
npar++;
}
}
}else{
npar = argc;
}
}

}

if(strchr((char *)&vname, 37) != NULL){
printf("Cheeky Bastard! :P (fmt exploitation not allowed)\n");
exit(0);
}

oldi = getchar();
printf("char %s =\n/* 0000:0000 */ \"", (char *)&vname);
while(oldi != EOF )
{
if( ucase == 0 ){
printf("\\x%.2x", oldi);
}else if( ucase == 1 ){
printf("\\x%.2X", oldi);
}
if(cc >= lsize){
if(cmt == 1){
place += cc;
if(cucase == 1){
printf("\"\n/* %.4X:%.4X */ ", *((unsigned short *)&place + 1), *((unsigned short *)&place));
}else{
printf("\"\n/* %.4x:%.4x */ ", *((unsigned short *)&place + 1), *((unsigned short *)&place));
}
}else{
printf("\"\n");
}
printf("\"");
cc = 0;
}
cc++;
oldi = getchar();
}
printf("\";\n");
return 0;
}
Login or Register to add favorites

File Archive:

December 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close