Welcome to PTaaS (short form of Penetration Testing as a Service) official document page. PTaaS is a service for performing automated penetration testings over cloud.
It is a network security application that reduces costs of a penetration testing. Also, it provides more observability over the testing process.
Our goal is to reduce penetration testing costs in a cloud environment. Also, we are looking forward to increase the process velocity and reduce the human errors.
Installation
In order to install this application, you can use docker or helm charts. Docker is useful when you want to install
the application on a bare-metal or on your local system. However, charts are being used to install the application
on a Kubernetes cluster.
Docker
For installing the application using Docker, first make sure that you have
docker & docker-compose command lines
installed on your machine. You may check
this link to install these dependencies.
Then use the following script in order to download the project deployment files and start the application:
#!/bin/bash
git clone https://github.com/ptaas-tool/deployments
cd deployments
# deploy the application
./deploy.sh up ptaas
Charts
In order to use
Helm Charts, first install the following dependencies on your machine:
After that use the following script in order to start the application on a Kubernetes cluster.
#!/bin/bash
git clone https://github.com/ptaas-tool/deployments
# deploy the application
helm install ptaa ptaas
Configs
Application configs are written into
YAML format. There are two base config files for this application. The
base config and gatway configs which are as follow:
core:
port: 9090
enable: true
workers: 1
secret: "#wercV89Qwerc09"
mysql:
host: "mysql-container"
port: 3306
user: root
pass: "mauFJcuf5dhRMQrjj"
database: "ptaas"
migrate: true
ai:
enable: false
method: "random"
limit: 10
factor: 7
scanner:
enable: false
defaults:
- "2fa"
command: "python3 scanner.py"
flags:
- "host"
- "endpoints"
- "type"
- "protocol"
migrate:
root: "admin"
pass: "12345"
enable: false
ftp:
host: "http://ftp-server:9091"
secret: "8bVc13329vn23"
access: "nnvXiu%2234nvoo3n1i98n3v"
Usage
Penetration testing as a service (PTaaS) is a form of cybersecurity service where organizations hire third-party security experts to conduct simulated attacks on their IT infrastructure, networks, applications, and other digital assets. The primary goal of penetration testing is to identify vulnerabilities and weaknesses in the organization's security defenses before malicious actors exploit them.
The main objective of PTaaS is to assess the security posture of an organization's digital assets by simulating real-world cyberattacks. This helps identify vulnerabilities and weaknesses that could be exploited by attackers. PTaaS can include various types of penetration testing, including network penetration testing, web application penetration testing, mobile application penetration testing, wireless network penetration testing, and social engineering testing.
Penetration testing typically follows a structured methodology that involves several phases, including reconnaissance, enumeration, vulnerability assessment, exploitation, and reporting. Security experts use a combination of automated tools and manual techniques to identify and exploit vulnerabilities. This approach ensures a thorough examination of the organization's security defenses.
PTaaS offers several benefits to organizations. It helps identify vulnerabilities proactively, allowing organizations to address them before they are exploited by malicious actors, thus reducing the risk of data breaches and cyberattacks. Additionally, many regulatory standards and industry best practices require organizations to conduct regular penetration testing to ensure compliance with security requirements. Furthermore, penetration testing provides valuable insights into the effectiveness of an organization's security defenses, allowing them to improve their security posture.
PTaaS can be offered through various engagement models, including one-time engagements, ongoing subscriptions, and customized engagements tailored to the organization's specific needs and requirements. Penetration testing results are typically documented in a detailed report that outlines the vulnerabilities discovered, the potential impact of these vulnerabilities, and recommendations for remediation.
Despite its benefits, PTaaS may face challenges such as cost considerations, resource constraints, and the need for skilled cybersecurity professionals to perform the testing effectively. However, penetration testing as a service remains a valuable cybersecurity offering that helps organizations identify and mitigate security risks to protect their digital assets from cyber threats.
Components
In the next sections we are going to check the four main parts of the system.
Base-API
This is PTaaS base api system. In this service we use scanner, ftp server, and ml components to
perform our penetration testing stages. In pkg/models directory we defined our base database modules
and system modules to be used in all other system components.
Base API docker image address:
docker pull amirhossein21/ptaas-tool:base-v0.X.X
Setup base API in docker container with following command:
docker run -d \
-v type=bind,source=$(pwd)/config.yml,dest=/app/config.yml
-p 80:80 \
amirhossein21/ptaas-tool:base-v0.X.X
Database
Application uses the latest version of
MySQL. If you want to migrate the modules, just set the following
configs in base-api config file:
mysql:
host: "mysql-container"
port: 3306
user: root
pass: "mauFJcuf5dhRMQrjj"
database: "ptaas"
migrate: true
migrate:
root: "admin"
pass: "12345"
enable: false
Scanner
Open source tool to perform API security scan in PTaaS.
This scanner uses nmap in order to get some details about our target. In this app, we get system information, critical issues, system vulnerabilities, and system dependencies. After that we return a list of possible vulnerabilities that might be used in a penetrating testing for that target.
pip install -r requirements.txt
python scanner.py --host webmail.aut.ac.ir
Output:
[
{
"vuln": "injection",
"attacks": [ "sql injection", "graphql injection" ]
"path": [
"/docs/{doc-name}",
"/docs?sort_by={sorting-field}",
],
"host" : {
"ip": "127.0.0.2",
"port": 8080
}
}
]
ML
Implementing a machine learning model in order to find the attacks that can be performed during a penetration testing by using analysis result data which consists of system vulnerabilities, bugs, and bad smells.
In order to execute the model to see its results use the following command:
jupyter nbconvert --execute ./notebook/analysis_data.ipynb
Gateway
Gateway is the PTaaS restful API for handling client http requests. This module handles the user interface logic in order to communicate with base-api and ftp-server. It is the system main gateway app.
Setup gateway service in docker container with following command:
docker run -d \
-v type=bind,source=$(pwd)/config.yaml,dest=/app/config.yaml \
-p 80:80 \
amirhossein21/ptaas-tool:gateway-v0.X.X
Make sure to create config.yaml file with the following variable init:
http:
port: 8080
core: 'http://localhost:9090/api'
core_secret: 'secret'
dev_mode: true
jwt:
private_key: 'super'
expire_time: 180 # minute
mysql:
host: 'localhost'
port: 3306
user: root
pass: ''
database: 'apt'
migrate: false
ftp:
host: 'http://localhost:9091'
secret: 'secret'
access: 'access'
FTP-Server
This is file manager component of our system. In this app we upload our attack scripts, we execute attack scripts, and we download the results. This system provides an interface in order to manage scripts and logs files from core app.
Setup ftp server in docker container with following command:
docker run -d \
-e HTTP_PORT=80 \
-p 80:80 \
amirhossein21/ptaas-tool:ftp-v0.X.X
Env variables:
- HTTP_PORT which is the system port
- ACCESS_KEY which is used to block download access for files
- PRIVATE_KEY which is used to give execute script system call enable only for core
- MINIO_CLUSTER is the minio configs. access:secret@endpoint&bucket&true
Object Storage
Application uses MinIO object storage for storing objects using S3 APIs.
Libatks
Put your new attacks in libatks directory. If you add draf at the end, it will be ignored. Make sure to have only one main.go file for your attack with the following code in the beginning of the main function.
log.SetOutput(os.Stdout)
var (
hostFlag = flag.String("host", "localhost", "target host address")
endpointsFlag = flag.String("endpoints", "/", "target specific endpoints")
paramsFlag = flag.String("params", "", "system parameters for testing")
)
flag.Parse()
endpoints := strings.Split(*endpointsFlag, ",")
paramSet := strings.Split(*paramsFlag, "&")
params := make(map[string]string)
for _, item := range paramSet {
parts := strings.Split(item, "=")
params[parts[0]] = parts[1]
}
log.Println(*hostFlag)
log.Println(endpoints)
log.Println(params)
Dashboard
Automated penetration testing UI implemented by Vue.js framework. A user interface to use PTaaS application. In order to setup the user interface, first make sure to have gateway api, base api, and ftp server up and running. After that read the manuals to setup the ui app in your kubernetes cluster.
Setup ui application in docker container with following command:
docker run -d \
-v type=bind,source=$(pwd)/.env,dest=/app/.env \
-p 80:80 \
amirhossein21/ptaas-tool:dashboard-v0.X.X