Skip to content

About

Automated provisioning and hardening of Oracle Cloud Always Free instances for offensive security labs and DevSecOps pipelines.

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Repository files navigation

OCI SecOps Logo

OCI SecOps

Scripts to provision, audit and manage instances on Oracle Cloud Infrastructure (OCI), getting the most out of the Always Free tier (Ampere A1 ARM). The project automates the whole lifecycle of environments for offensive security (bug bounty / pentest) and defensive security (CI/CD AppSec).

Supported topologies

The orchestrator can split the Always Free allowance in different ways:

Option Topology Resources Best for
1 Full Power 4 OCPU / 24 GB RAM Heavy automation, brute force
2 Balanced Pair 2× (2 OCPU / 12 GB RAM) Splitting scan scopes
3 Small Cluster 4× (1 OCPU / 6 GB RAM) Master/worker setups, avoiding IP blocks
4 Single Instance 1 OCPU / 6 GB RAM Quick, isolated tests
5 CI Security 4 OCPU / 24 GB RAM Full SAST/DAST/SCA pipeline
6 Limited Full Power Detected automatically Reduced quotas per region

About option 6. Oracle documents 4 OCPU / 24 GB as the Always Free ceiling for Ampere A1, but the effective limit is set per tenancy and per region: accounts in high-demand regions often get half of that, without notice. Option 6 reads your real quota from the API at run time and sizes a single instance with the most it allows, boot volume included. If your limit is raised later, it follows on its own.


Always Free compliance

The provisioner enforces the Always Free ceilings locally, in every strategy, not only in option 6.

This is needed because the tenancy quota is not a reliable safety net. On a Free Tier account, going over the allotment is rejected by the API (LimitExceeded), which fails safe. On a Pay As You Go account, the same launch is accepted and billed. OCI does not expose through the API which case an account is, so the script does not leave that decision to it.

Layer When Protection
check_free_tier_budget() Before any launch Adds what is already in use to what will be created and blocks if it goes over 4 OCPU / 24 GB / 200 GB, or if the tenancy quota is not enough. Shows the balance and asks for explicit confirmation.
Per-instance guard Inside launch_vps() No single instance goes over the ceiling, whoever the caller is.
Fixed parameters In the launch command Explicit VM.Standard.A1.Flex shape and boot volume at VPU 10 (Balanced), without relying on CLI defaults.

The strategies that launch in parallel (options 2 and 3) are now blocked before the first instance starts when the quota cannot hold the total, avoiding the partial deploy that used to leave half the cluster running.


Components

Orchestration and lifecycle

  • oci_provision.sh: the main orchestrator. Maps the tenancy, compartments, VCNs and images; detects the real Ampere A1 quota through the API; applies the Always Free guardrails before deploying; injects the right post-configuration scripts for the chosen profile; waits for boot and runs the installation remotely over SSH.

  • oci_inventory.sh: audits Always Free usage (OCPUs, RAM, disks) across all compartments recursively. Compares real usage with two references, the effective tenancy quota and the Always Free ceiling, and reports the exact margin left for the next deploy. Warns when the quota exceeds Always Free (Pay As You Go accounts, where the excess is billed) and when the scan disagrees with the API's accounting, a sign of compartments without read permission.

  • oci_teardown.sh: terminates instances and destroys their boot volumes, avoiding charges and orphaned disks after testing.

  • oci_dashboard.sh: live monitoring panel. Shows the state, public IP and resources of every instance, refreshing every 15 seconds.

Hardening (cloud-init)

  • harden.sh: injected through cloud-init into pentest instances. Applies kernel tuning (sysctl: TCP SYN flood, IP spoofing), disables SSH password authentication, restricts ports with UFW, configures Fail2Ban and creates a dynamic 4 GB swap.

  • harden_ci.sh: hardening variant for CI instances. Includes Docker Engine and the extra sysctl settings that SonarQube's embedded Elasticsearch needs (vm.max_map_count).

Post-deploy toolchains

  • pentest_arsenal.sh: installs the full offensive toolset on the hardened instance: native ARM64 Go, web recon tools (Subfinder, Httpx, Nuclei, Ffuf, etc.), infrastructure pentest tools (Impacket, NetExec, Certipy, Sliver C2, Metasploit, Ligolo-ng) and an XFCE + VNC desktop (optional, with --vnc).

    Profiles: --web, --infra, --full (default), --vnc.

  • setup_ci.sh: CI Security profile only. Deploys the AppSec trio in Docker containers:

    • SonarQube Community + PostgreSQL (reached through an SSH tunnel on port 9000)
    • OWASP ZAP (zap-baseline and zap-api wrappers for DAST scans)
    • OWASP Dependency-Check (dep-check wrapper for SCA, with a pre-populated NVD cache)

Requirements

  • Native Linux or WSL2
  • OCI CLI installed and configured (~/.oci/config)
  • An SSH key pair saved as ~/.ssh/oci_vps_key and ~/.ssh/oci_vps_key.pub
  • jq installed locally

