Generator: Fully automatically generate numerous injection codes for web application assessment
Fully automatically generate numerous injection codes for web application assessment.
PyGenerator can fully automatically generate numerous injection codes for detecting web app vulnerabilities.
The current version is beta. Therefore, it can only generate injection codes of reflected Cross Site Scripting (XSS).
Following injection codes were generated by PyGenerator.
Overview of Genetic Algorithm
Generate a population composed of multiple individuals.
Each individual is composed of multiple genes.
Step.2. Fitness / Evaluation
Evaluate the fitness of each individual to the environment.
Give high scores to superior individuals based on the evaluation result.
Select individuals with a high score from the population. Individuals with a low score are culled.
Swap part of the genes of the selected individuals and generate new individuals. The new individuals (offspring) comprise the next population (next generation).
Select some individuals stochastically from the new population and randomly swap some of the genes. Mutations may generate individuals that are more adapted to the environment.
After completing all the steps, repeat Step 2 to Step 5 for the next population. This cycle is repeated until the termination condition is met. Generally, conditions such as “when the number of generations reaches the upper limit” or “when the score average of all individuals exceeds the threshold” are set as the termination condition.
By repeating this evolutionary computing for many generations, only the “individuals with an excellent combination of genes” that are adapted to the environment will survive.
By the way, what “adapted to the environment” means would change depending on the type of the task. In the abovementioned bullet train example, the fitness to the environment is judged by evaluating “how small the air resistance becomes”. In the fuzzer example, it is by evaluating “how high the coverage becomes”. Therefore, in order to carry over the genes of excellent individuals to the next generations, it is very important to design an “evaluation function” that evaluates the adaptability to the environment.
Please refer to this blog for detail explanation of pyGenerator.
PyGenerator consists of two algorithms that Genetic Algorithm (GA) and Generative Adversarial Networks (GAN).
The injection codes are generated in two steps.
- Gather the components of injection codes.
- Create some injection codes using Genetic Algorithm.
- Generate numerous injection codes using Generative Adversarial Networks.
Step.0 Git clone pyGenerator’s repository.
Step.1 Install required python packages.
Step.2 Get the web driver for selenium.
[!] I use the Google chrome driver in this example.
You have to download the chrome driver for selenium.
And you have to move downloaded driver file to web_drivers directory.
Step.3 Get html checker (tidy).
[!] I use the tidy 5.4.0 win64 in this example.
You have to download the
tidy 5.4.0 win64.
And you have to move tidy directory to pyGenerator root.
Step.0 Execute pyGenerator
Step.1 Check generated injection codes.
Copyright 2017 Isao Takaesu