Best laravel framework open-source packages.

Ctfdbbuilder

A database query builder for CTFer(出题专用/开发阶段/慎用)
Updated 1 year ago

DB Builder for CTFer

一个无任何防护的PHP数据库Builder,支持Mysql/Postgresql/Sqlite。

Install

composer require phith0n/ctfdbbuilder:dev-master

Usage

<?php
include 'vendor/autoload.php';

$connect = new \CTFDBBuilder\Connection('mysql', [
    'driver'    => 'mysql', // Db driver
    'host'      => 'localhost',
    'database'  => 'your-database',
    'username'  => 'root',
    'password'  => 'your-password',
    'charset'   => 'utf8mb4', // Optional
    'options'   => [ // PDO constructor options, optional
        \PDO::ATTR_TIMEOUT => 5,
        \PDO::ATTR_EMULATE_PREPARES => false,
    ],
]);
$builder = $connect->getBuilder();

Select (SQL injection)

<?php
$article = $builder->table('articles')->where('id', '=', $_GET['id'])->first();
<?php
$article = $builder->table('users')->where('age', '>', $_GET['age'])->first();
<?php
$article = $builder->table('users')->orderBy('age', 'desc')->get();
<?php
$article = $builder->table('users')->select('COUNT() AS `cnt`')->first();
<?php
$article = $builder->table('users')->where('username', $_POST['username'])->where('password', md5($_POST['password']))->first();