How to: Store user geolocation in a web host log file

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 1579 Views - Last Post: 05 March 2014 - 11:35 AM

#1 jase81   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

How to: Store user geolocation in a web host log file

Posted 03 March 2014 - 08:23 PM

I'd like to create a simple webpage that when the user visits, it stores (in a log file or elsewhere) the geolocation of the user, their PC details, IP and if possible their router MAC address.

Most services like Google, only display visitor data on a city/country level. If the user lets me use their geolocation I can get their location down to street and street number level, which is what I would like.

Has anyone done something like this before? Can you help me as to how to implement something like this (preferably without PHP)?

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: How to: Store user geolocation in a web host log file

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14097
  • View blog
  • Posts: 56,501
  • Joined: 12-June 08

Re: How to: Store user geolocation in a web host log file

Posted 03 March 2014 - 08:44 PM

Quote

I'd like to create a simple webpage that when the user visits, it stores (in a log file or elsewhere) the geolocation of the user, their PC details, IP and if possible their router MAC address.

Most services like Google, only display visitor data on a city/country level. If the user lets me use their geolocation I can get their location down to street and street number level, which is what I would like.

My curiosity is piqued - why?


As for mac addresses - you can't.
Was This Post Helpful? 0
  • +
  • -

#3 laytonsdad   User is offline

  • Let it rip!
  • member icon

Reputation: 466
  • View blog
  • Posts: 1,992
  • Joined: 30-April 10

Re: How to: Store user geolocation in a web host log file

Posted 03 March 2014 - 10:12 PM

I have the same question as modi- why do you need this, it seems a bit stalkerish to me.
Was This Post Helpful? 0
  • +
  • -

#4 jase81   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

Re: How to: Store user geolocation in a web host log file

Posted 03 March 2014 - 10:16 PM

View Postmodi123_1, on 03 March 2014 - 08:44 PM, said:

My curiosity is piqued - why?


As for mac addresses - you can't.

I recently had my house broken into. They took a brand new laptop, tablet etc. My plan was to create a webpage on my site and then set the homepage on my browsers to this address, with a quick redirect to Google. Then when my stolen device is online and the browser is opened, I'll get a hit. Of course I could use Prey or something, but I had another idea. What I'll do is create a folder on all my USB drives called "My Password List", which would be a hyperlink to the same webpage. Then anyone who takes my flash drive/ external HDD and opens the link, will also hand me their location. Of course I'll be relying on the user to click the yes button when asked for location, but it's better than nothing.

I know these thieves will try again, but this time I want to have a trap set.

I really want the router MAC though so when I am outside the property I can find the router that was used and using its signal strength find exactly the right house. I might have to write my own windows service or something for that one.
Was This Post Helpful? 0
  • +
  • -

#5 andile makatini   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 26-February 14

Re: How to: Store user geolocation in a web host log file

Posted 04 March 2014 - 02:48 AM

View Postjase81, on 03 March 2014 - 08:23 PM, said:

I'd like to create a simple webpage that when the user visits, it stores (in a log file or elsewhere) the geolocation of the user, their PC details, IP and if possible their router MAC address.

Most services like Google, only display visitor data on a city/country level. If the user lets me use their geolocation I can get their location down to street and street number level, which is what I would like.

Has anyone done something like this before? Can you help me as to how to implement something like this (preferably without PHP)?

Thanks


if you don't mind me asking by geolocation you mean it must keep track of where the person is logging in from??

View Postjase81, on 03 March 2014 - 10:16 PM, said:

View Postmodi123_1, on 03 March 2014 - 08:44 PM, said:

My curiosity is piqued - why?


As for mac addresses - you can't.

