programing

firefox 동일 출처 정책 비활성화

nasanasas 2020. 8. 15. 09:21
반응형

firefox 동일 출처 정책 비활성화


Firefox의 동일한 출처 정책을 해제해야하는 지역 조사 도구를 개발 중입니다 (스크립트 액세스 측면에서 저는 교차 도메인 요청에 대해 신경 쓰지 않습니다).

특히 호스트 도메인의 스크립트가 도메인에 관계없이 페이지에 포함 된 모든 iframe의 임의 요소에 액세스 할 수 있기를 바랍니다.

CORS FF 확장에 대해 언급 한 이전 Q & A를 알고 있지만 CORS 만 허용하고 스크립트 액세스는 허용하지 않기 때문에 필요하지 않습니다.

쉽게 수행 할 수 없다면 SOP를 비활성화하도록 수정할 수있는 FF src 코드의 특정 부분을 알려주는 통찰력을 통해 FF를 다시 컴파일 할 수 있습니다.


2015 년 3 월 5 일에 출시 된 최신 Firefox ( 빌드 36.0.1 ) 에서 작동하는 모든 HTTP 응답에 CORS 헤더를 추가하는 Firefox 확장 기능이 있습니다. 나는 그것을 테스트했고 Windows 7과 Mavericks 모두에서 작동하고 있습니다. 작동하도록 단계를 안내해 드리겠습니다.

1) 확장 받기

여기 (작성자 빌드) 또는 여기 (미러, 업데이트되지 않을 수 있음 ) 에서 xpi를 다운로드 할 수 있습니다 .

또는 GitHub 에서 파일다운로드하십시오 . 이제 Firefox Marketplace에도 있습니다 . 여기에서 다운로드하세요 . 이 경우 설치를 클릭하면 애드온이 설치되며 4 단계로 건너 뛸 수 있습니다.

xpi를 다운로드 한 경우 3 단계로 이동할 수 있습니다. GitHub에서 zip을 다운로드 한 경우 2 단계로 이동합니다.

2) xpi 빌드

압축을 풀고 "cors-everywhere-firefox-addon-master"폴더로 들어가 모든 항목을 선택하고 압축해야합니다. 그런 다음 생성 된 zip의 이름을 * .xpi로 바꿉니다.

참고 : OS X GUI를 사용하는 경우 일부 숨겨진 파일이 생성 될 수 있으므로 명령 줄을 사용하는 것이 좋습니다.

3) xpi 설치

xpi를 Firefox로 드래그 앤 드롭하거나 "about : addons"로 이동하여 오른쪽 상단 모서리에있는 톱니 바퀴를 클릭하고 "파일에서 추가 기능 설치"를 선택한 다음 .xpi 파일을 선택할 수 있습니다. 이제 firefox를 다시 시작하십시오.

4) 작동시키기

이제 확장 프로그램은 기본적으로 작동하지 않습니다. 확장 아이콘을 확장 표시 줄로 끌어 야하지만 걱정하지 마십시오. 사진이 있습니다!

  • Firefox 메뉴를 클릭하십시오
  • 사용자 정의를 클릭하십시오.

p1

  • CorsE를 막대로 드래그
  • Now, click on the icon, when it's green the CORS headers will be added to any HTTP response

p2

5) Testing if it's working

jQuery

$.get( "http://example.com/", function( data ) {
  console.log (data);
});

JavaScript

xmlhttp=new XMLHttpRequest();

xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4) {
        console.log(xmlhttp.responseText);
    }
}

xmlhttp.open("GET","http://example.com/");
xmlhttp.send();

6) Final considerations

Note that https to http is not allowed.

There may be a way around it, but it's behind the scope of the question.


about:config -> security.fileuri.strict_origin_policy -> false

I realized my older answer is downvoted because I didn't specify how to disable FF's same origin policy specifically. Here I will give a more detailed answer:

Warning: This requires a re-compilation of FF, and the newly compiled version of Firefox will not be able to enable SOP again.

Check out Mozilla's Firefox's source code, find nsScriptSecurityManager.cpp in the src directory. I will use the one listed here as example: http://mxr.mozilla.org/aviarybranch/source/caps/src/nsScriptSecurityManager.cpp

Go to the function implementation nsScriptSecurityManager::CheckSameOriginURI, which is line 568 as of date 03/02/2016.

Make that function always return NS_OK.

This will disable SOP for good.

The browser addon answer by @Giacomo should be useful for most people and I have accepted that answer, however, for my personal research needs (TL;won't explain here) it is not enough and I figure other researchers may need to do what I did here to fully kill SOP.


I wrote an add-on to overcome this issue in Firefox (Chrome, Opera version will have soon). It works with the latest Firefox version, with beautiful UI and support JS regex: https://addons.mozilla.org/en-US/firefox/addon/cross-domain-cors

여기에 이미지 설명 입력


As of September 2016 this addon is the best to disable CORS: https://github.com/fredericlb/Force-CORS/releases

In the options panel you can configure which header to inject and specific website to have it enabled automatically.

여기에 이미지 설명 입력


The cors-everywhere addon works for me until Firefox 68, after 68 I need to adjust 'privacy.file_unique_origin' -> false (by open 'about:config') to solve 'CORS request not HTTP' for new CORS same-origin rule introduced.

참고 URL : https://stackoverflow.com/questions/17088609/disable-firefox-same-origin-policy

반응형