Record.java 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. package de.tudarmstadt.informatik.hostage.logging;
  2. import android.os.Parcel;
  3. import android.os.Parcelable;
  4. import de.tudarmstadt.informatik.hostage.logging.formatter.Formatter;
  5. /**
  6. * This class defines the attributes of a record.<br>
  7. * A Record is a single message exchanged between the application and an
  8. * attacker.<br>
  9. * The class has no own functionality except for getter and setter methods. To
  10. * change the logging mechanism you have to to change the logger in
  11. * {@link de.tudarmstadt.informatik.hostage.HoneyService HoneyService} and
  12. * {@link de.tudarmstadt.informatik.hostage.ui.ViewLog ViewLog}
  13. *
  14. * @author Mihai Plasoianu
  15. * @author Lars Pandikow
  16. */
  17. public class Record implements Parcelable {
  18. public static enum TYPE {
  19. SEND, RECEIVE
  20. };
  21. // attack
  22. private int id;
  23. private long attack_id;
  24. private long timestamp;
  25. private String protocol;
  26. private TYPE type;
  27. private String packet;
  28. // network
  29. private String localIP;
  30. private String localHost;
  31. private int localPort;
  32. private String remoteIP;
  33. private String remoteHost;
  34. private int remotePort;
  35. private String externalIP;
  36. private String bssid;
  37. private String ssid;
  38. // location
  39. private long timestampLocation;
  40. private double latitude;
  41. private double longitude;
  42. private float accuracy;
  43. @Override
  44. public int describeContents() {
  45. return 0;
  46. }
  47. @Override
  48. public void writeToParcel(Parcel dest, int flags) {
  49. // attack
  50. dest.writeInt(id);
  51. dest.writeLong(attack_id);
  52. dest.writeLong(timestamp);
  53. dest.writeString(protocol);
  54. dest.writeString(type.name());
  55. dest.writeString(packet);
  56. // network
  57. dest.writeString(localIP);
  58. dest.writeString(localHost);
  59. dest.writeInt(localPort);
  60. dest.writeString(remoteIP);
  61. dest.writeString(remoteHost);
  62. dest.writeInt(remotePort);
  63. dest.writeString(externalIP);
  64. dest.writeString(bssid);
  65. dest.writeString(ssid);
  66. // location
  67. dest.writeLong(timestampLocation);
  68. dest.writeDouble(latitude);
  69. dest.writeDouble(longitude);
  70. dest.writeFloat(accuracy);
  71. }
  72. public static final Parcelable.Creator<Record> CREATOR = new Parcelable.Creator<Record>() {
  73. @Override
  74. public Record createFromParcel(Parcel source) {
  75. return new Record(source);
  76. }
  77. @Override
  78. public Record[] newArray(int size) {
  79. return new Record[size];
  80. }
  81. };
  82. public Record() {
  83. }
  84. public Record(Parcel source) {
  85. // attack
  86. this.id = source.readInt();
  87. this.attack_id = source.readLong();
  88. this.timestamp = source.readLong();
  89. this.protocol = source.readString();
  90. this.type = TYPE.valueOf(source.readString());
  91. this.packet = source.readString();
  92. // network
  93. this.localIP = source.readString();
  94. this.localHost = source.readString();
  95. this.localPort = source.readInt();
  96. this.remoteIP = source.readString();
  97. this.remoteHost = source.readString();
  98. this.remotePort = source.readInt();
  99. this.externalIP = source.readString();
  100. this.bssid = source.readString();
  101. this.ssid = source.readString();
  102. // location
  103. this.timestampLocation = source.readLong();
  104. this.latitude = source.readDouble();
  105. this.longitude = source.readDouble();
  106. this.accuracy = source.readFloat();
  107. }
  108. public int getId() {
  109. return id;
  110. }
  111. public void setId(int id) {
  112. this.id = id;
  113. }
  114. public long getAttack_id() {
  115. return attack_id;
  116. }
  117. public void setAttack_id(long attack_id) {
  118. this.attack_id = attack_id;
  119. }
  120. public long getTimestamp() {
  121. return timestamp;
  122. }
  123. public void setTimestamp(long timestamp) {
  124. this.timestamp = timestamp;
  125. }
  126. public String getProtocol() {
  127. return protocol;
  128. }
  129. public void setProtocol(String protocol) {
  130. this.protocol = protocol;
  131. }
  132. public TYPE getType() {
  133. return type;
  134. }
  135. public void setType(TYPE type) {
  136. this.type = type;
  137. }
  138. public String getPacket() {
  139. return packet;
  140. }
  141. public void setPacket(String packet) {
  142. this.packet = packet;
  143. }
  144. public String getLocalIP() {
  145. return localIP;
  146. }
  147. public void setLocalIP(String localIP) {
  148. this.localIP = localIP;
  149. }
  150. public String getLocalHost() {
  151. return localHost;
  152. }
  153. public void setLocalHost(String localHost) {
  154. this.localHost = localHost;
  155. }
  156. public int getLocalPort() {
  157. return localPort;
  158. }
  159. public void setLocalPort(int localPort) {
  160. this.localPort = localPort;
  161. }
  162. public String getRemoteIP() {
  163. return remoteIP;
  164. }
  165. public void setRemoteIP(String remoteIP) {
  166. this.remoteIP = remoteIP;
  167. }
  168. public String getRemoteHost() {
  169. return remoteHost;
  170. }
  171. public void setRemoteHost(String remoteHost) {
  172. this.remoteHost = remoteHost;
  173. }
  174. public int getRemotePort() {
  175. return remotePort;
  176. }
  177. public void setRemotePort(int remotePort) {
  178. this.remotePort = remotePort;
  179. }
  180. public String getExternalIP() {
  181. return externalIP;
  182. }
  183. public void setExternalIP(String externalIP) {
  184. this.externalIP = externalIP;
  185. }
  186. public String getBssid() {
  187. return bssid;
  188. }
  189. public void setBssid(String bssid) {
  190. this.bssid = bssid;
  191. }
  192. public String getSsid() {
  193. return ssid;
  194. }
  195. public void setSsid(String ssid) {
  196. this.ssid = ssid;
  197. }
  198. public long getTimestampLocation() {
  199. return timestampLocation;
  200. }
  201. public void setTimestampLocation(long timestampLocation) {
  202. this.timestampLocation = timestampLocation;
  203. }
  204. public double getLatitude() {
  205. return latitude;
  206. }
  207. public void setLatitude(double latitude) {
  208. this.latitude = latitude;
  209. }
  210. public double getLongitude() {
  211. return longitude;
  212. }
  213. public void setLongitude(double longitude) {
  214. this.longitude = longitude;
  215. }
  216. public float getAccuracy() {
  217. return accuracy;
  218. }
  219. public void setAccuracy(float accuracy) {
  220. this.accuracy = accuracy;
  221. }
  222. @Override
  223. public String toString() {
  224. return toString(null);
  225. }
  226. public String toString(Formatter formatter) {
  227. if (null == formatter) {
  228. return Formatter.getDefault().format(this);
  229. }
  230. return formatter.format(this);
  231. }
  232. }