S.P.U.T.0, Sistema Protettivo Ultimo - Tentativo 0

« Older   Newer »
  Share  
riki107
icon1  CAT_IMG Posted on 25/5/2013, 23:42 by: riki107     +1   -1




Salve a tutti :)

Ecco a voi "S.P.U.T.0", ovvero il "Sistema Protettivo Ultimo - Tentativo 0" :asd:

Versione 2.0.0 ! ^_^

-------------------------

Roba della prima versione qui sotto :)

Spiegazione:
CODICE
Questo piccolo programmino, interamente gestito dalla TrayIcon, permette di proteggere il pc in maniera molto efficiente (almeno a parer mio, datemi conferma):

- Una volta settata la password, premendo avvia si avvierà la protezione, che consiste in:
          - Bloccare il mouse
          - Riavviare lo script premendo i tasti ALT, CTRL, WIN, ESC (onde evitare chiusura forzata attraverso scorciatoie di sistema)
          - Se attivo, chiudere il Task Manager (per evitare la chiusura attraverso esso)

- Per rimuovere la protezione è necessario premere shift e, una volta comparsa la InputBox, digitare la password e premere invio

- Il metodo di criptazione della password è stato creato da me (non è molto potente, ma penso sia abbastanza sicuro)


Questa è la prima versione, ma conto di svilupparla sempre di più :')

Codice:
CODICE
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=wmploc_815.ico
#AutoIt3Wrapper_Res_Comment=Sistema Protettivo Ultimo - Tentativo 0
#AutoIt3Wrapper_Res_Fileversion=0.1.0.1
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_Language=1040
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ---------------------------------------------------------
      Nome programma:

      S.P.U.T.0
      cioè
      Sistema Protettivo Ultimo - Tentativo 0

      Data di inizio progetto: 30 aprile 2013, 21.08.29

      Autore: Riccardo Salerno

      Obiettivo: Creare un sistema di protezione del pc abbastanza efficente
#ce ---------------------------------------------------------

#include "(De)Cript Math.au3"
#include <Misc.au3>
#include <Security.au3>
#include <SendMessage.au3>

Opt("WinTitleMatchMode", 4)
Opt("TrayMenuMode", 3)



TraySetIcon("C:\WINDOWS\system32\wmploc.dll", -66)
TraySetToolTip("S.P.U.T.0 (Sistema Protettivo Ultimo - Tentativo 0)")

Global $keys[5] = ["A0", "12", "11", "1B", "5B"] ; LEFT SHIFT, ALT, CTRL, ESC, LEFT WIN
Global $dll = "user32.dll"

Global $sec = False
Global $new = False

Global $sAccount = @UserName
Global $tSID = _Security__GetAccountSid($sAccount)
Global $sStringSID = _Security__SidToStringSid($tSID)
Global $Fp = @UserProfileDir & "\{" & $sStringSID & "}\S.P.U.T.0\lock.k" ; File con pass

$MenuItem1 = TrayCreateItem("Avvia")
$MenuItem2 = TrayCreateItem("Cambia password")
TrayCreateItem("")
$Help = TrayCreateItem("Help")
$MenuItem3 = TrayCreateItem("About")
TrayCreateItem("")
$MenuItem4 = TrayCreateItem("Esci")
TraySetState()

AdlibRegister("_Warning", 250)

_Lol()

Func _Lol()

If Not FileExists($Fp) And Not FileExists($Fp & ".mC") Then _FirstRun()

If StringRight(FileRead(@UserProfileDir & "\{" & $sStringSID & "}\S.P.U.T.0\s.k"), 1) = 1 Then _Start()


While 1
       $nMsg = TrayGetMsg()
               Switch $nMsg
                       Case $MenuItem1
                               _Avvia()
                       Case $MenuItem2
                               _ChangePass()
                       Case $Help
                               _Help()
                       Case $MenuItem3
                               _About()
                       Case $MenuItem4
                               _Esci()
               EndSwitch
WEnd

EndFunc

Func _Avvia()

       While 1

               If FileRead($Fp) = "" And Not FileExists($Fp & ".mC") Then
                       $CheckP = MsgBox(4, "S.P.U.T.0 - Attezione", "Non hai ancora impostato una password." & @CRLF & "Per attivare la protezione è necessario impostarne una." & @CRLF & "Vuoi procedere ora?")
                               If $CheckP = 6 Then
                                       $new = True
                                       _SetPass()
                                       Return
                               Else
                                       Return
                               EndIf
               Else
                       _Start()
               EndIf

       WEnd

EndFunc   ;==>_Avvia

