Skip to content

Device uuid#192

Merged
CastagnaIT merged 2 commits into
masterfrom
credfix
Sep 14, 2019
Merged

Device uuid#192
CastagnaIT merged 2 commits into
masterfrom
credfix

Conversation

@CastagnaIT

@CastagnaIT CastagnaIT commented Sep 7, 2019

Copy link
Copy Markdown
Owner

Check if this PR fulfills these requirements:

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Feature change (non-breaking change which change behaviour of an existing functionality)
  • Improvement (non-breaking change which improve functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

It is no longer possible to use MAC-address to make safe the credentials
due to security-related changes in operating systems in first place android 9 and up
So change keys to use a per device UUID

Side note for macos:
in _get_macos_uuid
the os.popen should be replaced with subprocess
however, first we need to find a user that have an apple products to run the tests

In case of Feature change / Breaking change:

Describe the current behavior

Describe the new behavior

Screenshots (if appropriate):

@CastagnaIT CastagnaIT added the WIP PR that is still being worked on label Sep 7, 2019
@CastagnaIT

CastagnaIT commented Sep 7, 2019

Copy link
Copy Markdown
Owner Author

This is only for test purpose,

  • on windows works

  • on kubunu-linux works, need to be tested like omsc

  • on MacOs/Iphone or tablets
    Need to be tested,
    according to the information on the net the system should work
    but we need someone to provide the logs for a test

  • on android
    @Smeulf you know the situations,
    I added kernel info platform as i wrote to you from python platform module,
    so the "System.OSVersionInfo" from kodi is too slow it does not get the information immediately
    often return a "Busy" text string

i checked your points @Smeulf:

  • the timezone (+3 -1 -2 etc..), i have tryied to use the tzlocal module included in kodi python but i couldn't get it to work do not recognize the module
    (I would like to avoid overloading the app by adding manually other modules)

  • System name? if you mean "windows", "linux" etc...does not seem very suitable

  • Language, i have the feeling that it is not reliable get it by a python module inside kodi

  • have bytes instead of megabytes, at the moment i didn't look for other ways

PS. you have already seen, but I say it anyway, just to make things easier as you see i put the call at the beginning, with output in the log, all temporary

@Smeulf

Smeulf commented Sep 7, 2019

Copy link
Copy Markdown

By system name I ment 'computer name'.

I agree if some data can't be retrieved correctly, then they should be excluded from UUID creation.

I gonna run some tests under:

  • Windows 10 pro x64: working

  • Windows 10 Home x86: working

  • LibreELEC for RPi: working

  • OSMC for RPi: working

  • LibreELEC for x86 (VM only): working. Also deleted the machine and build an another one, /var/lib/dbus/machine-id returns a different value for each instance.

We definitely need Android tests and MacOS. Those are the most affected by the bug, we may find some willing people :)

Can you offuscate the UUID in logs? Like keeping only the 5/10 first chars and put some stars for the remaining ones?

@CastagnaIT

Copy link
Copy Markdown
Owner Author

yes when i implement it for credentials i will eliminate all debugging output
to now it is necessary to verify that it is always same string
in the case find out how to get something more on android let me know

@Smeulf

Smeulf commented Sep 7, 2019

Copy link
Copy Markdown

@Smeulf

Smeulf commented Sep 7, 2019

Copy link
Copy Markdown

Also still thinking.
We need a way to ask for credentials again in case they can't be decrypted, at least one time, to ensure migration from previous encryption to new encryption.

I was thinking about a flag in the db like 'enc_version' = 2, so if it's not 2 then ask for credentials. But it may be wise to just handle the exception a wrong encryption key generates. I don't know what's the best way...

@CastagnaIT

Copy link
Copy Markdown
Owner Author

Not sure what data it can retrieve:
https://android.googlesource.com/platform/development/+/master/python-packages/adb/device.py

nothing of useful it can be used only from "outside" of the android device

@CastagnaIT

Copy link
Copy Markdown
Owner Author

a user who performed the macintosh test contacted me, unfortunately the code didn't work
i tryied to change the string to use subprocess:
uuid_value = subprocess.check_output("/usr/sbin/system_profiler SPHardwareDataType | awk '/UUID/ { print $3; }'")
but the command going in error without an output message
it's a little difficult to do tests without a device by hand
first of all because i don't know mac os x...and this user is not expert i can't ask for particular things

I have tried several attempts to install macosx in virtualbox to have a chance to make tests
but without success... when start machine black screen or stuck at efi boot install

@Smeulf

Smeulf commented Sep 7, 2019

Copy link
Copy Markdown

