Python low-interaction honeyclient

Overview

Thug

version badge github badge lgtm badge codefactor badge codecov badge bandit badge

The number of client-side attacks has grown significantly in the past few years shifting focus on poorly protected vulnerable clients. Just as the most known honeypot technologies enable research into server-side attacks, honeyclients allow the study of client-side attacks.

A complement to honeypots, a honeyclient is a tool designed to mimic the behavior of a user-driven network client application, such as a web browser, and be exploited by an attacker's content.

Thug is a Python low-interaction honeyclient aimed at mimicing the behavior of a web browser in order to detect and emulate malicious contents.

Documentation

docs badge

Documentation about Thug installation and usage can be found at http://thug-honeyclient.readthedocs.io/.

Contributions

donate badge

Thug is open source and we welcome contributions in all forms!

Thug is free to use for any purpose (even commercial ones). If you use and appreciate Thug, please consider supporting the project with a donation using Paypal.

Testing

To run the full test suite using tox, run the command:

tox

Since tox builds and installs dependencies from scratch, using pytest for faster testing is recommended:

pytest --cov thug

License information

Copyright (C) 2011-2021 Angelo Dell'Aera <[email protected]>

License: GNU General Public License, version 2

Comments
  • Add support for WScriptNetwork object.

    Add support for WScriptNetwork object.

    Adds support for the WScriptNetwork object which was used in some recent samples.

    Ideally the attributes shouldn't be static but retrieved using WScriptShell.ExpandEnvironmentStrings(). Any comments on how to do that?

    Also did some improvements on the Scripting.FileSystemObject module.

    enhancement 
    opened by tweemeterjop 17
  • Thug not properly handling redirects logging

    Thug not properly handling redirects logging

    Hi! Let's take a look at this situation: At hxxp://localhost:1337/ek_tests/dummy_redirect_chain/exploit.html some code was added by nasty hacker.

    <html>
    <head>
    <title>Dummy sploit</title>
    </head>
    <body>
    <!-- malicious code start -->
    <script src="javascript.php?option=0"></script>
    <!-- malicious code end -->
    </body>
    </html>
    

    That code redirects (indirectly) to (imaginated) exploit kit's gate (that uses alert(1) from js as exploit). It creates some new scripts on the way to gate. At the backend side, it looks like this:

    <?php
    /**
    * javascript.php
    */
    $i = $_GET['option'];
    $to_write = "";
    switch ($i) {
        case 0:
            $to_write =  "var script = document.createElement('script');
    script.src = 'javascript.php?option=1';
    document.body.appendChild(script);";
            break;
        case 1:
            header('Location: javascript.php?option=2');
            break;
        case 2:
            $to_write = "document.write(\"<iframe src='iframe.php?option=1'></iframe>\");";
            break;
       case 3:
            $to_write =  "var script = document.createElement('script');
    script.src = 'javascript.php?option=4';";
        case 4:
           $to_write = "alert('1');";
    }
    echo $to_write;
    ?>
    

    Also uses iframes

    <?php
    /**
    * iframe.php
    */
    $i = $_GET['option'];
    $to_write = "";
    switch ($i) {
        case 0:
            $to_write =  "var script = document.createElement('script');
    script.src = 'javascript.php?option=1';";
            break;
        case 1:
            $to_write = "<script src='javascript.php?option=3'></script>";
            break;
        case 2:
            $to_write = "document.write(\"<iframe src='iframe.php?option=1'></iframe>\");";
            break;
       case 3:
            $to_write =  "var script = document.createElement('script');
    script.src = 'javascript.php?option=4';";
        case 4:
           $to_write = "document.alert(1);";
    }
    echo '<html><head></head><body>';
    echo $to_write;
    echo '</body></html>';
    ?>
    

    When user (thug) enters that site, it produces some redirects with alert(1) at the end. It looks like this: http://svgur.com/i/1XW.svg - graph made by thug itself.

    The problem is: Even if one script leads to another, we are not informed about that. We cannot build proper redirect chains for that redirections. We get such output:

     | -> 1    / (2->3 redirected by HTTP Location header)
    0| -> 2 -> 3
     | -> 4
    

    Even if that really should be:

    0 -> 1 -> 2 -> 3 -> 4
    

    I know that this is caused by, for example, that newly created scripts are executed within base (0's) DOM. I believe we could somehow get information about real source of some action from V8. It is critical aspect for analysis of web threats, because at the moment we don't really know what part of website is malicious, and what is not. Also, thanks for a great tool :)

    enhancement 
    opened by internaldefect 16
  • new version - missing graph.svg

    new version - missing graph.svg

    Using thug via docker installation, very good tool. Recently installed the new version but it seems the graph.svg file is not being created within the analysis folder.

    Is this feature removed completely or can it be enabled?

    Thanks

    configuration 
    opened by arunkhan1984 13
  • First time set-up problems.

    First time set-up problems.

    Hi, firstly I am on Ubuntu 16.04 and have gone through the Thug installation guide multiple time and am currently stuck as where to go from here. I installed all packages except HoneyAgent & VirusTotal (both optional). My problem is that when I run thug --list-ua I get this:

    
    [2017-03-28 10:11:03] [HTML Classifier] Skipping not existing default classification rule file
    [2017-03-28 10:11:03] [HTML Classifier] Skipping not existing default filter file
    [2017-03-28 10:11:03] [JS Classifier] Skipping not existing default classification rule file
    [2017-03-28 10:11:03] [JS Classifier] Skipping not existing default filter file
    [2017-03-28 10:11:03] [VBS Classifier] Skipping not existing default classification rule file
    [2017-03-28 10:11:03] [VBS Classifier] Skipping not existing default filter file
    [2017-03-28 10:11:03] [URL Classifier] Skipping not existing default classification rule file
    [2017-03-28 10:11:03] [URL Classifier] Skipping not existing default filter file
    [2017-03-28 10:11:03] [Sample Classifier] Skipping not existing default classification rule file
    [2017-03-28 10:11:03] [Sample Classifier] Skipping not existing default filter file
    [2017-03-28 10:11:03] [Text Classifier] Skipping not existing default classification rule file
    [2017-03-28 10:11:03] [Text Classifier] Skipping not existing default filter file
    
    Synopsis:
        Thug: Pure Python honeyclient implementation
    
        Available User-Agents:
    

    So lots of skipping, I don't know if that is a problem but no User-Agents? Also when I try to run Thug I get the following:

    [2017-03-28 10:15:41] [HTML Classifier] Skipping not existing default classification rule file
    [2017-03-28 10:15:41] [HTML Classifier] Skipping not existing default filter file
    [2017-03-28 10:15:41] [JS Classifier] Skipping not existing default classification rule file
    [2017-03-28 10:15:41] [JS Classifier] Skipping not existing default filter file
    [2017-03-28 10:15:41] [VBS Classifier] Skipping not existing default classification rule file
    [2017-03-28 10:15:41] [VBS Classifier] Skipping not existing default filter file
    [2017-03-28 10:15:41] [URL Classifier] Skipping not existing default classification rule file
    [2017-03-28 10:15:41] [URL Classifier] Skipping not existing default filter file
    [2017-03-28 10:15:41] [Sample Classifier] Skipping not existing default classification rule file
    [2017-03-28 10:15:41] [Sample Classifier] Skipping not existing default filter file
    [2017-03-28 10:15:41] [Text Classifier] Skipping not existing default classification rule file
    [2017-03-28 10:15:41] [Text Classifier] Skipping not existing default filter file
    [2017-03-28 10:15:41] [WARNING] VirusTotal disabled (no configuration file found)
    [2017-03-28 10:15:41] [CRITICAL] Logging subsystem not initialized (configuration file not found)
    Traceback (most recent call last):
      File "/usr/local/bin/thug", line 11, in <module>
        sys.exit(main())
      File "/usr/local/lib/python2.7/dist-packages/thug/thug.py", line 334, in main
        Thug(sys.argv[1:])()
      File "/usr/local/lib/python2.7/dist-packages/thug/ThugAPI/ThugAPI.py", line 86, in __call__
        self.analyze()
      File "/usr/local/lib/python2.7/dist-packages/thug/thug.py", line 324, in analyze
        ThugPlugins(PRE_ANALYSIS_PLUGINS, self)()
      File "/usr/local/lib/python2.7/dist-packages/thug/Plugins/ThugPlugins.py", line 44, in __init__
        self.get_plugins()
      File "/usr/local/lib/python2.7/dist-packages/thug/Plugins/ThugPlugins.py", line 68, in get_plugins
        for p in os.listdir(PLUGINS_PATH):
    OSError: [Errno 2] No such file or directory: '/etc/thug/plugins'
    
    

    I have followed the installation guide step by step and it is now at the Usage section? Am I meant to install the Docker too or is there something else I have missed?

    Thank you for your help in advance!

    opened by Waffles-2 11
  • ReferenceError

    ReferenceError

    There is malicious code and normal code in javascript. If a reference error occurs in the normal code, the malicious code will not be analyzed in the future. Can I pass(skip) the reference error?... and then I want to continue analyzing the malicious code

    [2018-11-12 21:47:41] Traceback (most recent call last):    File "/usr/lib/python2.7/site-packages/thug-0.9.37-py2.7.egg/thug/Debugger/Shellcode.py", line 162, in run      result = self.ctxt.eval (self.script) ReferenceError: ReferenceError: functions is not defined (@ 1: 0) -> functions.validateAndSubmitForm ();

    not an issue 
    opened by parknom 10
  • Data in mongodb

    Data in mongodb

    Hi, I wonder how possible it would be to push most of the data in analysis.xml/avlog.json and graph.svg into mongodb so it can be used by eg. a web interface.

    I really want to use thug, but I find the lack of a web interface for viewing the reports quite the problem.

    Ideally I guess a JSON version of the MAEC schema would be the best, but that kinda goes against the MAEC specifications, for now.. :)

    An example of a web interface I could make with having all the data in mongodb could be something like http://two.mrfjo.org/02906d5b-a7cd-47f8-9885-6e80eecf967a/

    enhancement 
    opened by espenfjo 10
  • Fix infinite recursion problem in Window.__getattr__

    Fix infinite recursion problem in Window.__getattr__

    Window object has infinite recursion when the following two conditions:

    1. Check whether the V8 JSContext has been initialized through getattr(). It would be a lookup loop which always calls getattr() since the code uses self.context before initializing V8 JSContext.

    Fix by: Raise attribute error if getattribute() can't find "_context" variable.

    1. Get the nonexistent variable or function by "self.context.eval(name)". When V8 JSContext can't find the variable, it will call getattr() again. It also becomes a lookup loop.

    Fix by: Avoid to call getattr() from V8Context internal.

    > python -m cProfile thug.py -l ../samples/Events/testEvent10.html

    Before fix: ncalls tottime percall cumtime percall filename:lineno(function) 588/5 0.193 0.000 0.759 0.152 Window.py:138(getattr) 6825 0.003 0.000 0.003 0.000 Window.py:196(window) 616/344 0.378 0.001 0.599 0.002 Window.py:850(context)

    After fix: ncalls tottime percall cumtime percall filename:lineno(function) 55/37 0.014 0.000 0.014 0.000 Window.py:139(getattr) 35 0.000 0.000 0.000 0.000 Window.py:206(window) 82/4 0.004 0.000 0.020 0.005 Window.py:860(context)

    opened by Joseph-CHC 10
  • javascript that fools thug

    javascript that fools thug

    Saw this on a landing page, thug did not follow it:

    <script type="text/javascript">
        setTimeout("testTime()", 0);
        function testTime() {
            location = "/";
        }
     </script>
    
    defect 
    opened by evilscheme 10
  • ImportError: libemu.so.2: cannot open shared object file: No such file or directory

    ImportError: libemu.so.2: cannot open shared object file: No such file or directory

    I have successfully installed V8 and PyV8. i have tested it and the result is OK.

    but while i was executing python thug.py -h,, the error was appeared. the errors look like:

    [email protected]:/home/kafin/thug/src# sudo python thug.py -h Traceback (most recent call last): File "thug.py", line 31, in from DOM import Window, DFT, MIMEHandler, SchemeHandler File "/home/kafin/thug/src/DOM/Window.py", line 32, in from .Location import Location File "/home/kafin/thug/src/DOM/Location.py", line 22, in import DFT File "/home/kafin/thug/src/DOM/DFT.py", line 20, in import pylibemu ImportError: libemu.so.2: cannot open shared object file: No such file or directory

    anyone got also this error, or how do i solve this?

    thanks

    opened by kafin 10
  • Problem with shellcode encoding - MongoDB logging

    Problem with shellcode encoding - MongoDB logging

    Hello, I think that the shellcode is not properly handled and stored in MongoDB. I get error messages like this one when thug tries to decode the hex encoded shellcode:

    ...
      File "/usr/local/lib/python2.7/dist-packages/thug/Logging/ThugLogging.py", line 125, in add_shellcode_snippet
        m(snippet, language, relationship, tag.hex, method)
      File "/usr/local/lib/python2.7/dist-packages/thug/Logging/modules/MongoDB.py", line 416, in add_code_snippet
        'snippet'      : self.fix(snippet),
      File "/usr/local/lib/python2.7/dist-packages/thug/Logging/modules/MongoDB.py", line 408, in fix
        return thug_unicode(data).replace("\n", "").strip()
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xeb in position 4: ordinal not in range(128) 
    

    The problem is that the shellcode contains non printable characters and thus can not be stored in decoded form. Also even when it is possible to decode the shellcode from unicode encoding the output is not as useful as the original hex encoded form. This exception also breaks the analysis and thus it is not properly finished. I think that the shellcode should not be decoded and should be stored in its original form. What do you think about that? Thank you.

    Stanislav

    defect 
    opened by standa4 9
  • Timeout option not working properly

    Timeout option not working properly

    Hello Is it possible that the timeout option (-T) is not working as intended? I was scanning some targets that take a long time or never finish at all (longer than the 600s default timeout), where I noticed that the runs actually don't finish after the default timeout. I still see the timeout message in the log: [2019-03-19 09:09:30] The analysis took more than 60 second(s). Aborting! however the run is not stopped as result, rather it continues as if nothing happened. The same behaviour was occurring after choosing different targets and a shorter timeout.

    I am running thug inside a docker container and am starting the scans with the following command (short timeout for testing purposes): docker run --rm -it buffer/thug thug -T 10 -d <target url>

    I am misinterpreting what the timeout option is for? I am assuming it should abort the scan as soon as the timeout is reached, but maybe that is not the case.

    defect docker 
    opened by PinkSheep 8
