Пример #1
0
def run():
    with open("projects") as f:
        data = f.read()

    data = yaml.load(data)

    for project_data in data:
        commands.install(project_data)
Пример #2
0
def main():
    args = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument('command', type=command_type, help=', '.join(COMMANDS))
    parser.add_argument('options', nargs='*')
    parsed = parser.parse_args(args)
    command = parsed.command
    options = parsed.options

    if command == 'install':
        opts = ArgumentParser(usage='%(prog)s install extension')
        opts.add_argument('extension')
        sub_args = opts.parse_args(options)
        return install(sub_args.extension)
    elif command == 'uninstall':
        opts = ArgumentParser(usage='%(prog)s uninstall extension')
        opts.add_argument('extension')
        sub_args = opts.parse_args(options)
        return uninstall(sub_args.extension)
    elif command == 'enable':
        opts = ArgumentParser(usage='%(prog)s enable extension')
        opts.add_argument('extension')
        sub_args = opts.parse_args(options)
        return enable(sub_args.extension)
    elif command == 'disable':
        opts = ArgumentParser(usage='%(prog)s disable extension')
        opts.add_argument('extension')
        sub_args = opts.parse_args(options)
        return disable(sub_args.extension)
    elif command == 'status':
        return status()
    elif command == 'ls':
        return ls()
    elif command == 'help':
        opts = ArgumentParser(usage='%(prog)s help command')
        opts.add_argument('command', type=command_type)
        sub_args = opts.parse_args(options)
        cmd = sub_args.command
        print('{} - {}'.format(cmd, COMMAND_DESCRIPTIONS[cmd]))
        return 0
    else:
        raise Exception('Somebody forgot to update some code')
