Skip to content

Commit

Permalink
xyz test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sec42 authored and schneider42 committed Apr 20, 2024
1 parent 47377de commit 45dda35
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions iridiumtk/reassembler/xyz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/env python3
# vim: set ts=4 sw=4 tw=0 et pm=:

import sys
import datetime
import re
import crcmod
import os

from util import fmt_iritime, to_ascii, xyz, channelize, channelize_str, dt

from .base import *
from .ida import ReassembleIDA
from ..config import config, outfile

class ReassembleIDAMap(ReassembleIDA):
"""Extract coordinates from access decision messages"""

intvl = 60
exptime = 60 * 8
last_output = 0

mt_pos = []

def __init__(self):
super().__init__()
global json
import json

def consume(self, q):
(data, time, ul, _, freq)=q
if len(data) < 2:
return

m_type = data[:2].hex()

if m_type !="0605" and m_type != "7605":
return

freq_print=channelize_str(freq)

if ul:
ul="UL"
else:
ul="DL"


if m_type == "7605":
if data[2] == 0 and data[3]&0xf0 == 0x40:
type = 'sbd'
pos=xyz(data[3:], 4)
elif data[3] == 0x50: # ack only
return
else: # no match
return
elif m_type == "0605":
off = (2+1+20+1+3+3+2+2+2)
if len(data) > off and data[off] == 0x1b:
type = 'gsm'
pos=xyz(data[off+1:], 0)
#lac_o=2+1+20
#if data[lac_o] == 0x04:
# print("lac=",data[lac_o+1:lac_o+3].hex())
#if data[lac_o+3] == 0x61:
# print("sca=",data[lac_o+4:lac_o+6].hex())
else: # no match
return
else:
raise ValueError

self.mt_pos.append({"xyz": [pos['x']*4, pos['y']*4, pos['z']*4], "type": type, "ts": int(time)})

if time >= self.last_output + self.intvl:
self.last_output = time
self.mt_pos = [x for x in self.mt_pos if x['ts'] > time - 60]

ofile=config.output
if ofile is None:
ofile="mt_map.json"
temp_file_path="%s.tmp"%(ofile)
with open(temp_file_path, "w") as f:
print(json.dumps({"time": int(time), "mt_pos": self.mt_pos}, separators=(',', ':')), file=f)
os.rename(temp_file_path, ofile)


modes=[
["live-mt-map", ReassembleIDAMap, ],
]

0 comments on commit 45dda35

Please sign in to comment.