Kali Linux

Onionservice : Manage Your Onion Services Via CLI Or TUI On Unix-like Operating System

Onionservice is a minimal requirement, portable collection of scripts and documentation to help the service operator juggle (manage) his onion(s).

WARNING: do not trust this repo yet, backup your hs keys in another location. This project has not been released and should be considered for development only.

History

This project was started after seeing the amazing OnionShare CLI python scripts, which possibilitates ephemeral onion services that never touch the disk and can be run on Tails or Whonix easily. Then after seeing the RaspiBlitz onion service bash script for the Raspberry Pi, the idea to port it to any Debian distribution started. As the idea grew, using GNU Bash and Linux was a single point of failure 1 2, so the making the script POSIX compliant to be compatible with any Unix-like system was a definitive goal.

Goal

The goal of this project is:

  • facilitate onion service management, from activating a service to adding client authorization to it, giving the full capabilities of editing files manually would have but with less tipying.
  • show the that managing the onion service is much more than just using a webserver with your pages.
  • distribution, from the source code level (FOSS) to the effect it takes when it allows anyone to run the code on any operating system, shell or service manager. Mitigation from a single point of failure

Mitigation from a single point of failure:

  • Kernel from predominant Linux to also BSD and any other Unix-like system.
  • Shell from predominant Bash to also any POSIX shell such as ksh, (y,d)ash and Zsh (emulating sh).
  • Service manager from predominant Systemd to also RC, OpenRC, SysVinit, Runit.

Editing the tor configuration file (torrc) is not difficult, but automation solves problem of misconfiguration and having:

  • less time spent by running a single line command
  • no downtime by rejecting invalid configuration before applying them to be used
  • complete uniformity
  • graphical interface to help newbies

Features

  • Enable service – Create directory if not existent (HiddenServiceDir), select onion version (HiddenServiceVersion), custom socket type being unix or tcp, with as many virtual ports as you would like, as well as targets (HiddenServicePort).
  • Disable service – Remove service configuration from the torrc, the service will not be acessible anymore, but you can enable it again any time you want. Optionally purge the service, deleting its configuration and directory, which will delete its keys permanently.
  • Renew service address – Focused on private onion services, if you ever leak its address, you can change its hostname, beware all of your authorized clients will be disconnected and the service keys will be permanently deleted.
  • Credentials – Show hostname, clients, torrc block, qrencoded hostname.
  • Onion authentication – For v3 onion services only. This depends on client and server side configuration and works with a key pair, the client holds the private key part either generate by him (more safe) or given by the service operator and the onion service operator holds the public part. If any if
    • Server – Generate key pair or add public part, list client names and their public keys from <HiddenServiceDir>/authorized_clients/<client>.auth. If any client is configured, the service will not be acessible without authentication.
    • Client – Generate key pair or add public part, list your <ClientOnionAuthDir>/<SOME_ONION>.auth_private.
  • Onion-Location – For public onion services You can redirect your plainnet users to your onion service with this guide for nginx, apache2 and html header attributes.
  • Backup – Better be safe.
    • Create – Backup of your torrc lines containing hidden service configuration, all of your directories of HiddenServiceDir and ClientOnionAuthDir.
    • Integrate – Integrate hidden serivces lines configuration from torrc and the directories HiddenServiceDir and ClientOnionAuthDir to your current system. This option should be used after creating a backup and importing to the current host.
  • OpSec – Operation Security
    • Vanguards – This addon protects against guard discovery and related traffic analysis attacks. A guard discovery attack enables an adversary to determine the guard node(s) that are in use by a Tor client and/or Tor onion service. Once the guard node is known, traffic analysis attacks that can deanonymize an onion service (or onion service user) become easier.
    • Unix socket – Support for enabling an onion service over unix socket to avoid localhost bypasses.
  • Web server – Serve files with your hidden service using Nginx or Apache2 web server.
  • Usability – There are two dialog boxes compatible with the project, dialog and whiptail.
  • Bulk – Some commands can be bulked with the argument @all to include all services or clients depending on the option --service or --client, list enabled arguments[SERV1,SERV2,...] and [CLIENT1,CLIENT2,...], the command will loop the variables and apply the combination.
  • Fool-proof – The script tries its best to filter invalid commands and incorrect syntax. The commands are not difficult but at first sight may scare you. Don’t worry, if it is invalid, it won’t run to avoid tor daemon failing to reload because of invalid configuration. If an invalid command runs, please open an issue.

