|
카테고리
태그
|
리눅스에서 passwd 명령어를 이용해서 비밀번호를 변경할 때 기존 비밀번호랑 패턴이 유사하면
Well anything you do via the web in some way can be a security risk so I don't see where using any windows objects even * winmgmts * via PHP and COM or .NET is anymore dangerous than opening a
Anyway WMI in web developing is used best as reading IO to help a administrator keep tack of system wide tasks! It can also be used as a write IO but you will be limited in doing this if using PHP 5, PHP 4 allows better access to WMI as more things are working in that version of PHP. A important thing that is broken in PHP 5 is passing collections of arrays by reference. This is used greatly in the WMI object model so accessing key data like * registry, user classes* will not work for over 50% of those inherited classes! If you use PHP 4 then you can access everything but it becomes very messy having to assign variants in your loops. In other words it's more work. For hardware tasks like drive info, Some real world examples.... (PHP 4, 5 any version) // Check if a process is running (PHP 5) <? define ( 'CPU_NAME', '.' ); $check = 'explorer.exe'; // the process to check $obj = new COM ( 'winmgmts:{impersonationLe if ( is_object ( $obj ) ) { $process = $obj->execquery ( "SELECT * FROM Win32_Process WHERE Name = '" . $check . "'" ); if ( $process->count > 0 ) { echo 'explorer is running'; } else { echo 'explorer is not running'; } $obj = null; } else { echo 'sorry can not create object: windows process check'; } ?> // get a list of all running processes (PHP 5) <? define ( 'CPU_NAME', '.' ); $obj = new COM ( 'winmgmts:{impersonationLe if ( is_object ( $obj ) ) { $process = $obj->execquery ( "SELECT * FROM Win32_Process" ); if ( $process->count > 0 ) { foreach ( $process AS $row ) { echo "PID: " . $row->processid . ", PROCESS NAME: " . strtolower ( $row->name ) . ", MEMORY USAGE: " . number_format ( $row->workingsetsize ) . "\r\n<br />\r\n"; } } else { echo 'no processes running'; } $obj = null; } else { echo 'sorry can not create object: windows running processes'; } ?> // read a registry tree starting at the root of any tree (PHP4 ONLY) will not work in PHP5 as array by reference is broken! <? $host = '.'; define ( 'HKLM', 0x80000002 ); $keys = new VARIANT ( '', VT_ARRAY ); $path = 'SOFTWARE\Microsoft\Window $obj = new COM ( 'winmgmts:{impersonationLe if ( is_object ( $obj ) ) { $obj->EnumKey ( HKLM, $path, &$keys ); $keys = $keys->value; foreach($keys as $key) { echo $key . "\r\n<br />\r\n"; } } else { echo 'Could not create object: registry read'; } ?> // get the processors on your system (type, speed, current load and more) (PHP 5) inherited class CIM_Processor <? define ( 'CPU_NAME', '.' ); $obj = new COM ( 'winmgmts:{impersonationLe $pc = 0; foreach ( $obj->instancesof ( 'Win32_Processor' ) as $mp ) { echo "<pre>Processor (" . ++$pc . ")\r\n\r\n"; echo " Processor Id: " . $mp->ProcessorId . "\r\n"; echo " Name: " . trim ( $mp->Name ) . " @ " . $mp->CurrentClockSpeed . " MHz\r\n"; echo " CPU Load: " . $mp->LoadPercentage . "%\r\n"; echo " CPU Status: " . $mp->Status . "\r\n"; echo " CPU Stepping: " . $mp->Stepping . "\r\n"; echo " CPU Revision: " . $mp->Revision . "\r\n"; echo " System Name: " . $mp->SystemName . "\r\n</pre>"; } ?> Need other examples, just ask! ms! 3가지는 꼭 직접 구현해 보고 싶었다. 첫째는 보호모드 OS를 만드는것, 둘째는 C 스크립트언어를 만드는것, 마지막 셋째는 영어 공부이다. 이제 약속했던 데드라인이 다가온다. 이 중에서 지킨게 뭐가 있나 되돌아 보니... 하나도 없다. 그래 이중에 하나라도 하자. PC 환경이 점점 예전으로 돌아가고 있다. 이제 클라이언트에서 뭔가를 실행시킨다는 것 자체가 매우 위험한 일이 되어 버렸다. 범용성과 호환성을 목표로 하기 위해 네이티브 바이너리가 아닌 메타 명령어로 컴파일이 되어 버리기 때문에 소스 코드가 너무나도 적날하게 노출되어 버린다. 그래서 이런 기술을 사용하기가 매우 조심스럽다. 결국 안전한 서버측에서 사용하는 모양이다. 이런 상황이다 보니 실제 클라이언트에서는 할 일이 없어졌다. 그냥 입력을 받아서 서버에 전달해주고 결과를 받아서 화면에 출력해주는 정도다. 즉 터미날로 다시 돌아가고 있다. 정말 요즘 같은 추세라면 모니터에 이더넷 카드와 USB 단자만 달린 제품을 만들어서 팔고 싶어진다. 이미 판매 할지도 모르겠다. 보통 생각하는 것들은 잘 찾아보면 이미 시장에 나온것들이다. 아무튼 인생은 재귀적이다.
sc라는 명령어가 있는지 몰랐을 때, net 명령어를 이용해서 서비스를 구동하곤 했다. 그런데 net 명령어는 서비스를 레지스트리에
등록하는게 존재하지 않아서 항상 불편했었다. 그래서 결국 서비스 관련 API를 이용해서 별도의 프로그램을 만들어 사용하곤 했는데 내가 만든 프로그램이다 보니 다른 PC에는 존재하지 않아서 역시나 불편하기 짝이 없었다. sc는 서비스 관련 API를 실행할 수 있도록 만들어진 윈도우즈 내장 프로그램이다. 가능한 OS는 아래에 나열했다.
| ||||