fping.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:faze 作者: KhasMek 项目源码 文件源码
def fping(self, cmd):
        print("{i} {c}".format(i=ctinfo, c=' '.join(cmd)))
        logging.info(' '.join(cmd))
        command = subprocess.run(cmd, stdout=subprocess.PIPE,
                                 stderr=subprocess.DEVNULL, universal_newlines=True, shell=False)
        wrapper = TextWrapper(initial_indent="{i}   ".format(i=ctinfo),
                              subsequent_indent="{i}     ".format(i=ctinfo))
        if len(command.stdout.split("\n")) > 2:
            output = wrapper.fill(command.stdout.replace("\n", ", "))
            output = output.rstrip(',')
            # TODO: write a function for this (in misc maybe) that cleans the target
            # and adds it if not a hostname (hostnames will be resolved & IP's added)
            for host in command.stdout.split("\n"):
                self.up_targets_dict.append(host)
        elif len(command.stdout.split("\n")) > 1:
            output = wrapper.fill(command.stdout.strip("\n"))
            for host in command.stdout.split("\n"):
                self.up_targets_dict.append(host)
        else:
            output = wrapper.fill("No Response")
        print(output)
        logging.info("Results: {r}".format(r=command.stdout.replace("\n", ", ")))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号