Thread: CRC Check

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    55

    CRC Check

    I am trying to a CRC check on a file against the CRC it should be so if any changes to the file were made, it will not continue with the program.

    Using the search function, I found this thread most useful..
    http://cboard.cprogramming.com/showthread.php?t=92194

    and google this page was most useful...
    http://www.gamedev.net/reference/art...rticle1941.asp

    It does exactly what I want except that I don't completely understand the concept here...

    What if I don't know the 'polynomial' of my file, how will I generate a lookup table? How do I find the 'polynomial' of the file and how can I get the values for the table? Is the table even necessary if I already know the CRC I am checking for?

    So, generate CRC of a given file, match it against the true CRC that it should be. The lightswitch hasn't gone off in my head yet of how all this matches up.. =[

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by silentkarma View Post
    I am trying to a CRC check on a file against the CRC it should be so if any changes to the file were made, it will not continue with the program.
    The goal being what?

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    55
    Not sure what you mean. The file I want to check is a .map file for a game. Many people 'mod' or 'modify' the .map file to cheat for unfair advantage. If there were any byte changes to the .map file, it will not load the game. I'm assuming a CRC check would be sufficient for this, if not, any other suggestions?

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by silentkarma View Post
    I'm assuming a CRC check would be sufficient for this, if not, any other suggestions?
    It would be completely insufficient, because if I was trying to hack your game, the first thing I'd do is locate the code which does this CRC check, and disable it.

    And once I did that, I would distribute my crack widely on the Internet to make it easy for everybody to use their own maps.

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    55
    brewbuck, I think you need to write a program to check your arrogance every once in a while...

    It's not my game. It's only for the servers I run for my clan mates to keep them from cheating in our servers.

    Besides the offtopic chat of how to hack my program, anyone else have any help they could advise me?

    There's no one in my clan that knows how to disable a CRC Check let alone reverse engineer anything, trust me, so enough with the hypothetical ifs. This will have to do for now.

  6. #6
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by silentkarma View Post
    It's not my game. It's only for the servers I run for my clan mates to keep them from cheating in our servers.
    If your clan mates are a bunch of cheaters, maybe you should find some other clan mates.

    There's no one in my clan that knows how to disable a CRC Check let alone reverse engineer anything, trust me, so enough with the hypothetical ifs. This will have to do for now.
    If you want to go forward with this, I'd suggest using an MD5 library. Not because it's more secure (it isn't), but because it's easy to find and use.

    I'm not opposed to explaining how to calculate a checksum. Just don't think it's going to stop anybody.

  7. #7
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by silentkarma View Post
    brewbuck, I think you need to write a program to check your arrogance every once in a while...

    It's not my game. It's only for the servers I run for my clan mates to keep them from cheating in our servers.

    Besides the offtopic chat of how to hack my program, anyone else have any help they could advise me?

    There's no one in my clan that knows how to disable a CRC Check let alone reverse engineer anything, trust me, so enough with the hypothetical ifs. This will have to do for now.
    Code:
    int main()
    {
        cout << "brewbuck's post was fine" << endl;
    }
    There wasn't any point in asking if it was sufficient if you had already decided yourself that the answer was yes.

    Make sure you put things in context first. You knew it was only for a bunch of mates and not the general public, we did not, and should not rightfully assume that either. You can't afford to be naieve when it comes to general software security.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  8. #8
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> brewbuck, I think you need to write a program to check your arrogance every once in a while...

    ok...

    >> so enough with the hypothetical ifs.

    is this how you chat with your mates, then?

    >> It would be completely insufficient, because if I was trying to hack your game, the first thing I'd do is locate the code which does this CRC check, and disable it.

    the code that does the checking is not generally in the file but in the program analyzing it (such as the game itself).

    >> Just don't think it's going to stop anybody.

    right. there's still a 1/(2^(word_size*8)) chance that fails to detect alterations, whatever algorithm is used.

    >> What if I don't know the 'polynomial' of my file, how will I generate a lookup table? How do I find the 'polynomial' of the file and how can I get the values for the table? Is the table even necessary if I already know the CRC I am checking for?

    you don't need to know the polynomial of anything. you pass the data through some mathematical function that produces a small, fixed size word that can be compared against.

    there are numerous CRC algorithms available (some are free and some are not).
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I believe md5sum is often used for this purpose, as it forms a longer checksum, and thus makes it much harder to find a combination that cancels one change with another. Using both CRC32 and MD5 would make it even harder to find a good way to change the data / code in a way that is undetectable in both (because the way that md5sum and crc32 works will not change in the same way for the same changes, and thus it makes for a hard to change situation).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. how to check input is decimal or not?
    By kalamram in forum C Programming
    Replies: 3
    Last Post: 08-31-2007, 07:07 PM
  3. Please check this loop
    By Daesom in forum C++ Programming
    Replies: 13
    Last Post: 11-02-2006, 01:52 AM
  4. CTRL+Z? How to check it?
    By Olimpo in forum C Programming
    Replies: 8
    Last Post: 10-01-2006, 04:07 PM
  5. how to check for end of line in a text file
    By anooj123 in forum C++ Programming
    Replies: 6
    Last Post: 10-24-2002, 11:21 PM