sky999
天山茗客 Lv7
UID 181291
Digest
2
Points 6
Posts 3317
金币 2355 块
Permissions 10
Register 2020-11-28
Status offline
|
import winreg
import psutil
import requests
def get_installed_software():
installed_software = []
key_path = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key_path) as key:
for i in range(0, winreg.QueryInfoKey(key)[0]):
skey_name = winreg.EnumKey(key, i)
skey_path = f"{key_path}\\{skey_name}"
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, skey_path) as skey:
try:
display_name = winreg.QueryValueEx(skey, "DisplayName")[0]
installed_software.append(display_name)
except FileNotFoundError:
pass
return installed_software
def get_running_processes():
running_processes = []
for proc in psutil.process_iter():
try:
running_processes.append(proc.name())
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
return running_processes
def post_data(url, data):
headers = {'Content-Type': 'application/json'}
response = requests.post(url, json=data, headers=headers)
print(response.text)
# 获取已安装的软件列表
installed_software = get_installed_software()
# 获取正在运行的程序列表
running_processes = get_running_processes()
# 将数据以JSON格式打包
data = {
'installed_software': installed_software,
'running_processes': running_processes
}
# 将数据POST到192.168.10.1/post.php
post_data('http://192.168.10.1/post.php', data)
| 做好事情,赚取应得。
和睦共处,合作共赢。
|
|