monkeyWie / proxyee

HTTP proxy server,support HTTPS&websocket.MITM impl,intercept and tamper HTTPS traffic.
MIT License
1.52k stars 567 forks source link

Application becomes unresponsive. #107

Closed Rich2020 closed 3 years ago

Rich2020 commented 3 years ago

Testing on a MacBook Pro, running macOS Catalina 10.15.6 (19G2021). Gradle project.

I created a default Android app, imported Proxee, and hit run. However, when I start Proxee, the app becomes unresponsive and then crashes after a while. There is no Logcat or terminal crash information.

I only created a single function proxee() in my test application, which is called when a button is pressed. I tried to intercept all traffic by modifying the Baidu URL in the example. I have also tried with the default port of 9999 as well as 8080. Here is the proxee function:

 public void proxee(){
        HttpProxyServerConfig config =  new HttpProxyServerConfig();

//enable HTTPS support
//If not enabled, HTTPS will not be intercepted, but forwarded directly to the raw packet.
        config.setHandleSsl(true);
        new HttpProxyServer()
                .serverConfig(config)
                .proxyInterceptInitializer(new HttpProxyInterceptInitializer() {
                    @Override
                    public void init(HttpProxyInterceptPipeline pipeline) {
                        pipeline.addLast(new FullResponseIntercept() {
                            @Override
                            public boolean match(HttpRequest httpRequest, HttpResponse httpResponse, HttpProxyInterceptPipeline pipeline) {
                                //Insert js when matching to Baidu homepage
                                return HttpUtil.checkUrl(pipeline.getHttpRequest(), "^$")
                                        && isHtml(httpRequest, httpResponse);
                            }

                            @Override
                            public void handleResponse(HttpRequest httpRequest, FullHttpResponse httpResponse, HttpProxyInterceptPipeline pipeline) {
                                super.handleResponse(httpRequest, httpResponse, pipeline);
                                System.out.println(httpResponse.toString());
                                System.out.println(httpResponse.content().toString(Charset.defaultCharset()));
                                //Edit response header and response body
                                httpResponse.headers().set("handel", "edit head");
                                httpResponse.content().writeBytes("<script>alert('hello proxyee')</script>".getBytes());

                            }
                        });
                    }
                })
                .start(8080);
    }

Here is all the Logcat output:

