Beispiel #1
0
 def details(self):
   record = api.get_record(self.ref_id, 
                           self.info.get('ref_collection', 'stream'), 
                           db_name=self.db_name)
   if not record or record.has_key('is_removed'):
     return Feed({})
   return Feed(record)
Beispiel #2
0
 def details(self):
     record = api.get_record(self.ref_id,
                             self.info.get('ref_collection', 'stream'),
                             db_name=self.db_name)
     if not record or record.has_key('is_removed'):
         return Feed({})
     return Feed(record, db_name=self.db_name)
Beispiel #3
0
 def item(self):
   record = api.get_record(self.ref_id, 
                           self.info.get('ref_collection', 'stream'), 
                           db_name=self.db_name)
   if not record or record.has_key('is_removed'):
     return Feed({})
   if self.comment_id:
     info = Feed(record, db_name=self.db_name)
     for i in info.comments:
       if i.id == self.comment_id:
         info.message = i.message
         info.owner = i.owner
         info.timestamp = i.timestamp
         break
   elif record.has_key('version'):
     info = Note(record, db_name=self.db_name)
     info.message = info.title
   elif record.has_key('when'):
     info = Event(record)
     info.message = info.name
   elif record.has_key('members'):
     info = Group(info, db_name=self.db_name)
   elif record.has_key('password'):
     info = User(info, db_name=self.db_name)
   else:
     info = Feed(record, db_name=self.db_name)
   return info
 def test_simple_get_record(self):
     specifier = 'title="test"'
     self.assertEqual(api.get_record(specifier),
                      {'title': {
                          '$options': 'i',
                          '$regex': 'test'
                      }})
Beispiel #5
0
 def item(self):
     record = api.get_record(self.ref_id,
                             self.info.get('ref_collection', 'stream'),
                             db_name=self.db_name)
     if not record or record.has_key('is_removed'):
         return Feed({})
     if self.comment_id:
         info = Feed(record, db_name=self.db_name)
         for i in info.comments:
             if i.id == self.comment_id:
                 info.message = i.message
                 info.owner = i.owner
                 info.timestamp = i.timestamp
                 break
     elif record.has_key('version'):
         info = Note(record, db_name=self.db_name)
         info.message = info.title
     elif record.has_key('when'):
         info = Event(record)
         info.message = info.name
     elif record.has_key('members'):
         info = Group(info, db_name=self.db_name)
     elif record.has_key('password'):
         info = User(info, db_name=self.db_name)
     else:
         info = Feed(record, db_name=self.db_name)
     return info
 def test_and_get_record(self):
     specifier = 'title="test"&title="here"'
     self.assertEqual(
         api.get_record(specifier), {
             '$and': [{
                 'title': {
                     '$options': 'i',
                     '$regex': 'test'
                 }
             }, {
                 'title': {
                     '$options': 'i',
                     '$regex': 'here'
                 }
             }]
         })
Beispiel #7
0
 def details(self):
   if self.ref_id == 'public':
     info = api.get_network_info(self.db_name)
     return info
   
   if self.info.get('type') == 'new_network':
     info = api.get_network_info(self.ref_id)
     return info
   
   record = api.get_record(self.ref_id, 
                           self.ref_collection, 
                           db_name=self.db_name)
     
   if not record or record.has_key('is_removed'):
     return None
   elif record.has_key('members'):
     info = Group(record, db_name=self.db_name)
   elif record.has_key('password'):
     info = User(record, db_name=self.db_name)
   else:
     info = Feed(record, db_name=self.db_name)
   return info
Beispiel #8
0
    def details(self):
        if self.ref_id == 'public':
            info = api.get_network_info(self.db_name)
            return info

        if self.info.get('type') == 'new_network':
            info = api.get_network_info(self.ref_id)
            return info

        record = api.get_record(self.ref_id,
                                self.ref_collection,
                                db_name=self.db_name)

        if not record or record.has_key('is_removed'):
            return None
        elif record.has_key('members'):
            info = Group(record, db_name=self.db_name)
        elif record.has_key('password'):
            info = User(record, db_name=self.db_name)
        else:
            info = Feed(record, db_name=self.db_name)
        return info
Beispiel #9
0
 def highlights(self):
   return [api.Note(api.get_record(i)) for i in self.highlight_ids]
Beispiel #10
0
 def highlights(self):
     return [api.Note(api.get_record(i, db_name=self.db_name)) \
             for i in self.highlight_ids]
Beispiel #11
0
 def highlights(self):
   return [api.Note(api.get_record(i)) for i in self.highlight_ids]
Beispiel #12
0
 def highlights(self):
   return [api.Note(api.get_record(i, db_name=self.db_name)) \
           for i in self.highlight_ids]
Beispiel #13
0
# we showed an error when we checked for the network information.
if network_info is None:
    sys.exit(1)

# Calculate Traceroute hops to 8.8.8.8
print 'Calculating traceroute hops.'
hops = net_info.calculate_hops()
router_ip = hops[0]

# Validate DNS records to check for DNS spoofing
print 'Calculating DNS records.'
address_list = net_info.lookup_domains()

# Get the record from the database.
print 'Requested known access point record.'
ap_record = api.get_record(network_info['bssid'])
if ap_record is not None:
    print GREEN + 'Record found.' + ENDC
    # Checking security type against the record
    print 'Checking security type against record.'
    if ap_record['securityType'] != network_info['security_type']:
        safety_weight -= 28
        print RED + 'Security type of known network is different.' + ENDC
        print RED + 'Current type is ' + network_info['security_type'] + ' and recorded type is ' + ap_record['securityType'] + ENDC
    # Checking SSID against the record
    print 'Checking SSID against record.'
    if ap_record['ssid'] != network_info['ssid']:
        safety_weight -= 3
        print RED + 'ESSID of known network is different.' + ENDC
        print RED + 'Current ESSID is ' + network_info['ssid'] + ' and the recorded type is ' + ap_record['ssid'] + ENDC
    # Check the public IP address against the records
Beispiel #14
0
def do_command(params):

    if (params.command == 'q'): 
        return False 

    elif (params.command == 'l'): 
        results = api.search_records(params, '')
        display.formatted_records(results)

    elif (params.command[:2] == 'g '):
        r = api.get_record(params, params.command[2:])
        if r:
            r.display()

    elif (params.command[:2] == 'r '): 
        api.rotate_password(params, params.command[2:])

    elif (params.command == 'c'):
        print(chr(27) + "[2J") 

    elif (params.command[:2] == 's '): 
        results = api.search_records(params, params.command[2:])
        display.formatted_records(results)

    elif (params.command[:2] == 'b '): 
        results = api.search_records(params, params.command[2:])
        for r in results:
            api.rotate_password(params, r.record_uid)

    elif (params.command == 'd'):
        api.sync_down(params)

    elif (params.command == 'a'):
        api.add_record(params)

    elif (params.command == 'h'):
        display.formatted_history(stack) 

    elif (params.command == 'debug'): 
        if params.debug: 
            params.debug = False
            print('Debug OFF')
        else:
            params.debug = True
            print('Debug ON')

    elif params.command == '':
        pass

    else:
        print('\n\nCommands:\n')
        print('  d         ... download & decrypt data')
        print('  l         ... list folders and titles')
        print('  s <regex> ... search with regular expression')
        print('  g <uid>   ... get record details for uid')
        print('  r <uid>   ... rotate password for uid')
        print('  b <regex> ... rotate password for matches of regular expression')
        print('  a         ... add a new record interactively')
        print('  c         ... clear the screen')
        print('  h         ... show command history')
        print('  q         ... quit')
        print('')

    if params.command:
        if params.command != 'h':
            stack.append(params.command)
            stack.reverse()

    return True
Beispiel #15
0
def do_command(params):

    if (params.command == 'q'):
        return False

    elif (params.command == 'l'):
        results = api.search_records(params, '')
        display.formatted_records(results)

    elif (params.command[:2] == 'g '):
        r = api.get_record(params, params.command[2:])
        if r:
            r.display()

    elif (params.command[:2] == 'r '):
        api.rotate_password(params, params.command[2:])

    elif (params.command == 'c'):
        print(chr(27) + "[2J")

    elif (params.command[:2] == 's '):
        results = api.search_records(params, params.command[2:])
        display.formatted_records(results)

    elif (params.command[:2] == 'b '):
        results = api.search_records(params, params.command[2:])
        for r in results:
            api.rotate_password(params, r.record_uid)

    elif (params.command == 'd'):
        api.sync_down(params)

    elif (params.command == 'a'):
        api.add_record(params)

    elif (params.command == 'h'):
        display.formatted_history(stack)

    elif (params.command == 'debug'):
        if params.debug:
            params.debug = False
            print('Debug OFF')
        else:
            params.debug = True
            print('Debug ON')

    elif params.command == '':
        pass

    else:
        print('\n\nCommands:\n')
        print('  d         ... download & decrypt data')
        print('  l         ... list folders and titles')
        print('  s <regex> ... search with regular expression')
        print('  g <uid>   ... get record details for uid')
        print('  r <uid>   ... rotate password for uid')
        print(
            '  b <regex> ... rotate password for matches of regular expression'
        )
        print('  a         ... add a new record interactively')
        print('  c         ... clear the screen')
        print('  h         ... show command history')
        print('  q         ... quit')
        print('')

    if params.command:
        if params.command != 'h':
            stack.append(params.command)
            stack.reverse()

    return True