实验说明
运行脚本
XShell可运行,工具->脚本
def Main():
xsh.Screen.Synchronous = True
xsh.Screen.Send("cat /etc/redhat-release" + "\n") #查看是否为CentOS
xsh.Screen.WaitForString("[root@iZuf6g5tip9a6dn5hwy0dzZ ~]# ")
xsh.Screen.Send("yum list nmap" + "\n") #查看nmap是否安装
xsh.Screen.WaitForString("[root@iZuf6g5tip9a6dn5hwy0dzZ ~]# ")
xsh.Screen.Send("yum -y install nmap" + "\n") #安装nmap
xsh.Screen.WaitForString("[root@iZuf6g5tip9a6dn5hwy0dzZ ~]# ")
xsh.Screen.Send("nmap -version" + "\n") #查看nmap版本
xsh.Screen.WaitForString("[root@iZuf6g5tip9a6dn5hwy0dzZ ~]# ")
xsh.Screen.Send("nmap -vv 47.102.110.2-100" + "\n")
xsh.Screen.WaitForString("[root@iZuf6g5tip9a6dn5hwy0dzZ ~]# ")
xsh.Screen.Send("nmap -v -n -sP --max-rtt-timeout 500ms 47.102.110.2-100 -T4" + "\n") #加快扫描速度
xsh.Screen.WaitForString("[root@iZuf6g5tip9a6dn5hwy0dzZ ~]# ")
#发现在线的网络服务
xsh.Screen.Send("nmap -sS -vv -n -PN -p21 --max-rtt-timeout 500ms 47.102.110.1/24 -T4 -oG - | grep 'open'" + "\n") #FTP
xsh.Screen.WaitForString("[root@iZuf6g5tip9a6dn5hwy0dzZ ~]# ")
xsh.Screen.Send("nmap -sS -vv -n -PN -p3306 --max-rtt-timeout 500ms 47.102.110.1/24 -T4 -oG - | grep 'open'" + "\n") #MySQL
xsh.Screen.WaitForString("[root@iZuf6g5tip9a6dn5hwy0dzZ ~]# ")
xsh.Screen.Send("nm" + chr(9) + "a" + chr(9) + "-sS -vv -n -PN -p22 --max-rtt-timeout 500ms 47.102.110.1/24 -T4 -Og" + chr(8) + chr(8) + "oG - | grep 'open'" + "\n") #SSH