Nmap7.5:如何将脚本添加到其路径中,除了/ usr / share / nmap / scripts

时间:2017-07-17 14:37:23

标签: linux ubuntu nmap

我曾经在我的Ubuntu上安装了nmap7.1并在其路径/usr/share/nmap/scripts中添加了一些nse脚本但是当我删除nmap7.1并使用官方源安装nmap7.5并自行编译时,我发现有一个我曾经添加的几个脚本和nmap命令都不能使用这些脚本。但我的python程序需要这些nse脚本,所以我的问题是这些nse脚本应该添加到哪个OR哪个命令可以添加这个nse脚本进入Nmap Path并正常工作。谢谢!

1 个答案:

答案 0 :(得分:0)

我已经解决了我的问题:这是我的文档结构:

scan_s/nse/modicon-info.nse
      /namp.py

这是我的python脚本:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from libnmap.process import NmapProcess
from time import sleep
try:
  import xml.etree.cElementTree as ET 
except ImportError: 
  import xml.etree.ElementTree as ET 
import sys 

nmap_proc = NmapProcess(targets="45.76.197.202", options="--script nse/s7-info.nse -p 102")
nmap_proc.run_background()
while nmap_proc.is_running():
    sleep(2)    
xml = nmap_proc.stdout
print xml
xmlfiled = open('testxml.xml','w')
xmlfiled.write(xml)
xmlfiled.close()
try:
    tree = ET.parse('testxml.xml')
    root =  tree.getroot()
    test = root.find('host').find('ports').find('port').find('script')
    test_dic = dict(test.attrib)
    s = test_dic['output']
except:
    s = 'unknown'
print s

希望它可以帮助你:)