-
Notifications
You must be signed in to change notification settings - Fork 0
/
basicscanreport.html
215 lines (199 loc) · 12.1 KB
/
basicscanreport.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Basic Scan Report Example — OpenDXL Nmap Service 1.0.0 documentation</title>
<link rel="stylesheet" href="_static/classic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="OpenDXL Nmap Service 1.0.0 documentation" href="index.html" />
<link rel="next" title="dxlnmapservice package" href="dxlnmapservice.html" />
<link rel="prev" title="Samples Configuration" href="sampleconfig.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="dxlnmapservice.html" title="dxlnmapservice package"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="sampleconfig.html" title="Samples Configuration"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">OpenDXL Nmap Service 1.0.0 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="basic-scan-report-example">
<h1>Basic Scan Report Example<a class="headerlink" href="#basic-scan-report-example" title="Permalink to this headline">¶</a></h1>
<p>This sample invokes and displays the results of an aggressive Nmap scan with the corresponding operating
system where this execution is being performed by invoking the Nmap service via DXL.</p>
<dl class="docutils">
<dt>For more information see:</dt>
<dd><a class="reference external" href="https://nmap.org">https://nmap.org</a></dd>
</dl>
<div class="section" id="prerequisites">
<h2>Prerequisites<a class="headerlink" href="#prerequisites" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li>The samples configuration step has been completed (see <a class="reference internal" href="sampleconfig.html"><em>Samples Configuration</em></a>)</li>
<li>The OpenDXL Nmap Service Python is running (see <a class="reference internal" href="running.html"><em>Running</em></a>)</li>
</ul>
</div>
<div class="section" id="setup">
<h2>Setup<a class="headerlink" href="#setup" title="Permalink to this headline">¶</a></h2>
<p>Modify the example to include the targets and options in the file you want to scan.</p>
<p>For example:</p>
<blockquote>
<div><div class="highlight-python"><div class="highlight"><pre><span class="c1"># Define elements to be analysed</span>
<span class="n">target1</span> <span class="o">=</span> <span class="s1">'200.17.2.2'</span>
<span class="n">target2</span> <span class="o">=</span> <span class="s1">'200.17.2.3'</span>
<span class="n">target_list</span> <span class="o">=</span> <span class="p">[</span><span class="n">target1</span><span class="p">,</span> <span class="n">target2</span><span class="p">]</span>
<span class="c1"># Define options to execute the tool</span>
<span class="n">option</span> <span class="o">=</span> <span class="s2">" -O -A"</span>
</pre></div>
</div>
</div></blockquote>
<p>Where <cite>“target_#”</cite> parameter represent the element to be analysed and <cite>“option”</cite> is the parameter to
execute Nmap tool
You can look for more information about Nmap tool in <a class="reference external" href="https://nmap.org/book/man-briefoptions.html">Nmap page</a></p>
</div>
<div class="section" id="running">
<h2>Running<a class="headerlink" href="#running" title="Permalink to this headline">¶</a></h2>
<p>To run this sample execute the <code class="docutils literal"><span class="pre">sample/basic/basic_aggressive_scan_report.py</span></code> script as follows:</p>
<blockquote>
<div><div class="highlight-python"><div class="highlight"><pre>python sample/basic/basic_scan_report.py
</pre></div>
</div>
</div></blockquote>
<p>The output should be similar to the following:</p>
<blockquote>
<div><div class="highlight-python"><div class="highlight"><pre><span class="n">Response</span> <span class="k">for</span> <span class="n">nmapservice_requesthandler</span><span class="p">:</span>
<span class="n">Response</span><span class="p">:</span>
<span class="p">{</span>
<span class="s2">"100"</span><span class="p">:</span> <span class="s2">"------------------------------------------"</span><span class="p">,</span>
<span class="s2">"101"</span><span class="p">:</span> <span class="s2">"Nmap scan report for 10.87.242.195. Host status: up"</span><span class="p">,</span>
<span class="s2">"102"</span><span class="p">:</span> <span class="s2">"Operating System: Linux"</span><span class="p">,</span>
<span class="s2">"103"</span><span class="p">:</span> <span class="s2">"Port: 22/tcp Status: open Service: ssh"</span><span class="p">,</span>
<span class="s2">"104"</span><span class="p">:</span> <span class="s2">"------------------------------------------"</span>
<span class="p">}</span>
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="details">
<h2>Details<a class="headerlink" href="#details" title="Permalink to this headline">¶</a></h2>
<p>The majority of the sample code is shown below:</p>
<blockquote>
<div><div class="highlight-python"><div class="highlight"><pre><span class="c1"># Connect to the fabric</span>
<span class="n">client</span><span class="o">.</span><span class="n">connect</span><span class="p">()</span>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Connected to DXL fabric."</span><span class="p">)</span>
<span class="c1"># Send request that will trigger request callback</span>
<span class="c1"># 'nmapservice_requesthandler'</span>
<span class="n">request_topic</span> <span class="o">=</span> <span class="s2">"/opendxl-nmap/service/scan/report"</span>
<span class="n">req</span> <span class="o">=</span> <span class="n">Request</span><span class="p">(</span><span class="n">request_topic</span><span class="p">)</span>
<span class="n">MessageUtils</span><span class="o">.</span><span class="n">dict_to_json_payload</span><span class="p">(</span><span class="n">req</span><span class="p">,</span> <span class="p">{</span><span class="s2">"target"</span> <span class="p">:</span> <span class="n">target_list</span><span class="p">,</span> <span class="s2">"option"</span><span class="p">:</span> <span class="n">option</span><span class="p">})</span>
<span class="n">res</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">sync_request</span><span class="p">(</span><span class="n">req</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
<span class="k">if</span> <span class="n">res</span><span class="o">.</span><span class="n">message_type</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">Message</span><span class="o">.</span><span class="n">MESSAGE_TYPE_ERROR</span><span class="p">:</span>
<span class="c1"># Display results</span>
<span class="k">print</span> <span class="s2">"Response for nmapservice_requesthandler: '{0}'"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">MessageUtils</span><span class="o">.</span><span class="n">json_payload_to_dict</span><span class="p">(</span><span class="n">res</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">print</span> <span class="s2">"Error invoking service with topic '{0}': {1} ({2})"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
<span class="n">request_topic</span><span class="p">,</span> <span class="n">res</span><span class="o">.</span><span class="n">error_message</span><span class="p">,</span> <span class="n">res</span><span class="o">.</span><span class="n">error_code</span><span class="p">)</span>
</pre></div>
</div>
</div></blockquote>
<p>Once a connection is established to the DXL fabric, a request message is created with a topic that targets the remote commands of the OpenDXL Nmap Service.</p>
<p>The final step is to display the contents of the returned dictionary (<code class="docutils literal"><span class="pre">dict</span></code>) which contains the results of the
aggressive scan report.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Basic Scan Report Example</a><ul>
<li><a class="reference internal" href="#prerequisites">Prerequisites</a></li>
<li><a class="reference internal" href="#setup">Setup</a></li>
<li><a class="reference internal" href="#running">Running</a></li>
<li><a class="reference internal" href="#details">Details</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="sampleconfig.html"
title="previous chapter">Samples Configuration</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="dxlnmapservice.html"
title="next chapter">dxlnmapservice package</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/basicscanreport.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="dxlnmapservice.html" title="dxlnmapservice package"
>next</a> |</li>
<li class="right" >
<a href="sampleconfig.html" title="Samples Configuration"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">OpenDXL Nmap Service 1.0.0 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright Copyright 2017.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.4.
</div>
</body>
</html>