利用ipc$漏洞远程攻击总会有诸多不便,为了解决这些问题,我写了一个简单的python代码(如下),通过标准库中的telnetlib来连接到telnet服务器,并发送命令行命令:
import telnetlib
# 创建telnet连接
tn = telnetlib.Telnet('hostname', port=23, timeout=10)
# 输入用户名
tn.read_until(b'login: ')
tn.write(b'your_username\n')
# 输入密码
tn.read_until(b'Password: ')
tn.write(b'your_password\n')
# 发送命令
tn.write(b'your_command\n') # 替换your_command为你想要执行的命令
# 读取命令执行结果
response = tn.read_all()
print(response.decode('ascii')) # 或者使用适当的编码
# 关闭连接
tn.close()