Sign in to follow this  
Followers 0
Fabry

LAN Broadcast

19 posts in this topic

In my Lan there are some subnets. How can I comunicate to everyone with a only one msg? I know in a subnet can I use the broadcast (192.168.x.255), but how in some subnets? With Netbeui? Can I use a dll?

Thank in advance.


A lan chat (Multilanguage)LanMuleFile transferTank gameTank 2 an online game[center]L'esperienza è il nome che tutti danno ai propri errori.Experience is the name everyone gives to their mistakes.Oscar Wilde[/center]

Share this post


Link to post
Share on other sites



@Fabry

You could use the cmd NET SEND in combination with NET VIEW for getting the subnets.

or Modify this appl.

Dim $un = @UserName
Dim $QT_web = "www.ClickTask.com"
$ver = "1.0"

;delete last listing
Filedelete(@TempDir & "\a.tmp")
Filedelete(@TempDir & "\b.tmp")

; make sure net send is running
RunWait("net start messenger","",@SW_HIDE)

;gets the computer list and a few other things
RunWait(@ComSpec & ' /c net view > ' & @TempDir & '\a.tmp',"", @SW_HIDE)
Sleep(300)
;open the file for working
$file = FileOpen(@TempDir & "\a.tmp", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "QT - Error", "Unable to open file.")
    Exit
EndIf

;Creates new file in which the result will be written
FileOpen(@TempDir & "\b.tmp", 1)

; Read in lines of text until the EOF is reached in file a.tmp
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
  ;find the string "\\"
    $result = StringInStr($line,"\\")
      if $result = 1 Then
    ;find next blank
      $blankpos = StringInStr($line," ")
    ;Find length of line
      $len = StringLen($line)
    ;calculate from what position to Trim string to the right
      $len = $len - $blankpos
    ;Trim all characters after the computer name
      $line = StringTrimRight($line, $len)
    ;Trim the //
      $line = StringTrimLeft($line,2)
    ;Write line to file, adding "|"
      FileWrite(@TempDir & "\b.tmp", $line & "|")
      EndIf

Wend

FileClose($file)
FileDelete(@TempDir & "\a.tmp")
$file2 = FileReadline(@TempDir & "\b.tmp", 1)

;install pics
    $Time_Logo = @TempDir & "\Time-logo.jpg"
    FileInstall("C:\XPClean-web\Settings\XPClean-pics\Time.jpg", $Time_Logo)
    $Time_icon = @TempDir & "\Time-Icon.ico"
    FileInstall("C:\XPClean-web\Settings\XPClean-pics\Time-Icon.ico", $Time_icon)
    $Sound_clk = @TempDir & "\Sound_clk.wav"
    FileInstall("C:\XPClean-web\Settings\XPClean-pics\Sounds\Clickerx.wav", $Sound_clk)
    $Sound_grp = @TempDir & "\Sound_grp.wav"
    FileInstall("C:\XPClean-web\Settings\XPClean-pics\Sounds\Group_open.wav", $Sound_grp)
    $Sound_bar = @TempDir & "\Sound_bar.wav"
    FileInstall("C:\XPClean-web\Settings\XPClean-pics\Sounds\xpinfbar.wav", $Sound_bar)
    $Sound_lnk = @TempDir & "\Sound_lnk.wav"
    FileInstall("C:\XPClean-web\Settings\XPClean-pics\Sounds\Notify.wav", $Sound_lnk)


;GUI Start
#include "GUIConstants.au3"
;#include <Process.au3>

;Set GUI
Opt("GUICoordMode", 1)
;Opt("GUINotifyMode", 1)
$Dummy_win = GUICreate('')
$Tmesg_win = GuiCreate("*QTime Station*  -  PC Messenger                                ver " & $ver, 482, 335, -1, -1,-1,$WS_EX_ACCEPTFILES,$Dummy_win);, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
GUISetFont(9, 400, -1, "MS Sans Serif")
GUISetIcon($Time_icon)
$Icon_1 = GUICtrlCreatePic($Time_Logo, 393, 10, 75, 70)
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "ClickTask.com")

