A free, open-source alternative to Burp Suite: an intercepting proxy and web app security testing suite with Repeater, Intruder, Collaborator and a built-in OWASP ZAP scanner. Linux, AGPL-3.0.
Java application-securityappsecbug-bountyburp-alternativeburp-suitedasthttp-proxyinfosecintercepting-proxyjavaowaspowasp-zappenetration-testingpentestingsecuritysecurity-toolsvulnerability-scannerweb-application-securityweb-security
#!/usr/bin/env bash
# End-to-end check of a built AppImage on Linux, as the release workflow
# runs it: the app starts with a new project, the proxy carries HTTP and HTTPS,
# a scan through the REST API crawls with the browser and finds a reflected XSS
# in a small local target, and when the app is killed the engine and every
# browser it started go with it.
#
# It turns on the REST API (loopback, no key) in this user's settings, so it is
# meant for a throwaway machine such as a CI runner. It needs a display: the
# workflow gives it a virtual one. Usage:
# tools/smoke-test-linux.sh [path/to/opensuite-x86_64.appimage]
set -euo pipefail
DIR="$(cd "$(dirname "$0")/.." && pwd)"
APP="${1:-$DIR/dist/opensuite-x86_64.appimage}"
JAVA="$DIR/jdk/bin/java"
# A CI runner has no FUSE: the AppImage unpacks itself and runs from there.
export APPIMAGE_EXTRACT_AND_RUN=1
WORK="$(mktemp -d)"
APP_PID=""; TARGET_PID=""
cleanup() {
app_pids | xargs -r kill -9 2>/dev/null || true
[ -n "$TARGET_PID" ] && kill "$TARGET_PID" 2>/dev/null || true
rm -rf "$WORK"
}
trap cleanup EXIT
# The app itself, not the AppImage's own small starter in front of it.
app_pids() { pgrep -f 'usr/bin/OpenSuite' || true; }
# On a failure: what the scan said of itself, what the target was asked for, and what the engine logged about its browser.
report() {
echo "--- the scan"; curl -s "http://127.0.0.1:1337/v0.1/scan/1" 2>/dev/null || true; echo
[ -f "$WORK/target.log" ] && { echo "--- requests the target received"; sort -u "$WORK/target.log" | head -40; }
for log in "$HOME"/.opensuite/engine/work/run-*/zap.log; do
[ -f "$log" ] || continue
echo "--- the engine on its browser crawl ($log)"
grep -iE 'ajax|selenium|webdriver|chrom|browser| WARN | ERROR ' "$log" | tail -60 || true
done
}
fail() { echo "FAIL: $*" >&2; report >&2 || true; exit 1; }
ok() { echo "ok $*"; }
[ -x "$APP" ] || fail "no AppImage at $APP"
[ -x "$JAVA" ] || fail "no JDK at $DIR/jdk (run ./fetch-jdk.sh)"
"$APP" --appimage-version >/dev/null 2>&1 || true
# A target with a reflected parameter and a link only JavaScript creates.
cat > "$WORK/target.py" <<'EOF'
import http.server, sys, urllib.parse
class H(http.server.BaseHTTPRequestHandler):
def do_GET(self):
u = urllib.parse.urlparse(self.path)
q = urllib.parse.parse_qs(u.query).get('q', [''])[0]
if u.path == '/':
body = ('<html><body><a href="/search?q=hello">search</a><div id="x"></div>'
'<script>var a=document.createElement("a");a.href="/js-only-page";a.textContent="js";'
'document.getElementById("x").appendChild(a);</script></body></html>')
elif u.path == '/search':
body = '<html><body>Results for: ' + q + '</body></html>'
elif u.path == '/js-only-page':
body = '<html><body>reached by script</body></html>'
else:
self.send_response(404); self.end_headers(); return
self.send_response(200); self.send_header('Content-Type', 'text/html'); self.end_headers()
self.wfile.write(body.encode())
def log_message(self, *a):
with open(sys.argv[1], 'a') as f: f.write(getattr(self, 'path', '') + '\n')
http.server.ThreadingHTTPServer(('127.0.0.1', 8765), H).serve_forever()
EOF
python3 "$WORK/target.py" "$WORK/target.log" &
TARGET_PID=$!
for _ in $(seq 1 60); do curl -fs -o /dev/null http://127.0.0.1:8765/ && break; sleep 1; done
curl -fs -o /dev/null http://127.0.0.1:8765/ || fail "the test target did not start"
cat > "$WORK/Prefs.java" <<'EOF'
public class Prefs { public static void main(String[] a) throws Exception {
var p = java.util.prefs.Preferences.userRoot().node("opensuite.v1");
p.put("rest.running", "true"); p.put("rest.noKey", "true"); p.flush(); } }
EOF
"$JAVA" "$WORK/Prefs.java"
# A project on the command line skips the startup dialog.
"$APP" "$WORK/smoke.osuite" >"$WORK/app.log" 2>&1 &
APP_PID=$!
REST=http://127.0.0.1:1337/v0.1
for _ in $(seq 1 90); do curl -fs "$REST/" >/dev/null 2>&1 && break; sleep 2; done
curl -fs "$REST/" >/dev/null || { cat "$WORK/app.log"; fail "the app did not start its REST API"; }
ok "app started (pid $APP_PID)"
# The REST API answers before the window is built, and the proxy listener
# starts with the window, so wait for it rather than assume it is there.
via=""
for _ in $(seq 1 60); do
via="$(curl -s -o /dev/null -w '%{http_code}' -x http://127.0.0.1:8080 http://127.0.0.1:8765/ || true)"
[ "$via" = 200 ] && break
sleep 1
done
if [ "$via" != 200 ]; then
echo "--- the app's own output"; cat "$WORK/app.log" || true
echo "--- listening ports"; ss -ltnp 2>/dev/null || true
fail "HTTP through the proxy (last answer: ${via:-none})"
fi
ok "HTTP through the proxy"
curl -fs -x http://127.0.0.1:8080 http://opensuite/cert/der -o "$WORK/ca.der"
openssl x509 -inform der -in "$WORK/ca.der" -out "$WORK/ca.pem"
[ "$(curl -s -o /dev/null -w '%{http_code}' --cacert "$WORK/ca.pem" -x http://127.0.0.1:8080 https://example.com/)" = 200 ] \
|| fail "HTTPS through the proxy, trusting its CA"
ok "HTTPS through the proxy, trusting its CA"
curl -fs "$REST/history?limit=50" | grep -q 'https://example.com/' || fail "history holds the HTTPS request"
ok "history holds the requests"
curl -fs -X POST "$REST/scan" -d '{"urls":["http://127.0.0.1:8765/"],"audit":true}' -o /dev/null
status=""
for _ in $(seq 1 120); do
status="$(curl -fs "$REST/scan/1" || true)"
case "$status" in *'"succeeded"'*|*'"failed"'*) break ;; esac
sleep 5
done
case "$status" in *'"succeeded"'*) ok "scan finished" ;; *) fail "scan did not finish: ${status:0:300}" ;; esac
curl -fs "$REST/issues" | grep -q 'Cross Site Scripting' || fail "the reflected XSS was not reported"
ok "reflected XSS found"
grep -q '^/js-only-page' "$WORK/target.log" || fail "the browser crawl did not reach the page only script links to"
ok "browser crawl reached the script-only page"
ENGINE="$(pgrep -f "$HOME/.opensuite/engine/zap-" || true)"
[ -n "$ENGINE" ] || fail "no engine process found"
[ -n "$(app_pids)" ] || fail "no app process found"
app_pids | xargs -r kill -9; APP_PID=""
for _ in $(seq 1 30); do
left="$(pgrep -f "$HOME/.opensuite/engine/zap-|usr/lib/browser/" || true)"
[ -z "$left" ] && break
sleep 1
done
[ -z "$left" ] || { ps -o pid,args -p $left; fail "processes outlived the app"; }
ok "engine and browsers ended with the app"
echo "smoke test passed"