SQLRecord.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. package de.tudarmstadt.informatik.hostage.logging;
  2. import java.net.InetAddress;
  3. public class SQLRecord {
  4. // private variables
  5. private int id;
  6. private int attack_id;
  7. private String protocol;
  8. private String type;
  9. private String timestamp;
  10. private String localIP;
  11. private int localPort;
  12. private String remoteIP;
  13. private int remotePort;
  14. private String packet;
  15. // Empty constructor
  16. public SQLRecord() {
  17. }
  18. // constructor
  19. public SQLRecord(int id, int attack_id, String protocol, String type, String timestamp,
  20. String localIP, int localPort, String remoteIP, int remotePort,
  21. String packet) {
  22. this.id = id;
  23. this.attack_id = attack_id;
  24. this.setProtocol(protocol);
  25. this.type = type;
  26. this.timestamp = timestamp;
  27. this.localIP = localIP;
  28. this.localPort = localPort;
  29. this.remoteIP = remoteIP;
  30. this.remotePort = remotePort;
  31. this.packet = packet;
  32. }
  33. // constructor
  34. public SQLRecord(int attack_id, String protocol, String type, String timestamp, String localIP,
  35. int localPort, String remoteIP, int remotePort, String packet) {
  36. this.attack_id = attack_id;
  37. this.setProtocol(protocol);
  38. this.type = type;
  39. this.timestamp = timestamp;
  40. this.localIP = localIP;
  41. this.localPort = localPort;
  42. this.remoteIP = remoteIP;
  43. this.remotePort = remotePort;
  44. this.packet = packet;
  45. }
  46. /**
  47. * @return the id
  48. */
  49. public int getID() {
  50. return id;
  51. }
  52. /**
  53. * @param id
  54. * the id to set
  55. */
  56. public void setID(int id) {
  57. this.id = id;
  58. }
  59. /**
  60. * @return the attack_id
  61. */
  62. public int getAttack_id() {
  63. return attack_id;
  64. }
  65. /**
  66. * @param attack_id
  67. * the attack_id to set
  68. */
  69. public void setAttack_id(int attack_id) {
  70. this.attack_id = attack_id;
  71. }
  72. /**
  73. * @return the protocol
  74. */
  75. public String getProtocol() {
  76. return protocol;
  77. }
  78. /**
  79. * @param protocol the protocol to set
  80. */
  81. public void setProtocol(String protocol) {
  82. this.protocol = protocol;
  83. }
  84. /**
  85. * @return the type
  86. */
  87. public String getType() {
  88. return type;
  89. }
  90. /**
  91. * @param type
  92. * the type to set
  93. */
  94. public void setType(String type) {
  95. this.type = type;
  96. }
  97. /**
  98. * @return the timestamp
  99. */
  100. public String getTimestamp() {
  101. return timestamp;
  102. }
  103. /**
  104. * @param timestamp
  105. * the timestamp to set
  106. */
  107. public void setTimestamp(String timestamp) {
  108. this.timestamp = timestamp;
  109. }
  110. /**
  111. * @return the localIP
  112. */
  113. public String getLocalIP() {
  114. return localIP;
  115. }
  116. /**
  117. * @param localIP
  118. * the localIP to set
  119. */
  120. public void setLocalIP(String localIP) {
  121. this.localIP = localIP;
  122. }
  123. /**
  124. * @return the localPort
  125. */
  126. public int getLocalPort() {
  127. return localPort;
  128. }
  129. /**
  130. * @param localPort
  131. * the localPort to set
  132. */
  133. public void setLocalPort(int localPort) {
  134. this.localPort = localPort;
  135. }
  136. /**
  137. * @return the remoteIP
  138. */
  139. public String getRemoteIP() {
  140. return remoteIP;
  141. }
  142. /**
  143. * @param remoteIP
  144. * the remoteIP to set
  145. */
  146. public void setRemoteIP(String remoteIP) {
  147. this.remoteIP = remoteIP;
  148. }
  149. /**
  150. * @return the remotePort
  151. */
  152. public int getRemotePort() {
  153. return remotePort;
  154. }
  155. /**
  156. * @param remotePort
  157. * the remotePort to set
  158. */
  159. public void setRemotePort(int remotePort) {
  160. this.remotePort = remotePort;
  161. }
  162. /**
  163. * @return the packet
  164. */
  165. public String getPacket() {
  166. return packet;
  167. }
  168. /**
  169. * @param packet
  170. * the packet to set
  171. */
  172. public void setPacket(String packet) {
  173. this.packet = packet;
  174. }
  175. @Override
  176. public String toString() {
  177. return String.format("%d %s [%s,%s:%d,%s:%d,%s]", attack_id, type, timestamp,
  178. localIP, localPort, remoteIP, remotePort, packet);
  179. }
  180. public String toJson() {
  181. return String
  182. .format("{ \"src\":{\"IP\": %s, \"Port\": %d} \"dst\": {\"IP\": %s, \"Port\": %d} \"type\": 0 \"name\": \"HOsTaGe\" }",
  183. localIP, localPort, remoteIP, remotePort);
  184. }
  185. }