473,372 Members | 1,089 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

How to detect remote machine os, while connecting?


How to detect remote machine os, while connecting?
I want to find out remote machine os is windows/unix/linux/solaries, without login into the machine, while connecting itself.

Sep 25 '12 #1
17 6240
589 Expert Mod 512MB
You need to provide more details on what you need to accomplish and in what context is the user connecting. Is this connection via a network share, or a web service, or RDP or telnet or ssh or something else?

You will probably also need to post your script and any errors/warnings that it generates.
Sep 25 '12 #2
Hi Ron,

I am connecting hosts via Telnet. So can u guide me how to know the host's os.

Sep 26 '12 #3
3,509 Expert Mod 2GB
Are you saying that your using telnet from the system command in Perl, from a Perl Module, or are you using telnet on the command line without the use of Perl? You need to please specify.

If you are using Perl for this, then you NEED to please provide your code, otherwise we will be grasping at straws, blindly.


Sep 26 '12 #4
Here is the code i use to connect host using telnet.

1. use Net::Telnet;
2. $telnet = new Net::Telnet ( Timeout=>60, Errmode=>'die');
3. $telnet->open('10.xxx.xxx.xxx'); # unix/win/linux/sun
4. $telnet->waitfor('/login: $/i');
5. $telnet->print('administrator'); # root/administrator
6. $telnet->waitfor('/password: $/i');
7. $telnet->print('admin');
8. $telnet->waitfor('/\>/'); # '/\>/'--win, '/# $/i' - unix

I need to know the os of host, before i login. at step 3.
so that i will write my own code to perform as per the os. bcz
"telnet->waitfor('/\>/');" is differ for os.

Sep 26 '12 #5
using eclipse i am executing perl code.
Sep 26 '12 #6
589 Expert Mod 512MB
You can't use telnet to determine the OS prior to login, but you can use the nmap utility to scan the host and determine the OS. However, keep in mind that there is no reliable way to accurately determine the OS prior to logging into the system.

nmap network scanner:

Perl module to interface with nmap:

Output from a scan of google.com
C:\Users\RKB>nmap -O -sSU google.com

