Record.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. package de.tudarmstadt.informatik.hostage.logging;
  2. import java.io.Serializable;
  3. import java.net.InetAddress;
  4. public class Record implements Serializable {
  5. private static final long serialVersionUID = 1L;
  6. public static enum TYPE {
  7. SEND, RECEIVE
  8. };
  9. private int id;
  10. private long attack_id;
  11. private String protocol;
  12. private TYPE type;
  13. private long timestamp;
  14. private InetAddress localIP;
  15. private int localPort;
  16. private InetAddress remoteIP;
  17. private int remotePort;
  18. private String BSSID;
  19. private String SSID;
  20. private String packet;
  21. /**
  22. * @return the id
  23. */
  24. public int getID() {
  25. return id;
  26. }
  27. /**
  28. * @param id
  29. * the id to set
  30. */
  31. public void setID(int id) {
  32. this.id = id;
  33. }
  34. /**
  35. * @return the attack_id
  36. */
  37. public long getAttack_id() {
  38. return attack_id;
  39. }
  40. /**
  41. * @param attack_id
  42. * the attack_id to set
  43. */
  44. public void setAttack_id(long attack_id) {
  45. this.attack_id = attack_id;
  46. }
  47. /**
  48. * @return the protocol
  49. */
  50. public String getProtocol() {
  51. return protocol;
  52. }
  53. /**
  54. * @param string the protocol to set
  55. */
  56. public void setProtocol(String string) {
  57. this.protocol = string;
  58. }
  59. public TYPE getType() {
  60. return type;
  61. }
  62. public void setType(TYPE type) {
  63. this.type = type;
  64. }
  65. public long getTimestamp() {
  66. return timestamp;
  67. }
  68. public void setTimestamp(long timestamp) {
  69. this.timestamp = timestamp;
  70. }
  71. public InetAddress getLocalIP() {
  72. return localIP;
  73. }
  74. public void setLocalIP(InetAddress localIP) {
  75. this.localIP = localIP;
  76. }
  77. public int getLocalPort() {
  78. return localPort;
  79. }
  80. public void setLocalPort(int localPort) {
  81. this.localPort = localPort;
  82. }
  83. public InetAddress getRemoteIP() {
  84. return remoteIP;
  85. }
  86. public void setRemoteIP(InetAddress remoteIP) {
  87. this.remoteIP = remoteIP;
  88. }
  89. public int getRemotePort() {
  90. return remotePort;
  91. }
  92. public void setRemotePort(int remotePort) {
  93. this.remotePort = remotePort;
  94. }
  95. /**
  96. * @return the bSSID
  97. */
  98. public String getBSSID() {
  99. return BSSID;
  100. }
  101. /**
  102. * @param bSSID the bSSID to set
  103. */
  104. public void setBSSID(String bSSID) {
  105. BSSID = bSSID;
  106. }
  107. /**
  108. * @return the sSID
  109. */
  110. public String getSSID() {
  111. return SSID;
  112. }
  113. /**
  114. * @param sSID the sSID to set
  115. */
  116. public void setSSID(String sSID) {
  117. SSID = sSID;
  118. }
  119. public String getPacket() {
  120. return packet;
  121. }
  122. public void setPacket(String packet) {
  123. this.packet = packet;
  124. }
  125. @Override
  126. public String toString() {
  127. return String.format("%d %s [%d,%s:%d,%s:%d,%s]", attack_id,
  128. ((type == TYPE.SEND) ? "SEND" : "RECEIVE"), timestamp,
  129. localIP.getHostAddress(), localPort, remoteIP.getHostAddress(),
  130. remotePort, packet);
  131. }
  132. public String toString(int format){
  133. // Choose String Format
  134. // Add additional case for your own Format. Also add format Name to /res/values/export_formats/
  135. switch (format){
  136. case 1:
  137. return String.format("{ \"src\":{\"IP\": %s, \"Port\": %d} \"dst\": {\"IP\": %s, \"Port\": %d} \"type\": 0 \"name\": \"HOsTaGe\" }", localIP.getHostAddress(), localPort, remoteIP.getHostAddress(),
  138. remotePort);
  139. case 2:
  140. return String.format("%d: %s in %s(%s) from [%s:%d] to [%s:%d]", attack_id, protocol, SSID, BSSID, remoteIP.getHostAddress(), remotePort, localIP.getHostAddress(), localPort);
  141. default:
  142. return toString();
  143. }
  144. }
  145. }