2009-02-06 5 views
16

자바 스크립트 obfuscator를 사용하려고합니다. 가장 인기있는 것은 무엇이며 실적에 어떤 영향을 미칩니 까?최고의 자바 스크립트 obfuscator는 무엇입니까?

+1

및 매우 유용합니다. 또한 Harvey는이 전문가 사이트가 단순한 질문과 전문가의 "의견"에만 답변 할 수 있으며 확장 된 토론은 어떻게 든 부정적이라는 것을 의미합니다. "나는 obsfuscators의 목록을 얻을 수 있습니까?" 감사합니다, Dave H. – DHorse

+0

** ** - >>> ** http : //stackoverflow.com/questions/194397/how-can-i-obfuscateprotect-javascript** –

+0

** DUPLICATE OF http : // jsobfuscator .byethost7.com/ –

답변

12

야후는 꽤 좋은 것을 가지고 있습니다. 기술적으로는 소형차이지만, 그 과정에서 난독 화가 잘됩니다.

YUI Compressor

+0

온라인으로 YUI Compressor를 통해 압축되고 난독 화되었습니다. http://refresh-sf.com/yui/ – NexusRex

+0

링크는 더 이상 작동하지 않습니다. –

3

음, 구글은 첫 번째 링크로이 제기 :

http://www.javascriptobfuscator.com

하지만 자바 스크립트의 좋은 난독이 무엇을 궁금해. 어쨌든 난독 처리가 필요한 자바 스크립트에서 무엇을하고 있더라도 어쨌든 서버 측에서 처리해야합니다. 맞습니까?

+0

내가 본 모든 것 중에서, 아마도 이것이 최고의 난독 화자 일 것입니다. JScrambler를 시도하지는 않았지만. – AStackOverflowUser

2

나는 생산에 난독을 사용한 적이 없으니까,하지만 난 JavaScript Utility을 테스트했습니다 그것은 꽤 좋은 것 같다.

성능 측면에서 보면 페이지가로드 될 때마다 난독 화 코드는 즉시 에 압축을 풀어야합니다. 작은 스크립트에서는 문제가되지 않을 수도 있지만 큰 파일에서는 언팩 시간이 중요합니다. 한편, 축소 된 코드는 브라우저에서 직접 실행 가능합니다.

일부 obfuscator는 이전 버전이나 덜 일반적인 브라우저에서 실행되지 않는 출력을 생성 할 수 있습니다. 지원하려는 브라우저로 신중하게 테스트해야합니다.

+1

Obfuscators는 코드 풀기를 요구하지 않습니다. 코드를 최소화하기위한 다른 방법은이를 요구할 수도 있지만, obfsucation 자체는 그렇지 않습니다. –

+0

나는 여기에 난독 화와 포장이 섞여 있음에 동의합니다. 패킹은 JS를 난독 화하는 일반적인 방법이지만 스크립트 파일의 크기를 줄이는 것이 주 목적입니다. –

2
+1

누구나 이것을 사용하는 방법을 알고 있습니까?나는 그것을 알아낼 수 없습니다. – Noitidart

6

은 (www.javascriptobfuscator.com 제외) 8 개 난독을 테스트하고, 그들은 모두 빨아 얼마나 놀랐다. 정규 표현식을 사용하여 내 자신의 obfuscator를 작성하는 것을 끝내기. 즐기십시오 :

static Dictionary<string, string> names = new Dictionary<string, string>(); 
static bool testing = false; 
static string[] files1 = 
    @"a.js,b.js,c.js" 
    .Split(new string[] { Environment.NewLine, " ", "\t", "," }, StringSplitOptions.RemoveEmptyEntries); 
static string[] ignore_names = 
    @"sin,cos,order,min,max,join,round,pow,abs,PI,floor,random,index,http, 
    __defineGetter__,__defineSetter__,indexOf,isPrototypeOf,length,clone,toString,split,clear,erase 
    RECT,SIZE,Vect,VectInt,vectint,vect,int,double,canvasElement,text1,text2,text3,textSizeTester,target,Number 
    number,TimeStep,images,solid,white,default,cursive,fantasy,". 
    Split(new string[] { Environment.NewLine, " ", "\t", "," }, StringSplitOptions.RemoveEmptyEntries); 