Requirements

  • General:
    • Unix-like system.
    • superuser privileges to call commands as root and the tor user, with doas or sudo.
  • Required programs:
    • sh – any POSIX shell: dash 0.5.4+, bash 2.03+, ksh 88+, mksh R28+, yash 2.29+, busybox ash 1.1.3+, zsh 3.1.9+ (zsh --emulate sh) etc.
    • doas/sudo (must be already configured)
    • tor >= 0.3.5.7
    • grep >=0.9
    • sed
    • tar (Backup)
    • openssl >= 1.1 (Client Authorization – requires algorithm x25519, so it can’t be LibreSSL)
    • basez >= 1.6.2 (Client Authorization)
    • git (Vanguards)
    • python(3)-stem >=1.8.0 (Vanguards)
    • dialog/whiptail (TUI)
    • nginx/apache2 (Web server)
  • Optional programs:
    • (lib)qrencode >= 4.1.1 (List)
  • Development programs:
    • pandoc (Manual)
    • shellcheck (Review)

If using Vanguards, python2.6 is the minimal required for Stem, but it is not going to be installed by default.

Instructions

Clone the repository

git clone https://github.com/nyxnor/onionjuggler.git
cd onionjuggler

et custom variables

You should not modify the default configuration on /etc/onionjuggler/onionjuggler.conf, it will be modified on every update. Your local configurations should be on /etc/onionjuggler/conf.d/*.conf.

To assign values to the variables, yyou can either:

  • Open the mentioned configuration file with your favorite editor:
  • “${EDITOR:-vi}” /etc/onionjuggler/cond.d/local.conf

or insert configuration to the end of the file with tee:

printf “su_cmd=\”sudo\”\n” | tee -a /etc/onionjuggler/cond.d/local.conf

or edit with sed:

sed -i” “s|^su_cmd=.*|su_cmd=\”doas\”|” /etc/onionjuggler/cond.d/local.conf

Setup the enviroment

Run from inside the cloned repository to create the tor directories, create manual pages and copy scripts to path:

./configure.sh –install

Usage

configure.sh

configure.sh setup the environment for OnionJuggler by adding the scripts and manual pages to path and detecting your operating system to fit with its default configuration. It can also be used to uninstall. Common development use is to create manual pages, check shell syntax and do all of the aforementioned and give the git status for files to be commited. The update option is raw and only recommended for development as of now.

Install

configure.sh –install ## -i

Uninstall

configure.sh –uninstall ## -d

Update

configure.sh –update ## -u

tui

onionjuggler-tui wraps the CLI in a Terminal User Interface. Some TUI options will let you edit the authorization files, which is recommended to set your favorite text editor to an environment variable that will be tried on the following order: DOAS_EDITOR/SUDO_EDITOR, if empty will try VISUAL, if empty will try EDITOR, if empty WILL fallback to Vi.

Read the tui manual

man onionjuggler-tui

To use the TUI, just run:

onionjuggler-tui

cli

onionjuggler-cli is the main script that manages the HiddenServices. Take a look at the documentation inside docs folder, there are many other onion services management guides. Read:

Don’t forget the cli manual and the conf manual for advanced usage:

man onionjuggler-cli
man onionjuggler.conf

To create a service named terminator, it is as easy as possible:

onionjuggler-cli activate -s terminator -p 80

But can be as advanced as specifying all the parameters:

onionjuggler-cli activate –service terminator –socket unix –version 3 –port 80,127.0.0.1:80

R K

Recent Posts

Bomber : Navigating Security Vulnerabilities In SBOMs

bomber is an application that scans SBOMs for security vulnerabilities. So you've asked a vendor…

13 hours ago

EmbedPayloadInPng : A Guide To Embedding And Extracting Encrypted Payloads In PNG Files

Embed a payload within a PNG file by splitting the payload across multiple IDAT sections.…

13 hours ago

Exploit Street – Navigating The New Terrain Of Windows LPEs

Exploit-Street, where we dive into the ever-evolving world of cybersecurity with a focus on Local…

3 days ago

ShadowDumper – Advanced Techniques For LSASS Memory Extraction

Shadow Dumper is a powerful tool used to dump LSASS (Local Security Authority Subsystem Service)…

3 days ago

Shadow-rs : Harnessing Rust’s Power For Kernel-Level Security Research

shadow-rs is a Windows kernel rootkit written in Rust, demonstrating advanced techniques for kernel manipulation…

2 weeks ago

ExecutePeFromPngViaLNK – Advanced Execution Of Embedded PE Files via PNG And LNK

Extract and execute a PE embedded within a PNG file using an LNK file. The…

3 weeks ago