Pyhexdmp - Python hex dump module

Related tags

Miscellaneouspyhexdmp
Overview

pyhexdmp Python hex dump module

Copyright 2021

Author: Paul Melson

Author notes:

  • Accept single variable as input, plus optional config arguments

  • Detect data type of input

  • Supported data types: str, bytes, bytearray

  • Unsupported data types: complex, bool, int, float

  • Undecided (currently unsupported): list, dict, range, tuple, memoryview

  • Convert input to bytearray()

  • Print hex output format, supported optional arguments:

    • offsets: on/off, default=on, print the distance of the first byte of each line in hex notation on the left

      hexdmp(test_data, offsets='off')
    • showascii: on/off, default=on, print the ASCII characters of each byte on the right (print periods for hi/lo bytes)

      hexdmp(test_data, showascii='off')
    • start: int, manually set offsets start value

      hexdmp(test_data, start=2)
    • width: positive int, default=16, let the user set the number of bytes per line to print

      hexdmp(test_data, width=8)

Usage:

>>> from pyhexdmp import hexdmp
>>> with open('/home/paul/sample.exe', 'rb') as f:
...     raw = f.read()
... 
>>> test_data = raw[:128]
>>> hexdmp(test_data)
00000000: 4d 5a 90 00 03 00 00 00 04 00 00 00 ff ff 00 00  MZ..............
00000010: b8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00  ........@.......
00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000030: 00 00 00 00 00 00 00 00 00 00 00 00 f8 00 00 00  ................
00000040: 0e 1f ba 0e 00 b4 09 cd 21 b8 01 4c cd 21 54 68  ........!..L.!Th
00000050: 69 73 20 70 72 6f 67 72 61 6d 20 63 61 6e 6e 6f  is program canno
00000060: 74 20 62 65 20 72 75 6e 20 69 6e 20 44 4f 53 20  t be run in DOS 
00000070: 6d 6f 64 65 2e 0d 0d 0a 24 00 00 00 00 00 00 00  mode....$.......
>>> hexdmp(test_data, offsets='off')
4d 5a 90 00 03 00 00 00 04 00 00 00 ff ff 00 00  MZ..............
b8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00  ........@.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00 00 00 00 00 00 00 00 00 00 00 00 f8 00 00 00  ................
0e 1f ba 0e 00 b4 09 cd 21 b8 01 4c cd 21 54 68  ........!..L.!Th
69 73 20 70 72 6f 67 72 61 6d 20 63 61 6e 6e 6f  is program canno
74 20 62 65 20 72 75 6e 20 69 6e 20 44 4f 53 20  t be run in DOS 
6d 6f 64 65 2e 0d 0d 0a 24 00 00 00 00 00 00 00  mode....$.......
>>> hexdmp(test_data, showascii='off')
00000000: 4d 5a 90 00 03 00 00 00 04 00 00 00 ff ff 00 00
00000010: b8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00
00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000030: 00 00 00 00 00 00 00 00 00 00 00 00 f8 00 00 00
00000040: 0e 1f ba 0e 00 b4 09 cd 21 b8 01 4c cd 21 54 68
00000050: 69 73 20 70 72 6f 67 72 61 6d 20 63 61 6e 6e 6f
00000060: 74 20 62 65 20 72 75 6e 20 69 6e 20 44 4f 53 20
00000070: 6d 6f 64 65 2e 0d 0d 0a 24 00 00 00 00 00 00 00
>>> hexdmp(test_data, start=2)
00000002: 90 00 03 00 00 00 04 00 00 00 ff ff 00 00 b8 00  ................
00000012: 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00 00  ......@.........
00000022: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000032: 00 00 00 00 00 00 00 00 00 00 f8 00 00 00 0e 1f  ................
00000042: ba 0e 00 b4 09 cd 21 b8 01 4c cd 21 54 68 69 73  ......!..L.!This
00000052: 20 70 72 6f 67 72 61 6d 20 63 61 6e 6e 6f 74 20   program cannot 
00000062: 62 65 20 72 75 6e 20 69 6e 20 44 4f 53 20 6d 6f  be run in DOS mo
00000072: 64 65 2e 0d 0d 0a 24 00 00 00 00 00 00 00        de....$.......
>>> hexdmp(test_data, width=8)
00000000: 4d 5a 90 00 03 00 00 00  MZ......
00000008: 04 00 00 00 ff ff 00 00  ........
00000010: b8 00 00 00 00 00 00 00  ........
00000018: 40 00 00 00 00 00 00 00  @.......
00000020: 00 00 00 00 00 00 00 00  ........
00000028: 00 00 00 00 00 00 00 00  ........
00000030: 00 00 00 00 00 00 00 00  ........
00000038: 00 00 00 00 f8 00 00 00  ........
00000040: 0e 1f ba 0e 00 b4 09 cd  ........
00000048: 21 b8 01 4c cd 21 54 68  !..L.!Th
00000050: 69 73 20 70 72 6f 67 72  is progr
00000058: 61 6d 20 63 61 6e 6e 6f  am canno
00000060: 74 20 62 65 20 72 75 6e  t be run
00000068: 20 69 6e 20 44 4f 53 20   in DOS 
00000070: 6d 6f 64 65 2e 0d 0d 0a  mode....
00000078: 24 00 00 00 00 00 00 00  $.......
>>> hexdmp(test_data, offsets='off', showascii='off', start=16, width=32)
b8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 f8 00 00 00 0e 1f ba 0e 00 b4 09 cd 21 b8 01 4c cd 21 54 68
69 73 20 70 72 6f 67 72 61 6d 20 63 61 6e 6e 6f 74 20 62 65 20 72 75 6e 20 69 6e 20 44 4f 53 20
6d 6f 64 65 2e 0d 0d 0a 24 00 00 00 00 00 00 00p
>>> from pyhexdmp import strhexdmp
>>> test_hexdump_string = strhexdmp(test_data)
>>> print(test_hexdump_string)
00000000: 4d 5a 90 00 03 00 00 00 04 00 00 00 ff ff 00 00  MZ..............
00000010: b8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00  ........@.......
00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000030: 00 00 00 00 00 00 00 00 00 00 00 00 f8 00 00 00  ................
00000040: 0e 1f ba 0e 00 b4 09 cd 21 b8 01 4c cd 21 54 68  ........!..L.!Th
00000050: 69 73 20 70 72 6f 67 72 61 6d 20 63 61 6e 6e 6f  is program canno
00000060: 74 20 62 65 20 72 75 6e 20 69 6e 20 44 4f 53 20  t be run in DOS 
00000070: 6d 6f 64 65 2e 0d 0d 0a 24 00 00 00 00 00 00 00  mode....$.......

