gregcube / unifi-mimic

Connect directly to UNVR with UniFi Protect mobile app on a different subnet.
19 stars 2 forks source link

Not working on UniFi-CloudKey-Gen2-Plus UniFi OS 3.2.7 and Protect 2.10.11 #6

Closed Gippsman2017 closed 8 months ago

Gippsman2017 commented 9 months ago

I must be be doing something wrong, but, I have run the Discover and it returned 2 files 192.168.1.6 and 192.168.1.6-1. I have then tried both and neither worked, then tried both at once, but the Unify Protect Android App still doesn't work.

On 192.168.1.0/24 Network ./unifi-mimic -D -i eth0 Returns UniFi-CloudKey-Gen2-Plus Cloudkey 192.168.1.6 192.168.1.6-1

then on 192.168.20.0/24 network ./unifi-mimic -L -i eth1 -p 192.168.1.6& ./unifi-mimic -L -i eth1 -p 192.168.1.6-1&

The App doesn't see it.

What am I doing wrong ?

gregcube commented 9 months ago

Any firewall blocking traffic?

Gippsman2017 commented 9 months ago

no, but I noticed that the app now sends out a broadcast as well as a multicast. Is is possible that one of the late 2022 updates included a subnet check ?. Also , have you been able to track down decoding the response payload, as I understand it, the integer address of the Unifi OS and Protect box is stored in it, although I haven't been able to break it down yet.

gregcube commented 9 months ago

I'm not using UniFi-CloudKey-Gen2-Plus; maybe that works different? Not sure...

The UNVR IP address (unifi_ip) is set in load_packet() when it reads the payload data in. Starts at address 13.

while (i < pkt_s && fscanf(fp, "%2hhx", &pkt_buf[i++]) == 1);
memcpy(&unifi_ip, &pkt_buf[13], sizeof(struct in_addr));

Can you paste me the contents of your two 192.168.1.6 files?

mgolik commented 9 months ago

So this was working for me for a log time but yesterday Play store updated my Protect app (on 3 devices) and it stopped working. I have UNVR not a Cloudkey but I think this may be the same issue - since Protect app release on play store was on 16.01.2024. Can I do anything to debug it? Packet capture is working but both old and new are not picked by the android app.

gregcube commented 9 months ago

It is still working for me on a UNVR running UniFi OS v3.2.9 and Protect v2.11.21. There was a UNVR OS and Protect app update recently, too. Did you install that? I'm running Protect 2.11.21 on the UNVR and Android app.

In terms of debugging, I'm not sure, maybe using wireshark to sniff out wifi traffic on your android.

mgolik commented 9 months ago

I have the same version of UniFi OS and Protect as you and Protect app was updated at 3 AM - so the same day as android app. But only after android app update is stopped working because in the morning everything was OK. I will try to capture something from my android then.

Gippsman2017 commented 9 months ago

Hi Greg, sorry for the delay, here is some tracing, I am not seeing any output from the Listener

I am running

./unifi-mimic -L -p 192.168.1.6 -i eth1 Listening on eth1:233.89.188.1:10001

The file 192.168.1.6 contains

0000007624000400001fffffff9115000e75756d5f636f6e74726f6c6c6572220017746c733a2f2f3139322e3136382e312e363a313238313202000a74ffffff83ffffffc27b7affffff9bffffffc0ffffffa8010616000d76312e32322e31372b343735332700080000000065ffffffbdffffffe0ffffffbc21000c3734383363323762376139620b000a554354524c2d37343833

tcpdump -ni eth1 -s0 -vv -X -c 1000

19:25:25.759935 IP (tos 0x0, ttl 64, id 22480, offset 0, flags [DF], proto UDP (17), length 32) 192.168.20.100.54089 > 255.255.255.255.10001: [udp sum ok] UDP, length 4 0x0000: 4500 0020 57d0 4000 4011 0df1 c0a8 1464 E...W.@.@......d 0x0010: ffff ffff d349 2711 000c 2f6f 0100 0000 .....I'.../o.... 0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............

19:25:25.759951 IP (tos 0x0, ttl 64, id 22481, offset 0, flags [DF], proto UDP (17), length 32) 192.168.20.100.54089 > 255.255.255.255.10001: [udp sum ok] UDP, length 4 0x0000: 4500 0020 57d1 4000 4011 0df0 c0a8 1464 E...W.@.@......d 0x0010: ffff ffff d349 2711 000c 2e67 0208 0000 .....I'....g.... 0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............

Hope this helps

gregcube commented 9 months ago

Something weird is definitely going on. Not sure exactly what, though. Seemingly something has changed. I started fresh and I'm seeing mixed results now. When I have some time I'm gonna dig more into it.

gregcube commented 8 months ago

It appears the mobile app (or at least on Android) no longer joins the multicast group 233.89.188.1. However, just this morning I saw another Android app update: version 1.20.0. This adds the option to manually specify a local IP address! Finally!

From the changelog:

Improvements:

  • Added ability to specify IP manually when connecting locally to the UniFi console.

I can confirm this works! You no longer need unifi-mimic.

mgolik commented 8 months ago

I can't believe they finally added it! Thank you for this project as without it using protect was very annoying!

gregcube commented 8 months ago

I'm going to close this issue. I believe unifi-mimic is pretty much useless now given the recent unifi app updates allowing direct/ local connections by IP.