How to detect remote machine os, while connecting?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ckant8
    New Member
    • Sep 2012
    • 10

    How to detect remote machine os, while connecting?

    Hi,

    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.


    Thanks
    srikanth
  • RonB
    Recognized Expert Contributor
    • Jun 2009
    • 589

    #2
    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.

    Comment

    • ckant8
      New Member
      • Sep 2012
      • 10

      #3
      Hi Ron,

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

      Thanks
      srikanth

      Comment

      • numberwhun
        Recognized Expert Moderator Specialist
        • May 2007
        • 3467

        #4
        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.

        Regards,

        Jeff

        Comment

        • ckant8
          New Member
          • Sep 2012
          • 10

          #5
          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.x xx.xxx'); # unix/win/linux/sun
          4. $telnet->waitfor('/login: $/i');
          5. $telnet->print('adminis trator'); # 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.

          Thanks
          srikanth

          Comment

          • ckant8
            New Member
            • Sep 2012
            • 10

            #6
            using eclipse i am executing perl code.

            Comment

            • RonB
              Recognized Expert Contributor
              • Jun 2009
              • 589

              #7
              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:
              Nmap Free Security Scanner, Port Scanner, & Network Exploration Tool. Download open source software for Linux, Windows, UNIX, FreeBSD, etc.


              Perl module to interface with nmap:
              Nmap::Scanner

              Output from a scan of google.com
              C:\Users\RKB>nm ap -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 (74.125.224.105 )
              Host is up (0.0028s latency).
              Hostname google.com resolves to 11 IPs. Only scanned 74.125.224.105
              rDNS record for 74.125.224.105: nuq04s08-in-f9.1e100.net
              Not shown: 998 filtered ports, 998 open|filtered ports
              PORT STATE SERVICE
              80/tcp open http
              113/tcp closed auth
              443/tcp open https
              33459/udp closed unknown
              Device type: WAP|printer|web cam|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

              Comment

              • ckant8
                New Member
                • Sep 2012
                • 10

                #8
                i hear that we can use socket function also to check os. if any help in this, it would be helpful for my script.

                Comment

                • RonB
                  Recognized Expert Contributor
                  • Jun 2009
                  • 589

                  #9
                  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

                  Comment

                  • ckant8
                    New Member
                    • Sep 2012
                    • 10

                    #10
                    can you give simple code to check host os.

                    Comment

                    • RonB
                      Recognized Expert Contributor
                      • Jun 2009
                      • 589

                      #11
                      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.

                      Comment

                      • ckant8
                        New Member
                        • Sep 2012
                        • 10

                        #12
                        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,...

                        Comment

                        • RonB
                          Recognized Expert Contributor
                          • Jun 2009
                          • 589

                          #13
                          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.

                          Comment

                          • RonB
                            Recognized Expert Contributor
                            • Jun 2009
                            • 589

                            #14
                            The more I read over your posts, the more it appears to me that you're attempting to write some sort of malware.

                            Comment

                            • ckant8
                              New Member
                              • Sep 2012
                              • 10

                              #15
                              Hi RonB,

                              If you see my code above, if i know the host os with that i can recognize(windo ws 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.

                              Comment

                              Working...