-1
# -*- coding: utf-8 -*-
# coding: utf-8
import sys

import os

import time

b = 'sudo tshark -i eth0 -R “tcp contains “attack”” -T fields -e ip.src -a duration:60>output.txt'

a = os.popen(b)

time.sleep(32)

f = open('output.txt','r')

text = 'IP address of attacker is'

print (text), f.read()

f.close

I am trying to execute this code to capture packets using tshark but i am getting this error:

tshark: "�" was unexpected in this context.

Please help me why that error is caused, thank you

Sunny
  • 11
  • 1
  • 3

1 Answers1

0

The error message is because tshark tries to disable some dangerous functions in Lua like dofile.

If you don't need Lua in tshark, you can disable Lua support: edit init.lua, change disable_lua = false to disable_lua = true.

If you need Lua support, read Platform-Specific information about capture privileges, see how to capture packets without root rivilege.

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
  • I changed the disable_lua = true in init.lua but still im getting the error: tshark: "�" was unexpected in this context. Please help me. – Sunny Dec 01 '14 at 05:56