cool stuff for cool kids

git-svn-id: file:///home/svn/incoming/trunk@2664 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Miller 2005-07-07 06:14:58 +00:00
parent 657b434ea5
commit 02361dde24
5 changed files with 24 additions and 8 deletions

View File

@ -47,13 +47,19 @@ class Core
}
# Display the commands
#
# TODO: change to column printing
all_commands.sort.each { |c|
cmd, desc = c
tbl = Table.new(
Table::Style::Default,
'Columns' =>
[
'Command',
'Description'
])
print_line(" #{cmd} #{desc}")
all_commands.sort.each { |c|
tbl << c
}
print(tbl.to_s)
end
alias cmd_? cmd_help

View File

@ -3,6 +3,8 @@ require 'Msf/Ui'
require 'Msf/Ui/Console/Shell'
require 'Msf/Ui/Console/CommandDispatcher'
require 'Msf/Ui/Console/Table'
module Msf
module Ui
module Console

View File

@ -20,3 +20,5 @@ require 'Rex/Socket/Parameters'
require 'Rex/Socket/Tcp'
require 'Rex/Socket/Comm/Local'
# Ui
require 'Rex/Ui/Text/Table'

View File

@ -76,7 +76,7 @@ class Socket
# representation of the left side of the socket for
# the caller to use
if (channel != nil)
res = Rex::Socket::Tcp.new(channel.lsock)
res = Rex::Socket::Stream.new(channel.lsock)
end
elsif (params.udp?)
if (params.server?)

View File

@ -20,6 +20,8 @@ class Table
self.width = opts['Width'] || 80
self.indent = opts['Indent'] || 0
self.cellpad = opts['CellPad'] || 2
self.prefix = opts['Prefix'] || ''
self.postfix = opts['Postfix'] || ''
self.colprops = []
self.columns.length.times { |idx|
@ -33,7 +35,8 @@ class Table
# Converts table contents to a string
#
def to_s
str = columns_to_s || ''
str = prefix
str += columns_to_s || ''
str += hr_to_s || ''
rows.each { |row|
@ -44,6 +47,8 @@ class Table
end
}
str += postfix
return str
end
@ -85,6 +90,7 @@ class Table
attr_accessor :columns, :rows, :colprops
attr_accessor :width, :indent, :cellpad
attr_accessor :prefix, :postfix
protected
@ -118,7 +124,7 @@ protected
columns.each_with_index { |col,idx|
nameline += col + pad(' ', col, idx)
barline += ('-' * colprops[idx]['MaxWidth']) + (' ' * cellpad)
barline += ('-' * col.length) + (' ' * cellpad)
}
return "#{nameline}\n#{barline}"