Programing

웹 페이지에서 자바 스크립트 코드를 숨기려면 어떻게해야합니까?

lottogame 2020. 10. 7. 07:11
반응형

웹 페이지에서 자바 스크립트 코드를 숨기려면 어떻게해야합니까? [복제]


이 질문에 이미 답변이 있습니다.

브라우저의 소스보기 기능을 통해 소스 코드를 볼 때 웹 페이지의 HTML에서 Javascript 코드를 숨길 수 있습니까?

코드를 난독화할 수 있다는 것을 알고 있지만 소스보기 기능에서 숨겨 지는 것을 선호합니다 .


다른 사람이 실제로 브라우저의 소스보기 명령에서보고있는 코드 인 귀하의 질문을 직접 해결했는지 잘 모르겠습니다.

다른 사람들이 말했듯이 결정된 뷰어로부터 브라우저에서 실행되도록 의도 된 자바 스크립트를 보호 할 방법이 없습니다. 브라우저가 그것을 실행할 수 있다면, 결정된 사람은 또한 그것을 보거나 실행할 수 있습니다.

그러나 다음과 함께 포함 된 외부 자바 스크립트 파일에 자바 스크립트를 넣는 경우 :

<script type="text/javascript" src="http://mydomain.com/xxxx.js"></script>

태그를 사용하면 소스보기 명령으로 자바 스크립트 코드가 즉시 표시되지 않습니다. 스크립트 태그 자체 만 그런 식으로 표시됩니다. 이는 누군가가 외부 자바 스크립트 파일을로드하여 볼 수 없다는 것을 의미하지는 않지만, 브라우저의 소스보기 명령에서이 파일을 유지하는 방법을 물어 보았습니다.

소스를보기 위해 더 많은 작업을 수행하려면 다음을 모두 수행하십시오.

  1. 외부 .js 파일에 넣으십시오.
  2. 대부분의 기본 변수 이름이 짧은 버전으로 대체되도록 파일을 난독 화하여 불필요한 모든 공백을 제거하여 추가 처리 없이는 읽을 수 없도록합니다.
  3. Google Analytics처럼 스크립트 태그를 프로그래밍 방식으로 추가하여 .js 파일을 동적으로 포함합니다. 클릭 할 수있는 쉬운 링크가 없기 때문에 소스보기 명령에서 소스 코드를 얻는 것이 훨씬 더 어려워집니다.
  4. 로컬 처리를 수행하는 대신 ajax 호출을 통해 검색하는 서버에 보호하려는 많은 흥미로운 로직을 넣으십시오.

모든 말과 함께 성능, 안정성 및 앱을 훌륭하게 만드는 데 집중해야한다고 생각합니다. 어떤 알고리즘을 반드시 보호해야한다면 서버에 올려 놓으십시오. 그 외에는 비밀이 아닌 최선을 다해 경쟁하십시오. 이것이 궁극적으로 성공이 웹에서 작동하는 방식입니다.


아니요, 불가능합니다.

브라우저에 제공하지 않으면 브라우저에없는 것입니다.

그렇게한다면, 그것은 (또는 쉽게 따라갈 수있는 참조) 소스의 일부를 형성합니다.


Html Encrypter를 사용합니다.

<link rel="stylesheet" href="styles/css.css" type="text/css" media="screen" />
<script type="text/javascript" src="script/js.js" language="javascript"></script>

copy and paste it to HTML Encrypter and the Result will goes like this
and paste it the location where you cut the above sample

<Script Language='Javascript'>
<!-- HTML Encryption provided by iWEBTOOL.com -->
<!--
document.write(unescape('%3C%6C%69%6E%6B%20%72%65%6C%3D%22%73%74%79%6C%65%73%68%65%65%74%22%20%68%72%65%66%3D%22%73%74%79%6C%65%73%2F%63%73%73%2E%63%73%73%22%20%74%79%70%65%3D%22%74%65%78%74%2F%63%73%73%22%20%6D%65%64%69%61%3D%22%73%63%72%65%65%6E%22%20%2F%3E%0A%3C%73%63%72%69%70%74%20%74%79%70%65%3D%22%74%65%78%74%2F%6A%61%76%61%73%63%72%69%70%74%22%20%73%72%63%3D%22%73%63%72%69%70%74%2F%6A%73%2E%6A%73%22%20%6C%61%6E%67%75%61%67%65%3D%22%6A%61%76%61%73%63%72%69%70%74%22%3E%3C%2F%73%63%72%69%70%74%3E%0A'));
//-->

HTML ENCRYPTER 참고 : 페이지에 자바 스크립트가있는 경우 .js 파일로 내보내고 위의 예와 같이 만드십시오.

