컴퓨터 사용제한(자녀피씨관리에 적절함)

반응형

출처 : qaos.comdamibasia 님이 제작하신 스크립트 입니다.



'인터넷, 컴퓨터 사용제한 스크립트, 최종수정 2006/8/6

'컴퓨터를 잘 알지 못하는 유저들을 대상으로 인터넷과 컴퓨터 사용을 제한하기 위한 스크립트입니다.
'사용시 발생하는 모든 문제는 사용자 자신에게 있습니다. 충분히 테스트를 한 후 사용하시길.

'다른 기능은 setcontrols.vbs 파일의 바로가기를 만든 후 등록정보에서 .vbs 후 옵션을 주어 실행합니다.
'인터넷 남은 시간 보기: setcontrols.vbs leftnet
'컴퓨터 남은 시간 보기: setcontrols.vbs leftcom
'모든 제한 허용하고 중지: setcontrols.vbs (설정한 adminpass)
'언인스톨: setcontrols.vbs uninst
'관리제한: setcontrols.vbs admrestrict (cmd와 reg, 레지스트리편집기, 작업관리자 사용을 제한. 다시 로그인해야 적용됨)
'관리제한해제: setcontrols.vbs admallow

'제가 베이직을 잘 모르고 마구잡이로 만든 것이라 코드가 이상해도 그러려니 하시길;;
'vbscript를 모르시더라도 수정하셔서 쓰실 수 있게 주석을 달았습니다.

'이 스크립트는 win9x에서는 동작하지 않습니다.
'win2000에 shutdown.exe가 없는 걸로 기억하는데요.
'인터넷이나 다운로드 받거나 xp에서 가져와서 winnt\system32에 넣어주세요.

' 옵션++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

'하루 인터넷 제한 시간(분)
limitoftime_net = 1440

'하루 컴퓨터 제한 시간(분)
limitoftime_com = 1440

'체크텀(분), ie기반이 아닌 브라우져의 경우 체크텀 주기로 강제 종료합니다.
checkterm = 5

'컴퓨터 금지시킬시 적용할 방식, 0은 시스템강제종료, 1은 체크텀 마다 화면잠그기
combantype = 1

'컴퓨터 강제 종료시, 인터넷 금지시 중지시킬 때 암호
adminpass = "예수님"

'인터넷사용 허용시간영역 설정, 1은 허용 0은 금지
dim timezone_net(24)
timezone_net(0)=1
timezone_net(1)=1
timezone_net(2)=1
timezone_net(3)=1
timezone_net(4)=1
timezone_net(5)=1
timezone_net(6)=1
timezone_net(7)=1
timezone_net(8)=1
timezone_net(9)=1
timezone_net(10)=1
timezone_net(11)=1
timezone_net(12)=1
timezone_net(13)=1
timezone_net(14)=1
timezone_net(15)=1
timezone_net(16)=1
timezone_net(17)=1
timezone_net(18)=1
timezone_net(19)=1
timezone_net(20)=1
timezone_net(21)=1
timezone_net(22)=1
timezone_net(23)=1

'컴퓨터용 허용시간영역 설정, 1은 허용 0은 금지
dim timezone_com(24)
timezone_com(0)=1
timezone_com(1)=1
timezone_com(2)=1
timezone_com(3)=1
timezone_com(4)=1
timezone_com(5)=1
timezone_com(6)=1
timezone_com(7)=1
timezone_com(8)=1
timezone_com(9)=1
timezone_com(10)=1
timezone_com(11)=1
timezone_com(12)=1
timezone_com(13)=1
timezone_com(14)=1
timezone_com(15)=1
timezone_com(16)=1
timezone_com(17)=1
timezone_com(18)=1
timezone_com(19)=1
timezone_com(20)=1
timezone_com(21)=1
timezone_com(22)=1
timezone_com(23)=1

'모니터링할 프로그램, 실행 중인지 아닌지를 검사하여 시간을 차감합니다.
'인터넷 제한이 적용되었을시 ie기반은 내용관리자가 인터넷을 금지하고
'firefox같은 브라우져는 체크텀마다 강제 종료시킵니다.
'문제는 iexplorer2.exe로 이름을 바꿔서 실행해버리면 시간이 차감되지 않게 됩니다;;;
'또 explorer.exe나 hta, 다른 어플로 실행해도 그냥 인터넷이 됩니다;;;
dim banprocess(20)
banprocess(0)="iexplore.exe"
banprocess(1)="webma.exe"
banprocess(2)="maxthon.exe"
banprocess(3)="jwBrowser.exe"
banprocess(4)="jwBrowsermini.exe"
banprocess(5)="firefox.exe"
banprocess(6)="netscape.exe"
banprocess(7)="aaa.exe"
banprocess(8)="aaa.exe"
banprocess(9)="aaa.exe"
banprocess(10)="aaa.exe"
banprocess(11)="aaa.exe"
banprocess(12)="aaa.exe"
banprocess(13)="aaa.exe"
banprocess(14)="aaa.exe"
banprocess(15)="aaa.exe"
banprocess(16)="aaa.exe"
banprocess(17)="aaa.exe"
banprocess(18)="aaa.exe"
banprocess(19)="aaa.exe"

