AttackRecord.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 the attack_id to set
  63. */
  64. public void setAttack_id(long attack_id) {
  65. this.attack_id = attack_id;
  66. }
  67. /**
  68. * @return the bssid
  69. */
  70. public String getBssid() {
  71. return bssid;
  72. }
  73. /**
  74. * @param bssid the bssid to set
  75. */
  76. public void setBssid(String bssid) {
  77. this.bssid = bssid;
  78. }
  79. /**
  80. * @return the protocol
  81. */
  82. public String getProtocol() {
  83. return protocol;
  84. }
  85. /**
  86. * @param protocol the protocol to set
  87. */
  88. public void setProtocol(String protocol) {
  89. this.protocol = protocol;
  90. }
  91. /**
  92. * @return the localIP
  93. */
  94. public String getLocalIP() {
  95. return localIP;
  96. }
  97. /**
  98. * @param localIP the localIP to set
  99. */
  100. public void setLocalIP(String localIP) {
  101. this.localIP = localIP;
  102. }
  103. /**
  104. * @return the localPort
  105. */
  106. public int getLocalPort() {
  107. return localPort;
  108. }
  109. /**
  110. * @param localPort the localPort to set
  111. */
  112. public void setLocalPort(int localPort) {
  113. this.localPort = localPort;
  114. }
  115. /**
  116. * @return the remoteIP
  117. */
  118. public String getRemoteIP() {
  119. return remoteIP;
  120. }
  121. /**
  122. * @param remoteIP the remoteIP to set
  123. */
  124. public void setRemoteIP(String remoteIP) {
  125. this.remoteIP = remoteIP;
  126. }
  127. /**
  128. * @return the remotePort
  129. */
  130. public int getRemotePort() {
  131. return remotePort;
  132. }
  133. /**
  134. * @param remotePort the remotePort to set
  135. */
  136. public void setRemotePort(int remotePort) {
  137. this.remotePort = remotePort;
  138. }
  139. /**
  140. * @return the externalIP
  141. */
  142. public String getExternalIP() {
  143. return externalIP;
  144. }
  145. /**
  146. * @param externalIP the externalIP to set
  147. */
  148. public void setExternalIP(String externalIP) {
  149. this.externalIP = externalIP;
  150. }
  151. //TEMP ZU TEST
  152. @Override
  153. public String toString(){
  154. return String
  155. .format("{ \"sensor\":{\"type\": \"Honeypot\", \"name\": \"HosTaGe\"}, \"type\": \"%s server access\", \"src\":{\"ip\": \"%s\", \"port\": %d}, \"dst\":{\"ip\": \"%s\", \"port\": %d} }",
  156. getProtocol(), getRemoteIP(), getRemotePort(), getExternalIP(), getLocalPort());
  157. }
  158. }