5 changed files with 2 additions and 723 deletions
			
			
		| @ -1,241 +0,0 @@ | |||||
| /*
 |  | ||||
|  * This code implements the MD5 message-digest algorithm. |  | ||||
|  * The algorithm is due to Ron Rivest.  This code was |  | ||||
|  * written by Colin Plumb in 1993, no copyright is claimed. |  | ||||
|  * This code is in the public domain; do with it what you wish. |  | ||||
|  * |  | ||||
|  * Equivalent code is available from RSA Data Security, Inc. |  | ||||
|  * This code has been tested against that, and is equivalent, |  | ||||
|  * except that you don't need to include two pages of legalese |  | ||||
|  * with every copy. |  | ||||
|  * |  | ||||
|  * To compute the message digest of a chunk of bytes, declare an |  | ||||
|  * MD5Context structure, pass it to MD5Init, call MD5Update as |  | ||||
|  * needed on buffers full of bytes, and then call MD5Final, which |  | ||||
|  * will fill a supplied 16-byte array with the digest. |  | ||||
|  * |  | ||||
|  * Changed so as no longer to depend on Colin Plumb's `usual.h' header |  | ||||
|  * definitions; now uses stuff from dpkg's config.h. |  | ||||
|  *  - Ian Jackson <ijackson@nyx.cs.du.edu>. |  | ||||
|  * Still in the public domain. |  | ||||
|  */ |  | ||||
| 
 |  | ||||
| #include <string.h>		/* for memcpy() */ |  | ||||
| 
 |  | ||||
| #include "md5.h" |  | ||||
| 
 |  | ||||
| /* HAS_BIGENDIAN_WORDS auskommentiertt wg. ppc-architektur */ |  | ||||
| /* #ifdef HAS_BIGENDIAN_WORDS */ |  | ||||
| void |  | ||||
| byteSwap(UWORD32 *buf, unsigned words) |  | ||||
| { |  | ||||
| 	md5byte *p = (md5byte *)buf; |  | ||||
| 
 |  | ||||
| 	do { |  | ||||
| 		*buf++ = (UWORD32)((unsigned)p[3] << 8 | p[2]) << 16 | |  | ||||
| 			((unsigned)p[1] << 8 | p[0]); |  | ||||
| 		p += 4; |  | ||||
| 	} while (--words); |  | ||||
| } |  | ||||
| /*
 |  | ||||
| #else |  | ||||
| #define byteSwap(buf,words) |  | ||||
| #endif |  | ||||
| */ |  | ||||
| 
 |  | ||||
| /*
 |  | ||||
|  * Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious |  | ||||
|  * initialization constants. |  | ||||
|  */ |  | ||||
| void |  | ||||
| MD5Init(struct MD5Context *ctx) |  | ||||
| { |  | ||||
| 	ctx->buf[0] = 0x67452301; |  | ||||
| 	ctx->buf[1] = 0xefcdab89; |  | ||||
| 	ctx->buf[2] = 0x98badcfe; |  | ||||
| 	ctx->buf[3] = 0x10325476; |  | ||||
| 
 |  | ||||
| 	ctx->bytes[0] = 0; |  | ||||
| 	ctx->bytes[1] = 0; |  | ||||
| } |  | ||||
| 
 |  | ||||
| /*
 |  | ||||
|  * Update context to reflect the concatenation of another buffer full |  | ||||
|  * of bytes. |  | ||||
|  */ |  | ||||
| void |  | ||||
| MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len) |  | ||||
| { |  | ||||
| 	UWORD32 t; |  | ||||
| 
 |  | ||||
| 	/* Update byte count */ |  | ||||
| 
 |  | ||||
| 	t = ctx->bytes[0]; |  | ||||
| 	if ((ctx->bytes[0] = t + len) < t) |  | ||||
| 		ctx->bytes[1]++;	/* Carry from low to high */ |  | ||||
| 
 |  | ||||
| 	t = 64 - (t & 0x3f);	/* Space available in ctx->in (at least 1) */ |  | ||||
| 	if (t > len) { |  | ||||
| 		memcpy((md5byte *)ctx->in + 64 - t, buf, len); |  | ||||
| 		return; |  | ||||
| 	} |  | ||||
| 	/* First chunk is an odd size */ |  | ||||
| 	memcpy((md5byte *)ctx->in + 64 - t, buf, t); |  | ||||
| 	byteSwap(ctx->in, 16); |  | ||||
| 	MD5Transform(ctx->buf, ctx->in); |  | ||||
| 	buf += t; |  | ||||
| 	len -= t; |  | ||||
| 
 |  | ||||
| 	/* Process data in 64-byte chunks */ |  | ||||
| 	while (len >= 64) { |  | ||||
| 		memcpy(ctx->in, buf, 64); |  | ||||
| 		byteSwap(ctx->in, 16); |  | ||||
| 		MD5Transform(ctx->buf, ctx->in); |  | ||||
| 		buf += 64; |  | ||||
| 		len -= 64; |  | ||||
| 	} |  | ||||
| 
 |  | ||||
| 	/* Handle any remaining bytes of data. */ |  | ||||
| 	memcpy(ctx->in, buf, len); |  | ||||
| } |  | ||||
| 
 |  | ||||
