Jump to content



Photo

secure you pc


  • Please log in to reply
10 replies to this topic

#1 Pakku

Pakku

    Prodigy

  • Active Members
  • PipPipPip
  • 183 posts

Posted 22 August 2006 - 01:24 PM

hi,

i made this script for security reasons, it asks you all the time if a running program is oke.
the include file compinfo.au3 can be found here: compinfo.au3 topic

please take a look at it.
does someone know how to modify this sothat the cpu usage will go down?

AutoIt         
;includes------------------------------ #include<GUIConstants.au3> #include <GuiListView.au3> #include <CompInfo.au3> ;options------------------------------ Opt("GUICloseOnESC",0) Opt("GUIOnEventMode",1) Opt("OnExitFunc","OnAutoItExit") Opt("RunErrorsFatal",0) Opt("TrayAutoPause",0) Opt("TrayIconDebug",1) Opt("TrayMenuMode",1 + 2 + 4) Opt("TrayOnEventMode",1) ;declarations----------------------------- Dim $on = 0 ;0 = uit Dim $Processes Global $hwnd Global $toegevoegd = 0 Global $sleep = 0 ;main gui-------------------------------- GUICreate("Rungate",572,388) GUISetBkColor(0xffffff) GUISetOnEvent($GUI_EVENT_CLOSE,"OnAutoItExit") GuiCtrlSetState(-1,$GUI_DISABLE) GUICtrlCreateLabel("Status:",60,10,120,40) GUICtrlSetFont(-1,30) GUICtrlCreatePic("images\rungate.gif",10,230,148) $list = GUICtrlCreateListView("      Process      |   Value   ",260,10,302,368) $status = GUICtrlCreatePic("images\redshd.gif",200,10,(37 * 60) / 46,60) $on_off = GUICtrlCreatePic("images\end_up.jpg",10,10,40,40) $add = GUICtrlCreateButton("Add",160,388 - 90,90,20) $remove = GUICtrlCreateButton("Remove",160,388 - 60,90,20) $edit = GUICtrlCreateButton("Edit",160,388 - 30,90,20) $timer = GUICtrlCreateSlider(10,60,100,20) GUICtrlSetLimit($timer,10,0) GUICtrlSetOnEvent($on_off,"_on_off") GUICtrlSetOnEvent($add,"_add_list") GUICtrlSetOnEvent($remove,"_remove_list") GUICtrlSetOnEvent($edit,"_edit_list") GUISetState() ;run before starting to use------------------------- _processes() ;main loop-------------------------------------- While 1     If $on = 1 Then         Dim $Processes         _ComputerGetProcesses($Processes)         For $i = 1 To $Processes[0][0] Step 1             If $on = 0 Then                 ExitLoop             EndIf             $ini = IniRead("processes.ini","processes",$Processes[$i][0],"-")             If $ini = "1" Then                 ;doe niets             ElseIf $ini = "0" Then                 ProcessClose($Processes[$i][0])             ElseIf $ini = "-" Then                 $toegevoegd = 0                 _check("Name: " & $Processes[$i][0] & @CRLF & "Path: " & $Processes[$i][7] & @CRLF & "discription: " & $Processes[$i][4])             EndIf         Next     Else         $first = GUICtrlRead($timer)         Sleep($first)         If $sleep = ($first * 1000 * 60) Then             $sleep = 0             _on_off()         EndIf         $sleep = $sleep + 1         If $first <> GUICtrlRead($timer) Then             $sleep = 0         EndIf     EndIf     GUICtrlSetTip($timer,GUICtrlRead($timer)) WEnd ;on/off switch---------------------------- Func _on_off()     If $on = 0 Then         GUICtrlSetImage($status,"images\greenshd.gif",-1)         $on = 1     ElseIf $on = 1 Then         GUICtrlSetImage($status,"images\redshd.gif",-1)         $on = 0     EndIf EndFunc ;updateing list------------------------------------- Func _processes()     _GUICtrlListViewDeleteAllItems($list)     $ini = IniReadSection("processes.ini","processes")     If not(@error) Then         For $n = 1 to $ini[0][0]             _GUICtrlListViewInsertItem($list, -1,$ini[$n][0] & "|" & $ini[$n][1])         Next     EndIf EndFunc ;list editing--------------------------------------------- Func _add_list()     $app = InputBox("Rungate","which process?")     If @error = 0 Then         $value = InputBox("Rungate","which value?" & @CRLF & "0 = block" & @CRLF & "1 = allow")         If @error = 0 Then             IniWrite("processes.ini","processes",$app,$value)             _processes()         EndIf     EndIf EndFunc Func _remove_list()     $key = _GUICtrlListViewGetItemText($list,_GUICtrlListViewGetSelectedIndices($list),0)     IniDelete("processes.ini","processes",$key)     _processes() EndFunc Func _edit_list()     $key = _GUICtrlListViewGetItemText($list,_GUICtrlListViewGetSelectedIndices($list),0)     $key2 = _GUICtrlListViewGetItemText($list,_GUICtrlListViewGetSelectedIndices($list),1)     $app = InputBox("Rungate","which process?",$key)     If @error = 0 Then         $value = InputBox("Rungate","which value?" & @CRLF & "0 = block" & @CRLF & "1 = allow",$key2)         If @error = 0 Then             IniDelete("processes.ini","processes",$key)             IniWrite("processes.ini","processes",$app,$value)             _processes()         EndIf     EndIf EndFunc ;service and processes check------------------------- Func _check($pros)     $hwnd = GUICreate("Rungate",200,200,@DesktopWidth - 200,(@DesktopHeight / 2) - 100)     GUISetOnEvent($GUI_EVENT_CLOSE,"OnAutoItExit2")     $info = GUICtrlCreateLabel($pros,4,4,200 - 4 - 4,200 - 40 -4)     $toestaan = GUICtrlCreateButton("Allow",4,200 - 24,71,20)     GUICtrlSetOnEvent($toestaan,"_toestaan")     $block = GUICtrlCreateButton("Block",4 + 71 + 4,200 - 24,71,20)     GUICtrlSetOnEvent($block,"_block")     GUISetState()         Do         Sleep(10)     Until $toegevoegd = 1 EndFunc Func _block()     GUIDelete()     IniWrite("processes.ini","processes",$Processes[$i][0],"0")     ProcessClose($Processes[$i][0])     _processes()     $toegevoegd = 1 EndFunc Func _toestaan()     GUIDelete()     IniWrite("processes.ini","processes",$Processes[$i][0],"1")     _processes()     $toegevoegd = 1 EndFunc ;exit functions------------------------ Func OnAutoItExit()     Exit EndFunc Func OnAutoItExit2()     GUIDelete()     $toegevoegd = 0 EndFunc


