Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EvaluatorOptions class for defining behavioral options in vbSparkle #2

Closed
wants to merge 15 commits into from

Conversation

sbruyere
Copy link
Contributor

@sbruyere sbruyere commented Jan 11, 2023

I am happy to release this new feature that I have been waiting to implement for a long time: a new option class, called EvaluatorOptions, that enables customization of the behavior of vbSparkle.

These options are:

  • IndentSpacing : define number of indentation spaces (default is 4 spaces)
  • SymbolRenamingMode : renaming of symbols (default None)
  • JunkCodeProcessingMode : junk/dead code processing (default is Comment)

Basically, here is how to declare these options:

var result = VbPartialEvaluator.PrettifyEncoded(content, new EvaluatorOptions()
{
    SymbolRenamingMode = SymbolRenamingMode.None,
    JunkCodeProcessingMode = JunkCodeProcessingMode.Remove,
    IndentSpacing = 4,
});

The currently available options for SymbolRenamingMode are :

[Flags]
public enum SymbolRenamingMode
{
    None,
    Variables,
    Constants,
    All = Variables | Constants
}

It's related to issue #1.

The options for dead/junk code processing are:

  • Nothing : the junk code will be kept with all the logic
  • Remove : the junk code will be removed
  • Comment : the junk code will be commented

The variable renaming feature currently implemented is simple. It's using the format of var_{idx} or const_{idx}.
It can be applied to variables and constants but it does not have scope-specific renaming capability (it means that idx counter is global).

Other changes where done:

  • some code cleaning
  • change of existing sample location to $(SolutionDir)\\Resources\\samples\\
  • fix a bit the way If / Then / ElseIf / Else blocks where evaluated
  • add action workflow for providing automatic releases when tagged

- Add EvaluatorOptions with following option
  - IndentSpacing (implemented)
  - PerfomPartialEvaluation (to implement)
  - JunkCodeProcessingMode (implemented)
  - SymbolRenamingMode (to implement)
- Implements JunkCodeProcessingMode option in If Then Else blocks
- Implements IndentSpacing in overall generated code
- Propagate the Option through context overall statement visitors & scoped objects
@sbruyere
Copy link
Contributor Author

sbruyere commented Jan 12, 2023

Also, the CLI has been updated accordingly to the new Options features:

  -p, --path                (Group: input) Path of directory or script file(s)
                            to be deobfuscated.

  --stdin                   (Group: input) (Default: false) Read from stdin

  -o, --output              File offset.

  --sym-rename-mode         (Default: None) Define how symbols can be renamed.
                            Valid values: None, Variables, Constants, All

  --junk-code-processing    (Default: Comment) Define junk code should be
                            processed. Valid values: Nothing, Remove, Comment

  -i, --indent-spacing      (Default: 4) Defines the number of spaces taken into
                            account for the indentation of the code.

And with an improved visual:
image

@citronneur , Let me know if you need more clarification to review/merge the PR. ;)

Provide syntax coloring

Try improve workflow

Fix naming in publish workflow

Provide real CLI with syntax Coloring

Fix readme with information about CLI options

Improve way of processing CLI options & standard input
Add of ExecuteObserver
Add of CreateObjectObserver
Add Shell() interceptor
Add CreateObject() interceptor
Constants
vbUseCompareOption
vbBinaryCompare
vbTextCompare
vbDatabaseCompare
String Manipulation Methods
InStr
InStrB
InStrRev
LCase
LCase_S
UCase
UCase_S
Len
LenB
Mid
Mid_S
MidB
MidB_S
Left
Left_S
LeftB
LeftB_S
Right
Right_S
RightB
RightB_S
RTrim
RTrim_S
LTrim
LTrim_S
Join
Split
Financial Methods
DDB
FV
IPmt
IRR
MIRR
NPer
NPV
Pmt
PPmt
PV
Rate
SLN
SYD
Array Methods
Array
LBound
UBound
@sbruyere sbruyere closed this Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant