keys, add a generator for keys, reflect dmbackend changes, change some of the proxy

This commit is contained in:
kxtzownsu 2025-03-07 05:33:29 +00:00
parent 946197c63e
commit 56fc38eb5d
12 changed files with 171 additions and 205 deletions

View File

@ -4,83 +4,28 @@ const path = require('path');
const express = require('express');
const url = require('url');
const child_proc = require('child_process');
const fs = require('fs');
const state = { pid: null };
/**
*
* @param {import("../../proxy").FilterInfo} f
*/
function filter(f) {
console.log("hi");
if (f.tls) {
return true;
}
return false;
}
async function startServerIfNeeded() {
return; // run the python3 srv manually for now
let realpath = path.resolve('.', 'dmbackend', 'start_server.sh')
let prc = child_proc.spawn("/bin/bash", [path.resolve('.', 'dmbackend', 'start_server.sh'), realpath], {stdio: "pipe"});
let wstream = fs.createWriteStream("./int_server.log");
let pidPath = path.resolve(path.dirname(realpath), "pid");
try {
fs.rmSync(pidPath);
} catch {};
prc.stdout.pipe(wstream);
prc.stderr.pipe(wstream);
// prc.stdout.once("data", async (c) => {
// let pid = 0;
// console.log("Started as PID: "+ (pid = parseInt(c.toString('utf-8').split("Server PID: ")[1].split('\n')[0])));
// state.pid = pid;
let buffer = null;
while (true) {
if ((buffer = await new Promise((resolve)=>{
fs.readFile(pidPath, (err, data)=>{
if (err)
resolve(null);
else {
resolve(data);
}
})
}))) {
break;
}
}
state.pid = parseInt(buffer.toString('utf-8'));
await new Promise((resolve)=>setTimeout(resolve, 200));
// })
console.log("Started internal server with pid of: " + state.pid);
}
const app = express();
app.post("/*", async function (req, res) {
console.log("Reading a post request")
console.log(req.header('Content-Length'));
var a = parseInt(req.header('Content-Length'))
const dat = Buffer.alloc(a);
var ptr = 0;
async function handle() {
console.log("handling: " + url.parse(req.url).search);
try {
// console.log(new URL(req.path).search);
fetch = (await import('node-fetch')).default;
await startServerIfNeeded();
const resFromRev = await fetch('http://127.0.0.1:3040/' + url.parse(req.url).search, {
body: dat,
"headers": req.headers,
method: "POST"
});
// console.log(resFromRev.data);
res.header('Content-Type', 'application/x-protobuffer');
res.writeHead(resFromRev.status, resFromRev.statusText);
res.end(new Uint8Array((await resFromRev.arrayBuffer())));
} catch (e) {
if (!e.response) {
console.log("Error occured here without a response. Weird.");
console.log(e);
console.error("An error occurred contacting dmbackend! Make sure you're running it!");
console.error(e);
res.writeHead(500, 'Internal server error');
res.end('An error has occured');
return;
@ -109,6 +54,18 @@ app.get('/*', (req, res) => {
res.writeHead(200, "OK");
res.end("OK");
})
/**
*
* @param {import("../../proxy").FilterInfo} f
*/
function filter(f) {
if (f.tls) {
return true;
}
return false;
}
/**
*
* @param {import("../../proxy").ServerConfig} config
@ -116,9 +73,8 @@ app.get('/*', (req, res) => {
*/
function proxy(config, sock) {
const ms = handlers.getMiniServer(function (req, res) {
// console.log(req);
app(req, res);
}, path.resolve(__dirname, "public", "m.google.com.pem"), path.resolve(__dirname, "public", "m.google.com.key"))
}, path.resolve(__dirname, "public", "google.com.pem"), path.resolve(__dirname, "public", "google.com.key"))
const socks = net.createConnection({
host: "127.0.0.1",
@ -127,7 +83,6 @@ function proxy(config, sock) {
sock.write('HTTP/1.1 200 OK\r\n\n');
sock.pipe(socks);
socks.pipe(sock);
// sock.write('HTTP/1.1 200 OK\r\n\n');
});
}

View File

@ -5,4 +5,4 @@ keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = m.google.com
DNS.1 = *.google.com

View File

@ -0,0 +1,52 @@
-----BEGIN PRIVATE KEY-----
MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQCq8oBxC2voYn6E
/l3IrjcavzPq/jdoj0L9BYaP9EckJWOws/hdX8Ei6UYGwn5PbjGZ3WOYV2paToPa
LjfSEB+RyhxAxgoDyu54rZGSSPtKKtNvkmE6u2xHyEGo0XMGQMmYa46M5sF46NDP
mxsJ/7f+x4Y6vFa8vYftk1Xxgv9q8jHf36kGGPiRpAW89fVrJhzB2E24L618T3Vm
NFpK8UdO/8ur8+7gV9dYlvgJLgEl88UfGrQL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vWS9mel7gO4bkPguY8YW1LU3lNDYGfd4W+Qmj0Ec3dH8WYB5DE6g==
-----END CERTIFICATE-----

@ -1 +1 @@
Subproject commit 605c336198ae7a430d3e1d71fbb998c63382c7b3
Subproject commit 7b077423c65a5e3a396287e5367e597592333708

View File

@ -1,14 +1,20 @@
#!/bin/bash
# Arguments: <server address>
DIR=.
mkdir -p "$DIR"
SCRIPTDIR=$(dirname "$(readlink -f "$0")")
SCRIPT_DIR=$(dirname "$0")
SCRIPT_DIR=${SCRIPT_DIR:-"."}
CA_PATH="${SCRIPT_DIR}/myCA"
openssl genrsa -out "$DIR/$1".key 4096
openssl req -new -key "$1".key -out "$DIR/in.csr" -subj "/C=US/ST=PRIVATE/L=PRIVATE/O=Success!/OU=Success/CN=$1"
cat > "$DIR/extfile" <<EOF
if [[ ! -f "$CA_PATH.pem" || ! -f "$CA_PATH.key" ]]; then
echo "CA certificates missing!"
echo "checked path: $CA_PATH.(pem/key)"
exit 1
fi
openssl genrsa -out "$SCRIPT_DIR/$1".key 4096
openssl req -new -key "$1".key -out "$SCRIPT_DIR/in.csr" -subj "/C=US/ST=PRIVATE/L=PRIVATE/O=Success!/OU=Success/CN=$1"
cat > "$SCRIPT_DIR/extfile" <<EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
@ -16,8 +22,7 @@ keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = $2
DNS.1 = $1
EOF
openssl x509 -req -out "$DIR/$1.pem" -CA "$SCRIPTDIR/myCA.pem" -CAkey "$SCRIPTDIR/myCA.key" -extfile "$DIR/extfile" -in "$DIR/in.csr"
# rm -rf "$DIR"
openssl x509 -req -out "$SCRIPT_DIR/$1.pem" -CA "$SCRIPT_DIR/myCA.pem" -CAkey "$SCRIPT_DIR/myCA.key" -extfile "$SCRIPT_DIR/extfile" -in "$SCRIPT_DIR/in.csr"

28
in.csr
View File

@ -1,28 +0,0 @@
-----B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kzxQfOWTuLuKB1l2wx9iQH/INVCunJ/RfXkPsLTENY8P+NzPXYL/7FmPV1ytHyi
OZGKyt/KcChbce0kJRU4f3CKDxCechIlWjR+TkZnfcliLhlBDvpqhd94Rk8NC/Uo
X8dD+h8l3Qh3NnfJDOHm6EwUBL3ontKisMl1Mqx99ssb9sc6X8w5jGPFbV3RvrEW
0WT9SoDpzVekRDBoD3BNB7PTTMlItsElaQjVFTD5AFTKAdl3Sp8F4BcyTS/tyG0u
k0fHJM+uPBzZqY3w7VvlT+fH+zsagvchhtOsAap9ZGwrY3p6vWkHAOEr4EDqIXvP
7crDrtn+3unVAJ/O7w5Y/RFOJ0uRAxqxDIe66gF2y3Xnud5yATDJS0DD7Og0oIFp
VMXxifBXm0gyr3IdIxwTXSOMnB1E7+s6gb94S2+Fg+jQOYJ4uvyQ6Q8ZRycKo7ti
5mHtSkAjtCPAOM/qI7tx9HoIGALJWvhN/sPIFouayoyASVmPYjyw53EVSM1IpnyY
h3gzsTkq5ph6gcEJtadDB59QxDFWCZ9rzxGYIyzu1CTXCFjbEWm2NawJ2BPV0ATS
sBQMfFPK
-----END CERTIFICATE REQUEST-----

View File

@ -141,8 +141,6 @@ server.on('connection', (clientToProxySocket) => {
var isFiltered = false;
var using = null;
Object.keys(serverCallbackMap).forEach((v)=>{
// console.log("Proxy is: "+ v);
// console.log(new RegExp(v).test(serverAddress));
if (new RegExp(v).test(serverAddress)) {
// It matches. We should run the handler.
using = v;

36
start-proxy.sh Normal file
View File

@ -0,0 +1,36 @@
#!/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