当前位置: 首页>>代码示例>>Java>>正文


Java AXmlNode.getAttribute方法代码示例

本文整理汇总了Java中soot.jimple.infoflow.android.axml.AXmlNode.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java AXmlNode.getAttribute方法的具体用法?Java AXmlNode.getAttribute怎么用?Java AXmlNode.getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在soot.jimple.infoflow.android.axml.AXmlNode的用法示例。


在下文中一共展示了AXmlNode.getAttribute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isComponentExported

import soot.jimple.infoflow.android.axml.AXmlNode; //导入方法依赖的package包/类
private boolean isComponentExported(AXmlNode node)
{
    boolean accessible = false;
    AXmlAttribute<?> attrEnabled = node.getAttribute("enabled");
    if (attrEnabled == null || !attrEnabled.getValue().equals(Boolean.FALSE)) {
        AXmlAttribute<?> attrExported = node.getAttribute("exported");
        if (attrExported != null){
            if(attrExported.getValue().equals(Boolean.TRUE)) {
                accessible = true;
            }
            else if(attrExported.getValue().equals(Boolean.FALSE))
            {
                accessible = false;
            }
        }
        else
        {
            if(node.getChildrenWithTag("intent-filter").size() != 0) {
                accessible = true;
            }
        }
    }
    return accessible;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:25,代码来源:ProcessManifest.java

示例2: checkAndAddComponent

import soot.jimple.infoflow.android.axml.AXmlNode; //导入方法依赖的package包/类
private void checkAndAddComponent(Set<String> entryPoints, AXmlNode node) {
	AXmlAttribute<?> attrEnabled = node.getAttribute("enabled");
	if (attrEnabled == null || !attrEnabled.getValue().equals(Boolean.FALSE)) {
		AXmlAttribute<?> attr = node.getAttribute("name");
		if (attr != null)
			entryPoints.add(expandClassName((String) attr.getValue()));
		else {
			// This component does not have a name, so this might be obfuscated
			// malware. We apply a heuristic.
			for (Entry<String, AXmlAttribute<?>> a : node.getAttributes().entrySet())
				if (a.getValue().getName().isEmpty()
						&& a.getValue().getType() == AxmlVisitor.TYPE_STRING) {
					String name = (String) a.getValue().getValue();
					if (isValidComponentName(name))
						entryPoints.add(expandClassName(name));
				}
		}
	}
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:20,代码来源:ProcessManifest.java

示例3: getPermissions

import soot.jimple.infoflow.android.axml.AXmlNode; //导入方法依赖的package包/类
/**
 * Gets the permissions this application requests
 * @return The permissions requested by this application
 * @return
 */
public Set<String> getPermissions() {
	List<AXmlNode> usesPerms = this.manifest.getChildrenWithTag("uses-permission");
	Set<String> permissions = new HashSet<String>();
	for (AXmlNode perm : usesPerms) {
		AXmlAttribute<?> attr = perm.getAttribute("name");
		if (attr != null)
			permissions.add((String) attr.getValue());
		else {
			// The required "name" attribute is missing, so we collect all empty
			// attributes as a best-effort solution for broken malware apps
			for (AXmlAttribute<?> a : perm.getAttributes().values())
				if (a.getType() == AxmlVisitor.TYPE_STRING && a.getName().isEmpty())
					permissions.add((String) a.getValue());
		}
	}
	return permissions;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:23,代码来源:ProcessManifest.java

示例4: checkPublicAccessibleCompoenent

import soot.jimple.infoflow.android.axml.AXmlNode; //导入方法依赖的package包/类
private void checkPublicAccessibleCompoenent(Set<String> entryPoints, AXmlNode node)
   {
	if (isComponentExported(node)) {
           AXmlAttribute<?> attr = node.getAttribute("name");
           if (attr != null)
               entryPoints.add(expandClassName((String) attr.getValue()));
       }
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:9,代码来源:ProcessManifest.java

示例5: getApplicationPackageName

import soot.jimple.infoflow.android.axml.AXmlNode; //导入方法依赖的package包/类
/**
 * Get the package name of the application
 * @param apkFileLocation
 * @return
 */
public static String getApplicationPackageName(String apkFileLocation) {
	String packageName = null;
	try {
		ProcessManifest pm = new ProcessManifest(apkFileLocation);
		AXmlHandler axmlh = pm.getAXml(); 
		
		// Find main activity and remove main intent-filter
		List<AXmlNode> anodes = axmlh.getNodesWithTag("manifest");
		for (AXmlNode an: anodes) {
			boolean hasMain = false;
			boolean hasLauncher = false;
			AXmlNode filter = null;
			
			AXmlAttribute aname = an.getAttribute("package");
			String aval = (String)aname.getValue();
			packageName = aval;
			System.out.println("package: "+ packageName);
			break;
			
		}
	} catch (IOException | XmlPullParserException ex) {
		System.err.println("Could not read Android manifest file: " + ex.getMessage());
		throw new RuntimeException(ex);
	}

	return packageName;
}
 
开发者ID:secure-software-engineering,项目名称:DroidForce,代码行数:33,代码来源:UpdateManifestAndCodeForWaitPDP.java

示例6: parseLayoutNode

import soot.jimple.infoflow.android.axml.AXmlNode; //导入方法依赖的package包/类
/**
 * Parses the layout file with the given root node
 * @param layoutFile The full path and file name of the file being parsed
 * @param rootNode The root node from where to start parsing
 */
private void parseLayoutNode(String layoutFile, AXmlNode rootNode) {
	if (rootNode.getTag() == null || rootNode.getTag().isEmpty()) {
		System.err.println("Encountered a null or empty node name "
				+ "in file " + layoutFile + ", skipping node...");
		return;
	}
	
	String tname = rootNode.getTag().trim();
	if (tname.equals("dummy")) {
		// dummy root node, ignore it
	}
	// Check for inclusions
	else if (tname.equals("include")) {
		parseIncludeAttributes(layoutFile, rootNode);
	}
	// The "merge" tag merges the next hierarchy level into the current
	// one for flattening hierarchies.
	else if (tname.equals("merge"))  {
		// do not consider any attributes of this elements, just
		// continue with the children
	}
	else if (tname.equals("fragment"))  {
		final AXmlAttribute<?> attr = rootNode.getAttribute("name");
		if (attr == null)
			System.err.println("Fragment without class name detected");
		else {
			if (attr.getType() != AxmlVisitor.TYPE_STRING)
				System.err.println("Invalid targer resource "+attr.getValue()+"for fragment class value");
			getLayoutClass(attr.getValue().toString());
		}
	}
	else {
		final SootClass childClass = getLayoutClass(tname);
		if (childClass != null && (isLayoutClass(childClass) || isViewClass(childClass)))
			parseLayoutAttributes(layoutFile, childClass, rootNode);
	}

	// Parse the child nodes
	for (AXmlNode childNode : rootNode.getChildren())
		parseLayoutNode(layoutFile, childNode);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:47,代码来源:LayoutFileParser.java

示例7: getMainActivityName

import soot.jimple.infoflow.android.axml.AXmlNode; //导入方法依赖的package包/类
/**
 * Get the name of the main activity in the AndroidManifest.xml file
 * @param apkFileLocation
 * @return
 */
public static String getMainActivityName(String apkFileLocation) {
	String mainActivityName = null;
	try {
		ProcessManifest pm = new ProcessManifest(apkFileLocation);
		AXmlHandler axmlh = pm.getAXml(); 
		
		// Find main activity and remove main intent-filter
		List<AXmlNode> anodes = axmlh.getNodesWithTag("activity");
		for (AXmlNode an: anodes) {
			boolean hasMain = false;
			boolean hasLauncher = false;
			AXmlNode filter = null;
			
			AXmlAttribute aname = an.getAttribute("name");
			String aval = (String)aname.getValue();
			System.out.println("activity: "+ aval);
			for (AXmlNode ch : an.getChildren()) {
				System.out.println("children: "+ ch);
			}
			List<AXmlNode> fnodes = an.getChildrenWithTag("intent-filter");
			for (AXmlNode fn: fnodes) {
				
				hasMain = false;
				hasLauncher = false;
				
				// check action
				List<AXmlNode> acnodes = fn.getChildrenWithTag("action");
				for (AXmlNode acn: acnodes) {
					AXmlAttribute acname = acn.getAttribute("name");
					String acval = (String)acname.getValue();
					System.out.println("action: "+ acval);
					if (acval.equals("android.intent.action.MAIN")) {
						hasMain = true;
					}
				}
				// check category
				List<AXmlNode> catnodes = fn.getChildrenWithTag("category");
				for (AXmlNode catn: catnodes) {
					AXmlAttribute catname = catn.getAttribute("name");
					String catval = (String)catname.getValue();
					System.out.println("category: "+ catval);
					if (catval.equals("android.intent.category.LAUNCHER")) {
						hasLauncher = true;
						filter = fn;
					}
				}
				if (hasLauncher && hasMain) {
					break;
				}
			}
			
			if (hasLauncher && hasMain) {
				// replace name with the activity waiting for the connection to the PDP
				System.out.println("main activity is: "+ aval);
				System.out.println("excluding filter: "+ filter);
				filter.exclude();
				mainActivityName = aval;
				break;
			}
			
		}
	} catch (IOException | XmlPullParserException ex) {
		System.err.println("Could not read Android manifest file: " + ex.getMessage());
		throw new RuntimeException(ex);
	}

	return mainActivityName;
}
 
开发者ID:secure-software-engineering,项目名称:DroidForce,代码行数:74,代码来源:UpdateManifestAndCodeForWaitPDP.java


注:本文中的soot.jimple.infoflow.android.axml.AXmlNode.getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。