コード例 #1
0
 def read_outxml(self, filename):
     try:
         return truantchild.Config(
             (filename,
              self.executable))._outputParams.getParameterListExt()
     except:
         pass
コード例 #2
0
    def __call__(self, argv):
        """Effectively "main" from Commandlinewrapper"""
        logConfig = None
        context = {}
        rendezvous = None
        try:
            (opts, args) = self.__coli_parser.parse_args(argv)
            if opts.InConfig is None:
                raise ExploitConfigError(
                    "You must pass a valid --InConfig option")

            # Read the input config and create a truanchild Config object
            self.config = truantchild.Config([opts.InConfig])

            # make sure the id from the binary matches the config
            if self.getID() != self.config.id:
                print "Mismatching configurations!!"
                return 1

            # XXX Add the bit about help, line 215

            inputs = self.config._inputParams
            outputs = self.config._outputParams
            constants = None  # Fuzzbunch doesn't support these yet

            #pytrch.Params_parseCommandLine( inputs.parameters, len(sys.argv), sys.argv, doHelp)

            # Convert the options from Truanchild to easy-to-handle input for the plugin
            iOptions = self.tc2List(inputs)
            oOptions = self.tc2Dict(outputs)

            # add the params from the wrapper
            valid = self.validateParams(iOptions)
            # XXX Print the invalid options
            if opts.ValidateOnly is True:
                return 0

            (fhNo, logConfig) = self.processWrapperParams(opts)

            # Setup all of the existing sockets
            self.doRendezvousClient(inputs)
            retval = self.processParams(iOptions, constants, oOptions, context,
                                        logConfig)

            try:
                self.options2Tc(oOptions, outputs)
            except Exception as e:
                # If this fails, the plugin was not successful
                print str(oOptions)
                print "Failed: {0}".format(e)
                return 1

            # Add the output parameter for the rendezvous
            (rendezvous,
             sock) = self.addWrapperOutputParams(outputs,
                                                 self.config.namespaceUri,
                                                 self.config.schemaVersion)
            exma.writeParamsToEM(fhNo, self.config.getMarshalledInConfig())

            # This sends us into a send/recv loop
            self.doRendezvousServer(rendezvous, sock)
            self.cleanup(EDF_CLEANUP_WAIT, context, logConfig)

        except Exception as e:
            print "Failed: {0}".format(e)
            raise
コード例 #3
0
ファイル: coli.py プロジェクト: unix1010/isf-1
    def __call__(self, argv):
        """Effectively "main" from Commandlinewrapper"""
        logConfig = None
        context = {}
        rendezvous = None

        try:
            (opts, args) = self.__coli_parser.parse_args(argv)
            if opts.InConfig is None:
                # not xml file run mode
                return

            # Read the input config and create a truanchild Config object
            self.config = truantchild.Config([opts.InConfig])

            # make sure the id from the binary matches the config
            if self.getID() != self.config.id and self.getID() != 0:
                print "Mismatching configurations!!"
                return 1

            # XXX Add the bit about help, line 215

            inputs = self.config._inputParams
            outputs= self.config._outputParams
            constants = None                # Fuzzbunch doesn't support these yet

            #pytrch.Params_parseCommandLine( inputs.parameters, len(sys.argv), sys.argv, doHelp)

            # Convert the options from Truanchild to easy-to-handle input for the plugin
            self.iOptions = self.tc2List( inputs )
            self.oOptions = self.tc2Dict( outputs )

            # get user para and global Paramaters
            self.options, tmp = self.get_coli_parser().parse_args(self.iOptions)

            valid = self.validateParams(self.iOptions)
            if not valid:
                print "Invalid Params"
                return 1

            # get ip and port
            try:
                self.TargetPort = 0
                self.TargetIp = self.getParam('TargetIp')
                self.TargetPort = str(self.getParam('TargetPort'))
            except:
                pass

            # XXX Print the invalid options
            if opts.ValidateOnly is True:
                return 0

            (fhNo, logConfig) = self.processWrapperParams( opts )

            # Setup all of the existing sockets
            self.doRendezvousClient(inputs)

            retval = self.processParams(self.iOptions, constants, self.oOptions, context, logConfig)

            try:
                self.options2Tc( self.oOptions, outputs )
            except Exception as e:
                # If this fails, the plugin was not successful
                # print str(self.oOptions)
                print("Failed: {0}".format(e))
                return 1

            # Add the output parameter for the rendezvous
            (rendezvous, sock) = self.addWrapperOutputParams( outputs, self.config.namespaceUri, self.config.schemaVersion )
            exma.writeParamsToEM( fhNo, self.config.getMarshalledInConfig() )
        
            # This sends us into a send/recv loop
            self.doRendezvousServer( rendezvous, sock )
            self.cleanup( EDF_CLEANUP_WAIT, context, logConfig )

        except KeyboardInterrupt:
            raise
        except (socket.error, socket.timeout):
            retval = -1
            print("[+] Connection error: %s:%s" % (self.TargetIp, str(self.TargetPort)))
        except Exception as e:
            print("[+] Failed: {0}".format(e))
            raise

        return retval