예제 #1
0
 public Loader(IServiceProvider services)
 {
     this.Services    = services;
     this.cfgSvc      = services.RequireService <IConfigurationService>();
     this.unpackerSvc = new UnpackingService(services);
     this.unpackerSvc.LoadSignatureFiles();
     Services.RequireService <IServiceContainer>().AddService(typeof(IUnpackerService), unpackerSvc);
 }
예제 #2
0
        public void Upsvc_Match_Wildcard()
        {
            var image = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x12, 0x34, 0x56, 0x00 };
            var sig = new ImageSignature
            {
                EntryPointPattern = "??34"
            };
            var upsvc = new UnpackingService(sc);

            Assert.IsTrue(upsvc.Matches(sig, image, 4));
        }
예제 #3
0
        public void Upsvc_Find_Match()
        {
            var image = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x12, 0x34, 0x00, 0x00 };
          
            var le = mr.Stub<LoaderElement>();
            le.Label = "LoaderKey";
            le.TypeName = typeof(TestImageLoader).AssemblyQualifiedName;
            cfgSvc.Stub(c => c.GetImageLoaders()).Return(new List<LoaderElement> { le });
            sc.AddService(typeof(IConfigurationService), cfgSvc);
            mr.ReplayAll();

            var upSvc = new UnpackingService(sc);
            upSvc.Signatures.Add(new ImageSignature
            {
                Name = "LoaderKey",
                EntryPointPattern = "1234",
            });
            var loader = upSvc.FindUnpackerBySignature("foo.exe", image, 4);
            Assert.IsInstanceOf<TestImageLoader>(loader);
        }
예제 #4
0
        public void Upsvc_LoadSuffixArray_CreateSuffixArrayIfpresent()
        {
            Given_NoFile("foo.exe.sufa-raw.ubj"); // , new byte[] { 0x5B, 0x24, 0x6C, 0x23, 0x69, 0x00 });
            var stm = new MemoryStream();
            fsSvc.Expect(f => f.CreateFileStream("foo.exe.sufa-raw.ubj", FileMode.Create, FileAccess.Write))
                .Return(stm);
            mr.ReplayAll();

            var upsvc = new UnpackingService(sc);
            upsvc.FindUnpackerBySignature("foo.exe", new byte[0x4], 0);
            Assert.AreEqual(new byte[] {
                0x5B, 0x24, 0x6C, 0x23, 0x69, 0x04,
                      0x00, 0x00, 0x00, 0x003,
                      0x00, 0x00, 0x00, 0x002,
                      0x00, 0x00, 0x00, 0x001,
                      0x00, 0x00, 0x00, 0x000,
                },
                stm.ToArray());
        }
예제 #5
0
        public void Upsvc_LoadSuffixArray_LoadSuffixArrayIfpresent()
        {
            Given_File("foo.exe.sufa-raw.ubj", new byte[] { 0x5B, 0x24, 0x6C, 0x23, 0x69, 0x00 });
            mr.ReplayAll();

            var upsvc = new UnpackingService(sc);
            upsvc.FindUnpackerBySignature("foo.exe", new byte[0x1000], 0x0100);
        }