Thomas’ Developer Blog

March 21, 2008

Free tracking software for your notebook! in VBS! (Vista)

Filed under: security, vbscript — Tags: , , , , , , , , , — sanzon @ 5:11 am

Well… god forbid the worse fear of most programers.. getting your computer stolen… it happened to my friend, and it got me really nervous!  So, as a result I thought to myself, I’m cheap, but I want some way of tracking my notebook if it is ever stolen.

The solution is really easy in vista and 2008 server with the new task scheduler. 

 Simply create a .vbs file that will send an email out with your current IP address information.  I’ll be dead honest, I have not a clue how to program console applications.  Yes I know a ton of .Net, but I never had a real reason to program in VB.

 So the code I modified is kind of hacked up, but it works fine.

I’m going to include it at the end, and don’t ask for a real explaination.  I can kind of figure it out through the code, but in this case, the code works and it’s easy to do.

To create the program you simply copy the code into notepad, change the username,password, and email to information, then save it as a .vbs file.

 Open up task scheduler and create a new task! (not basic task)  Then follow the the tabs.

Set it to run a program on startup with no delay, then place the vbs file in a hidden location.  I choose the classic win32 folder.  Then place it as a hidden task so no-one finds it on startup, and finally, go ahead and place a condition to wait for an internet connection.

Once connected it’ll shoot out the email with your info, and once you have that, you can easily find out the last DNS and track it down to a location to send to the police.  As well it gives the MAC, so you can figure out exactly who took it and where they are!  And it’s free!

Hope you enjoy this really simple code: (setup for use with gmail)

‘GetNics.vbs
‘Support Site: http://www.mousetrax.com
‘Author: Greg Chapman
‘Date: 5/24/2002

‘Force Declaration of Variables
Option Explicit

‘Declare Variables
Dim j, NIC1, Nic, StrNic, lngCount, StrIP, i ,objNet,objHost, mymessage

‘If something fails, move on
‘On Error Resume Next

‘Get the Computer’s network name
Set objNet=CreateObject(“wscript.Network”)
objHost=objNet.ComputerName
mymessage = mymessage & “Analysis of ” & objHost & “.”

‘Get a connection to the WMI NetAdapteConfig object
Set NIC1 = GetObject(“winmgmts:”).InstancesOf(“Win32_NetworkAdapterConfiguration”)

