binaryfiles

Is it possible to extract constants and other predefined values from binary executables?

╄→尐↘猪︶ㄣ 提交于 2019-12-10 14:36:19
问题 Let's say we have this program here class Message{ public static SUPER_SECRET_STRING = "bar"; public static void Main(){ string SECRET = "foo"; Console.Write(sha(SUPER_SECRET_STRING) + "" + sha(SECRET)); } } Now, after building this program, is there any way using a hex editor or some other utility to extract the values "foo" and "bar" from the compiled binary file? Also let's assume that memory editors are not allowed. Is this applicable to all compiled languages like C++? What about ones

Rust library for inspecting .rlib binaries

与世无争的帅哥 提交于 2019-12-10 13:43:39
问题 I'm looking for a way to load and inspect .rlib binaries generated by rustc. I've hunted around the standard library without much luck. My assumption is that an .rlib contains all the type information necessary to statically type check programs that "extern crate" it. rustc::metadata is where my hunt ended. I can't quite figure out if the structures available at this point in the compiler are intended as entry points for users, or if they are solely intermediate abstractions depending on a

How to create binary file using Bash?

只谈情不闲聊 提交于 2019-12-10 12:35:13
问题 How can I create a binary file with consequent binary values in bash? like: $ hexdump testfile 0000000 0100 0302 0504 0706 0908 0b0a 0d0c 0f0e 0000010 1110 1312 1514 1716 1918 1b1a 1d1c 1f1e 0000020 2120 2322 2524 2726 2928 2b2a 2d2c 2f2e 0000030 .... In C, I do: fd = open("testfile", O_RDWR | O_CREAT); for (i=0; i< CONTENT_SIZE; i++) { testBufOut[i] = i; } num_bytes_written = write(fd, testBufOut, CONTENT_SIZE); close (fd); this is what I wanted: #! /bin/bash i=0 while [ $i -lt 256 ]; do h=$

Python: ctypes hashable c_char array replacement without tripping over '\0' bytes

与世无争的帅哥 提交于 2019-12-10 11:46:14
问题 For illustration purposes, this script creates a file mapfile containing the content of the files, given as arguments, prepended by a binary header with a sha1 checksum, that allows for duplication detection on subsequent runs. What's needed here is a hashable ctypes.c_char replacement, that can hold sha1 checksums with minimum fuzz, but not choking on '\0' bytes. # -*- coding: utf8 -* import io import mmap import ctypes import hashlib import logging from collections import OrderedDict log =

How to efficiently read binary data from files that has complex structure in C++

☆樱花仙子☆ 提交于 2019-12-10 10:38:21
问题 I am writing a piece of code to read in several GB of data that spans multiple files using C++ IOStreams, which I've chosen over the C API for a number of design reasons that I won't bore you with. Since the data is produced by a separate program on the same machine where my code will run, I am confident that issues such as those relating to endianess can, for the most part, be ignored. The files have a reasonably complicated structure. For example, there is a header that describes the number

simple reading of fortran binary data not so simple in python

て烟熏妆下的殇ゞ 提交于 2019-12-10 10:28:01
问题 I have a binary output file from a FORTRAN code. Want to read it in python. (Reading with FORTRAN and outputting text to read for python is not an option. Long story.) I can read the first record in a simplistic manner: >>> binfile=open('myfile','rb') >>> pad1=struct.unpack('i',binfile.read(4))[0] >>> ver=struct.unpack('d',binfile.read(8))[0] >>> pad2=struct.unpack('i',binfile.read(4))[0] >>> pad1,ver,pad2 (8,3.13,8) Just fine. But this is a big file and I need to do this more efficiently. So

File to Byte Array in WinJS

血红的双手。 提交于 2019-12-10 09:40:47
问题 I'm tinkering with some Windows Store development in JavaScript and I seem to be stuck on how to get a byte array from a binary file. I've found a couple of examples online, but they all seem to only read in text whereas my file is an image. I'm opening the file like this: Windows.Storage.FileIO.readBufferAsync(photos[currentIndex]).done(function (buffer) { var dataReader = Windows.Storage.Streams.DataReader.fromBuffer(buffer); var fileContent = dataReader.readString(buffer.length);

How to read a BLE Characteristic Float in Swift

∥☆過路亽.° 提交于 2019-12-10 09:03:42
问题 I am trying to connect to a Bluetooth LE / Bluetooth Smart / BLE health device's Health Thermometer Service (0x1809), as officially described here: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.health_thermometer.xml. Specifically, I'm requesting notifications from the Health Thermometer Characteristic (0x2A1C), with description here: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth

General question about Binary files

我的未来我决定 提交于 2019-12-10 03:21:09
问题 I am a beginner and I am having trouble in grasping binary files. When I write to a file in binary mode (in python), I just write normal text. There is nothing binary about it. I know every file on my computer is a binary file but I am having trouble distinguishing between files written in binary mode by me and files like audio, video etc files that show up as gibberish if I open them in a text editor. How are files that show up as gibberish created? Can you please give an example of a small

updating binary file containing structs in c, offsets changing to corrupt rest of file

无人久伴 提交于 2019-12-09 23:03:03
问题 I'm trying to write a method that will, given a file containing values to update or append, will update a second binary file. Apparently, when I overwrite a struct in the binary file, the offsets somehow change and that corrupts everything after it. Am I doing something wrong, and is there a way to prevent this without truncating and appending to the file? Current code: typedef struct{ int number; double price; } stock; void update(char* updatefile, char* binfile){ FILE *fin, *fout; stock