I recently had my house broken into. They took a brand new laptop, tablet etc. My plan was to create a webpage on my site and then set the homepage on my browsers to this address, with a quick redirect to Google. Then when my stolen device is online and the browser is opened, I'll get a hit. Of course I could use Prey or something, but I had another idea. What I'll do is create a folder on all my USB drives called "My Password List", which would be a hyperlink to the same webpage. Then anyone who takes my flash drive/ external HDD and opens the link, will also hand me their location. Of course I'll be relying on the user to click the yes button when asked for location, but it's better than nothing.

I know these thieves will try again, but this time I want to have a trap set.

I really want the router MAC though so when I am outside the property I can find the router that was used and using its signal strength find exactly the right house. I might have to write my own windows service or something for that one.

Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14097
  • View blog
  • Posts: 56,501
  • Joined: 12-June 08

Re: How to: Store user geolocation in a web host log file

Posted 04 March 2014 - 06:36 AM

Your plan seems overly complicated and convoluted... that's what lojack, prey, etc are all for and why they are not webpages.. webpages, by their inherent nature, have bare bones information.. mac addresses of the router and/or machine is way off limits.. again - that's why those security applications are applications and not websites.
Was This Post Helpful? 0
  • +
  • -

#7 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2031
  • View blog
  • Posts: 6,202
  • Joined: 15-January 14

Re: How to: Store user geolocation in a web host log file

Posted 04 March 2014 - 11:27 AM

As far as getting their location, you can get their IP address and then use a geolookup service (that doesn't need to happen all at once, if you get their IP you can do a geolookup on your own time), which you can do without asking them for anything. If you use the browser location API then it will ask for their permission, and they'll be looking at a blank page with your URL. If you want to be really tricky then you would copy the Google home page and use that code, and then add your own Javascript to it. The URL won't be right, but at least they might think that Google is asking them.
Was This Post Helpful? 0
  • +
  • -

#8 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6643
  • View blog
  • Posts: 30,932
  • Joined: 10-May 07

Re: How to: Store user geolocation in a web host log file

Posted 04 March 2014 - 11:39 AM

Most likely your stuff is formatted & sold. This project will take a long time & won't yield the results to get your stuff back.

Without proper software on the laptop, there is little to do to get it back. As suggested, install back-end connection software & get it returned.


Was This Post Helpful? 0
  • +
  • -

#9 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14097
  • View blog
  • Posts: 56,501
  • Joined: 12-June 08

Re: How to: Store user geolocation in a web host log file

Posted 04 March 2014 - 11:59 AM

Quote

I know these thieves will try again, but this time I want to have a trap set.

Then there's this statement.. which would beg to be answered by - provide a more adequate premises security so you are not using laptops as bait, but prevent the issue to begin with.
Was This Post Helpful? 1
  • +
  • -

#10 jase81   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

Re: How to: Store user geolocation in a web host log file

Posted 04 March 2014 - 02:48 PM

View Postmodi123_1, on 04 March 2014 - 11:59 AM, said:

Then there's this statement.. which would beg to be answered by - provide a more adequate premises security so you are not using laptops as bait, but prevent the issue to begin with.

Obviously I don't want anything to be stolen. I asked the police how I can deter burglars and the response I got was basically, "there's nothing you can do." I said what about CCTV, bigger locks or keeping the curtains closed so the thief won't know what's inside (I already have an alarm). The police said, it makes no difference. If they see your house is empty, they will break in and take whatever they find. I found it hard to believe, but who am I to argue with someone who investigates break-in's all day every day.

My goal isn't to bait a thief, it's to try and recover stolen goods. I have already installed Prey on my computers, but my theory behind the webpage geolocation is that I can put links on external harddrives and the set Playstation browser homepage so that if they don't wipe the device I could track it. Prey only works on computers, my solution would let me put a link (still dependent on user opening it) on any storage device. SD cards, Wii homepage, thumb drive, external HDD, XBox, whatever.

So yes, I realise it seems overly complicated, and may deliver absolutely no result, but after being robbed, I would much rather prefer to do something and have a 1 in a million chance of catching the criminal, than sitting idly by and having zero chance. The thought of the same burglars coming back to the house in the future, and maybe my wife and children walking in on them, warrants some effort on my part.

As for using the visitor IP address (which is what most site webmasters use) it is not that useful to me. In New Zealand, nearly everyone is on a dynamic IP so I would need to timestamp the IP and send it to the police/ISP etc. If I use HTML5 geolocation, the browser uses the router mac address to give the exact area where you are located (unless they're using a VPN or proxy).

TL;DR: I understand the issues, but want to proceed if possible.

So back to the question, if a user clicks to share their geolocation in an HTML5 webpage, can I somehow record their location on the server?
Was This Post Helpful? 0
  • +
  • -

#11 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6643
  • View blog
  • Posts: 30,932
  • Joined: 10-May 07

Re: How to: Store user geolocation in a web host log file

Posted 04 March 2014 - 02:52 PM

You can lookup the location of the ip. This is not ground breaking technology. But you have no way to validate that the ip hitting your wesite is actually where they are sitting behind a keyboard. There are many ways they could purposefully, or incidentally have an ip from a location that is not accurate.

For example, the isp at my shop used to show the location of Seattle Washington, even though it's actually Akron Ohio. At some point they fixed it. During maintenance it sometimes shows up as Chicago.
Was This Post Helpful? 0
  • +
  • -

#12 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14097
  • View blog
  • Posts: 56,501
  • Joined: 12-June 08

Re: How to: Store user geolocation in a web host log file

Posted 04 March 2014 - 03:10 PM

One more thing - 'geolocation' is not exact. Running geolocation (via a browser) returns a lat/long that is about 15+ miles away.

Quote

So yes, I realise it seems overly complicated, and may deliver absolutely no result, but after being robbed, I would much rather prefer to do something and have a 1 in a million chance of catching the criminal, than sitting idly by and having zero chance.

Then get the professional grade software installed, and put aside this Scooby-doo-esque plan.

For less than trackable items etch your name and some specific number on it.. Write down your device's MAC address.. keep the serial number.. install a CCTV. Hell there's studies that suggest having one of those 'this house is protected by X alarm' signs staked out reduces the risk because thieves tend to be opportunists and path of least resistance when burgling.


That all being said - it's pretty simple to use the geolocation information.. once you have that you can pop that into a database via ajax, php, or what ever.

https://developer.mo...CurrentPosition


<html>



<script>

function getPagesLoc()
{
   var foo = document.getElementById("demo");	

// see if geoloc is on.
    if (navigator.geolocation)
    {
// if so provide a callback function to the navigator.geolocation.. per the api.
	navigator.geolocation.getCurrentPosition(barDealWithLoc);

	foo.innerHTML="Lat: " + position.coords.latitude + 
        "<br>Lon: " + position.coords.longitude;  
    }
    else
    {
        foo.innerHTML="Geoloc is not supported";
    }

}

function barDealWithLoc(position)
{
var x = document.getElementById("demo");
// puke out the variables.. deal with as needed.
    x.innerHTML="Latitude: " + position.coords.latitude + 
        "<br>Longitude: " + position.coords.longitude;  
	
}
 
</script>


<body>

<button onclick="getPagesLoc()">asdf</button>
<br />
<br />
<div id="demo">here</div>

</body>
</html>





This post has been edited by modi123_1: 04 March 2014 - 03:25 PM

Was This Post Helpful? 0
  • +
  • -

#13 jase81   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

Re: How to: Store user geolocation in a web host log file

Posted 04 March 2014 - 03:38 PM

View Postno2pencil, on 04 March 2014 - 02:52 PM, said:

You can lookup the location of the ip. This is not ground breaking technology. But you have no way to validate that the ip hitting your wesite is actually where they are sitting behind a keyboard. There are many ways they could purposefully, or incidentally have an ip from a location that is not accurate.

For example, the isp at my shop used to show the location of Seattle Washington, even though it's actually Akron Ohio. At some point they fixed it. During maintenance it sometimes shows up as Chicago.

Correct, IP location is done by the internet provider assigning ranges of IP's to specific geographic regions. HTML5 geolocation on the other hand actually takes your router mac address, and thanks to wonderful people at Google, they know exactly where your router is located (down to router signal accuracy).
Was This Post Helpful? 0
  • +
  • -

#14 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2031
  • View blog
  • Posts: 6,202
  • Joined: 15-January 14

Re: How to: Store user geolocation in a web host log file

Posted 04 March 2014 - 04:04 PM

That's not how it works. The web browser does not have access to any MAC address, for anything. It does not even have access to it. MAC addresses are not saved or used in any way in Javascript. MAC addresses are not sent as part of the HTTP protocol. HTML5 geolocation is accomplished by multiple ways. On a mobile device, for example, you have a GPS that it can use to get the location that way. Or, if the GPS is unavailable, it can contact the nearest cell towers and attempt to triangulate its position, which is less accurate than GPS. If neither GPS nor the cell radio are available then it falls back to even lower-resolution ways, such as down to looking up your IP address in a database that indicates the general area where it is assigned. The MAC address is not part of any of those, it's not even part of HTTP. Your IP address, not MAC address, is part of HTTP. The MAC might be included in something like TCP or IP, but definitely not HTTP.
Was This Post Helpful? 0
  • +
  • -

#15 jase81   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

Re: How to: Store user geolocation in a web host log file

Posted 04 March 2014 - 05:12 PM

View PostArtificialSoldier, on 04 March 2014 - 04:04 PM, said:

That's not how it works. The web browser does not have access to any MAC address, for anything. It does not even have access to it. MAC addresses are not saved or used in any way in Javascript. MAC addresses are not sent as part of the HTTP protocol. HTML5 geolocation is accomplished by multiple ways. On a mobile device, for example, you have a GPS that it can use to get the location that way. Or, if the GPS is unavailable, it can contact the nearest cell towers and attempt to triangulate its position, which is less accurate than GPS. If neither GPS nor the cell radio are available then it falls back to even lower-resolution ways, such as down to looking up your IP address in a database that indicates the general area where it is assigned. The MAC address is not part of any of those, it's not even part of HTTP. Your IP address, not MAC address, is part of HTTP. The MAC might be included in something like TCP or IP, but definitely not HTTP.

I'm not saying the MAC address is in HTTP, Google allow you to search a location based on (among other things) MAC address: https://developers.g...ss/geolocation/

When an HTML5 webpages says "Allow us to access your location" your browser builds a geolocation access token which is then used to query your location. The contents of the token are stored by Mozilla, Google, Apple and Microsoft (and other providers) and have been built up in a database of all wifi networks and cell towers everywhere. When your friend walks into you house with his iPhone on, his phone picks up your home wifi mac address from your router ethernet packet header. It sends that off to Apple with his GPS location. Everyone is doing this all the time so Google etc have extremely accurate coordinates for every wifi network around. When you say use geolocation, your browser creates an access token (using your MAC address and neighbors wifi, mac addresses) and send it all off to Google. It expires after two weeks at which point, your browser will generate a new token.


http://help.opera.com/Linux/11.00/en/geolocation.html said:

How does geolocation work? How well does it work?

It depends on the device, and its way of connecting to the Internet.

If the device is a desktop computer, without any wireless connections, the IP address is used to determine the device's location, and the measurement is rather crude.

To determine the location of a laptop or other wireless device, Opera may in addition send the following data from nearby Wi-Fi access points:

MAC address (uniquely identifies the hardware)
signal strength (tells how far away it is)



IP packets do not contain MAC address info. Ethernet packets which your router broadcasts do. Google knows your routers MAC address. That's just the way it is.

This post has been edited by jase81: 04 March 2014 - 05:17 PM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2