To create new wiki account, please join us on #znc at Libera.Chat and ask admins to create a wiki account for you. You can say thanks to spambots for this inconvenience.

CService: Difference between revisions

From ZNC
Jump to navigation Jump to search
SiD (talk | contribs)
No edit summary
SiD (talk | contribs)
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:cservice}}
{{DISPLAYTITLE:cservice}}
{{External Module}}
{{External Module}}


The `CService` ZNC module provides secure login functionality for X on UnderNet, including support for 2FA/TOTP authentication and LoC (Login on Connect). It allows users to configure login details, enable/disable 2FA, and specify user modes. Sensitive data, such as passwords and 2FA secrets, are encrypted using AES-256 encryption for enhanced security.
The `CService` ZNC module provides secure login functionality for X on UnderNet, including support for 2FA/TOTP authentication and LoC (Login on Connect). It allows users to configure login details, enable/disable 2FA, and specify user modes. Sensitive data, such as passwords and 2FA secrets, are encrypted using AES-256 encryption for enhanced security.<br><br>


== Features ==
== Features ==
# **Secure Login**: Authenticate securely with UnderNet using your username, password, and optional TOTP-based 2FA.
# **Secure Login**: Authenticate securely with UnderNet using your username, password, and optional TOTP-based 2FA.
# **2FA/TOTP Support**: Enhance security by adding time-based one-time passwords to your login process.
# **2FA/TOTP Support**: Enhance security by adding time-based one-time passwords to your login process.
# **LoC (Login on Connect)**: Seamlessly log in to UnderNet using their LoC feature. Learn more: [UnderNet LoC](https://www.undernet.org/loc/).
# **LoC (Login on Connect)**: Seamlessly log in to UnderNet using their LoC feature. Learn more: [UnderNet LoC](https://www.undernet.org/loc/).
# **Custom User Modes**: Set your preferred user mode prefix (`-x!`, `+x!`, or `-!+x`) during server connection.
# **Custom User Modes**: Set your preferred user mode prefix (`-x!`, `+x!`, or `-!+x`) during server connection.
# **Encrypted Credentials**: Protect your password and 2FA secret with AES-256 encryption, ensuring that sensitive data is stored securely.
# **Encrypted Credentials**: Protect your password and 2FA secret with AES-256 encryption, ensuring that sensitive data is stored securely.<br><br>


== Installation ==
== Installation ==
1. Clone the repository:
1. Clone the repository:
<pre>git clone https://github.com/your-repository/cservice-znc-module.git
<pre>git clone https://github.com/your-repository/cservice-znc-module.git
cd cservice-znc-module</pre>
cd cservice-znc-module</pre
<br> 
2. Generate your `MASTER_KEY` for encrypting sensitive data (password and 2FA secret): 
<pre>openssl rand -hex 32</pre> 
Replace the placeholder `MASTER_KEY` in the module code with the generated key: 
<pre>const std::string MASTER_KEY = "REPLACE_WITH_YOUR_OWN_SECURE_KEY";</pre><br>


2. Generate your `MASTER_KEY` for encrypting sensitive data (password and 2FA secret):
3. Build the module:
<pre>openssl rand -hex 32</pre>
<pre>znc-buildmod cservice.cpp</pre>
Replace the placeholder `MASTER_KEY` in the module code with the generated key:
<pre>const std::string MASTER_KEY = "REPLACE_WITH_YOUR_OWN_SECURE_KEY";</pre>


3. Build the module:
4. Place the compiled module in your ZNC modules directory:
<pre>znc-buildmod cservice.cpp</pre>
<pre>mv cservice.so ~/.znc/modules/</pre><br>


4. Place the compiled module in your ZNC modules directory:
5. Load the module in ZNC:
<pre>mv cservice.so ~/.znc/modules/</pre>
<pre>/znc loadmod cservice</pre><br>


5. Load the module in ZNC:
== Configuration == 
<pre>/znc loadmod cservice</pre>
After loading the module, run the following command for help and configuration options:
<pre>/msg *cservice help</pre><br>


