How to use the aioblescan.IntByte function in aioblescan

To help you get started, we’ve selected a few aioblescan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frawau / aioblescan / aioblescan / plugins / eddystone.py View on Github external
extval=None
        if myhostname.split(".")[-1] in url_domain:
            extval = url_domain.index(myhostname.split(".")[-1])
            myhostname = ".".join(myhostname.split(".")[:-1])
        if extval is not None and not mypath.startswith("/"):
            extval+=7
        else:
            if myurl.port is None:
                if extval is not None:
                    mypath = mypath[1:]
            else:
                extval += 7
        encodedurl.append(aios.String("URL string"))
        encodedurl[-1].val = myhostname
        if extval is not None:
            encodedurl.append(aios.IntByte("URL Extention",extval))

        if myurl.port:
            asisurl += ":"+str(myurl.port)+mypath
        asisurl += mypath
        if myurl.params:
            asisurl += ";"+myurl.params
        if myurl.query:
            asisurl += "?"+myurl.query
        if myurl.fragment:
            asisurl += "#"+myurl.fragment
        encodedurl.append(aios.String("Rest of URL"))
        encodedurl[-1].val = asisurl
        tlength=0
        for x in encodedurl: #Check the payload length
            tlength += len(x)
        if tlength > 19: #Actually 18 but we have tx power
github frawau / aioblescan / aioblescan / plugins / eddystone.py View on Github external
def url_encoder(self):
        encodedurl = []
        encodedurl.append(aios.IntByte("Tx Power",self.power))
        asisurl=""
        myurl = urlparse(self.type_payload)
        myhostname = myurl.hostname
        mypath = myurl.path
        if (myurl.scheme,myhostname.startswith("www.")) in url_schemes:
            encodedurl.append(aios.IntByte("URL Scheme",
                                           url_schemes.index((myurl.scheme,myhostname.startswith("www.")))))
            if myhostname.startswith("www."):
                myhostname = myhostname[4:]
        extval=None
        if myhostname.split(".")[-1] in url_domain:
            extval = url_domain.index(myhostname.split(".")[-1])
            myhostname = ".".join(myhostname.split(".")[:-1])
        if extval is not None and not mypath.startswith("/"):
            extval+=7
        else:
            if myurl.port is None:
                if extval is not None:
                    mypath = mypath[1:]
            else:
                extval += 7
        encodedurl.append(aios.String("URL string"))
github frawau / aioblescan / aioblescan / plugins / eddystone.py View on Github external
def url_encoder(self):
        encodedurl = []
        encodedurl.append(aios.IntByte("Tx Power",self.power))
        asisurl=""
        myurl = urlparse(self.type_payload)
        myhostname = myurl.hostname
        mypath = myurl.path
        if (myurl.scheme,myhostname.startswith("www.")) in url_schemes:
            encodedurl.append(aios.IntByte("URL Scheme",
                                           url_schemes.index((myurl.scheme,myhostname.startswith("www.")))))
            if myhostname.startswith("www."):
                myhostname = myhostname[4:]
        extval=None
        if myhostname.split(".")[-1] in url_domain:
            extval = url_domain.index(myhostname.split(".")[-1])
            myhostname = ".".join(myhostname.split(".")[:-1])
        if extval is not None and not mypath.startswith("/"):
            extval+=7
        else:
github frawau / aioblescan / aioblescan / plugins / eddystone.py View on Github external
top=found.retrieve("Adv Payload")[0]
        except:
            return None
        #Rebuild that part of the structure
        found.payload.remove(top)
        #Now decode
        result={}
        data=top.val
        etype = aios.EnumByte("type",self.type.val,{ESType.uid.value:"Eddystone-UID",
                                                ESType.url.value:"Eddystone-URL",
                                                ESType.tlm.value:"Eddystone-TLM",
                                                ESType.eid.value:"Eddystone-EID"})
        data=etype.decode(data)
        found.payload.append(etype)
        if etype.val== ESType.uid.value:
            power=aios.IntByte("tx_power")
            data=power.decode(data)
            found.payload.append(power)
            result["tx_power"]=power.val

            nspace=aios.Itself("namespace")
            xx=nspace.decode(data[:10])  #According to https://github.com/google/eddystone/tree/master/eddystone-uid
            data=data[10:]
            found.payload.append(nspace)
            result["name space"]=nspace.val

            nspace=aios.Itself("instance")
            xx=nspace.decode(data[:6])  #According to https://github.com/google/eddystone/tree/master/eddystone-uid
            data=data[6:]
            found.payload.append(nspace)
            result["instance"]=nspace.val
github frawau / aioblescan / aioblescan / plugins / eddystone.py View on Github external
def uid_encoder(self):
        encodedurl = []
        encodedurl.append(aios.IntByte("Tx Power",self.power))
        encodedurl.append(aios.NBytes("Namespace",10))
        encodedurl[-1].val = self.type_payload["namespace"]
        encodedurl.append(aios.NBytes("Instance",6))
        encodedurl[-1].val = self.type_payload["instance"]
        encodedurl.append(aios.NBytes("RFU",2))
        encodedurl[-1].val = b'\x00\x00'
        self.service_data_length.val = 23 #Update the payload length/ways the same for uid
        return encodedurl
github frawau / aioblescan / aioblescan / plugins / eddystone.py View on Github external
def eid_encoder(self):
        encodedurl = []
        encodedurl.append(aios.IntByte("Tx Power",self.power))
        encodedurl.append(aios.NBytes("Namespace",8))
        encodedurl[-1].val = self.type_payload
        self.service_data_length.val = 13
        return encodedurl
github frawau / aioblescan / aioblescan / plugins / eddystone.py View on Github external
def __init__(self, type=ESType.url, param="https://goo.gl/m9UiEA"):
        self.power = 0
        self.payload = []     #As defined in https://github.com/google/eddystone/blob/master/protocol-specification.md
        self.payload.append(aios.Byte("Flag Length",b'\x02'))
        self.payload.append(aios.Byte("Flag Data Type",b'\x01'))
        self.payload.append(aios.Byte("Flag Data",b'\x1a'))
        self.payload.append(aios.Byte("Length UUID services",b'\x03'))
        self.payload.append(aios.Byte("Complete List UUID Service",b'\x03'))
        self.payload.append(aios.Byte("Eddystone UUID",b'\xaa'))
        self.payload.append(aios.Byte("...",b'\xfe'))
        self.service_data_length = aios.IntByte("Service Data length",4)
        self.payload.append(self.service_data_length)
        self.payload.append(aios.Byte("Service Data data type value",b'\x16'))
        self.payload.append(aios.Byte("Eddystone UUID",b'\xaa'))
        self.payload.append(aios.Byte("...",b'\xfe'))
        self.type = aios.EnumByte("type",type.value,{ESType.uid.value:"Eddystone-UID",
                                               ESType.url.value:"Eddystone-URL",
                                               ESType.tlm.value:"Eddystone-TLM",
                                               ESType.eid.value:"Eddystone-EID"})
        self.payload.append(self.type)
        self.parsed_payload = b''
        self.type_payload=param