-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: do not deobfuscate known top level domains with 2 or 3 characters
- Loading branch information
Showing
3 changed files
with
508 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package jadx.core.deobf; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.InputStreamReader; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import jadx.core.utils.exceptions.JadxRuntimeException; | ||
|
||
/** | ||
* Provides a list of all top level domains with 3 characters and less, | ||
* so we can exclude them from deobfuscation. | ||
*/ | ||
public class TldHelper { | ||
|
||
private static final Set<String> TLD_SET = loadTldFile(); | ||
|
||
private static Set<String> loadTldFile() { | ||
Set<String> tldNames = new HashSet<>(); | ||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(Deobfuscator.class.getResourceAsStream("tld_3.txt")))) { | ||
String line; | ||
while ((line = reader.readLine()) != null) { | ||
line = line.trim(); | ||
if (!line.startsWith("#") && !line.isEmpty()) { | ||
tldNames.add(line); | ||
} | ||
} | ||
return tldNames; | ||
} catch (Exception e) { | ||
throw new JadxRuntimeException("Failed to load top level domain list tld_3.txt", e); | ||
} | ||
} | ||
|
||
public static boolean contains(String name) { | ||
return TLD_SET.contains(name); | ||
} | ||
|
||
} |
Oops, something went wrong.