pull/1/head
Ivan Olexyn 5 years ago
parent d519725651
commit 8cdfed0d96

@ -14,23 +14,15 @@ It is estimated to require two servlets - one on the webhost (`mispbridge`), and
<br> <br>
#### How to Run / Debug #### How to Run / Debug
* In `mispmock` run `core.Main`. * `com.olexyn.misp.embedded.RunAll.main()`
<br> <br>
#### How to Deploy #### How to Deploy
* Install Tomcat * Set the URIs in code.
* `apt-get install tomcat9` * Build (e.g. with `build-install-all.sh`)
* Start Tomcat: * Put the generated `forward-0.1.war` in a servlet container (e.g. Jetty).
* `/usr/bin/tomcat9-instance-create -p 9090 <foo>/tomcat/` * Launch the `reverse-0.1.jar` on your host.
* `<foo>/tomcat/bin/startup.sh`
* Link this project to where Tomcat expects files:
* `ln -s <bar>/mispbridge/mispbridge/ <foo>/tomcat/webapps/`
* `ln -s <bar>/mispclient/mispclient/ <foo>/tomcat/webapps/`
* Set up your IDE to compile to:
* `<bar>/mispbridge/mispbridge/WEB-INF/classes/`
* `<bar>/mispclient/mispclient/WEB-INF/classes/`
* Compile the project & restart Tomcat.
<br> <br>

@ -1,12 +1,6 @@
#### TODO #### TODO
* FIX errors when setting WAIT to low.
* In `ClientMock` put `GET (Ride)(Request)(Data)` on it's own thread.
* Currently it is on the `POST (Ride)` thread.
* It would be better to "decouple" it.
* Clean the `mispmock` code.
* Use real `app` * Use real `app`
* Lower `sleep()` without breaking.
* Replace `AppMock` with *guacamole* * Replace `AppMock` with *guacamole*
* Does *guac* take *json*? * Does *guac* take *json*?
* Adjust `UserMock` to query *guac*. * Adjust `UserMock` to query *guac*.
@ -19,8 +13,5 @@
#### DO MAYBE #### DO MAYBE
* In `ClientMock` put `GET (Request)` on it's own thread. *
* Currently it is on the `POST (Ride)` thread. *
* This might be tricky since
* `GET (Request)` doesn't neccessarily know `(Ride)`
* and thus need a trick (?) to be syncronized with it

