2017-07-17 10 views
0

私のUbuntuにnmap7.1をインストールし、そのパスにnseスクリプトを追加しました。/usr/share/nmap/scripts nmap7.1を削除してインストールするとnmap7.5を公式のソースでコンパイルして、私が以前に追加したものであるいくつかのnseスクリプトが見つかりました。nmapコマンドはこれらのスクリプトを使用できません。しかし、私のpythonプログラムにはこれらのnseスクリプトが必要です。これらのnseスクリプトをORに追加して、このnseスクリプトをNmap Pathに追加して正しく動作させることができます。Nmap7.5:/ usr/share/nmap/scripts以外のパスにスクリプトを追加する方法

答えて

0

私は私の問題を解決した:これは私のcocument構造である:

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 

が、それはあなたを助けることができると思います:)

関連する問題