Error while executing python code

351 views Asked by At
# -*- 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

1

There are 1 answers

1
Yu Hao On

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.