| /*
 |  | ||||
|  * Final wrapup - pad to 64-byte boundary with the bit pattern  |  | ||||
|  * 1 0* (64-bit count of bits processed, MSB-first) |  | ||||
|  */ |  | ||||
| void |  | ||||
| MD5Final(md5byte digest[16], struct MD5Context *ctx) |  | ||||
| { |  | ||||
| 	int count = ctx->bytes[0] & 0x3f;	/* Number of bytes in ctx->in */ |  | ||||
| 	md5byte *p = (md5byte *)ctx->in + count; |  | ||||
| 
 |  | ||||
| 	/* Set the first char of padding to 0x80.  There is always room. */ |  | ||||
| 	*p++ = 0x80; |  | ||||
| 
 |  | ||||
| 	/* Bytes of padding needed to make 56 bytes (-8..55) */ |  | ||||
| 	count = 56 - 1 - count; |  | ||||
| 
 |  | ||||
| 	if (count < 0) {	/* Padding forces an extra block */ |  | ||||
| 		memset(p, 0, count + 8); |  | ||||
| 		byteSwap(ctx->in, 16); |  | ||||
| 		MD5Transform(ctx->buf, ctx->in); |  | ||||
| 		p = (md5byte *)ctx->in; |  | ||||
| 		count = 56; |  | ||||
| 	} |  | ||||
| 	memset(p, 0, count); |  | ||||
| 	byteSwap(ctx->in, 14); |  | ||||
| 
 |  | ||||
| 	/* Append length in bits and transform */ |  | ||||
| 	ctx->in[14] = ctx->bytes[0] << 3; |  | ||||
| 	ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29; |  | ||||
| 	MD5Transform(ctx->buf, ctx->in); |  | ||||
| 
 |  | ||||
| 	byteSwap(ctx->buf, 4); |  | ||||
| 	memcpy(digest, ctx->buf, 16); |  | ||||
| 	memset(ctx, 0, sizeof(ctx));	/* In case it's sensitive */ |  | ||||
| } |  | ||||
| 
 |  | ||||
| #ifndef ASM_MD5 |  | ||||
| 
 |  | ||||
| /* The four core functions - F1 is optimized somewhat */ |  | ||||
| 
 |  | ||||
| /* #define F1(x, y, z) (x & y | ~x & z) */ |  | ||||
| #define F1(x, y, z) (z ^ (x & (y ^ z))) |  | ||||
| #define F2(x, y, z) F1(z, x, y) |  | ||||
| #define F3(x, y, z) (x ^ y ^ z) |  | ||||
| #define F4(x, y, z) (y ^ (x | ~z)) |  | ||||
| 
 |  | ||||
| /* This is the central step in the MD5 algorithm. */ |  | ||||
| #define MD5STEP(f,w,x,y,z,in,s) \ |  | ||||
| 	 (w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x) |  | ||||
| 
 |  | ||||
| /*
 |  | ||||
|  * The core of the MD5 algorithm, this alters an existing MD5 hash to |  | ||||
|  * reflect the addition of 16 longwords of new data.  MD5Update blocks |  | ||||
|  * the data and converts bytes into longwords for this routine. |  | ||||
|  */ |  | ||||
| void |  | ||||
| MD5Transform(UWORD32 buf[4], UWORD32 const in[16]) |  | ||||
| { |  | ||||
| 	register UWORD32 a, b, c, d; |  | ||||
| 
 |  | ||||
| 	a = buf[0]; |  | ||||
| 	b = buf[1]; |  | ||||
| 	c = buf[2]; |  | ||||
| 	d = buf[3]; |  | ||||
| 
 |  | ||||
| 	MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); |  | ||||
| 	MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); |  | ||||
| 	MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); |  | ||||
| 	MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); |  | ||||
| 	MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); |  | ||||
| 	MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); |  | ||||
| 	MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); |  | ||||
| 	MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); |  | ||||
| 	MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); |  | ||||
| 	MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); |  | ||||
| 	MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); |  | ||||
| 	MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); |  | ||||
| 	MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); |  | ||||
| 	MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); |  | ||||
| 	MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); |  | ||||
| 	MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); |  | ||||
| 
 |  | ||||
