Sign in to follow this  
Followers 0
HAL9000

how to create a similar software with autoit

24 posts in this topic




#2 ·  Posted (edited)

not same but you can block the sites by checking their title and close them with a message.

a example:

CODE: AutoIt

Opt("WinTitleMatchMode", 2)

While 1

If WinExists("MyTitle") Then

WinClose("MyTitle")

MsgBox(0, "Blocked", "You can not view this site")

EndIf

WEnd

or if you have many sites to block then use then

CODE: AutoIt

Opt("WinTitleMatchMode", 2)

$Title = "SiteTitle1|new|warcraft|GSM|Love|" ; you can add many titles like this.

$Title &= "software|news|YouTube|video|Name|"

$Title &= "ItsLast|"

;$Title is case-insensitive like "YouTube" will match on youtube,YOUTUBE etc

$A = 1

While $A < 3

$B = 1

While $B < 580

Sleep(1000) ;it will check every second

If WinExists("[REGEXPTITLE:(?i)" & $Title & "]") Then

WinClose("[last]")

EndIf

WEnd

WEnd

if it is not what you want to do then explain what you really want to do.

Edited by zFrank

[font="Georgia"]GSM Expert[/font] but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php
$Life = "Happy"
If @Error Then
$Life = "Risk"

Share this post


Link to post
Share on other sites

host block notifier shows a message when you try to visit a site blocked by the hosts file

i want to create a script to do the same thing

If you are using hosts file to block bad hosts (malware, advertisements, etc.), you are directing the system to point to the local machine. The web browser will just show a message to tell you that it couldn't connect to the server or the page cannot be displayed.

Host Block Notifier is a little tool that acts like a local web server.Your browser will inform you whenever you access a blocked website. You will need to leave this program running in the background.

Share this post


Link to post
Share on other sites

That's easy. Just write a small http server and set it to listen on 127.0.0.1.

Share this post


Link to post
Share on other sites

That's sent as part of the host information. It's all part of the http header.

Share this post


Link to post
Share on other sites

Or you just put it it the host file like this:

127.0.0.1/mywebsite.com mywebsite.com

or:

127.0.0.1/page.php?url=mywebsite.com mywebsite.com

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

That's sent as part of the host information. It's all part of the http header.

And which part would that be? ;)

A small example: [just run this script > browse to "http://127.0.0.1/" or "http://localhost/" with your webbrowser, and tadaaa! :P ]

TCPStartup()

$iServer = TCPListen("127.0.0.1",80)

$sPage = "<b>Hello you!</b><p>You have been redirected to this page because this site is blocked by your host file. <br>"& _
            "If you have totally no clue of whats happening here, your brother/sister is probably messing with you. :P"& _
            "<p><p><i><font color=red>Made by Kip</font></i>"

$CurrentClient = 0

While 1
    
    $iClient = TCPAccept($iServer)
    
    if $iClient <> -1 Then
        $CurrentClient = $iClient
    EndIf
    
    $sRecv = TCPRecv($CurrentClient,1024)
    If $sRecv Then
        HttpSend($CurrentClient, $sPage)
    EndIf
    
WEnd

TCPShutdown()


Func HttpSend($iClientW, $sText)
    
    Local $sHeader = "HTTP/1.1 200 OK" &@CRLF& _
 "Date: Mon, 23 May 2005 22:38:34 GMT" &@CRLF& _
 "Server: Apache/1.3.3.7 (Unix)  (Red-Hat/Linux)" &@CRLF& _; I know: wrong
 "Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT" &@CRLF& _; Wrong too
 "Accept-Ranges: bytes" &@CRLF& _
 "Content-Length: "&StringLen($sText) &@CRLF& _
 "Content-Type: text/html"&@CRLF&@CRLF
    
    Return TCPSend($iClientW,$sHeader&$sText)
    
EndFunc
Edited by Kip

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Better version: allows to download other files than the index page (pictures, videos, audio), and replaces %ascii codes with their characters (%20 = space)

This actually is a basic web server. (in just 100 lines ;) )

Global $DefaultFile = "Index.html"

TCPStartup()

$iServer = TCPListen("127.0.0.1",80)

$CurrentClient = 0

While 1
    
    $iClient = TCPAccept($iServer)
    
    if $iClient <> -1 Then
        $CurrentClient = $iClient
    EndIf
    
    $sRecv = TCPRecv($CurrentClient,1024)
    If $sRecv Then
        
        $Split = StringSplit($sRecv,@CRLF)
        $FirstLine = $Split[1]
        
        $Get = StringReplace($FirstLine,"GET /","")
        $Get = StringReplace($Get," HTTP/1.1","")
        

