2

I'm looking to implement a shared configuration file that will be written (output) in python, but be read (input) in C.

The only prerequisite of this configuration file is that it can't be human readable.

Anyone have any suggestions on what file format I should use for this project?

Edit: The file can't be human readable because we don't want the user to be able to modify the configuration, also, in some cases, we don't want the user to know about certain configurations.

7
  • 4
    ... Why can't it be human-readable? Commented Dec 21, 2010 at 22:17
  • 2
    @CodingWithoutComments: I think that the correct way of doing that would be to protect the configuration file with the security facilities provided by the OS. Security by obscurity isn't very effective and would be really fastidious if there was a legit need to change that file manually. Commented Dec 21, 2010 at 22:22
  • 4
    How about you let the user configure his own application? Commented Dec 21, 2010 at 22:28
  • 2
    Our product used to have that (XML obfuscated with DES + fixed key), but we removed the obfuscation at the request of our support people, so they could check the actual configuration in the case of problems. Commented Dec 21, 2010 at 22:30
  • 5
    You can have the file both readable and non-modifiable by appending a hash on the end. If the hash doesn't match a new hash of the contents, reject the configuration. Commented Dec 21, 2010 at 22:46

4 Answers 4

2

How secure do you need this config file to be?

There is no absolute security, you'll quickly run into DRM like issues (allow users to open a file but not allow them to open it ... I know it's insane).

Often simple obfuscation is quite effective. Dump the config to a JSON file (please don't use xml). XOR the contents and change the extension. That will stop all casual inspection of the file. Obviously don't document that this is your obfuscation procedure.

If you're worried about user modification of config files (you don't care if the configs are readable you just want prevent loading custom configs) use a cryptographic signature. Store the private key at your company and use it and the python app to generate a signed configuration. Store the public key in the c++ application and use it to verify the config is properly signed before applying the settings.

Sign up to request clarification or add additional context in comments.

1 Comment

@Arafangion: I was drawing a (subtle) parallel between locking down a config file and creating a music format that can only be played in certain situations. Both monumental and arguably impossible tasks.
1

try this one http://www.picklingtools.com/

Comments

1

Probably easiest to use XML, then obfuscate it with a simple cypher or encryption with a fixed key.

2 Comments

Even plain XML can be quite unreadable on its own. (just jocking :))
I definitely read this as just "Probably easiest to use XML"`hahahah.
0

Use a plain human readable format such as XML, and then obfuscate that to make it uneditable (i.e. encrypt the whole thing and store a hash somewhere and fail to load if its' been messed with).

Otherwise you just have to bite the bullet and write a spec for the binary format that'll be exchanged between the two programs.

5 Comments

IME Very rarely is some proprietary XML file significantly more easily reverse engineered than some proprietary binary - usually binaries have a fixed field format, and most the effort is semantics not syntax.
What tools would I go about using to obsfuscate on the python side, then de-obfuscate on the C++ side?
@CodingWithoutComments: I'd just use a standard block cipher -- i.e. AES. It'd not be all that hard to break (Someone could disassemble your app and find the key), but it will keep out casual attackers. I'm sure Python probably already includes such a library, and you can use AES from C++ using a library like CryptoPP
@Pete: My assumption was that the XML would be semantic -- that is, that the format would make sense upon casual examination. Of course if you design the format such that that is not the case then of course you need not take the extra obfuscation step.
I'm used to formats which are configuring embedded devices which end up looking like <config><NodeID>137</NodeID><Register1>241</Register1>...</config> - the designers thought the tags were 'semantic', but unless you know that putting 0xf1 in register 1 sets channels 0 and 4 to 7 into output mode you're no better off.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.