-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathAttackerClient.py
96 lines (78 loc) · 3.86 KB
/
AttackerClient.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from email.mime.multipart import MIMEMultipart
import argparse
import socket
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# Define global variables
SERVER_EMAIL_HOST = None
SERVER_EMAIL_PORT = None
SERVER_LLAVA_HOST = None
SERVER_LLAVA_PORT = None
MYEMAIL = None
MAILSERVER = None
saveMail_directory = None
MyEmails = None
CycleNewEmails = None
BaseEmails_directory = None
def send_Email(Command, sender, recipient, subject, body, attachment_path, SERVER_HOST, SERVER_PORT,
AdditionalQuery=['']): # this function sends a new email to the server
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client_socket:
client_socket.connect((SERVER_HOST, SERVER_PORT))
# Create the message
msg = MIMEMultipart()
msg["Command"] = Command
msg["Subject"] = subject
msg["From"] = sender
msg["To"] = recipient
if AdditionalQuery != '':
for i in range(len(AdditionalQuery)):
msg["AdditionalQuery" + str(i)] = AdditionalQuery[i]
msg["AdditionalQueryNum"] = str(len(AdditionalQuery))
msg.attach(MIMEText(body, "plain"))
filename = attachment_path
with open(filename, "rb") as f:
img = MIMEImage(f.read())
img.add_header("Content-Disposition", "attachment", filename=filename)
msg.attach(img)
message = msg.as_string().encode('utf-8')
client_socket.sendall(message) # send the message to the server
return 'Email Sent!'
def main():
print("Attacker script is starting to run")
global MAILSERVER, SERVER_EMAIL_HOST, SERVER_EMAIL_PORT, SERVER_LLAVA_HOST, SERVER_LLAVA_PORT, MYEMAIL
MAILSERVER = '[email protected]'
parser = argparse.ArgumentParser(description='Description of your program')
parser.add_argument('--SERVER_EMAIL_HOST', type=str, help='Server Email IP')
parser.add_argument('--SERVER_EMAIL_PORT', type=int, help='Server Email Port')
parser.add_argument('--SERVER_LLAVA_HOST', type=str, help='Server LLaVa IP')
parser.add_argument('--SERVER_LLAVA_PORT', type=int, help='Server LLaVa Port')
parser.add_argument('--MYEMAIL', type=str, help='[email protected] Email')
args = parser.parse_args()
SERVER_EMAIL_HOST = args.SERVER_EMAIL_HOST
SERVER_EMAIL_PORT = args.SERVER_EMAIL_PORT
SERVER_LLAVA_HOST = args.SERVER_LLAVA_HOST
SERVER_LLAVA_PORT = args.SERVER_LLAVA_PORT
MYEMAIL = args.MYEMAIL
Command = "SEND_EMAIL"
sender = MYEMAIL
###### Send a malicous Email to any recipient to start the attack ######
##### Edit the following variables to send the email #####
subject = "Black Friday Deal!"
attachment_path = "../PerturbatedImages/DjiPerturbClassForward.png" # path to the attachment of the perturbated image
body = 'Happy Cyber Monday Cornell ! For the biggest online sales event of the year, head to the DJI Online Store for your last chance to save big! Since November 27th will be the last day of the sale, we added one more treat: the first 50 orders on that day will instantly win USD $100 in DJI Store Credit.'
recipient1 = '[email protected]'
recipient2 = '[email protected]'
##### Edit the following variables to send the email #####
print('-' * 50)
print(
f' \n attacker is sending an email to {recipient1} and {recipient2} \n with subject: {subject} \n and body: \n {body} \n and attachment: \n {attachment_path}\n')
print('-' * 50)
response = send_Email(Command, sender, recipient1, subject, body, attachment_path, SERVER_EMAIL_HOST,
SERVER_EMAIL_PORT)
print(response)
response = send_Email(Command, sender, recipient2, subject, body, attachment_path, SERVER_EMAIL_HOST,
SERVER_EMAIL_PORT)
print(response)
if __name__ == '__main__':
main()