AttackRecord.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. package de.tudarmstadt.informatik.hostage.logging;
  2. import java.io.Serializable;
  3. import android.os.Parcel;
  4. import android.os.Parcelable;
  5. /**
  6. * Holds all necessary information about a single attack.
  7. */
  8. public class AttackRecord implements Parcelable, Serializable {
  9. private static final long serialVersionUID = 6111024905373724227L;
  10. private long attack_id;
  11. private String bssid;
  12. private String protocol;
  13. private String localIP;
  14. private int localPort;
  15. private String remoteIP;
  16. private int remotePort;
  17. private String externalIP;
  18. public static final Parcelable.Creator<AttackRecord> CREATOR = new Parcelable.Creator<AttackRecord>() {
  19. @Override
  20. public AttackRecord createFromParcel(Parcel source) {
  21. return new AttackRecord(source);
  22. }
  23. @Override
  24. public AttackRecord[] newArray(int size) {
  25. return new AttackRecord[size];
  26. }
  27. };
  28. public AttackRecord() {
  29. }
  30. public AttackRecord(Parcel source) {
  31. this.attack_id = source.readLong();
  32. this.protocol = source.readString();
  33. this.localIP = source.readString();
  34. this.localPort = source.readInt();
  35. this.remoteIP = source.readString();
  36. this.remotePort = source.readInt();
  37. this.externalIP = source.readString();
  38. this.bssid = source.readString();
  39. }
  40. @Override
  41. public int describeContents() {
  42. return 0;
  43. }
  44. @Override
  45. public void writeToParcel(Parcel dest, int flags) {
  46. dest.writeLong(attack_id);
  47. dest.writeString(protocol);
  48. dest.writeString(localIP);
  49. dest.writeInt(localPort);
  50. dest.writeString(remoteIP);
  51. dest.writeInt(remotePort);
  52. dest.writeString(externalIP);
  53. dest.writeString(bssid);
  54. }
  55. /**
  56. * @return the attack_id
  57. */
  58. public long getAttack_id() {
  59. return attack_id;
  60. }
  61. /**
  62. * @param attack_id
  63. * the attack_id to set
  64. */
  65. public void setAttack_id(long attack_id) {
  66. this.attack_id = attack_id;
  67. }
  68. /**
  69. * @return the bssid
  70. */
  71. public String getBssid() {
  72. return bssid;
  73. }
  74. /**
  75. * @param bssid
  76. * the bssid to set
  77. */
  78. public void setBssid(String bssid) {
  79. this.bssid = bssid;
  80. }
  81. /**
  82. * @return the protocol
  83. */
  84. public String getProtocol() {
  85. return protocol;
  86. }
  87. /**
  88. * @param protocol
  89. * the protocol to set
  90. */
  91. public void setProtocol(String protocol) {
  92. this.protocol = protocol;
  93. }
  94. /**
  95. * @return the localIP
  96. */
  97. public String getLocalIP() {
  98. return localIP;
  99. }
  100. /**
  101. * @param localIP
  102. * the localIP to set
  103. */
  104. public void setLocalIP(String localIP) {
  105. this.localIP = localIP;
  106. }
  107. /**
  108. * @return the localPort
  109. */
  110. public int getLocalPort() {
  111. return localPort;
  112. }
  113. /**
  114. * @param localPort
  115. * the localPort to set
  116. */
  117. public void setLocalPort(int localPort) {
  118. this.localPort = localPort;
  119. }
  120. /**
  121. * @return the remoteIP
  122. */
  123. public String getRemoteIP() {
  124. return remoteIP;
  125. }
  126. /**
  127. * @param remoteIP
  128. * the remoteIP to set
  129. */
  130. public void setRemoteIP(String remoteIP) {
  131. this.remoteIP = remoteIP;
  132. }
  133. /**
  134. * @return the remotePort
  135. */
  136. public int getRemotePort() {
  137. return remotePort;
  138. }
  139. /**
  140. * @param remotePort
  141. * the remotePort to set
  142. */
  143. public void setRemotePort(int remotePort) {
  144. this.remotePort = remotePort;
  145. }
  146. /**
  147. * @return the externalIP
  148. */
  149. public String getExternalIP() {
  150. return externalIP;
  151. }
  152. /**
  153. * @param externalIP
  154. * the externalIP to set
  155. */
  156. public void setExternalIP(String externalIP) {
  157. this.externalIP = externalIP;
  158. }
  159. // TEMP ZU TEST
  160. @Override
  161. public String toString() {
  162. return String
  163. .format("{ \"sensor\":{\"type\": \"Honeypot\", \"name\": \"HosTaGe\"}, \"type\": \"%s server access\", \"src\":{\"ip\": \"%s\", \"port\": %d}, \"dst\":{\"ip\": \"%s\", \"port\": %d} }",
  164. getProtocol(), getRemoteIP(), getRemotePort(), getExternalIP(), getLocalPort());
  165. }
  166. }