The UDP Command Listener is a tool designed to receive and execute commands sent over a UDP connection on linux devices. It listens for incoming UDP packets on a specified port and processes the commands contained within those packets. This tool is particularly useful for remote command execution and automation tasks.
The behavior of the UDP Command Listener can be configured using the ucl.conf
configuration file. This file allows you to specify various settings, including the listening port and any authentication secrets.
The configuration file looks like this:
#--------------------------------------------
# Configuration file for UDP Command Listener-
#--------------------------------------------
PORT=15000 # UDP listening port
SECRET= # Secret key to authorize command execution
....
It is important to set a strong secret key to prevent unauthorized access to the command execution functionality, but it is not required. You can leave it empty if you don't need authentication.
The UDP Command Listener has a whitelist and a blacklist for controlling which commands are allowed or denied. For obvious reasons, you can't have both of them functioning at the same time.
The whitelist is a list of commands that are explicitly allowed to be executed. If a command is not on the whitelist, it will be denied. It looks like this
whitelisted_commands_ON=true # Enable whitelisted commands
whitelisted_commands=( # Commands with spaces
ls -lah
shutdown -h now
)
The program checks if every word in the command is in the whitelist before allowing execution. You need to introduce the complete command on the whitelist.
The blacklist is a list of commands that are explicitly denied from being executed. If a command is on the blacklist, it will be denied regardless of the whitelist settings. It looks like this
banned_commands_ON=true # Enable banned commands
banned_commands=( # Commands with spaces
shutdown
reboot
sl
)
To use the UDP Command Listener, follow these steps:
- Configure the
ucl.conf
file with the desired settings. - Start the listener by running the appropriate command (e.g.,
./udp_command_listener
,systemctl start udp_command_listener
). - Send UDP packets to the specified port with the commands you want to execute on the device.
To install it, you need to run the installation script as root:
sudo ./install.sh
This will install the binaries to /usr/local/bin/udp_command_listener/
and the configuration to /etc/udp_command_listener/
. It will also create the systemd service and a shortcut in /usr/bin/udp_receive
.
To start the service:
sudo systemctl start udp_command_listener.service
To enable the service at boot:
sudo systemctl enable udp_command_listener.service
To check the status:
sudo systemctl status udp_command_listener.service
You can run the listener manually from anywhere with:
udp_receive
To edit the configuration:
sudo udp_receive --config
This will open the /etc/udp_command_listener/ucl.conf
file in the editor defined by the PREFERRED_EDITOR
variable.
You can use an NFC-enabled device to send commands to the UDP Command Listener. For example, you could configure your NFC tags to send specific commands when scanned, allowing for seamless automation of tasks. With an android device, you can use apps like Tasker or NFC Tools to create automations that trigger UDP packets to be sent to the listener.