Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Is there anyway to restore the obfuscated decomplied scripts?

Discussion in 'Scripting' started by Bagazi, Mar 6, 2023.

  1. Bagazi

    Bagazi

    Joined:
    Apr 18, 2018
    Posts:
    609
    For example, this is a section of decompiled script that was obfuscated before,as the variable name was replaced by "a"/"b"/"c",is there any tool to restore to original ,or like 90% ?




    Code (CSharp):
    1. /*     */     public Builder setStatusBarColor(int statusBarColor) { this.a = statusBarColor; return this; }
    2. /*     */     public Builder setStatusBarDarkColor(boolean statusBarDarkColor) { this.b = statusBarDarkColor; return this; }
    3. /*     */     public Builder setNavigationIcon(String backIcon) { this.c = backIcon; return this; }
    4. /*  37 */     public Builder setNavigationIconDrawable(Drawable navBackIconDrawable) { this.d = navBackIconDrawable; return this; } public Builder setNavigationBackIconWidth(int backIconWidth) { this.f = backIconWidth; return this; } public Builder setNavigationBackIconHeight(int backIconHeight) { this.g = backIconHeight; return this; } public Builder setHideNavigationBackIcon(boolean isHideBackIcon) { this.e = isHideBackIcon; return this; } public Builder setNavigationBackgroundColor(int backgroundColor) { this.h = backgroundColor; return this; } public Builder setNavigationHeight(int navHeight) { this.j = navHeight; return this; } public Builder setNavigationTitle(String title) { this.i = title; return this; } public Builder setNavigationTitleColor(int titleColor) { this.k = titleColor; return this; } public Builder setNavTitleSize(int navTitleSize) { this.l = navTitleSize; return this; } public Builder setNavTitleDpSize(int navTitleDpSize) { this.m = navTitleDpSize; return this; } public Builder setHideNavigation(boolean isHideNavigation) { this.n = isHideNavigation; return this; } public Builder setNavTitleBold(boolean navTitleBold) { this.o = navTitleBold; return this; } public Builder setLogoIconName(String logoIconName) { this.p = logoIconName; return this; } public Builder setLogoIconDrawable(Drawable logoIconDrawable) { this.q = logoIconDrawable; return this; } public Builder setLogoWidth(int logoWidth) { this.r = logoWidth; return this; } public Builder setLogoHeight(int logoHeight) { this.s = logoHeight; return this; } public Builder setLogoTopYOffset(int logoTopYOffset) { this.t = logoTopYOffset; return this; } public Builder setLogoBottomYOffset(int logoBottomYOffset) { this.u = logoBottomYOffset; return this; } public Builder setLogoXOffset(int logoXOffset) { this.v = logoXOffset; return this; } public Builder setHideLogo(boolean hideLogo) { this.w = hideLogo; return this; } public Builder setMaskNumberColor(int maskNumberColor) { this.x = maskNumberColor; return this; } public Builder setMaskNumberSize(int maskNumberSize) { this.y = maskNumberSize; return this; } public Builder setMaskNumberDpSize(int maskNumberDpSize) { this.z = maskNumberDpSize; return this; } public Builder setMaskNumberTypeface(Typeface tf) { this.A = tf; return this; } public Builder setMaskNumberTopYOffset(int maskNumberTopYOffset) { this.B = maskNumberTopYOffset; return this; } public Builder setMaskNumberBottomYOffset(int maskNumberBottomYOffset) { this.C = maskNumberBottomYOffset; return this; } public Builder setMaskNumberXOffset(int maskNumberXOffset) { this.D = maskNumberXOffset; return this; } public Builder setSloganSize(int sloganSize) { this.E = sloganSize; return this; } public Builder setSloganDpSize(int sloganDpSize) { this.F = sloganDpSize; return this; } public Builder setSloganColor(int sloganColor) { this.G = sloganColor; return this; } public Builder setSloganTopYOffset(int sloganTopYOffset) { this.H = sloganTopYOffset; return this; } public Builder setSloganBottomYOffset(int sloganBottomYOffset) { this.I = sloganBottomYOffset; return this; } public Builder setSloganXOffset(int sloganXOffset) { this.J = sloganXOffset; return this; } public Builder setLoginBtnText(String loginBtnText) { this.K = loginBtnText; return this; } public Builder setLoginBtnTextSize(int loginBtnTextSize) { this.L = loginBtnTextSize; return this; } public Builder setLoginBtnTextDpSize(int loginBtnTextDpSize) { this.M = loginBtnTextDpSize; return this; } public Builder setLoginBtnTextColor(int loginBtnTextColor) { this.N = loginBtnTextColor; return this; } public Builder setLoginBtnWidth(int loginBtnWidth) { this.O = loginBtnWidth; return this; } public Builder setLoginBtnHeight(int loginBtnHeight) { this.P = loginBtnHeight; return this; } public Builder setLoginBtnBackgroundRes(String loginBtnBackgroundRes) { this.Q = loginBtnBackgroundRes; return this; } public Builder setLoginBtnBackgroundDrawable(Drawable loginBtnBackgroundDrawable) { this.R = loginBtnBackgroundDrawable; return this; } public Builder setLoginBtnTopYOffset(int loginBtnTopYOffset) { this.S = loginBtnTopYOffset; return this; } public Builder setLoginBtnBottomYOffset(int loginBtnBottomYOffset) { this.T = loginBtnBottomYOffset; return this; } public Builder setLoginBtnXOffset(int loginBtnXOffset) { this.U = loginBtnXOffset; return this; } public Builder setPrivacyTextColor(int privacyTextColor) { this.V = privacyTextColor; return this; } public Builder setPrivacyProtocolColor(int privacyProtocolColor) { this.W = privacyProtocolColor; return this; } public Builder setPrivacySize(int privacySize) { this.X = privacySize; return this; } public Builder setPrivacyDpSize(int privacyDpSize) { this.Y = privacyDpSize; return this; } public Builder setPrivacyTopYOffset(int privacyTopYOffset) { this.Z = privacyTopYOffset; return this; } public Builder setPrivacyBottomYOffset(int privacyBottomYOffset) { this.a0 = privacyBottomYOffset; return this; } public Builder setPrivacyMarginLeft(int privacyMarginLeft) { this.b0 = privacyMarginLeft; return this; } public Builder setPrivacyMarginRight(int privacyMarginRight) { this.c0 = privacyMarginRight; return this; } public Builder setPrivacyTextMarginLeft(int privacyTextMarginLeft) { this.i0 = privacyTextMarginLeft; return this; } public Builder setPrivacyState(boolean privacyState) { this.d0 = privacyState; return this; } public Builder setHidePrivacyCheckBox(boolean hidePrivacyCheckBox) { this.e0 = hidePrivacyCheckBox; return this; } public Builder setPrivacyTextGravityCenter(boolean privacyTextGravityCenter) { this.g0 = privacyTextGravityCenter; return this; } public Builder setPrivacyTextLayoutGravity(int privacyTextLayoutGravity) { this.h0 = privacyTextLayoutGravity; return this; } public Builder setHidePrivacySmh(boolean hidePrivacySmh) { this.f0 = hidePrivacySmh; return this; } public Builder setCheckBoxGravity(int checkBoxGravity) { this.j0 = checkBoxGravity; return this; } public Builder setPrivacyCheckBoxWidth(int privacyCheckBoxWidth) { this.k0 = privacyCheckBoxWidth; return this; } public Builder setPrivacyCheckBoxHeight(int privacyCheckBoxHeight) { this.l0 = privacyCheckBoxHeight; return this; } public Builder setCheckedImageName(String checkedImageName) { this.m0 = checkedImageName; return this; } public Builder setCheckedImageDrawable(Drawable checkedImageDrawable) { this.n0 = checkedImageDrawable; return this; } public Builder setUnCheckedImageName(String unCheckedImageName) { this.o0 = unCheckedImageName; return this; } public Builder setUnCheckedImageDrawable(Drawable unCheckedImageNameDrawable) { this.p0 = unCheckedImageNameDrawable; return this; } public Builder setPrivacyTextStart(String privacyTextStart) { this.q0 = privacyTextStart; return this; } public Builder setPrivacyTextStartSize(float spVal) { this.r0 = spVal; return this; } public Builder setPrivacyLineSpacing(float add, float mult) { this.s0 = add; this.t0 = mult; return this; } public Builder setProtocolText(String protocolText) { this.u0 = protocolText; return this; } private String K = " Quick Pass";
    5. /*     */     public Builder setProtocolLink(String protocolLink) { this.v0 = protocolLink; return this; }
    PS: Just for research ,not for any illegal purpose:)
     
  2. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    3,531
    I'm sure there are some deofuscators out there. Though it can not "restore" what isn't there anymore. In your case here since the argument names of all those setters is still there, it would be possible to derive the original field names from the argument names and what they are assigned to. So "a" should probably be "statusBarColor", etc ...
     
  3. dogmachris

    dogmachris

    Joined:
    Sep 15, 2014
    Posts:
    1,373
    Cracking obfuscation algorithms is not exactly part of the curriculum on this board, but here's an idea: why don't you just ask the original developer to hook you up with the original code? Who knows, maybe he obfuscated it for no reason and would be happy to give it to ta total stranger, if asked nicely.
     
    Sluggy and Bunny83 like this.
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,134
    ChatGPT is capable of deobfuscating code but with the limitation that it has to be code that has an actual purpose since the way it does it is to look at the context of the surrounding code to determine how to name and lay out the code.
     
    Last edited: Mar 7, 2023
    Sluggy likes this.