1 | | - | from os import remove |
| 1 | + | import os |
2 | 2 | | from shodan import Shodan |
3 | 3 | | |
4 | 4 | | def shodan(): |
5 | | - | api_key = "" |
| 5 | + | api_key = os.environ["SHODAN_API_KEY"].strip() |
6 | 6 | | api = Shodan(api_key) |
7 | 7 | | # https://michaelkoczwara.medium.com/hunting-c2-with-shodan-223ca250d06f |
8 | 8 | | # https://michaelkoczwara.medium.com/cobalt-strike-c2-hunting-with-shodan-c448d501a6e2 |
| skipped 38 lines |
47 | 47 | | seen.add(line) |
48 | 48 | | initial_count += 1 |
49 | 49 | | f.close() |
50 | | - | remove("data/" + ip_file) |
| 50 | + | os.remove("data/" + ip_file) |
51 | 51 | | new_count = 0 |
52 | 52 | | f = open("data/" + ip_file, "a") |
53 | 53 | | for ip in seen: |
| skipped 9 lines |
63 | 63 | | seen.add(line) |
64 | 64 | | initial_count_all += 1 |
65 | 65 | | a.close() |
66 | | - | remove("data/all.txt") |
| 66 | + | os.remove("data/all.txt") |
67 | 67 | | new_count_all = 0 |
68 | 68 | | a = open("data/all.txt", "a") |
69 | 69 | | for ip in seen: |
| skipped 10 lines |