1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
from core.vectors import PhpCode
from core.module import Module
from core import messages
import random
class Extensions(Module):
"""Collect PHP and webserver extension list."""
def init(self):
self.register_info(
{
'author': [
'Emilio Pinna'
],
'license': 'GPLv3'
}
)
self.register_vectors(
[
PhpCode("""
$f='get_loaded_extensions';
if(function_exists($f)&&is_callable($f))
foreach($f() as $o) print($o.PHP_EOL);
""", 'php_extensions'),
PhpCode("""
$f='apache_get_modules';
if(function_exists($f)&&is_callable($f))
foreach($f() as $o) print($o.PHP_EOL);
""", 'apache_modules'),
]
)
self.register_arguments([
{ 'name' : '-info',
'help' : 'Select modules or extensions',
'choices' : self.vectors.get_names(),
'nargs' : '+' }
])
def run(self, **kwargs):
result = self.vectors.get_results(
names = self.args.get('info', [])
)
# Returns a string when a single information is requested,
# else returns a dictionary containing all the results.
info = self.args.get('info')
if info and len(info) == 1:
return result[info[0]]
else:
return result
|