@ -4,9 +4,7 @@ import com.olexyn.min.http.server.MinJettyServer;
import com.olexyn.misp.forward.Forward; import com.olexyn.misp.forward.Forward;
import com.olexyn.misp.mirror.Mirror; import com.olexyn.misp.mirror.Mirror;
/**
* Hello world!
*/
public class Embedded implements Runnable { public class Embedded implements Runnable {

@ -6,14 +6,16 @@ public class RunAll {
public static void main(String... args) throws InterruptedException { public static void main(String... args) throws InterruptedException {
Thread serverT = new Thread(new Embedded()); Thread serverT = new Thread(new Embedded());
serverT.start(); serverT.start();
Thread.sleep(2000); Thread.sleep(2000);
Thread reverseT = new Thread(new Reverse()); Reverse reverse = new Reverse();
reverse.FORWARD_URL = "http://localhost:8090/forward";
reverse.APP_URL = "http://localhost:8090/app";
Thread reverseT = new Thread(reverse);
reverseT.start(); reverseT.start();
} }
} }

@ -1,5 +1,2 @@
#### About #### About
The `mispbridge` servlet. The `forward` servlet.
* `./src` the code.
* `./war/wrapper` supplements needed for `.war`.
* `./war/<name>.war` copy this to `tomcat/webapps`.

@ -9,9 +9,6 @@
<version>0.1</version> <version>0.1</version>
<name>helper</name> <name>helper</name>
<description>A simple helper.</description>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

@ -5,17 +5,12 @@ import org.json.JSONObject;
public class JsonHelper { public class JsonHelper {
public static boolean isJson(String string){ public static boolean isJson(String string){
try{ try{
new JSONObject(string); new JSONObject(string);
}catch (JSONException | NullPointerException e){ }catch (JSONException | NullPointerException e){
return false; return false;
} }
return true; return true;
} }
} }

@ -13,9 +13,7 @@ public class Ride {
private String request; private String request;
private String data; private String data;
// FUTURE it might be possible to use a ride for many requests.
// private List<String> requests = new ArrayList<>();
// private Map<String,String> data = new HashMap<>();
public Ride() { public Ride() {

@ -7,27 +7,6 @@ import java.util.Map;
public class WebPrint { public class WebPrint {
final static public String SPLIT = "io32413445353";
public static String list(List<String> list, String type) {
StringBuilder sb = new StringBuilder();
sb.append("<table style=\"width:100%\">");
sb.append("<tr>");
sb.append("<th>");
sb.append("List: ");
sb.append(type);
sb.append("</th>");
sb.append("</tr>");
for (String entry : list) {
sb.append("<tr><td>");
sb.append(entry);
sb.append("</td></tr>");
}
return sb.toString();
}
public static String requestList(List<String> list) { public static String requestList(List<String> list) {
@ -35,17 +14,14 @@ public class WebPrint {
sb.append("<table style=\"width:100%\">"); sb.append("<table style=\"width:100%\">");
JSONObject obj = new JSONObject(list.get(0)); JSONObject obj = new JSONObject(list.get(0));
Map<String,Object> map = obj.toMap(); Map<String, Object> map = obj.toMap();
sb.append("<tr>"); sb.append("<tr>");
for (Map.Entry<String,Object> entry : map.entrySet()){ for (Map.Entry<String, Object> entry : map.entrySet()) {
sb.append("<th>"); sb.append("<th>");
sb.append( entry.getKey()); sb.append(entry.getKey());
sb.append("</th>"); sb.append("</th>");
} }
sb.append("</tr>"); sb.append("</tr>");
@ -54,22 +30,16 @@ public class WebPrint {
for (String entry : list) { for (String entry : list) {
JSONObject line = new JSONObject(entry); JSONObject line = new JSONObject(entry);
Map<String,Object> map2 = line.toMap(); Map<String, Object> map2 = line.toMap();
sb.append("<tr>"); sb.append("<tr>");
for (Map.Entry<String,Object> entry2 : map2.entrySet()){ for (Map.Entry<String, Object> entry2 : map2.entrySet()) {
sb.append("<td>"); sb.append("<td>");
sb.append(entry2.getValue().toString()); sb.append(entry2.getValue().toString());
sb.append("</td>"); sb.append("</td>");
} }
sb.append("</tr>"); sb.append("</tr>");
} }
return sb.toString(); return sb.toString();
} }
} }

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="misp-helper" xmlns="http://maven.apache.org/DECORATION/1.8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 http://maven.apache.org/xsd/decoration-1.8.0.xsd">
<bannerLeft>
<name>misp-helper</name>
<src>https://maven.apache.org/images/apache-maven-project.png</src>
<href>https://www.apache.org/</href>
</bannerLeft>
<bannerRight>
<src>https://maven.apache.org/images/maven-logo-black-on-white.png</src>
<href>https://maven.apache.org/</href>
</bannerRight>
<skin>
<groupId>org.apache.maven.skins</groupId>
<artifactId>maven-fluido-skin</artifactId>
<version>1.7</version>
</skin>
<body>
<menu ref="parent" />
<menu ref="reports" />
</body>
</project>

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

@ -1,47 +1,36 @@
package com.olexyn.misp.mirror; package com.olexyn.misp.mirror;
import com.olexyn.misp.helper.Ride;
import com.olexyn.misp.helper.WebPrint; import com.olexyn.misp.helper.WebPrint;
import org.apache.commons.io.IOUtils;
import org.json.JSONObject; import org.json.JSONObject;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public class Mirror extends HttpServlet { public class Mirror extends HttpServlet {
private final List<String> list = new ArrayList<>(); private final List<String> list = new ArrayList<>();
private void addRequest(HttpServletRequest request) {
private void addRequest(HttpServletRequest request){
synchronized (list) { synchronized (list) {
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
obj.put("RequestURL", request.getRequestURL()); obj.put("RequestURL", request.getRequestURL());
obj.put("RemoteAddr" , request.getRemoteAddr()); obj.put("RemoteAddr", request.getRemoteAddr());
obj.put("Method", request.getMethod()); obj.put("Method", request.getMethod());
obj.put("Param", request.getParameterMap().toString()); obj.put("Param", request.getParameterMap().toString());
obj.put("QueryString", request.getQueryString()); obj.put("QueryString", request.getQueryString());
obj.put("ContextPath",request.getContextPath()); obj.put("ContextPath", request.getContextPath());
list.add(obj.toString()); list.add(obj.toString());
} }
} }
// #######
//
// #######
@Override @Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
@ -51,7 +40,6 @@ public class Mirror extends HttpServlet {
PrintWriter print = response.getWriter(); PrintWriter print = response.getWriter();
print.println("<!DOCTYPE html>"); print.println("<!DOCTYPE html>");
print.println("<html lang=\"en\">"); print.println("<html lang=\"en\">");
print.println("<head>"); print.println("<head>");
print.println("<meta charset=\"utf-8\">"); print.println("<meta charset=\"utf-8\">");
@ -60,31 +48,18 @@ public class Mirror extends HttpServlet {
print.println("<script src=\"script.js\"></script>"); print.println("<script src=\"script.js\"></script>");
print.println("</head>"); print.println("</head>");
print.println("<body>"); print.println("<body>");
synchronized (list) { synchronized (list) { print.println(WebPrint.requestList(list)); }
print.println(WebPrint.requestList(list));
}
print.println(" </body></html>"); print.println(" </body></html>");
} }
@Override @Override
public void doPost(HttpServletRequest request, HttpServletResponse response) { public void doPost(HttpServletRequest request, HttpServletResponse response) { addRequest(request); }
addRequest(request);
}
@Override @Override
public void doPut(HttpServletRequest request, HttpServletResponse response){ public void doPut(HttpServletRequest request, HttpServletResponse response) { addRequest(request); }
addRequest(request);
}
} }

@ -1,204 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<diagram program="umlet" version="13.3">
<zoom_level>10</zoom_level>
<element>
<id>UMLClass</id>
<coordinates>
<x>670</x>
<y>1040</y>
<w>130</w>
<h>30</h>
</coordinates>
<panel_attributes>TinyVNC</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>670</x>
<y>1010</y>
<w>130</w>
<h>30</h>
</coordinates>
<panel_attributes>Guacamole</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>650</x>
<y>970</y>
<w>170</w>
<h>150</h>
</coordinates>
<panel_attributes>Debian VM</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>630</x>
<y>910</y>
<w>210</w>
<h>230</h>
</coordinates>
<panel_attributes>VirtualBox
layer=-1</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>670</x>
<y>1070</y>
<w>130</w>
<h>30</h>
</coordinates>
<panel_attributes>JavaFX</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>650</x>
<y>940</y>
<w>170</w>
<h>30</h>
</coordinates>
<panel_attributes>Bridged Connection</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>610</x>
<y>880</y>
<w>250</w>
<h>280</h>
</coordinates>
<panel_attributes>Debian Host
layer=-1</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>670</x>
<y>760</y>
<w>130</w>
<h>30</h>
</coordinates>
<panel_attributes>4G Modem</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>910</x>
<y>610</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>URL</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>650</x>
<y>580</y>
<w>170</w>
<h>80</h>
</coordinates>
<panel_attributes>Hosting Provider</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>910</x>
<y>760</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>IP / Port</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>910</x>
<y>940</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>IP / Port</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>960</x>
<y>780</y>
<w>30</w>
<h>180</h>
</coordinates>
<panel_attributes>lt=&lt;-&gt;</panel_attributes>
<additional_attributes>10.0;10.0;10.0;160.0</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>670</x>
<y>610</y>
<w>130</w>
<h>30</h>
</coordinates>
<panel_attributes>WordPress</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>810</x>
<y>940</y>
<w>120</w>
<h>30</h>
</coordinates>
<panel_attributes>lt=-</panel_attributes>
<additional_attributes>100.0;10.0;10.0;10.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>790</x>
<y>760</y>
<w>140</w>
<h>30</h>
</coordinates>
<panel_attributes>lt=-</panel_attributes>
<additional_attributes>120.0;10.0;10.0;10.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>960</x>
<y>630</y>
<w>30</w>
<h>150</h>
</coordinates>
<panel_attributes>lt=&lt;-&gt;</panel_attributes>
<additional_attributes>10.0;10.0;10.0;130.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>790</x>
<y>610</y>
<w>140</w>
<h>30</h>
</coordinates>
<panel_attributes>lt=-</panel_attributes>
<additional_attributes>120.0;10.0;10.0;10.0</additional_attributes>
</element>
</diagram>

@ -1,3 +0,0 @@
#!/bin/bash
./make-war.sh
./copy-restart.sh
Loading…
Cancel
Save