JesusFreke / smali

smali/baksmali
6.29k stars 1.07k forks source link

Thanks for your help #408

Closed dinasaif closed 8 years ago

dinasaif commented 8 years ago

Really you are Collaborator man because you really help me when I write this code: `public class DexWriterTest {

public static void main(String[] args) throws IOException  {

    DexFile dexFile = DexFileFactory.loadDexFile("classes.dex", 15);

    Set<MethodReference> calledMethods = Sets.newHashSet();

    for (ClassDef classDef: dexFile.getClasses()) {
        for (Method method: classDef.getMethods()) {
            MethodImplementation implementation = method.getImplementation();
            if (implementation != null) {
                for (Instruction instruction: implementation.getInstructions()) {
                    if (instruction.getOpcode().referenceType == ReferenceType.METHOD) {
                        calledMethods.add((MethodReference)((ReferenceInstruction)instruction).getReference());
                    }
                }
            }
        }
    }

    for (MethodReference methodReference: calledMethods) {
        System.out.println(ReferenceUtil.getReferenceString(methodReference));
    }

}

} It works fine for me and the output like this: Landroid/support/v4/widget/ViewDragHelper;->forceSettleCapturedViewAt(IIII)Z Landroid/support/v4/app/ShareCompat$IntentBuilder;->(Landroid/app/Activity;)V Landroid/support/v4/widget/DrawerLayout;->getResources()Landroid/content/res/Resources; Landroid/support/v7/app/ActionBarImplICS;->findAndRemoveMenuVisWrapper(Landroid/support/v7/app/ActionBar$OnMenuVisibilityListener;)Landroid/support/v7/app/ActionBarImplICS$OnMenuVisibilityListenerWrapper; Landroid/support/v7/internal/widget/ActionBarContextView;->setSplitWhenNarrow(Z)V Landroid/support/v7/app/ActionBarActivityDelegate;->onBackPressed()Z Landroid/view/Window;->getAttributes()Landroid/view/WindowManager$LayoutParams; Landroid/os/Process;->setThreadPriority(I)V Landroid/support/v4/net/TrafficStatsCompat$BaseTrafficStatsCompatImpl$SocketTags;->()V Landroid/support/v4/app/ListFragment;->ensureList()V Landroid/widget/OverScroller;->startScroll(IIII)V Landroid/support/v4/app/Fragment;->performActivityCreated(Landroid/os/Bundle;)V Landroid/widget/FrameLayout;->setOnLongClickListener(Landroid/view/View$OnLongClickListener;)V Landroid/support/v4/widget/SlidingPaneLayout$SavedState$1;->newArray(I)[Landroid/support/v4/widget/SlidingPaneLayout$SavedState; Landroid/support/v4/util/MapCollections$MapIterator;->getValue()Ljava/lang/Object; Ljava/util/concurrent/ExecutionException;->getCause()Ljava/lang/Throwable; Landroid/view/Menu;->addSubMenu(I)Landroid/view/SubMenu; Landroid/support/v4/app/NotificationCompat$Style;->setBuilder(Landroid/support/v4/app/NotificationCompat$Builder;)V Landroid/support/v4/view/accessibility/AccessibilityRecordCompat$AccessibilityRecordImpl;->obtain()Ljava/lang/Object; Landroid/support/v4/widget/EdgeEffectCompatIcs;->newEdgeEffect(Landroid/content/Context;)Ljava/lang/Object; Landroid/widget/PopupWindow;->setBackgroundDrawable(Landroid/graphics/drawable/Drawable;)V Landroid/support/v7/internal/view/menu/MenuItemWrapperICS;->(Landroid/view/MenuItem;)V Landroid/support/v7/internal/widget/ActionBarView$HomeView;->getParent()Landroid/view/ViewParent; Landroid/view/View$BaseSavedState;->(Landroid/os/Parcel;)V Landroid/support/v7/internal/widget/AdapterViewICS;->getTop()I Landroid/support/v7/internal/view/menu/MenuPopupHelper;->(Landroid/content/Context;Landroid/support/v7/internal/view/menu/MenuBuilder;Landroid/view/View;Z)V Landroid/support/v7/internal/view/menu/MenuItemImpl;->getAlphabeticShortcut()C Landroid/support/v7/internal/view/menu/ActionMenuPresenter;->getMenuView(Landroid/view/ViewGroup;)Landroid/support/v7/internal/view/menu/MenuView; Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V Landroid/app/Dialog;->setOwnerActivity(Landroid/app/Activity;)V Landroid/support/v4/app/FragmentActivity;->isFinishing()Z Landroid/support/v4/widget/DrawerLayout;->sendAccessibilityEvent(I)V Landroid/support/v4/view/accessibility/AccessibilityNodeInfoCompatKitKat;->setLiveRegion(Ljava/lang/Object;I)V Landroid/support/v4/view/accessibility/AccessibilityNodeProviderCompat;->findFocus(I)Landroid/support/v4/view/accessibility/AccessibilityNodeInfoCompat; Landroid/view/GestureDetector$OnGestureListener;->onScroll(Landroid/view/MotionEvent;Landroid/view/MotionEvent;FF)Z Landroid/support/v4/view/accessibility/AccessibilityRecordCompat$AccessibilityRecordImpl;->getFromIndex(Ljava/lang/Object;)I Landroid/print/PrintDocumentAdapter;->()V Landroid/support/v4/widget/ScrollerCompat$ScrollerCompatImpl;->getCurrX(Ljava/lang/Object;)I Landroid/view/View;->layout(IIII)V Landroid/os/Parcel;->writeLong(J)V Landroid/support/v7/internal/widget/ActivityChooserView;->access$900(Landroid/support/v7/internal/widget/ActivityChooserView;)I Landroid/support/v4/media/TransportMediatorCallback;->getPlaybackPosition()J Landroid/view/Window$Callback;->dispatchKeyEvent(Landroid/view/KeyEvent;)Z Landroid/support/v4/view/VelocityTrackerCompatHoneycomb;->getXVelocity(Landroid/view/VelocityTracker;I)F Landroid/widget/TextView;->setTextColor(I)V Landroid/graphics/drawable/Drawable;->setState([I)Z` How can I get api from the previous result and also suspicious api I know that I can use baksmali to get suspicious apis . Thanks again

JesusFreke commented 8 years ago

Thanks, glad you found it useful :)

dinasaif commented 8 years ago

How can I get api from the previous result and also suspicious api I know that I can use baksmali to get suspicious apis .

JesusFreke commented 8 years ago

define "suspicious apis"

dinasaif commented 8 years ago

how ? I mean the above result give me the methods name not apis I want suspicious apis also can you give me some details ?

JesusFreke commented 8 years ago

Ok, let's go up a step. Define what you mean by "API".

dinasaif commented 8 years ago

For example, chmod is a sensitive API that might be used for changing users’ permissions on files and ContentResolver;->delete is a sensitive API that might be used for deleting users’ messages or contacts

dinasaif commented 8 years ago

android. telephony.SmsManager.sendTextMessage a sensitive API that might be used for sending message

JesusFreke commented 8 years ago

ContentResolver;->delete looks like a method to me ;)

android has no public "chmod" api exposed to java, so I'm not sure what you're referring to.

android.telephony.SmsManager.sendTextMessage also looks like a method.

dinasaif commented 8 years ago

You mean that I must make it manually , define all suspicious api and search in the result

JesusFreke commented 8 years ago

well, dexlib certainly doesn't have a "getSuspiciousMethodCalls" api :)

dinasaif commented 8 years ago

ok , There isn't any other way to do that

dinasaif commented 8 years ago

Thanks , I'm really tired you with me