Jump to content

How to close/Block other connections?


Recommended Posts

Hi all,

Scrapping my last project, I have decieded to try and make a firewall in AutoIT.

I have ideas/Scripts for doing everything but closing a guilty connection.

How? Any ideas? This been done before?

Thx,

Hypoz.

ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Link to comment
Share on other sites

Any chance you could post your "ideas/Scripts for doing everything" please ?

Well, first off, excution would be in a while loop, (oboviously)

It would look for processes that are using an internet connection (established)

Then either see if it is running as admin, or look up name against a file.

If neither of those things return positive, It would either block, or prompt user.

This code will get all running TCP connections and associated programs. Note i did not write it and it must be running as admin.

#include <Array.au3>

$aConnections = _GetAllConnections()

_ArrayDisplay($aConnections, "Connection Info")

Func _GetAllConnections()
    Local $iOld_Opt_REF = Opt("RunErrorsFatal", 0)
    
    Local $iPID = Run(@SystemDir & "\netstat.exe -b", "", @SW_HIDE, 2 + 4)
    Local $sConnections = "", $aReturn[1][6]
    Local $aSplit_Connections, $aData_Split, $sType, $sPID, $sProcName, $sStatus, $sLocal, $sRemote, $iUbound
    
    While ProcessExists($iPID)
        $sConnections &= StdoutRead($iPID)
    WEnd
    
    $aSplit_Connections = StringSplit($sConnections, @CRLF)
    If @error Then Return SetError(1, 0, "")
    
    For $i = 1 To $aSplit_Connections[0]
        If $aSplit_Connections[$i] = "" Then ContinueLoop
        
        $aSplit_Connections[$i] = StringStripWS($aSplit_Connections[$i], 7)
        
        $aData_Split = StringSplit($aSplit_Connections[$i], " ")
        If UBound($aData_Split) < 4 Or $aData_Split[1] <> "TCP" Then ContinueLoop
        
        $sPID = $aData_Split[$aData_Split[0]]
        $sType = $aData_Split[1]
        $sLocal = $aData_Split[2]
        $sRemote = $aData_Split[3]
        $sStatus = $aData_Split[4]
        
        If $i+2 <= $aSplit_Connections[0] Then $sProcName = StringStripWS($aSplit_Connections[$i+2], 3)
        If Not StringRegExp($sProcName, "\[.*\]") Then $sProcName = StringStripWS($aSplit_Connections[$i+1], 3)
        $sProcName = StringRegExpReplace($sProcName, "\[(.*)\]", "\1")
        
        $aReturn[0][0] += 1
        $iUbound = $aReturn[0][0]
        
        ReDim $aReturn[$iUbound + 1][6]
        
        $aReturn[$iUbound][0] = $sType
        $aReturn[$iUbound][1] = $sProcName
        $aReturn[$iUbound][2] = $sPID
        $aReturn[$iUbound][3] = $sStatus
        $aReturn[$iUbound][4] = $sLocal
        $aReturn[$iUbound][5] = $sRemote
    Next
    
    Opt("RunErrorsFatal", $iOld_Opt_REF)
    
    Return $aReturn
EndFunc   ;==>_GetAllConnections

Still, any ideas?

Edited by hyperzap

ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Link to comment
Share on other sites

trancexx has a script for that sort of thing, if you search her threads in example scripts forum you will find it.

I can't find it. Can you post a link?

ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...