enaiman Posted November 15, 2007 Posted November 15, 2007 (edited) I wonder if it is possible to detect if a TFTP server application is running or not. (the application name is unknown = it could be any TFTP type application so ProcessList won't help) I know that a TFTP server listens on port 69 but I'm not sure if it opens that port or not (I suppose "listening" = opening the port but I might be wrong about). What I tried so far: I made a small script to open UDP port 69 UDPStartup() $socket = UDPOpen("192.168.0.30", 69) If @error Then MsgBox(16,"err", "can't open") Else MsgBox(16,"ok", "opened") EndIf UDPCloseSocket($socket) UDPShutdown() Ran this with a TFTP server running and without (hoping that if the server is running I won't be able to open the port) and the result: I always opened the port no matter the status of TFTP server. Can some1 give me some ideas about how could I detect if something is listening on this port? Thank you, edit: Tried also 127.0.0.1 for IP and got the same result Edited November 15, 2007 by enaiman SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
CoePSX Posted November 15, 2007 Posted November 15, 2007 Why don't you send an WRQ packet to your own UDP port 69 to see if it returns an ACK? [quote name='Valik' post='301213' date='Jan 31 2007, 10:36 PM']You seem to have a habit of putting things in the wrong place. I feel sorry for any female you attempt to have sex with.[/quote][font="Lucida Sans Unicode"]╔══════════════════════════════╗║░░██░░░░░░░░██░░███░░░████░░░█║║░█░░█░░██░░█░░█░█░░█░█░░░░█░█░║║░█░░░░█░░█░████░███░░░██░░░█░░║║░█░░█░█░░█░█░░░░█░░░░░░░█░█░█░║║░░██░░░██░░░██░░█░░░░███░█░░░█║╚══════════════════════════════╝[/font]
ptrex Posted November 15, 2007 Posted November 15, 2007 @ In the same exampke script you posted you could include a listener. To see that you receive feedback from the server. While (1) $srcv = UDPRecv($Socket, 69) If ($srcv <> "") Then ConsoleWrite("Received Response" & @CR) ConsoleWrite($srcv & @CR) EndIf sleep(100) WEnd In a normal good connection state you should get back a response like Received Response HTTP/1.1 200 OK Then if this response is there you can perform an action in the script. Regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
enaiman Posted November 15, 2007 Author Posted November 15, 2007 (edited) @CoePSX and ptrex Thank you very much - I have never thought to do that. It is brilliant edit: tried the following code: UDPStartup() $socket = UDPOpen("192.168.0.30", 69) While (1) $status = UDPSend($socket, "Message") If $status = 0 then MsgBox(0, "ERROR", "Error while sending UDP message: " & @error) Exit EndIf ;sleep(100) $srcv = UDPRecv($Socket, 200) If ($srcv <> "") Then ConsoleWrite("Received Response" & @CR) ConsoleWrite($srcv & @CR) ExitLoop EndIf sleep(100) WEnd UDPCloseSocket($socket) UDPShutdown() the UDPSend is working fine, I can see the result on my TFTP server (aborted requests) but UDPReceive returns nothing, any ideas? Thanks, Edited November 15, 2007 by enaiman SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
ptrex Posted November 16, 2007 Posted November 16, 2007 @enaiman This works on my network. expandcollapse popup#include <string.au3> Dim $Broadcast $Broadcast = "10.0.0.X" ; Your address here $Port = 69 ; UDP 69 = TFTP port UDPStartUp() $Start = 1 $Socket = UDPopen($Broadcast, $Port) ConsoleWrite($Socket[1] & "|" & $Socket[2] & "|" & $Socket[3] & @LF & @LF) $cmd = 'PING ICMP' & @CRLF ;$cmd &= 'HOST:239.255.255.250:69' & @CRLF $cmd &= @CRLF ConsoleWrite($cmd & @LF& @LF) UDPSend($Socket, $cmd) _StartListener() sleep (2000) Func _StartListener() If $Start = 1 Then $i = 0 While (1) $srcv = UDPRecv($Socket, 2048) If ($srcv <> "") Then ConsoleWrite("Received Response" & @CR) ConsoleWrite($srcv & @CR) ConsoleWrite(_HexToString(Stringmid($srcv,9)) & @CR) EndIf sleep(100) WEnd EndIf EndFunc Func OnAutoItExit() UDPCloseSocket($Socket) UDPShutdown() EndFunc But beaware that the returned data might be HEX data. When testing this the HEXToString function is bugged in AU3. See bug Report where I posted a fix for this. Regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
enaiman Posted November 17, 2007 Author Posted November 17, 2007 @ptrex Thank you, I really appreciate it. I will test the code on Monday and I'll let you know about the outcome. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
ptrex Posted November 17, 2007 Posted November 17, 2007 @enaiman OK You might have to change this line in the script in order to get correct output depending on what the device is replying. ConsoleWrite(_HexToString(Stringmid($srcv,9)) & @CR) regards, Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
hellAT Posted November 17, 2007 Posted November 17, 2007 hm, is tftp (what should be checked) running on the pc where the script is running? that it might be enought to use a netstat... "netstat -an -p udp | findstr :69" and look in the result... /Karsten
enaiman Posted November 18, 2007 Author Posted November 18, 2007 @ptrex and hell@wurstgurke.de Gentlemen, thank you very much for your help, Both examples work very nice SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now