@Thunderbird2086 had the problem on Mac (see #186), maybe he would be experimented enough to help?

@CastagnaIT

Copy link
Copy Markdown
Owner Author

i have found this
https://github.com/filipp/system_profiler/blob/master/system_profiler.py
should be useful to get something working, so i hope..

@Smeulf

Smeulf commented Sep 7, 2019

Copy link
Copy Markdown

#192 (comment) updated regarding my current tests. Take a look from time to time, i'll keep update it.

@Smeulf

Smeulf commented Sep 7, 2019

Copy link
Copy Markdown

Do you need more linux version tests?
Mint, Ubuntu, Debian? Any other?
It takes sometime to download the ISOs but it's not a problem to try tomorrow or monday (on VM only)

@CastagnaIT

CastagnaIT commented Sep 7, 2019

Copy link
Copy Markdown
Owner Author

Mmh no other distributions should be use the same id path
On omsc and librelec its ok?

@Smeulf

Smeulf commented Sep 8, 2019

Copy link
Copy Markdown

On omsc and librelec its OK?

Both rebooted to confirm, all fine, UUIDs are generated and same after reboot.

I figured out you didn't change the encryption method yet hahaha

@Smeulf

Smeulf commented Sep 8, 2019

Copy link
Copy Markdown

Windows 10 x86 works fine too.

@CastagnaIT

CastagnaIT commented Sep 8, 2019

Copy link
Copy Markdown
Owner Author

as long ago microsoft said "why change a thing if it works"...
but lately it sounds strange!?🤣

I did a last test with macintosh following about the operations of the link I posted
and has WORKED! has extracted hardware information from the mac

now I have to figure out how to extract the right information

@CastagnaIT

Copy link
Copy Markdown
Owner Author

on my honor8 android is working, but as previously mentioned, every time the operating system is updated, credentials will be requested...and the strings are not very robust
the current system in android is not perfect but I cannot find other solutions that can be used
also in the latest versions of android they have denied access to all types of serials

yesterday i have found "pyjnius" to get access to android class (ANDROID_ID), but also this module have part of C... again nothing.

@CastagnaIT

Copy link
Copy Markdown
Owner Author

i have found the hostname in android
i need you can check in your andorid 9 if there is the property
you can in this way:
install app Material Terminal
After opened write: getprop | grep hostname

should be output the hostname string
let me know

@CastagnaIT

CastagnaIT commented Sep 8, 2019

Copy link
Copy Markdown
Owner Author

ok tested on an HonorPlay with android 9 it's working
now i want understand if the hash contained in hostname is always the same on other devices of same model
i asked help to xda i'm waiting a reply

@Smeulf

Smeulf commented Sep 8, 2019

Copy link
Copy Markdown

After opened write: getprop | grep hostname:

[net.hostname]: [HUAWEI_P10-38382af9f94208]

Looks interesting!

@CastagnaIT

Copy link
Copy Markdown
Owner Author

@Smeulf

Smeulf commented Sep 8, 2019

Copy link
Copy Markdown

They're trying to make us crazy?!

@CastagnaIT
CastagnaIT force-pushed the credfix branch 2 times, most recently from 29ce632 to eaab9b2 Compare September 8, 2019 17:21
@CastagnaIT

Copy link
Copy Markdown
Owner Author

that's enough for me, can you do a quick check?

@Smeulf

Smeulf commented Sep 9, 2019

Copy link
Copy Markdown

That's working, tested setting the other device first as main, the update refused to work as expected. Then set the device as main, "et voilà".

However, sometimes _compute_next_schedule shows 'Library auto update scheduled is disabled' as if it has no sufficient time to retreive g.ADDON.getSettingInt('auto_update')

Maybe we should add a xbmc.sleep(2000) to make sure the setting is correctly written on the file before getting it.

@CastagnaIT

Copy link
Copy Markdown
Owner Author

you can test with minor time like 500?
so add an argument to
_compute_next_schedule(delay=False)
and use it only with onSettingsChanged

@fateddy3496

Copy link
Copy Markdown

Hi guys. I can test android 9 and 8.1 which also didn't work. Let me know what I can help with. I'm a coder from the OLD days with a bit of time on my hands these days. Also can test windows of course.

Cheers

@Smeulf

Smeulf commented Sep 9, 2019

Copy link
Copy Markdown

@CastagnaIT 500ms is indeed sufficient.

See associated PR #202, I did it the brutal way again haha, because I don't think it's usefull to have a parameter in _compute_next_schedule. Having the delay in onSettingChange is sufficient.

@CastagnaIT CastagnaIT removed the WIP PR that is still being worked on label Sep 14, 2019
@CastagnaIT

Copy link
Copy Markdown
Owner Author

@dagwieers
can you understand why winreg is not imported correctly?

@dagwieers

Copy link
Copy Markdown
Contributor

Because it is not a Windows system ?

@CastagnaIT

Copy link
Copy Markdown
Owner Author

also adding sys.platform.startswith('win') not work

@CastagnaIT

Copy link
Copy Markdown
Owner Author

I don't understand why, the code works correctly we have already tested on all types of systems

This fixes problems with newer androids 9/10
that have random mac address and also with apple devices
@CastagnaIT
CastagnaIT merged commit 64f8091 into master Sep 14, 2019
@CastagnaIT
CastagnaIT deleted the credfix branch September 14, 2019 11:46
@dagwieers

Copy link
Copy Markdown
Contributor

pylint does code analysis based on what is available on the system. If you call modules, classes and methods, it verifies if they exist and are called correctly, without running the code. So it cannot evaluate expressions and doesn't know what parts of the code are dead for a specific platform.

So in that case you have to exclude pylint checks. It is a trade-off.

@CastagnaIT

Copy link
Copy Markdown
Owner Author

exactly i had to disable some checks

@greve greve mentioned this pull request Sep 18, 2019
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants