Browse code

Add JSON properties to PE parsing

Shawn Webb authored on 2014/05/07 23:56:35
Showing 1 changed files
... ...
@@ -63,6 +63,8 @@
63 63
 #include "ishield.h"
64 64
 #include "asn1.h"
65 65
 
66
+#include "json_api.h"
67
+
66 68
 #define DCONF ctx->dconf->pe
67 69
 
68 70
 #define PE_IMAGE_DOS_SIGNATURE	    0x5a4d	    /* MZ */
... ...
@@ -602,6 +604,110 @@ end:
602 602
     return ret;
603 603
 }
604 604
 
605
+#if HAVE_JSON
606
+static struct json_object *get_pe_property(cli_ctx *ctx)
607
+{
608
+    struct json_object *pe;
609
+
610
+    if (!(ctx) || !(ctx->wrkproperty))
611
+        return NULL;
612
+
613
+    pe = json_object_object_get(ctx->wrkproperty, "PE");
614
+    if (!(pe)) {
615
+        pe = json_object_new_object();
616
+        if (!(pe))
617
+            return NULL;
618
+
619
+        json_object_object_add(ctx->wrkproperty, "PE", pe);
620
+    }
621
+
622
+    return pe;
623
+}
624
+
625
+static void pe_add_heuristic_property(cli_ctx *ctx, const char *key)
626
+{
627
+    struct json_object *heuristics;
628
+    struct json_object *pe;
629
+    struct json_object *str;
630
+
631
+    pe = get_pe_property(ctx);
632
+    if (!(pe))
633
+        return;
634
+
635
+    heuristics = json_object_object_get(pe, "Heuristics");
636
+    if (!(heuristics)) {
637
+        heuristics = json_object_new_array();
638
+        if (!(heuristics))
639
+            return;
640
+
641
+        json_object_object_add(pe, "Heuristics", heuristics);
642
+    }
643
+
644
+    str = json_object_new_string(key);
645
+    if (!(str))
646
+        return;
647
+
648
+    json_object_array_add(heuristics, str);
649
+}
650
+
651
+static struct json_object *get_section_json(cli_ctx *ctx)
652
+{
653
+    struct json_object *pe;
654
+    struct json_object *section;
655
+
656
+    pe = get_pe_property(ctx);
657
+    if (!(pe))
658
+        return NULL;
659
+
660
+    section = json_object_object_get(pe, "Sections");
661
+    if (!(section)) {
662
+        section = json_object_new_array();
663
+        if (!(section))
664
+            return NULL;
665
+
666
+        json_object_object_add(pe, "Sections", section);
667
+    }
668
+
669
+    return section;
670
+}
671
+
672
+static void add_section_info(cli_ctx *ctx, struct cli_exe_section *s)
673
+{
674
+    struct json_object *sections, *section, *obj;
675
+    char address[16];
676
+
677
+    sections = get_section_json(ctx);
678
+    if (!(sections))
679
+        return;
680
+
681
+    section = json_object_new_object();
682
+    if (!(section))
683
+        return;
684
+
685
+    obj = json_object_new_int((int32_t)(s->rsz));
686
+    if (!(obj))
687
+        return;
688
+
689
+    json_object_object_add(section, "RawSize", obj);
690
+
691
+    obj = json_object_new_int((int32_t)(s->raw));
692
+    if (!(obj))
693
+        return;
694
+
695
+    json_object_object_add(section, "RawOffset", obj);
696
+
697
+    snprintf(address, sizeof(address), "0x%08x", s->rva);
698
+
699
+    obj = json_object_new_string(address);
700
+    if (!(obj))
701
+        return;
702
+
703
+    json_object_object_add(section, "VirtualAddress", obj);
704
+
705
+    json_object_array_add(sections, section);
706
+}
707
+#endif
708
+
605 709
 int cli_scanpe(cli_ctx *ctx)
