I've tried to add autocompletion mechanism to some file related plugins (the idea - after running "ls", the "cat" plugin, or any other plugin, will have autocompletion for the remote files and dirs):
def complete_cat(self, text, *_):
return [x for x in session.TargetFiles if x.startswith(text)]
self.File = None
self.TargetFiles = []
def _isattr(self, name):
rows = sorted(rows, key=(lambda elem: elem[-1]))
for file in rows:
file = file[3]
if file != "." and file != "..":
session.TargetFiles.append(target + file)
rows.insert(0, rows_hdr)
When I'm testing it, it's never working as it supposed to work, and behaving very strange:
phpsploit(localhost) > cat D:\\
D:\xampp\FileZillaFTP D:\xampp\contrib D:\xampp\mailtodisk D:\xampp\readme_de.txt D:\xampp\webdav
D:\xampp\MercuryMail D:\xampp\ctlscript.bat D:\xampp\mercury_start.bat D:\xampp\readme_en.txt D:\xampp\xampp-control.exe
D:\xampp\anonymous D:\xampp\filezilla_setup.bat D:\xampp\mercury_stop.bat D:\xampp\security D:\xampp\xampp-control.ini
D:\xampp\apache D:\xampp\filezilla_start.bat D:\xampp\mysql D:\xampp\service.exe D:\xampp\xampp-control.log
D:\xampp\apache_start.bat D:\xampp\filezilla_stop.bat D:\xampp\mysql_start.bat D:\xampp\setup_xampp.bat D:\xampp\xampp_shell.bat
D:\xampp\apache_stop.bat D:\xampp\htdocs D:\xampp\mysql_stop.bat D:\xampp\src D:\xampp\xampp_start.exe
D:\xampp\catalina_service.bat D:\xampp\img D:\xampp\passwords.txt D:\xampp\test_php.bat D:\xampp\xampp_stop.exe
D:\xampp\catalina_start.bat D:\xampp\install D:\xampp\perl D:\xampp\tmp
D:\xampp\catalina_stop.bat D:\xampp\licenses D:\xampp\php D:\xampp\tomcat
D:\xampp\cgi-bin D:\xampp\locale D:\xampp\phpMyAdmin D:\xampp\uninstall.dat
D:\xampp\changes.txt D:\xampp\mailoutput D:\xampp\properties.ini D:\xampp\uninstall.exe
phpsploit(localhost) > cat D:\\D:\Temp\[!] Runtime Error: can't re-enter readline
Readline internal error
Traceback (most recent call last):
File "C:\Python3\lib\site-packages\pyreadline\console\console.py", line 768, in hook_wrapper_23
res = ensure_str(readline_hook(prompt))
File "C:\Python3\lib\site-packages\pyreadline\rlmain.py", line 571, in readline
self._readline_from_keyboard()
File "C:\Python3\lib\site-packages\pyreadline\rlmain.py", line 536, in _readline_from_keyboard
if self._readline_from_keyboard_poll():
File "C:\Python3\lib\site-packages\pyreadline\rlmain.py", line 556, in _readline_from_keyboard_poll
result = self.mode.process_keyevent(event.keyinfo)
File "C:\Python3\lib\site-packages\pyreadline\modes\emacs.py", line 243, in process_keyevent
r = self.process_keyevent_queue[-1](keyinfo)
File "C:\Python3\lib\site-packages\pyreadline\modes\emacs.py", line 286, in _process_keyevent
r = dispatch_func(keyinfo)
File "C:\Python3\lib\site-packages\pyreadline\modes\basemode.py", line 257, in complete
completions = self._get_completions()
File "C:\Python3\lib\site-packages\pyreadline\modes\basemode.py", line 200, in _get_completions
r = self.completer(ensure_unicode(text), i)
File "D:\phpspolit\deps\shnake-0.4\shnake\shell.py", line 402, in complete
compfunc = getattr(self, 'complete_'+name)
TypeError: Can't convert 'NoneType' object to str implicitly