Ashok Purushotham
(ashok@cs.arizona.edu)
Rathna Prabhu
(prabhu@cs.arizona.edu)
Christian Collberg
(collberg@cs.arizona.edu)
This algorithm is a Static Watermarker that adds bogus local variables to a method .The number of bogus local variables is entered as a string into the ConstantPool of a classfile.
sm$len: The string in which we hide the number of bogus local variables.
The watermark is stored in the initial value of these locals as given:
Consider a watermark value "1056", then
class C1{ void m2(){ ... int sm$1=10; int sm$2=56; } }
Embedding
Consider a watermark "120340". This will be embedded into the classfile
by selecting a method and adding 3 bogus local variables as sm$1=12,
sm$2=3* and sm$3=40. If the number of
digits were odd, then add a trailing '0' which we strip out during
watermark recognition, eg. consider a watermark "5075441", then sm$1=50,
sm$2=75, sm$3=44 and sm$4=10. Basically we insert BIPUSH statements to
push the value of a part of the watermark for each Bogus Variable.
Recognition
Obtain the value of sm$len. Based on the value of sm$len, we use a loop
to find out the values of BIPUSH. Inherent advantage is that, we aren't
relying on the names of added bogus variables, because some compilers
may strip out such information. For example, if watermark was 1056, then
the code added during embedding would give us the following:
0: bipush 56
2: istore %4
4: bipush 10
6: istore_3
..... The method's code
.....
We strip out the values in BIPUSH statements and reconstruct back the
original watermark.
* Instead of pushing 03, we use 3 as the value of the variable, beacuse the leading zeroes in an integer are stripped out. Therefore while recognizing, we need to check if the value was less than 10 and if so, expand it by adding a leading "0".