Skip to content

Commit

Permalink
parse processes in android-tools.apk
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-black-tea committed May 3, 2023
1 parent 9ba7c1a commit 53f7cf5
Show file tree
Hide file tree
Showing 26 changed files with 322 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import android.text.TextUtils;

@SuppressWarnings({"rawtypes", "unchecked"})
public class FActivity extends FComponent {
public class Activity extends Component {

public FPermission permission;
public Permission permission;

public FActivity(PackageParser.Activity activity) {
public Activity(PackageParser.Activity activity) {
super(activity, activity.info);
if (!TextUtils.isEmpty(activity.info.permission)) {
permission = new FPermission(activity.info.permission);
permission = new Permission(activity.info.permission);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
import java.util.ArrayList;
import java.util.List;

public class FComponent<II extends PackageParser.IntentInfo> {
public class Component<II extends PackageParser.IntentInfo> {

public String name;
public boolean exported;
public boolean enabled;
public List<FIntentFilter> intents;
public List<IntentFilter> intents;

@SuppressLint("SwitchIntDef")
public FComponent(PackageParser.Component<II> component, ComponentInfo info) {
public Component(PackageParser.Component<II> component, ComponentInfo info) {
PackageManager packageManager = Environment.getPackageManager();
ComponentName componentName = component.getComponentName();

Expand All @@ -43,7 +43,7 @@ public FComponent(PackageParser.Component<II> component, ComponentInfo info) {
if (component.intents != null && component.intents.size() > 0) {
intents = new ArrayList<>(component.intents.size());
for (II intent : component.intents) {
intents.add(new FIntentFilter(intent));
intents.add(new IntentFilter(intent));
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
package org.ironman.framework.bean.app;

import android.content.IntentFilter;
import android.os.Build;
import android.os.PatternMatcher;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class FIntentFilter {
public class IntentFilter {

public List<String> actions;
public List<String> categories;
public List<String> dataSchemes;
public List<FPatternMatcher> dataSchemeSpecificParts;
public List<FIntentFilter.AuthorityEntry> dataAuthorities;
public List<FPatternMatcher> dataPaths;
public List<PatternMatcher> dataSchemeSpecificParts;
public List<IntentFilter.AuthorityEntry> dataAuthorities;
public List<PatternMatcher> dataPaths;
public List<String> dataTypes;

public FIntentFilter(IntentFilter intent) {
public IntentFilter(android.content.IntentFilter intent) {
if (intent.countActions() > 0) {
actions = new ArrayList<>(intent.countActions());
Iterator<String> it = intent.actionsIterator();
Expand Down Expand Up @@ -46,26 +44,26 @@ public FIntentFilter(IntentFilter intent) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (intent.countDataSchemeSpecificParts() > 0) {
dataSchemeSpecificParts = new ArrayList<>(intent.countDataSchemeSpecificParts());
Iterator<PatternMatcher> it = intent.schemeSpecificPartsIterator();
Iterator<android.os.PatternMatcher> it = intent.schemeSpecificPartsIterator();
while (it.hasNext()) {
dataSchemeSpecificParts.add(new FPatternMatcher(it.next()));
dataSchemeSpecificParts.add(new PatternMatcher(it.next()));
}
}
}

if (intent.countDataAuthorities() > 0) {
dataAuthorities = new ArrayList<>(intent.countDataAuthorities());
Iterator<IntentFilter.AuthorityEntry> it = intent.authoritiesIterator();
Iterator<android.content.IntentFilter.AuthorityEntry> it = intent.authoritiesIterator();
while (it.hasNext()) {
dataAuthorities.add(new AuthorityEntry(it.next()));
}
}

if (intent.countDataPaths() > 0) {
dataPaths = new ArrayList<>(intent.countDataPaths());
Iterator<PatternMatcher> it = intent.pathsIterator();
Iterator<android.os.PatternMatcher> it = intent.pathsIterator();
while (it.hasNext()) {
dataPaths.add(new FPatternMatcher(it.next()));
dataPaths.add(new PatternMatcher(it.next()));
}
}

Expand All @@ -84,7 +82,7 @@ public static class AuthorityEntry {
public String host;
public int port;

public AuthorityEntry(IntentFilter.AuthorityEntry authority) {
public AuthorityEntry(android.content.IntentFilter.AuthorityEntry authority) {
host = authority.getHost();
port = authority.getPort();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* Created by hu on 18-12-29.
*/

public class FPackage {
public class Package {

private static final String TAG = FPackage.class.getSimpleName();
private static final String TAG = Package.class.getSimpleName();

public String name;
public String appName;
Expand All @@ -30,18 +30,18 @@ public class FPackage {
public boolean debuggable;
public boolean allowBackup;

public List<FPermission> requestedPermissions;
public List<FPermission> permissions;
public List<FActivity> activities;
public List<FService> services;
public List<FReceiver> receivers;
public List<FProvider> providers;
public List<Permission> requestedPermissions;
public List<Permission> permissions;
public List<Activity> activities;
public List<Service> services;
public List<Receiver> receivers;
public List<Provider> providers;

public FPackage(PackageInfo info) {
public Package(PackageInfo info) {
this(info, true);
}

public FPackage(PackageInfo info, boolean skipParse) {
public Package(PackageInfo info, boolean skipParse) {
name = info.packageName;
appName = PackageUtil.getApplicationName(info);
userId = info.applicationInfo.uid;
Expand All @@ -67,42 +67,42 @@ public FPackage(PackageInfo info, boolean skipParse) {
if (pkg.requestedPermissions != null && pkg.requestedPermissions.size() > 0) {
requestedPermissions = new ArrayList<>(pkg.requestedPermissions.size());
for (String permission : pkg.requestedPermissions) {
requestedPermissions.add(new FPermission(permission));
requestedPermissions.add(new Permission(permission));
}
}

if (pkg.permissions != null && pkg.permissions.size() > 0) {
permissions = new ArrayList<>(pkg.permissions.size());
for (PackageParser.Permission p : pkg.permissions) {
permissions.add(new FPermission(p.info.name));
permissions.add(new Permission(p.info.name));
}
}

if (pkg.activities != null && pkg.activities.size() > 0) {
activities = new ArrayList<>(pkg.activities.size());
for (PackageParser.Activity a : pkg.activities) {
activities.add(new FActivity(a));
activities.add(new Activity(a));
}
}

if (pkg.services != null && pkg.services.size() > 0) {
services = new ArrayList<>(pkg.services.size());
for (PackageParser.Service s : pkg.services) {
services.add(new FService(s));
services.add(new Service(s));
}
}

if (pkg.receivers != null && pkg.receivers.size() > 0) {
receivers = new ArrayList<>(pkg.receivers.size());
for (PackageParser.Activity r : pkg.receivers) {
receivers.add(new FReceiver(r));
receivers.add(new Receiver(r));
}
}

if (pkg.providers != null && pkg.providers.size() > 0) {
providers = new ArrayList<>(pkg.providers.size());
for (PackageParser.Provider p : pkg.providers) {
providers.add(new FProvider(p));
providers.add(new Provider(p));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.ironman.framework.bean.app;


public class PathPermission extends PatternMatcher {

public Permission readPermission;
public Permission writePermission;

public PathPermission(android.content.pm.PathPermission pathPermission) {
super(pathPermission);
readPermission = new Permission(pathPermission.getReadPermission());
writePermission = new Permission(pathPermission.getWritePermission());
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.ironman.framework.bean.app;

import android.os.PatternMatcher;

public class FPatternMatcher {
public class PatternMatcher {

public enum Type {
literal,
Expand All @@ -14,7 +12,7 @@ public enum Type {
public String path;
public Type type;

public FPatternMatcher(PatternMatcher patternMatcher) {
public PatternMatcher(android.os.PatternMatcher patternMatcher) {
path = patternMatcher.getPath();
type = getType(patternMatcher.getType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import org.ironman.framework.util.PermissionUtil;

public class FPermission {
public class Permission {

public enum Protection {
dangerous,
Expand All @@ -16,12 +16,12 @@ public enum Protection {
public String name;
public Protection protection;

public FPermission(String name) {
public Permission(String name) {
this.name = name;
this.protection = PermissionUtil.getProtection(name);
}

public FPermission(PackageParser.Permission perm) {
public Permission(PackageParser.Permission perm) {
this.name = perm.info.name;
this.protection = PermissionUtil.getProtection(perm.info);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@
import java.util.List;

@SuppressWarnings({"rawtypes", "unchecked"})
public class FProvider extends FComponent {
public class Provider extends Component {

public String authority;
public FPermission readPermission;
public FPermission writePermission;
public List<FPatternMatcher> uriPermissionPatterns;
public List<FPathPermission> pathPermissions;
public Permission readPermission;
public Permission writePermission;
public List<PatternMatcher> uriPermissionPatterns;
public List<PathPermission> pathPermissions;

public FProvider(PackageParser.Provider provider) {
public Provider(PackageParser.Provider provider) {
super(provider, provider.info);

authority = provider.info.authority;
if (!TextUtils.isEmpty(provider.info.readPermission)) {
readPermission = new FPermission(provider.info.readPermission);
readPermission = new Permission(provider.info.readPermission);
}
if (!TextUtils.isEmpty(provider.info.writePermission)) {
writePermission = new FPermission(provider.info.writePermission);
writePermission = new Permission(provider.info.writePermission);
}
if (provider.info.uriPermissionPatterns != null) {
uriPermissionPatterns = new ArrayList<>(provider.info.uriPermissionPatterns.length);
for (android.os.PatternMatcher uriPermissionPattern : provider.info.uriPermissionPatterns) {
uriPermissionPatterns.add(new FPatternMatcher(uriPermissionPattern));
uriPermissionPatterns.add(new PatternMatcher(uriPermissionPattern));
}
}
if (provider.info.pathPermissions != null) {
pathPermissions = new ArrayList<>(provider.info.pathPermissions.length);
for (android.content.pm.PathPermission pathPermission : provider.info.pathPermissions) {
pathPermissions.add(new FPathPermission(pathPermission));
pathPermissions.add(new PathPermission(pathPermission));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import android.text.TextUtils;

@SuppressWarnings({"rawtypes", "unchecked"})
public class FReceiver extends FComponent {
public class Receiver extends Component {

public FPermission permission;
public Permission permission;

public FReceiver(PackageParser.Activity receiver) {
public Receiver(PackageParser.Activity receiver) {
super(receiver, receiver.info);
if (!TextUtils.isEmpty(receiver.info.permission)) {
permission = new FPermission(receiver.info.permission);
permission = new Permission(receiver.info.permission);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import android.text.TextUtils;

@SuppressWarnings({"rawtypes", "unchecked"})
public class FService extends FComponent {
public class Service extends Component {

public FPermission permission;
public Permission permission;

public FService(PackageParser.Service service) {
public Service(PackageParser.Service service) {
super(service, service.info);
if (!TextUtils.isEmpty(service.info.permission)) {
permission = new FPermission(service.info.permission);
permission = new Permission(service.info.permission);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.ironman.framework.bean.net;

public class FInetSocket extends FSocket {
public class InetSocket extends Socket {

public String localAddress;
public int localPort;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.ironman.framework.bean.net;

public class FSocket {
public class Socket {
public String proto;
public String state;
public long inode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created by hu on 19-2-13.
*/

public class FUnixSocket extends FSocket {
public class UnixSocket extends Socket {
public long refCnt;
public String flags;
public String type;
Expand Down
Loading

0 comments on commit 53f7cf5

Please sign in to comment.