| 	MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); |  | ||||
| 	MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); |  | ||||
| 	MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); |  | ||||
| 	MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); |  | ||||
| 	MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); |  | ||||
| 	MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); |  | ||||
| 	MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); |  | ||||
| 	MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); |  | ||||
| 	MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); |  | ||||
| 	MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); |  | ||||
| 	MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); |  | ||||
| 	MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); |  | ||||
| 	MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); |  | ||||
| 	MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); |  | ||||
| 	MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); |  | ||||
| 	MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); |  | ||||
| 
 |  | ||||
| 	MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); |  | ||||
| 	MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); |  | ||||
| 	MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); |  | ||||
| 	MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); |  | ||||
| 	MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); |  | ||||
| 	MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); |  | ||||
| 	MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); |  | ||||
| 	MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); |  | ||||
| 	MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); |  | ||||
| 	MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); |  | ||||
| 	MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); |  | ||||
| 	MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); |  | ||||
| 	MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); |  | ||||
| 	MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); |  | ||||
| 	MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); |  | ||||
| 	MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); |  | ||||
| 
 |  | ||||
| 	MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); |  | ||||
| 	MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); |  | ||||
| 	MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); |  | ||||
| 	MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); |  | ||||
| 	MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); |  | ||||
| 	MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); |  | ||||
| 	MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); |  | ||||
| 	MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); |  | ||||
| 	MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); |  | ||||
| 	MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); |  | ||||
| 	MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); |  | ||||
| 	MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); |  | ||||
| 	MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); |  | ||||
| 	MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); |  | ||||
| 	MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); |  | ||||
| 	MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); |  | ||||
| 
 |  | ||||
| 	buf[0] += a; |  | ||||
| 	buf[1] += b; |  | ||||
| 	buf[2] += c; |  | ||||
| 	buf[3] += d; |  | ||||
| } |  | ||||
| 
 |  | ||||
| #endif |  | ||||
| @ -1,46 +0,0 @@ | |||||
| /*
 |  | ||||
|  * This is the header file for the MD5 message-digest algorithm. |  | ||||
|  * The algorithm is due to Ron Rivest.  This code was |  | ||||
|  * written by Colin Plumb in 1993, no copyright is claimed. |  | ||||
|  * This code is in the public domain; do with it what you wish. |  | ||||
|  * |  | ||||
|  * Equivalent code is available from RSA Data Security, Inc. |  | ||||
|  * This code has been tested against that, and is equivalent, |  | ||||
|  * except that you don't need to include two pages of legalese |  | ||||
|  * with every copy. |  | ||||
|  * |  | ||||
|  * To compute the message digest of a chunk of bytes, declare an |  | ||||
|  * MD5Context structure, pass it to MD5Init, call MD5Update as |  | ||||
|  * needed on buffers full of bytes, and then call MD5Final, which |  | ||||
|  * will fill a supplied 16-byte array with the digest. |  | ||||
|  * |  | ||||
|  * Changed so as no longer to depend on Colin Plumb's `usual.h' |  | ||||
|  * header definitions; now uses stuff from dpkg's config.h |  | ||||
|  *  - Ian Jackson <ijackson@nyx.cs.du.edu>. |  | ||||
|  * Still in the public domain. |  | ||||
|  */ |  | ||||
| 
 |  | ||||
| #ifndef MD5_H |  | ||||
| #define MD5_H |  | ||||
| 
 |  | ||||
| #if (defined AIX ||defined HPUX || defined SUN || defined NMP) |  | ||||
| #define HAS_BIGENDIAN_WORDS 1 |  | ||||
| #else |  | ||||
| #undef HAS_BIGENDIAN_WORDS |  | ||||
| #endif  |  | ||||
| 
 |  | ||||
| typedef unsigned char md5byte; |  | ||||
| typedef unsigned int UWORD32; |  | ||||
| 
 |  | ||||
| struct MD5Context { |  | ||||
| 	UWORD32 buf[4]; |  | ||||
| 	UWORD32 bytes[2]; |  | ||||
| 	UWORD32 in[16]; |  | ||||
| }; |  | ||||
| 
 |  | ||||
| void MD5Init(struct MD5Context *context); |  | ||||
| void MD5Update(struct MD5Context *context, md5byte const *buf, unsigned len); |  | ||||
| void MD5Final(unsigned char digest[16], struct MD5Context *context); |  | ||||
| void MD5Transform(UWORD32 buf[4], UWORD32 const in[16]); |  | ||||
| 
 |  | ||||
