OWASP / ZSC

OWASP ZSC - Shellcode/Obfuscate Code Generator https://www.secologist.com/
https://www.secologist.com/
Other
647 stars 217 forks source link

Base64 Obfuscation for javascript #35

Closed Pratik151 closed 8 years ago

Pratik151 commented 8 years ago

As there is base64 obfuscation for python in PR, I added for Javascript. I am not so much familiar with Javascript but I checked other module and made this. I tested this and it is working good.

Is this the correct way to go? I am now making base64 obfuscation for php.

Ali-Razmjoo commented 8 years ago

Hi, Thanks for PR,

there is a problem in python3 which need to be fix

   ______          __      _____ _____    ___________ _____
  / __ \ \        / /\    / ____|  __ \  |___  / ____|  __ \
 | |  | \ \  /\  / /  \  | (___ | |__) |    / / |    | |__) |
 | |  | |\ \/  \/ / /\ \  \___ \|  ___/    / /| |    |  _  /
 | |__| | \  /\  / ____ \ ____) | |       / /_| |____| | \ \
  \____/ _ \/ _\/_/___ \_\_____/|_|  ____/_____\_____|_|__\_\_ _____    _
  / ____| |  | |  ____| |    | |    / ____/ __ \|  __ \|  ____|  __ \  | |
 | (___ | |__| | |__  | |    | |   | |   | |  | | |  | | |__  | |__) | | |
  \___ \|  __  |  __| | |    | |   | |   | |  | | |  | |  __| |  _  /  | |
  ____) | |  | | |____| |____| |___| |___| |__| | |__| | |____| | \ \  |_|
 |_____/|_|  |_|______|______|______\_____\____/|_____/|______|_|  \_\ (_)

                        OWASP ZeroDay Cyber Research Shellcoder

zsc> obfuscate
zsc/obfuscate> javascript
filename>
CHANGELOG.md   file.html      readme.md      version
LICENSE.md     installer.py   uninstaller.py zsc.py
filename> file.html
encode>
base64     simple_hex
encode> base64
Traceback (most recent call last):
  File "zsc.py", line 22, in <module>
    main() #execute main function
  File "zsc.py", line 18, in main
    run.engine(commands) #run engine
  File "C:\Users\Ali\Desktop\OWASP-ZSC-Dev\core\run.py", line 235, in engine
    getcommand(commands)
  File "C:\Users\Ali\Desktop\OWASP-ZSC-Dev\core\run.py", line 122, in getcommand
    obf_code(option,encode,filename,content)
  File "C:\Users\Ali\Desktop\OWASP-ZSC-Dev\core\obfuscate.py", line 15, in obf_code
    content = start(content) #encoded content as returned value
  File "C:\Users\Ali\Desktop\OWASP-ZSC-Dev\lib\encoder\javascript\base64.py", line 42, in start
    return str(str('/*\n')+str(content.replace('*/','*_/'))+str('\n*/') + str(encode(content))+str('\n'))
  File "C:\Users\Ali\Desktop\OWASP-ZSC-Dev\lib\encoder\javascript\base64.py", line 23, in encode
    data = val_name + ' = "' + str(binascii.b2a_base64(f).replace('\n','').encode('latin-1')).decode('latin-1') +'"'
TypeError: a bytes-like object is required, not 'str'

C:\Users\Ali\Desktop\OWASP-ZSC-Dev>

it's the same problem with johanna PR , https://github.com/Ali-Razmjoo/OWASP-ZSC/pull/31 I give some guides there.

Regards.

Pratik151 commented 8 years ago

@Ali-Razmjoo Fixed. Sorry for that, I didn't read your comment there first, Tested on python 3.4.3 and I think this should work for 3.5 too.

I also did base64 obfuscation for php will send PR now.

Next I am planning to do simple_hex_reverse obfuscation for python. So can you help me with that? Do we need to reverse the hex like '4b' to 'b4' or something else like invert?

Ali-Razmjoo commented 8 years ago

@Pratik151 yes sure you can add also simple_hex_reverse too, anything you like!