$iPos = 1
        
        While 1
            
            $Occ = StringInStr($Get,"%",2,$iPos)
            If not $Occ Then ExitLoop
            
            $HexVal = StringMid($Get,$Occ+1,2)
            
            $Get = StringReplace($Get,"%"&$HexVal,Chr("0x"&$HexVal))
            
            $iPos += 1
            
        WEnd

        If not $Get Then $Get = $DefaultFile
        
        $File = FileOpen($Get,16)
        $sPage = BinaryToString(FileRead($File))
        FileClose($File)
        
        $Split = StringSplit($Get,".")
        $Ext = $Split[$Split[0]]
        
        
        Switch $Ext
            Case "png"
                $ContentType = "image/png"
            Case "bmp"
                $ContentType = "image/bmp"
            Case "asf"
                $ContentType = "video/x-ms-asf"
            Case "avi"
                $ContentType = "video/avi"
            Case "doc"
                $ContentType = "application/msword"
            Case "zip"
                $ContentType = "application/zip"
            Case "xls"
                $ContentType = "application/vnd.ms-excel"
            Case "gif"
                $ContentType = "image/gif"
            Case "jpg", "jpeg"
                $ContentType = "image/jpeg"
            Case "wav"
                $ContentType = "audio/wav"
            Case "mp3"
                $ContentType = "audio/mpeg3"
            Case "mpg", "mpeg"
                $ContentType = "video/mpeg"
            Case "rtf"
                $ContentType = "application/rtf"
            Case "htm", "html"
                $ContentType = "text/html"
            Case "asp"
                $ContentType = "text/asp"
            case Else
                $ContentType = "text/html"
        EndSwitch
        
        HttpSend($CurrentClient, $sPage, $ContentType)
    EndIf
    
WEnd

TCPShutdown()


Func HttpSend($iClientW, $sText, $CT)
    
    Local $sHeader = "HTTP/1.1 200 OK" &@CRLF& _
 "Server: Kip server" &@CRLF& _
 "Accept-Ranges: bytes" &@CRLF& _
 "Content-Length: "&StringLen($sText) &@CRLF& _
 "Content-Type: "&$CT&@CRLF&@CRLF
    
    Return TCPSend($iClientW,$sHeader&$sText)
    
EndFunc
Edited by Kip

Share this post


Link to post
Share on other sites

Lol cool, a web server in AutoIt.


- Dan [Website]

Share this post


Link to post
Share on other sites

It's been done before.

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

thank you ;)

Share this post


Link to post
Share on other sites

Global $DefaultFile = "Index.html"
dim $i_PID
ProcessSetPriority(@AutoItPID, 0)
TCPStartup()
$iServer = TCPListen("127.0.0.1",80)
$CurrentClient = 0

While 1
    sleep(1)
    $memo = ProcessGetStats(@AutoItPID)
    if $memo[0]>1000000 then ReduceMemory()
    $iClient = TCPAccept($iServer)
    
    if $iClient <> -1 Then
        $CurrentClient = $iClient
    EndIf
    
    $sRecv = TCPRecv($CurrentClient,1024)
    If $sRecv Then
        
        $Split = StringSplit($sRecv,@CRLF)
        $FirstLine = $Split[1]
        
        $Get = StringReplace($FirstLine,"GET /","")
        $Get = StringReplace($Get," HTTP/1.1","")
        
$iPos = 1
        
        While 1
            
            $Occ = StringInStr($Get,"%",2,$iPos)
            If not $Occ Then ExitLoop
            
            $HexVal = StringMid($Get,$Occ+1,2)
            
            $Get = StringReplace($Get,"%"&$HexVal,Chr("0x"&$HexVal))
            
            $iPos += 1
            
        WEnd

        If not $Get Then $Get = $DefaultFile
        
        $File = FileOpen($Get,16)
        $sPage = BinaryToString(FileRead($File))
        FileClose($File)
        
        $Split = StringSplit($Get,".")
        $Ext = $Split[$Split[0]]
        
        
        Switch $Ext
            Case "png"
                $ContentType = "image/png"
            Case "bmp"
                $ContentType = "image/bmp"
            Case "asf"
                $ContentType = "video/x-ms-asf"
            Case "avi"
                $ContentType = "video/avi"
            Case "doc"
                $ContentType = "application/msword"
            Case "zip"
                $ContentType = "application/zip"
            Case "xls"
                $ContentType = "application/vnd.ms-excel"
            Case "gif"
                $ContentType = "image/gif"
            Case "jpg", "jpeg"
                $ContentType = "image/jpeg"
            Case "wav"
                $ContentType = "audio/wav"
            Case "mp3"
                $ContentType = "audio/mpeg3"
            Case "mpg", "mpeg"
                $ContentType = "video/mpeg"
            Case "rtf"
                $ContentType = "application/rtf"
            Case "htm", "html"
                $ContentType = "text/html"
            Case "asp"
                $ContentType = "text/asp"
            case Else
                $ContentType = "text/html"
        EndSwitch
        
        HttpSend($CurrentClient, $sPage, $ContentType)
    EndIf
    
WEnd

TCPShutdown()

Func HttpSend($iClientW, $sText, $CT)
    
    Local $sHeader = "HTTP/1.1 200 OK" &@CRLF& _
"Server: Kip server" &@CRLF& _
"Accept-Ranges: bytes" &@CRLF& _
"Content-Length: "&StringLen($sText) &@CRLF& _
"Content-Type: "&$CT&@CRLF&@CRLF
    
    Return TCPSend($iClientW,$sHeader&$sText)
    
EndFunc

Func ReduceMemory()
    If $i_PID <> -1 Then
        Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', @AutoItPID)
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
        DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Else
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf
    
    Return $ai_Return[0]
EndFunc;==> ReduceMemory()

Share this post


Link to post
Share on other sites

It's been done before.

I most certainly do not doubt that. I just haven't happened to see it, it's been a while since I've visited the forums hehe.


- Dan [Website]

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