user2373081
user2373081

Reputation: 35

Run console application in background

I am working on a script in python where first I set ettercap to ARP poisoning and then start urlsnarf to log the URLs. I want to have ettercap to start first and then, while poisoning, start urlsnarf. The problem is that these jobs must run at the same time and then urlsnarf show the output. So I thought it would be nice If I could run ettercap in background without waiting to exit and then run urlsnarf. I tried command nohup but at the time that urlsnarf had to show the url the script just ended. I run:

subprocess.call(["ettercap",
                 "-M ARP /192.168.1.254/ /192.168.1.66/ -p -T -q -i wlan0"])

But I get:

ettercap NG-0.7.4.2 copyright 2001-2005 ALoR & NaGA

MITM method ' ARP /192.168.1.254/ /192.168.1.66/ -p -T -q -i wlan0' not supported...

Which means that somehow the arguments were not passed correctly

Upvotes: 0

Views: 865

Answers (1)

mshildt
mshildt

Reputation: 9362

You could use the subprocess module in the Python standard library to spawn ettercap as a separate process that will run simultaneously with the parent. Using the Popen class from subprocess you'll be able to spawn your ettercap process run your other processing and then kill the ettercap process when you are done. More info here: Python Subprocess Package

import shlex, subprocess

args = shlex.split("ettercap -M ARP /192.168.1.254/ /192.168.1.66/ -p -T -q -i wlan0")
ettercap = subprocess.Popen(args)

# program continues without waiting for ettercap process to finish.

Upvotes: 1

Related Questions