Interacting with a process that I ran with subprocess module

P

py.adriano

Hi folks,

I'm trying to use the nmap runtime interaction feature while using it
with the subprocess module. For those not familiar with nmap, the
runtime interaction feature allow users to get informations about the
scan stats during the nmap execution. More at:
http://www.insecure.org/nmap/man/man-runtime-interaction.html
If someone want to try, just run nmap and try to type some keys to see
what happens. This only works with nmap 4.00 and above.

Ok.. What I've tried is shown below:

from subprocess import Popen, PIPE
nmap = Popen("nmap -T3 -A 10.0.0.1-254", stdin=PIPE, stdout=PIPE,
stderr=PIPE, shell=True, bufsize=1)

To interact with nmap, I tried:

nmap.communicate("?")

And I tried this, also:

nmap.stdin.write("?")
nmap.stdout.read()

What's wrong? Is that suposed to be this way? Is there a better way to
interact with it that I've missed? Any help is very welcome. Thanks in
advance!

Cheers!
 
D

Diez B. Roggisch

Hi folks,

I'm trying to use the nmap runtime interaction feature while using it
with the subprocess module. For those not familiar with nmap, the
runtime interaction feature allow users to get informations about the
scan stats during the nmap execution. More at:
http://www.insecure.org/nmap/man/man-runtime-interaction.html
If someone want to try, just run nmap and try to type some keys to see
what happens. This only works with nmap 4.00 and above.

Ok.. What I've tried is shown below:

from subprocess import Popen, PIPE
nmap = Popen("nmap -T3 -A 10.0.0.1-254", stdin=PIPE, stdout=PIPE,
stderr=PIPE, shell=True, bufsize=1)

To interact with nmap, I tried:

nmap.communicate("?")

And I tried this, also:

nmap.stdin.write("?")
nmap.stdout.read()

What's wrong? Is that suposed to be this way? Is there a better way to
interact with it that I've missed? Any help is very welcome. Thanks in
advance!

Programs that interact with users usually require a terminal to be run
from. This is not the case when using pipes. Use pexpect.

Diez
 
P

py.adriano

Well...

I found pexpect as you said, but I also found that it doesn't work on
windows. I need a cross-platform solution, as the program is going to
run on several operating systems. Any other sugestion?

Cheers!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,299
Messages
2,571,545
Members
48,298
Latest member
RufusChipm

Latest Threads

Top