' 옵션++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'아래부터는 수정하지 않으셔도 됩니다.





set wshshell = createobject("wscript.shell")

'에러가 나도 스크립트를 계속 진행.
on error resume next

'첫번째 인수를 받음.
arg0 = wscript.arguments(0)

'현재 날짜, 시간, 분을 구함.
c_date = datepart("d",date)
c_hour = datepart("h",time)
c_min = datepart("n",time)

'레지스트리 정보가 저장될 위치.
regkey = "HKCU\Software\Setcontrols\"
regtype = "REG_DWORD"

'인터넷 남은 시간 체크.
if arg0 =  "leftnet" then
tmp = msgbox (wshshell.regread("HKCU\Software\Setcontrols\lefttime_net") & "분 남았습니다. 하루 " & limitoftime_net & "분 인터넷 허용   ", 32, "인터넷사용제한")
end if

'컴퓨터 남은 시간 체크.
if arg0 =  "leftcom" then
tmp = msgbox (wshshell.regread("HKCU\Software\Setcontrols\lefttime_com") & "분 남았습니다. 하루 " & limitoftime_com & "분 컴퓨터 허용   ", 32, "컴퓨터사용제한")
end if

'리셋 Setcontrols 중지
if arg0 =  adminpass Then
tmp = msgbox("사용시간을 리셋하고 인터넷을 허용하고 Setcontrols를 중지하시겠습니까?", 65, "Setcontrols")
If tmp = 1 Then
wshshell.regwrite regkey & "s_date", c_date, regtype
wshshell.regwrite regkey & "lefttime_net", limitoftime_net, regtype
wshshell.regwrite regkey & "lefttime_com", limitoftime_com, regtype
allow ()
tmp = msgbox("적용되었습니다.", 64, "Setcontrols")
killprocess("wscript.exe")
End if
end if

'언인스톨
if arg0 =  "uninst" then
tmp = msgbox("Setcontrols을 제거하고 모든 설정을 되돌리시겠습니까?", 65, "Setcontrols")
If tmp = 1 Then
allow ()
admallow ()
wshshell.regdelete regkey
wshshell.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\Setcontrols"
tmp = msgbox("Setcontrols가 제거되었습니다. 관리제한은 다시 로그인해야 적용됩니다.", 64, "Setcontrols")
killprocess("wscript.exe")
End if
end If

'관리제한함
if arg0 =  "admrestrict" Then
tmp = msgbox("관리자 제한을 적용하시겠습니까?", 65, "Setcontrols")
If tmp = 1 Then
admrestrict ()
tmp = msgbox("제한이 적용되었습니다. 다시 로그인하세요.", 64, "Setcontrols")
End if
end If

'관리제한해제
if arg0 =  "admallow" Then
tmp = msgbox("관리자 제한을 해제하시겠습니까?", 65, "Setcontrols")
If tmp = 1 Then
admallow ()
tmp = msgbox("제한이 해제되었습니다. 다시 로그인하세요.", 64, "Setcontrols")
End if
end If



if arg0 =  "" Then '인수가 없을 경우
wshshell.regread(regkey & "s_date") '설치 되지 않았을 경우 에러가 남.
if hex(err)="80070002" then
err.clear
tmp = msgbox("컴퓨터를 잘 알지 못하는 유저들을 대상으로 인터넷과 컴퓨터 사용을 제한하기 위한 스크립트입니다.사용시 발생하는 모든 문제는 사용자 자신에게 있습니다. 충분히 테스트를 한 후 사용하시길.", 48, "Setcontrols")
q_install = msgbox("Setcontrols를 처음 실행했습니다. 옵션을 수정하려면 Setcontrols.vbs 파일을 메모장으로 연 후 수정하세요. Setcontrols.vbs를 현재 폴더에 설치하려면 Yes를 누르시고 설치하지 않으려면 No를 누르세요. 다른 폴더에 Setcontrols.vbs를 두고 싶다면 파일을 원하는 폴더로 옮긴 후 본 파일을 실행하고 Yes를 누르세요.", 324, "Setcontrols")
if q_install = 6 then
  wshshell.regwrite regkey & "s_date", c_date, regtype
  wshshell.regwrite regkey & "lefttime_net", limitoftime_net, regtype
  wshshell.regwrite regkey & "lefttime_com", limitoftime_com, regtype
  wshshell.regwrite regkey & "forbidden_net", 0, regtype
  wshshell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\Setcontrols", WshShell.CurrentDirectory & "\setcontrols.vbs", "REG_SZ"
  admrestrict ()
  tmp = msgbox("레지스트리, 작업관리자, 커맨드창의 금지는 다시 로그인해야 완전히 적용됩니다.", 48, "Setcontrols")
