#!/usr/bin/python import connect data = raw_input ('Enter name server, nusers name:').split(' ') print ('Now we are checking if backup is...') # bash_check_backup = 'ls -la /backup/cpbackup/daily/ | grep ' + data[2] # bash_check_backup = 'date -r /backup/cpbackup/daily/' + data[2] + '/version' bash_check_backup = 'date +%m.%-d.%Y_%H-%M-%S -r /backup/cpbackup/daily/' + data[2] + '/version' result_split = connect.request_to_server(data[0], data[1], bash_check_backup)[:-1] if result_split.find('No such file or directory') != -1: print 'Backup has not been found' else: print (('Backup has been found: {0} {1}').format(result_split, data[2])) print(connect.request_to_server(data[0], data[1], 'du -sh /backup/cpbackup/daily/' + data[2])) answer1 = raw_input ('Do you want to create an archive of backup? (y/n)') if answer1 == ('y' or 'Y' or 'yes' or 'Yes'): name_of_archive = 'backup-' + result_split + '_' + data[2] + '.tar.gz' answer_link = raw_input ('Do you want to create a link on the backup? (y/n)') if answer_link == ('y' or 'Y' or 'yes' or 'Yes'): bash_create_backup = 'cd /backup/cpbackup/daily/' +data[2] + '/; tar cvfz /home/' + name_of_archive+ ' ./; ln -s /home/' + name_of_archive+ ' /etc/httpd/htdocs/' + name_of_archive print(bash_create_backup) connect.request_to_server(data[0], data[1], bash_create_backup) print('Archive: /home/' + name_of_archive + '\nLink: ' + connect.host + '/' + name_of_archive) else: bash_create_backup = 'cd /backup/cpbackup/daily/' +data[2] + '; tar cvfz /home/' + name_of_archive+ ' .'
#!/usr/bin/python import connect data = raw_input ('Enter name server, nusers name:').split(' ') answer1 = raw_input ('Where can I find?\n1. /var/cpanel/\n2. Backup') if answer1 == '1': bash_check = 'cat /var/cpanel/users/'+ data[2] elif answer1 == '2': bash_check = 'cat /backup/cpbackup/daily/' +data[2] + '/cp/' + data[2] info= (connect.request_to_server(data[0], data[1], bash_check)) print info print ('Number of domains = {0}').format(info.count('DNS'))
#!/usr/bin/python import connect import argparse data = raw_input('Enter name server, user, port, chat:').split(' ') username = data[2] port = data[3] chat = data[4] id_user = connect.request_to_server(data[0], data[1], 'id -u ' + username) # if check_user[2] != 'No': try: id_user_id = int(id_user) id_user_id = str(id_user_id) bash_rule_in_csf = 'sed -i "/#=-=-=-= Custom ACL =-=-=-=#/ a tcp:out:d=' + port + ':u=' + id_user_id + ' # caht ID ' + chat + '" /etc/csf/csf.allow' print(bash_rule_in_csf) # print (connect.request_to_server(data[0], data[1], bash_create_modsec + '; ' + bash_edit_modsec + '; ' + bash_restart_httpd)) print (connect.request_to_server(data[0], data[1], bash_rule_in_csf + '; csf -r ')) except ValueError: print('User has been not found')
#!/usr/bin/python import connect import argparse data = raw_input('Enter name server, user, port, chat:').split(' ') username = data[2] port = data[3] chat = data[4] id_user = connect.request_to_server(data[0], data[1], 'id -u ' + username) # if check_user[2] != 'No': try: id_user_id = int(id_user) id_user_id = str(id_user_id) bash_rule_in_csf = 'sed -i "/#=-=-=-= Custom ACL =-=-=-=#/ a tcp:out:d=' + port + ':u=' + id_user_id + ' # caht ID ' + chat + '" /etc/csf/csf.allow' print(bash_rule_in_csf) # print (connect.request_to_server(data[0], data[1], bash_create_modsec + '; ' + bash_edit_modsec + '; ' + bash_restart_httpd)) print( connect.request_to_server(data[0], data[1], bash_rule_in_csf + '; csf -r ')) except ValueError: print('User has been not found')
#!/usr/bin/python import connect data = raw_input ('Enter name server, username, role:').split(' ') username = data[2] rule = data[3] path_std = '/usr/local/apache/conf/userdata/std/2_2/' path_ssl = '/usr/local/apache/conf/userdata/ssl/2_2/' path_ssl_std = [path_std, path_ssl] check_user = connect.request_to_server(data[0], data[1], 'id ' + username).split(' ') if check_user[2] != 'No': print 'User has been found' bash_restart_httpd = 'service httpd restart' for path in path_ssl_std: bash_create_modsec = 'echo -e "<LocationMatch .*>\n</LocationMatch>" > ' + path + username + '/modsec.conf' bash_edit_modsec = 'sed -i "/<LocationMatch .*>/ a SecRuleRemoveById ' + rule + '" ' + path + username +'/modsec.conf' bash_create_folder = 'mkdir ' + path + username + '; chmod 775 ' + path + username bash_grep_rules = 'grep ' + rule +' ' + path + username + '/modsec.conf' bash_check_dir = 'ls -l ' + path + ' | grep ' + username dir_path = connect.request_to_server(data[0], data[1], bash_check_dir) if dir_path: print (dir_path) bash_check_modsec = 'ls ' + path + username + '/modsec.conf' bash_check_modsec_result = connect.request_to_server(data[0], data[1], bash_check_modsec).split(' ') print bash_check_modsec_result
#!/usr/bin/python import connect data = raw_input ('Enter name server, user name:').split(' ') user = data[2] bash_list_quarantine = 'cd /opt/cxs/quarantine/cxsuser/' + user +'; ls -la; cxs --force ./' print(connect.request_to_server(data[0], data[1], bash_list_quarantine)) show_file = raw_input ('Do you want to look into file?(n/name file)') if show_file != ('n' or 'no'): bash_cat_file = 'cat /opt/cxs/quarantine/cxsuser/' + user + '/' + show_file print(connect.request_to_server(data[0], data[1], bash_cat_file )) restore_file = raw_input('Do you want to restore the file?(n/name file)') if restore_file != ('n' or 'no'): md5sum = connect.request_to_server(data[0], data[1], 'md5sum /opt/cxs/quarantine/cxsuser/' + user +'/'+ restore_file) md5sum = md5sum.split(' ') md5sum = md5sum[0] bash_actfile = 'grep actfile /opt/cxs/quarantine/cxsuser/' + user +'/'+ restore_file + '.restore4' bash_actfile = connect.request_to_server(data[0], data[1], bash_actfile).split('=') bash_actfile = bash_actfile[1] print(bash_actfile) # bash_actfile = bash_actfile[1] # print(bash_actfile) bash_whitelist = 'echo md5sum:' + md5sum + ' >> /etc/cxs/cxs.ignore; echo md5sum:' + md5sum + ' >> /etc/cxs/cxs.ignore.watch ; cp ' + restore_file + ' ' + bash_actfile + '; chown ' + user + '. ' + bash_actfile print(bash_whitelist) # print(connect.request_to_server(data[0], data[1], bash_whitelist))
#!/usr/bin/python import connect data = raw_input('Enter name server, nusers name:').split(' ') print('Now we are checking if backup is...') # bash_check_backup = 'ls -la /backup/cpbackup/daily/ | grep ' + data[2] # bash_check_backup = 'date -r /backup/cpbackup/daily/' + data[2] + '/version' bash_check_backup = 'date +%m.%-d.%Y_%H-%M-%S -r /backup/cpbackup/daily/' + data[ 2] + '/version' result_split = connect.request_to_server(data[0], data[1], bash_check_backup)[:-1] if result_split.find('No such file or directory') != -1: print 'Backup has not been found' else: print(('Backup has been found: {0} {1}').format(result_split, data[2])) print( connect.request_to_server(data[0], data[1], 'du -sh /backup/cpbackup/daily/' + data[2])) answer1 = raw_input('Do you want to create an archive of backup? (y/n)') if answer1 == ('y' or 'Y' or 'yes' or 'Yes'): name_of_archive = 'backup-' + result_split + '_' + data[2] + '.tar.gz' answer_link = raw_input( 'Do you want to create a link on the backup? (y/n)') if answer_link == ('y' or 'Y' or 'yes' or 'Yes'): bash_create_backup = 'cd /backup/cpbackup/daily/' + data[ 2] + '/; tar cvfz /home/' + name_of_archive + ' ./; ln -s /home/' + name_of_archive + ' /etc/httpd/htdocs/' + name_of_archive print(bash_create_backup)
#!/usr/bin/python import connect data = raw_input('Enter name server, user name:').split(' ') user = data[2] bash_list_quarantine = 'cd /opt/cxs/quarantine/cxsuser/' + user + '; ls -la; cxs --force ./' print(connect.request_to_server(data[0], data[1], bash_list_quarantine)) show_file = raw_input('Do you want to look into file?(n/name file)') if show_file != ('n' or 'no'): bash_cat_file = 'cat /opt/cxs/quarantine/cxsuser/' + user + '/' + show_file print(connect.request_to_server(data[0], data[1], bash_cat_file)) restore_file = raw_input('Do you want to restore the file?(n/name file)') if restore_file != ('n' or 'no'): md5sum = connect.request_to_server( data[0], data[1], 'md5sum /opt/cxs/quarantine/cxsuser/' + user + '/' + restore_file) md5sum = md5sum.split(' ') md5sum = md5sum[0] bash_actfile = 'grep actfile /opt/cxs/quarantine/cxsuser/' + user + '/' + restore_file + '.restore4' bash_actfile = connect.request_to_server(data[0], data[1], bash_actfile).split('=') bash_actfile = bash_actfile[1] print(bash_actfile) # bash_actfile = bash_actfile[1] # print(bash_actfile)
#!/usr/bin/python import connect data = raw_input('Enter name server, user: '******' ') username = data[2] # domen = data[3] check_domen = connect.request_to_server(data[0], data[1], 'grep DNS= /var/cpanel/users/' + username) domen = check_domen.split('=') domen = domen[1].split('.') domen = domen[0] print ('LVEINFO:\n{0}').format(connect.request_to_server(data[0], data[1], 'lveinfo -u ' + username + ' --period=12h')) print ('CRON:\n{0}').format(connect.request_to_server(data[0], data[1], 'cat /var/spool/cron/' + username)) print ('TOP:\n{0}').format(connect.request_to_server(data[0], data[1], 'top -c -b -n 1 -u ' + username)) print ('APACHE:\n{0}').format(connect.request_to_server(data[0], data[1], 'lynx -dump -width=500 http://localhost:81/whm-server-status | grep ' + domen + '| sort -k11')) print ('MYSQL:\n{0}').format(connect.request_to_server(data[0], data[1], 'mysqladmin pr | grep ' + username))
#!/usr/bin/python import connect data = raw_input('Enter name server, nusers name:').split(' ') answer1 = raw_input('Where can I find?\n1. /var/cpanel/\n2. Backup') if answer1 == '1': bash_check = 'cat /var/cpanel/users/' + data[2] elif answer1 == '2': bash_check = 'cat /backup/cpbackup/daily/' + data[2] + '/cp/' + data[2] info = (connect.request_to_server(data[0], data[1], bash_check)) print info print('Number of domains = {0}').format(info.count('DNS'))
#!/usr/bin/python import connect data = raw_input('Enter name server, username, role:').split(' ') username = data[2] rule = data[3] path_std = '/usr/local/apache/conf/userdata/std/2_2/' path_ssl = '/usr/local/apache/conf/userdata/ssl/2_2/' path_ssl_std = [path_std, path_ssl] check_user = connect.request_to_server(data[0], data[1], 'id ' + username).split(' ') if check_user[2] != 'No': print 'User has been found' bash_restart_httpd = 'service httpd restart' for path in path_ssl_std: bash_create_modsec = 'echo -e "<LocationMatch .*>\n</LocationMatch>" > ' + path + username + '/modsec.conf' bash_edit_modsec = 'sed -i "/<LocationMatch .*>/ a SecRuleRemoveById ' + rule + '" ' + path + username + '/modsec.conf' bash_create_folder = 'mkdir ' + path + username + '; chmod 775 ' + path + username bash_grep_rules = 'grep ' + rule + ' ' + path + username + '/modsec.conf' bash_check_dir = 'ls -l ' + path + ' | grep ' + username dir_path = connect.request_to_server(data[0], data[1], bash_check_dir) if dir_path: print(dir_path) bash_check_modsec = 'ls ' + path + username + '/modsec.conf' bash_check_modsec_result = connect.request_to_server( data[0], data[1], bash_check_modsec).split(' ') print bash_check_modsec_result