0

I'd like to use ngrep and/or perl to monitor the incoming data stream on a socket, then, when the appropriate characters arrive, like in this case, the string "192.168.1.101:8080", input to the data stream a redirect to another ipaddress, such as "192.168.1.102"

Is this even possible?

Lester Kahn
  • 31
  • 1
  • 1
  • 4

2 Answers2

0

Sure, thats possible.

Algorithm/application would require:

  • MiM listenning server (creating sockets session sockets)
  • hand-shake on MiM:
  • (best thing would be if there would be a text stream not binary protocol used)
  • recv from client, parse message then:

  • if IP comes in, open or use already opened socket to the target server/port

  • send message or rest of the message to target server
  • provide communication beteween client and target sever (operate as gateway)
  • recv() client or server and send() back to appropriate side

General advice: operate on select() or epoll(), approach more advanced but better.

bua
  • 4,761
  • 1
  • 26
  • 32
0

This can done easily in Perl.

Take a look at perldoc perlipc, IO::Socket and IO::Select for examples.

You might find Beej's Guide to Network Programming helpful, too. The examples are all in C, but Perl's networking API is pretty close to the C flavor.

daotoad
  • 26,689
  • 7
  • 59
  • 100