diff --git a/ducky/RaspiDucky/Configuration.py b/ducky/RaspiDucky/Configuration.py index fb80a09..a50dc16 100644 --- a/ducky/RaspiDucky/Configuration.py +++ b/ducky/RaspiDucky/Configuration.py @@ -12,7 +12,8 @@ def __init__(self): config.readfp(open(self._config_file)) self._uuid = config.get('service', 'uuid') except ConfigParser.NoOptionError: - print "Error reading config file." + print + "Error reading config file." exit(2) def get_uuid(self): diff --git a/ducky/RaspiDucky/Daemonize.py b/ducky/RaspiDucky/Daemonize.py index 8183deb..57f6c4b 100644 --- a/ducky/RaspiDucky/Daemonize.py +++ b/ducky/RaspiDucky/Daemonize.py @@ -102,7 +102,8 @@ def stop(self): if os.path.exists(self._pidfile): os.remove(self._pidfile) else: - print str(err) + print + str(err) sys.exit(1) def restart(self): diff --git a/ducky/duckyd.py b/ducky/duckyd.py new file mode 100755 index 0000000..73e5d03 --- /dev/null +++ b/ducky/duckyd.py @@ -0,0 +1,24 @@ +#!/usr/bin/python + +import argparse + +from RaspiDucky.Daemonize import Daemonize + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('--start', help='Start Server', action="store_true") + parser.add_argument('--stop', help='Stop Server', action="store_true") + parser.add_argument('--restart', help='Restart Server', action="store_true") + + args = parser.parse_args() + + daemon = Daemonize() + + if args.start: + daemon.start() + elif args.stop: + daemon.stop() + elif args.restart: + daemon.restart() + else: + parser.print_help() diff --git a/ducky/raspiducky.py b/ducky/raspiducky.py index c4f98c3..8d73b24 100755 --- a/ducky/raspiducky.py +++ b/ducky/raspiducky.py @@ -1,32 +1,16 @@ #!/usr/bin/python import argparse -import sys -from RaspiDucky.Daemonize import Daemonize from RaspiDucky.RunPayload import RunPayload if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument('--payload', '-p', required=False, help='Path to payload file') + parser.add_argument('--payload', '-p', required=True, help='Path to payload file') parser.add_argument('--remote', '-r', required=False, help='Run payload on remote device', action="store_true") parser.add_argument('--address', '-a', required=False, help='Remote device address') - parser.add_argument('--daemon', '-d', choices=['start', 'stop', 'restart'], required=False, - help='Run as daemon') args = parser.parse_args() - if args.daemon is not None: - daemon = Daemonize() - if args.daemon == 'restart': - daemon.restart() - elif args.daemon == 'stop': - daemon.stop() - else: - daemon.start() - elif args.payload is not None: - ducky = RunPayload() - ducky.run(payload=args.payload, remote=args.remote, address=args.address) - else: - parser.print_help() - sys.exit(1) + ducky = RunPayload() + ducky.run(payload=args.payload, remote=args.remote, address=args.address) diff --git a/ducky/setup.py b/ducky/setup.py index 23efff5..83be5ac 100644 --- a/ducky/setup.py +++ b/ducky/setup.py @@ -20,7 +20,8 @@ description="A Keyboard emulator like Rubber Ducky build over Raspberry Pi Zero W", data_files=[ - ('/usr/bin', ['raspiducky.py']) + ('/usr/bin', ['raspiducky.py']), + ('/usr/bin', ['duckyd.py']) ], requires=['pybluez'] ) diff --git a/scripts/run_payload.sh b/scripts/run_payload.sh index b23cd93..82e6547 100644 --- a/scripts/run_payload.sh +++ b/scripts/run_payload.sh @@ -2,7 +2,7 @@ . /etc/raspiducky/raspiducky.conf -[ $RUN_AS_DAEMON == "Yes" ] && /bin/hciconfig hci0 piscan && /usr/bin/raspiducky.py -d start +[ $RUN_AS_DAEMON == "Yes" ] && /bin/hciconfig hci0 piscan && /usr/bin/duckyd.py --start if [ -f /etc/raspiducky/onboot_payload/payload.dd ] then