Generalized views for each module type, added platform icons support and started the base for full payload generation support.

git-svn-id: file:///home/svn/framework3/trunk@3996 4d416f70-5f16-0410-b530-b9f4589650da
unstable
lmh 2006-09-29 13:53:51 +00:00
parent 9ae0737253
commit 03fb9ae376
14 changed files with 203 additions and 179 deletions

View File

@ -1,7 +1,12 @@
# Author: HDM <hdm@metasploit.com> and L.M.H <lmh@info-pull.com>
# Description: Helper methods for the controllers, including search and other
# functionality.
# Filters added to this controller will be run for all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
# Search functionality for modules
def search_modules(mlist, terms)
res = {}
@ -38,4 +43,37 @@ class ApplicationController < ActionController::Base
list
end
# Returns the module by id of specified type.
def get_view_for_module(module_type, module_id)
@tmod = nil
# Get available moduls of specified type
case module_type
when "exploit"
@mod_list = Exploit.find_all()
when "auxiliary"
@mod_list = Auxiliary.find_all()
when "payload"
@mod_list = Payload.find_all()
when "nop"
@mod_list = Nop.find_all()
when "encoder"
@mod_list = Encoder.find_all()
else
return @tmod
end
# Return the module if found
if id
@mod_list.each do |m|
if m.refname.gsub('/', ':') == params[:id]
@tmod = m
break
end
end
end
return @tmod
end
end

View File

@ -1,3 +1,8 @@
# Author: L.M.H <lmh@info-pull.com>
# Description: The auxiliary controller of msfweb v.3. Handles views, listing
# and other actions related to auxiliary modules. Code and processing goes here.
# Instance variables, final values, etc, go into views.
class AuxiliariesController < ApplicationController
layout 'windows'
@ -5,6 +10,11 @@ class AuxiliariesController < ApplicationController
end
def view
@tmod = get_view_for_module("auxiliary", params[:id])
unless @tmod
render_text "Unknown module specified."
end
end
def run

View File

@ -1,3 +1,8 @@
# Author: L.M.H <lmh@info-pull.com>
# Description: The encoder controller of msfweb v.3. Handles views, listing
# and other actions related to encoder modules. Code and processing goes here.
# Instance variables, final values, etc, go into views.
class EncodersController < ApplicationController
layout 'windows'
@ -5,6 +10,11 @@ class EncodersController < ApplicationController
end
def view
@tmod = get_view_for_module("encoder", params[:id])
unless @tmod
render_text "Unknown module specified."
end
end
def encode

View File

@ -10,15 +10,7 @@ class ExploitsController < ApplicationController
end
def view
@exploits = Exploit.find_all()
if params[:id]
@exploits.each do |m|
if m.refname.gsub('/', ':') == params[:id]
@tmod = m
break
end
end
end
@tmod = get_view_for_module("exploit", params[:id])
unless @tmod
render_text "Unknown module specified."

View File

@ -1,3 +1,8 @@
# Author: L.M.H <lmh@info-pull.com>
# Description: The nop controller of msfweb v.3. Handles views, listing
# and other actions related to nop modules. Code and processing goes here.
# Instance variables, final values, etc, go into views.
class NopsController < ApplicationController
layout 'windows'
@ -5,7 +10,11 @@ class NopsController < ApplicationController
end
def view
@nops = Nop.find_all()
@tmod = get_view_for_module("nop", params[:id])
unless @tmod
render_text "Unknown module specified."
end
end
def generate

View File

@ -1,3 +1,8 @@
# Author: L.M.H <lmh@info-pull.com>
# Description: The payload controller of msfweb v.3. Handles views, listing
# and other actions related to payload modules. Code and processing goes here.
# Instance variables, final values, etc, go into views.
class PayloadsController < ApplicationController
layout 'windows'
@ -5,7 +10,16 @@ class PayloadsController < ApplicationController
end
def view
@payloads = Payload.find_all()
@tmod = get_view_for_module("payload", params[:id])
unless @tmod
render_text "Unknown module specified."
end
if params[:step]
@module_step = params[:step]
end
end
def generate

View File

