|
@@ -4,6 +4,7 @@ package de.tudarmstadt.informatik.hostage.logging;
|
|
|
* Created by Julien on 08.12.2014.
|
|
|
*/
|
|
|
|
|
|
+import android.os.Message;
|
|
|
import android.os.Parcel;
|
|
|
import android.os.Parcelable;
|
|
|
|
|
@@ -13,8 +14,12 @@ import android.os.Parcel;
|
|
|
import android.os.Parcelable;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
+import java.lang.reflect.Array;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.zip.Deflater;
|
|
|
|
|
|
+import de.tudarmstadt.informatik.hostage.wrapper.Packet;
|
|
|
+
|
|
|
public class SyncRecord implements Parcelable, Serializable {
|
|
|
|
|
|
private static final long serialVersionUID = 7106818788090434192L;
|
|
@@ -32,11 +37,15 @@ public class SyncRecord implements Parcelable, Serializable {
|
|
|
private String externalIP;
|
|
|
private int wasInternalAttack; // 1 if attacker ip and local ip were in same subnet, else 0
|
|
|
|
|
|
+ private AttackRecord attackRecord;
|
|
|
+
|
|
|
// attack
|
|
|
- private int id;
|
|
|
- private long timestamp;
|
|
|
- private MessageRecord.TYPE type;
|
|
|
- private String packet;
|
|
|
+ //private int id;
|
|
|
+ //private long timestamp;
|
|
|
+ //private MessageRecord.TYPE type;
|
|
|
+ //private String packet;
|
|
|
+
|
|
|
+ private ArrayList<MessageRecord> messageRecords;
|
|
|
|
|
|
public static final Parcelable.Creator<SyncRecord> CREATOR = new Parcelable.Creator<SyncRecord>() {
|
|
|
@Override
|
|
@@ -54,6 +63,20 @@ public class SyncRecord implements Parcelable, Serializable {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public SyncRecord(AttackRecord attackRecord){
|
|
|
+ this.attackRecord = attackRecord;
|
|
|
+ this.setAttack_id(attackRecord.getAttack_id());
|
|
|
+ this.setProtocol(attackRecord.getProtocol());
|
|
|
+ this.setExternalIP(attackRecord.getExternalIP());
|
|
|
+ this.setLocalPort(attackRecord.getLocalPort());
|
|
|
+ this.setRemoteIP(attackRecord.getRemoteIP());
|
|
|
+ this.setRemotePort(attackRecord.getRemotePort());
|
|
|
+ this.setWasInternalAttack(attackRecord.getWasInternalAttack());
|
|
|
+ this.setBssid(attackRecord.getBssid());
|
|
|
+ this.setSync_id(attackRecord.getSync_id());
|
|
|
+ this.setDevice(attackRecord.getDevice());
|
|
|
+ }
|
|
|
+
|
|
|
public SyncRecord(Parcel source) {
|
|
|
super();
|
|
|
this.attack_id = source.readLong();
|
|
@@ -68,10 +91,20 @@ public class SyncRecord implements Parcelable, Serializable {
|
|
|
this.device = source.readString();
|
|
|
this.sync_id = source.readLong();
|
|
|
|
|
|
- this.id = source.readInt();
|
|
|
- this.timestamp = source.readLong();
|
|
|
- this.type = MessageRecord.TYPE.valueOf(source.readString());
|
|
|
- this.packet = source.readString();
|
|
|
+ this.messageRecords = source.readArrayList(MessageRecord.class.getClassLoader());
|
|
|
+
|
|
|
+ if (messageRecords != null){
|
|
|
+ AttackRecord attack= this.getAttackRecord();
|
|
|
+ for (MessageRecord messageRecord : this.messageRecords){
|
|
|
+ messageRecord.setAttack_id(attack.getAttack_id());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //this.id = source.readInt();
|
|
|
+ //this.timestamp = source.readLong();
|
|
|
+ //this.type = MessageRecord.TYPE.valueOf(source.readString());
|
|
|
+ //this.packet = source.readString();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -93,42 +126,45 @@ public class SyncRecord implements Parcelable, Serializable {
|
|
|
dest.writeString(device);
|
|
|
dest.writeLong(sync_id);
|
|
|
|
|
|
- dest.writeInt(id);
|
|
|
- dest.writeLong(timestamp);
|
|
|
- dest.writeString(type.name());
|
|
|
- dest.writeString(packet);
|
|
|
+ dest.writeList(this.messageRecords);
|
|
|
+ //dest.writeInt(id);
|
|
|
+ //dest.writeLong(timestamp);
|
|
|
+ //dest.writeString(type.name());
|
|
|
+ //dest.writeString(packet);
|
|
|
}
|
|
|
|
|
|
|
|
|
public AttackRecord getAttackRecord(){
|
|
|
- boolean autoincrement = !this.device.equals(SyncDevice.currentDevice().getDeviceID());
|
|
|
- AttackRecord record = new AttackRecord(autoincrement);
|
|
|
-
|
|
|
- if (!autoincrement)
|
|
|
- record.setAttack_id(this.attack_id);
|
|
|
-
|
|
|
- this.attack_id = record.getAttack_id();
|
|
|
- record.setProtocol(this.protocol);
|
|
|
- record.setSync_id(this.sync_id);
|
|
|
- record.setLocalIP(this.localIP);
|
|
|
- record.setLocalPort(this.localPort);
|
|
|
- record.setBssid(this.bssid);
|
|
|
- record.setDevice(this.device);
|
|
|
- record.setExternalIP(this.externalIP);
|
|
|
- record.setWasInternalAttack(this.getWasInternalAttack());
|
|
|
- record.setRemoteIP(this.remoteIP);
|
|
|
- record.setRemotePort(this.remotePort);
|
|
|
-
|
|
|
- return record;
|
|
|
+ if (this.attackRecord == null){
|
|
|
+ boolean autoincrement = !this.device.equals(SyncDevice.currentDevice().getDeviceID());
|
|
|
+ AttackRecord record = new AttackRecord(autoincrement);
|
|
|
+
|
|
|
+ if (!autoincrement)
|
|
|
+ record.setAttack_id(this.attack_id);
|
|
|
+
|
|
|
+ this.attack_id = record.getAttack_id();
|
|
|
+ record.setProtocol(this.protocol);
|
|
|
+ record.setSync_id(this.sync_id);
|
|
|
+ record.setLocalIP(this.localIP);
|
|
|
+ record.setLocalPort(this.localPort);
|
|
|
+ record.setBssid(this.bssid);
|
|
|
+ record.setDevice(this.device);
|
|
|
+ record.setExternalIP(this.externalIP);
|
|
|
+ record.setWasInternalAttack(this.getWasInternalAttack());
|
|
|
+ record.setRemoteIP(this.remoteIP);
|
|
|
+ record.setRemotePort(this.remotePort);
|
|
|
+ this.attackRecord = record;
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.attackRecord;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ArrayList<MessageRecord> getMessageRecords(){
|
|
|
+ return this.messageRecords;
|
|
|
}
|
|
|
|
|
|
- public MessageRecord getMessageRecord(){
|
|
|
- MessageRecord record = new MessageRecord(true);
|
|
|
- record.setAttack_id(this.attack_id);
|
|
|
- record.setPacket(this.packet);
|
|
|
- record.setTimestamp(this.timestamp);
|
|
|
- record.setType(this.type);
|
|
|
- return record;
|
|
|
+ public void setMessageRecords(ArrayList<MessageRecord> mr){
|
|
|
+ this.messageRecords = mr;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -259,64 +295,6 @@ public class SyncRecord implements Parcelable, Serializable {
|
|
|
public void setWasInternalAttack(boolean b) {wasInternalAttack = b ? 1 : 0;}
|
|
|
|
|
|
|
|
|
-
|
|
|
- /*
|
|
|
- *
|
|
|
- *
|
|
|
- * MESSAGE RECORD
|
|
|
- *
|
|
|
- *
|
|
|
- */
|
|
|
- /**
|
|
|
- * @return the id
|
|
|
- */
|
|
|
- public int getId() {
|
|
|
- return id;
|
|
|
- }
|
|
|
- /**
|
|
|
- * @param id the id to set
|
|
|
- */
|
|
|
- public void setId(int id) {
|
|
|
- this.id = id;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @return the timestamp
|
|
|
- */
|
|
|
- public long getTimestamp() {
|
|
|
- return timestamp;
|
|
|
- }
|
|
|
- /**
|
|
|
- * @param timestamp the timestamp to set
|
|
|
- */
|
|
|
- public void setTimestamp(long timestamp) {
|
|
|
- this.timestamp = timestamp;
|
|
|
- }
|
|
|
- /**
|
|
|
- * @return the type
|
|
|
- */
|
|
|
- public MessageRecord.TYPE getType() {
|
|
|
- return type;
|
|
|
- }
|
|
|
- /**
|
|
|
- * @param type the type to set
|
|
|
- */
|
|
|
- public void setType(MessageRecord.TYPE type) {
|
|
|
- this.type = type;
|
|
|
- }
|
|
|
- /**
|
|
|
- * @return the packet
|
|
|
- */
|
|
|
- public String getPacket() {
|
|
|
- return packet;
|
|
|
- }
|
|
|
- /**
|
|
|
- * @param packet the packet to set
|
|
|
- */
|
|
|
- public void setPacket(String packet) {
|
|
|
- this.packet = packet;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @return the number_of_attacks
|
|
|
*/
|