Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #RequireAdmin ; Just for manipulating hosts file
- main()
- Func main()
- Local Const $Hostname = "www.autoitscript.com"
- Local Const $URL = "http://" & $Hostname & "/"
- Local Const $HostnameToLocalhost = "127.0.0.1 " & $Hostname ; redirect the hostname to localhost IP
- Local Const $hosts = @WindowsDir & "\system32\drivers\etc\hosts"
- $BINSource = InetRead($URL, 1) ; get binary index.html forcing reload
- $STRSource = BinaryToString($BINSource) ; transforms into a string
- MsgBox(0,"Before redirection",$STRSource) ; displays data before redirection
- ;backup hosts
- $hostsHandle = FileOpen($hosts)
- $hostsBackup = FileRead($hostsHandle)
- FileClose($hostsHandle)
- ;redirect hostname to localhost
- $hostsHandle = FileOpen($hosts, 1)
- FileWrite($hostsHandle, @CRLF & $HostnameToLocalhost)
- FileClose($hostsHandle)
- ;delay for redirection
- Sleep(5000)
- ;try to get source code again
- $BINSource = InetRead($URL, 1) ; get binary index.html forcing reload
- $STRSource = BinaryToString($BINSource) ; transforms into a string
- MsgBox(0,"After redirection", $STRSource) ; displays data after redirection
- ;restore hosts
- $hostsHandle = FileOpen($hosts, 2)
- FileWrite($hostsHandle, $hostsBackup)
- FileClose($hostsHandle)
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement