Advertisement
goebelmasse

SURBL-Abfrage für Domains (verbesserte Version)

Aug 21st, 2016 (edited)
1,797
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.12 KB | None | 0 0
  1. #!/bin/sh
  2. ########################################################################
  3. #
  4. # surbl
  5. # $Id: surbl,v 1.4 2023/12/22 10:58:17 elias Exp $
  6. #
  7. # Send queries to SURBL.
  8. #
  9. # Requires dig and gawk. (Does the good old awk perform bitwise ops?)
  10. #
  11. ########################################################################
  12.  
  13. if test -t 1
  14. then
  15.     term=1
  16. else
  17.     term=0
  18. fi
  19.  
  20. for domain
  21. do
  22.     result=`dig ${domain}.multi.surbl.org |
  23.     sed -e '/^;/d' -e '/^\s*$/d' -e '/SOA/d' -e 's/.*\.\(.*$\)/\1/'`
  24.     echo $domain $result
  25. done |
  26. gawk '
  27. BEGIN {
  28.  term = '$term'
  29.  if (term) {
  30.    red="\033[1;31m"
  31.    green="\033[1;32m"
  32.    norm="\033[0m"
  33.  } else {
  34.    red=""
  35.    green=""
  36.    norm=""
  37.  }
  38. }
  39. {
  40.  if(!$2) $2 = 0
  41.  printf("%s\t", $1)
  42.  if ($2)           { printf("%sLISTED:%s ", red, norm) }
  43.  if (and($2, 4))   { printf("DM ") }
  44.  if (and($2, 8))   { printf("PH ") }
  45.  if (and($2, 16))  { printf("MW ") }
  46.  if (and($2, 32))  { printf("CT ") }
  47.  if (and($2, 64))  { printf("ABUSE ") }
  48.  if (and($2, 128)) { printf("CR ") }
  49.  if (!$2)          { printf("%sokay%s", green, norm) }
  50.  printf("\n")
  51. }'
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement