1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-12 11:52:01 +01:00
metasploit-framework/tools/context/stat-key.c
HD Moore 74a68138fc Add new context-keyed encoders from Dimitris Glynos ( http://census-labs.com/news/2010/06/04/athcon-2010-update/ )
git-svn-id: file:///home/svn/framework3/trunk@9457 4d416f70-5f16-0410-b530-b9f4589650da
2010-06-09 16:43:46 +00:00

35 lines
713 B
C

/*
* Given a filename, outputs a 32bit key for use in
* context keyed payload encoding. The key is derived from
* XOR-ing the st_size and st_mtime fields of the
* relevant struct stat for this file.
*
* Author: Dimitris Glynos <dimitris at census-labs.com>
*/
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
char *filename;
struct stat stat_buf;
if (argc != 2) {
fprintf(stderr, "usage: %s <filename>\n", argv[0]);
return 1;
}
filename = argv[1];
if (stat(filename, &stat_buf) == -1) {
perror("error while stat(2)-ing file");
return 1;
}
printf("%#.8lx\n", stat_buf.st_mtime ^ stat_buf.st_size);
return 0;
}