Jump to content

Problem in 'network-related' Function


SetEnv
 Share

Recommended Posts

Hello!

First of all: I'm sorry about my verry bad english...

Now...

I tried to write a simple function to get the abuse email related to an IP.

The code is not working, and I don't know why...

In fact: you can telnet 'whois.ripe.net 43' and ask for whois any ip/address you want. Then, you will receive the answer containing all the infos...

Here's the not-working-code ...

GetProviderMail()

Func GetProviderMail()
    $gSocket = TCPConnect("whois.ripe.net", "43")
    
    If $gSocket <> -1 Then ; If no error then
        TCPSend($gSocket, "4.2.2.4") ; ask about 4.2.2.4 (for example)
        
        $gSocket = -1
            
        Do
            $gSocket = TCPAccept($gSocket)
        Until $gSocket <> -1
        
        $gData = TCPRecv($gSocket,2048)
        
        $gDataSplit = StringSplit($gData,":")
        If $gDataSplit[1] == "e-mail" Then TrayTip("server","AbuseEmail for '4.2.2.4' is:"& $gDataSplit[2],5,2)
    EndIf
EndFunc
Link to comment
Share on other sites

  • Developers

to get you started:

GetProviderMail()
Func GetProviderMail()
    $gData = ""
    TCPStartup()
    $gSocket = TCPConnect(TCPNameToIP("whois.ripe.net"), 43)
    If $gSocket <> -1 Then; If no error then
        TCPSend($gSocket, "4.2.2.4"); ask about 4.2.2.4 (for example)
        sleep(500)
        $gData &= TCPRecv($gSocket, 2048)
        ConsoleWrite('$gData = ' & $gData & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
    EndIf
    TCPShutdown()
EndFunc  ;==>GetProviderMail

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

It seems I can't receive all the response... I just read the 'first' block

I'm using a while to re-read the datas, but apparently, that's not working.

Could you tell me where i'm wrong? Thanks

eg:

% Some informations

% here about ripe.net

% ...

% http://www.ripe.net

<

here should

come the informations

about the requested ip

>

The code:

GetProviderMail()

Func GetProviderMail()
    $gData = ""
    TCPStartup()
    $gSocket = TCPConnect(TCPNameToIP("whois.ripe.net"), 43)
    If $gSocket <> -1 Then; If no error then
        
        TCPSend($gSocket, "4.2.2.4"); ask about 4.2.2.4 (for example)

        sleep(500)
        
        While 1
            $gData = TCPRecv($gSocket, 2048)
            
            If $gData == -1 Then 
                ExitLoop 
            Else
                $gSplit = StringSplit($gData,":") ; split data
            
                For $gVar = $gSplit[0] To 1 Step -1 
                    Debug($gSplit[$gVar]) ;### Debug TrayTip
                Next
            EndIf
        WEnd
    EndIf
    TCPShutdown()
EndFunc  ;==>GetProviderMail

Func Debug($dbg)
    TrayTip("DEBUG:",$dbg,3, 1)
    Sleep(3100)
EndFunc  ;==>Debug
Edited by SetEnv
Link to comment
Share on other sites

Try mine, I did this some days ago.

TCPStartUp()
$Domain = TCPNameToIP("whois.ripe.net");whois.arin.net  whois.internic.net  whois.ripe.net
$Port = 43
$Address = '4.2.2.4'

Global $recv

$socket = TCPConnect($Domain, $Port)

If $socket <> -1 Then
   TCPSend($socket, $Address & @CRLF)
   
    Do
        $recv &= TCPRecv($socket, 2048) 
    Until @error
   ConsoleWrite($recv)
   TCPCloseSocket($socket)
   
EndIf
TCPShutdown()
Edited by Pain
Link to comment
Share on other sites

Yup,

Your code seems work perfectly !

But (yeah...) the datas are not totally received :-s

Your code with little modifications:

GetAbuseEmail()

Func GetAbuseEmail()

    TCPStartUp()
    $Domain = TCPNameToIP("whois.ripe.net");whois.arin.net  whois.internic.net  whois.ripe.net
    $Port = 43
    $Address = '-B 4.2.2.4' ; flag -B used to force 'update' (whois.ripe.net args)

    Global $recv

    $socket = TCPConnect($Domain, $Port)

    If $socket <> -1 Then
    TCPSend($socket, $Address & @CRLF)
  
        Do
            $recv &= TCPRecv($socket, 2048)
        Until @error
    
    TrayTip("debug", $recv, 4, 1)
    Sleep(2000)
    TCPCloseSocket($socket)
  
    EndIf
    TCPShutdown()
EndFunc ;==> GetAbuseEmail
Edited by SetEnv
Link to comment
Share on other sites

Yeah but,

Traytip("test", "test "test", 3, 3) Will not work, and it's normal...

And, in whois.ripe.net response, there was some '"' or "'"

That's why when i tryied to traytip() thoses chains containing '"' or "'" , I saw nothing.

Now, without traytip(), the code woks perfectly and I can extract the email adress

That's why I think Traytip() is bugged =)

Link to comment
Share on other sites

It's not bugged, from the helpfile

Message the balloon tip will display. (255 characters maximum)

Try with ConsoleWrite(StringLen($recv)), I got 1934 so that might be the reason why. :)

TCPStartUp()
$Domain = TCPNameToIP("whois.ripe.net");whois.arin.net  whois.internic.net  whois.ripe.net
$Port = 43
$Address = '-B 4.2.2.4'

Global $recv

$socket = TCPConnect($Domain, $Port)

If $socket <> -1 Then
   TCPSend($socket, $Address & @CRLF)
   
    Do
        $recv &= TCPRecv($socket, 2048) 
    Until @error
;~  ConsoleWrite($recv)
    TrayTip("",StringLeft($recv, 255), 4, 1)
    Sleep(2000)
   TCPCloseSocket($socket)
   
EndIf
TCPShutdown()
Edited by Pain
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...