string[] extra_names = @"a,b,c".Split(new string[] { Environment.NewLine, " ", "\t", "," }, StringSplitOptions.RemoveEmptyEntries); 
string src = @"C:\temp"; 
string dest1 = src + "\\all1.js"; 
string dest2 = src + "\\all2.js"; 

static void Main() 
{ 
    File.Delete(dest1); 
    File.Delete(dest2); 
    foreach (string s in files1) 
    File.AppendAllText(dest1, File.ReadAllText(src + "\\" + s) + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine, Encoding.UTF8); 

    string all = File.ReadAllText(dest1); 
    int free_index = 0; 

    foreach (string s in extra_names) 
    { 
    free_index++; 
    string free_name = "" + (char)('A' + (free_index % 25)) + (char)('A' + ((free_index/25) % 25)); 
    Debug.Assert(free_name != "AA"); 
    names.Add(s, free_name); 
    } 

    Regex reg1 = new Regex("(var |function |\\.prototype\\.)([a-zA-Z0-9_]+)"); 

    int startat = 0; 
    while (startat < all.Length) 
    { 
    Match match = reg1.Match(all, startat); 
    if (!match.Success) 
     break; 

    string key = all.Substring(match.Groups[2].Index, match.Groups[2].Length); 
    if (!ignore_names.Contains(key)) 
    { 
     free_index++; 
     string free_name = "" + (char)('A' + (free_index % 25)) + (char)('A' + ((free_index/25) % 25)); 
     Debug.Assert(free_name != "AA"); 
     if (!names.ContainsKey(key)) 
     names.Add(key, testing ? key + free_name : free_name); 
    } 
    startat = match.Groups[0].Index + match.Groups[0].Length; 
    } 

    Regex reg2 = new Regex(@"/\*.*\*/", RegexOptions.Multiline); 
    Regex reg3 = new Regex("([^:\\\\])//.*\r\n"); 
    Regex reg4 = new Regex("([a-zA-Z0-9_]+)"); 
    Regex reg5 = new Regex("(\r\n)*[ \t]+"); 
    Regex reg6 = new Regex("(\r\n)+"); 
    all = reg2.Replace(all, eval2); 
    all = reg3.Replace(all, eval3); 
    all = reg4.Replace(all, eval4); 
    all = reg5.Replace(all, eval5); 
    all = reg6.Replace(all, eval6); 
    File.WriteAllText(dest2, all); 
} 

public static string eval4(Match match) 
{ 
    return names.ContainsKey(match.Groups[1].Value) ? names[match.Groups[1].Value] : match.Groups[0].Value; 
} 
public static string eval5(Match match) 
{ 
    return string.IsNullOrEmpty(match.Groups[1].Value) ? " " : Environment.NewLine; 
} 
public static string eval6(Match match) 
{ 
    return Environment.NewLine; 
} 
public static string eval2(Match match) 
{ 
    return " "; 
} 
public static string eval3(Match match) 
{ 
    return match.Groups[1].Value + Environment.NewLine; 
} 
+12

왜 "모두 다 빨다"? 귀하의 코드는 어떤 문제점을 해결합니까? – frenchie

+2

@frenchie 그런데 "sucky"obfuscator로 생성 된 난독 화 된 자바 스크립트를 http://jsbeautifier.org/의 JavaScript 미인기에 붙여 넣기 만하면 즉시 흐리게 처리되지 않는 것을 볼 수 있습니다. – trusktr

+1

@AareP, 몇 가지 샘플 변환을 제공 할 수 있습니까? – trusktr

0

패커를 base62로

http://dean.edwards.name/packer/
https://github.com/jcoglan/packr < = 루비 버전 로버트 하비에 의해 제기 된 문제가 어느 정도 사실 일 수 있지만, 여기에 대한 답변을 난독의 목록을 제공

+2

이것을 사용하여 난독 화 된 코드를 http://jsbeautifier.org/에 붙여 넣고 원본처럼 다시 작성하십시오. – trusktr

관련 문제