Exploit databaseDownload repository ZIP
GH-e5b1907c9af9938793498cc339f2f81c
reneoliveirajr/wp_cve-2020-35489_checker
Sources for CVE-2020-35489
8 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files3
reneoliveirajr/wp_cve-2020-35489_checkerRevision 31bd6b036a74
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
cve_2020_35489_checker.py
Python · 3,846 bytesimport argparse
import asyncio
import os
import aiofiles
import aiohttp
from packaging import version
async def detect_plugin_version(readme):
start_tag = "Stable tag: "
version_start_index = readme.find(start_tag)
if version_start_index == -1:
raise KeyError("Invalid readme format: 'Stable tag: ' not found.")
version_end_index = readme.find("\n", version_start_index)
if version_end_index == -1:
raise IndexError("Invalid readme format: Version end tag not found.")
plugin_version = readme[version_start_index + len(start_tag):version_end_index]
if not plugin_version:
raise ValueError("Plugin version is missing.")
return plugin_version
def format_domain(domain):
if domain.startswith("http"):
return domain
else:
return f"https://{domain}"
async def check_site(session, domain, output_file):
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"}
domain = format_domain(domain)
plugin_url = f"{domain}/wp-content/plugins/contact-form-7/readme.txt"
try:
async with session.get(plugin_url, headers=headers, timeout=3, ssl=False) as response:
if response.status == 200:
plugin_version = await detect_plugin_version(await response.text())
is_vulnerable = version.parse(plugin_version) < version.parse("5.3.2")
print(f"\nSite: {domain}\nContact Form 7 Plugin Version: {plugin_version}\n"
f"{domain} {'------------------------> ' if is_vulnerable else ' :( NOT '}VULNERABLE!\n")
if output_file and is_vulnerable:
async with aiofiles.open(output_file, "a") as f:
await f.write(f"Site: {domain}\nContact Form 7 Plugin Version: {plugin_version}\n\n")
else:
print(f"\nSite: {domain}\nFailed to make an HTTP request to retrieve the plugin version:\nStatus code: {response.status}")
except asyncio.TimeoutError:
print(f"\nSite: {domain}\nFailure: The request to retrieve the plugin version exceeded the timeout. (3 seconds)\n")
except Exception as e:
print(f"\nSite: {domain}\nAn error occurred while obtaining the plugin version:\n{str(e)}\n")
async def main():
parser = argparse.ArgumentParser(description='Checks if a WordPress website is vulnerable to CVE-2020-35489.')
parser.add_argument('-d', '--domain', help='Check a single site (Example: python cve_2020_35489_checker.py -d example.com)')
parser.add_argument('-i', '--input-file', help='Check multiple sites from a text file (Example: python cve_2020_35489_checker.py -i list.txt -o vulnerable.txt)')
parser.add_argument('-o', '--output-file', help='Output file for the list of vulnerable sites')
args = parser.parse_args()
if args.output_file and not os.path.exists(args.output_file):
open(args.output_file, 'w').close()
if args.input_file:
if not os.path.exists(args.input_file):
open(args.input_file, 'w').close()
print(f"\nThe input file '{args.input_file}' was created in the current directory '{os.getcwd()}', but it is empty.\nPlease populate it with a list of sites to test and then try again.\n")
else:
async with aiohttp.ClientSession() as session:
async with aiofiles.open(args.input_file, 'r') as f:
lines = await f.readlines()
tasks = [check_site(session, line.strip(), args.output_file) for line in lines if line.strip()]
await asyncio.gather(*tasks)
elif args.domain:
async with aiohttp.ClientSession() as session:
await check_site(session, args.domain, args.output_file)
else:
parser.print_help()
asyncio.run(main())