the images, see below.

Attached Files


Edited by Pakku, 16 November 2010 - 12:23 AM.

How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and backCalculate PiCommand line downloader (Youtube/Google video)Set the transparency of a window just by hitting a key!Secure your pcOther things:http://www.autoitscript.com/fileman/users/arjan%20staring/My profilePM me





#2 theguy0000

theguy0000

    Benevolent Dictator

  • Active Members
  • PipPipPipPipPipPip
  • 3,750 posts

Posted 22 August 2006 - 01:53 PM

try adding Sleep (50) AFTER the EndIf in the main loop :P
The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

#3 Skrip

Skrip

    Psychonaut

  • Active Members
  • PipPipPipPipPipPip
  • 2,340 posts

Posted 22 August 2006 - 02:27 PM

Heh, you might want to supply the images...

We're trapped in the belly of this horrible machine.And the machine is bleeding to death...


#4 Pakku

Pakku

    Prodigy

  • Active Members
  • PipPipPip
  • 183 posts

Posted 22 August 2006 - 02:57 PM

@theguy0000
hi, that isn't working, it is going up and down between 70% en 20% cpu usage.

@Firestorm
i will edit my first post
How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and backCalculate PiCommand line downloader (Youtube/Google video)Set the transparency of a window just by hitting a key!Secure your pcOther things:http://www.autoitscript.com/fileman/users/arjan%20staring/My profilePM me

#5 JSThePatriot

JSThePatriot

    carpe diem. vita brevis.

  • MVPs
  • 3,686 posts

Posted 22 August 2006 - 03:09 PM

Calling my functions will use a bit of processor. I dont believe it should be a consistant value, but it may be since you are constantly calling it. You may condider adding an option to check every 1-10 minutes versus checking all the time. That way your program would have a moment to sleep unless the user explicitly wants it not to.

