-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
honeypot_5.py
174 lines (136 loc) · 5.91 KB
/
honeypot_5.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import discord
import json
import random
import asyncio
import os
import requests
from discord.ext import commands
from discord.enums import ActivityType
import time
def HONEYPOT_5():
print("[HONEYPOT_5] Establishing connection to bot_instance...")
time.sleep(0.2)
print("[HONEYPOT_5] Connection established to bot_instance.")
time.sleep(0.5)
def load_token_config(file_name):
with open(os.path.join('Tokens', file_name), 'r') as f:
print(f"[HONEYPOT_5] Config {file_name} was loaded.")
return json.load(f)
def load_database(file_name):
with open(os.path.join('Database', file_name), 'r') as f:
print(f"[HONEYPOT_5] Config {file_name} was loaded.")
return json.load(f)
pronouns = load_database('pronouns.json') # Not directly used in this example
names = load_database('nicknames.json')
images = [os.path.join('Database', 'images', img) for img in load_database('images.json')]
statuses = load_database('status.json')
bios = load_database('about_me.json') # Added for bio updates
token_data = load_token_config('token_5.json')
# Bot setup
intents = discord.Intents.default()
intents.messages = True
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents, self_bot=True)
def get_activity(status):
activity_type = getattr(ActivityType, status.get("type", "").lower(), None)
if activity_type is None:
return discord.Game(name=status.get("name"))
elif activity_type == ActivityType.streaming:
return discord.Streaming(name=status.get("name"), url=status.get("url"))
else:
return discord.Activity(type=activity_type, name=status.get("name"))
def update_bio(token, new_bio):
url = "https://discord.com/api/v9/users/@me"
headers = {"Authorization": f"Bot {token}"}
json_data = {"bio": new_bio}
response = requests.patch(url, headers=headers, json=json_data)
return response.status_code
async def change_profile():
while True:
new_name = random.choice(names)
new_image_path = random.choice(images)
new_bio = random.choice(bios) # Select a new bio
try:
await bot.user.edit(username=new_name)
print(f"[HONEYPOT_5] Changed username to {new_name}")
except discord.HTTPException as e:
print(f"[HONEYPOT_5] Failed to change username: {e}")
try:
with open(new_image_path, 'rb') as img:
await bot.user.edit(avatar=img.read())
print(f"[HONEYPOT_5] Changed avatar image to {new_image_path}")
except discord.HTTPException as e:
print(f"[HONEYPOT_5] Failed to change avatar: {e}")
# Update the bio using the external function
status_code = update_bio(bot_token, new_bio)
if status_code != 200:
print(f"[HONEYPOT_5] Failed to update bio: HTTP {status_code}")
await asyncio.sleep(random.randint(12 * 3600, 72 * 3600))
async def change_status():
while True:
status_info = random.choice(statuses)
new_status = get_activity(status_info)
print(f"[HONEYPOT_5] Changed status to {new_status}")
await bot.change_presence(activity=new_status)
await asyncio.sleep(random.randint(600, 1800))
@bot.event
async def on_ready():
print(f'[HONEYPOT_5] Logged in as {bot.user.name}. Changing username...')
bot.loop.create_task(change_profile())
print(f'[HONEYPOT_5] Attempting to change avatar and username')
bot.loop.create_task(change_status())
print(f'[HONEYPOT_5] Attempting to change status')
@bot.event
async def on_message(message):
if not message.guild: # Check if the message is a DM
# Correctly getting the profile photo URL
avatar_url = str(message.author.avatar.url if message.author.avatar else None)
# Construct a log entry string with the desired information
log_entry_str = f"[HONEYPOT_5] DM Received - Time: {message.created_at}, From: {message.author} (ID: {message.author.id}, Avatar URL: {avatar_url}, Message: {message.content}"
print(log_entry_str) # Print the constructed log entry string to the console
log_entry = {
"time": str(message.created_at),
"from": {
"id": message.author.id,
"name": str(message.author),
"avatar_url": avatar_url,
},
"message": message.content
}
logs_path = os.path.join('Honeypot-Logs', "honeypot_dm_logs_5.json")
# Load existing logs or initialize an empty list
if os.path.exists(logs_path) and os.path.getsize(logs_path) > 0:
with open(logs_path, 'r') as file:
logs = json.load(file)
else:
logs = []
logs.append(log_entry)
# Write updated logs to file
with open(logs_path, 'w') as file:
json.dump(logs, file, indent=4)
# Immediately send the log to the specified channel
await send_dm_log_to_channel(log_entry)
await bot.process_commands(message)
async def send_dm_log_to_channel(log_entry):
channel_id = token_data.get('channel_id')
if not channel_id:
print("[HONEYPOT_5] Channel ID is not set in token.json.")
return
channel = bot.get_channel(int(channel_id))
if not channel:
print(f"[HONEYPOT_5] Channel with ID {channel_id} not found.")
return
message_content = (
"## HONEYPOT NO.1 WAS TRIGGERED\n"
f"- **HONEYPOT NO.1 RUNNING AS: @{bot.user.name}**\n"
f"- **DATE:** {log_entry['time'][:10]}\n"
f"- **TIME:** {log_entry['time'][11:19]}\n"
f"- **USERNAME:** {log_entry['from']['name']}\n"
f"- **USER ID:** {log_entry['from']['id']}\n"
f"- **USER AVATAR:** [Link]({log_entry['from']['avatar_url']})\n"
f"- **MESSAGE CONTENTS:** {log_entry['message']}"
)
await channel.send(message_content)
# Use the token from your token.json
bot_token = token_data['token']
bot.run(bot_token)