Nmap engine failed to load a script

爷,独闯天下 提交于 2020-05-24 05:21:05

问题


EDITED - run subprocess instead, but the output will be string.

I'm writing a python script to automate nmap daily tasks, I'm using python 3.6 and nmap installed in my windows. when i run the nmap from command line it works. while from the python script it throws an error

{'nmap': {'command_line': 'nmap -oX - -p 443 --script=C:/Users/670241893/PycharmProjects/untitled/SSLandTLS/nmap_script/ssl-cert.nse google.com', 'scaninfo': {'error': ["NSE: Failed to load C:/Users/670241893/PycharmProjects/untitled/SSLandTLS/nmap_script/ssl-cert.nse:\r\n...harmProjects/untitled/SSLandTLS/nmap_script/ssl-cert.nse:3: module 'outlib' not found:\r\n\tNSE failed to find nselib/outlib.lua in search paths.\r\n\tno field package.preload['outlib']\r\n\tno file 'C:\\Program Files (x86)\\Nmap\\lua\\outlib.lua'\r\n\tno file 'C:\\Program Files (x86)\\Nmap\\lua\\outlib\\init.lua'\r\n\tno ...

the script I'm using load the nmap NSE script from a folder using nmap engine

import nmap

def nmap_dh_paramater_check():
    nm = nmap.PortScanner()
    results = nm.scan('google.com', '443', arguments='--script=C:/Users/670241893/PycharmProjects/untitled/SSLandTLS/nmap_script/ssl-cert.nse')
    print (results)

the path of the script is validated. what went wrong?

or I could run cmd command using python like this

def run_nmap_command():
    command ="nmap -p 443 --script ssl-cert google.com"
    output = subprocess.getoutput(command)
    print(output)
    return output

but the output will be string , is there a way how to hv JSON output?

来源:https://stackoverflow.com/questions/61098484/nmap-engine-failed-to-load-a-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!