Пример #1
0
void pprint_attack_point(Panda__AttackPoint *ap) {        
    printf ("(attack_point,(%s,", gstr(ap->info));
    pprint_call_stack(ap->call_stack);
    printf (",");
    pprint_src_info(ap->src_info);
    printf (")");
}
Пример #2
0
void Shader::addGeometryShader(const char *gfile)
{
	std::string gstr(gfile);
	if(gstr.size() != 0){
		m_gs = createShader(GL_GEOMETRY_SHADER,file_read(gfile));
		glAttachShader(m_Program, m_gs);
		std::cout<<"Geometry Shader \""<<gstr<<"\" Added"<<std::endl;
	}
	else{
		std::cerr<<"No Geometry Shader Detected";
	}
}
Пример #3
0
int
CIFSsession(Session *s)
{
	char os[64], *q;
	Rune r;
	Pkt *p;
	enum {
		mycaps = CAP_UNICODE | CAP_LARGE_FILES | CAP_NT_SMBS |
			CAP_NT_FIND | CAP_STATUS32,
	};

	s->seqrun = 1;	/* activate the sequence number generation/checking */

	p = cifshdr(s, nil, SMB_COM_SESSION_SETUP_ANDX);
	p8(p, 0xFF);			/* No secondary command */
	p8(p, 0);			/* Reserved (must be zero) */
	pl16(p, 0);			/* Offset to next command */
	pl16(p, MTU);			/* my max buffer size */
	pl16(p, 1);			/* my max multiplexed pending requests */
	pl16(p, 0);			/* Virtual connection # */
	pl32(p, 0);			/* Session key (if vc != 0) */


	if((s->secmode & SECMODE_PW_ENCRYPT) == 0) {
		pl16(p, utflen(Sess->auth->resp[0])*2 + 2); /* passwd size */
		pl16(p, utflen(Sess->auth->resp[0])*2 + 2); /* passwd size (UPPER CASE) */
		pl32(p, 0);			/* Reserved */
		pl32(p, mycaps);
		pbytes(p);

		for(q = Sess->auth->resp[0]; *q; ){
			q += chartorune(&r, q);
			pl16(p, toupperrune(r));
		}
		pl16(p, 0);

		for(q = Sess->auth->resp[0]; *q; ){
			q += chartorune(&r, q);
			pl16(p, r);
		}
		pl16(p, 0);
	}else{
		pl16(p, Sess->auth->len[0]);	/* LM passwd size */
		pl16(p, Sess->auth->len[1]);	/* NTLM passwd size */
		pl32(p, 0);			/* Reserved  */
		pl32(p, mycaps);
		pbytes(p);

		pmem(p, Sess->auth->resp[0], Sess->auth->len[0]);
		pmem(p, Sess->auth->resp[1], Sess->auth->len[1]);
	}

	pstr(p, Sess->auth->user);	/* Account name */
	pstr(p, Sess->auth->windom);	/* Primary domain */
	pstr(p, "plan9");		/* Client OS */
	pstr(p, argv0);			/* Client LAN Manager type */

	if(cifsrpc(p) == -1){
		free(p);
		return -1;
	}

	g8(p);				/* Reserved (0) */
	gl16(p);			/* Offset to next command wordcount */
	Sess->isguest = gl16(p) & 1;	/* logged in as guest */

	gl16(p);
	gl16(p);
	/* no security blob here - we don't understand extended security anyway */
	gstr(p, os, sizeof os);
	s->remos = estrdup9p(os);

	free(p);
	return 0;
}
Пример #4
0
/*
 * Some older servers (old samba) prefer to talk older
 * dialects but if given no choice they will talk the
 * more modern ones, so we don't give them the choice.
 */
