카테고리 없음
구글DNS에서 유튜브 IP주소를 얻어오는 VBScript
냐옹이.
2010. 5. 29. 14:55
Info
- 임시파일 폴더(%temp%)에 youtube_dns.tmp라는 nslookup 쿼리를 저장합니다. youtube_dns.tmp파일은 자동으로 삭제되지 않습니다. 삭제하려면 직접 삭제하거나 임시파일 폴더를 청소하면 삭제할 수 있습니다.
- 모든 작업이 끝난 후 바탕화면에 youtube.txt파일을 생성합니다. 이 파일은 %windir%\System32\drivers\etc\hosts파일에 붙여 넣을 수 있는 형식으로 되어있습니다.
- 스크립트 실행파일의 첫줄의 strDNS를 다른 DNS서버 주소로 변경하면 그에 맞는 IP를 가져올 수 있습니다. 잘못된 주소를 넣으면 129번의 Cancel 버튼 또는 ESC키를 눌려야 할지 모릅니다.
Google Public DNS
p : 8.8.8.8 s : 8.8.4.4
Script file and contents
strDNS = "8.8.8.8" Set objShell = WScript.CreateObject("WScript.Shell") Set objFS = CreateObject("Scripting.FileSystemObject") strTempPath = objShell.ExpandEnvironmentStrings("%temp%") strDesktopPath = objShell.ExpandEnvironmentStrings("%UserProfile%") & "\Desktop" If MsgBox("It takes about 5 minutes. take it easy", vbInformation + vbSystemModal + vbOkCancel) = vbCancel Then WScript.Quit End If Function nslookup(strDomain) strCmd = "%comspec% /c nslookup " & " " & strDomain & " " & strDNS & " > %temp%\youtube_dns.tmp" objShell.Run strCmd, 0, True Set objFile = objFS.OpenTextFile (strTempPath & "\youtube_dns.tmp", 1) strResult = objFile.ReadAll AddressTokens = Split(strResult, "Address:") If UBound(AddressTokens) < 2 Then nslookup = False Else AliasesTokens = Split(AddressTokens(2), "Aliases:") strIP = Trim(AliasesTokens(0)) nslookup = strDomain & vbTab & strIP End If End Function For nCache = 1 To 8 For nV = 1 To 24 strDomain = "v" & nV & ".lscache" & nCache & ".c.youtube.com" result = True Do result = nslookup(strDomain) If result = False Then If MsgBox("Failed to get IP Address for " & strDomain & ". Try once more?", vbQuestion + vbOKCancel) = vbCancel Then Exit Do End If Else strHost = strHost & result Exit Do End If Loop Next Next Set newFile = objFS.CreateTextFile(strDesktopPath & "\youtube.txt", True) newFile.Write(strHost) newFile.Close If MsgBox("Finished!!" & vbNewLine & "Run Explorer and Notepad?", vbQuestion + vbOkCancel) = vbOk Then objShell.Run "%windir%\System32\drivers\etc", 1, False objShell.Run "%UserProfile%\Desktop\youtube.txt", 1, False End If