exploit the possibilities

service_check.tcl

service_check.tcl
Posted Jan 11, 2000
Authored by Phil Ehrens

This is a simple script written in tcl which parses the output of the nmap program to determine whether required services are in fact running on a machine. Output is written as an html formatted log file.

tags | tool, scanner
systems | unix
MD5 | 1bff7c5cd7f052304d69dfdf624e2f1f

service_check.tcl

Change Mirror Download
#!/ldcg/bin/tclsh
# This is a simple script which parses the output of
# the nmap program to determine whether required services
# are in fact running on a machine. Output is written as
# an html formatted log file with a sensible default name.
# Two arguments are accepted:
#
# service_check [ hostname ] [ polling interval ]
#
# where polling interval is given in seconds.
# Note that there is considerable time overhead when
# running nmap in "Polite mode, so times less than 100 sec
# may be significantly longer than they should be!

;## no checking is done for bad values.
if { [ llength $argv ] == 2 } {
set host [ lindex $argv 0 ]
set interval [ lindex $argv 1 ]
} else {
set host $::env(HOST)
set interval 10
}

;## if a single arg is given, if it is an integer, assume
;## it is an interval, else it is a hostname.
if { [ llength $argv ] == 1 } {
if { [ regexp {^\d+$} [ lindex $argv 0 ] ] } {
set interval [ lindex $argv 0 ]
} else {
set host [ lindex $argv 0 ]
}
}

set log [ file join ${host}_servicelog.html ]

array set services {
7 echo
9 discard
13 daytime
19 chargen
22 ssh
25 smtp
37 time
111 sunrpc
512 exec
514 shell
515 printer
540 uucp
6000 X11
6112 dtspc
7100 font-service
10000 LDAS-manager-operator-port
}

set ports [ join [ lsort -integer [ array names services ] ] , ]
set fid [ open $log a+ ]


proc run {} {
set msg "<b>$::host</b> [ clock format [ clock seconds ] ]<br><ul>\n"
set data [ exec nmap -T Polite -p $::ports $::host ]
foreach port [ array names ::services ] {
set name $::services($port)
if { ! [ regexp "$port\[a-z \]+$name" $data ] } {
append msg "<item><font color=red><b>$name</b></font> not running on $::host port $port<br>\n"
}
}
puts $::fid "$msg<br></ul>\n"
flush $::fid
after [ expr { $::interval * 1000 } ] run
}
run
vwait enter-mainloop


Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

April 2019

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    21 Files
  • 2
    Apr 2nd
    35 Files
  • 3
    Apr 3rd
    21 Files
  • 4
    Apr 4th
    16 Files
  • 5
    Apr 5th
    15 Files
  • 6
    Apr 6th
    1 Files
  • 7
    Apr 7th
    2 Files
  • 8
    Apr 8th
    23 Files
  • 9
    Apr 9th
    19 Files
  • 10
    Apr 10th
    15 Files
  • 11
    Apr 11th
    14 Files
  • 12
    Apr 12th
    11 Files
  • 13
    Apr 13th
    2 Files
  • 14
    Apr 14th
    5 Files
  • 15
    Apr 15th
    14 Files
  • 16
    Apr 16th
    19 Files
  • 17
    Apr 17th
    19 Files
  • 18
    Apr 18th
    8 Files
  • 19
    Apr 19th
    4 Files
  • 20
    Apr 20th
    5 Files
  • 21
    Apr 21st
    1 Files
  • 22
    Apr 22nd
    10 Files
  • 23
    Apr 23rd
    22 Files
  • 24
    Apr 24th
    11 Files
  • 25
    Apr 25th
    10 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2019 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close