Exploit database

GH-7c3f210736b96137d01066be808bddae

0x0d3ad/cve-2021-3129

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2021-3129

36 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files7
0x0d3ad/cve-2021-3129Revision baf217c497da

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

lib/PHPGGC/Util.php

PHP · 1,717 bytes
<?php

namespace PHPGGC;

/**
 * Utility functions.
 */
class Util
{
    /**
     * Creates a file in the temporary directory.
     * 
     * @param string $name Filename
     * @param string $contents Contents of the file 
     * 
     * @return string Full path to the file
     */
    static public function temp_file($name, $contents)
    {
        $path = static::temp_path($name);
        file_put_contents($path, $contents);
        return $path;
    }

    /**
     * Creates a file in the temporary directory.
     * 
     * @param string $contents Contents of the file 
     * @param string $prefix A string to prepend to the filename
     * @param string $suffix A string to append to the filename
     * 
     * @return string Full path to the file
     */
    static public function rand_file($contents, $prefix='', $suffix='')
    {
        $path = static::rand_path($prefix, $suffix);
        file_put_contents($path, $contents);
        return $path;
    }
    
    /**
     * Returns a random temporary file path. 
     * 
     * @param string $prefix A string to prepend to the filename
     * @param string $suffix A string to append to the filename
     * 
     * @return string Full path to the file
     */
    static public function rand_path($prefix='', $suffix='')
    {
        return static::temp_path(
            $prefix . 'phpggc' . sha1(rand()) . $suffix
        );
    }

    /**
     * Returns a temporary file path whose basename is $name
     * 
     * @param string $name Name of the temporary file
     * 
     * @return string Full path to the file
     */
    static public function temp_path($name)
    {
        return sys_get_temp_dir() . DIRECTORY_SEPARATOR . $name;
    }
}