diff --git a/README.md b/README.md index 2136c25be..e23557f1e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The AnsweringMachine is built to overcome this troubles ## New!! * [Automatic recording of http](docs/plugins/socks5.md) without configuration :zap: -* [Quickstart for any server application](docs/quickstartany.md) :zap: +* [Quickstart for any server application](docs/generated/quickstartproxy.md) :zap: * Migrated to docker-compose 3.2 * Migrated php sample and php base docker image to php 8.1
diff --git a/docs/gen_scripts/quickstartproxy.bat b/docs/gen_scripts/quickstartproxy.bat new file mode 100644 index 000000000..bc1b7d3ca --- /dev/null +++ b/docs/gen_scripts/quickstartproxy.bat @@ -0,0 +1,14 @@ +@echo off + +cd %~dp0 + +set TARGET=..\generated\quickstartproxy.md +set SOURCE=..\gen_sources + +type noedit.htm > %TARGET% +echo In this demo you will >> %TARGET% +type quickstartproxy.md >> %TARGET% +type %SOURCE%\proxy.md >> %TARGET% +type %SOURCE%\approxy.md >> %TARGET% +type %SOURCE%\runproxyham.md >> %TARGET% +type %SOURCE%\createrecording.md >> %TARGET% \ No newline at end of file diff --git a/docs/gen_scripts/quickstartproxy.md b/docs/gen_scripts/quickstartproxy.md new file mode 100644 index 000000000..0fec8b564 --- /dev/null +++ b/docs/gen_scripts/quickstartproxy.md @@ -0,0 +1,12 @@ + +* Install Java 11 +* Start locally HAM server +* Connect to it through proxy + +Download the ham tar.gz from [github releases](https://github.com/kendarorg/HttpAnsweringMachine/releases) +and extract it + + +Ensure your application is calling -ONLY- http pages or it will not record the +interactions content + diff --git a/docs/gen_sources/approxy.md b/docs/gen_sources/approxy.md new file mode 100644 index 000000000..44895d1c7 --- /dev/null +++ b/docs/gen_sources/approxy.md @@ -0,0 +1,36 @@ + +## Configure the application proxy + +Here is configured for both http and https BUT only http traffic will be intercepted + +### On the application + +* [On Baeldung for java](https://www.baeldung.com/java-connect-via-proxy-server) + +Just add to the java command to start the application the following: + +
+    -Dhttp.proxyHost=127.0.0.1  -Dhttp.proxyPort=1081
+    -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=1081
+
+ +* [Some C# suggestions](https://dotnetcoretutorials.com/2021/07/11/socks-proxy-support-in-net/?series) + +### On HAM configuration + +First ensure that all the ports called by your application are set on the +file httpproxy.external.json in the "http" section. In the example here the +http listen on 80, 8081 and 8082 + +
+  {
+    "id": "http",
+    "system": true,
+    "active": true,
+    "port": "80;8081;8082",
+    "backlog": 50,
+    "useCachedExecutor": true
+  },
+
+ + diff --git a/docs/gen_sources/createrecording.md b/docs/gen_sources/createrecording.md new file mode 100644 index 000000000..eaa5538c2 --- /dev/null +++ b/docs/gen_sources/createrecording.md @@ -0,0 +1,20 @@ + +## Record some interaction + +You can now check ham application going on http://localhost + +* You can create a recording on the [recording page](http://www.local.test/plugins/recording) + +Create recording + +* Once you create the recording you can start recording! + +Start recording + +* Do some interaction on your application +* And stop the recording! +* Now you will se all the calls on the just created recording! + +Start recording + +* "Download" the recording as "Sample.json" diff --git a/docs/gen_sources/runproxyham.md b/docs/gen_sources/runproxyham.md new file mode 100644 index 000000000..1daf9e826 --- /dev/null +++ b/docs/gen_sources/runproxyham.md @@ -0,0 +1,5 @@ + +## Run!! + +Start the HAM application with the "httpproxy.run.bat/sh" +Start your appplication \ No newline at end of file diff --git a/docs/generated/quickstartproxy.md b/docs/generated/quickstartproxy.md new file mode 100644 index 000000000..dd7df55cc --- /dev/null +++ b/docs/generated/quickstartproxy.md @@ -0,0 +1,110 @@ + + +In this demo you will + +* Install Java 11 +* Start locally HAM server +* Connect to it through proxy + +Download the ham tar.gz from [github releases](https://github.com/kendarorg/HttpAnsweringMachine/releases) +and extract it + + +Ensure your application is calling -ONLY- http pages or it will not record the +interactions content + + +## Configure proxy + +Should set the proxy to 127.0.0.1 And port 1080 for socks5 or 1081 for http/https + +
+ Click me for more explanations + +* Chrome: + * Install [Proxy Switch Omega](https://chrome.google.com/webstore/detail/proxy-switchyomega/padekgcemlokbadohgkifijomclgjgif) + * Go to options + * Add http and https proxy server with + * Address: 127.0.0.1 + * Port 1081. + + Ham Proxyes + * Select "proxy" from the extension menu and back to "direct" when you want to disconnect + * + Ham Proxyes + +* Firefox + * Navigate to [about:preferences](about:preferences) + * Search for "proxy" + * Click on "Settings" + * Go to "Manual proxy Configuration" + * Select the socks5 proxy + * Address: 127.0.0.1 + * Port 1080 + * Check the "Proxy DNS when using SOCKS v5" flag + * Clean the settings when needed + + Ham Proxyes + +
+ + +## Configure the application proxy + +Here is configured for both http and https BUT only http traffic will be intercepted + +### On the application + +* [On Baeldung for java](https://www.baeldung.com/java-connect-via-proxy-server) + +Just add to the java command to start the application the following: + +
+    -Dhttp.proxyHost=127.0.0.1  -Dhttp.proxyPort=1081
+    -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=1081
+
+ +* [Some C# suggestions](https://dotnetcoretutorials.com/2021/07/11/socks-proxy-support-in-net/?series) + +### On HAM configuration + +First ensure that all the ports called by your application are set on the +file httpproxy.external.json in the "http" section. In the example here the +http listen on 80, 8081 and 8082 + +
+  {
+    "id": "http",
+    "system": true,
+    "active": true,
+    "port": "80;8081;8082",
+    "backlog": 50,
+    "useCachedExecutor": true
+  },
+
+ + + +## Run!! + +Start the HAM application with the "httpproxy.run.bat/sh" +Start your appplication +## Record some interaction + +You can now check ham application going on http://localhost + +* You can create a recording on the [recording page](http://www.local.test/plugins/recording) + +Create recording + +* Once you create the recording you can start recording! + +Start recording + +* Do some interaction on your application +* And stop the recording! +* Now you will se all the calls on the just created recording! + +Start recording + +* "Download" the recording as "Sample.json" diff --git a/ham/httproxy.external.json b/ham/httproxy.external.json new file mode 100644 index 000000000..4835dd879 --- /dev/null +++ b/ham/httproxy.external.json @@ -0,0 +1,76 @@ +[ + "#include:external/dns.json", + { + "id": "staticPage", + "system": true, + "staticPages": [ + ] + }, + { + "id": "http", + "system": true, + "active": true, + "port": "80", + "backlog": 50, + "useCachedExecutor": true + }, + "#include:external/proxy.json", + "#include:external/dbproxy.json", + "#include:external/ssl.json", + "#include:external/https.json", + "#include:external/mongo.json", + { + "id": "global", + "system": true, + "db": { + "url": "jdbc:h2:tcp://localhost/ham;MODE=MYSQL;", + "login": "sa", + "password": "sa", + "startInternalH2": true, + "driver": "org.h2.Driver", + "hibernateDialect": "org.hibernate.dialect.MySQLDialect" + }, + "localAddress": "localhost", + "logging": { + "logLevel": "INFO", + "loggers": { + "org.kendar.servers.http.Request": "OFF", + "org.kendar.servers.http.Response": "OFF", + "org.kendar.servers.http.StaticRequest": "OFF", + "org.kendar.servers.http.DynamicRequest": "OFF", + "org.kendar.dns.DnsQueries": "OFF", + "org.kendar.servers.http.InternalRequest": "OFF", + "org.hibernate": "OFF", + "org.kendar.mongo.logging.MongoLogClient": "OFF", + "org.kendar.mongo.logging.MongoLogServer": "OFF", + "org.mongodb.driver": "OFF", + "com.sun.net.httpserver": "ERROR" + } + }, + "filters": { + "12363272": false + } + }, + { + "id": "oidc.server", + "tokenExpiration": 86400, + "active": false + }, + { + "id": "js.filters", + "path": "jsplugins", + "active": true + }, + { + "id": "replayer.server", + "path": "replayerdata", + "active": true + }, + { + "id": "socks5.server", + "port": 1080, + "httpProxyPort": 1081, + "interceptAllHttp":true, + "active": true + } +] diff --git a/scripts/templates/releasebuild/ham/httpproxy.run.bat b/scripts/templates/releasebuild/ham/httpproxy.run.bat new file mode 100644 index 000000000..7306514a8 --- /dev/null +++ b/scripts/templates/releasebuild/ham/httpproxy.run.bat @@ -0,0 +1,18 @@ +@ECHO OFF + +REM Initialize +set SCRIPT_DIR=%~dp0 +cd %SCRIPT_DIR% + +REM Retrieve the jar name +dir /b %SCRIPT_DIR%\*.jar > .temp.txt +set /p JAR_NAME=<.temp.txt +del /s /f /q .temp.txt 2>&1 1>NUL + + + + +REM Start the application +java "-Dloader.path=%SCRIPT_DIR%/libs" -Dloader.main=org.kendar.Main ^ + "-Djsonconfig=%SCRIPT_DIR%\httpproxy.external.json" ^ + -jar %JAR_NAME% org.springframework.boot.loader.PropertiesLauncher diff --git a/scripts/templates/releasebuild/ham/httpproxy.run.sh b/scripts/templates/releasebuild/ham/httpproxy.run.sh new file mode 100644 index 000000000..bb28be7ab --- /dev/null +++ b/scripts/templates/releasebuild/ham/httpproxy.run.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Initialize +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +cd $SCRIPT_DIR + +# Retrieve the jar name +ls -lA|grep -oE '[^ ]+$'|grep .jar$ > tmp_txt +export JAR_NAME=$(head -1 tmp_txt) +rm tmp_txt || true + + + +# Start the application +java "-Dloader.path=$SCRIPT_DIR/libs" -Dloader.main=org.kendar.Main \ + "-Djsonconfig=$SCRIPT_DIR/httpproxy.external.json" \ + -jar "$JAR_NAME" org.springframework.boot.loader.PropertiesLauncher