mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-01-02 11:36:22 +01:00
import 1cf077a from python 2.7 branch (2.7.10+)
This commit is contained in:
parent
2492316f55
commit
e878ac3286
535
c/meterpreter/source/extensions/python/Include/Python-ast.h
Normal file
535
c/meterpreter/source/extensions/python/Include/Python-ast.h
Normal file
@ -0,0 +1,535 @@
|
||||
/* File automatically generated by Parser/asdl_c.py. */
|
||||
|
||||
#include "asdl.h"
|
||||
|
||||
typedef struct _mod *mod_ty;
|
||||
|
||||
typedef struct _stmt *stmt_ty;
|
||||
|
||||
typedef struct _expr *expr_ty;
|
||||
|
||||
typedef enum _expr_context { Load=1, Store=2, Del=3, AugLoad=4, AugStore=5,
|
||||
Param=6 } expr_context_ty;
|
||||
|
||||
typedef struct _slice *slice_ty;
|
||||
|
||||
typedef enum _boolop { And=1, Or=2 } boolop_ty;
|
||||
|
||||
typedef enum _operator { Add=1, Sub=2, Mult=3, Div=4, Mod=5, Pow=6, LShift=7,
|
||||
RShift=8, BitOr=9, BitXor=10, BitAnd=11, FloorDiv=12 }
|
||||
operator_ty;
|
||||
|
||||
typedef enum _unaryop { Invert=1, Not=2, UAdd=3, USub=4 } unaryop_ty;
|
||||
|
||||
typedef enum _cmpop { Eq=1, NotEq=2, Lt=3, LtE=4, Gt=5, GtE=6, Is=7, IsNot=8,
|
||||
In=9, NotIn=10 } cmpop_ty;
|
||||
|
||||
typedef struct _comprehension *comprehension_ty;
|
||||
|
||||
typedef struct _excepthandler *excepthandler_ty;
|
||||
|
||||
typedef struct _arguments *arguments_ty;
|
||||
|
||||
typedef struct _keyword *keyword_ty;
|
||||
|
||||
typedef struct _alias *alias_ty;
|
||||
|
||||
|
||||
enum _mod_kind {Module_kind=1, Interactive_kind=2, Expression_kind=3,
|
||||
Suite_kind=4};
|
||||
struct _mod {
|
||||
enum _mod_kind kind;
|
||||
union {
|
||||
struct {
|
||||
asdl_seq *body;
|
||||
} Module;
|
||||
|
||||
struct {
|
||||
asdl_seq *body;
|
||||
} Interactive;
|
||||
|
||||
struct {
|
||||
expr_ty body;
|
||||
} Expression;
|
||||
|
||||
struct {
|
||||
asdl_seq *body;
|
||||
} Suite;
|
||||
|
||||
} v;
|
||||
};
|
||||
|
||||
enum _stmt_kind {FunctionDef_kind=1, ClassDef_kind=2, Return_kind=3,
|
||||
Delete_kind=4, Assign_kind=5, AugAssign_kind=6, Print_kind=7,
|
||||
For_kind=8, While_kind=9, If_kind=10, With_kind=11,
|
||||
Raise_kind=12, TryExcept_kind=13, TryFinally_kind=14,
|
||||
Assert_kind=15, Import_kind=16, ImportFrom_kind=17,
|
||||
Exec_kind=18, Global_kind=19, Expr_kind=20, Pass_kind=21,
|
||||
Break_kind=22, Continue_kind=23};
|
||||
struct _stmt {
|
||||
enum _stmt_kind kind;
|
||||
union {
|
||||
struct {
|
||||
identifier name;
|
||||
arguments_ty args;
|
||||
asdl_seq *body;
|
||||
asdl_seq *decorator_list;
|
||||
} FunctionDef;
|
||||
|
||||
struct {
|
||||
identifier name;
|
||||
asdl_seq *bases;
|
||||
asdl_seq *body;
|
||||
asdl_seq *decorator_list;
|
||||
} ClassDef;
|
||||
|
||||
struct {
|
||||
expr_ty value;
|
||||
} Return;
|
||||
|
||||
struct {
|
||||
asdl_seq *targets;
|
||||
} Delete;
|
||||
|
||||
struct {
|
||||
asdl_seq *targets;
|
||||
expr_ty value;
|
||||
} Assign;
|
||||
|
||||
struct {
|
||||
expr_ty target;
|
||||
operator_ty op;
|
||||
expr_ty value;
|
||||
} AugAssign;
|
||||
|
||||
struct {
|
||||
expr_ty dest;
|
||||
asdl_seq *values;
|
||||
bool nl;
|
||||
} Print;
|
||||
|
||||
struct {
|
||||
expr_ty target;
|
||||
expr_ty iter;
|
||||
asdl_seq *body;
|
||||
asdl_seq *orelse;
|
||||
} For;
|
||||
|
||||
struct {
|
||||
expr_ty test;
|
||||
asdl_seq *body;
|
||||
asdl_seq *orelse;
|
||||
} While;
|
||||
|
||||
struct {
|
||||
expr_ty test;
|
||||
asdl_seq *body;
|
||||
asdl_seq *orelse;
|
||||
} If;
|
||||
|
||||
struct {
|
||||
expr_ty context_expr;
|
||||
expr_ty optional_vars;
|
||||
asdl_seq *body;
|
||||
} With;
|
||||
|
||||
struct {
|
||||
expr_ty type;
|
||||
expr_ty inst;
|
||||
expr_ty tback;
|
||||
} Raise;
|
||||
|
||||
struct {
|
||||
asdl_seq *body;
|
||||
asdl_seq *handlers;
|
||||
asdl_seq *orelse;
|
||||
} TryExcept;
|
||||
|
||||
struct {
|
||||
asdl_seq *body;
|
||||
asdl_seq *finalbody;
|
||||
} TryFinally;
|
||||
|
||||
struct {
|
||||
expr_ty test;
|
||||
expr_ty msg;
|
||||
} Assert;
|
||||
|
||||
struct {
|
||||
asdl_seq *names;
|
||||
} Import;
|
||||
|
||||
struct {
|
||||
identifier module;
|
||||
asdl_seq *names;
|
||||
int level;
|
||||
} ImportFrom;
|
||||
|
||||
struct {
|
||||
expr_ty body;
|
||||
expr_ty globals;
|
||||
expr_ty locals;
|
||||
} Exec;
|
||||
|
||||
struct {
|
||||
asdl_seq *names;
|
||||
} Global;
|
||||
|
||||
struct {
|
||||
expr_ty value;
|
||||
} Expr;
|
||||
|
||||
} v;
|
||||
int lineno;
|
||||
int col_offset;
|
||||
};
|
||||
|
||||
enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4,
|
||||
IfExp_kind=5, Dict_kind=6, Set_kind=7, ListComp_kind=8,
|
||||
SetComp_kind=9, DictComp_kind=10, GeneratorExp_kind=11,
|
||||
Yield_kind=12, Compare_kind=13, Call_kind=14, Repr_kind=15,
|
||||
Num_kind=16, Str_kind=17, Attribute_kind=18,
|
||||
Subscript_kind=19, Name_kind=20, List_kind=21, Tuple_kind=22};
|
||||
struct _expr {
|
||||
enum _expr_kind kind;
|
||||
union {
|
||||
struct {
|
||||
boolop_ty op;
|
||||
asdl_seq *values;
|
||||
} BoolOp;
|
||||
|
||||
struct {
|
||||
expr_ty left;
|
||||
operator_ty op;
|
||||
expr_ty right;
|
||||
} BinOp;
|
||||
|
||||
struct {
|
||||
unaryop_ty op;
|
||||
expr_ty operand;
|
||||
} UnaryOp;
|
||||
|
||||
struct {
|
||||
arguments_ty args;
|
||||
expr_ty body;
|
||||
} Lambda;
|
||||
|
||||
struct {
|
||||
expr_ty test;
|
||||
expr_ty body;
|
||||
expr_ty orelse;
|
||||
} IfExp;
|
||||
|
||||
struct {
|
||||
asdl_seq *keys;
|
||||
asdl_seq *values;
|
||||
} Dict;
|
||||
|
||||
struct {
|
||||
asdl_seq *elts;
|
||||
} Set;
|
||||
|
||||
struct {
|
||||
expr_ty elt;
|
||||
asdl_seq *generators;
|
||||
} ListComp;
|
||||
|
||||
struct {
|
||||
expr_ty elt;
|
||||
asdl_seq *generators;
|
||||
} SetComp;
|
||||
|
||||
struct {
|
||||
expr_ty key;
|
||||
expr_ty value;
|
||||
asdl_seq *generators;
|
||||
} DictComp;
|
||||
|
||||
struct {
|
||||
expr_ty elt;
|
||||
asdl_seq *generators;
|
||||
} GeneratorExp;
|
||||
|
||||
struct {
|
||||
expr_ty value;
|
||||
} Yield;
|
||||
|
||||
struct {
|
||||
expr_ty left;
|
||||
asdl_int_seq *ops;
|
||||
asdl_seq *comparators;
|
||||
} Compare;
|
||||
|
||||
struct {
|
||||
expr_ty func;
|
||||
asdl_seq *args;
|
||||
asdl_seq *keywords;
|
||||
expr_ty starargs;
|
||||
expr_ty kwargs;
|
||||
} Call;
|
||||
|
||||
struct {
|
||||
expr_ty value;
|
||||
} Repr;
|
||||
|
||||
struct {
|
||||
object n;
|
||||
} Num;
|
||||
|
||||
struct {
|
||||
string s;
|
||||
} Str;
|
||||
|
||||
struct {
|
||||
expr_ty value;
|
||||
identifier attr;
|
||||
expr_context_ty ctx;
|
||||
} Attribute;
|
||||
|
||||
struct {
|
||||
expr_ty value;
|
||||
slice_ty slice;
|
||||
expr_context_ty ctx;
|
||||
} Subscript;
|
||||
|
||||
struct {
|
||||
identifier id;
|
||||
expr_context_ty ctx;
|
||||
} Name;
|
||||
|
||||
struct {
|
||||
asdl_seq *elts;
|
||||
expr_context_ty ctx;
|
||||
} List;
|
||||
|
||||
struct {
|
||||
asdl_seq *elts;
|
||||
expr_context_ty ctx;
|
||||
} Tuple;
|
||||
|
||||
} v;
|
||||
int lineno;
|
||||
int col_offset;
|
||||
};
|
||||
|
||||
enum _slice_kind {Ellipsis_kind=1, Slice_kind=2, ExtSlice_kind=3, Index_kind=4};
|
||||
struct _slice {
|
||||
enum _slice_kind kind;
|
||||
union {
|
||||
struct {
|
||||
expr_ty lower;
|
||||
expr_ty upper;
|
||||
expr_ty step;
|
||||
} Slice;
|
||||
|
||||
struct {
|
||||
asdl_seq *dims;
|
||||
} ExtSlice;
|
||||
|
||||
struct {
|
||||
expr_ty value;
|
||||
} Index;
|
||||
|
||||
} v;
|
||||
};
|
||||
|
||||
struct _comprehension {
|
||||
expr_ty target;
|
||||
expr_ty iter;
|
||||
asdl_seq *ifs;
|
||||
};
|
||||
|
||||
enum _excepthandler_kind {ExceptHandler_kind=1};
|
||||
struct _excepthandler {
|
||||
enum _excepthandler_kind kind;
|
||||
union {
|
||||
struct {
|
||||
expr_ty type;
|
||||
expr_ty name;
|
||||
asdl_seq *body;
|
||||
} ExceptHandler;
|
||||
|
||||
} v;
|
||||
int lineno;
|
||||
int col_offset;
|
||||
};
|
||||
|
||||
struct _arguments {
|
||||
asdl_seq *args;
|
||||
identifier vararg;
|
||||
identifier kwarg;
|
||||
asdl_seq *defaults;
|
||||
};
|
||||
|
||||
struct _keyword {
|
||||
identifier arg;
|
||||
expr_ty value;
|
||||
};
|
||||
|
||||
struct _alias {
|
||||
identifier name;
|
||||
identifier asname;
|
||||
};
|
||||
|
||||
|
||||
#define Module(a0, a1) _Py_Module(a0, a1)
|
||||
mod_ty _Py_Module(asdl_seq * body, PyArena *arena);
|
||||
#define Interactive(a0, a1) _Py_Interactive(a0, a1)
|
||||
mod_ty _Py_Interactive(asdl_seq * body, PyArena *arena);
|
||||
#define Expression(a0, a1) _Py_Expression(a0, a1)
|
||||
mod_ty _Py_Expression(expr_ty body, PyArena *arena);
|
||||
#define Suite(a0, a1) _Py_Suite(a0, a1)
|
||||
mod_ty _Py_Suite(asdl_seq * body, PyArena *arena);
|
||||
#define FunctionDef(a0, a1, a2, a3, a4, a5, a6) _Py_FunctionDef(a0, a1, a2, a3, a4, a5, a6)
|
||||
stmt_ty _Py_FunctionDef(identifier name, arguments_ty args, asdl_seq * body,
|
||||
asdl_seq * decorator_list, int lineno, int col_offset,
|
||||
PyArena *arena);
|
||||
#define ClassDef(a0, a1, a2, a3, a4, a5, a6) _Py_ClassDef(a0, a1, a2, a3, a4, a5, a6)
|
||||
stmt_ty _Py_ClassDef(identifier name, asdl_seq * bases, asdl_seq * body,
|
||||
asdl_seq * decorator_list, int lineno, int col_offset,
|
||||
PyArena *arena);
|
||||
#define Return(a0, a1, a2, a3) _Py_Return(a0, a1, a2, a3)
|
||||
stmt_ty _Py_Return(expr_ty value, int lineno, int col_offset, PyArena *arena);
|
||||
#define Delete(a0, a1, a2, a3) _Py_Delete(a0, a1, a2, a3)
|
||||
stmt_ty _Py_Delete(asdl_seq * targets, int lineno, int col_offset, PyArena
|
||||
*arena);
|
||||
#define Assign(a0, a1, a2, a3, a4) _Py_Assign(a0, a1, a2, a3, a4)
|
||||
stmt_ty _Py_Assign(asdl_seq * targets, expr_ty value, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define AugAssign(a0, a1, a2, a3, a4, a5) _Py_AugAssign(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_AugAssign(expr_ty target, operator_ty op, expr_ty value, int
|
||||
lineno, int col_offset, PyArena *arena);
|
||||
#define Print(a0, a1, a2, a3, a4, a5) _Py_Print(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_Print(expr_ty dest, asdl_seq * values, bool nl, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define For(a0, a1, a2, a3, a4, a5, a6) _Py_For(a0, a1, a2, a3, a4, a5, a6)
|
||||
stmt_ty _Py_For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq *
|
||||
orelse, int lineno, int col_offset, PyArena *arena);
|
||||
#define While(a0, a1, a2, a3, a4, a5) _Py_While(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno,
|
||||
int col_offset, PyArena *arena);
|
||||
#define If(a0, a1, a2, a3, a4, a5) _Py_If(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno,
|
||||
int col_offset, PyArena *arena);
|
||||
#define With(a0, a1, a2, a3, a4, a5) _Py_With(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body,
|
||||
int lineno, int col_offset, PyArena *arena);
|
||||
#define Raise(a0, a1, a2, a3, a4, a5) _Py_Raise(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define TryExcept(a0, a1, a2, a3, a4, a5) _Py_TryExcept(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse,
|
||||
int lineno, int col_offset, PyArena *arena);
|
||||
#define TryFinally(a0, a1, a2, a3, a4) _Py_TryFinally(a0, a1, a2, a3, a4)
|
||||
stmt_ty _Py_TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define Assert(a0, a1, a2, a3, a4) _Py_Assert(a0, a1, a2, a3, a4)
|
||||
stmt_ty _Py_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset,
|
||||
PyArena *arena);
|
||||
#define Import(a0, a1, a2, a3) _Py_Import(a0, a1, a2, a3)
|
||||
stmt_ty _Py_Import(asdl_seq * names, int lineno, int col_offset, PyArena
|
||||
*arena);
|
||||
#define ImportFrom(a0, a1, a2, a3, a4, a5) _Py_ImportFrom(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_ImportFrom(identifier module, asdl_seq * names, int level, int
|
||||
lineno, int col_offset, PyArena *arena);
|
||||
#define Exec(a0, a1, a2, a3, a4, a5) _Py_Exec(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define Global(a0, a1, a2, a3) _Py_Global(a0, a1, a2, a3)
|
||||
stmt_ty _Py_Global(asdl_seq * names, int lineno, int col_offset, PyArena
|
||||
*arena);
|
||||
#define Expr(a0, a1, a2, a3) _Py_Expr(a0, a1, a2, a3)
|
||||
stmt_ty _Py_Expr(expr_ty value, int lineno, int col_offset, PyArena *arena);
|
||||
#define Pass(a0, a1, a2) _Py_Pass(a0, a1, a2)
|
||||
stmt_ty _Py_Pass(int lineno, int col_offset, PyArena *arena);
|
||||
#define Break(a0, a1, a2) _Py_Break(a0, a1, a2)
|
||||
stmt_ty _Py_Break(int lineno, int col_offset, PyArena *arena);
|
||||
#define Continue(a0, a1, a2) _Py_Continue(a0, a1, a2)
|
||||
stmt_ty _Py_Continue(int lineno, int col_offset, PyArena *arena);
|
||||
#define BoolOp(a0, a1, a2, a3, a4) _Py_BoolOp(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset,
|
||||
PyArena *arena);
|
||||
#define BinOp(a0, a1, a2, a3, a4, a5) _Py_BinOp(a0, a1, a2, a3, a4, a5)
|
||||
expr_ty _Py_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define UnaryOp(a0, a1, a2, a3, a4) _Py_UnaryOp(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset,
|
||||
PyArena *arena);
|
||||
#define Lambda(a0, a1, a2, a3, a4) _Py_Lambda(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset,
|
||||
PyArena *arena);
|
||||
#define IfExp(a0, a1, a2, a3, a4, a5) _Py_IfExp(a0, a1, a2, a3, a4, a5)
|
||||
expr_ty _Py_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define Dict(a0, a1, a2, a3, a4) _Py_Dict(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_Dict(asdl_seq * keys, asdl_seq * values, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define Set(a0, a1, a2, a3) _Py_Set(a0, a1, a2, a3)
|
||||
expr_ty _Py_Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena);
|
||||
#define ListComp(a0, a1, a2, a3, a4) _Py_ListComp(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_ListComp(expr_ty elt, asdl_seq * generators, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define SetComp(a0, a1, a2, a3, a4) _Py_SetComp(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_SetComp(expr_ty elt, asdl_seq * generators, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define DictComp(a0, a1, a2, a3, a4, a5) _Py_DictComp(a0, a1, a2, a3, a4, a5)
|
||||
expr_ty _Py_DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int
|
||||
lineno, int col_offset, PyArena *arena);
|
||||
#define GeneratorExp(a0, a1, a2, a3, a4) _Py_GeneratorExp(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define Yield(a0, a1, a2, a3) _Py_Yield(a0, a1, a2, a3)
|
||||
expr_ty _Py_Yield(expr_ty value, int lineno, int col_offset, PyArena *arena);
|
||||
#define Compare(a0, a1, a2, a3, a4, a5) _Py_Compare(a0, a1, a2, a3, a4, a5)
|
||||
expr_ty _Py_Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators,
|
||||
int lineno, int col_offset, PyArena *arena);
|
||||
#define Call(a0, a1, a2, a3, a4, a5, a6, a7) _Py_Call(a0, a1, a2, a3, a4, a5, a6, a7)
|
||||
expr_ty _Py_Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty
|
||||
starargs, expr_ty kwargs, int lineno, int col_offset, PyArena
|
||||
*arena);
|
||||
#define Repr(a0, a1, a2, a3) _Py_Repr(a0, a1, a2, a3)
|
||||
expr_ty _Py_Repr(expr_ty value, int lineno, int col_offset, PyArena *arena);
|
||||
#define Num(a0, a1, a2, a3) _Py_Num(a0, a1, a2, a3)
|
||||
expr_ty _Py_Num(object n, int lineno, int col_offset, PyArena *arena);
|
||||
#define Str(a0, a1, a2, a3) _Py_Str(a0, a1, a2, a3)
|
||||
expr_ty _Py_Str(string s, int lineno, int col_offset, PyArena *arena);
|
||||
#define Attribute(a0, a1, a2, a3, a4, a5) _Py_Attribute(a0, a1, a2, a3, a4, a5)
|
||||
expr_ty _Py_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
|
||||
lineno, int col_offset, PyArena *arena);
|
||||
#define Subscript(a0, a1, a2, a3, a4, a5) _Py_Subscript(a0, a1, a2, a3, a4, a5)
|
||||
expr_ty _Py_Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int
|
||||
lineno, int col_offset, PyArena *arena);
|
||||
#define Name(a0, a1, a2, a3, a4) _Py_Name(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_Name(identifier id, expr_context_ty ctx, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define List(a0, a1, a2, a3, a4) _Py_List(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_List(asdl_seq * elts, expr_context_ty ctx, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define Tuple(a0, a1, a2, a3, a4) _Py_Tuple(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define Ellipsis(a0) _Py_Ellipsis(a0)
|
||||
slice_ty _Py_Ellipsis(PyArena *arena);
|
||||
#define Slice(a0, a1, a2, a3) _Py_Slice(a0, a1, a2, a3)
|
||||
slice_ty _Py_Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena);
|
||||
#define ExtSlice(a0, a1) _Py_ExtSlice(a0, a1)
|
||||
slice_ty _Py_ExtSlice(asdl_seq * dims, PyArena *arena);
|
||||
#define Index(a0, a1) _Py_Index(a0, a1)
|
||||
slice_ty _Py_Index(expr_ty value, PyArena *arena);
|
||||
#define comprehension(a0, a1, a2, a3) _Py_comprehension(a0, a1, a2, a3)
|
||||
comprehension_ty _Py_comprehension(expr_ty target, expr_ty iter, asdl_seq *
|
||||
ifs, PyArena *arena);
|
||||
#define ExceptHandler(a0, a1, a2, a3, a4, a5) _Py_ExceptHandler(a0, a1, a2, a3, a4, a5)
|
||||
excepthandler_ty _Py_ExceptHandler(expr_ty type, expr_ty name, asdl_seq * body,
|
||||
int lineno, int col_offset, PyArena *arena);
|
||||
#define arguments(a0, a1, a2, a3, a4) _Py_arguments(a0, a1, a2, a3, a4)
|
||||
arguments_ty _Py_arguments(asdl_seq * args, identifier vararg, identifier
|
||||
kwarg, asdl_seq * defaults, PyArena *arena);
|
||||
#define keyword(a0, a1, a2) _Py_keyword(a0, a1, a2)
|
||||
keyword_ty _Py_keyword(identifier arg, expr_ty value, PyArena *arena);
|
||||
#define alias(a0, a1, a2) _Py_alias(a0, a1, a2)
|
||||
alias_ty _Py_alias(identifier name, identifier asname, PyArena *arena);
|
||||
|
||||
PyObject* PyAST_mod2obj(mod_ty t);
|
||||
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);
|
||||
int PyAST_Check(PyObject* obj);
|
178
c/meterpreter/source/extensions/python/Include/Python.h
Normal file
178
c/meterpreter/source/extensions/python/Include/Python.h
Normal file
@ -0,0 +1,178 @@
|
||||
#ifndef Py_PYTHON_H
|
||||
#define Py_PYTHON_H
|
||||
/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
|
||||
|
||||
/* Include nearly all Python header files */
|
||||
|
||||
#include "patchlevel.h"
|
||||
#include "pyconfig.h"
|
||||
#include "pymacconfig.h"
|
||||
|
||||
/* Cyclic gc is always enabled, starting with release 2.3a1. Supply the
|
||||
* old symbol for the benefit of extension modules written before then
|
||||
* that may be conditionalizing on it. The core doesn't use it anymore.
|
||||
*/
|
||||
#ifndef WITH_CYCLE_GC
|
||||
#define WITH_CYCLE_GC 1
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef UCHAR_MAX
|
||||
#error "Something's broken. UCHAR_MAX should be defined in limits.h."
|
||||
#endif
|
||||
|
||||
#if UCHAR_MAX != 255
|
||||
#error "Python's source code assumes C's unsigned char is an 8-bit type."
|
||||
#endif
|
||||
|
||||
#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE)
|
||||
#define _SGI_MP_SOURCE
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#ifndef NULL
|
||||
# error "Python.h requires that stdio.h define NULL."
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* For size_t? */
|
||||
#ifdef HAVE_STDDEF_H
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
/* CAUTION: Build setups should ensure that NDEBUG is defined on the
|
||||
* compiler command line when building Python in release mode; else
|
||||
* assert() calls won't be removed.
|
||||
*/
|
||||
#include <assert.h>
|
||||
|
||||
#include "pyport.h"
|
||||
|
||||
/* pyconfig.h or pyport.h may or may not define DL_IMPORT */
|
||||
#ifndef DL_IMPORT /* declarations for DLL import/export */
|
||||
#define DL_IMPORT(RTYPE) RTYPE
|
||||
#endif
|
||||
#ifndef DL_EXPORT /* declarations for DLL import/export */
|
||||
#define DL_EXPORT(RTYPE) RTYPE
|
||||
#endif
|
||||
|
||||
/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG.
|
||||
* PYMALLOC_DEBUG is in error if pymalloc is not in use.
|
||||
*/
|
||||
#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG)
|
||||
#define PYMALLOC_DEBUG
|
||||
#endif
|
||||
#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC)
|
||||
#error "PYMALLOC_DEBUG requires WITH_PYMALLOC"
|
||||
#endif
|
||||
#include "pymath.h"
|
||||
#include "pymem.h"
|
||||
|
||||
#include "object.h"
|
||||
#include "objimpl.h"
|
||||
|
||||
#include "pydebug.h"
|
||||
|
||||
#include "unicodeobject.h"
|
||||
#include "intobject.h"
|
||||
#include "boolobject.h"
|
||||
#include "longobject.h"
|
||||
#include "floatobject.h"
|
||||
#ifndef WITHOUT_COMPLEX
|
||||
#include "complexobject.h"
|
||||
#endif
|
||||
#include "rangeobject.h"
|
||||
#include "stringobject.h"
|
||||
#include "memoryobject.h"
|
||||
#include "bufferobject.h"
|
||||
#include "bytesobject.h"
|
||||
#include "bytearrayobject.h"
|
||||
#include "tupleobject.h"
|
||||
#include "listobject.h"
|
||||
#include "dictobject.h"
|
||||
#include "enumobject.h"
|
||||
#include "setobject.h"
|
||||
#include "methodobject.h"
|
||||
#include "moduleobject.h"
|
||||
#include "funcobject.h"
|
||||
#include "classobject.h"
|
||||
#include "fileobject.h"
|
||||
#include "cobject.h"
|
||||
#include "pycapsule.h"
|
||||
#include "traceback.h"
|
||||
#include "sliceobject.h"
|
||||
#include "cellobject.h"
|
||||
#include "iterobject.h"
|
||||
#include "genobject.h"
|
||||
#include "descrobject.h"
|
||||
#include "warnings.h"
|
||||
#include "weakrefobject.h"
|
||||
|
||||
#include "codecs.h"
|
||||
#include "pyerrors.h"
|
||||
|
||||
#include "pystate.h"
|
||||
|
||||
#include "pyarena.h"
|
||||
#include "modsupport.h"
|
||||
#include "pythonrun.h"
|
||||
#include "ceval.h"
|
||||
#include "sysmodule.h"
|
||||
#include "intrcheck.h"
|
||||
#include "import.h"
|
||||
|
||||
#include "abstract.h"
|
||||
|
||||
#include "compile.h"
|
||||
#include "eval.h"
|
||||
|
||||
#include "pyctype.h"
|
||||
#include "pystrtod.h"
|
||||
#include "pystrcmp.h"
|
||||
#include "dtoa.h"
|
||||
|
||||
/* _Py_Mangle is defined in compile.c */
|
||||
PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
|
||||
|
||||
/* PyArg_GetInt is deprecated and should not be used, use PyArg_Parse(). */
|
||||
#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a))
|
||||
|
||||
/* PyArg_NoArgs should not be necessary.
|
||||
Set ml_flags in the PyMethodDef to METH_NOARGS. */
|
||||
#define PyArg_NoArgs(v) PyArg_Parse(v, "")
|
||||
|
||||
/* Argument must be a char or an int in [-128, 127] or [0, 255]. */
|
||||
#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff))
|
||||
|
||||
#include "pyfpe.h"
|
||||
|
||||
/* These definitions must match corresponding definitions in graminit.h.
|
||||
There's code in compile.c that checks that they are the same. */
|
||||
#define Py_single_input 256
|
||||
#define Py_file_input 257
|
||||
#define Py_eval_input 258
|
||||
|
||||
#ifdef HAVE_PTH
|
||||
/* GNU pth user-space thread support */
|
||||
#include <pth.h>
|
||||
#endif
|
||||
|
||||
/* Define macros for inline documentation. */
|
||||
#define PyDoc_VAR(name) static char name[]
|
||||
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
|
||||
#ifdef WITH_DOC_STRINGS
|
||||
#define PyDoc_STR(str) str
|
||||
#else
|
||||
#define PyDoc_STR(str) ""
|
||||
#endif
|
||||
|
||||
#endif /* !Py_PYTHON_H */
|
1396
c/meterpreter/source/extensions/python/Include/abstract.h
Normal file
1396
c/meterpreter/source/extensions/python/Include/abstract.h
Normal file
File diff suppressed because it is too large
Load Diff
45
c/meterpreter/source/extensions/python/Include/asdl.h
Normal file
45
c/meterpreter/source/extensions/python/Include/asdl.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef Py_ASDL_H
|
||||
#define Py_ASDL_H
|
||||
|
||||
typedef PyObject * identifier;
|
||||
typedef PyObject * string;
|
||||
typedef PyObject * object;
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef enum {false, true} bool;
|
||||
#endif
|
||||
|
||||
/* It would be nice if the code generated by asdl_c.py was completely
|
||||
independent of Python, but it is a goal the requires too much work
|
||||
at this stage. So, for example, I'll represent identifiers as
|
||||
interned Python strings.
|
||||
*/
|
||||
|
||||
/* XXX A sequence should be typed so that its use can be typechecked. */
|
||||
|
||||
typedef struct {
|
||||
int size;
|
||||
void *elements[1];
|
||||
} asdl_seq;
|
||||
|
||||
typedef struct {
|
||||
int size;
|
||||
int elements[1];
|
||||
} asdl_int_seq;
|
||||
|
||||
asdl_seq *asdl_seq_new(int size, PyArena *arena);
|
||||
asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena);
|
||||
|
||||
#define asdl_seq_GET(S, I) (S)->elements[(I)]
|
||||
#define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
|
||||
#ifdef Py_DEBUG
|
||||
#define asdl_seq_SET(S, I, V) { \
|
||||
int _asdl_i = (I); \
|
||||
assert((S) && _asdl_i < (S)->size); \
|
||||
(S)->elements[_asdl_i] = (V); \
|
||||
}
|
||||
#else
|
||||
#define asdl_seq_SET(S, I, V) (S)->elements[I] = (V)
|
||||
#endif
|
||||
|
||||
#endif /* !Py_ASDL_H */
|
13
c/meterpreter/source/extensions/python/Include/ast.h
Normal file
13
c/meterpreter/source/extensions/python/Include/ast.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef Py_AST_H
|
||||
#define Py_AST_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(mod_ty) PyAST_FromNode(const node *, PyCompilerFlags *flags,
|
||||
const char *, PyArena *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_AST_H */
|
32
c/meterpreter/source/extensions/python/Include/bitset.h
Normal file
32
c/meterpreter/source/extensions/python/Include/bitset.h
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
#ifndef Py_BITSET_H
|
||||
#define Py_BITSET_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Bitset interface */
|
||||
|
||||
#define BYTE char
|
||||
|
||||
typedef BYTE *bitset;
|
||||
|
||||
bitset newbitset(int nbits);
|
||||
void delbitset(bitset bs);
|
||||
#define testbit(ss, ibit) (((ss)[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0)
|
||||
int addbit(bitset bs, int ibit); /* Returns 0 if already set */
|
||||
int samebitset(bitset bs1, bitset bs2, int nbits);
|
||||
void mergebitset(bitset bs1, bitset bs2, int nbits);
|
||||
|
||||
#define BITSPERBYTE (8*sizeof(BYTE))
|
||||
#define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE)
|
||||
|
||||
#define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE)
|
||||
#define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE)
|
||||
#define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit))
|
||||
#define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_BITSET_H */
|
36
c/meterpreter/source/extensions/python/Include/boolobject.h
Normal file
36
c/meterpreter/source/extensions/python/Include/boolobject.h
Normal file
@ -0,0 +1,36 @@
|
||||
/* Boolean object interface */
|
||||
|
||||
#ifndef Py_BOOLOBJECT_H
|
||||
#define Py_BOOLOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef PyIntObject PyBoolObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyBool_Type;
|
||||
|
||||
#define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type)
|
||||
|
||||
/* Py_False and Py_True are the only two bools in existence.
|
||||
Don't forget to apply Py_INCREF() when returning either!!! */
|
||||
|
||||
/* Don't use these directly */
|
||||
PyAPI_DATA(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct;
|
||||
|
||||
/* Use these macros */
|
||||
#define Py_False ((PyObject *) &_Py_ZeroStruct)
|
||||
#define Py_True ((PyObject *) &_Py_TrueStruct)
|
||||
|
||||
/* Macros for returning Py_True or Py_False, respectively */
|
||||
#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
|
||||
#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
|
||||
|
||||
/* Function to return a bool from a C long */
|
||||
PyAPI_FUNC(PyObject *) PyBool_FromLong(long);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_BOOLOBJECT_H */
|
@ -0,0 +1,33 @@
|
||||
|
||||
/* Buffer object interface */
|
||||
|
||||
/* Note: the object's structure is private */
|
||||
|
||||
#ifndef Py_BUFFEROBJECT_H
|
||||
#define Py_BUFFEROBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyBuffer_Type;
|
||||
|
||||
#define PyBuffer_Check(op) (Py_TYPE(op) == &PyBuffer_Type)
|
||||
|
||||
#define Py_END_OF_BUFFER (-1)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyBuffer_FromObject(PyObject *base,
|
||||
Py_ssize_t offset, Py_ssize_t size);
|
||||
PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteObject(PyObject *base,
|
||||
Py_ssize_t offset,
|
||||
Py_ssize_t size);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, Py_ssize_t size);
|
||||
PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyBuffer_New(Py_ssize_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_BUFFEROBJECT_H */
|
@ -0,0 +1,57 @@
|
||||
/* ByteArray object interface */
|
||||
|
||||
#ifndef Py_BYTEARRAYOBJECT_H
|
||||
#define Py_BYTEARRAYOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
/* Type PyByteArrayObject represents a mutable array of bytes.
|
||||
* The Python API is that of a sequence;
|
||||
* the bytes are mapped to ints in [0, 256).
|
||||
* Bytes are not characters; they may be used to encode characters.
|
||||
* The only way to go between bytes and str/unicode is via encoding
|
||||
* and decoding.
|
||||
* For the convenience of C programmers, the bytes type is considered
|
||||
* to contain a char pointer, not an unsigned char pointer.
|
||||
*/
|
||||
|
||||
/* Object layout */
|
||||
typedef struct {
|
||||
PyObject_VAR_HEAD
|
||||
/* XXX(nnorwitz): should ob_exports be Py_ssize_t? */
|
||||
int ob_exports; /* how many buffer exports */
|
||||
Py_ssize_t ob_alloc; /* How many bytes allocated */
|
||||
char *ob_bytes;
|
||||
} PyByteArrayObject;
|
||||
|
||||
/* Type object */
|
||||
PyAPI_DATA(PyTypeObject) PyByteArray_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
|
||||
|
||||
/* Type check macros */
|
||||
#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type)
|
||||
#define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type)
|
||||
|
||||
/* Direct API functions */
|
||||
PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t);
|
||||
PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *);
|
||||
PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *);
|
||||
PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
|
||||
|
||||
/* Macros, trading safety for speed */
|
||||
#define PyByteArray_AS_STRING(self) \
|
||||
(assert(PyByteArray_Check(self)), \
|
||||
Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_bytes : _PyByteArray_empty_string)
|
||||
#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self))
|
||||
|
||||
PyAPI_DATA(char) _PyByteArray_empty_string[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_BYTEARRAYOBJECT_H */
|
@ -0,0 +1,75 @@
|
||||
#ifndef Py_BYTES_CTYPE_H
|
||||
#define Py_BYTES_CTYPE_H
|
||||
|
||||
/*
|
||||
* The internal implementation behind PyString (bytes) and PyBytes (buffer)
|
||||
* methods of the given names, they operate on ASCII byte strings.
|
||||
*/
|
||||
extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len);
|
||||
extern PyObject* _Py_bytes_isalpha(const char *cptr, Py_ssize_t len);
|
||||
extern PyObject* _Py_bytes_isalnum(const char *cptr, Py_ssize_t len);
|
||||
extern PyObject* _Py_bytes_isdigit(const char *cptr, Py_ssize_t len);
|
||||
extern PyObject* _Py_bytes_islower(const char *cptr, Py_ssize_t len);
|
||||
extern PyObject* _Py_bytes_isupper(const char *cptr, Py_ssize_t len);
|
||||
extern PyObject* _Py_bytes_istitle(const char *cptr, Py_ssize_t len);
|
||||
|
||||
/* These store their len sized answer in the given preallocated *result arg. */
|
||||
extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len);
|
||||
extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len);
|
||||
extern void _Py_bytes_title(char *result, char *s, Py_ssize_t len);
|
||||
extern void _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len);
|
||||
extern void _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len);
|
||||
|
||||
/* Shared __doc__ strings. */
|
||||
extern const char _Py_isspace__doc__[];
|
||||
extern const char _Py_isalpha__doc__[];
|
||||
extern const char _Py_isalnum__doc__[];
|
||||
extern const char _Py_isdigit__doc__[];
|
||||
extern const char _Py_islower__doc__[];
|
||||
extern const char _Py_isupper__doc__[];
|
||||
extern const char _Py_istitle__doc__[];
|
||||
extern const char _Py_lower__doc__[];
|
||||
extern const char _Py_upper__doc__[];
|
||||
extern const char _Py_title__doc__[];
|
||||
extern const char _Py_capitalize__doc__[];
|
||||
extern const char _Py_swapcase__doc__[];
|
||||
|
||||
/* These are left in for backward compatibility and will be removed
|
||||
in 2.8/3.2 */
|
||||
#define ISLOWER(c) Py_ISLOWER(c)
|
||||
#define ISUPPER(c) Py_ISUPPER(c)
|
||||
#define ISALPHA(c) Py_ISALPHA(c)
|
||||
#define ISDIGIT(c) Py_ISDIGIT(c)
|
||||
#define ISXDIGIT(c) Py_ISXDIGIT(c)
|
||||
#define ISALNUM(c) Py_ISALNUM(c)
|
||||
#define ISSPACE(c) Py_ISSPACE(c)
|
||||
|
||||
#undef islower
|
||||
#define islower(c) undefined_islower(c)
|
||||
#undef isupper
|
||||
#define isupper(c) undefined_isupper(c)
|
||||
#undef isalpha
|
||||
#define isalpha(c) undefined_isalpha(c)
|
||||
#undef isdigit
|
||||
#define isdigit(c) undefined_isdigit(c)
|
||||
#undef isxdigit
|
||||
#define isxdigit(c) undefined_isxdigit(c)
|
||||
#undef isalnum
|
||||
#define isalnum(c) undefined_isalnum(c)
|
||||
#undef isspace
|
||||
#define isspace(c) undefined_isspace(c)
|
||||
|
||||
/* These are left in for backward compatibility and will be removed
|
||||
in 2.8/3.2 */
|
||||
#define TOLOWER(c) Py_TOLOWER(c)
|
||||
#define TOUPPER(c) Py_TOUPPER(c)
|
||||
|
||||
#undef tolower
|
||||
#define tolower(c) undefined_tolower(c)
|
||||
#undef toupper
|
||||
#define toupper(c) undefined_toupper(c)
|
||||
|
||||
/* this is needed because some docs are shared from the .o, not static */
|
||||
#define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str)
|
||||
|
||||
#endif /* !Py_BYTES_CTYPE_H */
|
27
c/meterpreter/source/extensions/python/Include/bytesobject.h
Normal file
27
c/meterpreter/source/extensions/python/Include/bytesobject.h
Normal file
@ -0,0 +1,27 @@
|
||||
#define PyBytesObject PyStringObject
|
||||
#define PyBytes_Type PyString_Type
|
||||
|
||||
#define PyBytes_Check PyString_Check
|
||||
#define PyBytes_CheckExact PyString_CheckExact
|
||||
#define PyBytes_CHECK_INTERNED PyString_CHECK_INTERNED
|
||||
#define PyBytes_AS_STRING PyString_AS_STRING
|
||||
#define PyBytes_GET_SIZE PyString_GET_SIZE
|
||||
#define Py_TPFLAGS_BYTES_SUBCLASS Py_TPFLAGS_STRING_SUBCLASS
|
||||
|
||||
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
|
||||
#define PyBytes_FromString PyString_FromString
|
||||
#define PyBytes_FromFormatV PyString_FromFormatV
|
||||
#define PyBytes_FromFormat PyString_FromFormat
|
||||
#define PyBytes_Size PyString_Size
|
||||
#define PyBytes_AsString PyString_AsString
|
||||
#define PyBytes_Repr PyString_Repr
|
||||
#define PyBytes_Concat PyString_Concat
|
||||
#define PyBytes_ConcatAndDel PyString_ConcatAndDel
|
||||
#define _PyBytes_Resize _PyString_Resize
|
||||
#define _PyBytes_Eq _PyString_Eq
|
||||
#define PyBytes_Format PyString_Format
|
||||
#define _PyBytes_FormatLong _PyString_FormatLong
|
||||
#define PyBytes_DecodeEscape PyString_DecodeEscape
|
||||
#define _PyBytes_Join _PyString_Join
|
||||
#define PyBytes_AsStringAndSize PyString_AsStringAndSize
|
||||
#define _PyBytes_InsertThousandsGrouping _PyString_InsertThousandsGrouping
|
73
c/meterpreter/source/extensions/python/Include/cStringIO.h
Normal file
73
c/meterpreter/source/extensions/python/Include/cStringIO.h
Normal file
@ -0,0 +1,73 @@
|
||||
#ifndef Py_CSTRINGIO_H
|
||||
#define Py_CSTRINGIO_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
|
||||
This header provides access to cStringIO objects from C.
|
||||
Functions are provided for calling cStringIO objects and
|
||||
macros are provided for testing whether you have cStringIO
|
||||
objects.
|
||||
|
||||
Before calling any of the functions or macros, you must initialize
|
||||
the routines with:
|
||||
|
||||
PycString_IMPORT
|
||||
|
||||
This would typically be done in your init function.
|
||||
|
||||
*/
|
||||
|
||||
#define PycStringIO_CAPSULE_NAME "cStringIO.cStringIO_CAPI"
|
||||
|
||||
#define PycString_IMPORT \
|
||||
PycStringIO = ((struct PycStringIO_CAPI*)PyCapsule_Import(\
|
||||
PycStringIO_CAPSULE_NAME, 0))
|
||||
|
||||
/* Basic functions to manipulate cStringIO objects from C */
|
||||
|
||||
static struct PycStringIO_CAPI {
|
||||
|
||||
/* Read a string from an input object. If the last argument
|
||||
is -1, the remainder will be read.
|
||||
*/
|
||||
int(*cread)(PyObject *, char **, Py_ssize_t);
|
||||
|
||||
/* Read a line from an input object. Returns the length of the read
|
||||
line as an int and a pointer inside the object buffer as char** (so
|
||||
the caller doesn't have to provide its own buffer as destination).
|
||||
*/
|
||||
int(*creadline)(PyObject *, char **);
|
||||
|
||||
/* Write a string to an output object*/
|
||||
int(*cwrite)(PyObject *, const char *, Py_ssize_t);
|
||||
|
||||
/* Get the output object as a Python string (returns new reference). */
|
||||
PyObject *(*cgetvalue)(PyObject *);
|
||||
|
||||
/* Create a new output object */
|
||||
PyObject *(*NewOutput)(int);
|
||||
|
||||
/* Create an input object from a Python string
|
||||
(copies the Python string reference).
|
||||
*/
|
||||
PyObject *(*NewInput)(PyObject *);
|
||||
|
||||
/* The Python types for cStringIO input and output objects.
|
||||
Note that you can do input on an output object.
|
||||
*/
|
||||
PyTypeObject *InputType, *OutputType;
|
||||
|
||||
} *PycStringIO;
|
||||
|
||||
/* These can be used to test if you have one */
|
||||
#define PycStringIO_InputCheck(O) \
|
||||
(Py_TYPE(O)==PycStringIO->InputType)
|
||||
#define PycStringIO_OutputCheck(O) \
|
||||
(Py_TYPE(O)==PycStringIO->OutputType)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_CSTRINGIO_H */
|
28
c/meterpreter/source/extensions/python/Include/cellobject.h
Normal file
28
c/meterpreter/source/extensions/python/Include/cellobject.h
Normal file
@ -0,0 +1,28 @@
|
||||
/* Cell object interface */
|
||||
|
||||
#ifndef Py_CELLOBJECT_H
|
||||
#define Py_CELLOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *ob_ref; /* Content of the cell or NULL when empty */
|
||||
} PyCellObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCell_Type;
|
||||
|
||||
#define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCell_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);
|
||||
PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *);
|
||||
|
||||
#define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref)
|
||||
#define PyCell_SET(op, v) (((PyCellObject *)(op))->ob_ref = v)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_TUPLEOBJECT_H */
|
153
c/meterpreter/source/extensions/python/Include/ceval.h
Normal file
153
c/meterpreter/source/extensions/python/Include/ceval.h
Normal file
@ -0,0 +1,153 @@
|
||||
#ifndef Py_CEVAL_H
|
||||
#define Py_CEVAL_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Interface to random parts in ceval.c */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
|
||||
PyObject *, PyObject *, PyObject *);
|
||||
|
||||
/* Inline this */
|
||||
#define PyEval_CallObject(func,arg) \
|
||||
PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj,
|
||||
const char *format, ...);
|
||||
PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
|
||||
const char *methodname,
|
||||
const char *format, ...);
|
||||
|
||||
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
|
||||
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
|
||||
|
||||
struct _frame; /* Avoid including frameobject.h */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);
|
||||
PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);
|
||||
PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);
|
||||
PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void);
|
||||
PyAPI_FUNC(int) PyEval_GetRestricted(void);
|
||||
|
||||
/* Look at the current frame's (if any) code's co_flags, and turn on
|
||||
the corresponding compiler flags in cf->cf_flags. Return 1 if any
|
||||
flag was set, else return 0. */
|
||||
PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
|
||||
|
||||
PyAPI_FUNC(int) Py_FlushLine(void);
|
||||
|
||||
PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
|
||||
PyAPI_FUNC(int) Py_MakePendingCalls(void);
|
||||
|
||||
/* Protection against deeply nested recursive calls */
|
||||
PyAPI_FUNC(void) Py_SetRecursionLimit(int);
|
||||
PyAPI_FUNC(int) Py_GetRecursionLimit(void);
|
||||
|
||||
#define Py_EnterRecursiveCall(where) \
|
||||
(_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \
|
||||
_Py_CheckRecursiveCall(where))
|
||||
#define Py_LeaveRecursiveCall() \
|
||||
(--PyThreadState_GET()->recursion_depth)
|
||||
PyAPI_FUNC(int) _Py_CheckRecursiveCall(const char *where);
|
||||
PyAPI_DATA(int) _Py_CheckRecursionLimit;
|
||||
#ifdef USE_STACKCHECK
|
||||
# define _Py_MakeRecCheck(x) (++(x) > --_Py_CheckRecursionLimit)
|
||||
#else
|
||||
# define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit)
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);
|
||||
PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *);
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc);
|
||||
|
||||
/* this used to be handled on a per-thread basis - now just two globals */
|
||||
PyAPI_DATA(volatile int) _Py_Ticker;
|
||||
PyAPI_DATA(int) _Py_CheckInterval;
|
||||
|
||||
/* Interface for threads.
|
||||
|
||||
A module that plans to do a blocking system call (or something else
|
||||
that lasts a long time and doesn't touch Python data) can allow other
|
||||
threads to run as follows:
|
||||
|
||||
...preparations here...
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
...blocking system call here...
|
||||
Py_END_ALLOW_THREADS
|
||||
...interpret result here...
|
||||
|
||||
The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
|
||||
{}-surrounded block.
|
||||
To leave the block in the middle (e.g., with return), you must insert
|
||||
a line containing Py_BLOCK_THREADS before the return, e.g.
|
||||
|
||||
if (...premature_exit...) {
|
||||
Py_BLOCK_THREADS
|
||||
PyErr_SetFromErrno(PyExc_IOError);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
An alternative is:
|
||||
|
||||
Py_BLOCK_THREADS
|
||||
if (...premature_exit...) {
|
||||
PyErr_SetFromErrno(PyExc_IOError);
|
||||
return NULL;
|
||||
}
|
||||
Py_UNBLOCK_THREADS
|
||||
|
||||
For convenience, that the value of 'errno' is restored across
|
||||
Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.
|
||||
|
||||
WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
|
||||
Py_END_ALLOW_THREADS!!!
|
||||
|
||||
The function PyEval_InitThreads() should be called only from
|
||||
initthread() in "threadmodule.c".
|
||||
|
||||
Note that not yet all candidates have been converted to use this
|
||||
mechanism!
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void);
|
||||
PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
|
||||
PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);
|
||||
PyAPI_FUNC(void) PyEval_InitThreads(void);
|
||||
PyAPI_FUNC(void) PyEval_AcquireLock(void);
|
||||
PyAPI_FUNC(void) PyEval_ReleaseLock(void);
|
||||
PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
|
||||
PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
|
||||
PyAPI_FUNC(void) PyEval_ReInitThreads(void);
|
||||
|
||||
#define Py_BEGIN_ALLOW_THREADS { \
|
||||
PyThreadState *_save; \
|
||||
_save = PyEval_SaveThread();
|
||||
#define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
|
||||
#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
|
||||
#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
|
||||
}
|
||||
|
||||
#else /* !WITH_THREAD */
|
||||
|
||||
#define Py_BEGIN_ALLOW_THREADS {
|
||||
#define Py_BLOCK_THREADS
|
||||
#define Py_UNBLOCK_THREADS
|
||||
#define Py_END_ALLOW_THREADS }
|
||||
|
||||
#endif /* !WITH_THREAD */
|
||||
|
||||
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_CEVAL_H */
|
83
c/meterpreter/source/extensions/python/Include/classobject.h
Normal file
83
c/meterpreter/source/extensions/python/Include/classobject.h
Normal file
@ -0,0 +1,83 @@
|
||||
|
||||
/* Class object interface */
|
||||
|
||||
/* Revealing some structures (not for general use) */
|
||||
|
||||
#ifndef Py_CLASSOBJECT_H
|
||||
#define Py_CLASSOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *cl_bases; /* A tuple of class objects */
|
||||
PyObject *cl_dict; /* A dictionary */
|
||||
PyObject *cl_name; /* A string */
|
||||
/* The following three are functions or NULL */
|
||||
PyObject *cl_getattr;
|
||||
PyObject *cl_setattr;
|
||||
PyObject *cl_delattr;
|
||||
PyObject *cl_weakreflist; /* List of weak references */
|
||||
} PyClassObject;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyClassObject *in_class; /* The class object */
|
||||
PyObject *in_dict; /* A dictionary */
|
||||
PyObject *in_weakreflist; /* List of weak references */
|
||||
} PyInstanceObject;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *im_func; /* The callable object implementing the method */
|
||||
PyObject *im_self; /* The instance it is bound to, or NULL */
|
||||
PyObject *im_class; /* The class that asked for the method */
|
||||
PyObject *im_weakreflist; /* List of weak references */
|
||||
} PyMethodObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type;
|
||||
|
||||
#define PyClass_Check(op) ((op)->ob_type == &PyClass_Type)
|
||||
#define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type)
|
||||
#define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyClass_New(PyObject *, PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyInstance_New(PyObject *, PyObject *,
|
||||
PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyInstance_NewRaw(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyMethod_Class(PyObject *);
|
||||
|
||||
/* Look up attribute with name (a string) on instance object pinst, using
|
||||
* only the instance and base class dicts. If a descriptor is found in
|
||||
* a class dict, the descriptor is returned without calling it.
|
||||
* Returns NULL if nothing found, else a borrowed reference to the
|
||||
* value associated with name in the dict in which name was found.
|
||||
* The point of this routine is that it never calls arbitrary Python
|
||||
* code, so is always "safe": all it does is dict lookups. The function
|
||||
* can't fail, never sets an exception, and NULL is not an error (it just
|
||||
* means "not found").
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyInstance_Lookup(PyObject *pinst, PyObject *name);
|
||||
|
||||
/* Macros for direct access to these values. Type checks are *not*
|
||||
done, so use with care. */
|
||||
#define PyMethod_GET_FUNCTION(meth) \
|
||||
(((PyMethodObject *)meth) -> im_func)
|
||||
#define PyMethod_GET_SELF(meth) \
|
||||
(((PyMethodObject *)meth) -> im_self)
|
||||
#define PyMethod_GET_CLASS(meth) \
|
||||
(((PyMethodObject *)meth) -> im_class)
|
||||
|
||||
PyAPI_FUNC(int) PyClass_IsSubclass(PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(int) PyMethod_ClearFreeList(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_CLASSOBJECT_H */
|
89
c/meterpreter/source/extensions/python/Include/cobject.h
Normal file
89
c/meterpreter/source/extensions/python/Include/cobject.h
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
CObjects are marked Pending Deprecation as of Python 2.7.
|
||||
The full schedule for 2.x is as follows:
|
||||
- CObjects are marked Pending Deprecation in Python 2.7.
|
||||
- CObjects will be marked Deprecated in Python 2.8
|
||||
(if there is one).
|
||||
- CObjects will be removed in Python 2.9 (if there is one).
|
||||
|
||||
Additionally, for the Python 3.x series:
|
||||
- CObjects were marked Deprecated in Python 3.1.
|
||||
- CObjects will be removed in Python 3.2.
|
||||
|
||||
You should switch all use of CObjects to capsules. Capsules
|
||||
have a safer and more consistent API. For more information,
|
||||
see Include/pycapsule.h, or read the "Capsules" topic in
|
||||
the "Python/C API Reference Manual".
|
||||
|
||||
Python 2.7 no longer uses CObjects itself; all objects which
|
||||
were formerly CObjects are now capsules. Note that this change
|
||||
does not by itself break binary compatibility with extensions
|
||||
built for previous versions of Python--PyCObject_AsVoidPtr()
|
||||
has been changed to also understand capsules.
|
||||
|
||||
*/
|
||||
|
||||
/* original file header comment follows: */
|
||||
|
||||
/* C objects to be exported from one extension module to another.
|
||||
|
||||
C objects are used for communication between extension modules.
|
||||
They provide a way for an extension module to export a C interface
|
||||
to other extension modules, so that extension modules can use the
|
||||
Python import mechanism to link to one another.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef Py_COBJECT_H
|
||||
#define Py_COBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCObject_Type;
|
||||
|
||||
#define PyCObject_Check(op) (Py_TYPE(op) == &PyCObject_Type)
|
||||
|
||||
/* Create a PyCObject from a pointer to a C object and an optional
|
||||
destructor function. If the second argument is non-null, then it
|
||||
will be called with the first argument if and when the PyCObject is
|
||||
destroyed.
|
||||
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtr(
|
||||
void *cobj, void (*destruct)(void*));
|
||||
|
||||
|
||||
/* Create a PyCObject from a pointer to a C object, a description object,
|
||||
and an optional destructor function. If the third argument is non-null,
|
||||
then it will be called with the first and second arguments if and when
|
||||
the PyCObject is destroyed.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtrAndDesc(
|
||||
void *cobj, void *desc, void (*destruct)(void*,void*));
|
||||
|
||||
/* Retrieve a pointer to a C object from a PyCObject. */
|
||||
PyAPI_FUNC(void *) PyCObject_AsVoidPtr(PyObject *);
|
||||
|
||||
/* Retrieve a pointer to a description object from a PyCObject. */
|
||||
PyAPI_FUNC(void *) PyCObject_GetDesc(PyObject *);
|
||||
|
||||
/* Import a pointer to a C object from a module using a PyCObject. */
|
||||
PyAPI_FUNC(void *) PyCObject_Import(char *module_name, char *cobject_name);
|
||||
|
||||
/* Modify a C object. Fails (==0) if object has a destructor. */
|
||||
PyAPI_FUNC(int) PyCObject_SetVoidPtr(PyObject *self, void *cobj);
|
||||
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
void *cobject;
|
||||
void *desc;
|
||||
void (*destructor)(void *);
|
||||
} PyCObject;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_COBJECT_H */
|
107
c/meterpreter/source/extensions/python/Include/code.h
Normal file
107
c/meterpreter/source/extensions/python/Include/code.h
Normal file
@ -0,0 +1,107 @@
|
||||
/* Definitions for bytecode */
|
||||
|
||||
#ifndef Py_CODE_H
|
||||
#define Py_CODE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Bytecode object */
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
int co_argcount; /* #arguments, except *args */
|
||||
int co_nlocals; /* #local variables */
|
||||
int co_stacksize; /* #entries needed for evaluation stack */
|
||||
int co_flags; /* CO_..., see below */
|
||||
PyObject *co_code; /* instruction opcodes */
|
||||
PyObject *co_consts; /* list (constants used) */
|
||||
PyObject *co_names; /* list of strings (names used) */
|
||||
PyObject *co_varnames; /* tuple of strings (local variable names) */
|
||||
PyObject *co_freevars; /* tuple of strings (free variable names) */
|
||||
PyObject *co_cellvars; /* tuple of strings (cell variable names) */
|
||||
/* The rest doesn't count for hash/cmp */
|
||||
PyObject *co_filename; /* string (where it was loaded from) */
|
||||
PyObject *co_name; /* string (name, for reference) */
|
||||
int co_firstlineno; /* first source line number */
|
||||
PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) See
|
||||
Objects/lnotab_notes.txt for details. */
|
||||
void *co_zombieframe; /* for optimization only (see frameobject.c) */
|
||||
PyObject *co_weakreflist; /* to support weakrefs to code objects */
|
||||
} PyCodeObject;
|
||||
|
||||
/* Masks for co_flags above */
|
||||
#define CO_OPTIMIZED 0x0001
|
||||
#define CO_NEWLOCALS 0x0002
|
||||
#define CO_VARARGS 0x0004
|
||||
#define CO_VARKEYWORDS 0x0008
|
||||
#define CO_NESTED 0x0010
|
||||
#define CO_GENERATOR 0x0020
|
||||
/* The CO_NOFREE flag is set if there are no free or cell variables.
|
||||
This information is redundant, but it allows a single flag test
|
||||
to determine whether there is any extra work to be done when the
|
||||
call frame it setup.
|
||||
*/
|
||||
#define CO_NOFREE 0x0040
|
||||
|
||||
#if 0
|
||||
/* This is no longer used. Stopped defining in 2.5, do not re-use. */
|
||||
#define CO_GENERATOR_ALLOWED 0x1000
|
||||
#endif
|
||||
#define CO_FUTURE_DIVISION 0x2000
|
||||
#define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */
|
||||
#define CO_FUTURE_WITH_STATEMENT 0x8000
|
||||
#define CO_FUTURE_PRINT_FUNCTION 0x10000
|
||||
#define CO_FUTURE_UNICODE_LITERALS 0x20000
|
||||
|
||||
/* This should be defined if a future statement modifies the syntax.
|
||||
For example, when a keyword is added.
|
||||
*/
|
||||
#if 1
|
||||
#define PY_PARSER_REQUIRES_FUTURE_KEYWORD
|
||||
#endif
|
||||
|
||||
#define CO_MAXBLOCKS 20 /* Max static block nesting within a function */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCode_Type;
|
||||
|
||||
#define PyCode_Check(op) (Py_TYPE(op) == &PyCode_Type)
|
||||
#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars))
|
||||
|
||||
/* Public interface */
|
||||
PyAPI_FUNC(PyCodeObject *) PyCode_New(
|
||||
int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *,
|
||||
PyObject *, PyObject *, PyObject *, PyObject *, int, PyObject *);
|
||||
/* same as struct above */
|
||||
|
||||
/* Creates a new empty code object with the specified source location. */
|
||||
PyAPI_FUNC(PyCodeObject *)
|
||||
PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno);
|
||||
|
||||
/* Return the line number associated with the specified bytecode index
|
||||
in this code object. If you just need the line number of a frame,
|
||||
use PyFrame_GetLineNumber() instead. */
|
||||
PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);
|
||||
|
||||
/* for internal use only */
|
||||
#define _PyCode_GETCODEPTR(co, pp) \
|
||||
((*Py_TYPE((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \
|
||||
((co)->co_code, 0, (void **)(pp)))
|
||||
|
||||
typedef struct _addr_pair {
|
||||
int ap_lower;
|
||||
int ap_upper;
|
||||
} PyAddrPair;
|
||||
|
||||
/* Update *bounds to describe the first and one-past-the-last instructions in the
|
||||
same line as lasti. Return the number of that line.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co,
|
||||
int lasti, PyAddrPair *bounds);
|
||||
|
||||
PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts,
|
||||
PyObject *names, PyObject *lineno_obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_CODE_H */
|
212
c/meterpreter/source/extensions/python/Include/codecs.h
Normal file
212
c/meterpreter/source/extensions/python/Include/codecs.h
Normal file
@ -0,0 +1,212 @@
|
||||
#ifndef Py_CODECREGISTRY_H
|
||||
#define Py_CODECREGISTRY_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
|
||||
Python Codec Registry and support functions
|
||||
|
||||
|
||||
Written by Marc-Andre Lemburg (mal@lemburg.com).
|
||||
|
||||
Copyright (c) Corporation for National Research Initiatives.
|
||||
|
||||
------------------------------------------------------------------------ */
|
||||
|
||||
/* Register a new codec search function.
|
||||
|
||||
As side effect, this tries to load the encodings package, if not
|
||||
yet done, to make sure that it is always first in the list of
|
||||
search functions.
|
||||
|
||||
The search_function's refcount is incremented by this function. */
|
||||
|
||||
PyAPI_FUNC(int) PyCodec_Register(
|
||||
PyObject *search_function
|
||||
);
|
||||
|
||||
/* Codec register lookup API.
|
||||
|
||||
Looks up the given encoding and returns a CodecInfo object with
|
||||
function attributes which implement the different aspects of
|
||||
processing the encoding.
|
||||
|
||||
The encoding string is looked up converted to all lower-case
|
||||
characters. This makes encodings looked up through this mechanism
|
||||
effectively case-insensitive.
|
||||
|
||||
If no codec is found, a KeyError is set and NULL returned.
|
||||
|
||||
As side effect, this tries to load the encodings package, if not
|
||||
yet done. This is part of the lazy load strategy for the encodings
|
||||
package.
|
||||
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyCodec_Lookup(
|
||||
const char *encoding
|
||||
);
|
||||
|
||||
/* Generic codec based encoding API.
|
||||
|
||||
object is passed through the encoder function found for the given
|
||||
encoding using the error handling method defined by errors. errors
|
||||
may be NULL to use the default method defined for the codec.
|
||||
|
||||
Raises a LookupError in case no encoder can be found.
|
||||
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Encode(
|
||||
PyObject *object,
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Generic codec based decoding API.
|
||||
|
||||
object is passed through the decoder function found for the given
|
||||
encoding using the error handling method defined by errors. errors
|
||||
may be NULL to use the default method defined for the codec.
|
||||
|
||||
Raises a LookupError in case no encoder can be found.
|
||||
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Decode(
|
||||
PyObject *object,
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Text codec specific encoding and decoding API.
|
||||
|
||||
Checks the encoding against a list of codecs which do not
|
||||
implement a unicode<->bytes encoding before attempting the
|
||||
operation.
|
||||
|
||||
Please note that these APIs are internal and should not
|
||||
be used in Python C extensions.
|
||||
|
||||
XXX (ncoghlan): should we make these, or something like them, public
|
||||
in Python 3.5+?
|
||||
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyCodec_LookupTextEncoding(
|
||||
const char *encoding,
|
||||
const char *alternate_command
|
||||
);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyCodec_EncodeText(
|
||||
PyObject *object,
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyCodec_DecodeText(
|
||||
PyObject *object,
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* These two aren't actually text encoding specific, but _io.TextIOWrapper
|
||||
* is the only current API consumer.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalDecoder(
|
||||
PyObject *codec_info,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalEncoder(
|
||||
PyObject *codec_info,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
|
||||
|
||||
/* --- Codec Lookup APIs --------------------------------------------------
|
||||
|
||||
All APIs return a codec object with incremented refcount and are
|
||||
based on _PyCodec_Lookup(). The same comments w/r to the encoding
|
||||
name also apply to these APIs.
|
||||
|
||||
*/
|
||||
|
||||
/* Get an encoder function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Encoder(
|
||||
const char *encoding
|
||||
);
|
||||
|
||||
/* Get a decoder function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Decoder(
|
||||
const char *encoding
|
||||
);
|
||||
|
||||
/* Get a IncrementalEncoder object for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Get a IncrementalDecoder object function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Get a StreamReader factory function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
|
||||
const char *encoding,
|
||||
PyObject *stream,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Get a StreamWriter factory function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_StreamWriter(
|
||||
const char *encoding,
|
||||
PyObject *stream,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Unicode encoding error handling callback registry API */
|
||||
|
||||
/* Register the error handling callback function error under the given
|
||||
name. This function will be called by the codec when it encounters
|
||||
unencodable characters/undecodable bytes and doesn't know the
|
||||
callback name, when name is specified as the error parameter
|
||||
in the call to the encode/decode function.
|
||||
Return 0 on success, -1 on error */
|
||||
PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);
|
||||
|
||||
/* Lookup the error handling callback function registered under the given
|
||||
name. As a special case NULL can be passed, in which case
|
||||
the error handling callback for "strict" will be returned. */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);
|
||||
|
||||
/* raise exc as an exception */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc);
|
||||
|
||||
/* ignore the unicode error, skipping the faulty input */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);
|
||||
|
||||
/* replace the unicode encode error with ? or U+FFFD */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);
|
||||
|
||||
/* replace the unicode encode error with XML character references */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc);
|
||||
|
||||
/* replace the unicode encode error with backslash escapes (\x, \u and \U) */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_CODECREGISTRY_H */
|
40
c/meterpreter/source/extensions/python/Include/compile.h
Normal file
40
c/meterpreter/source/extensions/python/Include/compile.h
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
#ifndef Py_COMPILE_H
|
||||
#define Py_COMPILE_H
|
||||
|
||||
#include "code.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Public interface */
|
||||
struct _node; /* Declare the existence of this type */
|
||||
PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
|
||||
|
||||
/* Future feature support */
|
||||
|
||||
typedef struct {
|
||||
int ff_features; /* flags set by future statements */
|
||||
int ff_lineno; /* line number of last future statement */
|
||||
} PyFutureFeatures;
|
||||
|
||||
#define FUTURE_NESTED_SCOPES "nested_scopes"
|
||||
#define FUTURE_GENERATORS "generators"
|
||||
#define FUTURE_DIVISION "division"
|
||||
#define FUTURE_ABSOLUTE_IMPORT "absolute_import"
|
||||
#define FUTURE_WITH_STATEMENT "with_statement"
|
||||
#define FUTURE_PRINT_FUNCTION "print_function"
|
||||
#define FUTURE_UNICODE_LITERALS "unicode_literals"
|
||||
|
||||
|
||||
struct _mod; /* Declare the existence of this type */
|
||||
PyAPI_FUNC(PyCodeObject *) PyAST_Compile(struct _mod *, const char *,
|
||||
PyCompilerFlags *, PyArena *);
|
||||
PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_COMPILE_H */
|
@ -0,0 +1,66 @@
|
||||
/* Complex number structure */
|
||||
|
||||
#ifndef Py_COMPLEXOBJECT_H
|
||||
#define Py_COMPLEXOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
double real;
|
||||
double imag;
|
||||
} Py_complex;
|
||||
|
||||
/* Operations on complex numbers from complexmodule.c */
|
||||
|
||||
#define c_sum _Py_c_sum
|
||||
#define c_diff _Py_c_diff
|
||||
#define c_neg _Py_c_neg
|
||||
#define c_prod _Py_c_prod
|
||||
#define c_quot _Py_c_quot
|
||||
#define c_pow _Py_c_pow
|
||||
#define c_abs _Py_c_abs
|
||||
|
||||
PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) c_neg(Py_complex);
|
||||
PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(double) c_abs(Py_complex);
|
||||
|
||||
|
||||
/* Complex object interface */
|
||||
|
||||
/*
|
||||
PyComplexObject represents a complex number with double-precision
|
||||
real and imaginary parts.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Py_complex cval;
|
||||
} PyComplexObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyComplex_Type;
|
||||
|
||||
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
|
||||
#define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
|
||||
PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
|
||||
|
||||
PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op);
|
||||
PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op);
|
||||
PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
|
||||
|
||||
/* Format the object based on the format_spec, as defined in PEP 3101
|
||||
(Advanced String Formatting). */
|
||||
PyAPI_FUNC(PyObject *) _PyComplex_FormatAdvanced(PyObject *obj,
|
||||
char *format_spec,
|
||||
Py_ssize_t format_spec_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_COMPLEXOBJECT_H */
|
239
c/meterpreter/source/extensions/python/Include/datetime.h
Normal file
239
c/meterpreter/source/extensions/python/Include/datetime.h
Normal file
@ -0,0 +1,239 @@
|
||||
/* datetime.h
|
||||
*/
|
||||
|
||||
#ifndef DATETIME_H
|
||||
#define DATETIME_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Fields are packed into successive bytes, each viewed as unsigned and
|
||||
* big-endian, unless otherwise noted:
|
||||
*
|
||||
* byte offset
|
||||
* 0 year 2 bytes, 1-9999
|
||||
* 2 month 1 byte, 1-12
|
||||
* 3 day 1 byte, 1-31
|
||||
* 4 hour 1 byte, 0-23
|
||||
* 5 minute 1 byte, 0-59
|
||||
* 6 second 1 byte, 0-59
|
||||
* 7 usecond 3 bytes, 0-999999
|
||||
* 10
|
||||
*/
|
||||
|
||||
/* # of bytes for year, month, and day. */
|
||||
#define _PyDateTime_DATE_DATASIZE 4
|
||||
|
||||
/* # of bytes for hour, minute, second, and usecond. */
|
||||
#define _PyDateTime_TIME_DATASIZE 6
|
||||
|
||||
/* # of bytes for year, month, day, hour, minute, second, and usecond. */
|
||||
#define _PyDateTime_DATETIME_DATASIZE 10
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PyObject_HEAD
|
||||
long hashcode; /* -1 when unknown */
|
||||
int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */
|
||||
int seconds; /* 0 <= seconds < 24*3600 is invariant */
|
||||
int microseconds; /* 0 <= microseconds < 1000000 is invariant */
|
||||
} PyDateTime_Delta;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PyObject_HEAD /* a pure abstract base class */
|
||||
} PyDateTime_TZInfo;
|
||||
|
||||
|
||||
/* The datetime and time types have hashcodes, and an optional tzinfo member,
|
||||
* present if and only if hastzinfo is true.
|
||||
*/
|
||||
#define _PyTZINFO_HEAD \
|
||||
PyObject_HEAD \
|
||||
long hashcode; \
|
||||
char hastzinfo; /* boolean flag */
|
||||
|
||||
/* No _PyDateTime_BaseTZInfo is allocated; it's just to have something
|
||||
* convenient to cast to, when getting at the hastzinfo member of objects
|
||||
* starting with _PyTZINFO_HEAD.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
_PyTZINFO_HEAD
|
||||
} _PyDateTime_BaseTZInfo;
|
||||
|
||||
/* All time objects are of PyDateTime_TimeType, but that can be allocated
|
||||
* in two ways, with or without a tzinfo member. Without is the same as
|
||||
* tzinfo == None, but consumes less memory. _PyDateTime_BaseTime is an
|
||||
* internal struct used to allocate the right amount of space for the
|
||||
* "without" case.
|
||||
*/
|
||||
#define _PyDateTime_TIMEHEAD \
|
||||
_PyTZINFO_HEAD \
|
||||
unsigned char data[_PyDateTime_TIME_DATASIZE];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
_PyDateTime_TIMEHEAD
|
||||
} _PyDateTime_BaseTime; /* hastzinfo false */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
_PyDateTime_TIMEHEAD
|
||||
PyObject *tzinfo;
|
||||
} PyDateTime_Time; /* hastzinfo true */
|
||||
|
||||
|
||||
/* All datetime objects are of PyDateTime_DateTimeType, but that can be
|
||||
* allocated in two ways too, just like for time objects above. In addition,
|
||||
* the plain date type is a base class for datetime, so it must also have
|
||||
* a hastzinfo member (although it's unused there).
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
_PyTZINFO_HEAD
|
||||
unsigned char data[_PyDateTime_DATE_DATASIZE];
|
||||
} PyDateTime_Date;
|
||||
|
||||
#define _PyDateTime_DATETIMEHEAD \
|
||||
_PyTZINFO_HEAD \
|
||||
unsigned char data[_PyDateTime_DATETIME_DATASIZE];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
_PyDateTime_DATETIMEHEAD
|
||||
} _PyDateTime_BaseDateTime; /* hastzinfo false */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
_PyDateTime_DATETIMEHEAD
|
||||
PyObject *tzinfo;
|
||||
} PyDateTime_DateTime; /* hastzinfo true */
|
||||
|
||||
|
||||
/* Apply for date and datetime instances. */
|
||||
#define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)o)->data[0] << 8) | \
|
||||
((PyDateTime_Date*)o)->data[1])
|
||||
#define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)o)->data[2])
|
||||
#define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)o)->data[3])
|
||||
|
||||
#define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)o)->data[4])
|
||||
#define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)o)->data[5])
|
||||
#define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)o)->data[6])
|
||||
#define PyDateTime_DATE_GET_MICROSECOND(o) \
|
||||
((((PyDateTime_DateTime*)o)->data[7] << 16) | \
|
||||
(((PyDateTime_DateTime*)o)->data[8] << 8) | \
|
||||
((PyDateTime_DateTime*)o)->data[9])
|
||||
|
||||
/* Apply for time instances. */
|
||||
#define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)o)->data[0])
|
||||
#define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)o)->data[1])
|
||||
#define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)o)->data[2])
|
||||
#define PyDateTime_TIME_GET_MICROSECOND(o) \
|
||||
((((PyDateTime_Time*)o)->data[3] << 16) | \
|
||||
(((PyDateTime_Time*)o)->data[4] << 8) | \
|
||||
((PyDateTime_Time*)o)->data[5])
|
||||
|
||||
|
||||
/* Define structure for C API. */
|
||||
typedef struct {
|
||||
/* type objects */
|
||||
PyTypeObject *DateType;
|
||||
PyTypeObject *DateTimeType;
|
||||
PyTypeObject *TimeType;
|
||||
PyTypeObject *DeltaType;
|
||||
PyTypeObject *TZInfoType;
|
||||
|
||||
/* constructors */
|
||||
PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*);
|
||||
PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int,
|
||||
PyObject*, PyTypeObject*);
|
||||
PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*);
|
||||
PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*);
|
||||
|
||||
/* constructors for the DB API */
|
||||
PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*);
|
||||
PyObject *(*Date_FromTimestamp)(PyObject*, PyObject*);
|
||||
|
||||
} PyDateTime_CAPI;
|
||||
|
||||
#define PyDateTime_CAPSULE_NAME "datetime.datetime_CAPI"
|
||||
|
||||
|
||||
/* "magic" constant used to partially protect against developer mistakes. */
|
||||
#define DATETIME_API_MAGIC 0x414548d5
|
||||
|
||||
#ifdef Py_BUILD_CORE
|
||||
|
||||
/* Macros for type checking when building the Python core. */
|
||||
#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType)
|
||||
#define PyDate_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateType)
|
||||
|
||||
#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType)
|
||||
#define PyDateTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateTimeType)
|
||||
|
||||
#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType)
|
||||
#define PyTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TimeType)
|
||||
|
||||
#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType)
|
||||
#define PyDelta_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DeltaType)
|
||||
|
||||
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType)
|
||||
#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TZInfoType)
|
||||
|
||||
#else
|
||||
|
||||
/* Define global variable for the C API and a macro for setting it. */
|
||||
static PyDateTime_CAPI *PyDateTimeAPI = NULL;
|
||||
|
||||
#define PyDateTime_IMPORT \
|
||||
PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0)
|
||||
|
||||
/* Macros for type checking when not building the Python core. */
|
||||
#define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType)
|
||||
#define PyDate_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateType)
|
||||
|
||||
#define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType)
|
||||
#define PyDateTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateTimeType)
|
||||
|
||||
#define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType)
|
||||
#define PyTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TimeType)
|
||||
|
||||
#define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType)
|
||||
#define PyDelta_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DeltaType)
|
||||
|
||||
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType)
|
||||
#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TZInfoType)
|
||||
|
||||
/* Macros for accessing constructors in a simplified fashion. */
|
||||
#define PyDate_FromDate(year, month, day) \
|
||||
PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType)
|
||||
|
||||
#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \
|
||||
PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, \
|
||||
min, sec, usec, Py_None, PyDateTimeAPI->DateTimeType)
|
||||
|
||||
#define PyTime_FromTime(hour, minute, second, usecond) \
|
||||
PyDateTimeAPI->Time_FromTime(hour, minute, second, usecond, \
|
||||
Py_None, PyDateTimeAPI->TimeType)
|
||||
|
||||
#define PyDelta_FromDSU(days, seconds, useconds) \
|
||||
PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \
|
||||
PyDateTimeAPI->DeltaType)
|
||||
|
||||
/* Macros supporting the DB API. */
|
||||
#define PyDateTime_FromTimestamp(args) \
|
||||
PyDateTimeAPI->DateTime_FromTimestamp( \
|
||||
(PyObject*) (PyDateTimeAPI->DateTimeType), args, NULL)
|
||||
|
||||
#define PyDate_FromTimestamp(args) \
|
||||
PyDateTimeAPI->Date_FromTimestamp( \
|
||||
(PyObject*) (PyDateTimeAPI->DateType), args)
|
||||
|
||||
#endif /* Py_BUILD_CORE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
94
c/meterpreter/source/extensions/python/Include/descrobject.h
Normal file
94
c/meterpreter/source/extensions/python/Include/descrobject.h
Normal file
@ -0,0 +1,94 @@
|
||||
/* Descriptors */
|
||||
#ifndef Py_DESCROBJECT_H
|
||||
#define Py_DESCROBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef PyObject *(*getter)(PyObject *, void *);
|
||||
typedef int (*setter)(PyObject *, PyObject *, void *);
|
||||
|
||||
typedef struct PyGetSetDef {
|
||||
char *name;
|
||||
getter get;
|
||||
setter set;
|
||||
char *doc;
|
||||
void *closure;
|
||||
} PyGetSetDef;
|
||||
|
||||
typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
|
||||
void *wrapped);
|
||||
|
||||
typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
|
||||
void *wrapped, PyObject *kwds);
|
||||
|
||||
struct wrapperbase {
|
||||
char *name;
|
||||
int offset;
|
||||
void *function;
|
||||
wrapperfunc wrapper;
|
||||
char *doc;
|
||||
int flags;
|
||||
PyObject *name_strobj;
|
||||
};
|
||||
|
||||
/* Flags for above struct */
|
||||
#define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */
|
||||
|
||||
/* Various kinds of descriptor objects */
|
||||
|
||||
#define PyDescr_COMMON \
|
||||
PyObject_HEAD \
|
||||
PyTypeObject *d_type; \
|
||||
PyObject *d_name
|
||||
|
||||
typedef struct {
|
||||
PyDescr_COMMON;
|
||||
} PyDescrObject;
|
||||
|
||||
typedef struct {
|
||||
PyDescr_COMMON;
|
||||
PyMethodDef *d_method;
|
||||
} PyMethodDescrObject;
|
||||
|
||||
typedef struct {
|
||||
PyDescr_COMMON;
|
||||
struct PyMemberDef *d_member;
|
||||
} PyMemberDescrObject;
|
||||
|
||||
typedef struct {
|
||||
PyDescr_COMMON;
|
||||
PyGetSetDef *d_getset;
|
||||
} PyGetSetDescrObject;
|
||||
|
||||
typedef struct {
|
||||
PyDescr_COMMON;
|
||||
struct wrapperbase *d_base;
|
||||
void *d_wrapped; /* This can be any function pointer */
|
||||
} PyWrapperDescrObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *,
|
||||
struct PyMemberDef *);
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
|
||||
struct PyGetSetDef *);
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
|
||||
struct wrapperbase *, void *);
|
||||
#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
|
||||
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyProperty_Type;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_DESCROBJECT_H */
|
||||
|
156
c/meterpreter/source/extensions/python/Include/dictobject.h
Normal file
156
c/meterpreter/source/extensions/python/Include/dictobject.h
Normal file
@ -0,0 +1,156 @@
|
||||
#ifndef Py_DICTOBJECT_H
|
||||
#define Py_DICTOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Dictionary object type -- mapping from hashable object to object */
|
||||
|
||||
/* The distribution includes a separate file, Objects/dictnotes.txt,
|
||||
describing explorations into dictionary design and optimization.
|
||||
It covers typical dictionary use patterns, the parameters for
|
||||
tuning dictionaries, and several ideas for possible optimizations.
|
||||
*/
|
||||
|
||||
/*
|
||||
There are three kinds of slots in the table:
|
||||
|
||||
1. Unused. me_key == me_value == NULL
|
||||
Does not hold an active (key, value) pair now and never did. Unused can
|
||||
transition to Active upon key insertion. This is the only case in which
|
||||
me_key is NULL, and is each slot's initial state.
|
||||
|
||||
2. Active. me_key != NULL and me_key != dummy and me_value != NULL
|
||||
Holds an active (key, value) pair. Active can transition to Dummy upon
|
||||
key deletion. This is the only case in which me_value != NULL.
|
||||
|
||||
3. Dummy. me_key == dummy and me_value == NULL
|
||||
Previously held an active (key, value) pair, but that was deleted and an
|
||||
active pair has not yet overwritten the slot. Dummy can transition to
|
||||
Active upon key insertion. Dummy slots cannot be made Unused again
|
||||
(cannot have me_key set to NULL), else the probe sequence in case of
|
||||
collision would have no way to know they were once active.
|
||||
|
||||
Note: .popitem() abuses the me_hash field of an Unused or Dummy slot to
|
||||
hold a search finger. The me_hash field of Unused or Dummy slots has no
|
||||
meaning otherwise.
|
||||
*/
|
||||
|
||||
/* PyDict_MINSIZE is the minimum size of a dictionary. This many slots are
|
||||
* allocated directly in the dict object (in the ma_smalltable member).
|
||||
* It must be a power of 2, and at least 4. 8 allows dicts with no more
|
||||
* than 5 active entries to live in ma_smalltable (and so avoid an
|
||||
* additional malloc); instrumentation suggested this suffices for the
|
||||
* majority of dicts (consisting mostly of usually-small instance dicts and
|
||||
* usually-small dicts created to pass keyword arguments).
|
||||
*/
|
||||
#define PyDict_MINSIZE 8
|
||||
|
||||
typedef struct {
|
||||
/* Cached hash code of me_key. Note that hash codes are C longs.
|
||||
* We have to use Py_ssize_t instead because dict_popitem() abuses
|
||||
* me_hash to hold a search finger.
|
||||
*/
|
||||
Py_ssize_t me_hash;
|
||||
PyObject *me_key;
|
||||
PyObject *me_value;
|
||||
} PyDictEntry;
|
||||
|
||||
/*
|
||||
To ensure the lookup algorithm terminates, there must be at least one Unused
|
||||
slot (NULL key) in the table.
|
||||
The value ma_fill is the number of non-NULL keys (sum of Active and Dummy);
|
||||
ma_used is the number of non-NULL, non-dummy keys (== the number of non-NULL
|
||||
values == the number of Active items).
|
||||
To avoid slowing down lookups on a near-full table, we resize the table when
|
||||
it's two-thirds full.
|
||||
*/
|
||||
typedef struct _dictobject PyDictObject;
|
||||
struct _dictobject {
|
||||
PyObject_HEAD
|
||||
Py_ssize_t ma_fill; /* # Active + # Dummy */
|
||||
Py_ssize_t ma_used; /* # Active */
|
||||
|
||||
/* The table contains ma_mask + 1 slots, and that's a power of 2.
|
||||
* We store the mask instead of the size because the mask is more
|
||||
* frequently needed.
|
||||
*/
|
||||
Py_ssize_t ma_mask;
|
||||
|
||||
/* ma_table points to ma_smalltable for small tables, else to
|
||||
* additional malloc'ed memory. ma_table is never NULL! This rule
|
||||
* saves repeated runtime null-tests in the workhorse getitem and
|
||||
* setitem calls.
|
||||
*/
|
||||
PyDictEntry *ma_table;
|
||||
PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, long hash);
|
||||
PyDictEntry ma_smalltable[PyDict_MINSIZE];
|
||||
};
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyDict_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictIterKey_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictIterValue_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictIterItem_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictKeys_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictItems_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictValues_Type;
|
||||
|
||||
#define PyDict_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS)
|
||||
#define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
|
||||
#define PyDictKeys_Check(op) (Py_TYPE(op) == &PyDictKeys_Type)
|
||||
#define PyDictItems_Check(op) (Py_TYPE(op) == &PyDictItems_Type)
|
||||
#define PyDictValues_Check(op) (Py_TYPE(op) == &PyDictValues_Type)
|
||||
/* This excludes Values, since they are not sets. */
|
||||
# define PyDictViewSet_Check(op) \
|
||||
(PyDictKeys_Check(op) || PyDictItems_Check(op))
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDict_New(void);
|
||||
PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);
|
||||
PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item);
|
||||
PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key);
|
||||
PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);
|
||||
PyAPI_FUNC(int) PyDict_Next(
|
||||
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);
|
||||
PyAPI_FUNC(int) _PyDict_Next(
|
||||
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, long *hash);
|
||||
PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);
|
||||
PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);
|
||||
PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);
|
||||
PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);
|
||||
PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);
|
||||
PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);
|
||||
PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, long hash);
|
||||
PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
|
||||
PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
|
||||
|
||||
/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */
|
||||
PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other);
|
||||
|
||||
/* PyDict_Merge updates/merges from a mapping object (an object that
|
||||
supports PyMapping_Keys() and PyObject_GetItem()). If override is true,
|
||||
the last occurrence of a key wins, else the first. The Python
|
||||
dict.update(other) is equivalent to PyDict_Merge(dict, other, 1).
|
||||
*/
|
||||
PyAPI_FUNC(int) PyDict_Merge(PyObject *mp,
|
||||
PyObject *other,
|
||||
int override);
|
||||
|
||||
/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing
|
||||
iterable objects of length 2. If override is true, the last occurrence
|
||||
of a key wins, else the first. The Python dict constructor dict(seq2)
|
||||
is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1).
|
||||
*/
|
||||
PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d,
|
||||
PyObject *seq2,
|
||||
int override);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key);
|
||||
PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);
|
||||
PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_DICTOBJECT_H */
|
15
c/meterpreter/source/extensions/python/Include/dtoa.h
Normal file
15
c/meterpreter/source/extensions/python/Include/dtoa.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef PY_NO_SHORT_FLOAT_REPR
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr);
|
||||
PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits,
|
||||
int *decpt, int *sign, char **rve);
|
||||
PyAPI_FUNC(void) _Py_dg_freedtoa(char *s);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
17
c/meterpreter/source/extensions/python/Include/enumobject.h
Normal file
17
c/meterpreter/source/extensions/python/Include/enumobject.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef Py_ENUMOBJECT_H
|
||||
#define Py_ENUMOBJECT_H
|
||||
|
||||
/* Enumerate Object */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyEnum_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyReversed_Type;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !Py_ENUMOBJECT_H */
|
36
c/meterpreter/source/extensions/python/Include/errcode.h
Normal file
36
c/meterpreter/source/extensions/python/Include/errcode.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef Py_ERRCODE_H
|
||||
#define Py_ERRCODE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Error codes passed around between file input, tokenizer, parser and
|
||||
interpreter. This is necessary so we can turn them into Python
|
||||
exceptions at a higher level. Note that some errors have a
|
||||
slightly different meaning when passed from the tokenizer to the
|
||||
parser than when passed from the parser to the interpreter; e.g.
|
||||
the parser only returns E_EOF when it hits EOF immediately, and it
|
||||
never returns E_OK. */
|
||||
|
||||
#define E_OK 10 /* No error */
|
||||
#define E_EOF 11 /* End Of File */
|
||||
#define E_INTR 12 /* Interrupted */
|
||||
#define E_TOKEN 13 /* Bad token */
|
||||
#define E_SYNTAX 14 /* Syntax error */
|
||||
#define E_NOMEM 15 /* Ran out of memory */
|
||||
#define E_DONE 16 /* Parsing complete */
|
||||
#define E_ERROR 17 /* Execution error */
|
||||
#define E_TABSPACE 18 /* Inconsistent mixing of tabs and spaces */
|
||||
#define E_OVERFLOW 19 /* Node had too many children */
|
||||
#define E_TOODEEP 20 /* Too many indentation levels */
|
||||
#define E_DEDENT 21 /* No matching outer block for dedent */
|
||||
#define E_DECODE 22 /* Error in decoding into Unicode */
|
||||
#define E_EOFS 23 /* EOF in triple-quoted string */
|
||||
#define E_EOLS 24 /* EOL in single-quoted string */
|
||||
#define E_LINECONT 25 /* Unexpected characters after a line continuation */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_ERRCODE_H */
|
25
c/meterpreter/source/extensions/python/Include/eval.h
Normal file
25
c/meterpreter/source/extensions/python/Include/eval.h
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
/* Interface to execute compiled code */
|
||||
|
||||
#ifndef Py_EVAL_H
|
||||
#define Py_EVAL_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyCodeObject *, PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyCodeObject *co,
|
||||
PyObject *globals,
|
||||
PyObject *locals,
|
||||
PyObject **args, int argc,
|
||||
PyObject **kwds, int kwdc,
|
||||
PyObject **defs, int defc,
|
||||
PyObject *closure);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_EVAL_H */
|
97
c/meterpreter/source/extensions/python/Include/fileobject.h
Normal file
97
c/meterpreter/source/extensions/python/Include/fileobject.h
Normal file
@ -0,0 +1,97 @@
|
||||
|
||||
/* File object interface */
|
||||
|
||||
#ifndef Py_FILEOBJECT_H
|
||||
#define Py_FILEOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
FILE *f_fp;
|
||||
PyObject *f_name;
|
||||
PyObject *f_mode;
|
||||
int (*f_close)(FILE *);
|
||||
int f_softspace; /* Flag used by 'print' command */
|
||||
int f_binary; /* Flag which indicates whether the file is
|
||||
open in binary (1) or text (0) mode */
|
||||
char* f_buf; /* Allocated readahead buffer */
|
||||
char* f_bufend; /* Points after last occupied position */
|
||||
char* f_bufptr; /* Current buffer position */
|
||||
char *f_setbuf; /* Buffer for setbuf(3) and setvbuf(3) */
|
||||
int f_univ_newline; /* Handle any newline convention */
|
||||
int f_newlinetypes; /* Types of newlines seen */
|
||||
int f_skipnextlf; /* Skip next \n */
|
||||
PyObject *f_encoding;
|
||||
PyObject *f_errors;
|
||||
PyObject *weakreflist; /* List of weak references */
|
||||
int unlocked_count; /* Num. currently running sections of code
|
||||
using f_fp with the GIL released. */
|
||||
int readable;
|
||||
int writable;
|
||||
} PyFileObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFile_Type;
|
||||
|
||||
#define PyFile_Check(op) PyObject_TypeCheck(op, &PyFile_Type)
|
||||
#define PyFile_CheckExact(op) (Py_TYPE(op) == &PyFile_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyFile_FromString(char *, char *);
|
||||
PyAPI_FUNC(void) PyFile_SetBufSize(PyObject *, int);
|
||||
PyAPI_FUNC(int) PyFile_SetEncoding(PyObject *, const char *);
|
||||
PyAPI_FUNC(int) PyFile_SetEncodingAndErrors(PyObject *, const char *, char *errors);
|
||||
PyAPI_FUNC(PyObject *) PyFile_FromFile(FILE *, char *, char *,
|
||||
int (*)(FILE *));
|
||||
PyAPI_FUNC(FILE *) PyFile_AsFile(PyObject *);
|
||||
PyAPI_FUNC(void) PyFile_IncUseCount(PyFileObject *);
|
||||
PyAPI_FUNC(void) PyFile_DecUseCount(PyFileObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFile_Name(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
|
||||
PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
|
||||
PyAPI_FUNC(int) PyFile_SoftSpace(PyObject *, int);
|
||||
PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *);
|
||||
|
||||
/* The default encoding used by the platform file system APIs
|
||||
If non-NULL, this is different than the default encoding for strings
|
||||
*/
|
||||
PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
|
||||
|
||||
/* Routines to replace fread() and fgets() which accept any of \r, \n
|
||||
or \r\n as line terminators.
|
||||
*/
|
||||
#define PY_STDIOTEXTMODE "b"
|
||||
char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
|
||||
size_t Py_UniversalNewlineFread(char *, size_t, FILE *, PyObject *);
|
||||
|
||||
/* A routine to do sanity checking on the file mode string. returns
|
||||
non-zero on if an exception occurred
|
||||
*/
|
||||
int _PyFile_SanitizeMode(char *mode);
|
||||
|
||||
#if defined _MSC_VER && _MSC_VER >= 1400
|
||||
/* A routine to check if a file descriptor is valid on Windows. Returns 0
|
||||
* and sets errno to EBADF if it isn't. This is to avoid Assertions
|
||||
* from various functions in the Windows CRT beginning with
|
||||
* Visual Studio 2005
|
||||
*/
|
||||
int _PyVerify_fd(int fd);
|
||||
#elif defined _MSC_VER && _MSC_VER >= 1200
|
||||
/* fdopen doesn't set errno EBADF and crashes for large fd on debug build */
|
||||
#define _PyVerify_fd(fd) (_get_osfhandle(fd) >= 0)
|
||||
#else
|
||||
#define _PyVerify_fd(A) (1) /* dummy */
|
||||
#endif
|
||||
|
||||
/* A routine to check if a file descriptor can be select()-ed. */
|
||||
#ifdef HAVE_SELECT
|
||||
#define _PyIsSelectable_fd(FD) (((FD) >= 0) && ((FD) < FD_SETSIZE))
|
||||
#else
|
||||
#define _PyIsSelectable_fd(FD) (1)
|
||||
#endif /* HAVE_SELECT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_FILEOBJECT_H */
|
140
c/meterpreter/source/extensions/python/Include/floatobject.h
Normal file
140
c/meterpreter/source/extensions/python/Include/floatobject.h
Normal file
@ -0,0 +1,140 @@
|
||||
|
||||
/* Float object interface */
|
||||
|
||||
/*
|
||||
PyFloatObject represents a (double precision) floating point number.
|
||||
*/
|
||||
|
||||
#ifndef Py_FLOATOBJECT_H
|
||||
#define Py_FLOATOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
double ob_fval;
|
||||
} PyFloatObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFloat_Type;
|
||||
|
||||
#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
|
||||
#define PyFloat_CheckExact(op) (Py_TYPE(op) == &PyFloat_Type)
|
||||
|
||||
/* The str() precision PyFloat_STR_PRECISION is chosen so that in most cases,
|
||||
the rounding noise created by various operations is suppressed, while
|
||||
giving plenty of precision for practical use. */
|
||||
|
||||
#define PyFloat_STR_PRECISION 12
|
||||
|
||||
#ifdef Py_NAN
|
||||
#define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN)
|
||||
#endif
|
||||
|
||||
#define Py_RETURN_INF(sign) do \
|
||||
if (copysign(1., sign) == 1.) { \
|
||||
return PyFloat_FromDouble(Py_HUGE_VAL); \
|
||||
} else { \
|
||||
return PyFloat_FromDouble(-Py_HUGE_VAL); \
|
||||
} while(0)
|
||||
|
||||
PyAPI_FUNC(double) PyFloat_GetMax(void);
|
||||
PyAPI_FUNC(double) PyFloat_GetMin(void);
|
||||
PyAPI_FUNC(PyObject *) PyFloat_GetInfo(void);
|
||||
|
||||
/* Return Python float from string PyObject. Second argument ignored on
|
||||
input, and, if non-NULL, NULL is stored into *junk (this tried to serve a
|
||||
purpose once but can't be made to work as intended). */
|
||||
PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*, char** junk);
|
||||
|
||||
/* Return Python float from C double. */
|
||||
PyAPI_FUNC(PyObject *) PyFloat_FromDouble(double);
|
||||
|
||||
/* Extract C double from Python float. The macro version trades safety for
|
||||
speed. */
|
||||
PyAPI_FUNC(double) PyFloat_AsDouble(PyObject *);
|
||||
#define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval)
|
||||
|
||||
/* Write repr(v) into the char buffer argument, followed by null byte. The
|
||||
buffer must be "big enough"; >= 100 is very safe.
|
||||
PyFloat_AsReprString(buf, x) strives to print enough digits so that
|
||||
PyFloat_FromString(buf) then reproduces x exactly. */
|
||||
PyAPI_FUNC(void) PyFloat_AsReprString(char*, PyFloatObject *v);
|
||||
|
||||
/* Write str(v) into the char buffer argument, followed by null byte. The
|
||||
buffer must be "big enough"; >= 100 is very safe. Note that it's
|
||||
unusual to be able to get back the float you started with from
|
||||
PyFloat_AsString's result -- use PyFloat_AsReprString() if you want to
|
||||
preserve precision across conversions. */
|
||||
PyAPI_FUNC(void) PyFloat_AsString(char*, PyFloatObject *v);
|
||||
|
||||
/* _PyFloat_{Pack,Unpack}{4,8}
|
||||
*
|
||||
* The struct and pickle (at least) modules need an efficient platform-
|
||||
* independent way to store floating-point values as byte strings.
|
||||
* The Pack routines produce a string from a C double, and the Unpack
|
||||
* routines produce a C double from such a string. The suffix (4 or 8)
|
||||
* specifies the number of bytes in the string.
|
||||
*
|
||||
* On platforms that appear to use (see _PyFloat_Init()) IEEE-754 formats
|
||||
* these functions work by copying bits. On other platforms, the formats the
|
||||
* 4- byte format is identical to the IEEE-754 single precision format, and
|
||||
* the 8-byte format to the IEEE-754 double precision format, although the
|
||||
* packing of INFs and NaNs (if such things exist on the platform) isn't
|
||||
* handled correctly, and attempting to unpack a string containing an IEEE
|
||||
* INF or NaN will raise an exception.
|
||||
*
|
||||
* On non-IEEE platforms with more precision, or larger dynamic range, than
|
||||
* 754 supports, not all values can be packed; on non-IEEE platforms with less
|
||||
* precision, or smaller dynamic range, not all values can be unpacked. What
|
||||
* happens in such cases is partly accidental (alas).
|
||||
*/
|
||||
|
||||
/* The pack routines write 4 or 8 bytes, starting at p. le is a bool
|
||||
* argument, true if you want the string in little-endian format (exponent
|
||||
* last, at p+3 or p+7), false if you want big-endian format (exponent
|
||||
* first, at p).
|
||||
* Return value: 0 if all is OK, -1 if error (and an exception is
|
||||
* set, most likely OverflowError).
|
||||
* There are two problems on non-IEEE platforms:
|
||||
* 1): What this does is undefined if x is a NaN or infinity.
|
||||
* 2): -0.0 and +0.0 produce the same string.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyFloat_Pack4(double x, unsigned char *p, int le);
|
||||
PyAPI_FUNC(int) _PyFloat_Pack8(double x, unsigned char *p, int le);
|
||||
|
||||
/* Used to get the important decimal digits of a double */
|
||||
PyAPI_FUNC(int) _PyFloat_Digits(char *buf, double v, int *signum);
|
||||
PyAPI_FUNC(void) _PyFloat_DigitsInit(void);
|
||||
|
||||
/* The unpack routines read 4 or 8 bytes, starting at p. le is a bool
|
||||
* argument, true if the string is in little-endian format (exponent
|
||||
* last, at p+3 or p+7), false if big-endian (exponent first, at p).
|
||||
* Return value: The unpacked double. On error, this is -1.0 and
|
||||
* PyErr_Occurred() is true (and an exception is set, most likely
|
||||
* OverflowError). Note that on a non-IEEE platform this will refuse
|
||||
* to unpack a string that represents a NaN or infinity.
|
||||
*/
|
||||
PyAPI_FUNC(double) _PyFloat_Unpack4(const unsigned char *p, int le);
|
||||
PyAPI_FUNC(double) _PyFloat_Unpack8(const unsigned char *p, int le);
|
||||
|
||||
/* free list api */
|
||||
PyAPI_FUNC(int) PyFloat_ClearFreeList(void);
|
||||
|
||||
/* Format the object based on the format_spec, as defined in PEP 3101
|
||||
(Advanced String Formatting). */
|
||||
PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj,
|
||||
char *format_spec,
|
||||
Py_ssize_t format_spec_len);
|
||||
|
||||
/* Round a C double x to the closest multiple of 10**-ndigits. Returns a
|
||||
Python float on success, or NULL (with an appropriate exception set) on
|
||||
failure. Used in builtin_round in bltinmodule.c. */
|
||||
PyAPI_FUNC(PyObject *) _Py_double_round(double x, int ndigits);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_FLOATOBJECT_H */
|
89
c/meterpreter/source/extensions/python/Include/frameobject.h
Normal file
89
c/meterpreter/source/extensions/python/Include/frameobject.h
Normal file
@ -0,0 +1,89 @@
|
||||
|
||||
/* Frame object interface */
|
||||
|
||||
#ifndef Py_FRAMEOBJECT_H
|
||||
#define Py_FRAMEOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int b_type; /* what kind of block this is */
|
||||
int b_handler; /* where to jump to find handler */
|
||||
int b_level; /* value stack level to pop to */
|
||||
} PyTryBlock;
|
||||
|
||||
typedef struct _frame {
|
||||
PyObject_VAR_HEAD
|
||||
struct _frame *f_back; /* previous frame, or NULL */
|
||||
PyCodeObject *f_code; /* code segment */
|
||||
PyObject *f_builtins; /* builtin symbol table (PyDictObject) */
|
||||
PyObject *f_globals; /* global symbol table (PyDictObject) */
|
||||
PyObject *f_locals; /* local symbol table (any mapping) */
|
||||
PyObject **f_valuestack; /* points after the last local */
|
||||
/* Next free slot in f_valuestack. Frame creation sets to f_valuestack.
|
||||
Frame evaluation usually NULLs it, but a frame that yields sets it
|
||||
to the current stack top. */
|
||||
PyObject **f_stacktop;
|
||||
PyObject *f_trace; /* Trace function */
|
||||
|
||||
/* If an exception is raised in this frame, the next three are used to
|
||||
* record the exception info (if any) originally in the thread state. See
|
||||
* comments before set_exc_info() -- it's not obvious.
|
||||
* Invariant: if _type is NULL, then so are _value and _traceback.
|
||||
* Desired invariant: all three are NULL, or all three are non-NULL. That
|
||||
* one isn't currently true, but "should be".
|
||||
*/
|
||||
PyObject *f_exc_type, *f_exc_value, *f_exc_traceback;
|
||||
|
||||
PyThreadState *f_tstate;
|
||||
int f_lasti; /* Last instruction if called */
|
||||
/* Call PyFrame_GetLineNumber() instead of reading this field
|
||||
directly. As of 2.3 f_lineno is only valid when tracing is
|
||||
active (i.e. when f_trace is set). At other times we use
|
||||
PyCode_Addr2Line to calculate the line from the current
|
||||
bytecode index. */
|
||||
int f_lineno; /* Current line number */
|
||||
int f_iblock; /* index in f_blockstack */
|
||||
PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */
|
||||
PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */
|
||||
} PyFrameObject;
|
||||
|
||||
|
||||
/* Standard object interface */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFrame_Type;
|
||||
|
||||
#define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type)
|
||||
#define PyFrame_IsRestricted(f) \
|
||||
((f)->f_builtins != (f)->f_tstate->interp->builtins)
|
||||
|
||||
PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
|
||||
PyObject *, PyObject *);
|
||||
|
||||
|
||||
/* The rest of the interface is specific for frame objects */
|
||||
|
||||
/* Block management functions */
|
||||
|
||||
PyAPI_FUNC(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int);
|
||||
PyAPI_FUNC(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *);
|
||||
|
||||
/* Extend the value stack */
|
||||
|
||||
PyAPI_FUNC(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int);
|
||||
|
||||
/* Conversions between "fast locals" and locals in dictionary */
|
||||
|
||||
PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int);
|
||||
PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *);
|
||||
|
||||
PyAPI_FUNC(int) PyFrame_ClearFreeList(void);
|
||||
|
||||
/* Return the line of code the frame is currently executing. */
|
||||
PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_FRAMEOBJECT_H */
|
76
c/meterpreter/source/extensions/python/Include/funcobject.h
Normal file
76
c/meterpreter/source/extensions/python/Include/funcobject.h
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
/* Function object interface */
|
||||
|
||||
#ifndef Py_FUNCOBJECT_H
|
||||
#define Py_FUNCOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Function objects and code objects should not be confused with each other:
|
||||
*
|
||||
* Function objects are created by the execution of the 'def' statement.
|
||||
* They reference a code object in their func_code attribute, which is a
|
||||
* purely syntactic object, i.e. nothing more than a compiled version of some
|
||||
* source code lines. There is one code object per source code "fragment",
|
||||
* but each code object can be referenced by zero or many function objects
|
||||
* depending only on how many times the 'def' statement in the source was
|
||||
* executed so far.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *func_code; /* A code object */
|
||||
PyObject *func_globals; /* A dictionary (other mappings won't do) */
|
||||
PyObject *func_defaults; /* NULL or a tuple */
|
||||
PyObject *func_closure; /* NULL or a tuple of cell objects */
|
||||
PyObject *func_doc; /* The __doc__ attribute, can be anything */
|
||||
PyObject *func_name; /* The __name__ attribute, a string object */
|
||||
PyObject *func_dict; /* The __dict__ attribute, a dict or NULL */
|
||||
PyObject *func_weakreflist; /* List of weak references */
|
||||
PyObject *func_module; /* The __module__ attribute, can be anything */
|
||||
|
||||
/* Invariant:
|
||||
* func_closure contains the bindings for func_code->co_freevars, so
|
||||
* PyTuple_Size(func_closure) == PyCode_GetNumFree(func_code)
|
||||
* (func_closure may be NULL if PyCode_GetNumFree(func_code) == 0).
|
||||
*/
|
||||
} PyFunctionObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFunction_Type;
|
||||
|
||||
#define PyFunction_Check(op) (Py_TYPE(op) == &PyFunction_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *);
|
||||
PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *);
|
||||
PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *);
|
||||
|
||||
/* Macros for direct access to these values. Type checks are *not*
|
||||
done, so use with care. */
|
||||
#define PyFunction_GET_CODE(func) \
|
||||
(((PyFunctionObject *)func) -> func_code)
|
||||
#define PyFunction_GET_GLOBALS(func) \
|
||||
(((PyFunctionObject *)func) -> func_globals)
|
||||
#define PyFunction_GET_MODULE(func) \
|
||||
(((PyFunctionObject *)func) -> func_module)
|
||||
#define PyFunction_GET_DEFAULTS(func) \
|
||||
(((PyFunctionObject *)func) -> func_defaults)
|
||||
#define PyFunction_GET_CLOSURE(func) \
|
||||
(((PyFunctionObject *)func) -> func_closure)
|
||||
|
||||
/* The classmethod and staticmethod types lives here, too */
|
||||
PyAPI_DATA(PyTypeObject) PyClassMethod_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyStaticMethod_Type;
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_FUNCOBJECT_H */
|
40
c/meterpreter/source/extensions/python/Include/genobject.h
Normal file
40
c/meterpreter/source/extensions/python/Include/genobject.h
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
/* Generator object interface */
|
||||
|
||||
#ifndef Py_GENOBJECT_H
|
||||
#define Py_GENOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _frame; /* Avoid including frameobject.h */
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
/* The gi_ prefix is intended to remind of generator-iterator. */
|
||||
|
||||
/* Note: gi_frame can be NULL if the generator is "finished" */
|
||||
struct _frame *gi_frame;
|
||||
|
||||
/* True if generator is being executed. */
|
||||
int gi_running;
|
||||
|
||||
/* The code object backing the generator */
|
||||
PyObject *gi_code;
|
||||
|
||||
/* List of weak reference. */
|
||||
PyObject *gi_weakreflist;
|
||||
} PyGenObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyGen_Type;
|
||||
|
||||
#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
|
||||
#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
|
||||
PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_GENOBJECT_H */
|
87
c/meterpreter/source/extensions/python/Include/graminit.h
Normal file
87
c/meterpreter/source/extensions/python/Include/graminit.h
Normal file
@ -0,0 +1,87 @@
|
||||
/* Generated by Parser/pgen */
|
||||
|
||||
#define single_input 256
|
||||
#define file_input 257
|
||||
#define eval_input 258
|
||||
#define decorator 259
|
||||
#define decorators 260
|
||||
#define decorated 261
|
||||
#define funcdef 262
|
||||
#define parameters 263
|
||||
#define varargslist 264
|
||||
#define fpdef 265
|
||||
#define fplist 266
|
||||
#define stmt 267
|
||||
#define simple_stmt 268
|
||||
#define small_stmt 269
|
||||
#define expr_stmt 270
|
||||
#define augassign 271
|
||||
#define print_stmt 272
|
||||
#define del_stmt 273
|
||||
#define pass_stmt 274
|
||||
#define flow_stmt 275
|
||||
#define break_stmt 276
|
||||
#define continue_stmt 277
|
||||
#define return_stmt 278
|
||||
#define yield_stmt 279
|
||||
#define raise_stmt 280
|
||||
#define import_stmt 281
|
||||
#define import_name 282
|
||||
#define import_from 283
|
||||
#define import_as_name 284
|
||||
#define dotted_as_name 285
|
||||
#define import_as_names 286
|
||||
#define dotted_as_names 287
|
||||
#define dotted_name 288
|
||||
#define global_stmt 289
|
||||
#define exec_stmt 290
|
||||
#define assert_stmt 291
|
||||
#define compound_stmt 292
|
||||
#define if_stmt 293
|
||||
#define while_stmt 294
|
||||
#define for_stmt 295
|
||||
#define try_stmt 296
|
||||
#define with_stmt 297
|
||||
#define with_item 298
|
||||
#define except_clause 299
|
||||
#define suite 300
|
||||
#define testlist_safe 301
|
||||
#define old_test 302
|
||||
#define old_lambdef 303
|
||||
#define test 304
|
||||
#define or_test 305
|
||||
#define and_test 306
|
||||
#define not_test 307
|
||||
#define comparison 308
|
||||
#define comp_op 309
|
||||
#define expr 310
|
||||
#define xor_expr 311
|
||||
#define and_expr 312
|
||||
#define shift_expr 313
|
||||
#define arith_expr 314
|
||||
#define term 315
|
||||
#define factor 316
|
||||
#define power 317
|
||||
#define atom 318
|
||||
#define listmaker 319
|
||||
#define testlist_comp 320
|
||||
#define lambdef 321
|
||||
#define trailer 322
|
||||
#define subscriptlist 323
|
||||
#define subscript 324
|
||||
#define sliceop 325
|
||||
#define exprlist 326
|
||||
#define testlist 327
|
||||
#define dictorsetmaker 328
|
||||
#define classdef 329
|
||||
#define arglist 330
|
||||
#define argument 331
|
||||
#define list_iter 332
|
||||
#define list_for 333
|
||||
#define list_if 334
|
||||
#define comp_iter 335
|
||||
#define comp_for 336
|
||||
#define comp_if 337
|
||||
#define testlist1 338
|
||||
#define encoding_decl 339
|
||||
#define yield_expr 340
|
93
c/meterpreter/source/extensions/python/Include/grammar.h
Normal file
93
c/meterpreter/source/extensions/python/Include/grammar.h
Normal file
@ -0,0 +1,93 @@
|
||||
|
||||
/* Grammar interface */
|
||||
|
||||
#ifndef Py_GRAMMAR_H
|
||||
#define Py_GRAMMAR_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "bitset.h" /* Sigh... */
|
||||
|
||||
/* A label of an arc */
|
||||
|
||||
typedef struct {
|
||||
int lb_type;
|
||||
char *lb_str;
|
||||
} label;
|
||||
|
||||
#define EMPTY 0 /* Label number 0 is by definition the empty label */
|
||||
|
||||
/* A list of labels */
|
||||
|
||||
typedef struct {
|
||||
int ll_nlabels;
|
||||
label *ll_label;
|
||||
} labellist;
|
||||
|
||||
/* An arc from one state to another */
|
||||
|
||||
typedef struct {
|
||||
short a_lbl; /* Label of this arc */
|
||||
short a_arrow; /* State where this arc goes to */
|
||||
} arc;
|
||||
|
||||
/* A state in a DFA */
|
||||
|
||||
typedef struct {
|
||||
int s_narcs;
|
||||
arc *s_arc; /* Array of arcs */
|
||||
|
||||
/* Optional accelerators */
|
||||
int s_lower; /* Lowest label index */
|
||||
int s_upper; /* Highest label index */
|
||||
int *s_accel; /* Accelerator */
|
||||
int s_accept; /* Nonzero for accepting state */
|
||||
} state;
|
||||
|
||||
/* A DFA */
|
||||
|
||||
typedef struct {
|
||||
int d_type; /* Non-terminal this represents */
|
||||
char *d_name; /* For printing */
|
||||
int d_initial; /* Initial state */
|
||||
int d_nstates;
|
||||
state *d_state; /* Array of states */
|
||||
bitset d_first;
|
||||
} dfa;
|
||||
|
||||
/* A grammar */
|
||||
|
||||
typedef struct {
|
||||
int g_ndfas;
|
||||
dfa *g_dfa; /* Array of DFAs */
|
||||
labellist g_ll;
|
||||
int g_start; /* Start symbol of the grammar */
|
||||
int g_accel; /* Set if accelerators present */
|
||||
} grammar;
|
||||
|
||||
/* FUNCTIONS */
|
||||
|
||||
grammar *newgrammar(int start);
|
||||
dfa *adddfa(grammar *g, int type, char *name);
|
||||
int addstate(dfa *d);
|
||||
void addarc(dfa *d, int from, int to, int lbl);
|
||||
dfa *PyGrammar_FindDFA(grammar *g, int type);
|
||||
|
||||
int addlabel(labellist *ll, int type, char *str);
|
||||
int findlabel(labellist *ll, int type, char *str);
|
||||
char *PyGrammar_LabelRepr(label *lb);
|
||||
void translatelabels(grammar *g);
|
||||
|
||||
void addfirstsets(grammar *g);
|
||||
|
||||
void PyGrammar_AddAccelerators(grammar *g);
|
||||
void PyGrammar_RemoveAccelerators(grammar *);
|
||||
|
||||
void printgrammar(grammar *g, FILE *fp);
|
||||
void printnonterminals(grammar *g, FILE *fp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_GRAMMAR_H */
|
71
c/meterpreter/source/extensions/python/Include/import.h
Normal file
71
c/meterpreter/source/extensions/python/Include/import.h
Normal file
@ -0,0 +1,71 @@
|
||||
|
||||
/* Module definition and import interface */
|
||||
|
||||
#ifndef Py_IMPORT_H
|
||||
#define Py_IMPORT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(long) PyImport_GetMagicNumber(void);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(char *name, PyObject *co);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
|
||||
char *name, PyObject *co, char *pathname);
|
||||
PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
|
||||
PyAPI_FUNC(PyObject *) PyImport_AddModule(const char *name);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ImportModule(const char *name);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(const char *);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(char *name,
|
||||
PyObject *globals, PyObject *locals, PyObject *fromlist, int level);
|
||||
|
||||
#define PyImport_ImportModuleEx(n, g, l, f) \
|
||||
PyImport_ImportModuleLevel(n, g, l, f, -1)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path);
|
||||
PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m);
|
||||
PyAPI_FUNC(void) PyImport_Cleanup(void);
|
||||
PyAPI_FUNC(int) PyImport_ImportFrozenModule(char *);
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
PyAPI_FUNC(void) _PyImport_AcquireLock(void);
|
||||
PyAPI_FUNC(int) _PyImport_ReleaseLock(void);
|
||||
#else
|
||||
#define _PyImport_AcquireLock()
|
||||
#define _PyImport_ReleaseLock() 1
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(struct filedescr *) _PyImport_FindModule(
|
||||
const char *, PyObject *, char *, size_t, FILE **, PyObject **);
|
||||
PyAPI_FUNC(int) _PyImport_IsScript(struct filedescr *);
|
||||
PyAPI_FUNC(void) _PyImport_ReInitLock(void);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyImport_FindExtension(char *, char *);
|
||||
PyAPI_FUNC(PyObject *) _PyImport_FixupExtension(char *, char *);
|
||||
|
||||
struct _inittab {
|
||||
char *name;
|
||||
void (*initfunc)(void);
|
||||
};
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyNullImporter_Type;
|
||||
PyAPI_DATA(struct _inittab *) PyImport_Inittab;
|
||||
|
||||
PyAPI_FUNC(int) PyImport_AppendInittab(const char *name, void (*initfunc)(void));
|
||||
PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
|
||||
|
||||
struct _frozen {
|
||||
char *name;
|
||||
unsigned char *code;
|
||||
int size;
|
||||
};
|
||||
|
||||
/* Embedding apps may change this pointer to point to their favorite
|
||||
collection of frozen modules: */
|
||||
|
||||
PyAPI_DATA(struct _frozen *) PyImport_FrozenModules;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_IMPORT_H */
|
81
c/meterpreter/source/extensions/python/Include/intobject.h
Normal file
81
c/meterpreter/source/extensions/python/Include/intobject.h
Normal file
@ -0,0 +1,81 @@
|
||||
|
||||
/* Integer object interface */
|
||||
|
||||
/*
|
||||
PyIntObject represents a (long) integer. This is an immutable object;
|
||||
an integer cannot change its value after creation.
|
||||
|
||||
There are functions to create new integer objects, to test an object
|
||||
for integer-ness, and to get the integer value. The latter functions
|
||||
returns -1 and sets errno to EBADF if the object is not an PyIntObject.
|
||||
None of the functions should be applied to nil objects.
|
||||
|
||||
The type PyIntObject is (unfortunately) exposed here so we can declare
|
||||
_Py_TrueStruct and _Py_ZeroStruct in boolobject.h; don't use this.
|
||||
*/
|
||||
|
||||
#ifndef Py_INTOBJECT_H
|
||||
#define Py_INTOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
long ob_ival;
|
||||
} PyIntObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyInt_Type;
|
||||
|
||||
#define PyInt_Check(op) \
|
||||
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_INT_SUBCLASS)
|
||||
#define PyInt_CheckExact(op) ((op)->ob_type == &PyInt_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int);
|
||||
#ifdef Py_USING_UNICODE
|
||||
PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyInt_FromLong(long);
|
||||
PyAPI_FUNC(PyObject *) PyInt_FromSize_t(size_t);
|
||||
PyAPI_FUNC(PyObject *) PyInt_FromSsize_t(Py_ssize_t);
|
||||
PyAPI_FUNC(long) PyInt_AsLong(PyObject *);
|
||||
PyAPI_FUNC(Py_ssize_t) PyInt_AsSsize_t(PyObject *);
|
||||
PyAPI_FUNC(int) _PyInt_AsInt(PyObject *);
|
||||
PyAPI_FUNC(unsigned long) PyInt_AsUnsignedLongMask(PyObject *);
|
||||
#ifdef HAVE_LONG_LONG
|
||||
PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(long) PyInt_GetMax(void);
|
||||
|
||||
/* Macro, trading safety for speed */
|
||||
#define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival)
|
||||
|
||||
/* These aren't really part of the Int object, but they're handy; the protos
|
||||
* are necessary for systems that need the magic of PyAPI_FUNC and that want
|
||||
* to have stropmodule as a dynamically loaded module instead of building it
|
||||
* into the main Python shared library/DLL. Guido thinks I'm weird for
|
||||
* building it this way. :-) [cjh]
|
||||
*/
|
||||
PyAPI_FUNC(unsigned long) PyOS_strtoul(char *, char **, int);
|
||||
PyAPI_FUNC(long) PyOS_strtol(char *, char **, int);
|
||||
|
||||
/* free list api */
|
||||
PyAPI_FUNC(int) PyInt_ClearFreeList(void);
|
||||
|
||||
/* Convert an integer to the given base. Returns a string.
|
||||
If base is 2, 8 or 16, add the proper prefix '0b', '0o' or '0x'.
|
||||
If newstyle is zero, then use the pre-2.6 behavior of octal having
|
||||
a leading "0" */
|
||||
PyAPI_FUNC(PyObject*) _PyInt_Format(PyIntObject* v, int base, int newstyle);
|
||||
|
||||
/* Format the object based on the format_spec, as defined in PEP 3101
|
||||
(Advanced String Formatting). */
|
||||
PyAPI_FUNC(PyObject *) _PyInt_FormatAdvanced(PyObject *obj,
|
||||
char *format_spec,
|
||||
Py_ssize_t format_spec_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_INTOBJECT_H */
|
15
c/meterpreter/source/extensions/python/Include/intrcheck.h
Normal file
15
c/meterpreter/source/extensions/python/Include/intrcheck.h
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
#ifndef Py_INTRCHECK_H
|
||||
#define Py_INTRCHECK_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) PyOS_InterruptOccurred(void);
|
||||
PyAPI_FUNC(void) PyOS_InitInterrupts(void);
|
||||
PyAPI_FUNC(void) PyOS_AfterFork(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_INTRCHECK_H */
|
23
c/meterpreter/source/extensions/python/Include/iterobject.h
Normal file
23
c/meterpreter/source/extensions/python/Include/iterobject.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef Py_ITEROBJECT_H
|
||||
#define Py_ITEROBJECT_H
|
||||
/* Iterators (the basic kind, over a sequence) */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PySeqIter_Type;
|
||||
|
||||
#define PySeqIter_Check(op) (Py_TYPE(op) == &PySeqIter_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *);
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCallIter_Type;
|
||||
|
||||
#define PyCallIter_Check(op) (Py_TYPE(op) == &PyCallIter_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_ITEROBJECT_H */
|
||||
|
68
c/meterpreter/source/extensions/python/Include/listobject.h
Normal file
68
c/meterpreter/source/extensions/python/Include/listobject.h
Normal file
@ -0,0 +1,68 @@
|
||||
|
||||
/* List object interface */
|
||||
|
||||
/*
|
||||
Another generally useful object type is an list of object pointers.
|
||||
This is a mutable type: the list items can be changed, and items can be
|
||||
added or removed. Out-of-range indices or non-list objects are ignored.
|
||||
|
||||
*** WARNING *** PyList_SetItem does not increment the new item's reference
|
||||
count, but does decrement the reference count of the item it replaces,
|
||||
if not nil. It does *decrement* the reference count if it is *not*
|
||||
inserted in the list. Similarly, PyList_GetItem does not increment the
|
||||
returned item's reference count.
|
||||
*/
|
||||
|
||||
#ifndef Py_LISTOBJECT_H
|
||||
#define Py_LISTOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_VAR_HEAD
|
||||
/* Vector of pointers to list elements. list[0] is ob_item[0], etc. */
|
||||
PyObject **ob_item;
|
||||
|
||||
/* ob_item contains space for 'allocated' elements. The number
|
||||
* currently in use is ob_size.
|
||||
* Invariants:
|
||||
* 0 <= ob_size <= allocated
|
||||
* len(list) == ob_size
|
||||
* ob_item == NULL implies ob_size == allocated == 0
|
||||
* list.sort() temporarily sets allocated to -1 to detect mutations.
|
||||
*
|
||||
* Items must normally not be NULL, except during construction when
|
||||
* the list is not yet visible outside the function that builds it.
|
||||
*/
|
||||
Py_ssize_t allocated;
|
||||
} PyListObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyList_Type;
|
||||
|
||||
#define PyList_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS)
|
||||
#define PyList_CheckExact(op) (Py_TYPE(op) == &PyList_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size);
|
||||
PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *);
|
||||
PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *);
|
||||
PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
|
||||
PyAPI_FUNC(int) PyList_Sort(PyObject *);
|
||||
PyAPI_FUNC(int) PyList_Reverse(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *);
|
||||
|
||||
/* Macro, trading safety for speed */
|
||||
#define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
|
||||
#define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
|
||||
#define PyList_GET_SIZE(op) Py_SIZE(op)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_LISTOBJECT_H */
|
103
c/meterpreter/source/extensions/python/Include/longintrepr.h
Normal file
103
c/meterpreter/source/extensions/python/Include/longintrepr.h
Normal file
@ -0,0 +1,103 @@
|
||||
#ifndef Py_LONGINTREPR_H
|
||||
#define Py_LONGINTREPR_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* This is published for the benefit of "friend" marshal.c only. */
|
||||
|
||||
/* Parameters of the long integer representation. There are two different
|
||||
sets of parameters: one set for 30-bit digits, stored in an unsigned 32-bit
|
||||
integer type, and one set for 15-bit digits with each digit stored in an
|
||||
unsigned short. The value of PYLONG_BITS_IN_DIGIT, defined either at
|
||||
configure time or in pyport.h, is used to decide which digit size to use.
|
||||
|
||||
Type 'digit' should be able to hold 2*PyLong_BASE-1, and type 'twodigits'
|
||||
should be an unsigned integer type able to hold all integers up to
|
||||
PyLong_BASE*PyLong_BASE-1. x_sub assumes that 'digit' is an unsigned type,
|
||||
and that overflow is handled by taking the result modulo 2**N for some N >
|
||||
PyLong_SHIFT. The majority of the code doesn't care about the precise
|
||||
value of PyLong_SHIFT, but there are some notable exceptions:
|
||||
|
||||
- long_pow() requires that PyLong_SHIFT be divisible by 5
|
||||
|
||||
- PyLong_{As,From}ByteArray require that PyLong_SHIFT be at least 8
|
||||
|
||||
- long_hash() requires that PyLong_SHIFT is *strictly* less than the number
|
||||
of bits in an unsigned long, as do the PyLong <-> long (or unsigned long)
|
||||
conversion functions
|
||||
|
||||
- the long <-> size_t/Py_ssize_t conversion functions expect that
|
||||
PyLong_SHIFT is strictly less than the number of bits in a size_t
|
||||
|
||||
- the marshal code currently expects that PyLong_SHIFT is a multiple of 15
|
||||
|
||||
The values 15 and 30 should fit all of the above requirements, on any
|
||||
platform.
|
||||
*/
|
||||
|
||||
#if PYLONG_BITS_IN_DIGIT == 30
|
||||
#if !(defined HAVE_UINT64_T && defined HAVE_UINT32_T && \
|
||||
defined HAVE_INT64_T && defined HAVE_INT32_T)
|
||||
#error "30-bit long digits requested, but the necessary types are not available on this platform"
|
||||
#endif
|
||||
typedef PY_UINT32_T digit;
|
||||
typedef PY_INT32_T sdigit; /* signed variant of digit */
|
||||
typedef PY_UINT64_T twodigits;
|
||||
typedef PY_INT64_T stwodigits; /* signed variant of twodigits */
|
||||
#define PyLong_SHIFT 30
|
||||
#define _PyLong_DECIMAL_SHIFT 9 /* max(e such that 10**e fits in a digit) */
|
||||
#define _PyLong_DECIMAL_BASE ((digit)1000000000) /* 10 ** DECIMAL_SHIFT */
|
||||
#elif PYLONG_BITS_IN_DIGIT == 15
|
||||
typedef unsigned short digit;
|
||||
typedef short sdigit; /* signed variant of digit */
|
||||
typedef unsigned long twodigits;
|
||||
typedef long stwodigits; /* signed variant of twodigits */
|
||||
#define PyLong_SHIFT 15
|
||||
#define _PyLong_DECIMAL_SHIFT 4 /* max(e such that 10**e fits in a digit) */
|
||||
#define _PyLong_DECIMAL_BASE ((digit)10000) /* 10 ** DECIMAL_SHIFT */
|
||||
#else
|
||||
#error "PYLONG_BITS_IN_DIGIT should be 15 or 30"
|
||||
#endif
|
||||
#define PyLong_BASE ((digit)1 << PyLong_SHIFT)
|
||||
#define PyLong_MASK ((digit)(PyLong_BASE - 1))
|
||||
|
||||
/* b/w compatibility with Python 2.5 */
|
||||
#define SHIFT PyLong_SHIFT
|
||||
#define BASE PyLong_BASE
|
||||
#define MASK PyLong_MASK
|
||||
|
||||
#if PyLong_SHIFT % 5 != 0
|
||||
#error "longobject.c requires that PyLong_SHIFT be divisible by 5"
|
||||
#endif
|
||||
|
||||
/* Long integer representation.
|
||||
The absolute value of a number is equal to
|
||||
SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i)
|
||||
Negative numbers are represented with ob_size < 0;
|
||||
zero is represented by ob_size == 0.
|
||||
In a normalized number, ob_digit[abs(ob_size)-1] (the most significant
|
||||
digit) is never zero. Also, in all cases, for all valid i,
|
||||
0 <= ob_digit[i] <= MASK.
|
||||
The allocation function takes care of allocating extra memory
|
||||
so that ob_digit[0] ... ob_digit[abs(ob_size)-1] are actually available.
|
||||
|
||||
CAUTION: Generic code manipulating subtypes of PyVarObject has to
|
||||
aware that longs abuse ob_size's sign bit.
|
||||
*/
|
||||
|
||||
struct _longobject {
|
||||
PyObject_VAR_HEAD
|
||||
digit ob_digit[1];
|
||||
};
|
||||
|
||||
PyAPI_FUNC(PyLongObject *) _PyLong_New(Py_ssize_t);
|
||||
|
||||
/* Return a copy of src. */
|
||||
PyAPI_FUNC(PyObject *) _PyLong_Copy(PyLongObject *src);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_LONGINTREPR_H */
|
135
c/meterpreter/source/extensions/python/Include/longobject.h
Normal file
135
c/meterpreter/source/extensions/python/Include/longobject.h
Normal file
@ -0,0 +1,135 @@
|
||||
#ifndef Py_LONGOBJECT_H
|
||||
#define Py_LONGOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Long (arbitrary precision) integer object interface */
|
||||
|
||||
typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyLong_Type;
|
||||
|
||||
#define PyLong_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS)
|
||||
#define PyLong_CheckExact(op) (Py_TYPE(op) == &PyLong_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromLong(long);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromDouble(double);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t);
|
||||
PyAPI_FUNC(long) PyLong_AsLong(PyObject *);
|
||||
PyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *);
|
||||
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *);
|
||||
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *);
|
||||
PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *);
|
||||
PyAPI_FUNC(int) _PyLong_AsInt(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyLong_GetInfo(void);
|
||||
|
||||
/* For use by intobject.c only */
|
||||
#define _PyLong_AsSsize_t PyLong_AsSsize_t
|
||||
#define _PyLong_FromSize_t PyLong_FromSize_t
|
||||
#define _PyLong_FromSsize_t PyLong_FromSsize_t
|
||||
PyAPI_DATA(int) _PyLong_DigitValue[256];
|
||||
|
||||
/* _PyLong_Frexp returns a double x and an exponent e such that the
|
||||
true value is approximately equal to x * 2**e. e is >= 0. x is
|
||||
0.0 if and only if the input is 0 (in which case, e and x are both
|
||||
zeroes); otherwise, 0.5 <= abs(x) < 1.0. On overflow, which is
|
||||
possible if the number of bits doesn't fit into a Py_ssize_t, sets
|
||||
OverflowError and returns -1.0 for x, 0 for e. */
|
||||
PyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e);
|
||||
|
||||
PyAPI_FUNC(double) PyLong_AsDouble(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *);
|
||||
PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *);
|
||||
|
||||
#ifdef HAVE_LONG_LONG
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG);
|
||||
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *);
|
||||
PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *);
|
||||
PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
|
||||
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *);
|
||||
#endif /* HAVE_LONG_LONG */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int);
|
||||
#ifdef Py_USING_UNICODE
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
|
||||
#endif
|
||||
|
||||
/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
|
||||
v must not be NULL, and must be a normalized long.
|
||||
There are no error cases.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyLong_Sign(PyObject *v);
|
||||
|
||||
|
||||
/* _PyLong_NumBits. Return the number of bits needed to represent the
|
||||
absolute value of a long. For example, this returns 1 for 1 and -1, 2
|
||||
for 2 and -2, and 2 for 3 and -3. It returns 0 for 0.
|
||||
v must not be NULL, and must be a normalized long.
|
||||
(size_t)-1 is returned and OverflowError set if the true result doesn't
|
||||
fit in a size_t.
|
||||
*/
|
||||
PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v);
|
||||
|
||||
/* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in
|
||||
base 256, and return a Python long with the same numeric value.
|
||||
If n is 0, the integer is 0. Else:
|
||||
If little_endian is 1/true, bytes[n-1] is the MSB and bytes[0] the LSB;
|
||||
else (little_endian is 0/false) bytes[0] is the MSB and bytes[n-1] the
|
||||
LSB.
|
||||
If is_signed is 0/false, view the bytes as a non-negative integer.
|
||||
If is_signed is 1/true, view the bytes as a 2's-complement integer,
|
||||
non-negative if bit 0x80 of the MSB is clear, negative if set.
|
||||
Error returns:
|
||||
+ Return NULL with the appropriate exception set if there's not
|
||||
enough memory to create the Python long.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyLong_FromByteArray(
|
||||
const unsigned char* bytes, size_t n,
|
||||
int little_endian, int is_signed);
|
||||
|
||||
/* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long
|
||||
v to a base-256 integer, stored in array bytes. Normally return 0,
|
||||
return -1 on error.
|
||||
If little_endian is 1/true, store the MSB at bytes[n-1] and the LSB at
|
||||
bytes[0]; else (little_endian is 0/false) store the MSB at bytes[0] and
|
||||
the LSB at bytes[n-1].
|
||||
If is_signed is 0/false, it's an error if v < 0; else (v >= 0) n bytes
|
||||
are filled and there's nothing special about bit 0x80 of the MSB.
|
||||
If is_signed is 1/true, bytes is filled with the 2's-complement
|
||||
representation of v's value. Bit 0x80 of the MSB is the sign bit.
|
||||
Error returns (-1):
|
||||
+ is_signed is 0 and v < 0. TypeError is set in this case, and bytes
|
||||
isn't altered.
|
||||
+ n isn't big enough to hold the full mathematical value of v. For
|
||||
example, if is_signed is 0 and there are more digits in the v than
|
||||
fit in n; or if is_signed is 1, v < 0, and n is just 1 bit shy of
|
||||
being large enough to hold a sign bit. OverflowError is set in this
|
||||
case, but bytes holds the least-signficant n bytes of the true value.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
|
||||
unsigned char* bytes, size_t n,
|
||||
int little_endian, int is_signed);
|
||||
|
||||
/* _PyLong_Format: Convert the long to a string object with given base,
|
||||
appending a base prefix of 0[box] if base is 2, 8 or 16.
|
||||
Add a trailing "L" if addL is non-zero.
|
||||
If newstyle is zero, then use the pre-2.6 behavior of octal having
|
||||
a leading "0", instead of the prefix "0o" */
|
||||
PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *aa, int base, int addL, int newstyle);
|
||||
|
||||
/* Format the object based on the format_spec, as defined in PEP 3101
|
||||
(Advanced String Formatting). */
|
||||
PyAPI_FUNC(PyObject *) _PyLong_FormatAdvanced(PyObject *obj,
|
||||
char *format_spec,
|
||||
Py_ssize_t format_spec_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_LONGOBJECT_H */
|
25
c/meterpreter/source/extensions/python/Include/marshal.h
Normal file
25
c/meterpreter/source/extensions/python/Include/marshal.h
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
/* Interface for marshal.c */
|
||||
|
||||
#ifndef Py_MARSHAL_H
|
||||
#define Py_MARSHAL_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define Py_MARSHAL_VERSION 2
|
||||
|
||||
PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int);
|
||||
PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int);
|
||||
PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int);
|
||||
|
||||
PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *);
|
||||
PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *);
|
||||
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *);
|
||||
PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *);
|
||||
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_MARSHAL_H */
|
@ -0,0 +1,74 @@
|
||||
/* Memory view object. In Python this is available as "memoryview". */
|
||||
|
||||
#ifndef Py_MEMORYOBJECT_H
|
||||
#define Py_MEMORYOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyMemoryView_Type;
|
||||
|
||||
#define PyMemoryView_Check(op) (Py_TYPE(op) == &PyMemoryView_Type)
|
||||
|
||||
/* Get a pointer to the underlying Py_buffer of a memoryview object. */
|
||||
#define PyMemoryView_GET_BUFFER(op) (&((PyMemoryViewObject *)(op))->view)
|
||||
/* Get a pointer to the PyObject from which originates a memoryview object. */
|
||||
#define PyMemoryView_GET_BASE(op) (((PyMemoryViewObject *)(op))->view.obj)
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base,
|
||||
int buffertype,
|
||||
char fort);
|
||||
|
||||
/* Return a contiguous chunk of memory representing the buffer
|
||||
from an object in a memory view object. If a copy is made then the
|
||||
base object for the memory view will be a *new* bytes object.
|
||||
|
||||
Otherwise, the base-object will be the object itself and no
|
||||
data-copying will be done.
|
||||
|
||||
The buffertype argument can be PyBUF_READ, PyBUF_WRITE,
|
||||
PyBUF_SHADOW to determine whether the returned buffer
|
||||
should be READONLY, WRITABLE, or set to update the
|
||||
original buffer if a copy must be made. If buffertype is
|
||||
PyBUF_WRITE and the buffer is not contiguous an error will
|
||||
be raised. In this circumstance, the user can use
|
||||
PyBUF_SHADOW to ensure that a a writable temporary
|
||||
contiguous buffer is returned. The contents of this
|
||||
contiguous buffer will be copied back into the original
|
||||
object after the memoryview object is deleted as long as
|
||||
the original object is writable and allows setting an
|
||||
exclusive write lock. If this is not allowed by the
|
||||
original object, then a BufferError is raised.
|
||||
|
||||
If the object is multi-dimensional and if fortran is 'F',
|
||||
the first dimension of the underlying array will vary the
|
||||
fastest in the buffer. If fortran is 'C', then the last
|
||||
dimension will vary the fastest (C-style contiguous). If
|
||||
fortran is 'A', then it does not matter and you will get
|
||||
whatever the object decides is more efficient.
|
||||
|
||||
A new reference is returned that must be DECREF'd when finished.
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyMemoryView_FromObject(PyObject *base);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyMemoryView_FromBuffer(Py_buffer *info);
|
||||
/* create new if bufptr is NULL
|
||||
will be a new bytesobject in base */
|
||||
|
||||
|
||||
/* The struct is declared here so that macros can work, but it shouldn't
|
||||
be considered public. Don't access those fields directly, use the macros
|
||||
and functions instead! */
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *base;
|
||||
Py_buffer view;
|
||||
} PyMemoryViewObject;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_MEMORYOBJECT_H */
|
18
c/meterpreter/source/extensions/python/Include/metagrammar.h
Normal file
18
c/meterpreter/source/extensions/python/Include/metagrammar.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef Py_METAGRAMMAR_H
|
||||
#define Py_METAGRAMMAR_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define MSTART 256
|
||||
#define RULE 257
|
||||
#define RHS 258
|
||||
#define ALT 259
|
||||
#define ITEM 260
|
||||
#define ATOM 261
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_METAGRAMMAR_H */
|
@ -0,0 +1,93 @@
|
||||
|
||||
/* Method object interface */
|
||||
|
||||
#ifndef Py_METHODOBJECT_H
|
||||
#define Py_METHODOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* This is about the type 'builtin_function_or_method',
|
||||
not Python methods in user-defined classes. See classobject.h
|
||||
for the latter. */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCFunction_Type;
|
||||
|
||||
#define PyCFunction_Check(op) (Py_TYPE(op) == &PyCFunction_Type)
|
||||
|
||||
typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
|
||||
typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
|
||||
PyObject *);
|
||||
typedef PyObject *(*PyNoArgsFunction)(PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *);
|
||||
PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *);
|
||||
|
||||
/* Macros for direct access to these values. Type checks are *not*
|
||||
done, so use with care. */
|
||||
#define PyCFunction_GET_FUNCTION(func) \
|
||||
(((PyCFunctionObject *)func) -> m_ml -> ml_meth)
|
||||
#define PyCFunction_GET_SELF(func) \
|
||||
(((PyCFunctionObject *)func) -> m_self)
|
||||
#define PyCFunction_GET_FLAGS(func) \
|
||||
(((PyCFunctionObject *)func) -> m_ml -> ml_flags)
|
||||
PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *);
|
||||
|
||||
struct PyMethodDef {
|
||||
const char *ml_name; /* The name of the built-in function/method */
|
||||
PyCFunction ml_meth; /* The C function that implements it */
|
||||
int ml_flags; /* Combination of METH_xxx flags, which mostly
|
||||
describe the args expected by the C func */
|
||||
const char *ml_doc; /* The __doc__ attribute, or NULL */
|
||||
};
|
||||
typedef struct PyMethodDef PyMethodDef;
|
||||
|
||||
PyAPI_FUNC(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, const char *);
|
||||
|
||||
#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL)
|
||||
PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *,
|
||||
PyObject *);
|
||||
|
||||
/* Flag passed to newmethodobject */
|
||||
#define METH_OLDARGS 0x0000
|
||||
#define METH_VARARGS 0x0001
|
||||
#define METH_KEYWORDS 0x0002
|
||||
/* METH_NOARGS and METH_O must not be combined with the flags above. */
|
||||
#define METH_NOARGS 0x0004
|
||||
#define METH_O 0x0008
|
||||
|
||||
/* METH_CLASS and METH_STATIC are a little different; these control
|
||||
the construction of methods for a class. These cannot be used for
|
||||
functions in modules. */
|
||||
#define METH_CLASS 0x0010
|
||||
#define METH_STATIC 0x0020
|
||||
|
||||
/* METH_COEXIST allows a method to be entered eventhough a slot has
|
||||
already filled the entry. When defined, the flag allows a separate
|
||||
method, "__contains__" for example, to coexist with a defined
|
||||
slot like sq_contains. */
|
||||
|
||||
#define METH_COEXIST 0x0040
|
||||
|
||||
typedef struct PyMethodChain {
|
||||
PyMethodDef *methods; /* Methods of this type */
|
||||
struct PyMethodChain *link; /* NULL or base type */
|
||||
} PyMethodChain;
|
||||
|
||||
PyAPI_FUNC(PyObject *) Py_FindMethodInChain(PyMethodChain *, PyObject *,
|
||||
const char *);
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyMethodDef *m_ml; /* Description of the C function to call */
|
||||
PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */
|
||||
PyObject *m_module; /* The __module__ attribute, can be anything */
|
||||
} PyCFunctionObject;
|
||||
|
||||
PyAPI_FUNC(int) PyCFunction_ClearFreeList(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_METHODOBJECT_H */
|
134
c/meterpreter/source/extensions/python/Include/modsupport.h
Normal file
134
c/meterpreter/source/extensions/python/Include/modsupport.h
Normal file
@ -0,0 +1,134 @@
|
||||
|
||||
#ifndef Py_MODSUPPORT_H
|
||||
#define Py_MODSUPPORT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Module support interface */
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
/* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier
|
||||
to mean Py_ssize_t */
|
||||
#ifdef PY_SSIZE_T_CLEAN
|
||||
#define PyArg_Parse _PyArg_Parse_SizeT
|
||||
#define PyArg_ParseTuple _PyArg_ParseTuple_SizeT
|
||||
#define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT
|
||||
#define PyArg_VaParse _PyArg_VaParse_SizeT
|
||||
#define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT
|
||||
#define Py_BuildValue _Py_BuildValue_SizeT
|
||||
#define Py_VaBuildValue _Py_VaBuildValue_SizeT
|
||||
#else
|
||||
PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list);
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);
|
||||
PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3);
|
||||
PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
|
||||
const char *, char **, ...);
|
||||
PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...);
|
||||
PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...);
|
||||
PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
|
||||
PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kw);
|
||||
|
||||
PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list);
|
||||
PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
|
||||
const char *, char **, va_list);
|
||||
PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list);
|
||||
|
||||
PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *);
|
||||
PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long);
|
||||
PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *);
|
||||
#define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
|
||||
#define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant(m, #c, c)
|
||||
|
||||
#define PYTHON_API_VERSION 1013
|
||||
#define PYTHON_API_STRING "1013"
|
||||
/* The API version is maintained (independently from the Python version)
|
||||
so we can detect mismatches between the interpreter and dynamically
|
||||
loaded modules. These are diagnosed by an error message but
|
||||
the module is still loaded (because the mismatch can only be tested
|
||||
after loading the module). The error message is intended to
|
||||
explain the core dump a few seconds later.
|
||||
|
||||
The symbol PYTHON_API_STRING defines the same value as a string
|
||||
literal. *** PLEASE MAKE SURE THE DEFINITIONS MATCH. ***
|
||||
|
||||
Please add a line or two to the top of this log for each API
|
||||
version change:
|
||||
|
||||
22-Feb-2006 MvL 1013 PEP 353 - long indices for sequence lengths
|
||||
|
||||
19-Aug-2002 GvR 1012 Changes to string object struct for
|
||||
interning changes, saving 3 bytes.
|
||||
|
||||
17-Jul-2001 GvR 1011 Descr-branch, just to be on the safe side
|
||||
|
||||
25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and
|
||||
PyFrame_New(); Python 2.1a2
|
||||
|
||||
14-Mar-2000 GvR 1009 Unicode API added
|
||||
|
||||
3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!)
|
||||
|
||||
3-Dec-1998 GvR 1008 Python 1.5.2b1
|
||||
|
||||
18-Jan-1997 GvR 1007 string interning and other speedups
|
||||
|
||||
11-Oct-1996 GvR renamed Py_Ellipses to Py_Ellipsis :-(
|
||||
|
||||
30-Jul-1996 GvR Slice and ellipses syntax added
|
||||
|
||||
23-Jul-1996 GvR For 1.4 -- better safe than sorry this time :-)
|
||||
|
||||
7-Nov-1995 GvR Keyword arguments (should've been done at 1.3 :-( )
|
||||
|
||||
10-Jan-1995 GvR Renamed globals to new naming scheme
|
||||
|
||||
9-Jan-1995 GvR Initial version (incompatible with older API)
|
||||
*/
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
/* Special defines for Windows versions used to live here. Things
|
||||
have changed, and the "Version" is now in a global string variable.
|
||||
Reason for this is that this for easier branding of a "custom DLL"
|
||||
without actually needing a recompile. */
|
||||
#endif /* MS_WINDOWS */
|
||||
|
||||
#if SIZEOF_SIZE_T != SIZEOF_INT
|
||||
/* On a 64-bit system, rename the Py_InitModule4 so that 2.4
|
||||
modules cannot get loaded into a 2.5 interpreter */
|
||||
#define Py_InitModule4 Py_InitModule4_64
|
||||
#endif
|
||||
|
||||
#ifdef Py_TRACE_REFS
|
||||
/* When we are tracing reference counts, rename Py_InitModule4 so
|
||||
modules compiled with incompatible settings will generate a
|
||||
link-time error. */
|
||||
#if SIZEOF_SIZE_T != SIZEOF_INT
|
||||
#undef Py_InitModule4
|
||||
#define Py_InitModule4 Py_InitModule4TraceRefs_64
|
||||
#else
|
||||
#define Py_InitModule4 Py_InitModule4TraceRefs
|
||||
#endif
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyObject *) Py_InitModule4(const char *name, PyMethodDef *methods,
|
||||
const char *doc, PyObject *self,
|
||||
int apiver);
|
||||
|
||||
#define Py_InitModule(name, methods) \
|
||||
Py_InitModule4(name, methods, (char *)NULL, (PyObject *)NULL, \
|
||||
PYTHON_API_VERSION)
|
||||
|
||||
#define Py_InitModule3(name, methods, doc) \
|
||||
Py_InitModule4(name, methods, doc, (PyObject *)NULL, \
|
||||
PYTHON_API_VERSION)
|
||||
|
||||
PyAPI_DATA(char *) _Py_PackageContext;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_MODSUPPORT_H */
|
@ -0,0 +1,24 @@
|
||||
|
||||
/* Module object interface */
|
||||
|
||||
#ifndef Py_MODULEOBJECT_H
|
||||
#define Py_MODULEOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyModule_Type;
|
||||
|
||||
#define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type)
|
||||
#define PyModule_CheckExact(op) (Py_TYPE(op) == &PyModule_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyModule_New(const char *);
|
||||
PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
|
||||
PyAPI_FUNC(char *) PyModule_GetName(PyObject *);
|
||||
PyAPI_FUNC(char *) PyModule_GetFilename(PyObject *);
|
||||
PyAPI_FUNC(void) _PyModule_Clear(PyObject *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_MODULEOBJECT_H */
|
41
c/meterpreter/source/extensions/python/Include/node.h
Normal file
41
c/meterpreter/source/extensions/python/Include/node.h
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
/* Parse tree node interface */
|
||||
|
||||
#ifndef Py_NODE_H
|
||||
#define Py_NODE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _node {
|
||||
short n_type;
|
||||
char *n_str;
|
||||
int n_lineno;
|
||||
int n_col_offset;
|
||||
int n_nchildren;
|
||||
struct _node *n_child;
|
||||
} node;
|
||||
|
||||
PyAPI_FUNC(node *) PyNode_New(int type);
|
||||
PyAPI_FUNC(int) PyNode_AddChild(node *n, int type,
|
||||
char *str, int lineno, int col_offset);
|
||||
PyAPI_FUNC(void) PyNode_Free(node *n);
|
||||
PyAPI_FUNC(Py_ssize_t) _PyNode_SizeOf(node *n);
|
||||
|
||||
/* Node access functions */
|
||||
#define NCH(n) ((n)->n_nchildren)
|
||||
|
||||
#define CHILD(n, i) (&(n)->n_child[i])
|
||||
#define RCHILD(n, i) (CHILD(n, NCH(n) + i))
|
||||
#define TYPE(n) ((n)->n_type)
|
||||
#define STR(n) ((n)->n_str)
|
||||
|
||||
/* Assert that the type of a node is what we expect */
|
||||
#define REQ(n, type) assert(TYPE(n) == (type))
|
||||
|
||||
PyAPI_FUNC(void) PyNode_ListTree(node *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_NODE_H */
|
1013
c/meterpreter/source/extensions/python/Include/object.h
Normal file
1013
c/meterpreter/source/extensions/python/Include/object.h
Normal file
File diff suppressed because it is too large
Load Diff
354
c/meterpreter/source/extensions/python/Include/objimpl.h
Normal file
354
c/meterpreter/source/extensions/python/Include/objimpl.h
Normal file
@ -0,0 +1,354 @@
|
||||
/* The PyObject_ memory family: high-level object memory interfaces.
|
||||
See pymem.h for the low-level PyMem_ family.
|
||||
*/
|
||||
|
||||
#ifndef Py_OBJIMPL_H
|
||||
#define Py_OBJIMPL_H
|
||||
|
||||
#include "pymem.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* BEWARE:
|
||||
|
||||
Each interface exports both functions and macros. Extension modules should
|
||||
use the functions, to ensure binary compatibility across Python versions.
|
||||
Because the Python implementation is free to change internal details, and
|
||||
the macros may (or may not) expose details for speed, if you do use the
|
||||
macros you must recompile your extensions with each Python release.
|
||||
|
||||
Never mix calls to PyObject_ memory functions with calls to the platform
|
||||
malloc/realloc/ calloc/free, or with calls to PyMem_.
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions and macros for modules that implement new object types.
|
||||
|
||||
- PyObject_New(type, typeobj) allocates memory for a new object of the given
|
||||
type, and initializes part of it. 'type' must be the C structure type used
|
||||
to represent the object, and 'typeobj' the address of the corresponding
|
||||
type object. Reference count and type pointer are filled in; the rest of
|
||||
the bytes of the object are *undefined*! The resulting expression type is
|
||||
'type *'. The size of the object is determined by the tp_basicsize field
|
||||
of the type object.
|
||||
|
||||
- PyObject_NewVar(type, typeobj, n) is similar but allocates a variable-size
|
||||
object with room for n items. In addition to the refcount and type pointer
|
||||
fields, this also fills in the ob_size field.
|
||||
|
||||
- PyObject_Del(op) releases the memory allocated for an object. It does not
|
||||
run a destructor -- it only frees the memory. PyObject_Free is identical.
|
||||
|
||||
- PyObject_Init(op, typeobj) and PyObject_InitVar(op, typeobj, n) don't
|
||||
allocate memory. Instead of a 'type' parameter, they take a pointer to a
|
||||
new object (allocated by an arbitrary allocator), and initialize its object
|
||||
header fields.
|
||||
|
||||
Note that objects created with PyObject_{New, NewVar} are allocated using the
|
||||
specialized Python allocator (implemented in obmalloc.c), if WITH_PYMALLOC is
|
||||
enabled. In addition, a special debugging allocator is used if PYMALLOC_DEBUG
|
||||
is also #defined.
|
||||
|
||||
In case a specific form of memory management is needed (for example, if you
|
||||
must use the platform malloc heap(s), or shared memory, or C++ local storage or
|
||||
operator new), you must first allocate the object with your custom allocator,
|
||||
then pass its pointer to PyObject_{Init, InitVar} for filling in its Python-
|
||||
specific fields: reference count, type pointer, possibly others. You should
|
||||
be aware that Python no control over these objects because they don't
|
||||
cooperate with the Python memory manager. Such objects may not be eligible
|
||||
for automatic garbage collection and you have to make sure that they are
|
||||
released accordingly whenever their destructor gets called (cf. the specific
|
||||
form of memory management you're using).
|
||||
|
||||
Unless you have specific memory management requirements, use
|
||||
PyObject_{New, NewVar, Del}.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Raw object memory interface
|
||||
* ===========================
|
||||
*/
|
||||
|
||||
/* Functions to call the same malloc/realloc/free as used by Python's
|
||||
object allocator. If WITH_PYMALLOC is enabled, these may differ from
|
||||
the platform malloc/realloc/free. The Python object allocator is
|
||||
designed for fast, cache-conscious allocation of many "small" objects,
|
||||
and with low hidden memory overhead.
|
||||
|
||||
PyObject_Malloc(0) returns a unique non-NULL pointer if possible.
|
||||
|
||||
PyObject_Realloc(NULL, n) acts like PyObject_Malloc(n).
|
||||
PyObject_Realloc(p != NULL, 0) does not return NULL, or free the memory
|
||||
at p.
|
||||
|
||||
Returned pointers must be checked for NULL explicitly; no action is
|
||||
performed on failure other than to return NULL (no warning it printed, no
|
||||
exception is set, etc).
|
||||
|
||||
For allocating objects, use PyObject_{New, NewVar} instead whenever
|
||||
possible. The PyObject_{Malloc, Realloc, Free} family is exposed
|
||||
so that you can exploit Python's small-block allocator for non-object
|
||||
uses. If you must use these routines to allocate object memory, make sure
|
||||
the object gets initialized via PyObject_{Init, InitVar} after obtaining
|
||||
the raw memory.
|
||||
*/
|
||||
PyAPI_FUNC(void *) PyObject_Malloc(size_t);
|
||||
PyAPI_FUNC(void *) PyObject_Realloc(void *, size_t);
|
||||
PyAPI_FUNC(void) PyObject_Free(void *);
|
||||
|
||||
|
||||
/* Macros */
|
||||
#ifdef WITH_PYMALLOC
|
||||
#ifdef PYMALLOC_DEBUG /* WITH_PYMALLOC && PYMALLOC_DEBUG */
|
||||
PyAPI_FUNC(void *) _PyObject_DebugMalloc(size_t nbytes);
|
||||
PyAPI_FUNC(void *) _PyObject_DebugRealloc(void *p, size_t nbytes);
|
||||
PyAPI_FUNC(void) _PyObject_DebugFree(void *p);
|
||||
PyAPI_FUNC(void) _PyObject_DebugDumpAddress(const void *p);
|
||||
PyAPI_FUNC(void) _PyObject_DebugCheckAddress(const void *p);
|
||||
PyAPI_FUNC(void) _PyObject_DebugMallocStats(void);
|
||||
PyAPI_FUNC(void *) _PyObject_DebugMallocApi(char api, size_t nbytes);
|
||||
PyAPI_FUNC(void *) _PyObject_DebugReallocApi(char api, void *p, size_t nbytes);
|
||||
PyAPI_FUNC(void) _PyObject_DebugFreeApi(char api, void *p);
|
||||
PyAPI_FUNC(void) _PyObject_DebugCheckAddressApi(char api, const void *p);
|
||||
PyAPI_FUNC(void *) _PyMem_DebugMalloc(size_t nbytes);
|
||||
PyAPI_FUNC(void *) _PyMem_DebugRealloc(void *p, size_t nbytes);
|
||||
PyAPI_FUNC(void) _PyMem_DebugFree(void *p);
|
||||
#define PyObject_MALLOC _PyObject_DebugMalloc
|
||||
#define PyObject_Malloc _PyObject_DebugMalloc
|
||||
#define PyObject_REALLOC _PyObject_DebugRealloc
|
||||
#define PyObject_Realloc _PyObject_DebugRealloc
|
||||
#define PyObject_FREE _PyObject_DebugFree
|
||||
#define PyObject_Free _PyObject_DebugFree
|
||||
|
||||
#else /* WITH_PYMALLOC && ! PYMALLOC_DEBUG */
|
||||
#define PyObject_MALLOC PyObject_Malloc
|
||||
#define PyObject_REALLOC PyObject_Realloc
|
||||
#define PyObject_FREE PyObject_Free
|
||||
#endif
|
||||
|
||||
#else /* ! WITH_PYMALLOC */
|
||||
#define PyObject_MALLOC PyMem_MALLOC
|
||||
#define PyObject_REALLOC PyMem_REALLOC
|
||||
#define PyObject_FREE PyMem_FREE
|
||||
|
||||
#endif /* WITH_PYMALLOC */
|
||||
|
||||
#define PyObject_Del PyObject_Free
|
||||
#define PyObject_DEL PyObject_FREE
|
||||
|
||||
/* for source compatibility with 2.2 */
|
||||
#define _PyObject_Del PyObject_Free
|
||||
|
||||
/*
|
||||
* Generic object allocator interface
|
||||
* ==================================
|
||||
*/
|
||||
|
||||
/* Functions */
|
||||
PyAPI_FUNC(PyObject *) PyObject_Init(PyObject *, PyTypeObject *);
|
||||
PyAPI_FUNC(PyVarObject *) PyObject_InitVar(PyVarObject *,
|
||||
PyTypeObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(PyObject *) _PyObject_New(PyTypeObject *);
|
||||
PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
|
||||
|
||||
#define PyObject_New(type, typeobj) \
|
||||
( (type *) _PyObject_New(typeobj) )
|
||||
#define PyObject_NewVar(type, typeobj, n) \
|
||||
( (type *) _PyObject_NewVar((typeobj), (n)) )
|
||||
|
||||
/* Macros trading binary compatibility for speed. See also pymem.h.
|
||||
Note that these macros expect non-NULL object pointers.*/
|
||||
#define PyObject_INIT(op, typeobj) \
|
||||
( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
|
||||
#define PyObject_INIT_VAR(op, typeobj, size) \
|
||||
( Py_SIZE(op) = (size), PyObject_INIT((op), (typeobj)) )
|
||||
|
||||
#define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize )
|
||||
|
||||
/* _PyObject_VAR_SIZE returns the number of bytes (as size_t) allocated for a
|
||||
vrbl-size object with nitems items, exclusive of gc overhead (if any). The
|
||||
value is rounded up to the closest multiple of sizeof(void *), in order to
|
||||
ensure that pointer fields at the end of the object are correctly aligned
|
||||
for the platform (this is of special importance for subclasses of, e.g.,
|
||||
str or long, so that pointers can be stored after the embedded data).
|
||||
|
||||
Note that there's no memory wastage in doing this, as malloc has to
|
||||
return (at worst) pointer-aligned memory anyway.
|
||||
*/
|
||||
#if ((SIZEOF_VOID_P - 1) & SIZEOF_VOID_P) != 0
|
||||
# error "_PyObject_VAR_SIZE requires SIZEOF_VOID_P be a power of 2"
|
||||
#endif
|
||||
|
||||
#define _PyObject_VAR_SIZE(typeobj, nitems) \
|
||||
(size_t) \
|
||||
( ( (typeobj)->tp_basicsize + \
|
||||
(nitems)*(typeobj)->tp_itemsize + \
|
||||
(SIZEOF_VOID_P - 1) \
|
||||
) & ~(SIZEOF_VOID_P - 1) \
|
||||
)
|
||||
|
||||
#define PyObject_NEW(type, typeobj) \
|
||||
( (type *) PyObject_Init( \
|
||||
(PyObject *) PyObject_MALLOC( _PyObject_SIZE(typeobj) ), (typeobj)) )
|
||||
|
||||
#define PyObject_NEW_VAR(type, typeobj, n) \
|
||||
( (type *) PyObject_InitVar( \
|
||||
(PyVarObject *) PyObject_MALLOC(_PyObject_VAR_SIZE((typeobj),(n)) ),\
|
||||
(typeobj), (n)) )
|
||||
|
||||
/* This example code implements an object constructor with a custom
|
||||
allocator, where PyObject_New is inlined, and shows the important
|
||||
distinction between two steps (at least):
|
||||
1) the actual allocation of the object storage;
|
||||
2) the initialization of the Python specific fields
|
||||
in this storage with PyObject_{Init, InitVar}.
|
||||
|
||||
PyObject *
|
||||
YourObject_New(...)
|
||||
{
|
||||
PyObject *op;
|
||||
|
||||
op = (PyObject *) Your_Allocator(_PyObject_SIZE(YourTypeStruct));
|
||||
if (op == NULL)
|
||||
return PyErr_NoMemory();
|
||||
|
||||
PyObject_Init(op, &YourTypeStruct);
|
||||
|
||||
op->ob_field = value;
|
||||
...
|
||||
return op;
|
||||
}
|
||||
|
||||
Note that in C++, the use of the new operator usually implies that
|
||||
the 1st step is performed automatically for you, so in a C++ class
|
||||
constructor you would start directly with PyObject_Init/InitVar
|
||||
*/
|
||||
|
||||
/*
|
||||
* Garbage Collection Support
|
||||
* ==========================
|
||||
*/
|
||||
|
||||
/* C equivalent of gc.collect(). */
|
||||
PyAPI_FUNC(Py_ssize_t) PyGC_Collect(void);
|
||||
|
||||
/* Test if a type has a GC head */
|
||||
#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC)
|
||||
|
||||
/* Test if an object has a GC head */
|
||||
#define PyObject_IS_GC(o) (PyType_IS_GC(Py_TYPE(o)) && \
|
||||
(Py_TYPE(o)->tp_is_gc == NULL || Py_TYPE(o)->tp_is_gc(o)))
|
||||
|
||||
PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t);
|
||||
#define PyObject_GC_Resize(type, op, n) \
|
||||
( (type *) _PyObject_GC_Resize((PyVarObject *)(op), (n)) )
|
||||
|
||||
/* for source compatibility with 2.2 */
|
||||
#define _PyObject_GC_Del PyObject_GC_Del
|
||||
|
||||
/* GC information is stored BEFORE the object structure. */
|
||||
typedef union _gc_head {
|
||||
struct {
|
||||
union _gc_head *gc_next;
|
||||
union _gc_head *gc_prev;
|
||||
Py_ssize_t gc_refs;
|
||||
} gc;
|
||||
long double dummy; /* force worst-case alignment */
|
||||
} PyGC_Head;
|
||||
|
||||
extern PyGC_Head *_PyGC_generation0;
|
||||
|
||||
#define _Py_AS_GC(o) ((PyGC_Head *)(o)-1)
|
||||
|
||||
#define _PyGC_REFS_UNTRACKED (-2)
|
||||
#define _PyGC_REFS_REACHABLE (-3)
|
||||
#define _PyGC_REFS_TENTATIVELY_UNREACHABLE (-4)
|
||||
|
||||
/* Tell the GC to track this object. NB: While the object is tracked the
|
||||
* collector it must be safe to call the ob_traverse method. */
|
||||
#define _PyObject_GC_TRACK(o) do { \
|
||||
PyGC_Head *g = _Py_AS_GC(o); \
|
||||
if (g->gc.gc_refs != _PyGC_REFS_UNTRACKED) \
|
||||
Py_FatalError("GC object already tracked"); \
|
||||
g->gc.gc_refs = _PyGC_REFS_REACHABLE; \
|
||||
g->gc.gc_next = _PyGC_generation0; \
|
||||
g->gc.gc_prev = _PyGC_generation0->gc.gc_prev; \
|
||||
g->gc.gc_prev->gc.gc_next = g; \
|
||||
_PyGC_generation0->gc.gc_prev = g; \
|
||||
} while (0);
|
||||
|
||||
/* Tell the GC to stop tracking this object.
|
||||
* gc_next doesn't need to be set to NULL, but doing so is a good
|
||||
* way to provoke memory errors if calling code is confused.
|
||||
*/
|
||||
#define _PyObject_GC_UNTRACK(o) do { \
|
||||
PyGC_Head *g = _Py_AS_GC(o); \
|
||||
assert(g->gc.gc_refs != _PyGC_REFS_UNTRACKED); \
|
||||
g->gc.gc_refs = _PyGC_REFS_UNTRACKED; \
|
||||
g->gc.gc_prev->gc.gc_next = g->gc.gc_next; \
|
||||
g->gc.gc_next->gc.gc_prev = g->gc.gc_prev; \
|
||||
g->gc.gc_next = NULL; \
|
||||
} while (0);
|
||||
|
||||
/* True if the object is currently tracked by the GC. */
|
||||
#define _PyObject_GC_IS_TRACKED(o) \
|
||||
((_Py_AS_GC(o))->gc.gc_refs != _PyGC_REFS_UNTRACKED)
|
||||
|
||||
/* True if the object may be tracked by the GC in the future, or already is.
|
||||
This can be useful to implement some optimizations. */
|
||||
#define _PyObject_GC_MAY_BE_TRACKED(obj) \
|
||||
(PyObject_IS_GC(obj) && \
|
||||
(!PyTuple_CheckExact(obj) || _PyObject_GC_IS_TRACKED(obj)))
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t);
|
||||
PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *);
|
||||
PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(void) PyObject_GC_Track(void *);
|
||||
PyAPI_FUNC(void) PyObject_GC_UnTrack(void *);
|
||||
PyAPI_FUNC(void) PyObject_GC_Del(void *);
|
||||
|
||||
#define PyObject_GC_New(type, typeobj) \
|
||||
( (type *) _PyObject_GC_New(typeobj) )
|
||||
#define PyObject_GC_NewVar(type, typeobj, n) \
|
||||
( (type *) _PyObject_GC_NewVar((typeobj), (n)) )
|
||||
|
||||
|
||||
/* Utility macro to help write tp_traverse functions.
|
||||
* To use this macro, the tp_traverse function must name its arguments
|
||||
* "visit" and "arg". This is intended to keep tp_traverse functions
|
||||
* looking as much alike as possible.
|
||||
*/
|
||||
#define Py_VISIT(op) \
|
||||
do { \
|
||||
if (op) { \
|
||||
int vret = visit((PyObject *)(op), arg); \
|
||||
if (vret) \
|
||||
return vret; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* This is here for the sake of backwards compatibility. Extensions that
|
||||
* use the old GC API will still compile but the objects will not be
|
||||
* tracked by the GC. */
|
||||
#define PyGC_HEAD_SIZE 0
|
||||
#define PyObject_GC_Init(op)
|
||||
#define PyObject_GC_Fini(op)
|
||||
#define PyObject_AS_GC(op) (op)
|
||||
#define PyObject_FROM_GC(op) (op)
|
||||
|
||||
|
||||
/* Test if a type supports weak references */
|
||||
#define PyType_SUPPORTS_WEAKREFS(t) \
|
||||
(PyType_HasFeature((t), Py_TPFLAGS_HAVE_WEAKREFS) \
|
||||
&& ((t)->tp_weaklistoffset > 0))
|
||||
|
||||
#define PyObject_GET_WEAKREFS_LISTPTR(o) \
|
||||
((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_OBJIMPL_H */
|
171
c/meterpreter/source/extensions/python/Include/opcode.h
Normal file
171
c/meterpreter/source/extensions/python/Include/opcode.h
Normal file
@ -0,0 +1,171 @@
|
||||
#ifndef Py_OPCODE_H
|
||||
#define Py_OPCODE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Instruction opcodes for compiled code */
|
||||
|
||||
#define STOP_CODE 0
|
||||
#define POP_TOP 1
|
||||
#define ROT_TWO 2
|
||||
#define ROT_THREE 3
|
||||
#define DUP_TOP 4
|
||||
#define ROT_FOUR 5
|
||||
#define NOP 9
|
||||
|
||||
#define UNARY_POSITIVE 10
|
||||
#define UNARY_NEGATIVE 11
|
||||
#define UNARY_NOT 12
|
||||
#define UNARY_CONVERT 13
|
||||
|
||||
#define UNARY_INVERT 15
|
||||
|
||||
#define BINARY_POWER 19
|
||||
|
||||
#define BINARY_MULTIPLY 20
|
||||
#define BINARY_DIVIDE 21
|
||||
#define BINARY_MODULO 22
|
||||
#define BINARY_ADD 23
|
||||
#define BINARY_SUBTRACT 24
|
||||
#define BINARY_SUBSCR 25
|
||||
#define BINARY_FLOOR_DIVIDE 26
|
||||
#define BINARY_TRUE_DIVIDE 27
|
||||
#define INPLACE_FLOOR_DIVIDE 28
|
||||
#define INPLACE_TRUE_DIVIDE 29
|
||||
|
||||
#define SLICE 30
|
||||
/* Also uses 31-33 */
|
||||
#define SLICE_1 31
|
||||
#define SLICE_2 32
|
||||
#define SLICE_3 33
|
||||
|
||||
#define STORE_SLICE 40
|
||||
/* Also uses 41-43 */
|
||||
#define STORE_SLICE_1 41
|
||||
#define STORE_SLICE_2 42
|
||||
#define STORE_SLICE_3 43
|
||||
|
||||
#define DELETE_SLICE 50
|
||||
/* Also uses 51-53 */
|
||||
#define DELETE_SLICE_1 51
|
||||
#define DELETE_SLICE_2 52
|
||||
#define DELETE_SLICE_3 53
|
||||
|
||||
#define STORE_MAP 54
|
||||
#define INPLACE_ADD 55
|
||||
#define INPLACE_SUBTRACT 56
|
||||
#define INPLACE_MULTIPLY 57
|
||||
#define INPLACE_DIVIDE 58
|
||||
#define INPLACE_MODULO 59
|
||||
#define STORE_SUBSCR 60
|
||||
#define DELETE_SUBSCR 61
|
||||
|
||||
#define BINARY_LSHIFT 62
|
||||
#define BINARY_RSHIFT 63
|
||||
#define BINARY_AND 64
|
||||
#define BINARY_XOR 65
|
||||
#define BINARY_OR 66
|
||||
#define INPLACE_POWER 67
|
||||
#define GET_ITER 68
|
||||
|
||||
#define PRINT_EXPR 70
|
||||
#define PRINT_ITEM 71
|
||||
#define PRINT_NEWLINE 72
|
||||
#define PRINT_ITEM_TO 73
|
||||
#define PRINT_NEWLINE_TO 74
|
||||
#define INPLACE_LSHIFT 75
|
||||
#define INPLACE_RSHIFT 76
|
||||
#define INPLACE_AND 77
|
||||
#define INPLACE_XOR 78
|
||||
#define INPLACE_OR 79
|
||||
#define BREAK_LOOP 80
|
||||
#define WITH_CLEANUP 81
|
||||
#define LOAD_LOCALS 82
|
||||
#define RETURN_VALUE 83
|
||||
#define IMPORT_STAR 84
|
||||
#define EXEC_STMT 85
|
||||
#define YIELD_VALUE 86
|
||||
#define POP_BLOCK 87
|
||||
#define END_FINALLY 88
|
||||
#define BUILD_CLASS 89
|
||||
|
||||
#define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */
|
||||
|
||||
#define STORE_NAME 90 /* Index in name list */
|
||||
#define DELETE_NAME 91 /* "" */
|
||||
#define UNPACK_SEQUENCE 92 /* Number of sequence items */
|
||||
#define FOR_ITER 93
|
||||
#define LIST_APPEND 94
|
||||
|
||||
#define STORE_ATTR 95 /* Index in name list */
|
||||
#define DELETE_ATTR 96 /* "" */
|
||||
#define STORE_GLOBAL 97 /* "" */
|
||||
#define DELETE_GLOBAL 98 /* "" */
|
||||
#define DUP_TOPX 99 /* number of items to duplicate */
|
||||
#define LOAD_CONST 100 /* Index in const list */
|
||||
#define LOAD_NAME 101 /* Index in name list */
|
||||
#define BUILD_TUPLE 102 /* Number of tuple items */
|
||||
#define BUILD_LIST 103 /* Number of list items */
|
||||
#define BUILD_SET 104 /* Number of set items */
|
||||
#define BUILD_MAP 105 /* Always zero for now */
|
||||
#define LOAD_ATTR 106 /* Index in name list */
|
||||
#define COMPARE_OP 107 /* Comparison operator */
|
||||
#define IMPORT_NAME 108 /* Index in name list */
|
||||
#define IMPORT_FROM 109 /* Index in name list */
|
||||
#define JUMP_FORWARD 110 /* Number of bytes to skip */
|
||||
|
||||
#define JUMP_IF_FALSE_OR_POP 111 /* Target byte offset from beginning
|
||||
of code */
|
||||
#define JUMP_IF_TRUE_OR_POP 112 /* "" */
|
||||
#define JUMP_ABSOLUTE 113 /* "" */
|
||||
#define POP_JUMP_IF_FALSE 114 /* "" */
|
||||
#define POP_JUMP_IF_TRUE 115 /* "" */
|
||||
|
||||
#define LOAD_GLOBAL 116 /* Index in name list */
|
||||
|
||||
#define CONTINUE_LOOP 119 /* Start of loop (absolute) */
|
||||
#define SETUP_LOOP 120 /* Target address (relative) */
|
||||
#define SETUP_EXCEPT 121 /* "" */
|
||||
#define SETUP_FINALLY 122 /* "" */
|
||||
|
||||
#define LOAD_FAST 124 /* Local variable number */
|
||||
#define STORE_FAST 125 /* Local variable number */
|
||||
#define DELETE_FAST 126 /* Local variable number */
|
||||
|
||||
#define RAISE_VARARGS 130 /* Number of raise arguments (1, 2 or 3) */
|
||||
/* CALL_FUNCTION_XXX opcodes defined below depend on this definition */
|
||||
#define CALL_FUNCTION 131 /* #args + (#kwargs<<8) */
|
||||
#define MAKE_FUNCTION 132 /* #defaults */
|
||||
#define BUILD_SLICE 133 /* Number of items */
|
||||
|
||||
#define MAKE_CLOSURE 134 /* #free vars */
|
||||
#define LOAD_CLOSURE 135 /* Load free variable from closure */
|
||||
#define LOAD_DEREF 136 /* Load and dereference from closure cell */
|
||||
#define STORE_DEREF 137 /* Store into cell */
|
||||
|
||||
/* The next 3 opcodes must be contiguous and satisfy
|
||||
(CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 */
|
||||
#define CALL_FUNCTION_VAR 140 /* #args + (#kwargs<<8) */
|
||||
#define CALL_FUNCTION_KW 141 /* #args + (#kwargs<<8) */
|
||||
#define CALL_FUNCTION_VAR_KW 142 /* #args + (#kwargs<<8) */
|
||||
|
||||
#define SETUP_WITH 143
|
||||
|
||||
/* Support for opargs more than 16 bits long */
|
||||
#define EXTENDED_ARG 145
|
||||
|
||||
#define SET_ADD 146
|
||||
#define MAP_ADD 147
|
||||
|
||||
|
||||
enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE, PyCmp_GT=Py_GT, PyCmp_GE=Py_GE,
|
||||
PyCmp_IN, PyCmp_NOT_IN, PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD};
|
||||
|
||||
#define HAS_ARG(op) ((op) >= HAVE_ARGUMENT)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_OPCODE_H */
|
63
c/meterpreter/source/extensions/python/Include/osdefs.h
Normal file
63
c/meterpreter/source/extensions/python/Include/osdefs.h
Normal file
@ -0,0 +1,63 @@
|
||||
#ifndef Py_OSDEFS_H
|
||||
#define Py_OSDEFS_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Operating system dependencies */
|
||||
|
||||
/* Mod by chrish: QNX has WATCOM, but isn't DOS */
|
||||
#if !defined(__QNX__)
|
||||
#if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__DJGPP__) || defined(PYOS_OS2)
|
||||
#if defined(PYOS_OS2) && defined(PYCC_GCC)
|
||||
#define MAXPATHLEN 260
|
||||
#define SEP '/'
|
||||
#define ALTSEP '\\'
|
||||
#else
|
||||
#define SEP '\\'
|
||||
#define ALTSEP '/'
|
||||
#define MAXPATHLEN 256
|
||||
#endif
|
||||
#define DELIM ';'
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef RISCOS
|
||||
#define SEP '.'
|
||||
#define MAXPATHLEN 256
|
||||
#define DELIM ','
|
||||
#endif
|
||||
|
||||
|
||||
/* Filename separator */
|
||||
#ifndef SEP
|
||||
#define SEP '/'
|
||||
#endif
|
||||
|
||||
/* Max pathname length */
|
||||
#ifdef __hpux
|
||||
#include <sys/param.h>
|
||||
#include <limits.h>
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX MAXPATHLEN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#if defined(PATH_MAX) && PATH_MAX > 1024
|
||||
#define MAXPATHLEN PATH_MAX
|
||||
#else
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Search path entry delimiter */
|
||||
#ifndef DELIM
|
||||
#define DELIM ':'
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_OSDEFS_H */
|
64
c/meterpreter/source/extensions/python/Include/parsetok.h
Normal file
64
c/meterpreter/source/extensions/python/Include/parsetok.h
Normal file
@ -0,0 +1,64 @@
|
||||
|
||||
/* Parser-tokenizer link interface */
|
||||
|
||||
#ifndef Py_PARSETOK_H
|
||||
#define Py_PARSETOK_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int error;
|
||||
const char *filename;
|
||||
int lineno;
|
||||
int offset;
|
||||
char *text;
|
||||
int token;
|
||||
int expected;
|
||||
} perrdetail;
|
||||
|
||||
#if 0
|
||||
#define PyPARSE_YIELD_IS_KEYWORD 0x0001
|
||||
#endif
|
||||
|
||||
#define PyPARSE_DONT_IMPLY_DEDENT 0x0002
|
||||
|
||||
#if 0
|
||||
#define PyPARSE_WITH_IS_KEYWORD 0x0003
|
||||
#endif
|
||||
|
||||
#define PyPARSE_PRINT_IS_FUNCTION 0x0004
|
||||
#define PyPARSE_UNICODE_LITERALS 0x0008
|
||||
|
||||
|
||||
|
||||
PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int,
|
||||
perrdetail *);
|
||||
PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int,
|
||||
char *, char *, perrdetail *);
|
||||
|
||||
PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int,
|
||||
perrdetail *, int);
|
||||
PyAPI_FUNC(node *) PyParser_ParseFileFlags(FILE *, const char *, grammar *,
|
||||
int, char *, char *,
|
||||
perrdetail *, int);
|
||||
PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(FILE *, const char *, grammar *,
|
||||
int, char *, char *,
|
||||
perrdetail *, int *);
|
||||
|
||||
PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(const char *,
|
||||
const char *,
|
||||
grammar *, int,
|
||||
perrdetail *, int);
|
||||
PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(const char *,
|
||||
const char *,
|
||||
grammar *, int,
|
||||
perrdetail *, int *);
|
||||
|
||||
/* Note that he following function is defined in pythonrun.c not parsetok.c. */
|
||||
PyAPI_FUNC(void) PyParser_SetError(perrdetail *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_PARSETOK_H */
|
43
c/meterpreter/source/extensions/python/Include/patchlevel.h
Normal file
43
c/meterpreter/source/extensions/python/Include/patchlevel.h
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
/* Newfangled version identification scheme.
|
||||
|
||||
This scheme was added in Python 1.5.2b2; before that time, only PATCHLEVEL
|
||||
was available. To test for presence of the scheme, test for
|
||||
defined(PY_MAJOR_VERSION).
|
||||
|
||||
When the major or minor version changes, the VERSION variable in
|
||||
configure.ac must also be changed.
|
||||
|
||||
There is also (independent) API version information in modsupport.h.
|
||||
*/
|
||||
|
||||
/* Values for PY_RELEASE_LEVEL */
|
||||
#define PY_RELEASE_LEVEL_ALPHA 0xA
|
||||
#define PY_RELEASE_LEVEL_BETA 0xB
|
||||
#define PY_RELEASE_LEVEL_GAMMA 0xC /* For release candidates */
|
||||
#define PY_RELEASE_LEVEL_FINAL 0xF /* Serial should be 0 here */
|
||||
/* Higher for patch releases */
|
||||
|
||||
/* Version parsed out into numeric values */
|
||||
/*--start constants--*/
|
||||
#define PY_MAJOR_VERSION 2
|
||||
#define PY_MINOR_VERSION 7
|
||||
#define PY_MICRO_VERSION 10
|
||||
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL
|
||||
#define PY_RELEASE_SERIAL 0
|
||||
|
||||
/* Version as a string */
|
||||
#define PY_VERSION "2.7.10+"
|
||||
/*--end constants--*/
|
||||
|
||||
/* Subversion Revision number of this file (not of the repository). Empty
|
||||
since Mercurial migration. */
|
||||
#define PY_PATCHLEVEL_REVISION ""
|
||||
|
||||
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.
|
||||
Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */
|
||||
#define PY_VERSION_HEX ((PY_MAJOR_VERSION << 24) | \
|
||||
(PY_MINOR_VERSION << 16) | \
|
||||
(PY_MICRO_VERSION << 8) | \
|
||||
(PY_RELEASE_LEVEL << 4) | \
|
||||
(PY_RELEASE_SERIAL << 0))
|
18
c/meterpreter/source/extensions/python/Include/pgen.h
Normal file
18
c/meterpreter/source/extensions/python/Include/pgen.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef Py_PGEN_H
|
||||
#define Py_PGEN_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Parser generator interface */
|
||||
|
||||
extern grammar *meta_grammar(void);
|
||||
|
||||
struct _node;
|
||||
extern grammar *pgen(struct _node *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_PGEN_H */
|
42
c/meterpreter/source/extensions/python/Include/pgenheaders.h
Normal file
42
c/meterpreter/source/extensions/python/Include/pgenheaders.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef Py_PGENHEADERS_H
|
||||
#define Py_PGENHEADERS_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Include files and extern declarations used by most of the parser. */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
|
||||
PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
|
||||
|
||||
#define addarc _Py_addarc
|
||||
#define addbit _Py_addbit
|
||||
#define adddfa _Py_adddfa
|
||||
#define addfirstsets _Py_addfirstsets
|
||||
#define addlabel _Py_addlabel
|
||||
#define addstate _Py_addstate
|
||||
#define delbitset _Py_delbitset
|
||||
#define dumptree _Py_dumptree
|
||||
#define findlabel _Py_findlabel
|
||||
#define mergebitset _Py_mergebitset
|
||||
#define meta_grammar _Py_meta_grammar
|
||||
#define newbitset _Py_newbitset
|
||||
#define newgrammar _Py_newgrammar
|
||||
#define pgen _Py_pgen
|
||||
#define printgrammar _Py_printgrammar
|
||||
#define printnonterminals _Py_printnonterminals
|
||||
#define printtree _Py_printtree
|
||||
#define samebitset _Py_samebitset
|
||||
#define showtree _Py_showtree
|
||||
#define tok_dump _Py_tok_dump
|
||||
#define translatelabels _Py_translatelabels
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_PGENHEADERS_H */
|
176
c/meterpreter/source/extensions/python/Include/py_curses.h
Normal file
176
c/meterpreter/source/extensions/python/Include/py_curses.h
Normal file
@ -0,0 +1,176 @@
|
||||
|
||||
#ifndef Py_CURSES_H
|
||||
#define Py_CURSES_H
|
||||
|
||||
#ifdef __APPLE__
|
||||
/*
|
||||
** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards
|
||||
** against multiple definition of wchar_t.
|
||||
*/
|
||||
#ifdef _BSD_WCHAR_T_DEFINED_
|
||||
#define _WCHAR_T
|
||||
#endif
|
||||
|
||||
/* the following define is necessary for OS X 10.6; without it, the
|
||||
Apple-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python
|
||||
can't get at the WINDOW flags field. */
|
||||
#define NCURSES_OPAQUE 0
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
/*
|
||||
** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards
|
||||
** against multiple definition of wchar_t and wint_t.
|
||||
*/
|
||||
#ifdef _XOPEN_SOURCE_EXTENDED
|
||||
#ifndef __FreeBSD_version
|
||||
#include <osreldate.h>
|
||||
#endif
|
||||
#if __FreeBSD_version >= 500000
|
||||
#ifndef __wchar_t
|
||||
#define __wchar_t
|
||||
#endif
|
||||
#ifndef __wint_t
|
||||
#define __wint_t
|
||||
#endif
|
||||
#else
|
||||
#ifndef _WCHAR_T
|
||||
#define _WCHAR_T
|
||||
#endif
|
||||
#ifndef _WINT_T
|
||||
#define _WINT_T
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#ifdef HAVE_TERM_H
|
||||
/* for tigetstr, which is not declared in SysV curses */
|
||||
#include <term.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NCURSES_H
|
||||
/* configure was checking <curses.h>, but we will
|
||||
use <ncurses.h>, which has all these features. */
|
||||
#ifndef WINDOW_HAS_FLAGS
|
||||
#define WINDOW_HAS_FLAGS 1
|
||||
#endif
|
||||
#ifndef MVWDELCH_IS_EXPRESSION
|
||||
#define MVWDELCH_IS_EXPRESSION 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PyCurses_API_pointers 4
|
||||
|
||||
/* Type declarations */
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
WINDOW *win;
|
||||
} PyCursesWindowObject;
|
||||
|
||||
#define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type)
|
||||
|
||||
#define PyCurses_CAPSULE_NAME "_curses._C_API"
|
||||
|
||||
|
||||
#ifdef CURSES_MODULE
|
||||
/* This section is used when compiling _cursesmodule.c */
|
||||
|
||||
#else
|
||||
/* This section is used in modules that use the _cursesmodule API */
|
||||
|
||||
static void **PyCurses_API;
|
||||
|
||||
#define PyCursesWindow_Type (*(PyTypeObject *) PyCurses_API[0])
|
||||
#define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;}
|
||||
#define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;}
|
||||
#define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;}
|
||||
|
||||
#define import_curses() \
|
||||
PyCurses_API = (void **)PyCapsule_Import(PyCurses_CAPSULE_NAME, 1);
|
||||
|
||||
#endif
|
||||
|
||||
/* general error messages */
|
||||
static char *catchall_ERR = "curses function returned ERR";
|
||||
static char *catchall_NULL = "curses function returned NULL";
|
||||
|
||||
/* Function Prototype Macros - They are ugly but very, very useful. ;-)
|
||||
|
||||
X - function name
|
||||
TYPE - parameter Type
|
||||
ERGSTR - format string for construction of the return value
|
||||
PARSESTR - format string for argument parsing
|
||||
*/
|
||||
|
||||
#define NoArgNoReturnFunction(X) \
|
||||
static PyObject *PyCurses_ ## X (PyObject *self) \
|
||||
{ \
|
||||
PyCursesInitialised \
|
||||
return PyCursesCheckERR(X(), # X); }
|
||||
|
||||
#define NoArgOrFlagNoReturnFunction(X) \
|
||||
static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \
|
||||
{ \
|
||||
int flag = 0; \
|
||||
PyCursesInitialised \
|
||||
switch(PyTuple_Size(args)) { \
|
||||
case 0: \
|
||||
return PyCursesCheckERR(X(), # X); \
|
||||
case 1: \
|
||||
if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL; \
|
||||
if (flag) return PyCursesCheckERR(X(), # X); \
|
||||
else return PyCursesCheckERR(no ## X (), # X); \
|
||||
default: \
|
||||
PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \
|
||||
return NULL; } }
|
||||
|
||||
#define NoArgReturnIntFunction(X) \
|
||||
static PyObject *PyCurses_ ## X (PyObject *self) \
|
||||
{ \
|
||||
PyCursesInitialised \
|
||||
return PyInt_FromLong((long) X()); }
|
||||
|
||||
|
||||
#define NoArgReturnStringFunction(X) \
|
||||
static PyObject *PyCurses_ ## X (PyObject *self) \
|
||||
{ \
|
||||
PyCursesInitialised \
|
||||
return PyString_FromString(X()); }
|
||||
|
||||
#define NoArgTrueFalseFunction(X) \
|
||||
static PyObject *PyCurses_ ## X (PyObject *self) \
|
||||
{ \
|
||||
PyCursesInitialised \
|
||||
if (X () == FALSE) { \
|
||||
Py_INCREF(Py_False); \
|
||||
return Py_False; \
|
||||
} \
|
||||
Py_INCREF(Py_True); \
|
||||
return Py_True; }
|
||||
|
||||
#define NoArgNoReturnVoidFunction(X) \
|
||||
static PyObject *PyCurses_ ## X (PyObject *self) \
|
||||
{ \
|
||||
PyCursesInitialised \
|
||||
X(); \
|
||||
Py_INCREF(Py_None); \
|
||||
return Py_None; }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !defined(Py_CURSES_H) */
|
||||
|
||||
|
62
c/meterpreter/source/extensions/python/Include/pyarena.h
Normal file
62
c/meterpreter/source/extensions/python/Include/pyarena.h
Normal file
@ -0,0 +1,62 @@
|
||||
/* An arena-like memory interface for the compiler.
|
||||
*/
|
||||
|
||||
#ifndef Py_PYARENA_H
|
||||
#define Py_PYARENA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _arena PyArena;
|
||||
|
||||
/* PyArena_New() and PyArena_Free() create a new arena and free it,
|
||||
respectively. Once an arena has been created, it can be used
|
||||
to allocate memory via PyArena_Malloc(). Pointers to PyObject can
|
||||
also be registered with the arena via PyArena_AddPyObject(), and the
|
||||
arena will ensure that the PyObjects stay alive at least until
|
||||
PyArena_Free() is called. When an arena is freed, all the memory it
|
||||
allocated is freed, the arena releases internal references to registered
|
||||
PyObject*, and none of its pointers are valid.
|
||||
XXX (tim) What does "none of its pointers are valid" mean? Does it
|
||||
XXX mean that pointers previously obtained via PyArena_Malloc() are
|
||||
XXX no longer valid? (That's clearly true, but not sure that's what
|
||||
XXX the text is trying to say.)
|
||||
|
||||
PyArena_New() returns an arena pointer. On error, it
|
||||
returns a negative number and sets an exception.
|
||||
XXX (tim): Not true. On error, PyArena_New() actually returns NULL,
|
||||
XXX and looks like it may or may not set an exception (e.g., if the
|
||||
XXX internal PyList_New(0) returns NULL, PyArena_New() passes that on
|
||||
XXX and an exception is set; OTOH, if the internal
|
||||
XXX block_new(DEFAULT_BLOCK_SIZE) returns NULL, that's passed on but
|
||||
XXX an exception is not set in that case).
|
||||
*/
|
||||
PyAPI_FUNC(PyArena *) PyArena_New(void);
|
||||
PyAPI_FUNC(void) PyArena_Free(PyArena *);
|
||||
|
||||
/* Mostly like malloc(), return the address of a block of memory spanning
|
||||
* `size` bytes, or return NULL (without setting an exception) if enough
|
||||
* new memory can't be obtained. Unlike malloc(0), PyArena_Malloc() with
|
||||
* size=0 does not guarantee to return a unique pointer (the pointer
|
||||
* returned may equal one or more other pointers obtained from
|
||||
* PyArena_Malloc()).
|
||||
* Note that pointers obtained via PyArena_Malloc() must never be passed to
|
||||
* the system free() or realloc(), or to any of Python's similar memory-
|
||||
* management functions. PyArena_Malloc()-obtained pointers remain valid
|
||||
* until PyArena_Free(ar) is called, at which point all pointers obtained
|
||||
* from the arena `ar` become invalid simultaneously.
|
||||
*/
|
||||
PyAPI_FUNC(void *) PyArena_Malloc(PyArena *, size_t size);
|
||||
|
||||
/* This routine isn't a proper arena allocation routine. It takes
|
||||
* a PyObject* and records it so that it can be DECREFed when the
|
||||
* arena is freed.
|
||||
*/
|
||||
PyAPI_FUNC(int) PyArena_AddPyObject(PyArena *, PyObject *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !Py_PYARENA_H */
|
56
c/meterpreter/source/extensions/python/Include/pycapsule.h
Normal file
56
c/meterpreter/source/extensions/python/Include/pycapsule.h
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
/* Capsule objects let you wrap a C "void *" pointer in a Python
|
||||
object. They're a way of passing data through the Python interpreter
|
||||
without creating your own custom type.
|
||||
|
||||
Capsules are used for communication between extension modules.
|
||||
They provide a way for an extension module to export a C interface
|
||||
to other extension modules, so that extension modules can use the
|
||||
Python import mechanism to link to one another.
|
||||
|
||||
For more information, please see "c-api/capsule.html" in the
|
||||
documentation.
|
||||
*/
|
||||
|
||||
#ifndef Py_CAPSULE_H
|
||||
#define Py_CAPSULE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCapsule_Type;
|
||||
|
||||
typedef void (*PyCapsule_Destructor)(PyObject *);
|
||||
|
||||
#define PyCapsule_CheckExact(op) (Py_TYPE(op) == &PyCapsule_Type)
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCapsule_New(
|
||||
void *pointer,
|
||||
const char *name,
|
||||
PyCapsule_Destructor destructor);
|
||||
|
||||
PyAPI_FUNC(void *) PyCapsule_GetPointer(PyObject *capsule, const char *name);
|
||||
|
||||
PyAPI_FUNC(PyCapsule_Destructor) PyCapsule_GetDestructor(PyObject *capsule);
|
||||
|
||||
PyAPI_FUNC(const char *) PyCapsule_GetName(PyObject *capsule);
|
||||
|
||||
PyAPI_FUNC(void *) PyCapsule_GetContext(PyObject *capsule);
|
||||
|
||||
PyAPI_FUNC(int) PyCapsule_IsValid(PyObject *capsule, const char *name);
|
||||
|
||||
PyAPI_FUNC(int) PyCapsule_SetPointer(PyObject *capsule, void *pointer);
|
||||
|
||||
PyAPI_FUNC(int) PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor);
|
||||
|
||||
PyAPI_FUNC(int) PyCapsule_SetName(PyObject *capsule, const char *name);
|
||||
|
||||
PyAPI_FUNC(int) PyCapsule_SetContext(PyObject *capsule, void *context);
|
||||
|
||||
PyAPI_FUNC(void *) PyCapsule_Import(const char *name, int no_block);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_CAPSULE_H */
|
31
c/meterpreter/source/extensions/python/Include/pyctype.h
Normal file
31
c/meterpreter/source/extensions/python/Include/pyctype.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef PYCTYPE_H
|
||||
#define PYCTYPE_H
|
||||
|
||||
#define PY_CTF_LOWER 0x01
|
||||
#define PY_CTF_UPPER 0x02
|
||||
#define PY_CTF_ALPHA (PY_CTF_LOWER|PY_CTF_UPPER)
|
||||
#define PY_CTF_DIGIT 0x04
|
||||
#define PY_CTF_ALNUM (PY_CTF_ALPHA|PY_CTF_DIGIT)
|
||||
#define PY_CTF_SPACE 0x08
|
||||
#define PY_CTF_XDIGIT 0x10
|
||||
|
||||
PyAPI_DATA(const unsigned int) _Py_ctype_table[256];
|
||||
|
||||
/* Unlike their C counterparts, the following macros are not meant to
|
||||
* handle an int with any of the values [EOF, 0-UCHAR_MAX]. The argument
|
||||
* must be a signed/unsigned char. */
|
||||
#define Py_ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER)
|
||||
#define Py_ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_UPPER)
|
||||
#define Py_ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALPHA)
|
||||
#define Py_ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_DIGIT)
|
||||
#define Py_ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_XDIGIT)
|
||||
#define Py_ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALNUM)
|
||||
#define Py_ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_SPACE)
|
||||
|
||||
PyAPI_DATA(const unsigned char) _Py_ctype_tolower[256];
|
||||
PyAPI_DATA(const unsigned char) _Py_ctype_toupper[256];
|
||||
|
||||
#define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)])
|
||||
#define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)])
|
||||
|
||||
#endif /* !PYCTYPE_H */
|
41
c/meterpreter/source/extensions/python/Include/pydebug.h
Normal file
41
c/meterpreter/source/extensions/python/Include/pydebug.h
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
#ifndef Py_PYDEBUG_H
|
||||
#define Py_PYDEBUG_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(int) Py_DebugFlag;
|
||||
PyAPI_DATA(int) Py_VerboseFlag;
|
||||
PyAPI_DATA(int) Py_InteractiveFlag;
|
||||
PyAPI_DATA(int) Py_InspectFlag;
|
||||
PyAPI_DATA(int) Py_OptimizeFlag;
|
||||
PyAPI_DATA(int) Py_NoSiteFlag;
|
||||
PyAPI_DATA(int) Py_BytesWarningFlag;
|
||||
PyAPI_DATA(int) Py_UseClassExceptionsFlag;
|
||||
PyAPI_DATA(int) Py_FrozenFlag;
|
||||
PyAPI_DATA(int) Py_TabcheckFlag;
|
||||
PyAPI_DATA(int) Py_UnicodeFlag;
|
||||
PyAPI_DATA(int) Py_IgnoreEnvironmentFlag;
|
||||
PyAPI_DATA(int) Py_DivisionWarningFlag;
|
||||
PyAPI_DATA(int) Py_DontWriteBytecodeFlag;
|
||||
PyAPI_DATA(int) Py_NoUserSiteDirectory;
|
||||
/* _XXX Py_QnewFlag should go away in 3.0. It's true iff -Qnew is passed,
|
||||
on the command line, and is used in 2.2 by ceval.c to make all "/" divisions
|
||||
true divisions (which they will be in 3.0). */
|
||||
PyAPI_DATA(int) _Py_QnewFlag;
|
||||
/* Warn about 3.x issues */
|
||||
PyAPI_DATA(int) Py_Py3kWarningFlag;
|
||||
PyAPI_DATA(int) Py_HashRandomizationFlag;
|
||||
|
||||
/* this is a wrapper around getenv() that pays attention to
|
||||
Py_IgnoreEnvironmentFlag. It should be used for getting variables like
|
||||
PYTHONPATH and PYTHONHOME from the environment */
|
||||
#define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s))
|
||||
|
||||
PyAPI_FUNC(void) Py_FatalError(const char *message);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_PYDEBUG_H */
|
329
c/meterpreter/source/extensions/python/Include/pyerrors.h
Normal file
329
c/meterpreter/source/extensions/python/Include/pyerrors.h
Normal file
@ -0,0 +1,329 @@
|
||||
#ifndef Py_ERRORS_H
|
||||
#define Py_ERRORS_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Error objects */
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *dict;
|
||||
PyObject *args;
|
||||
PyObject *message;
|
||||
} PyBaseExceptionObject;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *dict;
|
||||
PyObject *args;
|
||||
PyObject *message;
|
||||
PyObject *msg;
|
||||
PyObject *filename;
|
||||
PyObject *lineno;
|
||||
PyObject *offset;
|
||||
PyObject *text;
|
||||
PyObject *print_file_and_line;
|
||||
} PySyntaxErrorObject;
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *dict;
|
||||
PyObject *args;
|
||||
PyObject *message;
|
||||
PyObject *encoding;
|
||||
PyObject *object;
|
||||
Py_ssize_t start;
|
||||
Py_ssize_t end;
|
||||
PyObject *reason;
|
||||
} PyUnicodeErrorObject;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *dict;
|
||||
PyObject *args;
|
||||
PyObject *message;
|
||||
PyObject *code;
|
||||
} PySystemExitObject;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *dict;
|
||||
PyObject *args;
|
||||
PyObject *message;
|
||||
PyObject *myerrno;
|
||||
PyObject *strerror;
|
||||
PyObject *filename;
|
||||
} PyEnvironmentErrorObject;
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *dict;
|
||||
PyObject *args;
|
||||
PyObject *message;
|
||||
PyObject *myerrno;
|
||||
PyObject *strerror;
|
||||
PyObject *filename;
|
||||
PyObject *winerror;
|
||||
} PyWindowsErrorObject;
|
||||
#endif
|
||||
|
||||
/* Error handling definitions */
|
||||
|
||||
PyAPI_FUNC(void) PyErr_SetNone(PyObject *);
|
||||
PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(void) PyErr_SetString(PyObject *, const char *);
|
||||
PyAPI_FUNC(PyObject *) PyErr_Occurred(void);
|
||||
PyAPI_FUNC(void) PyErr_Clear(void);
|
||||
PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **);
|
||||
PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *);
|
||||
|
||||
#ifdef Py_DEBUG
|
||||
#define _PyErr_OCCURRED() PyErr_Occurred()
|
||||
#else
|
||||
#define _PyErr_OCCURRED() (_PyThreadState_Current->curexc_type)
|
||||
#endif
|
||||
|
||||
/* Error testing and normalization */
|
||||
PyAPI_FUNC(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int) PyErr_ExceptionMatches(PyObject *);
|
||||
PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**);
|
||||
PyAPI_FUNC(void) _PyErr_ReplaceException(PyObject *, PyObject *, PyObject *);
|
||||
|
||||
/* */
|
||||
|
||||
#define PyExceptionClass_Check(x) \
|
||||
(PyClass_Check((x)) || (PyType_Check((x)) && \
|
||||
PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS)))
|
||||
|
||||
#define PyExceptionInstance_Check(x) \
|
||||
(PyInstance_Check((x)) || \
|
||||
PyType_FastSubclass((x)->ob_type, Py_TPFLAGS_BASE_EXC_SUBCLASS))
|
||||
|
||||
#define PyExceptionClass_Name(x) \
|
||||
(PyClass_Check((x)) \
|
||||
? PyString_AS_STRING(((PyClassObject*)(x))->cl_name) \
|
||||
: (char *)(((PyTypeObject*)(x))->tp_name))
|
||||
|
||||
#define PyExceptionInstance_Class(x) \
|
||||
((PyInstance_Check((x)) \
|
||||
? (PyObject*)((PyInstanceObject*)(x))->in_class \
|
||||
: (PyObject*)((x)->ob_type)))
|
||||
|
||||
|
||||
/* Predefined exceptions */
|
||||
|
||||
PyAPI_DATA(PyObject *) PyExc_BaseException;
|
||||
PyAPI_DATA(PyObject *) PyExc_Exception;
|
||||
PyAPI_DATA(PyObject *) PyExc_StopIteration;
|
||||
PyAPI_DATA(PyObject *) PyExc_GeneratorExit;
|
||||
PyAPI_DATA(PyObject *) PyExc_StandardError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ArithmeticError;
|
||||
PyAPI_DATA(PyObject *) PyExc_LookupError;
|
||||
|
||||
PyAPI_DATA(PyObject *) PyExc_AssertionError;
|
||||
PyAPI_DATA(PyObject *) PyExc_AttributeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_EOFError;
|
||||
PyAPI_DATA(PyObject *) PyExc_FloatingPointError;
|
||||
PyAPI_DATA(PyObject *) PyExc_EnvironmentError;
|
||||
PyAPI_DATA(PyObject *) PyExc_IOError;
|
||||
PyAPI_DATA(PyObject *) PyExc_OSError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ImportError;
|
||||
PyAPI_DATA(PyObject *) PyExc_IndexError;
|
||||
PyAPI_DATA(PyObject *) PyExc_KeyError;
|
||||
PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt;
|
||||
PyAPI_DATA(PyObject *) PyExc_MemoryError;
|
||||
PyAPI_DATA(PyObject *) PyExc_NameError;
|
||||
PyAPI_DATA(PyObject *) PyExc_OverflowError;
|
||||
PyAPI_DATA(PyObject *) PyExc_RuntimeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_NotImplementedError;
|
||||
PyAPI_DATA(PyObject *) PyExc_SyntaxError;
|
||||
PyAPI_DATA(PyObject *) PyExc_IndentationError;
|
||||
PyAPI_DATA(PyObject *) PyExc_TabError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ReferenceError;
|
||||
PyAPI_DATA(PyObject *) PyExc_SystemError;
|
||||
PyAPI_DATA(PyObject *) PyExc_SystemExit;
|
||||
PyAPI_DATA(PyObject *) PyExc_TypeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnboundLocalError;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnicodeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ValueError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError;
|
||||
#ifdef MS_WINDOWS
|
||||
PyAPI_DATA(PyObject *) PyExc_WindowsError;
|
||||
#endif
|
||||
#ifdef __VMS
|
||||
PyAPI_DATA(PyObject *) PyExc_VMSError;
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyObject *) PyExc_BufferError;
|
||||
|
||||
PyAPI_DATA(PyObject *) PyExc_MemoryErrorInst;
|
||||
PyAPI_DATA(PyObject *) PyExc_RecursionErrorInst;
|
||||
|
||||
/* Predefined warning categories */
|
||||
PyAPI_DATA(PyObject *) PyExc_Warning;
|
||||
PyAPI_DATA(PyObject *) PyExc_UserWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_DeprecationWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_SyntaxWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_RuntimeWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_FutureWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_ImportWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnicodeWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_BytesWarning;
|
||||
|
||||
|
||||
/* Convenience functions */
|
||||
|
||||
PyAPI_FUNC(int) PyErr_BadArgument(void);
|
||||
PyAPI_FUNC(PyObject *) PyErr_NoMemory(void);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject(
|
||||
PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(
|
||||
PyObject *, const char *);
|
||||
#ifdef MS_WINDOWS
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
|
||||
PyObject *, const Py_UNICODE *);
|
||||
#endif /* MS_WINDOWS */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyErr_Format(PyObject *, const char *, ...)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 2, 3)));
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenameObject(
|
||||
int, const char *);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
|
||||
int, const char *);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
|
||||
int, const Py_UNICODE *);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
|
||||
PyObject *,int, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
|
||||
PyObject *,int, const char *);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
|
||||
PyObject *,int, const Py_UNICODE *);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
|
||||
#endif /* MS_WINDOWS */
|
||||
|
||||
/* Export the old function so that the existing API remains available: */
|
||||
PyAPI_FUNC(void) PyErr_BadInternalCall(void);
|
||||
PyAPI_FUNC(void) _PyErr_BadInternalCall(char *filename, int lineno);
|
||||
/* Mask the old API with a call to the new API for code compiled under
|
||||
Python 2.0: */
|
||||
#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
|
||||
|
||||
/* Function to create a new exception */
|
||||
PyAPI_FUNC(PyObject *) PyErr_NewException(
|
||||
char *name, PyObject *base, PyObject *dict);
|
||||
PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc(
|
||||
char *name, char *doc, PyObject *base, PyObject *dict);
|
||||
PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *);
|
||||
|
||||
/* In sigcheck.c or signalmodule.c */
|
||||
PyAPI_FUNC(int) PyErr_CheckSignals(void);
|
||||
PyAPI_FUNC(void) PyErr_SetInterrupt(void);
|
||||
|
||||
/* In signalmodule.c */
|
||||
int PySignal_SetWakeupFd(int fd);
|
||||
|
||||
/* Support for adding program text to SyntaxErrors */
|
||||
PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int);
|
||||
PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int);
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
/* The following functions are used to create and modify unicode
|
||||
exceptions from C */
|
||||
|
||||
/* create a UnicodeDecodeError object */
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(
|
||||
const char *, const char *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
|
||||
|
||||
/* create a UnicodeEncodeError object */
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
|
||||
const char *, const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
|
||||
|
||||
/* create a UnicodeTranslateError object */
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
|
||||
const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
|
||||
|
||||
/* get the encoding attribute */
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *);
|
||||
|
||||
/* get the object attribute */
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *);
|
||||
|
||||
/* get the value of the start attribute (the int * may not be NULL)
|
||||
return 0 on success, -1 on failure */
|
||||
PyAPI_FUNC(int) PyUnicodeEncodeError_GetStart(PyObject *, Py_ssize_t *);
|
||||
PyAPI_FUNC(int) PyUnicodeDecodeError_GetStart(PyObject *, Py_ssize_t *);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_GetStart(PyObject *, Py_ssize_t *);
|
||||
|
||||
/* assign a new value to the start attribute
|
||||
return 0 on success, -1 on failure */
|
||||
PyAPI_FUNC(int) PyUnicodeEncodeError_SetStart(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyUnicodeDecodeError_SetStart(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_SetStart(PyObject *, Py_ssize_t);
|
||||
|
||||
/* get the value of the end attribute (the int *may not be NULL)
|
||||
return 0 on success, -1 on failure */
|
||||
PyAPI_FUNC(int) PyUnicodeEncodeError_GetEnd(PyObject *, Py_ssize_t *);
|
||||
PyAPI_FUNC(int) PyUnicodeDecodeError_GetEnd(PyObject *, Py_ssize_t *);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_GetEnd(PyObject *, Py_ssize_t *);
|
||||
|
||||
/* assign a new value to the end attribute
|
||||
return 0 on success, -1 on failure */
|
||||
PyAPI_FUNC(int) PyUnicodeEncodeError_SetEnd(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyUnicodeDecodeError_SetEnd(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_SetEnd(PyObject *, Py_ssize_t);
|
||||
|
||||
/* get the value of the reason attribute */
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetReason(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetReason(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *);
|
||||
|
||||
/* assign a new value to the reason attribute
|
||||
return 0 on success, -1 on failure */
|
||||
PyAPI_FUNC(int) PyUnicodeEncodeError_SetReason(
|
||||
PyObject *, const char *);
|
||||
PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason(
|
||||
PyObject *, const char *);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
|
||||
PyObject *, const char *);
|
||||
#endif
|
||||
|
||||
|
||||
/* These APIs aren't really part of the error implementation, but
|
||||
often needed to format error messages; the native C lib APIs are
|
||||
not available on all platforms, which is why we provide emulations
|
||||
for those platforms in Python/mysnprintf.c,
|
||||
WARNING: The return value of snprintf varies across platforms; do
|
||||
not rely on any particular behavior; eventually the C99 defn may
|
||||
be reliable.
|
||||
*/
|
||||
#if defined(MS_WIN32) && !defined(HAVE_SNPRINTF)
|
||||
# define HAVE_SNPRINTF
|
||||
# define snprintf _snprintf
|
||||
# define vsnprintf _vsnprintf
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 3, 4)));
|
||||
PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 3, 0)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_ERRORS_H */
|
48
c/meterpreter/source/extensions/python/Include/pyexpat.h
Normal file
48
c/meterpreter/source/extensions/python/Include/pyexpat.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* Stuff to export relevant 'expat' entry points from pyexpat to other
|
||||
* parser modules, such as cElementTree. */
|
||||
|
||||
/* note: you must import expat.h before importing this module! */
|
||||
|
||||
#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.0"
|
||||
#define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI"
|
||||
|
||||
struct PyExpat_CAPI
|
||||
{
|
||||
char* magic; /* set to PyExpat_CAPI_MAGIC */
|
||||
int size; /* set to sizeof(struct PyExpat_CAPI) */
|
||||
int MAJOR_VERSION;
|
||||
int MINOR_VERSION;
|
||||
int MICRO_VERSION;
|
||||
/* pointers to selected expat functions. add new functions at
|
||||
the end, if needed */
|
||||
const XML_LChar * (*ErrorString)(enum XML_Error code);
|
||||
enum XML_Error (*GetErrorCode)(XML_Parser parser);
|
||||
XML_Size (*GetErrorColumnNumber)(XML_Parser parser);
|
||||
XML_Size (*GetErrorLineNumber)(XML_Parser parser);
|
||||
enum XML_Status (*Parse)(
|
||||
XML_Parser parser, const char *s, int len, int isFinal);
|
||||
XML_Parser (*ParserCreate_MM)(
|
||||
const XML_Char *encoding, const XML_Memory_Handling_Suite *memsuite,
|
||||
const XML_Char *namespaceSeparator);
|
||||
void (*ParserFree)(XML_Parser parser);
|
||||
void (*SetCharacterDataHandler)(
|
||||
XML_Parser parser, XML_CharacterDataHandler handler);
|
||||
void (*SetCommentHandler)(
|
||||
XML_Parser parser, XML_CommentHandler handler);
|
||||
void (*SetDefaultHandlerExpand)(
|
||||
XML_Parser parser, XML_DefaultHandler handler);
|
||||
void (*SetElementHandler)(
|
||||
XML_Parser parser, XML_StartElementHandler start,
|
||||
XML_EndElementHandler end);
|
||||
void (*SetNamespaceDeclHandler)(
|
||||
XML_Parser parser, XML_StartNamespaceDeclHandler start,
|
||||
XML_EndNamespaceDeclHandler end);
|
||||
void (*SetProcessingInstructionHandler)(
|
||||
XML_Parser parser, XML_ProcessingInstructionHandler handler);
|
||||
void (*SetUnknownEncodingHandler)(
|
||||
XML_Parser parser, XML_UnknownEncodingHandler handler,
|
||||
void *encodingHandlerData);
|
||||
void (*SetUserData)(XML_Parser parser, void *userData);
|
||||
/* always add new stuff to the end! */
|
||||
};
|
||||
|
176
c/meterpreter/source/extensions/python/Include/pyfpe.h
Normal file
176
c/meterpreter/source/extensions/python/Include/pyfpe.h
Normal file
@ -0,0 +1,176 @@
|
||||
#ifndef Py_PYFPE_H
|
||||
#define Py_PYFPE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
---------------------------------------------------------------------
|
||||
/ Copyright (c) 1996. \
|
||||
| The Regents of the University of California. |
|
||||
| All rights reserved. |
|
||||
| |
|
||||
| Permission to use, copy, modify, and distribute this software for |
|
||||
| any purpose without fee is hereby granted, provided that this en- |
|
||||
| tire notice is included in all copies of any software which is or |
|
||||
| includes a copy or modification of this software and in all |
|
||||
| copies of the supporting documentation for such software. |
|
||||
| |
|
||||
| This work was produced at the University of California, Lawrence |
|
||||
| Livermore National Laboratory under contract no. W-7405-ENG-48 |
|
||||
| between the U.S. Department of Energy and The Regents of the |
|
||||
| University of California for the operation of UC LLNL. |
|
||||
| |
|
||||
| DISCLAIMER |
|
||||
| |
|
||||
| This software was prepared as an account of work sponsored by an |
|
||||
| agency of the United States Government. Neither the United States |
|
||||
| Government nor the University of California nor any of their em- |
|
||||
| ployees, makes any warranty, express or implied, or assumes any |
|
||||
| liability or responsibility for the accuracy, completeness, or |
|
||||
| usefulness of any information, apparatus, product, or process |
|
||||
| disclosed, or represents that its use would not infringe |
|
||||
| privately-owned rights. Reference herein to any specific commer- |
|
||||
| cial products, process, or service by trade name, trademark, |
|
||||
| manufacturer, or otherwise, does not necessarily constitute or |
|
||||
| imply its endorsement, recommendation, or favoring by the United |
|
||||
| States Government or the University of California. The views and |
|
||||
| opinions of authors expressed herein do not necessarily state or |
|
||||
| reflect those of the United States Government or the University |
|
||||
| of California, and shall not be used for advertising or product |
|
||||
\ endorsement purposes. /
|
||||
---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* Define macros for handling SIGFPE.
|
||||
* Lee Busby, LLNL, November, 1996
|
||||
* busby1@llnl.gov
|
||||
*
|
||||
*********************************************
|
||||
* Overview of the system for handling SIGFPE:
|
||||
*
|
||||
* This file (Include/pyfpe.h) defines a couple of "wrapper" macros for
|
||||
* insertion into your Python C code of choice. Their proper use is
|
||||
* discussed below. The file Python/pyfpe.c defines a pair of global
|
||||
* variables PyFPE_jbuf and PyFPE_counter which are used by the signal
|
||||
* handler for SIGFPE to decide if a particular exception was protected
|
||||
* by the macros. The signal handler itself, and code for enabling the
|
||||
* generation of SIGFPE in the first place, is in a (new) Python module
|
||||
* named fpectl. This module is standard in every respect. It can be loaded
|
||||
* either statically or dynamically as you choose, and like any other
|
||||
* Python module, has no effect until you import it.
|
||||
*
|
||||
* In the general case, there are three steps toward handling SIGFPE in any
|
||||
* Python code:
|
||||
*
|
||||
* 1) Add the *_PROTECT macros to your C code as required to protect
|
||||
* dangerous floating point sections.
|
||||
*
|
||||
* 2) Turn on the inclusion of the code by adding the ``--with-fpectl''
|
||||
* flag at the time you run configure. If the fpectl or other modules
|
||||
* which use the *_PROTECT macros are to be dynamically loaded, be
|
||||
* sure they are compiled with WANT_SIGFPE_HANDLER defined.
|
||||
*
|
||||
* 3) When python is built and running, import fpectl, and execute
|
||||
* fpectl.turnon_sigfpe(). This sets up the signal handler and enables
|
||||
* generation of SIGFPE whenever an exception occurs. From this point
|
||||
* on, any properly trapped SIGFPE should result in the Python
|
||||
* FloatingPointError exception.
|
||||
*
|
||||
* Step 1 has been done already for the Python kernel code, and should be
|
||||
* done soon for the NumPy array package. Step 2 is usually done once at
|
||||
* python install time. Python's behavior with respect to SIGFPE is not
|
||||
* changed unless you also do step 3. Thus you can control this new
|
||||
* facility at compile time, or run time, or both.
|
||||
*
|
||||
********************************
|
||||
* Using the macros in your code:
|
||||
*
|
||||
* static PyObject *foobar(PyObject *self,PyObject *args)
|
||||
* {
|
||||
* ....
|
||||
* PyFPE_START_PROTECT("Error in foobar", return 0)
|
||||
* result = dangerous_op(somearg1, somearg2, ...);
|
||||
* PyFPE_END_PROTECT(result)
|
||||
* ....
|
||||
* }
|
||||
*
|
||||
* If a floating point error occurs in dangerous_op, foobar returns 0 (NULL),
|
||||
* after setting the associated value of the FloatingPointError exception to
|
||||
* "Error in foobar". ``Dangerous_op'' can be a single operation, or a block
|
||||
* of code, function calls, or any combination, so long as no alternate
|
||||
* return is possible before the PyFPE_END_PROTECT macro is reached.
|
||||
*
|
||||
* The macros can only be used in a function context where an error return
|
||||
* can be recognized as signaling a Python exception. (Generally, most
|
||||
* functions that return a PyObject * will qualify.)
|
||||
*
|
||||
* Guido's original design suggestion for PyFPE_START_PROTECT and
|
||||
* PyFPE_END_PROTECT had them open and close a local block, with a locally
|
||||
* defined jmp_buf and jmp_buf pointer. This would allow recursive nesting
|
||||
* of the macros. The Ansi C standard makes it clear that such local
|
||||
* variables need to be declared with the "volatile" type qualifier to keep
|
||||
* setjmp from corrupting their values. Some current implementations seem
|
||||
* to be more restrictive. For example, the HPUX man page for setjmp says
|
||||
*
|
||||
* Upon the return from a setjmp() call caused by a longjmp(), the
|
||||
* values of any non-static local variables belonging to the routine
|
||||
* from which setjmp() was called are undefined. Code which depends on
|
||||
* such values is not guaranteed to be portable.
|
||||
*
|
||||
* I therefore decided on a more limited form of nesting, using a counter
|
||||
* variable (PyFPE_counter) to keep track of any recursion. If an exception
|
||||
* occurs in an ``inner'' pair of macros, the return will apparently
|
||||
* come from the outermost level.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef WANT_SIGFPE_HANDLER
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
#include <math.h>
|
||||
extern jmp_buf PyFPE_jbuf;
|
||||
extern int PyFPE_counter;
|
||||
extern double PyFPE_dummy(void *);
|
||||
|
||||
#define PyFPE_START_PROTECT(err_string, leave_stmt) \
|
||||
if (!PyFPE_counter++ && setjmp(PyFPE_jbuf)) { \
|
||||
PyErr_SetString(PyExc_FloatingPointError, err_string); \
|
||||
PyFPE_counter = 0; \
|
||||
leave_stmt; \
|
||||
}
|
||||
|
||||
/*
|
||||
* This (following) is a heck of a way to decrement a counter. However,
|
||||
* unless the macro argument is provided, code optimizers will sometimes move
|
||||
* this statement so that it gets executed *before* the unsafe expression
|
||||
* which we're trying to protect. That pretty well messes things up,
|
||||
* of course.
|
||||
*
|
||||
* If the expression(s) you're trying to protect don't happen to return a
|
||||
* value, you will need to manufacture a dummy result just to preserve the
|
||||
* correct ordering of statements. Note that the macro passes the address
|
||||
* of its argument (so you need to give it something which is addressable).
|
||||
* If your expression returns multiple results, pass the last such result
|
||||
* to PyFPE_END_PROTECT.
|
||||
*
|
||||
* Note that PyFPE_dummy returns a double, which is cast to int.
|
||||
* This seeming insanity is to tickle the Floating Point Unit (FPU).
|
||||
* If an exception has occurred in a preceding floating point operation,
|
||||
* some architectures (notably Intel 80x86) will not deliver the interrupt
|
||||
* until the *next* floating point operation. This is painful if you've
|
||||
* already decremented PyFPE_counter.
|
||||
*/
|
||||
#define PyFPE_END_PROTECT(v) PyFPE_counter -= (int)PyFPE_dummy(&(v));
|
||||
|
||||
#else
|
||||
|
||||
#define PyFPE_START_PROTECT(err_string, leave_stmt)
|
||||
#define PyFPE_END_PROTECT(v)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_PYFPE_H */
|
18
c/meterpreter/source/extensions/python/Include/pygetopt.h
Normal file
18
c/meterpreter/source/extensions/python/Include/pygetopt.h
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
#ifndef Py_PYGETOPT_H
|
||||
#define Py_PYGETOPT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(int) _PyOS_opterr;
|
||||
PyAPI_DATA(int) _PyOS_optind;
|
||||
PyAPI_DATA(char *) _PyOS_optarg;
|
||||
|
||||
PyAPI_FUNC(void) _PyOS_ResetGetOpt(void);
|
||||
PyAPI_FUNC(int) _PyOS_GetOpt(int argc, char **argv, char *optstring);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_PYGETOPT_H */
|
102
c/meterpreter/source/extensions/python/Include/pymacconfig.h
Normal file
102
c/meterpreter/source/extensions/python/Include/pymacconfig.h
Normal file
@ -0,0 +1,102 @@
|
||||
#ifndef PYMACCONFIG_H
|
||||
#define PYMACCONFIG_H
|
||||
/*
|
||||
* This file moves some of the autoconf magic to compile-time
|
||||
* when building on MacOSX. This is needed for building 4-way
|
||||
* universal binaries and for 64-bit universal binaries because
|
||||
* the values redefined below aren't configure-time constant but
|
||||
* only compile-time constant in these scenarios.
|
||||
*/
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
||||
# undef SIZEOF_LONG
|
||||
# undef SIZEOF_PTHREAD_T
|
||||
# undef SIZEOF_SIZE_T
|
||||
# undef SIZEOF_TIME_T
|
||||
# undef SIZEOF_VOID_P
|
||||
# undef SIZEOF__BOOL
|
||||
# undef SIZEOF_UINTPTR_T
|
||||
# undef SIZEOF_PTHREAD_T
|
||||
# undef WORDS_BIGENDIAN
|
||||
# undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754
|
||||
# undef DOUBLE_IS_BIG_ENDIAN_IEEE754
|
||||
# undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754
|
||||
# undef HAVE_GCC_ASM_FOR_X87
|
||||
|
||||
# undef VA_LIST_IS_ARRAY
|
||||
# if defined(__LP64__) && defined(__x86_64__)
|
||||
# define VA_LIST_IS_ARRAY 1
|
||||
# endif
|
||||
|
||||
# undef HAVE_LARGEFILE_SUPPORT
|
||||
# ifndef __LP64__
|
||||
# define HAVE_LARGEFILE_SUPPORT 1
|
||||
# endif
|
||||
|
||||
# undef SIZEOF_LONG
|
||||
# ifdef __LP64__
|
||||
# define SIZEOF__BOOL 1
|
||||
# define SIZEOF__BOOL 1
|
||||
# define SIZEOF_LONG 8
|
||||
# define SIZEOF_PTHREAD_T 8
|
||||
# define SIZEOF_SIZE_T 8
|
||||
# define SIZEOF_TIME_T 8
|
||||
# define SIZEOF_VOID_P 8
|
||||
# define SIZEOF_UINTPTR_T 8
|
||||
# define SIZEOF_PTHREAD_T 8
|
||||
# else
|
||||
# ifdef __ppc__
|
||||
# define SIZEOF__BOOL 4
|
||||
# else
|
||||
# define SIZEOF__BOOL 1
|
||||
# endif
|
||||
# define SIZEOF_LONG 4
|
||||
# define SIZEOF_PTHREAD_T 4
|
||||
# define SIZEOF_SIZE_T 4
|
||||
# define SIZEOF_TIME_T 4
|
||||
# define SIZEOF_VOID_P 4
|
||||
# define SIZEOF_UINTPTR_T 4
|
||||
# define SIZEOF_PTHREAD_T 4
|
||||
# endif
|
||||
|
||||
# if defined(__LP64__)
|
||||
/* MacOSX 10.4 (the first release to support 64-bit code
|
||||
* at all) only supports 64-bit in the UNIX layer.
|
||||
* Therefore surpress the toolbox-glue in 64-bit mode.
|
||||
*/
|
||||
|
||||
/* In 64-bit mode setpgrp always has no argments, in 32-bit
|
||||
* mode that depends on the compilation environment
|
||||
*/
|
||||
# undef SETPGRP_HAVE_ARG
|
||||
|
||||
# endif
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
#define WORDS_BIGENDIAN 1
|
||||
#define DOUBLE_IS_BIG_ENDIAN_IEEE754
|
||||
#else
|
||||
#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754
|
||||
#endif /* __BIG_ENDIAN */
|
||||
|
||||
#ifdef __i386__
|
||||
# define HAVE_GCC_ASM_FOR_X87
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The definition in pyconfig.h is only valid on the OS release
|
||||
* where configure ran on and not necessarily for all systems where
|
||||
* the executable can be used on.
|
||||
*
|
||||
* Specifically: OSX 10.4 has limited supported for '%zd', while
|
||||
* 10.5 has full support for '%zd'. A binary built on 10.5 won't
|
||||
* work properly on 10.4 unless we surpress the definition
|
||||
* of PY_FORMAT_SIZE_T
|
||||
*/
|
||||
#undef PY_FORMAT_SIZE_T
|
||||
|
||||
|
||||
#endif /* defined(_APPLE__) */
|
||||
|
||||
#endif /* PYMACCONFIG_H */
|
217
c/meterpreter/source/extensions/python/Include/pymactoolbox.h
Normal file
217
c/meterpreter/source/extensions/python/Include/pymactoolbox.h
Normal file
@ -0,0 +1,217 @@
|
||||
/*
|
||||
** pymactoolbox.h - globals defined in mactoolboxglue.c
|
||||
*/
|
||||
#ifndef Py_PYMACTOOLBOX_H
|
||||
#define Py_PYMACTOOLBOX_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
#ifndef __LP64__
|
||||
#include <QuickTime/QuickTime.h>
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/*
|
||||
** Helper routines for error codes and such.
|
||||
*/
|
||||
char *PyMac_StrError(int); /* strerror with mac errors */
|
||||
extern PyObject *PyMac_OSErrException; /* Exception for OSErr */
|
||||
PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */
|
||||
PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */
|
||||
PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */
|
||||
#ifndef __LP64__
|
||||
extern OSErr PyMac_GetFullPathname(FSSpec *, char *, int); /* convert
|
||||
fsspec->path */
|
||||
#endif /* __LP64__ */
|
||||
|
||||
/*
|
||||
** These conversion routines are defined in mactoolboxglue.c itself.
|
||||
*/
|
||||
int PyMac_GetOSType(PyObject *, OSType *); /* argument parser for OSType */
|
||||
PyObject *PyMac_BuildOSType(OSType); /* Convert OSType to PyObject */
|
||||
|
||||
PyObject *PyMac_BuildNumVersion(NumVersion);/* Convert NumVersion to PyObject */
|
||||
|
||||
int PyMac_GetStr255(PyObject *, Str255); /* argument parser for Str255 */
|
||||
PyObject *PyMac_BuildStr255(Str255); /* Convert Str255 to PyObject */
|
||||
PyObject *PyMac_BuildOptStr255(Str255); /* Convert Str255 to PyObject,
|
||||
NULL to None */
|
||||
|
||||
int PyMac_GetRect(PyObject *, Rect *); /* argument parser for Rect */
|
||||
PyObject *PyMac_BuildRect(Rect *); /* Convert Rect to PyObject */
|
||||
|
||||
int PyMac_GetPoint(PyObject *, Point *); /* argument parser for Point */
|
||||
PyObject *PyMac_BuildPoint(Point); /* Convert Point to PyObject */
|
||||
|
||||
int PyMac_GetEventRecord(PyObject *, EventRecord *); /* argument parser for
|
||||
EventRecord */
|
||||
PyObject *PyMac_BuildEventRecord(EventRecord *); /* Convert EventRecord to
|
||||
PyObject */
|
||||
|
||||
int PyMac_GetFixed(PyObject *, Fixed *); /* argument parser for Fixed */
|
||||
PyObject *PyMac_BuildFixed(Fixed); /* Convert Fixed to PyObject */
|
||||
int PyMac_Getwide(PyObject *, wide *); /* argument parser for wide */
|
||||
PyObject *PyMac_Buildwide(wide *); /* Convert wide to PyObject */
|
||||
|
||||
/*
|
||||
** The rest of the routines are implemented by extension modules. If they are
|
||||
** dynamically loaded mactoolboxglue will contain a stub implementation of the
|
||||
** routine, which imports the module, whereupon the module's init routine will
|
||||
** communicate the routine pointer back to the stub.
|
||||
** If USE_TOOLBOX_OBJECT_GLUE is not defined there is no glue code, and the
|
||||
** extension modules simply declare the routine. This is the case for static
|
||||
** builds (and could be the case for MacPython CFM builds, because CFM extension
|
||||
** modules can reference each other without problems).
|
||||
*/
|
||||
|
||||
#ifdef USE_TOOLBOX_OBJECT_GLUE
|
||||
/*
|
||||
** These macros are used in the module init code. If we use toolbox object glue
|
||||
** it sets the function pointer to point to the real function.
|
||||
*/
|
||||
#define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) { \
|
||||
extern PyObject *(*PyMacGluePtr_##rtn)(object); \
|
||||
PyMacGluePtr_##rtn = _##rtn; \
|
||||
}
|
||||
#define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) { \
|
||||
extern int (*PyMacGluePtr_##rtn)(PyObject *, object *); \
|
||||
PyMacGluePtr_##rtn = _##rtn; \
|
||||
}
|
||||
#else
|
||||
/*
|
||||
** If we don't use toolbox object glue the init macros are empty. Moreover, we define
|
||||
** _xxx_New to be the same as xxx_New, and the code in mactoolboxglue isn't included.
|
||||
*/
|
||||
#define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn)
|
||||
#define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn)
|
||||
#endif /* USE_TOOLBOX_OBJECT_GLUE */
|
||||
|
||||
/* macfs exports */
|
||||
#ifndef __LP64__
|
||||
int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */
|
||||
PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
int PyMac_GetFSRef(PyObject *, FSRef *); /* argument parser for FSRef */
|
||||
PyObject *PyMac_BuildFSRef(FSRef *); /* Convert FSRef to PyObject */
|
||||
|
||||
/* AE exports */
|
||||
extern PyObject *AEDesc_New(AppleEvent *); /* XXXX Why passed by address?? */
|
||||
extern PyObject *AEDesc_NewBorrowed(AppleEvent *);
|
||||
extern int AEDesc_Convert(PyObject *, AppleEvent *);
|
||||
|
||||
/* Cm exports */
|
||||
extern PyObject *CmpObj_New(Component);
|
||||
extern int CmpObj_Convert(PyObject *, Component *);
|
||||
extern PyObject *CmpInstObj_New(ComponentInstance);
|
||||
extern int CmpInstObj_Convert(PyObject *, ComponentInstance *);
|
||||
|
||||
/* Ctl exports */
|
||||
#ifndef __LP64__
|
||||
extern PyObject *CtlObj_New(ControlHandle);
|
||||
extern int CtlObj_Convert(PyObject *, ControlHandle *);
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/* Dlg exports */
|
||||
#ifndef __LP64__
|
||||
extern PyObject *DlgObj_New(DialogPtr);
|
||||
extern int DlgObj_Convert(PyObject *, DialogPtr *);
|
||||
extern PyObject *DlgObj_WhichDialog(DialogPtr);
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/* Drag exports */
|
||||
#ifndef __LP64__
|
||||
extern PyObject *DragObj_New(DragReference);
|
||||
extern int DragObj_Convert(PyObject *, DragReference *);
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/* List exports */
|
||||
#ifndef __LP64__
|
||||
extern PyObject *ListObj_New(ListHandle);
|
||||
extern int ListObj_Convert(PyObject *, ListHandle *);
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/* Menu exports */
|
||||
#ifndef __LP64__
|
||||
extern PyObject *MenuObj_New(MenuHandle);
|
||||
extern int MenuObj_Convert(PyObject *, MenuHandle *);
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/* Qd exports */
|
||||
#ifndef __LP64__
|
||||
extern PyObject *GrafObj_New(GrafPtr);
|
||||
extern int GrafObj_Convert(PyObject *, GrafPtr *);
|
||||
extern PyObject *BMObj_New(BitMapPtr);
|
||||
extern int BMObj_Convert(PyObject *, BitMapPtr *);
|
||||
extern PyObject *QdRGB_New(RGBColor *);
|
||||
extern int QdRGB_Convert(PyObject *, RGBColor *);
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/* Qdoffs exports */
|
||||
#ifndef __LP64__
|
||||
extern PyObject *GWorldObj_New(GWorldPtr);
|
||||
extern int GWorldObj_Convert(PyObject *, GWorldPtr *);
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/* Qt exports */
|
||||
#ifndef __LP64__
|
||||
extern PyObject *TrackObj_New(Track);
|
||||
extern int TrackObj_Convert(PyObject *, Track *);
|
||||
extern PyObject *MovieObj_New(Movie);
|
||||
extern int MovieObj_Convert(PyObject *, Movie *);
|
||||
extern PyObject *MovieCtlObj_New(MovieController);
|
||||
extern int MovieCtlObj_Convert(PyObject *, MovieController *);
|
||||
extern PyObject *TimeBaseObj_New(TimeBase);
|
||||
extern int TimeBaseObj_Convert(PyObject *, TimeBase *);
|
||||
extern PyObject *UserDataObj_New(UserData);
|
||||
extern int UserDataObj_Convert(PyObject *, UserData *);
|
||||
extern PyObject *MediaObj_New(Media);
|
||||
extern int MediaObj_Convert(PyObject *, Media *);
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/* Res exports */
|
||||
extern PyObject *ResObj_New(Handle);
|
||||
extern int ResObj_Convert(PyObject *, Handle *);
|
||||
extern PyObject *OptResObj_New(Handle);
|
||||
extern int OptResObj_Convert(PyObject *, Handle *);
|
||||
|
||||
/* TE exports */
|
||||
#ifndef __LP64__
|
||||
extern PyObject *TEObj_New(TEHandle);
|
||||
extern int TEObj_Convert(PyObject *, TEHandle *);
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/* Win exports */
|
||||
#ifndef __LP64__
|
||||
extern PyObject *WinObj_New(WindowPtr);
|
||||
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
||||
extern PyObject *WinObj_WhichWindow(WindowPtr);
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/* CF exports */
|
||||
extern PyObject *CFObj_New(CFTypeRef);
|
||||
extern int CFObj_Convert(PyObject *, CFTypeRef *);
|
||||
extern PyObject *CFTypeRefObj_New(CFTypeRef);
|
||||
extern int CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
|
||||
extern PyObject *CFStringRefObj_New(CFStringRef);
|
||||
extern int CFStringRefObj_Convert(PyObject *, CFStringRef *);
|
||||
extern PyObject *CFMutableStringRefObj_New(CFMutableStringRef);
|
||||
extern int CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *);
|
||||
extern PyObject *CFArrayRefObj_New(CFArrayRef);
|
||||
extern int CFArrayRefObj_Convert(PyObject *, CFArrayRef *);
|
||||
extern PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef);
|
||||
extern int CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *);
|
||||
extern PyObject *CFDictionaryRefObj_New(CFDictionaryRef);
|
||||
extern int CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *);
|
||||
extern PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef);
|
||||
extern int CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *);
|
||||
extern PyObject *CFURLRefObj_New(CFURLRef);
|
||||
extern int CFURLRefObj_Convert(PyObject *, CFURLRef *);
|
||||
extern int OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
214
c/meterpreter/source/extensions/python/Include/pymath.h
Normal file
214
c/meterpreter/source/extensions/python/Include/pymath.h
Normal file
@ -0,0 +1,214 @@
|
||||
#ifndef Py_PYMATH_H
|
||||
#define Py_PYMATH_H
|
||||
|
||||
#include "pyconfig.h" /* include for defines */
|
||||
|
||||
/**************************************************************************
|
||||
Symbols and macros to supply platform-independent interfaces to mathematical
|
||||
functions and constants
|
||||
**************************************************************************/
|
||||
|
||||
/* Python provides implementations for copysign, round and hypot in
|
||||
* Python/pymath.c just in case your math library doesn't provide the
|
||||
* functions.
|
||||
*
|
||||
*Note: PC/pyconfig.h defines copysign as _copysign
|
||||
*/
|
||||
#ifndef HAVE_COPYSIGN
|
||||
extern double copysign(double, double);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ROUND
|
||||
extern double round(double);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_HYPOT
|
||||
extern double hypot(double, double);
|
||||
#endif
|
||||
|
||||
/* extra declarations */
|
||||
#ifndef _MSC_VER
|
||||
#ifndef __STDC__
|
||||
extern double fmod (double, double);
|
||||
extern double frexp (double, int *);
|
||||
extern double ldexp (double, int);
|
||||
extern double modf (double, double *);
|
||||
extern double pow(double, double);
|
||||
#endif /* __STDC__ */
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#ifdef _OSF_SOURCE
|
||||
/* OSF1 5.1 doesn't make these available with XOPEN_SOURCE_EXTENDED defined */
|
||||
extern int finite(double);
|
||||
extern double copysign(double, double);
|
||||
#endif
|
||||
|
||||
/* High precision defintion of pi and e (Euler)
|
||||
* The values are taken from libc6's math.h.
|
||||
*/
|
||||
#ifndef Py_MATH_PIl
|
||||
#define Py_MATH_PIl 3.1415926535897932384626433832795029L
|
||||
#endif
|
||||
#ifndef Py_MATH_PI
|
||||
#define Py_MATH_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#ifndef Py_MATH_El
|
||||
#define Py_MATH_El 2.7182818284590452353602874713526625L
|
||||
#endif
|
||||
|
||||
#ifndef Py_MATH_E
|
||||
#define Py_MATH_E 2.7182818284590452354
|
||||
#endif
|
||||
|
||||
/* On x86, Py_FORCE_DOUBLE forces a floating-point number out of an x87 FPU
|
||||
register and into a 64-bit memory location, rounding from extended
|
||||
precision to double precision in the process. On other platforms it does
|
||||
nothing. */
|
||||
|
||||
/* we take double rounding as evidence of x87 usage */
|
||||
#ifndef Py_FORCE_DOUBLE
|
||||
# ifdef X87_DOUBLE_ROUNDING
|
||||
PyAPI_FUNC(double) _Py_force_double(double);
|
||||
# define Py_FORCE_DOUBLE(X) (_Py_force_double(X))
|
||||
# else
|
||||
# define Py_FORCE_DOUBLE(X) (X)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GCC_ASM_FOR_X87
|
||||
PyAPI_FUNC(unsigned short) _Py_get_387controlword(void);
|
||||
PyAPI_FUNC(void) _Py_set_387controlword(unsigned short);
|
||||
#endif
|
||||
|
||||
/* Py_IS_NAN(X)
|
||||
* Return 1 if float or double arg is a NaN, else 0.
|
||||
* Caution:
|
||||
* X is evaluated more than once.
|
||||
* This may not work on all platforms. Each platform has *some*
|
||||
* way to spell this, though -- override in pyconfig.h if you have
|
||||
* a platform where it doesn't work.
|
||||
* Note: PC/pyconfig.h defines Py_IS_NAN as _isnan
|
||||
*/
|
||||
#ifndef Py_IS_NAN
|
||||
#if defined HAVE_DECL_ISNAN && HAVE_DECL_ISNAN == 1
|
||||
#define Py_IS_NAN(X) isnan(X)
|
||||
#else
|
||||
#define Py_IS_NAN(X) ((X) != (X))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Py_IS_INFINITY(X)
|
||||
* Return 1 if float or double arg is an infinity, else 0.
|
||||
* Caution:
|
||||
* X is evaluated more than once.
|
||||
* This implementation may set the underflow flag if |X| is very small;
|
||||
* it really can't be implemented correctly (& easily) before C99.
|
||||
* Override in pyconfig.h if you have a better spelling on your platform.
|
||||
* Py_FORCE_DOUBLE is used to avoid getting false negatives from a
|
||||
* non-infinite value v sitting in an 80-bit x87 register such that
|
||||
* v becomes infinite when spilled from the register to 64-bit memory.
|
||||
* Note: PC/pyconfig.h defines Py_IS_INFINITY as _isinf
|
||||
*/
|
||||
#ifndef Py_IS_INFINITY
|
||||
# if defined HAVE_DECL_ISINF && HAVE_DECL_ISINF == 1
|
||||
# define Py_IS_INFINITY(X) isinf(X)
|
||||
# else
|
||||
# define Py_IS_INFINITY(X) ((X) && \
|
||||
(Py_FORCE_DOUBLE(X)*0.5 == Py_FORCE_DOUBLE(X)))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Py_IS_FINITE(X)
|
||||
* Return 1 if float or double arg is neither infinite nor NAN, else 0.
|
||||
* Some compilers (e.g. VisualStudio) have intrisics for this, so a special
|
||||
* macro for this particular test is useful
|
||||
* Note: PC/pyconfig.h defines Py_IS_FINITE as _finite
|
||||
*/
|
||||
#ifndef Py_IS_FINITE
|
||||
#if defined HAVE_DECL_ISFINITE && HAVE_DECL_ISFINITE == 1
|
||||
#define Py_IS_FINITE(X) isfinite(X)
|
||||
#elif defined HAVE_FINITE
|
||||
#define Py_IS_FINITE(X) finite(X)
|
||||
#else
|
||||
#define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* HUGE_VAL is supposed to expand to a positive double infinity. Python
|
||||
* uses Py_HUGE_VAL instead because some platforms are broken in this
|
||||
* respect. We used to embed code in pyport.h to try to worm around that,
|
||||
* but different platforms are broken in conflicting ways. If you're on
|
||||
* a platform where HUGE_VAL is defined incorrectly, fiddle your Python
|
||||
* config to #define Py_HUGE_VAL to something that works on your platform.
|
||||
*/
|
||||
#ifndef Py_HUGE_VAL
|
||||
#define Py_HUGE_VAL HUGE_VAL
|
||||
#endif
|
||||
|
||||
/* Py_NAN
|
||||
* A value that evaluates to a NaN. On IEEE 754 platforms INF*0 or
|
||||
* INF/INF works. Define Py_NO_NAN in pyconfig.h if your platform
|
||||
* doesn't support NaNs.
|
||||
*/
|
||||
#if !defined(Py_NAN) && !defined(Py_NO_NAN)
|
||||
#if !defined(__INTEL_COMPILER)
|
||||
#define Py_NAN (Py_HUGE_VAL * 0.)
|
||||
#else /* __INTEL_COMPILER */
|
||||
#if defined(ICC_NAN_STRICT)
|
||||
#pragma float_control(push)
|
||||
#pragma float_control(precise, on)
|
||||
#pragma float_control(except, on)
|
||||
#if defined(_MSC_VER)
|
||||
__declspec(noinline)
|
||||
#else /* Linux */
|
||||
__attribute__((noinline))
|
||||
#endif /* _MSC_VER */
|
||||
static double __icc_nan()
|
||||
{
|
||||
return sqrt(-1.0);
|
||||
}
|
||||
#pragma float_control (pop)
|
||||
#define Py_NAN __icc_nan()
|
||||
#else /* ICC_NAN_RELAXED as default for Intel Compiler */
|
||||
static union { unsigned char buf[8]; double __icc_nan; } __nan_store = {0,0,0,0,0,0,0xf8,0x7f};
|
||||
#define Py_NAN (__nan_store.__icc_nan)
|
||||
#endif /* ICC_NAN_STRICT */
|
||||
#endif /* __INTEL_COMPILER */
|
||||
#endif
|
||||
|
||||
/* Py_OVERFLOWED(X)
|
||||
* Return 1 iff a libm function overflowed. Set errno to 0 before calling
|
||||
* a libm function, and invoke this macro after, passing the function
|
||||
* result.
|
||||
* Caution:
|
||||
* This isn't reliable. C99 no longer requires libm to set errno under
|
||||
* any exceptional condition, but does require +- HUGE_VAL return
|
||||
* values on overflow. A 754 box *probably* maps HUGE_VAL to a
|
||||
* double infinity, and we're cool if that's so, unless the input
|
||||
* was an infinity and an infinity is the expected result. A C89
|
||||
* system sets errno to ERANGE, so we check for that too. We're
|
||||
* out of luck if a C99 754 box doesn't map HUGE_VAL to +Inf, or
|
||||
* if the returned result is a NaN, or if a C89 box returns HUGE_VAL
|
||||
* in non-overflow cases.
|
||||
* X is evaluated more than once.
|
||||
* Some platforms have better way to spell this, so expect some #ifdef'ery.
|
||||
*
|
||||
* OpenBSD uses 'isinf()' because a compiler bug on that platform causes
|
||||
* the longer macro version to be mis-compiled. This isn't optimal, and
|
||||
* should be removed once a newer compiler is available on that platform.
|
||||
* The system that had the failure was running OpenBSD 3.2 on Intel, with
|
||||
* gcc 2.95.3.
|
||||
*
|
||||
* According to Tim's checkin, the FreeBSD systems use isinf() to work
|
||||
* around a FPE bug on that platform.
|
||||
*/
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#define Py_OVERFLOWED(X) isinf(X)
|
||||
#else
|
||||
#define Py_OVERFLOWED(X) ((X) != 0.0 && (errno == ERANGE || \
|
||||
(X) == Py_HUGE_VAL || \
|
||||
(X) == -Py_HUGE_VAL))
|
||||
#endif
|
||||
|
||||
#endif /* Py_PYMATH_H */
|
122
c/meterpreter/source/extensions/python/Include/pymem.h
Normal file
122
c/meterpreter/source/extensions/python/Include/pymem.h
Normal file
@ -0,0 +1,122 @@
|
||||
/* The PyMem_ family: low-level memory allocation interfaces.
|
||||
See objimpl.h for the PyObject_ memory family.
|
||||
*/
|
||||
|
||||
#ifndef Py_PYMEM_H
|
||||
#define Py_PYMEM_H
|
||||
|
||||
#include "pyport.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* BEWARE:
|
||||
|
||||
Each interface exports both functions and macros. Extension modules should
|
||||
use the functions, to ensure binary compatibility across Python versions.
|
||||
Because the Python implementation is free to change internal details, and
|
||||
the macros may (or may not) expose details for speed, if you do use the
|
||||
macros you must recompile your extensions with each Python release.
|
||||
|
||||
Never mix calls to PyMem_ with calls to the platform malloc/realloc/
|
||||
calloc/free. For example, on Windows different DLLs may end up using
|
||||
different heaps, and if you use PyMem_Malloc you'll get the memory from the
|
||||
heap used by the Python DLL; it could be a disaster if you free()'ed that
|
||||
directly in your own extension. Using PyMem_Free instead ensures Python
|
||||
can return the memory to the proper heap. As another example, in
|
||||
PYMALLOC_DEBUG mode, Python wraps all calls to all PyMem_ and PyObject_
|
||||
memory functions in special debugging wrappers that add additional
|
||||
debugging info to dynamic memory blocks. The system routines have no idea
|
||||
what to do with that stuff, and the Python wrappers have no idea what to do
|
||||
with raw blocks obtained directly by the system routines then.
|
||||
|
||||
The GIL must be held when using these APIs.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Raw memory interface
|
||||
* ====================
|
||||
*/
|
||||
|
||||
/* Functions
|
||||
|
||||
Functions supplying platform-independent semantics for malloc/realloc/
|
||||
free. These functions make sure that allocating 0 bytes returns a distinct
|
||||
non-NULL pointer (whenever possible -- if we're flat out of memory, NULL
|
||||
may be returned), even if the platform malloc and realloc don't.
|
||||
Returned pointers must be checked for NULL explicitly. No action is
|
||||
performed on failure (no exception is set, no warning is printed, etc).
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(void *) PyMem_Malloc(size_t);
|
||||
PyAPI_FUNC(void *) PyMem_Realloc(void *, size_t);
|
||||
PyAPI_FUNC(void) PyMem_Free(void *);
|
||||
|
||||
/* Starting from Python 1.6, the wrappers Py_{Malloc,Realloc,Free} are
|
||||
no longer supported. They used to call PyErr_NoMemory() on failure. */
|
||||
|
||||
/* Macros. */
|
||||
#ifdef PYMALLOC_DEBUG
|
||||
/* Redirect all memory operations to Python's debugging allocator. */
|
||||
#define PyMem_MALLOC _PyMem_DebugMalloc
|
||||
#define PyMem_REALLOC _PyMem_DebugRealloc
|
||||
#define PyMem_FREE _PyMem_DebugFree
|
||||
|
||||
#else /* ! PYMALLOC_DEBUG */
|
||||
|
||||
/* PyMem_MALLOC(0) means malloc(1). Some systems would return NULL
|
||||
for malloc(0), which would be treated as an error. Some platforms
|
||||
would return a pointer with no memory behind it, which would break
|
||||
pymalloc. To solve these problems, allocate an extra byte. */
|
||||
/* Returns NULL to indicate error if a negative size or size larger than
|
||||
Py_ssize_t can represent is supplied. Helps prevents security holes. */
|
||||
#define PyMem_MALLOC(n) ((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \
|
||||
: malloc((n) ? (n) : 1))
|
||||
#define PyMem_REALLOC(p, n) ((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \
|
||||
: realloc((p), (n) ? (n) : 1))
|
||||
#define PyMem_FREE free
|
||||
|
||||
#endif /* PYMALLOC_DEBUG */
|
||||
|
||||
/*
|
||||
* Type-oriented memory interface
|
||||
* ==============================
|
||||
*
|
||||
* Allocate memory for n objects of the given type. Returns a new pointer
|
||||
* or NULL if the request was too large or memory allocation failed. Use
|
||||
* these macros rather than doing the multiplication yourself so that proper
|
||||
* overflow checking is always done.
|
||||
*/
|
||||
|
||||
#define PyMem_New(type, n) \
|
||||
( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
|
||||
( (type *) PyMem_Malloc((n) * sizeof(type)) ) )
|
||||
#define PyMem_NEW(type, n) \
|
||||
( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
|
||||
( (type *) PyMem_MALLOC((n) * sizeof(type)) ) )
|
||||
|
||||
/*
|
||||
* The value of (p) is always clobbered by this macro regardless of success.
|
||||
* The caller MUST check if (p) is NULL afterwards and deal with the memory
|
||||
* error if so. This means the original value of (p) MUST be saved for the
|
||||
* caller's memory error handler to not lose track of it.
|
||||
*/
|
||||
#define PyMem_Resize(p, type, n) \
|
||||
( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
|
||||
(type *) PyMem_Realloc((p), (n) * sizeof(type)) )
|
||||
#define PyMem_RESIZE(p, type, n) \
|
||||
( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
|
||||
(type *) PyMem_REALLOC((p), (n) * sizeof(type)) )
|
||||
|
||||
/* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used
|
||||
* anymore. They're just confusing aliases for PyMem_{Free,FREE} now.
|
||||
*/
|
||||
#define PyMem_Del PyMem_Free
|
||||
#define PyMem_DEL PyMem_FREE
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !Py_PYMEM_H */
|
941
c/meterpreter/source/extensions/python/Include/pyport.h
Normal file
941
c/meterpreter/source/extensions/python/Include/pyport.h
Normal file
@ -0,0 +1,941 @@
|
||||
#ifndef Py_PYPORT_H
|
||||
#define Py_PYPORT_H
|
||||
|
||||
#include "pyconfig.h" /* include for defines */
|
||||
|
||||
/* Some versions of HP-UX & Solaris need inttypes.h for int32_t,
|
||||
INT32_MAX, etc. */
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
/**************************************************************************
|
||||
Symbols and macros to supply platform-independent interfaces to basic
|
||||
C language & library operations whose spellings vary across platforms.
|
||||
|
||||
Please try to make documentation here as clear as possible: by definition,
|
||||
the stuff here is trying to illuminate C's darkest corners.
|
||||
|
||||
Config #defines referenced here:
|
||||
|
||||
SIGNED_RIGHT_SHIFT_ZERO_FILLS
|
||||
Meaning: To be defined iff i>>j does not extend the sign bit when i is a
|
||||
signed integral type and i < 0.
|
||||
Used in: Py_ARITHMETIC_RIGHT_SHIFT
|
||||
|
||||
Py_DEBUG
|
||||
Meaning: Extra checks compiled in for debug mode.
|
||||
Used in: Py_SAFE_DOWNCAST
|
||||
|
||||
HAVE_UINTPTR_T
|
||||
Meaning: The C9X type uintptr_t is supported by the compiler
|
||||
Used in: Py_uintptr_t
|
||||
|
||||
HAVE_LONG_LONG
|
||||
Meaning: The compiler supports the C type "long long"
|
||||
Used in: PY_LONG_LONG
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/* For backward compatibility only. Obsolete, do not use. */
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
#define Py_PROTO(x) x
|
||||
#else
|
||||
#define Py_PROTO(x) ()
|
||||
#endif
|
||||
#ifndef Py_FPROTO
|
||||
#define Py_FPROTO(x) Py_PROTO(x)
|
||||
#endif
|
||||
|
||||
/* typedefs for some C9X-defined synonyms for integral types.
|
||||
*
|
||||
* The names in Python are exactly the same as the C9X names, except with a
|
||||
* Py_ prefix. Until C9X is universally implemented, this is the only way
|
||||
* to ensure that Python gets reliable names that don't conflict with names
|
||||
* in non-Python code that are playing their own tricks to define the C9X
|
||||
* names.
|
||||
*
|
||||
* NOTE: don't go nuts here! Python has no use for *most* of the C9X
|
||||
* integral synonyms. Only define the ones we actually need.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifndef PY_LONG_LONG
|
||||
#define PY_LONG_LONG long long
|
||||
#if defined(LLONG_MAX)
|
||||
/* If LLONG_MAX is defined in limits.h, use that. */
|
||||
#define PY_LLONG_MIN LLONG_MIN
|
||||
#define PY_LLONG_MAX LLONG_MAX
|
||||
#define PY_ULLONG_MAX ULLONG_MAX
|
||||
#elif defined(__LONG_LONG_MAX__)
|
||||
/* Otherwise, if GCC has a builtin define, use that. */
|
||||
#define PY_LLONG_MAX __LONG_LONG_MAX__
|
||||
#define PY_LLONG_MIN (-PY_LLONG_MAX-1)
|
||||
#define PY_ULLONG_MAX (__LONG_LONG_MAX__*2ULL + 1ULL)
|
||||
#else
|
||||
/* Otherwise, rely on two's complement. */
|
||||
#define PY_ULLONG_MAX (~0ULL)
|
||||
#define PY_LLONG_MAX ((long long)(PY_ULLONG_MAX>>1))
|
||||
#define PY_LLONG_MIN (-PY_LLONG_MAX-1)
|
||||
#endif /* LLONG_MAX */
|
||||
#endif
|
||||
#endif /* HAVE_LONG_LONG */
|
||||
|
||||
/* a build with 30-bit digits for Python long integers needs an exact-width
|
||||
* 32-bit unsigned integer type to store those digits. (We could just use
|
||||
* type 'unsigned long', but that would be wasteful on a system where longs
|
||||
* are 64-bits.) On Unix systems, the autoconf macro AC_TYPE_UINT32_T defines
|
||||
* uint32_t to be such a type unless stdint.h or inttypes.h defines uint32_t.
|
||||
* However, it doesn't set HAVE_UINT32_T, so we do that here.
|
||||
*/
|
||||
#ifdef uint32_t
|
||||
#define HAVE_UINT32_T 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UINT32_T
|
||||
#ifndef PY_UINT32_T
|
||||
#define PY_UINT32_T uint32_t
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Macros for a 64-bit unsigned integer type; used for type 'twodigits' in the
|
||||
* long integer implementation, when 30-bit digits are enabled.
|
||||
*/
|
||||
#ifdef uint64_t
|
||||
#define HAVE_UINT64_T 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UINT64_T
|
||||
#ifndef PY_UINT64_T
|
||||
#define PY_UINT64_T uint64_t
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Signed variants of the above */
|
||||
#ifdef int32_t
|
||||
#define HAVE_INT32_T 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_INT32_T
|
||||
#ifndef PY_INT32_T
|
||||
#define PY_INT32_T int32_t
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef int64_t
|
||||
#define HAVE_INT64_T 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_INT64_T
|
||||
#ifndef PY_INT64_T
|
||||
#define PY_INT64_T int64_t
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* If PYLONG_BITS_IN_DIGIT is not defined then we'll use 30-bit digits if all
|
||||
the necessary integer types are available, and we're on a 64-bit platform
|
||||
(as determined by SIZEOF_VOID_P); otherwise we use 15-bit digits. */
|
||||
|
||||
#ifndef PYLONG_BITS_IN_DIGIT
|
||||
#if (defined HAVE_UINT64_T && defined HAVE_INT64_T && \
|
||||
defined HAVE_UINT32_T && defined HAVE_INT32_T && SIZEOF_VOID_P >= 8)
|
||||
#define PYLONG_BITS_IN_DIGIT 30
|
||||
#else
|
||||
#define PYLONG_BITS_IN_DIGIT 15
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* uintptr_t is the C9X name for an unsigned integral type such that a
|
||||
* legitimate void* can be cast to uintptr_t and then back to void* again
|
||||
* without loss of information. Similarly for intptr_t, wrt a signed
|
||||
* integral type.
|
||||
*/
|
||||
#ifdef HAVE_UINTPTR_T
|
||||
typedef uintptr_t Py_uintptr_t;
|
||||
typedef intptr_t Py_intptr_t;
|
||||
|
||||
#elif SIZEOF_VOID_P <= SIZEOF_INT
|
||||
typedef unsigned int Py_uintptr_t;
|
||||
typedef int Py_intptr_t;
|
||||
|
||||
#elif SIZEOF_VOID_P <= SIZEOF_LONG
|
||||
typedef unsigned long Py_uintptr_t;
|
||||
typedef long Py_intptr_t;
|
||||
|
||||
#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P <= SIZEOF_LONG_LONG)
|
||||
typedef unsigned PY_LONG_LONG Py_uintptr_t;
|
||||
typedef PY_LONG_LONG Py_intptr_t;
|
||||
|
||||
#else
|
||||
# error "Python needs a typedef for Py_uintptr_t in pyport.h."
|
||||
#endif /* HAVE_UINTPTR_T */
|
||||
|
||||
/* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) ==
|
||||
* sizeof(size_t). C99 doesn't define such a thing directly (size_t is an
|
||||
* unsigned integral type). See PEP 353 for details.
|
||||
*/
|
||||
#ifdef HAVE_SSIZE_T
|
||||
typedef ssize_t Py_ssize_t;
|
||||
#elif SIZEOF_VOID_P == SIZEOF_SIZE_T
|
||||
typedef Py_intptr_t Py_ssize_t;
|
||||
#else
|
||||
# error "Python needs a typedef for Py_ssize_t in pyport.h."
|
||||
#endif
|
||||
|
||||
/* Largest possible value of size_t.
|
||||
SIZE_MAX is part of C99, so it might be defined on some
|
||||
platforms. If it is not defined, (size_t)-1 is a portable
|
||||
definition for C89, due to the way signed->unsigned
|
||||
conversion is defined. */
|
||||
#ifdef SIZE_MAX
|
||||
#define PY_SIZE_MAX SIZE_MAX
|
||||
#else
|
||||
#define PY_SIZE_MAX ((size_t)-1)
|
||||
#endif
|
||||
|
||||
/* Largest positive value of type Py_ssize_t. */
|
||||
#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
|
||||
/* Smallest negative value of type Py_ssize_t. */
|
||||
#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
|
||||
|
||||
#if SIZEOF_PID_T > SIZEOF_LONG
|
||||
# error "Python doesn't support sizeof(pid_t) > sizeof(long)"
|
||||
#endif
|
||||
|
||||
/* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf
|
||||
* format to convert an argument with the width of a size_t or Py_ssize_t.
|
||||
* C99 introduced "z" for this purpose, but not all platforms support that;
|
||||
* e.g., MS compilers use "I" instead.
|
||||
*
|
||||
* These "high level" Python format functions interpret "z" correctly on
|
||||
* all platforms (Python interprets the format string itself, and does whatever
|
||||
* the platform C requires to convert a size_t/Py_ssize_t argument):
|
||||
*
|
||||
* PyString_FromFormat
|
||||
* PyErr_Format
|
||||
* PyString_FromFormatV
|
||||
*
|
||||
* Lower-level uses require that you interpolate the correct format modifier
|
||||
* yourself (e.g., calling printf, fprintf, sprintf, PyOS_snprintf); for
|
||||
* example,
|
||||
*
|
||||
* Py_ssize_t index;
|
||||
* fprintf(stderr, "index %" PY_FORMAT_SIZE_T "d sucks\n", index);
|
||||
*
|
||||
* That will expand to %ld, or %Id, or to something else correct for a
|
||||
* Py_ssize_t on the platform.
|
||||
*/
|
||||
#ifndef PY_FORMAT_SIZE_T
|
||||
# if SIZEOF_SIZE_T == SIZEOF_INT && !defined(__APPLE__)
|
||||
# define PY_FORMAT_SIZE_T ""
|
||||
# elif SIZEOF_SIZE_T == SIZEOF_LONG
|
||||
# define PY_FORMAT_SIZE_T "l"
|
||||
# elif defined(MS_WINDOWS)
|
||||
# define PY_FORMAT_SIZE_T "I"
|
||||
# else
|
||||
# error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* PY_FORMAT_LONG_LONG is analogous to PY_FORMAT_SIZE_T above, but for
|
||||
* the long long type instead of the size_t type. It's only available
|
||||
* when HAVE_LONG_LONG is defined. The "high level" Python format
|
||||
* functions listed above will interpret "lld" or "llu" correctly on
|
||||
* all platforms.
|
||||
*/
|
||||
#ifdef HAVE_LONG_LONG
|
||||
# ifndef PY_FORMAT_LONG_LONG
|
||||
# if defined(MS_WIN64) || defined(MS_WINDOWS)
|
||||
# define PY_FORMAT_LONG_LONG "I64"
|
||||
# else
|
||||
# error "This platform's pyconfig.h needs to define PY_FORMAT_LONG_LONG"
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Py_LOCAL can be used instead of static to get the fastest possible calling
|
||||
* convention for functions that are local to a given module.
|
||||
*
|
||||
* Py_LOCAL_INLINE does the same thing, and also explicitly requests inlining,
|
||||
* for platforms that support that.
|
||||
*
|
||||
* If PY_LOCAL_AGGRESSIVE is defined before python.h is included, more
|
||||
* "aggressive" inlining/optimizaion is enabled for the entire module. This
|
||||
* may lead to code bloat, and may slow things down for those reasons. It may
|
||||
* also lead to errors, if the code relies on pointer aliasing. Use with
|
||||
* care.
|
||||
*
|
||||
* NOTE: You can only use this for functions that are entirely local to a
|
||||
* module; functions that are exported via method tables, callbacks, etc,
|
||||
* should keep using static.
|
||||
*/
|
||||
|
||||
#undef USE_INLINE /* XXX - set via configure? */
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(PY_LOCAL_AGGRESSIVE)
|
||||
/* enable more aggressive optimization for visual studio */
|
||||
#pragma optimize("agtw", on)
|
||||
#endif
|
||||
/* ignore warnings if the compiler decides not to inline a function */
|
||||
#pragma warning(disable: 4710)
|
||||
/* fastest possible local call under MSVC */
|
||||
#define Py_LOCAL(type) static type __fastcall
|
||||
#define Py_LOCAL_INLINE(type) static __inline type __fastcall
|
||||
#elif defined(USE_INLINE)
|
||||
#define Py_LOCAL(type) static type
|
||||
#define Py_LOCAL_INLINE(type) static inline type
|
||||
#else
|
||||
#define Py_LOCAL(type) static type
|
||||
#define Py_LOCAL_INLINE(type) static type
|
||||
#endif
|
||||
|
||||
/* Py_MEMCPY can be used instead of memcpy in cases where the copied blocks
|
||||
* are often very short. While most platforms have highly optimized code for
|
||||
* large transfers, the setup costs for memcpy are often quite high. MEMCPY
|
||||
* solves this by doing short copies "in line".
|
||||
*/
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define Py_MEMCPY(target, source, length) do { \
|
||||
size_t i_, n_ = (length); \
|
||||
char *t_ = (void*) (target); \
|
||||
const char *s_ = (void*) (source); \
|
||||
if (n_ >= 16) \
|
||||
memcpy(t_, s_, n_); \
|
||||
else \
|
||||
for (i_ = 0; i_ < n_; i_++) \
|
||||
t_[i_] = s_[i_]; \
|
||||
} while (0)
|
||||
#else
|
||||
#define Py_MEMCPY memcpy
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_IEEEFP_H
|
||||
#include <ieeefp.h> /* needed for 'finite' declaration on some platforms */
|
||||
#endif
|
||||
|
||||
#include <math.h> /* Moved here from the math section, before extern "C" */
|
||||
|
||||
/********************************************
|
||||
* WRAPPER FOR <time.h> and/or <sys/time.h> *
|
||||
********************************************/
|
||||
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#else /* !TIME_WITH_SYS_TIME */
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#else /* !HAVE_SYS_TIME_H */
|
||||
#include <time.h>
|
||||
#endif /* !HAVE_SYS_TIME_H */
|
||||
#endif /* !TIME_WITH_SYS_TIME */
|
||||
|
||||
|
||||
/******************************
|
||||
* WRAPPER FOR <sys/select.h> *
|
||||
******************************/
|
||||
|
||||
/* NB caller must include <sys/types.h> */
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
|
||||
#include <sys/select.h>
|
||||
|
||||
#endif /* !HAVE_SYS_SELECT_H */
|
||||
|
||||
/*******************************
|
||||
* stat() and fstat() fiddling *
|
||||
*******************************/
|
||||
|
||||
/* We expect that stat and fstat exist on most systems.
|
||||
* It's confirmed on Unix, Mac and Windows.
|
||||
* If you don't have them, add
|
||||
* #define DONT_HAVE_STAT
|
||||
* and/or
|
||||
* #define DONT_HAVE_FSTAT
|
||||
* to your pyconfig.h. Python code beyond this should check HAVE_STAT and
|
||||
* HAVE_FSTAT instead.
|
||||
* Also
|
||||
* #define HAVE_SYS_STAT_H
|
||||
* if <sys/stat.h> exists on your platform, and
|
||||
* #define HAVE_STAT_H
|
||||
* if <stat.h> does.
|
||||
*/
|
||||
#ifndef DONT_HAVE_STAT
|
||||
#define HAVE_STAT
|
||||
#endif
|
||||
|
||||
#ifndef DONT_HAVE_FSTAT
|
||||
#define HAVE_FSTAT
|
||||
#endif
|
||||
|
||||
#ifdef RISCOS
|
||||
#include <sys/types.h>
|
||||
#include "unixstuff.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#if defined(PYOS_OS2) && defined(PYCC_GCC)
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#elif defined(HAVE_STAT_H)
|
||||
#include <stat.h>
|
||||
#endif
|
||||
|
||||
#if defined(PYCC_VACPP)
|
||||
/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */
|
||||
#define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG)
|
||||
#endif
|
||||
|
||||
#ifndef S_ISREG
|
||||
#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
|
||||
#endif
|
||||
|
||||
#ifndef S_ISDIR
|
||||
#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* Move this down here since some C++ #include's don't like to be included
|
||||
inside an extern "C" */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Py_ARITHMETIC_RIGHT_SHIFT
|
||||
* C doesn't define whether a right-shift of a signed integer sign-extends
|
||||
* or zero-fills. Here a macro to force sign extension:
|
||||
* Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J)
|
||||
* Return I >> J, forcing sign extension. Arithmetically, return the
|
||||
* floor of I/2**J.
|
||||
* Requirements:
|
||||
* I should have signed integer type. In the terminology of C99, this can
|
||||
* be either one of the five standard signed integer types (signed char,
|
||||
* short, int, long, long long) or an extended signed integer type.
|
||||
* J is an integer >= 0 and strictly less than the number of bits in the
|
||||
* type of I (because C doesn't define what happens for J outside that
|
||||
* range either).
|
||||
* TYPE used to specify the type of I, but is now ignored. It's been left
|
||||
* in for backwards compatibility with versions <= 2.6 or 3.0.
|
||||
* Caution:
|
||||
* I may be evaluated more than once.
|
||||
*/
|
||||
#ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS
|
||||
#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \
|
||||
((I) < 0 ? -1-((-1-(I)) >> (J)) : (I) >> (J))
|
||||
#else
|
||||
#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J))
|
||||
#endif
|
||||
|
||||
/* Py_FORCE_EXPANSION(X)
|
||||
* "Simply" returns its argument. However, macro expansions within the
|
||||
* argument are evaluated. This unfortunate trickery is needed to get
|
||||
* token-pasting to work as desired in some cases.
|
||||
*/
|
||||
#define Py_FORCE_EXPANSION(X) X
|
||||
|
||||
/* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW)
|
||||
* Cast VALUE to type NARROW from type WIDE. In Py_DEBUG mode, this
|
||||
* assert-fails if any information is lost.
|
||||
* Caution:
|
||||
* VALUE may be evaluated more than once.
|
||||
*/
|
||||
#ifdef Py_DEBUG
|
||||
#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \
|
||||
(assert((WIDE)(NARROW)(VALUE) == (VALUE)), (NARROW)(VALUE))
|
||||
#else
|
||||
#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE)
|
||||
#endif
|
||||
|
||||
/* Py_SET_ERRNO_ON_MATH_ERROR(x)
|
||||
* If a libm function did not set errno, but it looks like the result
|
||||
* overflowed or not-a-number, set errno to ERANGE or EDOM. Set errno
|
||||
* to 0 before calling a libm function, and invoke this macro after,
|
||||
* passing the function result.
|
||||
* Caution:
|
||||
* This isn't reliable. See Py_OVERFLOWED comments.
|
||||
* X is evaluated more than once.
|
||||
*/
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || (defined(__hpux) && defined(__ia64))
|
||||
#define _Py_SET_EDOM_FOR_NAN(X) if (isnan(X)) errno = EDOM;
|
||||
#else
|
||||
#define _Py_SET_EDOM_FOR_NAN(X) ;
|
||||
#endif
|
||||
#define Py_SET_ERRNO_ON_MATH_ERROR(X) \
|
||||
do { \
|
||||
if (errno == 0) { \
|
||||
if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \
|
||||
errno = ERANGE; \
|
||||
else _Py_SET_EDOM_FOR_NAN(X) \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* Py_SET_ERANGE_ON_OVERFLOW(x)
|
||||
* An alias of Py_SET_ERRNO_ON_MATH_ERROR for backward-compatibility.
|
||||
*/
|
||||
#define Py_SET_ERANGE_IF_OVERFLOW(X) Py_SET_ERRNO_ON_MATH_ERROR(X)
|
||||
|
||||
/* Py_ADJUST_ERANGE1(x)
|
||||
* Py_ADJUST_ERANGE2(x, y)
|
||||
* Set errno to 0 before calling a libm function, and invoke one of these
|
||||
* macros after, passing the function result(s) (Py_ADJUST_ERANGE2 is useful
|
||||
* for functions returning complex results). This makes two kinds of
|
||||
* adjustments to errno: (A) If it looks like the platform libm set
|
||||
* errno=ERANGE due to underflow, clear errno. (B) If it looks like the
|
||||
* platform libm overflowed but didn't set errno, force errno to ERANGE. In
|
||||
* effect, we're trying to force a useful implementation of C89 errno
|
||||
* behavior.
|
||||
* Caution:
|
||||
* This isn't reliable. See Py_OVERFLOWED comments.
|
||||
* X and Y may be evaluated more than once.
|
||||
*/
|
||||
#define Py_ADJUST_ERANGE1(X) \
|
||||
do { \
|
||||
if (errno == 0) { \
|
||||
if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \
|
||||
errno = ERANGE; \
|
||||
} \
|
||||
else if (errno == ERANGE && (X) == 0.0) \
|
||||
errno = 0; \
|
||||
} while(0)
|
||||
|
||||
#define Py_ADJUST_ERANGE2(X, Y) \
|
||||
do { \
|
||||
if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL || \
|
||||
(Y) == Py_HUGE_VAL || (Y) == -Py_HUGE_VAL) { \
|
||||
if (errno == 0) \
|
||||
errno = ERANGE; \
|
||||
} \
|
||||
else if (errno == ERANGE) \
|
||||
errno = 0; \
|
||||
} while(0)
|
||||
|
||||
/* The functions _Py_dg_strtod and _Py_dg_dtoa in Python/dtoa.c (which are
|
||||
* required to support the short float repr introduced in Python 3.1) require
|
||||
* that the floating-point unit that's being used for arithmetic operations
|
||||
* on C doubles is set to use 53-bit precision. It also requires that the
|
||||
* FPU rounding mode is round-half-to-even, but that's less often an issue.
|
||||
*
|
||||
* If your FPU isn't already set to 53-bit precision/round-half-to-even, and
|
||||
* you want to make use of _Py_dg_strtod and _Py_dg_dtoa, then you should
|
||||
*
|
||||
* #define HAVE_PY_SET_53BIT_PRECISION 1
|
||||
*
|
||||
* and also give appropriate definitions for the following three macros:
|
||||
*
|
||||
* _PY_SET_53BIT_PRECISION_START : store original FPU settings, and
|
||||
* set FPU to 53-bit precision/round-half-to-even
|
||||
* _PY_SET_53BIT_PRECISION_END : restore original FPU settings
|
||||
* _PY_SET_53BIT_PRECISION_HEADER : any variable declarations needed to
|
||||
* use the two macros above.
|
||||
*
|
||||
* The macros are designed to be used within a single C function: see
|
||||
* Python/pystrtod.c for an example of their use.
|
||||
*/
|
||||
|
||||
/* get and set x87 control word for gcc/x86 */
|
||||
#ifdef HAVE_GCC_ASM_FOR_X87
|
||||
#define HAVE_PY_SET_53BIT_PRECISION 1
|
||||
/* _Py_get/set_387controlword functions are defined in Python/pymath.c */
|
||||
#define _Py_SET_53BIT_PRECISION_HEADER \
|
||||
unsigned short old_387controlword, new_387controlword
|
||||
#define _Py_SET_53BIT_PRECISION_START \
|
||||
do { \
|
||||
old_387controlword = _Py_get_387controlword(); \
|
||||
new_387controlword = (old_387controlword & ~0x0f00) | 0x0200; \
|
||||
if (new_387controlword != old_387controlword) \
|
||||
_Py_set_387controlword(new_387controlword); \
|
||||
} while (0)
|
||||
#define _Py_SET_53BIT_PRECISION_END \
|
||||
if (new_387controlword != old_387controlword) \
|
||||
_Py_set_387controlword(old_387controlword)
|
||||
#endif
|
||||
|
||||
/* get and set x87 control word for VisualStudio/x86 */
|
||||
#if defined(_MSC_VER) && !defined(_WIN64) /* x87 not supported in 64-bit */
|
||||
#define HAVE_PY_SET_53BIT_PRECISION 1
|
||||
#define _Py_SET_53BIT_PRECISION_HEADER \
|
||||
unsigned int old_387controlword, new_387controlword, out_387controlword
|
||||
/* We use the __control87_2 function to set only the x87 control word.
|
||||
The SSE control word is unaffected. */
|
||||
#define _Py_SET_53BIT_PRECISION_START \
|
||||
do { \
|
||||
__control87_2(0, 0, &old_387controlword, NULL); \
|
||||
new_387controlword = \
|
||||
(old_387controlword & ~(_MCW_PC | _MCW_RC)) | (_PC_53 | _RC_NEAR); \
|
||||
if (new_387controlword != old_387controlword) \
|
||||
__control87_2(new_387controlword, _MCW_PC | _MCW_RC, \
|
||||
&out_387controlword, NULL); \
|
||||
} while (0)
|
||||
#define _Py_SET_53BIT_PRECISION_END \
|
||||
do { \
|
||||
if (new_387controlword != old_387controlword) \
|
||||
__control87_2(old_387controlword, _MCW_PC | _MCW_RC, \
|
||||
&out_387controlword, NULL); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/* default definitions are empty */
|
||||
#ifndef HAVE_PY_SET_53BIT_PRECISION
|
||||
#define _Py_SET_53BIT_PRECISION_HEADER
|
||||
#define _Py_SET_53BIT_PRECISION_START
|
||||
#define _Py_SET_53BIT_PRECISION_END
|
||||
#endif
|
||||
|
||||
/* If we can't guarantee 53-bit precision, don't use the code
|
||||
in Python/dtoa.c, but fall back to standard code. This
|
||||
means that repr of a float will be long (17 sig digits).
|
||||
|
||||
Realistically, there are two things that could go wrong:
|
||||
|
||||
(1) doubles aren't IEEE 754 doubles, or
|
||||
(2) we're on x86 with the rounding precision set to 64-bits
|
||||
(extended precision), and we don't know how to change
|
||||
the rounding precision.
|
||||
*/
|
||||
|
||||
#if !defined(DOUBLE_IS_LITTLE_ENDIAN_IEEE754) && \
|
||||
!defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) && \
|
||||
!defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754)
|
||||
#define PY_NO_SHORT_FLOAT_REPR
|
||||
#endif
|
||||
|
||||
/* double rounding is symptomatic of use of extended precision on x86. If
|
||||
we're seeing double rounding, and we don't have any mechanism available for
|
||||
changing the FPU rounding precision, then don't use Python/dtoa.c. */
|
||||
#if defined(X87_DOUBLE_ROUNDING) && !defined(HAVE_PY_SET_53BIT_PRECISION)
|
||||
#define PY_NO_SHORT_FLOAT_REPR
|
||||
#endif
|
||||
|
||||
/* Py_DEPRECATED(version)
|
||||
* Declare a variable, type, or function deprecated.
|
||||
* Usage:
|
||||
* extern int old_var Py_DEPRECATED(2.3);
|
||||
* typedef int T1 Py_DEPRECATED(2.4);
|
||||
* extern int x() Py_DEPRECATED(2.5);
|
||||
*/
|
||||
#if defined(__GNUC__) && ((__GNUC__ >= 4) || \
|
||||
(__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
|
||||
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
|
||||
#else
|
||||
#define Py_DEPRECATED(VERSION_UNUSED)
|
||||
#endif
|
||||
|
||||
/**************************************************************************
|
||||
Prototypes that are missing from the standard include files on some systems
|
||||
(and possibly only some versions of such systems.)
|
||||
|
||||
Please be conservative with adding new ones, document them and enclose them
|
||||
in platform-specific #ifdefs.
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef SOLARIS
|
||||
/* Unchecked */
|
||||
extern int gethostname(char *, int);
|
||||
#endif
|
||||
|
||||
#ifdef __BEOS__
|
||||
/* Unchecked */
|
||||
/* It's in the libs, but not the headers... - [cjh] */
|
||||
int shutdown( int, int );
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__GETPTY
|
||||
#include <sys/types.h> /* we need to import mode_t */
|
||||
extern char * _getpty(int *, int, mode_t, int);
|
||||
#endif
|
||||
|
||||
/* On QNX 6, struct termio must be declared by including sys/termio.h
|
||||
if TCGETA, TCSETA, TCSETAW, or TCSETAF are used. sys/termio.h must
|
||||
be included before termios.h or it will generate an error. */
|
||||
#if defined(HAVE_SYS_TERMIO_H) && !defined(__hpux)
|
||||
#include <sys/termio.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY)
|
||||
#if !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) && !defined(HAVE_UTIL_H)
|
||||
/* BSDI does not supply a prototype for the 'openpty' and 'forkpty'
|
||||
functions, even though they are included in libutil. */
|
||||
#include <termios.h>
|
||||
extern int openpty(int *, int *, char *, struct termios *, struct winsize *);
|
||||
extern pid_t forkpty(int *, char *, struct termios *, struct winsize *);
|
||||
#endif /* !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) */
|
||||
#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */
|
||||
|
||||
|
||||
/* These are pulled from various places. It isn't obvious on what platforms
|
||||
they are necessary, nor what the exact prototype should look like (which
|
||||
is likely to vary between platforms!) If you find you need one of these
|
||||
declarations, please move them to a platform-specific block and include
|
||||
proper prototypes. */
|
||||
#if 0
|
||||
|
||||
/* From Modules/resource.c */
|
||||
extern int getrusage();
|
||||
extern int getpagesize();
|
||||
|
||||
/* From Python/sysmodule.c and Modules/posixmodule.c */
|
||||
extern int fclose(FILE *);
|
||||
|
||||
/* From Modules/posixmodule.c */
|
||||
extern int fdatasync(int);
|
||||
#endif /* 0 */
|
||||
|
||||
|
||||
/* On 4.4BSD-descendants, ctype functions serves the whole range of
|
||||
* wchar_t character set rather than single byte code points only.
|
||||
* This characteristic can break some operations of string object
|
||||
* including str.upper() and str.split() on UTF-8 locales. This
|
||||
* workaround was provided by Tim Robbins of FreeBSD project.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <osreldate.h>
|
||||
#if __FreeBSD_version > 500039
|
||||
# define _PY_PORT_CTYPE_UTF8_ISSUE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__APPLE__)
|
||||
# define _PY_PORT_CTYPE_UTF8_ISSUE
|
||||
#endif
|
||||
|
||||
#ifdef _PY_PORT_CTYPE_UTF8_ISSUE
|
||||
#include <ctype.h>
|
||||
#include <wctype.h>
|
||||
#undef isalnum
|
||||
#define isalnum(c) iswalnum(btowc(c))
|
||||
#undef isalpha
|
||||
#define isalpha(c) iswalpha(btowc(c))
|
||||
#undef islower
|
||||
#define islower(c) iswlower(btowc(c))
|
||||
#undef isspace
|
||||
#define isspace(c) iswspace(btowc(c))
|
||||
#undef isupper
|
||||
#define isupper(c) iswupper(btowc(c))
|
||||
#undef tolower
|
||||
#define tolower(c) towlower(btowc(c))
|
||||
#undef toupper
|
||||
#define toupper(c) towupper(btowc(c))
|
||||
#endif
|
||||
|
||||
|
||||
/* Declarations for symbol visibility.
|
||||
|
||||
PyAPI_FUNC(type): Declares a public Python API function and return type
|
||||
PyAPI_DATA(type): Declares public Python data and its type
|
||||
PyMODINIT_FUNC: A Python module init function. If these functions are
|
||||
inside the Python core, they are private to the core.
|
||||
If in an extension module, it may be declared with
|
||||
external linkage depending on the platform.
|
||||
|
||||
As a number of platforms support/require "__declspec(dllimport/dllexport)",
|
||||
we support a HAVE_DECLSPEC_DLL macro to save duplication.
|
||||
*/
|
||||
|
||||
/*
|
||||
All windows ports, except cygwin, are handled in PC/pyconfig.h.
|
||||
|
||||
BeOS and cygwin are the only other autoconf platform requiring special
|
||||
linkage handling and both of these use __declspec().
|
||||
*/
|
||||
#if defined(__CYGWIN__) || defined(__BEOS__)
|
||||
# define HAVE_DECLSPEC_DLL
|
||||
#endif
|
||||
|
||||
/* only get special linkage if built as shared or platform is Cygwin */
|
||||
#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__)
|
||||
# if defined(HAVE_DECLSPEC_DLL)
|
||||
# ifdef Py_BUILD_CORE
|
||||
# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
|
||||
# define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE
|
||||
/* module init functions inside the core need no external linkage */
|
||||
/* except for Cygwin to handle embedding (FIXME: BeOS too?) */
|
||||
# if defined(__CYGWIN__)
|
||||
# define PyMODINIT_FUNC __declspec(dllexport) void
|
||||
# else /* __CYGWIN__ */
|
||||
# define PyMODINIT_FUNC void
|
||||
# endif /* __CYGWIN__ */
|
||||
# else /* Py_BUILD_CORE */
|
||||
/* Building an extension module, or an embedded situation */
|
||||
/* public Python functions and data are imported */
|
||||
/* Under Cygwin, auto-import functions to prevent compilation */
|
||||
/* failures similar to those described at the bottom of 4.1: */
|
||||
/* http://docs.python.org/extending/windows.html#a-cookbook-approach */
|
||||
# if !defined(__CYGWIN__)
|
||||
# define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE
|
||||
# endif /* !__CYGWIN__ */
|
||||
# define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE
|
||||
/* module init functions outside the core must be exported */
|
||||
# if defined(__cplusplus)
|
||||
# define PyMODINIT_FUNC extern "C" __declspec(dllexport) void
|
||||
# else /* __cplusplus */
|
||||
# define PyMODINIT_FUNC __declspec(dllexport) void
|
||||
# endif /* __cplusplus */
|
||||
# endif /* Py_BUILD_CORE */
|
||||
# endif /* HAVE_DECLSPEC */
|
||||
#endif /* Py_ENABLE_SHARED */
|
||||
|
||||
/* If no external linkage macros defined by now, create defaults */
|
||||
#ifndef PyAPI_FUNC
|
||||
# define PyAPI_FUNC(RTYPE) RTYPE
|
||||
#endif
|
||||
#ifndef PyAPI_DATA
|
||||
# define PyAPI_DATA(RTYPE) extern RTYPE
|
||||
#endif
|
||||
#ifndef PyMODINIT_FUNC
|
||||
# if defined(__cplusplus)
|
||||
# define PyMODINIT_FUNC extern "C" void
|
||||
# else /* __cplusplus */
|
||||
# define PyMODINIT_FUNC void
|
||||
# endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
/* Deprecated DL_IMPORT and DL_EXPORT macros */
|
||||
#if defined(Py_ENABLE_SHARED) && defined (HAVE_DECLSPEC_DLL)
|
||||
# if defined(Py_BUILD_CORE)
|
||||
# define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE
|
||||
# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
|
||||
# else
|
||||
# define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE
|
||||
# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
|
||||
# endif
|
||||
#endif
|
||||
#ifndef DL_EXPORT
|
||||
# define DL_EXPORT(RTYPE) RTYPE
|
||||
#endif
|
||||
#ifndef DL_IMPORT
|
||||
# define DL_IMPORT(RTYPE) RTYPE
|
||||
#endif
|
||||
/* End of deprecated DL_* macros */
|
||||
|
||||
/* If the fd manipulation macros aren't defined,
|
||||
here is a set that should do the job */
|
||||
|
||||
#if 0 /* disabled and probably obsolete */
|
||||
|
||||
#ifndef FD_SETSIZE
|
||||
#define FD_SETSIZE 256
|
||||
#endif
|
||||
|
||||
#ifndef FD_SET
|
||||
|
||||
typedef long fd_mask;
|
||||
|
||||
#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
|
||||
#ifndef howmany
|
||||
#define howmany(x, y) (((x)+((y)-1))/(y))
|
||||
#endif /* howmany */
|
||||
|
||||
typedef struct fd_set {
|
||||
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
|
||||
} fd_set;
|
||||
|
||||
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
|
||||
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
|
||||
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
|
||||
#define FD_ZERO(p) memset((char *)(p), '\0', sizeof(*(p)))
|
||||
|
||||
#endif /* FD_SET */
|
||||
|
||||
#endif /* fd manipulation macros */
|
||||
|
||||
|
||||
/* limits.h constants that may be missing */
|
||||
|
||||
#ifndef INT_MAX
|
||||
#define INT_MAX 2147483647
|
||||
#endif
|
||||
|
||||
#ifndef LONG_MAX
|
||||
#if SIZEOF_LONG == 4
|
||||
#define LONG_MAX 0X7FFFFFFFL
|
||||
#elif SIZEOF_LONG == 8
|
||||
#define LONG_MAX 0X7FFFFFFFFFFFFFFFL
|
||||
#else
|
||||
#error "could not set LONG_MAX in pyport.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LONG_MIN
|
||||
#define LONG_MIN (-LONG_MAX-1)
|
||||
#endif
|
||||
|
||||
#ifndef LONG_BIT
|
||||
#define LONG_BIT (8 * SIZEOF_LONG)
|
||||
#endif
|
||||
|
||||
#if LONG_BIT != 8 * SIZEOF_LONG
|
||||
/* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent
|
||||
* 32-bit platforms using gcc. We try to catch that here at compile-time
|
||||
* rather than waiting for integer multiplication to trigger bogus
|
||||
* overflows.
|
||||
*/
|
||||
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Hide GCC attributes from compilers that don't support them.
|
||||
*/
|
||||
#if (!defined(__GNUC__) || __GNUC__ < 2 || \
|
||||
(__GNUC__ == 2 && __GNUC_MINOR__ < 7) ) && \
|
||||
!defined(RISCOS)
|
||||
#define Py_GCC_ATTRIBUTE(x)
|
||||
#else
|
||||
#define Py_GCC_ATTRIBUTE(x) __attribute__(x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Add PyArg_ParseTuple format where available.
|
||||
*/
|
||||
#ifdef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE
|
||||
#define Py_FORMAT_PARSETUPLE(func,p1,p2) __attribute__((format(func,p1,p2)))
|
||||
#else
|
||||
#define Py_FORMAT_PARSETUPLE(func,p1,p2)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Specify alignment on compilers that support it.
|
||||
*/
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
#define Py_ALIGNED(x) __attribute__((aligned(x)))
|
||||
#else
|
||||
#define Py_ALIGNED(x)
|
||||
#endif
|
||||
|
||||
/* Eliminate end-of-loop code not reached warnings from SunPro C
|
||||
* when using do{...}while(0) macros
|
||||
*/
|
||||
#ifdef __SUNPRO_C
|
||||
#pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Older Microsoft compilers don't support the C99 long long literal suffixes,
|
||||
* so these will be defined in PC/pyconfig.h for those compilers.
|
||||
*/
|
||||
#ifndef Py_LL
|
||||
#define Py_LL(x) x##LL
|
||||
#endif
|
||||
|
||||
#ifndef Py_ULL
|
||||
#define Py_ULL(x) Py_LL(x##U)
|
||||
#endif
|
||||
|
||||
#endif /* Py_PYPORT_H */
|
200
c/meterpreter/source/extensions/python/Include/pystate.h
Normal file
200
c/meterpreter/source/extensions/python/Include/pystate.h
Normal file
@ -0,0 +1,200 @@
|
||||
|
||||
/* Thread and interpreter state structures and their interfaces */
|
||||
|
||||
|
||||
#ifndef Py_PYSTATE_H
|
||||
#define Py_PYSTATE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* State shared between threads */
|
||||
|
||||
struct _ts; /* Forward */
|
||||
struct _is; /* Forward */
|
||||
|
||||
typedef struct _is {
|
||||
|
||||
struct _is *next;
|
||||
struct _ts *tstate_head;
|
||||
|
||||
PyObject *modules;
|
||||
PyObject *sysdict;
|
||||
PyObject *builtins;
|
||||
PyObject *modules_reloading;
|
||||
|
||||
PyObject *codec_search_path;
|
||||
PyObject *codec_search_cache;
|
||||
PyObject *codec_error_registry;
|
||||
|
||||
#ifdef HAVE_DLOPEN
|
||||
int dlopenflags;
|
||||
#endif
|
||||
#ifdef WITH_TSC
|
||||
int tscdump;
|
||||
#endif
|
||||
|
||||
} PyInterpreterState;
|
||||
|
||||
|
||||
/* State unique per thread */
|
||||
|
||||
struct _frame; /* Avoid including frameobject.h */
|
||||
|
||||
/* Py_tracefunc return -1 when raising an exception, or 0 for success. */
|
||||
typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);
|
||||
|
||||
/* The following values are used for 'what' for tracefunc functions: */
|
||||
#define PyTrace_CALL 0
|
||||
#define PyTrace_EXCEPTION 1
|
||||
#define PyTrace_LINE 2
|
||||
#define PyTrace_RETURN 3
|
||||
#define PyTrace_C_CALL 4
|
||||
#define PyTrace_C_EXCEPTION 5
|
||||
#define PyTrace_C_RETURN 6
|
||||
|
||||
typedef struct _ts {
|
||||
/* See Python/ceval.c for comments explaining most fields */
|
||||
|
||||
struct _ts *next;
|
||||
PyInterpreterState *interp;
|
||||
|
||||
struct _frame *frame;
|
||||
int recursion_depth;
|
||||
/* 'tracing' keeps track of the execution depth when tracing/profiling.
|
||||
This is to prevent the actual trace/profile code from being recorded in
|
||||
the trace/profile. */
|
||||
int tracing;
|
||||
int use_tracing;
|
||||
|
||||
Py_tracefunc c_profilefunc;
|
||||
Py_tracefunc c_tracefunc;
|
||||
PyObject *c_profileobj;
|
||||
PyObject *c_traceobj;
|
||||
|
||||
PyObject *curexc_type;
|
||||
PyObject *curexc_value;
|
||||
PyObject *curexc_traceback;
|
||||
|
||||
PyObject *exc_type;
|
||||
PyObject *exc_value;
|
||||
PyObject *exc_traceback;
|
||||
|
||||
PyObject *dict; /* Stores per-thread state */
|
||||
|
||||
/* tick_counter is incremented whenever the check_interval ticker
|
||||
* reaches zero. The purpose is to give a useful measure of the number
|
||||
* of interpreted bytecode instructions in a given thread. This
|
||||
* extremely lightweight statistic collector may be of interest to
|
||||
* profilers (like psyco.jit()), although nothing in the core uses it.
|
||||
*/
|
||||
int tick_counter;
|
||||
|
||||
int gilstate_counter;
|
||||
|
||||
PyObject *async_exc; /* Asynchronous exception to raise */
|
||||
long thread_id; /* Thread id where this tstate was created */
|
||||
|
||||
int trash_delete_nesting;
|
||||
PyObject *trash_delete_later;
|
||||
|
||||
/* XXX signal handlers should also be here */
|
||||
|
||||
} PyThreadState;
|
||||
|
||||
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);
|
||||
PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *);
|
||||
PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *);
|
||||
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
|
||||
PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *);
|
||||
PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *);
|
||||
PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
|
||||
PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);
|
||||
#ifdef WITH_THREAD
|
||||
PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void);
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *);
|
||||
PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void);
|
||||
PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *);
|
||||
|
||||
|
||||
/* Variable and macro for in-line access to current thread state */
|
||||
|
||||
PyAPI_DATA(PyThreadState *) _PyThreadState_Current;
|
||||
|
||||
#ifdef Py_DEBUG
|
||||
#define PyThreadState_GET() PyThreadState_Get()
|
||||
#else
|
||||
#define PyThreadState_GET() (_PyThreadState_Current)
|
||||
#endif
|
||||
|
||||
typedef
|
||||
enum {PyGILState_LOCKED, PyGILState_UNLOCKED}
|
||||
PyGILState_STATE;
|
||||
|
||||
/* Ensure that the current thread is ready to call the Python
|
||||
C API, regardless of the current state of Python, or of its
|
||||
thread lock. This may be called as many times as desired
|
||||
by a thread so long as each call is matched with a call to
|
||||
PyGILState_Release(). In general, other thread-state APIs may
|
||||
be used between _Ensure() and _Release() calls, so long as the
|
||||
thread-state is restored to its previous state before the Release().
|
||||
For example, normal use of the Py_BEGIN_ALLOW_THREADS/
|
||||
Py_END_ALLOW_THREADS macros are acceptable.
|
||||
|
||||
The return value is an opaque "handle" to the thread state when
|
||||
PyGILState_Ensure() was called, and must be passed to
|
||||
PyGILState_Release() to ensure Python is left in the same state. Even
|
||||
though recursive calls are allowed, these handles can *not* be shared -
|
||||
each unique call to PyGILState_Ensure must save the handle for its
|
||||
call to PyGILState_Release.
|
||||
|
||||
When the function returns, the current thread will hold the GIL.
|
||||
|
||||
Failure is a fatal error.
|
||||
*/
|
||||
PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void);
|
||||
|
||||
/* Release any resources previously acquired. After this call, Python's
|
||||
state will be the same as it was prior to the corresponding
|
||||
PyGILState_Ensure() call (but generally this state will be unknown to
|
||||
the caller, hence the use of the GILState API.)
|
||||
|
||||
Every call to PyGILState_Ensure must be matched by a call to
|
||||
PyGILState_Release on the same thread.
|
||||
*/
|
||||
PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE);
|
||||
|
||||
/* Helper/diagnostic function - get the current thread state for
|
||||
this thread. May return NULL if no GILState API has been used
|
||||
on the current thread. Note that the main thread always has such a
|
||||
thread-state, even if no auto-thread-state call has been made
|
||||
on the main thread.
|
||||
*/
|
||||
PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);
|
||||
|
||||
/* The implementation of sys._current_frames() Returns a dict mapping
|
||||
thread id to that thread's current frame.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);
|
||||
|
||||
/* Routines for advanced debuggers, requested by David Beazley.
|
||||
Don't use unless you know what you are doing! */
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
|
||||
PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
|
||||
|
||||
typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
|
||||
|
||||
/* hook for PyEval_GetFrame(), requested for Psyco */
|
||||
PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_PYSTATE_H */
|
23
c/meterpreter/source/extensions/python/Include/pystrcmp.h
Normal file
23
c/meterpreter/source/extensions/python/Include/pystrcmp.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef Py_STRCMP_H
|
||||
#define Py_STRCMP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) PyOS_mystrnicmp(const char *, const char *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyOS_mystricmp(const char *, const char *);
|
||||
|
||||
#if defined(MS_WINDOWS) || defined(PYOS_OS2)
|
||||
#define PyOS_strnicmp strnicmp
|
||||
#define PyOS_stricmp stricmp
|
||||
#else
|
||||
#define PyOS_strnicmp PyOS_mystrnicmp
|
||||
#define PyOS_stricmp PyOS_mystricmp
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !Py_STRCMP_H */
|
45
c/meterpreter/source/extensions/python/Include/pystrtod.h
Normal file
45
c/meterpreter/source/extensions/python/Include/pystrtod.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef Py_STRTOD_H
|
||||
#define Py_STRTOD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
PyAPI_FUNC(double) PyOS_ascii_strtod(const char *str, char **ptr);
|
||||
PyAPI_FUNC(double) PyOS_ascii_atof(const char *str);
|
||||
|
||||
/* Deprecated in 2.7 and 3.1. Will disappear in 2.8 (if it exists) and 3.2 */
|
||||
PyAPI_FUNC(char *) PyOS_ascii_formatd(char *buffer, size_t buf_len,
|
||||
const char *format, double d);
|
||||
PyAPI_FUNC(double) PyOS_string_to_double(const char *str,
|
||||
char **endptr,
|
||||
PyObject *overflow_exception);
|
||||
|
||||
/* The caller is responsible for calling PyMem_Free to free the buffer
|
||||
that's is returned. */
|
||||
PyAPI_FUNC(char *) PyOS_double_to_string(double val,
|
||||
char format_code,
|
||||
int precision,
|
||||
int flags,
|
||||
int *type);
|
||||
|
||||
PyAPI_FUNC(double) _Py_parse_inf_or_nan(const char *p, char **endptr);
|
||||
|
||||
|
||||
/* PyOS_double_to_string's "flags" parameter can be set to 0 or more of: */
|
||||
#define Py_DTSF_SIGN 0x01 /* always add the sign */
|
||||
#define Py_DTSF_ADD_DOT_0 0x02 /* if the result is an integer add ".0" */
|
||||
#define Py_DTSF_ALT 0x04 /* "alternate" formatting. it's format_code
|
||||
specific */
|
||||
|
||||
/* PyOS_double_to_string's "type", if non-NULL, will be set to one of: */
|
||||
#define Py_DTST_FINITE 0
|
||||
#define Py_DTST_INFINITE 1
|
||||
#define Py_DTST_NAN 2
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !Py_STRTOD_H */
|
182
c/meterpreter/source/extensions/python/Include/pythonrun.h
Normal file
182
c/meterpreter/source/extensions/python/Include/pythonrun.h
Normal file
@ -0,0 +1,182 @@
|
||||
|
||||
/* Interfaces to parse and execute pieces of python code */
|
||||
|
||||
#ifndef Py_PYTHONRUN_H
|
||||
#define Py_PYTHONRUN_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \
|
||||
CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \
|
||||
CO_FUTURE_UNICODE_LITERALS)
|
||||
#define PyCF_MASK_OBSOLETE (CO_NESTED)
|
||||
#define PyCF_SOURCE_IS_UTF8 0x0100
|
||||
#define PyCF_DONT_IMPLY_DEDENT 0x0200
|
||||
#define PyCF_ONLY_AST 0x0400
|
||||
|
||||
typedef struct {
|
||||
int cf_flags; /* bitmask of CO_xxx flags relevant to future */
|
||||
} PyCompilerFlags;
|
||||
|
||||
PyAPI_FUNC(void) Py_SetProgramName(char *);
|
||||
PyAPI_FUNC(char *) Py_GetProgramName(void);
|
||||
|
||||
PyAPI_FUNC(void) Py_SetPythonHome(char *);
|
||||
PyAPI_FUNC(char *) Py_GetPythonHome(void);
|
||||
|
||||
PyAPI_FUNC(void) Py_Initialize(void);
|
||||
PyAPI_FUNC(void) Py_InitializeEx(int);
|
||||
PyAPI_FUNC(void) Py_Finalize(void);
|
||||
PyAPI_FUNC(int) Py_IsInitialized(void);
|
||||
PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void);
|
||||
PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *);
|
||||
|
||||
PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
|
||||
PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
|
||||
PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
|
||||
PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
|
||||
PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *);
|
||||
PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *);
|
||||
|
||||
PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(const char *, const char *,
|
||||
int, PyCompilerFlags *flags,
|
||||
PyArena *);
|
||||
PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(FILE *, const char *, int,
|
||||
char *, char *,
|
||||
PyCompilerFlags *, int *,
|
||||
PyArena *);
|
||||
#define PyParser_SimpleParseString(S, B) \
|
||||
PyParser_SimpleParseStringFlags(S, B, 0)
|
||||
#define PyParser_SimpleParseFile(FP, S, B) \
|
||||
PyParser_SimpleParseFileFlags(FP, S, B, 0)
|
||||
PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int,
|
||||
int);
|
||||
PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *,
|
||||
int, int);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
|
||||
PyObject *, PyCompilerFlags *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int,
|
||||
PyObject *, PyObject *, int,
|
||||
PyCompilerFlags *);
|
||||
|
||||
#define Py_CompileString(str, p, s) Py_CompileStringFlags(str, p, s, NULL)
|
||||
PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int,
|
||||
PyCompilerFlags *);
|
||||
PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int);
|
||||
|
||||
PyAPI_FUNC(void) PyErr_Print(void);
|
||||
PyAPI_FUNC(void) PyErr_PrintEx(int);
|
||||
PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(int) Py_AtExit(void (*func)(void));
|
||||
|
||||
PyAPI_FUNC(void) Py_Exit(int);
|
||||
|
||||
PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
|
||||
|
||||
/* Bootstrap */
|
||||
PyAPI_FUNC(int) Py_Main(int argc, char **argv);
|
||||
|
||||
/* Use macros for a bunch of old variants */
|
||||
#define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
|
||||
#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
|
||||
#define PyRun_AnyFileEx(fp, name, closeit) \
|
||||
PyRun_AnyFileExFlags(fp, name, closeit, NULL)
|
||||
#define PyRun_AnyFileFlags(fp, name, flags) \
|
||||
PyRun_AnyFileExFlags(fp, name, 0, flags)
|
||||
#define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL)
|
||||
#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL)
|
||||
#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL)
|
||||
#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL)
|
||||
#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL)
|
||||
#define PyRun_File(fp, p, s, g, l) \
|
||||
PyRun_FileExFlags(fp, p, s, g, l, 0, NULL)
|
||||
#define PyRun_FileEx(fp, p, s, g, l, c) \
|
||||
PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
|
||||
#define PyRun_FileFlags(fp, p, s, g, l, flags) \
|
||||
PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
|
||||
|
||||
/* In getpath.c */
|
||||
PyAPI_FUNC(char *) Py_GetProgramFullPath(void);
|
||||
PyAPI_FUNC(char *) Py_GetPrefix(void);
|
||||
PyAPI_FUNC(char *) Py_GetExecPrefix(void);
|
||||
PyAPI_FUNC(char *) Py_GetPath(void);
|
||||
|
||||
/* In their own files */
|
||||
PyAPI_FUNC(const char *) Py_GetVersion(void);
|
||||
PyAPI_FUNC(const char *) Py_GetPlatform(void);
|
||||
PyAPI_FUNC(const char *) Py_GetCopyright(void);
|
||||
PyAPI_FUNC(const char *) Py_GetCompiler(void);
|
||||
PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
|
||||
PyAPI_FUNC(const char *) _Py_svnversion(void);
|
||||
PyAPI_FUNC(const char *) Py_SubversionRevision(void);
|
||||
PyAPI_FUNC(const char *) Py_SubversionShortBranch(void);
|
||||
PyAPI_FUNC(const char *) _Py_hgidentifier(void);
|
||||
PyAPI_FUNC(const char *) _Py_hgversion(void);
|
||||
|
||||
/* Internal -- various one-time initializations */
|
||||
PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void);
|
||||
PyAPI_FUNC(PyObject *) _PySys_Init(void);
|
||||
PyAPI_FUNC(void) _PyImport_Init(void);
|
||||
PyAPI_FUNC(void) _PyExc_Init(void);
|
||||
PyAPI_FUNC(void) _PyImportHooks_Init(void);
|
||||
PyAPI_FUNC(int) _PyFrame_Init(void);
|
||||
PyAPI_FUNC(int) _PyInt_Init(void);
|
||||
PyAPI_FUNC(int) _PyLong_Init(void);
|
||||
PyAPI_FUNC(void) _PyFloat_Init(void);
|
||||
PyAPI_FUNC(int) PyByteArray_Init(void);
|
||||
PyAPI_FUNC(void) _PyRandom_Init(void);
|
||||
|
||||
/* Various internal finalizers */
|
||||
PyAPI_FUNC(void) _PyExc_Fini(void);
|
||||
PyAPI_FUNC(void) _PyImport_Fini(void);
|
||||
PyAPI_FUNC(void) PyMethod_Fini(void);
|
||||
PyAPI_FUNC(void) PyFrame_Fini(void);
|
||||
PyAPI_FUNC(void) PyCFunction_Fini(void);
|
||||
PyAPI_FUNC(void) PyDict_Fini(void);
|
||||
PyAPI_FUNC(void) PyTuple_Fini(void);
|
||||
PyAPI_FUNC(void) PyList_Fini(void);
|
||||
PyAPI_FUNC(void) PySet_Fini(void);
|
||||
PyAPI_FUNC(void) PyString_Fini(void);
|
||||
PyAPI_FUNC(void) PyInt_Fini(void);
|
||||
PyAPI_FUNC(void) PyFloat_Fini(void);
|
||||
PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
|
||||
PyAPI_FUNC(void) PyByteArray_Fini(void);
|
||||
PyAPI_FUNC(void) _PyRandom_Fini(void);
|
||||
|
||||
/* Stuff with no proper home (yet) */
|
||||
PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
|
||||
PyAPI_DATA(int) (*PyOS_InputHook)(void);
|
||||
PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);
|
||||
PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
|
||||
|
||||
/* Stack size, in "pointers" (so we get extra safety margins
|
||||
on 64-bit platforms). On a 32-bit platform, this translates
|
||||
to a 8k margin. */
|
||||
#define PYOS_STACK_MARGIN 2048
|
||||
|
||||
#if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) && _MSC_VER >= 1300
|
||||
/* Enable stack checking under Microsoft C */
|
||||
#define USE_STACKCHECK
|
||||
#endif
|
||||
|
||||
#ifdef USE_STACKCHECK
|
||||
/* Check that we aren't overflowing our stack */
|
||||
PyAPI_FUNC(int) PyOS_CheckStack(void);
|
||||
#endif
|
||||
|
||||
/* Signals */
|
||||
typedef void (*PyOS_sighandler_t)(int);
|
||||
PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int);
|
||||
PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
|
||||
|
||||
/* Random */
|
||||
PyAPI_FUNC(int) _PyOS_URandom (void *buffer, Py_ssize_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_PYTHONRUN_H */
|
41
c/meterpreter/source/extensions/python/Include/pythread.h
Normal file
41
c/meterpreter/source/extensions/python/Include/pythread.h
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
#ifndef Py_PYTHREAD_H
|
||||
#define Py_PYTHREAD_H
|
||||
|
||||
typedef void *PyThread_type_lock;
|
||||
typedef void *PyThread_type_sema;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(void) PyThread_init_thread(void);
|
||||
PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *);
|
||||
PyAPI_FUNC(void) PyThread_exit_thread(void);
|
||||
PyAPI_FUNC(long) PyThread_get_thread_ident(void);
|
||||
|
||||
PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void);
|
||||
PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock);
|
||||
PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int);
|
||||
#define WAIT_LOCK 1
|
||||
#define NOWAIT_LOCK 0
|
||||
PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock);
|
||||
|
||||
PyAPI_FUNC(size_t) PyThread_get_stacksize(void);
|
||||
PyAPI_FUNC(int) PyThread_set_stacksize(size_t);
|
||||
|
||||
/* Thread Local Storage (TLS) API */
|
||||
PyAPI_FUNC(int) PyThread_create_key(void);
|
||||
PyAPI_FUNC(void) PyThread_delete_key(int);
|
||||
PyAPI_FUNC(int) PyThread_set_key_value(int, void *);
|
||||
PyAPI_FUNC(void *) PyThread_get_key_value(int);
|
||||
PyAPI_FUNC(void) PyThread_delete_key_value(int key);
|
||||
|
||||
/* Cleanup after a fork */
|
||||
PyAPI_FUNC(void) PyThread_ReInitTLS(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !Py_PYTHREAD_H */
|
28
c/meterpreter/source/extensions/python/Include/rangeobject.h
Normal file
28
c/meterpreter/source/extensions/python/Include/rangeobject.h
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
/* Range object interface */
|
||||
|
||||
#ifndef Py_RANGEOBJECT_H
|
||||
#define Py_RANGEOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* This is about the type 'xrange', not the built-in function range(), which
|
||||
returns regular lists. */
|
||||
|
||||
/*
|
||||
A range object represents an integer range. This is an immutable object;
|
||||
a range cannot change its value after creation.
|
||||
|
||||
Range objects behave like the corresponding tuple objects except that
|
||||
they are represented by a start, stop, and step datamembers.
|
||||
*/
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyRange_Type;
|
||||
|
||||
#define PyRange_Check(op) (Py_TYPE(op) == &PyRange_Type)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_RANGEOBJECT_H */
|
99
c/meterpreter/source/extensions/python/Include/setobject.h
Normal file
99
c/meterpreter/source/extensions/python/Include/setobject.h
Normal file
@ -0,0 +1,99 @@
|
||||
/* Set object interface */
|
||||
|
||||
#ifndef Py_SETOBJECT_H
|
||||
#define Py_SETOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
There are three kinds of slots in the table:
|
||||
|
||||
1. Unused: key == NULL
|
||||
2. Active: key != NULL and key != dummy
|
||||
3. Dummy: key == dummy
|
||||
|
||||
Note: .pop() abuses the hash field of an Unused or Dummy slot to
|
||||
hold a search finger. The hash field of Unused or Dummy slots has
|
||||
no meaning otherwise.
|
||||
*/
|
||||
|
||||
#define PySet_MINSIZE 8
|
||||
|
||||
typedef struct {
|
||||
long hash; /* cached hash code for the entry key */
|
||||
PyObject *key;
|
||||
} setentry;
|
||||
|
||||
|
||||
/*
|
||||
This data structure is shared by set and frozenset objects.
|
||||
*/
|
||||
|
||||
typedef struct _setobject PySetObject;
|
||||
struct _setobject {
|
||||
PyObject_HEAD
|
||||
|
||||
Py_ssize_t fill; /* # Active + # Dummy */
|
||||
Py_ssize_t used; /* # Active */
|
||||
|
||||
/* The table contains mask + 1 slots, and that's a power of 2.
|
||||
* We store the mask instead of the size because the mask is more
|
||||
* frequently needed.
|
||||
*/
|
||||
Py_ssize_t mask;
|
||||
|
||||
/* table points to smalltable for small tables, else to
|
||||
* additional malloc'ed memory. table is never NULL! This rule
|
||||
* saves repeated runtime null-tests.
|
||||
*/
|
||||
setentry *table;
|
||||
setentry *(*lookup)(PySetObject *so, PyObject *key, long hash);
|
||||
setentry smalltable[PySet_MINSIZE];
|
||||
|
||||
long hash; /* only used by frozenset objects */
|
||||
PyObject *weakreflist; /* List of weak references */
|
||||
};
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PySet_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyFrozenSet_Type;
|
||||
|
||||
/* Invariants for frozensets:
|
||||
* data is immutable.
|
||||
* hash is the hash of the frozenset or -1 if not computed yet.
|
||||
* Invariants for sets:
|
||||
* hash is -1
|
||||
*/
|
||||
|
||||
#define PyFrozenSet_CheckExact(ob) (Py_TYPE(ob) == &PyFrozenSet_Type)
|
||||
#define PyAnySet_CheckExact(ob) \
|
||||
(Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type)
|
||||
#define PyAnySet_Check(ob) \
|
||||
(Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type || \
|
||||
PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \
|
||||
PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type))
|
||||
#define PySet_Check(ob) \
|
||||
(Py_TYPE(ob) == &PySet_Type || \
|
||||
PyType_IsSubtype(Py_TYPE(ob), &PySet_Type))
|
||||
#define PyFrozenSet_Check(ob) \
|
||||
(Py_TYPE(ob) == &PyFrozenSet_Type || \
|
||||
PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type))
|
||||
|
||||
PyAPI_FUNC(PyObject *) PySet_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *);
|
||||
PyAPI_FUNC(Py_ssize_t) PySet_Size(PyObject *anyset);
|
||||
#define PySet_GET_SIZE(so) (((PySetObject *)(so))->used)
|
||||
PyAPI_FUNC(int) PySet_Clear(PyObject *set);
|
||||
PyAPI_FUNC(int) PySet_Contains(PyObject *anyset, PyObject *key);
|
||||
PyAPI_FUNC(int) PySet_Discard(PyObject *set, PyObject *key);
|
||||
PyAPI_FUNC(int) PySet_Add(PyObject *set, PyObject *key);
|
||||
PyAPI_FUNC(int) _PySet_Next(PyObject *set, Py_ssize_t *pos, PyObject **key);
|
||||
PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, long *hash);
|
||||
PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set);
|
||||
PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_SETOBJECT_H */
|
44
c/meterpreter/source/extensions/python/Include/sliceobject.h
Normal file
44
c/meterpreter/source/extensions/python/Include/sliceobject.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef Py_SLICEOBJECT_H
|
||||
#define Py_SLICEOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The unique ellipsis object "..." */
|
||||
|
||||
PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */
|
||||
|
||||
#define Py_Ellipsis (&_Py_EllipsisObject)
|
||||
|
||||
/* Slice object interface */
|
||||
|
||||
/*
|
||||
|
||||
A slice object containing start, stop, and step data members (the
|
||||
names are from range). After much talk with Guido, it was decided to
|
||||
let these be any arbitrary python type. Py_None stands for omitted values.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *start, *stop, *step; /* not NULL */
|
||||
} PySliceObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PySlice_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyEllipsis_Type;
|
||||
|
||||
#define PySlice_Check(op) (Py_TYPE(op) == &PySlice_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
|
||||
PyObject* step);
|
||||
PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop);
|
||||
PyAPI_FUNC(int) PySlice_GetIndices(PySliceObject *r, Py_ssize_t length,
|
||||
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
|
||||
PyAPI_FUNC(int) PySlice_GetIndicesEx(PySliceObject *r, Py_ssize_t length,
|
||||
Py_ssize_t *start, Py_ssize_t *stop,
|
||||
Py_ssize_t *step, Py_ssize_t *slicelength);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_SLICEOBJECT_H */
|
210
c/meterpreter/source/extensions/python/Include/stringobject.h
Normal file
210
c/meterpreter/source/extensions/python/Include/stringobject.h
Normal file
@ -0,0 +1,210 @@
|
||||
|
||||
/* String (str/bytes) object interface */
|
||||
|
||||
#ifndef Py_STRINGOBJECT_H
|
||||
#define Py_STRINGOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
/*
|
||||
Type PyStringObject represents a character string. An extra zero byte is
|
||||
reserved at the end to ensure it is zero-terminated, but a size is
|
||||
present so strings with null bytes in them can be represented. This
|
||||
is an immutable object type.
|
||||
|
||||
There are functions to create new string objects, to test
|
||||
an object for string-ness, and to get the
|
||||
string value. The latter function returns a null pointer
|
||||
if the object is not of the proper type.
|
||||
There is a variant that takes an explicit size as well as a
|
||||
variant that assumes a zero-terminated string. Note that none of the
|
||||
functions should be applied to nil objects.
|
||||
*/
|
||||
|
||||
/* Caching the hash (ob_shash) saves recalculation of a string's hash value.
|
||||
Interning strings (ob_sstate) tries to ensure that only one string
|
||||
object with a given value exists, so equality tests can be one pointer
|
||||
comparison. This is generally restricted to strings that "look like"
|
||||
Python identifiers, although the intern() builtin can be used to force
|
||||
interning of any string.
|
||||
Together, these sped the interpreter by up to 20%. */
|
||||
|
||||
typedef struct {
|
||||
PyObject_VAR_HEAD
|
||||
long ob_shash;
|
||||
int ob_sstate;
|
||||
char ob_sval[1];
|
||||
|
||||
/* Invariants:
|
||||
* ob_sval contains space for 'ob_size+1' elements.
|
||||
* ob_sval[ob_size] == 0.
|
||||
* ob_shash is the hash of the string or -1 if not computed yet.
|
||||
* ob_sstate != 0 iff the string object is in stringobject.c's
|
||||
* 'interned' dictionary; in this case the two references
|
||||
* from 'interned' to this object are *not counted* in ob_refcnt.
|
||||
*/
|
||||
} PyStringObject;
|
||||
|
||||
#define SSTATE_NOT_INTERNED 0
|
||||
#define SSTATE_INTERNED_MORTAL 1
|
||||
#define SSTATE_INTERNED_IMMORTAL 2
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyBaseString_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyString_Type;
|
||||
|
||||
#define PyString_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_STRING_SUBCLASS)
|
||||
#define PyString_CheckExact(op) (Py_TYPE(op) == &PyString_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t);
|
||||
PyAPI_FUNC(PyObject *) PyString_FromString(const char *);
|
||||
PyAPI_FUNC(PyObject *) PyString_FromFormatV(const char*, va_list)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
|
||||
PyAPI_FUNC(PyObject *) PyString_FromFormat(const char*, ...)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
|
||||
PyAPI_FUNC(Py_ssize_t) PyString_Size(PyObject *);
|
||||
PyAPI_FUNC(char *) PyString_AsString(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyString_Repr(PyObject *, int);
|
||||
PyAPI_FUNC(void) PyString_Concat(PyObject **, PyObject *);
|
||||
PyAPI_FUNC(void) PyString_ConcatAndDel(PyObject **, PyObject *);
|
||||
PyAPI_FUNC(int) _PyString_Resize(PyObject **, Py_ssize_t);
|
||||
PyAPI_FUNC(int) _PyString_Eq(PyObject *, PyObject*);
|
||||
PyAPI_FUNC(PyObject *) PyString_Format(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyString_FormatLong(PyObject*, int, int,
|
||||
int, char**, int*);
|
||||
PyAPI_FUNC(PyObject *) PyString_DecodeEscape(const char *, Py_ssize_t,
|
||||
const char *, Py_ssize_t,
|
||||
const char *);
|
||||
|
||||
PyAPI_FUNC(void) PyString_InternInPlace(PyObject **);
|
||||
PyAPI_FUNC(void) PyString_InternImmortal(PyObject **);
|
||||
PyAPI_FUNC(PyObject *) PyString_InternFromString(const char *);
|
||||
PyAPI_FUNC(void) _Py_ReleaseInternedStrings(void);
|
||||
|
||||
/* Use only if you know it's a string */
|
||||
#define PyString_CHECK_INTERNED(op) (((PyStringObject *)(op))->ob_sstate)
|
||||
|
||||
/* Macro, trading safety for speed */
|
||||
#define PyString_AS_STRING(op) (((PyStringObject *)(op))->ob_sval)
|
||||
#define PyString_GET_SIZE(op) Py_SIZE(op)
|
||||
|
||||
/* _PyString_Join(sep, x) is like sep.join(x). sep must be PyStringObject*,
|
||||
x must be an iterable object. */
|
||||
PyAPI_FUNC(PyObject *) _PyString_Join(PyObject *sep, PyObject *x);
|
||||
|
||||
/* --- Generic Codecs ----------------------------------------------------- */
|
||||
|
||||
/* Create an object by decoding the encoded string s of the
|
||||
given size. */
|
||||
|
||||
PyAPI_FUNC(PyObject*) PyString_Decode(
|
||||
const char *s, /* encoded string */
|
||||
Py_ssize_t size, /* size of buffer */
|
||||
const char *encoding, /* encoding */
|
||||
const char *errors /* error handling */
|
||||
);
|
||||
|
||||
/* Encodes a char buffer of the given size and returns a
|
||||
Python object. */
|
||||
|
||||
PyAPI_FUNC(PyObject*) PyString_Encode(
|
||||
const char *s, /* string char buffer */
|
||||
Py_ssize_t size, /* number of chars to encode */
|
||||
const char *encoding, /* encoding */
|
||||
const char *errors /* error handling */
|
||||
);
|
||||
|
||||
/* Encodes a string object and returns the result as Python
|
||||
object. */
|
||||
|
||||
PyAPI_FUNC(PyObject*) PyString_AsEncodedObject(
|
||||
PyObject *str, /* string object */
|
||||
const char *encoding, /* encoding */
|
||||
const char *errors /* error handling */
|
||||
);
|
||||
|
||||
/* Encodes a string object and returns the result as Python string
|
||||
object.
|
||||
|
||||
If the codec returns an Unicode object, the object is converted
|
||||
back to a string using the default encoding.
|
||||
|
||||
DEPRECATED - use PyString_AsEncodedObject() instead. */
|
||||
|
||||
PyAPI_FUNC(PyObject*) PyString_AsEncodedString(
|
||||
PyObject *str, /* string object */
|
||||
const char *encoding, /* encoding */
|
||||
const char *errors /* error handling */
|
||||
);
|
||||
|
||||
/* Decodes a string object and returns the result as Python
|
||||
object. */
|
||||
|
||||
PyAPI_FUNC(PyObject*) PyString_AsDecodedObject(
|
||||
PyObject *str, /* string object */
|
||||
const char *encoding, /* encoding */
|
||||
const char *errors /* error handling */
|
||||
);
|
||||
|
||||
/* Decodes a string object and returns the result as Python string
|
||||
object.
|
||||
|
||||
If the codec returns an Unicode object, the object is converted
|
||||
back to a string using the default encoding.
|
||||
|
||||
DEPRECATED - use PyString_AsDecodedObject() instead. */
|
||||
|
||||
PyAPI_FUNC(PyObject*) PyString_AsDecodedString(
|
||||
PyObject *str, /* string object */
|
||||
const char *encoding, /* encoding */
|
||||
const char *errors /* error handling */
|
||||
);
|
||||
|
||||
/* Provides access to the internal data buffer and size of a string
|
||||
object or the default encoded version of an Unicode object. Passing
|
||||
NULL as *len parameter will force the string buffer to be
|
||||
0-terminated (passing a string with embedded NULL characters will
|
||||
cause an exception). */
|
||||
|
||||
PyAPI_FUNC(int) PyString_AsStringAndSize(
|
||||
register PyObject *obj, /* string or Unicode object */
|
||||
register char **s, /* pointer to buffer variable */
|
||||
register Py_ssize_t *len /* pointer to length variable or NULL
|
||||
(only possible for 0-terminated
|
||||
strings) */
|
||||
);
|
||||
|
||||
|
||||
/* Using the current locale, insert the thousands grouping
|
||||
into the string pointed to by buffer. For the argument descriptions,
|
||||
see Objects/stringlib/localeutil.h */
|
||||
PyAPI_FUNC(Py_ssize_t) _PyString_InsertThousandsGroupingLocale(char *buffer,
|
||||
Py_ssize_t n_buffer,
|
||||
char *digits,
|
||||
Py_ssize_t n_digits,
|
||||
Py_ssize_t min_width);
|
||||
|
||||
/* Using explicit passed-in values, insert the thousands grouping
|
||||
into the string pointed to by buffer. For the argument descriptions,
|
||||
see Objects/stringlib/localeutil.h */
|
||||
PyAPI_FUNC(Py_ssize_t) _PyString_InsertThousandsGrouping(char *buffer,
|
||||
Py_ssize_t n_buffer,
|
||||
char *digits,
|
||||
Py_ssize_t n_digits,
|
||||
Py_ssize_t min_width,
|
||||
const char *grouping,
|
||||
const char *thousands_sep);
|
||||
|
||||
/* Format the object based on the format_spec, as defined in PEP 3101
|
||||
(Advanced String Formatting). */
|
||||
PyAPI_FUNC(PyObject *) _PyBytes_FormatAdvanced(PyObject *obj,
|
||||
char *format_spec,
|
||||
Py_ssize_t format_spec_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_STRINGOBJECT_H */
|
@ -0,0 +1,99 @@
|
||||
#ifndef Py_STRUCTMEMBER_H
|
||||
#define Py_STRUCTMEMBER_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Interface to map C struct members to Python object attributes */
|
||||
|
||||
#include <stddef.h> /* For offsetof */
|
||||
|
||||
/* The offsetof() macro calculates the offset of a structure member
|
||||
in its structure. Unfortunately this cannot be written down
|
||||
portably, hence it is provided by a Standard C header file.
|
||||
For pre-Standard C compilers, here is a version that usually works
|
||||
(but watch out!): */
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(type, member) ( (int) & ((type*)0) -> member )
|
||||
#endif
|
||||
|
||||
/* An array of memberlist structures defines the name, type and offset
|
||||
of selected members of a C structure. These can be read by
|
||||
PyMember_Get() and set by PyMember_Set() (except if their READONLY flag
|
||||
is set). The array must be terminated with an entry whose name
|
||||
pointer is NULL. */
|
||||
|
||||
struct memberlist {
|
||||
/* Obsolete version, for binary backwards compatibility */
|
||||
char *name;
|
||||
int type;
|
||||
int offset;
|
||||
int flags;
|
||||
};
|
||||
|
||||
typedef struct PyMemberDef {
|
||||
/* Current version, use this */
|
||||
char *name;
|
||||
int type;
|
||||
Py_ssize_t offset;
|
||||
int flags;
|
||||
char *doc;
|
||||
} PyMemberDef;
|
||||
|
||||
/* Types */
|
||||
#define T_SHORT 0
|
||||
#define T_INT 1
|
||||
#define T_LONG 2
|
||||
#define T_FLOAT 3
|
||||
#define T_DOUBLE 4
|
||||
#define T_STRING 5
|
||||
#define T_OBJECT 6
|
||||
/* XXX the ordering here is weird for binary compatibility */
|
||||
#define T_CHAR 7 /* 1-character string */
|
||||
#define T_BYTE 8 /* 8-bit signed int */
|
||||
/* unsigned variants: */
|
||||
#define T_UBYTE 9
|
||||
#define T_USHORT 10
|
||||
#define T_UINT 11
|
||||
#define T_ULONG 12
|
||||
|
||||
/* Added by Jack: strings contained in the structure */
|
||||
#define T_STRING_INPLACE 13
|
||||
|
||||
/* Added by Lillo: bools contained in the structure (assumed char) */
|
||||
#define T_BOOL 14
|
||||
|
||||
#define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError
|
||||
when the value is NULL, instead of
|
||||
converting to None. */
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#define T_LONGLONG 17
|
||||
#define T_ULONGLONG 18
|
||||
#endif /* HAVE_LONG_LONG */
|
||||
|
||||
#define T_PYSSIZET 19 /* Py_ssize_t */
|
||||
|
||||
|
||||
/* Flags */
|
||||
#define READONLY 1
|
||||
#define RO READONLY /* Shorthand */
|
||||
#define READ_RESTRICTED 2
|
||||
#define PY_WRITE_RESTRICTED 4
|
||||
#define RESTRICTED (READ_RESTRICTED | PY_WRITE_RESTRICTED)
|
||||
|
||||
|
||||
/* Obsolete API, for binary backwards compatibility */
|
||||
PyAPI_FUNC(PyObject *) PyMember_Get(const char *, struct memberlist *, const char *);
|
||||
PyAPI_FUNC(int) PyMember_Set(char *, struct memberlist *, const char *, PyObject *);
|
||||
|
||||
/* Current API, use this */
|
||||
PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, struct PyMemberDef *);
|
||||
PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef *, PyObject *);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_STRUCTMEMBER_H */
|
41
c/meterpreter/source/extensions/python/Include/structseq.h
Normal file
41
c/meterpreter/source/extensions/python/Include/structseq.h
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
/* Tuple object interface */
|
||||
|
||||
#ifndef Py_STRUCTSEQ_H
|
||||
#define Py_STRUCTSEQ_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct PyStructSequence_Field {
|
||||
char *name;
|
||||
char *doc;
|
||||
} PyStructSequence_Field;
|
||||
|
||||
typedef struct PyStructSequence_Desc {
|
||||
char *name;
|
||||
char *doc;
|
||||
struct PyStructSequence_Field *fields;
|
||||
int n_in_sequence;
|
||||
} PyStructSequence_Desc;
|
||||
|
||||
extern char* PyStructSequence_UnnamedField;
|
||||
|
||||
PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type,
|
||||
PyStructSequence_Desc *desc);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);
|
||||
|
||||
typedef struct {
|
||||
PyObject_VAR_HEAD
|
||||
PyObject *ob_item[1];
|
||||
} PyStructSequence;
|
||||
|
||||
/* Macro, *only* to be used to fill in brand new objects */
|
||||
#define PyStructSequence_SET_ITEM(op, i, v) \
|
||||
(((PyStructSequence *)(op))->ob_item[i] = v)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_STRUCTSEQ_H */
|
98
c/meterpreter/source/extensions/python/Include/symtable.h
Normal file
98
c/meterpreter/source/extensions/python/Include/symtable.h
Normal file
@ -0,0 +1,98 @@
|
||||
#ifndef Py_SYMTABLE_H
|
||||
#define Py_SYMTABLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock }
|
||||
_Py_block_ty;
|
||||
|
||||
struct _symtable_entry;
|
||||
|
||||
struct symtable {
|
||||
const char *st_filename; /* name of file being compiled */
|
||||
struct _symtable_entry *st_cur; /* current symbol table entry */
|
||||
struct _symtable_entry *st_top; /* module entry */
|
||||
PyObject *st_symbols; /* dictionary of symbol table entries */
|
||||
PyObject *st_stack; /* stack of namespace info */
|
||||
PyObject *st_global; /* borrowed ref to MODULE in st_symbols */
|
||||
int st_nblocks; /* number of blocks */
|
||||
PyObject *st_private; /* name of current class or NULL */
|
||||
PyFutureFeatures *st_future; /* module's future features */
|
||||
};
|
||||
|
||||
typedef struct _symtable_entry {
|
||||
PyObject_HEAD
|
||||
PyObject *ste_id; /* int: key in st_symbols */
|
||||
PyObject *ste_symbols; /* dict: name to flags */
|
||||
PyObject *ste_name; /* string: name of block */
|
||||
PyObject *ste_varnames; /* list of variable names */
|
||||
PyObject *ste_children; /* list of child ids */
|
||||
_Py_block_ty ste_type; /* module, class, or function */
|
||||
int ste_unoptimized; /* false if namespace is optimized */
|
||||
int ste_nested; /* true if block is nested */
|
||||
unsigned ste_free : 1; /* true if block has free variables */
|
||||
unsigned ste_child_free : 1; /* true if a child block has free vars,
|
||||
including free refs to globals */
|
||||
unsigned ste_generator : 1; /* true if namespace is a generator */
|
||||
unsigned ste_varargs : 1; /* true if block has varargs */
|
||||
unsigned ste_varkeywords : 1; /* true if block has varkeywords */
|
||||
unsigned ste_returns_value : 1; /* true if namespace uses return with
|
||||
an argument */
|
||||
int ste_lineno; /* first line of block */
|
||||
int ste_opt_lineno; /* lineno of last exec or import * */
|
||||
int ste_tmpname; /* counter for listcomp temp vars */
|
||||
struct symtable *ste_table;
|
||||
} PySTEntryObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PySTEntry_Type;
|
||||
|
||||
#define PySTEntry_Check(op) (Py_TYPE(op) == &PySTEntry_Type)
|
||||
|
||||
PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(struct symtable *) PySymtable_Build(mod_ty, const char *,
|
||||
PyFutureFeatures *);
|
||||
PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *);
|
||||
|
||||
PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
|
||||
|
||||
/* Flags for def-use information */
|
||||
|
||||
#define DEF_GLOBAL 1 /* global stmt */
|
||||
#define DEF_LOCAL 2 /* assignment in code block */
|
||||
#define DEF_PARAM 2<<1 /* formal parameter */
|
||||
#define USE 2<<2 /* name is used */
|
||||
#define DEF_FREE 2<<3 /* name used but not defined in nested block */
|
||||
#define DEF_FREE_CLASS 2<<4 /* free variable from class's method */
|
||||
#define DEF_IMPORT 2<<5 /* assignment occurred via import */
|
||||
|
||||
#define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT)
|
||||
|
||||
/* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol
|
||||
table. GLOBAL is returned from PyST_GetScope() for either of them.
|
||||
It is stored in ste_symbols at bits 12-14.
|
||||
*/
|
||||
#define SCOPE_OFF 11
|
||||
#define SCOPE_MASK 7
|
||||
|
||||
#define LOCAL 1
|
||||
#define GLOBAL_EXPLICIT 2
|
||||
#define GLOBAL_IMPLICIT 3
|
||||
#define FREE 4
|
||||
#define CELL 5
|
||||
|
||||
/* The following three names are used for the ste_unoptimized bit field */
|
||||
#define OPT_IMPORT_STAR 1
|
||||
#define OPT_EXEC 2
|
||||
#define OPT_BARE_EXEC 4
|
||||
#define OPT_TOPLEVEL 8 /* top-level names, including eval and exec */
|
||||
|
||||
#define GENERATOR 1
|
||||
#define GENERATOR_EXPRESSION 2
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_SYMTABLE_H */
|
31
c/meterpreter/source/extensions/python/Include/sysmodule.h
Normal file
31
c/meterpreter/source/extensions/python/Include/sysmodule.h
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
/* System module interface */
|
||||
|
||||
#ifndef Py_SYSMODULE_H
|
||||
#define Py_SYSMODULE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyObject *) PySys_GetObject(char *);
|
||||
PyAPI_FUNC(int) PySys_SetObject(char *, PyObject *);
|
||||
PyAPI_FUNC(FILE *) PySys_GetFile(char *, FILE *);
|
||||
PyAPI_FUNC(void) PySys_SetArgv(int, char **);
|
||||
PyAPI_FUNC(void) PySys_SetArgvEx(int, char **, int);
|
||||
PyAPI_FUNC(void) PySys_SetPath(char *);
|
||||
|
||||
PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
|
||||
PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
|
||||
|
||||
PyAPI_FUNC(void) PySys_ResetWarnOptions(void);
|
||||
PyAPI_FUNC(void) PySys_AddWarnOption(char *);
|
||||
PyAPI_FUNC(int) PySys_HasWarnOptions(void);
|
||||
|
||||
PyAPI_FUNC(size_t) _PySys_GetSizeOf(PyObject *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_SYSMODULE_H */
|
26
c/meterpreter/source/extensions/python/Include/timefuncs.h
Normal file
26
c/meterpreter/source/extensions/python/Include/timefuncs.h
Normal file
@ -0,0 +1,26 @@
|
||||
/* timefuncs.h
|
||||
*/
|
||||
|
||||
/* Utility function related to timemodule.c. */
|
||||
|
||||
#ifndef TIMEFUNCS_H
|
||||
#define TIMEFUNCS_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Cast double x to time_t, but raise ValueError if x is too large
|
||||
* to fit in a time_t. ValueError is set on return iff the return
|
||||
* value is (time_t)-1 and PyErr_Occurred().
|
||||
*/
|
||||
PyAPI_FUNC(time_t) _PyTime_DoubleToTimet(double x);
|
||||
|
||||
/* Get the current time since the epoch in seconds */
|
||||
PyAPI_FUNC(double) _PyTime_FloatTime(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* TIMEFUNCS_H */
|
85
c/meterpreter/source/extensions/python/Include/token.h
Normal file
85
c/meterpreter/source/extensions/python/Include/token.h
Normal file
@ -0,0 +1,85 @@
|
||||
|
||||
/* Token types */
|
||||
|
||||
#ifndef Py_TOKEN_H
|
||||
#define Py_TOKEN_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#undef TILDE /* Prevent clash of our definition with system macro. Ex AIX, ioctl.h */
|
||||
|
||||
#define ENDMARKER 0
|
||||
#define NAME 1
|
||||
#define NUMBER 2
|
||||
#define STRING 3
|
||||
#define NEWLINE 4
|
||||
#define INDENT 5
|
||||
#define DEDENT 6
|
||||
#define LPAR 7
|
||||
#define RPAR 8
|
||||
#define LSQB 9
|
||||
#define RSQB 10
|
||||
#define COLON 11
|
||||
#define COMMA 12
|
||||
#define SEMI 13
|
||||
#define PLUS 14
|
||||
#define MINUS 15
|
||||
#define STAR 16
|
||||
#define SLASH 17
|
||||
#define VBAR 18
|
||||
#define AMPER 19
|
||||
#define LESS 20
|
||||
#define GREATER 21
|
||||
#define EQUAL 22
|
||||
#define DOT 23
|
||||
#define PERCENT 24
|
||||
#define BACKQUOTE 25
|
||||
#define LBRACE 26
|
||||
#define RBRACE 27
|
||||
#define EQEQUAL 28
|
||||
#define NOTEQUAL 29
|
||||
#define LESSEQUAL 30
|
||||
#define GREATEREQUAL 31
|
||||
#define TILDE 32
|
||||
#define CIRCUMFLEX 33
|
||||
#define LEFTSHIFT 34
|
||||
#define RIGHTSHIFT 35
|
||||
#define DOUBLESTAR 36
|
||||
#define PLUSEQUAL 37
|
||||
#define MINEQUAL 38
|
||||
#define STAREQUAL 39
|
||||
#define SLASHEQUAL 40
|
||||
#define PERCENTEQUAL 41
|
||||
#define AMPEREQUAL 42
|
||||
#define VBAREQUAL 43
|
||||
#define CIRCUMFLEXEQUAL 44
|
||||
#define LEFTSHIFTEQUAL 45
|
||||
#define RIGHTSHIFTEQUAL 46
|
||||
#define DOUBLESTAREQUAL 47
|
||||
#define DOUBLESLASH 48
|
||||
#define DOUBLESLASHEQUAL 49
|
||||
#define AT 50
|
||||
/* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */
|
||||
#define OP 51
|
||||
#define ERRORTOKEN 52
|
||||
#define N_TOKENS 53
|
||||
|
||||
/* Special definitions for cooperation with parser */
|
||||
|
||||
#define NT_OFFSET 256
|
||||
|
||||
#define ISTERMINAL(x) ((x) < NT_OFFSET)
|
||||
#define ISNONTERMINAL(x) ((x) >= NT_OFFSET)
|
||||
#define ISEOF(x) ((x) == ENDMARKER)
|
||||
|
||||
|
||||
PyAPI_DATA(char *) _PyParser_TokenNames[]; /* Token names */
|
||||
PyAPI_FUNC(int) PyToken_OneChar(int);
|
||||
PyAPI_FUNC(int) PyToken_TwoChars(int, int);
|
||||
PyAPI_FUNC(int) PyToken_ThreeChars(int, int, int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_TOKEN_H */
|
31
c/meterpreter/source/extensions/python/Include/traceback.h
Normal file
31
c/meterpreter/source/extensions/python/Include/traceback.h
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
#ifndef Py_TRACEBACK_H
|
||||
#define Py_TRACEBACK_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _frame;
|
||||
|
||||
/* Traceback interface */
|
||||
|
||||
typedef struct _traceback {
|
||||
PyObject_HEAD
|
||||
struct _traceback *tb_next;
|
||||
struct _frame *tb_frame;
|
||||
int tb_lasti;
|
||||
int tb_lineno;
|
||||
} PyTracebackObject;
|
||||
|
||||
PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *);
|
||||
PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, const char *, int, int);
|
||||
|
||||
/* Reveal traceback type so we can typecheck traceback objects */
|
||||
PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
|
||||
#define PyTraceBack_Check(v) (Py_TYPE(v) == &PyTraceBack_Type)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_TRACEBACK_H */
|
61
c/meterpreter/source/extensions/python/Include/tupleobject.h
Normal file
61
c/meterpreter/source/extensions/python/Include/tupleobject.h
Normal file
@ -0,0 +1,61 @@
|
||||
|
||||
/* Tuple object interface */
|
||||
|
||||
#ifndef Py_TUPLEOBJECT_H
|
||||
#define Py_TUPLEOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
Another generally useful object type is a tuple of object pointers.
|
||||
For Python, this is an immutable type. C code can change the tuple items
|
||||
(but not their number), and even use tuples are general-purpose arrays of
|
||||
object references, but in general only brand new tuples should be mutated,
|
||||
not ones that might already have been exposed to Python code.
|
||||
|
||||
*** WARNING *** PyTuple_SetItem does not increment the new item's reference
|
||||
count, but does decrement the reference count of the item it replaces,
|
||||
if not nil. It does *decrement* the reference count if it is *not*
|
||||
inserted in the tuple. Similarly, PyTuple_GetItem does not increment the
|
||||
returned item's reference count.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
PyObject_VAR_HEAD
|
||||
PyObject *ob_item[1];
|
||||
|
||||
/* ob_item contains space for 'ob_size' elements.
|
||||
* Items must normally not be NULL, except during construction when
|
||||
* the tuple is not yet visible outside the function that builds it.
|
||||
*/
|
||||
} PyTupleObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyTuple_Type;
|
||||
|
||||
#define PyTuple_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS)
|
||||
#define PyTuple_CheckExact(op) (Py_TYPE(op) == &PyTuple_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size);
|
||||
PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
|
||||
PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t);
|
||||
PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...);
|
||||
PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
|
||||
|
||||
/* Macro, trading safety for speed */
|
||||
#define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i])
|
||||
#define PyTuple_GET_SIZE(op) Py_SIZE(op)
|
||||
|
||||
/* Macro, *only* to be used to fill in brand new tuples */
|
||||
#define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
|
||||
|
||||
PyAPI_FUNC(int) PyTuple_ClearFreeList(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_TUPLEOBJECT_H */
|
33
c/meterpreter/source/extensions/python/Include/ucnhash.h
Normal file
33
c/meterpreter/source/extensions/python/Include/ucnhash.h
Normal file
@ -0,0 +1,33 @@
|
||||
/* Unicode name database interface */
|
||||
|
||||
#ifndef Py_UCNHASH_H
|
||||
#define Py_UCNHASH_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* revised ucnhash CAPI interface (exported through a "wrapper") */
|
||||
|
||||
#define PyUnicodeData_CAPSULE_NAME "unicodedata.ucnhash_CAPI"
|
||||
|
||||
typedef struct {
|
||||
|
||||
/* Size of this struct */
|
||||
int size;
|
||||
|
||||
/* Get name for a given character code. Returns non-zero if
|
||||
success, zero if not. Does not set Python exceptions.
|
||||
If self is NULL, data come from the default version of the database.
|
||||
If it is not NULL, it should be a unicodedata.ucd_X_Y_Z object */
|
||||
int (*getname)(PyObject *self, Py_UCS4 code, char* buffer, int buflen);
|
||||
|
||||
/* Get character code for a given name. Same error handling
|
||||
as for getname. */
|
||||
int (*getcode)(PyObject *self, const char* name, int namelen, Py_UCS4* code);
|
||||
|
||||
} _PyUnicode_Name_CAPI;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_UCNHASH_H */
|
1413
c/meterpreter/source/extensions/python/Include/unicodeobject.h
Normal file
1413
c/meterpreter/source/extensions/python/Include/unicodeobject.h
Normal file
File diff suppressed because it is too large
Load Diff
23
c/meterpreter/source/extensions/python/Include/warnings.h
Normal file
23
c/meterpreter/source/extensions/python/Include/warnings.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef Py_WARNINGS_H
|
||||
#define Py_WARNINGS_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(void) _PyWarnings_Init(void);
|
||||
|
||||
PyAPI_FUNC(int) PyErr_WarnEx(PyObject *, const char *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *, const char *, int,
|
||||
const char *, PyObject *);
|
||||
|
||||
#define PyErr_WarnPy3k(msg, stacklevel) \
|
||||
(Py_Py3kWarningFlag ? PyErr_WarnEx(PyExc_DeprecationWarning, msg, stacklevel) : 0)
|
||||
|
||||
/* DEPRECATED: Use PyErr_WarnEx() instead. */
|
||||
#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_WARNINGS_H */
|
||||
|
@ -0,0 +1,82 @@
|
||||
/* Weak references objects for Python. */
|
||||
|
||||
#ifndef Py_WEAKREFOBJECT_H
|
||||
#define Py_WEAKREFOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct _PyWeakReference PyWeakReference;
|
||||
|
||||
/* PyWeakReference is the base struct for the Python ReferenceType, ProxyType,
|
||||
* and CallableProxyType.
|
||||
*/
|
||||
struct _PyWeakReference {
|
||||
PyObject_HEAD
|
||||
|
||||
/* The object to which this is a weak reference, or Py_None if none.
|
||||
* Note that this is a stealth reference: wr_object's refcount is
|
||||
* not incremented to reflect this pointer.
|
||||
*/
|
||||
PyObject *wr_object;
|
||||
|
||||
/* A callable to invoke when wr_object dies, or NULL if none. */
|
||||
PyObject *wr_callback;
|
||||
|
||||
/* A cache for wr_object's hash code. As usual for hashes, this is -1
|
||||
* if the hash code isn't known yet.
|
||||
*/
|
||||
long hash;
|
||||
|
||||
/* If wr_object is weakly referenced, wr_object has a doubly-linked NULL-
|
||||
* terminated list of weak references to it. These are the list pointers.
|
||||
* If wr_object goes away, wr_object is set to Py_None, and these pointers
|
||||
* have no meaning then.
|
||||
*/
|
||||
PyWeakReference *wr_prev;
|
||||
PyWeakReference *wr_next;
|
||||
};
|
||||
|
||||
PyAPI_DATA(PyTypeObject) _PyWeakref_RefType;
|
||||
PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType;
|
||||
PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType;
|
||||
|
||||
#define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType)
|
||||
#define PyWeakref_CheckRefExact(op) \
|
||||
(Py_TYPE(op) == &_PyWeakref_RefType)
|
||||
#define PyWeakref_CheckProxy(op) \
|
||||
((Py_TYPE(op) == &_PyWeakref_ProxyType) || \
|
||||
(Py_TYPE(op) == &_PyWeakref_CallableProxyType))
|
||||
|
||||
#define PyWeakref_Check(op) \
|
||||
(PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op))
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob,
|
||||
PyObject *callback);
|
||||
PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob,
|
||||
PyObject *callback);
|
||||
PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref);
|
||||
|
||||
PyAPI_FUNC(Py_ssize_t) _PyWeakref_GetWeakrefCount(PyWeakReference *head);
|
||||
|
||||
PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self);
|
||||
|
||||
/* Explanation for the Py_REFCNT() check: when a weakref's target is part
|
||||
of a long chain of deallocations which triggers the trashcan mechanism,
|
||||
clearing the weakrefs can be delayed long after the target's refcount
|
||||
has dropped to zero. In the meantime, code accessing the weakref will
|
||||
be able to "see" the target object even though it is supposed to be
|
||||
unreachable. See issue #16602. */
|
||||
|
||||
#define PyWeakref_GET_OBJECT(ref) \
|
||||
(Py_REFCNT(((PyWeakReference *)(ref))->wr_object) > 0 \
|
||||
? ((PyWeakReference *)(ref))->wr_object \
|
||||
: Py_None)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_WEAKREFOBJECT_H */
|
254
c/meterpreter/source/extensions/python/LICENSE
Normal file
254
c/meterpreter/source/extensions/python/LICENSE
Normal file
@ -0,0 +1,254 @@
|
||||
A. HISTORY OF THE SOFTWARE
|
||||
==========================
|
||||
|
||||
Python was created in the early 1990s by Guido van Rossum at Stichting
|
||||
Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands
|
||||
as a successor of a language called ABC. Guido remains Python's
|
||||
principal author, although it includes many contributions from others.
|
||||
|
||||
In 1995, Guido continued his work on Python at the Corporation for
|
||||
National Research Initiatives (CNRI, see http://www.cnri.reston.va.us)
|
||||
in Reston, Virginia where he released several versions of the
|
||||
software.
|
||||
|
||||
In May 2000, Guido and the Python core development team moved to
|
||||
BeOpen.com to form the BeOpen PythonLabs team. In October of the same
|
||||
year, the PythonLabs team moved to Digital Creations (now Zope
|
||||
Corporation, see http://www.zope.com). In 2001, the Python Software
|
||||
Foundation (PSF, see http://www.python.org/psf/) was formed, a
|
||||
non-profit organization created specifically to own Python-related
|
||||
Intellectual Property. Zope Corporation is a sponsoring member of
|
||||
the PSF.
|
||||
|
||||
All Python releases are Open Source (see http://www.opensource.org for
|
||||
the Open Source Definition). Historically, most, but not all, Python
|
||||
releases have also been GPL-compatible; the table below summarizes
|
||||
the various releases.
|
||||
|
||||
Release Derived Year Owner GPL-
|
||||
from compatible? (1)
|
||||
|
||||
0.9.0 thru 1.2 1991-1995 CWI yes
|
||||
1.3 thru 1.5.2 1.2 1995-1999 CNRI yes
|
||||
1.6 1.5.2 2000 CNRI no
|
||||
2.0 1.6 2000 BeOpen.com no
|
||||
1.6.1 1.6 2001 CNRI yes (2)
|
||||
2.1 2.0+1.6.1 2001 PSF no
|
||||
2.0.1 2.0+1.6.1 2001 PSF yes
|
||||
2.1.1 2.1+2.0.1 2001 PSF yes
|
||||
2.1.2 2.1.1 2002 PSF yes
|
||||
2.1.3 2.1.2 2002 PSF yes
|
||||
2.2 and above 2.1.1 2001-now PSF yes
|
||||
|
||||
Footnotes:
|
||||
|
||||
(1) GPL-compatible doesn't mean that we're distributing Python under
|
||||
the GPL. All Python licenses, unlike the GPL, let you distribute
|
||||
a modified version without making your changes open source. The
|
||||
GPL-compatible licenses make it possible to combine Python with
|
||||
other software that is released under the GPL; the others don't.
|
||||
|
||||
(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,
|
||||
because its license has a choice of law clause. According to
|
||||
CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1
|
||||
is "not incompatible" with the GPL.
|
||||
|
||||
Thanks to the many outside volunteers who have worked under Guido's
|
||||
direction to make these releases possible.
|
||||
|
||||
|
||||
B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON
|
||||
===============================================================
|
||||
|
||||
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
|
||||
--------------------------------------------
|
||||
|
||||
1. This LICENSE AGREEMENT is between the Python Software Foundation
|
||||
("PSF"), and the Individual or Organization ("Licensee") accessing and
|
||||
otherwise using this software ("Python") in source or binary form and
|
||||
its associated documentation.
|
||||
|
||||
2. Subject to the terms and conditions of this License Agreement, PSF hereby
|
||||
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
|
||||
analyze, test, perform and/or display publicly, prepare derivative works,
|
||||
distribute, and otherwise use Python alone or in any derivative version,
|
||||
provided, however, that PSF's License Agreement and PSF's notice of copyright,
|
||||
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
2011, 2012, 2013, 2014, 2015 Python Software Foundation; All Rights Reserved"
|
||||
are retained in Python alone or in any derivative version prepared by Licensee.
|
||||
|
||||
3. In the event Licensee prepares a derivative work that is based on
|
||||
or incorporates Python or any part thereof, and wants to make
|
||||
the derivative work available to others as provided herein, then
|
||||
Licensee hereby agrees to include in any such work a brief summary of
|
||||
the changes made to Python.
|
||||
|
||||
4. PSF is making Python available to Licensee on an "AS IS"
|
||||
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
|
||||
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
|
||||
INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
|
||||
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
||||
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
||||
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
|
||||
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
|
||||
6. This License Agreement will automatically terminate upon a material
|
||||
breach of its terms and conditions.
|
||||
|
||||
7. Nothing in this License Agreement shall be deemed to create any
|
||||
relationship of agency, partnership, or joint venture between PSF and
|
||||
Licensee. This License Agreement does not grant permission to use PSF
|
||||
trademarks or trade name in a trademark sense to endorse or promote
|
||||
products or services of Licensee, or any third party.
|
||||
|
||||
8. By copying, installing or otherwise using Python, Licensee
|
||||
agrees to be bound by the terms and conditions of this License
|
||||
Agreement.
|
||||
|
||||
|
||||
BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
|
||||
-------------------------------------------
|
||||
|
||||
BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
|
||||
|
||||
1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
|
||||
office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
|
||||
Individual or Organization ("Licensee") accessing and otherwise using
|
||||
this software in source or binary form and its associated
|
||||
documentation ("the Software").
|
||||
|
||||
2. Subject to the terms and conditions of this BeOpen Python License
|
||||
Agreement, BeOpen hereby grants Licensee a non-exclusive,
|
||||
royalty-free, world-wide license to reproduce, analyze, test, perform
|
||||
and/or display publicly, prepare derivative works, distribute, and
|
||||
otherwise use the Software alone or in any derivative version,
|
||||
provided, however, that the BeOpen Python License is retained in the
|
||||
Software, alone or in any derivative version prepared by Licensee.
|
||||
|
||||
3. BeOpen is making the Software available to Licensee on an "AS IS"
|
||||
basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
|
||||
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
|
||||
INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
|
||||
4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
|
||||
SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
|
||||
AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
|
||||
DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
|
||||
5. This License Agreement will automatically terminate upon a material
|
||||
breach of its terms and conditions.
|
||||
|
||||
6. This License Agreement shall be governed by and interpreted in all
|
||||
respects by the law of the State of California, excluding conflict of
|
||||
law provisions. Nothing in this License Agreement shall be deemed to
|
||||
create any relationship of agency, partnership, or joint venture
|
||||
between BeOpen and Licensee. This License Agreement does not grant
|
||||
permission to use BeOpen trademarks or trade names in a trademark
|
||||
sense to endorse or promote products or services of Licensee, or any
|
||||
third party. As an exception, the "BeOpen Python" logos available at
|
||||
http://www.pythonlabs.com/logos.html may be used according to the
|
||||
permissions granted on that web page.
|
||||
|
||||
7. By copying, installing or otherwise using the software, Licensee
|
||||
agrees to be bound by the terms and conditions of this License
|
||||
Agreement.
|
||||
|
||||
|
||||
CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
|
||||
---------------------------------------
|
||||
|
||||
1. This LICENSE AGREEMENT is between the Corporation for National
|
||||
Research Initiatives, having an office at 1895 Preston White Drive,
|
||||
Reston, VA 20191 ("CNRI"), and the Individual or Organization
|
||||
("Licensee") accessing and otherwise using Python 1.6.1 software in
|
||||
source or binary form and its associated documentation.
|
||||
|
||||
2. Subject to the terms and conditions of this License Agreement, CNRI
|
||||
hereby grants Licensee a nonexclusive, royalty-free, world-wide
|
||||
license to reproduce, analyze, test, perform and/or display publicly,
|
||||
prepare derivative works, distribute, and otherwise use Python 1.6.1
|
||||
alone or in any derivative version, provided, however, that CNRI's
|
||||
License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
|
||||
1995-2001 Corporation for National Research Initiatives; All Rights
|
||||
Reserved" are retained in Python 1.6.1 alone or in any derivative
|
||||
version prepared by Licensee. Alternately, in lieu of CNRI's License
|
||||
Agreement, Licensee may substitute the following text (omitting the
|
||||
quotes): "Python 1.6.1 is made available subject to the terms and
|
||||
conditions in CNRI's License Agreement. This Agreement together with
|
||||
Python 1.6.1 may be located on the Internet using the following
|
||||
unique, persistent identifier (known as a handle): 1895.22/1013. This
|
||||
Agreement may also be obtained from a proxy server on the Internet
|
||||
using the following URL: http://hdl.handle.net/1895.22/1013".
|
||||
|
||||
3. In the event Licensee prepares a derivative work that is based on
|
||||
or incorporates Python 1.6.1 or any part thereof, and wants to make
|
||||
the derivative work available to others as provided herein, then
|
||||
Licensee hereby agrees to include in any such work a brief summary of
|
||||
the changes made to Python 1.6.1.
|
||||
|
||||
4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
|
||||
basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
|
||||
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
|
||||
INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
|
||||
5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
||||
1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
||||
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
|
||||
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
|
||||
6. This License Agreement will automatically terminate upon a material
|
||||
breach of its terms and conditions.
|
||||
|
||||
7. This License Agreement shall be governed by the federal
|
||||
intellectual property law of the United States, including without
|
||||
limitation the federal copyright law, and, to the extent such
|
||||
U.S. federal law does not apply, by the law of the Commonwealth of
|
||||
Virginia, excluding Virginia's conflict of law provisions.
|
||||
Notwithstanding the foregoing, with regard to derivative works based
|
||||
on Python 1.6.1 that incorporate non-separable material that was
|
||||
previously distributed under the GNU General Public License (GPL), the
|
||||
law of the Commonwealth of Virginia shall govern this License
|
||||
Agreement only as to issues arising under or with respect to
|
||||
Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this
|
||||
License Agreement shall be deemed to create any relationship of
|
||||
agency, partnership, or joint venture between CNRI and Licensee. This
|
||||
License Agreement does not grant permission to use CNRI trademarks or
|
||||
trade name in a trademark sense to endorse or promote products or
|
||||
services of Licensee, or any third party.
|
||||
|
||||
8. By clicking on the "ACCEPT" button where indicated, or by copying,
|
||||
installing or otherwise using Python 1.6.1, Licensee agrees to be
|
||||
bound by the terms and conditions of this License Agreement.
|
||||
|
||||
ACCEPT
|
||||
|
||||
|
||||
CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
|
||||
--------------------------------------------------
|
||||
|
||||
Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
|
||||
The Netherlands. All rights reserved.
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the name of Stichting Mathematisch
|
||||
Centrum or CWI not be used in advertising or publicity pertaining to
|
||||
distribution of the software without specific, written prior
|
||||
permission.
|
||||
|
||||
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
|
||||
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
603
c/meterpreter/source/extensions/python/Lib/BaseHTTPServer.py
Normal file
603
c/meterpreter/source/extensions/python/Lib/BaseHTTPServer.py
Normal file
@ -0,0 +1,603 @@
|
||||
"""HTTP server base class.
|
||||
|
||||
Note: the class in this module doesn't implement any HTTP request; see
|
||||
SimpleHTTPServer for simple implementations of GET, HEAD and POST
|
||||
(including CGI scripts). It does, however, optionally implement HTTP/1.1
|
||||
persistent connections, as of version 0.3.
|
||||
|
||||
Contents:
|
||||
|
||||
- BaseHTTPRequestHandler: HTTP request handler base class
|
||||
- test: test function
|
||||
|
||||
XXX To do:
|
||||
|
||||
- log requests even later (to capture byte count)
|
||||
- log user-agent header and other interesting goodies
|
||||
- send error log to separate file
|
||||
"""
|
||||
|
||||
|
||||
# See also:
|
||||
#
|
||||
# HTTP Working Group T. Berners-Lee
|
||||
# INTERNET-DRAFT R. T. Fielding
|
||||
# <draft-ietf-http-v10-spec-00.txt> H. Frystyk Nielsen
|
||||
# Expires September 8, 1995 March 8, 1995
|
||||
#
|
||||
# URL: http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt
|
||||
#
|
||||
# and
|
||||
#
|
||||
# Network Working Group R. Fielding
|
||||
# Request for Comments: 2616 et al
|
||||
# Obsoletes: 2068 June 1999
|
||||
# Category: Standards Track
|
||||
#
|
||||
# URL: http://www.faqs.org/rfcs/rfc2616.html
|
||||
|
||||
# Log files
|
||||
# ---------
|
||||
#
|
||||
# Here's a quote from the NCSA httpd docs about log file format.
|
||||
#
|
||||
# | The logfile format is as follows. Each line consists of:
|
||||
# |
|
||||
# | host rfc931 authuser [DD/Mon/YYYY:hh:mm:ss] "request" ddd bbbb
|
||||
# |
|
||||
# | host: Either the DNS name or the IP number of the remote client
|
||||
# | rfc931: Any information returned by identd for this person,
|
||||
# | - otherwise.
|
||||
# | authuser: If user sent a userid for authentication, the user name,
|
||||
# | - otherwise.
|
||||
# | DD: Day
|
||||
# | Mon: Month (calendar name)
|
||||
# | YYYY: Year
|
||||
# | hh: hour (24-hour format, the machine's timezone)
|
||||
# | mm: minutes
|
||||
# | ss: seconds
|
||||
# | request: The first line of the HTTP request as sent by the client.
|
||||
# | ddd: the status code returned by the server, - if not available.
|
||||
# | bbbb: the total number of bytes sent,
|
||||
# | *not including the HTTP/1.0 header*, - if not available
|
||||
# |
|
||||
# | You can determine the name of the file accessed through request.
|
||||
#
|
||||
# (Actually, the latter is only true if you know the server configuration
|
||||
# at the time the request was made!)
|
||||
|
||||
__version__ = "0.3"
|
||||
|
||||
__all__ = ["HTTPServer", "BaseHTTPRequestHandler"]
|
||||
|
||||
import sys
|
||||
import time
|
||||
import socket # For gethostbyaddr()
|
||||
from warnings import filterwarnings, catch_warnings
|
||||
with catch_warnings():
|
||||
if sys.py3kwarning:
|
||||
filterwarnings("ignore", ".*mimetools has been removed",
|
||||
DeprecationWarning)
|
||||
import mimetools
|
||||
import SocketServer
|
||||
|
||||
# Default error message template
|
||||
DEFAULT_ERROR_MESSAGE = """\
|
||||
<head>
|
||||
<title>Error response</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Error response</h1>
|
||||
<p>Error code %(code)d.
|
||||
<p>Message: %(message)s.
|
||||
<p>Error code explanation: %(code)s = %(explain)s.
|
||||
</body>
|
||||
"""
|
||||
|
||||
DEFAULT_ERROR_CONTENT_TYPE = "text/html"
|
||||
|
||||
def _quote_html(html):
|
||||
return html.replace("&", "&").replace("<", "<").replace(">", ">")
|
||||
|
||||
class HTTPServer(SocketServer.TCPServer):
|
||||
|
||||
allow_reuse_address = 1 # Seems to make sense in testing environment
|
||||
|
||||
def server_bind(self):
|
||||
"""Override server_bind to store the server name."""
|
||||
SocketServer.TCPServer.server_bind(self)
|
||||
host, port = self.socket.getsockname()[:2]
|
||||
self.server_name = socket.getfqdn(host)
|
||||
self.server_port = port
|
||||
|
||||
|
||||
class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
|
||||
|
||||
"""HTTP request handler base class.
|
||||
|
||||
The following explanation of HTTP serves to guide you through the
|
||||
code as well as to expose any misunderstandings I may have about
|
||||
HTTP (so you don't need to read the code to figure out I'm wrong
|
||||
:-).
|
||||
|
||||
HTTP (HyperText Transfer Protocol) is an extensible protocol on
|
||||
top of a reliable stream transport (e.g. TCP/IP). The protocol
|
||||
recognizes three parts to a request:
|
||||
|
||||
1. One line identifying the request type and path
|
||||
2. An optional set of RFC-822-style headers
|
||||
3. An optional data part
|
||||
|
||||
The headers and data are separated by a blank line.
|
||||
|
||||
The first line of the request has the form
|
||||
|
||||
<command> <path> <version>
|
||||
|
||||
where <command> is a (case-sensitive) keyword such as GET or POST,
|
||||
<path> is a string containing path information for the request,
|
||||
and <version> should be the string "HTTP/1.0" or "HTTP/1.1".
|
||||
<path> is encoded using the URL encoding scheme (using %xx to signify
|
||||
the ASCII character with hex code xx).
|
||||
|
||||
The specification specifies that lines are separated by CRLF but
|
||||
for compatibility with the widest range of clients recommends
|
||||
servers also handle LF. Similarly, whitespace in the request line
|
||||
is treated sensibly (allowing multiple spaces between components
|
||||
and allowing trailing whitespace).
|
||||
|
||||
Similarly, for output, lines ought to be separated by CRLF pairs
|
||||
but most clients grok LF characters just fine.
|
||||
|
||||
If the first line of the request has the form
|
||||
|
||||
<command> <path>
|
||||
|
||||
(i.e. <version> is left out) then this is assumed to be an HTTP
|
||||
0.9 request; this form has no optional headers and data part and
|
||||
the reply consists of just the data.
|
||||
|
||||
The reply form of the HTTP 1.x protocol again has three parts:
|
||||
|
||||
1. One line giving the response code
|
||||
2. An optional set of RFC-822-style headers
|
||||
3. The data
|
||||
|
||||
Again, the headers and data are separated by a blank line.
|
||||
|
||||
The response code line has the form
|
||||
|
||||
<version> <responsecode> <responsestring>
|
||||
|
||||
where <version> is the protocol version ("HTTP/1.0" or "HTTP/1.1"),
|
||||
<responsecode> is a 3-digit response code indicating success or
|
||||
failure of the request, and <responsestring> is an optional
|
||||
human-readable string explaining what the response code means.
|
||||
|
||||
This server parses the request and the headers, and then calls a
|
||||
function specific to the request type (<command>). Specifically,
|
||||
a request SPAM will be handled by a method do_SPAM(). If no
|
||||
such method exists the server sends an error response to the
|
||||
client. If it exists, it is called with no arguments:
|
||||
|
||||
do_SPAM()
|
||||
|
||||
Note that the request name is case sensitive (i.e. SPAM and spam
|
||||
are different requests).
|
||||
|
||||
The various request details are stored in instance variables:
|
||||
|
||||
- client_address is the client IP address in the form (host,
|
||||
port);
|
||||
|
||||
- command, path and version are the broken-down request line;
|
||||
|
||||
- headers is an instance of mimetools.Message (or a derived
|
||||
class) containing the header information;
|
||||
|
||||
- rfile is a file object open for reading positioned at the
|
||||
start of the optional input data part;
|
||||
|
||||
- wfile is a file object open for writing.
|
||||
|
||||
IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING!
|
||||
|
||||
The first thing to be written must be the response line. Then
|
||||
follow 0 or more header lines, then a blank line, and then the
|
||||
actual data (if any). The meaning of the header lines depends on
|
||||
the command executed by the server; in most cases, when data is
|
||||
returned, there should be at least one header line of the form
|
||||
|
||||
Content-type: <type>/<subtype>
|
||||
|
||||
where <type> and <subtype> should be registered MIME types,
|
||||
e.g. "text/html" or "text/plain".
|
||||
|
||||
"""
|
||||
|
||||
# The Python system version, truncated to its first component.
|
||||
sys_version = "Python/" + sys.version.split()[0]
|
||||
|
||||
# The server software version. You may want to override this.
|
||||
# The format is multiple whitespace-separated strings,
|
||||
# where each string is of the form name[/version].
|
||||
server_version = "BaseHTTP/" + __version__
|
||||
|
||||
# The default request version. This only affects responses up until
|
||||
# the point where the request line is parsed, so it mainly decides what
|
||||
# the client gets back when sending a malformed request line.
|
||||
# Most web servers default to HTTP 0.9, i.e. don't send a status line.
|
||||
default_request_version = "HTTP/0.9"
|
||||
|
||||
def parse_request(self):
|
||||
"""Parse a request (internal).
|
||||
|
||||
The request should be stored in self.raw_requestline; the results
|
||||
are in self.command, self.path, self.request_version and
|
||||
self.headers.
|
||||
|
||||
Return True for success, False for failure; on failure, an
|
||||
error is sent back.
|
||||
|
||||
"""
|
||||
self.command = None # set in case of error on the first line
|
||||
self.request_version = version = self.default_request_version
|
||||
self.close_connection = 1
|
||||
requestline = self.raw_requestline
|
||||
requestline = requestline.rstrip('\r\n')
|
||||
self.requestline = requestline
|
||||
words = requestline.split()
|
||||
if len(words) == 3:
|
||||
command, path, version = words
|
||||
if version[:5] != 'HTTP/':
|
||||
self.send_error(400, "Bad request version (%r)" % version)
|
||||
return False
|
||||
try:
|
||||
base_version_number = version.split('/', 1)[1]
|
||||
version_number = base_version_number.split(".")
|
||||
# RFC 2145 section 3.1 says there can be only one "." and
|
||||
# - major and minor numbers MUST be treated as
|
||||
# separate integers;
|
||||
# - HTTP/2.4 is a lower version than HTTP/2.13, which in
|
||||
# turn is lower than HTTP/12.3;
|
||||
# - Leading zeros MUST be ignored by recipients.
|
||||
if len(version_number) != 2:
|
||||
raise ValueError
|
||||
version_number = int(version_number[0]), int(version_number[1])
|
||||
except (ValueError, IndexError):
|
||||
self.send_error(400, "Bad request version (%r)" % version)
|
||||
return False
|
||||
if version_number >= (1, 1) and self.protocol_version >= "HTTP/1.1":
|
||||
self.close_connection = 0
|
||||
if version_number >= (2, 0):
|
||||
self.send_error(505,
|
||||
"Invalid HTTP Version (%s)" % base_version_number)
|
||||
return False
|
||||
elif len(words) == 2:
|
||||
command, path = words
|
||||
self.close_connection = 1
|
||||
if command != 'GET':
|
||||
self.send_error(400,
|
||||
"Bad HTTP/0.9 request type (%r)" % command)
|
||||
return False
|
||||
elif not words:
|
||||
return False
|
||||
else:
|
||||
self.send_error(400, "Bad request syntax (%r)" % requestline)
|
||||
return False
|
||||
self.command, self.path, self.request_version = command, path, version
|
||||
|
||||
# Examine the headers and look for a Connection directive
|
||||
self.headers = self.MessageClass(self.rfile, 0)
|
||||
|
||||
conntype = self.headers.get('Connection', "")
|
||||
if conntype.lower() == 'close':
|
||||
self.close_connection = 1
|
||||
elif (conntype.lower() == 'keep-alive' and
|
||||
self.protocol_version >= "HTTP/1.1"):
|
||||
self.close_connection = 0
|
||||
return True
|
||||
|
||||
def handle_one_request(self):
|
||||
"""Handle a single HTTP request.
|
||||
|
||||
You normally don't need to override this method; see the class
|
||||
__doc__ string for information on how to handle specific HTTP
|
||||
commands such as GET and POST.
|
||||
|
||||
"""
|
||||
try:
|
||||
self.raw_requestline = self.rfile.readline(65537)
|
||||
if len(self.raw_requestline) > 65536:
|
||||
self.requestline = ''
|
||||
self.request_version = ''
|
||||
self.command = ''
|
||||
self.send_error(414)
|
||||
return
|
||||
if not self.raw_requestline:
|
||||
self.close_connection = 1
|
||||
return
|
||||
if not self.parse_request():
|
||||
# An error code has been sent, just exit
|
||||
return
|
||||
mname = 'do_' + self.command
|
||||
if not hasattr(self, mname):
|
||||
self.send_error(501, "Unsupported method (%r)" % self.command)
|
||||
return
|
||||
method = getattr(self, mname)
|
||||
method()
|
||||
self.wfile.flush() #actually send the response if not already done.
|
||||
except socket.timeout, e:
|
||||
#a read or a write timed out. Discard this connection
|
||||
self.log_error("Request timed out: %r", e)
|
||||
self.close_connection = 1
|
||||
return
|
||||
|
||||
def handle(self):
|
||||
"""Handle multiple requests if necessary."""
|
||||
self.close_connection = 1
|
||||
|
||||
self.handle_one_request()
|
||||
while not self.close_connection:
|
||||
self.handle_one_request()
|
||||
|
||||
def send_error(self, code, message=None):
|
||||
"""Send and log an error reply.
|
||||
|
||||
Arguments are the error code, and a detailed message.
|
||||
The detailed message defaults to the short entry matching the
|
||||
response code.
|
||||
|
||||
This sends an error response (so it must be called before any
|
||||
output has been generated), logs the error, and finally sends
|
||||
a piece of HTML explaining the error to the user.
|
||||
|
||||
"""
|
||||
|
||||
try:
|
||||
short, long = self.responses[code]
|
||||
except KeyError:
|
||||
short, long = '???', '???'
|
||||
if message is None:
|
||||
message = short
|
||||
explain = long
|
||||
self.log_error("code %d, message %s", code, message)
|
||||
# using _quote_html to prevent Cross Site Scripting attacks (see bug #1100201)
|
||||
content = (self.error_message_format %
|
||||
{'code': code, 'message': _quote_html(message), 'explain': explain})
|
||||
self.send_response(code, message)
|
||||
self.send_header("Content-Type", self.error_content_type)
|
||||
self.send_header('Connection', 'close')
|
||||
self.end_headers()
|
||||
if self.command != 'HEAD' and code >= 200 and code not in (204, 304):
|
||||
self.wfile.write(content)
|
||||
|
||||
error_message_format = DEFAULT_ERROR_MESSAGE
|
||||
error_content_type = DEFAULT_ERROR_CONTENT_TYPE
|
||||
|
||||
def send_response(self, code, message=None):
|
||||
"""Send the response header and log the response code.
|
||||
|
||||
Also send two standard headers with the server software
|
||||
version and the current date.
|
||||
|
||||
"""
|
||||
self.log_request(code)
|
||||
if message is None:
|
||||
if code in self.responses:
|
||||
message = self.responses[code][0]
|
||||
else:
|
||||
message = ''
|
||||
if self.request_version != 'HTTP/0.9':
|
||||
self.wfile.write("%s %d %s\r\n" %
|
||||
(self.protocol_version, code, message))
|
||||
# print (self.protocol_version, code, message)
|
||||
self.send_header('Server', self.version_string())
|
||||
self.send_header('Date', self.date_time_string())
|
||||
|
||||
def send_header(self, keyword, value):
|
||||
"""Send a MIME header."""
|
||||
if self.request_version != 'HTTP/0.9':
|
||||
self.wfile.write("%s: %s\r\n" % (keyword, value))
|
||||
|
||||
if keyword.lower() == 'connection':
|
||||
if value.lower() == 'close':
|
||||
self.close_connection = 1
|
||||
elif value.lower() == 'keep-alive':
|
||||
self.close_connection = 0
|
||||
|
||||
def end_headers(self):
|
||||
"""Send the blank line ending the MIME headers."""
|
||||
if self.request_version != 'HTTP/0.9':
|
||||
self.wfile.write("\r\n")
|
||||
|
||||
def log_request(self, code='-', size='-'):
|
||||
"""Log an accepted request.
|
||||
|
||||
This is called by send_response().
|
||||
|
||||
"""
|
||||
|
||||
self.log_message('"%s" %s %s',
|
||||
self.requestline, str(code), str(size))
|
||||
|
||||
def log_error(self, format, *args):
|
||||
"""Log an error.
|
||||
|
||||
This is called when a request cannot be fulfilled. By
|
||||
default it passes the message on to log_message().
|
||||
|
||||
Arguments are the same as for log_message().
|
||||
|
||||
XXX This should go to the separate error log.
|
||||
|
||||
"""
|
||||
|
||||
self.log_message(format, *args)
|
||||
|
||||
def log_message(self, format, *args):
|
||||
"""Log an arbitrary message.
|
||||
|
||||
This is used by all other logging functions. Override
|
||||
it if you have specific logging wishes.
|
||||
|
||||
The first argument, FORMAT, is a format string for the
|
||||
message to be logged. If the format string contains
|
||||
any % escapes requiring parameters, they should be
|
||||
specified as subsequent arguments (it's just like
|
||||
printf!).
|
||||
|
||||
The client ip address and current date/time are prefixed to every
|
||||
message.
|
||||
|
||||
"""
|
||||
|
||||
sys.stderr.write("%s - - [%s] %s\n" %
|
||||
(self.client_address[0],
|
||||
self.log_date_time_string(),
|
||||
format%args))
|
||||
|
||||
def version_string(self):
|
||||
"""Return the server software version string."""
|
||||
return self.server_version + ' ' + self.sys_version
|
||||
|
||||
def date_time_string(self, timestamp=None):
|
||||
"""Return the current date and time formatted for a message header."""
|
||||
if timestamp is None:
|
||||
timestamp = time.time()
|
||||
year, month, day, hh, mm, ss, wd, y, z = time.gmtime(timestamp)
|
||||
s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
|
||||
self.weekdayname[wd],
|
||||
day, self.monthname[month], year,
|
||||
hh, mm, ss)
|
||||
return s
|
||||
|
||||
def log_date_time_string(self):
|
||||
"""Return the current time formatted for logging."""
|
||||
now = time.time()
|
||||
year, month, day, hh, mm, ss, x, y, z = time.localtime(now)
|
||||
s = "%02d/%3s/%04d %02d:%02d:%02d" % (
|
||||
day, self.monthname[month], year, hh, mm, ss)
|
||||
return s
|
||||
|
||||
weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
||||
|
||||
monthname = [None,
|
||||
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
||||
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
||||
|
||||
def address_string(self):
|
||||
"""Return the client address formatted for logging.
|
||||
|
||||
This version looks up the full hostname using gethostbyaddr(),
|
||||
and tries to find a name that contains at least one dot.
|
||||
|
||||
"""
|
||||
|
||||
host, port = self.client_address[:2]
|
||||
return socket.getfqdn(host)
|
||||
|
||||
# Essentially static class variables
|
||||
|
||||
# The version of the HTTP protocol we support.
|
||||
# Set this to HTTP/1.1 to enable automatic keepalive
|
||||
protocol_version = "HTTP/1.0"
|
||||
|
||||
# The Message-like class used to parse headers
|
||||
MessageClass = mimetools.Message
|
||||
|
||||
# Table mapping response codes to messages; entries have the
|
||||
# form {code: (shortmessage, longmessage)}.
|
||||
# See RFC 2616.
|
||||
responses = {
|
||||
100: ('Continue', 'Request received, please continue'),
|
||||
101: ('Switching Protocols',
|
||||
'Switching to new protocol; obey Upgrade header'),
|
||||
|
||||
200: ('OK', 'Request fulfilled, document follows'),
|
||||
201: ('Created', 'Document created, URL follows'),
|
||||
202: ('Accepted',
|
||||
'Request accepted, processing continues off-line'),
|
||||
203: ('Non-Authoritative Information', 'Request fulfilled from cache'),
|
||||
204: ('No Content', 'Request fulfilled, nothing follows'),
|
||||
205: ('Reset Content', 'Clear input form for further input.'),
|
||||
206: ('Partial Content', 'Partial content follows.'),
|
||||
|
||||
300: ('Multiple Choices',
|
||||
'Object has several resources -- see URI list'),
|
||||
301: ('Moved Permanently', 'Object moved permanently -- see URI list'),
|
||||
302: ('Found', 'Object moved temporarily -- see URI list'),
|
||||
303: ('See Other', 'Object moved -- see Method and URL list'),
|
||||
304: ('Not Modified',
|
||||
'Document has not changed since given time'),
|
||||
305: ('Use Proxy',
|
||||
'You must use proxy specified in Location to access this '
|
||||
'resource.'),
|
||||
307: ('Temporary Redirect',
|
||||
'Object moved temporarily -- see URI list'),
|
||||
|
||||
400: ('Bad Request',
|
||||
'Bad request syntax or unsupported method'),
|
||||
401: ('Unauthorized',
|
||||
'No permission -- see authorization schemes'),
|
||||
402: ('Payment Required',
|
||||
'No payment -- see charging schemes'),
|
||||
403: ('Forbidden',
|
||||
'Request forbidden -- authorization will not help'),
|
||||
404: ('Not Found', 'Nothing matches the given URI'),
|
||||
405: ('Method Not Allowed',
|
||||
'Specified method is invalid for this resource.'),
|
||||
406: ('Not Acceptable', 'URI not available in preferred format.'),
|
||||
407: ('Proxy Authentication Required', 'You must authenticate with '
|
||||
'this proxy before proceeding.'),
|
||||
408: ('Request Timeout', 'Request timed out; try again later.'),
|
||||
409: ('Conflict', 'Request conflict.'),
|
||||
410: ('Gone',
|
||||
'URI no longer exists and has been permanently removed.'),
|
||||
411: ('Length Required', 'Client must specify Content-Length.'),
|
||||
412: ('Precondition Failed', 'Precondition in headers is false.'),
|
||||
413: ('Request Entity Too Large', 'Entity is too large.'),
|
||||
414: ('Request-URI Too Long', 'URI is too long.'),
|
||||
415: ('Unsupported Media Type', 'Entity body in unsupported format.'),
|
||||
416: ('Requested Range Not Satisfiable',
|
||||
'Cannot satisfy request range.'),
|
||||
417: ('Expectation Failed',
|
||||
'Expect condition could not be satisfied.'),
|
||||
|
||||
500: ('Internal Server Error', 'Server got itself in trouble'),
|
||||
501: ('Not Implemented',
|
||||
'Server does not support this operation'),
|
||||
502: ('Bad Gateway', 'Invalid responses from another server/proxy.'),
|
||||
503: ('Service Unavailable',
|
||||
'The server cannot process the request due to a high load'),
|
||||
504: ('Gateway Timeout',
|
||||
'The gateway server did not receive a timely response'),
|
||||
505: ('HTTP Version Not Supported', 'Cannot fulfill request.'),
|
||||
}
|
||||
|
||||
|
||||
def test(HandlerClass = BaseHTTPRequestHandler,
|
||||
ServerClass = HTTPServer, protocol="HTTP/1.0"):
|
||||
"""Test the HTTP request handler class.
|
||||
|
||||
This runs an HTTP server on port 8000 (or the first command line
|
||||
argument).
|
||||
|
||||
"""
|
||||
|
||||
if sys.argv[1:]:
|
||||
port = int(sys.argv[1])
|
||||
else:
|
||||
port = 8000
|
||||
server_address = ('', port)
|
||||
|
||||
HandlerClass.protocol_version = protocol
|
||||
httpd = ServerClass(server_address, HandlerClass)
|
||||
|
||||
sa = httpd.socket.getsockname()
|
||||
print "Serving HTTP on", sa[0], "port", sa[1], "..."
|
||||
httpd.serve_forever()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test()
|
180
c/meterpreter/source/extensions/python/Lib/Bastion.py
Normal file
180
c/meterpreter/source/extensions/python/Lib/Bastion.py
Normal file
@ -0,0 +1,180 @@
|
||||
"""Bastionification utility.
|
||||
|
||||
A bastion (for another object -- the 'original') is an object that has
|
||||
the same methods as the original but does not give access to its
|
||||
instance variables. Bastions have a number of uses, but the most
|
||||
obvious one is to provide code executing in restricted mode with a
|
||||
safe interface to an object implemented in unrestricted mode.
|
||||
|
||||
The bastionification routine has an optional second argument which is
|
||||
a filter function. Only those methods for which the filter method
|
||||
(called with the method name as argument) returns true are accessible.
|
||||
The default filter method returns true unless the method name begins
|
||||
with an underscore.
|
||||
|
||||
There are a number of possible implementations of bastions. We use a
|
||||
'lazy' approach where the bastion's __getattr__() discipline does all
|
||||
the work for a particular method the first time it is used. This is
|
||||
usually fastest, especially if the user doesn't call all available
|
||||
methods. The retrieved methods are stored as instance variables of
|
||||
the bastion, so the overhead is only occurred on the first use of each
|
||||
method.
|
||||
|
||||
Detail: the bastion class has a __repr__() discipline which includes
|
||||
the repr() of the original object. This is precomputed when the
|
||||
bastion is created.
|
||||
|
||||
"""
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("the Bastion module has been removed in Python 3.0", stacklevel=2)
|
||||
del warnpy3k
|
||||
|
||||
__all__ = ["BastionClass", "Bastion"]
|
||||
|
||||
from types import MethodType
|
||||
|
||||
|
||||
class BastionClass:
|
||||
|
||||
"""Helper class used by the Bastion() function.
|
||||
|
||||
You could subclass this and pass the subclass as the bastionclass
|
||||
argument to the Bastion() function, as long as the constructor has
|
||||
the same signature (a get() function and a name for the object).
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, get, name):
|
||||
"""Constructor.
|
||||
|
||||
Arguments:
|
||||
|
||||
get - a function that gets the attribute value (by name)
|
||||
name - a human-readable name for the original object
|
||||
(suggestion: use repr(object))
|
||||
|
||||
"""
|
||||
self._get_ = get
|
||||
self._name_ = name
|
||||
|
||||
def __repr__(self):
|
||||
"""Return a representation string.
|
||||
|
||||
This includes the name passed in to the constructor, so that
|
||||
if you print the bastion during debugging, at least you have
|
||||
some idea of what it is.
|
||||
|
||||
"""
|
||||
return "<Bastion for %s>" % self._name_
|
||||
|
||||
def __getattr__(self, name):
|
||||
"""Get an as-yet undefined attribute value.
|
||||
|
||||
This calls the get() function that was passed to the
|
||||
constructor. The result is stored as an instance variable so
|
||||
that the next time the same attribute is requested,
|
||||
__getattr__() won't be invoked.
|
||||
|
||||
If the get() function raises an exception, this is simply
|
||||
passed on -- exceptions are not cached.
|
||||
|
||||
"""
|
||||
attribute = self._get_(name)
|
||||
self.__dict__[name] = attribute
|
||||
return attribute
|
||||
|
||||
|
||||
def Bastion(object, filter = lambda name: name[:1] != '_',
|
||||
name=None, bastionclass=BastionClass):
|
||||
"""Create a bastion for an object, using an optional filter.
|
||||
|
||||
See the Bastion module's documentation for background.
|
||||
|
||||
Arguments:
|
||||
|
||||
object - the original object
|
||||
filter - a predicate that decides whether a function name is OK;
|
||||
by default all names are OK that don't start with '_'
|
||||
name - the name of the object; default repr(object)
|
||||
bastionclass - class used to create the bastion; default BastionClass
|
||||
|
||||
"""
|
||||
|
||||
raise RuntimeError, "This code is not secure in Python 2.2 and later"
|
||||
|
||||
# Note: we define *two* ad-hoc functions here, get1 and get2.
|
||||
# Both are intended to be called in the same way: get(name).
|
||||
# It is clear that the real work (getting the attribute
|
||||
# from the object and calling the filter) is done in get1.
|
||||
# Why can't we pass get1 to the bastion? Because the user
|
||||
# would be able to override the filter argument! With get2,
|
||||
# overriding the default argument is no security loophole:
|
||||
# all it does is call it.
|
||||
# Also notice that we can't place the object and filter as
|
||||
# instance variables on the bastion object itself, since
|
||||
# the user has full access to all instance variables!
|
||||
|
||||
def get1(name, object=object, filter=filter):
|
||||
"""Internal function for Bastion(). See source comments."""
|
||||
if filter(name):
|
||||
attribute = getattr(object, name)
|
||||
if type(attribute) == MethodType:
|
||||
return attribute
|
||||
raise AttributeError, name
|
||||
|
||||
def get2(name, get1=get1):
|
||||
"""Internal function for Bastion(). See source comments."""
|
||||
return get1(name)
|
||||
|
||||
if name is None:
|
||||
name = repr(object)
|
||||
return bastionclass(get2, name)
|
||||
|
||||
|
||||
def _test():
|
||||
"""Test the Bastion() function."""
|
||||
class Original:
|
||||
def __init__(self):
|
||||
self.sum = 0
|
||||
def add(self, n):
|
||||
self._add(n)
|
||||
def _add(self, n):
|
||||
self.sum = self.sum + n
|
||||
def total(self):
|
||||
return self.sum
|
||||
o = Original()
|
||||
b = Bastion(o)
|
||||
testcode = """if 1:
|
||||
b.add(81)
|
||||
b.add(18)
|
||||
print "b.total() =", b.total()
|
||||
try:
|
||||
print "b.sum =", b.sum,
|
||||
except:
|
||||
print "inaccessible"
|
||||
else:
|
||||
print "accessible"
|
||||
try:
|
||||
print "b._add =", b._add,
|
||||
except:
|
||||
print "inaccessible"
|
||||
else:
|
||||
print "accessible"
|
||||
try:
|
||||
print "b._get_.func_defaults =", map(type, b._get_.func_defaults),
|
||||
except:
|
||||
print "inaccessible"
|
||||
else:
|
||||
print "accessible"
|
||||
\n"""
|
||||
exec testcode
|
||||
print '='*20, "Using rexec:", '='*20
|
||||
import rexec
|
||||
r = rexec.RExec()
|
||||
m = r.add_module('__main__')
|
||||
m.b = b
|
||||
r.r_exec(testcode)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
_test()
|
378
c/meterpreter/source/extensions/python/Lib/CGIHTTPServer.py
Normal file
378
c/meterpreter/source/extensions/python/Lib/CGIHTTPServer.py
Normal file
@ -0,0 +1,378 @@
|
||||
"""CGI-savvy HTTP Server.
|
||||
|
||||
This module builds on SimpleHTTPServer by implementing GET and POST
|
||||
requests to cgi-bin scripts.
|
||||
|
||||
If the os.fork() function is not present (e.g. on Windows),
|
||||
os.popen2() is used as a fallback, with slightly altered semantics; if
|
||||
that function is not present either (e.g. on Macintosh), only Python
|
||||
scripts are supported, and they are executed by the current process.
|
||||
|
||||
In all cases, the implementation is intentionally naive -- all
|
||||
requests are executed sychronously.
|
||||
|
||||
SECURITY WARNING: DON'T USE THIS CODE UNLESS YOU ARE INSIDE A FIREWALL
|
||||
-- it may execute arbitrary Python code or external programs.
|
||||
|
||||
Note that status code 200 is sent prior to execution of a CGI script, so
|
||||
scripts cannot send other status codes such as 302 (redirect).
|
||||
"""
|
||||
|
||||
|
||||
__version__ = "0.4"
|
||||
|
||||
__all__ = ["CGIHTTPRequestHandler"]
|
||||
|
||||
import os
|
||||
import sys
|
||||
import urllib
|
||||
import BaseHTTPServer
|
||||
import SimpleHTTPServer
|
||||
import select
|
||||
import copy
|
||||
|
||||
|
||||
class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||
|
||||
"""Complete HTTP server with GET, HEAD and POST commands.
|
||||
|
||||
GET and HEAD also support running CGI scripts.
|
||||
|
||||
The POST command is *only* implemented for CGI scripts.
|
||||
|
||||
"""
|
||||
|
||||
# Determine platform specifics
|
||||
have_fork = hasattr(os, 'fork')
|
||||
have_popen2 = hasattr(os, 'popen2')
|
||||
have_popen3 = hasattr(os, 'popen3')
|
||||
|
||||
# Make rfile unbuffered -- we need to read one line and then pass
|
||||
# the rest to a subprocess, so we can't use buffered input.
|
||||
rbufsize = 0
|
||||
|
||||
def do_POST(self):
|
||||
"""Serve a POST request.
|
||||
|
||||
This is only implemented for CGI scripts.
|
||||
|
||||
"""
|
||||
|
||||
if self.is_cgi():
|
||||
self.run_cgi()
|
||||
else:
|
||||
self.send_error(501, "Can only POST to CGI scripts")
|
||||
|
||||
def send_head(self):
|
||||
"""Version of send_head that support CGI scripts"""
|
||||
if self.is_cgi():
|
||||
return self.run_cgi()
|
||||
else:
|
||||
return SimpleHTTPServer.SimpleHTTPRequestHandler.send_head(self)
|
||||
|
||||
def is_cgi(self):
|
||||
"""Test whether self.path corresponds to a CGI script.
|
||||
|
||||
Returns True and updates the cgi_info attribute to the tuple
|
||||
(dir, rest) if self.path requires running a CGI script.
|
||||
Returns False otherwise.
|
||||
|
||||
If any exception is raised, the caller should assume that
|
||||
self.path was rejected as invalid and act accordingly.
|
||||
|
||||
The default implementation tests whether the normalized url
|
||||
path begins with one of the strings in self.cgi_directories
|
||||
(and the next character is a '/' or the end of the string).
|
||||
"""
|
||||
collapsed_path = _url_collapse_path(self.path)
|
||||
dir_sep = collapsed_path.find('/', 1)
|
||||
head, tail = collapsed_path[:dir_sep], collapsed_path[dir_sep+1:]
|
||||
if head in self.cgi_directories:
|
||||
self.cgi_info = head, tail
|
||||
return True
|
||||
return False
|
||||
|
||||
cgi_directories = ['/cgi-bin', '/htbin']
|
||||
|
||||
def is_executable(self, path):
|
||||
"""Test whether argument path is an executable file."""
|
||||
return executable(path)
|
||||
|
||||
def is_python(self, path):
|
||||
"""Test whether argument path is a Python script."""
|
||||
head, tail = os.path.splitext(path)
|
||||
return tail.lower() in (".py", ".pyw")
|
||||
|
||||
def run_cgi(self):
|
||||
"""Execute a CGI script."""
|
||||
dir, rest = self.cgi_info
|
||||
path = dir + '/' + rest
|
||||
i = path.find('/', len(dir)+1)
|
||||
while i >= 0:
|
||||
nextdir = path[:i]
|
||||
nextrest = path[i+1:]
|
||||
|
||||
scriptdir = self.translate_path(nextdir)
|
||||
if os.path.isdir(scriptdir):
|
||||
dir, rest = nextdir, nextrest
|
||||
i = path.find('/', len(dir)+1)
|
||||
else:
|
||||
break
|
||||
|
||||
# find an explicit query string, if present.
|
||||
rest, _, query = rest.partition('?')
|
||||
|
||||
# dissect the part after the directory name into a script name &
|
||||
# a possible additional path, to be stored in PATH_INFO.
|
||||
i = rest.find('/')
|
||||
if i >= 0:
|
||||
script, rest = rest[:i], rest[i:]
|
||||
else:
|
||||
script, rest = rest, ''
|
||||
|
||||
scriptname = dir + '/' + script
|
||||
scriptfile = self.translate_path(scriptname)
|
||||
if not os.path.exists(scriptfile):
|
||||
self.send_error(404, "No such CGI script (%r)" % scriptname)
|
||||
return
|
||||
if not os.path.isfile(scriptfile):
|
||||
self.send_error(403, "CGI script is not a plain file (%r)" %
|
||||
scriptname)
|
||||
return
|
||||
ispy = self.is_python(scriptname)
|
||||
if not ispy:
|
||||
if not (self.have_fork or self.have_popen2 or self.have_popen3):
|
||||
self.send_error(403, "CGI script is not a Python script (%r)" %
|
||||
scriptname)
|
||||
return
|
||||
if not self.is_executable(scriptfile):
|
||||
self.send_error(403, "CGI script is not executable (%r)" %
|
||||
scriptname)
|
||||
return
|
||||
|
||||
# Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html
|
||||
# XXX Much of the following could be prepared ahead of time!
|
||||
env = copy.deepcopy(os.environ)
|
||||
env['SERVER_SOFTWARE'] = self.version_string()
|
||||
env['SERVER_NAME'] = self.server.server_name
|
||||
env['GATEWAY_INTERFACE'] = 'CGI/1.1'
|
||||
env['SERVER_PROTOCOL'] = self.protocol_version
|
||||
env['SERVER_PORT'] = str(self.server.server_port)
|
||||
env['REQUEST_METHOD'] = self.command
|
||||
uqrest = urllib.unquote(rest)
|
||||
env['PATH_INFO'] = uqrest
|
||||
env['PATH_TRANSLATED'] = self.translate_path(uqrest)
|
||||
env['SCRIPT_NAME'] = scriptname
|
||||
if query:
|
||||
env['QUERY_STRING'] = query
|
||||
host = self.address_string()
|
||||
if host != self.client_address[0]:
|
||||
env['REMOTE_HOST'] = host
|
||||
env['REMOTE_ADDR'] = self.client_address[0]
|
||||
authorization = self.headers.getheader("authorization")
|
||||
if authorization:
|
||||
authorization = authorization.split()
|
||||
if len(authorization) == 2:
|
||||
import base64, binascii
|
||||
env['AUTH_TYPE'] = authorization[0]
|
||||
if authorization[0].lower() == "basic":
|
||||
try:
|
||||
authorization = base64.decodestring(authorization[1])
|
||||
except binascii.Error:
|
||||
pass
|
||||
else:
|
||||
authorization = authorization.split(':')
|
||||
if len(authorization) == 2:
|
||||
env['REMOTE_USER'] = authorization[0]
|
||||
# XXX REMOTE_IDENT
|
||||
if self.headers.typeheader is None:
|
||||
env['CONTENT_TYPE'] = self.headers.type
|
||||
else:
|
||||
env['CONTENT_TYPE'] = self.headers.typeheader
|
||||
length = self.headers.getheader('content-length')
|
||||
if length:
|
||||
env['CONTENT_LENGTH'] = length
|
||||
referer = self.headers.getheader('referer')
|
||||
if referer:
|
||||
env['HTTP_REFERER'] = referer
|
||||
accept = []
|
||||
for line in self.headers.getallmatchingheaders('accept'):
|
||||
if line[:1] in "\t\n\r ":
|
||||
accept.append(line.strip())
|
||||
else:
|
||||
accept = accept + line[7:].split(',')
|
||||
env['HTTP_ACCEPT'] = ','.join(accept)
|
||||
ua = self.headers.getheader('user-agent')
|
||||
if ua:
|
||||
env['HTTP_USER_AGENT'] = ua
|
||||
co = filter(None, self.headers.getheaders('cookie'))
|
||||
if co:
|
||||
env['HTTP_COOKIE'] = ', '.join(co)
|
||||
# XXX Other HTTP_* headers
|
||||
# Since we're setting the env in the parent, provide empty
|
||||
# values to override previously set values
|
||||
for k in ('QUERY_STRING', 'REMOTE_HOST', 'CONTENT_LENGTH',
|
||||
'HTTP_USER_AGENT', 'HTTP_COOKIE', 'HTTP_REFERER'):
|
||||
env.setdefault(k, "")
|
||||
|
||||
self.send_response(200, "Script output follows")
|
||||
|
||||
decoded_query = query.replace('+', ' ')
|
||||
|
||||
if self.have_fork:
|
||||
# Unix -- fork as we should
|
||||
args = [script]
|
||||
if '=' not in decoded_query:
|
||||
args.append(decoded_query)
|
||||
nobody = nobody_uid()
|
||||
self.wfile.flush() # Always flush before forking
|
||||
pid = os.fork()
|
||||
if pid != 0:
|
||||
# Parent
|
||||
pid, sts = os.waitpid(pid, 0)
|
||||
# throw away additional data [see bug #427345]
|
||||
while select.select([self.rfile], [], [], 0)[0]:
|
||||
if not self.rfile.read(1):
|
||||
break
|
||||
if sts:
|
||||
self.log_error("CGI script exit status %#x", sts)
|
||||
return
|
||||
# Child
|
||||
try:
|
||||
try:
|
||||
os.setuid(nobody)
|
||||
except os.error:
|
||||
pass
|
||||
os.dup2(self.rfile.fileno(), 0)
|
||||
os.dup2(self.wfile.fileno(), 1)
|
||||
os.execve(scriptfile, args, env)
|
||||
except:
|
||||
self.server.handle_error(self.request, self.client_address)
|
||||
os._exit(127)
|
||||
|
||||
else:
|
||||
# Non Unix - use subprocess
|
||||
import subprocess
|
||||
cmdline = [scriptfile]
|
||||
if self.is_python(scriptfile):
|
||||
interp = sys.executable
|
||||
if interp.lower().endswith("w.exe"):
|
||||
# On Windows, use python.exe, not pythonw.exe
|
||||
interp = interp[:-5] + interp[-4:]
|
||||
cmdline = [interp, '-u'] + cmdline
|
||||
if '=' not in query:
|
||||
cmdline.append(query)
|
||||
|
||||
self.log_message("command: %s", subprocess.list2cmdline(cmdline))
|
||||
try:
|
||||
nbytes = int(length)
|
||||
except (TypeError, ValueError):
|
||||
nbytes = 0
|
||||
p = subprocess.Popen(cmdline,
|
||||
stdin = subprocess.PIPE,
|
||||
stdout = subprocess.PIPE,
|
||||
stderr = subprocess.PIPE,
|
||||
env = env
|
||||
)
|
||||
if self.command.lower() == "post" and nbytes > 0:
|
||||
data = self.rfile.read(nbytes)
|
||||
else:
|
||||
data = None
|
||||
# throw away additional data [see bug #427345]
|
||||
while select.select([self.rfile._sock], [], [], 0)[0]:
|
||||
if not self.rfile._sock.recv(1):
|
||||
break
|
||||
stdout, stderr = p.communicate(data)
|
||||
self.wfile.write(stdout)
|
||||
if stderr:
|
||||
self.log_error('%s', stderr)
|
||||
p.stderr.close()
|
||||
p.stdout.close()
|
||||
status = p.returncode
|
||||
if status:
|
||||
self.log_error("CGI script exit status %#x", status)
|
||||
else:
|
||||
self.log_message("CGI script exited OK")
|
||||
|
||||
|
||||
def _url_collapse_path(path):
|
||||
"""
|
||||
Given a URL path, remove extra '/'s and '.' path elements and collapse
|
||||
any '..' references and returns a colllapsed path.
|
||||
|
||||
Implements something akin to RFC-2396 5.2 step 6 to parse relative paths.
|
||||
The utility of this function is limited to is_cgi method and helps
|
||||
preventing some security attacks.
|
||||
|
||||
Returns: The reconstituted URL, which will always start with a '/'.
|
||||
|
||||
Raises: IndexError if too many '..' occur within the path.
|
||||
|
||||
"""
|
||||
# Query component should not be involved.
|
||||
path, _, query = path.partition('?')
|
||||
path = urllib.unquote(path)
|
||||
|
||||
# Similar to os.path.split(os.path.normpath(path)) but specific to URL
|
||||
# path semantics rather than local operating system semantics.
|
||||
path_parts = path.split('/')
|
||||
head_parts = []
|
||||
for part in path_parts[:-1]:
|
||||
if part == '..':
|
||||
head_parts.pop() # IndexError if more '..' than prior parts
|
||||
elif part and part != '.':
|
||||
head_parts.append( part )
|
||||
if path_parts:
|
||||
tail_part = path_parts.pop()
|
||||
if tail_part:
|
||||
if tail_part == '..':
|
||||
head_parts.pop()
|
||||
tail_part = ''
|
||||
elif tail_part == '.':
|
||||
tail_part = ''
|
||||
else:
|
||||
tail_part = ''
|
||||
|
||||
if query:
|
||||
tail_part = '?'.join((tail_part, query))
|
||||
|
||||
splitpath = ('/' + '/'.join(head_parts), tail_part)
|
||||
collapsed_path = "/".join(splitpath)
|
||||
|
||||
return collapsed_path
|
||||
|
||||
|
||||
nobody = None
|
||||
|
||||
def nobody_uid():
|
||||
"""Internal routine to get nobody's uid"""
|
||||
global nobody
|
||||
if nobody:
|
||||
return nobody
|
||||
try:
|
||||
import pwd
|
||||
except ImportError:
|
||||
return -1
|
||||
try:
|
||||
nobody = pwd.getpwnam('nobody')[2]
|
||||
except KeyError:
|
||||
nobody = 1 + max(map(lambda x: x[2], pwd.getpwall()))
|
||||
return nobody
|
||||
|
||||
|
||||
def executable(path):
|
||||
"""Test for executable file."""
|
||||
try:
|
||||
st = os.stat(path)
|
||||
except os.error:
|
||||
return False
|
||||
return st.st_mode & 0111 != 0
|
||||
|
||||
|
||||
def test(HandlerClass = CGIHTTPRequestHandler,
|
||||
ServerClass = BaseHTTPServer.HTTPServer):
|
||||
SimpleHTTPServer.test(HandlerClass, ServerClass)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test()
|
753
c/meterpreter/source/extensions/python/Lib/ConfigParser.py
Normal file
753
c/meterpreter/source/extensions/python/Lib/ConfigParser.py
Normal file
@ -0,0 +1,753 @@
|
||||
"""Configuration file parser.
|
||||
|
||||
A setup file consists of sections, lead by a "[section]" header,
|
||||
and followed by "name: value" entries, with continuations and such in
|
||||
the style of RFC 822.
|
||||
|
||||
The option values can contain format strings which refer to other values in
|
||||
the same section, or values in a special [DEFAULT] section.
|
||||
|
||||
For example:
|
||||
|
||||
something: %(dir)s/whatever
|
||||
|
||||
would resolve the "%(dir)s" to the value of dir. All reference
|
||||
expansions are done late, on demand.
|
||||
|
||||
Intrinsic defaults can be specified by passing them into the
|
||||
ConfigParser constructor as a dictionary.
|
||||
|
||||
class:
|
||||
|
||||
ConfigParser -- responsible for parsing a list of
|
||||
configuration files, and managing the parsed database.
|
||||
|
||||
methods:
|
||||
|
||||
__init__(defaults=None)
|
||||
create the parser and specify a dictionary of intrinsic defaults. The
|
||||
keys must be strings, the values must be appropriate for %()s string
|
||||
interpolation. Note that `__name__' is always an intrinsic default;
|
||||
its value is the section's name.
|
||||
|
||||
sections()
|
||||
return all the configuration section names, sans DEFAULT
|
||||
|
||||
has_section(section)
|
||||
return whether the given section exists
|
||||
|
||||
has_option(section, option)
|
||||
return whether the given option exists in the given section
|
||||
|
||||
options(section)
|
||||
return list of configuration options for the named section
|
||||
|
||||
read(filenames)
|
||||
read and parse the list of named configuration files, given by
|
||||
name. A single filename is also allowed. Non-existing files
|
||||
are ignored. Return list of successfully read files.
|
||||
|
||||
readfp(fp, filename=None)
|
||||
read and parse one configuration file, given as a file object.
|
||||
The filename defaults to fp.name; it is only used in error
|
||||
messages (if fp has no `name' attribute, the string `<???>' is used).
|
||||
|
||||
get(section, option, raw=False, vars=None)
|
||||
return a string value for the named option. All % interpolations are
|
||||
expanded in the return values, based on the defaults passed into the
|
||||
constructor and the DEFAULT section. Additional substitutions may be
|
||||
provided using the `vars' argument, which must be a dictionary whose
|
||||
contents override any pre-existing defaults.
|
||||
|
||||
getint(section, options)
|
||||
like get(), but convert value to an integer
|
||||
|
||||
getfloat(section, options)
|
||||
like get(), but convert value to a float
|
||||
|
||||
getboolean(section, options)
|
||||
like get(), but convert value to a boolean (currently case
|
||||
insensitively defined as 0, false, no, off for False, and 1, true,
|
||||
yes, on for True). Returns False or True.
|
||||
|
||||
items(section, raw=False, vars=None)
|
||||
return a list of tuples with (name, value) for each option
|
||||
in the section.
|
||||
|
||||
remove_section(section)
|
||||
remove the given file section and all its options
|
||||
|
||||
remove_option(section, option)
|
||||
remove the given option from the given section
|
||||
|
||||
set(section, option, value)
|
||||
set the given option
|
||||
|
||||
write(fp)
|
||||
write the configuration state in .ini format
|
||||
"""
|
||||
|
||||
try:
|
||||
from collections import OrderedDict as _default_dict
|
||||
except ImportError:
|
||||
# fallback for setup.py which hasn't yet built _collections
|
||||
_default_dict = dict
|
||||
|
||||
import re
|
||||
|
||||
__all__ = ["NoSectionError", "DuplicateSectionError", "NoOptionError",
|
||||
"InterpolationError", "InterpolationDepthError",
|
||||
"InterpolationSyntaxError", "ParsingError",
|
||||
"MissingSectionHeaderError",
|
||||
"ConfigParser", "SafeConfigParser", "RawConfigParser",
|
||||
"DEFAULTSECT", "MAX_INTERPOLATION_DEPTH"]
|
||||
|
||||
DEFAULTSECT = "DEFAULT"
|
||||
|
||||
MAX_INTERPOLATION_DEPTH = 10
|
||||
|
||||
|
||||
|
||||
# exception classes
|
||||
class Error(Exception):
|
||||
"""Base class for ConfigParser exceptions."""
|
||||
|
||||
def _get_message(self):
|
||||
"""Getter for 'message'; needed only to override deprecation in
|
||||
BaseException."""
|
||||
return self.__message
|
||||
|
||||
def _set_message(self, value):
|
||||
"""Setter for 'message'; needed only to override deprecation in
|
||||
BaseException."""
|
||||
self.__message = value
|
||||
|
||||
# BaseException.message has been deprecated since Python 2.6. To prevent
|
||||
# DeprecationWarning from popping up over this pre-existing attribute, use
|
||||
# a new property that takes lookup precedence.
|
||||
message = property(_get_message, _set_message)
|
||||
|
||||
def __init__(self, msg=''):
|
||||
self.message = msg
|
||||
Exception.__init__(self, msg)
|
||||
|
||||
def __repr__(self):
|
||||
return self.message
|
||||
|
||||
__str__ = __repr__
|
||||
|
||||
class NoSectionError(Error):
|
||||
"""Raised when no section matches a requested option."""
|
||||
|
||||
def __init__(self, section):
|
||||
Error.__init__(self, 'No section: %r' % (section,))
|
||||
self.section = section
|
||||
self.args = (section, )
|
||||
|
||||
class DuplicateSectionError(Error):
|
||||
"""Raised when a section is multiply-created."""
|
||||
|
||||
def __init__(self, section):
|
||||
Error.__init__(self, "Section %r already exists" % section)
|
||||
self.section = section
|
||||
self.args = (section, )
|
||||
|
||||
class NoOptionError(Error):
|
||||
"""A requested option was not found."""
|
||||
|
||||
def __init__(self, option, section):
|
||||
Error.__init__(self, "No option %r in section: %r" %
|
||||
(option, section))
|
||||
self.option = option
|
||||
self.section = section
|
||||
self.args = (option, section)
|
||||
|
||||
class InterpolationError(Error):
|
||||
"""Base class for interpolation-related exceptions."""
|
||||
|
||||
def __init__(self, option, section, msg):
|
||||
Error.__init__(self, msg)
|
||||
self.option = option
|
||||
self.section = section
|
||||
self.args = (option, section, msg)
|
||||
|
||||
class InterpolationMissingOptionError(InterpolationError):
|
||||
"""A string substitution required a setting which was not available."""
|
||||
|
||||
def __init__(self, option, section, rawval, reference):
|
||||
msg = ("Bad value substitution:\n"
|
||||
"\tsection: [%s]\n"
|
||||
"\toption : %s\n"
|
||||
"\tkey : %s\n"
|
||||
"\trawval : %s\n"
|
||||
% (section, option, reference, rawval))
|
||||
InterpolationError.__init__(self, option, section, msg)
|
||||
self.reference = reference
|
||||
self.args = (option, section, rawval, reference)
|
||||
|
||||
class InterpolationSyntaxError(InterpolationError):
|
||||
"""Raised when the source text into which substitutions are made
|
||||
does not conform to the required syntax."""
|
||||
|
||||
class InterpolationDepthError(InterpolationError):
|
||||
"""Raised when substitutions are nested too deeply."""
|
||||
|
||||
def __init__(self, option, section, rawval):
|
||||
msg = ("Value interpolation too deeply recursive:\n"
|
||||
"\tsection: [%s]\n"
|
||||
"\toption : %s\n"
|
||||
"\trawval : %s\n"
|
||||
% (section, option, rawval))
|
||||
InterpolationError.__init__(self, option, section, msg)
|
||||
self.args = (option, section, rawval)
|
||||
|
||||
class ParsingError(Error):
|
||||
"""Raised when a configuration file does not follow legal syntax."""
|
||||
|
||||
def __init__(self, filename):
|
||||
Error.__init__(self, 'File contains parsing errors: %s' % filename)
|
||||
self.filename = filename
|
||||
self.errors = []
|
||||
self.args = (filename, )
|
||||
|
||||
def append(self, lineno, line):
|
||||
self.errors.append((lineno, line))
|
||||
self.message += '\n\t[line %2d]: %s' % (lineno, line)
|
||||
|
||||
class MissingSectionHeaderError(ParsingError):
|
||||
"""Raised when a key-value pair is found before any section header."""
|
||||
|
||||
def __init__(self, filename, lineno, line):
|
||||
Error.__init__(
|
||||
self,
|
||||
'File contains no section headers.\nfile: %s, line: %d\n%r' %
|
||||
(filename, lineno, line))
|
||||
self.filename = filename
|
||||
self.lineno = lineno
|
||||
self.line = line
|
||||
self.args = (filename, lineno, line)
|
||||
|
||||
|
||||
class RawConfigParser:
|
||||
def __init__(self, defaults=None, dict_type=_default_dict,
|
||||
allow_no_value=False):
|
||||
self._dict = dict_type
|
||||
self._sections = self._dict()
|
||||
self._defaults = self._dict()
|
||||
if allow_no_value:
|
||||
self._optcre = self.OPTCRE_NV
|
||||
else:
|
||||
self._optcre = self.OPTCRE
|
||||
if defaults:
|
||||
for key, value in defaults.items():
|
||||
self._defaults[self.optionxform(key)] = value
|
||||
|
||||
def defaults(self):
|
||||
return self._defaults
|
||||
|
||||
def sections(self):
|
||||
"""Return a list of section names, excluding [DEFAULT]"""
|
||||
# self._sections will never have [DEFAULT] in it
|
||||
return self._sections.keys()
|
||||
|
||||
def add_section(self, section):
|
||||
"""Create a new section in the configuration.
|
||||
|
||||
Raise DuplicateSectionError if a section by the specified name
|
||||
already exists. Raise ValueError if name is DEFAULT or any of it's
|
||||
case-insensitive variants.
|
||||
"""
|
||||
if section.lower() == "default":
|
||||
raise ValueError, 'Invalid section name: %s' % section
|
||||
|
||||
if section in self._sections:
|
||||
raise DuplicateSectionError(section)
|
||||
self._sections[section] = self._dict()
|
||||
|
||||
def has_section(self, section):
|
||||
"""Indicate whether the named section is present in the configuration.
|
||||
|
||||
The DEFAULT section is not acknowledged.
|
||||
"""
|
||||
return section in self._sections
|
||||
|
||||
def options(self, section):
|
||||
"""Return a list of option names for the given section name."""
|
||||
try:
|
||||
opts = self._sections[section].copy()
|
||||
except KeyError:
|
||||
raise NoSectionError(section)
|
||||
opts.update(self._defaults)
|
||||
if '__name__' in opts:
|
||||
del opts['__name__']
|
||||
return opts.keys()
|
||||
|
||||
def read(self, filenames):
|
||||
"""Read and parse a filename or a list of filenames.
|
||||
|
||||
Files that cannot be opened are silently ignored; this is
|
||||
designed so that you can specify a list of potential
|
||||
configuration file locations (e.g. current directory, user's
|
||||
home directory, systemwide directory), and all existing
|
||||
configuration files in the list will be read. A single
|
||||
filename may also be given.
|
||||
|
||||
Return list of successfully read files.
|
||||
"""
|
||||
if isinstance(filenames, basestring):
|
||||
filenames = [filenames]
|
||||
read_ok = []
|
||||
for filename in filenames:
|
||||
try:
|
||||
fp = open(filename)
|
||||
except IOError:
|
||||
continue
|
||||
self._read(fp, filename)
|
||||
fp.close()
|
||||
read_ok.append(filename)
|
||||
return read_ok
|
||||
|
||||
def readfp(self, fp, filename=None):
|
||||
"""Like read() but the argument must be a file-like object.
|
||||
|
||||
The `fp' argument must have a `readline' method. Optional
|
||||
second argument is the `filename', which if not given, is
|
||||
taken from fp.name. If fp has no `name' attribute, `<???>' is
|
||||
used.
|
||||
|
||||
"""
|
||||
if filename is None:
|
||||
try:
|
||||
filename = fp.name
|
||||
except AttributeError:
|
||||
filename = '<???>'
|
||||
self._read(fp, filename)
|
||||
|
||||
def get(self, section, option):
|
||||
opt = self.optionxform(option)
|
||||
if section not in self._sections:
|
||||
if section != DEFAULTSECT:
|
||||
raise NoSectionError(section)
|
||||
if opt in self._defaults:
|
||||
return self._defaults[opt]
|
||||
else:
|
||||
raise NoOptionError(option, section)
|
||||
elif opt in self._sections[section]:
|
||||
return self._sections[section][opt]
|
||||
elif opt in self._defaults:
|
||||
return self._defaults[opt]
|
||||
else:
|
||||
raise NoOptionError(option, section)
|
||||
|
||||
def items(self, section):
|
||||
try:
|
||||
d2 = self._sections[section]
|
||||
except KeyError:
|
||||
if section != DEFAULTSECT:
|
||||
raise NoSectionError(section)
|
||||
d2 = self._dict()
|
||||
d = self._defaults.copy()
|
||||
d.update(d2)
|
||||
if "__name__" in d:
|
||||
del d["__name__"]
|
||||
return d.items()
|
||||
|
||||
def _get(self, section, conv, option):
|
||||
return conv(self.get(section, option))
|
||||
|
||||
def getint(self, section, option):
|
||||
return self._get(section, int, option)
|
||||
|
||||
def getfloat(self, section, option):
|
||||
return self._get(section, float, option)
|
||||
|
||||
_boolean_states = {'1': True, 'yes': True, 'true': True, 'on': True,
|
||||
'0': False, 'no': False, 'false': False, 'off': False}
|
||||
|
||||
def getboolean(self, section, option):
|
||||
v = self.get(section, option)
|
||||
if v.lower() not in self._boolean_states:
|
||||
raise ValueError, 'Not a boolean: %s' % v
|
||||
return self._boolean_states[v.lower()]
|
||||
|
||||
def optionxform(self, optionstr):
|
||||
return optionstr.lower()
|
||||
|
||||
def has_option(self, section, option):
|
||||
"""Check for the existence of a given option in a given section."""
|
||||
if not section or section == DEFAULTSECT:
|
||||
option = self.optionxform(option)
|
||||
return option in self._defaults
|
||||
elif section not in self._sections:
|
||||
return False
|
||||
else:
|
||||
option = self.optionxform(option)
|
||||
return (option in self._sections[section]
|
||||
or option in self._defaults)
|
||||
|
||||
def set(self, section, option, value=None):
|
||||
"""Set an option."""
|
||||
if not section or section == DEFAULTSECT:
|
||||
sectdict = self._defaults
|
||||
else:
|
||||
try:
|
||||
sectdict = self._sections[section]
|
||||
except KeyError:
|
||||
raise NoSectionError(section)
|
||||
sectdict[self.optionxform(option)] = value
|
||||
|
||||
def write(self, fp):
|
||||
"""Write an .ini-format representation of the configuration state."""
|
||||
if self._defaults:
|
||||
fp.write("[%s]\n" % DEFAULTSECT)
|
||||
for (key, value) in self._defaults.items():
|
||||
fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t')))
|
||||
fp.write("\n")
|
||||
for section in self._sections:
|
||||
fp.write("[%s]\n" % section)
|
||||
for (key, value) in self._sections[section].items():
|
||||
if key == "__name__":
|
||||
continue
|
||||
if (value is not None) or (self._optcre == self.OPTCRE):
|
||||
key = " = ".join((key, str(value).replace('\n', '\n\t')))
|
||||
fp.write("%s\n" % (key))
|
||||
fp.write("\n")
|
||||
|
||||
def remove_option(self, section, option):
|
||||
"""Remove an option."""
|
||||
if not section or section == DEFAULTSECT:
|
||||
sectdict = self._defaults
|
||||
else:
|
||||
try:
|
||||
sectdict = self._sections[section]
|
||||
except KeyError:
|
||||
raise NoSectionError(section)
|
||||
option = self.optionxform(option)
|
||||
existed = option in sectdict
|
||||
if existed:
|
||||
del sectdict[option]
|
||||
return existed
|
||||
|
||||
def remove_section(self, section):
|
||||
"""Remove a file section."""
|
||||
existed = section in self._sections
|
||||
if existed:
|
||||
del self._sections[section]
|
||||
return existed
|
||||
|
||||
#
|
||||
# Regular expressions for parsing section headers and options.
|
||||
#
|
||||
SECTCRE = re.compile(
|
||||
r'\[' # [
|
||||
r'(?P<header>[^]]+)' # very permissive!
|
||||
r'\]' # ]
|
||||
)
|
||||
OPTCRE = re.compile(
|
||||
r'(?P<option>[^:=\s][^:=]*)' # very permissive!
|
||||
r'\s*(?P<vi>[:=])\s*' # any number of space/tab,
|
||||
# followed by separator
|
||||
# (either : or =), followed
|
||||
# by any # space/tab
|
||||
r'(?P<value>.*)$' # everything up to eol
|
||||
)
|
||||
OPTCRE_NV = re.compile(
|
||||
r'(?P<option>[^:=\s][^:=]*)' # very permissive!
|
||||
r'\s*(?:' # any number of space/tab,
|
||||
r'(?P<vi>[:=])\s*' # optionally followed by
|
||||
# separator (either : or
|
||||
# =), followed by any #
|
||||
# space/tab
|
||||
r'(?P<value>.*))?$' # everything up to eol
|
||||
)
|
||||
|
||||
def _read(self, fp, fpname):
|
||||
"""Parse a sectioned setup file.
|
||||
|
||||
The sections in setup file contains a title line at the top,
|
||||
indicated by a name in square brackets (`[]'), plus key/value
|
||||
options lines, indicated by `name: value' format lines.
|
||||
Continuations are represented by an embedded newline then
|
||||
leading whitespace. Blank lines, lines beginning with a '#',
|
||||
and just about everything else are ignored.
|
||||
"""
|
||||
cursect = None # None, or a dictionary
|
||||
optname = None
|
||||
lineno = 0
|
||||
e = None # None, or an exception
|
||||
while True:
|
||||
line = fp.readline()
|
||||
if not line:
|
||||
break
|
||||
lineno = lineno + 1
|
||||
# comment or blank line?
|
||||
if line.strip() == '' or line[0] in '#;':
|
||||
continue
|
||||
if line.split(None, 1)[0].lower() == 'rem' and line[0] in "rR":
|
||||
# no leading whitespace
|
||||
continue
|
||||
# continuation line?
|
||||
if line[0].isspace() and cursect is not None and optname:
|
||||
value = line.strip()
|
||||
if value:
|
||||
cursect[optname].append(value)
|
||||
# a section header or option header?
|
||||
else:
|
||||
# is it a section header?
|
||||
mo = self.SECTCRE.match(line)
|
||||
if mo:
|
||||
sectname = mo.group('header')
|
||||
if sectname in self._sections:
|
||||
cursect = self._sections[sectname]
|
||||
elif sectname == DEFAULTSECT:
|
||||
cursect = self._defaults
|
||||
else:
|
||||
cursect = self._dict()
|
||||
cursect['__name__'] = sectname
|
||||
self._sections[sectname] = cursect
|
||||
# So sections can't start with a continuation line
|
||||
optname = None
|
||||
# no section header in the file?
|
||||
elif cursect is None:
|
||||
raise MissingSectionHeaderError(fpname, lineno, line)
|
||||
# an option line?
|
||||
else:
|
||||
mo = self._optcre.match(line)
|
||||
if mo:
|
||||
optname, vi, optval = mo.group('option', 'vi', 'value')
|
||||
optname = self.optionxform(optname.rstrip())
|
||||
# This check is fine because the OPTCRE cannot
|
||||
# match if it would set optval to None
|
||||
if optval is not None:
|
||||
if vi in ('=', ':') and ';' in optval:
|
||||
# ';' is a comment delimiter only if it follows
|
||||
# a spacing character
|
||||
pos = optval.find(';')
|
||||
if pos != -1 and optval[pos-1].isspace():
|
||||
optval = optval[:pos]
|
||||
optval = optval.strip()
|
||||
# allow empty values
|
||||
if optval == '""':
|
||||
optval = ''
|
||||
cursect[optname] = [optval]
|
||||
else:
|
||||
# valueless option handling
|
||||
cursect[optname] = optval
|
||||
else:
|
||||
# a non-fatal parsing error occurred. set up the
|
||||
# exception but keep going. the exception will be
|
||||
# raised at the end of the file and will contain a
|
||||
# list of all bogus lines
|
||||
if not e:
|
||||
e = ParsingError(fpname)
|
||||
e.append(lineno, repr(line))
|
||||
# if any parsing errors occurred, raise an exception
|
||||
if e:
|
||||
raise e
|
||||
|
||||
# join the multi-line values collected while reading
|
||||
all_sections = [self._defaults]
|
||||
all_sections.extend(self._sections.values())
|
||||
for options in all_sections:
|
||||
for name, val in options.items():
|
||||
if isinstance(val, list):
|
||||
options[name] = '\n'.join(val)
|
||||
|
||||
import UserDict as _UserDict
|
||||
|
||||
class _Chainmap(_UserDict.DictMixin):
|
||||
"""Combine multiple mappings for successive lookups.
|
||||
|
||||
For example, to emulate Python's normal lookup sequence:
|
||||
|
||||
import __builtin__
|
||||
pylookup = _Chainmap(locals(), globals(), vars(__builtin__))
|
||||
"""
|
||||
|
||||
def __init__(self, *maps):
|
||||
self._maps = maps
|
||||
|
||||
def __getitem__(self, key):
|
||||
for mapping in self._maps:
|
||||
try:
|
||||
return mapping[key]
|
||||
except KeyError:
|
||||
pass
|
||||
raise KeyError(key)
|
||||
|
||||
def keys(self):
|
||||
result = []
|
||||
seen = set()
|
||||
for mapping in self._maps:
|
||||
for key in mapping:
|
||||
if key not in seen:
|
||||
result.append(key)
|
||||
seen.add(key)
|
||||
return result
|
||||
|
||||
class ConfigParser(RawConfigParser):
|
||||
|
||||
def get(self, section, option, raw=False, vars=None):
|
||||
"""Get an option value for a given section.
|
||||
|
||||
If `vars' is provided, it must be a dictionary. The option is looked up
|
||||
in `vars' (if provided), `section', and in `defaults' in that order.
|
||||
|
||||
All % interpolations are expanded in the return values, unless the
|
||||
optional argument `raw' is true. Values for interpolation keys are
|
||||
looked up in the same manner as the option.
|
||||
|
||||
The section DEFAULT is special.
|
||||
"""
|
||||
sectiondict = {}
|
||||
try:
|
||||
sectiondict = self._sections[section]
|
||||
except KeyError:
|
||||
if section != DEFAULTSECT:
|
||||
raise NoSectionError(section)
|
||||
# Update with the entry specific variables
|
||||
vardict = {}
|
||||
if vars:
|
||||
for key, value in vars.items():
|
||||
vardict[self.optionxform(key)] = value
|
||||
d = _Chainmap(vardict, sectiondict, self._defaults)
|
||||
option = self.optionxform(option)
|
||||
try:
|
||||
value = d[option]
|
||||
except KeyError:
|
||||
raise NoOptionError(option, section)
|
||||
|
||||
if raw or value is None:
|
||||
return value
|
||||
else:
|
||||
return self._interpolate(section, option, value, d)
|
||||
|
||||
def items(self, section, raw=False, vars=None):
|
||||
"""Return a list of tuples with (name, value) for each option
|
||||
in the section.
|
||||
|
||||
All % interpolations are expanded in the return values, based on the
|
||||
defaults passed into the constructor, unless the optional argument
|
||||
`raw' is true. Additional substitutions may be provided using the
|
||||
`vars' argument, which must be a dictionary whose contents overrides
|
||||
any pre-existing defaults.
|
||||
|
||||
The section DEFAULT is special.
|
||||
"""
|
||||
d = self._defaults.copy()
|
||||
try:
|
||||
d.update(self._sections[section])
|
||||
except KeyError:
|
||||
if section != DEFAULTSECT:
|
||||
raise NoSectionError(section)
|
||||
# Update with the entry specific variables
|
||||
if vars:
|
||||
for key, value in vars.items():
|
||||
d[self.optionxform(key)] = value
|
||||
options = d.keys()
|
||||
if "__name__" in options:
|
||||
options.remove("__name__")
|
||||
if raw:
|
||||
return [(option, d[option])
|
||||
for option in options]
|
||||
else:
|
||||
return [(option, self._interpolate(section, option, d[option], d))
|
||||
for option in options]
|
||||
|
||||
def _interpolate(self, section, option, rawval, vars):
|
||||
# do the string interpolation
|
||||
value = rawval
|
||||
depth = MAX_INTERPOLATION_DEPTH
|
||||
while depth: # Loop through this until it's done
|
||||
depth -= 1
|
||||
if value and "%(" in value:
|
||||
value = self._KEYCRE.sub(self._interpolation_replace, value)
|
||||
try:
|
||||
value = value % vars
|
||||
except KeyError, e:
|
||||
raise InterpolationMissingOptionError(
|
||||
option, section, rawval, e.args[0])
|
||||
else:
|
||||
break
|
||||
if value and "%(" in value:
|
||||
raise InterpolationDepthError(option, section, rawval)
|
||||
return value
|
||||
|
||||
_KEYCRE = re.compile(r"%\(([^)]*)\)s|.")
|
||||
|
||||
def _interpolation_replace(self, match):
|
||||
s = match.group(1)
|
||||
if s is None:
|
||||
return match.group()
|
||||
else:
|
||||
return "%%(%s)s" % self.optionxform(s)
|
||||
|
||||
|
||||
class SafeConfigParser(ConfigParser):
|
||||
|
||||
def _interpolate(self, section, option, rawval, vars):
|
||||
# do the string interpolation
|
||||
L = []
|
||||
self._interpolate_some(option, L, rawval, section, vars, 1)
|
||||
return ''.join(L)
|
||||
|
||||
_interpvar_re = re.compile(r"%\(([^)]+)\)s")
|
||||
|
||||
def _interpolate_some(self, option, accum, rest, section, map, depth):
|
||||
if depth > MAX_INTERPOLATION_DEPTH:
|
||||
raise InterpolationDepthError(option, section, rest)
|
||||
while rest:
|
||||
p = rest.find("%")
|
||||
if p < 0:
|
||||
accum.append(rest)
|
||||
return
|
||||
if p > 0:
|
||||
accum.append(rest[:p])
|
||||
rest = rest[p:]
|
||||
# p is no longer used
|
||||
c = rest[1:2]
|
||||
if c == "%":
|
||||
accum.append("%")
|
||||
rest = rest[2:]
|
||||
elif c == "(":
|
||||
m = self._interpvar_re.match(rest)
|
||||
if m is None:
|
||||
raise InterpolationSyntaxError(option, section,
|
||||
"bad interpolation variable reference %r" % rest)
|
||||
var = self.optionxform(m.group(1))
|
||||
rest = rest[m.end():]
|
||||
try:
|
||||
v = map[var]
|
||||
except KeyError:
|
||||
raise InterpolationMissingOptionError(
|
||||
option, section, rest, var)
|
||||
if "%" in v:
|
||||
self._interpolate_some(option, accum, v,
|
||||
section, map, depth + 1)
|
||||
else:
|
||||
accum.append(v)
|
||||
else:
|
||||
raise InterpolationSyntaxError(
|
||||
option, section,
|
||||
"'%%' must be followed by '%%' or '(', found: %r" % (rest,))
|
||||
|
||||
def set(self, section, option, value=None):
|
||||
"""Set an option. Extend ConfigParser.set: check for string values."""
|
||||
# The only legal non-string value if we allow valueless
|
||||
# options is None, so we need to check if the value is a
|
||||
# string if:
|
||||
# - we do not allow valueless options, or
|
||||
# - we allow valueless options but the value is not None
|
||||
if self._optcre is self.OPTCRE or value:
|
||||
if not isinstance(value, basestring):
|
||||
raise TypeError("option values must be strings")
|
||||
if value is not None:
|
||||
# check for bad percent signs:
|
||||
# first, replace all "good" interpolations
|
||||
tmp_value = value.replace('%%', '')
|
||||
tmp_value = self._interpvar_re.sub('', tmp_value)
|
||||
# then, check if there's a lone percent sign left
|
||||
if '%' in tmp_value:
|
||||
raise ValueError("invalid interpolation syntax in %r at "
|
||||
"position %d" % (value, tmp_value.find('%')))
|
||||
ConfigParser.set(self, section, option, value)
|
773
c/meterpreter/source/extensions/python/Lib/Cookie.py
Normal file
773
c/meterpreter/source/extensions/python/Lib/Cookie.py
Normal file
@ -0,0 +1,773 @@
|
||||
####
|
||||
# Copyright 2000 by Timothy O'Malley <timo@alum.mit.edu>
|
||||
#
|
||||
# All Rights Reserved
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software
|
||||
# and its documentation for any purpose and without fee is hereby
|
||||
# granted, provided that the above copyright notice appear in all
|
||||
# copies and that both that copyright notice and this permission
|
||||
# notice appear in supporting documentation, and that the name of
|
||||
# Timothy O'Malley not be used in advertising or publicity
|
||||
# pertaining to distribution of the software without specific, written
|
||||
# prior permission.
|
||||
#
|
||||
# Timothy O'Malley DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
||||
# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
# AND FITNESS, IN NO EVENT SHALL Timothy O'Malley BE LIABLE FOR
|
||||
# ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
# PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
####
|
||||
#
|
||||
# Id: Cookie.py,v 2.29 2000/08/23 05:28:49 timo Exp
|
||||
# by Timothy O'Malley <timo@alum.mit.edu>
|
||||
#
|
||||
# Cookie.py is a Python module for the handling of HTTP
|
||||
# cookies as a Python dictionary. See RFC 2109 for more
|
||||
# information on cookies.
|
||||
#
|
||||
# The original idea to treat Cookies as a dictionary came from
|
||||
# Dave Mitchell (davem@magnet.com) in 1995, when he released the
|
||||
# first version of nscookie.py.
|
||||
#
|
||||
####
|
||||
|
||||
r"""
|
||||
Here's a sample session to show how to use this module.
|
||||
At the moment, this is the only documentation.
|
||||
|
||||
The Basics
|
||||
----------
|
||||
|
||||
Importing is easy..
|
||||
|
||||
>>> import Cookie
|
||||
|
||||
Most of the time you start by creating a cookie. Cookies come in
|
||||
three flavors, each with slightly different encoding semantics, but
|
||||
more on that later.
|
||||
|
||||
>>> C = Cookie.SimpleCookie()
|
||||
>>> C = Cookie.SerialCookie()
|
||||
>>> C = Cookie.SmartCookie()
|
||||
|
||||
[Note: Long-time users of Cookie.py will remember using
|
||||
Cookie.Cookie() to create a Cookie object. Although deprecated, it
|
||||
is still supported by the code. See the Backward Compatibility notes
|
||||
for more information.]
|
||||
|
||||
Once you've created your Cookie, you can add values just as if it were
|
||||
a dictionary.
|
||||
|
||||
>>> C = Cookie.SmartCookie()
|
||||
>>> C["fig"] = "newton"
|
||||
>>> C["sugar"] = "wafer"
|
||||
>>> C.output()
|
||||
'Set-Cookie: fig=newton\r\nSet-Cookie: sugar=wafer'
|
||||
|
||||
Notice that the printable representation of a Cookie is the
|
||||
appropriate format for a Set-Cookie: header. This is the
|
||||
default behavior. You can change the header and printed
|
||||
attributes by using the .output() function
|
||||
|
||||
>>> C = Cookie.SmartCookie()
|
||||
>>> C["rocky"] = "road"
|
||||
>>> C["rocky"]["path"] = "/cookie"
|
||||
>>> print C.output(header="Cookie:")
|
||||
Cookie: rocky=road; Path=/cookie
|
||||
>>> print C.output(attrs=[], header="Cookie:")
|
||||
Cookie: rocky=road
|
||||
|
||||
The load() method of a Cookie extracts cookies from a string. In a
|
||||
CGI script, you would use this method to extract the cookies from the
|
||||
HTTP_COOKIE environment variable.
|
||||
|
||||
>>> C = Cookie.SmartCookie()
|
||||
>>> C.load("chips=ahoy; vienna=finger")
|
||||
>>> C.output()
|
||||
'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger'
|
||||
|
||||
The load() method is darn-tootin smart about identifying cookies
|
||||
within a string. Escaped quotation marks, nested semicolons, and other
|
||||
such trickeries do not confuse it.
|
||||
|
||||
>>> C = Cookie.SmartCookie()
|
||||
>>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
|
||||
>>> print C
|
||||
Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"
|
||||
|
||||
Each element of the Cookie also supports all of the RFC 2109
|
||||
Cookie attributes. Here's an example which sets the Path
|
||||
attribute.
|
||||
|
||||
>>> C = Cookie.SmartCookie()
|
||||
>>> C["oreo"] = "doublestuff"
|
||||
>>> C["oreo"]["path"] = "/"
|
||||
>>> print C
|
||||
Set-Cookie: oreo=doublestuff; Path=/
|
||||
|
||||
Each dictionary element has a 'value' attribute, which gives you
|
||||
back the value associated with the key.
|
||||
|
||||
>>> C = Cookie.SmartCookie()
|
||||
>>> C["twix"] = "none for you"
|
||||
>>> C["twix"].value
|
||||
'none for you'
|
||||
|
||||
|
||||
A Bit More Advanced
|
||||
-------------------
|
||||
|
||||
As mentioned before, there are three different flavors of Cookie
|
||||
objects, each with different encoding/decoding semantics. This
|
||||
section briefly discusses the differences.
|
||||
|
||||
SimpleCookie
|
||||
|
||||
The SimpleCookie expects that all values should be standard strings.
|
||||
Just to be sure, SimpleCookie invokes the str() builtin to convert
|
||||
the value to a string, when the values are set dictionary-style.
|
||||
|
||||
>>> C = Cookie.SimpleCookie()
|
||||
>>> C["number"] = 7
|
||||
>>> C["string"] = "seven"
|
||||
>>> C["number"].value
|
||||
'7'
|
||||
>>> C["string"].value
|
||||
'seven'
|
||||
>>> C.output()
|
||||
'Set-Cookie: number=7\r\nSet-Cookie: string=seven'
|
||||
|
||||
|
||||
SerialCookie
|
||||
|
||||
The SerialCookie expects that all values should be serialized using
|
||||
cPickle (or pickle, if cPickle isn't available). As a result of
|
||||
serializing, SerialCookie can save almost any Python object to a
|
||||
value, and recover the exact same object when the cookie has been
|
||||
returned. (SerialCookie can yield some strange-looking cookie
|
||||
values, however.)
|
||||
|
||||
>>> C = Cookie.SerialCookie()
|
||||
>>> C["number"] = 7
|
||||
>>> C["string"] = "seven"
|
||||
>>> C["number"].value
|
||||
7
|
||||
>>> C["string"].value
|
||||
'seven'
|
||||
>>> C.output()
|
||||
'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string="S\'seven\'\\012p1\\012."'
|
||||
|
||||
Be warned, however, if SerialCookie cannot de-serialize a value (because
|
||||
it isn't a valid pickle'd object), IT WILL RAISE AN EXCEPTION.
|
||||
|
||||
|
||||
SmartCookie
|
||||
|
||||
The SmartCookie combines aspects of each of the other two flavors.
|
||||
When setting a value in a dictionary-fashion, the SmartCookie will
|
||||
serialize (ala cPickle) the value *if and only if* it isn't a
|
||||
Python string. String objects are *not* serialized. Similarly,
|
||||
when the load() method parses out values, it attempts to de-serialize
|
||||
the value. If it fails, then it fallsback to treating the value
|
||||
as a string.
|
||||
|
||||
>>> C = Cookie.SmartCookie()
|
||||
>>> C["number"] = 7
|
||||
>>> C["string"] = "seven"
|
||||
>>> C["number"].value
|
||||
7
|
||||
>>> C["string"].value
|
||||
'seven'
|
||||
>>> C.output()
|
||||
'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string=seven'
|
||||
|
||||
|
||||
Backwards Compatibility
|
||||
-----------------------
|
||||
|
||||
In order to keep compatibilty with earlier versions of Cookie.py,
|
||||
it is still possible to use Cookie.Cookie() to create a Cookie. In
|
||||
fact, this simply returns a SmartCookie.
|
||||
|
||||
>>> C = Cookie.Cookie()
|
||||
>>> print C.__class__.__name__
|
||||
SmartCookie
|
||||
|
||||
|
||||
Finis.
|
||||
""" #"
|
||||
# ^
|
||||
# |----helps out font-lock
|
||||
|
||||
#
|
||||
# Import our required modules
|
||||
#
|
||||
import string
|
||||
|
||||
try:
|
||||
from cPickle import dumps, loads
|
||||
except ImportError:
|
||||
from pickle import dumps, loads
|
||||
|
||||
import re, warnings
|
||||
|
||||
__all__ = ["CookieError","BaseCookie","SimpleCookie","SerialCookie",
|
||||
"SmartCookie","Cookie"]
|
||||
|
||||
_nulljoin = ''.join
|
||||
_semispacejoin = '; '.join
|
||||
_spacejoin = ' '.join
|
||||
|
||||
#
|
||||
# Define an exception visible to External modules
|
||||
#
|
||||
class CookieError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
# These quoting routines conform to the RFC2109 specification, which in
|
||||
# turn references the character definitions from RFC2068. They provide
|
||||
# a two-way quoting algorithm. Any non-text character is translated
|
||||
# into a 4 character sequence: a forward-slash followed by the
|
||||
# three-digit octal equivalent of the character. Any '\' or '"' is
|
||||
# quoted with a preceding '\' slash.
|
||||
#
|
||||
# These are taken from RFC2068 and RFC2109.
|
||||
# _LegalChars is the list of chars which don't require "'s
|
||||
# _Translator hash-table for fast quoting
|
||||
#
|
||||
_LegalChars = string.ascii_letters + string.digits + "!#$%&'*+-.^_`|~"
|
||||
_Translator = {
|
||||
'\000' : '\\000', '\001' : '\\001', '\002' : '\\002',
|
||||
'\003' : '\\003', '\004' : '\\004', '\005' : '\\005',
|
||||
'\006' : '\\006', '\007' : '\\007', '\010' : '\\010',
|
||||
'\011' : '\\011', '\012' : '\\012', '\013' : '\\013',
|
||||
'\014' : '\\014', '\015' : '\\015', '\016' : '\\016',
|
||||
'\017' : '\\017', '\020' : '\\020', '\021' : '\\021',
|
||||
'\022' : '\\022', '\023' : '\\023', '\024' : '\\024',
|
||||
'\025' : '\\025', '\026' : '\\026', '\027' : '\\027',
|
||||
'\030' : '\\030', '\031' : '\\031', '\032' : '\\032',
|
||||
'\033' : '\\033', '\034' : '\\034', '\035' : '\\035',
|
||||
'\036' : '\\036', '\037' : '\\037',
|
||||
|
||||
# Because of the way browsers really handle cookies (as opposed
|
||||
# to what the RFC says) we also encode , and ;
|
||||
|
||||
',' : '\\054', ';' : '\\073',
|
||||
|
||||
'"' : '\\"', '\\' : '\\\\',
|
||||
|
||||
'\177' : '\\177', '\200' : '\\200', '\201' : '\\201',
|
||||
'\202' : '\\202', '\203' : '\\203', '\204' : '\\204',
|
||||
'\205' : '\\205', '\206' : '\\206', '\207' : '\\207',
|
||||
'\210' : '\\210', '\211' : '\\211', '\212' : '\\212',
|
||||
'\213' : '\\213', '\214' : '\\214', '\215' : '\\215',
|
||||
'\216' : '\\216', '\217' : '\\217', '\220' : '\\220',
|
||||
'\221' : '\\221', '\222' : '\\222', '\223' : '\\223',
|
||||
'\224' : '\\224', '\225' : '\\225', '\226' : '\\226',
|
||||
'\227' : '\\227', '\230' : '\\230', '\231' : '\\231',
|
||||
'\232' : '\\232', '\233' : '\\233', '\234' : '\\234',
|
||||
'\235' : '\\235', '\236' : '\\236', '\237' : '\\237',
|
||||
'\240' : '\\240', '\241' : '\\241', '\242' : '\\242',
|
||||
'\243' : '\\243', '\244' : '\\244', '\245' : '\\245',
|
||||
'\246' : '\\246', '\247' : '\\247', '\250' : '\\250',
|
||||
'\251' : '\\251', '\252' : '\\252', '\253' : '\\253',
|
||||
'\254' : '\\254', '\255' : '\\255', '\256' : '\\256',
|
||||
'\257' : '\\257', '\260' : '\\260', '\261' : '\\261',
|
||||
'\262' : '\\262', '\263' : '\\263', '\264' : '\\264',
|
||||
'\265' : '\\265', '\266' : '\\266', '\267' : '\\267',
|
||||
'\270' : '\\270', '\271' : '\\271', '\272' : '\\272',
|
||||
'\273' : '\\273', '\274' : '\\274', '\275' : '\\275',
|
||||
'\276' : '\\276', '\277' : '\\277', '\300' : '\\300',
|
||||
'\301' : '\\301', '\302' : '\\302', '\303' : '\\303',
|
||||
'\304' : '\\304', '\305' : '\\305', '\306' : '\\306',
|
||||
'\307' : '\\307', '\310' : '\\310', '\311' : '\\311',
|
||||
'\312' : '\\312', '\313' : '\\313', '\314' : '\\314',
|
||||
'\315' : '\\315', '\316' : '\\316', '\317' : '\\317',
|
||||
'\320' : '\\320', '\321' : '\\321', '\322' : '\\322',
|
||||
'\323' : '\\323', '\324' : '\\324', '\325' : '\\325',
|
||||
'\326' : '\\326', '\327' : '\\327', '\330' : '\\330',
|
||||
'\331' : '\\331', '\332' : '\\332', '\333' : '\\333',
|
||||
'\334' : '\\334', '\335' : '\\335', '\336' : '\\336',
|
||||
'\337' : '\\337', '\340' : '\\340', '\341' : '\\341',
|
||||
'\342' : '\\342', '\343' : '\\343', '\344' : '\\344',
|
||||
'\345' : '\\345', '\346' : '\\346', '\347' : '\\347',
|
||||
'\350' : '\\350', '\351' : '\\351', '\352' : '\\352',
|
||||
'\353' : '\\353', '\354' : '\\354', '\355' : '\\355',
|
||||
'\356' : '\\356', '\357' : '\\357', '\360' : '\\360',
|
||||
'\361' : '\\361', '\362' : '\\362', '\363' : '\\363',
|
||||
'\364' : '\\364', '\365' : '\\365', '\366' : '\\366',
|
||||
'\367' : '\\367', '\370' : '\\370', '\371' : '\\371',
|
||||
'\372' : '\\372', '\373' : '\\373', '\374' : '\\374',
|
||||
'\375' : '\\375', '\376' : '\\376', '\377' : '\\377'
|
||||
}
|
||||
|
||||
_idmap = ''.join(chr(x) for x in xrange(256))
|
||||
|
||||
def _quote(str, LegalChars=_LegalChars,
|
||||
idmap=_idmap, translate=string.translate):
|
||||
#
|
||||
# If the string does not need to be double-quoted,
|
||||
# then just return the string. Otherwise, surround
|
||||
# the string in doublequotes and precede quote (with a \)
|
||||
# special characters.
|
||||
#
|
||||
if "" == translate(str, idmap, LegalChars):
|
||||
return str
|
||||
else:
|
||||
return '"' + _nulljoin( map(_Translator.get, str, str) ) + '"'
|
||||
# end _quote
|
||||
|
||||
|
||||
_OctalPatt = re.compile(r"\\[0-3][0-7][0-7]")
|
||||
_QuotePatt = re.compile(r"[\\].")
|
||||
|
||||
def _unquote(str):
|
||||
# If there aren't any doublequotes,
|
||||
# then there can't be any special characters. See RFC 2109.
|
||||
if len(str) < 2:
|
||||
return str
|
||||
if str[0] != '"' or str[-1] != '"':
|
||||
return str
|
||||
|
||||
# We have to assume that we must decode this string.
|
||||
# Down to work.
|
||||
|
||||
# Remove the "s
|
||||
str = str[1:-1]
|
||||
|
||||
# Check for special sequences. Examples:
|
||||
# \012 --> \n
|
||||
# \" --> "
|
||||
#
|
||||
i = 0
|
||||
n = len(str)
|
||||
res = []
|
||||
while 0 <= i < n:
|
||||
Omatch = _OctalPatt.search(str, i)
|
||||
Qmatch = _QuotePatt.search(str, i)
|
||||
if not Omatch and not Qmatch: # Neither matched
|
||||
res.append(str[i:])
|
||||
break
|
||||
# else:
|
||||
j = k = -1
|
||||
if Omatch: j = Omatch.start(0)
|
||||
if Qmatch: k = Qmatch.start(0)
|
||||
if Qmatch and ( not Omatch or k < j ): # QuotePatt matched
|
||||
res.append(str[i:k])
|
||||
res.append(str[k+1])
|
||||
i = k+2
|
||||
else: # OctalPatt matched
|
||||
res.append(str[i:j])
|
||||
res.append( chr( int(str[j+1:j+4], 8) ) )
|
||||
i = j+4
|
||||
return _nulljoin(res)
|
||||
# end _unquote
|
||||
|
||||
# The _getdate() routine is used to set the expiration time in
|
||||
# the cookie's HTTP header. By default, _getdate() returns the
|
||||
# current time in the appropriate "expires" format for a
|
||||
# Set-Cookie header. The one optional argument is an offset from
|
||||
# now, in seconds. For example, an offset of -3600 means "one hour ago".
|
||||
# The offset may be a floating point number.
|
||||
#
|
||||
|
||||
_weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
||||
|
||||
_monthname = [None,
|
||||
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
||||
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
||||
|
||||
def _getdate(future=0, weekdayname=_weekdayname, monthname=_monthname):
|
||||
from time import gmtime, time
|
||||
now = time()
|
||||
year, month, day, hh, mm, ss, wd, y, z = gmtime(now + future)
|
||||
return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % \
|
||||
(weekdayname[wd], day, monthname[month], year, hh, mm, ss)
|
||||
|
||||
|
||||
#
|
||||
# A class to hold ONE key,value pair.
|
||||
# In a cookie, each such pair may have several attributes.
|
||||
# so this class is used to keep the attributes associated
|
||||
# with the appropriate key,value pair.
|
||||
# This class also includes a coded_value attribute, which
|
||||
# is used to hold the network representation of the
|
||||
# value. This is most useful when Python objects are
|
||||
# pickled for network transit.
|
||||
#
|
||||
|
||||
class Morsel(dict):
|
||||
# RFC 2109 lists these attributes as reserved:
|
||||
# path comment domain
|
||||
# max-age secure version
|
||||
#
|
||||
# For historical reasons, these attributes are also reserved:
|
||||
# expires
|
||||
#
|
||||
# This is an extension from Microsoft:
|
||||
# httponly
|
||||
#
|
||||
# This dictionary provides a mapping from the lowercase
|
||||
# variant on the left to the appropriate traditional
|
||||
# formatting on the right.
|
||||
_reserved = { "expires" : "expires",
|
||||
"path" : "Path",
|
||||
"comment" : "Comment",
|
||||
"domain" : "Domain",
|
||||
"max-age" : "Max-Age",
|
||||
"secure" : "secure",
|
||||
"httponly" : "httponly",
|
||||
"version" : "Version",
|
||||
}
|
||||
|
||||
_flags = {'secure', 'httponly'}
|
||||
|
||||
def __init__(self):
|
||||
# Set defaults
|
||||
self.key = self.value = self.coded_value = None
|
||||
|
||||
# Set default attributes
|
||||
for K in self._reserved:
|
||||
dict.__setitem__(self, K, "")
|
||||
# end __init__
|
||||
|
||||
def __setitem__(self, K, V):
|
||||
K = K.lower()
|
||||
if not K in self._reserved:
|
||||
raise CookieError("Invalid Attribute %s" % K)
|
||||
dict.__setitem__(self, K, V)
|
||||
# end __setitem__
|
||||
|
||||
def isReservedKey(self, K):
|
||||
return K.lower() in self._reserved
|
||||
# end isReservedKey
|
||||
|
||||
def set(self, key, val, coded_val,
|
||||
LegalChars=_LegalChars,
|
||||
idmap=_idmap, translate=string.translate):
|
||||
# First we verify that the key isn't a reserved word
|
||||
# Second we make sure it only contains legal characters
|
||||
if key.lower() in self._reserved:
|
||||
raise CookieError("Attempt to set a reserved key: %s" % key)
|
||||
if "" != translate(key, idmap, LegalChars):
|
||||
raise CookieError("Illegal key value: %s" % key)
|
||||
|
||||
# It's a good key, so save it.
|
||||
self.key = key
|
||||
self.value = val
|
||||
self.coded_value = coded_val
|
||||
# end set
|
||||
|
||||
def output(self, attrs=None, header = "Set-Cookie:"):
|
||||
return "%s %s" % ( header, self.OutputString(attrs) )
|
||||
|
||||
__str__ = output
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s: %s=%s>' % (self.__class__.__name__,
|
||||
self.key, repr(self.value) )
|
||||
|
||||
def js_output(self, attrs=None):
|
||||
# Print javascript
|
||||
return """
|
||||
<script type="text/javascript">
|
||||
<!-- begin hiding
|
||||
document.cookie = \"%s\";
|
||||
// end hiding -->
|
||||
</script>
|
||||
""" % ( self.OutputString(attrs).replace('"',r'\"'), )
|
||||
# end js_output()
|
||||
|
||||
def OutputString(self, attrs=None):
|
||||
# Build up our result
|
||||
#
|
||||
result = []
|
||||
RA = result.append
|
||||
|
||||
# First, the key=value pair
|
||||
RA("%s=%s" % (self.key, self.coded_value))
|
||||
|
||||
# Now add any defined attributes
|
||||
if attrs is None:
|
||||
attrs = self._reserved
|
||||
items = self.items()
|
||||
items.sort()
|
||||
for K,V in items:
|
||||
if V == "": continue
|
||||
if K not in attrs: continue
|
||||
if K == "expires" and type(V) == type(1):
|
||||
RA("%s=%s" % (self._reserved[K], _getdate(V)))
|
||||
elif K == "max-age" and type(V) == type(1):
|
||||
RA("%s=%d" % (self._reserved[K], V))
|
||||
elif K == "secure":
|
||||
RA(str(self._reserved[K]))
|
||||
elif K == "httponly":
|
||||
RA(str(self._reserved[K]))
|
||||
else:
|
||||
RA("%s=%s" % (self._reserved[K], V))
|
||||
|
||||
# Return the result
|
||||
return _semispacejoin(result)
|
||||
# end OutputString
|
||||
# end Morsel class
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Pattern for finding cookie
|
||||
#
|
||||
# This used to be strict parsing based on the RFC2109 and RFC2068
|
||||
# specifications. I have since discovered that MSIE 3.0x doesn't
|
||||
# follow the character rules outlined in those specs. As a
|
||||
# result, the parsing rules here are less strict.
|
||||
#
|
||||
|
||||
_LegalKeyChars = r"\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\="
|
||||
_LegalValueChars = _LegalKeyChars + r"\[\]"
|
||||
_CookiePattern = re.compile(
|
||||
r"(?x)" # This is a Verbose pattern
|
||||
r"\s*" # Optional whitespace at start of cookie
|
||||
r"(?P<key>" # Start of group 'key'
|
||||
"["+ _LegalKeyChars +"]+?" # Any word of at least one letter, nongreedy
|
||||
r")" # End of group 'key'
|
||||
r"(" # Optional group: there may not be a value.
|
||||
r"\s*=\s*" # Equal Sign
|
||||
r"(?P<val>" # Start of group 'val'
|
||||
r'"(?:[^\\"]|\\.)*"' # Any doublequoted string
|
||||
r"|" # or
|
||||
r"\w{3},\s[\s\w\d-]{9,11}\s[\d:]{8}\sGMT" # Special case for "expires" attr
|
||||
r"|" # or
|
||||
"["+ _LegalValueChars +"]*" # Any word or empty string
|
||||
r")" # End of group 'val'
|
||||
r")?" # End of optional value group
|
||||
r"\s*" # Any number of spaces.
|
||||
r"(\s+|;|$)" # Ending either at space, semicolon, or EOS.
|
||||
)
|
||||
|
||||
|
||||
# At long last, here is the cookie class.
|
||||
# Using this class is almost just like using a dictionary.
|
||||
# See this module's docstring for example usage.
|
||||
#
|
||||
class BaseCookie(dict):
|
||||
# A container class for a set of Morsels
|
||||
#
|
||||
|
||||
def value_decode(self, val):
|
||||
"""real_value, coded_value = value_decode(STRING)
|
||||
Called prior to setting a cookie's value from the network
|
||||
representation. The VALUE is the value read from HTTP
|
||||
header.
|
||||
Override this function to modify the behavior of cookies.
|
||||
"""
|
||||
return val, val
|
||||
# end value_encode
|
||||
|
||||
def value_encode(self, val):
|
||||
"""real_value, coded_value = value_encode(VALUE)
|
||||
Called prior to setting a cookie's value from the dictionary
|
||||
representation. The VALUE is the value being assigned.
|
||||
Override this function to modify the behavior of cookies.
|
||||
"""
|
||||
strval = str(val)
|
||||
return strval, strval
|
||||
# end value_encode
|
||||
|
||||
def __init__(self, input=None):
|
||||
if input: self.load(input)
|
||||
# end __init__
|
||||
|
||||
def __set(self, key, real_value, coded_value):
|
||||
"""Private method for setting a cookie's value"""
|
||||
M = self.get(key, Morsel())
|
||||
M.set(key, real_value, coded_value)
|
||||
dict.__setitem__(self, key, M)
|
||||
# end __set
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
"""Dictionary style assignment."""
|
||||
if isinstance(value, Morsel):
|
||||
# allow assignment of constructed Morsels (e.g. for pickling)
|
||||
dict.__setitem__(self, key, value)
|
||||
else:
|
||||
rval, cval = self.value_encode(value)
|
||||
self.__set(key, rval, cval)
|
||||
# end __setitem__
|
||||
|
||||
def output(self, attrs=None, header="Set-Cookie:", sep="\015\012"):
|
||||
"""Return a string suitable for HTTP."""
|
||||
result = []
|
||||
items = self.items()
|
||||
items.sort()
|
||||
for K,V in items:
|
||||
result.append( V.output(attrs, header) )
|
||||
return sep.join(result)
|
||||
# end output
|
||||
|
||||
__str__ = output
|
||||
|
||||
def __repr__(self):
|
||||
L = []
|
||||
items = self.items()
|
||||
items.sort()
|
||||
for K,V in items:
|
||||
L.append( '%s=%s' % (K,repr(V.value) ) )
|
||||
return '<%s: %s>' % (self.__class__.__name__, _spacejoin(L))
|
||||
|
||||
def js_output(self, attrs=None):
|
||||
"""Return a string suitable for JavaScript."""
|
||||
result = []
|
||||
items = self.items()
|
||||
items.sort()
|
||||
for K,V in items:
|
||||
result.append( V.js_output(attrs) )
|
||||
return _nulljoin(result)
|
||||
# end js_output
|
||||
|
||||
def load(self, rawdata):
|
||||
"""Load cookies from a string (presumably HTTP_COOKIE) or
|
||||
from a dictionary. Loading cookies from a dictionary 'd'
|
||||
is equivalent to calling:
|
||||
map(Cookie.__setitem__, d.keys(), d.values())
|
||||
"""
|
||||
if type(rawdata) == type(""):
|
||||
self.__ParseString(rawdata)
|
||||
else:
|
||||
# self.update() wouldn't call our custom __setitem__
|
||||
for k, v in rawdata.items():
|
||||
self[k] = v
|
||||
return
|
||||
# end load()
|
||||
|
||||
def __ParseString(self, str, patt=_CookiePattern):
|
||||
i = 0 # Our starting point
|
||||
n = len(str) # Length of string
|
||||
M = None # current morsel
|
||||
|
||||
while 0 <= i < n:
|
||||
# Start looking for a cookie
|
||||
match = patt.match(str, i)
|
||||
if not match: break # No more cookies
|
||||
|
||||
K,V = match.group("key"), match.group("val")
|
||||
i = match.end(0)
|
||||
|
||||
# Parse the key, value in case it's metainfo
|
||||
if K[0] == "$":
|
||||
# We ignore attributes which pertain to the cookie
|
||||
# mechanism as a whole. See RFC 2109.
|
||||
# (Does anyone care?)
|
||||
if M:
|
||||
M[ K[1:] ] = V
|
||||
elif K.lower() in Morsel._reserved:
|
||||
if M:
|
||||
if V is None:
|
||||
if K.lower() in Morsel._flags:
|
||||
M[K] = True
|
||||
else:
|
||||
M[K] = _unquote(V)
|
||||
elif V is not None:
|
||||
rval, cval = self.value_decode(V)
|
||||
self.__set(K, rval, cval)
|
||||
M = self[K]
|
||||
# end __ParseString
|
||||
# end BaseCookie class
|
||||
|
||||
class SimpleCookie(BaseCookie):
|
||||
"""SimpleCookie
|
||||
SimpleCookie supports strings as cookie values. When setting
|
||||
the value using the dictionary assignment notation, SimpleCookie
|
||||
calls the builtin str() to convert the value to a string. Values
|
||||
received from HTTP are kept as strings.
|
||||
"""
|
||||
def value_decode(self, val):
|
||||
return _unquote( val ), val
|
||||
def value_encode(self, val):
|
||||
strval = str(val)
|
||||
return strval, _quote( strval )
|
||||
# end SimpleCookie
|
||||
|
||||
class SerialCookie(BaseCookie):
|
||||
"""SerialCookie
|
||||
SerialCookie supports arbitrary objects as cookie values. All
|
||||
values are serialized (using cPickle) before being sent to the
|
||||
client. All incoming values are assumed to be valid Pickle
|
||||
representations. IF AN INCOMING VALUE IS NOT IN A VALID PICKLE
|
||||
FORMAT, THEN AN EXCEPTION WILL BE RAISED.
|
||||
|
||||
Note: Large cookie values add overhead because they must be
|
||||
retransmitted on every HTTP transaction.
|
||||
|
||||
Note: HTTP has a 2k limit on the size of a cookie. This class
|
||||
does not check for this limit, so be careful!!!
|
||||
"""
|
||||
def __init__(self, input=None):
|
||||
warnings.warn("SerialCookie class is insecure; do not use it",
|
||||
DeprecationWarning)
|
||||
BaseCookie.__init__(self, input)
|
||||
# end __init__
|
||||
def value_decode(self, val):
|
||||
# This could raise an exception!
|
||||
return loads( _unquote(val) ), val
|
||||
def value_encode(self, val):
|
||||
return val, _quote( dumps(val) )
|
||||
# end SerialCookie
|
||||
|
||||
class SmartCookie(BaseCookie):
|
||||
"""SmartCookie
|
||||
SmartCookie supports arbitrary objects as cookie values. If the
|
||||
object is a string, then it is quoted. If the object is not a
|
||||
string, however, then SmartCookie will use cPickle to serialize
|
||||
the object into a string representation.
|
||||
|
||||
Note: Large cookie values add overhead because they must be
|
||||
retransmitted on every HTTP transaction.
|
||||
|
||||
Note: HTTP has a 2k limit on the size of a cookie. This class
|
||||
does not check for this limit, so be careful!!!
|
||||
"""
|
||||
def __init__(self, input=None):
|
||||
warnings.warn("Cookie/SmartCookie class is insecure; do not use it",
|
||||
DeprecationWarning)
|
||||
BaseCookie.__init__(self, input)
|
||||
# end __init__
|
||||
def value_decode(self, val):
|
||||
strval = _unquote(val)
|
||||
try:
|
||||
return loads(strval), val
|
||||
except:
|
||||
return strval, val
|
||||
def value_encode(self, val):
|
||||
if type(val) == type(""):
|
||||
return val, _quote(val)
|
||||
else:
|
||||
return val, _quote( dumps(val) )
|
||||
# end SmartCookie
|
||||
|
||||
|
||||
###########################################################
|
||||
# Backwards Compatibility: Don't break any existing code!
|
||||
|
||||
# We provide Cookie() as an alias for SmartCookie()
|
||||
Cookie = SmartCookie
|
||||
|
||||
#
|
||||
###########################################################
|
||||
|
||||
def _test():
|
||||
import doctest, Cookie
|
||||
return doctest.testmod(Cookie)
|
||||
|
||||
if __name__ == "__main__":
|
||||
_test()
|
||||
|
||||
|
||||
#Local Variables:
|
||||
#tab-width: 4
|
||||
#end:
|
279
c/meterpreter/source/extensions/python/Lib/DocXMLRPCServer.py
Normal file
279
c/meterpreter/source/extensions/python/Lib/DocXMLRPCServer.py
Normal file
@ -0,0 +1,279 @@
|
||||
"""Self documenting XML-RPC Server.
|
||||
|
||||
This module can be used to create XML-RPC servers that
|
||||
serve pydoc-style documentation in response to HTTP
|
||||
GET requests. This documentation is dynamically generated
|
||||
based on the functions and methods registered with the
|
||||
server.
|
||||
|
||||
This module is built upon the pydoc and SimpleXMLRPCServer
|
||||
modules.
|
||||
"""
|
||||
|
||||
import pydoc
|
||||
import inspect
|
||||
import re
|
||||
import sys
|
||||
|
||||
from SimpleXMLRPCServer import (SimpleXMLRPCServer,
|
||||
SimpleXMLRPCRequestHandler,
|
||||
CGIXMLRPCRequestHandler,
|
||||
resolve_dotted_attribute)
|
||||
|
||||
class ServerHTMLDoc(pydoc.HTMLDoc):
|
||||
"""Class used to generate pydoc HTML document for a server"""
|
||||
|
||||
def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
|
||||
"""Mark up some plain text, given a context of symbols to look for.
|
||||
Each context dictionary maps object names to anchor names."""
|
||||
escape = escape or self.escape
|
||||
results = []
|
||||
here = 0
|
||||
|
||||
# XXX Note that this regular expression does not allow for the
|
||||
# hyperlinking of arbitrary strings being used as method
|
||||
# names. Only methods with names consisting of word characters
|
||||
# and '.'s are hyperlinked.
|
||||
pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|'
|
||||
r'RFC[- ]?(\d+)|'
|
||||
r'PEP[- ]?(\d+)|'
|
||||
r'(self\.)?((?:\w|\.)+))\b')
|
||||
while 1:
|
||||
match = pattern.search(text, here)
|
||||
if not match: break
|
||||
start, end = match.span()
|
||||
results.append(escape(text[here:start]))
|
||||
|
||||
all, scheme, rfc, pep, selfdot, name = match.groups()
|
||||
if scheme:
|
||||
url = escape(all).replace('"', '"')
|
||||
results.append('<a href="%s">%s</a>' % (url, url))
|
||||
elif rfc:
|
||||
url = 'http://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc)
|
||||
results.append('<a href="%s">%s</a>' % (url, escape(all)))
|
||||
elif pep:
|
||||
url = 'http://www.python.org/dev/peps/pep-%04d/' % int(pep)
|
||||
results.append('<a href="%s">%s</a>' % (url, escape(all)))
|
||||
elif text[end:end+1] == '(':
|
||||
results.append(self.namelink(name, methods, funcs, classes))
|
||||
elif selfdot:
|
||||
results.append('self.<strong>%s</strong>' % name)
|
||||
else:
|
||||
results.append(self.namelink(name, classes))
|
||||
here = end
|
||||
results.append(escape(text[here:]))
|
||||
return ''.join(results)
|
||||
|
||||
def docroutine(self, object, name, mod=None,
|
||||
funcs={}, classes={}, methods={}, cl=None):
|
||||
"""Produce HTML documentation for a function or method object."""
|
||||
|
||||
anchor = (cl and cl.__name__ or '') + '-' + name
|
||||
note = ''
|
||||
|
||||
title = '<a name="%s"><strong>%s</strong></a>' % (
|
||||
self.escape(anchor), self.escape(name))
|
||||
|
||||
if inspect.ismethod(object):
|
||||
args, varargs, varkw, defaults = inspect.getargspec(object.im_func)
|
||||
# exclude the argument bound to the instance, it will be
|
||||
# confusing to the non-Python user
|
||||
argspec = inspect.formatargspec (
|
||||
args[1:],
|
||||
varargs,
|
||||
varkw,
|
||||
defaults,
|
||||
formatvalue=self.formatvalue
|
||||
)
|
||||
elif inspect.isfunction(object):
|
||||
args, varargs, varkw, defaults = inspect.getargspec(object)
|
||||
argspec = inspect.formatargspec(
|
||||
args, varargs, varkw, defaults, formatvalue=self.formatvalue)
|
||||
else:
|
||||
argspec = '(...)'
|
||||
|
||||
if isinstance(object, tuple):
|
||||
argspec = object[0] or argspec
|
||||
docstring = object[1] or ""
|
||||
else:
|
||||
docstring = pydoc.getdoc(object)
|
||||
|
||||
decl = title + argspec + (note and self.grey(
|
||||
'<font face="helvetica, arial">%s</font>' % note))
|
||||
|
||||
doc = self.markup(
|
||||
docstring, self.preformat, funcs, classes, methods)
|
||||
doc = doc and '<dd><tt>%s</tt></dd>' % doc
|
||||
return '<dl><dt>%s</dt>%s</dl>\n' % (decl, doc)
|
||||
|
||||
def docserver(self, server_name, package_documentation, methods):
|
||||
"""Produce HTML documentation for an XML-RPC server."""
|
||||
|
||||
fdict = {}
|
||||
for key, value in methods.items():
|
||||
fdict[key] = '#-' + key
|
||||
fdict[value] = fdict[key]
|
||||
|
||||
server_name = self.escape(server_name)
|
||||
head = '<big><big><strong>%s</strong></big></big>' % server_name
|
||||
result = self.heading(head, '#ffffff', '#7799ee')
|
||||
|
||||
doc = self.markup(package_documentation, self.preformat, fdict)
|
||||
doc = doc and '<tt>%s</tt>' % doc
|
||||
result = result + '<p>%s</p>\n' % doc
|
||||
|
||||
contents = []
|
||||
method_items = sorted(methods.items())
|
||||
for key, value in method_items:
|
||||
contents.append(self.docroutine(value, key, funcs=fdict))
|
||||
result = result + self.bigsection(
|
||||
'Methods', '#ffffff', '#eeaa77', pydoc.join(contents))
|
||||
|
||||
return result
|
||||
|
||||
class XMLRPCDocGenerator:
|
||||
"""Generates documentation for an XML-RPC server.
|
||||
|
||||
This class is designed as mix-in and should not
|
||||
be constructed directly.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
# setup variables used for HTML documentation
|
||||
self.server_name = 'XML-RPC Server Documentation'
|
||||
self.server_documentation = \
|
||||
"This server exports the following methods through the XML-RPC "\
|
||||
"protocol."
|
||||
self.server_title = 'XML-RPC Server Documentation'
|
||||
|
||||
def set_server_title(self, server_title):
|
||||
"""Set the HTML title of the generated server documentation"""
|
||||
|
||||
self.server_title = server_title
|
||||
|
||||
def set_server_name(self, server_name):
|
||||
"""Set the name of the generated HTML server documentation"""
|
||||
|
||||
self.server_name = server_name
|
||||
|
||||
def set_server_documentation(self, server_documentation):
|
||||
"""Set the documentation string for the entire server."""
|
||||
|
||||
self.server_documentation = server_documentation
|
||||
|
||||
def generate_html_documentation(self):
|
||||
"""generate_html_documentation() => html documentation for the server
|
||||
|
||||
Generates HTML documentation for the server using introspection for
|
||||
installed functions and instances that do not implement the
|
||||
_dispatch method. Alternatively, instances can choose to implement
|
||||
the _get_method_argstring(method_name) method to provide the
|
||||
argument string used in the documentation and the
|
||||
_methodHelp(method_name) method to provide the help text used
|
||||
in the documentation."""
|
||||
|
||||
methods = {}
|
||||
|
||||
for method_name in self.system_listMethods():
|
||||
if method_name in self.funcs:
|
||||
method = self.funcs[method_name]
|
||||
elif self.instance is not None:
|
||||
method_info = [None, None] # argspec, documentation
|
||||
if hasattr(self.instance, '_get_method_argstring'):
|
||||
method_info[0] = self.instance._get_method_argstring(method_name)
|
||||
if hasattr(self.instance, '_methodHelp'):
|
||||
method_info[1] = self.instance._methodHelp(method_name)
|
||||
|
||||
method_info = tuple(method_info)
|
||||
if method_info != (None, None):
|
||||
method = method_info
|
||||
elif not hasattr(self.instance, '_dispatch'):
|
||||
try:
|
||||
method = resolve_dotted_attribute(
|
||||
self.instance,
|
||||
method_name
|
||||
)
|
||||
except AttributeError:
|
||||
method = method_info
|
||||
else:
|
||||
method = method_info
|
||||
else:
|
||||
assert 0, "Could not find method in self.functions and no "\
|
||||
"instance installed"
|
||||
|
||||
methods[method_name] = method
|
||||
|
||||
documenter = ServerHTMLDoc()
|
||||
documentation = documenter.docserver(
|
||||
self.server_name,
|
||||
self.server_documentation,
|
||||
methods
|
||||
)
|
||||
|
||||
return documenter.page(self.server_title, documentation)
|
||||
|
||||
class DocXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||
"""XML-RPC and documentation request handler class.
|
||||
|
||||
Handles all HTTP POST requests and attempts to decode them as
|
||||
XML-RPC requests.
|
||||
|
||||
Handles all HTTP GET requests and interprets them as requests
|
||||
for documentation.
|
||||
"""
|
||||
|
||||
def do_GET(self):
|
||||
"""Handles the HTTP GET request.
|
||||
|
||||
Interpret all HTTP GET requests as requests for server
|
||||
documentation.
|
||||
"""
|
||||
# Check that the path is legal
|
||||
if not self.is_rpc_path_valid():
|
||||
self.report_404()
|
||||
return
|
||||
|
||||
response = self.server.generate_html_documentation()
|
||||
self.send_response(200)
|
||||
self.send_header("Content-type", "text/html")
|
||||
self.send_header("Content-length", str(len(response)))
|
||||
self.end_headers()
|
||||
self.wfile.write(response)
|
||||
|
||||
class DocXMLRPCServer( SimpleXMLRPCServer,
|
||||
XMLRPCDocGenerator):
|
||||
"""XML-RPC and HTML documentation server.
|
||||
|
||||
Adds the ability to serve server documentation to the capabilities
|
||||
of SimpleXMLRPCServer.
|
||||
"""
|
||||
|
||||
def __init__(self, addr, requestHandler=DocXMLRPCRequestHandler,
|
||||
logRequests=1, allow_none=False, encoding=None,
|
||||
bind_and_activate=True):
|
||||
SimpleXMLRPCServer.__init__(self, addr, requestHandler, logRequests,
|
||||
allow_none, encoding, bind_and_activate)
|
||||
XMLRPCDocGenerator.__init__(self)
|
||||
|
||||
class DocCGIXMLRPCRequestHandler( CGIXMLRPCRequestHandler,
|
||||
XMLRPCDocGenerator):
|
||||
"""Handler for XML-RPC data and documentation requests passed through
|
||||
CGI"""
|
||||
|
||||
def handle_get(self):
|
||||
"""Handles the HTTP GET request.
|
||||
|
||||
Interpret all HTTP GET requests as requests for server
|
||||
documentation.
|
||||
"""
|
||||
|
||||
response = self.generate_html_documentation()
|
||||
|
||||
print 'Content-Type: text/html'
|
||||
print 'Content-Length: %d' % len(response)
|
||||
print
|
||||
sys.stdout.write(response)
|
||||
|
||||
def __init__(self):
|
||||
CGIXMLRPCRequestHandler.__init__(self)
|
||||
XMLRPCDocGenerator.__init__(self)
|
475
c/meterpreter/source/extensions/python/Lib/HTMLParser.py
Normal file
475
c/meterpreter/source/extensions/python/Lib/HTMLParser.py
Normal file
@ -0,0 +1,475 @@
|
||||
"""A parser for HTML and XHTML."""
|
||||
|
||||
# This file is based on sgmllib.py, but the API is slightly different.
|
||||
|
||||
# XXX There should be a way to distinguish between PCDATA (parsed
|
||||
# character data -- the normal case), RCDATA (replaceable character
|
||||
# data -- only char and entity references and end tags are special)
|
||||
# and CDATA (character data -- only end tags are special).
|
||||
|
||||
|
||||
import markupbase
|
||||
import re
|
||||
|
||||
# Regular expressions used for parsing
|
||||
|
||||
interesting_normal = re.compile('[&<]')
|
||||
incomplete = re.compile('&[a-zA-Z#]')
|
||||
|
||||
entityref = re.compile('&([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]')
|
||||
charref = re.compile('&#(?:[0-9]+|[xX][0-9a-fA-F]+)[^0-9a-fA-F]')
|
||||
|
||||
starttagopen = re.compile('<[a-zA-Z]')
|
||||
piclose = re.compile('>')
|
||||
commentclose = re.compile(r'--\s*>')
|
||||
|
||||
# see http://www.w3.org/TR/html5/tokenization.html#tag-open-state
|
||||
# and http://www.w3.org/TR/html5/tokenization.html#tag-name-state
|
||||
# note: if you change tagfind/attrfind remember to update locatestarttagend too
|
||||
tagfind = re.compile('([a-zA-Z][^\t\n\r\f />\x00]*)(?:\s|/(?!>))*')
|
||||
# this regex is currently unused, but left for backward compatibility
|
||||
tagfind_tolerant = re.compile('[a-zA-Z][^\t\n\r\f />\x00]*')
|
||||
|
||||
attrfind = re.compile(
|
||||
r'((?<=[\'"\s/])[^\s/>][^\s/=>]*)(\s*=+\s*'
|
||||
r'(\'[^\']*\'|"[^"]*"|(?![\'"])[^>\s]*))?(?:\s|/(?!>))*')
|
||||
|
||||
locatestarttagend = re.compile(r"""
|
||||
<[a-zA-Z][^\t\n\r\f />\x00]* # tag name
|
||||
(?:[\s/]* # optional whitespace before attribute name
|
||||
(?:(?<=['"\s/])[^\s/>][^\s/=>]* # attribute name
|
||||
(?:\s*=+\s* # value indicator
|
||||
(?:'[^']*' # LITA-enclosed value
|
||||
|"[^"]*" # LIT-enclosed value
|
||||
|(?!['"])[^>\s]* # bare value
|
||||
)
|
||||
)?(?:\s|/(?!>))*
|
||||
)*
|
||||
)?
|
||||
\s* # trailing whitespace
|
||||
""", re.VERBOSE)
|
||||
endendtag = re.compile('>')
|
||||
# the HTML 5 spec, section 8.1.2.2, doesn't allow spaces between
|
||||
# </ and the tag name, so maybe this should be fixed
|
||||
endtagfind = re.compile('</\s*([a-zA-Z][-.a-zA-Z0-9:_]*)\s*>')
|
||||
|
||||
|
||||
class HTMLParseError(Exception):
|
||||
"""Exception raised for all parse errors."""
|
||||
|
||||
def __init__(self, msg, position=(None, None)):
|
||||
assert msg
|
||||
self.msg = msg
|
||||
self.lineno = position[0]
|
||||
self.offset = position[1]
|
||||
|
||||
def __str__(self):
|
||||
result = self.msg
|
||||
if self.lineno is not None:
|
||||
result = result + ", at line %d" % self.lineno
|
||||
if self.offset is not None:
|
||||
result = result + ", column %d" % (self.offset + 1)
|
||||
return result
|
||||
|
||||
|
||||
class HTMLParser(markupbase.ParserBase):
|
||||
"""Find tags and other markup and call handler functions.
|
||||
|
||||
Usage:
|
||||
p = HTMLParser()
|
||||
p.feed(data)
|
||||
...
|
||||
p.close()
|
||||
|
||||
Start tags are handled by calling self.handle_starttag() or
|
||||
self.handle_startendtag(); end tags by self.handle_endtag(). The
|
||||
data between tags is passed from the parser to the derived class
|
||||
by calling self.handle_data() with the data as argument (the data
|
||||
may be split up in arbitrary chunks). Entity references are
|
||||
passed by calling self.handle_entityref() with the entity
|
||||
reference as the argument. Numeric character references are
|
||||
passed to self.handle_charref() with the string containing the
|
||||
reference as the argument.
|
||||
"""
|
||||
|
||||
CDATA_CONTENT_ELEMENTS = ("script", "style")
|
||||
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize and reset this instance."""
|
||||
self.reset()
|
||||
|
||||
def reset(self):
|
||||
"""Reset this instance. Loses all unprocessed data."""
|
||||
self.rawdata = ''
|
||||
self.lasttag = '???'
|
||||
self.interesting = interesting_normal
|
||||
self.cdata_elem = None
|
||||
markupbase.ParserBase.reset(self)
|
||||
|
||||
def feed(self, data):
|
||||
r"""Feed data to the parser.
|
||||
|
||||
Call this as often as you want, with as little or as much text
|
||||
as you want (may include '\n').
|
||||
"""
|
||||
self.rawdata = self.rawdata + data
|
||||
self.goahead(0)
|
||||
|
||||
def close(self):
|
||||
"""Handle any buffered data."""
|
||||
self.goahead(1)
|
||||
|
||||
def error(self, message):
|
||||
raise HTMLParseError(message, self.getpos())
|
||||
|
||||
__starttag_text = None
|
||||
|
||||
def get_starttag_text(self):
|
||||
"""Return full source of start tag: '<...>'."""
|
||||
return self.__starttag_text
|
||||
|
||||
def set_cdata_mode(self, elem):
|
||||
self.cdata_elem = elem.lower()
|
||||
self.interesting = re.compile(r'</\s*%s\s*>' % self.cdata_elem, re.I)
|
||||
|
||||
def clear_cdata_mode(self):
|
||||
self.interesting = interesting_normal
|
||||
self.cdata_elem = None
|
||||
|
||||
# Internal -- handle data as far as reasonable. May leave state
|
||||
# and data to be processed by a subsequent call. If 'end' is
|
||||
# true, force handling all data as if followed by EOF marker.
|
||||
def goahead(self, end):
|
||||
rawdata = self.rawdata
|
||||
i = 0
|
||||
n = len(rawdata)
|
||||
while i < n:
|
||||
match = self.interesting.search(rawdata, i) # < or &
|
||||
if match:
|
||||
j = match.start()
|
||||
else:
|
||||
if self.cdata_elem:
|
||||
break
|
||||
j = n
|
||||
if i < j: self.handle_data(rawdata[i:j])
|
||||
i = self.updatepos(i, j)
|
||||
if i == n: break
|
||||
startswith = rawdata.startswith
|
||||
if startswith('<', i):
|
||||
if starttagopen.match(rawdata, i): # < + letter
|
||||
k = self.parse_starttag(i)
|
||||
elif startswith("</", i):
|
||||
k = self.parse_endtag(i)
|
||||
elif startswith("<!--", i):
|
||||
k = self.parse_comment(i)
|
||||
elif startswith("<?", i):
|
||||
k = self.parse_pi(i)
|
||||
elif startswith("<!", i):
|
||||
k = self.parse_html_declaration(i)
|
||||
elif (i + 1) < n:
|
||||
self.handle_data("<")
|
||||
k = i + 1
|
||||
else:
|
||||
break
|
||||
if k < 0:
|
||||
if not end:
|
||||
break
|
||||
k = rawdata.find('>', i + 1)
|
||||
if k < 0:
|
||||
k = rawdata.find('<', i + 1)
|
||||
if k < 0:
|
||||
k = i + 1
|
||||
else:
|
||||
k += 1
|
||||
self.handle_data(rawdata[i:k])
|
||||
i = self.updatepos(i, k)
|
||||
elif startswith("&#", i):
|
||||
match = charref.match(rawdata, i)
|
||||
if match:
|
||||
name = match.group()[2:-1]
|
||||
self.handle_charref(name)
|
||||
k = match.end()
|
||||
if not startswith(';', k-1):
|
||||
k = k - 1
|
||||
i = self.updatepos(i, k)
|
||||
continue
|
||||
else:
|
||||
if ";" in rawdata[i:]: # bail by consuming '&#'
|
||||
self.handle_data(rawdata[i:i+2])
|
||||
i = self.updatepos(i, i+2)
|
||||
break
|
||||
elif startswith('&', i):
|
||||
match = entityref.match(rawdata, i)
|
||||
if match:
|
||||
name = match.group(1)
|
||||
self.handle_entityref(name)
|
||||
k = match.end()
|
||||
if not startswith(';', k-1):
|
||||
k = k - 1
|
||||
i = self.updatepos(i, k)
|
||||
continue
|
||||
match = incomplete.match(rawdata, i)
|
||||
if match:
|
||||
# match.group() will contain at least 2 chars
|
||||
if end and match.group() == rawdata[i:]:
|
||||
self.error("EOF in middle of entity or char ref")
|
||||
# incomplete
|
||||
break
|
||||
elif (i + 1) < n:
|
||||
# not the end of the buffer, and can't be confused
|
||||
# with some other construct
|
||||
self.handle_data("&")
|
||||
i = self.updatepos(i, i + 1)
|
||||
else:
|
||||
break
|
||||
else:
|
||||
assert 0, "interesting.search() lied"
|
||||
# end while
|
||||
if end and i < n and not self.cdata_elem:
|
||||
self.handle_data(rawdata[i:n])
|
||||
i = self.updatepos(i, n)
|
||||
self.rawdata = rawdata[i:]
|
||||
|
||||
# Internal -- parse html declarations, return length or -1 if not terminated
|
||||
# See w3.org/TR/html5/tokenization.html#markup-declaration-open-state
|
||||
# See also parse_declaration in _markupbase
|
||||
def parse_html_declaration(self, i):
|
||||
rawdata = self.rawdata
|
||||
if rawdata[i:i+2] != '<!':
|
||||
self.error('unexpected call to parse_html_declaration()')
|
||||
if rawdata[i:i+4] == '<!--':
|
||||
# this case is actually already handled in goahead()
|
||||
return self.parse_comment(i)
|
||||
elif rawdata[i:i+3] == '<![':
|
||||
return self.parse_marked_section(i)
|
||||
elif rawdata[i:i+9].lower() == '<!doctype':
|
||||
# find the closing >
|
||||
gtpos = rawdata.find('>', i+9)
|
||||
if gtpos == -1:
|
||||
return -1
|
||||
self.handle_decl(rawdata[i+2:gtpos])
|
||||
return gtpos+1
|
||||
else:
|
||||
return self.parse_bogus_comment(i)
|
||||
|
||||
# Internal -- parse bogus comment, return length or -1 if not terminated
|
||||
# see http://www.w3.org/TR/html5/tokenization.html#bogus-comment-state
|
||||
def parse_bogus_comment(self, i, report=1):
|
||||
rawdata = self.rawdata
|
||||
if rawdata[i:i+2] not in ('<!', '</'):
|
||||
self.error('unexpected call to parse_comment()')
|
||||
pos = rawdata.find('>', i+2)
|
||||
if pos == -1:
|
||||
return -1
|
||||
if report:
|
||||
self.handle_comment(rawdata[i+2:pos])
|
||||
return pos + 1
|
||||
|
||||
# Internal -- parse processing instr, return end or -1 if not terminated
|
||||
def parse_pi(self, i):
|
||||
rawdata = self.rawdata
|
||||
assert rawdata[i:i+2] == '<?', 'unexpected call to parse_pi()'
|
||||
match = piclose.search(rawdata, i+2) # >
|
||||
if not match:
|
||||
return -1
|
||||
j = match.start()
|
||||
self.handle_pi(rawdata[i+2: j])
|
||||
j = match.end()
|
||||
return j
|
||||
|
||||
# Internal -- handle starttag, return end or -1 if not terminated
|
||||
def parse_starttag(self, i):
|
||||
self.__starttag_text = None
|
||||
endpos = self.check_for_whole_start_tag(i)
|
||||
if endpos < 0:
|
||||
return endpos
|
||||
rawdata = self.rawdata
|
||||
self.__starttag_text = rawdata[i:endpos]
|
||||
|
||||
# Now parse the data between i+1 and j into a tag and attrs
|
||||
attrs = []
|
||||
match = tagfind.match(rawdata, i+1)
|
||||
assert match, 'unexpected call to parse_starttag()'
|
||||
k = match.end()
|
||||
self.lasttag = tag = match.group(1).lower()
|
||||
|
||||
while k < endpos:
|
||||
m = attrfind.match(rawdata, k)
|
||||
if not m:
|
||||
break
|
||||
attrname, rest, attrvalue = m.group(1, 2, 3)
|
||||
if not rest:
|
||||
attrvalue = None
|
||||
elif attrvalue[:1] == '\'' == attrvalue[-1:] or \
|
||||
attrvalue[:1] == '"' == attrvalue[-1:]:
|
||||
attrvalue = attrvalue[1:-1]
|
||||
if attrvalue:
|
||||
attrvalue = self.unescape(attrvalue)
|
||||
attrs.append((attrname.lower(), attrvalue))
|
||||
k = m.end()
|
||||
|
||||
end = rawdata[k:endpos].strip()
|
||||
if end not in (">", "/>"):
|
||||
lineno, offset = self.getpos()
|
||||
if "\n" in self.__starttag_text:
|
||||
lineno = lineno + self.__starttag_text.count("\n")
|
||||
offset = len(self.__starttag_text) \
|
||||
- self.__starttag_text.rfind("\n")
|
||||
else:
|
||||
offset = offset + len(self.__starttag_text)
|
||||
self.handle_data(rawdata[i:endpos])
|
||||
return endpos
|
||||
if end.endswith('/>'):
|
||||
# XHTML-style empty tag: <span attr="value" />
|
||||
self.handle_startendtag(tag, attrs)
|
||||
else:
|
||||
self.handle_starttag(tag, attrs)
|
||||
if tag in self.CDATA_CONTENT_ELEMENTS:
|
||||
self.set_cdata_mode(tag)
|
||||
return endpos
|
||||
|
||||
# Internal -- check to see if we have a complete starttag; return end
|
||||
# or -1 if incomplete.
|
||||
def check_for_whole_start_tag(self, i):
|
||||
rawdata = self.rawdata
|
||||
m = locatestarttagend.match(rawdata, i)
|
||||
if m:
|
||||
j = m.end()
|
||||
next = rawdata[j:j+1]
|
||||
if next == ">":
|
||||
return j + 1
|
||||
if next == "/":
|
||||
if rawdata.startswith("/>", j):
|
||||
return j + 2
|
||||
if rawdata.startswith("/", j):
|
||||
# buffer boundary
|
||||
return -1
|
||||
# else bogus input
|
||||
self.updatepos(i, j + 1)
|
||||
self.error("malformed empty start tag")
|
||||
if next == "":
|
||||
# end of input
|
||||
return -1
|
||||
if next in ("abcdefghijklmnopqrstuvwxyz=/"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
|
||||
# end of input in or before attribute value, or we have the
|
||||
# '/' from a '/>' ending
|
||||
return -1
|
||||
if j > i:
|
||||
return j
|
||||
else:
|
||||
return i + 1
|
||||
raise AssertionError("we should not get here!")
|
||||
|
||||
# Internal -- parse endtag, return end or -1 if incomplete
|
||||
def parse_endtag(self, i):
|
||||
rawdata = self.rawdata
|
||||
assert rawdata[i:i+2] == "</", "unexpected call to parse_endtag"
|
||||
match = endendtag.search(rawdata, i+1) # >
|
||||
if not match:
|
||||
return -1
|
||||
gtpos = match.end()
|
||||
match = endtagfind.match(rawdata, i) # </ + tag + >
|
||||
if not match:
|
||||
if self.cdata_elem is not None:
|
||||
self.handle_data(rawdata[i:gtpos])
|
||||
return gtpos
|
||||
# find the name: w3.org/TR/html5/tokenization.html#tag-name-state
|
||||
namematch = tagfind.match(rawdata, i+2)
|
||||
if not namematch:
|
||||
# w3.org/TR/html5/tokenization.html#end-tag-open-state
|
||||
if rawdata[i:i+3] == '</>':
|
||||
return i+3
|
||||
else:
|
||||
return self.parse_bogus_comment(i)
|
||||
tagname = namematch.group(1).lower()
|
||||
# consume and ignore other stuff between the name and the >
|
||||
# Note: this is not 100% correct, since we might have things like
|
||||
# </tag attr=">">, but looking for > after tha name should cover
|
||||
# most of the cases and is much simpler
|
||||
gtpos = rawdata.find('>', namematch.end())
|
||||
self.handle_endtag(tagname)
|
||||
return gtpos+1
|
||||
|
||||
elem = match.group(1).lower() # script or style
|
||||
if self.cdata_elem is not None:
|
||||
if elem != self.cdata_elem:
|
||||
self.handle_data(rawdata[i:gtpos])
|
||||
return gtpos
|
||||
|
||||
self.handle_endtag(elem)
|
||||
self.clear_cdata_mode()
|
||||
return gtpos
|
||||
|
||||
# Overridable -- finish processing of start+end tag: <tag.../>
|
||||
def handle_startendtag(self, tag, attrs):
|
||||
self.handle_starttag(tag, attrs)
|
||||
self.handle_endtag(tag)
|
||||
|
||||
# Overridable -- handle start tag
|
||||
def handle_starttag(self, tag, attrs):
|
||||
pass
|
||||
|
||||
# Overridable -- handle end tag
|
||||
def handle_endtag(self, tag):
|
||||
pass
|
||||
|
||||
# Overridable -- handle character reference
|
||||
def handle_charref(self, name):
|
||||
pass
|
||||
|
||||
# Overridable -- handle entity reference
|
||||
def handle_entityref(self, name):
|
||||
pass
|
||||
|
||||
# Overridable -- handle data
|
||||
def handle_data(self, data):
|
||||
pass
|
||||
|
||||
# Overridable -- handle comment
|
||||
def handle_comment(self, data):
|
||||
pass
|
||||
|
||||
# Overridable -- handle declaration
|
||||
def handle_decl(self, decl):
|
||||
pass
|
||||
|
||||
# Overridable -- handle processing instruction
|
||||
def handle_pi(self, data):
|
||||
pass
|
||||
|
||||
def unknown_decl(self, data):
|
||||
pass
|
||||
|
||||
# Internal -- helper to remove special character quoting
|
||||
entitydefs = None
|
||||
def unescape(self, s):
|
||||
if '&' not in s:
|
||||
return s
|
||||
def replaceEntities(s):
|
||||
s = s.groups()[0]
|
||||
try:
|
||||
if s[0] == "#":
|
||||
s = s[1:]
|
||||
if s[0] in ['x','X']:
|
||||
c = int(s[1:], 16)
|
||||
else:
|
||||
c = int(s)
|
||||
return unichr(c)
|
||||
except ValueError:
|
||||
return '&#'+s+';'
|
||||
else:
|
||||
# Cannot use name2codepoint directly, because HTMLParser supports apos,
|
||||
# which is not part of HTML 4
|
||||
import htmlentitydefs
|
||||
if HTMLParser.entitydefs is None:
|
||||
entitydefs = HTMLParser.entitydefs = {'apos':u"'"}
|
||||
for k, v in htmlentitydefs.name2codepoint.iteritems():
|
||||
entitydefs[k] = unichr(v)
|
||||
try:
|
||||
return self.entitydefs[s]
|
||||
except KeyError:
|
||||
return '&'+s+';'
|
||||
|
||||
return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));", replaceEntities, s)
|
186
c/meterpreter/source/extensions/python/Lib/MimeWriter.py
Normal file
186
c/meterpreter/source/extensions/python/Lib/MimeWriter.py
Normal file
@ -0,0 +1,186 @@
|
||||
"""Generic MIME writer.
|
||||
|
||||
This module defines the class MimeWriter. The MimeWriter class implements
|
||||
a basic formatter for creating MIME multi-part files. It doesn't seek around
|
||||
the output file nor does it use large amounts of buffer space. You must write
|
||||
the parts out in the order that they should occur in the final file.
|
||||
MimeWriter does buffer the headers you add, allowing you to rearrange their
|
||||
order.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
import mimetools
|
||||
|
||||
__all__ = ["MimeWriter"]
|
||||
|
||||
import warnings
|
||||
|
||||
warnings.warn("the MimeWriter module is deprecated; use the email package instead",
|
||||
DeprecationWarning, 2)
|
||||
|
||||
class MimeWriter:
|
||||
|
||||
"""Generic MIME writer.
|
||||
|
||||
Methods:
|
||||
|
||||
__init__()
|
||||
addheader()
|
||||
flushheaders()
|
||||
startbody()
|
||||
startmultipartbody()
|
||||
nextpart()
|
||||
lastpart()
|
||||
|
||||
A MIME writer is much more primitive than a MIME parser. It
|
||||
doesn't seek around on the output file, and it doesn't use large
|
||||
amounts of buffer space, so you have to write the parts in the
|
||||
order they should occur on the output file. It does buffer the
|
||||
headers you add, allowing you to rearrange their order.
|
||||
|
||||
General usage is:
|
||||
|
||||
f = <open the output file>
|
||||
w = MimeWriter(f)
|
||||
...call w.addheader(key, value) 0 or more times...
|
||||
|
||||
followed by either:
|
||||
|
||||
f = w.startbody(content_type)
|
||||
...call f.write(data) for body data...
|
||||
|
||||
or:
|
||||
|
||||
w.startmultipartbody(subtype)
|
||||
for each part:
|
||||
subwriter = w.nextpart()
|
||||
...use the subwriter's methods to create the subpart...
|
||||
w.lastpart()
|
||||
|
||||
The subwriter is another MimeWriter instance, and should be
|
||||
treated in the same way as the toplevel MimeWriter. This way,
|
||||
writing recursive body parts is easy.
|
||||
|
||||
Warning: don't forget to call lastpart()!
|
||||
|
||||
XXX There should be more state so calls made in the wrong order
|
||||
are detected.
|
||||
|
||||
Some special cases:
|
||||
|
||||
- startbody() just returns the file passed to the constructor;
|
||||
but don't use this knowledge, as it may be changed.
|
||||
|
||||
- startmultipartbody() actually returns a file as well;
|
||||
this can be used to write the initial 'if you can read this your
|
||||
mailer is not MIME-aware' message.
|
||||
|
||||
- If you call flushheaders(), the headers accumulated so far are
|
||||
written out (and forgotten); this is useful if you don't need a
|
||||
body part at all, e.g. for a subpart of type message/rfc822
|
||||
that's (mis)used to store some header-like information.
|
||||
|
||||
- Passing a keyword argument 'prefix=<flag>' to addheader(),
|
||||
start*body() affects where the header is inserted; 0 means
|
||||
append at the end, 1 means insert at the start; default is
|
||||
append for addheader(), but insert for start*body(), which use
|
||||
it to determine where the Content-Type header goes.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, fp):
|
||||
self._fp = fp
|
||||
self._headers = []
|
||||
|
||||
def addheader(self, key, value, prefix=0):
|
||||
"""Add a header line to the MIME message.
|
||||
|
||||
The key is the name of the header, where the value obviously provides
|
||||
the value of the header. The optional argument prefix determines
|
||||
where the header is inserted; 0 means append at the end, 1 means
|
||||
insert at the start. The default is to append.
|
||||
|
||||
"""
|
||||
lines = value.split("\n")
|
||||
while lines and not lines[-1]: del lines[-1]
|
||||
while lines and not lines[0]: del lines[0]
|
||||
for i in range(1, len(lines)):
|
||||
lines[i] = " " + lines[i].strip()
|
||||
value = "\n".join(lines) + "\n"
|
||||
line = key + ": " + value
|
||||
if prefix:
|
||||
self._headers.insert(0, line)
|
||||
else:
|
||||
self._headers.append(line)
|
||||
|
||||
def flushheaders(self):
|
||||
"""Writes out and forgets all headers accumulated so far.
|
||||
|
||||
This is useful if you don't need a body part at all; for example,
|
||||
for a subpart of type message/rfc822 that's (mis)used to store some
|
||||
header-like information.
|
||||
|
||||
"""
|
||||
self._fp.writelines(self._headers)
|
||||
self._headers = []
|
||||
|
||||
def startbody(self, ctype, plist=[], prefix=1):
|
||||
"""Returns a file-like object for writing the body of the message.
|
||||
|
||||
The content-type is set to the provided ctype, and the optional
|
||||
parameter, plist, provides additional parameters for the
|
||||
content-type declaration. The optional argument prefix determines
|
||||
where the header is inserted; 0 means append at the end, 1 means
|
||||
insert at the start. The default is to insert at the start.
|
||||
|
||||
"""
|
||||
for name, value in plist:
|
||||
ctype = ctype + ';\n %s=\"%s\"' % (name, value)
|
||||
self.addheader("Content-Type", ctype, prefix=prefix)
|
||||
self.flushheaders()
|
||||
self._fp.write("\n")
|
||||
return self._fp
|
||||
|
||||
def startmultipartbody(self, subtype, boundary=None, plist=[], prefix=1):
|
||||
"""Returns a file-like object for writing the body of the message.
|
||||
|
||||
Additionally, this method initializes the multi-part code, where the
|
||||
subtype parameter provides the multipart subtype, the boundary
|
||||
parameter may provide a user-defined boundary specification, and the
|
||||
plist parameter provides optional parameters for the subtype. The
|
||||
optional argument, prefix, determines where the header is inserted;
|
||||
0 means append at the end, 1 means insert at the start. The default
|
||||
is to insert at the start. Subparts should be created using the
|
||||
nextpart() method.
|
||||
|
||||
"""
|
||||
self._boundary = boundary or mimetools.choose_boundary()
|
||||
return self.startbody("multipart/" + subtype,
|
||||
[("boundary", self._boundary)] + plist,
|
||||
prefix=prefix)
|
||||
|
||||
def nextpart(self):
|
||||
"""Returns a new instance of MimeWriter which represents an
|
||||
individual part in a multipart message.
|
||||
|
||||
This may be used to write the part as well as used for creating
|
||||
recursively complex multipart messages. The message must first be
|
||||
initialized with the startmultipartbody() method before using the
|
||||
nextpart() method.
|
||||
|
||||
"""
|
||||
self._fp.write("\n--" + self._boundary + "\n")
|
||||
return self.__class__(self._fp)
|
||||
|
||||
def lastpart(self):
|
||||
"""This is used to designate the last part of a multipart message.
|
||||
|
||||
It should always be used when writing multipart messages.
|
||||
|
||||
"""
|
||||
self._fp.write("\n--" + self._boundary + "--\n")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import test.test_MimeWriter
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user