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>
#### How to Run / Debug
* In `mispmock` run `core.Main`.
* `com.olexyn.misp.embedded.RunAll.main()`
<br>
#### How to Deploy
* Install Tomcat
* `apt-get install tomcat9`
* Start Tomcat:
* `/usr/bin/tomcat9-instance-create -p 9090 <foo>/tomcat/`
* `<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.
* Set the URIs in code.
* Build (e.g. with `build-install-all.sh`)
* Put the generated `forward-0.1.war` in a servlet container (e.g. Jetty).
* Launch the `reverse-0.1.jar` on your host.
<br>

@ -1,12 +1,6 @@
#### 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`
* Lower `sleep()` without breaking.
* Replace `AppMock` with *guacamole*
* Does *guac* take *json*?
* Adjust `UserMock` to query *guac*.
@ -19,8 +13,5 @@
#### 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.mirror.Mirror;
/**
* Hello world!
*/
public class Embedded implements Runnable {

@ -6,14 +6,16 @@ public class RunAll {
public static void main(String... args) throws InterruptedException {
Thread serverT = new Thread(new Embedded());
serverT.start();
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();
}
}

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

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

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

@ -13,9 +13,7 @@ public class Ride {
private String request;
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() {

@ -7,27 +7,6 @@ import java.util.Map;
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) {
@ -35,13 +14,10 @@ public class WebPrint {
sb.append("<table style=\"width:100%\">");
JSONObject obj = new JSONObject(list.get(0));
Map<String, Object> map = obj.toMap();
sb.append("<tr>");
for (Map.Entry<String, Object> entry : map.entrySet()) {
sb.append("<th>");
@ -63,13 +39,7 @@ public class WebPrint {
sb.append("</td>");
}
sb.append("</tr>");
}
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,30 +1,22 @@
package com.olexyn.misp.mirror;
import com.olexyn.misp.helper.Ride;
import com.olexyn.misp.helper.WebPrint;
import org.apache.commons.io.IOUtils;
import org.json.JSONObject;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Mirror extends HttpServlet {
private final List<String> list = new ArrayList<>();
private void addRequest(HttpServletRequest request) {
synchronized (list) {
JSONObject obj = new JSONObject();
@ -35,13 +27,10 @@ public class Mirror extends HttpServlet {
obj.put("QueryString", request.getQueryString());
obj.put("ContextPath", request.getContextPath());
list.add(obj.toString());
}
}
// #######
//
// #######
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
@ -51,7 +40,6 @@ public class Mirror extends HttpServlet {
PrintWriter print = response.getWriter();
print.println("<!DOCTYPE html>");
print.println("<html lang=\"en\">");
print.println("<head>");
print.println("<meta charset=\"utf-8\">");
@ -60,31 +48,18 @@ public class Mirror extends HttpServlet {
print.println("<script src=\"script.js\"></script>");
print.println("</head>");
print.println("<body>");
synchronized (list) {
print.println(WebPrint.requestList(list));
}
synchronized (list) { print.println(WebPrint.requestList(list)); }
print.println(" </body></html>");
}
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) {
addRequest(request);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) { addRequest(request); }
@Override
public void doPut(HttpServletRequest request, HttpServletResponse response){
addRequest(request);
}
public void doPut(HttpServletRequest request, HttpServletResponse response) { 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