| #endif /* !MD5_H */ |  | ||||
| @ -1,387 +0,0 @@ | |||||
| #include <stdio.h> |  | ||||
| #include <stdlib.h> |  | ||||
| #include <string.h> |  | ||||
| 
 |  | ||||
| #include "vinfo.h" |  | ||||
| #include "md5.h" |  | ||||
| 
 |  | ||||
| static struct md5emu md5emu_versions[] = |  | ||||
| { |  | ||||
| 	{"21cfa58e94ea12e93cb344361cfca0d3","2011/02/21"},	// cs2gbox
 |  | ||||
| 	{"60290d667a8fceb8e61ed568416fa7e5","v2.1B"},		// NI cs2gbox [Mar 04 2011]
 |  | ||||
| 	{"627bf42e18d100418b8eb26aeb208f05","v2.1C"},		// NI cs2gbox [Aug 14 2011]
 |  | ||||
| 	{"3ade7732b3259b372b9c61c6260730aa","v2.2A"},		// NI cs2gbox [Aug 16 2011]
 |  | ||||
| 	{"ae7adbf886156b5e699a9b71cb8c3fed","v2.1C 2012"},	// NI cs2gbox [2012]
 |  | ||||
| }; |  | ||||
| 
 |  | ||||
| static struct mgcamd mgcamd_versions[] = |  | ||||
| { |  | ||||
| 	{"2282041518e3cf58d706e127adfa97b0","1.35a 2010/01/26"}, |  | ||||
| 	{"4a0f1ef99d09f8e386ff2b03f8dc5a24","1.35a 2010/07/30"}, |  | ||||
| 	{"291a3f7a9ba3f7cc0afe79b058650464","1.35a Austria-SAT"}, |  | ||||
| 	{"cd60d00cd76d66214c0b57d3181447b7","1.35a 2014/02/03"},	//by mixvt (compiled Feb  3 2014 19:20:06)
 |  | ||||
| 	{"0d7206cc96c050fd7d4fa4a777c44503","1.35c Austria-/Canalsat"}, |  | ||||
| }; |  | ||||
| 
 |  | ||||
| s_string searchstring[] = { |  | ||||
| 	{ "compiled %s %s)", 17 },		// mgcamd
 |  | ||||
| 	{ "Butter-team", 15 },			// newcs
 |  | ||||
| 	{ "started version", 16 },		// oscam version old
 |  | ||||
| 	{ "cardserver %s, version", 23 },	// oscam version new
 |  | ||||
| 	{ "svn, build #", 12 },			// oscam build
 |  | ||||
| 	{ "svn, build r", 12 },			// oscam build new
 |  | ||||
| 	{ "EMU: ", 5 },				// doscam
 |  | ||||
| 	{ "svn", 31 },				// gbox svn
 |  | ||||
| 	//{ "gbox_cfg, trace", -27 },		// gbox git - old function
 |  | ||||
| 	{ "Linux@ARM", 55 },			// gbox git
 |  | ||||
| }; |  | ||||
| 
 |  | ||||
| void Usage() |  | ||||
| { |  | ||||
| 	printf("%s\n", VERSION); |  | ||||
| 	printf("Usage: vinfo <CAM-Code> <Path to emu>\n"); |  | ||||
| 	printf("\tInfo: get emu-information offline\n"); |  | ||||
| 	printf("\tSupportboard: %s\n", SUPPORT); |  | ||||
| 	printf("\tCopyright: %s\n\n", COPYRIGHT); |  | ||||
| 	printf("<CAM-Code> (Supported Binarys):\n"); |  | ||||
| 	printf("   NEWCS\n"); |  | ||||
| 	printf("   MGCAMD\n"); |  | ||||
| 	printf("   GBOX.NET\n"); |  | ||||
| 	printf("   OSEMU\n"); |  | ||||
| 	printf("   OSCAM\n"); |  | ||||
| 	printf("   NCAM\n"); |  | ||||
| 	printf("   DOSCAM\n"); |  | ||||
| 	printf("   CS2GBOX\n"); |  | ||||
| } |  | ||||
| 
 |  | ||||