Configuration

.env: provisioning credentials

Required before the first run. It holds the credentials injected into the instances during deploy:

cp .env.example .env
# edit .env with your values
Variable Description
NVD_API_KEY NVD API key for OWASP Dependency-Check. Get one for free at nvd.nist.gov/developers/request-an-api-key
VNC_PASSWORD VNC server password (--vnc profile)
SONAR_DB_PASSWORD Password of SonarQube's internal PostgreSQL database

.env.ci: SonarQube token (after deploy)

After the CI instance is deployed and you first sign in to SonarQube (http://localhost:9000 through an SSH tunnel), create a user token and export it before running the scanner:

# on the CI instance, or locally through the tunnel
export SONAR_TOKEN=sqp_...
sonar-scan

Optionally, save it in .env.ci to reuse across sessions; the file is already in .gitignore:

echo "SONAR_TOKEN=sqp_..." > .env.ci
source .env.ci && sonar-scan

Usage

cd scripts/
chmod +x *.sh
./oci_provision.sh

The orchestrator walks you through provisioning interactively. At the end it prints the SSH command for each instance it created.

Tuning the capacity hunt

A1 capacity opens in short, unpredictable windows, so provisioning works with a time budget instead of a fixed number of attempts. Polling uses the CreateComputeCapacityReport API, which has no side effects and a much looser rate limit than launch_instance, and only fires a real launch when the report says AVAILABLE, in any AD of the region.

Variable Default What it does
HUNT_MINUTES 180 Total hunting window per instance
POLL_SECONDS 30 Interval between capacity polls
BLIND_POLL_SECONDS 60 Interval when the capacity report is not available
MAX_RATE_RETRIES 6 Consecutive 429 responses tolerated
BOOT_TIMEOUT_SECONDS 900 Maximum wait until the instance is RUNNING
# 8-hour hunt, polling every 20 s
HUNT_MINUTES=480 POLL_SECONDS=20 ./oci_provision.sh

To check capacity by hand, without provisioning anything:

oci compute compute-capacity-report create \
  --compartment-id <tenancy-ocid> \
  --availability-domain <your-AD> \
  --shape-availabilities '[{"instanceShape":"VM.Standard.A1.Flex","instanceShapeConfig":{"ocpus":2.0,"memoryInGBs":12.0}}]'

Standalone utilities

# Always Free resource inventory
./oci_inventory.sh

# Live monitoring panel
./oci_dashboard.sh

# Terminate instances
./oci_teardown.sh

Troubleshooting

LimitExceeded when provisioning

"code": "LimitExceeded",
"message": "The following service limits were exceeded: standard-a1-core-count, ..."

Your A1 quota is smaller than the chosen strategy. It is not an authentication error: the call was authenticated and authorized normally; the API refused it because of the quota. Check your real limit:

oci limits resource-availability get \
  --service-name compute \
  --limit-name standard-a1-core-count \
  --compartment-id <tenancy-ocid> \
  --availability-domain <your-AD>

Use standard-a1-memory-count instead of standard-a1-core-count for RAM. Option 6 adjusts to these values automatically.

To try to raise the limit: Console → Governance & Administration → Limits, Quotas and Usage → standard-a1-core-count → Request a service limit increase. The request is free, but in regions under capacity pressure it may be denied for the very reason the limit was cut.

TooManyRequests (HTTP 429)

"code": "TooManyRequests",
"message": "Too many requests for the user"

API rate limit. OCI limits launch_instance calls per user, and repeated attempts, including the ones that failed for other reasons, count toward the limit. That is why the hunt polls the capacity report and only spends a launch_instance call when there is capacity; in practice the 429 stops showing up.

When it still happens, launch_vps() applies exponential backoff (60 s → 120 s → 240 s → 480 s → 600 s). The cutoff is on consecutive 429s (MAX_RATE_RETRIES, default 6): any normal response resets the counter, so a long hunt does not die from 429s accumulated over hours.

If the limit persists after that, wait about 15 minutes without new attempts before running again: every attempt during the block renews the count.

Out of host capacity

There is no free A1 hardware in the region right now, which is different from a quota problem. The hunt keeps polling every AD in the region within the HUNT_MINUTES window (3 h by default) and launches as soon as hardware shows up. Low-demand hours, such as late night UTC, improve the odds; in chronically saturated regions, run with HUNT_MINUTES=480 or more.

Shape not available in the region

Newer regions may not offer the whole Always Free catalog. Check what actually exists before trusting the official table:

oci compute shape list --compartment-id <tenancy-ocid> --all \
  | jq -r '[.data[].shape] | unique | .[]'

A quota often shows up filled in (for example vm-standard-e2-1-micro-count = 2) while the matching shape does not exist in the region: quota on paper, with no hardware to run it.

License

MIT

About

Automated provisioning and hardening of Oracle Cloud Always Free instances for offensive security labs and DevSecOps pipelines.

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages