mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-24 15:56:07 +00:00
commit
5c196f1ca5
6 changed files with 108 additions and 0 deletions
|
@ -116,6 +116,7 @@
|
|||
<package android:name="com.azure.authenticator" />
|
||||
<package android:name="com.valvesoftware.android.steam.community" />
|
||||
<package android:name="com.authenticator.authservice2" />
|
||||
<package android:name="com.duosecurity.duomobile" />
|
||||
</queries>
|
||||
|
||||
</manifest>
|
||||
|
|
|
@ -32,6 +32,7 @@ public abstract class DatabaseImporter {
|
|||
_importers.add(new Definition("andOTP", AndOtpImporter.class, R.string.importer_help_andotp, false));
|
||||
_importers.add(new Definition("Authenticator Plus", AuthenticatorPlusImporter.class, R.string.importer_help_authenticator_plus, false));
|
||||
_importers.add(new Definition("Authy", AuthyImporter.class, R.string.importer_help_authy, true));
|
||||
_importers.add(new Definition("DUO", DuoImporter.class, R.string.importer_help_duo, true));
|
||||
_importers.add(new Definition("FreeOTP", FreeOtpImporter.class, R.string.importer_help_freeotp, true));
|
||||
_importers.add(new Definition("FreeOTP+", FreeOtpPlusImporter.class, R.string.importer_help_freeotp_plus, true));
|
||||
_importers.add(new Definition("Google Authenticator", GoogleAuthImporter.class, R.string.importer_help_google_authenticator, true));
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
package com.beemdevelopment.aegis.importers;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.beemdevelopment.aegis.encoding.Base32;
|
||||
import com.beemdevelopment.aegis.encoding.EncodingException;
|
||||
import com.beemdevelopment.aegis.otp.HotpInfo;
|
||||
import com.beemdevelopment.aegis.otp.OtpInfo;
|
||||
import com.beemdevelopment.aegis.otp.OtpInfoException;
|
||||
import com.beemdevelopment.aegis.otp.TotpInfo;
|
||||
import com.beemdevelopment.aegis.util.IOUtils;
|
||||
import com.beemdevelopment.aegis.vault.VaultEntry;
|
||||
import com.topjohnwu.superuser.io.SuFile;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class DuoImporter extends DatabaseImporter {
|
||||
private static final String _pkgName = "com.duosecurity.duomobile";
|
||||
private static final String _subPath = "files/duokit/accounts.json";
|
||||
|
||||
public DuoImporter(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull SuFile getAppPath() throws DatabaseImporterException, NameNotFoundException {
|
||||
return getAppPath(_pkgName, _subPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull State read(
|
||||
@NonNull InputStream stream, boolean isInternal
|
||||
) throws DatabaseImporterException {
|
||||
try {
|
||||
String contents = new String(IOUtils.readAll(stream), UTF_8);
|
||||
return new DecryptedState(new JSONArray(contents));
|
||||
} catch (JSONException | IOException e) {
|
||||
throw new DatabaseImporterException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static class DecryptedState extends DatabaseImporter.State {
|
||||
private final JSONArray _array;
|
||||
|
||||
public DecryptedState(@NonNull JSONArray array) {
|
||||
super(false);
|
||||
_array = array;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Result convert() throws DatabaseImporterException {
|
||||
Result result = new Result();
|
||||
|
||||
try {
|
||||
for (int i = 0; i < _array.length(); i++) {
|
||||
JSONObject entry = _array.getJSONObject(i);
|
||||
try {
|
||||
result.addEntry(convertEntry(entry));
|
||||
} catch (DatabaseImporterEntryException e) {
|
||||
result.addError(e);
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new DatabaseImporterException(e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static @NonNull VaultEntry convertEntry(
|
||||
@NonNull JSONObject entry
|
||||
) throws DatabaseImporterEntryException {
|
||||
try {
|
||||
String label = entry.optString("name");
|
||||
|
||||
JSONObject otpData = entry.getJSONObject("otpGenerator");
|
||||
|
||||
byte[] secret = Base32.decode(otpData.getString("otpSecret"));
|
||||
|
||||
Long counter = otpData.has("counter") ? otpData.getLong("counter") : null;
|
||||
|
||||
OtpInfo otp = counter == null
|
||||
? new TotpInfo(secret)
|
||||
: new HotpInfo(secret, counter);
|
||||
|
||||
return new VaultEntry(otp, label, "");
|
||||
} catch (JSONException | OtpInfoException | EncodingException e) {
|
||||
throw new DatabaseImporterEntryException(e, entry.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -370,6 +370,7 @@
|
|||
<string name="importer_help_authenticator_plus">Предоставьте файл экспорта Authenticator Plus, полученный через <b>«Настройки» → «Рез. копия и восстановление» → «Экспорт текста и HTML»</b>.</string>
|
||||
<string name="importer_help_authy">Предоставьте копию файла <b>/data/data/com.authy.authy/shared_prefs/com.authy.storage.tokens.authenticator.xml</b>, расположенного в папке Authy во внутренней памяти.</string>
|
||||
<string name="importer_help_andotp">Предоставьте файл экспорта/резервной копии andOTP.</string>
|
||||
<string name="importer_help_duo">Предоставьте копию файла <b>/data/data/com.duosecurity.duomobile/files/duokit/accounts.json</b>, расположенного в папке DUO во внутренней памяти.</string>
|
||||
<string name="importer_help_freeotp">Предоставьте копию файла <b>/data/data/org.fedorahosted.freeotp/shared_prefs/tokens.xml</b>, расположенного в папке FreeOTP во внутренней памяти.</string>
|
||||
<string name="importer_help_freeotp_plus">Предоставьте файл экспорта FreeOTP+.</string>
|
||||
<string name="importer_help_google_authenticator">Предоставьте копию файла <b>/data/data/com.google.android.apps.authenticator2/databases/databases</b>, расположенного в папке Google Authenticator во внутренней памяти.</string>
|
||||
|
|
|
@ -337,6 +337,7 @@
|
|||
<string name="importer_help_authenticator_plus">Надайте файл експорту Authenticator Plus, отриманий через <b>Settings -> Backup & Restore -> Export as Text and HTML</b>.</string>
|
||||
<string name="importer_help_authy">Надайте копію <b>/data/com.authy.authy/shared_prefs/com.authy.storage.tokens.authenticator.xml</b>, що знаходиться в каталозі Authy у внутрішній пам\'яті.</string>
|
||||
<string name="importer_help_andotp">Надайте файл експорту/резервної копії andOTP.</string>
|
||||
<string name="importer_help_duo">Надайте копію <b>/data/data/com.duosecurity.duomobile/files/duokit/accounts.json</b>, що знаходиться в каталозі DUO у внутрішній пам\'яті.</string>
|
||||
<string name="importer_help_freeotp">Надайте копію <b>/data/org.fedorahosted.freeotp/shared_prefs/tokens.xml</b>, що знаходиться в каталозі FreeOTP у внутрішній пам\'яті.</string>
|
||||
<string name="importer_help_freeotp_plus">Надайте файл експортований з FreeOTP+.</string>
|
||||
<string name="importer_help_google_authenticator">Надайте копію <b>/data/com.google.android.apps.authenticator2/databases/databases</b>, що знаходиться в каталозі Google Authenticator у внутрішній пам\'яті.</string>
|
||||
|
|
|
@ -391,6 +391,7 @@
|
|||
<string name="importer_help_authenticator_plus">Supply an Authenticator Plus export file obtained through <b>Settings -> Backup & Restore -> Export as Text and HTML</b>.</string>
|
||||
<string name="importer_help_authy">Supply a copy of <b>/data/data/com.authy.authy/shared_prefs/com.authy.storage.tokens.authenticator.xml</b>, located in the internal storage directory of Authy.</string>
|
||||
<string name="importer_help_andotp">Supply an andOTP export/backup file.</string>
|
||||
<string name="importer_help_duo">Supply a copy of <b>/data/data/com.duosecurity.duomobile/files/duokit/accounts.json</b>, located in the internal storage directory of DUO.</string>
|
||||
<string name="importer_help_freeotp">Supply a copy of <b>/data/data/org.fedorahosted.freeotp/shared_prefs/tokens.xml</b>, located in the internal storage directory of FreeOTP.</string>
|
||||
<string name="importer_help_freeotp_plus">Supply a FreeOTP+ export file.</string>
|
||||
<string name="importer_help_google_authenticator">Supply a copy of <b>/data/data/com.google.android.apps.authenticator2/databases/databases</b>, located in the internal storage directory of Google Authenticator.</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue