Page 1 of 1

RIPE request for a given IP address

Posted: Sun Aug 20, 2006 10:09 pm
by fweil
Code updated For 5.20+
May you wish to know more about a given IP address, ie when analyzing a log file of your server, you can send a request to the RIPE organization. This can be done using http://www.ripe.net/.

But the RIPE allows, under certain condition of use to request directly to the database, using a telnet light protocol on 43 port.

Here is a code that you can run to test it.

By entering a given IP, the RIPE database will send back all registered information about the corresponding record.

Code: Select all

    Enumeration
      #Window_Main
      #Gadget_String
      #Gadget_Editor
    EndEnumeration

    Procedure.s ReceiveNetworkString(ConnectionID, *Buffer, BufferLength)
      Result.s = ""
      Length = BufferLength
      While Length = BufferLength
        Length = ReceiveNetworkData(ConnectionID, *Buffer, BufferLength)
        Result + PeekS(*Buffer, Length)
      Wend
      ProcedureReturn Result
    EndProcedure

    Procedure.s RIPE(Server.s)
      BufferLength = 1000
      *Buffer = AllocateMemory(BufferLength)
      ConnectionID = OpenNetworkConnection("whois.ripe.net", 43, #PB_Network_TCP)
      If ConnectionID
          String.s = ReceiveNetworkString(ConnectionID, *Buffer, BufferLength)
          SendNetworkString(ConnectionID, "-B " + Server + Chr(10))
          String + ReceiveNetworkString(ConnectionID, *Buffer, BufferLength)
          String + ReceiveNetworkString(ConnectionID, *Buffer, BufferLength)
          CloseNetworkConnection(ConnectionID)
      EndIf
      ProcedureReturn String
    EndProcedure

    ;
    ;
    ;
      If InitNetwork()
          WindowWidth = 640
          WindowHeight = 480
          WindowTitle.s = "RIPE information request"
          If OpenWindow(#Window_Main, 0, 0, WindowWidth, WindowHeight, WindowTitle, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
              AddKeyboardShortcut(#Window_Main, #PB_Shortcut_Escape, #PB_Shortcut_Escape)
              AddKeyboardShortcut(#Window_Main, #PB_Shortcut_Return, #PB_Shortcut_Return)

                  StringGadget(#Gadget_String, 10, 10, WindowWidth - 20, 20, "")
                  EditorGadget(#Gadget_Editor, 10, 40, WindowWidth - 20, WindowHeight - 50)
              EndIf
              Quit = #False
              Repeat
                Select WaitWindowEvent()
                  Case #PB_Event_CloseWindow
                    Quit = #True
                  Case #PB_Event_Menu
                    Select EventMenu()
                      Case #PB_Shortcut_Escape
                        Quit = #True
                      Case #PB_Shortcut_Return
                        SetGadgetText(#Gadget_Editor, RIPE(GetGadgetText(#Gadget_String)))
                    EndSelect
                EndSelect
              Until Quit
          EndIf

      CallDebugger
    End


Posted: Mon Aug 21, 2006 8:46 am
by dell_jockey
Bonjour FWeil,

'merci bien' for sharing this nice piece of code. Educational and useful!

thanks again