| static char *trim(char *txt) |  | ||||
| { |  | ||||
| 	register int l; |  | ||||
| 	register char *p1, *p2; |  | ||||
| 
 |  | ||||
| 	if (*txt==' ') |  | ||||
| 	{ |  | ||||
| 		for (p1=p2=txt; |  | ||||
| 			(*p1==' ') || (*p1=='\t') || (*p1=='\n') || (*p1=='\r'); |  | ||||
| 			p1++){}; |  | ||||
| 		while (*p1) |  | ||||
| 			*p2++=*p1++; |  | ||||
| 		*p2='\0'; |  | ||||
| 	} |  | ||||
| 	if ((l=strlen(txt))>0) |  | ||||
| 		for (p1=txt+l-1; |  | ||||
| 			(*p1==' ') || (*p1=='\t') || (*p1=='\n') || (*p1=='\r'); |  | ||||
| 			*p1--='\0'){}; |  | ||||
| 	return(txt); |  | ||||
| } |  | ||||
| 
 |  | ||||
| FILE *OpenBinFile(char *file) |  | ||||
| { |  | ||||
| 	FILE *fh; |  | ||||
| 	if (!(fh=fopen(file, "rb"))) |  | ||||
| 	{ |  | ||||
| 		perror("Can`t open file"); |  | ||||
| 		exit(EXIT_FAILURE); |  | ||||
| 	} |  | ||||
| 	return(fh); |  | ||||
| } |  | ||||
| 
 |  | ||||
| long Search(FILE *fh, s_string *string, int emu) |  | ||||
| { |  | ||||
| 	long found_pos;						// Rückgabewert
 |  | ||||
| 	char buffer[1024];					// Gröe des Lesebuffers
 |  | ||||
| 	char * p;						// temp. Zeiger für buffer erstellen
 |  | ||||
| 	int slen = strlen(string[emu].str);			// Länge der Zeichenkette für Überlappung ermitteln
 |  | ||||
| 	//printf("string: %i (%s)\n", slen, string[emu].str);
 |  | ||||
| 	int idx; |  | ||||
| 	int found = 0; |  | ||||
| 	long sp = 0;						// fr berlappung
 |  | ||||
| 	 |  | ||||
| 	//printf("--> String: %s\n", string[emu].str);
 |  | ||||
| 	int szread; |  | ||||
| 	while ((szread = fread(buffer, 1, sizeof(buffer), fh))) |  | ||||
| 	{ |  | ||||
| 		p = buffer; |  | ||||
| 		for ( idx = 0; idx < szread; idx++ )  |  | ||||
| 		{ |  | ||||
| 			switch (emu) |  | ||||
| 			{ |  | ||||
| /*
 |  | ||||
| 				case CAMD3: |  | ||||
| 					if (p[0] == '\0' && p[1] == string[emu].str[0] && p[2] == string[emu].str[1]) |  | ||||
| 					{ |  | ||||
| 						found_pos = ftell(fh)-szread+idx; |  | ||||
| 						return(found_pos); |  | ||||
| 					} |  | ||||
| 					break; |  | ||||
| */				default: |  | ||||
| 					if ( *p == string[emu].str[0] )  |  | ||||
| 					{ |  | ||||
| 						found = ( strstr( p, string[emu].str ) == p ); |  | ||||
| 						if (found) |  | ||||
| 						{ |  | ||||
| 							found_pos = ftell(fh)-szread+idx; |  | ||||
| 							return(found_pos); |  | ||||
| 						} |  | ||||
| 					} |  | ||||
| 					 |  | ||||
| 			} |  | ||||
| 			p++; |  | ||||
| 		} |  | ||||
| 		sp += ( sizeof(buffer) - slen ); |  | ||||
| 		fseek( fh, sp, SEEK_SET ); |  | ||||
| 		szread = fread(buffer,1,sizeof(buffer), fh );       |  | ||||
| 	} |  | ||||
| 	 |  | ||||
| 	return(0); |  | ||||
| } |  | ||||
| 
 |  | ||||
| void Emu (char *file, s_string *search, int emu) |  | ||||
| { |  | ||||
| 	FILE *fh; |  | ||||
| 	fh = OpenBinFile(file); |  | ||||
| 	strcpy(version,"keine Informationen gefunden"); |  | ||||
| 
 |  | ||||
| 	long pos = Search(fh, searchstring, emu); |  | ||||
| 	//printf("pos: %ld\n", pos);
 |  | ||||
| 	if (pos == 0) |  | ||||
| 		fclose(fh); |  | ||||
| 	else |  | ||||
| 	{ |  | ||||
| 		fseek(fh, pos+searchstring[emu].offset, SEEK_SET); |  | ||||
| 		fscanf(fh, COMPILE_STRING, version); |  | ||||
| 		fclose(fh); |  | ||||
| 	} |  | ||||
| } |  | ||||
| 
 |  | ||||
