22
33import decouple
44
5- from leakix import Client
5+ from leakix import Client , Scope
66from leakix .field import CountryField , Operator , PluginField , TimeField
77from leakix .plugin import Plugin
88from leakix .query import MustNotQuery , MustQuery , RawQuery
@@ -118,6 +118,36 @@ def example_get_subdomains():
118118 print (response .json ())
119119
120120
121+ def example_search_simple ():
122+ """Simple search using query string syntax (same as the website)."""
123+ response = CLIENT .search ("+plugin:GitConfigHttpPlugin" , scope = Scope .LEAK )
124+ for event in response .json ():
125+ print (event .ip )
126+
127+
128+ def example_search_service ():
129+ """Search for services with multiple filters."""
130+ response = CLIENT .search ("+country:FR +port:22" , scope = Scope .SERVICE )
131+ for event in response .json ():
132+ print (event .ip , event .port )
133+
134+
135+ def example_get_domain ():
136+ """Get services and leaks for a domain."""
137+ response = CLIENT .get_domain ("example.com" )
138+ if response .is_success ():
139+ print ("Services:" , response .json ()["services" ])
140+ print ("Leaks:" , response .json ()["leaks" ])
141+
142+
143+ def example_bulk_export_stream ():
144+ """Streaming bulk export - memory efficient for large datasets."""
145+ query = MustQuery (field = PluginField (Plugin .GitConfigHttpPlugin ))
146+ for aggregation in CLIENT .bulk_export_stream (queries = [query ]):
147+ for event in aggregation .events :
148+ print (event .ip )
149+
150+
121151if __name__ == "__main__" :
122152 example_get_host_filter_plugin ()
123153 example_get_service_filter_plugin ()
@@ -131,3 +161,7 @@ def example_get_subdomains():
131161 example_bulk_service ()
132162 example_bulk_export_last_event ()
133163 example_get_subdomains ()
164+ example_search_simple ()
165+ example_search_service ()
166+ example_get_domain ()
167+ example_bulk_export_stream ()
0 commit comments