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...teraction.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.communicat e("?")
And I tried this, also:
nmap.stdin.writ e("?")
nmap.stdout.rea d()
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! 2 1795 py********@gmai l.com schrieb: 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...teraction.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.communicat e("?")
And I tried this, also:
nmap.stdin.writ e("?") nmap.stdout.rea d()
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
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!
Diez B. Roggisch wrote: py********@gmai l.com schrieb: 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...teraction.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.communicat e("?")
And I tried this, also:
nmap.stdin.writ e("?") nmap.stdout.rea d()
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Earl Eiland |
last post by:
The command string consists of "filename.exe instruction1 instruction2
...." It works in subprocess, but in process, returns the error "can't
find the file instruction1".
How do I pass command line instructions in process.Process? I tried a
list with the same
result.
If you're wondering why I'm switching, it's because I'm working with a
poorly behaved 3rd party program that causes a severe memory leak, and I
|
by: Natan |
last post by:
Hi.
I have a python script under linux where I poll many hundreds of
interfaces with mrtg every 5 minutes. Today I create some threads and
use os.system(command) to run the process, but some of them just hang.
I would like to terminate the process after 15 seconds if it doesn't
finish, but os.system() doesn't have any timeout parameter.
Can anyone help me on what can I use to do this?
|
by: cypher543 |
last post by:
This has been driving me insane for the last hour or so. I have search
everywhere, and nothing works. I am trying to use the subprocess module
to run a program and get its output line by line. But, it always waits
for the process to terminate and then return the output all at once.
Can someone please show me some code that actually works for this sort
of thing? It doesn't even have to use the subprocess module. Don't
worry if the code...
|
by: Pappy |
last post by:
SHORT VERSION:
Python File B changes sys.stdout to a file so all 'prints' are written
to the file. Python file A launches python file B with os.popen("./B
2>&^1 >dev/null &"). Python B's output disappears into never-never
land.
LONG VERSION:
I am working on a site that can kick off large-scale simulations. It
will write the output to an html file and a link will be emailed to
the user. Also, the site will continue to display...
|
by: Greg Ercolano |
last post by:
When I use os.popen(cmd,'w'), I find that under windows, the stdout
of the child process disappears, instead of appearing in the DOS window
the script is invoked from. eg:
C:\type foo.py
import os
import sys
file = os.popen("nslookup", 'w')
file.write("google.com\n")
file.close()
| |
by: bhunter |
last post by:
Hi,
I've used subprocess with 2.4 several times to execute a process, wait
for it to finish, and then look at its output. Now I want to spawn
the process separately, later check to see if it's finished, and if it
is look at its output. I may want to send a signal at some point to
kill the process. This seems straightforward, but it doesn't seem to
be working.
Here's my test case:
|
by: geoffbache |
last post by:
Am currently being very confused over the following code on Windows
import subprocess, os
file = open("filename", "w")
try:
proc = subprocess.Popen("nosuchprogram", stdout=file)
except OSError:
file.close()
os.remove("filename")
|
by: Samuel A. Falvo II |
last post by:
I have a shell script script.sh that launches a Java process in the
background using the &-operator, like so:
#!/bin/bash
java ... arguments here ... &
In my Python code, I want to invoke this shell script using the
Subprocess module. Here is my code:
def resultFromRunning_(command):
|
by: Catherine Moroney |
last post by:
I have one script (Match1) that calls a Fortran executable as a
sub-process, and I want to write another script (Match4) that
spawns off several instances of Match1 in parallel and then waits
until they all finish running. The only way I can think of doing this
is to call it as a sub-process, rather than directly.
I'm able to get Match1 working correctly in isolation, using the
subprocess.Popen command, but calling an instance of Match1...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |