void			show_alloc_mem(void)
{
	size_t		total_size;

	total_size = 0;
	total_size += show_memory(g_memory.tiny, "TINY : ");
	total_size += show_memory(g_memory.small, "SMALL : ");
	total_size += show_memory(g_memory.large, "LARGE : ");
	ft_putstr("Total : ");
	ft_putnbr_base(total_size, 10);
	ft_putstr(" octets\n");
}
Esempio n. 2
0
int process_tcp_pkt2(char *pkt, int pkt_len, int *last_recv_pkt_num) {
	int ret;

	RC4_crypt(pkt, pkt_len, &rc4_save, 0);

	memcpy(last_recv_pkt_num,pkt+1,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,"result2:");
	
	// supernode check
	// if yet 06 0x21 blob, this is supernode reply
	ret=main_unpack_test(pkt, pkt_len, 0x06, 0x21) ;

	if (ret==0){
		//printf("skype client, dumping nodes\n");
		//main_unpack_saveip(pkt,pkt_len);
		return -1;
	};

	
	return 0;
};
Esempio n. 3
0
int process_tcp_pkt1(char *pkt, int pkt_len, u32 *remote_tcp_rnd) {
	u32	newrnd;
	u32 iv;
	
	if (pkt_len<0x0E) {
		//printf("too short packet\n");
		//printf("not skype\n");
		return -1;
	};

	memcpy(&newrnd,pkt,4);
	
	iv = bswap32(newrnd);
	
	Skype_RC4_Expand_IV (&rc4_save, iv, 1);
	
	RC4_crypt (pkt+4, 10, &rc4_save, 1);
	
	if (pkt_len > 0x0E) {
		RC4_crypt (pkt+14, pkt_len-14, &rc4_save, 0);
	};

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

	if (strncmp(pkt+4+2,"\x00\x00\x00\x01\x00\x00\x00\x03",8)!=0) {
		//printf("first answer wrong\n");
		//printf("not skype\n");
		return -1;
	};

	*remote_tcp_rnd=newrnd;


	return 0;
};
Esempio n. 4
0
static size_t
show_section(struct mca_section_header *sh)
{
	static uuid_t uuid_cpu = MCA_UUID_CPU;
	static uuid_t uuid_memory = MCA_UUID_MEMORY;
	static uuid_t uuid_sel = MCA_UUID_SEL;
	static uuid_t uuid_pci_bus = MCA_UUID_PCI_BUS;
	static uuid_t uuid_smbios = MCA_UUID_SMBIOS;
	static uuid_t uuid_pci_dev = MCA_UUID_PCI_DEV;
	static uuid_t uuid_generic = MCA_UUID_GENERIC;

	printf("  <section>\n");
	show_value(4, "uuid", "%s", uuid(&sh->sh_uuid));
	show_value(4, "revision", "%d.%d", BCD(sh->sh_major),
	    BCD(sh->sh_minor));

	if (uuid_equal(&sh->sh_uuid, &uuid_cpu, NULL))
		show_cpu((void*)(sh + 1));
	else if (uuid_equal(&sh->sh_uuid, &uuid_memory, NULL))
		show_memory((void*)(sh + 1));
	else if (uuid_equal(&sh->sh_uuid, &uuid_sel, NULL))
		show_sel();
	else if (uuid_equal(&sh->sh_uuid, &uuid_pci_bus, NULL))
		show_pci_bus((void*)(sh + 1));
	else if (uuid_equal(&sh->sh_uuid, &uuid_smbios, NULL))
		show_smbios();
	else if (uuid_equal(&sh->sh_uuid, &uuid_pci_dev, NULL))
		show_pci_dev((void*)(sh + 1));
	else if (uuid_equal(&sh->sh_uuid, &uuid_generic, NULL))
		show_generic();

	printf("  </section>\n");
	return (sh->sh_length);
}
Esempio n. 5
0
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;
};
Esempio n. 6
0
///////////////////////////////
//tcp second packet
////////////////////////////////
int make_tcp_pkt2(u16 seqnum, u32 rnd, char *pkt, int *pkt_len) {
	int len;
	u32	iv;

	u8 result[0x1000];
	int result_len;

	//42394 - 0xA59A my iport
	skype_thing	mythings[] = {
		{0, 0x01, 0x00000003, 0},
		{1, 0x0D, 0xD6BA8CD9, 0x9205E2CD},
		{0, 0x10, 0xA59A, 0},
	};
	int mythings_len=3;

	u8 send_probe_pkt[]="\x30\xFF\xFF\x13\xF2\x01\xFF\xFF\x42\x44\x40\xFA\x3B\x4C\xE4\xAF\x94\xD9\x8C\xBA\xD6\xCD\xE2\x05\x92";
	len=sizeof(send_probe_pkt)-1;


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

	memcpy(send_probe_pkt+8,result,result_len);

	show_memory(send_probe_pkt,len,"send pkt2:");


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

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

	iv = rnd;

	Skype_RC4_Expand_IV (&rc4, iv, 1);
	
	RC4_crypt (send_probe_pkt, len, &rc4, 0);


	memcpy(pkt,send_probe_pkt,len);
	
	*pkt_len=len;


	return 0;
};
Esempio n. 7
0
int process_udp_push_pkt1(char *globalptr, char *pkt,int pkt_len,char *ourip,char *destip) {
	RC4_context rc4;
	u32 newrnd;
	u32 targetip;
	u32 publicip;
	u32	iv3[3];
	u32 iv;
	int header_len;
	int ret;

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


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

	targetip=inet_addr(destip);
	publicip=inet_addr(ourip);

	newrnd = bswap32(dword(pkt+3));

	iv3[2] = bswap16(word(pkt)); 
	iv3[1] = bswap32(publicip);
	iv3[0] = bswap32(targetip);

	iv = crc32(iv3,3) ^ newrnd;

	Skype_RC4_Expand_IV (&rc4, iv, 1);

	header_len=11;

	//show_memory(pkt+header_len,pkt_len-header_len,"bef rc4:");	
	RC4_crypt (pkt+header_len, pkt_len-header_len, &rc4, 0);
	if (DEBUG_LEVEL>=100) show_memory(pkt+header_len,pkt_len-header_len,"aft rc4:");	


	//main_unpack(pkt+header_len,pkt_len-header_len);


	ret=memcmp(pkt+header_len+1,"\xB3\x04",2);
	if (ret!=0){
		if (DEBUG_LEVEL>=100) printf("push reply negative\n");
		return -1;
	};

	if (DEBUG_LEVEL>=100) printf("push reply ok\n");

	return 1;
};
Esempio n. 8
0
///////////////////////////////
//tcp third packet
////////////////////////////////
int make_tcp_pkt3(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[]="\x16\xFF\xFF\x06\x82\x03\xFF\xFF\x42\x33\x48\x93";
	u8 send_probe_pkt[]="\x14\xFF\xFF\x06\x32\xFF\xFF\x42\x85\x14\xC9";
	len=sizeof(send_probe_pkt)-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+1,(char *)&seqnum,2);
	seqnum=bswap16(seqnum);

	seqnum--;
	seqnum=bswap16(seqnum);
	memcpy(send_probe_pkt+5,(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;
};
Esempio n. 9
0
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;
};
Esempio n. 10
0
int main() {
	unsigned char membuf[0x1000];
	int header_len;
	int tmplen;

	//memcpy(membuf, "\xA1\x85\x02", 3);

	memcpy(membuf, "\x93\x8D\x02", 3);
	
	memcpy(membuf, "\xC9\x6E", 2);

	
	show_memory(membuf, 2, "Input:");

    // pass 1-3 bytes of header
    header_len = 0;
    tmplen = get_packet_size2(membuf, 4, &header_len);
    //tmplen = tmplen-1;
    
    printf("7bit decoded len: %d\n", tmplen);

};
Esempio n. 11
0
int parse_cmd_lines(_MIPD_ int argc, char* argv[], char *globalptr) {
	int len;
	u32 secret_p[17], secret_q[17];
	char public_key[0x81];
	char secret_key[0x81];

	u8   userhex[0x1000];
	char str_skypename[0x1000];
	char user_cred[0x101];

	char str_remote_skype[1024];
	char tmpdestip[1024];
	char tmpdestport[1024];

	char line1[0x1000];
	char line2[0x1000];
	
	int retcode;
	
	int fd;

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

	memset(public_key,0,sizeof(public_key));
	memset(secret_key,0,sizeof(secret_key));



	if (argc!=2){
		printf("usege: skydirect <our public ip>\n");
		return -1;
	};

	strncpy(global->our_public_ip,argv[1],0x100);

	fd=open("a_cred.txt",O_RDONLY);
	len=read(fd,&line1,0x1000);
	close(fd);
	if (len<=0){
		if(DEBUG_LEVEL>=100) printf("file open error\n");
		return -1;
	};
	if (len>=0x1000){
		if(DEBUG_LEVEL>=100) printf("file too big\n");
		return -1;
	};
	line1[len]=0;

	parse_input_line(line1, secret_p, secret_q, (char*)&str_skypename, (char*)&user_cred);


	if(DEBUG_LEVEL>=100) printf("skypename=%s\n",str_skypename);

	show_memory(user_cred,0x100,"cred:");

	memcpy(global->CREDENTIALS,"\x00\x00\x00\x01",4);
	memcpy(global->CREDENTIALS+4,user_cred,0x100);
	global->CREDENTIALS_LEN=0x104;


	//
	fd=open("a_sendto.txt",O_RDONLY);
	len=read(fd,&line2,0x1000);
	close(fd);
	if (len<=0){
		if(DEBUG_LEVEL>=100) printf("file open error\n");
		return -1;
	};
	if (len>=0x1000){
		if(DEBUG_LEVEL>=100) printf("file too big\n");
		return -1;
	};
	line2[len]=0;

	retcode=parse_input_line2(line2, (u8 *)&userhex, (char *)&str_remote_skype, (char *)&tmpdestip, (char *)&tmpdestport);

	if(DEBUG_LEVEL>=100) show_memory(userhex,0x08,"userhex id:");

	memcpy(global->USERHEX,userhex,0x08);

	if (retcode==-1){
		printf("load parsing, at sendto file parsing error\n");
		return -1;
	};
	


	if(DEBUG_LEVEL>=100) printf("remote_skypename=%s\n",str_remote_skype);
	if(DEBUG_LEVEL>=100) printf("destip=%s\n",tmpdestip);
	if(DEBUG_LEVEL>=100) printf("destport=%s\n",tmpdestport);

	strncpy(global->user_snodeip,tmpdestip,1024);
	global->user_snodeport=atoi(tmpdestport);


	restore_user_keypair(_MIPP_ secret_p, secret_q, public_key, secret_key);


	memcpy(global->xoteg_pub,public_key,0x80);
	memcpy(global->xoteg_sec,secret_key,0x80);

	show_memory(global->xoteg_pub,0x80,"xoteg_pubkey:");
	show_memory(global->xoteg_sec,0x80,"xoteg_seckey:");

	show_memory(global->CREDENTIALS,0x104,"CREDENTIALS:");


	strcpy(global->REMOTE_NAME,str_remote_skype);

	strcat(global->CHAT_STRING,"#");
	strcat(global->CHAT_STRING,str_skypename);
	strcat(global->CHAT_STRING,"/$");
	strcat(global->CHAT_STRING,global->REMOTE_NAME);
	strcat(global->CHAT_STRING,";");
	strcat(global->CHAT_STRING,global->CHAT_RND_ID);

	strcat(global->CHAT_PEERS,global->REMOTE_NAME);
	strcat(global->CHAT_PEERS," ");
	strcat(global->CHAT_PEERS,str_skypename);


	if(DEBUG_LEVEL>=100) printf("CHAT_STRING: %s\n",global->CHAT_STRING);
    if(DEBUG_LEVEL>=100) printf("REMOTE_NAME: %s\n",global->REMOTE_NAME);
    if(DEBUG_LEVEL>=100) printf("CHAT_PEERS: %s\n",global->CHAT_PEERS);


	fd=open("a_msg.txt",O_RDONLY);
	len=read(fd,&global->MSG_TEXT,0x1000);
	close(fd);
    
	if (len<=0){
		if(DEBUG_LEVEL>=100) printf("file open error\n");
		return -1;
	};
	if (len>=0x1000){
		if(DEBUG_LEVEL>=100) printf("file too big\n");
		return -1;
	};

	global->MSG_TEXT[len]=0;

 	if(DEBUG_LEVEL>=100) printf("\nMSG_TEXT: %s\n",global->MSG_TEXT);


	return 1;
}
Esempio n. 12
0
///////////////////////////////
//tcp third packet
////////////////////////////////
int make_tcp_pkt3(u16 seqnum, u32 rnd, int last_recv_pkt_num, int start_slot, char *pkt, int *pkt_len) {
	int len;
	u16 seqnum42;
	
	u8 result[0x2000];
	int result_len;
	u8 bufheader[0x10];
	int bufheader_len;
	u8 pkt_tmp[0x2000];
	int pkt_tmp_len;

	u32 num_nodes_from_slot=0x0A;

	skype_thing	mythings[] = {
		{0, 0, 0xFF, 0x00},
		{0, 5, 0xFF, 0x00},
	};
	int mythings_len=2;
    u8 send_pkt1[] = "\x07\x01\xFF\xFF";




	// pkt1 confirm 
	len=0;
	memcpy(send_pkt1+2,&last_recv_pkt_num,2);
	memcpy(pkt+len,send_pkt1,sizeof(send_pkt1)-1);
	len+=sizeof(send_pkt1)-1;



	mythings[0].m=start_slot;
	mythings[0].n=0;
	mythings[1].m=num_nodes_from_slot;
	mythings[1].n=0;
	result_len=main_pack(mythings, mythings_len, result, sizeof(result)-1 );

	// 42 header
	seqnum42=seqnum+1;
	bufheader_len=first_bytes_header2(seqnum42, bufheader, sizeof(bufheader)-1, result, result_len);
	if (bufheader_len==-1){
		return -1;
	};

	// 42 header and data
	pkt_tmp_len=0;
	memcpy(pkt_tmp+pkt_tmp_len,bufheader,bufheader_len);
	pkt_tmp_len+=bufheader_len;
	memcpy(pkt_tmp+pkt_tmp_len,result,result_len);
	pkt_tmp_len+=result_len;


	// pkt header
	seqnum42=seqnum+2;
	bufheader_len=first_bytes_size(seqnum42, bufheader, sizeof(bufheader)-1, pkt_tmp, pkt_tmp_len);
	if (bufheader_len==-1){
		return -1;
	};

	memcpy(pkt+len,bufheader,bufheader_len);
	len+=bufheader_len;
	memcpy(pkt+len,pkt_tmp,pkt_tmp_len);
	len+=pkt_tmp_len;


	show_memory(pkt,len,"send pkt3:");
	
	RC4_crypt (pkt, len, &rc4, 0);

	*pkt_len=len;

	return 0;
};
Esempio n. 13
0
////////////////////////
// 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;

};
Esempio n. 14
0
int parse_cmd_lines(_MIPD_ int argc, char* argv[], char *globalptr) {
	int len;
	u32 secret_p[17], secret_q[17];
	char public_key[0x81];
	char secret_key[0x81];

	char str_skypename[0x1000];
	char user_cred[0x101];

	char str_remote_skype[1024];
	char tmpdestip[1024];
	char tmpdestport[1024];

	char line1[0x1000];
	char line2[0x1000];

	int fd;

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

	memset(public_key,0,sizeof(public_key));
	memset(secret_key,0,sizeof(secret_key));


	fd=open("a_cred.txt",O_RDONLY);
	len=read(fd,&line1,0x1000);
	close(fd);
	if (len<=0){
		if(DEBUG_LEVEL>=100) printf("file open error\n");
		return -1;
	};
	if (len>=0x1000){
		if(DEBUG_LEVEL>=100) printf("file too big\n");
		return -1;
	};

	line1[len]=0;
	while(len>0){
		if (line1[len]==0x0D){
			line1[len]=0;
		};
		if (line1[len]==0x0A){
			line1[len]=0;
		};
		len--;
	}

	len=strlen(line1);

	//printf("%c %c\n",line1[len-2], line1[len-1] );

	if ( (line1[len-2]==':') && (line1[len-1]=='2') ){

		if (DEBUG_LEVEL>=100) printf("format version 2\n");

		parse_input_line_type2(line1, (char*)&public_key, (char*)&secret_key, (char*)&str_skypename, (char*)&user_cred);

		memcpy(global->xoteg_pub,public_key,0x80);
		memcpy(global->xoteg_sec,secret_key,0x80);

		show_memory(global->xoteg_pub,0x80,"xoteg_pubkey:");
		show_memory(global->xoteg_sec,0x80,"xoteg_seckey:");

	}else{

		if (DEBUG_LEVEL>=100) printf("format version 1\n");

		parse_input_line(line1, secret_p, secret_q, (char*)&str_skypename, (char*)&user_cred);

		restore_user_keypair(_MIPP_ secret_p, secret_q, public_key, secret_key);

		memcpy(global->xoteg_pub,public_key,0x80);
		memcpy(global->xoteg_sec,secret_key,0x80);

		show_memory(global->xoteg_pub,0x80,"xoteg_pubkey:");
		show_memory(global->xoteg_sec,0x80,"xoteg_seckey:");
	};




	if(DEBUG_LEVEL>=100) printf("skypename=%s\n",str_skypename);

	show_memory(user_cred,0x100,"cred:");

	memcpy(global->CREDENTIALS,"\x00\x00\x00\x01",4);
	memcpy(global->CREDENTIALS+4,user_cred,0x100);
	global->CREDENTIALS_LEN=0x104;


	//
	fd=open("a_sendto.txt",O_RDONLY);
	len=read(fd,&line2,0x1000);
	close(fd);
	if (len<=0){
		if(DEBUG_LEVEL>=100) printf("file open error\n");
		return -1;
	};
	if (len>=0x1000){
		if(DEBUG_LEVEL>=100) printf("file too big\n");
		return -1;
	};
	line2[len]=0;

	parse_input_line2(line2, (char *)&str_remote_skype, (char *)&tmpdestip, (char *)&tmpdestport);

	if(DEBUG_LEVEL>=100) printf("remote_skypename=%s\n",str_remote_skype);
	if(DEBUG_LEVEL>=100) printf("destip=%s\n",tmpdestip);
	if(DEBUG_LEVEL>=100) printf("destport=%s\n",tmpdestport);

	strncpy(global->remoteip,tmpdestip,1024);
	global->remoteport=atoi(tmpdestport);



	show_memory(global->CREDENTIALS,0x104,"CREDENTIALS:");


	strcpy(global->REMOTE_NAME,str_remote_skype);

	strcat(global->CHAT_STRING,"#");
	strcat(global->CHAT_STRING,str_skypename);
	strcat(global->CHAT_STRING,"/$");
	strcat(global->CHAT_STRING,global->REMOTE_NAME);
	strcat(global->CHAT_STRING,";");
	strcat(global->CHAT_STRING,global->CHAT_RND_ID);

	strcat(global->CHAT_PEERS,global->REMOTE_NAME);
	strcat(global->CHAT_PEERS," ");
	strcat(global->CHAT_PEERS,str_skypename);


	if(DEBUG_LEVEL>=100) printf("CHAT_STRING: %s\n",global->CHAT_STRING);
    if(DEBUG_LEVEL>=100) printf("REMOTE_NAME: %s\n",global->REMOTE_NAME);
    if(DEBUG_LEVEL>=100) printf("CHAT_PEERS: %s\n",global->CHAT_PEERS);


	fd=open("a_msg.txt",O_RDONLY);
	len=read(fd,&global->MSG_TEXT,0x1000);
	close(fd);
    
	if (len<=0){
		if(DEBUG_LEVEL>=100) printf("file open error\n");
		return -1;
	};
	if (len>=0x1000){
		if(DEBUG_LEVEL>=100) printf("file too big\n");
		return -1;
	};

	global->MSG_TEXT[len]=0;

 	if(DEBUG_LEVEL>=100) printf("\nMSG_TEXT: %s\n",global->MSG_TEXT);


	return 0;
}
Esempio n. 15
0
main()
{

    show_memory();

}
Esempio n. 16
0
/////////////////////////////////////////
// aes crypt
/////////////////////////////////////////
int process_aes_crypt(char *globalptr, char *data, int datalen, int usekey, int blkseq, int need_xor){	
	static u8 zero[32];
	static u32 ks[60];
	u32 blk[0x10];
	int j;
	int k;
	char *ptr;

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


	memset(ks,0,sizeof(ks));

	// if no key, use zero
	memset(zero,0,sizeof(zero));

	// use real key
	if (usekey){
		memcpy(zero,global->AES_KEY,0x20);
	};

	// setup key
	aes_256_setkey (zero, ks);
	
	// for debug aes encoding
	// print key material
	if (0) {
		ptr=(char *)ks;
		show_memory(ptr, 60*4, "KeyMat");
	};

	// setup control block
	memset (blk, 0, 0x10);

	//if using key, control block have local and remote session id data.
	if (usekey){
		blk[0]=global->LOCAL_SESSION_ID * 0x10000 + global->REMOTE_SESSION_ID;
	};
	
	// need xor session id in control block
	if (need_xor){
		blk[0]=blk[0] ^ 0xFFFFFFFF;
	};

	blk[1]=blk[0];
	blk[3]=blk[3] + (blkseq * 0x10000);
	

	show_memory(data, datalen, "Before AES crypt");

	// process aes crypt
	for (j = 0; j+16 < datalen; j += 16){
		aes_256_encrypt (blk, blk+4, ks);
		dword(data+j+ 0) ^= bswap32(blk[4]);
		dword(data+j+ 4) ^= bswap32(blk[5]);
		dword(data+j+ 8) ^= bswap32(blk[6]);
		dword(data+j+12) ^= bswap32(blk[7]);
		blk[3]++;
	};
	if (j < datalen){
		aes_256_encrypt (blk, blk+4, ks);
		for (k = 0; j < datalen; j++, k++) data[j] ^= ((u8 *)(blk+4))[k^3];
	};

	show_memory(data, datalen, "After AES crypt");


	return 0;

};