@ -19,4 +19,34 @@ module ApplicationHelper
return "onMouseOver=\"this.className='#{css_class_name}'\" onMouseOut=\"this.className=''\""
end
# Adapted from old msfweb code, returns HTML necessary for displaying icons
# associated with a specific module.
# Added missing platform icons (HPUX, Irix, etc).
def module_platform_icons(platform)
return "" if (platform.nil?)
# If this module has no platforms, then we don't show any icons...
return "" if (platform.empty?)
# Otherwise, get the platform specific information...
html = ""
[
[ Msf::Module::Platform::Windows, "windows.png", "win32" ],
[ Msf::Module::Platform::Linux, "linux.png", "linux" ],
[ Msf::Module::Platform::Solaris, "sun.png", "solaris" ],
[ Msf::Module::Platform::OSX, "apple.png", "osx" ],
[ Msf::Module::Platform::BSD, "bsd.gif", "bsd" ],
[ Msf::Module::Platform::BSDi, "bsd.gif", "bsdi" ],
[ Msf::Module::Platform::HPUX, "hp.png", "hpux" ],
[ Msf::Module::Platform::Irix, "sgi.png", "irix" ],
[ Msf::Module::Platform::Unix, "unix.png", "unix" ]
].each do |plat|
if (platform.supports?(Msf::Module::PlatformList.new(plat[0])) == true)
html += "<img src=\"/images/platform-icons/#{plat[1]}\" alt=\"#{plat[2]}\"/>"
end
end
return html
end
end

View File

