예제 #1
0
        /// <summary>
        /// Extracts all the file resources to the specified base path.
        /// </summary>
        public static void ExtractAll()
        {
            var basePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            var executablePermissions = SysCall.StringToInteger("0777", IntPtr.Zero, 8);

            foreach (var resourceName in ResourceNames)
            {
                var filename   = resourceName.Substring($"{typeof(EmbeddedResources).Namespace}.".Length);
                var targetPath = Path.Combine(basePath, filename);
                if (File.Exists(targetPath))
                {
                    return;
                }

                using (var stream = typeof(EmbeddedResources).Assembly
                                    .GetManifestResourceStream(resourceName))
                {
                    using (var outputStream = File.OpenWrite(targetPath))
                    {
                        stream?.CopyTo(outputStream);
                    }

                    try
                    {
                        SysCall.Chmod(targetPath, (uint)executablePermissions);
                    }
                    catch
                    {
                        /* Ignore */
                    }
                }
            }
        }
예제 #2
0
 public void call(int id)
 {
     if (_systemCall.ContainsKey(id))
     {
         SysCall syscall = _systemCall[id];
         syscall();
     }
 }
예제 #3
0
        public static bool WriteToLsass(ref IntPtr hLsass, IntPtr addr, byte[] bytesToWrite)
        {
            IntPtr   bytesWrited = IntPtr.Zero;
            GCHandle pbytesToWritepinnedArray = GCHandle.Alloc(bytesToWrite, GCHandleType.Pinned);
            IntPtr   pbytesToWrite            = pbytesToWritepinnedArray.AddrOfPinnedObject();

            NTSTATUS status = SysCall.NtWriteVirtualMemory10(hLsass, addr, pbytesToWrite, (uint)bytesToWrite.Length, ref bytesWrited);

            return(status == NTSTATUS.Success);
        }
예제 #4
0
파일: Utility.cs 프로젝트: zhouzu/SharpKatz
        public static byte[] ReadFromLsass(ref IntPtr hLsass, IntPtr addr, ulong bytesToRead)
        {
            int bytesRead = 0;

            byte[] bytev = new byte[Convert.ToInt32(bytesToRead)];

            NTSTATUS status = SysCall.NtReadVirtualMemory10(hLsass, addr, bytev, Convert.ToInt32(bytesToRead), bytesRead);

            return(bytev);
        }
 public WallpaperDTO MapToDTO(Wallpaper wp, bool includeContent = false)
 {
     return(new WallpaperDTO()
     {
         Id = wp.Id,
         WallpaperFileName = wp.WallpaperFileName,
         WallpaperFileType = wp.WallpaperFileType,
         WallpaperContent = includeContent ? SysCall.LoadContent(wp.WallpaperFileName) : null
     });
 }
예제 #6
0
        public WallpaperDTO UploadWallpaper(WallpaperUploadDTO dto)
        {
            string filename = SysCall.SaveContent(dto.WallpaperFileName, dto.WallpaperContent);
            int    id       = dbservice.RegisterWallpaper(new Wallpaper()
            {
                WallpaperFileName = dto.WallpaperFileName,
                WallpaperFileType = Path.GetExtension(dto.WallpaperFileName).Substring(1)
            });

            return(mapper.MapToDTO(dbservice.GetWallpaper(id)));
        }
예제 #7
0
        /// <inheritdoc />
        public void Write(byte[] buffer)
        {
            lock (_syncLock)
            {
                var result = SysCall.Write(FileDescriptor, buffer, buffer.Length);

                if (result < 0)
                {
                    HardwareException.Throw(nameof(SpiChannel), nameof(Write));
                }
            }
        }
예제 #8
0
        public static byte[] ReadFromLsass(ref IntPtr hLsass, IntPtr addr, long bytesToRead)
        {
            if (bytesToRead < 0)
            {
                throw new ArgumentException($"{bytesToRead} is not a valid number of bytes to read");
            }

            if (bytesToRead == 0)
            {
                return(new byte[0]);
            }

            int bytesRead = 0;

            byte[] bytev = new byte[bytesToRead];

            NTSTATUS status = SysCall.NtReadVirtualMemory10(hLsass, addr, bytev, (int)bytesToRead, bytesRead);

            return(bytev);
        }
예제 #9
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            bool hide = bool.Parse(Configuration["HideOnStart"]);

            if (hide)
            {
                SysCall.Hide();
            }

            bool seed = bool.Parse(Configuration["SeedOnStart"]);

            if (seed)
            {
                DatabaseService databaseService = new DatabaseService(Configuration);
                databaseService.RegisterWallpaper(new Wallpaper()
                {
                    WallpaperFileName = "test.png", WallpaperFileType = "png"
                });
            }
        }
예제 #10
0
 private void addSysCall(int id, SysCall syscall)
 {
     _systemCall.Add(id, syscall);
 }