Detect device from webserver - proxy

we are currently working on device detection for our subscription. Problem is easy but complicated to solve.
Problem we have
Want to have premium subscription which allows you to read our published content on maximum of three devices. These devices can be smartphones, tablets, computers.
What we tried
User-Agent parsing - problem of this method is simple, if you have ONE device, you can use multiple browsers (still on one device), and UA is changing - so in the end, we thought that our customers are using more than one device.
Another problem was that UA contains minor versions of browsers and OS, so when somebody updated for example Chrome, we detect that it's new device.
Data we have in moment of authorisation
We have proxy written in LUA which is Varnish module for checking if user is logged, if have subscription and how many devices this user is using.
So we are checking device on Varnish level (which is cache level) - first level. In this case we have informations about request, cookies, ip address, user-agent...
We have a little problem with algorithm which should improve our detection. There are many possibilities but we didn't find any suitable for us.
Suggestions?
Cases which are problematic
When somebody update browser - problem with UA solution
When somebody leave wi-fi or have dynamic IP address - IP address detection problem
Set cookie - Browser related problem
When somebody want to show
desktop version of our mobile website - UA is changed
Suggestions?

Related

WLAN_BSS_LIST is updated very slow if a Hotspot is turned off

I'm currently developing a windows application which detects WiFi network changes every 10 to 15 seconds. There is no problem with detecting new mobile hotspots (updates were reflected after at least 20 or 30 seconds). However, there is a problem when a mobile hotspot is turned off as it disappears in the _WLAN_BSS_LIST after at least 90 to 120 seconds.
I used WlanScan and WlanGetAvailableNetworkList to retrieve the updated list of WiFi networks. I even used WlanRegisterNotification to notify changes thru callback. However, same behavior exists. It seems that the cache list of WiFi networks has issues when a mobile hotspot is turned off.
I also tried checking the following but behavior is still the same.
Refresh WiFi network list with 'WlanScan' (convert api syntax from c# to vba... or a workaround?)
I'm using Kotlin multiplatform to develop the application.
I'm also using the following:
I read something interesting in the Microsoft documentation (https://learn.microsoft.com/en-us/windows/win32/api/wlanapi/nf-wlanapi-wlanscan ):
The Wireless LAN Service does not send notifications when available wireless networks change. The Wireless LAN Service does not track changes to the list of available networks across multiple scans. The current default behavior is that the Wireless LAN Service only asks the wireless interface driver to scan for wireless networks every 60 seconds, and in some cases (when already connected to wireless network) the Wireless LAN Service does not ask for scans at all
Does this mean that even when I call WlanScan and WlanGetAvailableNetworkList functions to retrieve the list of networks, I would still not able to get updated list since scan is performed every 60 seconds?
So my question - Is my expectation correct that we can retrieve an updated list of WiFi network list if we call the said functions accordingly as soon as possible? If yes, what are the ways to do it?
Thank you!!

How can I find, is any wifi router connected in my network

I am trying to develop an application for network monitoring. A part of this application is to detect "is any wifi router connected to any switches ports".
Basically, I have a mysql database table where I have all the mac addresses of devices(pc,wifi router,..) connected to each switch port(by SNMP). As far I know, first three bytes of mac address (Organizationally Unique Identifier - OUI) represent the vendor/manufacturer of the device. So, I want to make a list of all known vendors who manufacture wifi routers (Linksys,TP-LINK,Netgear,SMC,..) and make a match with the OUI to the mac addresses stored in database.
Q1. Is the solution correct? or what would be the appropriate way to solve this problem.
It would be a great help if any one suggest me what should be the appropriate way.
Thanks in advance
No, this is not an appropriate solution. For example, macOS allows a Macintosh to act as a Wi-Fi router via the Internet Sharing feature, but its Ethernet MAC address will still just have a regular Apple vendor prefix.
As already stated by Gordon Davisson you will be missing "Internet sharing"-constructions, so your results will be incomplete (i.e. False Negatives).
Another source of False Negatives could be wireless routers using NICs from a large generic vendor (think Intel).
Besides that; the OUI will tell you what the device's vendor is, but NOT what kind of device it is. It could, for instance, be a WIRED router, leading to results which are not, in fact, wireless routers (i.e. False Positives).
The big pain in the behind for your problem is that what you are trying to detect; a (wireless) router; shields certain data-traffic from clients behind from means of identification that would aid you in your query.

REST call not working for phone, but does work for desktop

I have a Raspberry Pi (Model 3B I believe) which I have equipped with a simple Spring REST service. The service supports a GET method which is mapped to [HOST]:[PORT]/test/get/. All this method does is return GET call successful! immediately after being invoked.
I used ifconfig on my Raspberry Pi to get its ip address, and it seems to function fine for the desktop (works in the URL and in Postman). My problem comes in when I try to access the same exact method using my phone. Attached below are images of the two calls. The URL is exactly the same in both calls.
Also, all three devices are connected to the same wifi network.
Please try to answer why it doesn't function on my phone as opposed to finding a work around. The purpose of me using this very basic GET method is because I have more complex methods that are running into the same issue and they boil down to this obstacle.
Device Details:
Raspberry Pi 3 Model B (Uses wifi)
Desktop with Windows 10
iPhone 6 Plus
I coincidentally found the answer through another person's phone. I'm using the Google Chrome app, but that doesn't come standard on all iPhones, so this person's phone only had Safari. When I tried to access the service using Safari it said:
Which is way clearer. Upon a google search of what this means, I discovered that port 6000 is one of a number of restricted ports that are reserved for other things. So I changed the REST service to use port 6001 (which I then verified is not a restricted port) and then the service worked in both safari and chrome.
So it was just bad luck that I picked 6000 as my port. I wish Google Chrome would give a more detailed message, would have saved me a lot of time.
NOTE: This answer lists all restricted ports:
https://superuser.com/a/188070/690813

How does my computer know that it is connected to the Internet?

Sorry for asking such a mundane question, but I'm suddenly curious. If I open the network connections dialog on my Windows machine, it shows me a cute little picture of my computer connecting to a router and then to a globe (labeled Internet). What is Windows trying to connect to in order for it to decide that the computer has Internet connectivity? I assume there is no IP4 address for 'The Internet', so where is it going? Is it just sending a ping to an address back at the Microsoft home office? If that address were to disappear, would my window's machine suddenly decide that it no longer has a route to the Internet? Would Windows boxes that were 'close' to that address incorrectly report that they could get to the Internet when they couldn't.
I'll stop now before this gets too silly. But seriously, what criteria does a Windows box use to determine that it has Internet connectivity? I'm assuming that Linux and iOS systems have an equivalent feature. Do they use the same criteria?
The general IP address that is used for 'the internet' is 8.8.8.8 - or Google.com.
If you can ping it, and get a web page from it, then there's a pretty good chance you can get to at least some of the internet.
But for specifically Windows - Network Connectivity Status Indicator - it uses a different domain: dns.msftncsi.com
It will (unless disabled by GPO):
resolve the name, and verify it has the 'right' IP (131.107.255.255
fd3e:4f5a:5b81::1 )
Perform a HTTP get to this address and check it gets a result. NCSI
Presumably if different responses are retrieved, then it can tell if it has a wi-fi login or similar.
Your intuitions seem correct. I am not on a Windows machine but you could find out by firing netstat and then connecting.
If I was programming this I'd make Ping, TCP and HTTP requests. Some devices are connected through proxies such as firewalls, captive portals and others. the only way to be sure is to send something and receive a reply.
My Android device for example can detect captive portals. It probably does that by trying to HTTP connect somewhere.

Redirect Traffic from NIC to Another NIC On Separate Networks While Using Remoting

The project I'm working on is to handle data capture from scan guns (Pocket PC 2003) and process this data on a host (Win XP) then into our inventory database on a separate server (Win 2000). This is all driven by the Remoting framework provided by MS and As Good As It Gets (http://gotcf.net). The application is complete enough for a general proof of concept with both the client and server working properly while in the emulator.
All is well until I began to test using actual scan guns. Due to security concerns, the scanners are on a separate network (for clarification the 10 network) than the server (the 15 network). My development machine has dual NIC connected to both networks and can communicate with both independently. However, I am having issues with my application receiving information from the 10 network using .Net Remoting, and then sending out information to the server on the 15 network via a third party app (Combination of ODBC, Btrieve, and OLE).
Is there anyway to process information from one network then update the server on another?
Any suggestions will be greatly appreciated!
Note: I'm not very familiar with networking, thus I may be calling it the wrong name but the gun IP's start with 10...* and the server IP's start with 15...*
So long as the computer's routing table is properly configured, you shouldn't have to worry about this from your application. So long as you're using the proper IP addresses, the networking stack should take care of delivering things to the right place.
You might want to check the output of "route print" (at least I think that was available on WinXp -- if not, someone else will likely post the correct command for XP soon). In any way, you should see what network destinations are configured for which interfaces. You'll need to make sure that the server's IP on the 15 network will properly route via the interface you want (ie. the lowest-cost matching destination/netmask lists your 15 interface).
The issue seems to stem from both the NIC cards not set up properly and a so far unresolved issue with the frameworks I've chosen.
To solve the NIC problem, the easiest solution I'd found had me clear the default gateway on the 10 network.
The other issue deals with recreating the remoting objects after they've been destroyed. I currently have to warm boot the scanner in order to re-connect to the host. In order to correct this issue I'm going to contact As Good As It Gets to see what their input is. Damn firewall

Resources