-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added redirect_port module and modified src/modules/attack/__init__.p…
…y to load any modules in the attack dir
- Loading branch information
1 parent
5a525fc
commit af50c12
Showing
2 changed files
with
52 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
__all__ = ["beef_hook", "pemod", "replacer"] | ||
from os.path import basename, dirname, abspath | ||
from glob import glob | ||
|
||
__all__ = [i for i in (basename(f)[:-3] for f in glob(dirname(abspath(__file__))+"/*.py")) if i != "__init__" and i != "attack"] | ||
__all__ = [v for v in __all__ if not v == "__init__"] |
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,47 @@ | ||
from attack import Attack | ||
import util | ||
from zoption import Zoption | ||
|
||
|
||
class redirect_port(Attack): | ||
def __init__(self): | ||
super(redirect_port, self).__init__("redirect_port") | ||
self.iptable = "iptables -t nat -A PREROUTING -p tcp --dport {0} -j REDIRECT --to-port {1}" | ||
self.config.update({"source_port": Zoption(type="int", value=80, required=True, display="Source port"), | ||
"dest_port": Zoption(type="int", value=8080, required=True, display="Destination port")}) | ||
self.config.update({}) | ||
self.running = False | ||
self.info = """ | ||
Redirects inbound TCP traffic on source port to destination port on localhost | ||
""" | ||
|
||
def modip(self, enable=True): | ||
""" | ||
Enable or disable the iptable rule | ||
""" | ||
to_exec = self.iptable.format(self.config['source_port'].value, self.config['dest_port'].value) | ||
if enable: | ||
util.init_app(to_exec) | ||
else: | ||
util.init_app(to_exec.replace('-A', '-D')) | ||
|
||
def initialize(self): | ||
util.Msg("Starting redirect_port...") | ||
|
||
self.modip() | ||
|
||
self.running = True | ||
|
||
util.Msg("Redirection to from TCP port {0} to {1}...") | ||
|
||
return True | ||
|
||
def shutdown(self): | ||
util.Msg("Shutting down RedirectPort...") | ||
self.modip(False) | ||
|
||
def session_view(self): | ||
""" | ||
Return information about the redirections | ||
""" | ||
return "Redirect from {0} to {1}".format(self.config['source_port'].value, self.config['dest_port'].value) |