mirror of
https://github.com/iio612/DEFENDER.git
synced 2026-02-13 19:24:23 +00:00
V6.1.0 update the help command
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
from dataclasses import dataclass, fields, field
|
||||
import copy
|
||||
from dataclasses import dataclass
|
||||
import random, faker, time, logging
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -45,9 +43,7 @@ class Clone():
|
||||
self.Definition = ircInstance.Loader.Definition
|
||||
|
||||
# Créer les nouvelles commandes du module
|
||||
self.commands_level = {
|
||||
1: ['clone']
|
||||
}
|
||||
self.Irc.build_command(1, self.module_name, 'clone', 'Connect, join, part, kill and say clones')
|
||||
|
||||
# Init the module (Mandatory)
|
||||
self.__init_module()
|
||||
@@ -57,9 +53,6 @@ class Clone():
|
||||
|
||||
def __init_module(self) -> None:
|
||||
|
||||
# Enrigstrer les nouvelles commandes dans le code
|
||||
self.__set_commands(self.commands_level)
|
||||
|
||||
# Créer les tables necessaire a votre module (ce n'es pas obligatoire)
|
||||
self.__create_tables()
|
||||
|
||||
@@ -79,20 +72,6 @@ class Clone():
|
||||
self.Protocol.send2socket(f":{self.Config.SERVICE_NICKNAME} MODE {self.Config.CLONE_CHANNEL} +nts")
|
||||
self.Protocol.send2socket(f":{self.Config.SERVICE_NICKNAME} MODE {self.Config.CLONE_CHANNEL} +k {self.Config.CLONE_CHANNEL_PASSWORD}")
|
||||
|
||||
def __set_commands(self, commands:dict[int, list[str]]) -> None:
|
||||
"""### Rajoute les commandes du module au programme principal
|
||||
|
||||
Args:
|
||||
commands (list): Liste des commandes du module
|
||||
"""
|
||||
for level, com in commands.items():
|
||||
for c in commands[level]:
|
||||
if not c in self.Irc.commands:
|
||||
self.Irc.commands_level[level].append(c)
|
||||
self.Irc.commands.append(c)
|
||||
|
||||
return None
|
||||
|
||||
def __create_tables(self) -> None:
|
||||
"""Methode qui va créer la base de donnée si elle n'existe pas.
|
||||
Une Session unique pour cette classe sera crée, qui sera utilisé dans cette classe / module
|
||||
@@ -155,7 +134,7 @@ class Clone():
|
||||
vhost = ''.join(rand_1) + '.' + ''.join(rand_2) + '.' + ''.join(rand_3) + '.IP'
|
||||
return vhost
|
||||
|
||||
def generate_clones(self, group: str = 'Default') -> None:
|
||||
def generate_clones(self, group: str = 'Default', auto_remote_ip: bool = False) -> None:
|
||||
try:
|
||||
|
||||
fakeEN = self.fakeEN
|
||||
@@ -188,7 +167,7 @@ class Clone():
|
||||
department = fakeFR.department_name()
|
||||
realname = f'{age} {gender} {department}'
|
||||
|
||||
decoded_ip = fakeEN.ipv4_private()
|
||||
decoded_ip = fakeEN.ipv4_private() if auto_remote_ip else '127.0.0.1'
|
||||
hostname = fakeEN.hostname()
|
||||
|
||||
vhost = self.generate_vhost()
|
||||
@@ -231,10 +210,10 @@ class Clone():
|
||||
except Exception as err:
|
||||
self.Logs.error(f"General Error: {err}")
|
||||
|
||||
def thread_connect_clones(self, number_of_clones:int , group: str, interval: float = 0.2) -> None:
|
||||
def thread_connect_clones(self, number_of_clones:int , group: str = 'Default', auto_remote_ip: bool = False, interval: float = 0.2) -> None:
|
||||
|
||||
for i in range(0, number_of_clones):
|
||||
self.generate_clones(group=group)
|
||||
self.generate_clones(group=group, auto_remote_ip=auto_remote_ip)
|
||||
|
||||
for clone in self.Clone.UID_CLONE_DB:
|
||||
|
||||
@@ -331,15 +310,15 @@ class Clone():
|
||||
|
||||
case 'connect':
|
||||
try:
|
||||
# clone connect 5 Group 3
|
||||
# clone connect 5 GroupName 3
|
||||
self.stop = False
|
||||
number_of_clones = int(cmd[2])
|
||||
group = str(cmd[3]).lower()
|
||||
connection_interval = int(cmd[4]) if len(cmd) == 5 else 0.5
|
||||
connection_interval = int(cmd[4]) if len(cmd) == 5 else 0.2
|
||||
|
||||
self.Base.create_thread(
|
||||
func=self.thread_connect_clones,
|
||||
func_args=(number_of_clones, group, connection_interval)
|
||||
func_args=(number_of_clones, group, False, connection_interval)
|
||||
)
|
||||
|
||||
except Exception as err:
|
||||
|
||||
@@ -40,21 +40,62 @@ class Command:
|
||||
# Add User object to the module (Mandatory)
|
||||
self.User = ircInstance.User
|
||||
|
||||
# Add Client object to the module (Mandatory)
|
||||
self.Client = ircInstance.Client
|
||||
|
||||
# Add Channel object to the module (Mandatory)
|
||||
self.Channel = ircInstance.Channel
|
||||
|
||||
# Create module commands (Mandatory)
|
||||
self.commands_level = {
|
||||
1: ['join', 'part','owner', 'deowner', 'protect', 'deprotect', 'op',
|
||||
'deop', 'halfop', 'dehalfop', 'voice','devoice', 'topic'],
|
||||
2: ['opall', 'deopall', 'devoiceall', 'voiceall', 'ban', 'automode',
|
||||
'unban', 'kick', 'kickban', 'umode',
|
||||
'mode', 'get_mode', 'svsjoin', 'svspart', 'svsnick',
|
||||
'wallops', 'globops','gnotice','whois', 'names', 'invite', 'inviteme',
|
||||
'sajoin', 'sapart', 'kill', 'gline', 'ungline', 'kline',
|
||||
'unkline', 'shun', 'unshun', 'glinelist', 'shunlist', 'klinelist'],
|
||||
3: ['map']
|
||||
}
|
||||
self.Irc.build_command(1, self.module_name, 'join', 'Join a channel')
|
||||
self.Irc.build_command(1, self.module_name, 'assign', 'Assign a user to a role or task')
|
||||
self.Irc.build_command(1, self.module_name, 'part', 'Leave a channel')
|
||||
self.Irc.build_command(1, self.module_name, 'unassign', 'Remove a user from a role or task')
|
||||
self.Irc.build_command(1, self.module_name, 'owner', 'Give channel ownership to a user')
|
||||
self.Irc.build_command(1, self.module_name, 'deowner', 'Remove channel ownership from a user')
|
||||
self.Irc.build_command(1, self.module_name, 'protect', 'Protect a user from being kicked')
|
||||
self.Irc.build_command(1, self.module_name, 'deprotect', 'Remove protection from a user')
|
||||
self.Irc.build_command(1, self.module_name, 'op', 'Grant operator privileges to a user')
|
||||
self.Irc.build_command(1, self.module_name, 'deop', 'Remove operator privileges from a user')
|
||||
self.Irc.build_command(1, self.module_name, 'halfop', 'Grant half-operator privileges to a user')
|
||||
self.Irc.build_command(1, self.module_name, 'dehalfop', 'Remove half-operator privileges from a user')
|
||||
self.Irc.build_command(1, self.module_name, 'voice', 'Grant voice privileges to a user')
|
||||
self.Irc.build_command(1, self.module_name, 'devoice', 'Remove voice privileges from a user')
|
||||
self.Irc.build_command(1, self.module_name, 'topic', 'Change the topic of a channel')
|
||||
self.Irc.build_command(2, self.module_name, 'opall', 'Grant operator privileges to all users')
|
||||
self.Irc.build_command(2, self.module_name, 'deopall', 'Remove operator privileges from all users')
|
||||
self.Irc.build_command(2, self.module_name, 'devoiceall', 'Remove voice privileges from all users')
|
||||
self.Irc.build_command(2, self.module_name, 'voiceall', 'Grant voice privileges to all users')
|
||||
self.Irc.build_command(2, self.module_name, 'ban', 'Ban a user from a channel')
|
||||
self.Irc.build_command(2, self.module_name, 'automode', 'Automatically set user modes upon join')
|
||||
self.Irc.build_command(2, self.module_name, 'unban', 'Remove a ban from a user')
|
||||
self.Irc.build_command(2, self.module_name, 'kick', 'Kick a user from a channel')
|
||||
self.Irc.build_command(2, self.module_name, 'kickban', 'Kick and ban a user from a channel')
|
||||
self.Irc.build_command(2, self.module_name, 'umode', 'Set user mode')
|
||||
self.Irc.build_command(2, self.module_name, 'mode', 'Set channel mode')
|
||||
self.Irc.build_command(2, self.module_name, 'get_mode', 'Retrieve current channel mode')
|
||||
self.Irc.build_command(2, self.module_name, 'svsjoin', 'Force a user to join a channel')
|
||||
self.Irc.build_command(2, self.module_name, 'svspart', 'Force a user to leave a channel')
|
||||
self.Irc.build_command(2, self.module_name, 'svsnick', 'Force a user to change their nickname')
|
||||
self.Irc.build_command(2, self.module_name, 'wallops', 'Send a message to all operators')
|
||||
self.Irc.build_command(2, self.module_name, 'globops', 'Send a global operator message')
|
||||
self.Irc.build_command(2, self.module_name, 'gnotice', 'Send a global notice')
|
||||
self.Irc.build_command(2, self.module_name, 'whois', 'Get information about a user')
|
||||
self.Irc.build_command(2, self.module_name, 'names', 'List users in a channel')
|
||||
self.Irc.build_command(2, self.module_name, 'invite', 'Invite a user to a channel')
|
||||
self.Irc.build_command(2, self.module_name, 'inviteme', 'Invite yourself to a channel')
|
||||
self.Irc.build_command(2, self.module_name, 'sajoin', 'Force yourself into a channel')
|
||||
self.Irc.build_command(2, self.module_name, 'sapart', 'Force yourself to leave a channel')
|
||||
self.Irc.build_command(2, self.module_name, 'kill', 'Disconnect a user from the server')
|
||||
self.Irc.build_command(2, self.module_name, 'gline', 'Ban a user from the entire server')
|
||||
self.Irc.build_command(2, self.module_name, 'ungline', 'Remove a global server ban')
|
||||
self.Irc.build_command(2, self.module_name, 'kline', 'Ban a user based on their hostname')
|
||||
self.Irc.build_command(2, self.module_name, 'unkline', 'Remove a K-line ban')
|
||||
self.Irc.build_command(2, self.module_name, 'shun', 'Prevent a user from sending messages')
|
||||
self.Irc.build_command(2, self.module_name, 'unshun', 'Remove a shun from a user')
|
||||
self.Irc.build_command(2, self.module_name, 'glinelist', 'List all global bans')
|
||||
self.Irc.build_command(2, self.module_name, 'shunlist', 'List all shunned users')
|
||||
self.Irc.build_command(2, self.module_name, 'klinelist', 'List all K-line bans')
|
||||
self.Irc.build_command(3, self.module_name, 'map', 'Show the server network map')
|
||||
|
||||
# Init the module
|
||||
self.__init_module()
|
||||
@@ -64,9 +105,6 @@ class Command:
|
||||
|
||||
def __init_module(self) -> None:
|
||||
|
||||
# Insert module commands into the core one (Mandatory)
|
||||
self.__set_commands(self.commands_level)
|
||||
|
||||
# Create you own tables (Mandatory)
|
||||
self.__create_tables()
|
||||
|
||||
@@ -79,20 +117,6 @@ class Command:
|
||||
|
||||
return None
|
||||
|
||||
def __set_commands(self, commands: dict[int, list[str]]) -> None:
|
||||
"""### Rajoute les commandes du module au programme principal
|
||||
|
||||
Args:
|
||||
commands (list): Liste des commandes du module
|
||||
"""
|
||||
for level, com in commands.items():
|
||||
for c in commands[level]:
|
||||
if c not in self.Irc.commands:
|
||||
self.Irc.commands_level[level].append(c)
|
||||
self.Irc.commands.append(c)
|
||||
|
||||
return None
|
||||
|
||||
def __create_tables(self) -> None:
|
||||
"""Methode qui va créer la base de donnée si elle n'existe pas.
|
||||
Une Session unique pour cette classe sera crée, qui sera utilisé dans cette classe / module
|
||||
@@ -248,14 +272,19 @@ class Command:
|
||||
user_uid = self.User.clean_uid(cmd[5])
|
||||
userObj: MUser = self.User.get_User(user_uid)
|
||||
channel_name = cmd[4] if self.Channel.Is_Channel(cmd[4]) else None
|
||||
client_obj = self.Client.get_Client(user_uid)
|
||||
nickname = userObj.nickname if userObj is not None else None
|
||||
|
||||
if client_obj is not None:
|
||||
nickname = client_obj.account
|
||||
|
||||
if userObj is None:
|
||||
return None
|
||||
|
||||
if 'r' not in userObj.umodes and 'o' not in userObj.umodes:
|
||||
if 'r' not in userObj.umodes and 'o' not in userObj.umodes and not self.Client.is_exist(userObj.uid):
|
||||
return None
|
||||
|
||||
db_data: dict[str, str] = {"nickname": userObj.nickname, "channel": channel_name}
|
||||
db_data: dict[str, str] = {"nickname": nickname, "channel": channel_name}
|
||||
db_query = self.Base.db_execute_query("SELECT id, mode FROM command_automode WHERE nickname = :nickname AND channel = :channel", db_data)
|
||||
db_result = db_query.fetchone()
|
||||
if db_result is not None:
|
||||
@@ -782,7 +811,7 @@ class Command:
|
||||
except Exception as err:
|
||||
self.Logs.warning(f'Unknown Error: {str(err)}')
|
||||
|
||||
case 'join':
|
||||
case 'join' | 'assign':
|
||||
|
||||
try:
|
||||
sent_channel = str(cmd[1]) if self.Channel.Is_Channel(cmd[1]) else None
|
||||
@@ -800,7 +829,7 @@ class Command:
|
||||
except Exception as err:
|
||||
self.Logs.warning(f'Unknown Error: {str(err)}')
|
||||
|
||||
case 'part':
|
||||
case 'part' | 'unassign':
|
||||
|
||||
try:
|
||||
sent_channel = str(cmd[1]) if self.Channel.Is_Channel(cmd[1]) else None
|
||||
|
||||
@@ -81,11 +81,16 @@ class Defender():
|
||||
self.Reputation = ircInstance.Reputation
|
||||
|
||||
# Create module commands (Mandatory)
|
||||
self.commands_level = {
|
||||
0: ['code'],
|
||||
1: ['info', 'autolimit'],
|
||||
3: ['reputation','proxy_scan', 'flood', 'status', 'timer','show_reputation', 'sentinel']
|
||||
}
|
||||
self.Irc.build_command(0, self.module_name, 'code', 'Display the code or key for access')
|
||||
self.Irc.build_command(1, self.module_name, 'info', 'Provide information about the channel or server')
|
||||
self.Irc.build_command(1, self.module_name, 'autolimit', 'Automatically set channel user limits')
|
||||
self.Irc.build_command(3, self.module_name, 'reputation', 'Check or manage user reputation')
|
||||
self.Irc.build_command(3, self.module_name, 'proxy_scan', 'Scan users for proxy connections')
|
||||
self.Irc.build_command(3, self.module_name, 'flood', 'Handle flood detection and mitigation')
|
||||
self.Irc.build_command(3, self.module_name, 'status', 'Check the status of the server or bot')
|
||||
self.Irc.build_command(3, self.module_name, 'timer', 'Set or manage timers')
|
||||
self.Irc.build_command(3, self.module_name, 'show_reputation', 'Display reputation information')
|
||||
self.Irc.build_command(3, self.module_name, 'sentinel', 'Monitor and guard the channel or server')
|
||||
|
||||
# Init the module (Mandatory)
|
||||
self.__init_module()
|
||||
@@ -95,9 +100,6 @@ class Defender():
|
||||
|
||||
def __init_module(self) -> None:
|
||||
|
||||
# Insert module commands into the core one (Mandatory)
|
||||
self.__set_commands(self.commands_level)
|
||||
|
||||
# Create you own tables if needed (Mandatory)
|
||||
self.__create_tables()
|
||||
|
||||
@@ -150,20 +152,6 @@ class Defender():
|
||||
|
||||
return None
|
||||
|
||||
def __set_commands(self, commands: dict[int, list[str]]) -> None:
|
||||
"""### Rajoute les commandes du module au programme principal
|
||||
|
||||
Args:
|
||||
commands (list): Liste des commandes du module
|
||||
"""
|
||||
for level, com in commands.items():
|
||||
for c in commands[level]:
|
||||
if c not in self.Irc.commands:
|
||||
self.Irc.commands_level[level].append(c)
|
||||
self.Irc.commands.append(c)
|
||||
|
||||
return None
|
||||
|
||||
def __create_tables(self) -> None:
|
||||
"""Methode qui va créer la base de donnée si elle n'existe pas.
|
||||
Une Session unique pour cette classe sera crée, qui sera utilisé dans cette classe / module
|
||||
|
||||
@@ -42,9 +42,8 @@ class Jsonrpc():
|
||||
self.Channel = ircInstance.Channel
|
||||
|
||||
# Create module commands (Mandatory)
|
||||
self.commands_level = {
|
||||
1: ['jsonrpc', 'jruser']
|
||||
}
|
||||
self.Irc.build_command(1, self.module_name, 'jsonrpc', 'Activate the JSON RPC Live connection [ON|OFF]')
|
||||
self.Irc.build_command(1, self.module_name, 'jruser', 'Get Information about a user using JSON RPC')
|
||||
|
||||
# Init the module
|
||||
self.__init_module()
|
||||
@@ -54,8 +53,6 @@ class Jsonrpc():
|
||||
|
||||
def __init_module(self) -> None:
|
||||
|
||||
# Insert module commands into the core one (Mandatory)
|
||||
self.__set_commands(self.commands_level)
|
||||
logging.getLogger('websockets').setLevel(logging.WARNING)
|
||||
logging.getLogger('unrealircd-rpc-py').setLevel(logging.CRITICAL)
|
||||
|
||||
@@ -103,20 +100,6 @@ class Jsonrpc():
|
||||
|
||||
return None
|
||||
|
||||
def __set_commands(self, commands:dict[int, list[str]]) -> None:
|
||||
"""### Rajoute les commandes du module au programme principal
|
||||
|
||||
Args:
|
||||
commands (list): Liste des commandes du module
|
||||
"""
|
||||
for level, com in commands.items():
|
||||
for c in commands[level]:
|
||||
if not c in self.Irc.commands:
|
||||
self.Irc.commands_level[level].append(c)
|
||||
self.Irc.commands.append(c)
|
||||
|
||||
return None
|
||||
|
||||
def __create_tables(self) -> None:
|
||||
"""Methode qui va créer la base de donnée si elle n'existe pas.
|
||||
Une Session unique pour cette classe sera crée, qui sera utilisé dans cette classe / module
|
||||
|
||||
@@ -46,12 +46,11 @@ class Test():
|
||||
self.Reputation = ircInstance.Reputation
|
||||
|
||||
# Create module commands (Mandatory)
|
||||
self.commands_level = {
|
||||
0: ['test-command'],
|
||||
1: ['test_level_1'],
|
||||
2: ['test_level_2'],
|
||||
3: ['test_level_3']
|
||||
}
|
||||
self.Irc.build_command(0, self.module_name, 'test-command', 'Execute a test command')
|
||||
self.Irc.build_command(1, self.module_name, 'test_level_1', 'Execute a level 1 test command')
|
||||
self.Irc.build_command(2, self.module_name, 'test_level_2', 'Execute a level 2 test command')
|
||||
self.Irc.build_command(3, self.module_name, 'test_level_3', 'Execute a level 3 test command')
|
||||
|
||||
|
||||
# Init the module
|
||||
self.__init_module()
|
||||
@@ -61,9 +60,6 @@ class Test():
|
||||
|
||||
def __init_module(self) -> None:
|
||||
|
||||
# Insert module commands into the core one (Mandatory)
|
||||
self.__set_commands(self.commands_level)
|
||||
|
||||
# Create you own tables (Mandatory)
|
||||
self.__create_tables()
|
||||
|
||||
@@ -73,20 +69,6 @@ class Test():
|
||||
|
||||
return None
|
||||
|
||||
def __set_commands(self, commands:dict[int, list[str]]) -> None:
|
||||
"""### Rajoute les commandes du module au programme principal
|
||||
|
||||
Args:
|
||||
commands (list): Liste des commandes du module
|
||||
"""
|
||||
for level, com in commands.items():
|
||||
for c in commands[level]:
|
||||
if not c in self.Irc.commands:
|
||||
self.Irc.commands_level[level].append(c)
|
||||
self.Irc.commands.append(c)
|
||||
|
||||
return None
|
||||
|
||||
def __create_tables(self) -> None:
|
||||
"""Methode qui va créer la base de donnée si elle n'existe pas.
|
||||
Une Session unique pour cette classe sera crée, qui sera utilisé dans cette classe / module
|
||||
|
||||
@@ -56,9 +56,7 @@ class Votekick():
|
||||
self.Channel = ircInstance.Channel
|
||||
|
||||
# Créer les nouvelles commandes du module
|
||||
self.commands_level = {
|
||||
0: ['vote']
|
||||
}
|
||||
self.Irc.build_command(1, self.module_name, 'vote', 'The kick vote module')
|
||||
|
||||
# Init the module
|
||||
self.__init_module()
|
||||
@@ -70,27 +68,11 @@ class Votekick():
|
||||
|
||||
# Add admin object to retrieve admin users
|
||||
self.Admin = self.Irc.Admin
|
||||
|
||||
self.__set_commands(self.commands_level)
|
||||
self.__create_tables()
|
||||
self.join_saved_channels()
|
||||
|
||||
return None
|
||||
|
||||
def __set_commands(self, commands:dict[int, list[str]]) -> None:
|
||||
"""### Rajoute les commandes du module au programme principal
|
||||
|
||||
Args:
|
||||
commands (list): Liste des commandes du module
|
||||
"""
|
||||
for level, com in commands.items():
|
||||
for c in commands[level]:
|
||||
if not c in self.Irc.commands:
|
||||
self.Irc.commands_level[level].append(c)
|
||||
self.Irc.commands.append(c)
|
||||
|
||||
return None
|
||||
|
||||
def __create_tables(self) -> None:
|
||||
"""Methode qui va créer la base de donnée si elle n'existe pas.
|
||||
Une Session unique pour cette classe sera crée, qui sera utilisé dans cette classe / module
|
||||
|
||||
Reference in New Issue
Block a user