Abaya has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Im trying to write a syn-scanner in perl and Im struck in not being able to get the return packet with syn-ack bits set from the destination host. The problem is Im getting a packet with source and destination IP as loop back address (127.0.0.1). and only the syn bit set. I dont know where I went wrong. I have generated the packet setting the syn_flag_bit=1. I have created two socket handles s_sock and r_sock for sending and recieving respectively with protocol number as 6 for both of them.

The send() command also works well and I get the number of bits sent (40 bytes, tcp and ip header together) as the return value. The segment looks like...

+ ...... ..... .... send($s_sock,$packet,0,$dest); $read = new IO::Select(); $read->add($r_sock); ($return)=IO::Select->select($read,undef,undef,5); + if ($return) { recv($r_sock,$buff,256,0); ........ ..... ... }
can u please tell me what is happening and why i get that return packet with loop back ip?

thanks, Abaya.

Edited by Chady -- minor formatting and code tags.

Replies are listed 'Best First'.
Re: perl network programming some problem in send and recv.
by johnnywang (Priest) on Aug 17, 2004 at 19:22 UTC
    It's pretty hard to tell from your post, may be you can add some more details? like more complete code, and the ip, port bindings? The fact you're getting an ack back from 127.0.0.1 indicates you are really talking to yourself, at first I thought may be it is a dns problem (like having a host entry to point to your self) or a route problem (like setting the gateway to yourself, in which case you shouldn't get an ack). Anyhow, I would doubt it is a perl problem, mostlikely some parameters in your code or your network setup. But that's just a guess.