[#5] Skript Challenge - Deobfuscater

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Status
Not open for further replies.

BaeFell

I'm Poppy
Staff member
Admin
skUnity Legend
Nov 27, 2016
1,022
241
73
discord.gg
Discord Username
BaeFell
Hi everyone,

Welcome to another Skript Challenge!

In this Skript Challenge, you must make a deobfuscator for @Donut's obfuscator

The rules are as follows (note: rules may change between challenge):
- Any of the languages below can be used but the code must be easily readable and accessible
- Your code must be in code tags, pastebin or on a public GitHub repo
- You can use addons, but, you're not allowed to use a feature from an addon which does this and the addon must of been released publicly prior to the creation of this thread (eg. WildSkript obfuscate expression...)
- You can use another user's code, but please don't edit your messages. I can see all message history and posts that do have edit history like this will not be counted
- Web API's or using an external source (eg, a Java obfuscation library), to get your result in is not allowed. All submissions must actually do the obfuscation themselves.
- You must list all addons used. I will be testing on Spigot 1.12.2

I might add a rule after a submission has been made, it's up to me whether or not that submission is valid. I can deny any submission for any reason.

Challenge details (specifics about this challenge):
- Your must successfully take the input of an obfuscated script that was obfuscated using @Donut's obfuscation tool and then return the deobfuscated output
- You can use any of the programming languages below, but the code must be accessible.
- I really like any information and stuff so gimme stats about what's going on and how everything went

Languages allowed:
- Java
- PHP
- Skript
- JavaScript
Those are the languages I am confident in and can only judge code using them.

Please follow this format:

Code:
Language used:
Published link (optional):
Source code link or pasted below:

Important
If you don't understand how your answer will be judged here is an explanation:
Better code quality = more points. I'm very anti-addon with some things. If you're using an addon for what can be done normally in Skript, then you're not Skripting right. Variable names, code structure, use of functions and code readability matters for this challenge. I'm specifically looking for the best code, not the smallest, but you shouldn't have code that is far too long, otherwise it's unlikely to be efficient.

The closing date is 7 days from now -> 7th of May - have fun!
(I might be too busy to post winners on the 8th of May, but any entries after the 7th of May at 11:59PM GMT will not be counted)

Please direct any questions at myself.

Thanks,
BaeFell

NOTICE: I will be accepting already created solutions, please link to where they are if they're published and the source code.
 
  • Like
Reactions: ShaneBee
Technically my deobfuscation addon was released prior to the posting of this thread, so here's my submission using Script Deobfuscator:
code_language.skript:
on script load:
  deobfuscate script

# obfuscated code here
 
So you can't make use of any of Skript's code like Pikachu's addon does, with Java nor skript-mirror, the method/function for deobfuscating needs to take the whole content of a script as a string parameter (/list of strings(lines), etc), process it without accessing Skript and then return it as a deobfuscated string?
 
For 1.1.5: (I made it yesterday but didn't post it yet)
Language: Skript
Addons: skUtilities (only for taking file input)
Input file: plugins/obf.sk
Code:
code_language.skript:
options:
    file: plugins/obf.sk
    @: @
          
function getOptions(f: text):
    set {_c::*} to file contents of {_f}
    set {_c} to join {_c::*} with nl
    set {_l::*} to split {_c} at "options:"
    set {_c} to {_l::3}
    delete {_l::*}
    replace every "    " in {_c} with ""
    set {_l::*} to split {_c} at nl
    delete {_l::1}
    loop {_l::*}:
        delete {_s::*}
        set {_s::*} to split loop-value at ": "
        set {obf-options::%{_s::1}%} to {_s::2}
  
function parseOptions(t: text) :: text:
    set {_c::*} to {_t} parsed as "{{@@}%text%}"
    return {_c::1}

function obf(t: text) :: text:
    return {obf-options::%{_t}%}
  
# function obfDecodeLine(t: text) :: text:
    # set {_f} to {_t}
    # set {_s::*} to split {_t} at ""
    # set {_w} to false
    # loop {_s::*}:
        # set {_i1} to loop-index parsed as a number
        # loop 10 times:
            # set {_i%loop-number + 1%} to {_i%loop-number%} + 1
        # if loop-value is "{":
            # {_w} is false
            # {_s::%{_i2}%} is "@"
            # set {_in} to false
            # if {_i3} is "}":
                # set {_in} to true
            # set {_w} to true
            # add {_i1} to {_ind::*}
        # if loop-value is "}":
            # {_w} is true
            # {_in} is false
            # add {_i1} to {_ind::*}
            # set {_w} to false
    # loop {_ind::*}:
        # mod(loop-index parsed as a number, 2) = 1
        # set {_i1} to loop-index parsed as a number
        # set {_i2} to {_i1} + 1
        # set {_txt} to subtext of {_t} from characters loop-value to {_ind::%{_i2}%}
        # set {_txt2} to obf(parseOptions({_txt}))
        # replace every {_txt} in {_f} with {_txt2}
    # return {_f}

function obfDecodeFile() :: text:
    getOptions("{@file}")
    set {_c::*} to file contents of "{@file}"
    set {_c} to join {_c::*} with nl
    set {_l::*} to split {_c} at "options:"
    set {_c} to {_l::3}
    delete {_l::*}
    set {_l::*} to split {_c} at nl
    delete {_l::1}
    loop {_l::*}:
        # set {_s} to loop-value
        if loop-value does not contain "    ":
            # broadcast "exit at %loop-value%"
            exit loop
        delete {_l::%loop-index%}
    loop {_l::*}:
        add obfDecodeLine2(loop-value) to {_out::*}
        # broadcast "%{_out::*}%"
        # stop
    set {_out} to join {_out::*} with nl
    replace every "    " in {_out} with "    "
    return {_out}
      
command /decode:
    trigger:
        broadcast obfDecodeFile()

function obfDecodeLine2(t: text) :: text:
    set {_f} to {_t}
    set {_s::*} to split {_t} at ""
    set {_w} to false
    loop {_s::*}:
        set {_i1} to loop-index parsed as a number
        loop 10 times:
            set {_i%loop-number + 1%} to {_i%loop-number%} + 1
        remove 1 from {_in}
        set {_c} to false
        if loop-value is "{":
            {_w} is false
            {_s::%{_i2}%} is "@"
            set {_in} to 0
            set {_c} to true
            if {_s::%{_i3}%} is "}":
                set {_in} to 2
            set {_w} to true
            add {_i1} to {_ind::*}
        if loop-value is "}":
            {_w} is true
            {_in} is not 0
            set {_c} to true
            set {_last} to last element out of {_ind::*}
            add subtext of {_t} from characters {_last} to {_i1} to {_l2::*}
            add {_i1} to {_ind::*}
            set {_w} to false
        if {_c} is false:
            {_w} is false
            add loop-value to {_l2::*}
    # loop {_ind::*}:
        # mod(loop-index parsed as a number, 2) = 1
        # set {_i1} to loop-index parsed as a number
        # set {_i2} to {_i1} + 1
        # set {_txt} to subtext of {_t} from characters loop-value to {_ind::%{_i2}%}
        # set {_txt2} to obf(parseOptions({_txt}))
        # replace every {_txt} in {_f} with {_txt2}
    # return {_f}
    # broadcast "%{_l2::*}%"
    # stop
    loop {_l2::*}:
        loop-value contains "@", "{" and "}"
        set {_l2::%loop-index%} to obf(parseOptions(loop-value))
    set {_out} to join {_l2::*} with ""
    replace every "    " in {_out} with "    "
    return {_out}
I'm going to make one for the newest version as well
EDIT:
Okay I think I won't be able to do the deobfuskator for 1.2.5 as skUtilities doesn't want to take input from the file :/, so I hope there will be a new version which skUtilities can read.
 
Last edited:
Just so everyone is aware - I'll be testing on the first released version of the obfuscator.
 
Okay this is my submission for the 1.0 version:
Language used: Skript
Addons (I seriously needed 2 for 2 different things):
  • skUtilities (for taking file input)
  • SkQuery (for the new line expression, idk if it's possible in vanilla Skript)
Input file: plugins/obf.sk
Command: /decode (will broadcast deobfuscated script so you can also see it in console)
Code:
code_language.skript:
options:
    file: plugins/obf.sk
    @: @
           
function getOptions(f: text):
    delete {obf-options::*}
    set {_c::*} to file contents of {_f}
    set {_c} to join {_c::*} with nl
    set {_l::*} to split {_c} at "options:"
    set {_c} to {_l::2}
    delete {_l::*}
    replace every "    " in {_c} with ""
    set {_l::*} to split {_c} at nl
    delete {_l::1}
    loop {_l::*}:
        delete {_s::*}
        set {_s::*} to split loop-value at ": "
        set {obf-options::%{_s::1}%} to {_s::2}
   
function parseOptions(t: text) :: text:
    set {_c::*} to {_t} parsed as "{{@@}%text%}"
    return {_c::1}

function obf(t: text) :: text:
    return {obf-options::%{_t}%}

function obfDecodeFile() :: text:
    getOptions("{@file}")
    set {_c::*} to file contents of "{@file}"
    set {_c} to join {_c::*} with nl
    set {_l::*} to split {_c} at "options:"
    set {_c} to {_l::2}
    delete {_l::*}
    set {_l::*} to split {_c} at nl
    delete {_l::1}
    loop {_l::*}:
        if loop-value does not contain "    ":
            exit loop
        delete {_l::%loop-index%}
    loop {_l::*}:
        add obfDecodeLine2(loop-value) to {_out::*}
    set {_out} to join {_out::*} with nl
    replace every "    " in {_out} with "    "
    return {_out}
       
command /decode:
    trigger:
        broadcast obfDecodeFile()

function obfDecodeLine2(t: text) :: text:
    set {_f} to {_t}
    set {_s::*} to split {_t} at ""
    set {_w} to false
    loop {_s::*}:
        set {_i1} to loop-index parsed as a number
        loop 10 times:
            set {_i%loop-number + 1%} to {_i%loop-number%} + 1
        remove 1 from {_in}
        set {_c} to false
        if loop-value is "{":
            {_w} is false
            {_s::%{_i2}%} is "@"
            set {_in} to 0
            set {_c} to true
            if {_s::%{_i3}%} is "}":
                set {_in} to 2
            set {_w} to true
            add {_i1} to {_ind::*}
        if loop-value is "}":
            {_w} is true
            {_in} is not 0
            set {_c} to true
            set {_last} to last element out of {_ind::*}
            add subtext of {_t} from characters {_last} to {_i1} to {_l2::*}
            add {_i1} to {_ind::*}
            set {_w} to false
        if {_c} is false:
            {_w} is false
            add loop-value to {_l2::*}
    loop {_l2::*}:
        loop-value contains "@", "{" and "}"
        set {_l2::%loop-index%} to obf(parseOptions(loop-value))
    set {_out} to join {_l2::*} with ""
    replace every "    " in {_out} with "    "
    return {_out}
 
  • Like
Reactions: Pikachu
Okay this is my submission for the 1.0 version:
Language used: Skript
Addons (I seriously needed 2 for 2 different things):
  • skUtilities (for taking file input)
  • SkQuery (for the new line expression, idk if it's possible in vanilla Skript)
Input file: plugins/obf.sk
Command: /decode (will broadcast deobfuscated script so you can also see it in console)
Code:
code_language.skript:
options:
    file: plugins/obf.sk
    @: @
          
function getOptions(f: text):
    delete {obf-options::*}
    set {_c::*} to file contents of {_f}
    set {_c} to join {_c::*} with nl
    set {_l::*} to split {_c} at "options:"
    set {_c} to {_l::2}
    delete {_l::*}
    replace every "    " in {_c} with ""
    set {_l::*} to split {_c} at nl
    delete {_l::1}
    loop {_l::*}:
        delete {_s::*}
        set {_s::*} to split loop-value at ": "
        set {obf-options::%{_s::1}%} to {_s::2}
  
function parseOptions(t: text) :: text:
    set {_c::*} to {_t} parsed as "{{@@}%text%}"
    return {_c::1}

function obf(t: text) :: text:
    return {obf-options::%{_t}%}

function obfDecodeFile() :: text:
    getOptions("{@file}")
    set {_c::*} to file contents of "{@file}"
    set {_c} to join {_c::*} with nl
    set {_l::*} to split {_c} at "options:"
    set {_c} to {_l::2}
    delete {_l::*}
    set {_l::*} to split {_c} at nl
    delete {_l::1}
    loop {_l::*}:
        if loop-value does not contain "    ":
            exit loop
        delete {_l::%loop-index%}
    loop {_l::*}:
        add obfDecodeLine2(loop-value) to {_out::*}
    set {_out} to join {_out::*} with nl
    replace every "    " in {_out} with "    "
    return {_out}
      
command /decode:
    trigger:
        broadcast obfDecodeFile()

function obfDecodeLine2(t: text) :: text:
    set {_f} to {_t}
    set {_s::*} to split {_t} at ""
    set {_w} to false
    loop {_s::*}:
        set {_i1} to loop-index parsed as a number
        loop 10 times:
            set {_i%loop-number + 1%} to {_i%loop-number%} + 1
        remove 1 from {_in}
        set {_c} to false
        if loop-value is "{":
            {_w} is false
            {_s::%{_i2}%} is "@"
            set {_in} to 0
            set {_c} to true
            if {_s::%{_i3}%} is "}":
                set {_in} to 2
            set {_w} to true
            add {_i1} to {_ind::*}
        if loop-value is "}":
            {_w} is true
            {_in} is not 0
            set {_c} to true
            set {_last} to last element out of {_ind::*}
            add subtext of {_t} from characters {_last} to {_i1} to {_l2::*}
            add {_i1} to {_ind::*}
            set {_w} to false
        if {_c} is false:
            {_w} is false
            add loop-value to {_l2::*}
    loop {_l2::*}:
        loop-value contains "@", "{" and "}"
        set {_l2::%loop-index%} to obf(parseOptions(loop-value))
    set {_out} to join {_l2::*} with ""
    replace every "    " in {_out} with "    "
    return {_out}
you can remove the reliance on skquery using skutilies sys prop expr
 
Here's my entry.

IM7MCFs.gif


100% client-side deobfuscation.

Source code: https://github.com/RezzedUp/Skript-Options-Deobfuscator

Use it here: https://goingoffskript.github.io/skript-options-deobfuscator/

Tested with Chrome.
 
Last edited by a moderator:
Status
Not open for further replies.