restore_session: remove yet one more indent layer

This commit is contained in:
rofl0r 2019-05-12 23:06:39 +01:00
parent 113f12fe26
commit 9db8bb69f6
1 changed files with 106 additions and 109 deletions

View File

@ -118,139 +118,136 @@ int restore_session()
/* Get the key1 index value */
if(fgets(line, MAX_LINE_SIZE, fp) == NULL) goto fout;
set_p1_index(atoi(line));
memset(line, 0, MAX_LINE_SIZE);
/* Get the key2 index value */
if(fgets(line, MAX_LINE_SIZE, fp) == NULL) goto fout;
set_p2_index(atoi(line));
memset(line, 0, MAX_LINE_SIZE);
/* Get the key status value */
if(fgets(line, MAX_LINE_SIZE, fp) != NULL)
{
set_p2_index(atoi(line));
memset(line, 0, MAX_LINE_SIZE);
set_key_status(atoi(line));
/* Get the key status value */
if(fgets(line, MAX_LINE_SIZE, fp) != NULL)
/* Read in all p1 values */
add = p1_tried = 0;
for(i=0; i<P1_SIZE; i++)
{
set_key_status(atoi(line));
memset(temp, 0, P1_READ_LEN);
/* Read in all p1 values */
add = p1_tried = 0;
for(i=0; i<P1_SIZE; i++)
if(fgets(temp, P1_READ_LEN, fp) != NULL)
{
memset(temp, 0, P1_READ_LEN);
if(fgets(temp, P1_READ_LEN, fp) != NULL)
/* NULL out the new line character */
temp[P1_STR_LEN] = 0;
/* check has first half pin was specified and yet is KEY1_WIP */
if (get_static_p1() && get_key_status() < KEY2_WIP)
{
/* NULL out the new line character */
temp[P1_STR_LEN] = 0;
/* check has first half pin was specified and yet is KEY1_WIP */
if (get_static_p1() && get_key_status() < KEY2_WIP)
if (i < get_p1_index())
{
if (i < get_p1_index())
/* Check the first half has been already tried */
if (strcmp(get_static_p1(), temp) == 0)
{
/* Check the first half has been already tried */
if (strcmp(get_static_p1(), temp) == 0)
{
p1_tried = 1;
}
}
else if (i == get_p1_index())
{
/* Check current index of first half is the specified pin
* Yes: do nothing
* No: insert into current index and set add to 1
*/
if (!p1_tried && strcmp(get_static_p1(), temp) != 0)
{
set_p1(i, get_static_p1());
add = 1;
}
}
else
{
/* Check former index of first half
* Yes: set add to 0 and continue to next loop;
* No: do nothing
*/
if (strcmp(get_static_p1(), temp) == 0)
{
add = 0;
continue;
}
p1_tried = 1;
}
}
set_p1(i+add, temp);
}
}
/* Read in all p2 values */
add = p2_tried = 0;
for(i=0; i<P2_SIZE; i++)
{
memset(temp, 0, P1_READ_LEN);
if(fgets(temp, P2_READ_LEN, fp) != NULL)
{
/* NULL out the new line character */
temp[P2_STR_LEN] = 0;
/* check has second half pin was specified and yet not KEY_DONE */
if (get_static_p2() && get_key_status() != KEY_DONE)
else if (i == get_p1_index())
{
if (i < get_p2_index())
/* Check current index of first half is the specified pin
* Yes: do nothing
* No: insert into current index and set add to 1
*/
if (!p1_tried && strcmp(get_static_p1(), temp) != 0)
{
/* Check the second half has been already tried */
if (strcmp(get_static_p2(), temp) == 0)
{
p2_tried = 1;
}
}
else if (i == get_p2_index())
{
/* Check current index of second half is the specified pin
* Yes: do nothing
* No: insert into current index and set add to 1
*/
if (!p2_tried && strcmp(get_static_p2(), temp) != 0)
{
set_p2(i, get_static_p2());
add = 1;
}
}
else
{
/* Check former index of second half
* Yes: set add to 0 and continue to next loop;
* No: do nothing
*/
if (strcmp(get_static_p2(), temp) == 0)
{
add = 0;
continue;
}
set_p1(i, get_static_p1());
add = 1;
}
}
else
{
/* Check former index of first half
* Yes: set add to 0 and continue to next loop;
* No: do nothing
*/
if (strcmp(get_static_p1(), temp) == 0)
{
add = 0;
continue;
}
}
set_p2(i+add, temp);
}
set_p1(i+add, temp);
}
}
ret_val = 1;
/* Read in all p2 values */
add = p2_tried = 0;
for(i=0; i<P2_SIZE; i++)
{
memset(temp, 0, P1_READ_LEN);
/* Print warning message if the specified first or second half PIN was ignored */
if (get_static_p1())
if(fgets(temp, P2_READ_LEN, fp) != NULL)
{
/* Check the specified 4/8 digit WPS PIN has been already tried */
if (p1_tried || p2_tried)
/* NULL out the new line character */
temp[P2_STR_LEN] = 0;
/* check has second half pin was specified and yet not KEY_DONE */
if (get_static_p2() && get_key_status() != KEY_DONE)
{
ret_val = -1;
}
/* Print message what first half pin ignored if former key status >= KEY2_WIP */
if (get_key_status() >= KEY2_WIP && strcmp(get_static_p1(), get_p1(get_p1_index())) != 0)
{
cprintf(INFO, "[!] First half PIN ignored, it was cracked\n");
}
/* Print message what second half pin ignored if former key status == KEY_DONE */
if (get_key_status() == KEY_DONE && strcmp(get_static_p2(), get_p2(get_p2_index())) != 0)
{
cprintf(INFO, "[!] Second half PIN ignored, it was cracked\n");
if (i < get_p2_index())
{
/* Check the second half has been already tried */
if (strcmp(get_static_p2(), temp) == 0)
{
p2_tried = 1;
}
}
else if (i == get_p2_index())
{
/* Check current index of second half is the specified pin
* Yes: do nothing
* No: insert into current index and set add to 1
*/
if (!p2_tried && strcmp(get_static_p2(), temp) != 0)
{
set_p2(i, get_static_p2());
add = 1;
}
}
else
{
/* Check former index of second half
* Yes: set add to 0 and continue to next loop;
* No: do nothing
*/
if (strcmp(get_static_p2(), temp) == 0)
{
add = 0;
continue;
}
}
}
set_p2(i+add, temp);
}
}
ret_val = 1;
/* Print warning message if the specified first or second half PIN was ignored */
if (get_static_p1())
{
/* Check the specified 4/8 digit WPS PIN has been already tried */
if (p1_tried || p2_tried)
{
ret_val = -1;
}
/* Print message what first half pin ignored if former key status >= KEY2_WIP */
if (get_key_status() >= KEY2_WIP && strcmp(get_static_p1(), get_p1(get_p1_index())) != 0)
{
cprintf(INFO, "[!] First half PIN ignored, it was cracked\n");
}
/* Print message what second half pin ignored if former key status == KEY_DONE */
if (get_key_status() == KEY_DONE && strcmp(get_static_p2(), get_p2(get_p2_index())) != 0)
{
cprintf(INFO, "[!] Second half PIN ignored, it was cracked\n");
}
}
}