Sign in to follow this  
Followers 0
BrettF

Computers In Network

31 posts in this topic

Hi,

I'm toying with an idea to see what files are shared on all computers connected to the network. So now wth some questions....

1) How can I get all of the computers connected in the network?

2) How can I find the shared folders and files on the computer?

Thanks,

Bert

Share this post


Link to post
Share on other sites



@bert

This will list all the share information in a PC.

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Share", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output = $Output & "AccessMask: " & $objItem.AccessMask & @CRLF
      $Output = $Output & "AllowMaximum: " & $objItem.AllowMaximum & @CRLF
      $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
      $Output = $Output & "Description: " & $objItem.Description & @CRLF
      $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output = $Output & "MaximumAllowed: " & $objItem.MaximumAllowed & @CRLF
      $Output = $Output & "Name: " & $objItem.Name & @CRLF
      $Output = $Output & "Path: " & $objItem.Path & @CRLF
      $Output = $Output & "Status: " & $objItem.Status & @CRLF
      $Output = $Output & "Type: " & $objItem.Type & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Share" )
Endif


Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

So you need to wite a text file with all PC names in it and that to an Array,

This way you can pick up all share info from those PC's.

Enjoy !!

ptrex

Share this post


Link to post
Share on other sites

1) How can I get all of the computers connected in the network?

You can use the command "Net view" in a dos window to get the names of all the computers currently online. I take it you do not have Active Directory or a dhcp server?

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

You can use the command "Net view" in a dos window to get the names of all the computers currently online. I take it you do not have Active Directory or a dhcp server?

I was just going to mention Net View. I'm working on the same issue, but I think I'll just go with scanning ip's and giving users an option to input them manually. nbtstat can be a usefull tool if you want to get the computername from an IP-adress. Want an example?

Share this post


Link to post
Share on other sites

I was just going to mention Net View. I'm working on the same issue, but I think I'll just go with scanning ip's and giving users an option to input them manually. nbtstat can be a usefull tool if you want to get the computername from an IP-adress. Want an example?

Yes please.... :whistle:

Share this post


Link to post
Share on other sites

@bert

This will list all the share information in a PC.

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Share", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output = $Output & "AccessMask: " & $objItem.AccessMask & @CRLF
      $Output = $Output & "AllowMaximum: " & $objItem.AllowMaximum & @CRLF
      $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
      $Output = $Output & "Description: " & $objItem.Description & @CRLF
      $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output = $Output & "MaximumAllowed: " & $objItem.MaximumAllowed & @CRLF
      $Output = $Output & "Name: " & $objItem.Name & @CRLF
      $Output = $Output & "Path: " & $objItem.Path & @CRLF
      $Output = $Output & "Status: " & $objItem.Status & @CRLF
      $Output = $Output & "Type: " & $objItem.Type & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Share" )
Endif
Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

So you need to wite a text file with all PC names in it and that to an Array,

This way you can pick up all share info from those PC's.

Enjoy !!

ptrex

That worked really well.... :whistle: How can I get shared info from other computers??

Share this post


Link to post
Share on other sites

That worked really well.... :whistle: How can I get shared info from other computers??

That may be something I can help you with if you can wait. In my Macgyver Toolkit, I am actually working on just that same issue as well. What i am trying to do is then use SQLite to store the results. For now, I think a real time report would be easier.

The answer may lie in the leverage of WMI, something that is really quite a marvel once you understand it. But what if the application isn't registered? Then what? Then I say, you have to manually search the HD for files which as you can imagine, might take some time. This is where I was thinking I could hack into Windows Desktop Search engine / Google Desktop and see if I could rip out their data (If the PC is already using those tools).

As I work on this, I can let you know if you don't mind waiting. My schedule is pretty crazy so I don't know how long it might take me. The WMI portion shouldn't take long and I already have the function to list the PCs and then cycle thru them. All you would need is admin rights to the remote PCs.


Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

Share this post


Link to post
Share on other sites

That worked really well.... :whistle: How can I get shared info from other computers??

... you mean like shared computer files?

I'm pretty sure you just type

\\IPADDRESS

or

\\COMPUTERNAME

...but it seems kinda easy. I think I'm mis-understanding your question.

Share this post


Link to post
Share on other sites

... you mean like shared computer files?

I'm pretty sure you just type

\\IPADDRESS

or

\\COMPUTERNAME

...but it seems kinda easy. I think I'm mis-understanding your question.

Ok... That worked but how can i find the computers in a network?

Share this post


Link to post
Share on other sites

Ok... That worked but how can i find the computers in a network?

