返回列表 发帖
写了个粗糙的
#ANSI编码&cls&powershell -Version 5.1 -NoLogo -NoProfile "gc '%~0'|out-string|iex"&pause&exit
dir -Directory | %{
    $n = (dir ($_.Name + '.*'))[0]
    $f = gc -Encoding UTF8 $n | Out-String
    cd $_
    if ($f -match 'UniqueCode="(.*?)"') {
        ..\7za.exe a ..\tmp.zip ('-p' + $Matches[1]) * | Out-Null
    } else {
        ..\7za.exe a ..\tmp.zip * | Out-Null
    }
    cd ..
    $b = [System.Convert]::ToBase64String((gc .\tmp.zip -Encoding Byte -Raw))
    $utf8NoBom = New-Object System.Text.UTF8Encoding($false)
    [System.IO.File]::WriteAllText($n, ($f -replace 'Value=""', ('Value="{0}"' -f $b)), $utf8NoBom)
    rm .\tmp.zip
}COPY

TOP

回复 9# 304802301


    把../7za.exe改成字符串以后,需要在开头加上&
& "c:\xxx\7za.exe" a ...COPY
另外,压缩率或其他地方不一样,生成的base6就不一样

TOP

#ANSI编码&cls&powershell -Version 5.1 -NoLogo -NoProfile -Command "gc -Encoding Oem -ReadCount 0 -LiteralPath '%~f0'|out-string|iex"&pause&exit/b
dir -Directory | %{
    $n = (dir -File ($_.Name + '.*'))[0]
    $f = gc -Encoding UTF8 -Raw $n
    cd $_
    if ($f -match 'UniqueCode="(.*?)"') {
        $p = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Matches[1]))
        & "D:\7za.exe" a ..\tmp.zip ('-p' + $p) * | Out-Null
    } else {
        & "D:\7za.exe" a ..\tmp.zip * | Out-Null
    }
    cd ..
    $b = [System.Convert]::ToBase64String((gc .\tmp.zip -Encoding Byte -Raw))
    $utf8NoBom = New-Object System.Text.UTF8Encoding($false)
    [System.IO.File]::WriteAllText($n, ($f -replace 'Value=""', ('Value="{0}"' -f $b)), $utf8NoBom)
    rm .\tmp.zip
}COPY
楼上大佬写的更好,我抄了一点 ,密码改用了解码后的

TOP

返回列表