Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't rewrite .wpc file if session was not modified #375

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
#define P1_SIZE 10000
#define P2_SIZE 1000

#define SESSION_SIGNATURE_LEN 32

#define EAPOL_START_MAX_TRIES 10
#define WARN_FAILURE_COUNT 10

Expand Down
2 changes: 2 additions & 0 deletions src/globule.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ struct globals

char *session; /* Path to session file */

char session_signature[SESSION_SIGNATURE_LEN]; /* buffer for session signature value */

char *ssid; /* Target SSID */

char *iface; /* Interface name */
Expand Down
21 changes: 21 additions & 0 deletions src/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ static void gen_sessionfile_name(const char* bssid, char* outbuf) {
#endif
}

static void make_session_signature(char* out)
{
snprintf(out, SESSION_SIGNATURE_LEN, "%s%s%d%04d%03d",
get_p1(get_p1_index()), get_p2(get_p2_index()), get_key_status(), get_p1_index(), get_p2_index());
}

int restore_session()
{
struct stat wpstat = { 0 };
Expand Down Expand Up @@ -167,6 +173,9 @@ int restore_session()
cprintf(INFO, "[+] Restored previous session\n");
}

/* set session signature */
make_session_signature(globule->session_signature);

/* If the specified pin was used, then insert into current index of p1 and p2 array */
if (!get_pin_string_mode() && get_static_p1()) {
i = jump_p1_queue(get_static_p1());
Expand Down Expand Up @@ -202,6 +211,14 @@ int save_session()
return 0;
}

/* Don't rewrite .wpc file if session was not modified */
char session_signature[SESSION_SIGNATURE_LEN];
make_session_signature(session_signature);
if (strcmp(globule->session_signature, session_signature) == 0) {
cprintf(VERBOSE, "[+] The session has already been saved.\n");
return 0;
}

/*
* If a session file was explicitly specified, use that; else, check for the
* default session file name for this BSSID.
Expand Down Expand Up @@ -241,6 +258,10 @@ int save_session()
for(i=0; i<P2_SIZE; i++) fprintf(fp, "%s\n", get_p2(i));

fclose(fp);

/* set session signature */
strcpy(globule->session_signature, session_signature);

return 1;
}

Expand Down