Advertisement
Guest User

Untitled

a guest
May 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #!/bin/bash
  2. SIMPLE=0
  3. while getopts i:r:input:rule:s:simple option
  4. do
  5. case "${option}"
  6. in
  7. i) INPUT_FILE=${OPTARG};;
  8. input) INPUT_FILE=${OPTARG};;
  9. r) RULE_FILE=${OPTARG};;
  10. rule) RULE_FILE=$OPTARG;;
  11. s) SIMPLE=1;;
  12. simple) SIMPLE=1;;
  13. esac
  14. done
  15.  
  16. # validate input & print guide
  17. #echo $INPUT_FILE
  18. #echo $RULE_FILE
  19.  
  20. IOCS_IN_LINE=$(cat "$INPUT_FILE" | tr "\n" " ")
  21. IOCS_ARRAY=($IOCS_IN_LINE)
  22. IOCS_ARRAY_LEN=${#IOCS_ARRAY[@]}
  23. #echo ${IOCS_ARRAY[*]}
  24. #echo "Number of IoCs: $IOCS_ARRAY_LEN"
  25. for IOC in "${IOCS_ARRAY[@]}"; do
  26. # strip space
  27. IOC=$(echo $IOC | xargs)
  28. grep -i "$IOC" $RULE_FILE >/dev/null 2>&1
  29. RESULT=$?
  30. if [ ! $RESULT -eq 0 ]; then
  31. echo "$IOC"
  32. fi
  33. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement