dc-securex 1.3.1__tar.gz → 1.8.5__tar.gz

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.
Files changed (32) hide show
  1. dc_securex-1.8.5/PKG-INFO +568 -0
  2. dc_securex-1.8.5/README.md +540 -0
  3. dc_securex-1.8.5/dc_securex.egg-info/PKG-INFO +568 -0
  4. {dc_securex-1.3.1 → dc_securex-1.8.5}/dc_securex.egg-info/SOURCES.txt +1 -0
  5. {dc_securex-1.3.1 → dc_securex-1.8.5}/dc_securex.egg-info/requires.txt +1 -0
  6. {dc_securex-1.3.1 → dc_securex-1.8.5}/pyproject.toml +2 -1
  7. {dc_securex-1.3.1 → dc_securex-1.8.5}/securex/backup/manager.py +245 -0
  8. dc_securex-1.8.5/securex/client.py +240 -0
  9. dc_securex-1.8.5/securex/handlers/channel.py +201 -0
  10. dc_securex-1.8.5/securex/handlers/role.py +172 -0
  11. {dc_securex-1.3.1 → dc_securex-1.8.5}/securex/handlers/role_monitor.py +38 -1
  12. {dc_securex-1.3.1 → dc_securex-1.8.5}/securex/models.py +1 -0
  13. dc_securex-1.8.5/securex/utils/punishment.py +123 -0
  14. {dc_securex-1.3.1 → dc_securex-1.8.5}/securex/utils/whitelist.py +42 -9
  15. {dc_securex-1.3.1 → dc_securex-1.8.5}/setup.py +2 -1
  16. dc_securex-1.3.1/PKG-INFO +0 -177
  17. dc_securex-1.3.1/README.md +0 -150
  18. dc_securex-1.3.1/dc_securex.egg-info/PKG-INFO +0 -177
  19. dc_securex-1.3.1/securex/client.py +0 -210
  20. dc_securex-1.3.1/securex/handlers/channel.py +0 -123
  21. dc_securex-1.3.1/securex/handlers/role.py +0 -111
  22. {dc_securex-1.3.1 → dc_securex-1.8.5}/LICENSE +0 -0
  23. {dc_securex-1.3.1 → dc_securex-1.8.5}/MANIFEST.in +0 -0
  24. {dc_securex-1.3.1 → dc_securex-1.8.5}/dc_securex.egg-info/dependency_links.txt +0 -0
  25. {dc_securex-1.3.1 → dc_securex-1.8.5}/dc_securex.egg-info/top_level.txt +0 -0
  26. {dc_securex-1.3.1 → dc_securex-1.8.5}/securex/__init__.py +0 -0
  27. {dc_securex-1.3.1 → dc_securex-1.8.5}/securex/backup/__init__.py +0 -0
  28. {dc_securex-1.3.1 → dc_securex-1.8.5}/securex/handlers/__init__.py +0 -0
  29. {dc_securex-1.3.1 → dc_securex-1.8.5}/securex/handlers/member.py +0 -0
  30. {dc_securex-1.3.1 → dc_securex-1.8.5}/securex/handlers/webhook.py +0 -0
  31. {dc_securex-1.3.1 → dc_securex-1.8.5}/securex/utils/__init__.py +0 -0
  32. {dc_securex-1.3.1 → dc_securex-1.8.5}/setup.cfg +0 -0