Пример #3
0
def main(argv):
    devices = adb.get_attached_devices()

    print """
    !!! Test AntiVirus !!!
    !!! Attenzione:    !!!
    !!! Prima dell'installazione dell'agente, al dispositivo va impedito il libero accesso ad internet. !!!
    """
    print """ prerequisiti:
    1) Telefono connesso in USB,
    2) USB Debugging enabled (settings/developer options/usb debugging)
    3) NESSUNA SIM INSTALLATA <======== NB!!!!!!!!!!!!!!!!!!!!!!!
    4) screen time 2m (settings/display/sleep)
    """

    print "devices connessi:"
    for device in devices:
        print device

    if not devices:
        print "non ci sono device connessi"
    else:

        if len(devices) > 1:
            dev = raw_input("su quale device si vuole eseguire il test? ")
            print "Eseguo il test su %s" % dev

        if len(sys.argv) >= 2:
            serialno = sys.argv[1]

        else:
            serialno = '.*'

        device = AdbClient(serialno=serialno)
        # print 'Args=', (str(sys.argv))
        # operation = sys.argv[1]

        init = raw_input('Init everything? (y/n)')
        if init == "y":
            print "Init!"
            commands.init_device(device.serialno)

        dev = device.serialno

        operation = -1

        while operation != "99":
            print ''
            print '#################       OPERATIONS      #################'
            print 'What operation do you want to perform?'
            print '1  - get new configuration from installed av'
            print '2  - use net RSSM'
            print '3  - use net TPLINK'
            print '4  - disable net'
            print '5  - get wifi network name'
            print '6  - ping google'
            print '7  - test all avs'
            print '8  - test a single av'
            print '9 - is infected?'
            print '10 - got r00t?'
            print '11 - pull file'
            print '12 - push file'
            print ''
            print '#################     INTERNAL TESTS    #################'
            print '20 - test get_server'
            print '21 - test set_server'
            print '22 - test get_client'
            print '23 - test set_client'
            print '24 - test install'
            print '25 - test install_agent'
            print '26 - test uninstall'
            print '27 - test uninstall_agent'
            print '28 - test execute'
            print '29 - test execute_agent'
            print ''
            print '#################          EXIT         #################'
            print '99 - Clean & exit!'

            operation = raw_input()

            if operation == '1':
                print 'Which av you want to retrieve?'
                print str(apk_dataLoader.get_av_list())
                av = raw_input()
                commands.update(av, dev)

            elif operation == '2':
                commands.wifi('open', dev)

            elif operation == '3':
                commands.wifi('av', dev)

            elif operation == '4':
                commands.wifi('disable', dev)

            elif operation == '5':
                print commands.info_wifi_network(dev)

            elif operation == '6':
                if commands.can_ping_google(dev):
                    print "I can ping google"
                else:
                    print "I canNOT ping google"

            elif operation == '7':
                # TODO: andrebbe spostato il do_test
                for av in apk_dataLoader.get_av_list():
                    do_test(device, av)

            elif operation == '8':
                # TODO: andrebbe spostato il do_test
                print 'Which av you want to test?'
                print str(apk_dataLoader.get_av_list())
                av = raw_input()
                do_test(device, av)

            elif operation == '9':
                if commands.check_infection(dev):
                    print "Infected"
                else:
                    print "Clean"

            elif operation == '10':
                if commands.check_su_permissions(dev):
                    print "Root!"
                else:
                    print "Not root :("
            elif operation == '11':
                print '12 - pull file'
                commands.pull(['file.png'], '/sdcard/', 'tmp', dev)
                if os.path.exists('tmp/file.png'):
                    print 'Pull OK!'
                    #debug: time.sleep(20)
                    os.remove('tmp/file.png')
                else:
                    print 'Pull failed!'

            elif operation == '12':
                print '13 - push file'
                commands.push(['file.png'], 'assets', '/sdcard/', dev)

            elif operation == '20':
                print "testvarsrv= " + commands.get_server('testvarsrv')
            elif operation == '21':
                commands.set_server({'testvarsrv': 'testvaluesrv'})
            elif operation == '22':
                print "testvarcli= " + commands.get_client('testvarcli')
            elif operation == '23':
                commands.set_client({'testvarcli': 'testvaluecli'})
            elif operation == '24':
                commands.install('wifi_enabler', dev)
            elif operation == '25':
                commands.install_agent(dev)
            elif operation == '26':
                commands.uninstall('wifi_enabler', dev)
            elif operation == '27':
                commands.uninstall_agent(dev)
            elif operation == '28':
                commands.execute('wifi_enabler', dev)
            elif operation == '29':
                commands.execute_agent(dev)

        print "Operazioni terminate, cleaning time"
        commands.reset_device(dev)
        print "The end"
Пример #4
0
init_parser = subparsers.add_parser(
    'init', help='Initialize and empty pistol project.')
init_parser.set_defaults(func=commands.init())


def project_name():
    import os
    current_dir = os.path.dirname(__file__)
    project_name = current_dir.split('/')[-1:][0]
    return project_name


init_parser.add_argument('--name', default=project_name())
init_parser.add_argument('--version')
init_parser.add_argument('--author')
init_parser.add_argument('--description')
init_parser.add_argument('--keyword')
init_parser.add_argument('--bin')

install_parser = subparsers.add_parser(
    'install',
    help='Install packages as specified within the package.yaml file.')
install_parser.set_defaults(func=commands.install())

uninstall_parser = subparsers.add_parser('uninstall', help='')
uninstall_parser.set_defaults(func=commands.uninstall())

