Пример #1
0
def add_subscriber(client, args):
    gsm = GSMSubscription()
    lte = LTESubscription()
    state = SubscriberState()

    if len(args.gsm_auth_tuple) != 0:
        gsm.state = GSMSubscription.ACTIVE
        for auth_tuple in args.gsm_auth_tuple:
            gsm.auth_tuples.append(bytes.fromhex(auth_tuple))

    if args.lte_auth_key is not None:
        lte.state = LTESubscription.ACTIVE
        lte.auth_key = bytes.fromhex(args.lte_auth_key)

    if args.lte_auth_next_seq is not None:
        state.lte_auth_next_seq = args.lte_auth_next_seq

    if args.lte_auth_opc is not None:
        lte.auth_opc = bytes.fromhex(args.lte_auth_opc)

    data = SubscriberData(
        sid=SIDUtils.to_pb(args.sid),
        gsm=gsm,
        lte=lte,
        state=state,
    )
    client.AddSubscriber(data)
Пример #2
0
    def setUp(self):
        # Create sqlite3 database for testing
        self._tmpfile = tempfile.TemporaryDirectory()
        store = SqliteStore(self._tmpfile.name + '/')
        op = 16 * b'\x11'
        amf = b'\x80\x00'
        self._sub_profiles = {
            'superfast':
            SubscriberDB.SubscriptionProfile(max_ul_bit_rate=100000,
                                             max_dl_bit_rate=50000)
        }
        self._default_sub_profile = SubscriberDB.SubscriptionProfile(
            max_ul_bit_rate=10000, max_dl_bit_rate=5000)

        self._processor = processor.Processor(store, self._default_sub_profile,
                                              self._sub_profiles, op, amf)

        # Add some test users
        (rand, sres, gsm_key) = _dummy_auth_tuple()
        gsm = GSMSubscription(state=GSMSubscription.ACTIVE,
                              auth_tuples=[rand + sres + gsm_key])
        lte_key = 16 * b'\x00'
        lte = LTESubscription(state=LTESubscription.ACTIVE, auth_key=lte_key)
        lte_opc = LTESubscription(state=LTESubscription.ACTIVE,
                                  auth_key=lte_key,
                                  auth_opc=Milenage.generate_opc(lte_key, op))
        lte_opc_short = LTESubscription(state=LTESubscription.ACTIVE,
                                        auth_key=lte_key,
                                        auth_opc=b'\x00')
        state = SubscriberState(lte_auth_next_seq=1)
        sub1 = SubscriberData(sid=SIDUtils.to_pb('IMSI11111'),
                              gsm=gsm,
                              lte=lte,
                              state=state,
                              sub_profile='superfast')
        sub2 = SubscriberData(
            sid=SIDUtils.to_pb('IMSI22222'),  # No auth keys
            gsm=GSMSubscription(state=GSMSubscription.ACTIVE),
            lte=LTESubscription(state=LTESubscription.ACTIVE))
        sub3 = SubscriberData(
            sid=SIDUtils.to_pb('IMSI33333'))  # No subscribtion
        sub4 = SubscriberData(sid=SIDUtils.to_pb('IMSI44444'),
                              lte=lte_opc,
                              state=state)
        sub5 = SubscriberData(sid=SIDUtils.to_pb('IMSI55555'),
                              lte=lte_opc_short,
                              state=state)
        store.add_subscriber(sub1)
        store.add_subscriber(sub2)
        store.add_subscriber(sub3)
        store.add_subscriber(sub4)
        store.add_subscriber(sub5)
Пример #3
0
def add_subscriber(client, args):
    gsm = GSMSubscription()
    lte = LTESubscription()
    state = SubscriberState()
    sub_network = CoreNetworkType()

    if len(args.gsm_auth_tuple) != 0:
        gsm.state = GSMSubscription.ACTIVE
        for auth_tuple in args.gsm_auth_tuple:
            gsm.auth_tuples.append(bytes.fromhex(auth_tuple))

    if args.lte_auth_key is not None:
        lte.state = LTESubscription.ACTIVE
        lte.auth_key = bytes.fromhex(args.lte_auth_key)

    if args.lte_auth_next_seq is not None:
        state.lte_auth_next_seq = args.lte_auth_next_seq

    if args.lte_auth_opc is not None:
        lte.auth_opc = bytes.fromhex(args.lte_auth_opc)

    if args.forbidden_network_types is not None:
        if (len(args.forbidden_network_types.split(",")) > 2):
            print("Forbidden Core Network Types are NT_5GC, NT_EPC")
            return
        for n in args.forbidden_network_types.split(","):
            if n == "NT_5GC":
                sub_network.forbidden_network_types.extend(
                    [CoreNetworkType.NT_5GC])
            elif n == "NT_EPC":
                sub_network.forbidden_network_types.extend(
                    [CoreNetworkType.NT_EPC])
            else:
                print(
                    "Invalid Network type, Forbidden Core Network Types are NT_5GC, NT_EPC"
                )
                return

    data = SubscriberData(
        sid=SIDUtils.to_pb(args.sid),
        gsm=gsm,
        lte=lte,
        state=state,
        sub_network=sub_network,
    )
    client.AddSubscriber(data)
Пример #4
0
    def setUp(self):
        # Create sqlite3 database for testing
        self._tmpfile = tempfile.TemporaryDirectory()
        store = SqliteStore(self._tmpfile.name + "/")
        op = 16 * b"\x11"
        amf = b"\x80\x00"
        sub_network = CoreNetworkType()
        self._sub_profiles = {
            "superfast":
            SubscriberDB.SubscriptionProfile(
                max_ul_bit_rate=100000,
                max_dl_bit_rate=50000,
            ),
        }
        self._default_sub_profile = SubscriberDB.SubscriptionProfile(
            max_ul_bit_rate=10000,
            max_dl_bit_rate=5000,
        )
        self._sub_network = sub_network

        self._processor = processor.Processor(
            store,
            self._default_sub_profile,
            self._sub_profiles,
            op,
            amf,
            self._sub_network,
        )

        # Add some test users
        (rand, sres, gsm_key) = _dummy_auth_tuple()
        gsm = GSMSubscription(
            state=GSMSubscription.ACTIVE,
            auth_tuples=[rand + sres + gsm_key],
        )
        lte_key = 16 * b"\x00"
        lte = LTESubscription(state=LTESubscription.ACTIVE, auth_key=lte_key)
        lte_opc = LTESubscription(
            state=LTESubscription.ACTIVE,
            auth_key=lte_key,
            auth_opc=Milenage.generate_opc(lte_key, op),
        )
        lte_opc_short = LTESubscription(
            state=LTESubscription.ACTIVE,
            auth_key=lte_key,
            auth_opc=b"\x00",
        )
        sub_network = CoreNetworkType(forbidden_network_types=[
            CoreNetworkType.NT_EPC, CoreNetworkType.NT_5GC
        ], )
        state = SubscriberState(lte_auth_next_seq=1)
        sub1 = SubscriberData(
            sid=SIDUtils.to_pb("IMSI11111"),
            gsm=gsm,
            lte=lte,
            state=state,
            sub_profile="superfast",
        )
        sub2 = SubscriberData(
            sid=SIDUtils.to_pb("IMSI22222"),  # No auth keys
            gsm=GSMSubscription(state=GSMSubscription.ACTIVE),
            lte=LTESubscription(state=LTESubscription.ACTIVE),
        )
        sub3 = SubscriberData(
            sid=SIDUtils.to_pb("IMSI33333"))  # No subscription
        sub4 = SubscriberData(sid=SIDUtils.to_pb("IMSI44444"),
                              lte=lte_opc,
                              state=state)
        sub5 = SubscriberData(
            sid=SIDUtils.to_pb("IMSI55555"),
            lte=lte_opc_short,
            state=state,
        )
        sub6 = SubscriberData(
            sid=SIDUtils.to_pb("IMSI66666"),
            sub_network=CoreNetworkType(),
        )
        store.add_subscriber(sub1)
        store.add_subscriber(sub2)
        store.add_subscriber(sub3)
        store.add_subscriber(sub4)
        store.add_subscriber(sub5)
        store.add_subscriber(sub6)