001.
<?
002.
if
(
$_POST
[
'target'
] !=
''
) {
003.
$rep
= trim(
str_replace
(
"\\\\","
\\",
$_POST
[
'target'
]));
004.
setcookie(
"reg"
,
$rep
, time()+3600*24*30);
005.
006.
header(
"Content-Type: application/octet-stream"
);
007.
header(
"Content-disposition: attachment; filename=regopen_"
. uniqid() .
".vbs"
);
008.
header(
"pragma: no-cache"
);
009.
header(
"Expires: Wed, 31 May 2000 14:59:58 GMT"
);
010.
header(
"Cache-control: no-cache"
);
011.
012.
foreach
(
$_GET
as
$Key
=>
$Value
) {
013.
$_POST
[
$Key
] =
$_GET
[
$Key
];
014.
}
015.
foreach
(
$_POST
as
$Key
=>
$Value
) {
016.
$_POST
[
$Key
] =
str_replace
(
"\\\\", "
\\",
$Value
);
017.
$_POST
[
$Key
] =
str_replace
(
"\\'"
,
"'"
,
$_POST
[
$Key
] );
018.
$_POST
[
$Key
] =
str_replace
(
"\\\""
,
"\""
,
$_POST
[
$Key
] );
019.
}
020.
021.
022.
$vbs
= <<<EOD
023.
strParam =
"{$rep}"
024.
025.
' レジストリ書き込み用
026.
Set WshShell = CreateObject(
"WScript.Shell"
)
027.
' WMI用
028.
Set objWMIService = GetObject(
"winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2"
)
029.
030.
' レジストリエディタが最後に開いていたキーの登録を行います
031.
strPath =
"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\LastKey"
032.
if
GetOSVersion() >= 6 then
033.
strRegPath =
"コンピュータ\\"
& strParam
034.
else
035.
strRegPath =
"マイ コンピュータ\\"
& strParam
036.
end
if
037.
038.
' 既に regedit が実行中の場合はいったん終了させます
039.
Set colProcessList = objWMIService.ExecQuery _
040.
(
"Select * from Win32_Process Where Name = 'regedit.exe'"
)
041.
For Each objProcess in colProcessList
042.
' 最後のウインドウの位置とサイズを保存する為の終わらせ方
043.
WshShell.AppActivate(
"レジストリ エディタ"
)
044.
Wscript.Sleep(500)
045.
WshShell.SendKeys (
"%{F4}"
)
046.
Wscript.Sleep(500)
047.
' 上記終わらせ方が失敗した時の強制終了
048.
on error resume next
049.
objProcess.Terminate()
050.
on error goto 0
051.
Next
052.
053.
WshShell.RegWrite
"HKCU\" & strPath, strRegPath, "
REG_SZ"
054.
055.
' レジストリエディタを起動します
056.
Call WshShell.Run(
"regedit.exe"
)
057.
' レジストリエディタが終わるまで待つ場合は以下のようにします
058.
' Call WshShell.Run(
"regedit.exe"
, , True )
059.
060.
REM **********************************************************
061.
REM OS バージョンの取得
062.
REM **********************************************************
063.
Function GetOSVersion()
064.
065.
Dim colTarget,str,aData,I,nTarget
066.
067.
Set colTarget = objWMIService.ExecQuery( _
068.
"select Version from Win32_OperatingSystem"
_
069.
)
070.
For Each objRow in colTarget
071.
str = objRow.Version
072.
Next
073.
074.
aData = Split( str,
"."
)
075.
For I = 0 to Ubound( aData )
076.
if
I > 1 then
077.
Exit
For
078.
end
if
079.
if
I > 0 then
080.
nTarget = nTarget &
"."
081.
end
if
082.
nTarget = nTarget & aData(I)
083.
Next
084.
085.
GetOSVersion = CDbl( nTarget )
086.
087.
End
Function
088.
089.
EOD;
090.
091.
print
str_replace
(
"\n"
,
"\r\n"
,
$vbs
);
092.
093.
}
094.
else
{
095.
header(
"Content-Type: text/html"
);
096.
$_COOKIE
[
'reg'
] = trim(
str_replace
(
"\\\\","
\\",
$_COOKIE
[
'reg'
]));
097.
?>
098.
<HTML>
099.
<HEAD>
100.
<META http-equiv=
"Content-type"
content=
"text/html; charset=shift_jis"
/>
101.
<TITLE>指定した位置でレジストリエディタを開く為のスクリプトをダウンロード</TITLE>
102.
<STYLE type=
"text/css"
>
103.
BODY {
104.
margin: 0;
105.
font-size: 12px;
106.
}
107.
108.
h1 {
109.
font-size: 13px;
110.
border-style: solid;
111.
border-width: 1px;
112.
border-color: #9192A3;
113.
padding: 7px 0px 8px 13px;
114.
background: url(http:
115.
}
116.
117.
span {
118.
color: #000000;
119.
}
120.
121.
</STYLE>
122.
</HEAD>
123.
<BODY>
124.
<FORM
125.
method=
"POST"
126.
>
127.
<H1>指定した位置でレジストリエディタを開く為のスクリプトをダウンロードします</H1>
128.
<div style=
'margin-top:-10px;padding-left:8px;'
>
129.
<INPUT
130.
id=
"reg"
131.
type=
"text"
132.
name=
"target"
133.
style=
'width:600px;'
134.
value=
"<?= $_COOKIE['reg'] ?>"
135.
>
136.
<INPUT
137.
type=
"submit"
138.
name=
"send"
139.
value=
"送信"
140.
>
141.
<br><br>
142.
例: <INPUT
143.
type=
"button"
value=
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft"
144.
onClick=
'document.getElementById("reg").value=this.value'
145.
style=
'width:300px;vertical-align:middle'
146.
>
147.
148.
<script type=
"text/javascript"
>
149.
if
(window.navigator.userAgent.toLowerCase().indexOf(
"msie"
) > -1) {
150.
var
str=
""
;
151.
str+=
"<INPUT style='vertical-align:middle' type=button value=\"IE専用貼り付けボタン\" onClick='document.getElementById(\"reg\").value=clipboardData.getData(\"Text\")'> "
;
152.
document.write( str );
153.
}
154.
</script>
155.
<br>
156.
<span>( クリップボードから貼り付けるのが通常です )</span><br>
157.
</div>
158.
</FORM>
159.
160.
</BODY>
161.
</HTML>
162.
163.
<? } ?>