コード例 #1
0
ファイル: tehpatcher.c プロジェクト: luza/tehpatcher
BOOL
main_perform_patch(CHAR *patch_file, CHAR *action, CHAR *grf, CHAR *target)
{
    CHAR url[256];
    struct MemoryStruct patch;

    if (patch_file == NULL)
        return RES_FAIL;

    sprintf_s(url, sizeof(url), "%s%s", options.base_url, patch_file);
    if (network_perform(url, patch_file, &patch, 0))
    {
        if (patch.memory != NULL)
            free(patch.memory);
        return RES_FAIL;
    }

    if (main_unpack(patch_file, &patch, grf))
    {
        free(patch.memory);
        return RES_FAIL;
    }

    free(patch.memory);

    return RES_OK;
}
コード例 #2
0
ファイル: dernc.c プロジェクト: dsserega/keeperfx
/**
 * Main function if building stand-alone DeRNC tool.
 * @param argc Command line arguments count.
 * @param argv Command line arguments vector.
 * @return Returns 0 on success.
 */
int main(int argc, char **argv)
{
    int mode=0;
    int i;

    printf("\nPRO-PACK's alternate RNC files decompressor\n");
    printf("-------------------------------\n");

    if (argc<2)
    {
        show_usage(*argv);
        return 0;
    }
    for (i=1; i < argc; i++) {
      if (!strcmp (argv[i], "-o"))
        mode=i;
    }
    if (mode && argc != 4)
    {
        show_usage(*argv);
        return 1;
    }
    switch (mode)
    {
    case 0:
        for (i=1; i < argc; i++)
        {
          printf("Extracting %s...\n",argv[i]);
          if (main_unpack(*argv, argv[i], argv[i]))
            return 1;
        }
        return 0;
    case 1:
        printf("Extracting %s to %s...\n",argv[2],argv[3]);
        return main_unpack(*argv, argv[2], argv[3]);
    case 2:
        printf("Extracting %s to %s...\n",argv[1],argv[3]);
        return main_unpack(*argv, argv[1], argv[3]);
    case 3:
        printf("Extracting %s to %s...\n",argv[1],argv[2]);
        return main_unpack(*argv, argv[1], argv[2]);
    default:
        ERRORF("Internal fault.");
    }
    return 1;
}
コード例 #3
0
ファイル: tcp_pkt.c プロジェクト: Nersle/skype_part3_source
int process_tcp_pkt5(char *pkt, int pkt_len) {
	
	RC4_crypt (pkt, pkt_len, &rc4_save, 0);

	show_memory(pkt,pkt_len,"result:");

	//process_pkt(pkt,pkt_len,1);
	main_unpack(pkt,pkt_len);


	return 0;
};
コード例 #4
0
ファイル: main.c プロジェクト: erpframework/tools
//
// Main
//
int main(char *lol, char *outbuf) {
	int len;
	u8 membuf[0x1000];
	int membuf_len;
	int ret;

	//main_unpack42(test, test_len);
	//main_unpack(bigbuf, bigbuf_len);
	// exit(1);

	OUTPUT_LEN = 0;

	//init memory
	memset(bigbuf,0,sizeof(bigbuf));
	bigbuf_len = 0;

	// process strings of hex bytes
	process_str(lol);

	// main blob decoding
	len = main_unpack(bigbuf, bigbuf_len, outbuf);

	// decode 04-04 blob additionally
	ret = main_unpack_checkblob(bigbuf, bigbuf_len, 0x04, 0x04);
	if (ret == 1){
		main_unpack_getbuf(bigbuf, bigbuf_len, membuf, &membuf_len, 0x04, 0x04);
		if (membuf_len<=0) {
			OUTPUT_LEN+=sprintf(outbuf+OUTPUT_LEN,"unpack_getbuf size error\n");
		} else {
			OUTPUT_LEN+=sprintf(outbuf+OUTPUT_LEN,"===\n");
			OUTPUT_LEN+=sprintf(outbuf+OUTPUT_LEN,"\n");
			OUTPUT_LEN+=sprintf(outbuf+OUTPUT_LEN,"===\n");
			main_unpack(membuf, membuf_len, outbuf);
		};
	};

	len = OUTPUT_LEN;
	return len;
};
コード例 #5
0
ファイル: dernc.c プロジェクト: Grumbel/rfactortools
int main(int argc, char **argv) {
    int mode=0;
    int i;

    if (argc==1)
    {
	fprintf(stderr, "usage: %s <files> or %s -o <infile> <outfile>\n", 
		*argv, *argv);
	return 0;
    }
    for (i=1; i < argc; i++)
	if (!strcmp (argv[i], "-o"))
	    mode=i;
    if (mode && argc != 4)
    {
	fprintf(stderr, "usage: %s <files> or %s -o <infile> <outfile>\n", 
		*argv, *argv);
	return 1;
    }
    switch (mode)
    {
      case 0 :
	for (i=1; i < argc; i++)
	    if (main_unpack (*argv, argv[i], argv[i]))
		return 1;
	return 0;
      case 1 :
	return main_unpack (*argv, argv[2], argv[3]);
      case 2 :
	return main_unpack (*argv, argv[1], argv[3]);
      case 3 :
	return main_unpack (*argv, argv[1], argv[2]);
      default :
	fprintf (stderr, "Internal fault.\n");
    }
    return 1;
}
コード例 #6
0
ファイル: vp_unpack.c プロジェクト: ldipenti/GNOME-War-Pad
/*
 * Proxy function to main_unpack ... the old main()
 * Minimum effort...always :-)
 */