$Group_1A = GuiCtrlCreateGroup( "Message from: ", 20, 10, 350, 50)
GUICtrlCreateLabel( $un, 40, 30, 150, 20)



;Create 1 combo box, give focus and populate with contents of b.tmp
$Group_1A = GuiCtrlCreateGroup("Message to: ",20, 70, 350, 50)
$combo_1 = GUICtrlCreateCombo("", 130, 87, 120, 20)
GUICtrlSetState(-1,$GUI_FOCUS)
GUICtrlSetData(-1,$file2)
$label_1 = GUICtrlCreateLabel( "C&hoose the PC", 40, 90, 80, 20)


$Group_4 = GuiCtrlCreateGroup("Last Message Sent", 20, 270, 350, 50)
$MSent = GUICtrlCreateLabel("No Recent Messages", 40, 288, 320, 28)

;Create buttons
$button_1 = GUICtrlCreateButton("S&end", 390, 190, 80, 30)
               GUICtrlSetState(-1,$GUI_DEFBUTTON)
$button_2 = GUICtrlCreateButton("Set-Up", 390, 275, 80, 20)
$button_3 = GUICtrlCreateButton("C&ancel",  390, 300, 80, 20)




;create text input
$Group_3 = GuiCtrlCreateGroup("Message Text", 20, 140, 350, 120)
GUICtrlCreateLabel("Please Type in Your Test Message in the Box Below", 40, 165, 310, 20)
GUICtrlCreateLabel("The Message includes the Time, Date, PC and Sender Name", 40, 185, 320, 20)
$text = GUICtrlCreateInput("Message", 40, 215, 310, 20)

;Show the GUI
GuiSetState (@SW_SHOW)
SoundPlay ($Sound_lnk,1)

;sets tray icon
    opt("TrayMenuMode", 1)  ; Default tray menu items (Script Paused/Exit) will not be shown.
    opt("TrayOnEventMode", 1)
;TraySetClick (16); right click
    
    $show_tray = TrayCreateItem ("Show  *QTime Station*")
    TrayItemSetOnEvent (-1, "Set_Show")
    TrayCreateItem ("")
    $upgrade_tray = TrayCreateItem ("Check New Releases")
    TrayItemSetOnEvent (-1, "Set_Update")
    TrayCreateItem ("")
    $setup_tray = TrayCreateItem ("Net-Send Setup")
    TrayItemSetOnEvent (-1, "Set_Setup")
    TrayCreateItem ("")
    $about_tray = TrayCreateItem ("About ClickTask.com")
    TrayItemSetOnEvent (-1, "Set_QT")
    TrayCreateItem ("")
    $exit_tray = TrayCreateItem ("Exit  *QTime Station*")
    TrayItemSetOnEvent (-1, "Set_Exit")
    
    TraySetState ()

$msg = 0
While 1; $msg <> -3
$msg = GuiGetMsg()
Select
case $msg = $button_3 Or $msg = $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $Tmesg_win)
    SoundPlay ($Sound_grp,1)
case $msg = $button_2
;SoundPlay ($Sound_clk,1)
    Call("Set_Setup")
case $msg = $button_1
    SoundPlay ($Sound_clk,1)
    $CPUID = GuictrlRead($combo_1)
    If $CPUID = "" Then
        MsgBox(64,"Send Error 1"," Please choose a PC to  *Send*  to...      ")
        ContinueLoop
    EndIf
    $msg1 = GuictrlRead($text)
    If $msg1 = "" Or $msg1 = "Message" Then
        MsgBox(64,"Send Error 2"," Please Type a  *Text Message*  First...      " )
        ContinueLoop
    EndIf
    $runvar =RunWait(@comspec & " /c net send " & $CPUID & $un & " says:   " & $msg1,"",@sw_hide)
