1
mirror of https://github.com/rapid7/metasploit-payloads synced 2024-12-21 05:35:54 +01:00

Land #32, switch FILE_HASH to use RAW, strings to use UTF-8

This commit is contained in:
Brent Cook 2015-05-15 09:58:38 -05:00
commit 3ba13e719a
3 changed files with 6 additions and 5 deletions

View File

@ -84,7 +84,7 @@ public class TLVPacket {
value = data;
} else if ((type & TLV_META_TYPE_STRING) != 0) {
in.readFully(data);
String string = new String(data, "ISO-8859-1"); // better safe than sorry
String string = new String(data, "UTF-8");
if (!string.endsWith("\0"))
throw new IOException("C string is not 0 terminated: " + string);
string = string.substring(0, string.length() - 1);
@ -281,7 +281,7 @@ public class TLVPacket {
private static void write(DataOutputStream out, int type, Object value) throws IOException {
byte[] data;
if ((type & TLV_META_TYPE_STRING) != 0) {
data = ((String) value + "\0").getBytes("ISO-8859-1");
data = ((String) value + "\0").getBytes("UTF-8");
} else if ((type & TLV_META_TYPE_QWORD) != 0) {
out.writeInt(16);
out.writeInt(type);

View File

@ -57,6 +57,7 @@ public interface TLVType {
public static final int TLV_TYPE_FILE_NAME = TLVPacket.TLV_META_TYPE_STRING | 1201;
public static final int TLV_TYPE_FILE_PATH = TLVPacket.TLV_META_TYPE_STRING | 1202;
public static final int TLV_TYPE_FILE_MODE = TLVPacket.TLV_META_TYPE_STRING | 1203;
public static final int TLV_TYPE_FILE_HASH = TLVPacket.TLV_META_TYPE_RAW | 1206;
public static final int TLV_TYPE_STAT_BUF = TLVPacket.TLV_META_TYPE_COMPLEX | 1220;
// Net

View File

@ -20,7 +20,7 @@ public abstract class HashCommand implements Command {
while ((len = in.read(buf)) != -1) {
md.update(buf, 0, len);
}
response.add(TLVType.TLV_TYPE_FILE_NAME, new String(md.digest(), "ISO-8859-1"));
response.add(TLVType.TLV_TYPE_FILE_HASH, md.digest());
return ERROR_SUCCESS;
}
}