• linux-shell系列3-wafAPI


    #!/bin/bash

    datestr=`env LANG=en_US.UTF-8 date -u "+%a, %d %b %Y %H:%M:%S GMT"`
    pwdstr=`echo -en ${datestr}| openssl dgst -sha1 -hmac "XXXXXXX" -binary| openssl enc -base64`
    ########1 安全防护安全状态汇总
    total=http://XXXXXX
    ########2 安全防护攻击详细信息接口
    att_info=http://XXXXX
    ########3 安全防护攻击次数详细信息接口
    att_detail=http://XXXXXX
    ########4 安全防护攻击拦截趋势
    hit_deny=http://XXXXXX

    wafgetdata(){
    datestr=`env LANG=en_US.UTF-8 date -u "+%a, %d %b %Y %H:%M:%S GMT"`
    pwdstr=`echo -en ${datestr}| openssl dgst -sha1 -hmac "xxxxxx" -binary| openssl enc -base64`
    curl -s -X POST
    -u cdtv:${pwdstr}
    -H "Accept:application/xml"
    -H "Date:${datestr}"
    -d "$body" $url
    }

    echo "datestr: $datestr"
    echo "pwdstr: $pwdstr"

    #for p in $@;do
    # if [ $p == "k" ];then
    # p="";fi
    #done
    body1=("channel=$1" "cust=$2" "region=$3" "startdate=$4" "enddate=$5" "resultType=$6")
    body2=("channel=$1" "cust=$2" "region=$3" "startdate=$4" "enddate=$5" "attIp=$6")
    body3=("channel=$1" "cust=$2" "region=$3" "startdate=$4" "enddate=$5" "alarmType=$6" "alarmIp=$7")
    body4=("channel=$1" "cust=$2" "region=$3" "startdate=$4" "enddate=$5" "date=$6" "resultType=$7" "attackType=$8")

    echo ${body1[*]}
    for ((i=0;i<=$#-1;i++));do
    x=($@)
    if [ ${x[i]} == 'k' ];then
    unset body1[i]
    unset body2[i]
    unset body3[i]
    unset body4[i]
    fi
    done
    str1=`echo ${body1[*]} |sed -e 's/ /&/g'`
    str2=`echo ${body1[*]} |sed -e 's/ /&/g'`
    str3=`echo ${body1[*]} |sed -e 's/ /&/g'`
    str4=`echo ${body1[*]} |sed -e 's/ /&/g'`
    echo $str1

    if [ $7 == 1 ];then body=$str1;url=$total;fi
    if [ $7 == 2 ];then body=$str2;url=$att_info;fi
    if [ $8 == 3 ];then body=$str3;url=$att_detail;fi
    if [ $9 == 4 ];then body=$str4;url=$hit_deny;fi


    #body1="$channel&$cust&$region&$startdate&$enddate&$resultType"
    # 1 参数6 channel cust region startdate enddate resultType
    #body1=("channel=$1" "cust=$2" "region=$3" "startdate=$4" "enddate=$5" "resultType=$6")
    # 2 参数6 channel cust region startdate enddate attIp
    #body2="channel=$1&cust=$2&region=$3&startdate=$4&enddate=$5&attIp=$6"
    # 3 参数7 channel cust region startdate enddate alarmType alarmIp
    #body3="channel=$1&cust=$2&region=$3&startdate=$4&enddate=$5&alarmType=$6&alarmIp=$7"
    # 4 参数8 channel cust region startdate enddate date resultType attackType
    #body4="channel=$1&cust=$2&region=$3&startdate=$4&enddate=$5&date=$6&resultType=$7&attackType=$8"

    wafgetdata $body $url

  • 相关阅读:
    小作业5
    小作业4
    Matplotlib基础
    Numpy学习笔记(下篇)
    Numpy学习笔记(上篇)
    机器学习的经典算法与应用
    opencv学习笔记D01
    Markdown新手入门
    python之生成器yeild
    pyinstaller打包.py程序为.exe操作指南
  • 原文地址:https://www.cnblogs.com/kuku0223/p/7761409.html
Copyright © 2020-2023  润新知