One, GPC
- Integer type not affected by GPC
- $_server variable is not protected by GPC
- $_files variable is not protected by GPC
- Wide byte injection
- Database operations easy to forget to add single quotation marks where: in ()/limit/order By/group by
- Only the value of the variable is filtered, but no key is filtered (some programs use key in the code, such as bringing in SQL statements)
- php5.3 later $_request no longer contain $_cookie (may result in incomplete filtering)
- When GPC is on, the GPC does not handle the key of the first dimensional variable in the case of PHP4 and php<5.2.1
- After the parameters are filtered and other operations are performed, such as substr,str_replace, this may cause the escape character to be deleted
Second, the characteristics
Functions/Syntax |
features |
In_array |
Type conversion of data prior to comparison |
Is_numeric |
Hexadecimal can bypass |
Intval |
Converts a string into a type, as long as the first character is a number to convert successfully |
Iconv |
Cause string truncation |
= = and = = = |
Double equals on both sides if the variable types are different, type conversions are done |
` ` |
Anti-quote Command execution |
“” |
Double quote variable parsing |
$a ($b) |
Dynamic function execution |
Is_file |
Use wildcard characters (<,>) to bypass |
Iii. Dangerous functions
- Eval
- Preg_replace
- Assert
- Call_user_func
- Call_user_func_array
- Create_function
- Array_map
- Include
- Require
- Require_once
- Include_once
- File_get_contents
- Highlight_file
- fopen
- ReadFile
- Fread
- Fgetss
- Fgets
- Parse_ini_file
- Show_source
- File ()
- Move_uploaded_file
- Exec
- System
- Popen
- PassThru
- Proc_open
- Pcntl_exec
- Shell_exec
` `
- $$
- Extract
- Parse_str
- Mb_parse_str
- Import_request_variables
- Encoding and decoding of variables
- Stripslashes
- Base64_decode
- Rawurldecode
- UrlDecode
- Unserialize
- Iconv
- Mb_convert_encoding
- Echo
- Print
- Printf
- sprintf
- Print_f
- vprintf
- Die
- Var_dump
- Var_export
- Serialize
- Unserialize
- __construct constructor function
- __destruct Destruction function
- __tostring automatically called when the object is printed
- Automatic invocation of __sleep serialization
- __wakeup automatically called when deserializing
- When Rand uses RAND to process sessions, attackers are prone to brute force to crack the session
Iv. reading Skills
- Read from the index file to learn about the program run process
- What security procedures are being handled at the entrance of the inspection program
- Check what security is being handled at the database entrance
- Check the code at the database connection
- Check login, register, retrieve password, bind mailbox, file management and file upload function points
- The process of procedure invocation and the flow of input data are cleared, which saves a lot of time and can be used to find a loophole.
V. NEW skills
- file contains truncation new pose: http://www.hackersb.cn/hacker/105.html
$a = $_get[' file ']; Include $a. '. html.php '; |
In the case where the protocol can be controlled, a new hello.html.php is created, the content is phpinfo (), then compressed into a zip, and then accessed Http://localhost/test/blog.php?file=zip://test.zip%23hello
Note: The variable name needs to be at the beginning to control the protocol
- function as above, protocol replacement for Phar, access by: http://localhost/test/blog.php?file=phar://1.zip/1.php
PHP Code Audit Basics