Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to determine a Linux machine on a mixed network?

Posted on 2011-03-01
7
Medium Priority
?
274 Views
Last Modified: 2012-05-11
Experts,

      I have a Powershell script that based on the network OS, a specific script will run to change users password. I have the MS OS's figured out. How do I determine that the computer entered is a Linux? Below is the Powershell script I have written so far...
$strComputer = Read-Host "Enter Computer Name"
$OS = Get-WmiObject -Class win32_OperatingSystem -namespace "root\CIMV2" `
-ComputerName $strComputer

# if statement to run code for Windows XP and Windows 2003 Server.
if (($OS.Version -eq "5.1.2600") -or ($OS.Version -eq "5.2.3790"))
{
write-host "Computer Name: " $strComputer
#nested if statement
if ($OS.Version -eq "5.1.2600") {
write-host "OS Version: Windows XP"
.\PromptReset.ps1
}
elseif ($OS.Version -eq "5.2.3790") 
{
write-host "OS Version: Windows 2003"
.\PromptReset.ps1
}
write-host "Description: " $objPrinter.Description
write-host
}
}
# if statement to run code for Windows 2000 Server
#elseif ($OS.Version -eq "5.0.2195")
#{
#write-host "Computer Name: " $strComputer
#write-host "OS Version: Windows 2000 Server"
#$colPrinters = Get-WmiObject -Class win32_PrintJob -namespace "root\CIMV2" `
#-computername $strComputer
##foreach ($objPrinter in $colPrinters) {
#write-host "Name: " $objPrinter.Name
#write-host "Description: " $objPrinter.Description
#write-host
#}
#}

# if OS not identified
else {write-host "The OS for: $strComputer is not a Windows OS."}
write-host "–END OF REPORT–"

Open in new window

0
Comment
Question by:missymadi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 80

Expert Comment

by:arnold
ID: 35012030
You will not be able to connect to the resources you are trying to access which would mean either the system is non-windows or it has a firewall on without an exception to allow access to 445/139/etc.

0
 

Author Comment

by:missymadi
ID: 35012139
I'm not sure I understand your response....

I wanted to test for a Linux box, .... maybe one solution would be to see if port 22 is open(ssh) if this port is open then it is Linux and I can connect and run the script that is local on the Linux box.

Is there another way to determine if a network computer is Linux. I know that hacking software uses some sort of tool to determine the OS.  
0
 
LVL 80

Accepted Solution

by:
arnold earned 1000 total points
ID: 35012521
port 22 is one check, but there are ways to enable ssh access on a windows system as well.
there are ways to check OS based on a tcp packet and analyzing the responses for OS signatures.
All these checks are limited by the firewall settings if enabled.

You could connect to port 80 and get information that way as well.
HEAD / HTTP/1.0

Note this will require that the http service is running and it was not configured to masquerade i.e. only report that it is running apache without version/OS designation in the Server: HTTP response.
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 9

Assisted Solution

by:expert_tanmay
expert_tanmay earned 1000 total points
ID: 35013807
You may use NMAP it is a open source tool, it has OS detection plus many more goodies. It detects the OS by using TCP/IP stack fingerprinting. It sends many TCP/UDP packets and tries to guess the OS based on their responce. Please visit http://nmap.org/book/man-os-detection.html

Cheers ..
0
 
LVL 1

Expert Comment

by:mbkirk
ID: 35015907
A firewall will defeat nmap if ping is disabled.  

Basically, unless the remote server has security holes you're going to need a means of securely logging into it to running software or of connecting to a service it provides.  You could run an ssh server on it and use the command set it provides - that software is available for most platforms.  

If your goal is to update passwords would you be better off with something like a windows acrive directory and using kerberos, samba, or "windows services for unix" (if that still exists)?  This is an infrastructure change and as such may be a much bigger deal than what you're prodposing.

There was also a Web Services management protocol under development at some point.  I don't know what happened to it in the end, but I know Microsoft had a version, and it was being developed for Linux too.
0
 
LVL 9

Expert Comment

by:expert_tanmay
ID: 35022101
@mbkuk first of all the user has not mentioned any thing about a firewall. Also please note that NMAP does not work on ping. You may please read about advanced tcp/ip packet structures and how flags are used in packets. We are not talking about packets with SYN flag on where a firewall can block. There are plenty of documentation on NMAP in nmap.org please read them if you have deep understanding of tcp/ip..
0
 
LVL 1

Expert Comment

by:mbkirk
ID: 35022633
You're right, he didn't say.   My point is that if he wants to log in remotely to boxes to update passwords he's better off using something designed for managing installations.  He doesn't say what his full task is, only asks how he can make his software work.  Maybe he's really solving the problem he needs to solve, and maybe not.  

And you're right nmap doesn't only use ping - it was the end of a long day and I was going a bit too fast.  A halfway-decent firewall of the sort that most windows IT installations use will defeat nmap's "IP stack fingerprinting" and most of its other tools.   The machine simply will simply drop the packets.   On the linux side a halfway decent iptables configuration will defeat it as well.

0

Featured Post

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
This article explains the fundamentals of industrial networking which ultimately is the backbone network which is providing communications for process devices like robots and other not so interesting stuff.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question