|
@@ -27,6 +27,8 @@ public final class SMB implements Protocol<ByteArray> {
|
|
*/
|
|
*/
|
|
private STATE state = STATE.NONE;
|
|
private STATE state = STATE.NONE;
|
|
|
|
|
|
|
|
+ private byte[] lastMessage;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public int getPort() {
|
|
public int getPort() {
|
|
return 445;
|
|
return 445;
|
|
@@ -41,8 +43,9 @@ public final class SMB implements Protocol<ByteArray> {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<ByteArray> processMessage(ByteArray message) {
|
|
public List<ByteArray> processMessage(ByteArray message) {
|
|
- byte[] primitiveByteArray = message.get();
|
|
|
|
- packet.newMsg(primitiveByteArray);
|
|
|
|
|
|
+ if(message != null)
|
|
|
|
+ lastMessage = message.get();
|
|
|
|
+ packet.newMsg(lastMessage);
|
|
byte smbCommand = packet.getSmbCommand();
|
|
byte smbCommand = packet.getSmbCommand();
|
|
List<ByteArray> response = new ArrayList<ByteArray>();
|
|
List<ByteArray> response = new ArrayList<ByteArray>();
|
|
|
|
|
|
@@ -131,6 +134,11 @@ public final class SMB implements Protocol<ByteArray> {
|
|
public String toString() {
|
|
public String toString() {
|
|
return "SMB";
|
|
return "SMB";
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String getPacketContent() {
|
|
|
|
+ return HelperUtils.byteToStr(lastMessage);
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* Converts the current system time into a byte[] with windows specific time
|
|
* Converts the current system time into a byte[] with windows specific time
|
|
@@ -277,7 +285,7 @@ public final class SMB implements Protocol<ByteArray> {
|
|
if(dialectMsg[i] == 0x00) {
|
|
if(dialectMsg[i] == 0x00) {
|
|
byte[] dialect = new byte[i-start];
|
|
byte[] dialect = new byte[i-start];
|
|
System.arraycopy(dialectMsg, start, dialect, 0, i-start);
|
|
System.arraycopy(dialectMsg, start, dialect, 0, i-start);
|
|
- if(byteToStr(dialect).contains("NT LM 0.12")) {
|
|
|
|
|
|
+ if(HelperUtils.byteToStr(dialect).contains("NT LM 0.12")) {
|
|
return new byte[]{(byte)dialectNumber, (byte)(dialectNumber >> 8)};
|
|
return new byte[]{(byte)dialectNumber, (byte)(dialectNumber >> 8)};
|
|
}
|
|
}
|
|
start = i+1;
|
|
start = i+1;
|
|
@@ -601,32 +609,7 @@ public final class SMB implements Protocol<ByteArray> {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public String toString() {
|
|
public String toString() {
|
|
- return byteToStr(message);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Converts a byte[] to a String, but only characters in ASCII between 32 and 127
|
|
|
|
- * @param bytes that are converted
|
|
|
|
- * @return converted String
|
|
|
|
- */
|
|
|
|
- private String byteToStr(byte[] bytes) {
|
|
|
|
- char[] chars = new char[bytes.length];
|
|
|
|
- for (int i = 0, j = 0; i < bytes.length && j < chars.length; i++) {
|
|
|
|
- if (isLetter((char) bytes[i])) {
|
|
|
|
- chars[j] = (char) bytes[i];
|
|
|
|
- j++;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return new String(chars);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Determines if a character is in ASCII between 32 and 127
|
|
|
|
- * @param character that is checked
|
|
|
|
- * @return true if the character is between 32 and 127, else false
|
|
|
|
- */
|
|
|
|
- private boolean isLetter(char character) {
|
|
|
|
- return (character >= 32 && character <= 127);
|
|
|
|
|
|
+ return HelperUtils.byteToStr(message);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|