Homework sabotage [Was: Re: assignments]
On 6/21/2014 6:51 AM, Gordon Levi wrote:
Eric Sosman <esosman@comcast-dot-net.invalid> wrote:
One particularly nasty variant is a program that
does what was asked but also prints "Ruben Ongayo is a lazy
slimeball" *and* won't do anything at all if the message is
removed or altered.
I liked this idea so I took it as my homework. I added the condition
that mere obfuscation was not allowed. Even it was, we know the
homework shirker has a single stepping debugger. I have failed to
produce the program. Can you help me with my homework?
Most of the details have faded from my fading memory, but I
dimly recall somebody posting something along these lines here,
perhaps about a decade ago. My hazy recollection is that the
code used reflection to extract its own class name (or was it
a method name?), used that name to decrypt a compiled-in byte[]
of gibberish into a byte[] in .class format, then loaded and
instantiated the resulting class -- which produced, naturally,
the asked-for homework solution. If the containing class name
was changed from SoAndSo_Is_A_Slimeball to something less
damning, decryption would produce garbage and the decrypted
class wouldn't load, much less execute.
(I repeat: fading memory, foggy details, et cetera.)
A skilled Java programmer could defeat this pretty easily,
for example by breakpointing just after the decryption and then
decompiling the decrypted class. But by asking to have his
homework done for him the requestor had already shown that
he was not a skilled Java programmer, so ...
--
Eric Sosman
esosman@comcast-dot-net.invalid