static void gui_restore_after_callback (Gimp *gimp, GimpInitStatusFunc status_callback) { GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (gimp->config); GimpDisplay *display; if (gimp->be_verbose) g_print ("INIT: %s\n", G_STRFUNC); gimp->message_handler = GIMP_MESSAGE_BOX; if (gui_config->restore_accels) menus_restore (gimp); ui_configurer = g_object_new (GIMP_TYPE_UI_CONFIGURER, "gimp", gimp, NULL); image_ui_manager = gimp_menu_factory_manager_new (global_menu_factory, "<Image>", gimp, gui_config->tearoff_menus); gimp_ui_manager_update (image_ui_manager, gimp); #ifdef GDK_WINDOWING_QUARTZ { GtkosxApplication *osx_app; GtkWidget *menu; GtkWidget *item; osx_app = gtkosx_application_get (); menu = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager), "/image-menubar"); if (GTK_IS_MENU_ITEM (menu)) menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu)); gtkosx_application_set_menu_bar (osx_app, GTK_MENU_SHELL (menu)); gtkosx_application_set_use_quartz_accelerators (osx_app, FALSE); gui_add_to_app_menu (image_ui_manager, osx_app, "/image-menubar/Help/dialogs-about", 0); #define PREFERENCES "/image-menubar/Edit/Preferences/" gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-preferences", 2); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-input-devices", 3); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-keyboard-shortcuts", 4); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-module-dialog", 5); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "plug-in-unit-editor", 6); #undef PREFERENCES item = gtk_separator_menu_item_new (); gtkosx_application_insert_app_menu_item (osx_app, item, 7); item = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager), "/image-menubar/File/file-quit"); gtk_widget_hide (item); g_signal_connect (osx_app, "NSApplicationBlockTermination", G_CALLBACK (gui_quartz_quit_callback), image_ui_manager); gtkosx_application_ready (osx_app); } #endif /* GDK_WINDOWING_QUARTZ */ g_signal_connect_object (gui_config, "notify::single-window-mode", G_CALLBACK (gui_single_window_mode_notify), ui_configurer, 0); g_signal_connect_object (gui_config, "notify::tearoff-menus", G_CALLBACK (gui_tearoff_menus_notify), image_ui_manager, 0); g_signal_connect (image_ui_manager, "show-tooltip", G_CALLBACK (gui_menu_show_tooltip), gimp); g_signal_connect (image_ui_manager, "hide-tooltip", G_CALLBACK (gui_menu_hide_tooltip), gimp); gimp_devices_restore (gimp); gimp_controllers_restore (gimp, image_ui_manager); if (status_callback == splash_update) splash_destroy (); color_history_restore (gimp); if (gimp_get_show_gui (gimp)) { GimpDisplayShell *shell; /* create the empty display */ display = GIMP_DISPLAY (gimp_create_display (gimp, NULL, GIMP_UNIT_PIXEL, 1.0)); shell = gimp_display_get_shell (display); if (gui_config->restore_session) session_restore (gimp); /* move keyboard focus to the display */ gtk_window_present (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (shell)))); } /* indicate that the application has finished loading */ gdk_notify_startup_complete (); }
static void gui_restore_after_callback (Gimp *gimp, GimpInitStatusFunc status_callback) { GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (gimp->config); GimpDisplay *display; if (gimp->be_verbose) g_print ("INIT: %s\n", G_STRFUNC); gimp->message_handler = GIMP_MESSAGE_BOX; /* load the recent documents after gimp_real_restore() because we * need the mime-types implemented by plug-ins */ status_callback (NULL, _("Documents"), 0.9); gimp_recent_list_load (gimp); /* enable this to always have icons everywhere */ if (g_getenv ("GIMP_ICONS_LIKE_A_BOSS")) { GdkScreen *screen = gdk_screen_get_default (); g_object_set (G_OBJECT (gtk_settings_get_for_screen (screen)), "gtk-button-images", TRUE, "gtk-menu-images", TRUE, NULL); } if (gui_config->restore_accels) menus_restore (gimp); ui_configurer = g_object_new (GIMP_TYPE_UI_CONFIGURER, "gimp", gimp, NULL); image_ui_manager = gimp_menu_factory_manager_new (global_menu_factory, "<Image>", gimp, gui_config->tearoff_menus); gimp_ui_manager_update (image_ui_manager, gimp); gimp_action_history_init (gimp); #ifdef GDK_WINDOWING_QUARTZ { GtkosxApplication *osx_app; GtkWidget *menu; GtkWidget *item; osx_app = gtkosx_application_get (); menu = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager), "/image-menubar"); if (GTK_IS_MENU_ITEM (menu)) menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu)); gtkosx_application_set_menu_bar (osx_app, GTK_MENU_SHELL (menu)); gtkosx_application_set_use_quartz_accelerators (osx_app, FALSE); gui_add_to_app_menu (image_ui_manager, osx_app, "/image-menubar/Help/dialogs-about", 0); gui_add_to_app_menu (image_ui_manager, osx_app, "/image-menubar/Help/dialogs-search-action", 1); #define PREFERENCES "/image-menubar/Edit/Preferences/" gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-preferences", 3); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-input-devices", 4); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-keyboard-shortcuts", 5); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-module-dialog", 6); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "plug-in-unit-editor", 7); #undef PREFERENCES item = gtk_separator_menu_item_new (); gtkosx_application_insert_app_menu_item (osx_app, item, 8); item = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager), "/image-menubar/File/file-quit"); gtk_widget_hide (item); g_signal_connect (osx_app, "NSApplicationBlockTermination", G_CALLBACK (gui_quartz_quit_callback), image_ui_manager); gtkosx_application_ready (osx_app); } #endif /* GDK_WINDOWING_QUARTZ */ g_signal_connect_object (gui_config, "notify::single-window-mode", G_CALLBACK (gui_single_window_mode_notify), ui_configurer, 0); g_signal_connect_object (gui_config, "notify::tearoff-menus", G_CALLBACK (gui_tearoff_menus_notify), image_ui_manager, 0); g_signal_connect (image_ui_manager, "show-tooltip", G_CALLBACK (gui_menu_show_tooltip), gimp); g_signal_connect (image_ui_manager, "hide-tooltip", G_CALLBACK (gui_menu_hide_tooltip), gimp); gimp_devices_restore (gimp); gimp_controllers_restore (gimp, image_ui_manager); if (status_callback == splash_update) splash_destroy (); color_history_restore (gimp); if (gimp_get_show_gui (gimp)) { GimpDisplayShell *shell; GtkWidget *toplevel; /* create the empty display */ display = GIMP_DISPLAY (gimp_create_display (gimp, NULL, GIMP_UNIT_PIXEL, 1.0, G_OBJECT (initial_screen), initial_monitor)); shell = gimp_display_get_shell (display); if (gui_config->restore_session) session_restore (gimp, initial_screen, initial_monitor); /* move keyboard focus to the display */ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell)); gtk_window_present (GTK_WINDOW (toplevel)); } /* indicate that the application has finished loading */ gdk_notify_startup_complete (); /* clear startup monitor variables */ initial_screen = NULL; initial_monitor = -1; }
/* Program entrypoint */ int main(int argc, char *argv[]) { unsigned long tempqueuesize=0; char *fvalue = NULL; char *dvalue = NULL; int option,option_index; int pflag=0, bflag = 0, rflag=0; int cpu_thread_factor=0; int cnt; int hash_num_threads=0; struct option long_options[] = { {"plugin-info", 2, 0, 'P'}, {"plugin", 1, 0, 'p'}, {"session-info", 2, 0, 'S'}, {"session", 1, 0, 's'}, {"hashlist", 1, 0, 'f'}, {"brute", 2, 0, 'b'}, {"outfile", 1, 0, 'o'}, {"uncrackedfile", 1, 0, 'O'}, {"markov-info", 0, 0, 'M'}, {"markov", 1, 0, 'm'}, {"markov-threshold", 1, 0, 'n'}, {"markov-limit", 1, 0, 'N'}, {"rule", 1, 0, 'r'}, {"rule-print", 1, 0, 'R'}, {"help", 0, 0, 'h'}, {"cpu", 0, 0, 'c'}, {"fast-markov",0,0,'F'}, {"gpu-threads", 1, 0, 'G'}, {"cpu-threads", 1, 0, 'C'}, {"gpu-double", 0, 0, 'D'}, {"gpu-temp", 0, 0, 'T'}, {"gpu-platform", 0, 0, 't'}, {"add-opts", 0, 0, 'a'}, {"plugin-opts", 0, 0, 'A'}, {0, 0, 0, 0} }; /* initialize */ printf("\n"); hlog("Version %s\n", PACKAGE_VERSION); session_restore_flag = 0; hash_plugin_parse_hash = NULL; hash_plugin_check_hash = NULL; hash_list = NULL; cracked_list = NULL; attack_method = -1; markov_attack_init(); attack_method = attack_method_markov; OpenSSL_add_all_algorithms(); fast_markov = 0; cpuonly=0; hashgen_stdout_mode=0; cnt=0; out_cracked_file=NULL; out_uncracked_file=NULL; markovstat = NULL; attack_checkpoints=0; attack_avgspeed=0; additional_options=malloc(1); additional_options[0]=0; padditional_options=malloc(1); padditional_options[0]=0; /* Detect CPU features and setup optimized routines */ if (cpu_feat_setup() == hash_err) { elog("No x86 CPU found! %s\n",""); exit(1); } while ((argv[cnt])&&(cnt<MAXARGV)) { session_argv[cnt]=malloc(strlen(argv[cnt])+1); strcpy(session_argv[cnt],argv[cnt]); cnt++; } have_ocl=0; nwthreads=0; /* Init scheduler */ scheduler_init(); ocl_user_threads=0; ocl_gpu_double=0; ocl_gpu_tempthreshold=90; ocl_gpu_platform=100; interactive_mode=0; /* Set AMD OpenCL secret envvars */ //setenv("GPU_MAX_ALLOC_PERCENT","100",1); //setenv("GPU_USE_SYNC_OBJECTS","1",1); // Bug in AMD Catalyst 13.4 setenv("GPU_FLUSH_ON_EXECUTION","1",1); /* See if someone tried to pipe to stdin */ detect_pipe(); disable_term_linebuffer(); #ifndef HAVE_JSON_JSON_H wlog("This hashkill build has session save/restore support disabled. Please reconfigure with --with-json and rebuild\n%s",""); #endif /* now store the command line parameters to be used by sessions module */ attack_over = 0; ctrl_c_pressed=0; session_put_commandline(argv); /* install SIGINT handler */ signal(SIGINT, sigint_handler); signal(SIGTERM, sigint_handler); opterr = 0; while ((option = getopt_long(argc, argv, "p:f:d:P::b::t:T:S::s:o:O:N:n:M::m:hicFDG:C:a:T:r:RA:",long_options, &option_index)) != -1) switch (option) { case 'r': if (optarg) { hlog("Rule based attack, using rule:%s\n",optarg); attack_method = attack_method_rule; rflag=1; rule_file=alloca(1024); strcpy(rule_file,optarg); } else { usage(argv[0]); exit(EXIT_FAILURE); } rflag = 1; break; case 'R': hashgen_stdout_mode=1; break; case 'h': usage(argv[0]); exit(EXIT_SUCCESS); break; case 'G': ocl_user_threads = atoi(optarg); if (ocl_user_threads>8) ocl_user_threads = 0; break; case 'C': cpu_thread_factor = atoi(optarg); if ((cpu_thread_factor>256)||(cpu_thread_factor<1)) cpu_thread_factor=16; break; case 's': if (!optarg) { usage(argv[0]); exit(EXIT_FAILURE); } else { if (session_restore(optarg) == hash_err) exit(EXIT_FAILURE); pflag = 1; } break; case 'P': if (!optarg) (void)print_plugins_summary(DATADIR"/hashkill/plugins"); else print_plugin_detailed(optarg); exit(EXIT_SUCCESS); break; case 'a': free(padditional_options); padditional_options = malloc(strlen(optarg)+1); strcpy(padditional_options,optarg); process_addopts(optarg); break; case 'A': free(additional_options); additional_options = malloc(strlen(optarg)+1); strcpy(additional_options,optarg); break; case 'c': cpuonly = 1; break; case 'i': hlog("interactive mode turned on!%s\n",""); interactive_mode = 1; break; case 'F': fast_markov = 1; break; case 'T': ocl_gpu_tempthreshold=atoi(optarg); break; case 'b': if (optarg) { if (parse_bruteforce_args(optarg) == hash_err) { exit(EXIT_FAILURE); } } else { char *tempopt = NULL; tempopt = malloc(100); strcpy(tempopt,"1:8:lalphanum:"); if (parse_bruteforce_args(tempopt) == hash_err) { free(tempopt); exit(EXIT_FAILURE); } free(tempopt); hlog("Using 1:8:lalpha defaults. Use -b<params> (no whitespaces) to specify them%s\n",""); } bflag = 1; break; case 'm': if (optarg) { if (markov_load_statfile(optarg) == hash_err) { exit(EXIT_FAILURE); } else { markovstat = malloc(64); strcpy(markovstat,optarg); attack_method = attack_method_markov; } } else { usage(argv[0]); exit(EXIT_FAILURE); } break; case 'S': if (!optarg) (void)print_sessions_summary(); else print_session_detailed(optarg); exit(EXIT_SUCCESS); break; case 'p': set_current_plugin(optarg); if (load_plugin()==hash_err) { elog("Cannot load plugin (%s)\n",optarg); exit(EXIT_FAILURE); } pflag=1; break; case 'N': markov_max_len = atoi(optarg); break; case 'D': ocl_gpu_double = 1; //setenv("GPU_MAX_HEAP_SIZE", "196", 1); hlog("Using GPU double mode\n%s",""); break; case 'n': markov_threshold = atoi(optarg); break; case 't': ocl_gpu_platform = atoi(optarg); break; case 'M': markov_print_statfiles(); exit(EXIT_SUCCESS); break; case 'f': fvalue = optarg; break; case 'd': dvalue = optarg; break; case 'o': out_cracked_file=malloc(strlen(optarg)+1); strcpy(out_cracked_file,optarg); break; case 'O': out_uncracked_file=malloc(strlen(optarg)+1); strcpy(out_uncracked_file,optarg); break; case '?': if ((optopt == 'f') || (optopt == 'P') || (optopt == 'd')) { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } default: break; } /* First check if out_cracked_file and out_uncracked_file are good */ if (out_cracked_file) if (hash_err == check_out_file(out_cracked_file)) exit(1); if (out_uncracked_file) if (hash_err == check_out_file(out_uncracked_file)) exit(1); if (fvalue) { strncpy(hashlist_file,fvalue,254); hashlist_file[254] = 0; if (pflag==0) { if (detect_plugin(DATADIR"/hashkill/plugins",hashlist_file,NULL) == hash_err) { elog("Cannot detect hash type%s\n",""); exit(EXIT_FAILURE); } } (void)load_hashes_file(fvalue); } /* Do we have argument (hash)? */ if (argv[optind]) { if (pflag==0) { if (detect_plugin(DATADIR"/hashkill/plugins",NULL,argv[optind])==hash_err) { elog("Cannot detect hash type%s\n",""); exit(EXIT_FAILURE); } } strncpy(hash_cmdline,argv[optind],HASHFILE_MAX_LINE_LENGTH); if (load_single_hash(hash_cmdline) == hash_err) { if (!fvalue) { elog("Cannot load hash: %s\n",argv[optind]); exit(EXIT_FAILURE); } } } if (strcmp(get_current_plugin(),"bitcoin")!=0) { /* Hashes num */ hashes_count = get_hashes_num(); /* Bruteforce? */ if ((bflag)&&(!dvalue)&&(!rflag)) { fast_markov = 0; // do not mess with the charset in the opencl code attack_method = attack_method_simple_bruteforce; } /* sl3 plugin is an exception: bruteforce only! */ if (strcmp(get_current_plugin(),"sl3")==0) { attack_method = attack_method_simple_bruteforce; } if ((attack_method != attack_method_simple_bruteforce) && ((attack_method != attack_method_markov)) && (attack_method != attack_method_rule)) { usage(argv[0]); exit(EXIT_FAILURE); } /* threads sizing */ if ((get_hashes_num() == 0)&&(hashgen_stdout_mode==0)) { elog("No hashes loaded!%s (try --help)\n",""); exit(EXIT_FAILURE); } if (cpu_thread_factor==0) { hash_num_threads = hash_num_cpu(); } else hash_num_threads = cpu_thread_factor; } else attack_method = attack_method_simple_bruteforce; time1=time(NULL); /* CPU optimize single hacks */ if (strcmp(get_current_plugin(),"md5")==0) { if ((attack_method==attack_method_simple_bruteforce)&&(bruteforce_end>7)) cpu_optimize_single=2; else if ((attack_method==attack_method_markov)&&(markov_max_len>7)) cpu_optimize_single=2; } if ((hash_list)&&(hash_list->next)) cpu_optimize_single=0; have_ocl = initialize_opencl(); if ((have_ocl==hash_ok)&&(cpuonly==0)) have_ocl = ocl_get_device(); if (cpuonly==1) { wlog("GPU acceleration available, but -c option was provided. Running on CPUs would likely be slower.\n%s",""); } /* Markov? */ if (attack_method == attack_method_markov) { if (!markovstat) { markov_load_statfile("rockyou"); markovstat = malloc(64); strcpy(markovstat,"rockyou"); } if ((cpuonly==0) && (have_ocl == hash_ok)) { if ((ocl_markov() != hash_ok) && (attack_over==0)) { if (tempqueuesize > HASHKILL_MAXQUEUESIZE) tempqueuesize = HASHKILL_MAXQUEUESIZE; (void)main_thread_markov(hash_num_threads); } } else main_thread_markov(hash_num_threads); } /* Rule-based */ if (attack_method == attack_method_rule) { if (hash_err==rule_preprocess(rule_file)) {exit(1);} if ((cpuonly==0) && (have_ocl == hash_ok)) { if ((ocl_rule() != hash_ok) && (attack_over==0)) { nwthreads = hash_num_threads; if (tempqueuesize > HASHKILL_MAXQUEUESIZE) tempqueuesize = HASHKILL_MAXQUEUESIZE; main_thread_rule(hash_num_threads); } } else main_thread_rule(hash_num_threads); } /* Bruteforce? */ if (attack_method == attack_method_simple_bruteforce) { if (strcmp(get_current_plugin(),"bitcoin")!=0) hlog("Bruteforce charset (size=%d): %s\n",strlen(bruteforce_charset),bruteforce_charset); if ((have_ocl == hash_ok) && (cpuonly==0)) { if ( (ocl_bruteforce() != hash_ok) && (attack_over==0)) { if (tempqueuesize > HASHKILL_MAXQUEUESIZE) tempqueuesize = HASHKILL_MAXQUEUESIZE; (void)main_thread_bruteforce(hash_num_threads); } } else main_thread_bruteforce(hash_num_threads); } /* We delete session file ONLY when attack is over */ if (ctrl_c_pressed==0) { session_unlink_file(); if (have_ocl==hash_ok) session_unlink_file_ocl(); } if (get_cracked_num() > 0) print_cracked_list(); if (out_cracked_file) { print_cracked_list_to_file(out_cracked_file); } if ((hash_plugin_is_special)&&(hash_plugin_is_special()==0)) { if (out_uncracked_file) { print_uncracked_list_to_file(out_uncracked_file); } } time2=time(NULL); printf("\n"); hlog("Attack took %u seconds.\n",(unsigned int)(time2-time1)); hlog("Bye bye :)\n\n%s",""); // thread_attack_cleanup(); // cleanup_lists(); return 0; }