Thread: Encryption/Decryption Help

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    4

    Encryption/Decryption Help

    I have 2 files, 1 fully encoded and 1 fully decoded. Both files are completely same byte size. Is there a way to find out the decription/encription technique they used with having both the fully encoded file and fully decoded file.


    Heres encoded bytes:
    Code:
    0x07 0xA3 0xDE 0xB0 0x36 0x7E 0x4C 0xAF 
    0x39 0x0C 0x5E 0x49 0x65 0x90 0xDD 0x23 
    0x40 0x33 0xB1 0x4D 0x3D 0x8C 0xE0 0x4D 
    0x6A 0xDB 0x10 0x49 0xE7 0xCC 0x43 0xAD 
    0x10 0x4C 0x20 0x7C 0xB7 0x66 0x96 0x02 
    0x1E 0x92 0x01 0xC8 0xF6 0xB6 0xB0 0xBC 
    0x15 0x14 0xCA 0xE2 0x44 0x28 0x41 0x69 
    0xB2 0x9F
    Heres decoded bytes:
    Code:
    0x03 0x00 0x00 0x00 0x06 0x00 0x00 0x00 
    0x07 0x00 0x00 0x00 0x02 0x00 0x00 0x00 
    0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 
    0x04 0x00 0x00 0x00 0xB1 0xE2 0xBA 0xBB 
    0x00 0x02 0x00 0x00 0x00 0x04 0x00 0x00 
    0x00 0xC1 0xDF 0xB1 0xDE 0x00 0x03 0x00 
    0x00 0x00 0x03 0x00 0x00 0x00 0x46 0x41 
    0x51 0x02

    I need help with finding the Decryption key, if that is even possible in this case.
    Last edited by Salem; 04-23-2008 at 12:53 PM. Reason: wrap long lines to a decent length

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Is there a way to find out the decription/encription technique they used with having both the fully encoded file and fully decoded file.
    No, not even with the key, since two different encryption algorithms could produce the same ciphertext given the same plaintext and key, for one particular plaintext/key combination.

    I need help with finding the Decryption key, if that is even possible in this case.
    No, since you know neither the algorithm nor the key, and only have one set of plaintext and corresponding ciphertext. Suppose a one time pad is used in which corresponding bytes are xored togethered. You could find the key by xoring the plaintext with the ciphertext, but you have no way of knowing if that is indeed the key since you do not know the algorithm.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    4
    what if I have like 10-15 files that are encoded, and decoded?

    cuz its pretty simple to get right now to get it but the files are a lot bigger, also I believe the byte ordering has not changed at all and of course like I said before the byte size will be the same for both files.

    The old algorithm that was in place:

    Code:
    uint modWord = 0x0816;                                                              
    			for (int i = 0; i < fileData.Length; i++)
    			{
    				byte encodedByte = fileData[i];
                    byte decodedByte = 0;
                    uint tmpModWord = modWord; 
                                                                                                
                    tmpModWord &= 0xff00;           
                    tmpModWord = tmpModWord >> 8;
                    decodedByte = (byte)(tmpModWord ^ encodedByte);
                    tmpModWord = encodedByte;
    				tmpModWord += modWord;
    				tmpModWord = tmpModWord & 0xffff; //eliminate overflow 
    				tmpModWord = tmpModWord * 0x6081; 
    				tmpModWord = tmpModWord & 0xffff; //eliminate overflow  
    				tmpModWord += 0x1608;
    				tmpModWord = tmpModWord & 0xffff; //eliminate overflow
    				modWord = tmpModWord;
    
    				fileData[i] = decodedByte;
    			}
    The fileData is the byte array that is first fully encoded and this was the decoder method used before, and most likely it'll be in similar form.

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Well... Suffice to say, even if its done in a basic way, your data is encrypted bud. The whole point was to keep someone from easily decrypting it, correct? This sounds more like user neglect than a class assignment. Just use the same key as before.

    [edit]In all that I forgot to mention, despite laserlight's uninspiring words you certainly could figure out the algorithm. Depending on the complexity of the algorithm, however, it may become exponentially unlikely[/edit].
    Last edited by master5001; 04-23-2008 at 12:25 PM.

  5. #5
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Ok well the algorithm is definitely the more valuable thing to have. You can try a brute forcing technique for the key. I won't spout lies to you my friend, this is probably the most caveman technique for cracking a file, and the most time consuming. Just loop through the file and try keys until your data opens.

    Obviously the biggest crux of brute forcing is the number of sheer variables that you will be dealing with. But there are a finite number of keys to try assuming you have a clue as to the length of the key.

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    4
    how would I get started with that, any clue really? I'm not great at encoding/decoding methodolgy, I've seen the programs out there, but is there no programs that would brute force check each and every pattern for it, finding some sort of correct algorithm to the code, by having like 10-15 encoded and decoded files?

    Obviously knowing the byte ordering stayed the same and total byte size is the same too, should help a lot I think.

  7. #7
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I feel the urge to ask a few follow up questions, and feel free to PM me about this as you see fit since I actually love these sorts of problems If you have an encrypted page and an unencrypted page, why do you need to decrypt the encrypted page? Am I to assume the key is the same for each of the files?

  8. #8
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Could you tell us the source where the data comes from? The decoded data doesn't look much like text.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  9. #9
    Registered User
    Join Date
    Apr 2008
    Posts
    4
    oops sorry forgot to check this post in a bit.

    Well here goes, I got like 50 files, and I can decode about 10-15 that are not changed since they changed the encryption method. Knowing these developers are incredibly lazy, they would most likely just change the encryption method, obviously they didn't add bytes to the data or change the byte ordering to make it more advanced, but in all honesty they are probably following the same encryption method I posted above, but changing a number or 2.

    These files consist about 8 data structures. The data itself comes decoded like this: first 4 bytes = # columns of data, using that number u can loop threw and find out the data type structures of the columns, aka 1st 4 bytes after might be the number 7 which = string, or 2nd 4 bytes after might be the number 3 indicating its a Int16

  10. #10
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    So to best understand your scenario, you are trying to hack some files you found? Either way, as I mentioned before, I am willing to meet you halfway (so long as you are doing something ethical) but you need to produce something first off. This isn't a place to give design specs and have an experienced software engineering group collaborate to meet your needs.

Popular pages Recent additions subscribe to a feed