Tag: extract

C#, Mono.Cecil, Programming

Extract all strings using Mono.Cecil in C#

First check this post on how to build and use Mono.Cecil library. private List<String> ReadAssemblyStrings(String executable) { try { if (!File.Exists(executable)) return null;   AssemblyDefinition AssemblyDef = AssemblyDefinition.ReadAssembly(executable); List<String> sstrs = new List<String>();   foreach (ModuleDefinition md in AssemblyDef.Modules) { foreach (TypeDefinition td in md.GetTypes()) { foreach (MethodDefinition mdf in td.Methods) { if (mdf.HasBody) { …

C#

Extract executable assembly/version information

Methods we are going to use: GetFileVersionInfo Retrieves version information for the specified file. GetFileVersionInfoSize Determines whether the operating system can retrieve version information for a specified file. If version information is available, GetFileVersionInfoSize returns the size, in bytes, of that information. VerQueryValue Retrieves specified version information from the specified version-information resource. To retrieve the …

Linux

Extract all printable characters from binary files

Strings is a very useful command that can extract all printable characters from binary files. Example: strings /usr/sbin/visudo | morestrings /usr/sbin/visudo | more /lib64/ld-linux-x86-64.so.2 __gmon_start__ libc.so.6 __printf_chk setgrent fnmatch readdir execv _IO_putc setlocale fopen strsignal strncmp optind strrchr __progname dcgettext getpwuid closedir getgrgid getdomainname fork futimes –More–/lib64/ld-linux-x86-64.so.2 __gmon_start__ libc.so.6 __printf_chk setgrent fnmatch readdir execv _IO_putc …

PHP

Extract substring from a UTF-8 string in PHP

When you are working with UTF-8 encoded strings you may lose characters or get question marks when you are trying to extract a substring from them, using substr() function. As you already know this happens because UTF-8 characters have length between 1 and 4 bytes.  To deal with this problem we are going to use …