Пример #1
0
def main():
    afl.init()

    try:
        decode_rfc6979_signature(sys.stdin.read())
    except ValueError:
        pass
Пример #2
0
def main() -> None:
    afl.init()
    with open(sys.argv[1]) as f:
        # afl-fuzz will often generate invalid Unicode and count that as a
        # crash. See
        # https://barro.github.io/2018/01/taking-a-look-at-python-afl/
        try:
            file_info = FileInfo(file_path="<stdin>", source_code=f.read())
        except UnicodeDecodeError:
            pass
        else:
            check_for_buggy_parse(file_info)
    os._exit(0)
Пример #3
0
def main():
    global swarm, showActions, noCheck, alwaysSave, noSave, sut

    if "--help" in sys.argv:
        print(
            "Usage:  tstl_afl [--noCheck] [--swarm] [--verbose] [--showActions] [--noSave] [--alwaysSave]"
        )
        print("Options:")
        print(" --noCheck:      do not run property checks")
        print(
            " --swarm         use first four bytes to determine a swarm configuration"
        )
        print(" --verbose:      make actions verbose")
        print(" --showActions:  show actions in test")
        print(
            " --noSave:       don't save failing tests as standard TSTL tests")
        print(" --alwaysSave:   save even non-failing tests")
        sys.exit(0)

    sut = SUT.sut()

    try:
        sut.stopCoverage()
    except BaseException:
        pass

    sut.restart()

    swarm = "--swarm" in sys.argv
    showActions = "--showActions" in sys.argv
    if "--verbose" in sys.argv:
        sut.verbose(True)
    noSave = "--noSave" in sys.argv
    alwaysSave = "--alwaysSave" in sys.argv
    noCheck = "--noCheck" in sys.argv
    persist = "--persist" in sys.argv

    if not persist:
        afl.init()
        runTest()
    else:
        while afl.loop():
            runTest()
            sut.restart()

    os._exit(0)
Пример #4
0
def main():
    global args, device, script, session, pid, sock, code, app_name
    opt = argparse.ArgumentParser(
        description=DESCR, formatter_class=argparse.RawTextHelpFormatter)
    opt.add_argument('-l',
                     action='store',
                     default='proxy/proxy.js',
                     help='Script filename')
    opt.add_argument('-U',
                     action='store_true',
                     default=False,
                     help='Connect to USB')
    opt.add_argument('-s',
                     action='store_true',
                     default=False,
                     help='Spawn instead of attach')
    opt.add_argument(
        '-t',
        action='store',
        help='file to store target program/pid (and arguments if spwaning)')
    opt.add_argument('input',
                     nargs=argparse.REMAINDER,
                     help='Input corpus file')
    args = opt.parse_args()

    app_name = args.t
    try:
        app_name = int(app_name)
        pid = app_name
    except:
        pass

    with open(args.l) as f:
        code = f.read()

    afl.init(remote_trace=True)
    fuzz()

    sys.stdin.read()
Пример #5
0
    p[0] = Vdecl(p[1], p[2])


# empty production
def p_empty(p):
    'empty :'
    pass


# Error rule for syntax errors
def p_error(p):
    print("Syntax error in input!")


precedence = (
    ('left', 'OR', 'AND'),
    ('nonassoc', 'LTH', 'BTH', 'EQU'),  # Nonassociative operators
    ('left', 'PLUS', 'MINUS'),
    ('left', 'TIMES', 'DIVIDE'),
    ('right', 'NEG'),  # Unary minus operator
)

afl.init()
parser = yacc.yacc()

#data = sys.stdin.read()

result = parser.parse(sys.stdin.read())

print(result)
Пример #6
0
def test_double_init():
    afl.init()
    with assert_raises_regex(RuntimeError, '^AFL already initialized$'):
        afl.init()
Пример #7
0
def test_double_init():
    afl.init()
    with assert_raises_regex(RuntimeError, '^AFL already initialized$'):
        afl.init()
Пример #8
0
#!/usr/bin/env python
from __future__ import print_function
from PrussianBlue.ccproto import ChatCommand, ProtocolError, CLIENT_COMMANDS
import afl
import sys

afl.init()

try:
    msg = unicode(sys.stdin.read(), 'utf-8').rstrip('\r\n')
    cmd = ChatCommand.cc_decode(CLIENT_COMMANDS, msg)
    res = cmd.cc_encode()
    assert msg == res, "%r != %r" % (msg, res)
    print("%r roundtrips." % msg)
except UnicodeError:
    pass
except ProtocolError:
    print("%r raises a ProtocolError." % msg)
    
Пример #9
0
def main():

    if "--help" in sys.argv:
        print(
            "Usage:  tstl_afl [--noCheck] [--swarm] [--verbose] [--showActions] [--noSave] [--alwaysSave]"
        )
        print("Options:")
        print(" --noCheck:      do not run property checks")
        print(
            " --swarm         use first four bytes to determine a swarm configuration"
        )
        print(" --verbose:      make actions verbose")
        print(" --showActions:  show actions in test")
        print(
            " --noSave:       don't save failing tests as standard TSTL tests")
        print(" --alwaysSave:   save even non-failing tests")
        sys.exit(0)

    sut = SUT.sut()

    try:
        sut.stopCoverage()
    except:
        pass

    sut.restart()

    if "--swarm" in sys.argv:
        swarm = True
        R = random.Random()
    else:
        swarm = False
    showActions = "--showActions" in sys.argv
    if "--verbose" in sys.argv:
        sut.verbose(True)
    noSave = "--noSave" in sys.argv
    alwaysSave = "--alwaysSave" in sys.argv
    noCheck = "--noCheck" in sys.argv

    afl.init()

    bytesin = sys.stdin.read()

    if len(bytesin) < 4:
        os._exit(0)

    if swarm:
        R.seed(struct.unpack("<L", bytesin[0:4])[0])
        sut.standardSwarm(R)
        bytesin = bytesin[4:]

    alen = len(sut.actions())

    test = sut.bytesToTest(bytesin)

    for a in test:
        if a[1]():
            if showActions:
                print(sut.prettyName(a[0]))
            ok = sut.safely(a)
            if (not noSave) and not ok:
                i = 0
                saveFile = "aflfail." + str(
                    os.getpid()) + "." + str(i) + ".test"
                while os.path.exists(saveFile):
                    i += 1
                    saveFile = "aflfail." + str(
                        os.getpid()) + "." + str(i) + ".test"
                sut.saveTest(sut.test(), saveFile)
            assert (ok)
            if not noCheck:
                checkResult = sut.check()
                if (not noSave) and not checkResult:
                    i = 0
                    saveFile = "aflfail." + str(
                        os.getpid()) + "." + str(i) + ".test"
                    while os.path.exists(saveFile):
                        i += 1
                        saveFile = "aflfail." + str(
                            os.getpid()) + "." + str(i) + ".test"
                    sut.saveTest(sut.test(), saveFile)
                assert (checkResult)
    if alwaysSave:
        i = 0
        saveFile = "afltest." + str(os.getpid()) + "." + str(i) + ".test"
        while os.path.exists(saveFile):
            i += 1
            saveFile = "afltest." + str(os.getpid()) + "." + str(i) + ".test"
        sut.saveTest(sut.test(), saveFile)
    os._exit(0)