开发者

Variable renaming for plagiarism detection for C/C++

开发者 https://www.devze.com 2023-03-02 08:27 出处:网络
I have a couple of simple C++ homeworks and I know the students shared code. These are smart students and they know how to cheat moss. I\'m looking for a tool that can rename variables based on their

I have a couple of simple C++ homeworks and I know the students shared code. These are smart students and they know how to cheat moss. I'm looking for a tool that can rename variables based on their types (first variable of type int will be int1, first int array will be intptr1...), or does something similar that I cannot think of now. Do you know 开发者_如何学JAVAa quick way to do this?

edit: I'm required to use moss and report 90% match

Thanks


Yep, the tool you're looking for is called a compiler. :)

Seriously, if the programs submitted are exactly the same except for the identifier names, compiling then (without debugging info) should result in exactly the same output.

If you do this with debugging turned on, the compiler may leave meta-data in the executable that is different for each executable, hence the comment about ensuring it is off. This is also why this wont work for Java programs - that kind of info is present whether in debug mode or not (for the purposes of dynamic introspection).

EDIT: I see from the comments added to the question that you're observing some submissions that are different in more than just identifier names. If the programs are still structurally equivalent, this should still work.

EDIT: Given that the use of moss is a requirement, this probably isn't the way to go. I does seem though that moss has some support for comparing assembly - perhaps compiling to assembler and submitting that to moss is an option (depending on what compiler you're using).


You can download and try our C CloneDR duplicate code detector. It finds duplicated code even when the variable names have been changed. Multiple changes in the same chunk are treated as just one; if they rename the varaibles consistenly everywhere, you'll get back a report of "one clone" with the precise variable subsitution.


You can try Copy Paste Detector with ignoreIdentifiers turned on. You can at least use it for a first pass before going to the effort of normalizing names for moss. Or, since the source is available, maybe you can get it to spit out its internal normalization of the code.


Another way of doing this would be to compile the applications and compare their binaries, so your examination is not limited to variable/function name changing.

An HEX editor can help you with that. I just tried ExamDiff (not free $) and I was happy with the result.

0

精彩评论

暂无评论...
验证码 换一张
取 消