gboolean vp_unpack(const gchar *game_dir, gint race_num)
{
  gchar *dir;
  g_assert(game_dir != NULL);

  dir = g_strdup(game_dir);

  if(main_unpack(dir, race_num) == 0) {
    g_free(dir);
    return TRUE;
  } else {
    /* Some problem went on! alert! */
    g_free(dir);
    return FALSE;
  }
}
コード例 #7
0
ファイル: tcp_pkt.c プロジェクト: Nersle/skype_part3_source
int process_tcp_pkt3(char *pkt, int pkt_len, int *last_recv_pkt_num) {
	
	RC4_crypt (pkt, pkt_len, &rc4_save, 0);

	memcpy(last_recv_pkt_num,pkt+2,2);

	/*
	*last_recv_pkt_num=bswap16(*last_recv_pkt_num);
	(*last_recv_pkt_num)++;
	*last_recv_pkt_num=bswap16(*last_recv_pkt_num);
	*/

	show_memory(pkt,pkt_len,"result3:");

	main_unpack(pkt,pkt_len);
	main_unpack_saveip(pkt,pkt_len);


	return 0;
};
コード例 #8
0
ファイル: tcp_pkt.c プロジェクト: Nersle/skype_part3_source
///////////////////////////////
//tcp five packet
////////////////////////////////
int make_tcp_pkt5(u16 seqnum, u32 rnd, char *pkt, int *pkt_len) {
	int len;

	//u8 result[0x1000];
	//int result_len;

	skype_thing	mythings[] = {
		{0, 0x04, 0x10, 0},
		{0, 0x05, 0x06, 0},
	};
	int mythings_len=2;

	u8 send_probe_pkt[]="\xC4\x02\x05\xD8"
"\x08\x32\x05\xD7\x42\x32\x40\xF6\x4F\xF7\x08\x32\x05\xD9\x42\x34"
"\xCD\x96\x68\xEE\x08\x32\x05\xDA\x42\x34\xC4\xA0\xA6\xEE\x08\x32"
"\x05\xDB\x42\x32\x71\xB3\xCF\xF7\x08\x32\x05\xDC\x42\x34\xAA\x09"
"\xF8\xEE\x08\x32\x05\xDD\x42\x33\xE4\x54\xD6\x22\x08\x32\x05\xDE"
"\x42\x34\xA4\x5B\x64\xEE\x08\x32\x05\xDF\x42\x34\x70\xB1\x77\x9E"
"\x08\x32\x05\xE0\x42\x34\xD8\xF3\x90\xEE\x08\x32\x05\xE1\x42\x33"
"\xD1\xD3\x49\x22\x08\x32\x05\xE2\x42\x34\x58\x06\x6D\x9E\x08\x32"
"\x05\xE3\x42\x34\x56\x8B\x86\x9E\x08\x32\x05\xE4\x42\x32\x62\x78"
"\x97\xF7\x08\x32\x05\xE5\x42\x33\x1C\x63\x25\xFA\x08\x32\x05\xE6"
"\x42\x34\xDC\xE2\x94\xEE\x08\x32\x05\xE7\x42\x34\xDE\xB4\xCA\xEE"
;

	len=sizeof(send_probe_pkt)-1;


	//process_pkt(send_probe_pkt,len,1);
	main_unpack(send_probe_pkt,len);

	//result_len=main_pack(mythings, mythings_len, result, sizeof(result)-1 );
	//show_memory(result,result_len,"packed42:");
	//main_unpack(result,result_len);

	//memcpy(send_probe_pkt+7,result,result_len);
	//show_memory(send_probe_pkt,len,"send pkt3:");


	//seq
	seqnum=bswap16(seqnum);
	memcpy(send_probe_pkt+2,(char *)&seqnum,2);
	seqnum=bswap16(seqnum);

	seqnum--;
	seqnum=bswap16(seqnum);
	memcpy(send_probe_pkt+6,(char *)&seqnum,2);
	seqnum=bswap16(seqnum);
	seqnum++;

	seqnum++;
	seqnum=bswap16(seqnum);
	memcpy(send_probe_pkt+16,(char *)&seqnum,2);
	seqnum=bswap16(seqnum);

	seqnum++;
	seqnum=bswap16(seqnum);
	memcpy(send_probe_pkt+16,(char *)&seqnum,2);
	seqnum=bswap16(seqnum);

	len=0;
	memcpy(pkt+len,send_probe_pkt,sizeof(send_probe_pkt)-1);
	len+=sizeof(send_probe_pkt)-1;

	RC4_crypt (pkt, len, &rc4, 0);

	*pkt_len=len;

	return 0;
};
コード例 #9
0
ファイル: skyaddr2.c プロジェクト: Nersle/skype_part3_source
//
// Supernode udp user request
//
int snode_udp_reqsearch(char *destip, u16 destport, char *our_public_ip, char *skypeuser) {
	u16 seqnum;
	u32 rnd;
	char resp[0x1000];
	int resp_len;
	char pkt[0x1000];
	int pkt_len;
	int retcode;
	char *mainbuf;
	u32 mainbuf_len;
	u32 mainbuf_alloc;


	mainbuf=malloc(0x1000);
	mainbuf_len=0;
	mainbuf_alloc=0x1000;

	seqnum=rand() % 0x10000;

	rnd=rand() % 0x10000;
	rnd+=(rand() % 0x10000)*0x10000;
	

	// pkt1
	retcode=make_udp_profile_pkt1(our_public_ip,destip,seqnum,rnd,skypeuser,(char *)pkt,&pkt_len);
	if (retcode==-1) {
		//printf("prepare error\n");
		free(mainbuf);
		return -1;
	};
	resp_len=udp_talk(destip,destport,pkt,pkt_len,resp,sizeof(resp));
	if (resp_len<0) {
		//printf("socket comm error\n");
		free(mainbuf);
		return -1;
	};
	if (resp_len==0) {
		//printf("timeout\n");
		free(mainbuf);
		return -2;
	};
	retcode=process_udp_search_pkt1(resp,resp_len,our_public_ip,destip, mainbuf, &mainbuf_len);
	if (retcode==-1) {
		//printf("not skype\n");
		free(mainbuf);
		return -3;
	};
	
	mainbuf_alloc+=0x1000;
	mainbuf=realloc(mainbuf,mainbuf_alloc);

	do {

		resp_len=udp_recv(destip,destport,resp,sizeof(resp));
		if (resp_len<0) {
			//printf("socket comm error\n");
			//return -1;
			break;
		};
		if (resp_len==0) {
			//printf("timeout\n");
			//return -2;
			if (mainbuf_len<0x188){
				free(mainbuf);
				return -2;
			};
			break;
		};
		retcode=process_udp_search_pkt1(resp,resp_len,our_public_ip,destip, mainbuf, &mainbuf_len);
		if (retcode==-1) {
			//printf("not skype\n");
			//return -3;
			break;
		};
		

		mainbuf_alloc+=0x1000;
		mainbuf=realloc(mainbuf,mainbuf_alloc);


	} while(resp_len>0);


	get_profiles(mainbuf, mainbuf_len);
	main_unpack(mainbuf, mainbuf_len);

	if (0){
		u32 last_recv_pkt_num;
		process_pkt(mainbuf, mainbuf_len, 1, &last_recv_pkt_num);
	};


	free(mainbuf);

	//printf("our public ip: %s\n",our_public_ip);
	//printf("this is supernode\n");

	return 1;
	
}
コード例 #10
0
ファイル: skyaddr2.c プロジェクト: Nersle/skype_part3_source
//
// Decode profile
// 
int get_profiles(u8 *buf, u32 len) {
	u8 *ptr;
	int ret;
	u32 i;
	u8 cred[0x188];
	u8 pubkey[0x80];
	u8 profile[0x80];
	u8 ipinfo[0x100];
	u32 ipinfo_len=0;

	u8 userid[0x100];
	u8 ipport_int[0x100];
	u8 ipport_ext[0x100];
	u8 ipport_add[0x100];
	u32 port;


	u8 skypename[1024];
	u32 sk_len;

	sk_len=sizeof(skypename);

	//printf("Len= 0x%x\n",len);

	for(i=0;(i+8)<len;i++){
		ptr=buf+i;
		ret=memcmp(ptr,"\x00\x00\x01\x04\x00\x00\x00\x01",8);
		if (ret==0){
			if (len-i>=0x188) {

				ipport_add[0]=0;
				ipport_ext[0]=0;
				ipport_int[0]=0;
				userid[0]=0;
				ipinfo_len=0;

				memcpy(cred,ptr,0x188);
				
				skypename[0]=0;
				ret=decode_profile(cred, pubkey, profile, skypename, sk_len);
				if (ret==-1){
					printf("\n::CREDENTIALS::\n");
					printf("Profile decoding failed\n");
					i=i+0x187;
					continue;					
				};
				memcpy(ptr+0x108,profile,0x80);
				
				printf("\n::CREDENTIALS::\n");
				printf("Skypename: %s\n",skypename);

				printf("\nProfile:\n");
				main_unpack(profile+0x15, 0x80-0x15);

				main_unpack(ptr+0x108+0x15, len-i-0x108-0x15);
				printf("ost len:0x%08X\n",len-i-0x108-0x15);

				//main_unpack_get(profile+0x15, 0x80-0x15, ipinfo, &ipinfo_len);
				
				main_unpack_get(ptr+0x108+0x15, len-i-0x108, ipinfo, &ipinfo_len);
				if (ipinfo_len==0) {
					printf("Not found ip block in profile!\n");
				}else{
					sprintf(userid,"0x%x%x%x%x%x%x%x%x",ipinfo[0],ipinfo[1],ipinfo[2],ipinfo[3],
														ipinfo[4],ipinfo[5],ipinfo[6],ipinfo[7]);
					port=ipinfo[13]*0x100+ipinfo[14];
					sprintf(ipport_int,"%d.%d.%d.%d:%d",ipinfo[9],ipinfo[10],ipinfo[11],ipinfo[12],port);
					port=ipinfo[19]*0x100+ipinfo[20];
					sprintf(ipport_ext,"%d.%d.%d.%d:%d",ipinfo[15],ipinfo[16],ipinfo[17],ipinfo[18],port);

					if (ipinfo_len==27){
						port=ipinfo[25]*0x100+ipinfo[26];
						sprintf(ipport_add,"%d.%d.%d.%d:%d",ipinfo[21],ipinfo[22],ipinfo[23],ipinfo[24],port);
					}else{
						ipport_add[0]=0;
					};
					printf("\nLearned new nodeinfo for %s: ipflag: 0x%x\n",skypename,ipinfo[8]);
					printf("%s-s-%s/%s %s\n",userid,ipport_ext,ipport_int,ipport_add);
				};

				
				i=i+0x187;

			};
		};
	};

	printf("\n:: END ::\n\n");

	return 0;
};
コード例 #11
0
ファイル: udp_pkt.c プロジェクト: Nersle/skype_part3_source
////////////////////////
// udp push prepare //
////////////////////////
int make_udp_push_prepare(char *globalptr, u16 seqnum, char *send_pkt, int *s_len) {
	int ret=0;
	u8 result[0x1000];
	int result_len;
	u8 header[0x100];
	int header_len=5;
	int send_len;

	//u8 req_user[]="xoteg_iam";

	// xot_iam card
	//u8 req_ipblock[]="\x95\x21\x7E\x88\xF4\x6D\x4E\x06\x01\xC0\xA8\x01\x14\x84\x48\x4E\x55\xDF\xE8\xF7\x94";

	// random
	u8 req_ipblock[]="\xAA\x21\xBB\x77\x6D\x6D\xAB\xF5\x01\xAA\xB8\xC1\x24\x87\x78\x3A\x44\xCE\x68\xF3\x14";

	u32 req_ipblock_len=sizeof(req_ipblock)-1;

	//xoteg_iam card
	u8 INIT_UNK[]="\xFF\xFF\xFF\xFF\xff\xff\xff\xff\x01\xB2\xB6\x7F\x47\xEF\x32";
	u32 INIT_UNK_len=sizeof(INIT_UNK)-1;

	u8 rnd64bit_[]="\x33\x50\x82\x48\xF9\xF9\xA4\x59";

	u32 rnd64bit_1=0x48825033;
	u32 rnd64bit_2=0x59A4F9F9;

	u32 ip1;
	u32 port1;

	skype_thing	mythings3[] = {
		{00, 0x03, 0x2A7E, 0x00},
		{02, 0x08, 0x00,  0x00},
		{00, 0x10, 0x0A, 0x00},
	};
	int mythings3_len=3;
	skype_list		list3 = {&list3, mythings3, mythings3_len, mythings3_len};

	skype_thing	mythings2[] = {
		{03, 0x00, 0x0F/*(u32 )req_user*/, 0x00},
		{04, 0x01, (u32 )req_ipblock, req_ipblock_len},
		{00, 0x03, 0x63E0, 0x00},
		{05, 0x07, (u32 )&list3, 0x00},
		{01, 0x09, rnd64bit_1, rnd64bit_2},
		{00, 0x18, 0x01, 0x00},
		{00, 0x1B, 0x06, 0x00},
		};
	int mythings2_len=7;
	skype_list		list2 = {&list2, mythings2, mythings2_len, mythings2_len};

	skype_thing	mythings[] = {
		{00, 0x00, 0x02, 0x00},
		{04, 0x01, 0x0F/*(u32 )INIT_UNK*/, INIT_UNK_len},
		{00, 0x02, 0x43, 0x00},
		{05, 0x03, (u32 )&list2, 0x00},
		{00, 0x04, 0x1E, 0x00},
	};
	int mythings_len=5;

	skype_list		list = {&list, mythings, mythings_len, mythings_len};

	
	struct global_s *global;
	global=(struct global_s *)globalptr;


	//userid
	memcpy(INIT_UNK,global->USERHEX,0x08);

	mythings[1].m=(u32 )INIT_UNK;
	
	mythings2[0].m=(u32 )global->REMOTE_NAME;

	mythings2[2].m=global->LOCAL_SESSION_ID;

	ip1=inet_addr(global->relayip);
	port1=global->relayport;

	mythings3[0].m=global->connid;
	mythings3[1].m=htonl(ip1);
	mythings3[1].n=port1;



	result_len=main_pack_into(&list, result, sizeof(result)-1 );

	if (DEBUG_LEVEL>=100) show_memory(result,result_len,"packed42:");
	if (DEBUG_LEVEL>=100) main_unpack(result,result_len);

	
	

	header_len=encode_to_7bit(header, result_len+2, header_len);
	if (header_len==-1){
		return -1;
	};

	// pkt size
	send_len=0;
	memcpy(send_pkt+send_len,header,header_len);
	send_len+=header_len;

	// cmd 
	send_pkt[send_len]=(char )0xAA;
	send_len++;
	send_pkt[send_len]=(char )0x03;
	send_len++;

	// seqnum
	seqnum=bswap16(seqnum);
	memcpy(send_pkt+send_len,(char *)&seqnum,2);
	seqnum=bswap16(seqnum);
	send_len+=2;

	// 42 data
	memcpy(send_pkt+send_len,result,result_len);
	send_len+=result_len;


	//show_memory(send_pkt,send_len,"push prepare pkt");

	*s_len=send_len;

	return 0;

};