Exemplo n.º 1
0
#################################
//Creating dynamic string for creating dynamic names
function num_gen($string_length, $characters)
{
    $string = '';
    for ($i = 0; $i < $string_length; $i++) {
        $string .= $characters[rand(0, strlen($characters) - 1)];
    }
    return $string;
}
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
//charset for dynamic generation of strings
// Generating a dynamic alfanumeric Table name with each purge.
$table = num_gen(10, $characters);
// Generating Secret key column.
$secret_key = "secret_" . num_gen(4, $characters);
//retrieve dynamic table name from database.
function table_name()
{
    include '../sql-connections/db-creds.inc';
    include '../sql-connections/sql-connect-1.php';
    $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema='{$dbname1}'";
    $result = mysql_query($sql) or die("error in function table_name()" . mysql_error());
    $row = mysql_fetch_array($result);
    if (!$row) {
        die("error in function table_name() output" . mysql_error());
    } else {
        return $row[0];
    }
}
//retrieve Column name from database.
Exemplo n.º 2
0
    echo "<br><br>\n";
}
include '../sql-connections/functions.php';
// Creating table
$sql = "CREATE TABLE IF NOT EXISTS {$dbname1}.{$table}\n\t\t(\n                id INT(2) UNSIGNED NOT NULL DEFAULT 1,\n\t\tsessid CHAR(32) PRIMARY KEY NOT NULL,\n\t\t{$secret_key} CHAR(32) NOT NULL,\n\t\ttryy INT(11) UNSIGNED NOT NULL DEFAULT 0 \n\t\t)";
if (mysql_query($sql)) {
    echo "[*]...................Creating New Table '{$table}' successfully";
    echo "<br><br>\n";
} else {
    echo "[*]...................Error creating Table: " . mysql_error();
    echo "<br><br>\n";
}
// creating random key
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
//characterset for generating random data
$sec_key = num_gen(24, $characters);
$hash = md5(rand(0, 100000));
//inserting Dummy data into table
$sql = "INSERT INTO {$dbname1}.{$table} VALUES (1, '{$hash}', '{$sec_key}', 0)";
if (mysql_query($sql)) {
    echo "[*]...................Inserted data correctly  into table '{$table}'";
    echo "<br><br>\n";
} else {
    echo "[*]...................Error inserting data: " . mysql_error();
    echo "<br><br>\n";
}
echo "[*]...................Inserted secret key '{$secret_key}' into table ";
echo "<br><br>\n";
if (isset($id)) {
    header("refresh:0;url={$id}");
}