信頼してレジストリエディタを開くページ

  regopen.php



WEB サイトのレジストリについて説明されているページでは、レジストリのパスが書かれてあったりしますが、
その場所を実際にレジストリエディタで開くのは時間がかかりすぎるので、自分のサイトに置いて、保存せずに
そのまま実行します( IE 以外はいったんダウンロードします )

↓ダウンロードで試して、自分のサイトに実装して試してみると良いでしょう




ブラウザでダウンロード

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://winofsql.jp/image/h1.png) repeat-x 0px 0px;
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.<? } ?>






  古いコード



ダウンロード用のファイルをサーバー側に一時的に作成して、後のアクセスで
一定時間経過したファイルを削除していました。

クライアント側のこのコードでは、Windows7( Vista ) で動作しません

001.<?
002.if ( $_POST['target'] != '' ) {
003.    session_start();
004.    $rep = trim(str_replace("\\\\","\\", $_POST['target']));
005.    setcookie("reg", $rep, time()+3600*24*30);
006.    $str = <<<VBS
007.Set WshShell = Wscript.CreateObject( "WScript.Shell" )
008.strPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\LastKey"
009.strRegPath = "マイ コンピュータ\\$rep"
010.WshShell.RegWrite "HKCU\\" & strPath, strRegPath, "REG_SZ"
011. 
012.Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2")
013.Set colProcessList = objWMIService.ExecQuery _
014.    ("Select * from Win32_Process Where Name = 'regedit.exe'")
015.For Each objProcess in colProcessList
016.    objProcess.Terminate()
017.Next
018. 
019.Call WshShell.Run( "regedit", , True )
020.VBS;
021.$flname = "regopen" . session_id() . ".vbs";
022.file_put_contents($flname,$str);
023.header( "Location: $flname" );
024.}
025.else {
026.    header( "Content-Type: text/html" );
027.    $_COOKIE['reg'] = trim(str_replace("\\\\","\\", $_COOKIE['reg']));
028.?>
029.<HTML>
030.<HEAD>
031.<META http-equiv="Content-type" content="text/html; charset=shift_jis" />
032.<TITLE>指定した位置でレジストリエディタを開く為のスクリプトをダウンロード</TITLE>
033.<STYLE type="text/css">
034.BODY {
035.    font-size: 12px;
036.}
037.</STYLE>
038.</HEAD>
039.<BODY>
040.<FORM
041.    method="POST"
042.>
043.● 指定した位置でレジストリエディタを開く為のスクリプトをダウンロードします<br>
044.  レジストリのパスを入力してください。<br>
045.  例: <INPUT
046. type="button" value="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft"
047. onClick='document.getElementById("reg").value=this.value'
048. style='width:300px;vertical-align:middle'
049.><br>
050.  ( クリップボードから貼り付けるのが通常です )<br>
051.    <INPUT
052.        id="reg"
053.        type="text"
054.        name="target"
055.        style='width:400px;'
056.        value="<?= $_COOKIE['reg'] ?>"
057.    >
058.    <INPUT
059.        type="submit"
060.        name="send"
061.        value="送信"
062.    >
063.</FORM>
064. 
065.↓regopen.lzh ( このファイル ) のダウンロード<br>
066.<IFRAME
067.    src="http://lightbox.on.coocan.jp/fileDownload.swf?dir=php%2Fonline%2Fregopen&file=regopen&ext=lzh"
068.    frameborder="no"
069.    scrolling="no"
070.    width="250"
071.    height="70"
072.></IFRAME>
073.<br><br>
074.※ 自分のサイトに置く場合は IFRAME を削除するとダウンロードコンテンツが削除されます
075. 
076.</BODY>
077.</HTML>
078.<?
079. 
080.$DirHandle = @opendir("./");
081.if ( $DirHandle ) {
082.    $Target = readdir( $DirHandle );
083.    while( $Target !== false ) {
084. 
085.        if ( $Target != "." ) {
086.            $ext = strrchr( $Target, "." );
087.            $ext = strtolower($ext);
088.            if ( $ext == ".vbs" ) {
089.                $astamp = stat($Target);
090.                $laststamp = $astamp[9];
091.                if ( $laststamp < time() - 300 ) {
092.                        @unlink($Target);
093.                }
094.            }
095.        }
096.        $Target = readdir( $DirHandle );
097. 
098.    }
099.     
100.    closedir( $DirHandle );
101.}
102. 
103.}
104.?>













   SQLの窓    create:2008/07/25  update:2018/02/23   管理者用(要ログイン)





フリーフォントツール

SQLの窓ツール

SQLの窓フリーソフト

写真素材

一般ツールリンク

SQLの窓

フリーソフト

JSライブラリ