使用方法:在linux环境下执行如下shell脚本,即可在/usr/bin下面生成脚本scanportDDCW.
scanportDDCW使用说明:直接执行该脚本显示本机开发的端口,scanportDDCW 主机 扫描主机开发的端口
代码如下:
#!/bin/env bash
#write by ddcw at 30191018
scriptname=$0
function exits(){
echo -e "\033[31;40m$1\033[0m"
exit 0
}
[ "`whoami`" == "root" ] || exits "this script must run by ROOT , \n(tips:tail -n +16 ${scriptname} )"
function set_SCANPORT() {
[ -f /usr/bin/scanportDDCW ] && exits "this os maybe have /usr/bin/scanportDDCW ,(so ,this script will be exit...)"
touch /usr/bin/scanportDDCW && tail -n +16 ${scriptname} > /usr/bin/scanportDDCW
chmod 755 /usr/bin/scanportDDCW && echo -e "now,you can run /usr/bin/\033[31;40mscanportDDCW\033[0m [hostname or ip] to get port of hosts,tips:default hostname is this OS `hostname`"
}
set_SCANPORT
exit 0
#!/bin/env bash
#write by ddcw at 30190823
dtbegin=`date +%s`
host=$1
[ -z ${host} ] && host=`hostname`
if ping -c 1 ${host} >/dev/null ;then
echo -e "${host} has been scann.........."
else
echo -e "\033[31;40m${host} net unreachable\033[0m"
exit 1
fi
for i in {1..65536}
do
if echo &>/dev/null > /dev/tcp/${host}/${i} ;then
echo -e "${host}:\t\033[31;40m${i}\033[0m is open"
fi
done
dtend=`date +%s`
echo -e "this script cost time: \033[32;40m`expr ${dtend} - ${dtbegin}`\033[0m second"
演示:
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。