How to use the farm.exploits.AbstractExploit function in farm

To help you get started, we’ve selected a few farm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github andgein / ctf-exploit-farm / exploits.examples / http_exploit.py View on Github external
#!/usr/bin/env python3

import re
import aiohttp

from farm.exploits import AbstractExploit


class HttpExploit(AbstractExploit):
    async def attack(self, hostname):
        # cookie_jar=aiohttp.CookieJar(unsafe=True) is needed to correct working on IP (not domain) hostnames
        async with aiohttp.ClientSession(cookie_jar=aiohttp.CookieJar(unsafe=True)) as session:
            async with session.get('https://en.wikipedia.org/wiki/Dog') as resp:
                self.logger.info('HTTP status is %d' % resp.status)
                text = await resp.text()

                count = re.findall(r'dog', text)
                self.logger.info('Dog exploit: found %d words "dog"' % len(count))

        return 'Test data U2M3QHS8VCH73R13ALX6R52LCO3E0UJ= flags-flags-flags GUDOITWYX4NSIM88KC23AQRWYDF2MPI='


if __name__ == '__main__':
    from farm.farms import Farm
    Farm.debug_exploit(HttpExploit(), '127.0.0.1')
github andgein / ctf-exploit-farm / exploits / quick_exploit.py View on Github external
from farm.exploits import AbstractExploit


class QuickExploit(AbstractExploit):
    async def attack(self, hostname):
        return ['1WBGKGVEZVULDS4SZ89A10GNPASQTFO=']
github andgein / ctf-exploit-farm / exploits.examples / quick_exploit.py View on Github external
#!/usr/bin/env python3

from farm.exploits import AbstractExploit


class QuickExploit(AbstractExploit):
    async def attack(self, hostname):
        return ['1WBGKGVEZVULDS4SZ89A10GNPASQTFO=']


if __name__ == '__main__':
    from farm.farms import Farm
    Farm.debug_exploit(QuickExploit(), '127.0.0.1')
github andgein / ctf-exploit-farm / exploits.examples / infinity_exploit.py View on Github external
#!/usr/bin/env python3

import asyncio

from farm.exploits import AbstractExploit


class InfinityExploit(AbstractExploit):
    async def attack(self, hostname):
        await asyncio.sleep(1000)
        return []


if __name__ == '__main__':
    from farm.farms import Farm
    Farm.debug_exploit(InfinityExploit(), '127.0.0.1')
github andgein / ctf-exploit-farm / exploits.examples / tcp_exploit.py View on Github external
#!/usr/bin/env python3

import asyncio

from farm.exploits import AbstractExploit


class TcpExploit(AbstractExploit):
    async def attack(self, hostname):
        reader, writer = await asyncio.open_connection(hostname, 8888)

        self.logger.info('Send "hello"')
        writer.write(b'hello\n')

        line = await reader.read(100)
        self.logger.info(f'Received line "{line}"')

        # Don't forget to close connection
        writer.close()

        return 'Test data U2M3QHS8VCH73R13ALX6R52LCO3E0UJ= flags-flags-flags GUDOITWYX4NSIM88KC23AQRWYDF2MPI='


if __name__ == '__main__':
github andgein / ctf-exploit-farm / farm / exploit_storage.py View on Github external
async def get_exploits(self):
        self.logger.info('Loading exploits from %s' % os.path.abspath(self.directory))
        AbstractExploit.clear_subclasses()
        for file_name in glob.glob(self.directory + '/**/*.py', recursive=True):
            self.logger.info('Try to load exploits from %s' % file_name)
            try:
                utils.import_module_from_file(file_name)
            except Exception as e:
                raise Exception('Can not load exploit from %s: %s' % (file_name, e), e)

        exploits_classes = AbstractExploit.get_all_subclasses()
        self.logger.info(
            'Found %d exploit classes: [%s]' % (
                len(exploits_classes),
                ', '.join(c.__name__ for c in exploits_classes)
            )
        )
        return [exploit_class() for exploit_class in exploits_classes]
github andgein / ctf-exploit-farm / farm / exploits.py View on Github external
def __init_subclass__(cls, **kwargs):
        AbstractExploit._subclasses.append(cls)
github andgein / ctf-exploit-farm / farm / exploit_storage.py View on Github external
async def get_exploits(self):
        self.logger.info('Loading exploits from %s' % os.path.abspath(self.directory))
        AbstractExploit.clear_subclasses()
        for file_name in glob.glob(self.directory + '/**/*.py', recursive=True):
            self.logger.info('Try to load exploits from %s' % file_name)
            try:
                utils.import_module_from_file(file_name)
            except Exception as e:
                raise Exception('Can not load exploit from %s: %s' % (file_name, e), e)

        exploits_classes = AbstractExploit.get_all_subclasses()
        self.logger.info(
            'Found %d exploit classes: [%s]' % (
                len(exploits_classes),
                ', '.join(c.__name__ for c in exploits_classes)
            )
        )
        return [exploit_class() for exploit_class in exploits_classes]
github andgein / ctf-exploit-farm / exploits / Ssss.py View on Github external
#!/usr/bin/env python
import re
import aiohttp

from farm.exploits import AbstractExploit


class Ssss(AbstractExploit):
    async def attack(self, hostname):
        async with aiohttp.ClientSession() as session:
            async with session.get('https://en.wikipedia.org/wiki/Dog') as resp:
                print(resp.status)
                text = await resp.text()

                current_word = ''
                find_count = 0
                for i in text:
                    if i == 'd' and current_word == '' or \
                       i == 'o' and current_word == 'd' or \
                       i == 'g' and current_word == 'do':
                            current_word += i
                            continue
                    elif current_word == 'dog':
                        find_count += 1