# -*- coding: utf-8 -*- import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=40, allow_agent=False, look_for_keys=False) cmd = r""" IPS="176.53.159.197 176.53.159.198 45.173.221.26 145.249.109.100 176.126.83.167 45.134.95.113 119.36.22.31 113.56.227.29 45.32.89.58 93.123.109.10 2.57.121.112 91.92.40.153 103.63.101.24" for ip in $IPS; do echo "==== $ip ====" curl -fsS --max-time 8 "http://ip-api.com/json/$ip?fields=status,country,regionName,city,isp,org,as,query,proxy,hosting" 2>/dev/null || true echo done echo "==== success 45.134.95.113 sample ====" grep "Accepted password for root from 45.134.95.113" /var/log/auth.log /var/log/auth.log.1 2>/dev/null | head -3 grep "Accepted password for root from 45.134.95.113" /var/log/auth.log /var/log/auth.log.1 2>/dev/null | tail -3 echo COUNT: grep -c "Accepted password for root from 45.134.95.113" /var/log/auth.log /var/log/auth.log.1 2>/dev/null echo "==== other success ====" grep -E "Accepted password for root from (113.56.227.29|45.32.89.58)" /var/log/auth.log /var/log/auth.log.1 2>/dev/null | head -12 """ _, o, e = c.exec_command(cmd, timeout=120) print((o.read() + e.read()).decode("utf-8", "replace")) c.close()