|
1 | 1 | ''' |
2 | | -MC Extractor v1.0.3.0 |
| 2 | +MC Extractor v1.1.0.1 |
3 | 3 | Copyright (C) 2016 Plato Mavropoulos |
4 | 4 | Based on UEFIStrip v7.8.2 by Lordkag |
5 | 5 | ''' |
6 | 6 |
|
7 | | -title = 'MC Extractor v1.0.3' |
| 7 | +title = 'MC Extractor v1.1.0 Dev 1' |
8 | 8 |
|
9 | 9 | import sys |
10 | 10 | import re |
@@ -573,7 +573,7 @@ def mass_scan(f_path) : |
573 | 573 | if param.conv_cont : |
574 | 574 | mc_f_ex = open(in_file, "r") |
575 | 575 |
|
576 | | - temp_file = tempfile.NamedTemporaryFile(mode='ab',delete=False) # No auto delete for use at init_file |
| 576 | + temp_file = tempfile.NamedTemporaryFile(mode='ab', delete=False) # No auto delete for use at init_file |
577 | 577 |
|
578 | 578 | try : |
579 | 579 | for line in mc_f_ex : |
@@ -620,10 +620,10 @@ def mass_scan(f_path) : |
620 | 620 | if not param.exp_check : |
621 | 621 | # Intel 64 and IA-32 Architectures Software Developer's Manual [325462, 06/2016] (Vol 3A, Ch 9.11.1, Page 2954) |
622 | 622 | # HeaderRev 01, LoaderRev 01, ProcesFlags xx00*3 |
623 | | - pat_icpu = re.compile(br'\x01\x00{3}.{4}[\x00-\x99](((\x19|\x20)[\x01-\x31][\x01-\x12])|(\x18\x07\x00)).{8}\x01\x00{3}.\x00{3}', re.DOTALL) |
| 623 | + pat_icpu = re.compile(br'\x01\x00{3}.{4}[\x00-\x99](([\x19-\x20][\x01-\x31][\x01-\x12])|(\x18\x07\x00)).{8}\x01\x00{3}.\x00{3}', re.DOTALL) |
624 | 624 | else : |
625 | 625 | # HeaderRev 01-02, LoaderRev 01-02, ProcesFlags xxxx00*2, Reserved xx*12 |
626 | | - pat_icpu = re.compile(br'(\x01|\x02)\x00{3}.{4}[\x00-\x99](((\x19|\x20)[\x01-\x31][\x01-\x12])|(\x18\x07\x00)).{8}(\x01|\x02)\x00{3}.{2}\x00{2}', re.DOTALL) |
| 626 | + pat_icpu = re.compile(br'(\x01|\x02)\x00{3}.{4}[\x00-\x99](([\x19-\x20][\x01-\x31][\x01-\x12])|(\x18\x07\x00)).{8}(\x01|\x02)\x00{3}.{2}\x00{2}', re.DOTALL) |
627 | 627 |
|
628 | 628 | match_list_i += pat_icpu.finditer(reading) |
629 | 629 |
|
@@ -743,20 +743,19 @@ def mass_scan(f_path) : |
743 | 743 | # CPUID 610F21 = 61 + 0F + 21 = (1 + 4) + (2 + 5) + (3 + 6) = 6+F + 12 + 01 = 15 + 12 + 01 = MU 151201 |
744 | 744 | # MU 151201 = 15 + 12 + 01 = 6+F + 12 + 01 = (1 + 3 + 5) + (2 + 4 + 6) = 610 + F21 = CPUID 610F21 |
745 | 745 |
|
746 | | - # General UEFI patterns, should be robust |
| 746 | + # UEFI patterns |
747 | 747 | pat_acpu_1 = re.compile(br'\x24\x55\x43\x4F\x44\x45((\x56\x53)|(\x32\x4B)|(\x34\x4B))') # $UCODEVS, $UCODE2K, $UCODE4K |
748 | 748 | match_list_a += pat_acpu_1.finditer(reading) |
749 | 749 |
|
| 750 | + # 1st MC from 1999 (K7), 2000 due to K7 Erratum and performance |
750 | 751 | if not param.exp_check : |
751 | | - # General non-UEFI patterns, should be robust (2 -> CPUID = 6 , 3 -> CPUID != 6) |
752 | | - pat_acpu_2 = re.compile(br'[\x00-\x99]\x20[\x01-\x31][\x01-\x13].{4}\x02\x80.{18}(\x00|\x01)\x00{3}', re.DOTALL) # 2000 & up |
753 | | - pat_acpu_3 = re.compile(br'(([\x00-\x99](\x19|\x20)[\x01-\x31][\x01-\x12])|(\x11\x20\x09\x13)).{4}(\x00|\x01|\x03)\x80.{18}(\x00|\x01)\xAA{3}', re.DOTALL) |
| 752 | + # BIOS pattern |
| 753 | + pat_acpu_2 = re.compile(br'[\x00-\x18]\x20[\x01-\x31][\x01-\x13].{4}[\x00-\x03]\x80.{18}[\x00-\x01](\xAA|\x00){3}', re.DOTALL) |
754 | 754 | match_list_a += pat_acpu_2.finditer(reading) |
755 | | - match_list_a += pat_acpu_3.finditer(reading) |
756 | 755 | else : |
757 | 756 | # Data Rev 00-09, Reserved AA or 00, API 00-09 |
758 | | - pat_acpu_4 = re.compile(br'(([\x00-\x99](\x19|\x20)[\x01-\x31][\x01-\x13])|(\x11\x20\x09\x13)).{4}[\x00-\x09]\x80.{18}[\x00-\x09](\x00{3}|\xAA{3})', re.DOTALL) |
759 | | - match_list_a += pat_acpu_4.finditer(reading) |
| 757 | + pat_acpu_3 = re.compile(br'[\x00-\x18]\x20[\x01-\x31][\x01-\x13].{4}[\x00-\x09]\x80.{18}[\x00-\x09](\xAA|\x00){3}', re.DOTALL) |
| 758 | + match_list_a += pat_acpu_3.finditer(reading) |
760 | 759 |
|
761 | 760 | for match_ucode in match_list_a : |
762 | 761 |
|
@@ -792,17 +791,13 @@ def mass_scan(f_path) : |
792 | 791 | nbsb_rev_id = '%0.2X' % mc_hdr.NbRevId + '%0.2X' % mc_hdr.SbRevId |
793 | 792 |
|
794 | 793 | full_date = "%s-%s-%s" % (day, month, year) |
795 | | - |
| 794 | + |
796 | 795 | # Remove false results, based on Date |
797 | | - try: |
798 | | - date_chk = datetime.datetime.strptime(full_date, '%d-%m-%Y') |
799 | | - if date_chk.year > 2016 or date_chk.year < 1997 : raise DateErr('WrongDate') # 1st MC from 1999 (K7), 1997 for safety |
800 | | - except : |
801 | | - if full_date == '09-13-2011' and patch == '03000027' : pass # Drunk employee #2, Happy 13th month from AMD! |
802 | | - else : |
803 | | - print(col_magenta + "\nWarning: Skipped microcode at 0x%0.2X, invalid Date of %s!\n" % (mc_bgn, full_date) + col_end) |
804 | | - continue |
805 | | - |
| 796 | + if full_date == '09-13-2011' and patch == '03000027' : pass # Drunk employee #2, Happy 13th month from AMD! |
| 797 | + elif month == '13' or year > '2016' : |
| 798 | + print(col_magenta + "\nWarning: Skipped microcode at 0x%0.2X, invalid Date of %s!\n" % (mc_bgn, full_date) + col_end) |
| 799 | + continue |
| 800 | + |
806 | 801 | # Remove false results, based on VEN_IDs |
807 | 802 | if (nb_id != '0'*8 and '1002' not in nb_id[4:8] and '1022' not in nb_id[4:8]) \ |
808 | 803 | or (sb_id != '0'*8 and '1002' not in sb_id[4:8] and '1022' not in sb_id[4:8]) : |
|
0 commit comments