-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patho7python.py
More file actions
119 lines (111 loc) · 4.26 KB
/
Copy patho7python.py
File metadata and controls
119 lines (111 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import asyncio
import discord
import subprocess
import time
import re
import os
import threading
TOKEN = ""
client = discord.Client()
val = 0
WHITELIST = os.environ['WHITELIST'] #dont want your pc to get hijacked
def preventinfiniteloop():
didthecommandwork = 0
time.sleep(300)
while True:
time.sleep(1)
if didthecommandwork == 0:
try:
os.execv(sys.executable, ['python'] + sys.argv)
didthecommandwork = 1
except:
didthecommandwork = 0
startthefunctiontopreventinfiniteloop = threading.Thread(target=preventinfiniteloop)
startthefunctiontopreventinfiniteloop.start()
def findcharlength(txtfile):
with open(txtfile) as infile:
words = 0
characters = 0
for lineno, line in enumerate(infile, 1):
wordslist = line.split()
words += len(wordslist)
characters += sum(len(word) for word in wordslist)
return characters
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
@client.event
async def on_message(message):
if message.author.bot:
return
if message.content == "test":
await message.channel.send("yeah im alive")
if message.author.id in WHITELIST:
nothingsdu8infgevusybt = 0
else:
return
if message.content == "enablepr":
global val
if val != 0:
val = 0
f = open("val.txt", "w")
f.write(str(val))
f.close()
await message.channel.send("printing each line disabled")
else:
val = 1
f = open("val.txt", "w")
f.write(str(val))
f.close()
await message.channel.send("printing each line enabled")
if message.content.startswith("pip3"):
packagetoinstall = message.content.split("pip3 ")[1]
await message.channel.send("installing : " + packagetoinstall)
os.system("pip3 install " + packagetoinstall)
await message.channel.send("done installing " + packagetoinstall)
if message.content.startswith("py"):
if "@everyone" in message.content:
await message.channel.send("<@" + str(message.author.id) + "> lmao no")
return
if "@here" in message.content:
await message.channel.send("<@" + str(message.author.id) + "> lmao no")
return
if 1 == 1:
file_object = open("pee.py", "w+")
removedpy = message.content.replace("py", "", 1)
calc = [m.start() for m in re.finditer("input()", removedpy)]
for i in range(len(calc)):
try:
await message.channel.send("input:")
msg = await client.wait_for("message", timeout=30) # 30 seconds to reply
removedpy = removedpy.replace("input()", str(msg.content), 1)
except asyncio.TimeoutError:
await message.channel.send("Sorry, you didn't reply in time!")
return
file_object.write(removedpy)
file_object.close()
std = subprocess.run(['python3', 'pee.py'], capture_output=True, text=True)
if not std.stderr:
if val == 1:
with open('assad.txt', 'w') as file:
file.write(std.stdout)
with open('assad.txt', 'r') as file:
msg = file.read(2000).strip()
while len(msg) > 0:
await message.channel.send(msg)
msg = file.read(2000).strip()
else:
if len(std.stdout) >= 2000:
with open("result.txt", "w") as file:
file.write(std.stdout)
with open("result.txt", "rb") as file:
await message.channel.send("<@" + str(message.author.id) + "> Your file is:", file=discord.File(file, "result.txt"))
elif std.stdout == None:
await message.cannel.send("<@" + str(message.author.id) + "> no response")
else:
await message.channel.send("<@" + str(message.author.id) + ">")
await message.channel.send(std.stdout.replace("@everyone", "@ everyone").replace("@here", "@ here"))
else:
await message.channel.send("Discord Error - " + str("none yet because nexity lazy") + '\n')
await message.channel.send("Tracebacks:\n " + str(std.stderr))
client.run(TOKEN)