Jump to content

Recommended Posts

Posted

Here's a simple script that monitors what URL's have been blocked by the HostsFile.

; HostsFile Monitor
; Released: February 10, 2012 by ripdad
; Description: Monitors what URL's have been blocked by the HostsFile
;
Opt('TrayAutoPause', 0)
Opt('MustDeclareVars', 1)
OnAutoItExitRegister('_Exit')
;
TCPStartup()
;
Local $a, $s, $t, $Socket, $Server = TCPListen('127.0.0.1', 80)
;
Local $gui = GUICreate(' HostsFile Monitor', 400, 250, -1, -1, Default, 0x00000008); <-- Always on Top
Local $hLv = GUICtrlCreateListView(" Blocked URL's| Date/Time", 5, 5, 390, 240)
GUICtrlSendMsg($hLv, 0x101E, 0, 240)
GUICtrlSendMsg($hLv, 0x101E, 1, 130)
GUISetState(@SW_SHOW)
;
While 1
    Do
        $Socket = TCPAccept($Server)
    Until (GUIGetMsg() = -3) Or ($Socket <> -1)
    If $Socket = -1 Then Exit
    $s = TCPRecv($Socket, 256)
    $a = StringRegExp($s, '(?i)Host:(.*?)' & @CRLF, 3)
    If IsArray($a) Then
        $t = @MON & '-' & @MDAY & '-' & @YEAR & '  ' & @HOUR & ':' & @MIN & ':' & @SEC
        GUICtrlCreateListViewItem($a[0] & '|' & $t, $hLv)
    EndIf
    TCPCloseSocket($Socket)
WEnd
;
Func _Exit()
    TCPShutdown()
    GUIDelete($gui)
    MsgBox(0, ' HostsFile Monitor', 'Exit', 1)
    Exit
EndFunc
;

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Posted

Very interesting, thanks.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

JohnOne,

The HOSTS file is for re-directing domains to the appropriate IP address, though the intended function of the HOSTS file has changed over time. For a specific IP address then you're looking at another piece of software which you can find by doing a bit of digging.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...