Ruroco is a tool that lets you execute commands on a server by sending UDP packets. The commands are configured on the server side, so the client does not define what is going to be executed, it only picks from existing commands.
ruroco is a tool that lets you execute commands on a server by sending UDP packets.
the tool consist of 4 binaries:
client: runs on your notebook/computer and sends the UDP packetsclient-ui: presents all the functionality of client in an easier to use user interface.server: receives the UDP packets and makes sure that they are validcommander: runs the command encoded by the data of the UDP packet if it's validThe commands are configured on the server side, so the client does not define what is going to be executed, it only picks from existing commands.
ruroco-client-ui
When first executed, a public-private key pair is generated and saved in the default config folder. The public key can then be copied from the user interface and saved on the server in the respective config.
ruroco-client
Usage: client <COMMAND>
Commands:
gen
send
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
ruroco-client gen --help
Generate a pair of private and public PEM keys
Usage: ruroco-client gen [OPTIONS]
Options:
-r, --private-pem-path <PRIVATE_PEM_PATH>
Path to the private PEM file [default: ./ruroco_private.pem]
-u, --public-pem-path <PUBLIC_PEM_PATH>
Path to the public PEM file [default: ./ruroco_public.pem]
-k, --key-size <KEY_SIZE>
Key size for the PEM file [default: 8192]
-h, --help
Print help
ruroco-client send --help
Send a command to a specific address
Usage: client send [OPTIONS] --address <ADDRESS>
Options:
-a, --address <ADDRESS>
Address to send the command to
-p, --private-pem-path <PRIVATE_PEM_PATH>
Path to the private PEM file [default: ~/.config/ruroco/ruroco_private.pem]
-c, --command <COMMAND>
Command to send [default: default]
-d, --deadline <DEADLINE>
Deadline from now in seconds [default: 5]
-e, --permissive
Allow permissive IP validation - source IP does not have to match provided IP
-i, --ip <IP>
Optional IP address from which the command was sent. Use -6ei "dead:beef:dead:beef::/64" to allow you whole current IPv6 network. To do this automatically, use -6ei $(curl -s6 https://api64.ipify.org | awk -F: '{print $1":"$2":"$3":"$4"::/64"}')
-n, --ntp <NTP>
NTP server (defaults to using the system time) [default: system]
-4, --ipv4
Connect via IPv4
-6, --ipv6
Connect via IPv6
-h, --help
Print help
ruroco-client gen to generate two files: ruroco_private.pem and ruroco_public.pemruroco_public.pem to /etc/ruroco/ruroco_public.pem on serverruroco_private.pem to ~/.config/ruroco/ruroco_private.pem on client/etc/ruroco/config.toml -> see config.tomldownload binaries from the releases page or build them yourself by running
make release
you can find the binaries in target/release/client, target/release/client_ui, target/release/server and
target/release/commander
See make goal install_client. This builds the project and copies the client binary to /usr/local/bin/ruroco-client
Download the client-v<major>.<minor>.<patch>-x86_64-linux binary from https://github.com/beac0n/ruroco/releases/latest
and move it to /usr/local/bin/ruroco-client
See make goal install_server, which
/usr/local/bin/ruroco user if it does not exist yetconfig.tomlserver-v<major>.<minor>.<patch>-x86_64-linux and commander-v<major>.<minor>.<patch>-x86_64-linux
binaries from https://github.com/beac0n/ruroco/releases/latest and move them to /usr/local/bin/ruroco-server and
/usr/local/bin/ruroco-commander.sudo chmod 500 /usr/local/bin/ruroco-serversudo chmod 100 /usr/local/bin/ruroco-commandersudo chown ruroco:ruroco /usr/local/bin/ruroco-serverruroco user: sudo useradd --system ruroco --shell /bin/falsesystemd folder: sudo cp ./systemd/* /etc/systemd/system/etc/ruroco/config.toml and define your config and commands
sudo chmod 400 /etc/ruroco/config.toml[commands] in /etc/ruroco/config.toml then restart ruroco-commandersudo systemctl daemon-reloadsudo systemctl enable ruroco.servicesudo systemctl enable ruroco-commander.servicesudo systemctl enable ruroco.socketsudo systemctl start ruroco-commander.servicesudo systemctl start ruroco.socketsudo systemctl start ruroco.serviceBuilding for android requires the following tools
For arch linux, the tools can be installed with the following commands. We use java 17, because that seem to be more stable than newer ones.
sudo pacman -S android-tools android-udev jdk17-openjdk
sudo archlinux-java set java-17-openjdk
yay -S android-ndk android-sdk android-sdk-build-tools android-sdk-platform-tools android-sdk-cmdline-tools-latest
You also have to install a platform. For arch linux, this can be done with the following commands.
If sdk manager prints a java error, you might have to set your JAVA_HOME env var:
export JAVA_HOME=/usr/lib/jvm/default
sdkmanager --install "platforms;android-35"
you might have to set env vars:
export ANDROID_HOME=/opt/android-sdk
export NDK_HOME=/opt/android-ndk
export PATH=$PATH:$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
Install xbuild (see https://github.com/rust-mobile/xbuild): cargo install xbuild and run x devices to check your
devices connected with adb. Don't forget to put your android device in usb debugging mode.
Run the app on your device:
x run --device adb:<device-id>
If you host a server on the web, you know that you'll get lots of brute-force attacks on (at least) the SSH port of your server. While using good practices in securing your server will keep you safe from such attacks, these attacks are quite annoying (filling up logs) and even if you secured your server correctly, you will still not be 100% safe, see https://www.schneier.com/blog/archives/2024/04/xz-utils-backdoor.html or https://www.qualys.com/2024/07/01/cve-2024-6387/regresshion.txt
Completely blocking all traffic to all ports that do not have to be open at all times can reduce the attack surface. But blocking the SSH port completely will make SSH unusable for that server.
This is where ruroco comes in. Ruroco can execute a command that opens up the SSH port for just a short amount of time, so that you can ssh into your server. Afterward ruruco closes the SSH port again. To implement this use case with ruroco, you have to use a configuration similar to the one shown below:
[commands]
open_ssh = "ufw allow from $RUROCO_IP proto tcp to any port 22" # open ssh for IP where request came from
close_ssh = "ufw delete allow from $RUROCO_IP proto tcp to any port 22" # close ssh for IP where request came from
If you have configured ruroco on server like that and execute the following client side command
ruroco-client send --address host.domain:8080 --command open_ssh
If you want to use a different IP address than the one you are sending the packet from, you can use the --ip argument
together with --permissive:
ruroco-client send --address host.domain:8080 --command open_ssh --ip 94.111.111.111 --permissive
If you want to make sure that an adversary does not spoof your source IP address, you can get your external IP address from a service - the ruroco server will make sure that the IP addresses match:
ruroco-client send --address host.domain:8080 --command open_ssh --ip $(curl -s https://api64.ipify.org)
the server will validate that the client is authorized to execute that command by using public-key cryptography (RSA)
and will then execute the command defined in the config above under "open_ssh". The --deadline argument means that the
command has to be started on the server within 5 seconds after executing the command.
This gives you the ability to effectively only allow access to the SSH port, for only the IP that the UDP packet was sent from, if you want to connect to your server. Of course, you should also do all the other security hardening tasks you would do if the SSH port would be exposed to the internet.
You can define any number of commands you wish, by adding more commands to configuration file.
You may run a webservice like https://github.com/filebrowser/filebrowser on your server, which you do not want to publicly expose. If you use nginx as a reverse proxy, you can use ruroco to enable or disable services:
[commands]
disable_file_browser = "mv /etc/nginx/conf.d/https_file_browser.conf /etc/nginx/conf.d/https_file_browser.conf_disabled && nginx -s reload"
enable_file_browser = "mv /etc/nginx/conf.d/https_file_browser.conf_disabled /etc/nginx/conf.d/https_file_browser.conf && nginx -s reload"
If you have configured ruroco on server like that and execute the following client side command
ruroco-client send --address host.domain:8080 --command enable_file_browser
the file browser nginx config will be enabled and nginx reloaded, effectively making the file browser accessible.
The service consists of three parts:
client
server
commander
┌────────────────┐ ┌────────────────┐
│ │ │ │
│ ┌────────┐ │ │ ┌────────────┐ │
│ │ Client ├───┼─┤►│ Server │ │
│ └────────┘ │ │ └─────┬──────┘ │
│ │ │ │ │
│ │ │ ┌─────▼──────┐ │
│ │ │ │ Commander │ │
│ │ │ └────────────┘ │
│ Local Host │ │ Remote Host │
└────────────────┘ └────────────────┘
Whenever a user sends a command via the client, the following steps are executed
┌─────────┐ ┌─────────┐ ┌───────────┐
│ Client │ │ Server │ │ Commander │
└────┬────┘ └────┬────┘ └─────┬─────┘
│ │ │
│ Encrypt and send │ │
├─────────────────────►│ │
│ data via UDP │ │
│ │ Decrypt and validate │
│ ├─────────────┐ data │
│ │ │ │
│ │◄────────────┘ │
│ │ │
│ │ │
│ │ │
┌────┬────┼──────────────────────┼─────────────────────────┼───────────────────┐
│alt │ │ │ │ │
├────┘ │ │ Log error │ │
│if is │ ├─────────────┐ │ │
│invalid │ │ │ │ │
│ │ │◄────────────┘ │ │
│ │ │ │ │
├─ ── ──┤ ── ── ── ── ── ─┤ ── ── ── ── ── ── ├── ── ── ── ── │
│else │ │ │ │
│ │ │ Send command name │ │
│ │ ├────────────────────────►│ │
│ │ │ │ │
│ │ │ │ Check if command │
│ │ │ │ is valid │
│ │ │ ├───────────────┐ │
│ │ │ │ │ │
│ │ │ │◄──────────────┘ │
│ │ │ │ │
│ │ ┌────┬────┼─────────────────────────┼───────────────────┤
│ │ │alt │ │ │ Execute command │
│ │ ├────┘ │ ├───────────────┐ │
│ │ │if is │ │ │ │
│ │ │valid │ │◄──────────────┘ │
│ │ │ │ │ │
│ │ ├─ ── ──┤ ── ── ── ── ── ── ├─ ── ── ── ── │
│ │ │else │ │Log Error │
│ │ │ │ ├───────────────┐ │
│ │ │ │ │ │ │
│ │ │ │ │◄──────────────┘ │
│ │ │ │ │ │
└─────────┴────────────┴─────────┴─────────────────────────┴───────────────────┘
No comments yet.
Sign in to be the first to comment.