xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

js 禁用开发者工具、js 禁用打印 pdf All In One

js 禁用开发者工具、js 禁用打印 pdf All In One

difficulty: Medium / 难度: 中等

原理分析

js 检查浏览器是否打开了开发者工具, 重定向到 about:blank 空白页
js 检测键盘所有按键事件,销毁页面, 重定向到 about:blank 空白页

image

solutions

js forbidden download pdf
js check first, then decide whether fetch pdf resource
load pdf preview, or redirect to about:blank page
listen to key down event, redirect to about:blank page

const url = `https://cdn.xgqfrms.xyz/pdf.html`;

fetch(url)
  .then(function(res) {
    return res.text();
  })
  .then((content) => {
    let newWindow = window.open(``, '_blank');
    newWindow.document.write(content);
    newWindow.document.close();
  });

破解方法

  1. 使用反向代理工具 Charles,监听网络抓包,获取 js 和 真实的 pdf 请求 URL

image

console-ban v4.1.0

https://www.npmjs.com/package/console-ban/v/4.1.0

https://github.com/fz6m/console-ban 💩 删库跑路,npm 下载的 package 中没有提供源码

image

image

http://c.gb688.cn/bzgk/gb/viewGbImg?fileName=LtD10kkUv5fcSz%2B0onLko3ONnBTAH2e4aHP%2F1FxI9bM%3D

多个 PNG 片段拼接的 PDF 文件, 编码混淆 ❓

image

pdfViewer 使用 background-position 定位获取 PNG 文件中的 PDF 片段

<div id="viewerContainer" tabindex="0">
  <div id="viewer" class="pdfViewer">
  <div id="0" class="page" bg="viewGbImg?fileName=LtD10kkUv5fcSz%2B0onLko3ONnBTAH2e4aHP%2F1FxI9bM%3D" style="width:1191px;height:1684px;margin-left:-595.5px;">
        <span class="pdfImg-3-8" style="background-position: -360px -169px;"></span>
   ...
   </div>
  </div>
</div>

image

https://www.npmjs.com/package/pdfviewer
https://github.com/teambition/pdfviewer

https://github.com/mozilla/pdf.js

https://www.npmjs.com/package/pdf-viewer

  1. OBS 视频录屏

  2. Xnip 长网页截屏

demos

GB 15979-2024

http://c.gb688.cn/bzgk/gb/showGb?type=online&hcno=75F8AECE33CDEB23A59C06ECFC69A39F

  1. Charles 抓取页面所有请求内容

  2. 下载网页 HTML 代码;

  3. 对所有相对路径资源的 URL 补全域名
    image

  4. 删除无用js代码,注释掉 console-ban.js 代码

image

  1. 下载 pdf ❓
// 图片无法下载
print();

image

mozdisallowselectionprint

https://mozilla.github.io/pdf.js/

https://github.com/mozilla/pdf.js#online-demo

https://mozilla.github.io/pdf.js/web/viewer.html

https://mozilla.github.io/pdf.js/legacy/web/viewer.html

image

copy toolbarViewerRight DOM

<div id="toolbarViewerRight" class="toolbarHorizontalGroup">
                <div id="editorModeButtons" class="toolbarHorizontalGroup" role="radiogroup">
                  <div id="editorHighlight" class="toolbarButtonWithContainer">
                    <button id="editorHighlightButton" class="toolbarButton" type="button" title="高亮" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorHighlightParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-highlight-button">
                      <span data-l10n-id="pdfjs-editor-highlight-button-label">高亮</span>
                    </button>
                    <div class="editorParamsToolbar hidden doorHangerRight" id="editorHighlightParamsToolbar">
                      <div id="highlightParamsToolbarContainer" class="editorParamsToolbarContainer">
                        <div id="editorHighlightColorPicker" class="colorPicker">
                          <span id="highlightColorPickerLabel" class="editorParamsLabel" data-l10n-id="pdfjs-editor-highlight-colorpicker-label">高亮色</span>
                        <div class="dropdown" role="listbox" aria-multiselectable="false" aria-orientation="horizontal" data-l10n-id="pdfjs-editor-colorpicker-dropdown" aria-labelledby="highlightColorPickerLabel" aria-label="颜色选择"><button tabindex="0" role="option" data-color="#FFFF98" title="黄色" data-l10n-id="pdfjs-editor-colorpicker-yellow" aria-selected="true"><span class="swatch" style="background-color: rgb(255, 255, 152);"></span></button><button tabindex="0" role="option" data-color="#53FFBC" title="绿色" data-l10n-id="pdfjs-editor-colorpicker-green" aria-selected="false"><span class="swatch" style="background-color: rgb(83, 255, 188);"></span></button><button tabindex="0" role="option" data-color="#80EBFF" title="蓝色" data-l10n-id="pdfjs-editor-colorpicker-blue" aria-selected="false"><span class="swatch" style="background-color: rgb(128, 235, 255);"></span></button><button tabindex="0" role="option" data-color="#FFCBE6" title="粉色" data-l10n-id="pdfjs-editor-colorpicker-pink" aria-selected="false"><span class="swatch" style="background-color: rgb(255, 203, 230);"></span></button><button tabindex="0" role="option" data-color="#FF4F5F" title="红色" data-l10n-id="pdfjs-editor-colorpicker-red" aria-selected="false"><span class="swatch" style="background-color: rgb(255, 79, 95);"></span></button></div></div>
                        <div id="editorHighlightThickness">
                          <label for="editorFreeHighlightThickness" class="editorParamsLabel" data-l10n-id="pdfjs-editor-free-highlight-thickness-input">粗细</label>
                          <div class="thicknessPicker">
                            <input type="range" id="editorFreeHighlightThickness" class="editorParamsSlider" data-l10n-id="pdfjs-editor-free-highlight-thickness-title" value="12" min="8" max="24" step="1" tabindex="0" title="更改高亮粗细(用于文本以外项目)">
                          </div>
                        </div>
                        <div id="editorHighlightVisibility">
                          <div class="divider"></div>
                          <div class="toggler">
                            <label for="editorHighlightShowAll" class="editorParamsLabel" data-l10n-id="pdfjs-editor-highlight-show-all-button-label">显示全部</label>
                            <button id="editorHighlightShowAll" class="toggle-button" type="button" data-l10n-id="pdfjs-editor-highlight-show-all-button" aria-pressed="true" tabindex="0" title="显示全部"></button>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                  <div id="editorFreeText" class="toolbarButtonWithContainer">
                    <button id="editorFreeTextButton" class="toolbarButton" type="button" title="文本" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorFreeTextParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-free-text-button">
                      <span data-l10n-id="pdfjs-editor-free-text-button-label">文本</span>
                    </button>
                    <div class="editorParamsToolbar hidden doorHangerRight" id="editorFreeTextParamsToolbar">
                      <div class="editorParamsToolbarContainer">
                        <div class="editorParamsSetter">
                          <label for="editorFreeTextColor" class="editorParamsLabel" data-l10n-id="pdfjs-editor-free-text-color-input">颜色</label>
                          <input type="color" id="editorFreeTextColor" class="editorParamsColor" tabindex="0">
                        </div>
                        <div class="editorParamsSetter">
                          <label for="editorFreeTextFontSize" class="editorParamsLabel" data-l10n-id="pdfjs-editor-free-text-size-input">字号</label>
                          <input type="range" id="editorFreeTextFontSize" class="editorParamsSlider" value="10" min="5" max="100" step="1" tabindex="0">
                        </div>
                      </div>
                    </div>
                  </div>
                  <div id="editorInk" class="toolbarButtonWithContainer">
                    <button id="editorInkButton" class="toolbarButton" type="button" title="绘图" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorInkParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-ink-button">
                      <span data-l10n-id="pdfjs-editor-ink-button-label">绘图</span>
                    </button>
                    <div class="editorParamsToolbar hidden doorHangerRight" id="editorInkParamsToolbar">
                      <div class="editorParamsToolbarContainer">
                        <div class="editorParamsSetter">
                          <label for="editorInkColor" class="editorParamsLabel" data-l10n-id="pdfjs-editor-ink-color-input">颜色</label>
                          <input type="color" id="editorInkColor" class="editorParamsColor" tabindex="0">
                        </div>
                        <div class="editorParamsSetter">
                          <label for="editorInkThickness" class="editorParamsLabel" data-l10n-id="pdfjs-editor-ink-thickness-input">粗细</label>
                          <input type="range" id="editorInkThickness" class="editorParamsSlider" value="1" min="1" max="20" step="1" tabindex="0">
                        </div>
                        <div class="editorParamsSetter">
                          <label for="editorInkOpacity" class="editorParamsLabel" data-l10n-id="pdfjs-editor-ink-opacity-input">不透明度</label>
                          <input type="range" id="editorInkOpacity" class="editorParamsSlider" value="100" min="1" max="100" step="1" tabindex="0">
                        </div>
                      </div>
                    </div>
                  </div>
                  <div id="editorStamp" class="toolbarButtonWithContainer">
                    <button id="editorStampButton" class="toolbarButton" type="button" title="添加或编辑图像" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorStampParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-stamp-button">
                      <span data-l10n-id="pdfjs-editor-stamp-button-label">添加或编辑图像</span>
                    </button>
                    <div class="editorParamsToolbar hidden doorHangerRight menu" id="editorStampParamsToolbar">
                      <div class="menuContainer">
                        <button id="editorStampAddImage" class="toolbarButton labeled" type="button" title="添加图像" tabindex="0" data-l10n-id="pdfjs-editor-stamp-add-image-button">
                          <span class="editorParamsLabel" data-l10n-id="pdfjs-editor-stamp-add-image-button-label">添加图像</span>
                        </button>
                      </div>
                    </div>
                  </div>
                </div>

                <div id="editorModeSeparator" class="verticalToolbarSeparator"></div>

                <div class="toolbarHorizontalGroup hiddenMediumView">
                  <button id="printButton" class="toolbarButton" type="button" title="打印" tabindex="0" data-l10n-id="pdfjs-print-button">
                    <span data-l10n-id="pdfjs-print-button-label">打印</span>
                  </button>

                  <button id="downloadButton" class="toolbarButton" type="button" title="保存" tabindex="0" data-l10n-id="pdfjs-save-button">
                    <span data-l10n-id="pdfjs-save-button-label">保存</span>
                  </button>
                </div>

                <div class="verticalToolbarSeparator hiddenMediumView"></div>

                <div id="secondaryToolbarToggle" class="toolbarButtonWithContainer">
                  <button id="secondaryToolbarToggleButton" class="toolbarButton" type="button" title="工具" tabindex="0" data-l10n-id="pdfjs-tools-button" aria-expanded="false" aria-haspopup="true" aria-controls="secondaryToolbar">
                    <span data-l10n-id="pdfjs-tools-button-label">工具</span>
                  </button>
                  <div id="secondaryToolbar" class="doorHangerRight menu hidden">
                    <div id="secondaryToolbarButtonContainer" class="menuContainer">
                      <button id="secondaryOpenFile" class="toolbarButton labeled" type="button" title="打开文件" tabindex="0" data-l10n-id="pdfjs-open-file-button">
                        <span data-l10n-id="pdfjs-open-file-button-label">打开</span>
                      </button>

                      <div class="visibleMediumView">
                        <button id="secondaryPrint" class="toolbarButton labeled" type="button" title="打印" tabindex="0" data-l10n-id="pdfjs-print-button">
                          <span data-l10n-id="pdfjs-print-button-label">打印</span>
                        </button>

                        <button id="secondaryDownload" class="toolbarButton labeled" type="button" title="保存" tabindex="0" data-l10n-id="pdfjs-save-button">
                          <span data-l10n-id="pdfjs-save-button-label">保存</span>
                        </button>

                      </div>

                      <div class="horizontalToolbarSeparator"></div>

                      <button id="presentationMode" class="toolbarButton labeled" type="button" title="切换到演示模式" tabindex="0" data-l10n-id="pdfjs-presentation-mode-button">
                        <span data-l10n-id="pdfjs-presentation-mode-button-label">演示模式</span>
                      </button>

                      <a href="#page=1&amp;zoom=auto,-12,798" id="viewBookmark" class="toolbarButton labeled" title="当前页面(在当前页面查看 URL)" tabindex="0" data-l10n-id="pdfjs-bookmark-button">
                        <span data-l10n-id="pdfjs-bookmark-button-label">当前页面</span>
                      </a>

                      <div id="viewBookmarkSeparator" class="horizontalToolbarSeparator"></div>

                      <button id="firstPage" class="toolbarButton labeled" type="button" title="转到第一页" tabindex="0" data-l10n-id="pdfjs-first-page-button" disabled="">
                        <span data-l10n-id="pdfjs-first-page-button-label">转到第一页</span>
                      </button>
                      <button id="lastPage" class="toolbarButton labeled" type="button" title="转到最后一页" tabindex="0" data-l10n-id="pdfjs-last-page-button">
                        <span data-l10n-id="pdfjs-last-page-button-label">转到最后一页</span>
                      </button>

                      <div class="horizontalToolbarSeparator"></div>

                      <button id="pageRotateCw" class="toolbarButton labeled" type="button" title="顺时针旋转" tabindex="0" data-l10n-id="pdfjs-page-rotate-cw-button">
                        <span data-l10n-id="pdfjs-page-rotate-cw-button-label">顺时针旋转</span>
                      </button>
                      <button id="pageRotateCcw" class="toolbarButton labeled" type="button" title="逆时针旋转" tabindex="0" data-l10n-id="pdfjs-page-rotate-ccw-button">
                        <span data-l10n-id="pdfjs-page-rotate-ccw-button-label">逆时针旋转</span>
                      </button>

                      <div class="horizontalToolbarSeparator"></div>

                      <div id="cursorToolButtons" role="radiogroup">
                        <button id="cursorSelectTool" class="toolbarButton labeled toggled" type="button" title="启用文本选择工具" tabindex="0" data-l10n-id="pdfjs-cursor-text-select-tool-button" role="radio" aria-checked="true">
                          <span data-l10n-id="pdfjs-cursor-text-select-tool-button-label">文本选择工具</span>
                        </button>
                        <button id="cursorHandTool" class="toolbarButton labeled" type="button" title="启用手形工具" tabindex="0" data-l10n-id="pdfjs-cursor-hand-tool-button" role="radio" aria-checked="false">
                          <span data-l10n-id="pdfjs-cursor-hand-tool-button-label">手形工具</span>
                        </button>
                      </div>

                      <div class="horizontalToolbarSeparator"></div>

                      <div id="scrollModeButtons" role="radiogroup">
                        <button id="scrollPage" class="toolbarButton labeled" type="button" title="使用页面滚动" tabindex="0" data-l10n-id="pdfjs-scroll-page-button" role="radio" aria-checked="false">
                          <span data-l10n-id="pdfjs-scroll-page-button-label">页面滚动</span>
                        </button>
                        <button id="scrollVertical" class="toolbarButton labeled toggled" type="button" title="使用垂直滚动" tabindex="0" data-l10n-id="pdfjs-scroll-vertical-button" role="radio" aria-checked="true">
                          <span data-l10n-id="pdfjs-scroll-vertical-button-label">垂直滚动</span>
                        </button>
                        <button id="scrollHorizontal" class="toolbarButton labeled" type="button" title="使用水平滚动" tabindex="0" data-l10n-id="pdfjs-scroll-horizontal-button" role="radio" aria-checked="false">
                          <span data-l10n-id="pdfjs-scroll-horizontal-button-label">水平滚动</span>
                        </button>
                        <button id="scrollWrapped" class="toolbarButton labeled" type="button" title="使用平铺滚动" tabindex="0" data-l10n-id="pdfjs-scroll-wrapped-button" role="radio" aria-checked="false">
                          <span data-l10n-id="pdfjs-scroll-wrapped-button-label">平铺滚动</span>
                        </button>
                      </div>

                      <div class="horizontalToolbarSeparator"></div>

                      <div id="spreadModeButtons" role="radiogroup">
                        <button id="spreadNone" class="toolbarButton labeled toggled" type="button" title="不加入衔接页" tabindex="0" data-l10n-id="pdfjs-spread-none-button" role="radio" aria-checked="true">
                          <span data-l10n-id="pdfjs-spread-none-button-label">单页视图</span>
                        </button>
                        <button id="spreadOdd" class="toolbarButton labeled" type="button" title="加入衔接页使奇数页作为起始页" tabindex="0" data-l10n-id="pdfjs-spread-odd-button" role="radio" aria-checked="false">
                          <span data-l10n-id="pdfjs-spread-odd-button-label">双页视图</span>
                        </button>
                        <button id="spreadEven" class="toolbarButton labeled" type="button" title="加入衔接页使偶数页作为起始页" tabindex="0" data-l10n-id="pdfjs-spread-even-button" role="radio" aria-checked="false">
                          <span data-l10n-id="pdfjs-spread-even-button-label">书籍视图</span>
                        </button>
                      </div>

                      <div id="imageAltTextSettingsSeparator" class="horizontalToolbarSeparator hidden"></div>
                      <button id="imageAltTextSettings" type="button" class="toolbarButton labeled hidden" title="图像替换文字设置" tabindex="0" data-l10n-id="pdfjs-image-alt-text-settings-button" aria-controls="altTextSettingsDialog">
                        <span data-l10n-id="pdfjs-image-alt-text-settings-button-label">图像替换文字设置</span>
                      </button>

                      <div class="horizontalToolbarSeparator"></div>

                      <button id="documentProperties" class="toolbarButton labeled" type="button" title="文档属性…" tabindex="0" data-l10n-id="pdfjs-document-properties-button" aria-controls="documentPropertiesDialog">
                        <span data-l10n-id="pdfjs-document-properties-button-label">文档属性…</span>
                      </button>
                    </div>
                  </div>  <!-- secondaryToolbar -->
                </div>
              </div>

CSS bug ❌

image

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

js 禁用开发者工具

https://www.cnblogs.com/xgqfrms/p/10043804.html

https://www.cnblogs.com/xgqfrms/p/13833003.html

https://cnblogs.com/xgqfrms/p/15012221.html

refs

https://www.cnblogs.com/xgqfrms/p/18438239#:~:text=高端纸 ✅-,js 禁用开发者工具、js 禁用打印,-原理分析%3A



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2024-09-28 23:08  xgqfrms  阅读(40)  评论(5编辑  收藏  举报