#!/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

linux-shell系列3-wafAPI的更多相关文章

  1. Linux Shell系列教程之(十七) Shell文件包含

    本文是Linux Shell系列教程的第(十七)篇,更多Linux Shell教程请看:Linux Shell系列教程 通过文件包含,可以引用其他文件的内容,也可以将复杂内容分开,使程序结构更加清晰. ...

  2. Linux Shell系列教程之(十六) Shell输入输出重定向

    本文是Linux Shell系列教程的第(十六)篇,更多Linux Shell教程请看:Linux Shell系列教程 Shell中的输出和输入的重定向是在使用中经常用到的一个功能,非常实用,今天就为 ...

  3. Linux Shell系列教程之(十五) Shell函数简介

    本文是Linux Shell系列教程的第(十五)篇,更多Linux Shell教程请看:Linux Shell系列教程 函数可以将一个复杂功能划分成若干模块,从而使程序结构更加清晰,代码重复利用率更高 ...

  4. Linux Shell系列教程之(十四) Shell Select教程

    本文是Linux Shell系列教程的第(十四)篇,更多Linux Shell教程请看:Linux Shell系列教程 在上一篇文章:Linux Shell系列教程之(十三)Shell分支语句case ...

  5. Linux Shell系列教程之(十三)Shell分支语句case … esac教程

    本文是Linux Shell系列教程的第(十三)篇,更多Linux Shell教程请看:Linux Shell系列教程 分支语句非常实用,基本上高级语言都支持分支语句(python 没有),大多数都使 ...

  6. Linux Shell系列教程之(十二)Shell until循环

    本文是Linux Shell系列教程的第(十二)篇,更多Linux Shell教程请看:Linux Shell系列教程 在上两篇文章Linux Shell系列教程之(十)Shell for循环和Lin ...

  7. (转)Linux Shell系列教程之(十四) Shell Select教程

    本文属于<Linux Shell 系列教程>文章系列,该系列共包括以下 18 部分: Linux Shell系列教程之(一)Shell简介 Linux Shell系列教程之(二)第一个Sh ...

  8. Linux Shell系列教程

    学习Linux Shell知识,就来Linux大学网(Linuxdaxue.com)! 本系列适合Linux初学者,属于Linux入门级教程,主要介绍了Shell的分类.语法格式以及脚本的使用和编写格 ...

  9. Linux Shell系列教程之(十一)Shell while循环

    本文是Linux Shell系列教程的第(十一)篇,更多Linux Shell教程请看:Linux Shell系列教程 在上一篇Linux Shell系列教程之(十)Shell for循环中,我们已经 ...

  10. Linux Shell系列教程之(十)Shell for循环

    本文是Linux Shell系列教程的第(十)篇,更多Linux Shell教程请看:Linux Shell系列教程 基本任何语言都有自己的循环语句,Shell当然也不例外,今天就为大家介绍下Shel ...

随机推荐

  1. hibernate(*.hbm.xml)中新添加的字段被标记为红色(找不到)的解决方法

    首先得是以这个方式生成的bean和xml,配置好了数据源(这样才能让hibernate中的配置和mysql进行交互) https://www.cnblogs.com/kinome/p/10549969 ...

  2. BAT美团滴滴java面试大纲(带答案版)之三:多线程synchronized

    继续面试大纲系列文章. 从这一篇开始,我们进入ava编程中的一个重要领域---多线程!多线程就像武学中对的吸星大法,理解透了用好了可以得道成仙,俯瞰芸芸众生:而滥用则会遭其反噬. 在多线程编程中要渡的 ...

  3. 实现一个简单的ConnectionPool

    看了一圈, 没看到稍微好用的ConnectionPool, 除了一个aiomysql, 但是这个是异步的, 我暂时没有用到这么高版本的Python, 所以就动手造一个轮子. 原理比较简单, 先造一个线 ...

  4. P2P平台介绍

    https://www.ludou.org/tutengdai.html https://www.tutengdai.com/register?invite_code=9991300

  5. 容器互联(linking)

    容器互联(linking)是一种让多个容器中的应用进行快速交互的方式. 它会在源和接受容器中间创建连接关系,接受容器可以通过容器名快速访问到源容器而不用指出具体的IP地址.

  6. Leetcode-645 Set Mismatch

    The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of ...

  7. CF892/problem/C

    题目传送门: [http://codeforces.com/contest/892/problem/C] 题意: 给你一个长度为n的数组,相邻两个元素的GCD(最大公约数)可以取代二者的任意一个,问你 ...

  8. Day7 Ubantu学习(一)

    Linux是多用户操作系统 Ubantu学习参考网址:https://www.cnblogs.com/resn/p/5800922.html 1.虚拟机网络类型的理解 bridged(桥接模式) : ...

  9. Django model操作

    一.各种查询统计操作   def all(self) # 获取所有的数据对象 def filter(self, *args, **kwargs) # 条件查询 # 条件可以是:参数,字典,Q def ...

  10. YARN的笔记