ATTACK AT NOON
would be encoded using an XOR with the byte 0x3C. Each character is represented by a cell, with the ASCII character (or control code) at the top, and the hex value of the character on the bottom.shows the first few bytes of the a.gif file encoded with different XOR keys. The goal of brute-forcing here is to try several different values for the XOR key until you see output that you recognize—in this case, an MZ header. The first column lists the value being used as the XOR key, the second column shows the initial bytes of content as they are transformed, and the last column shows whether the suspected content has been found.
, the code for this modified XOR is not much more complicated than the original.
Now compare (with the obvious 0x12 key) with . represents the same encoded PE file, encoded again with 0x12, but this time using the NULL-preserving single-byte XOR encoding. As you can see, with the NULL-preserving encoding, it is more difficult to identify the XOR encoding, and there is no evidence of the key.
xor edx,edx
).An XOR encoding loop may use either of the other two forms: an XOR of a register with a constant or an XOR of a register with a different register. If you are lucky, the XOR will be of a register with a constant, because that will confirm that you are probably seeing encoding, and you will know the key. The instruction xor edx, 12h
in is an example of this second form of XOR.
One of the signs of encoding is a small loop that contains the XOR function. Let’s look at the instruction we identified in . As the IDA Pro flowchart in shows, the XOR with the 0x12 instruction briefly describes some of these encoding schemes. We won’t delve into the specifics of each of these techniques, but you should be aware of them so that you can recognize them if you see them.
ATT
). The second line is the hex representation of ATT
at the nibble level (a nibble is 4 bits). The middle line shows the actual bits used to represent ATT
. The fourth line is the value of the bits in each particular 6-bit-long section as a decimal number. Finally, the last string is the character used to represent the decimal number via the index into a reference string.Cookie
are Base64-encoded values. While the Cookie
value appears to remain constant, it looks like the attacker is sending two different encoded messages in the two GET
requests.A quick way to encode or decode using the Base64 standard is with an online tool such as the decoder found at . Simply enter the Base64-encoded content into the top window and click the button labeled Decode Safely As Text. For example, shows what happens if we run the Cookie
value through a Base64 decoder.