diff --git a/app/build.gradle b/app/build.gradle index bada4cc6..70b724d4 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -139,6 +139,7 @@ dependencies { implementation 'com.google.android.material:material:1.5.0' implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation 'com.google.android.gms:play-services-ads:20.5.0' + implementation group: 'com.macasaet.fernet', name: 'fernet-java8', version: '1.4.2' } /* Automated APK Generation */ diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoSession.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoSession.java index 283579f1..58b77846 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoSession.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoSession.java @@ -29,7 +29,6 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.NotificationCompat; import androidx.core.content.FileProvider; -import com.darkweb.genesissearchengine.appManager.homeManager.homeController.homeController; import com.darkweb.genesissearchengine.constants.constants; import com.darkweb.genesissearchengine.constants.enums; import com.darkweb.genesissearchengine.constants.keys; @@ -38,7 +37,7 @@ import com.darkweb.genesissearchengine.constants.strings; import com.darkweb.genesissearchengine.dataManager.dataEnums; import com.darkweb.genesissearchengine.eventObserver; import com.darkweb.genesissearchengine.helperManager.helperMethod; -import com.darkweb.genesissearchengine.libs.trueTime.trueTime; +import com.darkweb.genesissearchengine.libs.trueTime.trueTimeEncryption; import com.darkweb.genesissearchengine.pluginManager.pluginController; import com.darkweb.genesissearchengine.pluginManager.pluginEnums; import com.example.myapplication.R; @@ -63,14 +62,12 @@ import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.lang.ref.WeakReference; -import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Objects; -import javax.crypto.spec.SecretKeySpec; import static com.darkweb.genesissearchengine.constants.constants.CONST_GENESIS_ERROR_CACHED; import static com.darkweb.genesissearchengine.constants.constants.CONST_GENESIS_ERROR_CACHED_DARK; @@ -79,9 +76,7 @@ import static com.darkweb.genesissearchengine.constants.constants.CONST_GENESIS_ import static com.darkweb.genesissearchengine.constants.constants.CONST_GENESIS_URL_CACHED; import static com.darkweb.genesissearchengine.constants.constants.CONST_GENESIS_URL_CACHED_DARK; import static com.darkweb.genesissearchengine.constants.enums.etype.M_DEFAULT_BROWSER; -import static com.darkweb.genesissearchengine.constants.enums.etype.M_NEW_LINK_IN_NEW_TAB; import static com.darkweb.genesissearchengine.constants.enums.etype.M_RATE_COUNT; -import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManager.M_APPLICATION_CRASH; import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManager.M_LONG_PRESS_URL; import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManager.M_LONG_PRESS_WITH_LINK; import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManagerCallbacks.M_RATE_APPLICATION; @@ -538,8 +533,7 @@ geckoSession extends GeckoSession implements GeckoSession.MediaDelegate,GeckoSes private String setGenesisVerificationToken(String pString){ try{ Uri built = Uri.parse(pString).buildUpon() - .appendQueryParameter(constants.CONST_GENESIS_GMT_TIME_GET_KEY, URLEncoder.encode(helperMethod.caesarCipherEncrypt(trueTime.getInstance().getGMT(),new SecretKeySpec(constants.CONST_ENCRYPTION_KEY.getBytes(), "AES")), "utf-8")) - .appendQueryParameter(constants.CONST_GENESIS_LOCAL_TIME_GET_KEY, URLEncoder.encode(helperMethod.caesarCipherEncrypt(trueTime.getInstance().getLTZ(),new SecretKeySpec(constants.CONST_ENCRYPTION_KEY.getBytes(), "AES")), "utf-8")) + .appendQueryParameter(constants.CONST_GENESIS_GMT_TIME_GET_KEY, trueTimeEncryption.getInstance().getSecretToken()) .build(); return built.toString(); }catch (Exception ex){ @@ -554,7 +548,7 @@ geckoSession extends GeckoSession implements GeckoSession.MediaDelegate,GeckoSes event.invokeObserver(Arrays.asList(mCurrentURL,mSessionID,mCurrentTitle, mTheme), enums.etype.M_NEW_IDENTITY_MESSAGED); return GeckoResult.fromValue(AllowOrDeny.DENY); } - if(!var1.uri.startsWith(CONST_GENESIS_URL_CACHED) && !var1.uri.startsWith(CONST_GENESIS_URL_CACHED_DARK) && var1.uri.startsWith("https://trcip42ymcgvv5hsa7nxpwdnott46ebomnn5pm5lovg5hpszyo4n35yd.onion") && !var1.uri.contains(constants.CONST_GENESIS_LOCAL_TIME_GET_KEY) && !var1.uri.contains(constants.CONST_GENESIS_LOCAL_TIME_GET_KEY)){ + if(!var1.uri.contains(constants.CONST_GENESIS_GMT_TIME_GET_KEY) && !var1.uri.startsWith(CONST_GENESIS_URL_CACHED) && !var1.uri.startsWith(CONST_GENESIS_URL_CACHED_DARK) && var1.uri.startsWith("http://trcip42ymcgvv5hsa7nxpwdnott46ebomnn5pm5lovg5hpszyo4n35yd.onion") && !var1.uri.contains(constants.CONST_GENESIS_LOCAL_TIME_GET_KEY) && !var1.uri.contains(constants.CONST_GENESIS_LOCAL_TIME_GET_KEY)){ String mVerificationURL = setGenesisVerificationToken(var1.uri); initURL(mVerificationURL); loadUri(mVerificationURL); diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeController.java index b2e6bf9d..259a7223 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeController.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeController.java @@ -73,7 +73,7 @@ import com.darkweb.genesissearchengine.appManager.activityStateManager; import com.darkweb.genesissearchengine.eventObserver; import com.darkweb.genesissearchengine.helperManager.helperMethod; import com.darkweb.genesissearchengine.appManager.activityThemeManager; -import com.darkweb.genesissearchengine.libs.trueTime.trueTime; +import com.darkweb.genesissearchengine.libs.trueTime.trueTimeEncryption; import com.darkweb.genesissearchengine.pluginManager.pluginController; import com.darkweb.genesissearchengine.pluginManager.pluginEnums; import com.example.myapplication.R; @@ -216,7 +216,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba dataController.getInstance().initialize(this); status.initStatus(this); dataController.getInstance().invokeSQLCipher(dataEnums.eSqlCipherCommands.M_INIT, Collections.singletonList(this)); - trueTime.getInstance().initTime(); + trueTimeEncryption.getInstance().initTime(); helperMethod.updateResources(this, status.mSystemLocale.getLanguage()); pluginController.getInstance().onLanguageInvoke(Collections.singletonList(this), pluginEnums.eLangManager.M_ACTIVITY_CREATED); diff --git a/app/src/main/java/com/darkweb/genesissearchengine/constants/constants.java b/app/src/main/java/com/darkweb/genesissearchengine/constants/constants.java index 211c08fc..e8c9bb47 100755 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/constants.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/constants.java @@ -33,7 +33,7 @@ public class constants public static final String CONST_GENESIS_DOMAIN_URL_SLASHED = "https://trcip42ymcgvv5hsa7nxpwdnott46ebomnn5pm5lovg5hpszyo4n35yd.onion/"; public static final String CONST_GENESIS_DOMAIN_URL = "https://trcip42ymcgvv5hsa7nxpwdnott46ebomnn5pm5lovg5hpszyo4n35yd.onion"; public static final String CONST_GENESIS_LOCAL_TIME_GET_KEY = "pLocalTimeVerificationToken"; - public static final String CONST_GENESIS_GMT_TIME_GET_KEY = "pGlobalTimeVerificationToken"; + public static final String CONST_GENESIS_GMT_TIME_GET_KEY = "pSecretToken"; public static final String CONST_GENESIS_HELP_URL_CACHE = "resource://android/assets/Help/help.html"; public static final String CONST_GENESIS_HELP_URL_CACHE_DARK = "resource://android/assets/Help/help-dark.html"; public static final String CONST_GENESIS_HELP_URL = "https://genesis.onion/help"; diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/trueTime/trueTime.java b/app/src/main/java/com/darkweb/genesissearchengine/libs/trueTime/trueTime.java deleted file mode 100644 index 9da24066..00000000 --- a/app/src/main/java/com/darkweb/genesissearchengine/libs/trueTime/trueTime.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.darkweb.genesissearchengine.libs.trueTime; - -import com.darkweb.genesissearchengine.constants.strings; -import com.instacart.library.truetime.TrueTime; -import java.util.Date; - -public class trueTime { - - private static trueTime ourInstance = new trueTime(); - public static trueTime getInstance() - { - return ourInstance; - } - - public void initTime(){ - try{ - TrueTime.build().initialize(); - }catch (Exception ignored){ } - } - - - public String getGMT(){ - if (TrueTime.isInitialized()) { - Date trueTime = TrueTime.now(); - return trueTime.getTime()+strings.GENERIC_EMPTY_STR; - }else { - return "null"; - } - } - - public String getLTZ(){ - return System.currentTimeMillis()+strings.GENERIC_EMPTY_STR; - } - -} diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/trueTime/trueTimeEncryption.java b/app/src/main/java/com/darkweb/genesissearchengine/libs/trueTime/trueTimeEncryption.java new file mode 100644 index 00000000..103c1010 --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/libs/trueTime/trueTimeEncryption.java @@ -0,0 +1,37 @@ +package com.darkweb.genesissearchengine.libs.trueTime; + +import android.os.Build; +import androidx.annotation.RequiresApi; +import com.instacart.library.truetime.TrueTime; +import com.macasaet.fernet.Key; +import com.macasaet.fernet.Token; + +import java.util.Base64; + +public class trueTimeEncryption { + + public static String S_FERNET_KEY = "W#ZYBHQa9G_DB_iU@yjA3Es@COu4-UzU"; + public static String S_APP_BLOCK_KEY = "D~S=05y68#M25oj]vprm}9HE))Tr'VX?[p|m-Wg`mrg^"; + + private static trueTimeEncryption ourInstance = new trueTimeEncryption(); + public static trueTimeEncryption getInstance() + { + return ourInstance; + } + + public void initTime(){ + try{ + TrueTime.build().initialize(); + }catch (Exception ignored){ } + } + + + public String getSecretToken() { + Key mkey = null; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { + mkey = new Key(Base64.getUrlEncoder().encodeToString(S_FERNET_KEY.getBytes())); + } + Token token = Token.generate(mkey, S_APP_BLOCK_KEY); + return token.serialise(); + } +}