>(o)__, >(o)__, >(o)__, >(o)__, >(o)__,
Ducktor's chat control for Tor on Debian
>(o)__, >(o)__, >(o)__, >(o)__, >(o)__,
Install ncat with apt install ncat
Users are divided into three groups. Public, regulars and operators.
The IRC server is configured with four ports:
6660 - webclient use
6661 - public users
6662 - regular users
6663 - operators
The webclient is hosted on two ports:
80 - public users
8080 - regular users
Ports 60000-60010 will be used for control functions.
Create separate tor instances for the groups:
tor-instance-create chatpublic
tor-instance-create chatregulars
tor-instance-create chatopers
Edit tor configurations, for each of these files the Socksport line can be deleted:
/etc/tor/instances/chatpublic/torrc
HiddenServiceDir /var/lib/tor-instances/chatpublic/service/
HiddenServicePort 80 127.0.0.1:80
HiddenServicePort 6667 127.0.0.1:6661
/etc/tor/instances/chatregulars/torrc
HiddenServiceDir /var/lib/tor-instances/chatregulars/service/
HiddenServicePort 80 127.0.0.1:8080
HiddenServicePort 6667 127.0.0.1:6662
/etc/tor/instances/chatopers/torrc
HiddenServiceDir /var/lib/tor-instances/chatopers/service/
HiddenServicePort 6667 127.0.0.1:6663
HiddenServicePort 60000 127.0.0.1:60000
HiddenServicePort 60001 127.0.0.1:60001
HiddenServicePort 60002 127.0.0.1:60002
HiddenServicePort 60003 127.0.0.1:60003
HiddenServicePort 60004 127.0.0.1:60004
HiddenServicePort 60005 127.0.0.1:60005
HiddenServicePort 60006 127.0.0.1:60006
HiddenServicePort 60007 127.0.0.1:60007
HiddenServicePort 60008 127.0.0.1:60008
HiddenServicePort 60009 127.0.0.1:60009
HiddenServicePort 60010 127.0.0.1:60010
Start the new tor instances and enable them on boot:
systemctl start
tor@chatpublic.service
systemctl enable
tor@chatpublic.service
systemctl start
tor@chatregulars.service
systemctl enable
tor@chatregulars.service
systemctl start
tor@chatopers.service
systemctl enable
tor@chatopers.service
Hostnames will be at the following locations:
/var/lib/tor-instances/chatpublic/service/hostname
/var/lib/tor-instances/chatregulars/service/hostname
/var/lib/tor-instances/chatopers/service/hostname
Create the following files and chmod +x them all:
/usr/local/bin/cc-pwc-reset
#!/bin/sh
ss -K dst 127.0.0.1 dport 80
echo "Public webclient connections reset"
/usr/local/bin/cc-p-reset
#!/bin/sh
ss -K dst 127.0.0.1 dport 6661
echo "Public IRC port reset"
/usr/local/bin/cc-pwc-disable
#!/bin/sh
sed -i 's/#HiddenServicePort 80 127.0.0.1:80/HiddenServicePort 80 127.0.0.1:80/g' /etc/tor/instances/chatpublic/torrc
sed -i 's/HiddenServicePort 80 127.0.0.1:80/#HiddenServicePort 80 127.0.0.1:80/g' /etc/tor/instances/chatpublic/torrc
systemctl reload
tor@chatpublic.service
echo "Public access to webclient disabled"
/usr/local/bin/cc-p-disable
#!/bin/sh
sed -i 's/#HiddenServiceDir/HiddenServiceDir/g' /etc/tor/instances/chatpublic/torrc
sed -i 's/#HiddenServicePort/HiddenServicePort/g' /etc/tor/instances/chatpublic/torrc
sed -i 's/HiddenServiceDir/#HiddenServiceDir/g' /etc/tor/instances/chatpublic/torrc
sed -i 's/HiddenServicePort/#HiddenServicePort/g' /etc/tor/instances/chatpublic/torrc
systemctl reload
tor@chatpublic.service
echo "Public access to chat disabled"
/usr/local/bin/cc-p-enable
#!/bin/sh
sed -i 's/#HiddenServiceDir/HiddenServiceDir/g' /etc/tor/instances/chatpublic/torrc
sed -i 's/#HiddenServicePort/HiddenServicePort/g' /etc/tor/instances/chatpublic/torrc
systemctl reload
tor@chatpublic.service
echo "Public access to chat enabled, including webclient"
/usr/local/bin/cc-rwc-reset
#!/bin/sh
ss -K dst 127.0.0.1 dport 8080
echo "Regulars webclient connections reset"
/usr/local/bin/cc-r-reset
#!/bin/sh
ss -K dst 127.0.0.1 dport 6662
echo "Regulars IRC port reset"
/usr/local/bin/cc-rwc-disable
#!/bin/sh
sed -i 's/#HiddenServicePort 80 127.0.0.1:8080/HiddenServicePort 80 127.0.0.1:8080/g' /etc/tor/instances/chatregulars/torrc
sed -i 's/HiddenServicePort 80 127.0.0.1:8080/#HiddenServicePort 80 127.0.0.1:8080/g' /etc/tor/instances/chatregulars/torrc
systemctl reload
tor@chatregulars.service
echo "Regulars access to webclient disabled"
/usr/local/bin/cc-r-disable
#!/bin/sh
sed -i 's/#HiddenServiceDir/HiddenServiceDir/g' /etc/tor/instances/chatregulars/torrc
sed -i 's/#HiddenServicePort/HiddenServicePort/g' /etc/tor/instances/chatregulars/torrc
sed -i 's/HiddenServiceDir/#HiddenServiceDir/g' /etc/tor/instances/chatregulars/torrc
sed -i 's/HiddenServicePort/#HiddenServicePort/g' /etc/tor/instances/chatregulars/torrc
systemctl reload
tor@chatregulars.service
echo "Regulars access to chat disabled"
/usr/local/bin/cc-r-enable
#!/bin/sh
sed -i 's/#HiddenServiceDir/HiddenServiceDir/g' /etc/tor/instances/chatregulars/torrc
sed -i 's/#HiddenServicePort/HiddenServicePort/g' /etc/tor/instances/chatregulars/torrc
systemctl reload
tor@chatregulars.service
echo "Regulars access to chat enabled, including webclient"
/usr/local/bin/cc-status
#!/bin/sh
echo ""
echo "Public Tor configuration:"
echo ""
cat /etc/tor/instances/chatpublic/torrc
echo ""
echo "Regulars Tor configuration:"
echo ""
cat /etc/tor/instances/chatregulars/torrc
Create the following systemd services:
/etc/systemd/system/cc-pwc-reset.service
[Unit]
Description=Chat control reset public webclient
After=network.target
[Service]
ExecStart=ncat -l -p 60000 -c "/usr/local/bin/cc-pwc-reset"
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
/etc/systemd/system/cc-p-reset.service
[Unit]
Description=Chat control reset public IRC port
After=network.target
[Service]
ExecStart=ncat -l -p 60001 -c "/usr/local/bin/cc-p-reset"
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
/etc/systemd/system/cc-pwc-disable.service
[Unit]
Description=Chat control disable public webclient
After=network.target
[Service]
ExecStart=ncat -l -p 60002 -c "/usr/local/bin/cc-pwc-disable"
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
/etc/systemd/system/cc-p-disable.service
[Unit]
Description=Chat control disable public access
After=network.target
[Service]
ExecStart=ncat -l -p 60003 -c "/usr/local/bin/cc-p-disable"
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
/etc/systemd/system/cc-p-enable.service
[Unit]
Description=Chat control enable public access
After=network.target
[Service]
ExecStart=ncat -l -p 60004 -c "/usr/local/bin/cc-p-enable"
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
/etc/systemd/system/cc-rwc-reset.service
[Unit]
Description=Chat control reset regulars webclient
After=network.target
[Service]
ExecStart=ncat -l -p 60005 -c "/usr/local/bin/cc-rwc-reset"
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
/etc/systemd/system/cc-r-reset.service
[Unit]
Description=Chat control reset public IRC port
After=network.target
[Service]
ExecStart=ncat -l -p 60006 -c "/usr/local/bin/cc-r-reset"
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
/etc/systemd/system/cc-rwc-disable.service
[Unit]
Description=Chat control disable public webclient
After=network.target
[Service]
ExecStart=ncat -l -p 60007 -c "/usr/local/bin/cc-rwc-disable"
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
/etc/systemd/system/cc-r-disable.service
[Unit]
Description=Chat control disable public access
After=network.target
[Service]
ExecStart=ncat -l -p 60008 -c "/usr/local/bin/cc-r-disable"
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
/etc/systemd/system/cc-r-enable.service
[Unit]
Description=Chat control enable public access
After=network.target
[Service]
ExecStart=ncat -l -p 60009 -c "/usr/local/bin/cc-r-enable"
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
/etc/systemd/system/cc-status.service
[Unit]
Description=Chat control status
After=network.target
[Service]
ExecStart=ncat -l -p 60010 -c "/usr/local/bin/cc-status"
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
Start the systemd services and enable them at boot:
systemctl start cc-pwc-reset.service
systemctl enable cc-pwc-reset.service
systemctl start cc-p-reset.service
systemctl enable cc-p-reset.service
systemctl start cc-pwc-disable.service
systemctl enable cc-pwc-disable.service
systemctl start cc-p-disable.service
systemctl enable cc-p-disable.service
systemctl start cc-p-enable.service
systemctl enable cc-p-enable.service
systemctl start cc-rwc-reset.service
systemctl enable cc-rwc-reset.service
systemctl start cc-r-reset.service
systemctl enable cc-r-reset.service
systemctl start cc-rwc-disable.service
systemctl enable cc-rwc-disable.service
systemctl start cc-r-disable.service
systemctl enable cc-r-disable.service
systemctl start cc-r-enable.service
systemctl enable cc-r-enable.service
systemctl start cc-status.service
systemctl enable cc-status.service
Control ports on the operator service:
60000 pwc-reset - public webclient reset
60001 p-reset - public IRC port reset
60002 pwc-disable - public webclient disable
60003 p-disable - public access full disable
60004 p-enable - public enable access including webclient
60005 rwc-reset - regulars webclient reset
60006 r-reset - regulars IRC port reset
60007 rwc-disable - regulars webclient disable
60008 r-disable - regulars access full disable
60009 r-enable - regulars access enable including webclient
60010 status - status of tor configuration
Functions are performed when a connection is made to a control port,
this can be done with a browser by specifying one of the ports, for
example
http://whatever.onion:60002 to disable the public webclient
with port 60002. The control ports can also be used with netcat and
torsocks.
Using ncat:
torsocks ncat -i 1 whatever.onion 60002
Using traditional netcat that installed with Debian:
torsocks nc.traditional whatever.onion 60002
>(o)__, >(o)__, >(o)__, >(o)__, >(o)__,
>(o)__, >(o)__, >(o)__, >(o)__, >(o)__,