Jump to content

BlackBerry BlueTooth "SmartCard"


evk86
 Share

Recommended Posts

So ive been messing around with this idea for a couple hours now... let me know what ya think.

Basically this program locks your computer when you walk away from it and unlocks it when you get back using your blackberry phone. All you need on your computer is a bluetooth chip and the supplied BlackBerry Desktop Manager from BlackBerry. For this to be able to run correctly, you need to have the Desktop Manager software set up to connect to your phone automatically and you'll need an ini file in location C:\Program Files\LockerWithBT\system.ini *or whatever you want to call it (just make sure you change it in the program)* Other than that, everything is straight forward.

#region Initialize
$list = ProcessList("LockerWithBT.exe")
If $list[0][0]>1 Then
    Exit
EndIf

#NoTrayIcon
#Include <Constants.au3>
#include <GUIConstants.au3>
#Include <Misc.au3>
#include <String.au3>
Opt("WinTitleMatchMode",2)
Opt("TrayAutoPause",0)
Opt("TrayMenuMode",1)
$PASSOPTIONS = TrayCreateItem("Password Options")
$EXIT = TrayCreateItem("Exit")
TraySetIcon("Shell32.dll",42);sets trayicon to Tree
TraySetToolTip("Locker")

PreSet()
#endregion

#region Main
Func ApplicationRunner();needs to be run constantly while armed
;Makes sure BlackBerry Desktop Manager is running:
    If Not WinExists("BlackBerry Desktop Manager") Then
        Run("C:\Program Files\Research In Motion\BlackBerry\DesktopMgr.exe")
        WinWait("BlackBerry Desktop Manager")
    EndIf
;If Prompted to connect to bluetooth device, accept
    If WinExists("Bluetooth Device Detected") Then
        Do
            ControlClick("Bluetooth Device Detected","","Button1")
        Until Not WinExists("Bluetooth Device Detected")
    EndIf
;If password is required, enter password
    If WinExists("Device Password Required") Then
        $OldTruePassword = IniRead("C:\Program Files\LockerWithBT\system.ini","BlackBerry","Pass","0")
        $OldTruePassword = _StringEncrypt(0,$OldTruePassword,"2452789479vfhvkj328vhsa",1)
        ControlSetText("Device Password Required","","Edit1",$OldTruePassword)
        Do
            ControlClick("Device Password Required","","Button1")
        Until Not WinExists("Device Password Required")
    EndIf
EndFunc

Func PreSet()
    TraySetClick(0)
    TraySetIcon("Shell32.dll",48);sets trayicon to Lock
    TrayItemSetState($EXIT, $TRAY_DISABLE)
    While 1
        $traymessage2 = TrayGetMsg()
        If Not WinExists("Connected - BlackBerry Desktop Manager") And Not WinExists("Working - BlackBerry Desktop Manager") Then
            LockDown()
        EndIf
        If $traymessage2 = $TRAY_EVENT_PRIMARYDOUBLE Then
            $PasswordCheck = EnterPassword()
            If $PasswordCheck = 1 Then
                TraySetIcon("Shell32.dll",42);sets trayicon to Tree
                TrayItemSetState($EXIT, $TRAY_ENABLE)
                TraySetClick(8)
                ExitLoop
            EndIf
        EndIf
    WEnd
EndFunc

Func EnterPassword()
    $passwordgui = GUICreate("Enter Password",150,55,-1,-1,$WS_POPUPWINDOW)
    GUICtrlCreateLabel("Enter Password to DisArm:",10,10)
    $passwordinput = GUICtrlCreateInput("",10,30,-1,-1,$ES_PASSWORD)
    GUISetState()
    WinSetOnTop("Enter Password","",1)
    while 1
        CheckCtrlAltDel()
        If _IsPressed("0D") Then
            $password = GUICtrlRead($passwordinput)
            GUIDelete()
            $OldTruePassword = IniRead("C:\Program Files\LockerWithBT\system.ini","UnArm","Pass","0")
            $OldTruePassword = _StringEncrypt(0,$OldTruePassword,"2452789479vfhvkj328vhsa",1)
            Switch $password
                Case $OldTruePassword
                    Return 1
                Case Else
                    Return 0
            EndSwitch
        EndIf
    WEnd
EndFunc

Func CheckCtrlAltDel()
    If WinExists("Task Manager") Then
        BlockInput(1)
        WinKill("Task Manager")
        MouseMove(10000,0,0)
    EndIf
EndFunc

Func GetTime()
    Switch @HOUR
        Case 00 To 11
            $hour = @HOUR
            If $hour = 00 Then
                $hour = 12
            EndIf
            $ampm = " AM"
        Case Else
            $hour = @HOUR - 12
            If $hour = 00 Then
                $hour = 12
            EndIf
            $ampm = " PM"
    EndSwitch
    $message = "COMPUTER IS LOCKED" & @CRLF & @CRLF & $hour & ":" & @MIN & ":" & @SEC & $ampm
    Return $message
EndFunc

Func LockDown()
    BlockInput(1)
    CheckCtrlAltDel()
    $mousepos = MouseGetPos()
    CheckCtrlAltDel()
    MouseMove(10000,0,0)
    CheckCtrlAltDel()
    ApplicationRunner()
    CheckCtrlAltDel()
    $splashmessage = GetTime()
    CheckCtrlAltDel()
    SplashTextOn("Computer Locked",$splashmessage,10000,10000,-1,-1,BitOr(1,32),-1,24,700)  
    CheckCtrlAltDel()
    While Not WinExists("Connected - BlackBerry Desktop Manager") And Not WinExists("Working - BlackBerry Desktop Manager")
        CheckCtrlAltDel()
        $origsplash = $splashmessage
        CheckCtrlAltDel()
        $splashmessage = GetTime()
        CheckCtrlAltDel()
        If $origsplash <> $splashmessage Then
            CheckCtrlAltDel()
            controlSetText("Computer Locked",$origsplash,"Static1",$splashmessage)
            CheckCtrlAltDel()
        EndIf
        CheckCtrlAltDel()
        WinSetOnTop("Computer Locked","Computer Locked",1)
        CheckCtrlAltDel()
        ApplicationRunner()
        CheckCtrlAltDel()
    WEnd
    SplashOff()
    MouseMove($mousepos[0],$mousepos[1],0)
    BlockInput(0)