args = parser.parse_args()
args.func(args)
Пример #5
0
def main(argv):
    devices = adb.get_attached_devices()

    print """
    !!! Test AntiVirus !!!
    !!! Attenzione:    !!!
    !!! Prima dell'installazione dell'agente, al dispositivo va impedito il libero accesso ad internet. !!!
    """
    print """ prerequisiti:
    1) Telefono connesso in USB,
    2) USB Debugging enabled (settings/developer options/usb debugging)
    3) NESSUNA SIM INSTALLATA <======== NB!!!!!!!!!!!!!!!!!!!!!!!
    4) screen time 2m (settings/display/sleep)
    """

    print "devices connessi:"
    for device in devices:
        print device

    if not devices:
        print "non ci sono device connessi"
    else:

        if len(devices) > 1:
            dev = raw_input("su quale device si vuole eseguire il test? ")
            print "Eseguo il test su %s" % dev

        if len(sys.argv) >= 2:
            serialno = sys.argv[1]

        else:
            serialno = '.*'

        device = AdbClient(serialno=serialno)
        # print 'Args=', (str(sys.argv))
        # operation = sys.argv[1]

        init = raw_input('Init everything? (y/n)')
        if init == "y":
            print "Init!"
            commands.init_device(device.serialno)

        dev = device.serialno

        operation = -1

        while operation != "99":
            print ''
            print '#################       OPERATIONS      #################'
            print 'What operation do you want to perform?'
            print '1  - get new configuration from installed av'
            print '2  - use net RSSM'
            print '3  - use net TPLINK'
            print '4  - disable net'
            print '5  - get wifi network name'
            print '6  - ping google'
            print '7  - test all avs'
            print '8  - test a single av'
            print '9 - is infected?'
            print '10 - got r00t?'
            print '11 - pull file'
            print '12 - push file'
            print ''
            print '#################     INTERNAL TESTS    #################'
            print '20 - test get_server'
            print '21 - test set_server'
            print '22 - test get_client'
            print '23 - test set_client'
            print '24 - test install'
            print '25 - test install_agent'
            print '26 - test uninstall'
            print '27 - test uninstall_agent'
            print '28 - test execute'
            print '29 - test execute_agent'
            print ''
            print '#################          EXIT         #################'
            print '99 - Clean & exit!'

            operation = raw_input()

            if operation == '1':
                print 'Which av you want to retrieve?'
                print str(apk_dataLoader.get_av_list())
                av = raw_input()
                commands.update(av, dev)

            elif operation == '2':
                commands.wifi('open', dev)

            elif operation == '3':
                commands.wifi('av', dev)

            elif operation == '4':
                commands.wifi('disable', dev)

            elif operation == '5':
                print commands.info_wifi_network(dev)

            elif operation == '6':
                if commands.can_ping_google(dev):
                    print "I can ping google"
                else:
                    print "I canNOT ping google"

            elif operation == '7':
                # TODO: andrebbe spostato il do_test
                for av in apk_dataLoader.get_av_list():
                    do_test(device, av)

            elif operation == '8':
                # TODO: andrebbe spostato il do_test
                print 'Which av you want to test?'
                print str(apk_dataLoader.get_av_list())
                av = raw_input()
                do_test(device, av)

            elif operation == '9':
                if commands.check_infection(dev):
                    print "Infected"
                else:
                    print "Clean"

            elif operation == '10':
                if commands.check_su_permissions(dev):
                    print "Root!"
                else:
                    print "Not root :("
            elif operation == '11':
                print '12 - pull file'
                commands.pull(['file.png'], '/sdcard/', 'tmp', dev)
                if os.path.exists('tmp/file.png'):
                    print 'Pull OK!'
                    #debug: time.sleep(20)
                    os.remove('tmp/file.png')
                else:
                    print 'Pull failed!'

            elif operation == '12':
                print '13 - push file'
                commands.push(['file.png'], 'assets', '/sdcard/', dev)

            elif operation == '20':
                print "testvarsrv= " + commands.get_server('testvarsrv')
            elif operation == '21':
                commands.set_server({'testvarsrv': 'testvaluesrv'})
            elif operation == '22':
                print "testvarcli= " + commands.get_client('testvarcli')
            elif operation == '23':
                commands.set_client({'testvarcli': 'testvaluecli'})
            elif operation == '24':
                commands.install('wifi_enabler', dev)
            elif operation == '25':
                commands.install_agent(dev)
            elif operation == '26':
                commands.uninstall('wifi_enabler', dev)
            elif operation == '27':
                commands.uninstall_agent(dev)
            elif operation == '28':
                commands.execute('wifi_enabler', dev)
            elif operation == '29':
                commands.execute_agent(dev)

        print "Operazioni terminate, cleaning time"
        commands.reset_device(dev)
        print "The end"