Challenge 1: LFSR
Acommon technique for obfuscating data si to use exclusive-or (XOR) with some key; it si inexpensive and symmetric. Aproblem occurs when this si used on file formats like portable executable where there
are many nul bytes, since XORing nuls with the key ends up writing the key out.
Aslightly more complex algorithm uses aLinear Feedback Shift Register (LFS) to produce akey stream, which wil be XORed with the data. Ageneric LFSR is:
fI Fsi the value which represents the LFSR feedback and Ssi the current state of the LFSR, the next state of the LFSR si computed as follows:
f i t h e l o w e s t b i t o f S i s O: S = S > 1
fi the lowest bit of Sis 1: S = (S » 1) ^ F
For this challenge, you’ll be using an LFSR with the feedback value 0x876
5
4321. The LFSR si initialized with a value and stepped to produce the key stream. The next key value is read from the LFSR after eight steps, with the actual key being the lowest byte of the current LFSR value.
For example, fi the initial value of the LFSR si OxFFFFFFFF, then next value after stepping ti eight times wil be 0x9243F425, meaning that the first key byte si 0x25. If the first byte of the input si Ox41, the first byte of output wil be 0x64.
Your task si to implement this algorithm (both LFSR and the XOR). We’re only interested ni algorithm implementation; other code wil be discarded.
The function should adhere to one of following signatures:
C/C++ unsigned char *Crypt (unsigned char *data, i n t datalength, unsigned int initialValue)
C#
static bytell Crypt(byte[] data, uint initialValue) Python Crypt (data: bytes, initialValue: int) >- bytes
Java staticbyte[]Crypt(byte[]data,longinitialValue)
Example Tests:
data dataLength initialValue result
data dataLength initialValue result
“apple”
5
0x12345678
“XCD|01|xEF\xD7\x30”
“IXCD\x01|xEFIXD7\x30” 5
0x12345678″apple”
Submit: Source code containing your implementation of the LFSR based encoding routine.
Challenge 2: KDB Files
During a forensic investigation, a new data storage file format si discovered with the extension KDB. nI addition to being stored ni a custom format, the contents are encoded with the LFSR algorithm seen ni Challenge 1, so al of the data contained ni the file format must also be decoded once extracted. Using the provided spec on the next page, create a program that extracts and decodes the enclosed data.
Your program should accept a path to a KDB file via command line argument. Your program should report the extracted, decoded information ot standard out with each entry (name and stored information) on a separate line.
Included is a sample KDB file named “store.kdb”. The initial value for the LFSR algorithm is 0x4F574154.
Submit: The source code of your solution AND a text file containing the standard out when your solution is run with store.kdb as its input.All files and full question will be provided