Last active
November 6, 2016 00:22
-
-
Save gcch/692a5166c9c0fa47f08b0c50a06b2872 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Product Key Retriver (before Office 2007, not after Office 2010) | |
' | |
' customized by tag | |
' | |
' ● 使い方 | |
' [1] レジストリから DigitalProductID を抽出してください。 | |
' 【 「レジストリ エディター」の場合 (Windows が正常に起動する場合) 】 | |
' (1) 「レジストリ エディター」を起動してください。 | |
' キーボードで「Windows キー + R」を押し、「regedit」と入力して [OK] を選択すると立ち上がります。 | |
' (2) DigitalProductID の保存されている場所を開いてください。 | |
' (3) キーをエクスポートしてください。 | |
' [ファイル(F)] -> [エクスポート(E)...] でエクスポートできます。 | |
' 【 「MiTeC Windows Registry File Viewer」の場合 (Windows が正常に起動しない場合) 】 | |
' (1) 「MiTeC Windows Registry File Viewer」を起動してください。 | |
' 起動時にエラーが発生する場合には、「RFV.exe」を右クリックし、[プロパティ]をクリック。 | |
' 「互換性」タブ内の「互換モードでこのプログラムを実行する」にチェックを入れ、 | |
' コンボボックスで「Windows XP (Service Pack 3)」を選択してください。 | |
' (2) DigitalProductID が格納されているレジストリが保存されているファイルを開きます。 | |
' 場所: "C:\Windows\System32\config\SOFTWARE" (C: がシステムドライブの場合) | |
' (3) DigitalProductID の保存されている場所を開いてください。 | |
' (4) キーをエクスポートしてください。 | |
' [File] -> [Export to REGEDIT4 format...] でエクスポートできます。 | |
' [2] 保存したファイルを適当なテキストエディタで開き、「"DigitalProductID"=hex:」に続く部分をコピーしてください。 | |
' [3] コピーしたデータをテキストとして保存してください。 | |
' その際、この VBS ファイルと同じ場所に「DPID.txt」というファイル名で保存してください。 | |
' [4] 変換対象の DigitalProductoID に合わせて、この VBS ファイル内の変数「Offset」を変更してください。 | |
' [5] この VBS ファイルを実行してください。プロダクトキーが表示されます。 | |
' | |
' | |
' ● DigitalProductID の場所 | |
' 32bit OS 上の Office 2007 (32bit): HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Registration\{90120000-0030-0000-0000-0000000FF1CE} | |
' 64bit OS 上の Office 2007 (32bit): HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office\12.0\Registration\{90120000-0030-0000-0000-0000000FF1CE} | |
Option Explicit | |
'================================================== | |
''' 変数群 | |
Dim Fso | |
Set Fso = CreateObject("Scripting.FileSystemObject") | |
'入力ファイル | |
Dim File, FileData | |
'DigitalProductID 格納用 | |
Dim DPID | |
'DigitalProductID (16進数) の文字長 | |
Dim HexDPIDLen | |
HexDPIDLen = 15 | |
ReDim ExHexDPID(HexDPIDLen - 1) | |
'DigitalProductID 内オフセット | |
' - Windows, Office 2003, 2007 -> 52 | |
' - Office 2010 -> 808 | |
Dim Offset | |
Offset = 808 'デコードしたい DPID によって変更が必要 | |
'ループ用変数 | |
Dim i, j, k | |
'プロダクトキー (出力結果) | |
Dim ProductKey | |
'プロダクトキーに使われる文字 | |
Dim DigitsArray | |
DigitsArray = Array("B", "C", "D", "F", "G", "H", "J", "K", "M", "P", "Q", "R", "T", "V", "W", "X", "Y", "2", "3", "4", "6", "7", "8", "9") | |
'================================================== | |
Dim Res | |
Res = MsgBox("キーの復元を開始します。この VBS ファイルと同じ場所に DigitalProductID が格納された DPID.txt を配置してください。", vbOKCancel, "Product Key Retriver") | |
Select Case Res | |
Case vbOK | |
'続行 | |
Case vbCancel | |
WScript.Quit | |
Case Else | |
WScript.Quit | |
End Select | |
'ファイルオープン | |
If Fso.FileExists("DPID.txt") = True Then | |
Set File = Fso.OpenTextFile("DPID.txt") | |
Else | |
Res = MsgBox("ファイル DPID.txt が見つかりません。終了します。", vbOKOnly, "Product Key Retriver") | |
WScript.Quit | |
End If | |
'置換 (「レジストリ エディター」で書きだした場合、いらない文字が入るので消す。) | |
FileData = File.ReadAll | |
File.Close | |
FileData = Replace(FileData, "\", "") | |
FileData = Replace(FileData, vbCrLf, "") | |
FileData = Replace(FileData, " ", "") | |
'書き出し (しなくてもいいけど、一応。) | |
Set File = Fso.CreateTextFile("DPID.txt") | |
File.Write(FileData) | |
File.Close | |
'DigitalProductID を格納 | |
DPID = Split(FileData, ",") | |
'必要データ抽出&16進数化 (&H を付加) | |
For i = 0 To (HexDPIDLen - 1) Step 1 | |
ReDim Preserve ExHexDPID( UBound(ExHexDPID) + 1 ) | |
ExHexDPID(i) = "&H" & DPID(i + Offset) | |
Next | |
'変換 | |
For i = 24 To 0 Step -1 | |
k = 0 | |
For j = (HexDPIDLen - 1) To 0 Step -1 | |
k = k * 256 Xor ExHexDPID(j) | |
ExHexDPID(j) = Int(k / 24) | |
k = k Mod 24 | |
Next | |
ProductKey = DigitsArray(k) & ProductKey | |
If i Mod 5 = 0 And i <> 0 Then | |
ProductKey = "-" & ProductKey | |
End If | |
Next | |
' 復元結果の書き出し | |
Set File = Fso.CreateTextFile("PK.txt") | |
File.Write(ProductKey) | |
File.Close | |
' 復元結果の表示 | |
Res = MsgBox("PK.txt に書き出しました。", vbOKOnly, "Product Key Retriver") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment