Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Monday, September 25, 2017

Stitch un RAT multiplataforma escrito en Python

Stitch un RAT multiplataforma escrito en Python


Stitch es un RAT multiplataforma escrito en Python que permite crear payloads personalizados para Windows, Mac OSX y Linux. Su autor, Nathan Lopez, lo cre� con la motivaci�n de avanzar en su conocimiento de python, hacking y para ver lo que pod�a lograr. Y, aunque apunto estuvo de abandonar el proyecto al ver que previamente se adelant� Pupy (otro pero impresionante RAT multiplataforma escrito en Python) al final decidi� publicarlo despu�s de todo el camino recorrido.


Sus caracter�sticas son:

Gen�ricas

- Multiplataforma
- Autocompletado de comandos y archivos
- Detecci�n de Antivirus
- Capacidad de apagar/encender la pantalla
- Ocultar y mostrar archivos y directorios
- Ver/editar el archivo hosts
- Ver todas las variables de entorno de sistema
- Keylogger con opciones para ver el estado, iniciar, detener y volcar los logs
- Ver la ubicaci�n y otra informaci�n de la m�quina de destino
- Ejecutar scripts de python personalizados que devuelven lo que se imprima a la pantalla
- Capturas de pantalla
- Detecci�n de m�quina virtual
- Descargar/subir archivos hacia/desde el sistema de destino
- Volcado de los hashes de las contrase�as del sistema
- Las propiedades de los payloads est�n "disimuladas" como otros programas conocidos

Espec�ficas para Windows

- Muestra un cuadro de di�logo con el usuario/contrase�a para enga�ar al usuario
- Vuelca la contrase�as guardadas en Chrome
- Permite borrar los registros del sistema, de seguridad y de la aplicaci�n
- Habilitar/deshabilitar servicios como RDP, UAC y Windows Defender
- Editar las propiedades de archivos accesibles, creados y modificados
- Crear un cuadro emergente personalizado
- Ver la c�mara web conectada y tomar instant�neas
- Ver las conexiones wifi conectadas y guardadas junto con sus contrase�as
- Ver informaci�n acerca de las unidades conectadas
- Ver el resumen de valores de registro como DEP


Espec�ficas para MacOS

- Cambiar el texto de inicio de sesi�n en la pantalla de inicio de sesi�n del usuario
- Capacidad de tomar capturas de la webcam

Espec�ficas para MacOS/Linux

- SSH desde la m�quina de destino a otro host
- Ejecutar comandos con sudo
- Realizar ataques de fuerza bruta con la lista de contrase�as que se encuentra en Tools/
- Capacidad de tomar capturas de la webcam

Transportes implementados

Toda comunicaci�n entre el host y el destino es cifrada con AES. Cada programa Stitch genera una clave AES que luego se pone en todos los payloads. Para acceder a un payload las claves AES deben coincidir. Para conectarse desde un sistema diferente que ejecuta Stitch se debe agregar la clave utilizando el comando showkey del sistema original y el comando addkey del nuevo sistema.

Instaladores de payload implementados

El comando "stitchgen" da al usuario la opci�n de crear instaladores NSIS en Windows y Makeself en m�quinas posix. Para Windows, el instalador empaqueta el payload y un exe para elevar privilegios, lo que evita el mensaje del firewall, instala el payload en el sistema e intenta a�adir persistencia. Para Mac OSX y Linux, el instalador coloca el payload e intenta agregar persistencia. Para crear instaladores NSIS se debe descargar e instalar NSIS.

Requisitos

Python 2.7

Instalaci�n

# para Windows
pip install -r win_requirements.txt

# para Mac OSX
pip install -r osx_requirements.txt

# para Linux
pip install -r lnx_requirements.txt
  • Pycrypto
  • Requests
  • Colorama
  • PIL
Especificos de Windows
  • Py2exe
  • pywin32
Especificos de Mac OSX
  • PyObjC
Especificos de Mac OSX/Linux
  • PyInstaller
  • pexpect
Para ejecutarlo

python main.py

o

./main.py

Otros RAT en Python de c�digo abierto de referencia:
  • vesche/basicRAT
  • n1nj4sec/pupy
DISCLAIMER

Stitch es para fines de educaci�n/investigaci�n solamente. El autor no asume ninguna responsabilidad y/o responsabilidad por la forma en que elijas utilizar cualquiera de las herramientas/c�digo fuente/cualquier archivo proporcionado. El autor y cualquier persona afiliada con no ser� responsable de ninguna p�rdida y/o da�os en relaci�n con el uso de CUALQUIER archivo proporcionado con Stitch. Mediante el uso de Stitch o cualquier archivo incluido, se entiende que estas ACEPTANDO USARLO POR TU PROPIO RIESGO. Una vez m�s, Stitch y TODOS los archivos incluidos son para fines de EDUCACI�N y/o de INVESTIGACI�N SOLAMENTE. Stitch est� SOLAMENTE pensado para ser utilizado en laboratorios propios de pentesting, o con el consentimiento expl�cito del due�o de la caracter�stica que est� siendo probada.

    Proyecto:  https://github.com/nathanlopez/Stitch


    download file now

    Read more »

    Thursday, September 21, 2017

    The Python application TwitterCroatia

    The Python application TwitterCroatia


    During the winter semester I have been developing a Python application.

    Since the Twitter API only allows 150 requests per hour, and Twitter does not generally allow users access to tweets older than a week or sometimes even less, the purpose of the code was to create a database of  tweets for later analysis. And so, using the Python wrapper for the Twitter API, I created a set of modules, the most important of which I will now elaborate:
    • The first and easiest to explain is the twitterDB module. It stores and retrieves data from files using pickle. Its main functions are addTweet, addUser, getTweets and getUsers. It can also fetch single or multiple tweets from a specified user or check if a file contains a user id, which are functions mostly used to avoid duplicates being needlessly stored in a file.
    • The module twitterCommunication is the module which communicates with the Twitter API using the python-twitter wrapper. Its functions mostly mimic those enabled by the wrapper itself, only with implemented error handling for most common errors (such as network malfunctions and exceeded rate limits) but the biggest advantage is the automated cursor handling. When a large enough amount of data is requested, the Twitter API breaks it up in pieces and sends only the first piece along with the cursor which is a reference to the next piece. The functions in this module expect this and call the API recursively until all pieces are delivered. It should be noted that this means that one call to a function may mean more than one request to the API.
    • The third module getAllFollowersAsObjects uses the aforementioned two modules to create a more complex functionality - download all user objects who follow a specified user using twitterCommunication and store them in a specified file using twitterDB.
    • The last module uses all the other modules, and was the end purpose of my code. It is currently called twitterCroatia although the name is not abstract enough and might be misleading, and so might change. It is the only module which has an infinitely long while loop, its function being the continuous collection of data. It starts by requesting a single user object, and then requesting its timeline and its followers, and proceeds to do the same for each of the followers, if there are any, ad infinitum. It is conceivable for the loop to be in fact finite, for example in a closed circle of friends who follow each other and nobody else, but this is unlikely to happen.
    TwitterCroatia can be modified to start with any user, but the default is VladaRH, the official Twitter channel of the Croatian Government. This by no means guarantees that users whose data and tweets are fetched this way will really be Croatian, and in fact some most surely will not be. For this filtering to be accomplished, additional resources are needed, for example by checking the Location data. Since most users do not enable publicly shared location data, natural language processing might be required.

    Also, with the csvToData module I have enabled integration with the CSV format (which Twitter recently offered its users for downloading their entire tweet history, and as of 2013, available in Croatia as well)
    The next steps are:
    • moving from pickle and data serialization to an SQLite database.
    • utilizing tools that might prove useful in future development such as the Python Graph Tool and Natural Language Toolkit.


    download file now

    Read more »