Ejemplo n.º 1
0
def main():
  if len(sys.argv) < 2 or len(sys.argv) > 3:
    helpPage()
    return

  inFile = sys.argv[1]
  outFile = sys.argv[2]

  timestamp = 0
  outfd = open(outFile, 'wb')
  outfd.write(pcap.pcap_global_header())
  outfd.flush()

  infd = open(inFile, "rb")
  f = infd.readlines()
  for line in f:
    try:
      p = line.index("dep raw")
      role = ">>" in line;
      payload = line[p+11:].rstrip()
      hdr = pcap.llcp_pcap_packet_header(0, role)
      data = hdr + payload.decode("hex")
      outfd.write(pcap.pcap_packet_header(timestamp, data))
      outfd.write(data)
      outfd.flush()
    except ValueError: # happens when reading header
      pass
Ejemplo n.º 2
0
def main():
  infd = sys.stdin
  outfd = sys.stdout

  outfd.write(pcap.pcap_global_header())
  outfd.flush()

  while True:
    line = infd.readline().strip()
    m = LOGCAT_RE.match(line)
    if m:
      chars = m.group(1)
      sys.stderr.write('%s\n' % chars)
      sent = '>' in line

      hdr = pcap.llcp_pcap_packet_header(0, sent)
      data = hdr + to_bytes(chars)

      outfd.write(pcap.pcap_packet_header(time.time(), data))
      outfd.write(data)
      outfd.flush()