Board logo

标题: [文本处理] [已解决]批处理整理SYN扫描的结果,只保留IP和端口? [打印本页]

作者: vipd    时间: 2009-1-2 23:37     标题: [已解决]批处理整理SYN扫描的结果,只保留IP和端口?

首先这是一个SYN 端口扫描批处理.他扫描的端口是3个.然后生成一个Result.txt 的 文本 .
  1. @echo off
  2. setlocal
  3. cls
  4. color A
  5. del ips.txt
  6. del Result.txt
  7. for /f "eol= tokens=1,2 delims= " %%i in (1.txt) do s syn %%i %%j
复制代码
8088,8089,8090 /save
这是用S扫描器扫描,之后会生成一个Result.txt 的 文本

我希望最好能在这段代码的基础上增加处理代码.让最后只留下IP:端口

Result.txt 的 文本 .格式如下.

-------------------------------------------------------------------------------
Performing Time: 12/20/2008 21:39:10 --> SYN Scan: About To Scan 16384 IP For 5 Ports Using 1 Thread
202.96.219.14    808   Open            
202.96.219.21    8090  Open            
202.96.246.22    8089  Open            
202.96.246.22    808   Open            
202.96.246.22    8091  Open            
202.96.246.22    8088  Open            
202.96.246.22    8090  Open            
202.96.246.194   8090  Open            
Scan 16384 IPs Complete In 0 Hours 0 Minutes 4 Seconds. Found 8 Hosts
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Performing Time: 12/20/2008 21:39:15 --> SYN Scan: About To Scan 32768 IP For 5 Ports Using 1 Thread
202.109.10.133   8089  Open            
202.109.12.118   8090  Open            
202.109.12.119   8089  Open                        
202.109.123.164  8088  Open            
202.109.126.18   8088  Open            
202.109.126.18   8090  Open            
Scan 32768 IPs Complete In 0 Hours 1 Minutes 4 Seconds. Found 33 Hosts
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Performing Time: 12/20/2008 21:40:19 --> SYN Scan: About To Scan 32768 IP For 5 Ports Using 1 Thread
         
处理最后想要达到的效果,只留下IP:端口
58.50.245.20:8088
58.51.50.120:8090
58.51.64.11:8088
58.51.66.156:8088
58.51.113.179:8088
58.52.141.113:8089
58.52.157.69:8090
58.52.158.182:8090
58.52.216.215:8089
58.54.57.47:8090
58.54.116.3:8088
58.55.74.51:8090
58.55.75.55:8088
58.55.75.241:8090
58.55.229.2:8090
59.172.101.2:8090
59.172.185.3:8089
59.172.195.124:8089
59.173.69.151:8088
59.173.79.136:8089
59.173.119.2:8088
59.173.123.118:8088
59.173.180.54:8089
59.173.204.37:8089
59.173.225.196:8088
59.174.11.181:8089
59.174.89.144:8089
61.183.83.253:8088
116.208.62.58:8089
116.208.170.75:8090
116.208.177.197:8088
116.209.43.73:8088
119.99.133.103:8090
119.99.139.210:8088
119.99.217.120:8089
119.100.143.240:8090
119.101.216.68:8090
121.61.66.52:8089

原来的批处理是单端口扫描的.我把源码放来.这个只能处理一个端口扫描的.我想进行3个端口扫描.然后再进行处理。就如开题所用代码
  1. for /f "eol= tokens=1,2 delims= " %%i in (1.txt) do s syn %%i %%j 8088 /save
  2. for /f "eol=- tokens=1 delims= " %%i in (Result.txt) do echo %%i>>s1.txt
  3. for /f "eol=P tokens=1 delims= " %%i in (s1.txt) do echo %%i>>s2.txt
  4. for /f "eol=S tokens=1 delims= " %%i in (s2.txt) do echo %%i:8088>>ips.txt
复制代码

作者: shqf    时间: 2009-1-3 12:59

在你的BAT文件中result.txt文件生成后的后面加上如下语句即可:
  1. for /f "tokens=1,2,3" %%a in ('type result.txt') do (
  2.   if "%%c"=="Open" (
  3.     if not defined flag (
  4.       set flag=a
  5.       >result.txt echo %%a:%%b ) else (
  6.       >>result.txt echo %%a:%%b
  7.     )
  8.   )
  9. )
  10. result.txt
复制代码

[ 本帖最后由 shqf 于 2009-1-3 13:01 编辑 ]
作者: vipd    时间: 2009-1-3 19:19     标题: 回复 2楼 的帖子

哎..真是高人啊 ..牛就是牛 谢谢啊
作者: ccccpp    时间: 2011-9-7 13:38

学习,未明,研究一下




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2