static void control_escape_set_alternate_character_set(char ch) { charset_func c = parse_charset(ch); if (c) console->g1_charset = c; else log_warning("console: set alternate character set: %c, ignored.\n", ch); console->processor = NULL; }
static void benchmark (void) { #ifdef HAVE_GETTIMEOFDAY int i; long j, k; struct timeval tv1, tv2; do { for (i = 0; i < HEADER_SIZE * 3; i++) files[i] = i ^ (i * 3); file_count = 3; strcpy (pw, "abcdefghij"); parse_charset ("a"); benchmark_count = BENCHMARK_LOOPS; verbosity = 0; printf ("%c%s: ", (crack_method - methods == default_method) ? '*' : ' ', crack_method->desc); if (strncmp ("zip", crack_method->desc, 3)) printf ("(skipped)"); else { fflush (stdout); crack_method->init_crack_pw (); gettimeofday (&tv1, 0); crack_method->crack_pw (benchmark_gen, false_callback); gettimeofday (&tv2, 0); tv2.tv_sec -= tv1.tv_sec; tv2.tv_usec -= tv1.tv_usec; j = tv2.tv_sec * 1000000 + tv2.tv_usec; k = BENCHMARK_LOOPS; printf ("cracks/s = "); for (i = 7; i--;) printf ("%ld", k / j), k = (k - k / j * j) * 10; } printf ("\n"); crack_method++; } while (method_number < 0 && crack_method->desc); #else fprintf (stderr, "This executable was compiled without support for benchmarking\n"); exit (1); #endif }
static int parse_document(xmlDocPtr document, Octstr *charset, simple_binary_t **sibxml) { xmlNodePtr node; (*sibxml)->wbxml_version = 0x02; /* WBXML Version number 1.2 */ (*sibxml)->public_id = 0x05; /* SI 1.0 Public ID */ charset = octstr_create("UTF-8"); (*sibxml)->charset = parse_charset(charset); octstr_destroy(charset); node = xmlDocGetRootElement(document); return parse_node(node, sibxml); }
static int parse_document(xmlDocPtr document, Octstr *charset, simple_binary_t **otabxml) { xmlNodePtr node; (*otabxml)->wbxml_version = 0x01; /* WBXML Version number 1.1 */ (*otabxml)->public_id = 0x01; /* Public id for an unknown document type */ charset = octstr_create("UTF-8"); (*otabxml)->charset = parse_charset(charset); octstr_destroy(charset); node = xmlDocGetRootElement(document); return parse_node(node, otabxml); }
static GObexApparam *parse_push_options(GObexApparam *apparam, DBusMessageIter *iter) { DBusMessageIter array; if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) return NULL; dbus_message_iter_recurse(iter, &array); while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) { const char *key; DBusMessageIter value, entry; dbus_message_iter_recurse(&array, &entry); dbus_message_iter_get_basic(&entry, &key); dbus_message_iter_next(&entry); dbus_message_iter_recurse(&entry, &value); if (strcasecmp(key, "Transparent") == 0) { if (parse_transparent(apparam, &value) == NULL) return NULL; } else if (strcasecmp(key, "Retry") == 0) { if (parse_retry(apparam, &value) == NULL) return NULL; } else if (strcasecmp(key, "Charset") == 0) { if (parse_charset(apparam, &value) == NULL) return NULL; } dbus_message_iter_next(&array); } return apparam; }
static void tag_handle_meta (int tagid, struct taginfo *tag, struct map_context *ctx) { char *name = find_attr (tag, "name", NULL); char *http_equiv = find_attr (tag, "http-equiv", NULL); if (http_equiv && 0 == strcasecmp (http_equiv, "refresh")) { /* Some pages use a META tag to specify that the page be refreshed by a new page after a given number of seconds. The general format for this is: <meta http-equiv=Refresh content="NUMBER; URL=index2.html"> So we just need to skip past the "NUMBER; URL=" garbage to get to the URL. */ struct urlpos *entry; int attrind; int timeout = 0; char *p; char *refresh = find_attr (tag, "content", &attrind); if (!refresh) return; for (p = refresh; c_isdigit (*p); p++) timeout = 10 * timeout + *p - '0'; if (*p++ != ';') return; while (c_isspace (*p)) ++p; if (!( c_toupper (*p) == 'U' && c_toupper (*(p + 1)) == 'R' && c_toupper (*(p + 2)) == 'L' && *(p + 3) == '=')) return; p += 4; while (c_isspace (*p)) ++p; entry = append_url (p, ATTR_POS(tag,attrind,ctx), ATTR_SIZE(tag,attrind), ctx); if (entry) { entry->link_refresh_p = 1; entry->refresh_timeout = timeout; entry->link_expect_html = 1; } } else if (http_equiv && 0 == strcasecmp (http_equiv, "content-type")) { /* Handle stuff like: <meta http-equiv="Content-Type" content="text/html; charset=CHARSET"> */ char *mcharset; char *content = find_attr (tag, "content", NULL); if (!content) return; mcharset = parse_charset (content); if (!mcharset) return; xfree_null (meta_charset); meta_charset = mcharset; } else if (name && 0 == strcasecmp (name, "robots")) { /* Handle stuff like: <meta name="robots" content="index,nofollow"> */ char *content = find_attr (tag, "content", NULL); if (!content) return; if (!strcasecmp (content, "none")) ctx->nofollow = true; else { while (*content) { char *end; /* Skip any initial whitespace. */ content += strspn (content, " \f\n\r\t\v"); /* Find the next occurrence of ',' or whitespace, * or the end of the string. */ end = content + strcspn (content, ", \f\n\r\t\v"); if (!strncasecmp (content, "nofollow", end - content)) ctx->nofollow = true; /* Skip past the next comma, if any. */ if (*end == ',') ++end; else { end = strchr (end, ','); if (end) ++end; else end = content + strlen (content); } content = end; } } } }
int main (int argc, char *argv[]) { int c; int option_index = 0; char *charset = "aA1!"; enum { m_benchmark, m_brute_force, m_dictionary } mode = m_brute_force; while ((c = getopt_long (argc, argv, "DbBc:hVvp:l:um:2:", options, &option_index)) != -1) switch (c) { case 'b': mode = m_brute_force; break; case 'D': mode = m_dictionary; break; case 'p': strcpy (pw, optarg); break; case 'l': pw[0] = 0; switch (sscanf (optarg, "%d-%d", &min_length, &max_length)) { default: fprintf (stderr, "'%s' is an incorrect length specification\n", optarg); exit (1); case 1: max_length = min_length; case 2: ; } break; case 2: if (sscanf (optarg, "%d/%d", &residuent, &modul) != 2) fprintf (stderr, "malformed --modulo option, expected 'residuent/modul'\n"), exit (1); if (residuent < 0 || modul <= 0) fprintf (stderr, "residuent and modul must be positive\n"), exit (1); if (residuent >= modul) fprintf (stderr, "residuent must be less than modul\n"), exit (1); break; case 'B': mode = m_benchmark; benchmark (); exit (0); case 'v': verbosity++; break; case 'm': { for (method_number = 0; methods[method_number].desc; method_number++) if (!strncmp (methods[method_number].desc, optarg, strlen (optarg))) break; if (!methods[method_number].desc) method_number = atoi (optarg); crack_method = methods + method_number; } break; case 'V': validate (); exit (0); case 'c': charset = optarg; break; case 'u': use_unzip = 1; break; case 'h': usage (0); case 'R': printf (PACKAGE " version " VERSION "\n"); exit (0); case ':': fprintf (stderr, "required argument missing\n"); exit (1); case '?': fprintf (stderr, "unknown option\n"); exit (1); default: usage (1); } if (method_number < 0) { method_number = default_method; crack_method = methods + default_method; } if (optind >= argc) { fprintf (stderr, "you have to specify one or more zip files (try --help)\n"); exit (1); } for (; optind < argc; optind++) if (file_count < MAX_FILES) crack_method->load_file (argv[optind]); else if (verbosity) printf ("%d file maximum reached, ignoring '%s'\n", MAX_FILES, argv[optind]); if (file_count == 0) { fprintf (stderr, "no usable files found\n"); exit (1); } crack_method->init_crack_pw (); switch (mode) { case m_brute_force: parse_charset (charset); if (!pw[0]) { if (min_length < 0) { fprintf (stderr, "you have to specify either --init-password or --length with --brute-force\n"); exit (1); } else { u8 *p = pw; while (p < pw + min_length) *p++ = bf_next[255]; *p++ = 0; } } if (residuent) { int xmodul = modul; modul = residuent; pw_end = pw + strlen (pw); brute_force_gen (); printf ("%s\n", pw); modul = xmodul; printf ("WARNING: residuent mode NOT supported YET!\n"); } crack_method->crack_pw (brute_force_gen, print_callback); break; case m_dictionary: if (!pw[0]) { fprintf (stderr, "you have to specify a file to read passwords from using the -p switch\n"); exit (1); } if (!(dict_file = fopen (pw, "r"))) { perror (pw); exit (1); } else { *(pw_end = pw) = 0; dictionary_gen (); /* fetch first password */ crack_method->crack_pw (dictionary_gen, print_callback); fclose (dict_file); } break; default: fprintf (stderr, "specified mode not supported in this version\n"); exit (1); } return 0; }