Win_telnet打造端口扫描工具

@echo off
set Cms=%*
setlocal enabledelayedexpansion
set files=""
set ports="" 
color 06
title telnet-scan端口扫描工具
if not defined Cms goto main
::-----------------参数分离开始-----------------------------------
if "%1" == "-l" (
set files=%2
)
if "%1" == "-d" (
goto del_history
)
if "%3" == "-l" (
set files=%4
)
if "%1" == "-p" (
set ports=%2
)
if "%3" == "-p" (
set ports=%4
)
echo %ports%
echo %files%
::-----------------参数分离结束-----------------------------------

::计算域名总数
set /a num=0
for /f %%i in (%files%) do (
set /a num=!num!+1
)


::----------------------开始扫描----------------------------------
set /a a=1
:sxh
set port=""
for /f "tokens=%a% delims=." %%i in ('echo %ports%') do (
set port=%%i
set /a a=%a%+1
)
if !port! NEQ "" (
echo --------------------程序正在扫描 !port! 端口,请稍后---------------------------------
::设置扫描到第几个域名
set /a nm=0 
::设置提示保存
set /a tib=0
for /f %%b in (%files%) do (
start /min cmd.exe /k "echo q|telnet %%b !port!&exit"
timeout /NOBREAK /t 1 >nul
set pd=""
for /f "tokens=1 delims= " %%a in ('tasklist /FI "windowtitle eq Telnet %%b"^|findstr "cmd.exe"') do (
set pd=%%a
)
if !pd! EQU "" (
echo %%b !port! Open
echo %%b>>!port!_Open.txt
set /a tib=1
) else (
echo %%b !port! Close
)
set /a nm=!nm!+1
title telnet-scan端口扫描工具 进度 !nm!/!num!
)
if !tib! == 0 (
echo -------------------------端口 !port! 扫描完毕-----------------------------------------
) else (
echo -------------------------端口 !port! 扫描完毕,保存为 !port!_Open.txt-----------------------
)
timeout /NOBREAK /t 35 >nul
goto sxh
) else (
goto tc
)
::----------------------扫描结束----------------------------------
:del_history
echo 正在删除历史扫描记录,请稍后.......
for /l %%i in (1,1,10000) do (
del /f /q %%i_Open.txt 1>nul 2>nul
)
echo 删除完毕!!!
goto tc
:main
mode con: cols=125 lines=45
echo  _       _            _ 
echo ^| ^|_ ___^| ^|_ __   ___^| ^|_     ___  ___ __ _ _ __  
echo ^| __^/ _ ^\ ^| ^'_ ^\ ^/ _ ^\ __^|____^/ __^|^/ __^/ _^` ^| ^'_ ^\
echo ^| ^|^|  __^/ ^| ^| ^| ^|  __^/ ^|^|_____^\__ ^\ ^(_^| ^(_^| ^| ^| ^| ^|
echo  ^\__^\___^|_^|_^| ^|_^|^\___^|^\__^|    ^|___^/^\___^\__^,_^|_^| ^|_^|
echo.
echo      ^<options^>:
echo                  -l  list     :域名列表文件
echo                  -p  port     :要扫描的端口
echo                  -d  del      :删除保存的历史记录(开放的端口号.txt)                       
echo.
echo       ^<Example^>:
echo                   scan.bat -l c:\host.txt -p 21   
echo                   scan.bat -l c:\host.txt -p 21.80.3389.1433                
echo.
:tc
-------------本文结束❤感谢阅读-------------

本文标题:Win_telnet打造端口扫描工具

文章作者:MaiKeFee

发布时间:2019年09月08日

最后更新:2019年09月08日

原始链接:http://MaiKeFee.com/archives/7c32cf47.html