You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python反向后门报错:builtin_function_or_method对象无split属性

错误原因
  • 核心触发点:如果使用Python2运行当前代码,内置的input()函数会将输入内容作为Python表达式执行,当你输入exit这类内置函数名时,返回的是函数对象而非字符串,调用split方法自然会抛出属性错误。
  • 隐藏问题:Python3下socket.recv()返回的是字节(bytes)类型,原代码直接和字符串类型的json_data拼接会触发类型错误,目前你没遇到是因为还没走到这一步就被split报错拦截了。
解决方案

方案1:使用Python3运行(推荐)

修改reliable_recv方法,对接收的字节内容先解码为字符串即可:

def reliable_recv(self):
    json_data = ""
    while True:
        try: 
            # 新增decode('utf-8')将接收的字节转为字符串
            json_data = json_data + self.connection.recv(1024).decode('utf-8')
            return json.loads(json_data)
        except ValueError:
            continue

修改完成后直接用Python3解释器运行代码即可正常使用。

方案2:坚持使用Python2运行

修改run方法的输入函数,把input替换为raw_input,确保获取的输入始终是字符串:

def run(self):
    while True:
        # 将input改为raw_input适配Python2的输入逻辑
        command = raw_input(">> ")
        command = command.split(" ")
        result = self.execute_remote(command)
        print(result)

另外原代码中打印连接信息的form是拼写错误,可以改成from,不影响运行但更规范。

内容的提问来源于stack exchange,提问作者aryan vir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 04:15:00