vbscript의 nmap 출력을 구문 분석하여 OS 만 반환


0

IP 주소를 쿼리하고 (아마도) 운영 체제를 반환하는 nmap 이라는 유틸리티를 찾았습니다 . 내 테스트에서 완벽하게 작동했습니다. vbscript에 포함시키고 함수로 호출하고 운영 체제 버전 만 반환하고 싶습니다.

샘플 출력 :

Starting Nmap 6.25 ( http://nmap.org ) at 2013-04-25 13:30 Central Daylight Time
Initiating Ping Scan at 13:30
Scanning servername (1.2.3.4) [4 ports]
Completed Ping Scan at 13:30, 0.28s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 13:30
Completed Parallel DNS resolution of 1 host. at 13:30, 0.02s elapsed
Initiating SYN Stealth Scan at 13:30
Scanning servername (1.2.3.4) [1000 ports]
Discovered open port 139/tcp on 1.2.3.4
Discovered open port 3389/tcp on 1.2.3.4
Discovered open port 80/tcp on 1.2.3.4
Discovered open port 445/tcp on 1.2.3.4
Discovered open port 3306/tcp on 1.2.3.4
Discovered open port 135/tcp on 1.2.3.4
Discovered open port 1025/tcp on 1.2.3.4
Discovered open port 1066/tcp on 1.2.3.4
Discovered open port 4445/tcp on 1.2.3.4
Completed SYN Stealth Scan at 13:30, 0.40s elapsed (1000 total ports)
Initiating OS detection (try #1) against servername (1.2.3.4)
Nmap scan report for servername (1.2.3.4)
Host is up (0.014s latency).
Not shown: 991 closed ports
PORT     STATE SERVICE
80/tcp   open  http
135/tcp  open  msrpc
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
1025/tcp open  NFS-or-IIS
1066/tcp open  fpo-fns
3306/tcp open  mysql
3389/tcp open  ms-wbt-server
4445/tcp open  upnotifyp
Device type: general purpose
Running: Microsoft Windows 2003
OS CPE: cpe:/o:microsoft:windows_server_2003::sp1 cpe:/o:microsoft:windows_server_2003::sp2
OS details: Microsoft Windows Server 2003 SP1 or SP2
Network Distance: 7 hops
TCP Sequence Prediction: Difficulty=262 (Good luck!)
IP ID Sequence Generation: Incremental

Read data files from: I:\Scott\Utilities\nmap-6.25
OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 2.30 seconds
           Raw packets sent: 1020 (45.570KB) | Rcvd: 1020 (41.434KB)

답변:


1

이것은 매우 잘 작동하는 것 같습니다

Public function GetOS(ServerName)
    Set objWShell = CreateObject("WScript.Shell") 
    Set objCmd = objWShell.Exec("nmap -O -v " & ServerName) 
    strPResult = objCmd.StdOut.Readall() 
    set objCmd = nothing: Set objWShell = nothing 
    GetOS = "Unknown" 
    if InStr(strPResult,"OS details:")>0 then 
        strTemp1 = split(strPResult,"OS details: ")
        strTemp2 = split(strTemp1(1),vbCrLf)
        GetOS = strTemp2(0)
    end if
End function

wscript.echo GetOS(testserver)
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.