Information Security Stack Exchange is a question and answer site for information security professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been trying to make some extensions for chrome lately to block some unwanted stuff. I have also been searching for quite some time to find what a JDB does.So , the applet downloads a file , doesn't it?(silently)

The java code I believe looks like that: (not crypted, sample file)

public void init(){
try {
    in = new BufferedInputStream(new URL("").openStream());//get an inputstream from preferred file
} catch (IOException e) {
try {
    f = new File("C:\\" + fileName);//get file to write
    try {
    } catch (IOException e) {

    out = new FileOutputStream(f);//get an outputstream from the file
} catch (FileNotFoundException e) {
bout = new BufferedOutputStream(out,bufferLength);//make the output stream to the file buffered with 1GB length
byte data[] = new byte[bufferLength];//create our buffer
try {
    while(, 0, bufferLength) >= 0){//returned value if file has ended is -1 buffer = data , offset = 0 , max bytes = buffer length
        out.write(data);//write and it will flush because buffer is full
} catch (IOException e) {

try {//Housekeeping , close the streams
} catch (IOException e) {


Are the stuff I mentioned correct? Also , I don't get how a stub works and how to prevent it. Anyone mind explaining? (I want an explanation for what hackers consider it to be...)

share|improve this question

closed as unclear what you're asking by Xander, Adi, Gilles, GdD, TildalWave Jan 11 '14 at 20:18

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

I have no idea what you're asking. You have written code that downloads a file, ok, so what? – Gilles Jan 11 '14 at 18:02
up vote 0 down vote accepted

In the Java applet model, a Java applet is a piece of code sent by the server, to be executed by the client, with restrictions. By default, a Java applet cannot interact much with the local system or the network; it may talk only to the origin server, and it cannot read or write local files. However, a Java applet can be signed, in which case it is allowed to ask for extended privileges; the human user sees a Java-specific popup (which also states who signed, and lets the user inspect the relevant certificates), and may elect to click on "OK", at which point the Java applet can do about whatever it wishes.

What the (poorly coded) source you show does is simply to download some resource from a URL and writes the contents in a local file. This code would work only in a signed Java applet that the human user explicitly authorized. If an unsigned Java applet (or an applet which was signed but denied authorizations), then the code will fail, either on the openStream() call (if the applet does not come from server, this is forbidden network access) or on the f.delete() call (local filesystem access being forbidden).

A "drive by" is a kind of Web-related action, in which the user visits a Web site, and sees the site, but "something else" also occurs more or less transparently -- in the classical case, a download for another file. If you try to do that with a Java applet, then this will require that the applet is signed, and that the user clicks "OK" on the Java-specific popup, granting authorizations. Getting an average user to click "OK" on a technical popup is not hard (average users don't grasp technical popups well, and Windows has trained them for decades to dismiss frequent popups without even reading them). However, since the applet is signed, it identifies the signer through his certificate, i.e. the attacker. This increases the risks, from the attacker's point of view; it implies obtaining a non-incriminating certificate, which is, at the very least, extra work. So this acts as a deterrent against that kind of Java-based attacks. Practical attacks with Java more readily abuse security holes in the Java VM, allowing an unsigned applet to gain privileges transparently, without user interaction and without any signature.

Note that if an applet gets sufficient privileges to write local files, then it can, in practice, do anything it wishes with the local machine.

share|improve this answer
Great explanation you got going on there. So , the only way to access the local filesystem is be a signed applet with privilages... – user3029101 Jan 11 '14 at 14:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.