Skip to content

Instantly share code, notes, and snippets.

@yonixw
Created October 27, 2019 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yonixw/b0f0aee40d77cdb21cf590453538d6ac to your computer and use it in GitHub Desktop.
Save yonixw/b0f0aee40d77cdb21cf590453538d6ac to your computer and use it in GitHub Desktop.
spin to localhost

access$700 will add the domain to cache. By removing it we will make each navigation query our local server. Also Im afraid to put there full url which will create bugs.

@@ -221,7 +221,7 @@

     iget-object v1, v1, Lorg/mozilla/gecko/TabGuardManager$2;->val$domainName:Ljava/lang/String;

-    invoke-static {v0, v1}, Lorg/mozilla/gecko/TabGuardManager;->access$700(Lorg/mozilla/gecko/TabGuardManager;Ljava/lang/String;)V
+    #invoke-static {v0, v1}, Lorg/mozilla/gecko/TabGuardManager;->access$700(Lorg/mozilla/gecko/TabGuardManager;Ljava/lang/String;)V
     :try_end_0
     .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0

Moving checking EP to localhost (v3 is port in hex)

@@ -63,16 +63,19 @@
     .line 508
     new-instance v1, Lch/boye/httpclientandroidlib/HttpHost;

-    const-string v2, "www.vionika.com"
+    #const-string v2, "www.vionika.com"
+    const-string v2, "localhost"

-    const/16 v3, 0x50
+    #const/16 v3, 0x50
+    const/16 v3, 0x1F40

     invoke-direct {v1, v2, v3}, Lch/boye/httpclientandroidlib/HttpHost;-><init>(Ljava/lang/String;I)V

     .line 510
     new-instance v2, Lch/boye/httpclientandroidlib/client/methods/HttpPost;

-    const-string v3, "http://www.vionika.com/services/examine/domain"
+#    const-string v3, "http://www.vionika.com/services/examine/domain"
+    const-string v3, "http://localhost:8000/check"

Delete the catch. Now if the localhost server is down (or bugging) each query will crash the app (on navigation). So default is to crash unless we get valid JSON response.

@@ -145,7 +148,7 @@

     invoke-virtual {v0, v1, v2, v3}, Lch/boye/httpclientandroidlib/impl/client/DefaultHttpClient;->execute(Lch/boye/httpclientandroidlib/HttpHost;Lch/boye/httpclientandroidlib/HttpRequest;Lch/boye/httpclientandroidlib/client/ResponseHandler;)Ljava/lang/Object;
     :try_end_1
-    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0
+# Fail if not online    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0
     .catch Ljava/security/KeyManagementException; {:try_start_1 .. :try_end_1} :catch_3
     .catch Ljava/security/NoSuchAlgorithmException; {:try_start_1 .. :try_end_1} :catch_2
     .catch Ljava/io/UnsupportedEncodingException; {:try_start_1 .. :try_end_1} :catch_1

Send the full url to the server and not just the domain (v1 = getDomain(p1))

@@ -2131,7 +2131,7 @@

     .line 183
     :cond_7
-    invoke-direct {p0, p1, v1, p2}, Lorg/mozilla/gecko/TabGuardManager;->categorizeDomain(Ljava/lang/String;Ljava/lang/String;Lorg/mozilla/gecko/TabGuardManager$TabProhibitedKillAction;)V
+    invoke-direct {p0, p1, p1, p2}, Lorg/mozilla/gecko/TabGuardManager;->categorizeDomain(Ljava/lang/String;Ljava/lang/String;Lorg/mozilla/gecko/TabGuardManager$TabProhibitedKillAction;)V

     return v2
 .end method
@yonixw
Copy link
Author

yonixw commented Oct 27, 2019

Reversed flow:

Guard$2 calls HTTP for categories
Guard$2$1 is the response listener
    on response:
        if Guard.access$600 processDomainCategories -> Block tab (navigate) if category is bad (like p-rn)
            then Guard.access$700 addCheckedDomain

tab.handleDocumentStart 
    -> tabGuardManager.isAllowedToOpen(url)
    -> break url to domains using 
            UrlSafetyHelper.findEmbeddedUrls(url) +  getDomainName() // find embed in params.
        -> check allowed  + already checked list (domain) from access$700
        categorizeDomain
        -> $2 (async but each tab has its own guard as seen in Tab class, so just close my owner)
            only alloweddomains (whitelist?) are static

@yonixw
Copy link
Author

yonixw commented Nov 24, 2019

TabGuardManager.smali
const-string v0, "https://www.spinbrowse.com/blocked/?domain=%s&category=%d&managed=%s&url=%s"

UrlSafetyHelper.smali
const-string v0, "http://www.spinbrowse.com/blocked/?domain=%s&category=%d&managed=%s&url=%s"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment