ShellSpells
  • 🧙‍♂️Welcome!
    • ShellSpells
    • FAQs
    • License & Disclaimer
  • 🐧Linux
    • System Ops
      • Transcripts
      • Help
      • System Info
        • Date/Time
        • System Details
        • Patches & Updates
        • Init System Identification
        • Hostname / Host ID
        • Variables
        • Hardware & Resources
      • Filesystem
        • Traverse & Enumerate
        • Drives & Partitions
        • Shares
        • Packages
        • Connected Devices
        • Kernel Modules (Drivers)
      • Users & Groups
        • Enumerate
        • Modify
      • Network
        • Enumerate
        • Modify
      • Scheduled Jobs
        • Enumerate
        • Modify
      • Processes
        • Enumerate
        • Modify
        • Custom Script and Shared Object
        • Process I/O Redirection
      • Services
        • Enumerate
        • Modify
        • Create a Service
      • Startup/Boot Scripts
        • Enumerate
        • Modify
      • Security
        • Antivirus
        • Firewall
        • SSH Keys
      • History & Logs
        • History
        • Logs
    • File Ops
      • Search
        • Filename
        • Content
        • Users (Owners)
        • Time
        • Size
        • Permission
        • Hidden Files
        • Inode
        • Find + Exec
        • Notes
      • Enumerate Metadata
      • Modify Metadata
      • Read Content
      • Modify Content
      • Extract Content
      • Sort / Compare / Count
      • Move
      • Copy
      • Execute
      • Hash
      • Encode/Decode
      • Compress/Decompress
      • Working With Weird Filenames
    • Terminal Ops
      • Keyboard Shortcuts
      • Tmux Shortcuts
  • 🪟Windows
    • System Ops
      • Transcripts
      • Help
      • System Info
        • One-liners
        • Date/Time
        • System Details
        • Hotfixes
        • Domain or Workgroup
        • Data Execution Prevention
        • Variables
        • Hardware & Resources
      • Filesystem
        • Traverse & Enumerate
        • Drives & Partitions
        • Installed Software
        • Drivers
        • Shares
      • Registry
        • Enumerate
        • Modify
        • Forensically Relevant Keys
      • Users & Groups
        • Enumerate
        • Modify
      • Network
        • Enumerate
        • Modify
      • Scheduled Tasks
      • Processes
        • Enumerate
        • Modify
      • Services
        • Enumerate
        • Modify
      • Autorun / Startup
        • Enumerate
        • Modify
      • Security
        • Permissions
          • Enumerate
          • Page
        • Antivirus
        • Firewall
          • Enumerate
          • Modify
        • Audit Policies
        • Remoting
          • Enumerate
          • Modify
          • Registry Locations
        • Stored Credentials
      • Remote Command Execution
      • Active Directory
        • Enumerate
        • Modify
      • History & Logs
        • History
        • Logs
      • PowerShell Config
      • Scripting
      • WMIC Notes
    • File Ops
      • Search
        • Filename
        • Time
        • Size
        • Permissions
        • Attributes
        • Wildcarding
      • Enumerate Metadata
        • One Liners
        • Users (Owners)
        • Timestamps
        • Size
        • Permissions
        • Attributes
      • Modify Metadata
        • Change Owner
        • Timestamps
        • Size
        • Attributes
      • Read Content
      • Modify Content
        • Overwrite
        • Insert
        • Append
        • Replace / Remove
        • Convert Case
        • Alternate Data Streams
      • Extract Content
      • Sort / Compare / Count
        • Sort
        • Count
        • Compare
      • Move
      • Copy
      • Execute
      • Hash
      • Encode/Decode
      • Compress/Decompress
      • Working With Weird Filenames
      • Output Formatting / Filtering
      • File Formatting
      • Operators
  • ⛓️Network
    • Traffic Manipulation
      • iptables
        • Option List
        • General Commands
        • Filter Tables
        • NAT
        • Mangle
        • Filter for SSH Traffic (Example)
      • nftables
    • Packet Capture
      • Syntax
      • TCPDump Examples
    • Packet Analysis
      • Wireshark
  • 🚗Maneuver
    • SSH
    • Control Sockets
    • RDP
    • Windows Port Proxy
  • 🛩️Data Transfer
    • SCP
    • FTP
    • Netcat
      • Netcat Relays
    • Server Interactions
    • Alternate Methods
  • 🪄REGEX
    • Examples
Powered by GitBook
On this page
  • Encode
  • Base64
  • URL
  • Hex
  • Character Set Conversion
  • MIME Encoding
  • Reverse
  • Decode
  • Base64
  • URL
  • Hex
  • Character Set Conversion
  • MIME Encoding
  • Reverse

Was this helpful?

  1. Linux
  2. File Ops

Encode/Decode

Encode

Base64

Encode in base64.

base64 [file]

Encode in base64 without wrapping lines.

The -w option specifies line wrap, and 0 disables it (GNU base64):

base64 -w 0 [file]

URL

Use Perl's URI::Escape module to URL-encode "string":

perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "string"

Use curl to URL-encode "string".

Sends a dummy request to curl and extracts the encoded URL part:

echo -n "string" | curl -Gso /dev/null -w %{url_effective} --data-urlencode @- "" | cut -c 3-

Hex

Create a hex dump of a file in a plain hex format using xxd.

This format is easy to use in scripts for further processing:

xxd -p [file]

Use od (octal dump) to output the file content in hexadecimal.

The cut command is used to trim the output to show only the hex values:

od -t x1 [file] | cut -c8- 

Character Set Conversion

Convert the character encoding of a file. -f specifies the original encoding, and -t specifies the target encoding.

iconv -f from_encoding -t to_encoding [file]

MIME Encoding

These commands might not be available in all distributions and are part of the mailutils or similar packages

Encode a file using MIME base64 encoding. This command is part of some older or specific utilities for handling email data:

mimencode [file]

Another tool for MIME base64 encoding. Similar in function to mimencode, but availability varies by system:

mmencode [file]

Reverse

Reverse content

tac [file] > [newfile]

Decode

Base64

Decode a base64-encoded file. The -d option specifies decoding (use -D on macOS):

base64 -d [file]

URL

Use Perl's URI::Escape module to URL-decode "encoded_string":

perl -MURI::Escape -e 'print uri_unescape($ARGV[0]);' "encoded_string"

Hex

Reverse (decode) a plain hex dump back into binary.

Use -r with xxd to revert a hex dump back to its original binary form:

xxd -p -r [file]

Character Set Conversion

Convert the character encoding of a file back to the desired encoding.

The process is the same as encoding, just reverse the -f (from) and -t (to) encodings as needed:

iconv -f from_encoding -t to_encoding [file]

MIME Encoding

If you used mimencode or mmencode for MIME base64 encoding, you might need to find an alternative for decoding since direct counterparts for decoding might not be explicitly named or available.

For MIME base64 decoding, you can use base64 -d or consider Perl solutions:

Decode a MIME base64-encoded file, assuming the content is base64 and does not include MIME headers:

base64 -d [file]

Reverse

Reverse content

tac [file] > <newfile>
PreviousHashNextCompress/Decompress

Last updated 1 year ago

Was this helpful?

🐧