致訪客
此處多為站主的學習隨筆,
以及生活中的一些點滴。
內容隨興,不嚴謹,甚至有些奇怪的喃喃。
如果有那麼一點東西,
能幫助到您,或是能引起您的共鳴,那都是本站榮幸。
如果您能留下建議或迴響那更是再好不過了。
期待與各位心靈、思維交會的瞬間。

因為裝了 UpNext extension ( from github) , 所以出現了這個提示。

實在很惱人,在看了低調一點的辦法後,發現我根本沒有 gpedit.msc 啊~

(因為我是 notebook windows 10 , 好像要 windows 專業版 才有這個功能)

但,深深被 geek 精神影響的我,內心其實也微微的排斥這種方法的,太 win 的方式不適合我 (被踢

既然插件是從很 geek 的 github 載下來的,解決方法也要很 geek 的從 stackoverflow 找啊 (其實是 google 找到的

不過試著用英文搜尋看看真的很重要,不要被中文思維所局限了,所謂視野開闊,就從英文搜尋開始~

so 上的 hacker 果然厲害,直接從 dll 下手,而且還是用 bat 檔改,恩,更新日期還很新(Jan 14, 2017),太棒了。(傳送門 戳我)

沒有摸過 bat , 只有摸過 linux 的 script , bat 也是看懂了一些,這位仁兄似乎是直接開檔改一些值,太狂啦~

講一下步驟

  1. Save the code below to DevWarningPatch.bat somewhere
    (on the Desktop, for example or in the folder with chrome.dll)
    將下列 code 存成 DevWarningPatch.bat (注意副檔名)。
    不會改副檔名自己找辦法(有些人可以直接用重新命名改),或用記事本存 .txt 再右鍵進內容改。
    儲存的位置不限,可以是桌面,或是 chrome 的系統夾。
    我才不會說 geeker 都是用 vim 呢 ( 謎 : geeker 才不用 windows )
    註:其實檔名沒那麼重要,但,尊重作者。
  2. Exit Chrome.
    Or let the script close it including its hidden background processes.
    關閉 chrome , (可以直接關閉他,或讓 script 關閉他) ,包含 chrome 在背景運作的程序都要關閉。
    ( 這,我就直接右上角按 x 而已)
     
  3. Rightclick the batch file and run it as administrator: it will find & patch all applicable chrome.dll
    Alternatively you can drag'n'drop chrome.dll onto the batch file
    右鍵點擊 bat 檔,並以系統管理員身分執行,他就會為 dll 上 patch ,
    或者你可以將 chrome.dll 拖曳到這個 bat 檔上。

完成提示圖

 


以下 bat 僅為參考,最新更新以 so 為主。( the bat file here )

<# :
@echo off
copy/b "%~f0" "%temp%\%~n0.ps1" >nul
powershell -Version 2 -ExecutionPolicy bypass -noprofile "%temp%\%~n0.ps1" "%cd% " "%~1"
del "%temp%\%~n0.ps1"
pause
exit /b
#>
param([string]$cwd='.', [string]$dll)

function main {
    "Chrome 'developer mode extensions' warning disabler v1.0.10.20170114`n"
    $pathsDone = @{}
    if ($dll -and (gi -literal $dll)) {
        doPatch "DRAG'n'DROPPED" ((gi -literal $dll).directoryName + '\')
        exit
    }
    doPatch CURRENT ((gi -literal $cwd).fullName + '\')
    ('HKLM', 'HKCU') | %{ $hive = $_
        ('', '\Wow6432Node') | %{
            $key = "${hive}:\SOFTWARE$_\Google\Update\Clients"
            gci -ea silentlycontinue $key -r | gp | ?{ $_.CommandLine } | %{
                $path = $_.CommandLine -replace '"(.+?\\\d+\.\d+\.\d+\.\d+\\).+', '$1'
                doPatch REGISTRY $path
            }
        }
    }
}

function doPatch([string]$pathLabel, [string]$path) {
    if ($pathsDone[$path.toLower()]) { return }

    $dll = $path + "chrome.dll"
    if (!(test-path -literal $dll)) {
        return
    }
    "======================="
    "$pathLabel PATH $((gi -literal $dll).DirectoryName)"

    "`tREADING Chrome.dll..."
    $bytes = [IO.File]::ReadAllBytes($dll)

    # process PE headers
    $BC = [BitConverter]
    $coff = $BC::ToUInt32($bytes,0x3C) + 4
    $is64 = $BC::ToUInt16($bytes,$coff) -eq 0x8664
    $opthdr = $coff+20
    $codesize = $BC::ToUInt32($bytes,$opthdr+4)
    $imagebase32 = $BC::ToUInt32($bytes,$opthdr+28)

    # patch the flag in data section
    $data = $BC::ToString($bytes,$codesize)
    $flag = "ExtensionDeveloperModeWarning"
    $stroffs = $data.IndexOf($BC::ToString($flag[1..99]))/3 - 1
    if ($stroffs -lt 0) {
        write-host -f red "`t$flag not found"
        return
    }
    $stroffs += $codesize
    if ($bytes[$stroffs] -eq 0) {
        write-host -f darkgreen "`tALREADY PATCHED"
        return
    }

    $exe = join-path (split-path $path) chrome.exe
    $EA = $ErrorActionPreference
    $ErrorActionPreference = 'silentlyContinue'
    while ((get-process chrome -module | ?{ $_.FileName -eq $exe })) {
        forEach ($timeout in 15..0) {
            write-host -n -b yellow -f black `
                "`rChrome is running and will be terminated in $timeout sec. "
            write-host -n -b yellow -f darkyellow "Press ENTER to do it now. "
            if ([console]::KeyAvailable) {
                $key = $Host.UI.RawUI.ReadKey("AllowCtrlC,IncludeKeyDown,NoEcho")
                if ($key.virtualKeyCode -eq 13) { break }
                if ($key.virtualKeyCode -eq 27) { write-host; exit }
            }
            sleep 1
        }
        write-host
        get-process chrome | ?{
            $_.MainWindowHandle.toInt64() -and ($_ | gps -file).FileName -eq $exe
        } | %{
            "`tTrying to exit gracefully..."
            if ($_.CloseMainWindow()) {
                sleep 1
            }
        }
        $killLabelShown = 0
        get-process chrome | ?{
            ($_ | gps -file | select -expand FileName) -eq $exe
        } | %{
            if (!$killLabelShown++) {
                "`tTerminating background chrome processes..."
            }
            stop-process $_ -force
        }
        sleep -milliseconds 200
    }
    $ErrorActionPreference = $EA

    $bytes[$stroffs] = 0
    "`tPATCHED $flag flag"

    # patch the channel restriction code for stable/beta
    $code = $BC::ToString($bytes,0,$codesize)
    $rxChannel = '83-F8-(?:03-7D|02-7F)'
    # old code: cmp eax,3; jge ...
    # new code: cmp eax,2; jg ...
    $chanpos = 0
    try {
        if ($is64) {
            $pos = 0
            $rx = [regex]"$rxChannel-.{1,100}-48-8D"
            do {
                $m = $rx.match($code,$pos)
                if (!$m.success) { break }
                $chanpos = $m.index/3 + 2
                $pos = $m.index + $m.length + 1
                $offs = $BC::ToUInt32($bytes,$pos/3+1)
                $diff = $pos/3+5+$offs - $stroffs
            } until ($diff -ge 0 -and $diff -le 4096 -and $diff % 256 -eq 0)
            if (!$m.success) {
                $rx = [regex]"84-C0.{18,48}($rxChannel)-.{30,60}84-C0"
                $m = $rx.matches($code)
                if ($m.count -ne 1) { throw }
                $chanpos = $m[0].groups[1].index/3 + 2
            }
        } else {
            $flagOffs = [uint32]$stroffs + [uint32]$imagebase32
            $flagOffsStr = $BC::ToString($BC::GetBytes($flagOffs))
            $variants = "(?<channel>$rxChannel-.{1,100})-68-(?<flag>`$1-.{6}`$2)",
                    "68-(?<flag>`$1-.{6}`$2).{300,500}E8.{12,32}(?<channel>$rxChannel)",
                    "E8.{12,32}(?<channel>$rxChannel).{300,500}68-(?<flag>`$1-.{6}`$2)"
            forEach ($variant in $variants) {
                $pattern = $flagOffsStr -replace '^(..)-.{6}(..)', $variant
                "`tLooking for $($pattern -replace '\?<.+?>', '')..."
                $minDiff = 65536
                foreach ($m in [regex]::matches($code, $pattern)) {
                    $maybeFlagOffs = $BC::toUInt32($bytes, $m.groups['flag'].index/3)
                    $diff = [Math]::abs($maybeFlagOffs - $flagOffs)
                    if ($diff % 256 -eq 0 -and $diff -lt $minDiff) {
                        $minDiff = $diff
                        $chanpos = $m.groups['channel'].index/3 + 2
                    }
                }
            }
            if (!$chanpos) { throw }
        }
    } catch {
        write-host -f red "`tUnable to find the channel code, try updating me"
        write-host -f red "`thttp://stackoverflow.com/a/30361260"
        return
    }
    $bytes[$chanpos] = 9
    "`tPATCHED Chrome release channel restriction"

    "`tWriting to a temporary dll..."
    [IO.File]::WriteAllBytes("$dll.new",$bytes)

    "`tBacking up the original dll..."
    move -literal $dll "$dll.bak" -force

    "`tRenaming the temporary dll as the original dll..."
    move -literal "$dll.new" $dll -force

    $pathsDone[$path.toLower()] = $true
    write-host -f green "`tDONE.`n"
    [GC]::Collect()
}

main
創作者介紹
創作者 nobodyzxc 的頭像
nobodyzxc

Nobody's Zero

nobodyzxc 發表在 痞客邦 留言(1) 人氣()


留言列表 (1)

發表留言
  • 訪客
  • 感謝翻譯

您尚未登入,將以訪客身份留言。亦可以上方服務帳號登入留言

請輸入暱稱 ( 最多顯示 6 個中文字元 )

請輸入標題 ( 最多顯示 9 個中文字元 )

請輸入內容 ( 最多 140 個中文字元 )

請輸入左方認證碼:

看不懂,換張圖

請輸入驗證碼