【发布时间】:2021-04-03 09:30:44
【问题描述】:
我正在尝试从 Linux 机器远程关闭 Windows 设备。
我做了什么:- 在 windows 端:启用远程注册表服务。 在 Linux 机器上:安装 samba-common
这个python脚本应该从flask HTML页面获取数据,然后运行net rpc命令。
from flask import Flask, render_template, request
import subprocess
app = Flask(__name__)
@app.route('/powershutdown', methods=["GET", "POST"])
def device_list():
if request.method == "POST":
ip_address = request.form.get('ipv4')
print(ip_address)
username = request.form.get('username')
print(username)
password = request.form.get('pwd')
print(password)
command = 'net rpc shutdown -I {} -U {}%{}.format(ip_address, username, password)'
subprocess.Popen(command.split(), stdout=subprocess.PIPE)
return "powering off " + ip_address
return render_template('shutdown.html')
if __name__ == '__main__':
app.run(debug=True)
<!DOCTYPE html>
<html>
<head>
<title>Power Shutdown</title>
</head>
<h2>Power Shutdown</h2>
<form action="{{url_for('device_list')}}" method='post'>
<label for="ip_address">IP Address:</label><br>
<input type="text" class="form-input" id="ipv4" name="ipv4" placeholder="xxx.xxx.xxx.xxx"/><br>
<label for="username">Username:</label><br>
<input type="text" id="username" name="username"><br>
<label for="pwd">Password:</label><br>
<input type="password" id="pwd" name="pwd">
<button type="submit">Submit</button>
</form>
</html>
我得到的错误的sn-p:
指定的 IP 地址无效 消息的 SMB2 签名错误 [0000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ............ [0000] B1 18 E2 DE F0 30 68 CB 2B 59 C1 DA 17 FB 04 C2 .....0h。 +Y…… 无法连接到服务器 127.0.0.1 连接失败:NT_STATUS_ACCESS_DENIED 消息的 SMB2 签名错误 [0000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ............ [0000] 6D 3B 12 34 26 06 D8 8F F4 C8 B3 CB 82 F3 BC 5F m;.4&........_ 无法连接到服务器 127.0.0.1 连接失败:NT_STATUS_ACCESS_DENIED
【问题讨论】:
标签: python html flask rpc samba