资源简介
通过nmap软件查询在线主机的java demo
代码片段和文件信息
#!/usr/bin/env python
# Ndiff
#
# This programs reads two Nmap xml files and displays a list of their
# differences.
#
# Copyright 2008 Insecure.Com LLC
# Ndiff is distributed under the same license as Nmap. See the file COPYING or
# https://nmap.org/data/COPYING. See https://nmap.org/book/man-legal.html for
# more details.
#
# David Fifield
# based on a design by Michael Pattrick
import datetime
import difflib
import getopt
import sys
import time
# Prevent loading Pyxml
import xml
xml.__path__ = [x for x in xml.__path__ if “_xmlplus“ not in x]
import xml.sax
import xml.sax.saxutils
import xml.dom.minidom
from StringIO import StringIO
verbose = False
NDIFF_xml_VERSION = u“1“
class OverrideEntityResolver(xml.sax.handler.EntityResolver):
“““This class overrides the default behavior of xml.sax to download
remote DTDs instead returning blank strings“““
empty = StringIO()
def resolveEntity(self publicId systemId):
return OverrideEntityResolver.empty
class Scan(object):
“““A single Nmap scan corresponding to a single invocation of Nmap. It is
a container for a list of hosts. It also has utility methods to load itself
from an Nmap xml file.“““
def __init__(self):
self.scanner = None
self.version = None
self.args = None
self.start_date = None
self.end_date = None
self.hosts = []
self.pre_script_results = []
self.post_script_results = []
def sort_hosts(self):
self.hosts.sort(key=lambda h: h.get_id())
def load(self f):
“““Load a scan from the Nmap xml in the file-like object f.“““
parser = xml.sax.make_parser()
handler = NmapContentHandler(self)
parser.setEntityResolver(OverrideEntityResolver())
parser.setContentHandler(handler)
parser.parse(f)
def load_from_file(self filename):
“““Load a scan from the Nmap xml file with the given filename.“““
f = open(filename “r“)
try:
self.load(f)
finally:
f.close()
def write_nmaprun_open(self writer):
attrs = {}
if self.scanner is not None:
attrs[u“scanner“] = self.scanner
if self.args is not None:
attrs[u“args“] = self.args
if self.start_date is not None:
attrs[u“start“] = “%d“ % time.mktime(self.start_date.timetuple())
attrs[u“startstr“] = self.start_date.strftime(
“%a %b %d %H:%M:%S %Y“)
if self.version is not None:
attrs[u“version“] = self.version
writer.startElement(u“nmaprun“ attrs)
def write_nmaprun_close(self writer):
writer.endElement(u“nmaprun“)
def nmaprun_to_dom_fragment(self document):
frag = document.createDocumentFragment()
elem = document.createElement(u“nmaprun“)
if self.scanner is not None:
elem.setAttribute(u“scanner“ self.scanner)
if self.args is not None:
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-05-12 15:04 localnet\
目录 0 2017-05-12 14:36 localnet\.gradle\
目录 0 2017-05-12 14:36 localnet\.gradle\2.13\
目录 0 2017-05-12 15:03 localnet\.gradle\2.13\taskArtifacts\
文件 31 2017-05-12 14:36 localnet\.gradle\2.13\taskArtifacts\cache.properties
文件 17 2017-05-12 14:37 localnet\.gradle\2.13\taskArtifacts\cache.properties.lock
文件 26124 2017-05-12 14:37 localnet\.gradle\2.13\taskArtifacts\fileHashes.bin
文件 63592 2017-05-12 14:37 localnet\.gradle\2.13\taskArtifacts\fileSnapshots.bin
文件 21479 2017-05-12 14:37 localnet\.gradle\2.13\taskArtifacts\taskArtifacts.bin
目录 0 2017-05-12 15:03 localnet\.idea\
文件 854 2017-05-11 17:15 localnet\.idea\compiler.xm
目录 0 2017-05-12 15:03 localnet\.idea\copyright\
文件 76 2017-05-11 15:48 localnet\.idea\copyright\profiles_settings.xm
文件 714 2017-05-11 16:13 localnet\.idea\gradle.xm
目录 0 2017-05-12 15:03 localnet\.idea\libraries\
文件 491 2017-05-11 16:13 localnet\.idea\libraries\Gradle__junit_junit_4_11.xm
文件 547 2017-05-11 16:13 localnet\.idea\libraries\Gradle__org_hamcrest_hamcrest_core_1_3.xm
文件 1610 2017-05-11 17:14 localnet\.idea\misc.xm
目录 0 2017-05-12 15:03 localnet\.idea\modules\
文件 592 2017-05-12 13:34 localnet\.idea\modules.xm
文件 737 2017-05-11 16:13 localnet\.idea\modules\localnet.iml
文件 942 2017-05-12 11:45 localnet\.idea\modules\localnet_main.iml
文件 1268 2017-05-12 11:45 localnet\.idea\modules\localnet_test.iml
文件 88278 2017-05-12 14:59 localnet\.idea\workspace.xm
目录 0 2017-05-12 15:03 localnet\build\
文件 713 2017-05-12 14:37 localnet\build.gradle
目录 0 2017-05-11 17:15 localnet\build\classes\
目录 0 2017-05-12 15:03 localnet\build\classes\main\
目录 0 2017-05-12 11:45 localnet\build\classes\main\com\
目录 0 2017-05-12 11:45 localnet\build\classes\main\com\keydak\
目录 0 2017-05-12 15:03 localnet\build\classes\main\com\keydak\localnet\
............此处省略960个文件信息
- 上一篇:Android的计算器App
- 下一篇:Android Camera开发一之基础知识
评论
共有 条评论