Guest User

Untitled

a guest
Jul 15th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. #!/bin/bash
  2. # @author: Keshav Mohta
  3. # file use to pump events using python script; this shell script help to build the required json data
  4. # call as `sh kep_flag.sh -a <appName> -e <event> -t <eventType> -h <hostname>`
  5. # example sh kep_flag.sh -a "Magento" -e "Attack" -t "Buffer Error" -h "20.20.1.47"
  6. # event = Attack | Threat | File
  7. # eventType
  8. # Attack : "ReflectiveXSS" | "File Integrity" | "SQLi"| "Spectre" | "DLLi" | "CSRF" | "CMDi" | "Buffer Error"
  9. # Threat: "ReflectiveXSS" | "File Integrity" | "CSRF" |
  10. # content of additional sh file such as m.sh
  11. # #########
  12. #!/bin/bash
  13. # # Magento root ID list
  14. # export APPID=100103
  15. # export AIID=5
  16. # export SID=200203
  17. # export PID=300303
  18. # ##################
  19.  
  20. if [ $# -lt 1 ]; then
  21. echo "Your command line contains $# arguments"
  22. exit 1
  23. fi
  24.  
  25. while getopts a:e:h:t: option
  26. do
  27. case "${option}"
  28. in
  29. a)
  30. APP_NAME=${OPTARG}
  31. ;;
  32. e)
  33. EVENT=${OPTARG}
  34. ;;
  35. h)
  36. HOST=${OPTARG}
  37. ;;
  38. t)
  39. EVENT_TYPE=${OPTARG}
  40. ;;
  41. \?)
  42. echo "Invalid option: -$OPTARG" >&2
  43. exit 2;;
  44. esac
  45. done
  46.  
  47. count=$(gshuf -i 0-20 -n 1) #generate random number
  48.  
  49. # application wise addition details
  50.  
  51. if [ "$APP_NAME" == "Magento" ]; then
  52. source app/m.sh
  53. fi
  54.  
  55. if [ "$APP_NAME" == "Nginx" ]; then
  56. source app/n.sh
  57. fi
  58.  
  59. if [ "$APP_NAME" == "OpenText" ]; then
  60. source app/o.sh
  61. fi
  62.  
  63. if [ "$APP_NAME" == "Sap" ]; then
  64. source app/s.sh
  65. fi
  66.  
  67. if [ "$APP_NAME" == "Tomcat" ]; then
  68. source app/t.sh
  69. fi
  70.  
  71. if [ "$APP_NAME" == "Wondercare" ];
  72. then
  73. source app/w.sh
  74. else
  75. source app/test.sh
  76. fi
  77.  
  78. json_data=$(cat <<EOF
  79. {
  80. "type_of_event": "$EVENT",
  81. "cronus_event_type": "$EVENT_TYPE",
  82. "count": "$count",
  83. "time_interval": 1,
  84. "start_time": "",
  85. "application_name": "$APP_NAME",
  86. "application_id": $APPID,
  87. "AI_id": $AIID,
  88. "AI_name": "AppInstance_New",
  89. "applicationService_id": $SID,
  90. "process_id": $PID,
  91. "AE_id": 1234,
  92. "AE_name": "AnalysisEngine_new",
  93. "Canary_id": 4424,
  94. "Time_Out":"False"
  95. }
  96. EOF
  97. )
  98. echo "$json_data";
  99.  
  100. echo "$json_data" > incident.json
  101.  
  102. python3 ./KEP.py --zeus-host-ip="$HOST" --zeus-port=9092 --master-json=incident.json
Add Comment
Please, Sign In to add comment