Created
September 4, 2013 17:27
-
-
Save KINGSABRI/6440089 to your computer and use it in GitHub Desktop.
Readline sub-command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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