EndFunc

Func PasswordOptions()
    $PasswordSelector = GUICreate("Password Options",230,200,-1,-1,$WS_DLGFRAME)
    $CancelButtSelect = GUICtrlCreateButton("Cancel",10,120,210,50,$BS_DEFPUSHBUTTON)
    $BlackBerrySelect = GUICtrlCreateButton("BlackBerry",10,10,100,100)
    $UnarmPasswSelect = GUICtrlCreateButton("UnArm Pass",120,10,100,100)
    GUISetState()
    Do
        $guimessage = GUIGetMsg()
    Until $guimessage = $BlackBerrySelect or $guimessage = $UnarmPasswSelect or $guimessage = $CancelButtSelect or $guimessage = $GUI_EVENT_CLOSE
    GUIDelete()
    Switch $guimessage
        Case $BlackBerrySelect
            ChangePassword("BlackBerry")
        Case $UnarmPasswSelect
            ChangePassword("UnArm")
    EndSwitch
EndFunc

Func ChangePassword($Mode)
    $PasswordChanger = GUICreate("Change " & $Mode &" Password",270,190,-1,-1,$WS_DLGFRAME)
    GUICtrlCreateLabel("Enter Old Password:",10,10,120,-1,$SS_RIGHT)
    $OldPassword = GUICtrlCreateInput("",140,8,-1,-1,$ES_PASSWORD)
    GUICtrlCreateLabel("Enter New Password:",10,40,120,-1,$SS_RIGHT)
    $NewPassword = GUICtrlCreateInput("",140,38,-1,-1,$ES_PASSWORD)
    GUICtrlCreateLabel("Re-Enter New Password:",10,70,120,-1,$SS_RIGHT)
    $RENewPassword = GUICtrlCreateInput("",140,68,-1,-1,$ES_PASSWORD)
    $CancelButton = GUICtrlCreateButton("Cancel",10,110,120,50)
    $SubmitButton = GUICtrlCreateButton("Submit",140,110,120,50)
    GUISetState()
    do
        $guimessage = GUIGetMsg()
    until $guimessage = $SubmitButton or $guimessage = $CancelButton or $guimessage = $GUI_EVENT_CLOSE
    $OldPasswordInput = GUICtrlRead($OldPassword)
    $NewPasswordInput = GUICtrlRead($NewPassword)
    $RENewPasswordInput = GUICtrlRead($RENewPassword)
    GUIDelete()
    If $guimessage = $SubmitButton Then
        If $NewPasswordInput <> $RENewPasswordInput Then
            MsgBox(0,'Password',"Passwords Do Not Match")
        Else
            $OldTruePassword = IniRead("C:\Program Files\LockerWithBT\system.ini",$Mode,"Pass","0")
            $OldTruePassword = _StringEncrypt(0,$OldTruePassword,"2452789479vfhvkj328vhsa",1)
            If $OldTruePassword = $OldPasswordInput Then
                $NewPasswordInput = _StringEncrypt(1,$NewPasswordInput,"2452789479vfhvkj328vhsa",1)
                IniWrite("C:\Program Files\LockerWithBT\system.ini",$Mode,"Pass",$NewPasswordInput)
                Msgbox(0,"Password","Password Change Successful")
            Else
                MsgBox(0,"Password","Passwords Do Not Match")
            EndIf
        EndIf
    EndIf
EndFunc

While 1
    $traymessage1 = TrayGetMsg()
    ApplicationRunner()
    Switch $traymessage1
        Case $TRAY_EVENT_PRIMARYDOUBLE
            PreSet()
        Case $PASSOPTIONS
            PasswordOptions()
        Case $EXIT
            $passwordcheck = EnterPassword()
            If $passwordcheck = 1 Then
                Exit
            EndIf
    EndSwitch
WEnd
#endregion

EDIT : in the ini file, you also need to specify the Section names as [blackBerry] and [unArm] and the Key for each to be "Pass" *no quotes

Edited by evk86
Link to comment
Share on other sites

  • Developers

You can only post in Examples after 5 posts to avoid new members posting their questions there....

Moved to Examples :P

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 1 month later...

no comments... alright thats cool

The idea sounds quite clever to me, but no so clever that I'd use it.

I haven't got a blackberry, but if I had one then the sort of thing that would happen to me would be that I'd install your script, fell pretty smug, walk away, loose my Blacberry within an hour and then go back to my computer to make an insurance claim ###**!!???

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

The idea sounds quite clever to me, but no so clever that I'd use it.

I haven't got a blackberry, but if I had one then the sort of thing that would happen to me would be that I'd install your script, fell pretty smug, walk away, loose my Blacberry within an hour and then go back to my computer to make an insurance claim ###**!!???

perhaps he could include some type of hot key over ride?

or a hard reboot.. save you some time with the insurance company!

Link to comment
Share on other sites

perhaps he could include some type of hot key over ride?

or a hard reboot.. save you some time with the insurance company!

I actually wrote in an ini checker that an outlook rule writes too if it receives an override e-mail... just in case

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