else
  killprocess("wscript.exe")
end if
end if
'=================================================================================
'스크립트가 실행될 때 루푸를 도는 영역이 시작됨.
do

'레지스트리에서 날짜와 금지여부를 불러옴.
s_date = int(wshshell.regread(regkey & "s_date"))
forbidden_net = int(wshshell.regread(regkey & "forbidden_net"))

'현재 시각을 갱신.
c_date = datepart("d",date)
c_hour = datepart("h",time)
c_min = datepart("n",time)

'날짜가 바뀔 경우 날짜를 갱신하고 제한 시간을 리셋.
if s_date <> c_date then
wshshell.regwrite regkey & "s_date", c_date, regtype
wshshell.regwrite regkey & "lefttime_net", limitoftime_net, regtype
wshshell.regwrite regkey & "lefttime_com", limitoftime_com, regtype
allow ()
wscript.sleep 3000
end if

'남은 시간을 불러옴.
lefttime_net = int(wshshell.regread(regkey & "lefttime_net"))
lefttime_com = int(wshshell.regread(regkey & "lefttime_com"))

'프로세스를 체크하고 실행 중이면 인터넷 제한 시간을 줄임.
dim i
for i = 0 to 19
if checkprocess (banprocess(i)) = 1 and lefttime_net > 0 and forbidden_net = 0 then
lefttime_net = lefttime_net - checkterm
wshshell.regwrite regkey & "lefttime_net", lefttime_net, regtype
end if
exit for
checkprocess (banprocess(i)) = 1 ' 동시에 여러 프로그램일 경우 중복 제외
next

'컴퓨터 사용시간을 줄임.
lefttime_com = lefttime_com - checkterm

'인터넷 제한 시간영역일 경우
if timezone_net(c_hour) = 0 and forbidden_net = 0 then
Call tmpmsg ("인터넷금지시간대, 1분 후 인터넷이 금지됩니다", "인터넷사용제한")
wscript.sleep 60000
forbid ()
dim j
for j = 0 to 19
killprocess (banprocess(j))
next
end if
if forbidden_net = 1 then
for j = 0 to 19
killprocess (banprocess(j))
Next
end if

'컴퓨터 제한 시간 영역일 경우
if timezone_com(c_hour) = 0 Then
If combantype = 1 Then
Call tmpmsg ("컴퓨터금지시간대, 1분 후 컴퓨터가 잠깁니다. (" & checkterm & "분마다 잠김)", "컴퓨터사용제한")
wscript.sleep 60000
wshshell.run "RunDll32.exe user32.dll,LockWorkStation",0
End If
If combantype = 0 Then
wshshell.run "shutdown.exe /s /f /t 60 /c "&""""&"컴퓨터금지시간대"&""""&"",0
adminp = inputbox("컴퓨터금지시간대, 1분 후 시스템이 종료됩니다. 종료를 취소하려면 패스워드를 입력하세요.", "컴퓨터사용제한",,0,0)
if adminp = adminpass Then
  wshshell.run "shutdown.exe -a" ' 강제 종료 취소.
  killprocess("wscript.exe")
else
  tmp = msgbox("패스워드가 틀렸습니다.", 48, "Setcontrols")
End if
end If
end if

'인터넷 사용시간 소진일 경우
if lefttime_net <= 0 and forbidden_net = 0 Then
Call tmpmsg ("인터넷할당시간소진, 1분 후 인터넷이 금지됩니다", "인터넷사용제한")
wscript.sleep 60000
forbid ()
dim k
for k = 0 to 19
killprocess (banprocess(k))
next
end if
if forbidden_net = 1 then
for j = 0 to 19
killprocess (banprocess(j))
Next
end if

