-
-
Notifications
You must be signed in to change notification settings - Fork 831
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a new tamper script "slash2env.py" that replaces slashes ("/") …
…with environment variable value "${PATH%%u*}"
- Loading branch information
1 parent
f877b67
commit c2d1ab5
Showing
4 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/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 sys | ||
from src.utils import settings | ||
|
||
""" | ||
About: Replaces slashes (/) with environment variable value "${PATH%%u*}". | ||
Notes: This tamper script works against *nix targets. | ||
Reference: https://www.secjuice.com/bypass-strict-input-validation-with-remove-suffix-and-prefix-pattern/ | ||
""" | ||
|
||
__tamper__ = "slash2env" | ||
|
||
if not settings.TAMPER_SCRIPTS[__tamper__]: | ||
settings.TAMPER_SCRIPTS[__tamper__] = True | ||
|
||
def tamper(payload): | ||
def add_slash2env(payload): | ||
settings.TAMPER_SCRIPTS[__tamper__] = True | ||
payload = payload.replace("/", "${PATH%%u*}") | ||
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() | ||
else: | ||
settings.TRANFROM_PAYLOAD = True | ||
if settings.TRANFROM_PAYLOAD: | ||
payload = 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() | ||
|
||
return payload | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters