快捷搜索:  汽车  科技

如何防御url 跳转漏洞,分享一个实用脚本

如何防御url 跳转漏洞,分享一个实用脚本

概述

上一次脚本没发出来,这次补上..

顺便分享一个URL检测脚本,仅供参考。


上一次查看磁盘使用TOP 10的脚本

#!/bin/bash #=============================================================================== # copyright by hwb # date:2020-11-3 # USAGE: ./find_disk_usage.sh <directory> # 用途: 根据指定目录,查找出目录下占用空间最大的top 10目录和文件 #=============================================================================== #传参 bk_directory="/" top_n=10 #调用函数库 [ -f /etc/init.d/functions ] && source /etc/init.d/functions export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin source /etc/profile #Require root to run this script. [ $(id -u) -gt 0 ] && echo "请用root用户执行此脚本!" && exit 1 #用第一个参数指定服务器目录 if [ -n "$1" ];then bk_directory=$1 #判断目录是否存在,防止当路径不存在时rm -rf /*之类问题发生 [ -d $bk_directory ] || echo "服务器目录[$bk_directory]不存在,请检查输入参数!" [ -d $bk_directory ] || exit 1 fi function find_disk_usage(){ echo "" echo -e "\033[33m************************File or directory [$bk_directory] disk usage top${top_n}************************\033[0m" temp_file=$( mktemp ) if [ $bk_directory = "/" ];then bk_directory="" fi #开始统计文件大小 top_count=1 while read usage_m file_path do [[ -f $file_path ]] && file_type="File"||file_type="Directory" #fmt -w 80命令会将echo输出的整行数据根据其命令选项指定的宽度(120个字符)进行折行显示,再将折行后的数据以多行的形式传递给sed命令。 #sed在收到fmt命令的格式化输出后,将会在折行后的第一行头部添加两个空格,在其余行的头部添加一个加号和一个空格以表示差别。 echo -e "\e[1;32m Top.${top_count} ${usage_m}(MB) ${file_type} $file_path \e[1;32m" | fmt -w 120 | sed -e '1s/^/ /' -e '2 $s/^/ /' top_count=$((top_count 1)) done <<< "$( du -am ${bk_directory}/* 2>$temp_file|sort -nr|head -${top_n} )" #打印没有权限日志 if [[ -s $temp_file ]];then cu_user=$( id|awk '{print $1}' ) echo "" echo -e "\033[33m*************************用户 $cu_user没有以下文件/目录权限************************\033[0m" cat $temp_file fi #删除临时文件 [[ -f $temp_file ]] && rm -f $temp_file echo "" echo -e "\033[33m*************************File or directory disk usage Over!**************************\033[0m" } find_disk_usage


URL检测脚本

#!/bin/bash #=============================================================================== # copyright by hwb # date:2020-11-4 # USAGE: ./get_url_status.sh <url> # 用途: 使用curl检测url,输出相关指标 #=============================================================================== #传参 url="https://xxxx" date=`date "%Y-%m-%d-%H:%M:%S"` #调用函数库 [ -f /etc/init.d/functions ] && source /etc/init.d/functions export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin source /etc/profile #Require root to run this script. [ $(id -u) -gt 0 ] && echo "请用root用户执行此脚本!" && exit 1 #用第一个参数指定服务器目录 if [ -n "$1" ];then url=$1 fi function get_url_status(){ echo "" echo -e "\033[33m*************************检测URL状态:${url}*************************\033[0m" echo "" echo -e "\033[36m Usage: $0 需检测URL地址[默认为https://xxxx] \033[0m" echo "" #测试URL echo "[${date}] >>> curl测试访问[${url}]的统计数据如下:" curl -L -w ' HTTP返回码:\t%{http_code} 返回内容大小:\t%{size_download} 重定向次数:\t%{num_redirects} 域名解析时长:\t%{time_namelookup} 建立链接时长:\t%{time_connect} 开始传输时长:\t%{time_starttransfer} 总时长:\t%{time_total} ' -o /dev/null -s "${url}" wget --spider -q -o /dev/null --tries=1 -T 5 ${url} if [ $? -eq 0 ] ;then echo "" echo -e "\033[32m 服务器访问[${url}]地址测试正常! \033[0m" else echo "" echo -e "\033[31m 服务器访问[${url}]地址测试异常! \033[0m" fi echo -e "\033[33m*********************完成${url}地址检测*****************************\033[0m" echo "" } get_url_status

如何防御url 跳转漏洞,分享一个实用脚本(1)


执行结果

如何防御url 跳转漏洞,分享一个实用脚本(2)

如何防御url 跳转漏洞,分享一个实用脚本(3)


后面会分享更多devops和DBA方面的内容,感兴趣的朋友可以关注下!

如何防御url 跳转漏洞,分享一个实用脚本(4)

猜您喜欢: