text
stringlengths
1
93.6k
for x in xrange(0,len(apl)):
if apl[x]==[]:
break
apl[x]=list(set(apl[x]))
apl[x].sort()
if x!=len(apl):
showapl+=str(apl[x])
if IsOrder == False:
continue
alen=len(apl[x])
if alen == 1:
showsig+=str(apl[x][0])+' '
elif len(set([ type(y) for y in apl[x] ])) != 1:
#showsig+='.'
IsOrder = False
elif type(apl[x][0])==int:
if apl[x][-1]-apl[x][0]>interval:
showsig+='.'
else:
showsig+=str(apl[x][0])+'<>'+str(apl[x][-1])+' '
else:
temp=[int(y) for y in apl[x]]
temp.sort()
if temp[-1]-temp[0]>interval:
showsig+='.'
else:
showsig+=str(temp[0])+'<>'+str(temp[-1])+' '
stream['banalysis']={}
stream['banalysis']['sig']=apl
stream['banalysis']['showsig']=showapl+'<br />'+showsig
return L3node,totalflow
def autoFilter(L3node,totalflow):
pass
return L3node,totalflow
def subNode(L3node,L3key,L5node,L5key,size,rate):
if L3key.split('_')[0][0]=='S':
ip=L5key.split('_')[2]
port=L5key.split('_')[3]
son=u'目的'
else:
ip=L5key.split('_')[0]
port=L5key.split('_')[1]
son=u'源端'
#增加TCP|UDP属性,增加时间戳
son+=L5key.split('_')[4]
L3node[L3key]['size']+=size
pnum=len(L5node[L5key]['session']['pl'])
if pnum==1 or L5node[L5key]['session']['canalysis']['quality']=='web':
linshi=L5node[L5key]['session']['showcontent'][0]
if linshi[0:3]=='GET':
if linshi[-18:]=="<br /><br /><br />":
linshi=linshi[:-12]
elif linshi[-12:]=="<br /><br />":
linshi=linshi[:-6]
elif linshi[-6:]!="<br />":
linshi=linshi+'<br />'
try:
L5ContentSig=linshi+"<a target='_blank' style='color:red' href='http://"+linshi.split('Host: ')[1].split('<br />')[0]+linshi.split(' ')[1]+u"'>访问</a>"
except:
L5ContentSig=linshi
else:
L5ContentSig=linshi
CorS='C'
else:
linshi=L5node[L5key]['session']['showcontent'][0]
if linshi[0:3]=='GET':
try:
L5ContentSig=linshi+'<br /><span style="color:red">'+L5node[L5key]['session']['canalysis']['showsig']+'</span>'+"<br /><a target='_blank' style='color:red' href='http://"+linshi.split('Host: ')[1].split('<br />')[0]+linshi.split(' ')[1]+u"'>访问</a>"
except:
L5ContentSig=linshi+'<br /><span style="color:red">'+L5node[L5key]['session']['canalysis']['showsig']+'</span>'
else:
L5ContentSig=linshi+'<br /><span style="color:red">'+L5node[L5key]['session']['canalysis']['showsig']+'</span>'
CorS='S'
L3node[L3key]['sub'].append([son,rate,'1','--',L5node[L5key]['session']['pl'][0],\
'--',ip,int(port),CorS,L5ContentSig,\
L5node[L5key]['apl'],size,L5node[L5key]['session']['content'][0],L5node[L5key]['session']['pl'][0],L3key,\
L5node[L5key]['pname']+'_'+L5key,L5node[L5key]['time'],L5node[L5key]['addsize'],L5node[L5key]['protocol'] ])
def autoMerger(L3node,totalflow,pre_L5node):
#[1]:WEB-AHnode:Atr+Host
AUnode={}
newnode={}
A=1
for key, stream in L3node.items():
#if stream['canalysis']['quality']=='web' and stream['canalysis'].has_key('hostSig'):
if stream['canalysis']['quality']=='web' and 'hostSig' in stream['canalysis']:
subkey=key.split('_')[0]+'_'+stream['canalysis']['hostSig']
#if AUnode.has_key(subkey):
if subkey in AUnode:
AUnode[subkey].append(key)
else:
AUnode[subkey]=[key]
for key in AUnode:
if len(AUnode[key])!=1:
newkey=calc.newL3key(AUnode[key],A,'AMHost')
newnode[newkey]={}
newnode[newkey]['pl']=[]