hexdump | Single file C library implementation of the BSD command

 by   wahern C Version: Current License: No License

kandi X-RAY | hexdump Summary

kandi X-RAY | hexdump Summary

hexdump is a C library. hexdump has no bugs, it has no vulnerabilities and it has low support. You can download it from GitHub.

hexdump.c is a single-file C library implementation of the arcane BSD command-line utility, hexdump(1). It allows specifying simple formatting programs for display and analysis of binary blobs. For example, the format specification. produces the more familiar output. hexdump.c can be built as a simple library, a Lua module, or a command-line utility; or just dropped into your project without fuss. In addition to a few bugs (see below), unlike the traditional utility hexdump.c allows specifying the byte order of the converted words. It also allows processing of odd sized words (e.g. 3 bytes), and in the future will allow processing of words larger than 4 bytes. I wrote hexdump.c because I kept rewriting fixed format ouput generators over-and-over, in both C and various scripting languages; for simple hexadecimal conversion of checksums, analysis of I/O buffers, etc. One bored day I asked myself, "why not solve this once and for all." hexdump(1) is what I use on the command-line, so I decided to copy its semantics. Instead of refactoring or otherwise copying the BSD implementation, I took the opportunity to flex some creative muscle and implement hexdump by translating the formatting specification to instructions for a simple virtual machine. I mean... why not, right?. hexdump.c is fairly conformant to the manual page description of hexdump(1). Known bugs include the lack of floating point support (i.e. no %E, %e, %f, %G, or %g conversions), the inability to handle %_A address conversions, and in a multiline format string no implicit looping of a trailing formatting unit to consume the remainder of a block. Because hexdump.c doesn't generate a parse tree of the formatting string, these latter two are more difficult to support and will have to wait until I have the patience to add the necessary black magic (i.e. splicing instructions into the generated code after analyzing more context). Note that the original BSD implementation contains a typo, printing the ASCII label "dcl" instead of "dc1" for the %_u conversion of octet 021 (0x11). This typo also manifests in the POSIX od(1) utility, which on BSD systems is implemented with hexdump. I've filed bug reports with FreeBSD, OpenBSD, NetBSD, Debian, and Dragonfly BSD. Apple appears to have quietly fixed their copy of BSD hexdump in OS X. (UPDATE: OpenBSD, NetBSD, FreeBSD, and Debian have fixed this in their respective trunks.). I'm unaware of any other independent implementations of hexdump. Some Linux distributions repackage BSD hexdump, although not od, which comes from GNU core-utils. RedHat's "hexdump" from util-linux appears to be a simple wrapper to GNU core-utils od, which cannot handle arbitrary formats, yet which is ironically much larger than BSD hexdump(1) or hexdump.c, which belies POSIX's stated reason for excluding hexdump. Solaris doesn't provide anything named hexdump; just od.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              hexdump has a low active ecosystem.
              It has 63 star(s) with 25 fork(s). There are 8 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 2 open issues and 1 have been closed. On average issues are closed in 1508 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of hexdump is current.

            kandi-Quality Quality

              hexdump has no bugs reported.

            kandi-Security Security

              hexdump has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              hexdump does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              hexdump releases are not available. You will need to build from source code and install.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of hexdump
            Get all kandi verified functions for this library.

            hexdump Key Features

            No Key Features are available at this moment for hexdump.

            hexdump Examples and Code Snippets

            No Code Snippets are available at this moment for hexdump.

            Community Discussions

            QUESTION

            Segmentation fault when decrypting with openssl in C
            Asked 2021-Jun-06 at 05:48

            I'm trying to decrypt a message encrypted with AES 192 ECB and getting a segmentation fault and don't know where to look anymore. I know ECB is unsafe, but it is not for a production application.

            • I already checked my readFile method, it works (I wrote the ciphre back into a file and checked with the diff tool)
            • The key is 24 Bytes long (checked with ls and hexdump)
            • ECB has no IV-Vector as far as I know, so I have set it to NULL
            • for the decryption part I used the example at https://wiki.openssl.org/index.php/EVP_Symmetric_Encryption_and_Decryption to get started
            • I think the problem is at EVP_DecryptUpdate
            • I tried to track it down further with gdb but I have no experience with this and only got

            0x00007ffff798089d in ?? () from /usr/lib64/libcrypto.so.1.1

            Thank you for your time.

            ...

            ANSWER

            Answered 2021-Jun-06 at 05:48

            This is prefaced by the top comments.

            your answer fixed it. The error on EVP_DecryptFinal_ex comes because of a wrong key Feel free to post your comment as an answer! – Akreter

            plaintext is uninitialized in main.

            I tried:

            Source https://stackoverflow.com/questions/67854666

            QUESTION

            adding text to file, results in invalid utf-8 encoding, and fail compilation on macos
            Asked 2021-Jun-01 at 07:09

            I'm using macOS Big Sur 11.4, i attempt to edit a .c file and add some logic to it, then compile it with a setup.py file which looks like that:

            ...

            ANSWER

            Answered 2021-Jun-01 at 07:09

            Ok, so I didnt completely resolved it, but I found a work around, also i've forgot to mention something important here I was actually compiling from a VM, through a VM shared folder (VMware Fusion) while coding on my host computer.

            anyways, instead of using the share, i copied the file using scp and then i had no encoding problems... not completely resolved issue, but for now I can live with that.

            Source https://stackoverflow.com/questions/67773318

            QUESTION

            Redirecting dbaccess output loses a character
            Asked 2021-May-28 at 18:43

            I have a very weird problem when using a dump from informix database via the dbaccess executable.

            Here is how the problem behaves:

            ...

            ANSWER

            Answered 2021-May-28 at 18:43

            The solution in my case was to use grep like this (I will explain the || true reason right away.

            Source https://stackoverflow.com/questions/67728071

            QUESTION

            Display and format aligned binary data using bash
            Asked 2021-May-26 at 11:41

            I have a binary file that stores a collection of C structs, e.g.

            ...

            ANSWER

            Answered 2021-May-26 at 11:41

            Tell od to print 7 bytes per line, each individually, and get rid of spaces using tr.

            Source https://stackoverflow.com/questions/67702947

            QUESTION

            Which format does /dev/urandom output?
            Asked 2021-May-24 at 01:22

            Hi can somebody tell me which format /dev/urandom outputs and How i can replicate the output manually?.

            I am trying to remove the idea of randomness from the script i am writing/using and instead place an incrementing value in order like 1,2,3,4,5 etc...

            Yet /dev/urandom does not output integers, i do not know which format the output is. It looks like some kind of Hex/Binary

            I think this is one way of using /dev/urandom

            ...

            ANSWER

            Answered 2021-May-24 at 00:50

            There is no format. It's random bytes. Every byte is random.

            Source https://stackoverflow.com/questions/67665536

            QUESTION

            Compare same string in two different encodings fails
            Asked 2021-Apr-26 at 10:45

            I am trying to filter a large json file based on a list of strings which I get from a tsv file by calling

            ...

            ANSWER

            Answered 2021-Apr-26 at 10:45

            Ok, your input appears to be "double over-encoded", that is, someone mistakenly encoded UTF-8 data into UTF-8... twice ;(

            You can clean this up in python:

            Source https://stackoverflow.com/questions/67264716

            QUESTION

            Why am I not receiving interrupts on Port Status Change Event with the Intel's xHC on QEMU?
            Asked 2021-Apr-26 at 06:13

            I'm coding a small OS kernel which is supposed to have a driver for the Intel's xHC (extensible host controller). I got to a point where I can actually generate Port Status Change Events by resetting the root hub ports. I'm using QEMU for virtualization.

            I ask QEMU to emulate a USB mouse and a USB keyboard which it seems to do because I actually get 2 Port Status Change Events when I reset all root hub ports. I get these events on the Event Ring of interrupter 0.

            The problem is I can't find out why I'm not getting interrupts generated on these events.

            I'm posting a complete reproducible example here. Bootloader.c is the UEFI app that I launch from the OVMF shell by typing fs0:bootloader.efi. Bootloader.c is compiled with the EDK2 toolset. I work on Linux Ubuntu 20. Sorry for the long code.

            The file main.cpp is a complete minimal reproducible example of my kernel. All the OS is compiled and launched with the 3 following scripts:

            compile

            ...

            ANSWER

            Answered 2021-Apr-26 at 06:13

            I finally got it working by inverting the MSI-X table structure found on osdev.org. I decided to completely reinitialize the xHC after leaving the UEFI environment as it could leave it in an unknown state. Here's the xHCI code for anyone wondering the same thing as me:

            Source https://stackoverflow.com/questions/67206312

            QUESTION

            How to convert hex to ASCII while preserving non-printable characters
            Asked 2021-Apr-25 at 21:39

            I've been experiencing some weird issues today while debugging, and I've managed to trace this to something I overlooked at first.

            Take a look at the outputs of these two commands:

            ...

            ANSWER

            Answered 2021-Apr-25 at 21:39

            xxd expects two characters per byte. One A is invalid. Do:

            Source https://stackoverflow.com/questions/67258444

            QUESTION

            Compact shellcode to print a 0-terminated string pointed-to by a register, given puts or printf at known absolute addresses?
            Asked 2021-Apr-24 at 08:04

            Background: I am a beginner trying to understand how to golf assembly, in particular to solve an online challenge.

            EDIT: clarification: I want to print the value at the memory address of RDX. So “SUPER SECRET!”

            Create some shellcode that can output the value of register RDX in <= 11 bytes. Null bytes are not allowed.

            The program is compiled with the c standard library, so I have access to the puts / printf statement. It’s running on x86 amd64.

            ...

            ANSWER

            Answered 2021-Apr-24 at 08:04

            Since I already spilled the beans and "spoiled" the answer to the online challenge in comments, I might as well write it up. 2 key tricks:

            • Create 0x7ffff7e3c5a0 (&puts) in a register with lea reg, [reg + disp32], using the known value of RDI which is within the +-2^31 range of a disp32. (Or use RBP as a starting point, but not RSP: that would need a SIB byte in the addressing mode).

              This is a generalization of the code-golf trick of lea edi, [rax+1] trick to create small constants from other small constants (especially 0) in 3 bytes, with code that runs less slowly than push imm8 / pop reg.

              The disp32 is large enough to not have any zero bytes; you have a couple registers to choose from in case one had been too close.

            • Copy a 64-bit register in 2 bytes with push reg / pop reg, instead of 3-byte mov rdi, rdx (REX + opcode + modrm). No savings if either push needs a REX prefix (for R8..R15), and actually costs bytes if both are "non-legacy" registers.

            See other answers on Tips for golfing in x86/x64 machine code on codegolf.SE for more.

            Source https://stackoverflow.com/questions/67239787

            QUESTION

            WordPress / PhpStorm script corruption
            Asked 2021-Apr-21 at 12:32

            When I access certain pages on the WP admin panel, it does not load due to corrupt script files.

            I have downloaded WordPress and opened it as a project in PhpStorm (2021.1). I am using PHP 7.4.9 (installed via HomeBrew) and the built-in web server.

            I have confirmed that the original script files are not corrupt. When the page loads the scripts via load-scripts.php (load-scripts.php?c=1&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils&ver=5.7.1), which returns a bunch of concatenated scripts, the response contains additional bytes in the middle.

            ...

            ANSWER

            Answered 2021-Apr-21 at 12:32

            This appears to be a bug/issue with the built-in web server of PHPStorm: https://youtrack.jetbrains.com/issue/WEB-43701

            Source https://stackoverflow.com/questions/67155195

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install hexdump

            Command-line utility substantially like BSD hexdump(1). Lua 5.1, 5.2, and 5.3 modules, respectively. Builds hexdump, dynamically selects libhexdump.so or libhexdump.dylib, and builds Lua modules according to $(LUA_APIS), which can contain a space-separated list of Lua APIs (e.g. make LUA_APIS="5.1 5.2 5.3"). If empty then LUA_APIS is dynamically set by searching for available Lua headers.

            Support

            No floating point support. In particular, no %E, %e, %f, %G, or %g conversions. No %_A[dox] conversions. %_a[dox] works fine, however. No implicit looping of trailing units to consume the remainder of a block. Instead of. Note the additional loop specification, "16", in the second format block. Unlike hexdump(1), runs of identical blocks are not skipped by default. There's no configuration option to change this, yet, either. No locale support for %_c and %_p, although I consider this a feature. For equivalent hexdump(1) output you need to do env LANG=C hexdump ....
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/wahern/hexdump.git

          • CLI

            gh repo clone wahern/hexdump

          • sshUrl

            git@github.com:wahern/hexdump.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link