Read HTTP request from a SOCKET in perl -
i have problem reading socket in perl
.
the story goes : 1.1.1.1
server 2.2.2.2
other server opened ssh tunnel on 1.1.1.1
3.3.3.3
ip mozilla firefox
i have ssh tunnel opened on port 12345
, tcp.pl
"server" oppenning on port 2000
, forwarding raw traffic port 12345
gets again.
i have oppened mozilla firefox
, put @ socks5 1.1.1.1:2000
(the tcp.pl server), , when surf web, surf 2.2.2.2
's ip, witch good.
i wrote someware in code print sockets tcp.pl
getting command :
`print $buffer;`
the problem can read http headers , see stuff
get / http/1.1 host: site.com user-agent: mozilla/5.0 (windows nt 6.1; wow64; rv:29.0) gecko/20100101 firefox/29.0 accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 accept-language: en-us,en;q=0.5 accept-encoding: gzip, deflate cookie: _ga=ga1.2.1235518067.1410367631 connection: keep-alive
witch ok, don't quite http content , mean don't html code. part of html code this
:g�� ��� <-- wired characters <html>...</html> ���lop� <-- wired characters
and get
puttyputtyputtyputtyputtyputtyputtyputtyputtyputtyputty
and beep sound.
the code (tcp.pl)
an infinite loop reads reads , reads ....
while (1) { $socket ($ioset->can_read) { if($socket == $server) { new_connection($server); } else { next unless exists $socket_map{$socket}; $remote = $socket_map{$socket}; $buffer; # data main port $read = $socket->sysread($buffer, 4096); if ($read) { print $read; # gives number 43243 5436346456 34654643464 print $buffer; # allways gives http headers, , token distorted, showing characters ":g�� ������lop�" , chunks of html code time time # output "puttyputtyputtyputtyputtyputtyputtyputtyputtyputtyputty" , hearing beeping sounds # forward data other port (in browser see no differance) $remote->syswrite($buffer); } else { close_connection($socket); } } } }
i believe because fact don't order packets properly, mean have read sockets , order ack
, seq
flags, read it.
now main quession, how read html content is?
thank you.
Comments
Post a Comment