
Research
Using Trusted Protocols Against You: Gmail as a C2 Mechanism
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.
To get started with using the astrie
package, follow these steps:
Installation
Install the package using pip:
pip install astrie
Importing
Import the AsTrie
class from the astrie
module:
from astrie import AsTrie
Object Initialization
Initialize an instance of the AsTrie
class:
trie = AsTrie()
To add words to the trie, you can use the following methods:
To add a single word:
trie.add("Python")
To add a list of words at once:
word_list = ["pineapple", "butterfly", "adventure", "rainbow", "whisper",
"enchantment", "tranquility", "galaxy", "serendipity", "blossom",
"chocolate", "meadow", "firefly", "symphony", "serenade",
"moonlight", "horizon", "oasis", "velvet", "reflection",
"sunrise", "wonder", "starlight", "cascade", "mystic",
"melody", "twilight", "radiant", "journey", "destiny",
"harmony", "peaceful", "embrace", "shimmer", "gentle",
"serene", "dreamer", "captivate", "inspire", "tranquility",
"cherish", "ethereal", "wanderlust", "cherished", "radiant",
"adventure", "captivate", "radiant", "enjoy", "serenity","Python","Hello","World"]
trie.add_many(word_list)
To remove words from the trie, you can use these methods:
To remove a single word:
trie.remove("Python")
To remove a list of words:
trie.remove_many(["Hello", "World"])
To empty the trie:
trie.clear()
You can perform various checks and obtain counts using these methods:
To check if a word exists in the trie:
exists = trie.has("horizon")
print(exists)
>>> True
To check if there are words that start with a given prefix:
starts_with = trie.starts_with("ad")
print(starts_with)
>>> True
To get the count of words that start with a prefix:
starts_with_count = trie.starts_with_count("ad")
print(starts_with_count)
>>> 2
To get the count of words equal to a given word:
count_equals = trie.count_equals("adventure")
print(count_equals)
>>> 2
To get the count of unique words in the trie:
unique_count = trie.unique_count()
print(unique_count)
>>> 48
You can retrieve words using these methods:
To get a generator object for all words in the trie:
all_words_generator = trie.all_words()
for word in all_words_generator:
print(word)
>>>
pineapple
butterfly
adventure
...
World
To get a generator object for words that start with a prefix:
starts_with_generator = trie.words_starts_with("m")
for word in starts_with_generator :
print(word)
>>>
meadow
melody
moonlight
mystic
Remember that for generator objects, you need to iterate over them to access the actual words they yield.
FAQs
A simple trie data structure implementation
We found that astrie demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.
Product
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.