epinna/weevely3

Obfuscator Template Error

B0y1n4o4 opened this issue · 4 comments

$ python weevely.py generate demo demo.php
[!][weevely] Exiting: Error with obfuscator template '/opt/weevely3/bd/obfuscators/obfusc1_php.tpl': 'ascii' codec can't decode byte 0xff in position 370: ordinal not in range(128)

what's problem ?

Make sure you're using the latest weevely version from this git repo. Could you please paste here the output of python --version? Thanks.

@epinna
weevely is the latest version

$ python --version           
Python 2.7.15

SYSTEM INFORMATION

$ sudo screenfetch        
              ............                root@Awesome
          .';;;;;.       .,;,.            OS: Deepin 15.7 unstable
       .,;;;;;;;.       ';;;;;;;.         Kernel: x86_64 Linux 4.15.0-29deepin-generic
     .;::::::::'     .,::;;,''''',.       Uptime: 1d 12h 11m
    ,'.::::::::    .;;'.          ';      Packages: 3180
   ;'  'cccccc,   ,' :: '..        .:     Shell: sudo
  ,,    :ccccc.  ;: .c, '' :.       ,;    Resolution: 1366x768
 .l.     cllll' ., .lc  :; .l'       l.   WM: Mutter(DeepinGala)
 .c       :lllc  ;cl:  .l' .ll.      :'   WM Theme: Adwaita
 .l        'looc. .   ,o:  'oo'      c,   CPU: Intel Core i5-4210U @ 4x 1.6GHz [51.5°C]
 .o.         .:ool::coc'  .ooo'      o.   GPU: intel
  ::            .....   .;dddo      ;c    RAM: 3203MiB / 7861MiB
   l:...            .';lddddo.     ,o    
    lxxxxxdoolllodxxxxxxxxxc      :l     
     ,dxxxxxxxxxxxxxxxxxxl.     'o,      
       ,dkkkkkkkkkkkkko;.    .;o;        
         .;okkkkkdl;.    .,cl:.          
             .,:cccccccc:,.              


Something errors

$ python weevely.py http://localhost:3333/test.php test

[+] weevely 3.7.0

[+] Target:	localhost:3333
[+] Session:	/home/b0y1n4o4/.weevely/sessions/localhost/test_0.session

[+] Browse the filesystem or execute commands starts the connection
[+] to the target. Type :help for more information.

weevely> :shell_sh whoami
[-][channel] Is the trailing comma missing at the end of the PHP code '..@error_reporting(0);@python_eval('import os; os.system('echo56363');');?>
Traceback (most recent call last):
  File "weevely.py", line 99, in <module>
    main(arguments)
  File "weevely.py", line 52, in main
    Terminal(session).cmdloop()
  File "/usr/lib/python2.7/cmd.py", line 143, in cmdloop
    stop = self.postcmd(stop, line)
  File "/opt/weevely3/core/terminal.py", line 249, in postcmd
    self.prompt = '%s %s ' % (self.session.get_connection_info(), prompt)
  File "/opt/weevely3/core/sessions.py", line 61, in get_connection_info
    path = self['file_cd']['results'].get('cwd', '.')
  File "/usr/local/lib/python2.7/dist-packages/mako/template.py", line 462, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/local/lib/python2.7/dist-packages/mako/runtime.py", line 838, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/local/lib/python2.7/dist-packages/mako/runtime.py", line 873, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/local/lib/python2.7/dist-packages/mako/runtime.py", line 899, in _exec_template
    callable_(context, *args, **kwargs)
  File "memory:0x7f01b718e050", line 41, in render_body
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 112: invalid start byte

Please try what I pushed on encoding-fix branch and let me know if it is any better.

git pull
git checkout encoding-fix

Please try what I pushed on encoding-fix branch and let me know if it is any better.

git pull
git checkout encoding-fix

Not work, result

# b0y1n4o4 @ Awesome in /opt/weevely3 on git:encoding-fix x [8:29:56] 
$ python weevely.py http://localhost:3333/test.php test
Traceback (most recent call last):
  File "weevely.py", line 99, in <module>
    main(arguments)
  File "weevely.py", line 52, in main
    Terminal(session).cmdloop()
  File "/opt/weevely3/core/terminal.py", line 148, in __init__
    conn_info = session.get_connection_info(),
  File "/opt/weevely3/core/sessions.py", line 61, in get_connection_info
    path = self['file_cd']['results'].get('cwd', '.')
  File "/usr/local/lib/python2.7/dist-packages/mako/template.py", line 462, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/local/lib/python2.7/dist-packages/mako/runtime.py", line 838, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/local/lib/python2.7/dist-packages/mako/runtime.py", line 873, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/local/lib/python2.7/dist-packages/mako/runtime.py", line 899, in _exec_template
    callable_(context, *args, **kwargs)
  File "memory:0x7fb02cb68990", line 41, in render_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 112: ordinal not in range(128)

$ python weevely.py generate demo demo.php             
[!][weevely] Exiting: Error with obfuscator template '/opt/weevely3/bd/obfuscators/obfusc1_php.tpl': 'ascii' codec can't decode byte 0xff in position 89: ordinal not in range(128)

I checkout many branch, it still not work, looks something wrong with my system, few months ago, it works fine..