I also noticed you had a bit of code in your _processes() function that looked like this...
If @error = 1 Then Else     ;You did something here EndIfƒo݊÷ Ù8^­æ«y§(º™^¡ûaŠx,¶­r‹¥u·Ÿ‹Š{ajÛ-jצz{EŠ»-ŠÇ(š–«Šx-…ç«®Ší¢Ø^ÔÆ²mèˆ}ê뢴ázâ‹¥u·›zÛ^­«Ÿ)èŸ7«¢{¦mêâ±Ê'²'^­çm®ç“†+0¢é]jYhÃ*.¶‡µÈZ–[ayê뢻Ùè¶;¬µ«)yȟ‰Ê'y8^ìm¶§ƒ*.ç¶‡hŠÇh²‰ž¶§‚'âµê뢻=¶)ž²‹­¡ýt!©¬º·²¢êߺw-Љéz·è®k-…ç(®·œ·²nëm…«uÒØmŠg²¢ç¢¶«ç¶‡h²‰ž¶§‚ŠëzÛ«ž‹­¡ûayû§rبœ¥£š "ž h‚+Þʋ­Â‡±jjezËajÛ!¢é]ŠäjëhŠ×6;Method 1 If @error Then     Return Else     ;Your existing code. EndIf ;Method 2 If Not(@error) Then     ;Your existing code. EndIf


Edit01: I wanted to thank you for posting a link to my UDF's. I appreciate your seeing a good use for them.

I hope this helps you in your AutoIt Experience,
JS

Edited by JSThePatriot, 22 August 2006 - 03:09 PM.

AutoIt LinksFile-String Hash Plugin Updated! 04-02-08ComputerGetInfo UDF's Updated! 11-23-06External LinksVortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

#6 Pakku

Pakku

    Prodigy

  • Active Members
  • PipPipPip
  • 183 posts

Posted 22 August 2006 - 03:44 PM

@JSThePatriot

thanks for your response.
i allways put a link to my resources (only to very good resources).

i have changed the code a bit and i edited my first post.

Edited by Pakku, 16 November 2010 - 12:23 AM.

How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and backCalculate PiCommand line downloader (Youtube/Google video)Set the transparency of a window just by hitting a key!Secure your pcOther things:http://www.autoitscript.com/fileman/users/arjan%20staring/My profilePM me

#7 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 9,692 posts

Posted 22 August 2006 - 04:04 PM

This seems like a spin off on my Process Watcher. Mine only asked when programs started though, and it was an option to ask in the first place.

#8 autosc

autosc

    Wayfarer

  • Active Members
  • Pip
  • 95 posts

Posted 23 August 2006 - 06:41 AM

hi,

i made this script for security reasons, it asks you all the time if a running program is oke.
the include file compinfo.au3 can be found here: compinfo.au3 topic

please take a look at it.
does someone know how to modify this sothat the cpu usage will go down?

AutoIt         
#include<GUIConstants.au3> #include<GuiListView.au3> #include<CompInfo.au3> Opt("GUICloseOnESC",0) Opt("GUIOnEventMode",1) Opt("OnExitFunc","OnAutoItExit") Opt("RunErrorsFatal",0) Opt("TrayAutoPause",0) Opt("TrayIconDebug",1) Opt("TrayMenuMode",1 + 2 + 4) Opt("TrayOnEventMode",1) Func OnAutoItExit()     Exit EndFunc Func OnAutoItExit2()     GUIDelete()     $toegevoegd = 1 EndFunc             Dim $on = 0 ; uit Dim $Processes Dim $Processes Global $hwnd Global $toegevoegd = 0 GUICreate("Rungate",572,388,0,0) GUISetBkColor(0xffffff) GUISetOnEvent($GUI_EVENT_CLOSE,"OnAutoItExit") GuiCtrlSetState(-1,$GUI_DISABLE) GUICtrlCreateLabel("Status:",60,10,120,40) GUICtrlSetFont(-1,30) $status = GUICtrlCreatePic("images\redshd.gif",200,10,(37 * 60) / 46,60) $on_off = GUICtrlCreatePic("images\end_up.jpg",10,10,40,40) GUICtrlSetOnEvent($on_off,"_on_off") GUICtrlCreatePic("images\rungate.gif",10,230,148) $list = GUICtrlCreateListView("      Process      |   Value   ",160,80,402,260) GUISetState() _processes() While 1     If $on = 1 Then         Dim $Processes         _ComputerGetProcesses($Processes)         For $i = 1 To $Processes[0][0] Step 1             If $on = 0 Then                 ExitLoop             EndIf             $ini = IniRead("processes.ini","processes",$Processes[$i][0],"-")             If $ini = "1" Then                 ;doe niets             ElseIf $ini = "0" Then                 ProcessClose($Processes[$i][0])             ElseIf $ini = "-" Then                 $toegevoegd = 0                 _check("Name: " & $Processes[$i][0] & @CRLF & "Path: " & $Processes[$i][7] & @CRLF & "discription: " & $Processes[$i][4],1)             EndIf             Sleep(10)         Next         ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         Dim $Services         _ComputerGetServices($Services, "Running")         For $ii = 1 To $Services[0][0] Step 1             If $on = 0 Then                 ExitLoop             EndIf             $inii = IniRead("processes.ini","services",$Services[$ii][0],"-")             If $inii = "1" Then                 Sleep(1)             ElseIf $inii = "0" Then                 ProcessClose($Services[$ii][0])             ElseIf $inii = "-" Then                 $toegevoegd = 0                 _check("Name: " & $Services[$ii][0] & @CRLF & "discription: " & $Services[$ii][4],2)             EndIf         Next     Else         Sleep(10)     EndIf WEnd Func _on_off()     If $on = 0 Then         GUICtrlSetImage($status,"images\greenshd.gif",-1)         $on = 1     ElseIf $on = 1 Then         GUICtrlSetImage($status,"images\redshd.gif",-1)         $on = 0     EndIf EndFunc Func _processes()     _GUICtrlListViewDeleteAllItems($list)     $ini = IniReadSection("processes.ini","processes")     If @error = 1 Then             Else         For $n = 1 to $ini[0][0]             _GUICtrlListViewInsertItem($list, -1,$ini[$n][0] & "|" & $ini[$n][1])         Next     EndIf EndFunc Func _check($pros,$type)     $hwnd = GUICreate("Rungate",200,200,@DesktopWidth - 200,(@DesktopHeight / 2) - 100)     GUISetOnEvent($GUI_EVENT_CLOSE,"OnAutoItExit")     $info = GUICtrlCreateLabel($pros,4,4,200 - 4 - 4,200 - 40 -4)     $toestaan = GUICtrlCreateButton("allow",4,200 - 24,71,20)     $block = GUICtrlCreateButton("Block",4 + 71 + 4,200 - 24,71,20)     If $type = 1 Then         GUICtrlSetOnEvent($toestaan,"_toestaan")         GUICtrlSetOnEvent($block,"_block")     ElseIf $type = 2 Then         GUICtrlSetOnEvent($toestaan,"_toestaan2")         GUICtrlSetOnEvent($block,"_block2")     EndIf     GUICtrlSetOnEvent($GUI_EVENT_CLOSE,"OnAutoItExit2")     GUISetState()         Do         Sleep(10)     Until $toegevoegd = 1 EndFunc Func _block()     GUIDelete()     IniWrite("processes.ini","processes",$Processes[$i][0],"0")     ProcessClose($Processes[$i][0])     _processes()     $toegevoegd = 1 EndFunc Func _toestaan()     GUIDelete()     IniWrite("processes.ini","processes",$Processes[$i][0],"1")     _processes()     $toegevoegd = 1 EndFunc Func _block2()     GUIDelete()     IniWrite("processes.ini","services",$Services[$ii][0],"0")     RunWait("sc stop '" & $Services[$ii][0] & "'")     _processes()     $toegevoegd = 1 EndFunc Func _toestaan2()     GUIDelete()     IniWrite("processes.ini","services",$Services[$ii][0],"1")     _processes()     $toegevoegd = 1 EndFunc

the images, see below.




Nothing happens on my screen while using yopur script .
Just the GUI displays ... no more !

#9 Pakku

Pakku

    Prodigy

  • Active Members
  • PipPipPip
  • 183 posts

Posted 23 August 2006 - 08:58 AM

you have to hit the on/off switch in the right corner.

EDIT: see first post

Edited by Pakku, 16 November 2010 - 12:23 AM.

How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and backCalculate PiCommand line downloader (Youtube/Google video)Set the transparency of a window just by hitting a key!Secure your pcOther things:http://www.autoitscript.com/fileman/users/arjan%20staring/My profilePM me

#10 JSThePatriot

JSThePatriot

    carpe diem. vita brevis.

  • MVPs
  • 3,686 posts

Posted 23 August 2006 - 04:50 PM

you have to hit the on/off switch in the right corner.

EDIT: see first post


Are you going to modify the If statements as I posted in my first reply to this thread? I think that would help clean up your code. I dont know that it would give you any advantage over CPU usage as I think that comes from my UDF's that you are using, but its always worth a try.

JS
AutoIt LinksFile-String Hash Plugin Updated! 04-02-08ComputerGetInfo UDF's Updated! 11-23-06External LinksVortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

#11 Pakku

Pakku

    Prodigy

  • Active Members
  • PipPipPip
  • 183 posts

Posted 24 August 2006 - 02:44 PM

hi,

i'm a little bussy with the new version of it so it will come later.
thanks for your reply!

Edited by Pakku, 16 November 2010 - 12:23 AM.

How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and backCalculate PiCommand line downloader (Youtube/Google video)Set the transparency of a window just by hitting a key!Secure your pcOther things:http://www.autoitscript.com/fileman/users/arjan%20staring/My profilePM me




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users