Skip to content

Commit 6162c3c

Browse files
committed
[#831] allow creation of Endpoint with null HW address
fixes #831
1 parent f24da27 commit 6162c3c

2 files changed

Lines changed: 9 additions & 19 deletions

File tree

cSploit/src/main/java/org/csploit/android/net/Endpoint.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
package org.csploit.android.net;
2020

2121
import android.support.annotation.NonNull;
22+
import android.support.annotation.Nullable;
23+
import org.csploit.android.core.System;
24+
import org.csploit.android.helpers.NetworkHelper;
2225

2326
import java.io.BufferedReader;
2427
import java.math.BigInteger;
2528
import java.net.InetAddress;
2629
import java.net.UnknownHostException;
2730
import java.util.Arrays;
2831

29-
import org.csploit.android.core.System;
30-
import org.csploit.android.helpers.NetworkHelper;
31-
3232
public class Endpoint implements Comparable<Endpoint>
3333
{
3434
private InetAddress mAddress = null;
@@ -57,15 +57,9 @@ public Endpoint(String address){
5757
this(address, null);
5858
}
5959

60-
public Endpoint(InetAddress address, byte[] hardware){
61-
try{
60+
public Endpoint(InetAddress address, @Nullable byte[] hardware){
6261
mAddress = address;
63-
mHardware = Arrays.copyOf(hardware, hardware.length);
64-
}
65-
catch(Exception e){
66-
System.errorLogging(e);
67-
mAddress = null;
68-
}
62+
mHardware = hardware != null ? Arrays.copyOf(hardware, hardware.length) : null;
6963
}
7064

7165
public Endpoint(String address, String hardware){

cSploit/src/main/java/org/csploit/android/net/Network.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,15 @@
2525
import android.net.wifi.WifiInfo;
2626
import android.net.wifi.WifiManager;
2727
import android.support.annotation.NonNull;
28+
import android.support.annotation.Nullable;
2829
import android.util.Patterns;
29-
3030
import org.apache.commons.net.util.SubnetUtils;
3131
import org.csploit.android.core.Logger;
3232
import org.csploit.android.core.System;
3333
import org.csploit.android.helpers.NetworkHelper;
3434

3535
import java.lang.reflect.Method;
36-
import java.net.InetAddress;
37-
import java.net.InterfaceAddress;
38-
import java.net.NetworkInterface;
39-
import java.net.NoRouteToHostException;
40-
import java.net.SocketException;
41-
import java.net.UnknownHostException;
36+
import java.net.*;
4237
import java.util.ArrayList;
4338
import java.util.Collections;
4439
import java.util.Enumeration;
@@ -339,9 +334,10 @@ public byte[] getGatewayHardware() {
339334
return Endpoint.parseMacAddress(mWifiInfo.getBSSID());
340335
}
341336

337+
@Nullable
342338
public byte[] getLocalHardware() {
343339
try {
344-
return mInterface.getHardwareAddress();
340+
return mInterface.getHardwareAddress(); //FIXME: #831
345341
} catch (SocketException e) {
346342
System.errorLogging(e);
347343
}

0 commit comments

Comments
 (0)