我正在为vpn和受ddos保护的vpn的ip过滤器应用程序工作,但是当我尝试运行该程序时,我的分析器功能(我在网上找到了大部分代码)调用语法错误。我只需要这些错误的帮助。我从使用分号和&符号的行中获取错误。这是错误产生的一些功能代码。
def packetAnalyzer(packet):
data = packet[0]
ip_header = data[0:20]
unpack_data = unpack('!BBHHHBBH4s4s', ip_header)
version_ihl = unpack_data[0]
version = version_ihl >> 4
ihl = version_ihl & 0xF
iph_length = ihl * 4
ttl = iph[5]
protocol = iph[6]
s_addr = socket.inet_ntoa(iph[8]);
d_addr = socket.inet_ntoa(iph[9]);
print 'Version : ' + str(version) + ' IP Header Length : ' + str(ihl) + ' TTL : ' + str(ttl) + ' Protocol : ' + str(protocol) + ' Source Address : ' + str(s_addr) + ' Destination Address : ' + str(d_addr)
tcp_header = data[iph_length:iph_length+20]
tcph = unpack('!HHLLBBHHH', tcp_header)
source_port = tcph[0]
dest_port = tcph[1]
sequence = tcph[2]
acknowledgement = tcph[3]
doff_reserved = tcph[4]
tcph_length = doff_reserved >> 4
print 'Source Port : ' + str(source_port) + ' Dest Port : ' + str(dest_port) + ' Sequence Number : ' + str(sequence) + ' Acknowledgement : ' + str(acknowledgement) + ' TCP header length : ' + str(tcph_length)
h_size = iph_length + tcph_length * 4
data_size = len(data) - h_size
data = data[h_size:]
print 'Data : ' + data
错误:
Traceback (most recent call last):
File "GV-Ddos-filter.py", line 1, in <module>
import filterFunctions
File "/home/ghostvip3r/Dev/python/Projects/server-client/VPN/ServerSide/AutoFilter/filterFunctions.py", line 17
version = version_ihl >> 4