Obfuscation does not obfuscate subroutines

It seems the subroutines are not properly obfuscated. Here’s an example project. onCreate calls doSomething which calls doSomethingElse which calls its subroutine nestedDoSomething, which intentionally crashes the app with a method call on a null object.

The crash log from Logcat indicates that obfuscation works on the public methods but does not work properly on the subroutine. Note that doSomethingElse is referred to as b in the stack trace initially but then referred to as doSomethingElse from within the subroutine, rather than b$c or even b$nestedDoSomething.

Attempt to invoke virtual method 'boolean java.lang.String.contains(java.lang.CharSequence)' on a null object reference
	at security.tests.MainActivity.doSomethingElse$nestedDoSomething(Unknown Source:3)
	at security.tests.MainActivity.b(Unknown Source:0)
	at security.tests.MainActivity.a(Unknown Source:0)

Here’s the project
security.tests.zip (31.8 KB)

interface
  
[assembly:Obfuscate(PublicMembers := true, Members := true)]
  
  uses
    android.app, android.content, android.os;

  type
    MainActivity = public class(Activity)
    public
      method onCreate(savedInstanceState: Bundle); override;
      method doSomething;
      method doSomethingElse;
    end;

implementation
  
  method MainActivity.onCreate(savedInstanceState: Bundle);
  begin
    inherited;
    ContentView := R.layout.main;
    
    doSomething;
  end;
  
  method MainActivity.doSomething;
  begin
    doSomethingElse;
  end;
  
  method MainActivity.doSomethingElse;

    method nestedDoSomething;
    begin
      var s: String;
      s.contains("a");
    end;
    
  begin
    nestedDoSomething;
  end;
end.

Fixed! thanks.

1 Like