"Political freedom is a society's safety valve, allowing the passionately critical a nonviolent way to express their dissatisfaction with the status quo." --David Cole
Introduction
Base64 is the de facto standard encoding used for attachments by MIME (multipurpose Internet mail extensions). Almost all small clients use MIME to send files as attachments, which means that a majority of mail clients use Base64 to encode files before they are sent across networks.
Base64 is also used in several other ways. For one, Web servers implementing HTTP-based basic authentication use Base64 to encode the username and password of such servers.
However, Base64 is a very weak encoding standard and can be reverse-engineered in only minutes. This guide will walk you through how.
Encoding
NOTE: You will need a binary converter to use this guide effectively
Base64 encoding is quite simple. When it is used to encode plaintext (as it often is), the following steps occur:
- The ASCII value is converted to its binary equivalent (A becomes 01000001, y becomes 01111001, etc.)
- The 8 bits that make up a byte are split up into groups of 6 bits. For example:
CODE :
word
01110111011011110111001001100100
011101 110110 111101 110010 011001 00
- These 6-bit binary values are then converted to their decimal form (using the table below), and then finally converted to their new encoded value. The table is in the format of BIN, DEC, ENCODED.
CODE :
000000 0 A
000001 1 B
000010 2 C
000011 3 D
000100 4 E
000101 5 F
000110 6 G
000111 7 H
001000 8 I
001001 9 J
001010 10 K
001011 11 L
001100 12 M
001101 13 N
001110 14 O
001111 15 P
010000 16 Q
010001 17 R
010010 18 S
010011 19 T
010100 20 U
010101 21 V
010110 22 W
010111 23 X
011000 24 Y
011001 25 Z
011010 26 a
011011 27 b
011100 28 c
011101 29 d
011110 30 e
011111 31 f
100000 32 g
100001 33 h
100010 34 i
100011 35 j
100100 36 k
100101 37 l
100110 38 m
100111 39 n
101000 40 o
101001 41 p
101010 42 q
101011 43 r
101100 44 s
101101 45 t
101110 46 u
101111 47 v
110000 48 w
110001 49 x
110010 50 y
110011 51 z
110100 52 0
110101 53 1
110110 54 2
110111 55 3
111000 56 4
111001 57 5
111010 58 6
111011 59 7
111100 60 8
111101 61 9
111110 62 +
111111 63 /
So, using the above table, we can take our previous example and finish it up.
CODE :
word
01110111011011110111001001100100
011101 110110 111101 110010 011001 00
d29yZA
word is d29yZA when encoded in Base64. See? Easy.
Decoding
- Convert the character to its 6-bit binary equivalent.
- Working from left to right, convert the 6-bit binary back to 8-bit binary. You may have some extra zeroes from the conversion, as we would in our example above. Trim them off until you get something that makes sense
- Convert the 8-bit binary back to its ASCII equivalents.
Cast your vote on this article 10 - Highest, 1 - Lowest
Comments: Published: 12 comments.
HackThisSite is is the collective work of the HackThisSite staff, licensed under a CC BY-NC license.
We ask that you inform us upon sharing or distributing.
Page Generated: Thu, 23 May 2013 20:50:06 +0000 Web Node: www2 | Page Gen: 0.14s | DB: 10q Current Code Revision: Thu Dec 6 19:06:02 UTC 2012