This repository has been archived on 2025-03-09. You can view files and clone it, but cannot push or open issues or pull requests.
httpmitm-old/start-proxy.sh

36 lines
1.2 KiB
Bash

#!/bin/bash
SCRIPT_DIR=$(dirname "$0")
SCRIPT_DIR=${SCRIPT_DIR:-"."}
VERSION=1.0.0
cat <<EOF
httpmitm - "rewritten" by kxtz!
v$VERSION-g$(git log -n 1 --pretty=format:%h -- $SCRIPT_DIR)
--------------------------------
EOF
CERT_PATH="${SCRIPT_DIR}/configs/m.google.com/public/google.com.pem"
if [[ ! -f "$CERT_PATH" ]]; then
echo "m.google.com certificate missing!"
echo "checked path: $CERT_PATH"
exit 1
fi
EXPIRY_DATE=$(openssl x509 -enddate -noout -in "$CERT_PATH" | cut -d= -f2)
EXPIRY_TIMESTAMP=$(date -d "$EXPIRY_DATE" +%s)
CURRENT_TIMESTAMP=$(date +%s)
CURRENT_TIMESTAMP="2743883708"
if [[ "$EXPIRY_TIMESTAMP" -lt "$CURRENT_TIMESTAMP" ]]; then
echo "Certificate expired. Regenerating..."
bash "${SCRIPT_DIR}/generate_ssl_certificate.sh" "*.google.com" "*.google.com"
mv "${SCRIPT_DIR}/*.google.com.pem" "${SCRIPT_DIR}/configs/m.google.com/public/google.com.pem"
mv "${SCRIPT_DIR}/*.google.com.key" "${SCRIPT_DIR}/configs/m.google.com/public/google.com.key"
mv "${SCRIPT_DIR}/extfile" "${SCRIPT_DIR}/configs/m.google.com/public"
mv "${SCRIPT_DIR}/in.csr" "${SCRIPT_DIR}/configs/m.google.com/public"
fi
cd $SCRIPT_DIR
npm i
node proxy.js