Func _Start()

       $sec = True

       _SendMessage(WinGetHandle("ClassName=Progman"), 274, 61808, 2) ; Spegne lo schermo

   While 1
               If _IsPressed($keys[0], $dll) Then
                       _Unlock()
                       Return
               EndIf
   WEnd

EndFunc   ;==>_Start

Func _Reload()

       If @Compiled Then
               Run(@ScriptFullPath & ' ' & $CmdLineRaw, @ScriptDir, Default, 1)
               Exit
       Else
               Run(@AutoItExe & ' "' & @ScriptFullPath & '" ' & $CmdLineRaw, @ScriptDir, Default, 1)
               Exit
       EndIf

EndFunc   ;==>_Reload

Func _Unlock()

       $IB = InputBox("Inserisci la password di sblocco", "Per sbloccare il computer, inserisci la password corretta...", "", "+M")
               If @error = 1 Then _Start()

       FileSetAttrib($Fp & ".mC", "-H")
       _mDecript($Fp & ".mC")

       If FileRead($Fp) = $IB Then
               _mCript($Fp)
               FileSetAttrib($Fp & ".mC", "+H")
               $sec = False
               FileOpen(@UserProfileDir & "\{" & $sStringSID & "}\S.P.U.T.0\s.k", 2)
               FileWrite(@UserProfileDir & "\{" & $sStringSID & "}\S.P.U.T.0\s.k", "0")
               FileClose(@UserProfileDir & "\{" & $sStringSID & "}\S.P.U.T.0\s.k")
               Sleep(100)
               _Lol()
       Else
               _mCript($Fp)
               FileSetAttrib($Fp & ".mC", "+H")
               _Start()
       EndIf

EndFunc   ;==>_Unlock

Func _FirstRun()

       TrayTip("Benvenuto in S.P.U.T.0!", "Ciao " & $sAccount & "!" & @CRLF & "Cliccami per accedere alle opzioni!", 4)

       DirCreate(@UserProfileDir & "\{" & $sStringSID & "}\S.P.U.T.0\")
       FileOpen(@UserProfileDir & "\{" & $sStringSID & "}\S.P.U.T.0\lock.k", 1)
       FileClose(@UserProfileDir & "\{" & $sStringSID & "}\S.P.U.T.0\lock.k")
       FileSetAttrib(@UserProfileDir & "\{" & $sStringSID & "}\", "+H", 1)

       Sleep(1000)

       If FileRead($Fp) = "" And Not FileExists($Fp & ".mC") Then

               $CheckP2 = MsgBox(4, "S.P.U.T.0 - Attezione", "Devi impostare una password per rendere efficente la protezione." & @CRLF & "Vuoi procedere ora?")

               If $CheckP2 = 6 Then
                       _SetPass()
                       Return
               Else
                       Return
               EndIf
       EndIf

EndFunc   ;==>_FirstRun

Func _SetPass()

       $Set1 = InputBox("Imposta password", "Imposta una password per rendere efficente la protezione.", "", "+M")
               If @error = 1 Then Return
       $Set2 = InputBox("Imposta password", "Per sicurezza, reinserisci la password appena immessa.", "", "+M")
               If @error = 1 Then Return

       If $Set1 <> $Set2 Then
               $sErMsg = MsgBox(4, "S.P.U.T.0 - Errore", "Attenzione! Le due password non coincidono." & @CRLF & "Vuoi riprovare?")
               If $sErMsg = 6 Then
                       _SetPass()
               Else
                       Return
               EndIf
       Else
               $Op = FileOpen($Fp, 1)
               FileWrite($Op, $Set1)
               FileClose($Op)
               Sleep(1000)
               FileSetAttrib($Fp, "-H")
               _mCript($Fp)
               FileSetAttrib($Fp & ".mC", "+H")
                       If $new = True Then
                               $new = False
                               _Avvia()
                       Else
                               _Lol()
                       EndIf
       EndIf

EndFunc   ;==>_SetPass

Func _ChangePass()

       If FileRead($Fp & ".mC") = "" And Not FileExists($Fp & ".mC") Then

               $CheckP1 = MsgBox(4, "S.P.U.T.0 - Attezione", "Non hai ancora impostato una password." & @CRLF & "Vuoi procedere ora?")
                       If $CheckP1 = 6 Then
                               _SetPass()
                               Return
                       Else
                               Return
                       EndIf
       Else
               $Set0 = InputBox("Imposta password", "Inserisci la vecchia password.", "", "+M")
                       If @error = 1 Then Return
               $Set1 = InputBox("Imposta password", "Imposta una nuova password.", "", "+M")
                       If @error = 1 Then Return
               $Set2 = InputBox("Imposta password", "Per sicurezza, reinserisci la password appena immessa.", "", "+M")
                       If @error = 1 Then Return

                       If $Set1 <> $Set2 Then
                               $sErMsg = MsgBox(4, "S.P.U.T.0 - Errore", "Attenzione! Le due nuove password non coincidono." & @CRLF & "Vuoi riprovare?")
                               If $sErMsg = 6 Then
                                       _ChangePass()
                                       Return
                               Else
                                       Return
                               EndIf
                       Else
                               FileSetAttrib($Fp & ".mC", "-H")
                               _mDecript($Fp & ".mC")
                               If $Set0 <> FileRead($Fp) Then
                                       _mCript($Fp)
                                       FileSetAttrib($Fp & ".mC", "+H")
                                       $erPASScheck = MsgBox(4, "S.P.U.T.0 - Errore", "Attenzione! Password errata!" & @CRLF & "Vuoi riprovare?")
                                               If $erPASScheck = 6 Then
                                                       _ChangePass()
                                                       Return
                                               Else
                                                       Return
                                               EndIf
                               Else
                                       $opn = FileOpen($Fp, 2)
                                       FileWrite($opn, $Set1)
                                       FileClose($opn)
                                       _mCript($Fp)
                                       FileSetAttrib($Fp & ".mC", "+H")
                                       Return
                               EndIf
                       EndIf

       EndIf
EndFunc   ;==>_ChangePass

Func _Help()

       Local $m1 = 'Utilizzare S.P.U.T.0 è semplicissimo:'&@CRLF&@CRLF&'- Una volta premuto "Avvia", schermo si oscurerà'&@CRLF
       Local $m2 = '- Mouvendo il mouse tornerà visibile'&@CRLF&'- Premendo il tasto SHIFT apparirà il campo immettere la password'&@CRLF
       Local $m3 = '- Una volta inserita, premere INVIO per disattivare la protezione'&@CRLF&@CRLF
       MsgBox(0, "S.P.U.T.0 - Help", $m1&$m2&$m3&'Per info o malfunzionamenti, contattami via e-mail: rikisale@gmail.com')
       Return

EndFunc   ;==>_Help

Func _About()

       MsgBox(0, "S.P.U.T.0 - About", "Creato da Riccardo Salerno"&@CRLF&"rikisale@gmail.com"&@CRLF&@CRLF&"Vieni a trovarmi anche su"&@CRLF&"www.autoit.forumcommunity.net")
       Return

EndFunc   ;==>_About

Func _Esci()

       $ex = MsgBox(4, "S.P.U.T.0 - Chiusura", "Vuoi veramente uscire?")
       If $ex = 6 Then
       _MouseTrap()
       AdlibUnRegister("_Warning")
       Exit
       EndIf

EndFunc   ;==>_Esci

Func  _Warning()

$MGP = MouseGetPos()

If $sec = True Then

       If $MGP[0] < ((@DesktopWidth / 2) - (1 / 2)) Or $MGP[0] > ((@DesktopWidth / 2) + (1 / 2)) Or $MGP[1] < ((@DesktopHeight / 2) - (1 / 2)) Or $MGP[1] > ((@DesktopHeight / 2) + (1 / 2)) Then
               _MouseTrap((@DesktopWidth / 2) - (1 / 2), (@DesktopHeight / 2) - (1 / 2), (@DesktopWidth / 2) + (1 / 2), (@DesktopHeight / 2) + (1 / 2))
       EndIf

       If _IsPressed($keys[1], $dll) Then
               FileWrite(@UserProfileDir & "\{" & $sStringSID & "}\S.P.U.T.0\s.k", "1")
               _Reload()
       ElseIf _IsPressed($keys[2], $dll) Then
               FileWrite(@UserProfileDir & "\{" & $sStringSID & "}\S.P.U.T.0\s.k", "1")
               _Reload()
       ElseIf _IsPressed($keys[3], $dll) Then
               FileWrite(@UserProfileDir & "\{" & $sStringSID & "}\S.P.U.T.0\s.k", "1")
               _Reload()
       ElseIf _IsPressed($keys[4], $dll) Then
               FileWrite(@UserProfileDir & "\{" & $sStringSID & "}\S.P.U.T.0\s.k", "1")
               _Reload()
       ElseIf ProcessExists("taskmgr.exe") Then
               ProcessClose("taskmgr.exe")
       EndIf

ElseIf $sec = False Then

       If $MGP[0] < ((@DesktopWidth / 2) - (1 / 2)) Or $MGP[0] > ((@DesktopWidth / 2) + (1 / 2)) Or $MGP[1] < ((@DesktopHeight / 2) - (1 / 2)) Or $MGP[1] > (( @DesktopHeight / 2) + (1 / 2)) Then
               _MouseTrap()
       EndIf

EndIf

EndFunc   ;==>_Warning

Metodo di criptazione, ovvero l'include "(De)Cript Math.au3":
CODICE
#include <Math.au3>

; #FUNCTION# ====================================================================================================================
; Name ..........: _mCript
; Description ...: Cripta Stringhe o Files con un algoritmo matematico-logico. Restituisce un file con estensione aggiuntiva ".mC"
; Syntax ........: _mCript($file)
; Parameters ....: $File                - Percorso del file.
; Return values .: Success: True
;                                   Failure:
;                                                        0 = File Not Found
;                                                        1 = File Already Cripted
; Author ........: Riccardo Salerno
; Modified ......: 01/05/2013 13.15
; Remarks .......: Requires <Math.au3>
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================

Func _mCript($file)

If Not FileExists($file) Then
       Return (0)

ElseIf StringTrimRight($file, 3) = ".mC" Then
       Return (1)

Else
       $Opnd1 = FileOpen($file)
       Global $k = StringToASCIIArray(FileRead($Opnd1))
       FileClose($Opnd1)
       $Opnd = FileOpen($file, 2)

       For $crypt = 0 To UBound($k)-1

               If $k[$crypt] > 3 And _MathCheckDiv($k[$crypt], 2) = 2 Then
                       $k[$crypt] /= 2
               ElseIf $k[$crypt] > 3 And _MathCheckDiv($k[$crypt], 2) = 1 Then
                       $k[$crypt] += 255
               Else
                       $k[$crypt] -= 2
               EndIf

       If $k[$crypt] = $k[UBound($k)-1] Then
               FileWrite($Opnd, $k[$crypt])
       Else
               FileWrite($Opnd, $k[$crypt]&"-")
       EndIf

       Next

       FileClose($Opnd)

       FileMove($file, $file&".mC")

       Return (True)
EndIf

EndFunc

; #FUNCTION# ====================================================================================================================
; Name ..........: _mDecript
; Description ...: Decripta Stringhe o Files con estensione ".mC", criptati con _mCript
; Syntax ........: _mDecript($file)
; Parameters ....: $File                - Percorso del file.
; Return values .: Success: True
;                                   Failure:
;                                                        0 = File Not Found
;                                                        1 = File has not the ".mC" extension
; Author ........: Riccardo Salerno
; Modified ......: 01/05/2013 13.26
; Remarks .......: Requires <Math.au3>
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================

Func _mDecript($file)

If Not FileExists($file) Then
       Return (0)

ElseIf StringRight($file, 3) <> ".mC" Then
       Return (1)

Else
       $Opnd1 = FileOpen($file)
       $read = FileRead($Opnd1)
       Global $s = StringSplit($read, "-", 1)
       Global $us = UBound($s)

       For $decrypt = 1 To $us-1

               If $s[$decrypt] < 2 Then
                       $s[$decrypt] += 2
               Elseif $s[$decrypt] > 1 And $s[$decrypt] < 123 Then
                       $s[$decrypt] *= 2
               Else
                       $s[$decrypt] -= 255
               EndIf

       Next

       $Opnd = FileOpen($file, 2)
       $wr = StringFromASCIIArray($s, 1, UBound($s))
       FileWrite($Opnd, $wr)

       FileClose($Opnd)

       FileMove($file, StringTrimRight($file, 3))

       Return (True)

EndIf

EndFunc


Bug conosciuti:
- Attualmente prende molta CPU durante la protezione, conto di fixare questo bug a breve. Ho tentato il fix, mi serve un tester per conferma. :)
- Protezione non funzionante durante l'inserimento password (In fase di correzione)

Bug Fixati:
- Ridotto il consumo eccessivo di CPU (forse)
-Risolto un problema inerente l'inserimento delle password negli InputBox (sfasavano premendo "annulla")

Ah, dimenticavo la cosa più importante: vado molto fiero di questo codice. :yum:
Proprio per questo, se avete consigli su come migliorarlo, dubbi o critiche, non esitate a scriverle qui sotto :)

Archivio con Codici+Exe+Ico

Peace and Love :)

Edited by riki107 - 19/7/2013, 00:46
 
Top
46 replies since 25/5/2013, 23:42   578 views
  Share