After i connect, i have to give username. There i need to know the OS type. Based on that i will give username.
How to detect remote machine os, while connecting?
Collapse
X
-
Here's an example demonstrating the fact that you won;t be able to accurately determine the OS.
Code:#!/usr/bin/perl use 5.10.1; use strict; use warnings; use XML::Simple; use Data::Dumper; close STDERR; foreach my $ip ( qw(10.100.0.130 10.100.0.119 10.100.0.118) ) { say "scanning $ip"; say '-' x 21; my $nmap = `nmap -v -v -v -O -oX - $ip`; my $nmap_xml = XMLin($nmap); say Dumper keys %{ $nmap_xml->{host}{os}{osmatch} }; }
scanning 10.100.0.130
---------------------
$VAR1 = 'name';
$VAR2 = 'accuracy';
$VAR3 = 'line';
scanning 10.100.0.119
---------------------
scanning 10.100.0.118
---------------------
$VAR1 = 'AXIS 211A Network Camera (Linux 2.6.20)';
$VAR2 = 'Linux 2.6.17 (Mandriva)';
$VAR3 = 'Linux 2.6.9 - 2.6.18';
$VAR4 = 'Linux 2.6.22 - 2.6.23';
$VAR5 = 'IBM System Storage DS4700 NAS device';
$VAR6 = 'Linux 2.6.9 - 2.6.27';
$VAR7 = 'Linux 2.6.9 - 2.6.28';
$VAR8 = 'Linux 2.6.28 (Gentoo)';
$VAR9 = 'AXIS 211A Network Camera (Linux 2.6)';
$VAR10 = 'Linux 2.6.18 (Centos 5.3)';
Can you tell me the OS for the first 2 and which one of those 10 results for the 3rd host is correct?Comment
Comment