TAILIEUCHUNG - Pro PHP Security phần 7

Chiều dài dây là thường rất quan trọng, hơn loại. Chúng tôi sẽ thảo luận về chiều dài chi tiết sau này. Số Nếu bạn đang mong đợi một số (giống như một năm), sau đó nhận được một phản ứng nonnumeric phải nâng cao lá cờ đỏ cho bạn. Mặc dù nó là đúng rằng PHP xử lý tất cả các mục hình thức mặc định như các loại dây, | 290 CHAPTER 14 PREVENTING REMOTE EXECUTION function is not enough to sanitize input to eval because it leaves most PHP metacharacters intact and it may cause unexpected errors in otherwise safe values. You can sanitize the PHP metacharacters in a string with a function that combines addslashes to disarm all quotation marks and str_replace to translate other metacharacters . Here is code for such a function which can be found also as safeForEval. php in the Chapter 14 folder of the downloadable archive of code for Pro PHP Security at http . php II use this function to sanitize input for eval function safeForEval string II newline check nl chr io if strpos string nl exit string is not permitted as input. meta array escaped array 36 123 125 91 93 96 59 II addslashes for quotes and backslashes out addslashes string II str_replace for php metacharacters out str_replace meta escaped out return out You first check to see whether the input contains a newline character if it does you exit immediately with an appropriate message. Otherwise you sanitize any PHP metacharacters you find in the input string by transforming them using decimal ASCII encoding. This technique will effectively render harmless any attempts at remote PHP execution generating a parse error that can be caught by your application and handled appropriately. Use a custom function like safeForEval on any user input being passed as an argument to eval . Here is a deliberately simple example demonstrating the use of the function this code can be found also as in the Chapter 14 folder of the downloadable archive of code for Pro PHP Security at http . DOCTYPE html PUBHC - W3C DTD XHTMf Transitional EN http TR xhtmll DTD html xmlns http 1999 xhtml xml lang en head title safeForEval test title meta http-equiv content-type content text html charset utf-8 head body CHAPTER 14 PREVENTING REMOTE EXECUTION 291 php function

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.