Sign in to follow this  
Followers 0
DarkHo

[HELP] Website blocker

29 posts in this topic

#1 ·  Posted (edited)

I have a code but i want the blocked sites to enter to my index.html file inte same director as the exe file how do i do that ? so when i enter the blocked site i see the index.html file

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button1
            FileWrite("C:\WINDOWS\system32\drivers\etc\hosts", "74.125.87.103   " &  GUICtrlRead($url) & @CRLF)

            MsgBox(64, "Added!", GUICtrlRead($url) & " was added whit ip =>" & "74.125.87.103")




    EndSwitch
WEnd
Edited by DarkHo

Share this post


Link to post
Share on other sites

Something like this?

$sBody = StringRegExpReplace(FileRead(@ScriptDir & "\index.html"), "(?i)(?s)(.+)(</body.+)", "$1<br />74.125.87.103   " &  GUICtrlRead($url) & "74.125.87.103   " &  GUICtrlRead($url) & @CRLF  & "$2")
$hFile = FileOpen(@ScriptDir & "\index.html", 2)
Filewrite($hFile, $sBody)
FileClose($hFile)
ShellExecute(@ScriptDir & \index.html")

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

because he missed ". It should be:

ShellExecute(@ScriptDir & "\index.html")
Edited by Makaule

Share this post


Link to post
Share on other sites

Why dosent this work ?

FileWrite("C:\WINDOWS\system32\drivers\etc\hosts", "http://www.mysite.com/blocke/index.html   " &  GUICtrlRead($url) & @CRLF)

            MsgBox(64, "Site Added!", GUICtrlRead($url))

Share this post


Link to post
Share on other sites

The host file has a "read only" attribute. You have to remove it first and then write.

FileSetAttrib("C:\WINDOWS\system32\drivers\etc\hosts", "-R")

--- Write to the file

--- When finished set it back to read only

FileSetAttrib("C:\WINDOWS\system32\drivers\etc\hosts", "+R")


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

Share this post


Link to post
Share on other sites

Why dosent this work ?

FileWrite("C:\WINDOWS\system32\drivers\etc\hosts", "http://www.mysite.com/blocke/index.html   " &  GUICtrlRead($url) & @CRLF)

            MsgBox(64, "Site Added!", GUICtrlRead($url))

What doesn't work other than the wrong format of a Hosts entry?

The host file has a "read only" attribute. You have to remove it first and then write.

FileSetAttrib("C:\WINDOWS\system32\drivers\etc\hosts", "-R")

--- Write to the file

--- When finished set it back to read only

FileSetAttrib("C:\WINDOWS\system32\drivers\etc\hosts", "+R")

This is not the case by default.

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

This is not the case by default.

I guess that depends on several factors ... but ..

On an XP machine, I've never seen it otherwise - unless someone took it off.

btw .. settings in the host file does not take effect until you reboot the pc.

This is how the format is with at least 10 spaces between them

127.0.0.1 (TENSPACESBETWEEN) localhost

127.0.0.1 (TENSPACESBETWEEN) www.mysite.com

127.0.0.1 (TENSPACESBETWEEN) www.google.com

and so on .......

-edit seems edit box was good but the post format changed. i'll fix it. ROFL

.

Edited by ripdad

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

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I guess that depends on several factors ... but ..

On an XP machine, I never seen it otherwise - unless someone took it off.

mmm .... guess we don't agree here. :P

btw .. settings in the host file does not take effect until you reboot the pc.

..and I am also not in agreement with this statement. The Host file entries will be in effect directly after the file is saved.

Jos :mellow:

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I've never seen it otherwise. again.

Anytime I've enabled it, I always had to restart the machine.

Of course, that could be because of cache.

Anyways .. enough of this .. got to go to bed

Edited by ripdad

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

Share this post


Link to post
Share on other sites

I've never seen it otherwise. again.

ripdad <--- computer tech 15 years

No need to prove you are experienced and am not questioning your findings... but lets at least agree that host file entries are active right after they are saved and that the 10 spaces aren't really needed. :P

Jos <---- 30+ years in IT :mellow:


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

So ? what code should i have ?


Share this post


Link to post
Share on other sites

sorry, can't agree.

and .. 30 years would put you in the stone age (computer time that is) <grin>


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

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

30 years would put you in the stone age (computer time that is) <grin>

Yea we agree on something here ... the computer stone-age was really the punchcard age. :mellow: Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Still dont know what to add


Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Still dont know what to add

Listen my friend, if memory serves me well: we have been here before.

Now what about you start doing some of the thinking, reading and put in some effort yourself?

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Like this ?

FileSetAttrib("C:\WINDOWS\system32\drivers\etc\hosts", "-R")
            FileWrite("C:\WINDOWS\system32\drivers\etc\hosts", "http://www.mysite.com/blocke/index.html   " &  GUICtrlRead($url) & @CRLF)

            MsgBox(64, "Site Added!", GUICtrlRead($url))
            
            FileSetAttrib("C:\WINDOWS\system32\drivers\etc\hosts", "+R")
Edited by DarkHo

Share this post


Link to post
Share on other sites

What are you trying to write to the HOSTS file and how should a Host file record really look?

The host file blockes sites when i enter local ip the site blockes but when i enter a site int dont work

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0