| int mdfile(FILE *fp, unsigned char *digest) |  | ||||
| { |  | ||||
| 	unsigned char buf[1024]; |  | ||||
| 	struct MD5Context ctx; |  | ||||
| 	int n; |  | ||||
| 
 |  | ||||
| 	MD5Init(&ctx); |  | ||||
| 	while ((n = fread(buf, 1, sizeof(buf), fp)) > 0) |  | ||||
| 		MD5Update(&ctx, buf, n); |  | ||||
| 	MD5Final(digest, &ctx); |  | ||||
| 	if (ferror(fp)) |  | ||||
| 		return -1; |  | ||||
| 	return 0; |  | ||||
| } |  | ||||
| 
 |  | ||||
| int ret_md5_sum(int emu) |  | ||||
| { |  | ||||
| 	switch (emu) |  | ||||
| 	{ |  | ||||
| 		case MD5EMU: |  | ||||
| 			return sizeof(md5emu_versions) / sizeof(*md5emu_versions); |  | ||||
| 		case MGCAMD: |  | ||||
| 			return sizeof(mgcamd_versions) / sizeof(*mgcamd_versions); |  | ||||
| 		default: |  | ||||
| 			return 0; |  | ||||
| 	} |  | ||||
| } |  | ||||
| 
 |  | ||||
| char *DetectMD5Version(unsigned char *p, int emu) |  | ||||
| { |  | ||||
| 	int count; |  | ||||
| 	char md5string[40]=""; |  | ||||
| 	char tmp[6]; |  | ||||
| 	 |  | ||||
| 	for (count=0; count<16; count++) |  | ||||
| 	{ |  | ||||
| 		sprintf((char*) &tmp, "%02x", p[count] ); |  | ||||
| 		strcat(md5string, tmp); |  | ||||
| 	} |  | ||||
| 
 |  | ||||
| 	int anz = ret_md5_sum(emu); |  | ||||
| 
 |  | ||||
| 	for(count=0; count<anz; count++) |  | ||||
| 	{ |  | ||||
| 		switch (emu) |  | ||||
| 		{ |  | ||||
| 			case MD5EMU: |  | ||||
| 				if (strcmp(md5emu_versions[count].md5, md5string)==0) |  | ||||
| 					return md5emu_versions[count].v_name; |  | ||||
| 			case MGCAMD: |  | ||||
| 				if (strcmp(mgcamd_versions[count].md5, md5string)==0) |  | ||||
| 					return mgcamd_versions[count].v_name; |  | ||||
| 				   |  | ||||
| 		} |  | ||||
| 	} |  | ||||
| 	return "Version unbekannt"; |  | ||||
| } |  | ||||
| 
 |  | ||||
| int File_check(const char * str) |  | ||||
| { |  | ||||
| 	FILE * Existance; |  | ||||
| 	 |  | ||||
| 	if ( ( Existance = fopen(str, "r+") ) == 0) |  | ||||
| 		return(false); |  | ||||
| 	else |  | ||||
| 		fclose(Existance); |  | ||||
| 	 |  | ||||
| 	return(true); |  | ||||
| } |  | ||||
| 
 |  | ||||
| void GBoxHandling(char *file, s_string *search) |  | ||||
| { |  | ||||
| 	FILE *fh; |  | ||||
| 	 |  | ||||
| 	if (File_check("/tmp/gbox.ver")) |  | ||||
| 	{ |  | ||||
| 		fh=fopen("/tmp/gbox.ver", "r"); |  | ||||
| 		fscanf(fh, "%40s", version); |  | ||||
| 		fclose(fh); |  | ||||
| 		printf("%s ",version); |  | ||||
| 	} |  | ||||
| 
 |  | ||||
| 	Emu(file, search, GBOX); |  | ||||
| 
 |  | ||||
| 	if (strstr(version, "keine Informationen gefunden")) { |  | ||||
| 		Emu(file, search, GBOX_GIT); |  | ||||
| 		printf("GIT #"); |  | ||||
| 	} |  | ||||
| 	else { |  | ||||
| 		printf("SVN #"); |  | ||||
| 	} |  | ||||
| } |  | ||||
| 
 |  | ||||
| void MgcamdHandling(char *file, s_string *search) |  | ||||
| { |  | ||||
| 	FILE *fh; |  | ||||
| 	 |  | ||||
| 	fh = OpenBinFile(file); |  | ||||
| 	unsigned char digest[16]; |  | ||||
| 	mdfile(fh, digest); |  | ||||
| 	strcpy(version, DetectMD5Version(digest, MGCAMD)); |  | ||||
| 	fclose(fh); |  | ||||
| 
 |  | ||||
| 	if (strstr(version, "Version unbekannt")) |  | ||||
| 		Emu(file, search, MGCAMD); |  | ||||
| } |  | ||||
| 
 |  | ||||
