Fix incorrect network prefix in Java Meterpreter

Apparently, getNetworkPrefixLength can return -1, which confuses the Ruby
side. Therefore fall back to guessing the prefix in this case, as we do it
for Java <= 1.6.
This commit is contained in:
Michael Schierl 2013-04-20 23:06:38 +02:00
parent 1365dfe68c
commit e98d510deb
1 changed files with 10 additions and 0 deletions

View File

@ -24,6 +24,16 @@ public class stdapi_net_config_get_interfaces_V1_6 extends stdapi_net_config_get
if (ip == null)
continue;
int prefixLength = addr.getNetworkPrefixLength();
if (prefixLength == -1 && ip.length == 4) {
// guess netmask by network class...
if ((ip[0] & 0xff) < 0x80) {
prefixLength = 8;
} else if ((ip[0] & 0xff) < 0xc0) {
prefixLength = 16;
} else {
prefixLength = 24;
}
}
byte[] scopeId = null;
if (addr.getAddress() instanceof Inet6Address) {
ByteBuffer bb = ByteBuffer.allocate(4);