== Configuration ==
You can set:<br> 
After loading the module, run the following command for help and configuration options:
- Your UnderNet username and password.<br> 
<pre>/msg *cservice help</pre>
- Your 2FA secret for TOTP.<br> 
You can set:
- Enable or disable 2FA.<br> 
- Your UnderNet username and password.
- Your preferred user mode (`-x!`, `+x!`, or `-!+x`)<br><br>
- Your 2FA secret for TOTP.
- Enable or disable 2FA.
- Your preferred user mode (`-x!`, `+x!`, or `-!+x`).


=== Formatting the 2FA Secret Key ===
=== Formatting the 2FA Secret Key ===
The CService website provides the 2FA secret key in eight groups separated by spaces, like this:
The CService website provides the 2FA secret key in eight groups separated by spaces, like this:
<pre>a1b2 c3d4 e5f6 g7h8 i9j0 k1l2 m3n4 o5p6
<pre>a1b2 c3d4 e5f6 g7h8 i9j0 k1l2 m3n4 o5p6</pre><br> 
Before entering the key into the module, you must:
1. Remove all spaces.
2. Convert all lowercase letters to uppercase.


For example, if CService gives you `a1b2 c3d4 e5f6 g7h8 i9j0 k1l2 m3n4 o5p6`, you should enter it as:
Before entering the key into the module, you must:<br> 
A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6</pre>
1. Remove all spaces.<br>
This ensures compatibility with the module.
2. Convert all lowercase letters to uppercase.<br><br>


You can use the following Linux command to reformat the key automatically:
For example, if CService gives you `a1b2 c3d4 e5f6 g7h8 i9j0 k1l2 m3n4 o5p6`, you should enter it as:
<pre>echo "a1b2 c3d4 e5f6 g7h8 i9j0 k1l2 m3n4 o5p6" | tr -d ' ' | tr '[:lower:]' '[:upper:]'</pre>
<pre>A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6</pre><br> 


== Password and 2FA Encryption ==
This ensures compatibility with the module.<br> 
This module encrypts sensitive data (password and 2FA secret) using AES-256 encryption. Each user must generate their own encryption key (referred to as `MASTER_KEY`) and update the module code before building it.


=== Generating a Secure Encryption Key ===
You can use the following Linux command to reformat the key automatically:
To generate a secure 256-bit (32-byte) hexadecimal key, use the following OpenSSL command:
<pre>echo "a1b2 c3d4 e5f6 g7h8 i9j0 k1l2 m3n4 o5p6" | tr -d ' ' | tr '[:lower:]' '[:upper:]'</pre><br><br>
<pre>openssl rand -hex 32</pre>
Replace the placeholder `MASTER_KEY` in the module code with the generated key:
<pre>const std::string MASTER_KEY = "REPLACE_WITH_YOUR_OWN_SECURE_KEY";</pre>


== Notes ==
== Password and 2FA Encryption ==
* **Security Warning**: Always keep your `MASTER_KEY` private. If the key is exposed, encrypted data can be compromised. If the `MASTER_KEY` is lost, the encrypted password and 2FA secret will no longer work, and you will have to reconfigure the module.
This module encrypts sensitive data (password and 2FA secret) using AES-256 encryption. Each user must generate their own encryption key (referred to as `MASTER_KEY`) and update the module code before building it.<br><br>
* For changes to take effect, reload the module after updating configuration or code:
<pre>/znc unloadmod cservice
/znc loadmod cservice</pre>


== See Also ==
=== Generating a Secure Encryption Key === 
For more information on UnderNet's Login on Connect (LoC) feature, visit [https://www.undernet.org/loc/ UnderNet LoC].
To generate a secure 256-bit (32-byte) hexadecimal key, use the following OpenSSL command:
<pre>openssl rand -hex 32</pre><br> 
Replace the placeholder `MASTER_KEY` in the module code with the generated key: 
<pre>const std::string MASTER_KEY = "REPLACE_WITH_YOUR_OWN_SECURE_KEY";</pre><br><br>


Enjoy secure and seamless logins with the `CService` ZNC module!
== Notes == 
* **Security Warning**: Always keep your `MASTER_KEY` private. If the key is exposed, encrypted data can be compromised. If the `MASTER_KEY` is lost, the encrypted password and 2FA secret will no longer work, and you will have to reconfigure the module.<br> 
* For changes to take effect, reload the module after updating configuration or code: 
<pre>/znc unloadmod cservice 
/znc loadmod cservice</pre><br>
 
