Question related to hardware, arduino etc - android

Is there any possibility to get the number from the mobile sim card using any sensor ???
For example, if a person have a mobile phone in her hand and when the person pass from the gate we want to get the number of that sim card whose in her mobile phone!

Not possible!! You cannot get the number directly from the Simcard chip.
The encrypted data and some other data!
https://www.elprocus.com/how-sim-card-works/
You can read the above article to be more clear!

No. Telephone number isn't stored on a sensor, it is obtained from the network, and if you want to make it available to your application you will need to have obtained permission to the telephony service, and you can then access it through a TelephonyManager object.

Related

Trusted source of time for JavaCard applet on SIM

I have a JavaCard applet working on Gemalto SIM card in a smartphone. I would like to create an electronic wallet with validity to a specifed date and time.
I know this is impossible using a classic smartcard, which has no clock inside because of absence of the battery. However, with a SIM card it might be possible: a SIM card must have some access to network time (not the local system time, which can be changed by the user) when connected to the network and the last known network time value could be probably stored somewhere on the SIM card.
Is there any way to access the last known network time from my applet in a secure way? (I do not trust any application installed in the phone, because it could be easily hacked)
Do you think there is any other solution of my problem?
EDIT
I did not mention the reason why I think about this: I need to solve this problem without the Internet connection, because my customers are supposed to use my electronic wallet without the Internet connection in their phones. They need to use it in subway where there is no signal and some of them do not pay for the Internet connection at all. So my application must be able to find out the time offline.
EDIT 2
On Android phones, there is an option:
That means there is some user-independent source of time. The question is, if it can be accessed somehow in a secure way from a JavaCard applet on the SIM card. (or if the last known value can be accessed in the case of no connection)
It depends on your project. You have 3 solutions. one is for cases that you have access to Internet on the phone and two for cases you don't.
If you have Internet access :
In the phone application installation step, it sends the IMSI of the SIM card to a server that you established already via a https channel(Optional!).
Your server records that IMSI and the date of installation in a database table in the server.
Henceforth, each time that the phone application want to start a session with the SIM applet, it must send a request to your server and the server respond that request with an encrypted(its current date+IMSI_counter).
If the phone application receive the answer successfully sends it and the time of phone (in plain) to the SIM applet.
The SIM applet encrypt the "plain phone date+IMSI+counter" itself with the same secret key that we used in server and then it compare the result with the value that its server sent to mobile phone.
If both are equal, that means that the time of the phone is the same time of your server.
Using the above procedure, in cases that you don't want the SIM applet to work anymore, you can send an invalid encrypted value in the respond of phone application requests.
If you don't have Internet access :
All SMS packets enveloped concatenated with current time of server but normally, the operator sends its packets to a special applet on the card. I mean the packets has a header that indicate the AID of its applet in the card. The SIM card analyze and decrypt this packet data and the body of it return to phone (For calls and SMS-s, and not for OTA envelopes).In this procedure the data (both encrypted and decrypted) are not shared on the SIM. So if you install an applet on the SIM, there is no way to gain those data (Including the network current time) and you must use one of the following options :
Request your network operator to send a time envelope to your applet (i.e. the header of the packet indicate your applet AID) every day and automatically. (Using this method you don't need to do anything in your phone application anymore)
or:
Using the network-time section of other SMS-s on the phone using your phone application. (Using this method you need to require the SMS sending/receiving reading/writing privilege from the phone in your phone app installation and you don't need to ask the operator to do anything special for you!)

How to find out phone number of a sim given its IMEI number?

I have a dual sim Android phone. Using this solution I retrieve IMEI numbers of both sims.
Given the IMEI number, how can I find out the phone number of each sim?
There are methods getDeviceIdGemini(int slotId) and getSimStateGemini(int slotId) it is possible to find out the IMEI number and the state of each sims.
I'm looking for a similar method for reading the phone number of the sim.
You can't. Phone number it's not stored on sim card, it's stored on operator's servers. Look for TelephonyManager.getSubscriberId(), this will give the unique id for each SIM.
Programmatically obtain the phone number of the Android phone
Basic answer- there is no way to get your current phone number. There's things that sometimes work, but not always and not on all carriers.
No,
Android doesn't support dual sim devices.
See: Detect the status of two SIM cards in a dual-SIM Android phone
as Android does not support multiple SIMs, at least from the SDK.
You can contact your device manufacturer and see if they have an SDK add-on or something that allows you to access the second SIM.May be an API which can help youto get your desired result.
Although you can find out the status of the device whether it is Dual sim or not by using this link Android : Check whether the phone is dual SIM
Using reflection, I looked at the methods of TelephonyManager and found this method: int getLine1NumberGemini(int).
I tried to invoke it (getLine1NumberGemini(0) for first sim and getLine1NumberGemini(1) for the second). In both cases I received an empty string.
But the reason for this seems to be the inability of the phone to get the phone number of my sims:
TelephonyManager.getLine1Number() returns empty string as well.
When I open "Sim management" in the settings of the phone, no phone numbers are displayed.

sim serial number vs imsi

I am building an android app that will be licensed on the user's SIM card. There are 2 possible values that I can check against:
SIM SERIAL NUMBER: TelephonyManager.getSimSerialNumber();
IMSI: TelephonyManager.getSubscriberId();
As I do not want to use both, I guess that there is no actually difference to rely to the one or to the other. Am I right or is there something that I am missing here?
Thanks!
It depends on what you want.
If the license works by checking that the serial number matches your database as an example.
If the user installs your app and the sim card serial is stored in your DB, if the user removes the sim card and inserts a new sim card, the license will fail as your DB doesn't store the serial for the new sim card.
If you get based on the IMSI number then the license will be with the device, so even if user replaces the SIM the license will still pass as your using the device ID.
Note though I don't know whether the SIM serial will work or how it will handle devices that do not have SIM such as CDMA devices in the US.
ICCID (SIM Serial) is the serial number of the SIM. It is unique per SIM.
IMSI is a SubsID. It is actually a network ID.
More reference: https://m.blog.naver.com/framkang/220363349346

How to know SIM card or mobile number for when an outgoing SMS was sent?

I'm building an app that needs to report some information about outgoing SMS messages. As I understand that a single Android device can house a different SIM card at any point in time, is there a way to look at the mobile number of the SIM card that sent a particular SMS message?
My current approach to looking at the sent SMSes is via a ContentObserver to content://sms, and while I can retrieve info such as the sending date, the target number, and the message body, I can't find a column from the Cursor that contains the device's mobile number when that message was sent. I also don't mind taking a different approach.
There is no guaranteed solution to this problem because the phone number is not physically stored on all SIM-cards, or broadcasted from the network to the phone. This is especially true in some countries which requires physical address verification, with number assignment only happening afterwards. Phone number assignment happens on the network - and can be changed without changing the SIM card or device (e.g. this is how porting is supported). I know it is pain, but most likely the best solution is just to ask the user to enter his/her phone number once and store it.

Getting the TMSI from the SIM card

Is it possible, in Android or any other mobile OS, to access the encrypted information passed from the SIM card to the cellular network? I mean the mobile signature, or the TMSI number. I need this data after it is encripted by the sim. I mean the IMSI after it is encrypted by the SIM to be sent to the network.
Thanks :)
Impossible. Android so far does not provide any direct API's and/or other interfaces to SIM card, except for some basic information like country code, operator name, etc, which is kindly provided by TelephonyManager.
Additionally, SIM interface normally is connected to modem CPU, not application one, thus eliminating any possible hacks/workarounds.
As I know SIM doesn't encrypt the IMSI information,that's the one reason to use TMSI.
Exactly, SIM doesn't do that. Its all done using Hardware of phone. And TMSI don't have anything to do with phone. It is used in radio interfaces just to secure user information and confidentiality. Phone will be always identified by IMSI not TMSI.
Basically they uses some key values. And those keys do the twist. Algorithm A5 and A8 are used for key purpose.
Pankaj Singh

Categories

Resources