Skip to content

Instantly share code, notes, and snippets.

File Magic Numbers

Magic numbers are the first bits of a file which uniquely identify the type of file. This makes programming easier because complicated file structures need not be searched in order to identify the file type.

For example, a jpeg file starts with ffd8 ffe0 0010 4a46 4946 0001 0101 0047 ......JFIF.....G ffd8 shows that it's a JPEG file, and ffe0 identify a JFIF type structure. There is an ascii encoding of "JFIF" which comes after a length code, but that is not necessary in order to identify the file. The first 4 bytes do that uniquely.

This gives an ongoing list of file-type magic numbers.

Image Files

@craig-m-unsw
craig-m-unsw / memory_layout.md
Created June 17, 2024 12:05 — forked from CMCDragonkai/memory_layout.md
Linux: Understanding the Memory Layout of Linux Executables

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
@craig-m-unsw
craig-m-unsw / Email Server (Linux, Unix, Mac).md
Created June 5, 2024 04:06 — forked from raelgc/Email Server (Linux, Unix, Mac).md
Setup a Local Only SMTP Email Server (Linux, Unix, Mac)

Setup a Local Only SMTP Email Server (Linux, Unix, Mac)

1 - Point localhost.com to your machine

Most of programs will not accept an email using just @localhost as domain. So, edit /etc/hosts file to make the domain localhost.com point to your machine, including this content to the file:

127.0.0.1 localhost.com

2 - Install Postfix

@craig-m-unsw
craig-m-unsw / README.md
Created June 5, 2024 03:55 — forked from mosquito/README.md
Add doker-compose as a systemd unit

Docker compose as a systemd unit

Create file /etc/systemd/system/[email protected]. SystemD calling binaries using an absolute path. In my case is prefixed by /usr/local/bin, you should use paths specific for your environment.

[Unit]
Description=%i service with docker compose
PartOf=docker.service
After=docker.service
@craig-m-unsw
craig-m-unsw / systemd_service_hardening.md
Created June 5, 2024 03:54 — forked from ageis/systemd_service_hardening.md
Options for hardening systemd service units

security and hardening options for systemd service units

A common and reliable pattern in service unit files is thus:

NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
DevicePolicy=closed
ProtectSystem=strict
@craig-m-unsw
craig-m-unsw / README.md
Created May 31, 2024 08:06 — forked from avoidik/README.md
Plain simple alternative to Docker Desktop

Multipass

It works both with VirtualBox and Hyper-V on Windows, it also support MacOS including M1

Install

Configure virtualization driver

If you want VirtualBox (works on Linux, Windows, and MacOS)

@craig-m-unsw
craig-m-unsw / README.md
Created May 16, 2024 06:50 — forked from gdamjan/README.md
Replace grub2 with systemd-boot on Ubuntu 22.04
  1. remove grub
apt purge --allow-remove-essential grub2-common grub-pc-bin grub-pc grub-gfxpayload-lists grub-efi-amd64-bin grub-efi-amd64-signed grub-common os-prober shim-signed libfreetype6 
apt-get autoremove --purge
rm -rf /boot/grub/
rm -rf /boot/efi/EFI/ubuntu
  1. make sure it's not installed back
    • edit /etc/apt/apt.conf.d/01autoremove
  • add "grub*"; at the end of the Never-MarkAuto-Sections section

Signing VirtualBox Kernel Modules

These are the steps I followed enable VirtualBox on my laptop without disabling UEFI Secure Boot. They're nearly identical to the process described on [Øyvind Stegard's blog][blog], save for a few key details. The images here are borrowed from the [Systemtap UEFI Secure Boot Wiki][systemtap].

  1. Install the VirtualBox package (this might be different for your platform).
    src='https://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo'

Install the virtualbox manually

sudo apt-get update  
sudo apt-get install virtualbox-6.1  

Sign the modules for secureboot

sudo -i  
mkdir /root/module-signing  
cd /root/module-signing  
@craig-m-unsw
craig-m-unsw / 1-orgs-archetype.md
Created December 7, 2023 05:03 — forked from whatupfoo/1-orgs-archetype.md
Orgs and Teams Best Practices

Organization archetypes

The intention of this document is to provide some guidance and suggestions to customers who are wondering how they should structure organizations and teams in their GitHub Enterprise environment. The idea isn't to give hard and fast rules on which approach is better than the other, but to give examples of when one approach might be preferable to another depending on the use case.

1. A single organization with direct organization membership for repository access (not teams)

          ________________
          |     Org      |
          |    ______    |
          |   |      |\  |

| | Repo | \ |