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

View File

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

View File

@ -20,3 +20,5 @@ require 'Rex/Socket/Parameters'
require 'Rex/Socket/Tcp' require 'Rex/Socket/Tcp'
require 'Rex/Socket/Comm/Local' 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 # representation of the left side of the socket for
# the caller to use # the caller to use
if (channel != nil) if (channel != nil)
res = Rex::Socket::Tcp.new(channel.lsock) res = Rex::Socket::Stream.new(channel.lsock)
end end
elsif (params.udp?) elsif (params.udp?)
if (params.server?) if (params.server?)

View File

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