1
0
mirror of https://github.com/calebstewart/pwncat.git synced 2024-11-27 19:04:15 +01:00

Completely moved pwncat.victim.config to pwncat.config

This commit is contained in:
Caleb Stewart 2020-10-08 13:39:51 -04:00
parent 83852e3d67
commit e658f9a592

View File

@ -100,8 +100,6 @@ class Victim:
setting the local terminal to raw. It also maintains the state to open a setting the local terminal to raw. It also maintains the state to open a
local terminal if requested and exit raw mode. """ local terminal if requested and exit raw mode. """
# Configuration storage for this victim
self.config = Config()
# Current user input state # Current user input state
self._state = None self._state = None
# Saved remote terminal state (for transition to/from raw mode) # Saved remote terminal state (for transition to/from raw mode)
@ -153,7 +151,7 @@ class Victim:
# framework assume a db engine exists, and therefore needs this # framework assume a db engine exists, and therefore needs this
# reference. Also, in the case a config isn't loaded this # reference. Also, in the case a config isn't loaded this
# needs to happen. # needs to happen.
self.engine = create_engine(self.config["db"], echo=False) self.engine = create_engine(pwncat.config["db"], echo=False)
pwncat.db.Base.metadata.create_all(self.engine) pwncat.db.Base.metadata.create_all(self.engine)
# Create the session_maker and default session # Create the session_maker and default session
@ -180,7 +178,7 @@ class Victim:
# Create the database engine, and then create the schema # Create the database engine, and then create the schema
# if needed. # if needed.
self.engine = create_engine(self.config["db"], echo=False) self.engine = create_engine(pwncat.config["db"], echo=False)
pwncat.db.Base.metadata.create_all(self.engine) pwncat.db.Base.metadata.create_all(self.engine)
# Create the session_maker and default session # Create the session_maker and default session
@ -240,7 +238,7 @@ class Victim:
# Create the database engine, and then create the schema # Create the database engine, and then create the schema
# if needed. # if needed.
if self.engine is None: if self.engine is None:
self.engine = create_engine(self.config["db"], echo=False) self.engine = create_engine(pwncat.config["db"], echo=False)
pwncat.db.Base.metadata.create_all(self.engine) pwncat.db.Base.metadata.create_all(self.engine)
# Create the session_maker and default session # Create the session_maker and default session
@ -703,11 +701,11 @@ class Victim:
""" """
if self.has_prefix: if self.has_prefix:
if data == self.config["prefix"].value: if data == pwncat.config["prefix"].value:
self.client.send(data) self.client.send(data)
else: else:
try: try:
binding = self.config.binding(data) binding = pwncat.config.binding(data)
# Pass is a special case that can be used at the beginning of a # Pass is a special case that can be used at the beginning of a
# command. # command.
@ -731,7 +729,7 @@ class Victim:
except KeyError: except KeyError:
pass pass
self.has_prefix = False self.has_prefix = False
elif data == self.config["prefix"].value: elif data == pwncat.config["prefix"].value:
self.has_prefix = True self.has_prefix = True
elif data == KeyType("c-d").value: elif data == KeyType("c-d").value:
# Don't allow exiting the remote prompt with C-d # Don't allow exiting the remote prompt with C-d
@ -859,7 +857,7 @@ class Victim:
ldflags = [] ldflags = []
try: try:
cross = self.config["cross"] cross = pwncat.config["cross"]
except KeyError: except KeyError:
cross = None cross = None
@ -1783,7 +1781,7 @@ class Victim:
): ):
if send_password and password is None: if send_password and password is None:
self.client.send(util.CTRL_C*2) self.client.send(util.CTRL_C * 2)
self.flush_output() self.flush_output()
raise PermissionError(f"{self.current_user.name}: no known password") raise PermissionError(f"{self.current_user.name}: no known password")
@ -1810,11 +1808,10 @@ class Victim:
f"{self.current_user.name}: incorrect password/permissions" f"{self.current_user.name}: incorrect password/permissions"
) )
else: else:
self.client.send(util.CTRL_C*2) self.client.send(util.CTRL_C * 2)
self.flush_output() self.flush_output()
raise PermissionError(f"{self.current_user.name}: no known password") raise PermissionError(f"{self.current_user.name}: no known password")
if stream: if stream:
return pipe return pipe