AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Retrieve your stolen Notebook (perhaps)

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
haichen



Joined: 05 Feb 2007
Posts: 189
Location: Osnabrück, Germany

PostPosted: Wed Dec 09, 2009 4:25 pm    Post subject: Retrieve your stolen Notebook (perhaps) Reply with quote

I make this small tool as an anti-theft protection.
The script starts with the PC, try to get the external IP and send an email with the pc-name and IP-number.
It does this only if the IP changes. That's all.
As you can see, it works only if the thief starts your notebook, if he login and if he is online at this moment.
Only a really dumb thief could be caught this way, but who knows.

You should compile the script with nodecompile to protect your email.


You've to do:
    Change the email params.
    Compile it with nodecompile.
    Put it somewhere on the PC.
    Start it once.

Now you get an email after PC start, including the IP-number and PC name.

Tested with Win7.


Hopefully you never need this.

Code:
/*
protect your hardware

The script starts with the PC, try to get the external IP and send an email with the pc-name and IP-number.
It does this only if the IP changes. For the autostart it writes to registry.

You've to add your email data and then you should compile the script with nodecompile.

To use it, put the compiled Exe somewhere and start it once. Then you get periodically emails with
the external IP.

author: haichen 2009

used code:
--------------
cdo com - email delivery
author sean
http://www.autohotkey.com/forum/viewtopic.php?t=39797

com - standard library
code from sean
http://www.autohotkey.com/forum/viewtopic.php?p=146242#146242

URLDownloadToVar
from Olfen
http://www.autohotkey.com/forum/viewtopic.php?p=64230#64230

Retrieve "external IP Adress"
from SKAN
http://www.autohotkey.com/forum/viewtopic.php?p=42420#42420

IP-number pattern
http://regexlib.com

Get your extern IP
http://Checkip.dyndns.org/

This script:
http://www.autohotkey.com/forum/viewtopic.php?p=316526#316526

*/
#NoTrayIcon

; filename where to store the IP-number
tmp=m189hhj.tmp
TmpFile=%WinDir%\TEMP\%tmp%

; get your external IP
MyExternalIPText := UrlDownloadToVar("http://Checkip.dyndns.org/")
pattern=\b(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5])\b
FoundPos := RegExMatch(MyExternalIPText, pattern, IP)
;-----------------------------------------------------------------
; if you install the program as a service you should comment this block
; Autostart
regname=mip
If a_isCompiled
  RegWrite,REG_SZ,HKEY_CURRENT_USER,Software\Microsoft\Windows\CurrentVersion\Run,%regname%,"%A_ScriptDir%\%A_ScriptName%"
;-----------------------------------------------------------------
; change your email params here
sFrom     := "mymail@googlemail.com"
sTo       := "mymail@googlemail.com"
sSubject  := "changed IP adress"
sBody     = External IP of  %A_ComputerName%: %ip%
sAttach   := ;"Path_Of_Attachment" ; can add Multiple attachments, the Delimiter is |

sServer   := "smtp.gmail.com" ; specify your SMTP server
nPort     := 465 ; 25
bTLS      := True ; False
nSend     := 2   ; cdoSendUsingPort
nAuth     := 1   ; cdoBasic
sUsername := "mymail@googlemail.com"
sPassword := "mymailpassword"
;-----------------------------------------------------------------

FileReadLine,oldIP,%TmpFile%,1

