suppress scapy warning message when importing the module

后端 未结 4 1861
無奈伤痛
無奈伤痛 2021-02-19 09:06

I\'m writing a small script, that gathers some information using scapy and then returns some xml code, that I\'ll pass on to the xmlrpc interface of metasploit. I\'d like it tha

4条回答
  •  不知归路
    2021-02-19 09:40

    With Python3, redefining sys.stderr to None threw an exception AttributeError: 'NoneType' object has no attribute 'write'. Instead, defining it to os.devnull does the job:

    import os
    import sys
    sys.stderr = os.devnull # suppress stderr
    from scapy.all import *
    sys.stderr = sys.__stderr__ # restore stderr
    

提交回复
热议问题