russhaun / artillery

The Artillery Project is an open-source blue team tool designed to protect Linux and Windows operating systems through multiple methods.
0 stars 0 forks source link

update format_ips() function to use Request instead of urlopen #81

Closed russhaun closed 1 week ago

russhaun commented 10 months ago

Description

 When pull_source_feeds() is run on program start you may receive an error when connecting to BinaryDefense.com.
  1. The list it creates works but when passed to format_ips() the request is made with urlopen() which uses the default python headers which most sites will block if used. So i have removed urlopen() and replaced it with Request, Session from the request module.

  2. This has allowed me to add custom headers, allow for partial string cleanup and then i pass it all to sort_banlist() as a list with no file writes (until later).this has allowed me to remove a large part of code from format_ips() due to not being needed.

  3. The sort_banlist() function has also been modified heavily to work with new method. most code was removed as not being needed. For now entire banlist is re-written each run along with additional string cleanup to achieve final file of unique entries.

  4. Also where possible is_windows() and is_posix() checks were removed about 95% to make functions less dependent on those calls resulting in better runtime. Overall all functions involved have reduced in size, complexity and platform reliance while achieving the same results.

russhaun commented 1 month ago

This will be included in next release.