예제 #1
0
def import_from_script_in_same_dir():
    from foobar import foo, bar
    foo()
    bar()
    # Alternative import way
    import foobar
    foobar.foo()
    foobar.bar()
예제 #2
0
def test_foo():
    assert foobar.foo() == 'foo'
예제 #3
0
print("File Name: {}\nModule Name: {}".format( __file__, __name__))   # print __file__ and __name__

print("\nSymbol Table 1 {}\n{}:".format(__file__, dir())) # names in current scope 

import foobar

print("\nSymbol Table 2 {}\n{}:".format(__file__, dir())) # names in current scope after import of foobar

print("\nSymbol Table 3 {}\n{}:".format(__file__, dir(foobar))) # names in foobar

print()

foobar.foo()    # call functions in foobar.py as foobar.foo()

foobar.bar()
예제 #4
0
def test_foo():
    assert foo() == "foo"
예제 #5
0
print("File Name: {} Module Name: {}".format(__file__, __name__))

print("\nSymbol Table 1 {} {}:".format(__file__,
                                       dir()))  # names in current scope
import foobar

print("\nSymbol Table 2 {} {}:".format(__file__,
                                       dir()))  # names in current scope

print("\nSymbol Table 3 {} {}:".format(__file__,
                                       dir(foobar)))  # names in foobar

foobar.foo()
foobar.bar()
예제 #6
0
def test_foo():
    with my_app.test_client() as c:
        rv = c.get('/foo')
        assert rv.status_code == 200 and rv.data.decode() == foobar.foo()
예제 #7
0
파일: solver.py 프로젝트: ryan-cd/ctf

for i in range(1, 600):
    log.info(io.recvline())
    challenge = io.recvlineS()
    log.info(challenge)
    if 'foo' in challenge:
        match = re.search('foo\((\?|\d+), (\?|\d+)\) = (\?|\d+)', challenge)
        args = [None if a == '?' else int(a) for a in match.groups()]

        # Iterations 50 and up contain flag information
        if i >= 50:
            if match.groups().index('?') == 1:
                set_flag_char(i, args[0], args[1], args[2])  # x is random_int
            elif match.groups().index('?') == 0:
                set_flag_char(i, args[0], args[1], args[2])  # y is random_int
            else:
                # skip this case for now, don't want to do the extra math
                pass
        io.sendline(str(foo(*args)))
    elif 'bar' in challenge:
        match = re.search('bar\((\?|\d+), (\?|\d+), (\?|\d+)\) = (\?|\d+)',
                          challenge)
        args = [None if a == '?' else int(a) for a in match.groups()]
        io.sendline(str(bar(*args)))
    log.info(io.recvline())

io.close()

display_flag_candidate()
예제 #8
0
 def test_foo1(self):
     self.assertEqual(foo(1, 2), 3)
     self.assertEqual(foo(1, 3), 4)