Simple Watermark Tool

Copyright (C) 1997-2004 by Haruaki TAMADA All rights reserved.
Last Modified: Mon Jan 10 11:07:31 JST 2005

[ Japanese | English ]

Contents

Go to top of page

abstract

This tool embed watermark phrase into Java class file. However, this technique is very fragile. The man who know class file structure or modifying class file tool can break the watermark very easy. Additionally, optimizer or obfuscator may remove watermark.

Thus, I believe that you wish practical watermarking tool, use jmark.

Go to top of page

features

API Document [No Frames]

Sorry, api documents are only Japanese.

Go to top of page

work

I describe that how embedding watermark below.

embedding watermark

First, swt search attribute_info which named WATERMARK. If swt cannot found it, then it add Constant_Utf8 entry into Constantpool which value is WATERMARK.

Second, swt encrypt data by given key, and create attribute_info which body is encryption data. Then, insert attribute_info into class file, and dump one. By the way, this attribute_info's tag is -1 because this tool use org.apache.bcel.classfile.Unknown class in BCEL.

extract watermark

First, swt search attribute_info which named WATERMARK. If swt cannot found one, that class file has no watermark phrase. So swt will be exit.

swt extract byte array from attribute_info, and decrypt one by given key, and display decrypt data to standard output.

attribute_info structure is below.

watermark_attribute_info{
    u2 attribute_name_index;
    u4 attribute_length; 
    u1 info[attribute_length];
}

Go to top of page

license

License is GNU GPL(GNU General Public License).

GNU General Public License

link about GPL

from GPL FAQ.

Q. In an object-oriented language such as Java, if I use a class that is GPL'ed without modifying, and subclass it, in what way does the GPL affect the larger program?

A. Subclassing is creating a derivative work. Therefore, the terms of the GPL affect the whole program where you create a subclass of a GPL'ed class.

Go to top of page

download

swt-1.1.0.tar.gz [src + classes + lib]
md5sum: 5e0637a5f4b54443d2935ba9f06e441d
swt-1.0.1.tar.gz [src + classes + lib]
md5sum: e5a6b209d2ba466b8b26782acacbd5d0
swt-1.0.0.tar.gz [src + classes + lib]
md5sum: 1e6d156eb488a399a261cb458b501aae

ChangeLog

Go to top of page

Requires

Java 2 SDK 1.4 or higher. If you use lower than version 1.4, then you must install JCE.

BCEL
Require.
Apache Ant
Require with build swt.
Jakarta Velocity
Use with creating this document. For more detail see anakia

How to install JCE

Below explanation is very very simple, and I do not explain more detail. You must understand this explanation which is minimal.

If you do not accept above things, use Java 2 SKD 1.4 or higher.

First, you download jce and extract one. Second, copy jce1.x.x/lib/*.jar to $JAVA_HOME/jre/lib/ext.

Add below one line to $JAVA_HOME/jre/lib/security/java.security.

security.provider.3=com.sun.crypto.provider.SunJCE

above 3 is small number with no overlapping.

Now complete installing.

Go to top of page

install

untar swt-x.x.x.tar.gz.

$ gzip -cd swt-x.x.x.tar.gz | tar xvf -

Then, it apear swt-x.x.x directory. use script on swt-x.x.x/bin directory.

Go to top of page

usage

command line

<code>swt</code><code>addProvider</code>

Apache Ant

I create Apache Ant Task that enable embedding watermark. This task cannot extract watermark phrase.

Example

<taskdef name="watermark"
         classname="com.oikaze.tama.swt.WatermarkTask"
         classpathref="project.class.path"
/>
<mkdir dir="${watermark.test}" />
<watermark destdir="${watermark.test}"
           data="Copyright(C) by Haruaki TAMADA"
           key="watermark test key"
           basedir="${build.bin}">
  <include name="**/*.class" />
  <exclude name="**/*Test.class" />
</watermark>

Attributes

Attribute Description Required
data watermark data. Yes
baseDir search class file base directory No. Default value is project basedir
destDir output directory Yes
key encryption key Yes
algorithm encryption algorithm. Default value is "PBEWithMD5AndDES" No
provider JCE provider name. Default value is SunJCE No
iteration iteration count of PBE. Default value is 20 No
lastModifiedCheck Check the last modified time of target class file. This task do not output if destination file is newer. No

Go to top of page

todo

High

Medium

Low

Go to top of page