<s> from scapy . all import * <EOL> import urllib2 <EOL> import json <EOL> from time import sleep <EOL> from urlparse import urlparse <EOL> import os <EOL> import argparse <EOL> import sys <EOL> ts , num , friend_id , time , msg , msg_sended = <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , '<STR_LIT>' , '<STR_LIT>' <EOL> msg_recive = [ <NUM_LIT> , <NUM_LIT> ] <EOL> msg_send = [ <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT> ] <EOL> ap = argparse . ArgumentParser ( epilog = "<STR_LIT>" + sys . argv [ <NUM_LIT:0> ] + "<STR_LIT>" , prog = sys . argv [ <NUM_LIT:0> ] , formatter_class = lambda prog : argparse . HelpFormatter ( prog , max_help_position = <NUM_LIT:50> ) ) <EOL> ap . add_argument ( '<STR_LIT>' , '<STR_LIT>' , nargs = <NUM_LIT:1> , help = "<STR_LIT>" ) <EOL> ap . add_argument ( '<STR_LIT>' , '<STR_LIT>' , nargs = <NUM_LIT:1> , help = "<STR_LIT>" ) <EOL> opts = ap . parse_args ( ) <EOL> pcts = list ( ) <EOL> def show_msgs ( pack ) : <EOL> try : <EOL> if '<STR_LIT>' in pack . load : <EOL> answ = json . loads ( pack . load . split ( '<STR_LIT>' ) [ <NUM_LIT:1> ] [ : - <NUM_LIT:2> ] ) <EOL> for i in answ [ '<STR_LIT>' ] : <EOL> if i [ <NUM_LIT:0> ] == <NUM_LIT:4> : <EOL> num , friend_id , time , msg = i [ <NUM_LIT:1> ] , i [ <NUM_LIT:3> ] , i [ <NUM_LIT:4> ] , i [ <NUM_LIT:6> ] <EOL> if msg in pcts : <EOL> pass <EOL> else : <EOL> pcts . append ( msg ) <EOL> if i [ <NUM_LIT:2> ] in msg_recive : <EOL> print '<STR_LIT:[>' + get_name_by_id ( friend_id ) + '<STR_LIT>' + pack [ IP ] . dst + '<STR_LIT>' + msg <EOL> elif i [ <NUM_LIT:2> ] in msg_send : <EOL> print '<STR_LIT:[>' + pack [ IP ] . dst + '<STR_LIT:]>' + '<STR_LIT>' + get_name_by_id ( friend_id ) + '<STR_LIT>' + msg <EOL> if len ( pcts ) > <NUM_LIT:10> : <EOL> pcts . pop ( <NUM_LIT:0> ) <EOL> except : pass <EOL> def get_name_by_id ( id ) : <EOL> get_name = json . loads ( urllib2 . urlopen ( '<STR_LIT>' + str ( id ) ) . readlines ( ) [ <NUM_LIT:0> ] ) <EOL> friend_name = get_name [ "<STR_LIT>" ] [ <NUM_LIT:0> ] [ "<STR_LIT>" ] + '<STR_LIT:U+0020>' + get_name [ "<STR_LIT>" ] [ <NUM_LIT:0> ] [ "<STR_LIT>" ] <EOL> return friend_name <EOL> try : <EOL> if opts . pcap != None : <EOL> for i in PcapReader ( opts . pcap [ <NUM_LIT:0> ] ) : <EOL> show_msgs ( i ) <EOL> if opts . interface [ <NUM_LIT:0> ] != None : <EOL> sniff ( iface = opts . interface [ <NUM_LIT:0> ] , prn = show_msgs ) <EOL> except : <EOL> pass </s>
