Making Attack Surface Management Easier with Python
Censys has deep roots in open source software, originating from the open source project, Zmap. Since then, Censys has continued to support open source projects and contribute to our public repositories which can be found here.
One of our most popular open source projects is our censys-python library. The library was originally created for Censys Search and is an easy-to-use and lightweight API wrapper, currently used in 180 projects across GitHub. With the recent release (v1.1.0), this library now includes a second API for the Attack Surface Management Platform (or ASM Platform). The Censys ASM API enables users to programmatically interact with resources on our ASM platform, including seeds, assets, and logbook events.
- seeds – Provides programmatic management of seeds in the ASM platform.
- assets – Returns asset data for hosts, certificates, and domains. This option also allows the user to manage tags and comments on assets.
- events – Returns logbook events. Can be used to execute targeted searches for events based on start id or date, and event type filters.
As a customer of the ASM Platform, this update allows users to automate their interactions in just a few short commands such as adding new seed data to the platform and fetching associated assets like IP addresses and domain names. Users can even keep track of their ASM asset history using the logbook endpoints and its event objects.
For example, adding new seeds to the Censys ASM Platform is now even easier:
|from censys.asm.seeds import Seeds
s = Seeds()
# Add a list of seeds. To add a single seed, just pass a list containing one seed.
# Add a list of seeds, replacing existing seeds with a specified label
As for assets, there are three types (hosts, certificates, and domains), each sharing the same API interface. An example of how you might go about viewing your assets on the Censys ASM Platform is:
|from censys.asm.assets import Assets
h = Assets(“hosts”)
# Get a generator that returns hosts
# Get a single host by ID (here we get host with ID=”0.0.0.0″)
Events are changes in the user’s attack surface such as a user adds a new certificate, a user opens a new port, etc.. Here is an example of how quickly you can grab your logbook, or list of all these type of events in chronological order, from the ASM platform:
|from censys.asm.events import Events
e = Events()
# Get a generator that returns all events
# Get events based off cursor specifications
If you have any issues or want to contribute to the library, please submit your pull request and we’ll get back to you with any questions! For more information about the ASM API and how to leverage the API in your current workflows, please see our documentation.