I am trying to send characters directly to the network stack as explained in this thread.
Even when the process work OK under CygWin (Windows), the same lines do fail on Ubuntu v14.04:
luis@Zarzamoro:~$ sudo echo -e "\xff">/dev/udp/255.255.255.255/4000
-bash: connect: Permission denied
-bash: /dev/udp/255.255.255.255/4000: Permission denied
Tested on Ubuntu for PC:
luis@Lamborghini:~$ bash --version
GNU bash, versión 4.3.11(1)-release (i686-pc-linux-gnu)
And Ubuntu for RaspBerry Pi 2:
luis@Zarzamoro:~$ bash --version
GNU bash, version 4.3.11(1)-release (arm-unknown-linux-gnueabihf)
Doing this via direct character sending to NIC instead of by using netcat or socat could be useful for some routers or embedded devices (like NAS) that have a rather modern Bash version, but don't allow (or it is awkward to achieve) installation of extra tools.
Why is this happening and how could I solve it?
Tested too:
luis@Zarzamoro:~$ sudo bash -c 'echo -e "\xff" >/dev/udp/255.255.255.255/4000'
bash: connect: Permission denied
bash: /dev/udp/255.255.255.255/4000: Permission denied
And:
luis@Zarzamoro:~$ echo -e "\xff" | sudo tee /dev/udp/255.255.255.255/4000
tee: /dev/udp/255.255.255.255/4000: No such file or directory
▒
luis@Zarzamoro:~$
New info from @Emeric: the problem seems to affect only to broadcast address(es):
luis@Zarzamoro:~$ sudo bash -c 'echo -e "\xff" >/dev/udp/192.168.11.255/4000'
bash: connect: Permission denied
bash: /dev/udp/192.168.11.255/4000: Permission denied
luis@Zarzamoro:~$ sudo bash -c 'echo -e "\xff" >/dev/udp/192.168.11.1/4000'
luis@Zarzamoro:~$
Tested failing too on Kali Linux v1.1.0 with Bash v4.2.37:
luis@Lamborghini:~$ sudo lsb_release -a
No LSB modules are available.
Distributor ID: Kali
Description: Kali GNU/Linux 1.1.0
Release: 1.1.0
Codename: moto
luis@Lamborghini:~$ bash --version
GNU bash, versión 4.2.37(1)-release (i486-pc-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
luis@Lamborghini:~$ sudo bash -c 'echo -e "\xff" >/dev/udp/192.168.11.255/4000'
bash: connect: Permiso denegado
bash: /dev/udp/192.168.11.255/4000: Permiso denegado
Tested failing too on Bash from Conceptronic CH3SNAS (a NAS with 2 HDDs) installed via Fun_Plug:
sh-4.1# bash --version
GNU bash, version 4.1.11(2)-release (arm-ffp-linux-uclibc)
sh-4.1# su
sh-4.1# echo -e "\xff" > /dev/udp/255.255.255.255/4000
sh: connect: Permission denied
sh: /dev/udp/255.255.255.255/4000: Permission denied
sudo
since a normal user for which a network interface is available can send data to a udp socket). I am still trying to find out what is wrong with the broadcast address, but it might be simply missing from bash's socket implementation.192.168.11.255
failing too.