Skip to content

Instantly share code, notes, and snippets.

@KINGSABRI
Created September 4, 2013 17:27
Show Gist options
  • Save KINGSABRI/6440089 to your computer and use it in GitHub Desktop.
Save KINGSABRI/6440089 to your computer and use it in GitHub Desktop.
Readline sub-command
require 'readline'
MAIN = ['help', 'show', 'set' , 'exit'].sort
SHOW = ['exploits', 'payloads', 'wiki'].sort
USE = ['exploit' , 'encoder'].sort
SET = ['payload', 'RHOST'].sort
comp = proc do |s|
if Readline.line_buffer =~ /help.* /
MAIN.grep( /^#{Regexp.escape(s)}/ )
elsif Readline.line_buffer =~ /set.*/
SET.grep( /^#{Regexp.escape(s)}/ )
elsif Readline.line_buffer =~ /show.*/
SHOW.grep( /^#{Regexp.escape(s)}/ )
else
MAIN.grep( /^#{Regexp.escape(s)}/ )
end
end
Readline.completion_proc = comp
Readline.completion_append_character = " "
while line = Readline.readline('-> ', true)
print("-> ", line, "\n")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment