void on_btnpacesched_clicked(GtkWidget *widget) { GtkComboBox *routeWidget = GTK_COMBO_BOX(glade_xml_get_widget(xml, "paceroutes")); gchar* route = gtk_combo_box_get_active_text(routeWidget); gchar url[512]; g_snprintf(url,512,"%s/pacebus/%ssched.pdf",getProgData(NULL),route); openPDF(url); }
void openStation(GtkComboBox *box) { if(gtk_combo_box_get_active_text(box) == NULL) return; //happens initially for(gint i=0;i<num_of_lines;++i) { if(box == lines[i].box) { //found ya ;) gint pos = gtk_combo_box_get_active(box); gchar pdf[512]; g_snprintf(pdf,512,"%s/%s/%s.pdf",getProgData("trains"),lines[i].line,lines[i].stations[pos].name); openPDF(pdf); return; } } }
void on_ctaroutes_changed(GtkWidget *widget) { /* so, ya wanta no your way around the chitown buses, eh? */ GtkComboBox* routeWidget = GTK_COMBO_BOX(widget); gchar* route = gtk_combo_box_get_active_text(routeWidget); gchar url[512]; if(route == NULL) { return; //this happens when page loads } //note: since getProgData(NULL) will have an ending slash, // we'll have a double slash. better then alternative g_snprintf(url,512,"%s/ctabus/%s.pdf",getProgData(NULL),route); openPDF(url); }
int main(int argc, char **argv) { int ret = 0; EncData *e; if(argc != 2) { fprintf(stderr,"Usage: %s filename\n", argv[0]); exit(1); } FILE *file; if((file = fopen(argv[1], "r")) == 0) { fprintf(stderr,"Error: file %s not found\n", argv[1]); exit(2); } // int ch; e = calloc(1,sizeof(EncData)); if(!openPDF(file,e)) { fprintf(stderr, "Error: Not a valid PDF\n"); ret = 3; goto out; } ret = getEncryptedInfo(file, e); if(ret != 0) { if(ret == EENCNF) fprintf(stderr, "Error: Could not extract encryption information\n"); else if(ret == ETRANF) fprintf(stderr, "Error: First trailer not found\n"); else if(ret == ETRENF) fprintf(stderr, "Error: Encryption object not found in trailer\n"); else if(ret == ETRINF) fprintf(stderr, "Error: ID object not found in trailer\n"); ret = 4; goto out; } printEncData(e); freeEncData(e); if(fclose(file) != 0) { fprintf(stderr, "Error: closing file %s\n", argv[1]); } return 0; out: freeEncData(e); if(fclose(file) != 0) { fprintf(stderr, "Error: closing file %s\n", argv[1]); } exit(ret); }
void Runner::showPdfIfDemo() const { if (projectName!="demo") { return; } QVector<QString> demoPDFs = QVector<QString>(); demoPDFs.append(finalProjectFolder+"/5_PS_SEPARATED/FRACTURE/WELL-1_FRACTURE.pdf"); demoPDFs.append(finalProjectFolder+"/6_WELL_PS_SEPARATED/FRACTURE/WELL-1_FRACTURE_TILTED.pdf"); foreach (QString demoPDF, demoPDFs) { qDebug() << "Trying to open demo pdf at" << demoPDF; if (QFile::exists(demoPDF)) openPDF(demoPDF); }
int pdf2john(int argc, char **argv) { int ret = 0; int c, i; FILE *file = NULL; uint8_t *userpassword = NULL; char *inputfile = NULL; unsigned char *p; struct custom_salt cs; cs.e.work_with_user = true; cs.e.have_userpassword = false; /* parse arguments */ while (true) { c = getopt(argc, argv, "op:v"); /* Detect the end of the options. */ if (c == -1) break; switch (c) { case 'o': cs.e.work_with_user = false; break; case 'p': userpassword = (uint8_t *) strdup(optarg); cs.e.work_with_user = false; cs.e.have_userpassword = true; break; case 'v': printf("pdfcrack version %d.%d\n", VERSION_MAJOR, VERSION_MINOR); return 0; default: printHelp(argv[0]); ret = 1; } } i = optind; if (i > 0) { if (i < argc) inputfile = strdup(argv[i++]); } if (!inputfile) { printHelp(argv[0]); ret = 1; goto cleanup; } if ((file = fopen(inputfile, "r")) == 0) { fprintf(stderr, "Error: file %s not found\n", inputfile); ret = 2; goto cleanup; } if (!openPDF(file, &cs.e)) { fprintf(stderr, "Error: Not a valid PDF\n"); ret = 3; goto cleanup; } ret = getEncryptedInfo(file, &cs.e); if (ret) { if (ret == EENCNF) fprintf(stderr, "Error: Could not extract encryption information\n"); else if (ret == ETRANF || ret == ETRENF || ret == ETRINF) fprintf(stderr, "Error: Encryption not detected (is the document password protected?)\n"); ret = 4; goto cleanup; } else if (cs.e.revision < 2 || (strcmp(cs.e.s_handler, "Standard") != 0)) { fprintf(stderr, "The specific version is not supported (%s - %d)\n", cs.e.s_handler, cs.e.revision); ret = 5; goto cleanup; } if (fclose(file)) { fprintf(stderr, "Error: closing file %s\n", inputfile); } #ifdef UNPDF_DEBUG printEncData(&cs.e); #endif /* try to initialize the cracking-engine */ if (!initPDFCrack(&cs)) { fprintf(stderr, "Wrong userpassword given, '%s'\n", userpassword); exit(-1); } /* deep serialize "e" structure */ printf("%s:$pdf$%s*", inputfile, cs.e.s_handler); p = cs.e.o_string; for (i = 0; i < 32; i++) printf("%c%c", itoa16[ARCH_INDEX(p[i] >> 4)], itoa16[ARCH_INDEX(p[i] & 0x0f)]); printf("*"); p = cs.e.u_string; for (i = 0; i < 32; i++) printf("%c%c", itoa16[ARCH_INDEX(p[i] >> 4)], itoa16[ARCH_INDEX(p[i] & 0x0f)]); printf("*%d*", cs.e.fileIDLen); p = cs.e.fileID; for (i = 0; i < cs.e.fileIDLen; i++) printf("%c%c", itoa16[ARCH_INDEX(p[i] >> 4)], itoa16[ARCH_INDEX(p[i] & 0x0f)]); printf("*%d*%d*%d*%u*%u*%d*%d*%d*%d", cs.e.encryptMetaData, cs.e.work_with_user, cs.e.have_userpassword, cs.e.version_major, cs.e.version_minor, cs.e.length, cs.e.permissions, cs.e.revision, cs.e.version); if (cs.e.have_userpassword) printf("*%s\n", userpassword); else printf("\n"); exit(0); cleanup: return ret; }
int main(int argc, char** argv) { int ret = 0, minpw = 0, maxpw = 32; struct sigaction act1, act2; FILE *file = NULL, *wordlist = NULL; bool recovery = false, quiet = false, work_with_user = true, permutation = false; uint8_t *userpassword = NULL; char *charset = NULL, *inputfile = NULL, *wordlistfile = NULL; EncData *e; /** Parse arguments */ while(true) { int c, option_index; static struct option long_options[] = { {"bench", no_argument , 0, 'b'}, {"charset", required_argument, 0, 'c'}, {"file", required_argument, 0, 'f'}, {"loadState",required_argument, 0, 'l'}, {"maxpw", required_argument, 0, 'm'}, {"minpw", required_argument, 0, 'n'}, {"owner", no_argument , 0, 'o'}, {"password", required_argument, 0, 'p'}, {"quiet", required_argument, 0, 'q'}, {"permutate",no_argument, 0, 's'}, {"user", no_argument , 0, 'u'}, {"wordlist", required_argument, 0, 'w'}, {"version", no_argument , 0, 'v'}, {0, 0, 0, 0}}; /* getopt_long stores the option index here. */ option_index = 0; c = getopt_long(argc, argv, "bc:f:l:m:n:op:qsuw:v", long_options, &option_index); /* Detect the end of the options. */ if(c == -1) break; switch(c) { case 'b': runBenchmark(); return 0; case 'c': if(charset) fprintf(stderr,"Charset already set\n"); else charset = strdup(optarg); break; case 'f': if(!recovery) inputfile = strdup(optarg); break; case 'l': if(inputfile) { free(inputfile); inputfile = NULL; } inputfile = strdup(optarg); recovery = true; break; case 'm': maxpw = atoi(optarg); break; case 'n': minpw = atoi(optarg); break; case 'o': work_with_user = false; break; case 'p': userpassword = (uint8_t*)strdup(optarg); work_with_user = false; break; case 'q': quiet = true; break; case 'u': if(!work_with_user) { fprintf(stderr, "Cannot work with both user- and owner-password\n"); exit(1); } work_with_user = true; break; case 's': permutation = true; break; case 'w': if(wordlistfile) fprintf(stderr, "Wordlist already set\n"); else wordlistfile = strdup(optarg); break; case 'v': printf("pdfcrack version %d.%d\n", VERSION_MAJOR, VERSION_MINOR); return 0; default: printHelp(argv[0]); ret = 1; goto out3; } } /** If there are any unhandled arguments and the filename and/or wordlist is not set: try to match the first as the filename and the second as wordlist. */ { int i = optind; if(i > 0) { if(i < argc && !inputfile) inputfile = strdup(argv[i++]); if(i < argc && !wordlistfile) wordlistfile = strdup(argv[i++]); if(i < argc) while(i<argc) { fprintf(stderr,"Non-option argument %s\n", argv[i++]); } } } if(!inputfile || minpw < 0 || maxpw < 0) { printHelp(argv[0]); ret = 1; goto out3; } if((file = fopen(inputfile, "r")) == 0) { fprintf(stderr,"Error: file %s not found\n", inputfile); ret = 2; goto out3; } e = calloc(1,sizeof(EncData)); if(recovery) { if(wordlistfile) { free(wordlistfile); wordlistfile = NULL; } if(!loadState(file, e, &wordlistfile, &work_with_user)) { fprintf(stderr, "Error: Not a savefile or savefile is damaged\n"); ret = 3; goto out1; } if(!quiet) printf("Loaded state for %s\n", inputfile); } else { /** !recovery */ if(!openPDF(file,e)) { fprintf(stderr, "Error: Not a valid PDF\n"); ret = 3; goto out1; } ret = getEncryptedInfo(file, e); if(ret) { if(ret == EENCNF) fprintf(stderr, "Error: Could not extract encryption information\n"); else if(ret == ETRANF || ret == ETRENF || ret == ETRINF) fprintf(stderr, "Error: Encryption not detected (is the document password protected?)\n"); ret = 4; goto out1; } else if(e->revision < 2 || (strcmp(e->s_handler,"Standard") != 0)) { fprintf(stderr, "The specific version is not supported (%s - %d)\n", e->s_handler, e->revision); ret = 5; goto out1; } } if(fclose(file)) { fprintf(stderr, "Error: closing file %s\n", inputfile); } if(minpw > maxpw) { fprintf(stderr, "Warning: minimum pw-length bigger than max\n"); } if(wordlistfile) { if((wordlist = fopen(wordlistfile, "r")) == 0) { fprintf(stderr,"Error: file %s not found\n", wordlistfile); ret = 6; goto out2; } } act2.sa_handler = autoSave; sigfillset(&act2.sa_mask); act2.sa_flags = 0; sigaction(SIGINT, &act2, 0); if(!quiet) { printEncData(e); act1.sa_handler = alarmInterrupt; sigemptyset(&act1.sa_mask); act1.sa_flags = 0; sigaction(SIGALRM, &act1, 0); alarm(PRINTERVAL); } /** Try to initialize the cracking-engine */ if(!initPDFCrack(e, userpassword, work_with_user, wordlistfile, wordlistfile?Wordlist:Generative, wordlist, charset, (unsigned int)minpw, (unsigned int)maxpw, permutation)) { cleanPDFCrack(); fprintf(stderr, "Wrong userpassword, '%s'\n", userpassword); ret = 7; goto out2; } /** Do the actual crunching */ runCrack(); /** cleanup */ cleanPDFCrack(); freeEncData(e); if(wordlistfile) { fclose(wordlist); free(wordlistfile); } if(inputfile) free(inputfile); if(charset) free(charset); if(userpassword) free(userpassword); return 0; out1: if(fclose(file)) fprintf(stderr, "Error: closing file %s\n", inputfile); out2: freeEncData(e); out3: if(inputfile) free(inputfile); if(charset) free(charset); if(userpassword) free(userpassword); exit(ret); }