To set it up for inetd, first put the script someplace publically-readable (but not writable) like /usr/local/bin or something.
Then we need to setup the reverse service. On other *nix, you would add a line to /etc/services, but this is Darwin/OS X, which uses NetInfo, so instead we must run
This creates an entry in NetInfo's services directory called reverse (change if you prefer it called something else); it has two properties: port (9876, again, change if you want a different port), and protocol (tcp).
Now we need to tell inetd about reverse:
One thing to note is be sure you save the script with Unix-type linebreaks; the attachment wasn't.
For those curious, see man inetd for information on the line added to inetd.conf (note the user used is nobody which is a security feature as this particular server shouldn't need any serious access).
Then we need to setup the reverse service. On other *nix, you would add a line to /etc/services, but this is Darwin/OS X, which uses NetInfo, so instead we must run
Code:
sudo niutil -create / /services/reverse
sudo niutil -createprop / /services/reverse port 9876
sudo niutil -createprop / /services/reverse protocol tcp
Now we need to tell inetd about reverse:
- edit /etc/inetd.conf (with pico, vi, whichever you prefer)
- add the line
Code:reverse stream tcp nowait nobody /usr/local/bin/reverse.pl reverse.pl
- run
Code:kill -1 `cat /var/run/inetd.pid`
Code:
$ telnet localhost 9876
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
this is the reverse server
revres esrever eht si siht
Connection closed by foreign host.
For those curious, see man inetd for information on the line added to inetd.conf (note the user used is nobody which is a security feature as this particular server shouldn't need any serious access).