606 710
 {
607 711
 	uint16_t e_magic; /* DOS signature ("MZ") */
... ...
@@ -638,12 +744,22 @@ int cli_scanpe(cli_ctx *ctx)
638 638
 	int sha_collect = ctx->sha_collect;
639 639
 #endif
640 640
 	const char * virname = NULL;
641
+    const char *archtype=NULL, *subsystem=NULL;
641 642
 	uint32_t viruses_found = 0;
643
+#if HAVE_JSON
644
+    struct json_object *pe_json=NULL;
645
+    char jsonbuf[128];
646
+#endif
642 647
 
643 648
     if(!ctx) {
644 649
 	cli_errmsg("cli_scanpe: ctx == NULL\n");
645 650
 	return CL_ENULLARG;
646 651
     }
652
+
653
+#if HAVE_JSON
654
+    if (ctx->options & CL_SCAN_FILE_PROPERTIES)
655
+        pe_json = get_pe_property(ctx);
656
+#endif
647 657
     map = *ctx->fmap;
648 658
     if(fmap_readn(map, &e_magic, 0, sizeof(e_magic)) != sizeof(e_magic)) {
649 659
 	cli_dbgmsg("Can't read DOS signature\n");
... ...
@@ -684,109 +800,127 @@ int cli_scanpe(cli_ctx *ctx)
684 684
     }
685 685
 
686 686
     if(EC16(file_hdr.Characteristics) & 0x2000) {
687
+#if HAVE_JSON
688
+        if ((pe_json))
689
+            cli_jsonstr(pe_json, "Type", "DLL");
690
+#endif
687 691
 	cli_dbgmsg("File type: DLL\n");
688 692
 	dll = 1;
689 693
     } else if(EC16(file_hdr.Characteristics) & 0x01) {
694
+#if HAVE_JSON
695
+        if ((pe_json))
696
+            cli_jsonstr(pe_json, "Type", "EXE");
697
+#endif
690 698
 	cli_dbgmsg("File type: Executable\n");
691 699
     }
692 700
 
693 701
     switch(EC16(file_hdr.Machine)) {
694 702
 	case 0x0:
695
-	    cli_dbgmsg("Machine type: Unknown\n");
703
+        archtype = "Unknown";
696 704
 	    break;
697 705
 	case 0x14c:
698
-	    cli_dbgmsg("Machine type: 80386\n");
706
+        archtype = "80386";
699 707
 	    break;
700 708
 	case 0x14d:
701
-	    cli_dbgmsg("Machine type: 80486\n");
709
+        archtype = "80486";
702 710
 	    break;
703 711
 	case 0x14e:
704
-	    cli_dbgmsg("Machine type: 80586\n");
712
+        archtype = "80586";
705 713
 	    break;
706 714
 	case 0x160:
707
-	    cli_dbgmsg("Machine type: R30000 (big-endian)\n");
715
+        archtype = "R30000 (big-endian)";
708 716
 	    break;
709 717
 	case 0x162:
710
-	    cli_dbgmsg("Machine type: R3000\n");
718
+        archtype = "R3000";
711 719
 	    break;
712 720
 	case 0x166:
713
-	    cli_dbgmsg("Machine type: R4000\n");
721
+        archtype = "R4000";
714 722
 	    break;
715 723
 	case 0x168:
716
-	    cli_dbgmsg("Machine type: R10000\n");
724
+        archtype = "R10000";
717 725
 	    break;
718 726
 	case 0x184:
719
-	    cli_dbgmsg("Machine type: DEC Alpha AXP\n");
727
+        archtype = "DEC Alpha AXP";
720 728
 	    break;
721 729
 	case 0x284:
722
-	    cli_dbgmsg("Machine type: DEC Alpha AXP 64bit\n");
730
+        archtype = "DEC Alpha AXP 64bit";
723 731
 	    break;
724 732
 	case 0x1f0:
725
-	    cli_dbgmsg("Machine type: PowerPC\n");
733
+        archtype = "PowerPC";
726 734
 	    break;
727 735
 	case 0x200:
728
-	    cli_dbgmsg("Machine type: IA64\n");
736
+        archtype = "IA64";
729 737
 	    break;
730 738
 	case 0x268:
731
-	    cli_dbgmsg("Machine type: M68k\n");
739
+        archtype = "M68k";
732 740
 	    break;
733 741
 	case 0x266:
734
-	    cli_dbgmsg("Machine type: MIPS16\n");
742
+        archtype = "MIPS16";
735 743
 	    break;
736 744
 	case 0x366:
737
-	    cli_dbgmsg("Machine type: MIPS+FPU\n");
745
+        archtype = "MIPS+FPU";
738 746
 	    break;
739 747
 	case 0x466:
740
-	    cli_dbgmsg("Machine type: MIPS16+FPU\n");
748
+        archtype = "MIPS16+FPU";
741 749
 	    break;
742 750
 	case 0x1a2:
743
-	    cli_dbgmsg("Machine type: Hitachi SH3\n");
751
+        archtype = "Hitachi SH3";
744 752
 	    break;
745 753
 	case 0x1a3:
746
-	    cli_dbgmsg("Machine type: Hitachi SH3-DSP\n");
754
+        archtype = "Hitachi SH3-DSP";
747 755
 	    break;
748 756
 	case 0x1a4:
749
-	    cli_dbgmsg("Machine type: Hitachi SH3-E\n");
757
+        archtype = "Hitachi SH3-E";
750 758
 	    break;
751 759
 	case 0x1a6:
752
-	    cli_dbgmsg("Machine type: Hitachi SH4\n");
760
+        archtype = "Hitachi SH4";
753 761
 	    break;
754 762
 	case 0x1a8:
755
-	    cli_dbgmsg("Machine type: Hitachi SH5\n");
763
+        archtype = "Hitachi SH5";
756 764
 	    break;
757 765
 	case 0x1c0:
758
-	    cli_dbgmsg("Machine type: ARM\n");
766
+        archtype = "ARM";
759 767
 	    break;
760 768
 	case 0x1c2:
761
-	    cli_dbgmsg("Machine type: THUMB\n");
769
+        archtype = "THUMB";
762 770
 	    break;
763 771
 	case 0x1d3:
764
-	    cli_dbgmsg("Machine type: AM33\n");
772
+        archtype = "AM33";
765 773
 	    break;
766 774
 	case 0x520:
767
-	    cli_dbgmsg("Machine type: Infineon TriCore\n");
775
+        archtype = "Infineon TriCore";
768 776
 	    break;
769 777
 	case 0xcef:
770
-	    cli_dbgmsg("Machine type: CEF\n");
778
+        archtype = "CEF";
771 779
 	    break;
772 780
 	case 0xebc:
773
-	    cli_dbgmsg("Machine type: EFI Byte Code\n");
781
+        archtype = "EFI Byte Code";
774 782
 	    break;
775 783
 	case 0x9041:
776
-	    cli_dbgmsg("Machine type: M32R\n");
784
+        archtype = "M32R";
777 785
 	    break;
778 786
 	case 0xc0ee:
779
-	    cli_dbgmsg("Machine type: CEE\n");
787
+        archtype = "CEEE";
780 788
 	    break;
781 789
 	case 0x8664:
782
-	    cli_dbgmsg("Machine type: AMD64\n");
790
+        archtype = "AMD64";
783 791
 	    break;
784 792
 	default:
785
-	    cli_dbgmsg("Machine type: ** UNKNOWN ** (0x%x)\n", EC16(file_hdr.Machine));
793
+        archtype = "Unknown";
794
+    }
795
+
796
+    if ((archtype)) {
797
+        cli_dbgmsg("Machine type: %s\n", archtype);
798
+#if HAVE_JSON
799
+        cli_jsonstr(pe_json, "ArchType", archtype);
800
+#endif
786 801
     }
787 802
 
788 803
     nsections = EC16(file_hdr.NumberOfSections);
789 804
     if(nsections < 1 || nsections > 96) {
805
+#if HAVE_JSON
806
+        pe_add_heuristic_property(ctx, "BadNumberOfSections");
807
+#endif
790 808
 	if(DETECT_BROKEN_PE) {
791 809
 	    cli_append_virus(ctx,"Heuristics.Broken.Executable");
792 810
 	    return CL_VIRUS;
... ...
@@ -807,6 +941,9 @@ int cli_scanpe(cli_ctx *ctx)
807 807
     cli_dbgmsg("SizeOfOptionalHeader: %x\n", EC16(file_hdr.SizeOfOptionalHeader));
808 808
 
809 809
     if (EC16(file_hdr.SizeOfOptionalHeader) < sizeof(struct pe_image_optional_hdr32)) {
810
+#if HAVE_JSON
811
+        pe_add_heuristic_property(ctx, "BadOptionalHeaderSize");
812
+#endif
810 813
         cli_dbgmsg("SizeOfOptionalHeader too small\n");
811 814
 	if(DETECT_BROKEN_PE) {
812 815
 	    cli_append_virus(ctx,"Heuristics.Broken.Executable");
... ...
@@ -828,6 +965,9 @@ int cli_scanpe(cli_ctx *ctx)
828 828
 
829 829
     /* This will be a chicken and egg problem until we drop 9x */
830 830
     if(EC16(optional_hdr64.Magic)==PE32P_SIGNATURE) {
831
+#if HAVE_JSON
832
+        pe_add_heuristic_property(ctx, "BadOptionalHeaderSizePE32Plus");
833
+#endif
831 834
         if(EC16(file_hdr.SizeOfOptionalHeader)!=sizeof(struct pe_image_optional_hdr64)) {
832 835
 	    /* FIXME: need to play around a bit more with xp64 */
833 836
 	    cli_dbgmsg("Incorrect SizeOfOptionalHeader for PE32+\n");
... ...
@@ -901,55 +1041,68 @@ int cli_scanpe(cli_ctx *ctx)
901 901
 	dirs = optional_hdr64.DataDirectory;
902 902
     }
903 903
 
904
+#if HAVE_JSON
905
+    if (ctx->options & CL_SCAN_FILE_PROPERTIES) {
906
+        snprintf(jsonbuf, sizeof(jsonbuf), "0x%x", vep);
907
+        cli_jsonstr(pe_json, "EntryPoint", jsonbuf);
908
+    }
909
+#endif
910
+
904 911
 
905 912
     switch(pe_plus ? EC16(optional_hdr64.Subsystem) : EC16(optional_hdr32.Subsystem)) {
906 913
 	case 0:
907
-	    cli_dbgmsg("Subsystem: Unknown\n");
914
+        subsystem = "Unknown";
908 915
 	    break;
909 916
 	case 1:
910
-	    cli_dbgmsg("Subsystem: Native (svc)\n");
917
+        subsystem = "Native (svc)";
911 918
 	    native = 1;
912 919
 	    break;
913 920
 	case 2:
914
-	    cli_dbgmsg("Subsystem: Win32 GUI\n");
921
+        subsystem = "Win32 GUI";
915 922
 	    break;
916 923
 	case 3:
917
-	    cli_dbgmsg("Subsystem: Win32 console\n");
924
+        subsystem = "Win32 console";
918 925
 	    break;
919 926
 	case 5:
920
-	    cli_dbgmsg("Subsystem: OS/2 console\n");
927
+        subsystem = "OS/2 console";
921 928
 	    break;
922 929
 	case 7:
923
-	    cli_dbgmsg("Subsystem: POSIX console\n");
930
+        subsystem = "POSIX console";
924 931
 	    break;
925 932
 	case 8:
926
-	    cli_dbgmsg("Subsystem: Native Win9x driver\n");
933
+        subsystem = "Native Win9x driver";
927 934
 	    break;
928 935
 	case 9:
929
-	    cli_dbgmsg("Subsystem: WinCE GUI\n");
936
+        subsystem = "WinCE GUI";
930 937
 	    break;
931 938
 	case 10:
932
-	    cli_dbgmsg("Subsystem: EFI application\n");
939
+        subsystem = "EFI application";
933 940
 	    break;
934 941
 	case 11:
935
-	    cli_dbgmsg("Subsystem: EFI driver\n");
942
+        subsystem = "EFI driver";
936 943
 	    break;
937 944
 	case 12:
938
-	    cli_dbgmsg("Subsystem: EFI runtime driver\n");
945
+        subsystem = "EFI runtime driver";
939 946
 	    break;
940 947
 	case 13:
941
-	    cli_dbgmsg("Subsystem: EFI ROM image\n");
948
+        subsystem = "EFI ROM image";
942 949
 	    break;
943 950
 	case 14:
944
-	    cli_dbgmsg("Subsystem: Xbox\n");
951
+        subsystem = "Xbox";
945 952
 	    break;
946 953
 	case 16:
947
-	    cli_dbgmsg("Subsystem: Boot application\n");
954
+        subsystem = "Boot application";
948 955
 	    break;
949 956
 	default:
950
-	    cli_dbgmsg("Subsystem: ** UNKNOWN ** (0x%x)\n", pe_plus ? EC16(optional_hdr64.Subsystem) : EC16(optional_hdr32.Subsystem));
957
+        subsystem = "Unknown";
951 958
     }
952 959
 
960
+    cli_dbgmsg("Subsystem: %s\n", subsystem);
961
+
962
+#if HAVE_JSON
963
+    cli_jsonstr(pe_json, "Subsystem", subsystem);
964
+#endif
965
+
953 966
     cli_dbgmsg("------------------------------------\n");
954 967
 
955 968
     if (DETECT_BROKEN_PE && !native && (!(pe_plus?EC32(optional_hdr64.SectionAlignment):EC32(optional_hdr32.SectionAlignment)) || (pe_plus?EC32(optional_hdr64.SectionAlignment):EC32(optional_hdr32.SectionAlignment))%0x1000)) {
... ...
@@ -1007,6 +1160,10 @@ int cli_scanpe(cli_ctx *ctx)
1007 1007
 
1008 1008
     hdr_size = PESALIGN(hdr_size, valign); /* Aligned headers virtual size */
1009 1009
 
1010
+#if HAVE_JSON
1011
+    cli_jsonint(pe_json, "NumberOfSections", nsections);
1012
+#endif
1013
+
1010 1014
     for(i = 0; i < nsections; i++) {
1011 1015
 	strncpy(sname, (char *) section_hdr[i].Name, 8);
1012 1016
 	sname[8] = 0;
... ...
@@ -1020,6 +1177,10 @@ int cli_scanpe(cli_ctx *ctx)
1020 1020
 	exe_sections[i].uraw = EC32(section_hdr[i].PointerToRawData);
1021 1021
 	exe_sections[i].ursz = EC32(section_hdr[i].SizeOfRawData);
1022 1022
 
1023
+#if HAVE_JSON
1024
+    add_section_info(ctx, &exe_sections[i]);
1025
+#endif
1026
+
1023 1027
 	if (!exe_sections[i].vsz && exe_sections[i].rsz)
1024 1028
 	    exe_sections[i].vsz=PESALIGN(exe_sections[i].ursz, valign);
1025 1029
 
... ...
@@ -1143,6 +1304,10 @@ int cli_scanpe(cli_ctx *ctx)
1143 1143
 	return CL_CLEAN;
1144 1144
     }
1145 1145
 
1146
+#if HAVE_JSON
1147
+    cli_jsonint(pe_json, "EntryPointOffset", ep);
1148
+#endif
1149
+
1146 1150
     cli_dbgmsg("EntryPoint offset: 0x%x (%d)\n", ep, ep);
1147 1151
 
1148 1152
     if(pe_plus) { /* Do not continue for PE32+ files */
... ...
@@ -1454,6 +1619,9 @@ int cli_scanpe(cli_ctx *ctx)
1454 1454
 	    if(!exe_sections[i].rsz && exe_sections[i].vsz && exe_sections[i + 1].rsz && exe_sections[i + 1].vsz) {
1455 1455
 		found = 1;
1456 1456
 		cli_dbgmsg("UPX/FSG/MEW: empty section found - assuming compression\n");
1457
+#if HAVE_JSON
1458
+        cli_jsonbool(pe_json, "HasEmptySection", 1);
1459
+#endif
1457 1460
 		break;
1458 1461
 	    }
1459 1462
 	}
... ...
@@ -1526,6 +1694,10 @@ int cli_scanpe(cli_ctx *ctx)
1526 1526
 	        uselzma = 0;
1527 1527
 	    }
1528 1528
 
1529
+#if HAVE_JSON
1530
+        cli_jsonstr(pe_json, "Packer", "MEW");
1531
+#endif
1532
+
1529 1533
 	    CLI_UNPTEMP("MEW",(src,exe_sections,0));
1530 1534
 	    CLI_UNPRESULTS("MEW",(unmew11(src, offdiff, ssize, dsize, EC32(optional_hdr32.ImageBase), exe_sections[0].rva, uselzma, ndesc)),1,(src,0));
1531 1535
 	    break;
... ...
@@ -1632,6 +1804,10 @@ int cli_scanpe(cli_ctx *ctx)
1632 1632
 		break;
1633 1633
 	    }
1634 1634
 
1635
+#if HAVE_JSON
1636
+        cli_jsonstr(pe_json, "Packer", "Upack");
1637
+#endif
1638
+
1635 1639
 	    CLI_UNPTEMP("Upack",(dest,exe_sections,0));
1636 1640
 	    CLI_UNPRESULTS("Upack",(unupack(upack, dest, dsize, epbuff, vma, ep, EC32(optional_hdr32.ImageBase), exe_sections[0].rva, ndesc)),1,(dest,0));
1637 1641
 	    break;
... ...
@@ -1715,6 +1891,10 @@ int cli_scanpe(cli_ctx *ctx)
1715 1715
 	    return CL_EMEM;
1716 1716
 	}
1717 1717
 
1718
+#if HAVE_JSON
1719
+    cli_jsonstr(pe_json, "Packer", "FSG");
1720
+#endif
1721
+
1718 1722
 	CLI_UNPTEMP("FSG",(dest,exe_sections,0));
1719 1723
 	CLI_UNPRESULTSFSG2("FSG",(unfsg_200(newesi - exe_sections[i + 1].rva + src, dest, ssize + exe_sections[i + 1].rva - newesi, dsize, newedi, EC32(optional_hdr32.ImageBase), newedx, ndesc)),1,(dest,0));
1720 1724
 	break;
... ...
@@ -1818,6 +1998,10 @@ int cli_scanpe(cli_ctx *ctx)
1818 1818
 	oldep = vep + 161 + 6 + cli_readint32(epbuff+163);
1819 1819
 	cli_dbgmsg("FSG: found old EP @%x\n", oldep);
1820 1820
 
1821
+#if HAVE_JSON
1822
+    cli_jsonstr(pe_json, "Packer", "FSG");
1823
+#endif
1824
+
1821 1825
 	CLI_UNPTEMP("FSG",(dest,sections,exe_sections,0));
1822 1826
 	CLI_UNPRESULTSFSG1("FSG",(unfsg_133(src + newesi - exe_sections[i + 1].rva, dest, ssize + exe_sections[i + 1].rva - newesi, dsize, sections, sectcnt, EC32(optional_hdr32.ImageBase), oldep, ndesc)),1,(dest,sections,0));
1823 1827
 	break; /* were done with 1.33 */
... ...
@@ -1920,6 +2104,10 @@ int cli_scanpe(cli_ctx *ctx)
1920 1920
 	oldep = vep + gp + 6 + cli_readint32(src+gp+2+oldep);
1921 1921
 	cli_dbgmsg("FSG: found old EP @%x\n", oldep);
1922 1922
 
1923
+#if HAVE_JSON
1924
+    cli_jsonstr(pe_json, "Packer", "FSG");
1925
+#endif
1926
+
1923 1927
 	CLI_UNPTEMP("FSG",(dest,sections,exe_sections,0));
1924 1928
 	CLI_UNPRESULTSFSG1("FSG",(unfsg_133(src + newesi - exe_sections[i + 1].rva, dest, ssize + exe_sections[i + 1].rva - newesi, dsize, sections, sectcnt, EC32(optional_hdr32.ImageBase), oldep, ndesc)),1,(dest,sections,0));
1925 1929
 	break; /* were done with 1.31 */
... ...
@@ -2051,6 +2239,9 @@ int cli_scanpe(cli_ctx *ctx)
2051 2051
 	free(exe_sections);
2052 2052
 
2053 2053
 	CLI_UNPTEMP("UPX/FSG",(dest,0));
2054
+#if HAVE_JSON
2055
+    cli_jsonstr(pe_json, "Packer", "UPX");
2056
+#endif
2054 2057
 
2055 2058
 	if((unsigned int) write(ndesc, dest, dsize) != dsize) {
2056 2059
 	    cli_dbgmsg("UPX/FSG: Can't write %d bytes\n", dsize);
... ...
@@ -2133,6 +2324,10 @@ int cli_scanpe(cli_ctx *ctx)
2133 2133
 		}
2134 2134
 	    }
2135 2135
 
2136
+#if HAVE_JSON
2137
+        cli_jsonstr(pe_json, "Packer", "Petite");
2138
+#endif
2139
+
2136 2140
 	    CLI_UNPTEMP("Petite",(dest,exe_sections,0));
2137 2141
 	    CLI_UNPRESULTS("Petite",(petite_inflate2x_1to9(dest, min, max - min, exe_sections, nsections - (found == 1 ? 1 : 0), EC32(optional_hdr32.ImageBase),vep, ndesc, found, EC32(optional_hdr32.DataDirectory[2].VirtualAddress),EC32(optional_hdr32.DataDirectory[2].Size))),0,(dest,0));
2138 2142
 	}
... ...
@@ -2162,6 +2357,10 @@ int cli_scanpe(cli_ctx *ctx)
2162 2162
 	    return CL_EREAD;
2163 2163
 	}
2164 2164
 
2165
+#if HAVE_JSON
2166
+    cli_jsonstr(pe_json, "Packer", "PEspin");
2167
+#endif
2168
+
2165 2169
 	CLI_UNPTEMP("PESpin",(spinned,exe_sections,0));
2166 2170
 	CLI_UNPRESULTS_("PEspin",SPINCASE(),(unspin(spinned, fsize, exe_sections, nsections - 1, vep, ndesc, ctx)),0,(spinned,0));
2167 2171
     }
... ...
@@ -2226,6 +2425,10 @@ int cli_scanpe(cli_ctx *ctx)
2226 2226
 	      return CL_EREAD;
2227 2227
 	    }
2228 2228
 
2229
+#if HAVE_JSON
2230
+        cli_jsonstr(pe_json, "Packer", "yC");
2231
+#endif
2232
+
2229 2233
 	    cli_dbgmsg("%d,%d,%d,%d\n", nsections-1, e_lfanew, ecx, offset);
2230 2234
 	    CLI_UNPTEMP("yC",(spinned,exe_sections,0));
2231 2235
 	    CLI_UNPRESULTS("yC",(yc_decrypt(spinned, fsize, exe_sections, nsections-1, e_lfanew, ndesc, ecx, offset)),0,(spinned,0));
... ...
@@ -2287,6 +2490,10 @@ int cli_scanpe(cli_ctx *ctx)
2287 2287
 	    return CL_EREAD;
2288 2288
 	}
2289 2289
 
2290
+#if HAVE_JSON
2291
+    cli_jsonstr(pe_json, "Packer", "WWPack");
2292
+#endif
2293
+
2290 2294
 	CLI_UNPTEMP("WWPack",(src,packer,exe_sections,0));
2291 2295
 	CLI_UNPRESULTS("WWPack",(wwunpack((uint8_t *)src, ssize, packer, exe_sections, nsections-1, e_lfanew, ndesc)),0,(src,packer,0));
