0

So, what I want to do is a module which can automatically look for some things, but for that I need to take outputs from NMAP, specifically the Software Version. I have only written this, I just want to know how could i make this or if it is possible

def check():
while True:
    cmd = raw_input("smb(check) > ")

This is an actual scan of NMAP

PORT STATE SERVICE VERSION 21/tcp open ftp ProFTPD 1.3.5b

What i want to do is to set that ProFTPD 1.3.5b as an object

SeemSMB
  • 1
  • 1
  • Are you looking to run the other program from within your Python script and capture its output, or are you looking to have the user pipe the output of the other program into the input or your program? – abarnert May 29 '18 at 21:15
  • For the former, see [the examples in the `subprocess` docs](https://docs.python.org/2/library/subprocess.html#replacing-bin-sh-shell-backquote). For the latter, you just read from `sys.stdin`/`raw_input()` the same way you do for actual user input (but you don't want to print out any prompts, of course). – abarnert May 29 '18 at 21:16
  • Also: there are multiple Python libraries on PyPI which either drive `nmap` and parse its output, or use `libnmap` to do the same things directly. Using a library that's already built and tested is probably going to be a whole lot easier than building it yourself. – abarnert May 29 '18 at 21:18
  • Look @abarnert what i want to do, for you to understand me, this is an actual nmap scan PORT STATE SERVICE VERSION 21/tcp open ftp ProFTPD 1.3.5b what i want to do is to take the ProFTPD version, so i can define an object in my code with that name – SeemSMB May 29 '18 at 21:20
  • That's fine, but that doesn't answer my question. Do you (a) want your script to run the `nmap` command that creates that scan, or (b) want that scan to be piped into your script with `nmap | python myscript.py` or `python myscript.py < mynmapoutput`? And, if the aswer is (a), is there a reason you can't use `python-nmap`, `python-libnmap`, or one of the other options out there instead of building it yourself? – abarnert May 29 '18 at 21:26
  • @abarnert none of that. What im trying to explain you is that what i want is to obtain that ftp version from the nmap scan on my code and define it automatically as an object – SeemSMB May 29 '18 at 21:28
  • It has to be one of that or the other of that, unless you just want to hardcode `proftp_version = 'ProFTPD 1.3.5b'` into your program. – abarnert May 29 '18 at 21:29
  • @abarnert for example. Instead of defining proftpd using version == "proftpd" directly from the code, what i want is to get the output of the version running an nmap scan – SeemSMB May 29 '18 at 21:30
  • Yes, I get that. But "running an nmap scan" means that either (a) your script has to run an nmap scan, or (b) you have to run an nmap scan and pass the result into your script. How else do you expect things to happen? – abarnert May 29 '18 at 21:30

0 Answers0