# -*- 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
The error message is because
tshark
tries to disable some dangerous functions in Lua likedofile
.If you don't need Lua in tshark, you can disable Lua support: edit
init.lua
, changedisable_lua = false
todisable_lua = true
.If you need Lua support, read Platform-Specific information about capture privileges, see how to capture packets without root rivilege.