int
CIFSnegotiate(Session *s, long *svrtime, char *domain, int domlen, char *cname,
	int cnamlen)
{
	int d, i;
	char *ispeak = "NT LM 0.12";
	static char *dialects[] = {
//		{ "PC NETWORK PROGRAM 1.0"},
//		{ "MICROSOFT NETWORKS 1.03"},
//		{ "MICROSOFT NETWORKS 3.0"},
//		{ "LANMAN1.0"},
//		{ "LM1.2X002"},
//		{ "NT LANMAN 1.0"},
		{ "NT LM 0.12" },
	};
	Pkt *p;

	/*
	 * This should not be necessary, however the XP seems to use
	 * Unicode strings in its Negoiate response, but not set the
	 * Flags2 UNICODE flag.
	 *
	 * It does however echo back the FL_UNICODE flag we set in the
	 * flags2 negoiate request.
	 *
	 * The bodge is to force FL_UNICODE for this single request, 
	 * clearing it after. Later we set FL2_UNICODE if the server 
	 * agrees to CAP_UNICODE as it "should" be done.
	 */
	s->flags2 |= FL2_UNICODE;
	p = cifshdr(s, nil, SMB_COM_NEGOTIATE);
	s->flags2 &= ~FL2_UNICODE;

	pbytes(p);
	for(i = 0; i < nelem(dialects); i++){
		p8(p, STR_DIALECT);
		pascii(p, dialects[i]);
	}

	if(cifsrpc(p) == -1){
		free(p);
		return -1;
	}

	d = gl16(p);
	if(d < 0 || d > nelem(dialects)){
		werrstr("no CIFS dialect in common");
		free(p);
		return -1;
	}

	if(strcmp(dialects[d], ispeak) != 0){
		werrstr("%s dialect unsupported", dialects[d]);
		free(p);
		return -1;
	}

	s->secmode = g8(p);			/* Security mode */

	gl16(p);				/* Max outstanding requests */
	gl16(p);				/* Max VCs */
	s->mtu = gl32(p);			/* Max buffer size */
	gl32(p);				/* Max raw buffer size (depricated) */
	gl32(p);				/* Session key */
	s->caps = gl32(p);			/* Server capabilities */
	*svrtime = gvtime(p);			/* fileserver time */
	s->tz = (short)gl16(p) * 60; 		/* TZ in mins, is signed (SNIA doc is wrong) */
	s->challen = g8(p);			/* Encryption key length */
	gl16(p);
	gmem(p, s->chal, s->challen);		/* Get the challenge */
	gstr(p, domain, domlen);		/* source domain */

	{		/* NetApp Filer seem not to report its called name */
		char *cn = emalloc9p(cnamlen);

		gstr(p, cn, cnamlen);		/* their name */
		if(strlen(cn) > 0)
			memcpy(cname, cn, cnamlen);
		free(cn);
	}

	if(s->caps & CAP_UNICODE)
		s->flags2 |= FL2_UNICODE;

	free(p);
	return 0;
}
Пример #5
0
void pprint_src_info(Panda__SrcInfo *si) {
    printf ("(src_info,%s,%s,%d,%d)",gstr(si->filename),gstr(si->astnodename),
            si->linenum, si->insertionpoint);
}
Пример #6
0
int main(int argc, char *argv[]){
	// Window Main(argc, argv);
	Json Settings("../settings/heatmap.json");
	Message Msg("en");

	int i, j, k, m;
	char drop, buf[3];
	char string[1000];
	FILE *open;
	struct one_pixel *rawdata;
	struct {
		int byte_per_line;
		int block;
		int byte_per_pixel[2];
		char theme[100];
		struct rgb base;
	}setting;

	struct specification{
		long code;
		struct rgb color;
	};

	struct range{
		long begin;
		long end;
		struct rgb color;
	};

	struct {
		int num;
		struct specification *list;
	}specification_data;

	struct {
		int num;
		struct range *list;
	}range_data;

	// Loading Setting
	setting.byte_per_line = atoi( Settings.get("settings.block_per_line")->value );
	setting.block = atoi( Settings.get("settings.block")->value );

	setting.byte_per_pixel[0] = atoi( Settings.get("settings.block_per_pixel.width")->value );
	setting.byte_per_pixel[1] = atoi( Settings.get("settings.block_per_pixel.height")->value );

	strcpy( setting.theme, Settings.get("settings.default_theme")->value );
	color( &setting.base, Settings.get("settings.campus_color")->value );

	// Loading Theme
	sprintf(string, "../themes/%s.json", setting.theme);
	open = fopen(string, "r");
	if(!open){
		Msg.show(2);
		sprintf(string, "../themes/%s.json", setting.theme);
	}else{
		fclose(open);
	}

	Json Theme(string);

	// Default
	struct rgb theme_default;
	color( &theme_default, Theme.get("default")->value );

	// Specification
	specification_data.num = Theme.array_range("specification");

	specification_data.list = (struct specification *)calloc(specification_data.num, sizeof(struct specification));
	if(!specification_data.list)
		Msg.show(3);

	for(i=0; i<specification_data.num; i++){
		// Clear Buffer
		for(j=0; j<1000; j++)
			string[j] = 0x00;

		color( &specification_data.list[i].color, gcat(&Msg, Theme.get( gstr(string, "specification", i, "color") ))->value );
		specification_data.list[i].code = strtol( gcat(&Msg, Theme.get( gstr(string, "specification", i, "addr") ))->value, NULL, 16 );
	}

	// Range
	range_data.num = Theme.array_range("range");
	range_data.list = (struct range *)calloc(range_data.num, sizeof(struct range));
	if(!range_data.list)
		Msg.show(3);

	for(i=0; i<range_data.num; i++){
		// Clear Buffer
		for(j=0; j<1000; j++)
			string[j] = 0x00;

		color( &range_data.list[i].color, gcat(&Msg, Theme.get( gstr(string, "range", i, "color") ))->value );
		range_data.list[i].begin = strtol( Theme.get( gstr(string, "range", i, "begin") )->value, NULL, 16 );
		range_data.list[i].end = strtol( Theme.get( gstr(string, "range", i, "end") )->value, NULL, 16 );
	}

	// Prepare
	long buffer;
	int image_width = setting.byte_per_pixel[0] * setting.byte_per_line;
	int image_size = -1, image_height;

	open = fopen("../bin/main", "rb");
	if(!open)
		Msg.show(5);

	while(!feof(open)){
		fread(&buffer, (size_t)setting.block , (size_t)1, open);
		image_size++;
	}

	image_height = setting.byte_per_pixel[1] * ((image_size / setting.byte_per_line) + 1);

	rawdata = (struct one_pixel *)calloc(image_width * image_height, sizeof(struct one_pixel));
	if(!rawdata)
		Msg.show(3);


	rewind( open );

	struct rgb *line;
	line = (struct rgb *)calloc(setting.byte_per_line, sizeof(struct rgb));
	if(!line)
		Msg.show(3);

	int cur_line = 0;
	long size_pointer = 0;

	for(j=0; j<setting.byte_per_line; j++)
		line[j] = setting.base;

	int debug = 0;
	bool break_flag = false;
	while(!feof(open)){
		buffer = 0x20;
		if(fread(&buffer, (size_t)setting.block, (size_t)1, open) != 1)
			break_flag = true;

		if(!break_flag){
			// printf("%d (%d) %s\n", debug, cur_line, "Write!");
			debug++;

			// Default Color
			line[cur_line] = theme_default;

			// Range
			for(j=0; j<range_data.num; j++){
				if(buffer >= range_data.list[j].begin && buffer <= range_data.list[j].end){
					line[cur_line] = range_data.list[j].color;
					break;
				}
			}

			// Specification
			for(j=0; j<specification_data.num; j++){
				if( buffer == specification_data.list[j].code ){
					line[cur_line] = specification_data.list[j].color;
					break;
				}
			}
		}

		if(cur_line >= setting.byte_per_line - 1 || break_flag){
			// Height
			for(j=0; j<setting.byte_per_pixel[1]; j++){
				// Dots
				for(m=0; m<setting.byte_per_line; m++){
					for(k=0; k<setting.byte_per_pixel[0]; k++){
						rgb_one_pixel(&line[m], &rawdata[size_pointer]);
						size_pointer++;
					}
				}
			}

			for(j=0; j<setting.byte_per_line; j++)
				line[j] = setting.base;

			cur_line = 0;
		}else{
			cur_line++;
		}
	}

	fclose( open );

	Window Main(argc, argv, image_width, image_height, 24, rawdata);	
	Bitmap Img(&Msg, "../test_2.bmp", image_width, image_height, 24, rawdata);

	// char drop;

	struct color_set{
		char key;
	};

	// while(TRUE){
	// 	scanf("%c", &drop);

	// 	printf("%c", drop);
	// }

	return 0;
}
Пример #7
0
int main (int argc, char **argv) {
    
    str2ind = LoadDB(std::string("/tmp/lavadb"));
    ind2str = InvertDB(str2ind);
    
    pandalog_open(argv[1], "r");
    Panda__LogEntry *ple;
    while (1) {
        ple = pandalog_read_entry();
        if (ple == NULL) {
            break;
        }
        if (ple->instr == -1) {
            printf ("[after replay end] : ");
        } 
        else {
            printf ("instr=%" PRIu64 " pc=0x%" PRIx64 " :", ple->instr, ple->pc);
        }

        // from asidstory / osi
        if (ple->has_asid) {
            printf (" asid=%" PRIx64, ple->asid);
        }

        if (ple->has_process_id != 0) {
            printf (" pid=%d", ple->process_id);
        }
        if (ple->process_name != 0) {
            printf (" process=[%s]", ple->process_name);
        }

        // from file_taint
        if (ple->has_taint_label_number) {
            printf (" tl=%d", ple->taint_label_number);
        }
        if (ple->has_taint_label_virtual_addr) {
            printf (" va=0x%" PRIx64, ple->taint_label_virtual_addr);
        }
        if (ple->has_taint_label_physical_addr) {
            printf (" pa=0x%" PRIx64 , ple->taint_label_physical_addr);
        }

        if (ple->n_callstack > 0) {
            printf (" callstack=(%u,[", (uint32_t) ple->n_callstack);
            uint32_t i;
            for (i=0; i<ple->n_callstack; i++) {
                printf (" 0x%" PRIx64 , ple->callstack[i]);
                if (i+1 < ple->n_callstack) {
                    printf (",");
                }
            }
            printf ("])");
        }

        if (ple->attack_point) {
            Panda__AttackPoint *ap = ple->attack_point;
            printf (" attack point: info=[%u][%s]", ap->info, gstr(ap->info));
        }

        if (ple->src_info) {
            Panda__SrcInfo *si = ple->src_info;
            printf (" src info filename=[%u][%s] astnode=[%u][%s] linenum=%d",
                    si->filename, gstr(si->filename), si->astnodename, 
                    gstr(si->astnodename), si->linenum);
        }

        if (ple->has_tainted_branch && ple->tainted_branch) {
            printf (" tainted branch");
        }
        if (ple->taint_query_hypercall) {
            Panda__TaintQueryHypercall *tqh = ple->taint_query_hypercall;
            printf (" taint query hypercall(buf=0x%" PRIx64 ",len=%u,num_tainted=%u)", tqh->buf, tqh->len, tqh->num_tainted);
        }
        if (ple->has_tainted_instr && ple->tainted_instr) {
            printf (" tainted instr");
        }

        // dead data
        if (ple->n_dead_data > 0) {
            printf ("\n");
            uint32_t i;
            for (i=0; i<ple->n_dead_data; i++) {
                printf (" dead_data(label=%d,deadness=%.2f\n", i, ple->dead_data[i]);
            }
        }

        // taint queries
        if (ple->taint_query_unique_label_set) {
            printf (" taint query unqiue label set: ptr=%" PRIx64" labels: ", ple->taint_query_unique_label_set->ptr);
            uint32_t i;
            for (i=0; i<ple->taint_query_unique_label_set->n_label; i++) {
                printf ("%d ", ple->taint_query_unique_label_set->label[i]);
            }
        }
        
        if (ple->taint_query) {
            Panda__TaintQuery *tq = ple->taint_query;
            printf (" taint query: labels ptr %" PRIx64" tcn=%d off=%d", tq->ptr, (int) tq->tcn, (int) tq->offset);
        }

        // win7proc
        if (ple->new_pid) { 
            printf (" new_pid ");
            print_process(ple->new_pid);
        }
        if (ple->nt_create_user_process) {
            printf (" nt_create_user_process ");
            printf (" [ cur " ); 
            print_process(ple->nt_create_user_process->cur_p); 
            printf (" ]");
            printf (" [ new " ); 
            print_process(ple->nt_create_user_process->new_p); 
            printf (" ]");
            printf (" name=[%s] ", 
                    ple->nt_create_user_process->new_long_name);
        }
        if (ple->nt_terminate_process) {
            printf (" nt_terminate_process ");
            printf (" [ cur " ); 
            print_process(ple->nt_terminate_process->cur_p);
            printf (" ]");
            printf (" [ term " ); 
            print_process(ple->nt_terminate_process->term_p);
            printf (" ]");
        }

        if (ple->nt_create_file) {
            printf (" nt_create_file ");
            print_process_file(ple->nt_create_file);
        }

        if (ple->nt_read_file) {
            printf (" nt_read_file ");
            print_process_file(ple->nt_read_file);
        }
        if (ple->nt_delete_file) {
            printf (" nt_delete_file ");
            print_process_file(ple->nt_delete_file);
        }
        if (ple->nt_write_file) {
            printf ("nt_write_file ");
            print_process_file(ple->nt_write_file);
        }
        if (ple->nt_create_key) {
            printf (" nt_create_key ");
            print_process_key(ple->nt_create_key);
        }
        if (ple->nt_create_key_transacted) {
            printf (" nt_create_key_transacted ");
            print_process_key(ple->nt_create_key_transacted);
        }
        if (ple->nt_open_key) {
            printf (" nt_open_key ");
            print_process_key(ple->nt_open_key);
        }
        if (ple->nt_open_key_ex) {
            printf (" nt_open_key_ex ");
            print_process_key(ple->nt_open_key_ex);
        }
        if (ple->nt_open_key_transacted) {
            printf (" nt_open_key_transacted ");
            print_process_key(ple->nt_open_key_transacted);
        }
        if (ple->nt_open_key_transacted_ex) {
            printf (" nt_open_key_transacted_ex ");
            print_process_key(ple->nt_open_key_transacted_ex);
        }
        if (ple->nt_delete_key) {
            printf (" nt_delete_key ");
            print_process_key(ple->nt_delete_key);
        }
        if (ple->nt_query_key) {
            printf (" nt_query_key ");
            print_process_key(ple->nt_query_key);
        }
        if (ple->nt_query_value_key) {
            printf (" nt_query_value_key ");
            print_process_key_value(ple->nt_query_value_key);
        }
        if (ple->nt_delete_value_key) {
            printf (" nt_delete_value_key ");
            print_process_key_value(ple->nt_delete_value_key);
        }
        if (ple->nt_set_value_key) {
            printf (" nt_set_value_key ");
            print_process_key_value(ple->nt_set_value_key);
        }
        if (ple->nt_enumerate_key) {
            printf (" nt_enumerate_key ");
            print_process_key_index(ple->nt_enumerate_key);
        }
        if (ple->nt_enumerate_value_key) {
            printf (" nt_enumerate_value_key ");
            print_process_key_index(ple->nt_enumerate_value_key);
        }

        printf ("\n");
        panda__log_entry__free_unpacked(ple, NULL);
    }
}