@@ -0,0 +1,568 @@
1
+ Metadata-Version: 2.4
2
+ Name: dc-securex
3
+ Version: 1.8.5
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 Anti-Nuke SDK
30
+
31
+ **Backend-only Discord anti-nuke protection.** You provide the UI, we provide the security logic.
32
+
33
+ [![PyPI version](https://badge.fury.io/py/dc-securex.svg)](https://pypi.org/project/dc-securex/)
34
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install dc-securex
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ ```python
45
+ import discord
46
+ from discord.ext import commands
47
+ from securex import SecureX
48
+
49
+ bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
50
+ sx = SecureX(bot)
51
+
52
+ @bot.event
53
+ async def on_ready():
54
+ # Enable protection with punishments
55
+ await sx.enable(
56
+ punishments={
57
+ "channel_delete": "ban",
58
+ "role_delete": "ban"
59
+ }
60
+ )
61
+
62
+ # Register callback for custom UI
63
+ @sx.on_threat_detected
64
+ async def alert(threat):
65
+ print(f"⚠️ {threat.type} by {threat.actor_id} - Punishment: {threat.punishment_action}")
66
+
67
+ bot.run("TOKEN")
68
+ ```
69
+
70
+ ## Features
71
+
72
+ ✅ **Channel Protection** - Detects & restores unauthorized channel changes
73
+ ✅ **Role Protection** - Detects & restores unauthorized role changes
74
+ ✅ **Member Protection** - Blocks unauthorized bots, bans, kicks
75
+ ✅ **Webhook Protection** - Removes spam webhooks
76
+ ✅ **Punishment System** - Configurable kick/ban/timeout/warn actions
77
+ ✅ **Role Position Monitoring** - 5-second checks with bulk restore
78
+ ✅ **Category Children Restoration** - Auto-restores child channels
79
+ ✅ **Auto-Backup** - Automatic server backups
80
+ ✅ **Whitelist System** - Manage authorized users
81
+ ❌ **No UI** - You decide how to present data!
82
+
83
+ ---
84
+
85
+ ## Complete API Reference
86
+
87
+ ### Initialization
88
+
89
+ ```python
90
+ sx = SecureX(bot, backup_dir="./data/backups")
91
+ ```
92
+
93
+ **Parameters:**
94
+ - `bot` (required): Your discord.py Bot or Client instance
95
+ - `backup_dir` (optional): Path to store backups (default: `"./data/backups"`)
96
+
97
+ ---
98
+
99
+ ### `enable()` - Enable Protection
100
+
101
+ ```python
102
+ await sx.enable(
103
+ guild_id=None,
104
+ whitelist=None,
105
+ auto_backup=True,
106
+ role_position_monitoring=True,
107
+ punishments=None,
108
+ timeout_duration=600,
109
+ notify_user=True
110
+ )
111
+ ```
112
+
113
+ **All Parameters:**
114
+
115
+ | Parameter | Type | Default | Description |
116
+ |-----------|------|---------|-------------|
117
+ | `guild_id` | `int` | `None` | Specific guild to enable for (optional) |
118
+ | `whitelist` | `List[int]` | `None` | List of user IDs to whitelist |
119
+ | `auto_backup` | `bool` | `True` | Enable automatic backups |
120
+ | `role_position_monitoring` | `bool` | `True` | Enable 5-second role position checks |
121
+ | `punishments` | `Dict[str, str]` | `None` | Punishment actions per violation type |
122
+ | `timeout_duration` | `int` | `600` | Timeout duration in seconds (for timeout punishment) |
123
+ | `notify_user` | `bool` | `True` | Whether to DM violators about punishment |
124
+
125
+ **Punishment Configuration:**
126
+
127
+ Available actions: `"none"`, `"warn"`, `"timeout"`, `"kick"`, `"ban"`
128
+
129
+ Available violation types:
130
+ - `channel_delete` - Channel deletion
131
+ - `channel_create` - Mass channel creation
132
+ - `channel_update` - Channel permission/name changes
133
+ - `role_delete` - Role deletion
134
+ - `role_create` - Mass role creation
135
+ - `role_update` - Role permission changes
136
+ - `member_ban` - Unauthorized bans
137
+ - `member_kick` - Unauthorized kicks
138
+ - `webhook_create` - Webhook spam
139
+ - `webhook_spam` - Webhook abuse
140
+
141
+ **Examples:**
142
+
143
+ ```python
144
+ # Example 1: Ban for delete, kick for create
145
+ await sx.enable(
146
+ punishments={
147
+ "channel_delete": "ban",
148
+ "role_delete": "ban",
149
+ "channel_create": "kick",
150
+ "role_create": "kick"
151
+ }
152
+ )
153
+
154
+ # Example 2: Use timeouts (30 minutes)
155
+ await sx.enable(
156
+ punishments={
157
+ "channel_delete": "timeout",
158
+ "role_delete": "timeout"
159
+ },
160
+ timeout_duration=1800,
161
+ notify_user=True
162
+ )
163
+
164
+ # Example 3: Just warnings (no action)
165
+ await sx.enable(
166
+ punishments={
167
+ "channel_delete": "warn",
168
+ "role_create": "warn"
169
+ }
170
+ )
171
+
172
+ # Example 4: No punishments (just restore)
173
+ await sx.enable() # All violations default to "none"
174
+ ```
175
+
176
+ ---
177
+
178
+ ### Other Methods
179
+
180
+ #### Backup Management
181
+
182
+ ```python
183
+ # Create manual backup
184
+ backup_info = await sx.create_backup(guild_id)
185
+ # Returns: BackupInfo(guild_id, timestamp, channel_count, role_count, ...)
186
+ ```
187
+
188
+ #### Threat History
189
+
190
+ ```python
191
+ # Get recent threats
192
+ threats = await sx.get_recent_threats(guild_id, limit=10)
193
+ # Returns: List[ThreatEvent]
194
+ ```
195
+
196
+ #### Whitelist Management
197
+
198
+ ```python
199
+ # Add user to whitelist
200
+ await sx.whitelist.add(guild_id, user_id)
201
+
202
+ # Remove from whitelist
203
+ await sx.whitelist.remove(guild_id, user_id)
204
+
205
+ # Get all whitelisted users
206
+ users = await sx.whitelist.get_all(guild_id)
207
+ # Returns: List[int]
208
+
209
+ # Check if whitelisted
210
+ is_safe = await sx.whitelist.is_whitelisted(guild_id, user_id)
211
+ # Returns: bool
212
+ ```
213
+
214
+ ---
215
+
216
+ ## Data Models
217
+
218
+ ### ThreatEvent
219
+
220
+ ```python
221
+ @dataclass
222
+ class ThreatEvent:
223
+ type: str # "channel_delete", "role_create", etc.
224
+ guild_id: int
225
+ actor_id: int # Who committed the violation
226
+ target_id: int # What was affected
227
+ target_name: str
228
+ prevented: bool # Was it stopped?
229
+ restored: bool # Was it restored?
230
+ timestamp: datetime
231
+ details: Dict # Additional context
232
+ punishment_action: str # What punishment was applied ("none", "warn", "kick", etc.)
233
+ ```
234
+
235
+ **Methods:**
236
+ - `threat.to_dict()` - Convert to dictionary
237
+ - `threat.to_json()` - Convert to JSON string
238
+
239
+ ### BackupInfo
240
+
241
+ ```python
242
+ @dataclass
243
+ class BackupInfo:
244
+ guild_id: int
245
+ timestamp: datetime
246
+ channel_count: int
247
+ role_count: int
248
+ backup_path: str
249
+ success: bool
250
+ ```
251
+
252
+ ### RestoreResult
253
+
254
+ ```python
255
+ @dataclass
256
+ class RestoreResult:
257
+ success: bool
258
+ items_restored: int
259
+ items_failed: int
260
+ errors: List[str]
261
+ duration: float
262
+ details: Dict
263
+ ```
264
+
265
+ ### WhitelistChange
266
+
267
+ ```python
268
+ @dataclass
269
+ class WhitelistChange:
270
+ guild_id: int
271
+ user_id: int
272
+ action: str # "added" or "removed"
273
+ timestamp: datetime
274
+ moderator_id: int
275
+ ```
276
+
277
+ ---
278
+
279
+ ## Callbacks
280
+
281
+ Register custom handlers for events:
282
+
283
+ ```python
284
+ @sx.on_threat_detected
285
+ async def handle_threat(threat: ThreatEvent):
286
+ # threat.punishment_action tells you what happened
287
+ print(f"{threat.type} - Punishment: {threat.punishment_action}")
288
+
289
+ @sx.on_backup_completed
290
+ async def handle_backup(backup: BackupInfo):
291
+ print(f"Backup completed: {backup.channel_count} channels")
292
+
293
+ @sx.on_restore_completed
294
+ async def handle_restore(result: RestoreResult):
295
+ print(f"Restored {result.items_restored} items")
296
+
297
+ @sx.on_whitelist_changed
298
+ async def handle_whitelist(change: WhitelistChange):
299
+ print(f"User {change.user_id} {change.action}")
300
+ ```
301
+
302
+ ---
303
+
304
+ ## Advanced Examples
305
+
306
+ ### Custom Discord Embed UI
307
+
308
+ ```python
309
+ @sx.on_threat_detected
310
+ async def custom_alert(threat):
311
+ embed = discord.Embed(
312
+ title="🚨 Security Alert",
313
+ description=f"**{threat.type.replace('_', ' ').title()}**",
314
+ color=discord.Color.red()
315
+ )
316
+ embed.add_field(name="Violator", value=f"<@{threat.actor_id}>", inline=True)
317
+ embed.add_field(name="Target", value=threat.target_name, inline=True)
318
+ embed.add_field(name="Prevented", value="✅" if threat.prevented else "❌", inline=True)
319
+
320
+ if threat.punishment_action and threat.punishment_action != "none":
321
+ embed.add_field(
322
+ name="Punishment",
323
+ value=f"**{threat.punishment_action.upper()}**",
324
+ inline=False
325
+ )
326
+
327
+ await log_channel.send(embed=embed)
328
+ ```
329
+
330
+ ### Webhook Integration
331
+
332
+ ```python
333
+ @sx.on_threat_detected
334
+ async def send_to_webhook(threat):
335
+ async with aiohttp.ClientSession() as session:
336
+ await session.post(
337
+ "https://your-webhook-url.com/alerts",
338
+ json=threat.to_dict()
339
+ )
340
+ ```
341
+
342
+ ### Database Logging
343
+
344
+ ```python
345
+ @sx.on_threat_detected
346
+ async def log_to_database(threat):
347
+ await db.execute(
348
+ "INSERT INTO threats (type, actor_id, target_name, punishment) VALUES (?, ?, ?, ?)",
349
+ threat.type, threat.actor_id, threat.target_name, threat.punishment_action
350
+ )
351
+ ```
352
+
353
+ ### Multi-Mode Punishment
354
+
355
+ ```python
356
+ @bot.command()
357
+ @commands.is_owner()
358
+ async def set_mode(ctx, mode: str):
359
+ """Switch between strict/normal/lenient modes"""
360
+
361
+ modes = {
362
+ "strict": {
363
+ "channel_delete": "ban",
364
+ "channel_create": "ban",
365
+ "role_delete": "ban",
366
+ "role_create": "ban"
367
+ },
368
+ "normal": {
369
+ "channel_delete": "kick",
370
+ "channel_create": "timeout",
371
+ "role_delete": "kick",
372
+ "role_create": "timeout"
373
+ },
374
+ "lenient": {
375
+ "channel_delete": "warn",
376
+ "channel_create": "warn",
377
+ "role_delete": "warn",
378
+ "role_create": "warn"
379
+ }
380
+ }
381
+
382
+ await sx.enable(punishments=modes.get(mode, {}))
383
+ await ctx.send(f"✅ Set to {mode} mode")
384
+ ```
385
+
386
+ ---
387
+
388
+ ## Why SDK Approach?
389
+
390
+ - 🎨 **Full UI Control** - Design your own embeds, dashboards, webhooks
391
+ - 📦 **Easy Integration** - Just `pip install` and import
392
+ - 🔒 **Battle-Tested Logic** - Proven anti-nuke protection
393
+ - 🚀 **No Boilerplate** - We handle the complex stuff
394
+ - 💰 **Reusable** - Use across multiple projects
395
+ - ⚙️ **Configurable** - Every parameter is optional with sensible defaults
396
+
397
+ ## Requirements
398
+
399
+ - Python 3.8+
400
+ - discord.py 2.0+
401
+ - Bot with these intents: `guilds`, `members`, `bans`, `webhooks`
402
+ - Bot permissions: `MANAGE_CHANNELS`, `MANAGE_ROLES`, `BAN_MEMBERS`, `KICK_MEMBERS`, `MODERATE_MEMBERS`
403
+
404
+ ## License
405
+
406
+ MIT License - see [LICENSE](LICENSE) file
407
+
408
+ ## Support
409
+
410
+ - **PyPI**: [dc-securex](https://pypi.org/project/dc-securex/)
411
+ - **Issues**: Report bugs on GitHub
412
+ - **Examples**: Check the `examples/` directory
413
+
414
+ ---
415
+
416
+ **Version 1.4.0** - Now with configurable punishment system!
417
+
418
+ Made with ❤️ by SecureX Team
419
+
420
+
421
+ **Backend-only Discord anti-nuke protection.** You provide the UI, we provide the security logic.
422
+
423
+ ## Installation
424
+
425
+ ```bash
426
+ pip install securex-antinuke
427
+ ```
428
+
429
+ ## Quick Start
430
+
431
+ ```python
432
+ import discord
433
+ from discord.ext import commands
434
+ from securex import SecureX
435
+
436
+ bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
437
+ sx = SecureX(bot)
438
+
439
+ # Enable protection
440
+ await sx.enable(whitelist=[123456789])
441
+
442
+ # Register callback - you build your own UI!
443
+ @sx.on_threat_detected
444
+ async def alert(threat):
445
+ # threat.type, threat.actor_id, threat.prevented, etc.
446
+ await channel.send(f"⚠️ Threat: {threat.type}")
447
+
448
+ bot.run("TOKEN")
449
+ ```
450
+
451
+ ## Features
452
+
453
+ ✅ **Channel Protection** - Detects & restores unauthorized channel changes
454
+ ✅ **Role Protection** - Detects & restores unauthorized role changes
455
+ ✅ **Member Protection** - Blocks unauthorized bots, bans, kicks
456
+ ✅ **Webhook Protection** - Removes spam webhooks
457
+ ✅ **Auto-Backup** - Automatic server backups
458
+ ✅ **Whitelist System** - Manage authorized users
459
+ ✅ **Role Position Monitoring** - 5-second checks with bulk restore (NEW in v1.2!)
460
+ ❌ **No UI** - You decide how to present data!
461
+
462
+ ## Data Objects
463
+
464
+ All callbacks receive **pure data objects** (no Discord embeds):
465
+
466
+ ### ThreatEvent
467
+ ```python
468
+ @dataclass
469
+ class ThreatEvent:
470
+ type: str # "channel_delete", "role_create", etc.
471
+ guild_id: int
472
+ actor_id: int # Who did it
473
+ target_id: int # What was affected
474
+ target_name: str
475
+ prevented: bool # Was it stopped?
476
+ restored: bool # Was it restored?
477
+ timestamp: datetime
478
+ details: dict # Additional context
479
+ ```
480
+
481
+ ## Examples
482
+
483
+ ### Custom Embed UI
484
+ ```python
485
+ @sx.on_threat_detected
486
+ async def custom_alert(threat):
487
+ embed = discord.Embed(
488
+ title="🚨 Security Alert",
489
+ description=f"Detected: {threat.type}"
490
+ )
491
+ embed.add_field(name="User", value=f"<@{threat.actor_id}>")
492
+ await log_channel.send(embed=embed)
493
+ ```
494
+
495
+ ### Webhook Integration
496
+ ```python
497
+ @sx.on_threat_detected
498
+ async def send_webhook(threat):
499
+ await webhook.send(threat.to_json())
500
+ ```
501
+
502
+ ### Multi-Output
503
+ ```python
504
+ @sx.on_threat_detected
505
+ async def handle(threat):
506
+ # Send to Discord
507
+ await channel.send(f"Threat: {threat.type}")
508
+
509
+ # Log to database
510
+ await db.insert(threat.to_dict())
511
+
512
+ # Send to external API
513
+ await api.post("/alerts", threat.to_json())
514
+ ```
515
+
516
+ ## API Reference
517
+
518
+ ### Main Client
519
+
520
+ ```python
521
+ sx = SecureX(bot, backup_dir=Path("./backups"))
522
+ ```
523
+
524
+ ### Methods
525
+
526
+ ```python
527
+ await sx.enable(whitelist=[...], auto_backup=True, role_position_monitoring=True)
528
+ await sx.create_backup(guild_id)
529
+ await sx.get_recent_threats(guild_id, limit=10)
530
+ ```
531
+
532
+ ### Whitelist
533
+
534
+ ```python
535
+ await sx.whitelist.add(guild_id, user_id)
536
+ await sx.whitelist.remove(guild_id, user_id)
537
+ users = await sx.whitelist.get_all(guild_id)
538
+ ```
539
+
540
+ ### Callbacks
541
+
542
+ ```python
543
+ @sx.on_threat_detected # ThreatEvent
544
+ @sx.on_backup_completed # BackupInfo
545
+ @sx.on_restore_completed # RestoreResult
546
+ @sx.on_whitelist_changed # WhitelistChange
547
+ ```
548
+
549
+ ## Why SDK?
550
+
551
+ - 🎨 **Full UI Control** - Design your own embeds, dashboards, webhooks
552
+ - 📦 **Easy Integration** - Just `pip install` and import
553
+ - 🔒 **Battle-Tested Logic** - Proven anti-nuke protection
554
+ - 🚀 **No Boilerplate** - We handle the complex stuff
555
+ - 💰 **Reusable** - Use across multiple projects
556
+
557
+ ## License
558
+
559
+ MIT License - see LICENSE file
560
+
561
+ ## Support
562
+
563
+ - GitHub: [github.com/yourusername/securex-antinuke](https://github.com/yourusername/securex-antinuke)
564
+ - Issues: [Report a bug](https://github.com/yourusername/securex-antinuke/issues)
565
+
566
+ ---
567
+
568
+ Made with ❤️ by SecureX Team