dc-securex 2.15.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dc-securex might be problematic. Click here for more details.
- dc_securex-2.15.3.dist-info/METADATA +653 -0
- dc_securex-2.15.3.dist-info/RECORD +17 -0
- dc_securex-2.15.3.dist-info/WHEEL +5 -0
- dc_securex-2.15.3.dist-info/licenses/LICENSE +21 -0
- dc_securex-2.15.3.dist-info/top_level.txt +1 -0
- securex/__init__.py +18 -0
- securex/backup/__init__.py +5 -0
- securex/backup/manager.py +693 -0
- securex/client.py +556 -0
- securex/handlers/__init__.py +8 -0
- securex/handlers/channel.py +97 -0
- securex/handlers/member.py +110 -0
- securex/handlers/role.py +74 -0
- securex/models.py +123 -0
- securex/utils/__init__.py +5 -0
- securex/utils/punishment.py +124 -0
- securex/utils/whitelist.py +129 -0
|
@@ -0,0 +1,653 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dc-securex
|
|
3
|
+
Version: 2.15.3
|
|
4
|
+
Summary: Backend-only Discord anti-nuke protection SDK
|
|
5
|
+
Home-page: https://github.com/yourusername/securex-antinuke-sdk
|
|
6
|
+
Author: SecureX Team
|
|
7
|
+
Author-email: SecureX Team <contact@securex.dev>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/yourusername/securex-antinuke-sdk
|
|
10
|
+
Project-URL: Repository, https://github.com/yourusername/securex-antinuke-sdk
|
|
11
|
+
Project-URL: Issues, https://github.com/yourusername/securex-antinuke-sdk/issues
|
|
12
|
+
Keywords: discord,bot,antinuke,security,protection,sdk
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Requires-Python: >=3.8
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: discord.py>=2.0.0
|
|
23
|
+
Requires-Dist: aiofiles>=23.0.0
|
|
24
|
+
Dynamic: author
|
|
25
|
+
Dynamic: home-page
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
Dynamic: requires-python
|
|
28
|
+
|
|
29
|
+
# 🛡️ SecureX SDK - Discord Server Protection Made Easy
|
|
30
|
+
|
|
31
|
+
**Protect your Discord server from attacks in just 5 lines of code!**
|
|
32
|
+
|
|
33
|
+
[](https://pypi.org/project/dc-securex/)
|
|
34
|
+
[](https://www.python.org/downloads/)
|
|
35
|
+
|
|
36
|
+
## 🤔 What is this?
|
|
37
|
+
|
|
38
|
+
SecureX is a **Python library** that protects your Discord server from people who try to destroy it.
|
|
39
|
+
|
|
40
|
+
Imagine someone gets admin powers and starts:
|
|
41
|
+
- 🗑️ Deleting all channels
|
|
42
|
+
- 👥 Kicking everyone
|
|
43
|
+
- 🚫 Banning members
|
|
44
|
+
- 🤖 Adding spam bots
|
|
45
|
+
|
|
46
|
+
**SecureX stops them in milliseconds** (0.005 seconds!) and fixes everything automatically!
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## ✨ What can it do?
|
|
51
|
+
|
|
52
|
+
✅ **Instant Protection** - Stops attacks in 5-10 milliseconds
|
|
53
|
+
✅ **Auto Restore** - Brings back deleted channels and roles
|
|
54
|
+
✅ **Smart Punishment** - Bans/kicks bad users automatically
|
|
55
|
+
✅ **Easy Setup** - Just 5 lines of code!
|
|
56
|
+
✅ **Your Design** - You build the commands & UI, we handle security
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 📋 Before You Start
|
|
61
|
+
|
|
62
|
+
### Step 1: Create a Discord Bot
|
|
63
|
+
|
|
64
|
+
1. Go to [Discord Developer Portal](https://discord.com/developers/applications)
|
|
65
|
+
2. Click **"New Application"**
|
|
66
|
+
3. Give it a name (like "SecureBot")
|
|
67
|
+
4. Go to **"Bot"** tab → Click **"Add Bot"**
|
|
68
|
+
5. **Important**: Enable these switches:
|
|
69
|
+
- ✅ SERVER MEMBERS INTENT
|
|
70
|
+
- ✅ MESSAGE CONTENT INTENT
|
|
71
|
+
6. Click **"Reset Token"** → Copy your bot token (you'll need this!)
|
|
72
|
+
|
|
73
|
+
### Step 2: Invite Bot to Your Server
|
|
74
|
+
|
|
75
|
+
Use this link (replace `YOUR_BOT_ID` with your bot's ID from Developer Portal):
|
|
76
|
+
```
|
|
77
|
+
https://discord.com/api/oauth2/authorize?client_id=YOUR_BOT_ID&permissions=8&scope=bot
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Permission value `8` = Administrator** (easiest for beginners)
|
|
81
|
+
|
|
82
|
+
### Step 3: Install Python & Libraries
|
|
83
|
+
|
|
84
|
+
You need Python 3.8 or newer. Check by running:
|
|
85
|
+
```bash
|
|
86
|
+
python --version
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
If you don't have it, download from [python.org](https://python.org)
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 🚀 Quick Setup (5 Steps!)
|
|
94
|
+
|
|
95
|
+
### Step 1: Install SecureX
|
|
96
|
+
|
|
97
|
+
Open your terminal/command prompt and type:
|
|
98
|
+
```bash
|
|
99
|
+
pip install dc-securex
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Step 2: Create Your Bot File
|
|
103
|
+
|
|
104
|
+
Create a file called `bot.py` and copy this code:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
import discord
|
|
108
|
+
from discord.ext import commands
|
|
109
|
+
from securex import SecureX
|
|
110
|
+
|
|
111
|
+
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
|
|
112
|
+
sx = SecureX(bot)
|
|
113
|
+
|
|
114
|
+
@bot.event
|
|
115
|
+
async def on_ready():
|
|
116
|
+
await sx.enable(
|
|
117
|
+
punishments={
|
|
118
|
+
"channel_delete": "ban",
|
|
119
|
+
"role_delete": "ban",
|
|
120
|
+
"member_ban": "ban",
|
|
121
|
+
"member_kick": "ban"
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
print(f"✅ {bot.user.name} is online and protected!")
|
|
125
|
+
|
|
126
|
+
bot.run("YOUR_BOT_TOKEN_HERE")
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Step 3: Add Your Bot Token
|
|
130
|
+
|
|
131
|
+
Replace `"YOUR_BOT_TOKEN_HERE"` with the token you copied from Discord Developer Portal.
|
|
132
|
+
|
|
133
|
+
**⚠️ KEEP YOUR TOKEN SECRET!** Never share it or post it online!
|
|
134
|
+
|
|
135
|
+
### Step 4: Run Your Bot
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
python bot.py
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
You should see: `✅ YourBotName is online and protected!`
|
|
142
|
+
|
|
143
|
+
### Step 5: Test It!
|
|
144
|
+
|
|
145
|
+
Your server is now protected! If someone tries to delete a channel or kick members without permission, SecureX will:
|
|
146
|
+
1. **Ban them instantly** (in 0.005 seconds!)
|
|
147
|
+
2. **Restore what they deleted** (channels, roles, etc.)
|
|
148
|
+
3. **Log the attack** (so you know what happened)
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## 🎯 Understanding the Code
|
|
153
|
+
|
|
154
|
+
Let's break down what each part does:
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
from securex import SecureX
|
|
158
|
+
```
|
|
159
|
+
This imports the SecureX library.
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
sx = SecureX(bot)
|
|
163
|
+
```
|
|
164
|
+
This connects SecureX to your bot.
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
await sx.enable(punishments={...})
|
|
168
|
+
```
|
|
169
|
+
This turns on protection and sets punishments:
|
|
170
|
+
- `"ban"` = Ban the attacker
|
|
171
|
+
- `"kick"` = Kick them out
|
|
172
|
+
- `"timeout"` = Mute them for 10 minutes
|
|
173
|
+
- `"none"` = Just restore, don't punish
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 🔧 What Can You Protect?
|
|
178
|
+
|
|
179
|
+
Here are ALL the things you can protect:
|
|
180
|
+
|
|
181
|
+
| Type | What it stops | Recommended Punishment |
|
|
182
|
+
|------|--------------|----------------------|
|
|
183
|
+
| `channel_delete` | Deleting channels | `"ban"` |
|
|
184
|
+
| `channel_create` | Creating too many channels (spam) | `"kick"` |
|
|
185
|
+
| `role_delete` | Deleting roles | `"ban"` |
|
|
186
|
+
| `role_create` | Creating too many roles (spam) | `"kick"` |
|
|
187
|
+
| `member_kick` | Kicking members | `"ban"` |
|
|
188
|
+
| `member_ban` | Banning members | `"ban"` |
|
|
189
|
+
| `member_unban` | Unbanning people | `"ban"` |
|
|
190
|
+
| `webhook_create` | Creating spam webhooks | `"ban"` |
|
|
191
|
+
| `bot_add` | Adding bad bots | Always bans (automatic) |
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 🎨 Simple Examples
|
|
196
|
+
|
|
197
|
+
### Example 1: Strict Mode (Ban Everything)
|
|
198
|
+
|
|
199
|
+
```python
|
|
200
|
+
await sx.enable(
|
|
201
|
+
punishments={
|
|
202
|
+
"channel_delete": "ban",
|
|
203
|
+
"channel_create": "ban",
|
|
204
|
+
"role_delete": "ban",
|
|
205
|
+
"role_create": "ban",
|
|
206
|
+
"member_kick": "ban",
|
|
207
|
+
"member_ban": "ban"
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Example 2: Gentle Mode (Warn Only)
|
|
213
|
+
|
|
214
|
+
```python
|
|
215
|
+
await sx.enable(
|
|
216
|
+
punishments={
|
|
217
|
+
"channel_delete": "timeout",
|
|
218
|
+
"role_delete": "timeout",
|
|
219
|
+
"member_kick": "warn"
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Example 3: Protection Without Punishment
|
|
225
|
+
|
|
226
|
+
```python
|
|
227
|
+
await sx.enable()
|
|
228
|
+
```
|
|
229
|
+
This only restores deleted stuff but doesn't punish anyone.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## 👥 Whitelist (Allow Trusted Users)
|
|
234
|
+
|
|
235
|
+
Want to allow some people to delete channels? Add them to the whitelist:
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
await sx.whitelist.add(guild_id, user_id)
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Example:**
|
|
242
|
+
```python
|
|
243
|
+
@bot.command()
|
|
244
|
+
@commands.is_owner()
|
|
245
|
+
async def trust(ctx, member: discord.Member):
|
|
246
|
+
await sx.whitelist.add(ctx.guild.id, member.id)
|
|
247
|
+
await ctx.send(f"✅ {member.name} is now trusted!")
|
|
248
|
+
|
|
249
|
+
@bot.command()
|
|
250
|
+
@commands.is_owner()
|
|
251
|
+
async def untrust(ctx, member: discord.Member):
|
|
252
|
+
await sx.whitelist.remove(ctx.guild.id, member.id)
|
|
253
|
+
await ctx.send(f"❌ {member.name} is no longer trusted!")
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## 🔔 Get Notified When Attacks Happen
|
|
259
|
+
|
|
260
|
+
Add this to your code to get alerts:
|
|
261
|
+
|
|
262
|
+
```python
|
|
263
|
+
@sx.on_threat_detected
|
|
264
|
+
async def alert(threat):
|
|
265
|
+
print(f"🚨 ATTACK DETECTED!")
|
|
266
|
+
print(f" Type: {threat.type}")
|
|
267
|
+
print(f" Attacker: {threat.actor_id}")
|
|
268
|
+
print(f" Punishment: {threat.punishment_action}")
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**Fancier Alert (Discord Embed):**
|
|
272
|
+
|
|
273
|
+
```python
|
|
274
|
+
@sx.on_threat_detected
|
|
275
|
+
async def fancy_alert(threat):
|
|
276
|
+
channel = bot.get_channel(YOUR_LOG_CHANNEL_ID)
|
|
277
|
+
|
|
278
|
+
embed = discord.Embed(
|
|
279
|
+
title="🚨 Security Alert!",
|
|
280
|
+
description=f"Someone tried to {threat.type}!",
|
|
281
|
+
color=discord.Color.red()
|
|
282
|
+
)
|
|
283
|
+
embed.add_field(name="Attacker", value=f"<@{threat.actor_id}>")
|
|
284
|
+
embed.add_field(name="What Happened", value=threat.target_name)
|
|
285
|
+
embed.add_field(name="Punishment", value=threat.punishment_action.upper())
|
|
286
|
+
|
|
287
|
+
await channel.send(embed=embed)
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## 📝 Full Working Example
|
|
293
|
+
|
|
294
|
+
Here's a complete bot with commands:
|
|
295
|
+
|
|
296
|
+
```python
|
|
297
|
+
import discord
|
|
298
|
+
from discord.ext import commands
|
|
299
|
+
from securex import SecureX
|
|
300
|
+
|
|
301
|
+
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
|
|
302
|
+
sx = SecureX(bot)
|
|
303
|
+
|
|
304
|
+
@bot.event
|
|
305
|
+
async def on_ready():
|
|
306
|
+
await sx.enable(punishments={"channel_delete": "ban", "member_ban": "ban"})
|
|
307
|
+
print(f"✅ {bot.user.name} is protecting {len(bot.guilds)} servers!")
|
|
308
|
+
|
|
309
|
+
@sx.on_threat_detected
|
|
310
|
+
async def log_attack(threat):
|
|
311
|
+
print(f"🚨 Stopped {threat.type} by user {threat.actor_id}")
|
|
312
|
+
|
|
313
|
+
@bot.command()
|
|
314
|
+
@commands.is_owner()
|
|
315
|
+
async def trust(ctx, member: discord.Member):
|
|
316
|
+
await sx.whitelist.add(ctx.guild.id, member.id)
|
|
317
|
+
await ctx.send(f"✅ {member.mention} can now manage the server!")
|
|
318
|
+
|
|
319
|
+
@bot.command()
|
|
320
|
+
@commands.is_owner()
|
|
321
|
+
async def untrust(ctx, member: discord.Member):
|
|
322
|
+
await sx.whitelist.remove(ctx.guild.id, member.id)
|
|
323
|
+
await ctx.send(f"❌ {member.mention} is no longer trusted!")
|
|
324
|
+
|
|
325
|
+
@bot.command()
|
|
326
|
+
async def ping(ctx):
|
|
327
|
+
await ctx.send(f"🏓 Pong! Protection active!")
|
|
328
|
+
|
|
329
|
+
bot.run("YOUR_BOT_TOKEN")
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## ❓ Common Questions
|
|
335
|
+
|
|
336
|
+
### Q: Will this slow down my bot?
|
|
337
|
+
**A:** No! SecureX is SUPER fast (5-10 milliseconds). Your bot will work normally.
|
|
338
|
+
|
|
339
|
+
### Q: What if I accidentally delete a channel?
|
|
340
|
+
**A:** If you're the server owner, SecureX won't stop you! Or add yourself to the whitelist.
|
|
341
|
+
|
|
342
|
+
### Q: Can I change punishments later?
|
|
343
|
+
**A:** Yes! Just call `await sx.enable(punishments={...})` again with new settings.
|
|
344
|
+
|
|
345
|
+
### Q: Does it work on multiple servers?
|
|
346
|
+
**A:** Yes! It automatically protects all servers your bot is in.
|
|
347
|
+
|
|
348
|
+
### Q: What if my bot goes offline?
|
|
349
|
+
**A:** When it comes back online, it automatically creates new backups. But it can't stop attacks while offline.
|
|
350
|
+
|
|
351
|
+
### Q: How do I make my own commands?
|
|
352
|
+
**A:** Check [discord.py documentation](https://discordpy.readthedocs.io/) to learn more about making bot commands!
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## 🔧 Troubleshooting
|
|
357
|
+
|
|
358
|
+
### ❌ "Missing Permissions" Error
|
|
359
|
+
|
|
360
|
+
**Solution:** Make sure your bot has Administrator permission, or at least these:
|
|
361
|
+
- Manage Channels
|
|
362
|
+
- Manage Roles
|
|
363
|
+
- Ban Members
|
|
364
|
+
- Kick Members
|
|
365
|
+
- View Audit Log
|
|
366
|
+
|
|
367
|
+
### ❌ Bot doesn't detect attacks
|
|
368
|
+
|
|
369
|
+
**Solution:**
|
|
370
|
+
1. Check if you enabled **SERVER MEMBERS INTENT** in Discord Developer Portal
|
|
371
|
+
2. Make sure your bot is using `intents=discord.Intents.all()`
|
|
372
|
+
3. Check if bot role is above other roles in Server Settings → Roles
|
|
373
|
+
|
|
374
|
+
### ❌ Can't restore deleted channels
|
|
375
|
+
|
|
376
|
+
**Solution:** Bot role must be **higher** than the roles it needs to manage
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
## 🏗️ Architecture (How It Works Under the Hood)
|
|
381
|
+
|
|
382
|
+
SecureX uses a **Triple-Worker Architecture** for maximum speed and reliability. Here's how it works:
|
|
383
|
+
|
|
384
|
+
### ⚡ The Triple-Worker System
|
|
385
|
+
|
|
386
|
+
Think of SecureX like a security team with 3 specialized workers:
|
|
387
|
+
|
|
388
|
+
```
|
|
389
|
+
┌─────────────────────────────────────────────────────────┐
|
|
390
|
+
│ DISCORD SERVER │
|
|
391
|
+
│ (Someone deletes a channel, kicks a member, etc.) │
|
|
392
|
+
└────────────────┬────────────────────────────────────────┘
|
|
393
|
+
│
|
|
394
|
+
▼
|
|
395
|
+
┌────────────────────────────────────────────────────────┐
|
|
396
|
+
│ DISCORD AUDIT LOG EVENT (Instant!) │
|
|
397
|
+
│ Discord creates a log entry: "User X deleted #general"│
|
|
398
|
+
└────────────────┬───────────────────────────────────────┘
|
|
399
|
+
│
|
|
400
|
+
▼ (5-10 milliseconds)
|
|
401
|
+
┌────────────────────────────────────────────────────────┐
|
|
402
|
+
│ SECUREX EVENT LISTENER │
|
|
403
|
+
│ (Catches the audit log instantly) │
|
|
404
|
+
└─────┬──────────┬─────────────┬────────────────────────┘
|
|
405
|
+
│ │ │
|
|
406
|
+
▼ ▼ ▼
|
|
407
|
+
┌─────┐ ┌─────┐ ┌─────┐
|
|
408
|
+
│ Q1 │ │ Q2 │ │ Q3 │ (3 Queues)
|
|
409
|
+
└──┬──┘ └──┬──┘ └──┬──┘
|
|
410
|
+
│ │ │
|
|
411
|
+
▼ ▼ ▼
|
|
412
|
+
┌─────────┐ ┌─────────┐ ┌─────────┐
|
|
413
|
+
│Worker 1 │ │Worker 2 │ │Worker 3 │
|
|
414
|
+
│ Action │ │ Cleanup │ │ Log │
|
|
415
|
+
└─────────┘ └─────────┘ └─────────┘
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### 🔨 Worker 1: Action Worker (PUNISHER)
|
|
419
|
+
**Job:** Ban/kick bad users INSTANTLY
|
|
420
|
+
|
|
421
|
+
**What it does:**
|
|
422
|
+
1. Checks if user is whitelisted
|
|
423
|
+
2. If NOT whitelisted → BAN them immediately
|
|
424
|
+
3. Takes only 5-10 milliseconds!
|
|
425
|
+
|
|
426
|
+
**Example:**
|
|
427
|
+
```
|
|
428
|
+
User "Hacker123" deletes #general
|
|
429
|
+
↓ (5ms later)
|
|
430
|
+
Action Worker: "Hacker123 is NOT whitelisted"
|
|
431
|
+
↓
|
|
432
|
+
*BANS Hacker123 instantly*
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### 🧹 Worker 2: Cleanup Worker (CLEANER)
|
|
436
|
+
**Job:** Delete spam creations (channels, roles, webhooks)
|
|
437
|
+
|
|
438
|
+
**What it does:**
|
|
439
|
+
1. If someone creates 50 spam channels
|
|
440
|
+
2. Deletes them all INSTANTLY
|
|
441
|
+
3. Prevents server from getting cluttered
|
|
442
|
+
|
|
443
|
+
**Example:**
|
|
444
|
+
```
|
|
445
|
+
User creates spam channel "#spam1"
|
|
446
|
+
↓ (10ms later)
|
|
447
|
+
Cleanup Worker: "Unauthorized channel!"
|
|
448
|
+
↓
|
|
449
|
+
*Deletes #spam1 immediately*
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
### � Worker 3: Log Worker (REPORTER)
|
|
453
|
+
**Job:** Alert you about attacks
|
|
454
|
+
|
|
455
|
+
**What it does:**
|
|
456
|
+
1. Fires your callbacks
|
|
457
|
+
2. Sends you alerts
|
|
458
|
+
3. Logs everything for review
|
|
459
|
+
|
|
460
|
+
**Example:**
|
|
461
|
+
```
|
|
462
|
+
Attack detected!
|
|
463
|
+
↓
|
|
464
|
+
Log Worker: Calls your @sx.on_threat_detected
|
|
465
|
+
↓
|
|
466
|
+
You get an alert embed in Discord!
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
### 🔄 Restoration System (Separate from Workers)
|
|
472
|
+
|
|
473
|
+
**Job:** Restore deleted stuff from backups
|
|
474
|
+
|
|
475
|
+
**How it works:**
|
|
476
|
+
```
|
|
477
|
+
Channel deleted
|
|
478
|
+
↓ (500ms wait for audit log)
|
|
479
|
+
↓
|
|
480
|
+
Restoration Handler checks: "Was this authorized?"
|
|
481
|
+
↓ NO
|
|
482
|
+
↓
|
|
483
|
+
Looks in backup: "Found #general backup!"
|
|
484
|
+
↓
|
|
485
|
+
*Recreates channel with same permissions*
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
**Automatic Backups:**
|
|
489
|
+
- Creates backup every 10 minutes
|
|
490
|
+
- Saves: Channels, roles, permissions, positions
|
|
491
|
+
- Stored in `./data/backups/` folder
|
|
492
|
+
|
|
493
|
+
---
|
|
494
|
+
|
|
495
|
+
### 🎯 Why Triple Workers?
|
|
496
|
+
|
|
497
|
+
**Speed:**
|
|
498
|
+
- Workers don't wait for each other
|
|
499
|
+
- All process in parallel
|
|
500
|
+
- Punishment happens in 5-10ms!
|
|
501
|
+
|
|
502
|
+
**Reliability:**
|
|
503
|
+
- If one worker crashes, others keep working
|
|
504
|
+
- Each worker has its own queue
|
|
505
|
+
- No single point of failure
|
|
506
|
+
|
|
507
|
+
**Separation:**
|
|
508
|
+
- Punishment (fast) ≠ Restoration (slower but thorough)
|
|
509
|
+
- Action Worker = instant ban
|
|
510
|
+
- Restoration Handler = careful rebuild
|
|
511
|
+
|
|
512
|
+
---
|
|
513
|
+
|
|
514
|
+
### 📊 Data Flow Example
|
|
515
|
+
|
|
516
|
+
Let's say "BadUser" deletes 5 channels:
|
|
517
|
+
|
|
518
|
+
**Timeline:**
|
|
519
|
+
```
|
|
520
|
+
0ms - BadUser deletes #general
|
|
521
|
+
5ms - SecureX detects it (audit log)
|
|
522
|
+
7ms - Broadcasts to 3 workers
|
|
523
|
+
10ms - Action Worker BANS BadUser
|
|
524
|
+
12ms - Cleanup Worker ready (no cleanup needed)
|
|
525
|
+
15ms - Log Worker alerts you
|
|
526
|
+
500ms - Restoration Handler starts
|
|
527
|
+
750ms - #general recreated with permissions
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
**Result:**
|
|
531
|
+
- ✅ BadUser banned in 10ms
|
|
532
|
+
- ✅ You alerted in 15ms
|
|
533
|
+
- ✅ #general restored in 750ms
|
|
534
|
+
- ✅ Total response: Less than 1 second!
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
### 🧠 Smart Permission Detection
|
|
539
|
+
|
|
540
|
+
When someone updates a member's roles:
|
|
541
|
+
|
|
542
|
+
```
|
|
543
|
+
User "Sneaky" gives Admin role to "Friend"
|
|
544
|
+
↓
|
|
545
|
+
Member Update Handler triggered
|
|
546
|
+
↓
|
|
547
|
+
Checks: "Is Sneaky whitelisted?"
|
|
548
|
+
↓ NO
|
|
549
|
+
↓
|
|
550
|
+
Scans ALL roles of "Friend"
|
|
551
|
+
↓
|
|
552
|
+
Finds roles with dangerous permissions:
|
|
553
|
+
- Administrator ❌
|
|
554
|
+
- Manage Roles ❌
|
|
555
|
+
- Ban Members ❌
|
|
556
|
+
↓
|
|
557
|
+
*Removes ALL dangerous roles in ONE API call*
|
|
558
|
+
↓
|
|
559
|
+
Friend is now safe!
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
**Dangerous Permissions Detected:**
|
|
563
|
+
- Administrator
|
|
564
|
+
- Kick Members
|
|
565
|
+
- Ban Members
|
|
566
|
+
- Manage Guild
|
|
567
|
+
- Manage Roles
|
|
568
|
+
- Manage Channels
|
|
569
|
+
- Manage Webhooks
|
|
570
|
+
- Manage Emojis
|
|
571
|
+
- Mention Everyone
|
|
572
|
+
- Manage Expressions
|
|
573
|
+
|
|
574
|
+
---
|
|
575
|
+
|
|
576
|
+
### 💾 Caching System
|
|
577
|
+
|
|
578
|
+
SecureX uses caching for maximum speed:
|
|
579
|
+
|
|
580
|
+
**Cached Data:**
|
|
581
|
+
1. **Whitelist** - Frozenset for O(1) lookup
|
|
582
|
+
2. **Dangerous Permissions** - Class-level constant
|
|
583
|
+
3. **Guild Backups** - Updated every 10 minutes
|
|
584
|
+
|
|
585
|
+
**Why This Matters:**
|
|
586
|
+
```python
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
OLD (v1.x):
|
|
590
|
+
Check whitelist → Database query (50-100ms)
|
|
591
|
+
|
|
592
|
+
NEW (v2.x):
|
|
593
|
+
Check whitelist → Memory lookup (0.001ms)
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
**50,000x faster!**
|
|
597
|
+
|
|
598
|
+
---
|
|
599
|
+
|
|
600
|
+
## 📊 How It Works (Simple Summary)
|
|
601
|
+
|
|
602
|
+
1. **Someone does something bad** (delete channel, ban member, etc.)
|
|
603
|
+
2. **Discord logs it** (in audit log)
|
|
604
|
+
3. **SecureX sees it instantly** (5-10 milliseconds later!)
|
|
605
|
+
4. **Checks if they're allowed** (whitelist check)
|
|
606
|
+
5. **If NOT allowed:**
|
|
607
|
+
- Bans/kicks them (punishment)
|
|
608
|
+
- Restores what they deleted (from backup)
|
|
609
|
+
- Alerts you (via callback)
|
|
610
|
+
|
|
611
|
+
All of this happens **automatically** while you sleep! 😴
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
---
|
|
615
|
+
|
|
616
|
+
## 🎓 Next Steps
|
|
617
|
+
|
|
618
|
+
1. ✅ Get bot token from Discord Developer Portal
|
|
619
|
+
2. ✅ Install: `pip install dc-securex`
|
|
620
|
+
3. ✅ Copy the example code
|
|
621
|
+
4. ✅ Add your bot token
|
|
622
|
+
5. ✅ Run: `python bot.py`
|
|
623
|
+
6. 🎉 Your server is protected!
|
|
624
|
+
|
|
625
|
+
---
|
|
626
|
+
|
|
627
|
+
## 📚 Want to Learn More?
|
|
628
|
+
|
|
629
|
+
- [Discord.py Docs](https://discordpy.readthedocs.io/) - Learn to make Discord bots
|
|
630
|
+
- [Python Tutorial](https://docs.python.org/3/tutorial/) - Learn Python basics
|
|
631
|
+
- [Discord Developer Portal](https://discord.com/developers/docs) - Official Discord docs
|
|
632
|
+
|
|
633
|
+
---
|
|
634
|
+
|
|
635
|
+
## 📄 License
|
|
636
|
+
|
|
637
|
+
MIT License - Free to use! ❤️
|
|
638
|
+
|
|
639
|
+
---
|
|
640
|
+
|
|
641
|
+
## 🌟 Support
|
|
642
|
+
|
|
643
|
+
Having issues? Questions? Found a bug?
|
|
644
|
+
- Open an issue on GitHub
|
|
645
|
+
- Read this README carefully
|
|
646
|
+
- Check if your bot has all permissions
|
|
647
|
+
|
|
648
|
+
---
|
|
649
|
+
|
|
650
|
+
**Made with ❤️ for Discord bot developers**
|
|
651
|
+
**Version 2.15.1** - Even faster and cleaner!
|
|
652
|
+
|
|
653
|
+
🚀 **Start protecting your server today!**
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
dc_securex-2.15.3.dist-info/licenses/LICENSE,sha256=5KCqFV9v4YdDdaL70-EV5iuwXUcIDzv-EScT_9fy4yg,1069
|
|
2
|
+
securex/__init__.py,sha256=2HZvu9GdWjP8cxk81D_bYhKQeg0eHoYAb9lR2KC4wjc,334
|
|
3
|
+
securex/client.py,sha256=mzWH-dOkZA-Qjp9R45HGyzAMn4rS4U-rcwl8Q4ESoSQ,20948
|
|
4
|
+
securex/models.py,sha256=x7U_6eFQoTqqNvxDClWxZ4xFI26tSkXuuKBkiWRVH1w,3467
|
|
5
|
+
securex/backup/__init__.py,sha256=1YBeSQgXgmJk1Fl4ALDh1Oy-96dWh4uMbnf9nrFZpWo,86
|
|
6
|
+
securex/backup/manager.py,sha256=IgLlHZUDqQ1rHoFXrvmulmdEr-Y2vY3LSTNTkvZY8lM,27568
|
|
7
|
+
securex/handlers/__init__.py,sha256=M6pgMkcXbNmB42BvHMTfLWwG4oVorJthJXpWpmpij9c,268
|
|
8
|
+
securex/handlers/channel.py,sha256=mAnADu-hpsi9eqg2J1XQNnVJMesSm8UoSsSyLsRLuwA,4064
|
|
9
|
+
securex/handlers/member.py,sha256=y1HSjQF8h6qXGHeb1eXgiKVHIado2fdpLBb166EINsc,4413
|
|
10
|
+
securex/handlers/role.py,sha256=cSVJeTMI1l7lN3e8ts7nk9yCCE4e2YJewS3exLS0fo0,2766
|
|
11
|
+
securex/utils/__init__.py,sha256=G5jQw6dReqHtmmQMZcIx7jjZc3MI2_rX9VOJ0-A1_Jk,93
|
|
12
|
+
securex/utils/punishment.py,sha256=nTlwvph70WM4gtADQR2oMmXpHBs4AufM6NQAuRtXO-g,4229
|
|
13
|
+
securex/utils/whitelist.py,sha256=Ph1q2XeMvY4tPSE529roTzYz6xDSZZKLmA-SOiAaDbQ,4626
|
|
14
|
+
dc_securex-2.15.3.dist-info/METADATA,sha256=6yB_smDtPZ_JXxBlbYV1Mvg_6hoiCtGRGrpnbvmbxGc,17522
|
|
15
|
+
dc_securex-2.15.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
16
|
+
dc_securex-2.15.3.dist-info/top_level.txt,sha256=sc0ranjjI4aZxvHY_nmCCTAZRnw2QVaU56sPAyd3q4E,8
|
|
17
|
+
dc_securex-2.15.3.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SecureX Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
securex
|