;MsgBox(0,"",$runvar)
    If $runvar > 0 Then
        MsgBox(64,"Send Error 3"," Your Message   *Could Not Be Sent*       " & @CRLF & @CRLF & " Please press the  *Set-Up*  Button    "  & @CRLF & @CRLF & "and press  *Set-Up*  on " & $CPUID & "  " )
        ContinueLoop
    EndIf
    GUICtrlSetData ( $MSent, $msg1)
    EndSelect
WEnd

Exit

;---------------------------- FUNCTIONS ----------------------

Func Set_Update()
    SoundPlay ($Sound_clk,1)
    Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe " & $QT_web)
    WinWaitActive("")
EndFunc

Func Set_Show()
    SoundPlay ($Sound_grp,1)
    GUISetState(@SW_SHOW, $Tmesg_win)
EndFunc  

Func Set_QT()
    SoundPlay ($Sound_grp,1)
    $iMsgBoxAnswer = MsgBox(32, "*QTime Station* ,  by   QTasc (Now ClickTask.com)", "WHO IS,  QT APPRAISAL SERVICE CO ?" & @CRLF & "" & @CRLF & "We are a Real Estate Appraisal Company based in Riverside, California. " & @CRLF & "" & @CRLF & "Thank you." & @CRLF & "" & @CRLF & "", 60)
    Select
        Case $iMsgBoxAnswer = -1;Timeout
        EndSelect
    SoundPlay ($Sound_grp,1)
EndFunc

Func Set_Exit()
    SoundPlay ($Sound_lnk,1)
    Exit
EndFunc  ;==>Set_Exit

Func Set_Setup()
    SoundPlay ($Sound_clk,1)
    GUISetState(@SW_HIDE, $Tmesg_win)
    Run("mmc Services.msc -k netsvcs", @SystemDir)
    WinWaitActive("Services")
    Sleep(300)
    Send("{TAB}")
    Sleep(300)
    Send("Messenger")
    Sleep(300)
    Send("{ENTER}")
    Sleep(300)
    Send("!e")
    Sleep(300)
    Send("A")
    Sleep(300)
    Send("!A")
    Sleep(300)
    Send("!S")
    Sleep(2000)
    MsgBox(64,"Finished Set-up"," If all settings are satisfactory...    " & @CRLF & " Please press  *OK*   ")
    While 3
        If Not WinExists("Messenger Properties") Then ExitLoop
        Sleep(100)
    WEnd
    Sleep(100)
    WinClose("Services")
    
EndFunc  ;==>Set_Exit

Regards

ptrex

Share this post


Link to post
Share on other sites

sending UDP or TCP is useless because you would need to install client sotfware on each PC.

I'm saing about TCPSend() and UDPsend() functions. They don't need to be installed

A lan chat (Multilanguage)LanMuleFile transferTank gameTank 2 an online game[center]L'esperienza è il nome che tutti danno ai propri errori.Experience is the name everyone gives to their mistakes.Oscar Wilde[/center]

Share this post


Link to post
Share on other sites

What are you talking about? Of course TCPSend() and UDPsend() need a client on the remote computers. Are you expecting just to fire off some packets and the remote computers are going to act accordingly without a program running?

Just because something can be broadcast doesn't mean the remote machines know how to interpret it. NET SEND uses a messaging service builtin to Windows so it knows what to do with said broadcast.

Share this post


Link to post
Share on other sites

@ptrex

Yes, I want send data at all clients in listening, but in all subnets.

Managed switches might limit what you can do over the broadcast address, which is just all 1's in the host portion. But routers will NEVER let you pass broadcast packets, so it would be problematic to broadcast to "all subnets".

Within your own subnet, though, it could work.

If all the targets are listening on the same port number, and you broadcast UDP to that port, they might get it, I guess. Never tried it.