| int OscamHandling(char *file) |  | ||||
| { |  | ||||
| 	FILE *pipe_reader; |  | ||||
| 	char *ptr; |  | ||||
| 	char *buffer; |  | ||||
| 	char str[128]	= ""; |  | ||||
| 	ssize_t read; |  | ||||
| 	size_t len; |  | ||||
| 	int ret = 0; |  | ||||
| 
 |  | ||||
| 	snprintf(str, sizeof(str), "%s -V", file); |  | ||||
| 
 |  | ||||
| 	buffer=NULL; |  | ||||
| 	if (!(pipe_reader = popen (str, "r"))) |  | ||||
| 		printf("[OscamHandling] popen error\n"); |  | ||||
| 
 |  | ||||
| 	strcpy(str,""); |  | ||||
| 
 |  | ||||
| 	while ((read = getline(&buffer, &len, pipe_reader)) != -1) |  | ||||
| 	{ |  | ||||
| 		if ((ptr = strstr(buffer, "Version:"))) { |  | ||||
| 			printf("%s\n",trim(ptr+8)); |  | ||||
| 			ret=1; |  | ||||
| 		} |  | ||||
| 	} |  | ||||
| 	pclose(pipe_reader); |  | ||||
| 	if(buffer) |  | ||||
| 		free(buffer); |  | ||||
| 	if(ret != 1) |  | ||||
| 		printf("%s\n", version); |  | ||||
| 	return(ret); |  | ||||
| } |  | ||||
| 
 |  | ||||
| void md5emuHandling(char *file, s_string *search) |  | ||||
| { |  | ||||
| 	FILE *fh; |  | ||||
| 	 |  | ||||
| 	fh = OpenBinFile(file); |  | ||||
| 	unsigned char digest[16]; |  | ||||
| 	mdfile(fh, digest); |  | ||||
| 	strcpy(version, DetectMD5Version(digest, MD5EMU)); |  | ||||
| 	fclose(fh); |  | ||||
| } |  | ||||
| 
 |  | ||||
| int main(int argc, char **argv) |  | ||||
| { |  | ||||
| 	switch (argc) |  | ||||
| 	{ |  | ||||
| 		case 3: |  | ||||
| 			if (strstr(argv[1], "MGCAMD")) |  | ||||
| 				MgcamdHandling(argv[2], searchstring); |  | ||||
| 			else if (strstr(argv[1], "NEWCS")) |  | ||||
| 				Emu(argv[2], searchstring, NEWCS); |  | ||||
| 			else if (strstr(argv[1], "OSEMU")) |  | ||||
| 				strcpy(version, "n/a"); |  | ||||
| 			else if (strstr(argv[1], "OSCAM")) |  | ||||
| 				Emu(argv[2], searchstring, OSCAM_VERSION); |  | ||||
| 			else if (strstr(argv[1], "NCAM")) |  | ||||
| 				Emu(argv[2], searchstring, OSCAM_VERSION_NEW); |  | ||||
| 			else if (strstr(argv[1], "CS2GBOX")) |  | ||||
| 				md5emuHandling(argv[2], searchstring); |  | ||||
| 			else if (strstr(argv[1], "GBOX.NET")) |  | ||||
| 				GBoxHandling(argv[2], searchstring); |  | ||||
| 			else |  | ||||
| 				Usage(); |  | ||||
| 			break; |  | ||||
| 		default: |  | ||||
| 			Usage(); |  | ||||
| 			exit(1); |  | ||||
| 	} |  | ||||
| #if 0 |  | ||||
| 	if (strstr(version, "keine Informationen gefunden")) |  | ||||
| 	{ |  | ||||
| 		if (strstr(argv[1], "NEWCAMD")) |  | ||||
| 			Emu(argv[2], searchstring, NEWCAMD_OLD); |  | ||||
| 		else if (strstr(argv[1], "CCCAM")) |  | ||||
| 			Emu(argv[2], searchstring, CCCAM_OLD); |  | ||||
| 		else if (strstr(argv[1], "RDGD")) |  | ||||
| 			Emu(argv[2], searchstring, RDGD_NEW); |  | ||||
| 		else if (strstr(argv[1], "NEWCS")) |  | ||||
| 			Emu(argv[2], searchstring, NEWCS_07); |  | ||||
| 		else if (strstr(argv[1], "EVOCAMD")) |  | ||||
| 		{ |  | ||||
| 			Emu(argv[2], searchstring, EVOCAMD_NEW); |  | ||||
| 			sscanf(version, "%[^ ]", version); |  | ||||
| 		} |  | ||||
| 		else if (strstr(argv[1], "SCAM")) |  | ||||
| 			ScamHandling(argv[2]); |  | ||||
| 	} |  | ||||
| 	 |  | ||||
| 	if (strstr(version, "Compiled on")) |  | ||||
| 		Emu(argv[2], searchstring, NEWCS_NEW); |  | ||||
| #endif |  | ||||
| 
 |  | ||||
| 	if (strstr(argv[1], "OSCAM")) |  | ||||
| 	{ |  | ||||
| 		int doscam = 0; |  | ||||
| 
 |  | ||||
| 		if (strstr(version, "keine Informationen gefunden")) |  | ||||
| 			Emu(argv[2], searchstring, OSCAM_VERSION_NEW); |  | ||||
| 
 |  | ||||
| 		if (!strstr(version, "keine Informationen gefunden")) |  | ||||
| 			printf("%s", version); |  | ||||
| 
 |  | ||||
| 		Emu(argv[2], searchstring, DOSCAM); |  | ||||
| 		if(strstr(version, "Key")) |  | ||||
| 			doscam = 1; |  | ||||
| 
 |  | ||||
| 		Emu(argv[2], searchstring, OSCAM_BUILD); |  | ||||
| 		if(strstr(version, "keine Informationen gefunden")) |  | ||||
| 			Emu(argv[2], searchstring, OSCAM_BUILD_NEW); |  | ||||
| 
 |  | ||||
| 		if (!strstr(version, "keine Informationen gefunden")) |  | ||||
| 			printf(" SVN #%s %s\n", version, (doscam?"(DOSCam)":"")); |  | ||||
| 		else  |  | ||||
| 			OscamHandling(argv[2]); |  | ||||
| 	} |  | ||||
| 	else |  | ||||
| 	{ |  | ||||
| 		printf("%s\n", version); |  | ||||
| 	} |  | ||||
| 
 |  | ||||
| 	exit(EXIT_SUCCESS); |  | ||||
| } |  | ||||
| @ -1,47 +0,0 @@ | |||||
| #ifndef VINFO_H_ |  | ||||
| #define VINFO_H_ |  | ||||
| 
 |  | ||||
