美文网首页
IMEI IMSI MAC 地址随机生成

IMEI IMSI MAC 地址随机生成

作者: 王国的荣耀 | 来源:发表于2021-04-09 16:27 被阅读0次

在逆向的步骤中,经常会随机产生IMEI、IMSI、MAC等字段。

python 代码

import random

# https://github.com/dylan-fan/imeiDemo
# https://www.cnblogs.com/bohr/p/7093392.html

def get_IMEI():
    r1 = 1000000 + random.randint(1,9000000)
    r2 = 1000000 + random.randint(1,9000000)
    input = str(r1) + str(r2)
    ch = list(input)
    a = 0
    b = 0
    for i in range(len(ch)):
        tt = int(ch[i])
        if (i % 2 == 0):
            a = a + tt
        else:
            temp = tt * 2
            b = b + temp / 10 + temp % 10

    last = int((a + b) % 10)
    if (last == 0):
        last = 0
    else:
        last = 10 - last
    new_imei = input + str(last)
    print("imei: " + new_imei)
    # 64136 37286 26742
    return new_imei

def get_IMSI():
    title = "4600"
    second = 0
    while second == 0:
        second = random.randint(1,8)
    r1 = 10000 + random.randint(1,90000)
    r2 = 10000 + random.randint(1,90000)
    new_imsi = title + "" + str(second) + "" + str(r1) + "" + str(r2)
    print("imsi: " +new_imsi)
    return new_imsi


def randomMac():
    maclist = []
    for i in range(1,7):
        randstr = "".join(random.sample("0123456789ABCDEF",2))
        maclist.append(randstr)
    randmac = ":".join(maclist)
    # randmac = "%3A".join(maclist)
    print("mac: " +randmac)
    return randmac

# imeiNu = int(input("请输入需要生成的imei数量:"))
# with open("imei.txt","w",encoding="utf-8") as fw:
#     for i in range(imeiNu):
#         new_imei = getImei()
#         fw.write(new_imei+'\n')

# 41958 54807 86139
# 46007 65859 96457
# CB:8D:B7:28:50:F7

if __name__ == '__main__':
    get_IMEI()
    get_IMSI()
    randomMac()

java 代码

private static String getIMEI() {// calculator IMEI
        int r1 = 1000000 + new java.util.Random().nextInt(9000000);
        int r2 = 1000000 + new java.util.Random().nextInt(9000000);
        String input = r1 + "" + r2;
        char[] ch = input.toCharArray();
        int a = 0, b = 0;
        for (int i = 0; i < ch.length; i++) {
            int tt = Integer.parseInt(ch[i] + "");
            if (i % 2 == 0) {
                a = a + tt;
            } else {
                int temp = tt * 2;
                b = b + temp / 10 + temp % 10;
            }
        }
        int last = (a + b) % 10;
        if (last == 0) {
            last = 0;
        } else {
            last = 10 - last;
        }
        return input + last;
    }

    private static String getImsi() {
        // 460022535025034
        String title = "4600";
        int second = 0;
        do {
            second = new java.util.Random().nextInt(8);
        } while (second == 4);
        int r1 = 10000 + new java.util.Random().nextInt(90000);
        int r2 = 10000 + new java.util.Random().nextInt(90000);
        return title + "" + second + "" + r1 + "" + r2;
    }
    private static String getMac(){
        char[] char1 = "abcdef".toCharArray();
        char[] char2 = "0123456789".toCharArray();
        StringBuffer mBuffer = new StringBuffer();
        for (int i = 0; i < 6; i++) {
            int t = new java.util.Random().nextInt(char1.length);
            int y = new java.util.Random().nextInt(char2.length);
            int key = new java.util.Random().nextInt(2);
            if (key ==0) {
                mBuffer.append(char2[y]).append(char1[t]);
            }else {
                mBuffer.append(char1[t]).append(char2[y]);
            }

            if (i!=5) {
                mBuffer.append(":");
            }
        }
        return mBuffer.toString();
    }

参考

IMEI码规则及校验算法

相关文章

网友评论

      本文标题:IMEI IMSI MAC 地址随机生成

      本文链接:https://www.haomeiwen.com/subject/gijmtltx.html