⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 callbacks.c

📁 一个功能强大的开源弱口令猜解程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * This file handles all that needs to be done... * Some stuff is stolen from gcombust since I never used pipes... ok, i  * only used them in reallife :) */#ifdef HAVE_CONFIG_H#  include <config.h>#endif#include <gtk/gtk.h>#include "callbacks.h"#include "interface.h"#include "support.h"#include <sys/types.h>#include <sys/wait.h>#include <sys/time.h>#include <sys/types.h>#include <sys/stat.h>#include <signal.h>#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <fcntl.h>#include <string.h>int hydra_pid = 0;char port[10];char tasks[10];char timeout[10];char smbntparm[4];char snmpparm[4];char sapr3id[4];char passLoginNull[4]; #define BUF_S 1024void hydra_select_file(GtkEntry *widget, char *text) {#ifdef GTK_TYPE_FILE_CHOOSER	GtkWidget *dialog;	char *filename;	dialog = gtk_file_chooser_dialog_new (text, (GtkWindow *) wndMain, GTK_FILE_CHOOSER_ACTION_OPEN,					GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL,					GTK_RESPONSE_CANCEL, NULL);	if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {		filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));		gtk_entry_set_text(widget, filename);		g_free (filename);	}	gtk_widget_destroy (dialog);#endif}int hydra_get_options(char *options[]) {	/* get the stuff from the gtk entries... */	int i = 1;	GtkWidget *widget;	GtkWidget *widget2;	int j;	gchar *tmp;	GString *a;	options[0] = HYDRA_BIN;	/* get the target, or target list */	widget = lookup_widget(GTK_WIDGET(wndMain), "radioTarget1");	if ( gtk_toggle_button_get_active((GtkToggleButton *) widget) ){			widget = lookup_widget(GTK_WIDGET(wndMain), "entTarget");		options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget);	} else {		options[i++] = "-M";		widget = lookup_widget(GTK_WIDGET(wndMain), "entTargetFile");		options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget);	}	/* get the service */	widget = lookup_widget(GTK_WIDGET(wndMain), "entProtocol");	options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget);		/* get the port */	widget = lookup_widget(GTK_WIDGET(wndMain), "spnPort");	j = gtk_spin_button_get_value_as_int((GtkSpinButton *) widget);	if ( j != 0 ){		snprintf(port, 10, "%d", j);		options[i++] = "-s";		options[i++] = port;	}	/* use SSL? */	widget = lookup_widget(GTK_WIDGET(wndMain), "chkSSL");		if ( gtk_toggle_button_get_active((GtkToggleButton *) widget) ){		options[i++] = "-S";	}	/* be verbose? */	widget = lookup_widget(GTK_WIDGET(wndMain), "chkVerbose");		if ( gtk_toggle_button_get_active((GtkToggleButton *) widget) ){		options[i++] = "-v";	}	/* show attempts */	widget = lookup_widget(GTK_WIDGET(wndMain), "chkAttempts");		if ( gtk_toggle_button_get_active((GtkToggleButton *) widget) ){		options[i++] = "-V";	}	/* debug mode? */	widget = lookup_widget(GTK_WIDGET(wndMain), "chkDebug");		if ( gtk_toggle_button_get_active((GtkToggleButton *) widget) ){		options[i++] = "-d";	}		/* use colon seperated list? */	widget = lookup_widget(GTK_WIDGET(wndMain), "chkColon");		if ( gtk_toggle_button_get_active((GtkToggleButton *) widget) ){			options[i++] = "-C";		widget = lookup_widget(GTK_WIDGET(wndMain), "entColonFile");		options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget);	} else {		/* get the username, or username list */		widget = lookup_widget(GTK_WIDGET(wndMain), "radioUsername1");		if ( gtk_toggle_button_get_active((GtkToggleButton *) widget) ){				options[i++] = "-l";			widget = lookup_widget(GTK_WIDGET(wndMain), "entUsername");			options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget);		} else {			options[i++] = "-L";			widget = lookup_widget(GTK_WIDGET(wndMain), "entUsernameFile");			options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget);		}		/* get the pass, or pass list */		widget = lookup_widget(GTK_WIDGET(wndMain), "radioPass1");		if ( gtk_toggle_button_get_active((GtkToggleButton *) widget) ){				options[i++] = "-p";			widget = lookup_widget(GTK_WIDGET(wndMain), "entPass");			options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget);		} else {			options[i++] = "-P";			widget = lookup_widget(GTK_WIDGET(wndMain), "entPassFile");			options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget);		}	}	/* empty passes / login as pass? */	memset(passLoginNull, 0, 4);	widget = lookup_widget(GTK_WIDGET(wndMain), "chkPassNull");	if ( gtk_toggle_button_get_active((GtkToggleButton *) widget) ){		passLoginNull[0] = 'n';	}	widget = lookup_widget(GTK_WIDGET(wndMain), "chkPassLogin");	if ( gtk_toggle_button_get_active((GtkToggleButton *) widget) ){		if ( passLoginNull[0] == 0 ) {			passLoginNull[0] = 's';		} else {			passLoginNull[1] = 's';		}	}	if ( passLoginNull[0] != 0 ) {		options[i++] = "-e";		options[i++] = passLoginNull;		}		/* #of tasks */	widget = lookup_widget(GTK_WIDGET(wndMain), "spnTasks");	j = gtk_spin_button_get_value_as_int((GtkSpinButton *) widget);	if ( j != 40 ){		snprintf(tasks, 10, "%d", j);		options[i++] = "-t";		options[i++] = tasks;	}	/* timeout */	widget = lookup_widget(GTK_WIDGET(wndMain), "spnTimeout");	j = gtk_spin_button_get_value_as_int((GtkSpinButton *) widget);	if ( j != 30 ){		snprintf(timeout, 10, "%d", j);		options[i++] = "-w";		options[i++] = timeout;	}	/* exit after first found pair? */	widget = lookup_widget(GTK_WIDGET(wndMain), "chkExitf");	if ( gtk_toggle_button_get_active((GtkToggleButton *) widget) ){		options[i++] = "-f";	}	/* get additional parameters */	widget = lookup_widget(GTK_WIDGET(wndMain), "entProtocol");	tmp = (char *) gtk_entry_get_text((GtkEntry *) widget);		if ( !strcmp(tmp, "http") || !strcmp(tmp, "https")) {		options[i++] = "-m";		widget = lookup_widget(GTK_WIDGET(wndMain), "entHTTPURL");		options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget);	} else if ( !strcmp(tmp, "cisco-enable")) {		options[i++] = "-m";		widget = lookup_widget(GTK_WIDGET(wndMain), "entCiscoPass");		options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget);	} else if ( !strcmp(tmp, "ldap")) {		options[i++] = "-m";		widget = lookup_widget(GTK_WIDGET(wndMain), "entLDAPDN");		options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget);	} else if ( !strcmp(tmp, "smbnt")) {		memset(smbntparm, 0, 4);		widget = lookup_widget(GTK_WIDGET(wndMain), "chkDomain");		widget2 = lookup_widget(GTK_WIDGET(wndMain), "chkLocal");		options[i++] = "-m";		smbntparm[0] = 'B';		if ( gtk_toggle_button_get_active((GtkToggleButton *) widget)) {			smbntparm[0] = 'D';		}		if ( gtk_toggle_button_get_active((GtkToggleButton *) widget2)) {			if ( gtk_toggle_button_get_active((GtkToggleButton *) widget)) {				smbntparm[0] = 'B';			} else {				smbntparm[0] = 'L';			}		}		widget = lookup_widget(GTK_WIDGET(wndMain), "chkNTLM");		if ( gtk_toggle_button_get_active((GtkToggleButton *) widget)) {			smbntparm[1] = 'H';		}		options[i++] = smbntparm;	} else if (!strcmp(tmp, "sapr3")) {		widget = lookup_widget(GTK_WIDGET(wndMain), "spnSAPR3");		j = gtk_spin_button_get_value_as_int((GtkSpinButton *) widget);		snprintf(sapr3id, 10, "%d", j);		options[i++] = "-m";		options[i++] = sapr3id;			} else if (!strcmp(tmp, "http-proxy")) {		widget = lookup_widget(GTK_WIDGET(wndMain), "entHTTPProxyURL");		options[i++] = "-m";		options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget);	} else if (!strcmp(tmp, "cvs")) {		widget = lookup_widget(GTK_WIDGET(wndMain), "entCVS");		options[i++] = "-m";		options[i++] = (char *) gtk_entry_get_text((GtkEntry *) widget);	} else if (!strcmp(tmp, "snmp")) {		memset(snmpparm, 0, 4);		widget = lookup_widget(GTK_WIDGET(wndMain), "radioSNMPVer1");		if ( gtk_toggle_button_get_active((GtkToggleButton *) widget)) {			snmpparm[0] = '1';		} else {			snmpparm[0] = '2';		}		widget = lookup_widget(GTK_WIDGET(wndMain), "radioSNMPWrite");		if ( gtk_toggle_button_get_active((GtkToggleButton *) widget)) {			snmpparm[0] = 'w';		} else {			snmpparm[0] = 'r';		}		options[i++] = "-m";		options[i++] = snmpparm;	}	/* clean up proxy settings */	unsetenv("HYDRA_PROXY_HTTP");	unsetenv("HYDRA_PROXY_CONNECT");	unsetenv("HYDRA_PROXY_AUTH");	/* proxy support */	widget = lookup_widget(GTK_WIDGET(wndMain), "radioProxy");	if ( !gtk_toggle_button_get_active((GtkToggleButton *) widget)) {		widget2 = lookup_widget(GTK_WIDGET(wndMain), "entHTTPProxy");		widget = lookup_widget(GTK_WIDGET(wndMain), "radioProxy2");		/* which variable do we set? */		if ((!strcmp(tmp, "http")) && ( gtk_toggle_button_get_active((GtkToggleButton *) widget))) {			setenv("HYDRA_PROXY_HTTP", gtk_entry_get_text((GtkEntry *) widget2), 1);		} else {			setenv("HYDRA_PROXY_CONNECT", (char *) gtk_entry_get_text((GtkEntry *) widget2), 1);		}		/* do we need to provide user and pass? */		widget = lookup_widget(GTK_WIDGET(wndMain), "chkProxyAuth");		if ( gtk_toggle_button_get_active((GtkToggleButton *) widget)) {			widget = lookup_widget(GTK_WIDGET(wndMain), "entProxyUser");			widget2 = lookup_widget(GTK_WIDGET(wndMain), "entProxyPass");			a = g_string_new((gchar *) gtk_entry_get_text((GtkEntry *) widget));			a = g_string_append_c(a, ':');			a = g_string_append(a, gtk_entry_get_text((GtkEntry *) widget2));			setenv("HYDRA_PROXY_AUTH", a->str, 1);			(void) g_string_free(a, TRUE);		}	}			options[i] = NULL;	return i;}intupdate_statusbar(){	int i,j;	char *options[128];	guint context_id;	GtkStatusbar *statusbar;	extern guint message_id;	GString *statustext = g_string_new("hydra ");	i = hydra_get_options(options);	for (j = 1; j < i; j++){		statustext = g_string_append(statustext, options[j]);		statustext = g_string_append_c(statustext, ' ');	}	statusbar = (GtkStatusbar *) lookup_widget(GTK_WIDGET(wndMain), "statusbar");	context_id =  gtk_statusbar_get_context_id(statusbar, "status");	/* an old message in stack? */	if ( message_id != 0 ){		gtk_statusbar_remove(statusbar, context_id, message_id);			}	message_id = gtk_statusbar_push(statusbar, context_id, (gchar *) statustext->str);	(void) g_string_free(statustext, TRUE);	return TRUE;}int read_into(int fd) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -