download with pseudo device


These commands were tested in Ubuntu, including WSL

exec 5<> /dev/tcp/riowing.net/80
echo -e “GET /riosite/p/exec.txt HTTP/1.0\n” >&5
cat <&5
output:
HTTP/1.1 200 OK
# more info such as server version, date, content type…
FromRioWingNet # this is the content of exec.txt

exec.txt has been downloaded at this point

Here is more investigation:
$ ls /dev/tcp #output: No such file or directory
$ ls -l /dev/fd/5
lrwx—— 1 rio rio 0 Nov 3 17:56 /proc/self/fd/5 -> ‘socket:[43]’
#/dev/fd is a symbolic link to /proc/self/fd
$ echo $$ #output 9
$ ls -l /proc/9/fd/5
lrwx—— 1 rio rio 0 Nov 3 18:05 /proc/9/fd/5 -> ‘socket:[43]’
#fd means file descriptor

Bottom line: the 5 in “exec 5” is the 5 in /proc/9/fd/5

Comments are closed.
%d bloggers like this: