Android Open Source - android-ssl-bypass Trace Methods J D I Plugin






From Project

Back to project page android-ssl-bypass.

License

The source code is released under:

Copyright (c) 2012, iSEC Partners. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the ...

If you think the Android project android-ssl-bypass listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * /*from  w  w w . j a  v  a  2  s . c  o m*/
 */
package com.isecpartners.android.jdwp.plugin;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.isecpartners.android.jdwp.LocationNotFoundException;
import com.isecpartners.android.jdwp.ReferenceTypeNotFoundException;
import com.isecpartners.android.jdwp.pluginservice.AbstractJDIPlugin;
import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.IncompatibleThreadStateException;
import com.sun.jdi.LocalVariable;
import com.sun.jdi.Location;
import com.sun.jdi.Method;
import com.sun.jdi.StackFrame;
import com.sun.jdi.ThreadReference;
import com.sun.jdi.Value;
import com.sun.jdi.event.Event;
import com.sun.jdi.event.MethodEntryEvent;

/**
 * @author nml
 * 
 */
public class TraceMethodsJDIPlugin extends AbstractJDIPlugin {

  private final static org.apache.log4j.Logger LOGGER = Logger
      .getLogger(TraceMethodsJDIPlugin.class.getName());
  private static final String FILTERS_FILENAME_KEY = "filters.filename";
  private ArrayList<String> filters = new ArrayList<String>();
  private String filtersFileName = null;

  public TraceMethodsJDIPlugin() throws FileNotFoundException, IOException {
    super(TraceMethodsJDIPlugin.class.getName());
  }

  @Override
  public void handleEvent(Event event) {
    StringBuilder out = new StringBuilder("");
    if (event instanceof MethodEntryEvent) {
      MethodEntryEvent meEvent = (MethodEntryEvent) event;
      ThreadReference tr = meEvent.thread();
      StackFrame fr;
      
      try {
        fr = tr.frame(0);
        Location loc = fr.location();
        Method method = loc.method();
        out.append("\n===============\n" + method.toString()
            + "\n===============\n");
        out.append("local variables:\n");
        List<LocalVariable> visVars = fr.visibleVariables();
        if (visVars != null && !visVars.isEmpty()) {
          Map<LocalVariable, Value> vars = fr.getValues(visVars);
          for (LocalVariable key : vars.keySet()) {
            out.append("\t" + key + " : " + vars.get(key) + "\n");
          }
        }
        out.append("\n =============== \n");
      } catch (IncompatibleThreadStateException e) {
        out.append("could not get visible variables due to IncompatibleThreadStateException");
        LOGGER.error(e);
      } catch (AbsentInformationException e) {
        out.append("could not get visible variables due to AbsentInformationException");
        //TODO should probably print full stack trace
        LOGGER.error(e);
      }

    } else {
      out.append("unexpected event type for handler: " + event);
    }
    
    LOGGER.info(out.toString());
    this.output(out.toString());
    this.resumeEventSet();
  }

  @Override
  public void setupEvents() {
    String filename = this.properties.getProperty(FILTERS_FILENAME_KEY,
        "filters");
    this.filtersFileName = this.basePath + File.separator + filename;
    LOGGER.info(this.filtersFileName);
    try {
      this.filters = this.readLines(this.filtersFileName);
      for (String f : filters) {
        this.createMethodEntryRequest(f);
      }
    } catch (IOException e) {
      LOGGER.info("could not get filters filename");
    } catch (LocationNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ReferenceTypeNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }

  public ArrayList<String> readLines(String filename) throws IOException {
    FileReader fileReader = new FileReader(filename);
    BufferedReader bufferedReader = new BufferedReader(fileReader);
    ArrayList<String> lines = new ArrayList<String>();
    String line = null;
    while ((line = bufferedReader.readLine()) != null) {
      lines.add(line);
    }
    bufferedReader.close();
    return lines;
  }

}




Java Source Code List

com.isec.helperapp.EasySSLSocketFactory.java
com.isec.helperapp.EasyX509TrustManager.java
com.isec.helperapp.MainActivity.java
com.isec.helperapp.TrustAllTrustManager.java
com.isec.ssltest.SSLTestActivity.java
com.isecpartners.android.jdwp.ADBInterface.java
com.isecpartners.android.jdwp.ClassLoaderUtils.java
com.isecpartners.android.jdwp.ClassWrapper.java
com.isecpartners.android.jdwp.CommandLine.java
com.isecpartners.android.jdwp.Constants.java
com.isecpartners.android.jdwp.Control.java
com.isecpartners.android.jdwp.DalvikUtils.java
com.isecpartners.android.jdwp.DexClassLoaderNotFoundException.java
com.isecpartners.android.jdwp.LocationNotFoundException.java
com.isecpartners.android.jdwp.NoLoadClassMethodException.java
com.isecpartners.android.jdwp.NoVMSessionException.java
com.isecpartners.android.jdwp.NotImplementedException.java
com.isecpartners.android.jdwp.ReferenceTypeNotFoundException.java
com.isecpartners.android.jdwp.VirtualMachineEventManager.java
com.isecpartners.android.jdwp.VirtualMachineSession.java
com.isecpartners.android.jdwp.common.Message.java
com.isecpartners.android.jdwp.common.QueueAgentInterface.java
com.isecpartners.android.jdwp.common.QueueAgent.java
com.isecpartners.android.jdwp.connection.AbstractConnection.java
com.isecpartners.android.jdwp.connection.AttachingConnection.java
com.isecpartners.android.jdwp.connection.DVMConnectionProvider.java
com.isecpartners.android.jdwp.connection.DefaultConnectionFactory.java
com.isecpartners.android.jdwp.connection.NoAttachingConnectorException.java
com.isecpartners.android.jdwp.connection.NoListeningConnectorException.java
com.isecpartners.android.jdwp.plugin.JythonConsoleJDIPlugin.java
com.isecpartners.android.jdwp.plugin.SSLBypassJDIPlugin.java
com.isecpartners.android.jdwp.plugin.TestJDIPlugin.java
com.isecpartners.android.jdwp.plugin.TraceMethodsJDIPlugin.java
com.isecpartners.android.jdwp.pluginservice.AbstractJDIPlugin.java
com.isecpartners.android.jdwp.pluginservice.AbstractJythonConsolePlugin.java
com.isecpartners.android.jdwp.pluginservice.AbstractPluginService.java
com.isecpartners.android.jdwp.pluginservice.ClasspathUtils.java
com.isecpartners.android.jdwp.pluginservice.JDIPluginServiceFactory.java
com.isecpartners.android.jdwp.pluginservice.JDIPluginService.java
com.isecpartners.android.jdwp.pluginservice.JDIPlugin.java
com.isecpartners.android.jdwp.pluginservice.JythonPluginServiceFactory.java
com.isecpartners.android.jdwp.pluginservice.JythonPluginService.java
com.isecpartners.android.jdwp.pluginservice.PluginNotFoundException.java
com.isecpartners.android.jdwp.pluginservice.PluginService.java