Bert, if you are a network tech, I highly recommend you read the MSDT book in order to understand XP and the next OS, VISTA. I'm a little nervous that you are asking for help on this issue cause I don't want you to do something that will cause issues later.

But if you need to know...

* If you are in an AD domain, then the list is in AD that you can export. In NT, it's a bit of a pain.

* If the network manager is willing, he can give you a list from the DHCP.

* You can always sniff your network but that requires a solid understanding of your network layout and the tools that you would use. Being that you are asking for help on this issue, I hesitate to say how to do this as you could cause serious issues depending on how you proceed.


Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

Share this post


Link to post
Share on other sites

can you state why you'ld want to list available pc's in the network first? Just curious.

Share this post


Link to post
Share on other sites

can you state why you'ld want to list available pc's in the network first? Just curious.

Accountability, auditing, organization, & security to start with. As with any network tool, you need to hav a list of your PCs that you can throw into your tool so that it can process each one. Without that list, it's like living in the dark. You don't know how many forks and knives you have nor do you know where they are. Imagine trying to find them.

How do you manage your network?


Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

Share this post


Link to post
Share on other sites

Accountability, auditing, organization, & security to start with. As with any network tool, you need to hav a list of your PCs that you can throw into your tool so that it can process each one. Without that list, it's like living in the dark. You don't know how many forks and knives you have nor do you know where they are. Imagine trying to find them.

How do you manage your network?

Sorry. Maybe I should have been more clear. I do get your reasoning though.... I'm maybe thinking that because it is part of a workgroup I could get all the computers from there??? Its not really my network.... Its schools. And (almost) everyone shares something.... Like a masive interconnected p2p network.... :whistle:

Share this post


Link to post
Share on other sites

I'd love to get a list of computers in a windows domain too, and not just offline ones with 'net view'.

Hmm..... I'm doing some reasearch now, seeing possible methods to get all computers in a workgroup... :whistle:

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Hmm..... I'm doing some reasearch now, seeing possible methods to get all computers in a workgroup... :whistle:

I'll join your research. I'm leaving domains and trying to get all computers in a workgroup too.

Edit: I know for fact that a router keeps a DHCP list. Getting that list might solve your problems..

Edited by Manadar

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Yes please.... :whistle:

$Info = _GetMacAndName("192.168.2.103")
If Not @error Then
    MsgBox(0x40,"_GetMacAndName()",$Info[0] & @CRLF & $Info[1])
Else
    MsgBox(0x20,"_GetMacAndName()", "Connection timed out. We were unable to get the mac-adress and name of the remote computer.")
EndIf


Func _GetMacAndName($g_IP)
    Dim $Return[2]
    $PID = Run(@ComSpec & " /c nbtstat -A " & $g_IP,@ScriptDir,@SW_HIDE,2)
    While ProcessExists($PID)
        Sleep(50)
    WEnd
    $nRead = StdoutRead($PID,1024)
    $Mac = StringRegExp($nRead,"([A-F0-9]{2}-?){6}",2)
    If Not @error Then
        $Computername = StringRegExp($nRead,"[^\n]+<..>",3)
        If Not @error Then
            $Computername = StringStripWS(StringTrimRight($Computername[0],4),8)
            $Return[0] = $Computername
            $Return[1] = $Mac[0]
            SetError(0)
            Return $Return
        EndIf
    EndIf
    SetError(1)
    Return 0
EndFunc
Edited by Manadar

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

I'll join your research. I'm leaving domains and trying to get all computers in a workgroup too.

Edit: I know for fact that a router keeps a DHCP list. Getting that list might solve your problems..

It would probably be easier to not try find that out............ I have no idea what the schools net even looks like.... With the whole place wireless, and everyone from grade 5 having laptops.... there's a few of them around..... (Last count around 2000+) and every person has 100mb of online storage (already around 200gb) But for what type the network is I have no idea.... I can tell you there's a proxy. and that the room with all the networking stuff has independant aircon! and they cant even get us some... :whistle: I did find a delphi code snipit, but it didnt really help.... :P

Edited by bert

Share this post


Link to post
Share on other sites

so ... basically you're just trying to grab stuff from other students computers without them knowing ? you could do a ipscan of the network, just use the netmask to figure out the span. Prolly the easiest way if you're unable to browse the DHCP-server.


> there are 10 types of people in the world, those who understand binary and those who don't.

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

so ... basically you're just trying to grab stuff from other students computers without them knowing ? you could do a ipscan of the network, just use the netmask to figure out the span. Prolly the easiest way if you're unable to browse the DHCP-server.

Heh..

Anywho, Quite an easy task, but it sounds like them two got it. :whistle: If they want to research it, the better! It'll be easier for them to understand.

Edited by CrewXp

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0