判断windows 3389端口和linux操作系统的脚本

发布时间:2020-07-02编辑:脚本学堂
判断windows 3389端口和linux操作系统的脚本

判断windows 3389端口和linux操作系统的脚本

复制代码 代码如下:

#!/bin/bash
###by gavin
##date:2012-10-12
##This is about scan windows and linux system,it can create remote'files that you use it on windows. you just only copy or mv this *.rdp  files to "C:Documents and SettingsAdministratorMy Documents" ,Okey you can use command "msts" ,seeing IP that can be remoted
##
cat>>rmote<<EOF
screen mode id:i:2
desktopwidth:i:1680
desktopheight:i:1050
session bpp:i:32
winposstr:s:0,1,22,200,822,800
compression:i:1
keyboardhook:i:2
displayconnectionbar:i:1
disable wallpaper:i:1
disable full window drag:i:1
allow desktop composition:i:0
allow font smoothing:i:0
disable menu anims:i:1
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1
full address:s:IP
audiomode:i:0
redirectprinters:i:1
redirectcomports:i:0
redirectsmartcards:i:1
redirectclipboard:i:1
redirectposdevices:i:0
autoreconnection enabled:i:1
authentication level:i:0
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:
gatewayusagemethod:i:4
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0
promptcredentialonce:i:1
username:s:administrator
EOF
#for i in {1..254};do
# cat 255.rdp>$IP.$i.rdp
# sed -i s/IP/$IP.$i.rdp/ ./$IP.$i.rdp
#done
IP=`ifconfig eth0 |grep "inet addr"| cut -f 2 -d ":"|cut -f 1 -d " "|awk -F. '{print $1"."$2"."$3}'`
PORT=3389
for I in {1..254};do
   nmap -sS $IP.$I -p 3389|grep open
if [ $? == 0 ];then
echo "$IP.$I:$PORT" >>./windows.txt
cat rmote >$IP.$I.rdp
sed -i 's/IP/$IP.$I/g' ./$IP.$I.rdp
fi
nmap -sS $IP.$I -p 22|grep open
if [ $? == 0 ];then
echo "$IP.$I" >>linux.txt
fi
done
echo "The windows.txt is windows system'ip,and it's 3389 port is opened !!"
echo "The linux.txt is linux system'ip,and it