PEDORRO es una utilidad del 2007 creada por KPS para tratar el tamaño de ficheros, por ejemplo si queremos eliminar ciertos bytes del principio de un fichero o del final o de ambos sentidos, un ejemplo práctico lo teneis con el juego
Silent hill 2 director's cut *MULTI 5* *RiP LOSSY* (https://www.kapitalsin.com/forum/index.php?topic=2279.0)
He creado una versión compilada con GCC para Windows 32 y para Linux 64 (estática, no necesita GLibc concretas ni nada), previamente estaba compilada con Cygwin que da problemas con Wine
Se liberó el código fuente bajo licéncia de DOMINIO PÚBLICO
CODIGO FUENTE
/* LICENSE: PUBLIC DOMAIN */
/* Pedorro: extracts a block from a file */
/* CODE KPS 2007 */
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <stdlib.h>
#if WIN32
#define fseeko _fseeki64
#define ftello _ftelli64
typedef __int64 off_t;
int fseeko(FILE *stream, off_t offset, int whence);
off_t ftello(FILE *stream);
#endif
void usage(void)
{
printf("KAPITALSIN 2007 PRESENTA\n");
printf("\n");
printf("Pedorro: extracts a block from a file\n");
printf("Usage: pedorro.exe in_file [-]start_pos [-][end_pos]\n");
printf("\n");
printf("in_file: Input file\n");
printf("start_pos: offset of the beginning of the block in bytes\n");
printf(" If positive, offset is from start of the file\n");
printf(" If negative, offset is from end of the file\n");
printf(" If zero, is start of file\n");
printf("end_pos: offset of the end of the block in bytes\n");
printf(" If positive, offset is from start of the file\n");
printf(" If negative, offset is from end of the file\n");
printf(" If zero, is end of file\n");
printf("\n");
printf("Example: pedorro.exe infile.bin 4 -8 >outfile.bin\n");
printf(" Removes the four first and the eight last bytes\n");
printf(" of the input file\n");
printf("\n");
}
int main(int argc, char *argv[])
{
FILE *in_file;
int data;
off_t start_pos;
off_t end_pos;
off_t counter;
off_t in_file_size;
if(argc < 4)
{
usage();
return 1;
}
in_file=fopen(argv[1], "rb");
if(in_file == NULL)
{
printf("Error in input file\n");
return 2;
}
fseeko(in_file, 0, SEEK_END);
in_file_size = ftello(in_file);
start_pos = atoi(argv[2]);
if(argc < 4)
{
end_pos = 0;
}
else
{
end_pos = atoi(argv[3]);
}
if(start_pos < 0) start_pos += in_file_size - 1;
if(end_pos == 0) end_pos = in_file_size - 1;
if(end_pos < 0) end_pos += in_file_size - 1;
fseeko(in_file, start_pos, SEEK_SET);
counter = end_pos - start_pos + 1;
while(counter-- > 0)
{
data = fgetc(in_file);
fputc(data, stdout);
}
fclose(in_file);
return 0;
}
Como compilarlo bajo windows (previamente tienes de tener el GCC instalado y los path del GCC)
gcc pedorro.c -o pedorro.exe
strip pedorro.exe
Bajo Linux
gcc -static pedorro.c -o pedorro.bin
strip pedorro.bin
Si tienes el upx (es recomendable pues
upx --ultra-brute pedorro.*
Igualmente lo podeis descargar en el adjunto al igual que los binarios compilados para Windows (32 bits) y GNU/Linux (64 bits)