>>> 
A Python module for decorators, wrappers and monkey patching.

wrapt The aim of the wrapt module is to provide a transparent object proxy for Python, which can be used as the basis for the construction of function

Graham Dumpleton 1.8k Jan 06, 2023
Simply create JIRA releases based on your github releases

Simply create JIRA releases based on your github releases

8 Jun 17, 2022
The fundamentals of Python!

The fundamentals of Python Author: Mohamed NIANG, Staff ML Scientist Presentation This repository contains notebooks on the fundamentals of Python. Th

Mohamed NIANG 1 Mar 15, 2022
This is the key combo trainer for League of Legends and Dota 2 players.

This is the key combo trainer for League of Legends and Dota 2 players. Place the mouse cursor on the blue point and press the key combo from the upper-left side of the screen.

Ilya Shpigor 1 Jan 31, 2022
Projeto-menu - This project is designed to learn more about control mechanisms in Python programming

Projeto-menu - This project is designed to learn more about control mechanisms in Python programming

Henrik Ricarte 2 Mar 01, 2022
Chemical equation balancer

Chemical equation balancer Balance your chemical equations with ease! Installation $ git clone

Marijan Smetko 4 Nov 26, 2022
A functional standard library for Python.

Toolz A set of utility functions for iterators, functions, and dictionaries. See the PyToolz documentation at https://toolz.readthedocs.io LICENSE New

4.1k Jan 04, 2023
Write Streamlit apps using Notion! (Prototype)

Streamlit + Notion test app Write Streamlit apps using Notion! ☠️ IMPORTANT: This is just a little prototype I made to play with some ideas. Not meant

Thiago Teixeira 22 Sep 08, 2022
Automator anble you to create automations on your system

WELCOME TO AUTOMATOR BETA This programm is able to create automations on your system. This programm is only an experimantal release; infact it works v

Davide 1 Jan 12, 2022
This repository contains Python Projects for Beginners as well as for Intermediate Developers built by Contributors.

Python Projects {Open Source} Introduction The repository was built with a tree-like structure in mind, it contains collections of Python Projects. Mo

Gaurav Pandey 115 Apr 30, 2022
Multi-Probe Attention for Semantic Indexing

Multi-Probe Attention for Semantic Indexing About This project is developed for the topic of COVID-19 semantic indexing. Directories & files A. The di

Jinghang Gu 1 Dec 18, 2022
This program goes thru reddit, finds the most mentioned tickers and uses Vader SentimentIntensityAnalyzer to calculate the ticker compound value.

This program goes thru reddit, finds the most mentioned tickers and uses Vader SentimentIntensityAnalyzer to calculate the ticker compound value.

195 Dec 13, 2022
to learn how to do pull request and do contribution to other's repo

Hacktoberfest-2021 - open-source-contribution An Open Source repository to Teach people How to contribute to open sources. 💥 🔥 JOIN PVX PROGRAMMING

Shubham Rawat 82 Dec 26, 2022
A fast Python in-process signal/event dispatching system.

Blinker Blinker provides a fast dispatching system that allows any number of interested parties to subscribe to events, or "signals". Signal receivers

jason kirtland 1.4k Dec 31, 2022
Minecraft Multi-Server Pinger Discord Embed

Minecraft Network Pinger Minecraft Multi-Server Pinger Discord Embed What does this bot do? It sends an embed and uses mcsrvstat API and checks if the

YungHub 2 Jan 05, 2022
CPython extension implementing Shared Transactional Memory with native-looking interface

CPython extension implementing Shared Transactional Memory with native-looking interface

21 Jul 22, 2022
HomeAssistant Linux Companion

Application to run on linux desktop computer to provide sensors data to homeasssistant, and get notifications as if it was a mobile device.

Javier Lopez 10 Dec 27, 2022
My qtile config with a fresh-looking bar and pywal support

QtileConfig My qtile config with a fresh-looking bar and pywal support. Note: This is my first rice and first github repo. Please excuse my poor codin

Eden 4 Nov 10, 2021
A docker container (Docker Desktop) for a simple python Web app few unit tested

Short web app using Flask, tested with unittest on making massive requests, responses of the website, containerized

Omar 1 Dec 13, 2021
This repo is related to Google Coding Challenge, given to Bright Network Internship Experience 2021.

BrightNetworkUK-GCC-2021 This repo is related to Google Coding Challenge, given to Bright Network Internship Experience 2021. Language used here is py

Dareer Ahmad Mufti 28 May 23, 2022