'컴퓨터 사용시간 소진일 경우
if lefttime_com <= 0 Then
If combantype = 1 Then
Call tmpmsg ("컴퓨터할당시간소진, 1분 후 컴퓨터가 잠깁니다. (" & checkterm & "분마다 잠김)", "컴퓨터사용제한")
wscript.sleep 60000
wshshell.run "RunDll32.exe user32.dll,LockWorkStation",0
End If
If combantype = 0 Then
wshshell.run "shutdown.exe /s /f /t 60 /c "&""""&"컴퓨터할당시간소진"&""""&"",0
adminp = inputbox("컴퓨터할당시간소진, 1분 후 시스템이 종료됩니다. 종료를 취소하려면 패스워드를 입력하세요.", "컴퓨터사용제한",,0,0)
if adminp = adminpass Then
  wshshell.run "shutdown.exe -a" ' 강제 종료 취소.
  killprocess("wscript.exe")
else
  tmp = msgbox("패스워드가 틀렸습니다.", 48, "Setcontrols")
end If
End if
end if

wscript.sleep checkterm*60000

loop
'=================================================================================
'루프 끝
end if




'프로세스를 종료함.
function killprocess (image)
strcomputer = "."
set objwmiservice = getobject("winmgmts:" _
  & "{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2")
set colprocesslist = objwmiservice.execquery _
("select * from win32_process where name = '"& image &"'")
for each objprocess in colprocesslist
objprocess.terminate()
next
end function

'프로세스가 기동 중인지 확인.
function checkprocess (image)
set checkprocess = getobject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2")
set runnigprocesslist = checkprocess.execquery _
("select * from win32_process where name = '" & image & "'")
checkprocess = runnigprocesslist.count
end function

'ie의 기능을 이용하여 인터넷을 금지시킴. 내용관리자에서 비밀번호를 무작위로 넣은 후의 이진값을 아래에서 추가하게 됨.
' 초기 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Ratings 키까지만 존재함.
function forbid ()
'레지스트리의 이진값을 임시파일 없이 추가하는 방식.
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Ratings"
strComputer = "."
iValues = Array(&H17,&H91,&Hd7,&H3a,&H3e,&H16,&He3,&He2,&Hbe,&He0,&Hdf,&H8e,&H05,&H4b,&H61,&Ha3)
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
BinaryValueName = "key"
oReg.SetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath,BinaryValueName,iValues
wshshell.regwrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Ratings\FileName0", "C:\\WINDOWS\\system32\\RSACi.rat", "REG_SZ"
wshshell.regwrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Ratings\.Default\Allow_Unknowns", 0, "REG_DWORD"
wshshell.regwrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Ratings\.Default\PleaseMom", 0, "REG_DWORD"
wshshell.regwrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Ratings\.Default\Enabled", 1, "REG_DWORD"
wshshell.regwrite regkey & "forbidden_net", 1, regtype
end function

'인터넷 사용을 허용함. 간단히 레지스트리값만 지워주면 제한이 해제됨.
function allow ()
on error resume next
wshshell.regdelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Ratings\key"
wshshell.regdelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Ratings\FileName0"
wshshell.regdelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Ratings\.Default\Allow_Unknowns"
wshshell.regdelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Ratings\.Default\PleaseMom"
wshshell.regdelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Ratings\.Default\Enabled"
wshshell.regdelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Ratings\.Default\"
wshshell.regwrite regkey & "forbidden_net", 0, regtype
end Function

'cmd와 reg, 레지스트리편집기, 작업관리자 사용을 제한.
function admrestrict ()
'로그오프-로그인해야 적용됨
wshshell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun","1", "REG_DWORD"
wshshell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun\1","cmd.exe", "REG_SZ"
wshshell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun\2","reg.exe", "REG_SZ"
'바로 적용
wshshell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableRegistryTools","2", "REG_DWORD"
wshshell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr","2", "REG_DWORD"
wshshell.regwrite "HKCU\Software\Policies\Microsoft\Windows\System\DisableCMD","2", "REG_DWORD"
end Function

'제한 관련 레지스트리를 지움. 바로 제한이 해제되는지??
function admallow ()
wshshell.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun"
wshshell.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableRegistryTools"
wshshell.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr"
wshshell.regdelete "HKCU\Software\Policies\Microsoft\Windows\System\DisableCMD"
end Function

'메시지 박스를 띄울 경우 스크립트가 멈추기 때문에 임시파일을 만들어 메시지박스 띄움.
Function tmpmsg (tmpmessage, tmptitle)
dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateTextFile("c:\msgtmp.vbs", true)
f.WriteLine("tmp = msgbox("&""""&tmpmessage&""""&", 48, "&""""&tmptitle&""""&")")
f.Close
wshshell.run "c:\msgtmp.vbs"
wscript.sleep 2000
Set f = fso.GetFile("c:\msgtmp.vbs")
f.Delete
End Function

반응형