Javascript access to hardware?
I work for a company that has web and mobile apps. They are going to implement some changes to get a device ID from mobile AND web browser based system. Looks like Javascript has some ability to get hardware info like motherboard serial number etc. I was a bit shocked by this since I though my desktop browser was somewhat limited in this respect.
So, my question to this group is:
- Is开发者_如何学编程 this true for WIN/MAC/Linux desktop systems running different browsers?
- Anyway to block this and have some control over what unscrupulous vendors/agencies can strip mine from my system?
This is completely false.
In-browser Javascript (without the use of plugins) has no hardware access, and (I strongly assume) never will have.
In general, browser makers (such as Microsoft's IE, Google Chrome, Mozilla Firefox, etc) do not supply JavaScript mechanisms for accessing specific hardware information.
However, in some browsers (especially "legacy" browsers such as IE6) the use of ActiveX, plugins, Java Applets, or even specific browser exploits can reveal this kind of information by executing code outside of the secure confines of the browser. What platform does your employer expect this information to be retrieved from?
Here's an example using ActiveX through JavaScript.
I have personally tested this code in IE8. It correctly displays motherboard information, including serial number. IE8 prompts me to allow the script to run, but an older version or poorly-configured version may run the script unconditionally. (Original Source):
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_BaseBoard");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.HostingBoard + "</td>");
document.write("<td>" + p.Manufacturer + "</td>");
document.write("<td>" + p.PoweredOn + "</td>");
document.write("<td>" + p.Product + "</td>");
document.write("<td>" + p.SerialNumber + "</td>");
document.write("<td>" + p.Version + "</td>");
document.write("</tr>");
}
document.write("</table>");
To prevent this from happening to your machine, use a modern browser (IE9, FF4+, Chrome) and always keep it up to date. Additionally, be mindful of what plugins you install and more importantly, where you install them from.
- No. Proof: FireFox, Chrome/Chromium, to name a few.
- Don't worry. JavaScript won't get access to these resources
A browser cannot access hardware information.
There are other javascript tools like Titanium or node.js that may access hardware or any other information.
精彩评论