security: replace hardcoded Discord webhook URLs with environment variable

- Remove leaked Discord webhook URL from autologin_no_attack.py
- Replace all hardcoded webhook URLs with os.environ.get('DISCORD_WEBHOOK_URL')
- Add .env.example file with webhook configuration template
- Add .gitignore to prevent .env files from being committed
- Affected files: autologin.py, autologin_no_attack.py, autocraft9x9.py, raidfarm2.py, trader.py, trader2.py, trader_laptop.py, trader_laptopv2.py, trader_wayland.py, trader_win.py, traderv2.py
- Improves security by separating configuration from code
This commit is contained in:
alexpolo1
2026-03-01 09:20:29 +01:00
parent bfc6100320
commit 185d865db9
13 changed files with 67 additions and 11 deletions

4
.env.example Normal file
View File

@@ -0,0 +1,4 @@
# Discord Webhook Configuration
# Set your Discord webhook URL here for Discord notifications
# Get a webhook URL from your Discord server settings
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/your-webhook-id-here/your-webhook-token-here

43
.gitignore vendored Normal file
View File

@@ -0,0 +1,43 @@
# Environment variables
.env
.env.local
.env.*.local
# Logs and temporary files
*.log
*.txt
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# IDE
.vscode/
.idea/
*.swp
*.swo
*~
# Screenshot directories
/tmp/mcscreens/

View File

@@ -2,13 +2,14 @@ import subprocess
import time
import pyautogui
import requests
import os
def log_and_print(message):
print(message)
# Add logging here if needed
def post_to_discord(message):
webhook_url = 'https://discord.com/api/webhooks/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")

View File

@@ -7,6 +7,7 @@ from PIL import ImageGrab
from datetime import datetime, timedelta
import time
import random
import os
# Define the paths to your screenshots
back_to_server_image_path = '/home/alex/minecraft/screenshots/back_to_server.png'
@@ -14,7 +15,7 @@ join_button_image_path = '/home/alex/minecraft/screenshots/join_button.png'
log_file_path = '/home/alex/minecraft/autologin.log'
# Set up the Discord webhook URL
webhook_url = 'https://discord.com/api/webhooks/your_webhook_url_here'
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
def log(message, discord_notify=True):
timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')

View File

@@ -15,7 +15,7 @@ temp_screenshot_directory = '/tmp/mcscreens'
os.makedirs(temp_screenshot_directory, exist_ok=True)
# Your Discord webhook URL
discord_webhook_url = 'https://discord.com/api/webhooks/1191486208895877150/-pxqBZs6RSUOBFFhPH8SwelQoaU5MEU9XX28fmp90EqNM0G98qkkZxsXfRxu7nN2Ze1X'
discord_webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
# Base64 encoded images for both buttons
encoded_images = {

View File

@@ -9,7 +9,7 @@ import requests
# Configuration
temp_screenshot_directory = '/tmp/mcscreens'
discord_webhook_url = 'https://discord.com/api/webhooks/xxxxxxxxxxxxxxxxxxxxxxxx'
discord_webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
screenshot_interval = 3600 # seconds (1 hour)
disconnect_check_interval = 10800 # seconds (3 hours)

View File

@@ -4,6 +4,7 @@ import time
from PIL import Image, ImageGrab
import logging
from Xlib import display
import os
# Setup logging
logging.basicConfig(filename='minecraft_automation_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
@@ -13,7 +14,7 @@ def log_and_print(message):
logging.info(message)
def post_to_discord(message):
webhook_url = 'https://discord.com/api/webhooks/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")

View File

@@ -3,6 +3,7 @@ import pyautogui
import time
from PIL import ImageGrab
import logging
import os
# Setup logging
logging.basicConfig(filename='minecraft_automation_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
@@ -12,7 +13,7 @@ def log_and_print(message):
logging.info(message)
def post_to_discord(message):
webhook_url = 'https://discord.com/api/webhooks/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")

View File

@@ -3,6 +3,7 @@ import subprocess
import time
from PIL import Image, ImageGrab
import logging
import os
# Setup logging
logging.basicConfig(filename='minecraft_automation_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
@@ -12,7 +13,7 @@ def log_and_print(message):
logging.info(message)
def post_to_discord(message):
webhook_url = 'https://discord.com/api/webhooks/xxxxxxxxxxxxxxxxxxxx'
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")

View File

@@ -3,6 +3,7 @@ import subprocess
import time
from PIL import Image, ImageGrab
import logging
import os
# Setup logging
logging.basicConfig(filename='minecraft_automation_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
@@ -12,7 +13,7 @@ def log_and_print(message):
logging.info(message)
def post_to_discord(message):
webhook_url = 'https://discord.com/api/webhooks/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")

View File

@@ -3,6 +3,7 @@ import subprocess
import time
from PIL import Image
import logging
import os
from wayland_screenshot import take_screenshot # This will be a custom function you need to implement
# Setup logging
@@ -13,7 +14,7 @@ def log_and_print(message):
logging.info(message)
def post_to_discord(message):
webhook_url = 'YOUR_DISCORD_WEBHOOK_URL'
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")

View File

@@ -3,6 +3,7 @@ import pyautogui
import time
from PIL import ImageGrab
import logging
import os
# Setup logging
logging.basicConfig(filename='minecraft_automation_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
@@ -12,7 +13,7 @@ def log_and_print(message):
logging.info(message)
def post_to_discord(message):
webhook_url = 'https://discord.com/api/webhooks/xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")

View File

@@ -3,6 +3,7 @@ import subprocess
import time
from PIL import Image, ImageGrab
import logging
import os
print("")
# Setup logging
logging.basicConfig(filename='minecraft_automation_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
@@ -22,7 +23,7 @@ def log_and_print(message):
logging.info(message)
def post_to_discord(message):
webhook_url = 'https://discord.com/api/webhooks/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
webhook_url = os.environ.get('DISCORD_WEBHOOK_URL', '')
data = {"content": message}
response = requests.post(webhook_url, json=data)
log_and_print(f"Posted to Discord: {message}")