-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShodan-CVE-2023-29489-Scanner.py
48 lines (35 loc) · 1.48 KB
/
Shodan-CVE-2023-29489-Scanner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import shodan
import sys
import os
# Shodan API key
API_KEY = "YOUR_SHODAN_API_KEY"
def main():
# Get the target domain or IP address from user input
target = input("Enter the target domain or IP address: ")
# Create a folder with the target name
folder_name = target.replace(".", "_") # Replace dots with underscores for folder name
os.makedirs(folder_name, exist_ok=True)
# Initialize the Shodan API client
api = shodan.Shodan(API_KEY)
try:
# Perform the Shodan search
query = f'ssl:"{target}" port:2083'
results = api.search(query)
# Write the IP addresses to an output file
output_file = os.path.join(folder_name, "output.txt")
with open(output_file, "w") as file:
for result in results["matches"]:
file.write(result["ip_str"] + "\n")
print("Search results written to output.txt")
# Run the httpx and nuclei commands
httpx_output = os.path.join(folder_name, "httpx_output.txt")
nuclei_output = os.path.join(folder_name, "nuclei_output.txt")
httpx_command = f"cat {output_file} | httpx -silent > {httpx_output}"
nuclei_command = f"nuclei -t /path/to/CVE-2023-29489.yaml -l {httpx_output} -o {nuclei_output}"
os.system(httpx_command)
os.system(nuclei_command)
print("Completed running httpx and nuclei commands")
except shodan.APIError as e:
print("Error: %s" % e)
if __name__ == "__main__":
main()