123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- package de.tudarmstadt.informatik.hostage.logging;
- import android.os.Parcel;
- import android.os.Parcelable;
- import de.tudarmstadt.informatik.hostage.logging.formatter.Formatter;
- /**
- * This class defines the attributes of a record.<br>
- * A Record is a single message exchanged between the application and an
- * attacker.<br>
- * The class has no own functionality except for getter and setter methods. To
- * change the logging mechanism you have to to change the logger in
- * {@link de.tudarmstadt.informatik.hostage.HoneyService HoneyService} and
- * {@link de.tudarmstadt.informatik.hostage.ui.ViewLog ViewLog}
- *
- * @author Mihai Plasoianu
- * @author Lars Pandikow
- */
- public class Record implements Parcelable {
- public static enum TYPE {
- SEND, RECEIVE
- };
- // attack
- private int id;
- private long attack_id;
- private long timestamp;
- private String protocol;
- private TYPE type;
- private String packet;
- // network
- private String localIP;
- private String localHost;
- private int localPort;
- private String remoteIP;
- private String remoteHost;
- private int remotePort;
- private String externalIP;
- private String bssid;
- private String ssid;
- // location
- private long timestampLocation;
- private double latitude;
- private double longitude;
- private float accuracy;
- public static final Parcelable.Creator<Record> CREATOR = new Parcelable.Creator<Record>() {
- @Override
- public Record createFromParcel(Parcel source) {
- return new Record(source);
- }
- @Override
- public Record[] newArray(int size) {
- return new Record[size];
- }
- };
- public Record() {
- }
- public Record(Parcel source) {
- // attack
- this.id = source.readInt();
- this.attack_id = source.readLong();
- this.timestamp = source.readLong();
- this.protocol = source.readString();
- this.type = TYPE.valueOf(source.readString());
- this.packet = source.readString();
- // network
- this.localIP = source.readString();
- this.localHost = source.readString();
- this.localPort = source.readInt();
- this.remoteIP = source.readString();
- this.remoteHost = source.readString();
- this.remotePort = source.readInt();
- this.externalIP = source.readString();
- this.bssid = source.readString();
- this.ssid = source.readString();
- // location
- this.timestampLocation = source.readLong();
- this.latitude = source.readDouble();
- this.longitude = source.readDouble();
- this.accuracy = source.readFloat();
- }
- @Override
- public int describeContents() {
- return 0;
- }
- public float getAccuracy() {
- return accuracy;
- }
- public long getAttack_id() {
- return attack_id;
- }
- public String getBssid() {
- return bssid;
- }
- public String getExternalIP() {
- return externalIP;
- }
- public int getId() {
- return id;
- }
- public double getLatitude() {
- return latitude;
- }
- public String getLocalHost() {
- return localHost;
- }
- public String getLocalIP() {
- return localIP;
- }
- public int getLocalPort() {
- return localPort;
- }
- public double getLongitude() {
- return longitude;
- }
- public String getPacket() {
- return packet;
- }
- public String getProtocol() {
- return protocol;
- }
- public String getRemoteHost() {
- return remoteHost;
- }
- public String getRemoteIP() {
- return remoteIP;
- }
- public int getRemotePort() {
- return remotePort;
- }
- public String getSsid() {
- return ssid;
- }
- public long getTimestamp() {
- return timestamp;
- }
- public long getTimestampLocation() {
- return timestampLocation;
- }
- public TYPE getType() {
- return type;
- }
- public void setAccuracy(float accuracy) {
- this.accuracy = accuracy;
- }
- public void setAttack_id(long attack_id) {
- this.attack_id = attack_id;
- }
- public void setBssid(String bssid) {
- this.bssid = bssid;
- }
- public void setExternalIP(String externalIP) {
- this.externalIP = externalIP;
- }
- public void setId(int id) {
- this.id = id;
- }
- public void setLatitude(double latitude) {
- this.latitude = latitude;
- }
- public void setLocalHost(String localHost) {
- this.localHost = localHost;
- }
- public void setLocalIP(String localIP) {
- this.localIP = localIP;
- }
- public void setLocalPort(int localPort) {
- this.localPort = localPort;
- }
- public void setLongitude(double longitude) {
- this.longitude = longitude;
- }
- public void setPacket(String packet) {
- this.packet = packet;
- }
- public void setProtocol(String protocol) {
- this.protocol = protocol;
- }
- public void setRemoteHost(String remoteHost) {
- this.remoteHost = remoteHost;
- }
- public void setRemoteIP(String remoteIP) {
- this.remoteIP = remoteIP;
- }
- public void setRemotePort(int remotePort) {
- this.remotePort = remotePort;
- }
- public void setSsid(String ssid) {
- this.ssid = ssid;
- }
- public void setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- }
- public void setTimestampLocation(long timestampLocation) {
- this.timestampLocation = timestampLocation;
- }
- public void setType(TYPE type) {
- this.type = type;
- }
- @Override
- public String toString() {
- return toString(null);
- }
- public String toString(Formatter formatter) {
- if (null == formatter) {
- return Formatter.getDefault().format(this);
- }
- return formatter.format(this);
- }
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- // attack
- dest.writeInt(id);
- dest.writeLong(attack_id);
- dest.writeLong(timestamp);
- dest.writeString(protocol);
- dest.writeString(type.name());
- dest.writeString(packet);
- // network
- dest.writeString(localIP);
- dest.writeString(localHost);
- dest.writeInt(localPort);
- dest.writeString(remoteIP);
- dest.writeString(remoteHost);
- dest.writeInt(remotePort);
- dest.writeString(externalIP);
- dest.writeString(bssid);
- dest.writeString(ssid);
- // location
- dest.writeLong(timestampLocation);
- dest.writeDouble(latitude);
- dest.writeDouble(longitude);
- dest.writeFloat(accuracy);
- }
- }
|