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

BSSIDs not properly recognized #7

Open
strasharo opened this issue Apr 2, 2017 · 2 comments
Open

BSSIDs not properly recognized #7

strasharo opened this issue Apr 2, 2017 · 2 comments

Comments

@strasharo
Copy link
Contributor

Hello. I deployed the latest dwpa on Debian Jessie with 7.0.17-1~dotdeb+8.1. For some reason all of the uploaded networks appear to be listed with BSSID 00:00:7f:ff:ff:ff , which prevents them from being properly cracked by the workers. I checked manually the handshakes in the CAP directory and they appear to be fine. Prior upgrading to PHP7 I tried with the stock PHP5 shipped with Jessie - for the first uploaded network in the database the BSSID was shown as all zeroes and for the others only the second half of the bssid was correct while the first one was all zeroes.

@strasharo
Copy link
Contributor Author

Turns out the issue is that I'm running on 32 bit install and the integer size is not sufficient to hold the value from hex2dec, so it converts it to float:
https://github.com/RealEnder/dwpa/blob/master/web/common.php#L393

I assembled a quick fix for it using some functions from bcmath (I'm not experienced with php, so there's probably a better approach to do this:

<?php

function bchexdec($hex)
{
    $dec = 0;
    $len = strlen($hex);
    for ($i = 1; $i <= $len; $i++) {
        $dec = bcadd($dec, bcmul(strval(hexdec($hex[$i - 1])), bcpow('16', strval($len - $i))));
    }
    return $dec;
}

function bcdechex($dec) {
        $last = bcmod($dec, 16);
        $remain = bcdiv(bcsub($dec, $last), 16);

        if($remain == 0) {
            return dechex($last);
        } else {
            return bcdechex($remain).dechex($last);
        }
}

function mac2long($mac) {
    return hexdec(str_replace(':', '', $mac));
}

function long2mac($lmac) {
    $pmac = str_pad(dechex($lmac), 12, '0', STR_PAD_LEFT);
    return "{$pmac[0]}{$pmac[1]}:{$pmac[2]}{$pmac[3]}:{$pmac[4]}{$pmac[5]}:{$pmac[6]}{$pmac[7]}:{$pmac[8]}{$pmac[9]}:{$pmac[10]}{$pmac[11]}";
}


function mac2longfix($mac) {
    return bchexdec(str_replace(':', '', $mac));
}

function long2macfix($lmac) {
    $pmac = str_pad(bcdechex($lmac), 12, '0', STR_PAD_LEFT);
    return "{$pmac[0]}{$pmac[1]}:{$pmac[2]}{$pmac[3]}:{$pmac[4]}{$pmac[5]}:{$pmac[6]}{$pmac[7]}:{$pmac[8]}{$pmac[9]}:{$pmac[10]}{$pmac[11]}";
}


$longmac = mac2long("84:16:93:EB:B0:8C");
$hexmac = long2mac($longmac);
$longmacfix = mac2longfix("84:16:93:EB:B0:8C");
$hexmacfix = long2macfix($longmacfix);

echo "Default functs\n";
echo "$longmac\n";
echo "$hexmac\n";
echo "With BCmath\n";
echo "$longmacfix\n";
echo "$hexmacfix\n";
?>

And the output on a 32bit platform:

root@dwpa:~# php test.php 
Default functs
1.4523250584385E+14
00:00:93:eb:b0:8c
With BCmath
145232505843852
84:16:93:eb:b0:8c
root@dwpa:~# 

@RealEnder
Copy link
Owner

Haven't seen 32bit srv install in years :)
Looks like this is the case here. Will try to find out a better way, since I don't want to pull additional deps just for that. Also search function has some logic for partial BSSID lookup, which have to be checked as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants