(kbs, sp)
| 758 | |
| 759 | # Show summary at the end of results containing the number of patches and the most recent patch installed |
| 760 | def print_summary(kbs, sp): |
| 761 | # Collect unique BulletinKBs |
| 762 | missingpatches = set(r['BulletinKB'] for r in kbs) |
| 763 | print(colored('[-] Missing patches: ', 'red') + '%s' % colored(len(missingpatches), 'yellow')) |
| 764 | |
| 765 | # Show missing KBs with number of vulnerabilites per KB |
| 766 | grouped = Counter([r['BulletinKB'] for r in kbs if r['DatePosted']]) |
| 767 | foundmissing = grouped.most_common() |
| 768 | for line in foundmissing: |
| 769 | kb = line[0] |
| 770 | number = line[1] |
| 771 | print(' - KB%s: patches %s %s' % (kb, number, 'vulnerability' if number == 1 else 'vulnerabilities')) |
| 772 | |
| 773 | # Show in case a service pack is missing |
| 774 | if sp: |
| 775 | print(colored('[-] Missing service pack', 'red')) |
| 776 | print(' - %s' % sp['Title']) |
| 777 | |
| 778 | # Show additional missing KBs when the --missing parameter is used |
| 779 | if len(missingpatches) > len(grouped): |
| 780 | difference = missingpatches.symmetric_difference([r[0] for r in foundmissing]) |
| 781 | for kb in difference: |
| 782 | print(' - KB%s: patches an unknown number of vulnerabilities' % kb) |
| 783 | print(colored('[I] Check the details of the unknown patches at https://support.microsoft.com/help/KBID,\n for example https://support.microsoft.com/help/890830 in case of KB890830', 'yellow')) |
| 784 | |
| 785 | # Show date of most recent KB |
| 786 | # Skip if no most recent KB available |
| 787 | if len(grouped) == 0: |
| 788 | return |
| 789 | foundkb = get_most_recent_kb(kbs) |
| 790 | message = colored('[I] KB with the most recent release date', 'yellow') |
| 791 | print('%s\n' |
| 792 | ' - ID: KB%s\n' |
| 793 | ' - Release date: %s' % (message, foundkb['BulletinKB'], foundkb['DatePosted'])) |
| 794 | |
| 795 | |
| 796 | # Obtain most recent KB from a dictionary of results |
no test coverage detected