Skip to content

Commit 01d790e

Browse files
committed
Land rapid7#1748, fix for java meterp network prefixes
[Closes rapid7#1748]
2 parents 2b4144f + a7effaf commit 01d790e

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

data/meterpreter/ext_server_stdapi.jar

100755100644
49 Bytes
Binary file not shown.

data/meterpreter/meterpreter.jar

100755100644
File mode changed.

external/source/javapayload/meterpreter/stdapi/src/main/java/com/metasploit/meterpreter/stdapi/stdapi_net_config_get_interfaces_V1_6.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ public Address[] getAddresses(NetworkInterface iface) throws IOException {
2424
if (ip == null)
2525
continue;
2626
int prefixLength = addr.getNetworkPrefixLength();
27+
if (prefixLength == -1 && ip.length == 4) {
28+
// guess netmask by network class...
29+
if ((ip[0] & 0xff) < 0x80) {
30+
prefixLength = 8;
31+
} else if ((ip[0] & 0xff) < 0xc0) {
32+
prefixLength = 16;
33+
} else {
34+
prefixLength = 24;
35+
}
36+
}
2737
byte[] scopeId = null;
2838
if (addr.getAddress() instanceof Inet6Address) {
2939
ByteBuffer bb = ByteBuffer.allocate(4);

0 commit comments

Comments
 (0)