‘For Each of the NICs in the connection
For Each Nic in NIC1
   ‘Get the Adapter Description
   StrNIC = Nic.Description
     ‘If IP is enabled on the NIC then let’s find out about the NIC
     IF Nic.IPEnabled THEN
        lngCount=UBound(Nic.IPAddress)
        For i=0 to lngCount
           If i >= 0 Then
           mymessage = mymessage & “===================================================” & _
                vbNewLine
           mymessage = mymessage & StrNic & vbNewLine
           StrIP = vbTab & Nic.IPAddress(i)
           If StrIP <> “” Then
              mymessage = mymessage & vbTab & “IP Address = ” & _
                  StrIP

              mymessage = mymessage & vbTab & “MAC Address = ” & _
                  Nic.MACAddress

              mymessage = mymessage & vbTab & “NIC Service (Short) Name = ” & _
              Nic.ServiceName

                mymessage = mymessage & vbTab & “IP Subnet(s): ”
                For j = 0 to UBound(Nic.IPSubnet)
                    mymessage = mymessage & vbTab & vbTab & Nic.IPSubnet(j)
                Next
                mymessage = mymessage & vbTab & “Internet Database Files Path = ” & _
                     Nic.DatabasePath
                mymessage = mymessage & vbTab & “Dead Gateway Detection = ” & _
                     Nic.DeadGWDetectEnabled

                mymessage = mymessage & vbTab & “IP Gateway(s): ”
                For j=0 to UBound(Nic.DefaultIPGateway)
                     mymessage = mymessage & vbTab & vbTab & Nic.DefaultIPGateway(j)
                Next

                If Nic.DHCPEnabled Then
                    mymessage = mymessage & vbTab & “DHCP Assigned IP address = ” & _
                        Nic.DHCPEnabled

                    mymessage = mymessage & vbTab & “DHCP Server = ” & _
                        Nic.DHCPServer
                    End If

                    mymessage = mymessage & vbTab & “DNS for WINS Resolution Enabled = ” & _
                        Nic.DNSEnabledforWINSResolution

                    mymessage = mymessage & vbTab & “DNS Host Name = ” & _
                        Nic.DNSHostName

                    mymessage = mymessage & vbTab & “DNS Servers:”
                    For j=0 to UBound(Nic.DNSServerSearchOrder)
                        mymessage = mymessage & vbTab & vbTab & Nic.DNSServerSearchOrder(j)
                    Next

                    mymessage = mymessage & vbTab & “IP Port Filtering Enabled = ” & _
                        Nic.IPFilterSecurityEnabled

                    If Nic.IPFilterSecurityEnabled Then
                        mymessage = mymessage & vbTab & “IP Filtering Enabled.”
                         If Nic.IPSecPermitIPProtocols <> 0 Then
                            For j=0 to UBound(Nic.IPSecPermitIPProtocols)
                                 mymessage = mymessage & vbTab & vbTab & “Protocol: ” & _
                                      Nic.IPSecPermitIPProtocols(j)
                            Next
                         Else
                            mymessage = mymessage & vbTab & vbTab & “No Protocols Filtered”
                         End If

                         If Nic.IPSecPermitTCPPorts <> 0 Then
                            For j=0 to UBound(Nic.IPSecPermitTCPPorts)
                                 mymessage = mymessage & vbTab & vbTab & “TCP Port: ” & _
                                       Nic.IPSecPermitTCPPorts(j)
                            Next
                         Else
                            mymessage = mymessage & vbTab & vbTab & “No TCP Ports Filtered”
                         End If

                         If Nic.IPSecPermitUDPPorts <> 0 Then
                            For j=0 to UBound(Nic.IPSecPermitUDPPorts)
                                 mymessage = mymessage & vbTab & vbTab & “UDP Port: ” & _
                                      Nic.IPSecPermitUDPPorts(j)
                            Next
                          Else
                            mymessage = mymessage & vbTab & vbTab & “No UDP Ports Filtered”
                          End If
                      End If

                      mymessage = mymessage & vbTab & “LMHOSTS Lookup Enabled = ” & _
                             Nic.WINSEnableLMHostsLookup

                      mymessage = mymessage & vbTab & “WINS Lookup File = ” & _
                             Nic.WINSHostLookupFile

                      mymessage = mymessage & vbTab & “Primary WINS Server = ” & _
                             Nic.WINSPrimaryServer

                      mymessage = mymessage & vbTab & “Secondary WINS Server = ” & _
                             Nic.WINSSecondaryServer

                      mymessage = mymessage & vbTab & “WINS Scope ID = ” & Nic.WINSScopeID

                  End If
              End If
            Next
          END IF
      Next
Dim strUsername,strPassword,strSchema,objEmail

strUsername = “********************”
strPassword = “********************”
strSchema = “http://schemas.microsoft.com/cdo/configuration/
Set objEmail = CreateObject(“CDO.Message”)
objEmail.From = strUsername
objEmail.To = “********************”
objEmail.Subject = “Login Info”
objEmail.Textbody = mymessage & vbcrlf & now()
objEmail.Configuration.Fields.Item (strSchema & “sendusing”) = 2
objEmail.Configuration.Fields.Item (strSchema & “smtpserver”) = “smtp.gmail.com”
objEmail.Configuration.Fields.Item (strSchema & “smtpserverport”) = 465
objEmail.Configuration.Fields.Item (strSchema & “smtpusessl”) = 1
objEmail.Configuration.Fields.Item (strSchema & “smtpauthenticate”) = 1
objEmail.Configuration.Fields.Item (strSchema & “sendusername”) = strUsername
objEmail.Configuration.Fields.Item (strSchema & “sendpassword”) = strPassword
objEmail.Configuration.Fields.Update
objEmail.Send

Just go ahead and replace the ****s with your info.

It’s a really easy code to simply copy and paste and I want to go ahead and thank Greg Chapman for the code he provided.  Now if you want to fix it up feel free, since it’s not a very pretty email, but it does the job.  Good luck.

Advertisements

1 Comment »

  1. Thanks for the topic
    شكرا علي الموضوع
    http://www.freeprogam.com

    Comment by medo — March 22, 2008 @ 9:18 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: