Exemplo n.º 1
0
 def insert_session_data(self, fd, sender, recipient, type, data=None):
     args =  dict(session_id = self.session_id,
                  _time = "from_unixtime(%s)" % fd.current_packet.ts_sec,
                  sender = sender,
                  offset = fd.tell(),
                  recipient = recipient,
                  type = type)
         
     CacheManager.urn_insert_to_table(fd.urn, "msn_session", args)
Exemplo n.º 2
0
    def insert_session_data(self, fd, sender, recipient, type, data=None):
        args = dict(session_id=self.session_id,
                    _time="from_unixtime(%s)" % fd.current_packet.ts_sec,
                    sender=sender,
                    offset=fd.tell(),
                    recipient=recipient,
                    type=type)

        CacheManager.urn_insert_to_table(fd.urn, "msn_session", args)
Exemplo n.º 3
0
    def scan(self, fd, scanners, type, mime, cookie, **args):
        if "MSN" in type and fd.urn.endswith("forward"):
            pyflaglog.log(pyflaglog.DEBUG,"Openning %s for MSN" % fd.inode_id)
            dbfs = FileSystem.DBFS(fd.case)
            self.forward_fd = fd
            self.reverse_fd = dbfs.open(urn = "%s/reverse" % os.path.dirname(fd.urn))

            ## Make back references to each other
            self.forward_fd.reverse = self.reverse_fd
            self.reverse_fd.reverse = self.forward_fd

            ## Install defaults
            self.forward_fd.client_id =  self.reverse_fd.client_id = ''
            self.forward_fd.dest_id = self.reverse_fd.dest_id = ''
            
            self.session_id = -1

            for fd in NetworkScanner.generate_streams_in_time_order(
                self.forward_fd, self.reverse_fd):
                try:
                    line = fd.readline()
                    items = line.split()
                    command = items[0]
                except IndexError: continue

                ## Try to process the command
                try:
                    handler = getattr(self, command)
                except:
                    #print "Command %s not handled" % command
                    continue

                handler(items, fd, scanners)

            CacheManager.update_table_from_urn(fd.case, self.forward_fd.urn)
            CacheManager.update_table_from_urn(fd.case, self.reverse_fd.urn)
Exemplo n.º 4
0
    def MSG(self, items, fd, scanners):
        """ Sends message to members of the current session

        There are two types of messages that may be sent:

        1) A message from the client to the message server. 
           This does not contain the nick of the client, but does contain a 
           transaction ID.  This message is sent to all users in the 
           current session.

        2) A message from the Switchboard server to the client contains 
           the nick of the sender.

        These two commands are totally different.

        1.

        MSG 1532 U 92
        MIME-Version: 1.0
        Content-Type: text/x-msmsgscontrol
        TypingUser: [email protected]

        Format is: MSG <Transaction ID> <Type of ACK required> <length of message in bytes>

        Transaction ID is used to correlate server responses to client requests.

        2.

        MSG [email protected] I%20am%20so%20great 102
        MIME-Version: 1.0
        Content-Type: text/x-msmsgscontrol
        TypingUser: [email protected]

        Format is: MSG <Nick> <URL encoded displayname> <length of message in bytes>
        
        """
        length = int(items[-1])
        start = fd.tell()
        end = start + length

        if "@" in items[1]:
            ## Its type 2 (see above)
            sender_name = "(%s)" % HTML.url_unquote(items[2])
        else:
            ## Its type 1
            sender_name = ''

        sender = fd.client_id
        ct = ''
        while 1:
            line = fd.readline().strip()
            if not line: break

            header, value = line.split(":",1)
            header = header.lower()
            
            if header == 'typinguser':
                fd.client_id = fd.reverse.dest_id = value.strip()
            elif header == 'content-type':
                ct = value

        ## Update the start to be start start of this line
        start = fd.tell()
        fd.seek(end - start, 1)
        ## We only care about text messages here
        if end > start and 'text/plain' in ct:
            ## Lets find out the timestamp of this point
            CacheManager.urn_insert_to_table(fd.urn, "msn_session",
                      dict(session_id = self.session_id,
                           _time = "from_unixtime(%s)" % fd.current_packet.ts_sec,
                           offset = start,
                           length = end - start,
                           sender = fd.client_id,
                           recipient = fd.dest_id,
                           type = 'MESSAGE',
                           ))
Exemplo n.º 5
0
    def MSG(self, items, fd, scanners):
        """ Sends message to members of the current session

        There are two types of messages that may be sent:

        1) A message from the client to the message server. 
           This does not contain the nick of the client, but does contain a 
           transaction ID.  This message is sent to all users in the 
           current session.

        2) A message from the Switchboard server to the client contains 
           the nick of the sender.

        These two commands are totally different.

        1.

        MSG 1532 U 92
        MIME-Version: 1.0
        Content-Type: text/x-msmsgscontrol
        TypingUser: [email protected]

        Format is: MSG <Transaction ID> <Type of ACK required> <length of message in bytes>

        Transaction ID is used to correlate server responses to client requests.

        2.

        MSG [email protected] I%20am%20so%20great 102
        MIME-Version: 1.0
        Content-Type: text/x-msmsgscontrol
        TypingUser: [email protected]

        Format is: MSG <Nick> <URL encoded displayname> <length of message in bytes>
        
        """
        length = int(items[-1])
        start = fd.tell()
        end = start + length

        if "@" in items[1]:
            ## Its type 2 (see above)
            sender_name = "(%s)" % HTML.url_unquote(items[2])
        else:
            ## Its type 1
            sender_name = ''

        sender = fd.client_id
        ct = ''
        while 1:
            line = fd.readline().strip()
            if not line: break

            header, value = line.split(":", 1)
            header = header.lower()

            if header == 'typinguser':
                fd.client_id = fd.reverse.dest_id = value.strip()
            elif header == 'content-type':
                ct = value

        ## Update the start to be start start of this line
        start = fd.tell()
        fd.seek(end - start, 1)
        ## We only care about text messages here
        if end > start and 'text/plain' in ct:
            ## Lets find out the timestamp of this point
            CacheManager.urn_insert_to_table(
                fd.urn, "msn_session",
                dict(
                    session_id=self.session_id,
                    _time="from_unixtime(%s)" % fd.current_packet.ts_sec,
                    offset=start,
                    length=end - start,
                    sender=fd.client_id,
                    recipient=fd.dest_id,
                    type='MESSAGE',
                ))