• Stars
    star
    323
  • Rank 130,051 (Top 3 %)
  • Language
    Python
  • License
    BSD Zero Clause L...
  • Created about 2 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The xx file format. Turn your hex dumps into art, then into binary data.

xx

xx is a simple text based file format for creating binary files and data buffers.

Who Is This For?

The xx format was designed for those who need to describe, annotate, or simply write binary data in a text file, and turn it into binary data.

This can usually be done with either an assembler, or a tool that can parse hex dumps and transform them into a binary file. The main limitation of these tools is that you need to follow the semantics of either the assembler or the hex dump format in order to build your file the way you want. Alternatively you can script out something to create a buffer for you, but this also relies on following the data representation rules for that scripting language.

With xx, there is a lot more freedom for how you can to write your data. The aim is to be an extensible, reliable format for portable binary data descriptions.

Usage

Type hex bytes into a text file, then run:

$ python3 xx.py file.xx

This will create a file called file.sha256[6].bin.

You can use the -x flag to do a simple hex dump to verify the contents of your buffer.

There are several example files in this repo for you to play with if you need some inspiration.

You can use yxd to create an xx compatible hex dump to work with.

Data Representation

The primary format for data is ASCII hex bytes. These can be represented in a number of common hex formats.

$ cat formats.xx
0x41, 0x41, 0x41, 0x41 -- Hex list
$42, $42, $42, $42     -- 8 Bit
43434343               -- Long hex string
44 44 4444             -- Spaced out bytes (any size) 
\x45\x45\x45\x45       -- C-style
46h 46h 46h 46h        -- asm style
47:47:47:47            -- MAC Address style
"This is a string"     -- Plain old string, must use double quotes!
0y01010101             -- Binary numbers, put "0y" at the start, followed by 8 bits, then a space or new line after.

Output:

$ python3 xx.py formats.xx -x
00000000: 41 41 41 41 42 42 42 42 43 43 43 43 44 44 44 44  AAAABBBBCCCCDDDD
00000010: 45 45 45 45 46 46 46 46 47 47 47 47 54 68 69 73  EEEEFFFFGGGGThis
00000020: 20 69 73 20 61 20 73 74 72 69 6E 67               is a string

Comments

Comments are a major component of .xx files. You can use a number of standard comment delimiters to take notes about bytes.

Current list of comments:

-- Lua Style
/* C multi-
line Style */
// C++ Style
# Python Style
; Nasm Style
% MATLAB, PDF 
| Pipes
┌─┬┐╔═╦╗╓╥  Any box drawing 
╖╒╤╕│║├┼┤╠  character can also
╬╣╟╫╢╞╪╡└┴  be used as a comment.
┘╚╩╝╙╨╜╘╧╛  Perfect for diagrams!
▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏ Any block element 
▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟ can also be used

Roadmap

Version 0.2 of xx is the simple version that I've personally been using and testing, but I wanted more people to play with it before adding all the bells and whistles.

  • Other number formats, WinDbg style: 0n11 = decimal 11, 0y11 = decimal 3.
  • ANSI formatting for data
  • Command and Macro interface
  • An official file format specification

Eventually I will combine this with the yxd project: https://github.com/netspooky/yxd

If you have any suggestions or ideas, feel free to submit an issue or a PR, or message me on twitter: @netspooky

Updates

  • Version 0.3 adds ANSI formatting and multiline comments.
  • Version 0.4 adds all the unicode Box Drawing Character and Block Elements as comments and an updated codebase that is easier to work with.
  • Version 0.4.1 fixes some issues with characters inside of ASCII strings
  • Version 0.5 adds binary numbers.

More Repositories

1

scare

A multi-arch assembly REPL and emulator for your command line.
Python
261
star
2

protocols

Python
223
star
3

inhale

A malware analysis and classification tool.
Python
192
star
4

gtfoplus

Linux Local Privesc Helper and Agent
Python
166
star
5

golfclub

Binary Golf Examples and Resources
Assembly
159
star
6

pdiff

Binary Protocol Differ
Python
99
star
7

BGGP

Binary Golf Grand Prix
Assembly
96
star
8

yxd

yxd - Yuu's heX Dumper
Python
77
star
9

reversi

Generate very tiny reverse shell binaries for Linux~
Assembly
70
star
10

jLoot

JIRA Secure Attachment Looter
Python
70
star
11

dissectors

random dissectors
Lua
62
star
12

kimagure

Assembly
40
star
13

hardcode

64KB and smaller demoscene intros. Sorted by size. hardcode.untergrund.net
C
35
star
14

i2ao

Intro to Assembly Optimization stream repo
Assembly
25
star
15

notes

Shell
25
star
16

uJunk

An unsorted collection of little tools and scripts I've made that don't fit anywhere else
Python
18
star
17

importsort

Group imports from Windows binaries
Python
15
star
18

b64mute

Base64 Mutator
Python
12
star
19

bgws

HTML
11
star
20

ai_dev

Python
8
star
21

pdiff2

Python
8
star
22

hexcalc

A simple hex calculator in the browser
HTML
8
star
23

enumgen

Enumeration Notes and Cheatsheet Generator
Python
7
star
24

pockettoolz

Python
6
star
25

Simple-Virtual-CPU

A very simple example of a virtual CPU written in C and an "assembler" in python 3.7.
C
5
star
26

ParrotSec_Alternate_Install

Fixes for Parrot Sec Install Scripts
Shell
3
star
27

3DSTests

Some WIP Scripts for the 3DS using ctrulib
Makefile
2
star
28

liltools

Shell
2
star
29

netspooky

2
star
30

NaoDev

Experimental Tools for the Naoqi robot
Makefile
1
star
31

dnb

one of the first projects i made with python
Python
1
star
32

majokko

Super small security focused linux project for embedded devices based on LFS and other embedded projects.
Shell
1
star