Bài tập  /  Bài đang cần trả lời

Tìm lỗi sai trong đoạn chương trình sau

<?
echo "<pre>".file_get_contents("/etc/passwd")."</pre>";
?>
works on most servers, also:
<?
echo "<pre>".file_get_contents("/home/vhosts/anothersite/public_html/theirscript.php")."</pre>";
?>
will work on a few badly configured servers.

5 trả lời
Hỏi chi tiết
351
1
5
Elon Musk
01/09/2020 05:31:17
+5đ tặng
alternatively, if there's a vulnerable script on that server, someone could exploit it to read your PHP code.

example:
vuln.php (very simplified)
<?
echo file_get_contents($_GET['thefile']);
?>

then someone could request this:
vuln.php?thefile=/path/to/your/script.php
and receive the source to your file.

while none of your scripts may be vulnerable, if you're on a shared server, any of the other sites hosted on that server might be exploitable.

and yes, it's unlikely that vuln.php will exist exactly as in the example, but lots of scripts read files, and if the paths to the files are sent via user data (get,post,cookie), then they can be exploited in this way.

Also, if someone is on a shared server, they can sometimes read all the file on the server, eg:

read.php:
<?
echo "<pre>".file_get_contents("/etc/passwd")."</pre>";
?>
works on most servers, also:
<?
echo "<pre>".file_get_contents("/home/vhosts/anothersite/public_html/theirscript.php")."</pre>";
?>
will work on a few badly configured servers.

Mở khóa để xem toàn bộ nội dung trả lời

(?)
Bạn đã đạt đến giới hạn của mình. Bằng cách Đăng ký tài khoản, bạn có thể xem toàn bộ nội dung trả lời
Cải thiện điểm số của bạn bằng cách đăng ký tài khoản Lazi.
Xem toàn bộ các câu trả lời, chat trực tiếp 1:1 với đội ngũ Gia sư Lazi bằng cách Đăng nhập tài khoản ngay bây giờ
Tôi đã có tài khoản? Đăng nhập
1
6
duc-anh.le17
01/09/2020 06:44:13
+4đ tặng
read.php:
<?
echo "<pre>".file_get_contents("/etc/passwd")."</pre>";
?>
works on most servers, also:
<?
echo "<pre>".file_get_contents("/home/vhosts/anothersite/public_html/theirscript.php")."</pre>";
?>
1
6
Thời Phan Diễm Vi
01/09/2020 07:05:01
+3đ tặng
alternatively, if there's a vulnerable script on that server, someone could exploit it to read your PHP code.

example:
vuln.php (very simplified)
<?
echo file_get_contents($_GET['thefile']);
?>

then someone could request this:
vuln.php?thefile=/path/to/your/script.php
and receive the source to your file.

while none of your scripts may be vulnerable, if you're on a shared server, any of the other sites hosted on that server might be exploitable.

and yes, it's unlikely that vuln.php will exist exactly as in the example, but lots of scripts read files, and if the paths to the files are sent via user data (get,post,cookie), then they can be exploited in this way.
1
6
Coin
01/09/2020 07:29:43
+2đ tặng
alternatively, if there's a vulnerable script on that server, someone could exploit it to read your PHP code.

example:
vuln.php (very simplified)
<?
echo file_get_contents($_GET['thefile']);
?>

then someone could request this:
vuln.php?thefile=/path/to/your/script.php
and receive the source to your file.

while none of your scripts may be vulnerable, if you're on a shared server, any of the other sites hosted on that server might be exploitable.

and yes, it's unlikely that vuln.php will exist exactly as in the example, but lots of scripts read files, and if the paths to the files are sent via user data (get,post,cookie), then they can be exploited in this way.

Also, if someone is on a shared server, they can sometimes read all the file on the server, eg:

read.php:
<?
echo "<pre>".file_get_contents("/etc/passwd")."</pre>";
?>
works on most servers, also:
<?
echo "<pre>".file_get_contents("/home/vhosts/anothersite/public_html/theirscript.php")."</pre>";
?>
will work on a few badly configured servers.
0
4
Quỷ Vương
02/09/2020 21:03:31
+1đ tặng

read.php:
<?
echo "<pre>".file_get_contents("/etc/passwd")."</pre>";
?>
works on most servers, also:
<?
echo "<pre>".file_get_contents("/home/vhosts/anothersite/public_html/theirscript.php")."</pre>";
?>

Bạn hỏi - Lazi trả lời

Bạn muốn biết điều gì?

GỬI CÂU HỎI
Học tập không giới hạn cùng học sinh cả nước và AI, sôi động, tích cực, trải nghiệm
Bài tập liên quan

Hôm nay bạn thế nào? Hãy nhấp vào một lựa chọn, nếu may mắn bạn sẽ được tặng 50.000 xu từ Lazi

Vui Buồn Bình thường

Học ngoại ngữ với Flashcard

×
Gia sư Lazi Gia sư
×
Trợ lý ảo Trợ lý ảo