Starting Nmap 5.21 ( http://nmap.org ) at 2012-09-26 06:28 Pacific Daylight Time
Nmap scan report for google.com (
Host is up (0.0028s latency).
Hostname google.com resolves to 11 IPs. Only scanned
rDNS record for nuq04s08-in-f9.1e100.net
Not shown: 998 filtered ports, 998 open|filtered ports
80/tcp open http
113/tcp closed auth
443/tcp open https
33459/udp closed unknown
Device type: WAP|printer|webcam|general purpose
Running (JUST GUESSING) : Linksys Linux 2.4.X (87%), Lexmark embedded (87%), AXIS Linux 2.6.X (87%), Linux 2.6.X|2.4.X (86%)
Aggressive OS guesses: OpenWrt White Russian 0.9 (Linux 2.4.30) (87%), Lexmark X644e printer (87%), AXIS 211A Network Camera (Linux 2.6) (87%), AXIS 211A Network Camera (Linux 2.6.20) (87%), OpenWrt Kamikaze 7.09 (Linux 2.6.2
2) (86%), Linux 2.6.24 (86%), OpenWrt 0.9 - 7.09 (Linux 2.4.30 - 2.4.34) (85%), Linux 2.4.20 - 2.4.27 (85%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 14 hops

OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 13.47 seconds
Sep 26 '12 #7
i hear that we can use socket function also to check os. if any help in this, it would be helpful for my script.
Sep 26 '12 #8
589 Expert Mod 512MB
Yes you can make a low level socket connection to a service running on the remote server (which is what Net::Telnet does). You need to decide which service you want/need to connect to which will give you the info you want.

Socket - networking constants and support functions
IO::Socket - Object interface to socket communications
Sep 26 '12 #9
can you give simple code to check host os.
Sep 27 '12 #10
589 Expert Mod 512MB
Sorry, I don't know of any server service that would easily give you the OS, so I can't give you what you want.

The nmap utility tries to "guess" the OS by looking at key "footprints", but I have no idea how they do that, however nmap is open source, so you can look at it's source code to try to find out how they attempt to discover the OS.

Why is it so important for you to know the OS prior to login?

If you're able to login via telnet, then it would be simple to execute a command to learn that info.
Sep 27 '12 #11
if i know the os, then i will login to specified host and write my code individually. because commands are differ from win to unix. commands are simple - diskpart,...
Sep 27 '12 #12
589 Expert Mod 512MB
Then the simple solution would be to put the OS specific code into subroutines and AFTER you login, you determine the OS and then execute the proper subroutine.
Sep 27 '12 #13
589 Expert Mod 512MB
The more I read over your posts, the more it appears to me that you're attempting to write some sort of malware.
Sep 27 '12 #14
Hi RonB,

If you see my code above, if i know the host os with that i can recognize(windows command prompt - >, unix - $) the host type and then i can proceed my code as per. For my job needs username(step 5) needs only administrator for windows and root for unix/linux. so if i know it before i will go straight.
Sep 27 '12 #15
After i connect, i have to give username. There i need to know the OS type. Based on that i will give username.
Sep 27 '12 #16
589 Expert Mod 512MB
You're not going to be able to determine the OS prior to login.
Sep 27 '12 #17
589 Expert Mod 512MB
Here's an example demonstrating the fact that you won;t be able to accurately determine the OS.

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  3. use 5.10.1;
  4. use strict;
  5. use warnings;
  6. use XML::Simple;
  7. use Data::Dumper;
  9. close STDERR;
  11. foreach my $ip ( qw( ) {
  12.     say "scanning $ip";
  13.     say '-' x 21;
  14.     my $nmap = `nmap -v -v -v -O  -oX - $ip`;
  15.     my $nmap_xml = XMLin($nmap);
  16.     say Dumper keys %{ $nmap_xml->{host}{os}{osmatch} };
  17. }
$VAR1 = 'name';
$VAR2 = 'accuracy';
$VAR3 = 'line';


$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)';
All 3 of those hosts are on the local network.

Can you tell me the OS for the first 2 and which one of those 10 results for the 3rd host is correct?
Sep 27 '12 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Marina Anufreichik | last post by:
Hi, After deploymnet web application on web server I can access page on local machine and login fine but when I'm trying to access web site from remote machine I can see login page, but when I'm...
by: McGeeky | last post by:
Is it possible to install an assembly on a remote machine's GAC? I don't see an option for it using gacutil.exe -- McGeeky http://mcgeeky.blogspot.com
by: Rohith | last post by:
I need to import dlls that are present in the remote machine. Its a dll written in C that exposes methods. I want to import that dll in my C# application. But that dll is not present in the local...
by: Winterminute | last post by:
I am trying to read a list of install programs using WMI with ASP.NET/C#. However, it fails with "Invalid Class". I have confirmed that if I query LOCALHOST then it works fine, but if I query a...
by: Wiwo | last post by:
Hello there! I'm trying to enable/disable a network interface card on a remote machine. No, I don't cut my own connection. The machine has two network interfaces and I want to control the second...
by: Chris Johnson | last post by:
Hey all, I have a small app I have developed that periodically pings a list of server and returns their status. Given my environment I have setup the program such that a server can be down 4...
by: remya1000 | last post by:
i'm tring to start a calculator in a remote machine from my system. and the codes i tried is this. Module Module1 Sub Main() Dim retValue As String retValue =...
by: Chris Marsh | last post by:
All I've been asked run a VM on my development machine, with Windows Server 2003 installed. I've also been asked to then develop against this environment from the host machine, using Visual...
by: vinoj | last post by:
Hi All, These are the following things which i want to do:- 1. I will be taking the ipaddress, username and password from the user using cgi ffrom the browser. 2. Now i want...
by: Namitha Bhat | last post by:
Hi ALL, This realates to vb script code to append a file in C Drive in a remote machine accessed from a machine in different domain. I am able to successfully connect to the machine, but the file...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.