deobfuscation in asp.net

arisse arisse 21 Reputation points
2022-04-17T21:51:52.913+00:00

how can i remove obfuscated javascript from code like this https://www.seosniffer.com tool. i want only to be using c# (console application .net framework) not javascript

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,277 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,286 questions
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 56,846 Reputation points
    2022-04-19T15:08:01.413+00:00

    Most of the JavaScript deobfuscaters are written in JavaScript. You could port one of the open source ones to C#. Or just use node to get a command line version

    https://github.com/lelinhtinh/de4js
    https://github.com/ben-sb/javascript-deobfuscator


5 additional answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,846 Reputation points
    2022-05-08T16:20:22.647+00:00

    your sample C# app is a pretty simple implementation, just a regex to handle a common obfuscation of string values.

    This javascript version details some of the issues not handled:

    https://github.com/ben-sb/javascript-deobfuscator

    a real deobfuscator like the sample javascript one is more complex.: when writing a deobfuscator, typically you:

    parse the obfuscated javascript into an abstract syntax tree (AST).
    once the AST is built you can perform transformations on the AST to deobfuscate known obfuscation patterns
    write the transformed AST back to javascript source.

    the javascript world has a standardized AST format used by javascript language parsers. this allow a large library AST transformations.

    https://github.com/estree/estree

    there is a C# port of this code, which is used the asp.net web optimization tools:

    https://github.com/sebastienros/esprima-dotnet

    note: if you are not familiar with AST's, they are common in language parsing. in C#, lambada expression trees (used by MVC binding, EF and Line to Sql libraries, etc) are a form of an AST. But for .net language parsing the roselyn AST is typically used.

    https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/get-started/syntax-analysis

    0 comments No comments