Ping 192.168.1.255 (assuming a net mask of /24) will get you multiple responses. But that's an ICMP packet.

TCP certainly won't work that way because you need to establish a connection with each target.

Then there's multicast... but that's another show.

- Alton Brown, on "Good Eats"

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I tried send a message at all broadcasts, but routers or switches filter it, they allow me to send at my broadcast.

For $i=0 to 255
$socket=udpopen('192.168.'&$i&'.255',$port)
udpsend($socket,'hello')
udpclose($socket)
next

It doesn't work for all broadcasts.


A lan chat (Multilanguage)LanMuleFile transferTank gameTank 2 an online game[center]L'esperienza è il nome che tutti danno ai propri errori.Experience is the name everyone gives to their mistakes.Oscar Wilde[/center]

Share this post


Link to post
Share on other sites

I tried send a message at all broadcasts, but routers or switches filter it, they allow me to send at my broadcast.

It doesn't work for all broadcasts.

You mean it worked for some? Which ones worked and which didn't? :P

The default mask for 192.168.x.y is /16, or 255.255.0.0. So your code would only produce an actual broadcast ONCE when it hit 192.168.255.255.

Unless you have a different mask, like /24 or 255.255.255.0 - Then your code would attempt broadcast on the various class-C subnets, but would likely fail because the gateway routing interface (at .1 or .254) is not likely to pass broadcasts.

Why are you trying to do broadcasts on a network you have to reach via the gateway anyway???

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

what you could do is allow one port to be opened.. write a client that can accept TCP And UDP Functions (like a tunneler)

then you can install this client on all PC's in every subnet. then you can send any type of packet to any subnet using this tunneler..

this is functionality that I came across for the first time while hacking (my own network) :) and nowadays altiris deployment server (PC Lifecycle management software) uses this to get their wake on lan packets to anywhere in the company..

Edited by lordofthestrings

Share this post


Link to post
Share on other sites

I think to send data every pc (turned on), the list of pc up (in italian=accesi) I get with net view, but only my domain , then for get all domain I tried "net view /domain > c:\temp.txt", but how can I exctract the domain from the file Temp.txt?


A lan chat (Multilanguage)LanMuleFile transferTank gameTank 2 an online game[center]L'esperienza è il nome che tutti danno ai propri errori.Experience is the name everyone gives to their mistakes.Oscar Wilde[/center]

Share this post


Link to post
Share on other sites

I would try:

(dos CMD that you can use from AutoIt)

FOR /F "usebackq skip=2" %x in (`net view /DOMAIN`) do net view /DOM:%x>>results.txt

so for every domain in "net view /DOMAIN" do net view /DOM:domainname (and place output in results textfile)

I hope this helps a bit?


Share this post


Link to post
Share on other sites

I would try:

(dos CMD that you can use from AutoIt)

FOR /F "usebackq skip=2" %x in (`net view /DOMAIN`) do net view /DOM:%x>>results.txt

so for every domain in "net view /DOMAIN" do net view /DOM:domainname (and place output in results textfile)

I hope this helps a bit?

Great, it works but give me error 87 and 6118. It does "net view /domain:"for every line, then give me errors when it does "net view /DOM:------------------------"

and "net view /DOM:Esecuzione comando riuscita" (=Comand executed succesfully)


A lan chat (Multilanguage)LanMuleFile transferTank gameTank 2 an online game[center]L'esperienza è il nome che tutti danno ai propri errori.Experience is the name everyone gives to their mistakes.Oscar Wilde[/center]

Share this post


Link to post
Share on other sites

You forget about Wake On LAN...

What are you talking about? Of course TCPSend() and UDPsend() need a client on the remote computers. Are you expecting just to fire off some packets and the remote computers are going to act accordingly without a program running?

Just because something can be broadcast doesn't mean the remote machines know how to interpret it. NET SEND uses a messaging service builtin to Windows so it knows what to do with said broadcast.

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