Skip to main content

Random generator of selected variables

Project description

Welcome to the generator library's documentation!


A generator library is a Python package that generates random data within set restrictions for you. A generator library is a Python package that generates random data within set restrictions for you. When you need to generate random individual values into a game for various players, this library is for you.


Compatibility

It supports only Python 3.6, and the above Python versions may work as well, however it is not guaranteed.

Basic Usage

Install with pip:

pip install generator.whl

Use generator.var_parser() to parse input variables in the file and then use generator.var_generator() to generate directory filled with generated data.

from generator.var_generator import generate
from generator.var_parser import parser_var_file

with open("input.yml") as file:
        seed = 1234
        variable_list = parser_var_file(file)
        print(file.read())
        
        # generated_text:
        #    type: text
        #
        #generated_password:
        #    type: password
        #
        #generated_username:
        #    type: username
        #
        #generated_port:
        #    type: port
        
        print(generate(variable_list, seed))
        
        # {'generated_text': 'I always did something i was not ready to do. I think that’s how you grow. When there’s that moment of ', 'generated_password': '6SBI1LEz', 'generated_username': 'persona', 'generated_port': '35608'}

        

How to use generator library with CTFd personal plugin?


To use generated values with individual flags within CTFd, try our generator application that manages all necessary for you. Just follow README.md instructions from Kosc-automated-problem-generation-app.

How it works


Generator pkg consists of var_generator.py where all required logical functions to generation process can be found, var_parser.py which function loads and processes the input data and finally var_object.py which stores class Variable.

var_generator.py

has function generator(list_of_Variable) with one argument that is a list filled with a Variable object. The result is that each object of Variable has been filled attribute generated_value with selected restrictions.

var_parser.py

has function parser_var_file(var_file) that reads all input data from var_file the Python file object and fill them into Variable objects that are returned as a list.

var_object.py

has a constructor with all possible attributes that have an impact on the generation process. The only mandatory arguments are name and type.

Supported variable types:


  • username - randomly chosen username
  • password - randomly generated characters
  • port - randomly generated number
  • text - randomly chosen sentence

How should variable in the input file look like?



You have to create one input file to set minimal or maximal generated values, set prohibited values for each generated variable.

keyword / type: username password text port IP
type
min - - -
max - - -
prohibited -
challenge_id
length - - -

bold - required attribute

normal - optional attribute

Structure of input file:

  <variable_name>:
     - type: <variable_type>  
        min: <value>
        max: <value>
        length: <value>
        prohibited: [<value>,<value>,...]
        challenge_id: <int>  

  <variable_name>:
        ...

Attributes:

  • min - Minimal value that still can be generated
  • max - Maximal value that still can be generated
  • length - Number variable of characters
  • prohibited - List of values that are excluded
  • challenge_id - ID of the challenge where will be generated flag uploaded

NOTE: challenge_id - works only with generator application (Kosc-automated-problem-generation-app)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file crczp_automated_problem_generation_lib-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for crczp_automated_problem_generation_lib-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 61ab3f88e14b0bea496387795b748437064aff8e1785b29f5a496264ceb4480d
MD5 ef17cda1472cf6b4209d4080d6ec91b6
BLAKE2b-256 27882abf1b712a7b7e834b9277ecf0847a890565ab201b81b72000b2200e6c3e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page