또한이 암호화 기는 웹 사이트를 엉망으로 만드는 일부 코드에서 항상 작동하지 않습니다. 예를 들어 숨길 가장 좋은 부분을 선택하십시오. <form> </form>

이것은 고급 사용자가 되돌릴 수 있지만 나와 같은 모든 멍청이가 그것을 아는 것은 아닙니다.

이것이 도움이되기를 바랍니다.


내 솔루션은 마지막 댓글에서 영감을 얻었습니다. 이것은 invisible.html의 코드입니다.

<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript" src="invisible_debut.js" ></script>
<body>
</body>

invisible_debut.js의 명확한 코드는 다음과 같습니다.

$(document).ready(function () {
var ga = document.createElement("script"); //ga is to remember Google Analytics ;-)
ga.type = 'text/javascript';
ga.src = 'invisible.js';
ga.id = 'invisible';
document.body.appendChild(ga);
$('#invisible').remove();});

마지막에 생성 된 스크립트를 제거합니다. invisible.js는 다음과 같습니다.

$(document).ready(function(){
    alert('try to find in the source the js script which did this alert!');
    document.write('It disappeared, my dear!');});

invisible.js는 제거되었고 자바 스크립트에 의해 생성 되었기 때문에 소스 코드에 없었기 때문에 콘솔에 나타나지 않습니다.

invisible_debut.js와 관련하여 나는 그것을 난독 화했습니다. 즉, invisible.js의 URL을 찾는 것이 매우 복잡하다는 것을 의미합니다. 완벽하지는 않지만 일반 해커에게는 충분히 어렵습니다.


'불가능하다!'

아, 그래 ....

//------------------------------
function unloadJS(scriptName) {
  var head = document.getElementsByTagName('head').item(0);
  var js = document.getElementById(scriptName);
  js.parentNode.removeChild(js);
}


//----------------------
function unloadAllJS() {
  var jsArray = new Array();
  jsArray = document.getElementsByTagName('script');
  for (i = 0; i < jsArray.length; i++){
    if (jsArray[i].id){
      unloadJS(jsArray[i].id)
    }else{
      jsArray[i].parentNode.removeChild(jsArray[i]);
    }
  }      
}

그 정보를 숨길 방법이 있는지 모르겠습니다. 자바 스크립트에서 무엇을하든 난독 화하거나 숨기려고 무엇을하든, 브라우저는 그것을 사용하기 위해 그것을로드해야한다는 사실로 귀결됩니다. 최신 브라우저에는 스크립트 추출 및보기를 간단하게 만드는 웹 디버깅 / 분석 도구가 있습니다 ( F12예 : Chrome에서 누르기 만하면 됨 ).

어떤 종류의 영업 비밀이나 알고리즘을 노출하는 것이 걱정된다면 웹 서비스 호출에 해당 로직을 캡슐화하고 페이지가 AJAX를 통해 해당 기능을 호출하도록하는 것이 유일한 방법입니다.


I think I found a solution to hide certain JavaScript codes in the view source of the browser. But you have to use jQuery to do this.

For example:

In your index.php

<head>
<script language = 'javascript' src = 'jquery.js'></script>
<script language = 'javascript' src = 'js.js'></script>
</head>

<body>
<a href = "javascript:void(null)" onclick = "loaddiv()">Click me.</a>

<div id = "content">
</div>

</body>

You load a file in the html/php body called by a jquery function in the js.js file.

js.js

function loaddiv()
{$('#content').load('content.php');}

Here's the trick.

In your content.php file put another head tag then call another js file from there.

content.php

<head>
<script language = 'javascript' src = 'js2.js'></script>
</head>

<a href = "javascript:void(null)" onclick = "loaddiv2()">Click me too.</a>

<div id = "content2">
</div>

in the js2.js file create any function you want.

example:

js2.js

function loaddiv2()
{$('#content2').load('content2.php');}

content2.php

<?php
echo "Test 2";
?>

Please follow link then copy paste it in the filename of jquery.js

http://dl.dropbox.com/u/36557803/jquery.js

I hope this helps.


You could use document.write.

Without jQuery

<!DOCTYPE html>
<html>
<head><meta charset=utf-8></head>
<body onload="document.write('<!doctype html><html><head><meta charset=utf-8></head><body><p>You cannot find this in the page source. (Your page needs to be in this document.write argument.)</p></body></html>');">
</body></html>

Or with jQuery

$(function () {
  document.write("<!doctype html><html><head><meta charset=utf-8></head><body><p>You cannot find this in the page source. (Your page needs to be in this document.write argument.)</p></body></html>")
});

Is not possbile!

The only way is to obfuscate javascript or minify your javascript which makes it hard for the end user to reverse engineer. however its not impossible to reverse engineer.

참고URL : https://stackoverflow.com/questions/6869312/how-do-i-hide-javascript-code-in-a-webpage

반응형