== See Also == 
For more information on UnderNet's Login on Connect (LoC) feature, visit [https://www.undernet.org/loc/ UnderNet LoC].<br>
 
Enjoy secure and seamless logins with the `CService` ZNC module!<br>

Revision as of 19:59, 8 February 2025

The `CService` ZNC module provides secure login functionality for X on UnderNet, including support for 2FA/TOTP authentication and LoC (Login on Connect). It allows users to configure login details, enable/disable 2FA, and specify user modes. Sensitive data, such as passwords and 2FA secrets, are encrypted using AES-256 encryption for enhanced security.

Features

  1. **Secure Login**: Authenticate securely with UnderNet using your username, password, and optional TOTP-based 2FA.
  2. **2FA/TOTP Support**: Enhance security by adding time-based one-time passwords to your login process.
  3. **LoC (Login on Connect)**: Seamlessly log in to UnderNet using their LoC feature. Learn more: [UnderNet LoC](https://www.undernet.org/loc/).
  4. **Custom User Modes**: Set your preferred user mode prefix (`-x!`, `+x!`, or `-!+x`) during server connection.
  5. **Encrypted Credentials**: Protect your password and 2FA secret with AES-256 encryption, ensuring that sensitive data is stored securely.

Installation

1. Clone the repository:

git clone https://github.com/your-repository/cservice-znc-module.git  
cd cservice-znc-module


2. Generate your `MASTER_KEY` for encrypting sensitive data (password and 2FA secret):

openssl rand -hex 32

Replace the placeholder `MASTER_KEY` in the module code with the generated key:

const std::string MASTER_KEY = "REPLACE_WITH_YOUR_OWN_SECURE_KEY";


3. Build the module:

znc-buildmod cservice.cpp

4. Place the compiled module in your ZNC modules directory:

mv cservice.so ~/.znc/modules/


5. Load the module in ZNC:

/znc loadmod cservice


Configuration

After loading the module, run the following command for help and configuration options:

/msg *cservice help


You can set:
- Your UnderNet username and password.
- Your 2FA secret for TOTP.
- Enable or disable 2FA.
- Your preferred user mode (`-x!`, `+x!`, or `-!+x`)

Formatting the 2FA Secret Key

The CService website provides the 2FA secret key in eight groups separated by spaces, like this:

a1b2 c3d4 e5f6 g7h8 i9j0 k1l2 m3n4 o5p6


Before entering the key into the module, you must:
1. Remove all spaces.
2. Convert all lowercase letters to uppercase.

For example, if CService gives you `a1b2 c3d4 e5f6 g7h8 i9j0 k1l2 m3n4 o5p6`, you should enter it as:

A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6


This ensures compatibility with the module.

You can use the following Linux command to reformat the key automatically:

echo "a1b2 c3d4 e5f6 g7h8 i9j0 k1l2 m3n4 o5p6" | tr -d ' ' | tr '[:lower:]' '[:upper:]'



Password and 2FA Encryption

This module encrypts sensitive data (password and 2FA secret) using AES-256 encryption. Each user must generate their own encryption key (referred to as `MASTER_KEY`) and update the module code before building it.

Generating a Secure Encryption Key

To generate a secure 256-bit (32-byte) hexadecimal key, use the following OpenSSL command:

openssl rand -hex 32


Replace the placeholder `MASTER_KEY` in the module code with the generated key:

const std::string MASTER_KEY = "REPLACE_WITH_YOUR_OWN_SECURE_KEY";



Notes

  • **Security Warning**: Always keep your `MASTER_KEY` private. If the key is exposed, encrypted data can be compromised. If the `MASTER_KEY` is lost, the encrypted password and 2FA secret will no longer work, and you will have to reconfigure the module.
  • For changes to take effect, reload the module after updating configuration or code:
/znc unloadmod cservice  
/znc loadmod cservice


See Also

For more information on UnderNet's Login on Connect (LoC) feature, visit UnderNet LoC.

Enjoy secure and seamless logins with the `CService` ZNC module!