Skip to content

Commit

Permalink
scripts/bindhosts: add simple tcpdump wrapper
Browse files Browse the repository at this point in the history
this way, at the very least, user can sniff domains being resolved
  • Loading branch information
backslashxx committed Dec 16, 2024
1 parent 970efed commit b83ef1a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions module/bindhosts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,25 @@ action () {
[ -f $rwdir/bindhosts_lockfile ] && rm $rwdir/bindhosts_lockfile > /dev/null 2>&1
}

tcpdump () {
if command -v tcpdump > /dev/null 2>&1; then
# reset hosts
reset
echo "[+] make sure to restore hosts as needed"
echo "[+] spawning tcpdump"
echo "[!] press ctrl+c to exit"
su -c "tcpdump -ltni any dst port 53"
else
echo "[!] tcpdump not found"
echo "[x] bailing out"
exit 0
fi
}

show_help () {
echo "usage:"
printf " --action \t\tsimulate action.sh\n"
printf " --tcpdump \t\tsniff dns requests via tcpdump (experimental)\n"
printf " --force-update \tforce an update\n"
printf " --force-reset \t\tforce a reset\n"
printf " --custom-cron \t\tcustom schedule, syntax: \"0 2 * * *\" \n"
Expand All @@ -289,6 +305,7 @@ show_help () {
# add arguments
case "$1" in
--action) action; exit ;;
--tcpdump) tcpdump; exit ;;
--force-update) run; exit ;;
--force-reset) reset; exit ;;
--custom-cron) custom_cron "$@"; exit ;;
Expand Down

0 comments on commit b83ef1a

Please sign in to comment.