| #define VERSION "vinfo Version 3.27" |  | ||||
| #define SUPPORT "www.neutrino-images.de" |  | ||||
| #define COPYRIGHT "luke777, FlatTV" |  | ||||
| 
 |  | ||||
| enum {false, true}; |  | ||||
| 
 |  | ||||
| enum {MGCAMD, NEWCS, OSCAM_VERSION, OSCAM_VERSION_NEW, OSCAM_BUILD, OSCAM_BUILD_NEW, DOSCAM, GBOX, GBOX_GIT, MD5EMU }; |  | ||||
| 
 |  | ||||
| typedef struct _s_string { |  | ||||
| 	char *str; |  | ||||
| 	int offset; |  | ||||
| } s_string; |  | ||||
| 
 |  | ||||
| struct md5emu |  | ||||
| { |  | ||||
| 	char md5[35]; |  | ||||
| 	char v_name[20]; |  | ||||
| }; |  | ||||
| 
 |  | ||||
| struct mgcamd |  | ||||
| { |  | ||||
| 	char md5[35]; |  | ||||
| 	char v_name[25]; |  | ||||
| }; |  | ||||
| 
 |  | ||||
| char version[40] = "keine Informationen gefunden"; |  | ||||
| const char COMPILE_STRING[] = "%[0-9.a-zA-Z ]"; |  | ||||
| const char COMPILE_STRING_NOSPACE[] = "%[0-9.a-zA-Z]"; |  | ||||
| 
 |  | ||||
| // Funktionsdeklarationen =====================================================
 |  | ||||
| void Usage(); |  | ||||
| FILE *OpenBinFile(char *file); |  | ||||
| long Search(FILE *fh, s_string *string, int emu); |  | ||||
| void Emu (char *file, s_string *search, int emu); |  | ||||
| void GBoxHandling(char *file, s_string *search); |  | ||||
| void MgcamdHandling(char *file, s_string *search); |  | ||||
| int OscamHandling(char *file); |  | ||||
| void md5emuHandling(char *file, s_string *search); |  | ||||
| // MD5 Funktionsdeklaration
 |  | ||||
| int mdfile(FILE *fp, unsigned char *digest); |  | ||||
| int ret_md5_sum(int emu); |  | ||||
| char *DetectMD5Version(unsigned char *p, int emu); |  | ||||
| 
 |  | ||||
| #endif /*VINFO_H_*/ |  | ||||
					Loading…
					
					
				
		Reference in new issue