Skip to content

Commit

Permalink
Merge pull request #13 from arrase/split
Browse files Browse the repository at this point in the history
Split
  • Loading branch information
arrase authored Apr 12, 2017
2 parents b5e0749 + dc84dcc commit 0b2ccf2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 23 deletions.
3 changes: 2 additions & 1 deletion ducky/RaspiDucky/Configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion ducky/RaspiDucky/Daemonize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
24 changes: 24 additions & 0 deletions ducky/duckyd.py
Original file line number Diff line number Diff line change
@@ -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()
22 changes: 3 additions & 19 deletions ducky/raspiducky.py
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 2 additions & 1 deletion ducky/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
)
2 changes: 1 addition & 1 deletion scripts/run_payload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0b2ccf2

Please sign in to comment.