最全的IMSI获取手机号段、归属地java代码

本文介绍了如何使用Java代码从IMSI(国际移动用户识别码)获取手机号段和归属地。IMSI包含移动国家代码MCC、移动网络代码MNC和移动用户识别码MSIN。通过反向解析IMSI,可以得到手机号段,而归属地信息通常需要结合预下载的归属地数据库来获取。由于未找到电信的规则,因此该方法可能不适用于电信网络。
摘要由CSDN通过智能技术生成

IMSI获取手机号段、归属地

IMSI国际移动用户识别码(IMSI:International Mobile Subscriber Identification Number)是区别移动用户的标志,储存在SIM卡中,可用于区别移动用户的有效信息。其总长度不超过15位,同样使用0~9的数字。其中MCC是移动用户所属国家代号,占3位数字,中国的MCC规定为460;MNC是移动网号码,由两位或者三位数字组成,中国移动的移动网络编码(MNC)为00;用于识别移动用户所归属的移动通信网;MSIN是移动用户识别码,用以识别某一移动通信网中的移动用户。简单的说IMSI就是手机号码的标识。

先看反向代码

public static String getMobileAll(String imsi){
   
        String s130  = "^46001(\\d{3})(\\d)[0,1]\\d+";
        String s131 = "^46001(\\d{3})(\\d)9\\d+";
        String s132 = "^46001(\\d{3})(\\d)2\\d+";
        String s134 = "^460020(\\d)(\\d{3})\\d+";
        String s13x0 = "^46000(\\d{3})([5,6,7,8,9])\\d+";
        String s13x = "^46000(\\d{3})([0,1,2,3,4])(\\d)\\d+";
        String s150 = "^460023(\\d)(\\d{3})\\d+";
        String s151 = "^460021(\\d)(\\d{3})\\d+";
        String s152 = "^460022(\\d)(\\d{3})\\d+";
        String s155 = "^46001(\\d{3})(\\d)4\\d+";
        String s156 = "^46001(\\d{3})(\\d)3\\d+";
        String s157 = "^460077(\\d)(\\d{3})\\d+";
        String s158 = "^460028(\\d)(\\d{3})\\d+";
        String s159 = "^460029(\\d)(\\d{3})\\d+";
        String s147 = "^460079(\\d)(\\d{3})\\d+";
        String s185 = "^46001(\\d{3})(\\d)5\\d+";
        String s186 = "^46001(\\d{3})(\\d)6\\d+";
        String s187 = "^460027(\\d)(\\d{3})\\d+";
        String s188 = "^460078(\\d)(\\d{3})\\d+";
        String s1705 = "^460070(\\d)(\\d{3})\\d+";
        String s170x = "^46001(\\d{3})(\\d)8\\d+";
        String s178 = "^460075(\\d)(\\d{3})\\d+";
        String s145 = "^46001(\\d{3})(\\d)7\\d+";
        String s182 = "^460026(\\d)(\\d{3})\\d+";
        String s183 = "^460025(\\d)(\\d{3})\\d+";
        String s184 = "^460024(\\d)(\\d{3})\\d+";
        //电信的,下面的还没有找到规则
        String s180 = "^46003(\\d)(\\d{3})7\\d+";
        String s153 = "^46003(\\d)(\\d{3})8\\d+";
        String s189 = "^46003(\\d)(\\d{3})9\\d+";

        String[] result = compile(s130,imsi);
        if(result != null && result.length==2){
   
            return "130"+result[1]+result[0];
        }
        result = compile(s131,imsi);
        if(result != null && result.length==2){
   
            return "131"+result[1]+result[0];
        
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

猫大叔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值