@ -1,52 +1,31 @@
<style type="text/css">
p.moduleNameX {
padding: 6px;
color: #222222;
font-weight: bold;
text-align: center;
background: #eeeeee;
}
p.moduleDescX {
color: #333333;
text-align: justify;
}
</style>
<table align="center" width="100%" cellspacing="0" cellpadding="15" border="0">
<tr width="100%" align='center'>
<p class="moduleNameX">
<tr width="100%" align="center">
<p class="moduleName">
<%= html_escape(@tmod.name) %>
</p>
</tr>
<tr width="100%" align='center'>
<tr width="100%" align="center">
<blockquote>
<p class="moduleDescX">
<%= html_escape(@tmod.description) %>
</p>
<p class="moduleDesc">
<%= html_escape(@tmod.description) %>
</p>
</blockquote>
</tr>
<tr width="100%" align='center'>
<tr width="100%" align="center">
<blockquote>
<p class="moduleDescX">
This module was provided by
<%= @tmod.author.join(' and ') %>
</p>
<p class="moduleDesc">
This module was provided by <%= @tmod.author.join(' and ') %>.
</p>
</blockquote>
</tr>
<tr width="100%" align='center'>
<tr width="100%" align="center">
<blockquote>
<p class="moduleDescX">
<p class="moduleDesc">
External references:
<ul>
<% @tmod.references.each { |ref| %>
@ -61,9 +40,9 @@ p.moduleDescX {
</blockquote>
</tr>
<tr width="100%" align='center'>
<tr width="100%" align="center">
<blockquote>
<p class="moduleDescX">
<p class="moduleDesc">
Available targets:
<ul>
<% @tmod.targets.each_with_index { |tgt, idx| %>
@ -75,71 +54,4 @@ p.moduleDescX {
</blockquote>
</tr>
</table>
<!--
<table align="center" width="95%" cellspacing="0" cellpadding="6" border="0">
<tr width="100%">
<p class="moduleName">
<%= html_escape(@tmod.name) %>
</p>
</tr>
<tr>
<td align="right" width="80" class="moduleFieldTitle">Authors:</td>
<td class="moduleFieldDescription">
<ul>
<% @tmod.author.each do |a| %>
<li><%= html_escape(a) %></li>
<% end %>
</ul>
</td>
</tr>
<tr>
<td align="right" width="80" valign="top" class="moduleFieldTitle">Description:</td>
<td colspan="2" valign="top" class="moduleFieldDescription">
<%= html_escape(@tmod.description) %>
</td>
</tr>
<tr>
<td align="right" width="80" valign="top" class="moduleFieldTitle">References:</td>
<td colspan="2" valign="top" class="moduleFieldDescription">
<% @tmod.references.each { |ref| %>
<% if (ref.kind_of?(Msf::Module::SiteReference)) %>
- <a href="<%= ref.site %>"><%= ref.to_s %></a><br/>
<% else %>
- <%= ref.to_s %><br/>
<% end %>
<% } %>
</td>
</tr>
<tr>
<td align="right" width="80" class="moduleFieldTitle">Targets:</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<table align="align" cellpadding="2" cellspacing="0" border="0" class="moduleFieldDescription">
<tr>
<td>Target Name</td>
<td>Platform</td>
</tr>
<% @tmod.targets.each_with_index { |tgt, idx| %>
<tr>
<td class="target<%= (idx % 2 == 0) ? "B" : "A" %>" align="left">
<%= idx %> - <a href='#'><%= tgt.name %></a>
</td>
<td class="target<%= (idx % 2 == 0) ? "B" : "A" %>" align="left">
#ICON#
</td>
</tr>
<% } %>
</table>
</td>
</tr>
</table>
-->

View File

@ -2,18 +2,23 @@
<table>
<thead>
<tr>
<th>Modules</th>
<th colspan="2">Modules</th>
</tr>
</thead>
<tbody>
<% @results.each do |m| %>
<tr class="itemTitle">
<tr>
<td class="itemTitle">
<a onClick="window.parent.openModuleWindow('<%= @module_type %>', '<%= m.refname.gsub('/', ':') %>', '<%= m.name.gsub('"','').gsub("'","") %>')" href="#"><%= h(m.name) %></a>
</td>
<td>
<% if m.platform %>
<%= module_platform_icons(m.platform) %>
<% end %>
</td>
</tr>
<tr class="itemDescription">
<td class="itemDescription"><%= m.description %></td>
<td colspan="2" class="itemDescription"><%= m.description %></td>
</tr>
<% end %>
</tbody>

View File

@ -1,50 +1,49 @@
<%
<table align="center" width="100%" cellspacing="0" cellpadding="2" border="0" class="moduleInfo">
modidx = (params[:id] || 0).to_i
modinst = @payloads[modidx]
%>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="moduleIcons" align="center">
<p class="moduleName">
<span class="moduleIcons">
<%= module_platform_icons(@tmod.platform) %>
</span>
<%= html_escape(@tmod.name) %>
</p>
</tr>
<tr>
<blockquote>
<p class="moduleDesc">
<%= html_escape(@tmod.description) %>
</p>
</blockquote>
</tr>
<tr>
<blockquote>
<p class="moduleDesc">
This module was provided by <%= @tmod.author.join(' and ') %>.
</p>
</blockquote>
</tr>
<tr>
<td>Version:</td>
<td><%= @tmod.version %></td>
</tr>
<tr>
<td>Size:</td>
<td><%= @tmod.generate.length %></td>
</tr>
<tr>
<td>Architecture:</td>
<td><%= @tmod.arch_to_s %></td>
</tr>
<tr>
<td>Operating system:</td>
<td><%= @tmod.platform_to_s %></td>
</tr>
</div>
</td>
<td class="moduleName">
<div class="textBold"><%= html_escape(modinst.name) %></div>
</td>
</tr>
</table>
<br/>
<table align="center" width="95%" cellspacing="0" cellpadding="6" border="0">
<tr>
<td align="right" width="80">Name:</td>
<td><%= html_escape(modinst.name) %></td>
</tr>
<tr>
<td align="right" width="80">Version:</td>
<td><%= html_escape(modinst.version) %></td>
</tr>
<tr>
<td align="right" width="80" valign="top">Authors:</td>
<td><%= modinst.author.map { |x| html_escape(x) }.join("<br/>") %></td>
</tr>
<tr>
<td align="right" width="80" valign="top">Description:</td>
<td colspan="2" valign="top">
<%= html_escape(modinst.description) %>
</td>
</tr>
<tr>
<td align="right" width="80">Size:</td>
<td><%= modinst.generate.length %></td>
</tr>
<tr>
<td align="right" width="80">Arch:</td>
<td><%= modinst.arch_to_s %></td>
</tr>
<tr>
<td align="right" width="80">OS:</td>
<td><%= modinst.platform_to_s %></td>
</tr>
</table>

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 646 B

After

Width:  |  Height:  |  Size: 949 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

View File

@ -19,8 +19,7 @@ table {
background: #FAFAFA;
}
table .itemTitle,
table .moduleFieldTitle {
table .itemTitle {
background: #666666 url(/images/bullet_go.png) left no-repeat;
color: #fff;
padding: 6px;
@ -40,8 +39,7 @@ table .itemTitle a:hover {
font-size: 9pt;
}
table .itemDescription,
table .moduleFieldDescription {
table .itemDescription {
background: #EDEDED;
padding: 5px;
border: 1px solid #ccc;
@ -57,16 +55,23 @@ table .itemDescription:hover {
border: 1px solid #444;
}
table.moduleInfo tr td {
}
p.moduleName {
background: #666666 url(/images/bug.png) left no-repeat;
color: #fff;
padding: 6px;
padding-left: 16px;
color: #222222;
font-weight: bold;
text-align: center;
border: 1px solid #AAAAAA;
background: #eeeeee;
}
table .moduleFieldName {
background: #ddd;
.moduleIcons {
float: left;
}
p.moduleDesc {
color: #333333;
text-align: justify;
}