!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: nginx/1.23.4. PHP/5.6.40-65+ubuntu20.04.1+deb.sury.org+1 

uname -a: Linux foro-restaurado-2 5.15.0-1040-oracle #46-Ubuntu SMP Fri Jul 14 21:47:21 UTC 2023
aarch64
 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/home/scripts/pba/phc-read-only/src/process_ir/   drwxrwxr-x
Free 83.2 GB of 96.73 GB (86.02%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     XML_unparser.cpp (11.42 KB)      -rw-rw-r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
/*
 * phc -- the open source PHP compiler
 * See doc/license/README.license for licensing information
 *
 * Convert the phc AST to XML format
 */
#include <ostream>

#include "cmdline.h"

#include "lib/base64.h"
#include "lib/Boolean.h"
#include "lib/error.h"
#include "lib/demangle.h"
#include "lib/List.h"
#include "lib/Object.h"
#include "lib/String.h"

#include "XML_unparser.h"

using namespace std;

extern gengetopt_args_info args_info;

template
<
    class Script,
    class Node,
    class Visitor,
    class Identifier,
    class Literal,
    class NIL,
    class CAST,
    class FOREIGN
>
class XML_unparser : public Visitor, virtual public GC_obj
{
protected:
    string xmlns; // XML namespace
    XML_unparser_state* state;

public:
    XML_unparser(string xmlns, std::ostream& os = std::cout, bool print_attrs = true, bool convert_base_64 = true)
    : xmlns(xmlns)
    {
        state = new XML_unparser_state (os, print_attrs, convert_base_64);
    }

    XML_unparser(string xmlns, XML_unparser_state* state)
    : xmlns(xmlns)
    , state(state)
    {
    }

    virtual ~XML_unparser() 
    {
    }

public:

    bool needs_encoding(String* str)
    {
        if (!state->convert_base_64)
            return false;

        String::const_iterator i;

        for(i = str->begin(); i != str->end(); i++)
        {
            if(*i < 32)
                return true;

            if(*i > 126)
                return true;

            if(*i == '<' || *i == '>' || *i == '&')
                return true;
        }

        return false;
    }

    void visit_marker(char const* name, bool value)
    {
        state->print_indent();
        state->os << "<bool>" 
            << "<!-- " << name << " -->"
            << (value ? "true" : "false") << "</bool>\n";
    }

    void visit_null(char const* name_space, char const* type_id)
    {
        state->print_indent();
        state->os << "<" << name_space << ":" << type_id << " xsi:nil=\"true\" />\n";
    }

    void visit_null_list(char const* name_space, char const* type_id)
    {
        state->print_indent();
        state->os << "<" << name_space << ":" << type_id << "_list xsi:nil=\"true\" />\n";
    }

    void pre_list(char const* name_space, char const* type_id, int size)
    {
        state->print_indent();
        state->os << "<" << name_space << ":" << type_id << "_list>\n";
        state->indent++;
    }

    void post_list(char const* name_space, char const* type_id, int size)
    {
        state->indent--;
        state->print_indent();
        state->os << "</" << name_space << ":" << type_id << "_list>\n";
    }

public:

    
    // Demangle and convert type names qualified with a namespace into XML
    // namespaces (eg AST::If into AST:If)
    const char* demangle_xml (Node* node)
    {
        String* demangled = new String (demangle (node, true));
        size_t index = demangled->find_first_of (':');
        if (index != string::npos)
        {
            demangled->erase (index, 1);
        }
        return demangled->c_str ();
    }

    void pre_node(Node* in)
    {
        bool is_root = dynamic_cast<Script*>(in);

        if(is_root)
            state->os << "<?xml version=\"1.0\"?>\n";

        
state->print_indent();

        
state->os << "<" << demangle_xml (in);

        if(
is_root)
        {
            
// TODO these should have different defintions.
            
state->os << " xmlns:AST=\"http://www.phpcompiler.org/phc-1.1\"";
            
state->os << " xmlns:HIR=\"http://www.phpcompiler.org/phc-1.1\"";
            
state->os << " xmlns:MIR=\"http://www.phpcompiler.org/phc-1.1\"";
            
state->os << " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
        }

        
state->os << ">\n";
        
state->indent++;

        if(
state->print_attrsprint_attributes(in);
    }

    
void post_node(Nodein)
    {
        
state->indent--;
        
state->print_indent();
        
state->os << "</" << demangle_xml(in) << ">\n";
    }

protected:

    
void maybe_encode (const chartag_nameStringvalue)
    {
        
state->os << "<" << tag_name;

        if(
needs_encoding(value))
        {
            
state->os << " encoding=\"base64\">";
            
state->os << *base64_encode(value);
        }
        else
        {
            
state->os << ">";
            
state->os << *value;
        }

        
state->os << "</" << tag_name << ">";
    }

    
void print_attributes(Nodein)
    {
        if(
in->attrs->size() == 0)
        {
            
state->print_indent();
            
state->os << "<attrs />\n";
        }
        else
        {
            
state->print_indent();
            
state->os << "<attrs>\n";
            
state->indent++;

            
AttrMap::const_iterator i;
            for(
in->attrs->begin(); != in->attrs->end(); i++)
            {
                
print_attribute((*i).first, (*i).second);
            }

            
state->indent--;
            
state->print_indent();
            
state->os << "</attrs>\n";
        }
    }

    
void print_attribute(string nameObjectattr)
    {
        
state->print_indent();

        if(
Stringstr dynamic_cast<String*>(attr))
        {
            
state->os << "<attr key=\"" << name << "\">";
            
maybe_encode ("string"str);
            
state->os << "</attr>\n";
        }
        else if(
Integerdynamic_cast<Integer*>(attr))
        {
            
state->os << "<attr key=\"" << name << "\"><integer>" << i->value () << "</integer></attr>\n";
        }
        else if(
Booleandynamic_cast<Boolean*>(attr))
        {
            
state->os << "<attr key=\"" << name << "\"><bool>" << (b->value() ? "true" "false") << "</bool></attr>\n";
        }
        else if (
IR::Nodenode dynamic_cast<IR::Node*> (attr))
        {
            
state->os << "<attr key=\"" << name << "\">\n";
            
xml_unparse (nodestate);
            
state->print_indent();
            
state->os << "</attr>\n";
        }
        else if (
attr == NULL)
        {
            
state->os << "<!-- skipping NULL attribute " << name << " -->\n";
        }
        else if(
String_listls dynamic_cast<String_list*>(attr))
        {
            
state->os << "<attr key=\"" << name << "\">\n";
            
state->indent++;
            
state->print_indent ();
            
state->os << "<string_list>\n";
            
state->indent++;

            foreach (
Strings, *ls)
            {
                
state->print_indent();
                
maybe_encode ("string"s);
                
state->os << "\n";
            }

            
state->indent--;
            
state->print_indent();
            
state->os << "</string_list>\n";
            
state->indent--;
            
state->print_indent();
            
state->os << "</attr>\n";
        }
        else if(
IR::Node_listls dynamic_cast<IR::Node_list*>(attr))
        {
            
// Allow lists of nodes, only if as List<IR::Node*>
            
state->os << "<attr key=\"" << name << "\">\n";
            
state->indent++;
            
state->print_indent ();
            
state->os << "<node_list>\n";
            
state->indent++;

            foreach (
IR::Nodenode, *ls)
                
xml_unparse (nodestate);

            
state->indent--;
            
state->print_indent();
            
state->os << "</node_list>\n";
            
state->indent--;
            
state->print_indent();
            
state->os << "</attr>\n";
        }
        else
            
phc_warning ("Don't know how to deal with attribute '%s' of type '%s'"name.c_str(), demangle(attrtrue));    
    }

    
void pre_literal(Literalin)
    {
        
Stringvalue in->get_value_as_string();

        
// NIL does not have a value
        
if(!isa<NIL> (in))
        {
            
state->print_indent();
            
maybe_encode ("value"value);
            
state->os << "\n";
        }
    }

    
void pre_identifier(Identifierin)
    {
        
Stringvalue in->get_value_as_string();

        
state->print_indent();
        
maybe_encode ("value"value);
        
state->os << "\n";
    }

    
// Foreign nodes delegate to the appropriate XML_unparser.
    
void pre_foreign (FOREIGNin)
    {
        
state->print_indent();
        
state->os << "<value>\n";

        
state->indent++;
        
xml_unparse (in->valuestate);
        
state->indent--;

        
state->print_indent();
        
state->os << "</value>\n";
    }
};

#include "AST_visitor.h"
class AST_XML_unparser : public XML_unparser
<
    
AST::PHP_script,
    
AST::Node,
    
AST::Visitor,
    
AST::Identifier,
    
AST::Literal,
    
AST::NIL,
    
AST::CAST,
    
AST::FOREIGN
>
{
    
typedef XML_unparser <    AST::PHP_scriptAST::NodeAST::Visitor,
                                    
AST::IdentifierAST::Literal,
                                    
AST::NILAST::CASTAST::FOREIGNparent;
public:
    
AST_XML_unparser(ostreamos std::coutbool print_attrs truebool convert_base_64 true)
    : 
parent ("AST"osprint_attrsconvert_base_64)
    {
    }

    
AST_XML_unparser(XML_unparser_statestate)
    : 
parent ("AST"state)
    {
    }
};

#include "HIR_visitor.h"
class HIR_XML_unparser : public XML_unparser
<
    
HIR::PHP_script,
    
HIR::Node,
    
HIR::Visitor,
    
HIR::Identifier,
    
HIR::Literal,
    
HIR::NIL,
    
HIR::CAST,
    
HIR::FOREIGN
>
{
    
typedef XML_unparser <    HIR::PHP_scriptHIR::NodeHIR::Visitor,
                                    
HIR::IdentifierHIR::Literal,
                                    
HIR::NILHIR::CASTHIR::FOREIGNparent;
public:
    
HIR_XML_unparser(ostreamos std::coutbool print_attrs truebool convert_base_64 true)
    : 
parent ("HIR"osprint_attrsconvert_base_64)
    {
    }

    
HIR_XML_unparser(XML_unparser_statestate)
    : 
parent ("HIR"state)
    {
    }
};

#include "MIR_visitor.h"
class MIR_XML_unparser : public XML_unparser
<
    
MIR::PHP_script
    
MIR::Node
    
MIR::Visitor,
    
MIR::Identifier,
    
MIR::Literal,
    
MIR::NIL,
    
MIR::CAST,
    
MIR::FOREIGN

{
    
typedef XML_unparser <    MIR::PHP_scriptMIR::NodeMIR::Visitor,
                                    
MIR::IdentifierMIR::Literal,
                                    
MIR::NILMIR::CASTMIR::FOREIGNparent;
public:
    
MIR_XML_unparser(ostreamos std::coutbool print_attrs truebool convert_base_64 true)
    : 
parent ("MIR"osprint_attrsconvert_base_64)
    {
    }

    
MIR_XML_unparser(XML_unparser_statestate)
    : 
parent ("MIR"state)
    {
    }

    
void pre_param_index (MIR::PARAM_INDEXin)
    {
        
Stringvalue in->get_value_as_string();

        
state->print_indent();
        
maybe_encode ("value"value);
        
state->os << "\n";
    }
};


#include "MICG_visitor.h"
class MICG_XML_unparser : public XML_unparser
<
    
MICG::All
    
MICG::Node
    
MICG::Visitor,
    
MICG::Identifier,
    
// The MICG doesnt have these node, so just use the MIR versions to satisfy
    // the type-checker. They'll be ignored at run-time, since the MICG wont
    // have any MIR nodes.
    
MIR::Literal,
    
MIR::NIL,
    
MIR::CAST,
    
MIR::FOREIGN

{
    
typedef XML_unparser <    MICG::AllMICG::NodeMICG::Visitor,
                                    
MICG::IdentifierMIR::Literal,
                                    
MIR::NILMIR::CASTMIR::FOREIGNparent;
public:
    
MICG_XML_unparser(ostreamos std::coutbool print_attrs truebool convert_base_64 true)
    : 
parent ("MICG"osprint_attrsconvert_base_64)
    {
    }

    
MICG_XML_unparser(XML_unparser_statestate)
    : 
parent ("MICG"state)
    {
    }
};




XML_unparser_state::XML_unparser_state (ostreamosbool print_attrsbool convert_base_64)
os (os)
print_attrs (print_attrs)
convert_base_64 (convert_base_64)
indent (0)
{
}

void
XML_unparser_state
::print_indent ()
{
    for(
int i 0indenti++)
        
os << args_info.tab_arg;
}

void
xml_unparse 
(AST::NodeinXML_unparser_statestate)
{
    
in->visit (new AST_XML_unparser (state));
}

void xml_unparse (HIR::NodeinXML_unparser_statestate)
{
    
in->visit (new HIR_XML_unparser (state));
}

void xml_unparse (MIR::NodeinXML_unparser_statestate)
{
    
in->visit (new MIR_XML_unparser (state));
}

void xml_unparse (MICG::NodeinXML_unparser_statestate)
{
    
in->visit (new MICG_XML_unparser (state));
}

void xml_unparse (IR::NodeinXML_unparser_statestate)
{
    if (
isa<AST::Node> (in))
        
xml_unparse (dyc<AST::Node> (in), state);
    else if (
isa<HIR::Node> (in))
        
xml_unparse (dyc<HIR::Node> (in), state);
    else
        
xml_unparse (dyc<MIR::Node> (in), state);
}

void xml_unparse (AST::Nodeinstd::ostreamosbool print_attrsbool convert_base_64)
{
  
in->visit (new AST_XML_unparser (osprint_attrsconvert_base_64));
}

void xml_unparse (HIR::Nodeinstd::ostreamosbool print_attrsbool convert_base_64)
{
  
in->visit (new HIR_XML_unparser (osprint_attrsconvert_base_64));
}

void xml_unparse (MIR::Nodeinstd::ostreamosbool print_attrsbool convert_base_64)
{
  
in->visit (new MIR_XML_unparser (osprint_attrsconvert_base_64));
}

void xml_unparse (MICG::Nodeinstd::ostreamosbool print_attrsbool convert_base_64)
{
  
in->visit (new MICG_XML_unparser (osprint_attrsconvert_base_64));
}




void xml_unparse (IR::PHP_scriptinstd::ostreamosbool print_attrsbool convert_base_64)
{
    if (
isa<AST::PHP_script> (in))
        
xml_unparse (dyc<AST::Node> (in), osprint_attrsconvert_base_64);
    else if (
isa<HIR::PHP_script> (in))
        
xml_unparse (dyc<HIR::Node> (in), osprint_attrsconvert_base_64);
    else
        
xml_unparse (dyc<MIR::Node> (in), osprint_attrsconvert_base_64);
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by HackingTool | HackingTool | Generation time: 0.0051 ]--