2020-10-30 15:12:43.095 15999-15999/? E/Zygote: isWhitelistProcess - Process is Whitelisted
2020-10-30 15:12:43.097 15999-15999/? E/Zygote: accessInfo : 1
2020-10-30 15:12:43.121 15999-15999/? I/ridge.proxeeap: Late-enabling -Xcheck:jni
2020-10-30 15:12:43.150 15999-15999/? E/ridge.proxeeap: Unknown bits set in runtime_flags: 0x8000
2020-10-30 15:12:43.165 15999-15999/? D/ActivityThread: setConscryptValidator
2020-10-30 15:12:43.165 15999-15999/? D/ActivityThread: setConscryptValidator - put
2020-10-30 15:12:43.847 15999-15999/com.defaultcompany.proxeeapp D/PhoneWindow: forceLight changed to true [] from com.android.internal.policy.PhoneWindow.updateForceLightNavigationBar:4268 com.android.internal.policy.DecorView.updateColorViews:1513 com.android.internal.policy.PhoneWindow.dispatchWindowAttributesChanged:3246 android.view.Window.setFlags:1148 com.android.internal.policy.PhoneWindow.generateLayout:2474 
2020-10-30 15:12:43.848 15999-15999/com.defaultcompany.proxeeapp I/MultiWindowDecorSupport: updateCaptionType >> DecorView@f71deb3[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true
2020-10-30 15:12:43.848 15999-15999/com.defaultcompany.proxeeapp D/MultiWindowDecorSupport: setCaptionType = 0, DecorView = DecorView@f71deb3[]
2020-10-30 15:12:43.873 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2020-10-30 15:12:43.874 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2020-10-30 15:12:44.073 15999-15999/com.defaultcompany.proxeeapp D/ViewRootImpl@30b76b2[MainActivity]: setView = com.android.internal.policy.DecorView@f71deb3 TM=true MM=false
2020-10-30 15:12:44.122 15999-15999/com.defaultcompany.proxeeapp D/ViewRootImpl@30b76b2[MainActivity]: Relayout returned: old=(0,0,1600,2560) new=(0,0,1600,2560) req=(1600,2560)0 dur=8 res=0x7 s={true 532673523712} ch=true
2020-10-30 15:12:44.122 15999-16120/com.defaultcompany.proxeeapp D/OpenGLRenderer: createReliableSurface : 0x7c05d89e80(0x7c05d0f000)
2020-10-30 15:12:44.123 15999-16120/com.defaultcompany.proxeeapp I/AdrenoGLES: QUALCOMM build                   : a2b3e74, I72742cdabd
    Build Date                       : 12/11/19
    OpenGL ES Shader Compiler Version: EV031.27.05.01
    Local Branch                     : 
    Remote Branch                    : refs/tags/AU_LINUX_ANDROID_LA.UM.8.8.R1.10.00.00.545.051
    Remote Branch                    : NONE
    Reconstruct Branch               : NOTHING
2020-10-30 15:12:44.123 15999-16120/com.defaultcompany.proxeeapp I/AdrenoGLES: Build Config                     : S P 8.0.11 AArch64
2020-10-30 15:12:44.126 15999-16120/com.defaultcompany.proxeeapp I/AdrenoGLES: PFP: 0x016ee187, ME: 0x00000000
2020-10-30 15:12:44.137 15999-16120/com.defaultcompany.proxeeapp D/OpenGLRenderer: makeCurrent EglSurface : 0x0 -> 0x0
2020-10-30 15:12:44.152 15999-16120/com.defaultcompany.proxeeapp D/OpenGLRenderer: makeCurrent EglSurface : 0x0 -> 0x7b69ef7380
2020-10-30 15:12:44.156 15999-16120/com.defaultcompany.proxeeapp W/Gralloc3: mapper 3.x is not supported
2020-10-30 15:12:44.364 15999-15999/com.defaultcompany.proxeeapp D/ViewRootImpl@30b76b2[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1
2020-10-30 15:12:44.364 15999-15999/com.defaultcompany.proxeeapp D/InputMethodManager: prepareNavigationBarInfo() DecorView@f71deb3[MainActivity]
2020-10-30 15:12:44.364 15999-15999/com.defaultcompany.proxeeapp D/InputMethodManager: getNavigationBarColor() -855310
2020-10-30 15:12:44.367 15999-15999/com.defaultcompany.proxeeapp D/InputMethodManager: prepareNavigationBarInfo() DecorView@f71deb3[MainActivity]
2020-10-30 15:12:44.367 15999-15999/com.defaultcompany.proxeeapp D/InputMethodManager: getNavigationBarColor() -855310
2020-10-30 15:12:44.367 15999-15999/com.defaultcompany.proxeeapp V/InputMethodManager: Starting input: tba=com.defaultcompany.proxeeapp ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
2020-10-30 15:12:44.367 15999-15999/com.defaultcompany.proxeeapp D/InputMethodManager: startInputInner - Id : 0
2020-10-30 15:12:44.367 15999-15999/com.defaultcompany.proxeeapp I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
2020-10-30 15:12:44.370 15999-15999/com.defaultcompany.proxeeapp D/ViewRootImpl@30b76b2[MainActivity]: MSG_RESIZED: frame=(0,0,1600,2560) ci=(0,54,0,108) vi=(0,54,0,108) or=1
2020-10-30 15:12:44.386 15999-15999/com.defaultcompany.proxeeapp D/InputMethodManager: prepareNavigationBarInfo() DecorView@f71deb3[MainActivity]
2020-10-30 15:12:44.386 15999-15999/com.defaultcompany.proxeeapp D/InputMethodManager: getNavigationBarColor() -855310
2020-10-30 15:12:44.387 15999-15999/com.defaultcompany.proxeeapp V/InputMethodManager: Starting input: tba=com.defaultcompany.proxeeapp ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
2020-10-30 15:12:44.387 15999-15999/com.defaultcompany.proxeeapp D/InputMethodManager: startInputInner - Id : 0
2020-10-30 15:12:46.173 15999-15999/com.defaultcompany.proxeeapp D/ViewRootImpl@30b76b2[MainActivity]: ViewPostIme pointer 0
2020-10-30 15:12:46.341 15999-15999/com.defaultcompany.proxeeapp D/ViewRootImpl@30b76b2[MainActivity]: ViewPostIme pointer 1
2020-10-30 15:12:46.417 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->arrayIndexScale(Ljava/lang/Class;)I (greylist, linking, allowed)
2020-10-30 15:12:46.418 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->allocateMemory(J)J (greylist, linking, allowed)
2020-10-30 15:12:46.418 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->freeMemory(J)V (greylist, linking, allowed)
2020-10-30 15:12:46.418 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->arrayBaseOffset(Ljava/lang/Class;)I (greylist,core-platform-api, linking, allowed)
2020-10-30 15:12:46.418 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->addressSize()I (greylist, linking, allowed)
2020-10-30 15:12:46.418 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->copyMemory(JJJ)V (greylist, linking, allowed)
2020-10-30 15:12:46.419 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
2020-10-30 15:12:46.419 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
2020-10-30 15:12:46.419 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->getChar(Ljava/lang/Object;J)C (greylist, linking, allowed)
2020-10-30 15:12:46.419 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->getByte(Ljava/lang/Object;J)B (greylist,core-platform-api, linking, allowed)
2020-10-30 15:12:46.419 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->getByte(J)B (greylist,core-platform-api, linking, allowed)
2020-10-30 15:12:46.419 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->getInt(J)I (greylist, linking, allowed)
2020-10-30 15:12:46.419 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
2020-10-30 15:12:46.419 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->getLong(J)J (greylist,core-platform-api, linking, allowed)
2020-10-30 15:12:46.419 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
2020-10-30 15:12:46.419 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->getShort(J)S (greylist, linking, allowed)
2020-10-30 15:12:46.419 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->getShort(Ljava/lang/Object;J)S (greylist, linking, allowed)
2020-10-30 15:12:46.420 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
2020-10-30 15:12:46.420 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
2020-10-30 15:12:46.420 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->putByte(JB)V (greylist,core-platform-api, linking, allowed)
2020-10-30 15:12:46.420 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->putByte(Ljava/lang/Object;JB)V (greylist,core-platform-api, linking, allowed)
2020-10-30 15:12:46.420 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->putInt(JI)V (greylist, linking, allowed)
2020-10-30 15:12:46.420 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
2020-10-30 15:12:46.420 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->putLong(JJ)V (greylist, linking, allowed)
2020-10-30 15:12:46.420 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
2020-10-30 15:12:46.420 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
2020-10-30 15:12:46.420 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->putShort(JS)V (greylist, linking, allowed)
2020-10-30 15:12:46.420 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->putShort(Ljava/lang/Object;JS)V (greylist, linking, allowed)
2020-10-30 15:12:46.420 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/Unsafe;->setMemory(JJB)V (greylist, linking, allowed)
2020-10-30 15:12:46.421 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden field Lsun/misc/Unsafe;->theUnsafe:Lsun/misc/Unsafe; (greylist, reflection, allowed)
2020-10-30 15:12:46.422 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lsun/misc/VM;->maxDirectMemory()J (greylist, reflection, allowed)
2020-10-30 15:12:46.425 15999-15999/com.defaultcompany.proxeeapp I/PlatformDependent: Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system instability.
2020-10-30 15:12:46.453 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden field Lsun/nio/ch/SelectorImpl;->selectedKeys:Ljava/util/Set; (greylist, reflection, allowed)
2020-10-30 15:12:46.453 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden field Lsun/nio/ch/SelectorImpl;->publicSelectedKeys:Ljava/util/Set; (greylist, reflection, allowed)
2020-10-30 15:12:46.495 15999-15999/com.defaultcompany.proxeeapp D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2020-10-30 15:12:46.576 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLProvider;-><init>()V (greylist,core-platform-api, reflection, allowed)
2020-10-30 15:12:46.577 15999-15999/com.defaultcompany.proxeeapp W/ridge.proxeeap: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLRandom;-><init>()V (greylist, reflection, allowed)
2020-10-30 15:13:00.879 15999-16031/com.defaultcompany.proxeeapp I/ridge.proxeeap: Thread[7,tid=16031,WaitingInMainSignalCatcherLoop,Thread*=0x7c05dfe000,peer=0x141c00a8,"Signal Catcher"]: reacting to signal 3
2020-10-30 15:13:01.014 15999-16031/com.defaultcompany.proxeeapp I/ridge.proxeeap: Wrote stack traces to tombstoned
monkeyWie commented 3 years ago

Maybe you can start proxyee server on a new thread, unresponsive is because starting the service will block the UI thread.

LamGC commented 3 years ago

@Rich2020 Calling the start() method will block the main activity thread, which will lead to ANR. To solve this problem, you need to use service and start a separate thread to start the server.

LamGC commented 3 years ago

In other words, the 'start()' method is a blocking method, which blocks the thread until the server stops.

Rich2020 commented 3 years ago

Hi guys, thanks - I guess I assumed Proxee would start itself on a new thread and not be something I'd need to do.