How to obtain Android phone number with adb command ?

Posted on 2014-09-01
Last Modified: 2014-09-02
Hello Experts,

I want to obtain phone number from Android phone for forensics with adb command.
I want to obtain it without operate Android phone directly.

Any hints welcome.
Question by:NobMiwa
    LVL 35

    Accepted Solution

    You can't, even if there was a command. That's because the number is not known to you or the phone, or even the SIM card.Situation 1: You just don't know (query phone or sim returns null), only the operator knows.
    Situation 2: You think you know it, because you query the SIM card. It's is the correct number.
    Situation 3: You think you know it, because you query the SIM card. It's is the WRONG number (subscriber changed phone number, not SIM card, since operator can change it from remote).
    Situation 5: You think you know it, because you query the phone. It's is the WRONG number (from past user input).
    Situation 3: You think you know it, because you query the phone. It's is the correct number (from past user input).

    As you can see, even if there as an adb command, you have a VERY high percentage it's not returning a number, and an equally high percentage it's the wrong number.

    Unique numbers you can get (if SIM is inserted) is the SIM serial number. However, on the operator can link that to a phone number, something you probably won't be able to (if you're not law enforcement). The IMEI is also a unique number you can get (sometimes not necessary to use software, if you can remove the back of the phone, you can also read it on some label inside the phone)

    Anyway, if you want to play roulette (as in, carry an investigation with unknown factors, including the risk of accusing wrong people, making wrong assumptions and wrong conclusions), try these commands:

    service call iphonesubinfo 4
    service call iphonesubinfo 5
    service call iphonesubinfo 6
    service call iphonesubinfo 7
    service call iphonesubinfo 8

    Assisted Solution

    You can access your Android device via the adb command on the command line. . An Android virtual device can be freely accessed, a normal Android phone needs to get rooted, e.g. you need to remove the protection to do everything on this device.

    The adb tools is located in the [android-sdks]/platform-tools directory. You should add this directory to your path to have direct access to this command.

    The adb allows you to send commands to your Android device, pull and push files to it, gives shell access to the Android device and allows you to read information from your device, for example the current memory usage. The following chapter describe the usage of the corresponding commands.

    If you have several devices running you can issue commands to one individual device.

    # Lists all devices
    adb devices
    List of devices attached
    emulator-5554 attached
    emulator-5555 attached
    # Issue a command to a specific device
    adb -s emulator-5554 shell
    LVL 60

    Assisted Solution

    Android iphonesubinfo service "keeps track" of the subscriber information including phone details.  iphonesubinfo does implement the Dump() method hence dumpsys shows phone details using service call command e.g. getLine1Number() or IPhoneSubInfo.getMsisdn(). However, it only reports Phone Details such as Phone Type (e.g., GSM) and Device ID (e.g., IMEI), not the phone number.  

    Depending on the android version and your carrier one or two of the a/m commands will tell you the phone number. But note that this does not seem to work without rooting the phone.
    service call iphonesubinfo 4 > getGroupIdLevel1
    service call iphonesubinfo 5 > getIccSerialNumber
    service call iphonesubinfo 6 > getLine1Number
    service call iphonesubinfo 7 > getLine1AlphaTag
    service call iphonesubinfo 8 >getMsisdn

    As for the not direct approach, I was thinking over TCP leveraging the below (maybe over WIFI or simply via n/w)
    e.g. adb tcpip <port>  - restarts the adbd daemon listening on TCP on the specified port
    Such as below
    adb tcpip 5555
    adb connect
    Be sure to replace with the IP address that is actually assigned to your device.

    Find the IP address in two ways:
    > Manual IP Discovery:  Go into Android's WiFi settings, click the menu button in the action bar (the vertical ellipsis), hit Advanced and see the IP address at the bottom of the screen.
    > Use ADB to discover IP: Execute the following command via adb:
    adb shell ip -f inet addr show wlan0

    Apps to automate the process: There are also several apps on Google Play that automate this process. A quick search suggests adbWireless, WiFi ADB and ADB WiFi.

    All of these require root access, but adbWireless requires fewer permissions. that may not be straightforward

    Author Closing Comment

    Thank you for all advice.

    I understood I cannot get phone number with adb.
    I will make small app which will be push into Android phone and dig phone number information.

    Nobuo Miwa
    LVL 35

    Expert Comment

    Don't forget, the 5 situations I described are still in effect, app or no app. You're still having uncertainty with the phone number. That's just something you have to live with.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    I recently asked a question ( about Computer Inventory applications for Mobile Devices.  I was specifically interested in an app I could use on my android phone.  The be…
    A short article about a problem I had getting the GPS LocationListener working.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now