Updated shell dropper

feature/node-rewrite
Sven Slootweg 13 years ago
parent 4e92b628c7
commit eebab0b47f

@ -1,6 +1,10 @@
#!/usr/bin/python #!/usr/bin/python
import paramiko, socket, sys, termios, tty, select, urllib, urllib2, json import socket, sys, termios, tty, select, urllib, urllib2, json, warnings, getpass
with warnings.catch_warnings():
warnings.simplefilter("ignore")
import paramiko
key = "abcde" key = "abcde"
endpoint = "http://cvm.local/api.local.php" endpoint = "http://cvm.local/api.local.php"
@ -57,6 +61,23 @@ def api_request(parameters, method="GET"):
response = urllib2.urlopen(req) response = urllib2.urlopen(req)
return json.loads(response.read()) return json.loads(response.read())
def show_list():
print ""
for key, vps in vpsmap.items():
node = nodemap[vps['NodeId']]
print "%s. %s (%s [%s], %s)" % (key, vps['Hostname'], node['Name'], node['Hostname'], node['PhysicalLocation'])
print ""
choice = raw_input("Make your choice: ")
try:
current_vps = vpsmap[int(choice)]
current_node = nodemap[current_vps['NodeId']]
open_shell(current_node['Hostname'], "vz", current_vps['InternalId'])
except KeyError, ValueError:
print "That was not a valid option. Try again. "
show_list()
print "#############################################################" print "#############################################################"
print "### CVM OpenVZ shell dropper ###" print "### CVM OpenVZ shell dropper ###"
@ -65,7 +86,7 @@ print ""
print "Please enter your VPS panel login details to continue." print "Please enter your VPS panel login details to continue."
print "" print ""
username = raw_input("Username: ") username = raw_input("Username: ")
password = raw_input("Password: ") password = getpass.getpass("Password: ")
print "" print ""
auth_result = api_request({ auth_result = api_request({
@ -105,20 +126,7 @@ if auth_result['data']['correct'] == True:
'nodeid': node 'nodeid': node
})['data'] })['data']
for key, vps in vpsmap.items(): show_list()
node = nodemap[vps['NodeId']]
print "%s. %s (%s [%s], %s)" % (key, vps['Hostname'], node['Name'], node['Hostname'], node['PhysicalLocation'])
print ""
choice = raw_input("Make your choice: ")
try:
current_vps = vpsmap[int(choice)]
current_node = nodemap[current_vps['NodeId']]
open_shell(current_node['Hostname'], "vz", current_vps['InternalId'])
except KeyError, ValueError:
print "That was not a valid option."
exit(0) exit(0)
else: else:

@ -44,6 +44,13 @@ if(isset($_GET['key']) && $_GET['key'] == $settings['local_api_key'])
$return_success = true; $return_success = true;
} }
} }
else
{
$return_object = array(
'correct' => false,
'userid' => 0
);
}
break; break;
case "list_vps": case "list_vps":

Loading…
Cancel
Save