Java Code Examples for pxb.android.axml.AxmlVisitor#TYPE_REFERENCE
The following examples show how to use
pxb.android.axml.AxmlVisitor#TYPE_REFERENCE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LayoutFileParser.java From LibScout with Apache License 2.0 | 5 votes |
@Override public void attr(String ns, String name, int resourceId, int type, Object obj) { // Is this the target file attribute? String tname = name.trim(); if (tname.equals("layout")) { if (type == AxmlVisitor.TYPE_REFERENCE && obj instanceof Integer) { // We need to get the target XML file from the binary manifest AbstractResource targetRes = resParser.findResource((Integer) obj); if (targetRes == null) { logger.trace(Utils.INDENT + "Target resource " + obj + " for layout include not found"); return; } if (!(targetRes instanceof StringResource)) { logger.trace(Utils.INDENT + "Invalid target node for include tag in layout XML, was " + targetRes.getClass().getName()); return; } String targetFile = ((StringResource) targetRes).getValue(); // If we have already processed the target file, we can // simply copy the callbacks we have found there if (callbackMethods.containsKey(targetFile)) for (String callback : callbackMethods.get(targetFile)) addCallbackMethod(layoutFile, callback); else { // We need to record a dependency to resolve later MapUtils.addToSet(includeDependencies, targetFile, layoutFile); } } } super.attr(ns, name, resourceId, type, obj); }
Example 2
Source File: LayoutFileParser.java From LibScout with Apache License 2.0 | 5 votes |
@Override public void attr(String ns, String name, int resourceId, int type, Object obj) { String tname = name.trim(); if (tname.equals("id") && type == AxmlVisitor.TYPE_REFERENCE) this.id = (Integer) obj; else if ((tname.equals("name") || tname.equals("class") && type == AxmlVisitor.TYPE_STRING && obj instanceof String)) { String className = ((String) obj).trim(); if (className.startsWith(".")) { logger.debug("Fragment attr parser:: \"" + tname + "\" contains leading dot: " + className); className = className.substring(1); // TODO: sometimes the parser adds a leading "." } // weird we had sth. like "5apperfection.bluebox.ui.fragments.DeviceLinksFragment" although the file included the string "apperfection.bluebox.ui.fragments.DeviceLinksFragment" while (!className.substring(0, 1).matches("[a-zA-Z]")) { logger.debug("Fragment attr parser:: \"" + tname + "\" starts with a non-letter character!: " + className + " fixing.."); className = className.substring(1); } try { fragmentClazz = WalaUtils.lookupClass(cha, className); } catch (ClassNotFoundException e) { logger.warn("Could not lookup IClass for Fragment " + className); } } super.attr(ns, name, resourceId, type, obj); }
Example 3
Source File: LayoutFileParser.java From LibScout with Apache License 2.0 | 5 votes |
@Override public void attr(String ns, String name, int resourceId, int type, Object obj) { // Check that we're actually working on an android attribute if (!isAndroidNamespace(ns)) return; String tname = name.trim(); if (tname.equals("id") && type == AxmlVisitor.TYPE_REFERENCE) this.id = (Integer) obj; else if (tname.equals("password") && type == AxmlVisitor.TYPE_INT_BOOLEAN) isSensitive = ((Integer) obj) != 0; // -1 for true, 0 for false else if (!isSensitive && tname.equals("inputType") && type == AxmlVisitor.TYPE_INT_HEX) { int tp = (Integer) obj; isSensitive = ((tp & TYPE_NUMBER_VARIATION_PASSWORD) == TYPE_NUMBER_VARIATION_PASSWORD) || ((tp & TYPE_TEXT_VARIATION_PASSWORD) == TYPE_TEXT_VARIATION_PASSWORD) || ((tp & TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) == TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) || ((tp & TYPE_TEXT_VARIATION_WEB_PASSWORD) == TYPE_TEXT_VARIATION_WEB_PASSWORD); } else if (isActionListener(tname) && type == AxmlVisitor.TYPE_STRING && obj instanceof String) { String strData = ((String) obj).trim(); addCallbackMethod(layoutFile, strData); } else { if (type == AxmlVisitor.TYPE_STRING) logger.trace(Utils.INDENT + "Found unrecognized XML attribute: " + tname); } super.attr(ns, name, resourceId, type, obj); }
Example 4
Source File: LayoutFileParser.java From JAADAS with GNU General Public License v3.0 | 5 votes |
/** * Parses the attributes required for a layout file inclusion * @param layoutFile The full path and file name of the file being parsed * @param rootNode The AXml node containing the attributes */ private void parseIncludeAttributes(String layoutFile, AXmlNode rootNode) { for (Entry<String, AXmlAttribute<?>> entry : rootNode.getAttributes().entrySet()) { String attrName = entry.getKey().trim(); AXmlAttribute<?> attr = entry.getValue(); if (attrName.equals("layout")) { if ((attr.getType() == AxmlVisitor.TYPE_REFERENCE || attr.getType() == AxmlVisitor.TYPE_INT_HEX) && attr.getValue() instanceof Integer) { // We need to get the target XML file from the binary manifest AbstractResource targetRes = resParser.findResource((Integer) attr.getValue()); if (targetRes == null) { System.err.println("Target resource " + attr.getValue() + " for layout include not found"); return; } if (!(targetRes instanceof StringResource)) { System.err.println("Invalid target node for include tag in layout XML, was " + targetRes.getClass().getName()); return; } String targetFile = ((StringResource) targetRes).getValue(); // If we have already processed the target file, we can // simply copy the callbacks we have found there if (callbackMethods.containsKey(targetFile)) for (String callback : callbackMethods.get(targetFile)) addCallbackMethod(layoutFile, callback); else { // We need to record a dependency to resolve later addToMapSet(includeDependencies, targetFile, layoutFile); } } } } }
Example 5
Source File: LayoutFileParser.java From JAADAS with GNU General Public License v3.0 | 4 votes |
/** * Parses the layout attributes in the given AXml node * @param layoutFile The full path and file name of the file being parsed * @param layoutClass The class for the attributes are parsed * @param rootNode The AXml node containing the attributes */ private void parseLayoutAttributes(String layoutFile, SootClass layoutClass, AXmlNode rootNode) { boolean isSensitive = false; int id = -1; for (Entry<String, AXmlAttribute<?>> entry : rootNode.getAttributes().entrySet()) { String attrName = entry.getKey().trim(); AXmlAttribute<?> attr = entry.getValue(); // On obfuscated Android malware, the attribute name may be empty if (attrName.isEmpty()) continue; // Check that we're actually working on an android attribute if (!isAndroidNamespace(attr.getNamespace())) continue; // Read out the field data if (attrName.equals("id") && (attr.getType() == AxmlVisitor.TYPE_REFERENCE || attr.getType() == AxmlVisitor.TYPE_INT_HEX)) id = (Integer) attr.getValue(); else if (attrName.equals("password")) { if (attr.getType() == AxmlVisitor.TYPE_INT_HEX) isSensitive = ((Integer) attr.getValue()) != 0; // -1 for true, 0 for false else if (attr.getType() == AxmlVisitor.TYPE_INT_BOOLEAN) isSensitive = (Boolean) attr.getValue(); else throw new RuntimeException("Unknown representation of boolean data type"); } else if (!isSensitive && attrName.equals("inputType") && attr.getType() == AxmlVisitor.TYPE_INT_HEX) { int tp = (Integer) attr.getValue(); isSensitive = ((tp & TYPE_NUMBER_VARIATION_PASSWORD) == TYPE_NUMBER_VARIATION_PASSWORD) || ((tp & TYPE_TEXT_VARIATION_PASSWORD) == TYPE_TEXT_VARIATION_PASSWORD) || ((tp & TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) == TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) || ((tp & TYPE_TEXT_VARIATION_WEB_PASSWORD) == TYPE_TEXT_VARIATION_WEB_PASSWORD); } else if (isActionListener(attrName) && attr.getType() == AxmlVisitor.TYPE_STRING && attr.getValue() instanceof String) { String strData = ((String) attr.getValue()).trim(); addCallbackMethod(layoutFile, strData); } else if (attr.getType() == AxmlVisitor.TYPE_STRING && attrName.equals("text")) { // To avoid unrecognized attribute for "text" field } else if (DEBUG && attr.getType() == AxmlVisitor.TYPE_STRING) { System.out.println("Found unrecognized XML attribute: " + attrName); } } // Register the new user control addToMapSet(this.userControls, layoutFile, new LayoutControl(id, layoutClass, isSensitive)); }