Releases(v4.7)
Owner
Angelo Dell'Aera
Linux kernel hacker, deeply interested in every facet of computer and information security, intensely involved in exploring and analyzing new emerging threats.
Angelo Dell'Aera
Credit Card And SK Checker Written In Python

💳 Credit Card Checker (CC Checker) & Mass SK Checker & Generator 💳

Rimuru Tempest 53 Dec 31, 2022
An interactive python script that enables root access on the T-Mobile (Wingtech) TMOHS1, as well as providing several useful utilites to change the configuration of the device.

TMOHS1 Root Utility Description An interactive python script that enables root access on the T-Mobile (Wingtech) TMOHS1, as well as providing several

40 Dec 29, 2022
Small Python library that adds password hashing methods to ORM objects

Password Mixin Mixin that adds some useful methods to ORM objects Compatible with Python 3.5 = 3.9 Install pip install password-mixin Setup first cre

Joe Gasewicz 5 Nov 22, 2022
Springboot directory scanning

Springboot directory scanning

WINEZERO 87 Dec 28, 2022
Python tool for dumping flash via uboot reliably

Reliable Uboot Flash Dumper is a Python tool for dumping flash via uboot reliably. If you've ever had to dump flash via uboot and a serial connection and became frustrated about doing it several time

SecurityJon 25 May 10, 2022
Fat-Stealer is a stealer that allows you to grab the Discord token from a user and open a backdoor in his machine.

