MCPcopy
hub / github.com/epinna/tplmap / MultilineShell

Class MultilineShell

core/clis.py:18–59  ·  view source on GitHub ↗

Interactive multiline shell.

Source from the content-addressed store, hash-verified

16 pass
17
18class MultilineShell(cmd.Cmd):
19 """Interactive multiline shell."""
20
21 def __init__(self, inject_function, prompt):
22 cmd.Cmd.__init__(self)
23
24 self.inject_function = inject_function
25 self.fixed_prompt = prompt
26
27 self.lines = []
28
29 self._format_prompt()
30
31 def _format_prompt(self):
32 self.prompt = '[%i] %s' % (
33 len(self.lines),
34 self.fixed_prompt
35 )
36
37 def postcmd(self, stop, line):
38 self._format_prompt()
39 return stop
40
41 def default(self, line):
42 self.lines.append(line)
43
44 def emptyline(self):
45
46 # Do not save empty line if there is nothing to send
47 if not self.lines:
48 return
49
50 def do_EOF(self, line):
51 # Run the inject function and reset the state
52
53 # Send the current line as well
54 if line:
55 self.lines.append(line)
56
57 print
58 print self.inject_function('\n'.join(self.lines))
59 self.lines = []
60
61
62

Callers 1

check_template_injectionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected