Jump to content

User Block!


jvanegmond
 Share

Recommended Posts

Warning: Running this script will cause you not being abled to log into your PC. If you do want to login to your PC, then hold the --- CTRL ---- key when you are logging on or either starting up.

When you forget it's the CTRL key: Just boot up in Safe-Mode. :D

Have fun teasing your parents, roommates, little brother, friends, other relatives, or yourself.

If Not @Compiled Then
    $Run = @AutoItExe & ' "' & @ScriptFullPath & '"'
Else
    $Run = @ScriptFullPath
EndIf

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Block", "REG_SZ", $Run)

If Not _IsPressed(11) Then
    Shutdown(0)
    Exit
EndIf

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Block")

;Note: The following function is not my work. It is Scripted by ezzetabi and Jon and i, Manadar, Simply copied this from Misc.au3 which is freely downloadable from www.autoitscript.com
Func _IsPressed($s_hexKey)
    Local $a_R = DllCall('user32.dll', "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc

[Edit] Script shortened, Thanks goes to JoshDB.

Edited by Manadar
Link to comment
Share on other sites

My girlfriend soon figured out how to bypass this system by holding Ctrl as it was designed. So i have built in a password function:

Note: You will not visually be prompted to type in your password but when you press Alt + Tab you can see it is there. All you have to do is type your pre-defined password and press Enter.

If Not @Compiled Then
    $Run = @AutoItExe & ' "' & @ScriptFullPath & '"'
Else
    $Run = @ScriptFullPath
EndIf

If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Block", "Pass") = "" Then
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Block", "Pass", "REG_SZ", Encrypt(InputBox("Password?", "Set a password for this PC." & @LF & "Note that this is a one time event.", "", "*")))
EndIf
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Block", "REG_SZ", $Run)

If Not _IsPressed(11) Then
    Shutdown(0)
    Exit
Else
    While 1
        $GUI = GUICreate("", @DesktopWidth * 2, @DesktopHeight * 2, -100, -100)
        GUISetState()
        WinSetOnTop($GUI,"",1)
        $Pass = InputBox("Alert", "This computer needs a password", "" , "*")
        If $Pass = Decrypt(RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Block", "Pass")) Then
            ExitLoop
        EndIf
    WEnd
EndIf

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Block")

Func Encrypt($string)
    Local $return
    
    $chr = StringSplit($string, "")
    For $i = 1 to $chr[0]
        $n = Asc($chr[$i])
        $n += 5
        $n *= 2
        $return &= $n & " "
    Next
    
    Return $return
EndFunc

Func Decrypt($string)
    Local $return
    
    $chr = StringSplit($string, " ")
    For $i = 1 to $chr[0] - 1
        $chr[$i] /= 2
        $chr[$i] -= 5
        $chr[$i] = Chr($chr[$i])
        $return &= $chr[$i]
    Next
    
    Return $return
EndFunc

;Note: The following function is not my work. It is Scripted by ezzetabi and Jon and i, Manadar, Simply copied this from Misc.au3 which is freely downloadable from www.autoitscript.com
Func _IsPressed($s_hexKey)
    Local $a_R = DllCall('user32.dll', "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc

[edit] I also built my own simple encryption system because i was bored.

Edited by Manadar
Link to comment
Share on other sites

I don't know how that encryption system works. It doesn't make sense to me. Char is an integral type, why are you dividing by 1.2?

I also don't understand writing to ...\Run\ and then deleting it. Why do you do that? That key is for running programs. When you write it, there is a tiny program loop and then you delete it. There is no time for it to do anything. In that span of time, it wouldn't even get written to the registry. It would sit in RAM in the registry cache.

Link to comment
Share on other sites

I don't know how that encryption system works. It doesn't make sense to me. Char is an integral type, why are you dividing by 1.2?

I also don't understand writing to ...\Run\ and then deleting it. Why do you do that? That key is for running programs. When you write it, there is a tiny program loop and then you delete it. There is no time for it to do anything. In that span of time, it wouldn't even get written to the registry. It would sit in RAM in the registry cache.

Look at this like a machine: Line by line. Let me explain. The encryption system turns a character into a number and then does some sort of math on it (The math realy doesn't matter at All. So i just did something random). So, if you ask me why am i dividing by 1.2? Because I can.

Next up, when you run the script, you want it to run every time a user logs in, so you're right about that. But if the Ctrl key isn't pressed it logs the users off and ends the script, so it never actually reaches the line where it says deletion. However, if you have the ctrl key pressed you have to enter your password, whereas the booting of the script on startup should stop. So to make it more clearly you could also see it like this:

While 1
        $GUI = GUICreate("", @DesktopWidth * 2, @DesktopHeight * 2, -100, -100)
        GUISetState()
        WinSetOnTop($GUI,"",1)
        $Pass = InputBox("Alert", "This computer needs a password", "" , "*")
        If $Pass = Decrypt(RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Block", "Pass")) Then
            ExitLoop
        EndIf
    WEnd
    RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Block")
EndIf

I hope this makes sense to you.

Edited by Manadar
Link to comment
Share on other sites

I suggest you use Google with the three terms: floating point error. After reading up on that, you should re-think doing anything with floating point numbers other than floating point math.

Edit: Clarity.

Edited by Valik
Link to comment
Share on other sites

  • 3 months later...

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...