|
|
|
|
|
by mrspuratic
42 days ago
|
|
This feature has been part of bash since 5.1 (ca 2020), though it may not be enabled in all distros. cd src/bash-5.3/examples/loadables
make accept
enable -f ./accept accept
(accept -r RHOST -v SOCKETFD -b 127.0.0.1 8000;
read -u $SOCKETFD SOCKETDATA;
printf "%s: %s\n" "$RHOST" "$SOCKETDATA";
printf "goodbye, world\n" 1>&${SOCKETFD} ) &
nc 127.0.0.1 8000 <<< "hello, world"
For real use you may need to add "exec {SOCKETFD}<&-" to close the FD.Edit: https://news.ycombinator.com/item?id=39369749 (2024) |
|