Jump to content
Welcome, Guest
Existing user? Sign In

Sign In



Sign Up
The MatriX
  • Welcome To Ghbsys
  • CS GO Streaming Version is released. Have fun streaming while cheating!
  • Have a Payment Issue? Send us a Support ticket.
  • Make a thread if you need support or join our discord for live support.
  • Have Suggestions? Make a thread and you'll earn Ghbsys Points for implemented suggestions.
  • Join our discord to stay well connected! Don't forget to integrate your discord to the site
  • Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum

    Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum, like most online communities you must register to view or post in our community, but don't worry this is a simple free process that requires minimal information for you to signup. Be apart of [GHB] - GAmEhAcKbAsTaRdS Forum by signing in or creating an account.
    • Start new topics and reply to others
    • Subscribe to topics and forums to get email updates
    • Get your own profile page and make new friends
    • Send personal messages to other members.

    [PHP] Include File by Link.


    Sayuta
     Share

    Recommended Posts

    Ever saw this like ?page=home ; and it included Home page?

     

    Did u always used case's ? and tired of it? >_>"

     

    Mehh gonna explain u now how they do it! ;']

     

    First of all we start with the $_GET Variable..

    $page = $_GET['page'];

     

    This gets the ?page= Number.

     

    For the hackers under us, we are going to protect it against shell executers etc..

     

    <?
    $uri = $_SERVER['REQUEST_URI']; // The Current URI
    $search = array('chr(', 'chr=', 'chr%20', '%20chr', 'wget%20', '%20wget', 'wget(',
    'cmd=', '%20cmd', 'cmd%20', 'rush=', '%20rush', 'rush%20',
    'union%20', '%20union', 'union(', 'union=', 'echr(', '%20echr', 'echr%20', 'echr=',
    'esystem(', 'esystem%20', 'cp%20', '%20cp', 'cp(', 'mdir%20', '%20mdir', 'mdir(',
    'mcd%20', 'mrd%20', 'rm%20', '%20mcd', '%20mrd', '%20rm',
    'mcd(', 'mrd(', 'rm(', 'mcd=', 'mrd=', 'mv%20', 'rmdir%20', 'mv(', 'rmdir(',
    'chmod(', 'chmod%20', '%20chmod', 'chmod(', 'chmod=', 'chown%20', 'chgrp%20', 'chown(', 'chgrp(',
    'locate%20', 'grep%20', 'locate(', 'grep(', 'diff%20', 'kill%20', 'kill(', 'killall',
    'passwd%20', '%20passwd', 'passwd(', 'telnet%20', 'vi(', 'vi%20',
    'insert%20into', 'select%20', 'fopen', 'fwrite', '%20like', 'like%20',
    '$_request', '$_get', '$request', '$get', '.system', 'HTTP_PHP', '&aim', '%20getenv', 'getenv%20',
    'new_password', '&icq','/etc/password','/etc/shadow', '/etc/groups', '/etc/gshadow',
    'HTTP_USER_AGENT', 'HTTP_HOST', '/bin/ps', 'wget%20', 'uname\x20-a', '/usr/bin/id',
    '/bin/echo', '/bin/kill', '/bin/', '/chgrp', '/chown', '/usr/bin', 'g\+\+', 'bin/python',
    'bin/tclsh', 'bin/nasm', 'perl%20', 'traceroute%20', 'ping%20', '.pl', 'lsof%20',
    '/bin/mail', '.conf', 'motd%20', 'HTTP/1.', '.inc.php', 'config.php', 'cgi-', '.eml',
    'file\://', 'window.open', '<script>', 'javascript\://','img src', 'img%20src','.jsp','ftp.exe',
    'xp_enumdsn', 'xp_availablemedia', 'xp_filelist', 'xp_cmdshell', 'nc.exe', '.htpasswd',
    'servlet', '/etc/passwd', 'wwwacl', '~root', '~ftp', '.js', '.jsp', 'admin_', '.history',
    'bash_history', '.bash_history', '~nobody', 'server-info', 'server-status', 'reboot%20', 'halt%20',
    'powerdown%20', '/home/ftp', '/home/www', 'secure_site, ok', 'chunked', 'org.apache', '/servlet/con',
    '<script', 'UPDATE', 'SELECT', 'DROP', '/robot.txt' ,'/perl' ,'mod_gzip_status', 'db_mysql.inc', '.inc', 'select%20from',
    'select from', 'drop%20', '.sys', '.ini', '.shell', 'getenv', 'http_', '_php', 'php_', 'phpinfo()', '<?php', '?>', 'sql='); // All the values we dont want 
    $value = str_replace($search, '', $uri); // Replace them with nothing, if theres something in it
    
    if($uri != $value){ // If it got replaced, Say a error.
    die('Shit Happend'); // Unlike me, u can put something else here;). but i just like to tease hackers.
    }
    $page = $_GET['page'];

     

    After being a bit 'amazed' by the above protection code,, YES its mine, and YES i keep logs whom tried to hack me, after 3 times ban IP by my firewall >< but thats just a bit too advanced from what im trying to teach you now.

     

    Now we got what ?page= Says.. we want the extension of the file!

    we do that just by adding the following variable :

    $ext = '.php';

     

    Lets get our.. File.

    if(isset($page) && $page != ""){ // Look if there is a variable ?page= and that ?page= is not empty.
    if(file_exists($page.$ext)){ // Look ONCE there is a ?page=.. the variable with .php after it, Lets pretend the case is ?page=home it will look for a file home.php
    include($page.$ext); // Include the home.php
    } else { // If it doesnt exist..
    echo "Error 404. Page not found."; // Say page is not found..
    } else { // If there isnt a ?page=.. 
    echo "Home"; // say Home.
    }

     

     

    Summaray.

    <?
    $uri = $_SERVER['REQUEST_URI']; // The Current URI
    $search = array('chr(', 'chr=', 'chr%20', '%20chr', 'wget%20', '%20wget', 'wget(',
    'cmd=', '%20cmd', 'cmd%20', 'rush=', '%20rush', 'rush%20',
    'union%20', '%20union', 'union(', 'union=', 'echr(', '%20echr', 'echr%20', 'echr=',
    'esystem(', 'esystem%20', 'cp%20', '%20cp', 'cp(', 'mdir%20', '%20mdir', 'mdir(',
    'mcd%20', 'mrd%20', 'rm%20', '%20mcd', '%20mrd', '%20rm',
    'mcd(', 'mrd(', 'rm(', 'mcd=', 'mrd=', 'mv%20', 'rmdir%20', 'mv(', 'rmdir(',
    'chmod(', 'chmod%20', '%20chmod', 'chmod(', 'chmod=', 'chown%20', 'chgrp%20', 'chown(', 'chgrp(',
    'locate%20', 'grep%20', 'locate(', 'grep(', 'diff%20', 'kill%20', 'kill(', 'killall',
    'passwd%20', '%20passwd', 'passwd(', 'telnet%20', 'vi(', 'vi%20',
    'insert%20into', 'select%20', 'fopen', 'fwrite', '%20like', 'like%20',
    '$_request', '$_get', '$request', '$get', '.system', 'HTTP_PHP', '&aim', '%20getenv', 'getenv%20',
    'new_password', '&icq','/etc/password','/etc/shadow', '/etc/groups', '/etc/gshadow',
    'HTTP_USER_AGENT', 'HTTP_HOST', '/bin/ps', 'wget%20', 'uname\x20-a', '/usr/bin/id',
    '/bin/echo', '/bin/kill', '/bin/', '/chgrp', '/chown', '/usr/bin', 'g\+\+', 'bin/python',
    'bin/tclsh', 'bin/nasm', 'perl%20', 'traceroute%20', 'ping%20', '.pl', 'lsof%20',
    '/bin/mail', '.conf', 'motd%20', 'HTTP/1.', '.inc.php', 'config.php', 'cgi-', '.eml',
    'file\://', 'window.open', '<script>', 'javascript\://','img src', 'img%20src','.jsp','ftp.exe',
    'xp_enumdsn', 'xp_availablemedia', 'xp_filelist', 'xp_cmdshell', 'nc.exe', '.htpasswd',
    'servlet', '/etc/passwd', 'wwwacl', '~root', '~ftp', '.js', '.jsp', 'admin_', '.history',
    'bash_history', '.bash_history', '~nobody', 'server-info', 'server-status', 'reboot%20', 'halt%20',
    'powerdown%20', '/home/ftp', '/home/www', 'secure_site, ok', 'chunked', 'org.apache', '/servlet/con',
    '<script', 'UPDATE', 'SELECT', 'DROP', '/robot.txt' ,'/perl' ,'mod_gzip_status', 'db_mysql.inc', '.inc', 'select%20from',
    'select from', 'drop%20', '.sys', '.ini', '.shell', 'getenv', 'http_', '_php', 'php_', 'phpinfo()', '<?php', '?>', 'sql='); // All the values we dont want 
    $value = str_replace($search, '', $uri); // Replace them with nothing, if theres something in it
    
    if($uri != $value){ // If it got replaced, Say a error.
    die('Shit Happend'); // Unlike me, u can put something else;). but i just like to tease hackers.
    }
    $page = $_GET['page']; // get the ?page=
    $ext = '.php'; // file extension to include.
    
    if(isset($page) && $page != ""){ // Look if there is a variable ?page= and that ?page= is not empty.
    if(file_exists($page.$ext)){ // Look ONCE there is a ?page=.. the variable with .php after it, Lets pretend the case is ?page=home it will look for a file home.php
    include($page.$ext); // Include the home.php
    } else { // If it doesnt exist..
    echo "Error 404. Page not found."; // Say page is not found..
    } else { // If there isnt a ?page=.. 
    echo "Home"; // say Home.
    }
    ?>

     

     

    Now all you have to do is a make a LINK.

    <a href="?page=home">Home</a><br>
    <a href="?page=test">Test</a></br>
    <?
    $uri = $_SERVER['REQUEST_URI']; // The Current URI
    $search = array('chr(', 'chr=', 'chr%20', '%20chr', 'wget%20', '%20wget', 'wget(',
    'cmd=', '%20cmd', 'cmd%20', 'rush=', '%20rush', 'rush%20',
    ... rest of all the other code.
    ?>

     

    The first link will include home.php

    Secondary will include test.php.

     

     

    Hope i helped.

     

     

    Notice

    -I wont translate it into any other language

    -If there is a error, report me please.. think it won't be >< i would like fail if this sample code isn't right after my 6 years in coding PHP.

    Link to comment
    Share on other sites

    Hey, i really like your comments and this tut as well...

     

    Would you mind posting more tutorials like that? I often dont find the time for that :S

    Link to comment
    Share on other sites

    • 2 weeks later...

    Very nice tutorial. Please write more.

    Also like the array searching O.o

     

    But most of my pages just got 5-6 subpages so I just use case xD very safe..

    Link to comment
    Share on other sites

    Guest
    This topic is now closed to further replies.
     Share

    • Recently Browsing   0 members

      • No registered users viewing this page.
    ×
    ×
    • Create New...