If ((ip<>"") and (oldIP <> ip) )
{
  FileDelete,%TmpFile%
  FileAppend, %IP%`n ,%TmpFile%

  COM_Init()
  pmsg :=   COM_CreateObject("CDO.Message")
  pcfg :=   COM_Invoke(pmsg, "Configuration")
  pfld :=   COM_Invoke(pcfg, "Fields")

  COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/Sendusing", nSend)
  COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60)
  COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserver", sServer)
  COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserverport", nPort)
  COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpusessl", bTLS)
  COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", nAuth)
  COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/Sendusername", sUsername)
  COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/SendPassword", sPassword)
  COM_Invoke(pfld, "Update")

  COM_Invoke(pmsg, "From", sFrom)
  COM_Invoke(pmsg, "To", sTo)
  COM_Invoke(pmsg, "Subject", sSubject)
  COM_Invoke(pmsg, "TextBody", sBody)
  Loop, Parse, sAttach, |, %A_Space%%A_Tab%
    COM_Invoke(pmsg, "AddAttachment", A_LoopField)
  COM_Invoke(pmsg, "Send")

  COM_Release(pfld)
  COM_Release(pcfg)
  COM_Release(pmsg)
  COM_Term()
}
Return

;functions

UrlDownloadToVar(URL, Proxy="", ProxyBypass="") {
    AutoTrim, Off
    hModule := DllCall("LoadLibrary", "str", "wininet.dll")

    If (Proxy != "")
      AccessType=3
    Else
      AccessType=1
    ;INTERNET_OPEN_TYPE_PRECONFIG                    0   // use registry configuration
    ;INTERNET_OPEN_TYPE_DIRECT                       1   // direct to net
    ;INTERNET_OPEN_TYPE_PROXY                        3   // via named proxy
    ;INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY  4   // prevent using java/script/INS

    io_hInternet := DllCall("wininet\InternetOpenA"
            , "str", "" ;lpszAgent
            , "uint", AccessType
            , "str", Proxy
            , "str", ProxyBypass
            , "uint", 0) ;dwFlags

    iou := DllCall("wininet\InternetOpenUrlA"
            , "uint", io_hInternet
            , "str", url
            , "str", "" ;lpszHeaders
            , "uint", 0 ;dwHeadersLength
            , "uint", 0x80000000 ;dwFlags: INTERNET_FLAG_RELOAD = 0x80000000 // retrieve the original item
            , "uint", 0) ;dwContext

    If (ErrorLevel != 0 or iou = 0) {
      DllCall("FreeLibrary", "uint", hModule)
      Return 0
    }

    VarSetCapacity(buffer, 512, 0)
    VarSetCapacity(NumberOfBytesRead, 4, 0)
    Loop
    {
      irf := DllCall("wininet\InternetReadFile", "uint", iou, "uint", &buffer, "uint", 512, "uint", &NumberOfBytesRead)
      NOBR = 0
      Loop 4  ; Build the Integer by adding up its bytes. - ExtractInteger
        NOBR += *(&NumberOfBytesRead + A_Index-1) << 8*(A_Index-1)
      IfEqual, NOBR, 0, Break
      ;BytesReadTotal += NOBR
      DllCall("lstrcpy", "str", buffer, "uint", &buffer)
      res = %res%%buffer%
    }
    StringTrimRight, res, res, 2

    DllCall("wininet\InternetCloseHandle",  "uint", iou)
    DllCall("wininet\InternetCloseHandle",  "uint", io_hInternet)
    DllCall("FreeLibrary", "uint", hModule)
    AutoTrim, on
    Return, res
  }
Back to top
View user's profile Send private message
Carcophan



Joined: 24 Dec 2008
Posts: 1308
Location: :noitacoL

PostPosted: Wed Dec 09, 2009 5:21 pm    Post subject: Reply with quote

Quote:
Only a really dumb thief could be caught this way, but who knows.


This is actually a good idea, but you are correct that it is not fool proof.


I don't know about your internet company, but who I subscribe too, we have 'Dynamic' IPs. The modem is issued a new IP every week or so. (I don't know why, they state security reasons)

Granted, if you are using a router, your IP will remain the same 192.169.x.x generally, but what if they thief has the same router IP as yours? Say you have a Netgear router and so does he, both Router IPs should be the same.


If you have a Static IP address this would be great.


A different idea, you may want to consider is the MAC. MAC id's are tied to modems, so even if/whem my IP changes my Modem MAC will still be 00:00:00:00:00:0a ect If the script notices that the laptop is plugged into a different modem/MAC, may be more accurate
Back to top
View user's profile Send private message
haichen



Joined: 05 Feb 2007
Posts: 189
Location: Osnabrück, Germany

PostPosted: Wed Dec 09, 2009 5:29 pm    Post subject: Reply with quote

I use http://Checkip.dyndns.org/ to get the external IP.
That's the ip your provider gives you.

Check it out!
Back to top
View user's profile Send private message
Carcophan



Joined: 24 Dec 2008
Posts: 1308
Location: :noitacoL

PostPosted: Wed Dec 09, 2009 5:39 pm    Post subject: Reply with quote

haichen wrote:
I use http://Checkip.dyndns.org/ to get the external IP.
That's the ip your provider gives you.

Check it out!


Sorry. It was my understanding that the external IP was the one that was dynamic/changes.
Back to top
View user's profile Send private message
tidbit



Joined: 09 Mar 2008
Posts: 1807
Location: Minnesota, USA

PostPosted: Wed Dec 09, 2009 5:44 pm    Post subject: Reply with quote

Carcophan wrote:
haichen wrote:
I use http://Checkip.dyndns.org/ to get the external IP.
That's the ip your provider gives you.

Check it out!


Sorry. It was my understanding that the external IP was the one that was dynamic/changes.

it is. mine changes almost daily.

it is he who is lost.
_________________
rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
Even monkeys fall from trees. - Japanese proverb


Last edited by tidbit on Wed Dec 09, 2009 5:48 pm; edited 1 time in total
Back to top
View user's profile Send private message
haichen



Joined: 05 Feb 2007
Posts: 189
Location: Osnabrück, Germany

PostPosted: Wed Dec 09, 2009 5:47 pm    Post subject: Reply with quote

The external IP change with time but nevertheless your adress can be found.
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Wed Dec 09, 2009 8:02 pm    Post subject: Reply with quote

most importantly with the external IP you can track down the ISP and find out where the IP connected from at the time with a location the Police may have cause for a search
_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Dec 10, 2009 12:38 am    Post subject: Reply with quote

Even better would be if your laptop has a GPS chip, then you can use google and give the cops the stinkin' house number!
Back to top
kakarukeys



Joined: 28 Sep 2009
Posts: 86

PostPosted: Thu Dec 10, 2009 4:28 am    Post subject: Reply with quote

I was thinking.... notepad can have gps installed. So it's easy to track the location, but not easy to protect the sensitive data from being extracted.
So maybe you can write the script to self-destruct all sensitive data on HDD, once un-authorized access is detected. Just an idea.
_________________
TypingAid autocompletion program made with AHK.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group