2292 2296
 	break;
... ...
@@ -2321,6 +2528,10 @@ int cli_scanpe(cli_ctx *ctx)
2321 2321
             break;
2322 2322
         }
2323 2323
 
2324
+#if HAVE_JSON
2325
+        cli_jsonstr(pe_json, "Packer", "Aspack");
2326
+#endif
2327
+
2324 2328
 	CLI_UNPTEMP("Aspack",(src,exe_sections,0));
2325 2329
 	CLI_UNPRESULTS("Aspack",(unaspack212((uint8_t *)src, ssize, exe_sections, nsections, vep-1, EC32(optional_hdr32.ImageBase), ndesc)),1,(src,0));
2326 2330
 	break;
... ...
@@ -2387,6 +2598,10 @@ int cli_scanpe(cli_ctx *ctx)
2387 2387
 	eprva=eprva+5+cli_readint32(nbuff+1);
2388 2388
 	cli_dbgmsg("NsPack: OEP = %08x\n", eprva);
2389 2389
 
2390
+#if HAVE_JSON
2391
+    cli_jsonstr(pe_json, "Packer", "NsPack");
2392
+#endif
2393
+
2390 2394
 	CLI_UNPTEMP("NsPack",(dest,exe_sections,0));
2391 2395
 	CLI_UNPRESULTS("NsPack",(unspack(src, dest, ctx, exe_sections[0].rva, EC32(optional_hdr32.ImageBase), eprva, ndesc)),0,(dest,0));
2392 2396
 	break;