Fat-Stealer is a stealer that allows you to grab the Discord token from a user and open a backdoor in his machine.

Jet Berry's 21 Jan 01, 2023
Details,PoC and patches for CVE-2021-45383 & CVE-2021-45384

CVE-2021-45383 & CVE-2021-45384 There are several network-layer vulnerabilities in the official server of Minecraft: Bedrock Edition (aka Bedrock Serv

20 Apr 07, 2022
GDID (Google Dorks for Information Disclosure)

GDID (Google Dorks for Information Disclosure) Script made for your recon automation in Bug Bounty or Pentest. It will help you to find Information Di

Nischacid 5 Mar 10, 2022
Spring-0day/CVE-2022-22965

CVE-2022-22965 Spring Framework/CVE-2022-22965 Vulnerability ID: CVE-2022-22965/CNVD-2022-23942/QVD-2022-1691 Reproduce the vulnerability docker pull

iak 4 Apr 05, 2022
A proxy for asyncio.AbstractEventLoop for testing purposes

aioloop-proxy A proxy for asyncio.AbstractEventLoop for testing purposes. When tests writing for asyncio based code, there are controversial requireme

aio-libs 12 Dec 12, 2022
Cobalt Strike Beacon configuration extractor and parser.

Cobalt Strike Configuration Extractor and Parser Overview Pure Python library and set of scripts to extract and parse configurations (configs) from Co

Stroz Friedberg 102 Dec 18, 2022
A dynamic multi-STL, multi-process OpenSCAD build system with autoplating support

scad-build This is a multi-STL OpenSCAD build system based around GNU make. It supports dynamic build targets, intelligent previews with user-defined

Jordan Mulcahey 1 Dec 21, 2021
HTTP security headers for Flask

Talisman: HTTP security headers for Flask Talisman is a small Flask extension that handles setting HTTP headers that can help protect against a few co

Google Cloud Platform 854 Dec 30, 2022
Evil-stalker - A simple tool written in python, it is so simple that it is based on google dorks

evil-stalker How to run First of all, you must install the necessary libraries.

rock3d 6 Nov 16, 2022
Bypass ReCaptcha: A Python script for dealing with recaptcha

Bypass ReCaptcha Bypass ReCaptcha is a Python script for dealing with recaptcha.

Marcos Camargo 1 Jan 11, 2022
Python3 script for scanning CVE-2021-44228 (Log4shell) vulnerable machines.

Log4j_checker.py (CVE-2021-44228) Description This Python3 script tries to look for servers vulnerable to CVE-2021-44228, also known as Log4Shell, a v

lfama 8 Feb 27, 2022
Local File Inclusion Scanner and Exploiter

LFI-Paradise Local File Inclusion Scanner and Exploiter Features 1- Scanner 2- E

11 Sep 04, 2022
Threat Intelligence Gathering 威胁情报收集,旨在提高蓝队拿到攻击 IP 后对其进行威胁情报信息收集的效率。

0x00 介绍 tig Threat Intelligence Gathering 威胁情报收集,旨在提高蓝队拿到攻击 IP 后对其进行威胁情报信息收集的效率,目前已集成微步、IP 域名反查、Fofa 信息收集、ICP 备案查询、IP 存活检测五个模块,现已支持以下信息的查询: ✅ 微步标签 ✅ I

Wolf Group Security Team 698 Dec 09, 2022
FTP-Exploits is a tool made in python that contains 4 diffrent types of ftp exploits that can be used in Penetration Testing.

FTP-exploits FTP-exploits is a tool which is used for Penetration Testing that can run many kinds of exploits on port 21(FTP) Commands and Exploits Ex

1 Dec 26, 2021
Password database With special stuff

This is a Password database I made for myself, as I want to keep all my passwords in the same place. but still protected, shall anyone get access to the file. And so I made this simple password datab

9 Oct 30, 2022